import { _ as _sfc_main$3, a as _sfc_main$1$1, b as _sfc_main$2, c as _sfc_main$2$1 } from './Card-m9yESRg-.mjs';
import { v as vueExports, d as useRoute$1, u as useHead, s as serverRenderer_cjs_prodExports, e as _sfc_main$8, b as useFetch, c as useIntervalFn } from './server.mjs';
import { _ as _sfc_main$4 } from './Badge-BnQthhyg.mjs';
import { _ as _sfc_main$1 } from './Alert-BgLL0z9r.mjs';
import '../../index.mjs';
import '@anthropic-ai/claude-agent-sdk';
import '@octokit/webhooks';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:path';
import 'node:crypto';
import 'node:process';
import 'consola';
import '@octokit/graphql';
import 'zod';
import '@octokit/auth-app';
import 'node:os';
import '@libsql/client';
import 'liquidjs';
import 'js-yaml';
import 'node:child_process';
import '@chat-adapter/github';
import '@chat-adapter/slack';
import 'chat';
import 'chat-adapter-asana';
import 'better-auth';
import 'better-auth/plugins';
import 'bun:sqlite';
import 'better-auth/db/migration';
import 'node:url';
import '@iconify/utils';
import 'rou3';
import 'better-auth/client/plugins';
import 'better-auth/vue';
import 'perfect-debounce';
import 'tailwindcss/colors';
import 'node:stream';
import '../routes/renderer.mjs';
import 'vue-bundle-renderer/runtime';
import 'vue/server-renderer';
import 'unhead/server';
import 'devalue';
import 'unhead/utils';
import 'vue';

function useSessionMessages(sessionId, intervalMs = 5e3) {
  const id = vueExports.computed(() => typeof sessionId === "function" ? sessionId() : sessionId.value);
  const { data: messages, error: fetchError, status, refresh } = useFetch(
    () => `/api/v1/sessions/${encodeURIComponent(id.value)}/messages`,
    { watch: [id], default: () => [] },
    "$I_yy7my_H9"
    /* nuxt-injected */
  );
  const error = vueExports.computed(() => fetchError.value?.message ?? null);
  const loading = vueExports.computed(() => status.value === "pending" && messages.value.length === 0);
  const { pause } = useIntervalFn(refresh, intervalMs);
  vueExports.onScopeDispose(pause);
  return { messages, error, loading, refresh };
}
const _sfc_main = /* @__PURE__ */ vueExports.defineComponent({
  __name: "[id]",
  __ssrInlineRender: true,
  setup(__props) {
    const route = useRoute$1();
    const sessionId = vueExports.computed(() => route.params.id);
    useHead({ title: () => `Session ${sessionId.value.slice(0, 8)} — Agent Please` });
    const { messages, loading, error } = useSessionMessages(sessionId);
    function blockText(block) {
      if (block.kind === "text")
        return block.text ?? "";
      return block.input ?? "";
    }
    return (_ctx, _push, _parent, _attrs) => {
      const _component_UDashboardPanel = _sfc_main$3;
      const _component_UDashboardNavbar = _sfc_main$2$1;
      const _component_UButton = _sfc_main$8;
      const _component_UBadge = _sfc_main$4;
      const _component_UAlert = _sfc_main$1;
      const _component_USkeleton = _sfc_main$1$1;
      const _component_UCard = _sfc_main$2;
      _push(serverRenderer_cjs_prodExports.ssrRenderComponent(_component_UDashboardPanel, _attrs, {
        header: vueExports.withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(serverRenderer_cjs_prodExports.ssrRenderComponent(_component_UDashboardNavbar, null, {
              left: vueExports.withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(`<div class="flex items-center gap-3"${_scopeId2}>`);
                  _push3(serverRenderer_cjs_prodExports.ssrRenderComponent(_component_UButton, {
                    icon: "i-lucide-arrow-left",
                    variant: "ghost",
                    size: "sm",
                    to: "/"
                  }, null, _parent3, _scopeId2));
                  _push3(`<span class="text-lg font-bold"${_scopeId2}>Session</span>`);
                  _push3(serverRenderer_cjs_prodExports.ssrRenderComponent(_component_UBadge, {
                    variant: "outline",
                    class: "font-mono text-xs"
                  }, {
                    default: vueExports.withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(`${serverRenderer_cjs_prodExports.ssrInterpolate(vueExports.unref(sessionId).slice(0, 8))}… `);
                      } else {
                        return [
                          vueExports.createTextVNode(vueExports.toDisplayString(vueExports.unref(sessionId).slice(0, 8)) + "… ", 1)
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                  _push3(`</div>`);
                } else {
                  return [
                    vueExports.createVNode("div", { class: "flex items-center gap-3" }, [
                      vueExports.createVNode(_component_UButton, {
                        icon: "i-lucide-arrow-left",
                        variant: "ghost",
                        size: "sm",
                        to: "/"
                      }),
                      vueExports.createVNode("span", { class: "text-lg font-bold" }, "Session"),
                      vueExports.createVNode(_component_UBadge, {
                        variant: "outline",
                        class: "font-mono text-xs"
                      }, {
                        default: vueExports.withCtx(() => [
                          vueExports.createTextVNode(vueExports.toDisplayString(vueExports.unref(sessionId).slice(0, 8)) + "… ", 1)
                        ]),
                        _: 1
                      })
                    ])
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
          } else {
            return [
              vueExports.createVNode(_component_UDashboardNavbar, null, {
                left: vueExports.withCtx(() => [
                  vueExports.createVNode("div", { class: "flex items-center gap-3" }, [
                    vueExports.createVNode(_component_UButton, {
                      icon: "i-lucide-arrow-left",
                      variant: "ghost",
                      size: "sm",
                      to: "/"
                    }),
                    vueExports.createVNode("span", { class: "text-lg font-bold" }, "Session"),
                    vueExports.createVNode(_component_UBadge, {
                      variant: "outline",
                      class: "font-mono text-xs"
                    }, {
                      default: vueExports.withCtx(() => [
                        vueExports.createTextVNode(vueExports.toDisplayString(vueExports.unref(sessionId).slice(0, 8)) + "… ", 1)
                      ]),
                      _: 1
                    })
                  ])
                ]),
                _: 1
              })
            ];
          }
        }),
        body: vueExports.withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(`<div class="space-y-4 p-6"${_scopeId}>`);
            if (vueExports.unref(error)) {
              _push2(serverRenderer_cjs_prodExports.ssrRenderComponent(_component_UAlert, {
                color: "error",
                variant: "subtle",
                title: vueExports.unref(error),
                icon: "i-lucide-alert-circle"
              }, null, _parent2, _scopeId));
            } else {
              _push2(`<!---->`);
            }
            if (vueExports.unref(loading)) {
              _push2(`<div class="space-y-4"${_scopeId}><!--[-->`);
              serverRenderer_cjs_prodExports.ssrRenderList(3, (i) => {
                _push2(serverRenderer_cjs_prodExports.ssrRenderComponent(_component_USkeleton, {
                  key: i,
                  class: "h-20 w-full rounded-xl"
                }, null, _parent2, _scopeId));
              });
              _push2(`<!--]--></div>`);
            } else if (vueExports.unref(messages).length === 0) {
              _push2(serverRenderer_cjs_prodExports.ssrRenderComponent(_component_UCard, null, {
                default: vueExports.withCtx((_2, _push3, _parent3, _scopeId2) => {
                  if (_push3) {
                    _push3(`<div class="py-8 text-center text-muted"${_scopeId2}> No messages found. </div>`);
                  } else {
                    return [
                      vueExports.createVNode("div", { class: "py-8 text-center text-muted" }, " No messages found. ")
                    ];
                  }
                }),
                _: 1
              }, _parent2, _scopeId));
            } else {
              _push2(`<!--[-->`);
              serverRenderer_cjs_prodExports.ssrRenderList(vueExports.unref(messages), (msg) => {
                _push2(serverRenderer_cjs_prodExports.ssrRenderComponent(_component_UCard, {
                  key: msg.uuid,
                  ui: { root: msg.type === "assistant" ? "border-primary/30" : "" }
                }, {
                  header: vueExports.withCtx((_2, _push3, _parent3, _scopeId2) => {
                    if (_push3) {
                      _push3(serverRenderer_cjs_prodExports.ssrRenderComponent(_component_UBadge, {
                        color: msg.type === "assistant" ? "primary" : "neutral",
                        variant: "subtle",
                        class: "text-xs"
                      }, {
                        default: vueExports.withCtx((_3, _push4, _parent4, _scopeId3) => {
                          if (_push4) {
                            _push4(`${serverRenderer_cjs_prodExports.ssrInterpolate(msg.type)}`);
                          } else {
                            return [
                              vueExports.createTextVNode(vueExports.toDisplayString(msg.type), 1)
                            ];
                          }
                        }),
                        _: 2
                      }, _parent3, _scopeId2));
                    } else {
                      return [
                        vueExports.createVNode(_component_UBadge, {
                          color: msg.type === "assistant" ? "primary" : "neutral",
                          variant: "subtle",
                          class: "text-xs"
                        }, {
                          default: vueExports.withCtx(() => [
                            vueExports.createTextVNode(vueExports.toDisplayString(msg.type), 1)
                          ]),
                          _: 2
                        }, 1032, ["color"])
                      ];
                    }
                  }),
                  default: vueExports.withCtx((_2, _push3, _parent3, _scopeId2) => {
                    if (_push3) {
                      _push3(`<div class="space-y-2"${_scopeId2}><!--[-->`);
                      serverRenderer_cjs_prodExports.ssrRenderList(msg.content, (block, i) => {
                        _push3(`<!--[-->`);
                        if (block.kind === "text") {
                          _push3(`<pre class="whitespace-pre-wrap text-sm leading-relaxed"${_scopeId2}>${serverRenderer_cjs_prodExports.ssrInterpolate(blockText(block))}</pre>`);
                        } else {
                          _push3(`<details class="rounded-md border bg-muted/50 text-sm"${_scopeId2}><summary class="cursor-pointer px-3 py-2 font-mono text-xs text-primary hover:bg-muted"${_scopeId2}>${serverRenderer_cjs_prodExports.ssrInterpolate(block.tool_name)}</summary><pre class="px-3 py-2 text-xs text-muted whitespace-pre-wrap overflow-x-auto"${_scopeId2}>${serverRenderer_cjs_prodExports.ssrInterpolate(blockText(block))}</pre></details>`);
                        }
                        _push3(`<!--]-->`);
                      });
                      _push3(`<!--]--></div>`);
                    } else {
                      return [
                        vueExports.createVNode("div", { class: "space-y-2" }, [
                          (vueExports.openBlock(true), vueExports.createBlock(vueExports.Fragment, null, vueExports.renderList(msg.content, (block, i) => {
                            return vueExports.openBlock(), vueExports.createBlock(vueExports.Fragment, { key: i }, [
                              block.kind === "text" ? (vueExports.openBlock(), vueExports.createBlock("pre", {
                                key: 0,
                                class: "whitespace-pre-wrap text-sm leading-relaxed"
                              }, vueExports.toDisplayString(blockText(block)), 1)) : (vueExports.openBlock(), vueExports.createBlock("details", {
                                key: 1,
                                class: "rounded-md border bg-muted/50 text-sm"
                              }, [
                                vueExports.createVNode("summary", { class: "cursor-pointer px-3 py-2 font-mono text-xs text-primary hover:bg-muted" }, vueExports.toDisplayString(block.tool_name), 1),
                                vueExports.createVNode("pre", { class: "px-3 py-2 text-xs text-muted whitespace-pre-wrap overflow-x-auto" }, vueExports.toDisplayString(blockText(block)), 1)
                              ]))
                            ], 64);
                          }), 128))
                        ])
                      ];
                    }
                  }),
                  _: 2
                }, _parent2, _scopeId));
              });
              _push2(`<!--]-->`);
            }
            _push2(`</div>`);
          } else {
            return [
              vueExports.createVNode("div", { class: "space-y-4 p-6" }, [
                vueExports.unref(error) ? (vueExports.openBlock(), vueExports.createBlock(_component_UAlert, {
                  key: 0,
                  color: "error",
                  variant: "subtle",
                  title: vueExports.unref(error),
                  icon: "i-lucide-alert-circle"
                }, null, 8, ["title"])) : vueExports.createCommentVNode("", true),
                vueExports.unref(loading) ? (vueExports.openBlock(), vueExports.createBlock("div", {
                  key: 1,
                  class: "space-y-4"
                }, [
                  (vueExports.openBlock(), vueExports.createBlock(vueExports.Fragment, null, vueExports.renderList(3, (i) => {
                    return vueExports.createVNode(_component_USkeleton, {
                      key: i,
                      class: "h-20 w-full rounded-xl"
                    });
                  }), 64))
                ])) : vueExports.unref(messages).length === 0 ? (vueExports.openBlock(), vueExports.createBlock(_component_UCard, { key: 2 }, {
                  default: vueExports.withCtx(() => [
                    vueExports.createVNode("div", { class: "py-8 text-center text-muted" }, " No messages found. ")
                  ]),
                  _: 1
                })) : (vueExports.openBlock(true), vueExports.createBlock(vueExports.Fragment, { key: 3 }, vueExports.renderList(vueExports.unref(messages), (msg) => {
                  return vueExports.openBlock(), vueExports.createBlock(_component_UCard, {
                    key: msg.uuid,
                    ui: { root: msg.type === "assistant" ? "border-primary/30" : "" }
                  }, {
                    header: vueExports.withCtx(() => [
                      vueExports.createVNode(_component_UBadge, {
                        color: msg.type === "assistant" ? "primary" : "neutral",
                        variant: "subtle",
                        class: "text-xs"
                      }, {
                        default: vueExports.withCtx(() => [
                          vueExports.createTextVNode(vueExports.toDisplayString(msg.type), 1)
                        ]),
                        _: 2
                      }, 1032, ["color"])
                    ]),
                    default: vueExports.withCtx(() => [
                      vueExports.createVNode("div", { class: "space-y-2" }, [
                        (vueExports.openBlock(true), vueExports.createBlock(vueExports.Fragment, null, vueExports.renderList(msg.content, (block, i) => {
                          return vueExports.openBlock(), vueExports.createBlock(vueExports.Fragment, { key: i }, [
                            block.kind === "text" ? (vueExports.openBlock(), vueExports.createBlock("pre", {
                              key: 0,
                              class: "whitespace-pre-wrap text-sm leading-relaxed"
                            }, vueExports.toDisplayString(blockText(block)), 1)) : (vueExports.openBlock(), vueExports.createBlock("details", {
                              key: 1,
                              class: "rounded-md border bg-muted/50 text-sm"
                            }, [
                              vueExports.createVNode("summary", { class: "cursor-pointer px-3 py-2 font-mono text-xs text-primary hover:bg-muted" }, vueExports.toDisplayString(block.tool_name), 1),
                              vueExports.createVNode("pre", { class: "px-3 py-2 text-xs text-muted whitespace-pre-wrap overflow-x-auto" }, vueExports.toDisplayString(blockText(block)), 1)
                            ]))
                          ], 64);
                        }), 128))
                      ])
                    ]),
                    _: 2
                  }, 1032, ["ui"]);
                }), 128))
              ])
            ];
          }
        }),
        _: 1
      }, _parent));
    };
  }
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = vueExports.useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/sessions/[id].vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};

export { _sfc_main as default };
//# sourceMappingURL=_id_-B-peNi7y.mjs.map
