elanous 0.2.11 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (342) hide show
  1. package/apps/pwa/out/404/index.html +1 -1
  2. package/apps/pwa/out/404.html +1 -1
  3. package/apps/pwa/out/_next/static/chunks/{1394-556de6d71bbdb0fb.js → 1394-931c9827067b2276.js} +1 -1
  4. package/apps/pwa/out/_next/static/chunks/3869-3cd46526879f454c.js +1 -0
  5. package/apps/pwa/out/_next/static/chunks/{3992-2e522a8ac5f2afde.js → 3992-fe5c06d6b31f8b25.js} +1 -1
  6. package/apps/pwa/out/_next/static/chunks/5250-c78ca295585bbf95.js +1 -0
  7. package/apps/pwa/out/_next/static/chunks/6511-ff8360be3d65aaa4.js +1 -0
  8. package/apps/pwa/out/_next/static/chunks/6588-ba380869b67c4fa7.js +1 -0
  9. package/apps/pwa/out/_next/static/chunks/7758-85c2b53f731da024.js +1 -0
  10. package/apps/pwa/out/_next/static/chunks/{8605-ea5bee9dfae512c7.js → 8605-9da4678f8a310d18.js} +1 -1
  11. package/apps/pwa/out/_next/static/chunks/9906-e7b8b5310a169dfe.js +1 -0
  12. package/apps/pwa/out/_next/static/chunks/app/approvals/page-e5b4e1b256f41076.js +1 -0
  13. package/apps/pwa/out/_next/static/chunks/app/autopilot/{page-6a061bd97f0b9398.js → page-e49b9b76c565a0b1.js} +1 -1
  14. package/apps/pwa/out/_next/static/chunks/app/board/page-b4f032c893b21cc9.js +1 -0
  15. package/apps/pwa/out/_next/static/chunks/app/botlab/page-f14987d5850a31e0.js +1 -0
  16. package/apps/pwa/out/_next/static/chunks/app/bots/page-b433308aad13ceb6.js +1 -0
  17. package/apps/pwa/out/_next/static/chunks/app/chat/{page-7c97dcdfe2e37a60.js → page-4c1dbb21861beab2.js} +1 -1
  18. package/apps/pwa/out/_next/static/chunks/app/consult/page-c85b816e3b269dbb.js +1 -0
  19. package/apps/pwa/out/_next/static/chunks/app/control/{page-5721537ca8a3598c.js → page-f6bc66b919b2ea7d.js} +1 -1
  20. package/apps/pwa/out/_next/static/chunks/app/design-check/{page-b654240a572e4c48.js → page-60603c1e056c9b25.js} +1 -1
  21. package/apps/pwa/out/_next/static/chunks/app/editor/{page-b9750abc897508c3.js → page-a0ea8f5a2341ee6b.js} +1 -1
  22. package/apps/pwa/out/_next/static/chunks/app/exec/page-45c5bf04b4a605e6.js +1 -0
  23. package/apps/pwa/out/_next/static/chunks/app/field/page-36c6c4183353ac9e.js +1 -0
  24. package/apps/pwa/out/_next/static/chunks/app/inside/page-cb2eb0fd809980da.js +1 -0
  25. package/apps/pwa/out/_next/static/chunks/app/intake/{page-c8b1ccda6ba7ae98.js → page-31012264da8a341f.js} +1 -1
  26. package/apps/pwa/out/_next/static/chunks/app/{layout-d6b1d156fb95e74b.js → layout-50309aeb0bdd554a.js} +1 -1
  27. package/apps/pwa/out/_next/static/chunks/app/live/page-bc00e964e855f4df.js +1 -0
  28. package/apps/pwa/out/_next/static/chunks/app/market/{page-9688f5b4f1ff950f.js → page-0696ee3fac9fe56c.js} +1 -1
  29. package/apps/pwa/out/_next/static/chunks/app/missions/[id]/page-66c27608f651b866.js +1 -0
  30. package/apps/pwa/out/_next/static/chunks/app/morning/{page-35414e0a007b4082.js → page-6ddd2109b7fc3a80.js} +1 -1
  31. package/apps/pwa/out/_next/static/chunks/app/not-found-4e50b7298c1f69a5.js +1 -0
  32. package/apps/pwa/out/_next/static/chunks/app/observatory/{page-e001823c35c9dd67.js → page-7a2bf830038a2264.js} +1 -1
  33. package/apps/pwa/out/_next/static/chunks/app/ops/checklist/{page-371423d1a573d64b.js → page-1f327f18694fabca.js} +1 -1
  34. package/apps/pwa/out/_next/static/chunks/app/ops/release/{page-4b764b125339ac17.js → page-e5cef2fe6e4028df.js} +1 -1
  35. package/apps/pwa/out/_next/static/chunks/app/ops/seats/{page-cdf8e4b01067bcf1.js → page-cf596128d2b420ba.js} +1 -1
  36. package/apps/pwa/out/_next/static/chunks/app/outputs/{page-3a24072b35470157.js → page-f672536f14f0969f.js} +1 -1
  37. package/apps/pwa/out/_next/static/chunks/app/page-b52365662232db89.js +1 -0
  38. package/apps/pwa/out/_next/static/chunks/app/reflection/page-e7a6c80f288b1948.js +1 -0
  39. package/apps/pwa/out/_next/static/chunks/app/scheduler/{page-d37cb0d52f9b6bd5.js → page-29a709616df9b050.js} +1 -1
  40. package/apps/pwa/out/_next/static/chunks/app/sessions/{page-686da0df9bf23e5c.js → page-fee842d7c2151129.js} +1 -1
  41. package/apps/pwa/out/_next/static/chunks/app/settings/devices/{page-4dc614f3ce043e63.js → page-78b40a344ed22f24.js} +1 -1
  42. package/apps/pwa/out/_next/static/chunks/app/settings/page-75d199f448171014.js +1 -0
  43. package/apps/pwa/out/_next/static/chunks/app/setup/done/{page-d02c782fc792e2af.js → page-a011dd5b0bff29c5.js} +1 -1
  44. package/apps/pwa/out/_next/static/chunks/app/setup/{page-239c17b911b84e72.js → page-d92e32d51ab5157e.js} +1 -1
  45. package/apps/pwa/out/_next/static/chunks/app/share/{page-dc6a79fb003f746c.js → page-5f21aed6932ef375.js} +1 -1
  46. package/apps/pwa/out/_next/static/chunks/app/showroom/{page-0fffb84cafdc9da6.js → page-1e1a53946804debf.js} +1 -1
  47. package/apps/pwa/out/_next/static/chunks/app/tasks/{page-1218753c82d585f6.js → page-a1833cd43d832601.js} +1 -1
  48. package/apps/pwa/out/_next/static/chunks/app/term/{page-4b5935e67531efb5.js → page-63d14a4d8fe1e1c1.js} +1 -1
  49. package/apps/pwa/out/_next/static/chunks/app/today/{page-3285bc87caf1eaa5.js → page-2a511d320f762e06.js} +1 -1
  50. package/apps/pwa/out/_next/static/chunks/app/trace/{page-ad553b0e06505ecd.js → page-1c3e03f88dac1e21.js} +1 -1
  51. package/apps/pwa/out/_next/static/chunks/app/vault/{page-fca096e3e860306f.js → page-c4d5289c2ea97a89.js} +1 -1
  52. package/apps/pwa/out/_next/static/chunks/app/workflows/chat-ui/{page-9ebfa78f0d9885c3.js → page-b91f8952deaeaf27.js} +1 -1
  53. package/apps/pwa/out/_next/static/chunks/app/workflows/{page-3dc5f21f7e39622d.js → page-71b43a2588489987.js} +1 -1
  54. package/apps/pwa/out/_next/static/chunks/app/workspace/page-2b256feed331546f.js +1 -0
  55. package/apps/pwa/out/_next/static/chunks/app/worktrees/page-505bb96d69a8622c.js +1 -0
  56. package/apps/pwa/out/_next/static/css/128fb7fb670b2fbf.css +1 -0
  57. package/apps/pwa/out/approvals/index.html +1 -1
  58. package/apps/pwa/out/approvals/index.txt +14 -14
  59. package/apps/pwa/out/autopilot/index.html +1 -1
  60. package/apps/pwa/out/autopilot/index.txt +14 -14
  61. package/apps/pwa/out/board/index.html +1 -1
  62. package/apps/pwa/out/board/index.txt +14 -14
  63. package/apps/pwa/out/botlab/index.html +1 -1
  64. package/apps/pwa/out/botlab/index.txt +14 -14
  65. package/apps/pwa/out/bots/index.html +1 -1
  66. package/apps/pwa/out/bots/index.txt +14 -14
  67. package/apps/pwa/out/chat/index.html +1 -1
  68. package/apps/pwa/out/chat/index.txt +14 -14
  69. package/apps/pwa/out/consult/index.html +1 -1
  70. package/apps/pwa/out/consult/index.txt +14 -14
  71. package/apps/pwa/out/control/index.html +1 -1
  72. package/apps/pwa/out/control/index.txt +14 -14
  73. package/apps/pwa/out/design-check/index.html +1 -1
  74. package/apps/pwa/out/design-check/index.txt +14 -14
  75. package/apps/pwa/out/editor/index.html +1 -1
  76. package/apps/pwa/out/editor/index.txt +14 -14
  77. package/apps/pwa/out/exec/index.html +1 -1
  78. package/apps/pwa/out/exec/index.txt +14 -14
  79. package/apps/pwa/out/field/index.html +1 -1
  80. package/apps/pwa/out/field/index.txt +14 -14
  81. package/apps/pwa/out/healthz +1 -1
  82. package/apps/pwa/out/index.html +1 -1
  83. package/apps/pwa/out/index.txt +14 -14
  84. package/apps/pwa/out/inside/index.html +1 -1
  85. package/apps/pwa/out/inside/index.txt +14 -14
  86. package/apps/pwa/out/intake/index.html +1 -1
  87. package/apps/pwa/out/intake/index.txt +14 -14
  88. package/apps/pwa/out/live/index.html +1 -1
  89. package/apps/pwa/out/live/index.txt +14 -14
  90. package/apps/pwa/out/market/index.html +1 -1
  91. package/apps/pwa/out/market/index.txt +14 -14
  92. package/apps/pwa/out/missions/placeholder/index.html +1 -1
  93. package/apps/pwa/out/missions/placeholder/index.txt +14 -14
  94. package/apps/pwa/out/morning/index.html +1 -1
  95. package/apps/pwa/out/morning/index.txt +14 -14
  96. package/apps/pwa/out/observatory/index.html +1 -1
  97. package/apps/pwa/out/observatory/index.txt +14 -14
  98. package/apps/pwa/out/ops/checklist/index.html +1 -1
  99. package/apps/pwa/out/ops/checklist/index.txt +14 -14
  100. package/apps/pwa/out/ops/release/index.html +1 -1
  101. package/apps/pwa/out/ops/release/index.txt +14 -14
  102. package/apps/pwa/out/ops/seats/index.html +1 -1
  103. package/apps/pwa/out/ops/seats/index.txt +14 -14
  104. package/apps/pwa/out/outputs/index.html +1 -1
  105. package/apps/pwa/out/outputs/index.txt +14 -14
  106. package/apps/pwa/out/reflection/index.html +1 -1
  107. package/apps/pwa/out/reflection/index.txt +15 -15
  108. package/apps/pwa/out/scheduler/index.html +1 -1
  109. package/apps/pwa/out/scheduler/index.txt +14 -14
  110. package/apps/pwa/out/sessions/index.html +1 -1
  111. package/apps/pwa/out/sessions/index.txt +14 -14
  112. package/apps/pwa/out/settings/devices/index.html +1 -1
  113. package/apps/pwa/out/settings/devices/index.txt +14 -14
  114. package/apps/pwa/out/settings/index.html +1 -1
  115. package/apps/pwa/out/settings/index.txt +14 -14
  116. package/apps/pwa/out/setup/done/index.html +1 -1
  117. package/apps/pwa/out/setup/done/index.txt +14 -14
  118. package/apps/pwa/out/setup/index.html +1 -1
  119. package/apps/pwa/out/setup/index.txt +14 -14
  120. package/apps/pwa/out/share/index.html +1 -1
  121. package/apps/pwa/out/share/index.txt +14 -14
  122. package/apps/pwa/out/showroom/index.html +1 -1
  123. package/apps/pwa/out/showroom/index.txt +14 -14
  124. package/apps/pwa/out/tasks/index.html +1 -1
  125. package/apps/pwa/out/tasks/index.txt +14 -14
  126. package/apps/pwa/out/term/index.html +1 -1
  127. package/apps/pwa/out/term/index.txt +14 -14
  128. package/apps/pwa/out/today/index.html +1 -1
  129. package/apps/pwa/out/today/index.txt +14 -14
  130. package/apps/pwa/out/trace/index.html +1 -1
  131. package/apps/pwa/out/trace/index.txt +14 -14
  132. package/apps/pwa/out/vault/index.html +1 -1
  133. package/apps/pwa/out/vault/index.txt +14 -14
  134. package/apps/pwa/out/workflows/chat-ui/index.html +1 -1
  135. package/apps/pwa/out/workflows/chat-ui/index.txt +14 -14
  136. package/apps/pwa/out/workflows/index.html +1 -1
  137. package/apps/pwa/out/workflows/index.txt +14 -14
  138. package/apps/pwa/out/workspace/index.html +1 -1
  139. package/apps/pwa/out/workspace/index.txt +14 -14
  140. package/apps/pwa/out/worktrees/index.html +1 -1
  141. package/apps/pwa/out/worktrees/index.txt +14 -14
  142. package/examples/teams/personas/backend.yaml +4 -0
  143. package/examples/teams/personas/pm.yaml +4 -0
  144. package/examples/teams/personas/qa.yaml +4 -0
  145. package/examples/teams/small-product.yaml +20 -0
  146. package/graphs/context/nightly-condense.yaml +21 -0
  147. package/graphs/context/recipes.yaml +12 -0
  148. package/graphs/demo/inside-seed.yaml +20 -0
  149. package/graphs/demo/recipes.yaml +12 -0
  150. package/graphs/lecture/lecture-note.yaml +28 -0
  151. package/graphs/lecture/recipes.yaml +17 -0
  152. package/package.json +2 -1
  153. package/plugins/card-followup/examples/sample-card.png +0 -0
  154. package/scripts/context-hooks/emit.ts +36 -14
  155. package/scripts/coord-channel-watch.sh +1 -0
  156. package/scripts/discord-seat-probe.ts +144 -0
  157. package/scripts/hq/hq-standby.sh +65 -0
  158. package/scripts/hq/standby-promote.ts +173 -0
  159. package/scripts/hq/standby-role.ts +59 -0
  160. package/scripts/hq/standby-snapshot.ts +226 -0
  161. package/scripts/hq/standby-verify.ts +219 -0
  162. package/scripts/lecture-note/node.ts +256 -0
  163. package/scripts/lib/telegram-inject-args.ts +31 -0
  164. package/scripts/measure-pod-memory-by-goal.ts +130 -0
  165. package/scripts/release-loop/auto-approve-node.ts +1 -1
  166. package/scripts/release-loop/checklist-gate-node.ts +2 -1
  167. package/scripts/release-loop/gate-node.ts +61 -17
  168. package/scripts/release-loop/ops-upgrade-node.ts +59 -6
  169. package/scripts/release-loop/publish-node.ts +4 -1
  170. package/scripts/release-loop/version-node.ts +13 -3
  171. package/scripts/telegram-inject.ts +14 -6
  172. package/scripts/test-deterministic.ts +53 -3
  173. package/scripts/test-diet/remeasure-list.ts +112 -0
  174. package/scripts/ux/demo-rehearsal.ts +17 -13
  175. package/scripts/ux/demo-seed.ts +108 -0
  176. package/scripts/ux/lib/rehearsal-verdict.ts +12 -5
  177. package/skills/omni-crawl/SKILL.md +16 -16
  178. package/skills/omni-crawl/package-lock.json +1 -544
  179. package/skills/omni-crawl/package.json +3 -4
  180. package/skills/omni-crawl/scripts/main.ts +13 -13
  181. package/skills/omni-crawl/scripts/monitor.ts +8 -8
  182. package/skills/omni-crawl/src/apify.ts +13 -2
  183. package/skills/omni-crawl/src/capture.ts +6 -0
  184. package/skills/omni-crawl/src/registry.ts +2 -2
  185. package/skills/omni-crawl/src/stdout-json.ts +4 -0
  186. package/skills/omni-digest/SKILL.md +10 -11
  187. package/skills/omni-digest/package-lock.json +0 -545
  188. package/skills/omni-digest/package.json +2 -5
  189. package/skills/omni-digest/scripts/main.ts +3 -3
  190. package/skills/omni-digest/src/delegate.ts +5 -5
  191. package/skills/omni-digest/src/fetch.ts +2 -2
  192. package/skills/omni-digest/src/media.ts +25 -11
  193. package/skills/omni-digest/src/visual.ts +3 -2
  194. package/skills/omni-market/scripts/main.ts +1 -1
  195. package/skills/omni-market/scripts/stdout-json.ts +4 -0
  196. package/src/agent/identity-env.ts +11 -0
  197. package/src/agent-mission/driver.ts +150 -23
  198. package/src/agent-mission/duo.ts +94 -0
  199. package/src/agent-mission/pty-decision.ts +2 -2
  200. package/src/autopilot/pty-control-loop.ts +4 -1
  201. package/src/autopilot/track-agent-shadow.ts +2 -1
  202. package/src/autopilot/track-agent.ts +4 -1
  203. package/src/boot/daemon-prompt-request.ts +3 -0
  204. package/src/boot/daemon-prompt-turn.ts +6 -2
  205. package/src/boot/daemon-runtime.ts +48 -16
  206. package/src/chat/index.ts +1 -0
  207. package/src/cli/decisions-cli.ts +51 -19
  208. package/src/cli/outputs-cli.ts +92 -0
  209. package/src/cli/persona-cli.ts +45 -13
  210. package/src/cli/pod-cli.ts +27 -3
  211. package/src/cli/pod-memory-advice.ts +35 -0
  212. package/src/cli/pr-cli.ts +15 -1
  213. package/src/cli/release-cli.ts +135 -15
  214. package/src/context-bus/condense.ts +194 -0
  215. package/src/context-bus/context-day.ts +82 -0
  216. package/src/context-bus/context-now-surfaces.ts +32 -2
  217. package/src/context-bus/context-now.ts +2 -2
  218. package/src/context-bus/coord-events.ts +2 -2
  219. package/src/context-bus/long-term-memory.ts +118 -22
  220. package/src/context-bus/nightly-condense.ts +153 -0
  221. package/src/context-bus/session-events.ts +35 -0
  222. package/src/dashboard/dashboard-status-lines.ts +2 -0
  223. package/src/dashboard/index.ts +8 -0
  224. package/src/dashboard/slash-runtime/dashboard-handlers.ts +24 -0
  225. package/src/decisions/decision-cards.ts +13 -7
  226. package/src/decisions/decision-ledger.ts +43 -17
  227. package/src/domains/outbound-alert.ts +99 -31
  228. package/src/domains/outbound-log-probe.ts +8 -0
  229. package/src/execution-loop/launch-gate.ts +17 -8
  230. package/src/field-note/telegram.ts +142 -0
  231. package/src/graph-kinds/registry.ts +2 -2
  232. package/src/graph-runner/graph-approval-card.ts +2 -2
  233. package/src/graph-runner/graph-grow-llm.ts +23 -13
  234. package/src/graph-runner/graph-grow.ts +69 -13
  235. package/src/graph-runner/graph-tick.ts +9 -2
  236. package/src/graph-runner/runner.ts +92 -24
  237. package/src/harness/harness-cli-command.ts +165 -17
  238. package/src/harness/harness-queue-child.ts +37 -0
  239. package/src/harness/harness-queue.ts +306 -0
  240. package/src/hooks/consult-intake.ts +153 -0
  241. package/src/hooks/github-shadow.ts +72 -2
  242. package/src/hooks/receiver.ts +82 -3
  243. package/src/hq/hq.ts +318 -0
  244. package/src/hq/lease.ts +210 -0
  245. package/src/hq/ledger-write-target.ts +41 -0
  246. package/src/index.ts +232 -16
  247. package/src/intake-plane/discord-seat-work.ts +36 -3
  248. package/src/intake-plane/linear-wish.ts +44 -0
  249. package/src/intake-plane/persona-answer.ts +5 -0
  250. package/src/intake-plane/telegram-seat-work.ts +13 -6
  251. package/src/intake-plane/wish-card.ts +33 -0
  252. package/src/llm/difficulty.ts +1 -1
  253. package/src/loops/checker.ts +178 -0
  254. package/src/loops/loop-cli.ts +37 -3
  255. package/src/loops/observe.ts +49 -0
  256. package/src/loops/orchestrator/overlap.ts +141 -0
  257. package/src/loops/orchestrator/traffic.ts +150 -0
  258. package/src/loops/package/verify.ts +125 -0
  259. package/src/loops/verdict.ts +22 -0
  260. package/src/maturity/feature-maturity.ts +5 -4
  261. package/src/memory.ts +37 -4
  262. package/src/nexus/api/card-followup-route.ts +118 -0
  263. package/src/nexus/api/decisions-route.ts +68 -0
  264. package/src/nexus/api/http-server.ts +78 -8
  265. package/src/nexus/api/outbound-report.ts +40 -7
  266. package/src/nexus/api/personas.ts +97 -54
  267. package/src/nexus/api/skill-exec-route.ts +97 -0
  268. package/src/nexus/api/task-cards-api.ts +19 -0
  269. package/src/nexus/api/workflow-history.ts +88 -0
  270. package/src/nexus/api/workflows.ts +52 -0
  271. package/src/nexus/outbound/delivery-ledger.ts +17 -8
  272. package/src/nexus/outbound/router.ts +8 -3
  273. package/src/persona/loader.ts +18 -0
  274. package/src/persona/persona-todo.ts +14 -9
  275. package/src/persona/presets.ts +10 -2
  276. package/src/persona/team.ts +105 -0
  277. package/src/persona/types.ts +4 -0
  278. package/src/plugins/maker/market-bundle.ts +2 -1
  279. package/src/pod-lease/host-lease.ts +130 -20
  280. package/src/release-loop/checklist.ts +15 -3
  281. package/src/release-loop/feature-store.ts +24 -10
  282. package/src/release-loop/landed-but-yellow.ts +60 -0
  283. package/src/seat-dispatch/seat-ask.ts +57 -12
  284. package/src/seat-loop/seat-loop.ts +253 -18
  285. package/src/seat-loop/seat-pack.ts +127 -0
  286. package/src/self-dev/ask-launch-flow.ts +3 -0
  287. package/src/self-dev/draft-sweep.ts +44 -10
  288. package/src/self-dev/draft-triage-rules.ts +54 -2
  289. package/src/self-implement/budget-gate.ts +29 -12
  290. package/src/self-implement/gate-candidate-ranking.ts +60 -0
  291. package/src/self-implement/gate-scope.ts +9 -8
  292. package/src/self-implement/headless-elanous-driver.ts +7 -2
  293. package/src/self-implement/l8-merge-queue.ts +157 -1
  294. package/src/self-implement/orchestrator.ts +15 -0
  295. package/src/self-implement/test-seams.ts +1 -0
  296. package/src/steward/launch.ts +5 -1
  297. package/src/steward/readiness.ts +125 -0
  298. package/src/steward/rescue.ts +75 -0
  299. package/src/steward/triage.ts +48 -9
  300. package/src/task-cards/card-cli.ts +78 -0
  301. package/src/task-orchestrator/surfaces/pod-command-job.ts +14 -10
  302. package/src/task-orchestrator/surfaces/pod-lease.ts +18 -6
  303. package/src/task-orchestrator/surfaces/pod-pool.ts +27 -10
  304. package/src/task-orchestrator/surfaces/self-implement-pod.ts +46 -8
  305. package/src/telegram-commands.ts +21 -0
  306. package/src/telegram-dispatch-forward.ts +1 -1
  307. package/src/telegram-fabric-plan.ts +90 -0
  308. package/src/telegram-project-command.ts +84 -4
  309. package/src/telegram.ts +37 -5
  310. package/src/tool-runtime/elanous-control-runtimes.ts +2 -1
  311. package/src/user-config.ts +101 -13
  312. package/src/version/packed-revision.json +1 -1
  313. package/src/workflow-runtime/executor.ts +4 -0
  314. package/src/workflow-runtime/node-catalog.ts +13 -0
  315. package/src/workflow-runtime/nodes/knowledge.ts +38 -0
  316. package/src/workflow-runtime/schema.ts +17 -1
  317. package/src/workflow-runtime/types.ts +13 -1
  318. package/apps/pwa/out/_next/static/chunks/2310-7a59f043f6db207e.js +0 -1
  319. package/apps/pwa/out/_next/static/chunks/2548-6e316138d347cefe.js +0 -1
  320. package/apps/pwa/out/_next/static/chunks/3869-a39d1d9921e10d43.js +0 -1
  321. package/apps/pwa/out/_next/static/chunks/507-5acd98bd6dab2d8a.js +0 -1
  322. package/apps/pwa/out/_next/static/chunks/5445-745eb795c5963d79.js +0 -1
  323. package/apps/pwa/out/_next/static/chunks/9906-482c6619b3fdda20.js +0 -1
  324. package/apps/pwa/out/_next/static/chunks/app/approvals/page-1dcdc58fc2de2454.js +0 -1
  325. package/apps/pwa/out/_next/static/chunks/app/board/page-cb95a7432c9ee744.js +0 -1
  326. package/apps/pwa/out/_next/static/chunks/app/botlab/page-b12b6d2f8d2d1aea.js +0 -1
  327. package/apps/pwa/out/_next/static/chunks/app/bots/page-b9efe868bfd36255.js +0 -1
  328. package/apps/pwa/out/_next/static/chunks/app/consult/page-8fd36984f549270a.js +0 -1
  329. package/apps/pwa/out/_next/static/chunks/app/exec/page-4cd1de371f8ad048.js +0 -1
  330. package/apps/pwa/out/_next/static/chunks/app/field/page-d99f89657828421c.js +0 -1
  331. package/apps/pwa/out/_next/static/chunks/app/inside/page-50cb2a0eb15e6c83.js +0 -1
  332. package/apps/pwa/out/_next/static/chunks/app/live/page-2a9932ddb62d76bd.js +0 -1
  333. package/apps/pwa/out/_next/static/chunks/app/missions/[id]/page-6b15dd6456c5df09.js +0 -1
  334. package/apps/pwa/out/_next/static/chunks/app/not-found-e7a529e0507ac86c.js +0 -1
  335. package/apps/pwa/out/_next/static/chunks/app/page-94c82eb0ae5abb32.js +0 -1
  336. package/apps/pwa/out/_next/static/chunks/app/reflection/page-0be8d4b2ced75ba0.js +0 -1
  337. package/apps/pwa/out/_next/static/chunks/app/settings/page-53f80edc6b8dc07c.js +0 -1
  338. package/apps/pwa/out/_next/static/chunks/app/workspace/page-c6da2b468454532d.js +0 -1
  339. package/apps/pwa/out/_next/static/chunks/app/worktrees/page-93bc70e36f595414.js +0 -1
  340. package/apps/pwa/out/_next/static/css/543f56bcb1f79fca.css +0 -1
  341. /package/apps/pwa/out/_next/static/{Y4zKzL62sakG5momz3SoQ → D51l8jUBplJrIpWvENsDK}/_buildManifest.js +0 -0
  342. /package/apps/pwa/out/_next/static/{Y4zKzL62sakG5momz3SoQ → D51l8jUBplJrIpWvENsDK}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8677],{1355:(e,t,r)=>{"use strict";r.d(t,{Zr:()=>l,f6:()=>a,oD:()=>s});let n="elanous.daemon.sessionId";function a(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():"s-".concat(Date.now().toString(36),"-").concat(Math.random().toString(36).slice(2,10))}function s(){let e=function(){let e=new URLSearchParams(window.location.search).get("session");return e?(localStorage.setItem(n,e),e):localStorage.getItem(n)}();if(e)return e;let t=a();return localStorage.setItem(n,t),t}function l(){let e=a();return localStorage.setItem(n,e),e}},10080:(e,t,r)=>{"use strict";r.d(t,{$:()=>i});var n=r(54456),a=r(80247),s=r(13680),l=r(74591);let o=(0,s.F)("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function i(e){let{className:t,variant:r="default",size:s="default",...i}=e;return(0,n.jsx)(a.$,{"data-slot":"button",className:(0,l.cn)(o({variant:r,size:s,className:t})),...i})}},19785:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>k});var n=r(54456),a=r(60500),s=r(36581),l=r(10080),o=r(31395),i=r(52468),d=r(81573),c=r(15375);let u="wikilink:",m={aliasDivider:"|",pageResolver:e=>[e],hrefTemplate:e=>"".concat(u).concat(encodeURIComponent(e))};function x(e){let{markdown:t,onWikilink:r}=e;return(0,n.jsx)("div",{className:"text-sm text-foreground/90",children:(0,n.jsx)(o.oz,{remarkPlugins:[i.A,c.A,[d.A,m]],components:{h1:e=>{let{children:t}=e;return(0,n.jsx)("h1",{className:"mb-3 mt-5 border-b border-border pb-1 text-2xl font-bold",children:t})},h2:e=>{let{children:t}=e;return(0,n.jsx)("h2",{className:"mb-2 mt-5 text-xl font-bold",children:t})},h3:e=>{let{children:t}=e;return(0,n.jsx)("h3",{className:"mb-2 mt-4 text-lg font-semibold",children:t})},h4:e=>{let{children:t}=e;return(0,n.jsx)("h4",{className:"mb-1 mt-3 text-base font-semibold",children:t})},h5:e=>{let{children:t}=e;return(0,n.jsx)("h5",{className:"mb-1 mt-2 text-sm font-semibold text-muted-foreground",children:t})},h6:e=>{let{children:t}=e;return(0,n.jsx)("h6",{className:"mb-1 mt-2 text-xs font-semibold uppercase text-muted-foreground",children:t})},p:e=>{let{children:t}=e;return(0,n.jsx)("p",{className:"my-2 leading-relaxed",children:t})},ul:e=>{let{children:t}=e;return(0,n.jsx)("ul",{className:"my-2 list-disc space-y-1 pl-6",children:t})},ol:e=>{let{children:t}=e;return(0,n.jsx)("ol",{className:"my-2 list-decimal space-y-1 pl-6",children:t})},li:e=>{let{children:t}=e;return(0,n.jsx)("li",{className:"leading-relaxed",children:t})},blockquote:e=>{let{children:t}=e;return(0,n.jsx)("blockquote",{className:"my-3 border-l-4 border-primary/40 bg-muted/40 py-1 pl-3 text-muted-foreground",children:t})},hr:()=>(0,n.jsx)("hr",{className:"my-4 border-border"}),table:e=>{let{children:t}=e;return(0,n.jsx)("div",{className:"my-3 overflow-x-auto",children:(0,n.jsx)("table",{className:"w-full border-collapse text-sm",children:t})})},thead:e=>{let{children:t}=e;return(0,n.jsx)("thead",{className:"bg-muted/60",children:t})},th:e=>{let{children:t}=e;return(0,n.jsx)("th",{className:"border border-border px-3 py-1.5 text-left font-semibold",children:t})},td:e=>{let{children:t}=e;return(0,n.jsx)("td",{className:"border border-border px-3 py-1.5",children:t})},code:e=>{let{className:t,children:r}=e;return t?(0,n.jsx)("code",{className:"".concat(t," font-mono"),children:r}):(0,n.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[0.85em]",children:r})},pre:e=>{let{children:t}=e;return(0,n.jsx)("pre",{className:"my-3 overflow-x-auto rounded-lg border border-border bg-muted/40 p-3 text-xs",children:t})},img:e=>{let{src:t,alt:r}=e;return(0,n.jsx)("img",{src:"string"==typeof t?t:"",alt:null!=r?r:"",className:"my-2 max-w-full rounded"})},a:e=>{let{href:t,children:a}=e,s=null!=t?t:"";if(s.startsWith(u)){let e=decodeURIComponent(s.slice(u.length));return(0,n.jsx)("button",{type:"button",onClick:()=>null==r?void 0:r(e),className:"text-primary underline decoration-dotted underline-offset-2 hover:decoration-solid",children:a})}return(0,n.jsx)("a",{href:s,target:"_blank",rel:"noreferrer",className:"text-primary underline underline-offset-2",children:a})}},children:t})})}class h{get(e){return this.client.fetchJson(e)}info(){return this.get("/v1/vault/info")}list(e){return this.get("/v1/vault/list".concat(e?"?cwd=".concat(encodeURIComponent(e)):""))}read(e,t){let r=new URLSearchParams({path:e,...t?{maxBytes:String(t)}:{}});return this.get("/v1/vault/read?".concat(r.toString()))}search(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:50;return this.get("/v1/vault/search?q=".concat(encodeURIComponent(e),"&limit=").concat(t))}notes(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;return this.get("/v1/vault/notes?".concat(e?"query=".concat(encodeURIComponent(e),"&"):"","limit=").concat(t))}backlinks(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;return this.get("/v1/vault/backlinks?target=".concat(encodeURIComponent(e),"&limit=").concat(t))}tags(){return this.get("/v1/vault/tags")}templates(){return this.get("/v1/vault/templates")}graph(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500,n=new URLSearchParams({limit:String(r),...e?{focus:e,hops:String(t)}:{}});return this.get("/v1/vault/graph?".concat(n.toString()))}pollChanges(e){return this.get("/v1/vault/poll-changes?sinceMs=".concat(e))}orphans(){return this.get("/v1/vault/orphans")}templateExpand(e,t){return this.client.fetchJson("/v1/vault/template-expand",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({templatePath:e,...t?{title:t}:{}})})}async writeNote(e){var t,r,n,a;let s=await this.client.fetchResponse("/v1/vault/file",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),l=(null!=(t=s.headers.get("content-type"))?t:"").includes("application/json")?await s.json():await s.text();if(!s.ok&&409!==s.status)throw Error(String("string"==typeof l?l:null!=(a=null!=(n=null!=(r=null==l?void 0:l.message)?r:null==l?void 0:l.reason)?n:null==l?void 0:l.error)?a:"".concat(s.status)));return l}async saveNote(e){var t,r,n;let a=await this.client.fetchResponse("/v1/notes/save",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),s=(null!=(t=a.headers.get("content-type"))?t:"").includes("application/json")?await a.json():await a.text();if(!a.ok&&409!==a.status)throw Error(String("string"==typeof s?s:null!=(n=null!=(r=null==s?void 0:s.reason)?r:null==s?void 0:s.error)?n:"".concat(a.status)));return s}constructor(e){this.client=e}}function p(e){let t=/^---\n([\s\S]*?)\n---\n?/.exec(e);return t?{frontmatter:t[1],body:e.slice(t[0].length)}:{frontmatter:null,body:e}}function g(e){let t=e.toLowerCase();return t.endsWith(".md")||t.endsWith(".markdown")?"markdown":/\.(png|jpe?g|gif|webp|svg)$/.test(t)?"image":t.endsWith(".pdf")?"pdf":/\.(txt|json|ya?ml|csv|log)$/.test(t)?"text":"other"}function f(e){let{onPickTag:t}=e,{client:r}=(0,s.Q)(),l=(0,a.useMemo)(()=>new h(r),[r]),[o,i]=(0,a.useState)([]),[d,c]=(0,a.useState)(""),[u,m]=(0,a.useState)(!0),x=(0,a.useCallback)(async()=>{m(!0);try{var e;let t=await l.tags();i((null!=(e=t.tags)?e:[]).sort((e,t)=>t.count-e.count))}catch(e){}finally{m(!1)}},[l]);(0,a.useEffect)(()=>{x()},[x]);let p=d?o.filter(e=>e.tag.toLowerCase().includes(d.toLowerCase())):o;return(0,n.jsxs)("div",{className:"flex h-full flex-col",children:[(0,n.jsx)("div",{className:"border-b border-border p-2",children:(0,n.jsx)("input",{value:d,onChange:e=>c(e.target.value),placeholder:"태그 필터…",className:"w-full rounded border border-border bg-background px-2 py-1 text-xs"})}),(0,n.jsx)("div",{className:"flex-1 overflow-auto p-1",children:u?(0,n.jsx)("p",{className:"p-2 text-xs text-muted-foreground",children:"불러오는 중…"}):0===p.length?(0,n.jsx)("p",{className:"p-2 text-xs text-muted-foreground",children:"태그 없음"}):(0,n.jsx)("ul",{className:"space-y-0.5",children:p.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{onClick:()=>t(e.tag),className:"flex w-full items-center justify-between rounded px-2 py-1 text-left text-xs hover:bg-muted",children:[(0,n.jsxs)("span",{className:"truncate",children:["#",e.tag]}),(0,n.jsx)("span",{className:"ml-2 shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground",children:e.count})]})},e.tag))})})]})}function v(e){var t,r;let{onOpen:o}=e,{client:i}=(0,s.Q)(),d=(0,a.useMemo)(()=>new h(i),[i]),[c,u]=(0,a.useState)(null),[m,x]=(0,a.useState)(null),[p,g]=(0,a.useState)(!0),f=(0,a.useCallback)(async e=>{g(!0);try{u(await d.graph(null!=e?e:void 0,1,e?60:400))}catch(e){}finally{g(!1)}},[d]);(0,a.useEffect)(()=>{f(m)},[f,m]);let v=(0,a.useMemo)(()=>{if(!c)return{nodes:[],edges:[]};let e=c.nodes.map(e=>e.id),t=c.edges.map(e=>({source:e.from,target:e.to}));return{nodes:function(e,t){var r,n,a;let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{width:800,height:600},{width:l,height:o}=s,i=null!=(r=s.iterations)?r:120,d=e.length,c=new Map;for(let e of t)c.set(e.source,(null!=(n=c.get(e.source))?n:0)+1),c.set(e.target,(null!=(a=c.get(e.target))?a:0)+1);let u=l/2,m=o/2,x=.4*Math.min(l,o),h=e.map((e,t)=>{var r;return{id:e,deg:null!=(r=c.get(e))?r:0,x:u+x*Math.cos(2*Math.PI*t/Math.max(1,d)),y:m+x*Math.sin(2*Math.PI*t/Math.max(1,d))}}),p=new Map(h.map((e,t)=>[e.id,t])),g=Math.sqrt(l*o/Math.max(1,d));for(let e=0;e<i;e++){let r=h.map(()=>({x:0,y:0}));for(let e=0;e<d;e++)for(let t=e+1;t<d;t++){let n=h[e].x-h[t].x,a=h[e].y-h[t].y,s=Math.hypot(n,a)||.01,l=g*g/s;n/=s,a/=s,r[e].x+=n*l,r[e].y+=a*l,r[t].x-=n*l,r[t].y-=a*l}for(let e of t){let t=p.get(e.source),n=p.get(e.target);if(null==t||null==n)continue;let a=h[t].x-h[n].x,s=h[t].y-h[n].y,l=Math.hypot(a,s)||.01,o=l*l/g;a/=l,s/=l,r[t].x-=a*o,r[t].y-=s*o,r[n].x+=a*o,r[n].y+=s*o}let n=1-e/i;for(let e=0;e<d;e++){let t=Math.hypot(r[e].x,r[e].y)||.01,a=Math.min(t,30*n);h[e].x=Math.max(20,Math.min(l-20,h[e].x+r[e].x/t*a)),h[e].y=Math.max(20,Math.min(o-20,h[e].y+r[e].y/t*a))}}return h}(e,t,{width:900,height:640,iterations:140}),edges:t}},[c]),b=(0,a.useMemo)(()=>new Map(v.nodes.map(e=>[e.id,e])),[v]),y=Math.max(1,...v.nodes.map(e=>e.deg));return(0,n.jsxs)("div",{className:"flex h-full flex-col",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2 text-sm",children:[(0,n.jsx)("span",{className:"font-medium",children:"노트 그래프"}),m?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:["focus: ",m," (1-hop)"]}),(0,n.jsx)(l.$,{size:"sm",variant:"outline",className:"ml-auto h-6 px-2 text-xs",onClick:()=>x(null),children:"전체 그래프"})]}):(0,n.jsxs)("span",{className:"ml-auto text-xs text-muted-foreground",children:[null!=(t=null==c?void 0:c.nodes.length)?t:0," 노드 \xb7 ",null!=(r=null==c?void 0:c.edges.length)?r:0," 링크",(null==c?void 0:c.truncated)?" (일부)":""]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto p-2",children:p?(0,n.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:"그래프 계산 중…"}):c&&0!==c.nodes.length?(0,n.jsxs)("svg",{viewBox:"0 0 ".concat(900," ").concat(640),className:"h-auto w-full",style:{maxHeight:"78vh"},children:[v.edges.map((e,t)=>{let r=b.get(e.source),a=b.get(e.target);return r&&a?(0,n.jsx)("line",{x1:r.x,y1:r.y,x2:a.x,y2:a.y,stroke:"currentColor",className:"text-border",strokeWidth:.6,opacity:.5},t):null}),v.nodes.map(e=>{let t=3+e.deg/y*9;return(0,n.jsxs)("g",{className:"cursor-pointer",onClick:()=>null==o?void 0:o(e.id),onDoubleClick:()=>x(e.id),children:[(0,n.jsx)("circle",{cx:e.x,cy:e.y,r:t,className:"fill-primary/70 hover:fill-primary"}),(e.deg>=.3*y||m)&&(0,n.jsx)("text",{x:e.x+t+2,y:e.y+3,className:"fill-foreground/70 text-[9px]",children:e.id.split("/").pop()})]},e.id)})]}):(0,n.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:"그래프가 비어있습니다."})}),(0,n.jsx)("p",{className:"border-t border-border px-3 py-1 text-[11px] text-muted-foreground",children:"클릭=노트 열기 \xb7 더블클릭=로컬 그래프(focus)"})]})}function b(e){let{onClose:t,onCreated:r}=e,{client:o}=(0,s.Q)(),i=(0,a.useMemo)(()=>new h(o),[o]),[d,c]=(0,a.useState)(""),[u,m]=(0,a.useState)([]),[x,p]=(0,a.useState)(""),[g,f]=(0,a.useState)(!1),[v,b]=(0,a.useState)(null);(0,a.useEffect)(()=>{i.templates().then(e=>{var t;return m(null!=(t=e.templates)?t:[])}).catch(()=>{})},[i]);let y=(0,a.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};f(!0),b(null);try{let t=e.daily?function(){let e=new Date;return"".concat(e.getFullYear(),"-").concat(String(e.getMonth()+1).padStart(2,"0"),"-").concat(String(e.getDate()).padStart(2,"0"))}():d.trim();if(!t){b("제목을 입력하세요"),f(!1);return}let n="# ".concat(t,"\n\n");if(x){let e=await i.templateExpand(x,t);e.content&&(n=e.content)}else e.daily&&(n="# ".concat(t,"\n\n## 오늘\n\n- \n"));let a=e.daily?"Daily/".concat(t,".md"):"".concat(t,".md"),s=await i.writeNote({path:a,content:n,createOnly:!0});if(s.error){b("file_exists"===s.error?"이미 존재하는 노트입니다":s.error),f(!1);return}r(a)}catch(e){b(e instanceof Error?e.message:String(e)),f(!1)}},[i,d,x,r]);return(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:t,children:(0,n.jsxs)("div",{className:"w-[420px] rounded-lg border border-border bg-card p-4 shadow-xl",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{className:"mb-3 text-sm font-semibold",children:"새 노트"}),(0,n.jsx)("input",{value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&y()},placeholder:"노트 제목…",autoFocus:!0,className:"mb-2 w-full rounded border border-border bg-background px-3 py-2 text-sm"}),u.length>0&&(0,n.jsxs)("select",{value:x,onChange:e=>p(e.target.value),className:"mb-2 w-full rounded border border-border bg-background px-2 py-1.5 text-sm",children:[(0,n.jsx)("option",{value:"",children:"템플릿 없음"}),u.map(e=>(0,n.jsx)("option",{value:e.relPath,children:e.name},e.relPath))]}),v&&(0,n.jsx)("p",{className:"mb-2 text-xs text-rose-400",children:v}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(l.$,{size:"sm",onClick:()=>void y(),disabled:g||!d.trim(),children:"생성"}),(0,n.jsx)(l.$,{size:"sm",variant:"outline",onClick:()=>void y({daily:!0}),disabled:g,children:"오늘 데일리노트"}),(0,n.jsx)(l.$,{size:"sm",variant:"ghost",className:"ml-auto",onClick:t,children:"취소"})]})]})})}let y="elanous.pwa.vaultTreeOpen";function j(e){let{onEdit:t}=e,{client:r}=(0,s.Q)(),o=(0,a.useMemo)(()=>new h(r),[r]),[i,d]=(0,a.useState)(null),[c,u]=(0,a.useState)(""),[m,x]=(0,a.useState)([]),[p,j]=(0,a.useState)(null),[N,k]=(0,a.useState)(null),[C,S]=(0,a.useState)(""),[M,z]=(0,a.useState)(null),[D,E]=(0,a.useState)(!1),[I,P]=(0,a.useState)("view"),[U,R]=(0,a.useState)("files"),[$,_]=(0,a.useState)(!1),[O,T]=(0,a.useState)(0),[q,F]=(0,a.useState)(!0);(0,a.useEffect)(()=>{F(function(e){try{return(null==e?void 0:e.getItem(y))!=="0"}catch(e){return!0}}(window.localStorage))},[]);let L=(0,a.useCallback)(()=>{F(e=>{let t=!e;var r=window.localStorage;try{null==r||r.setItem(y,t?"1":"0")}catch(e){}return t})},[]);(0,a.useEffect)(()=>{let e=Date.now(),t=setInterval(()=>{o.pollChanges(e).then(e=>{var t;return T(null!=(t=e.count)?t:0)}).catch(()=>{})},3e4);return()=>clearInterval(t)},[o]);let K=(0,a.useCallback)(e=>{S("#".concat(e)),R("files"),(async()=>{E(!0);try{var t;let r=await o.search("#".concat(e),50);z(null!=(t=r.matches)?t:[])}catch(e){z([])}finally{E(!1)}})()},[o]),Q=(0,a.useCallback)(async e=>{E(!0),z(null);try{let t=await o.list(e||void 0);t.error||(x(t.entries),u(t.cwd))}catch(e){}finally{E(!1)}},[o]);(0,a.useEffect)(()=>{let e=!0;return o.info().then(t=>{e&&(d(t),t.available&&Q(""))}).catch(()=>{}),()=>{e=!1}},[o,Q]);let W=(0,a.useCallback)(async e=>{j(e),k(null),window.innerWidth<=767&&F(!1);try{k(await o.read(e))}catch(e){}},[o]),A=(0,a.useCallback)(async()=>{let e=C.trim();if(!e)return void z(null);E(!0);try{var t;let r=await o.search(e,50);z(null!=(t=r.matches)?t:[])}catch(e){z([])}finally{E(!1)}},[o,C]),V=c&&(null==i?void 0:i.root)?c.replace(i.root,"").split("/").filter(Boolean):[],Y=(null==i?void 0:i.root)?c.replace(i.root,"").replace(/^\//,""):"";return i&&!i.available?(0,n.jsxs)("div",{className:"p-6 text-sm text-muted-foreground",children:["Obsidian vault를 찾을 수 없습니다 (source: ",i.source,"). ~/.elanous/config.json 의 obsidian.vault 를 확인하세요."]}):(0,n.jsxs)("div",{className:"mx-auto flex h-[calc(100vh-3rem)] max-w-[1920px] gap-3 px-3 py-3",children:[$&&(0,n.jsx)(b,{onClose:()=>_(!1),onCreated:e=>{_(!1),Q(""),null==t||t(e)}}),(0,n.jsxs)("div",{"data-testid":"vault-tree",className:[q?"flex":"hidden","w-full shrink-0 flex-col rounded-lg border border-border bg-card/40 md:w-64 lg:w-72"].join(" "),children:[(0,n.jsxs)("div",{className:"flex items-center gap-1 border-b border-border px-2 py-1.5",children:[["files","tags","graph"].map(e=>(0,n.jsx)("button",{onClick:()=>R(e),className:["rounded px-2 py-0.5 text-xs",U===e?"bg-primary/20 text-foreground":"text-muted-foreground"].join(" "),children:{files:"파일",tags:"태그",graph:"그래프"}[e]},e)),O>0&&(0,n.jsxs)("span",{className:"rounded bg-amber-500/15 px-1.5 py-0.5 text-[10px] text-amber-300",title:"외부 변경 감지",children:["↻ ",O]}),(0,n.jsx)(l.$,{size:"sm",variant:"outline",className:"ml-auto h-6 px-2 text-xs",onClick:()=>_(!0),children:"+ 새 노트"})]}),"graph"===U?(0,n.jsx)(v,{onOpen:e=>{R("files"),W("".concat(e,".md"))}}):"tags"===U?(0,n.jsx)(f,{onPickTag:K}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"border-b border-border p-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{value:C,onChange:e=>S(e.target.value),onKeyDown:e=>{"Enter"===e.key&&A()},placeholder:"vault 전문검색…",className:"min-w-0 flex-1 rounded border border-border bg-background px-2 py-1 text-sm"}),(0,n.jsx)(l.$,{size:"sm",variant:"outline",onClick:()=>void A(),children:"검색"})]}),!M&&(0,n.jsxs)("div",{className:"mt-1.5 flex flex-wrap items-center gap-1 text-xs text-muted-foreground",children:[(0,n.jsx)("button",{className:"hover:text-foreground",onClick:()=>void Q(""),children:"vault"}),V.map((e,t)=>(0,n.jsxs)("span",{children:["/ ",(0,n.jsx)("button",{className:"hover:text-foreground",onClick:()=>void Q("".concat(i.root,"/").concat(V.slice(0,t+1).join("/"))),children:e})]},t))]})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-auto p-1",children:[D&&(0,n.jsx)("p",{className:"p-2 text-xs text-muted-foreground",children:"불러오는 중…"}),M?0===M.length?(0,n.jsx)("p",{className:"p-2 text-xs text-muted-foreground",children:"검색 결과 없음"}):(0,n.jsx)("ul",{className:"space-y-1",children:M.map((e,t)=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{className:"w-full rounded px-2 py-1.5 text-left text-xs hover:bg-muted",onClick:()=>void W(e.path),children:[(0,n.jsx)("span",{className:"font-medium",children:e.path.split("/").pop()})," ",(0,n.jsxs)("span",{className:"text-muted-foreground",children:[":",e.lineNumber]}),(0,n.jsx)("div",{className:"truncate text-muted-foreground",children:e.snippet})]})},t))}):(0,n.jsxs)("ul",{children:[Y&&(0,n.jsx)("li",{children:(0,n.jsx)("button",{className:"w-full rounded px-2 py-1.5 text-left text-sm text-muted-foreground hover:bg-muted",onClick:()=>void Q("".concat(i.root,"/").concat(function(e){let t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}(Y))),children:"\uD83D\uDCC1 .."})}),m.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{className:["flex w-full items-center gap-1.5 rounded px-2 py-1.5 text-left text-sm hover:bg-muted",p==="".concat(Y?Y+"/":"").concat(e.name)?"bg-muted":""].join(" "),onClick:()=>e.isDir?void Q("".concat(c,"/").concat(e.name)):void W("".concat(Y?Y+"/":"").concat(e.name)),children:[(0,n.jsx)("span",{children:e.isDir?"\uD83D\uDCC1":"markdown"===g(e.name)?"\uD83D\uDCDD":"image"===g(e.name)?"\uD83D\uDDBC️":"\uD83D\uDCC4"}),(0,n.jsx)("span",{className:"truncate",children:e.name})]})},e.relPath))]})]})]})]}),(0,n.jsxs)("div",{className:[q?"hidden md:flex":"flex","min-w-0 flex-1 flex-col rounded-lg border border-border bg-card/40"].join(" "),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("button",{type:"button",onClick:L,"aria-expanded":q,"aria-label":q?"폴더 접기":"폴더 펴기",title:q?"폴더 접기":"폴더 펴기",className:"shrink-0 rounded px-1.5 py-0.5 text-xs text-muted-foreground ring-1 ring-border hover:text-foreground",children:q?"◀ 폴더":"▶ 폴더"}),(0,n.jsx)("span",{className:"truncate text-sm font-medium",children:null!=p?p:"파일을 선택하세요"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[p&&"markdown"===g(p)&&(0,n.jsx)("div",{className:"flex items-center gap-0.5 rounded ring-1 ring-border",children:["view","raw"].map(e=>(0,n.jsx)("button",{onClick:()=>P(e),className:["px-2 py-0.5 text-xs",I===e?"bg-primary/20 text-foreground":"text-muted-foreground"].join(" "),children:"view"===e?"View":"Raw"},e))}),p&&"markdown"===g(p)&&t&&(0,n.jsx)(l.$,{size:"sm",variant:"outline",onClick:()=>t(p),children:"편집"})]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto p-4",children:N?(0,n.jsx)(w,{preview:N,selected:p,mode:I,onWikilink:e=>{W("".concat(Y?Y+"/":"").concat(e,".md"))}}):(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:p?"로딩…":"좌측에서 노트를 선택하면 여기에 표시됩니다."})})]})]})}function w(e){let{preview:t,selected:r,mode:a,onWikilink:s}=e;if(t.error)return(0,n.jsx)("p",{className:"text-sm text-rose-400",children:t.error});let l=g(r);if("image"===l&&t.bytes)return(0,n.jsx)("img",{src:"data:".concat(t.mime,";base64,").concat(t.bytes),alt:r,className:"max-w-full rounded"});if("markdown"===l&&null!=t.content){let{frontmatter:e,body:r}=p(t.content);return"raw"===a?(0,n.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed",children:t.content}):(0,n.jsxs)("div",{children:[e&&(0,n.jsx)("pre",{className:"mb-3 rounded bg-muted/40 p-2 text-[11px] text-muted-foreground",children:e}),(0,n.jsx)(x,{markdown:r,onWikilink:s}),t.truncated&&(0,n.jsxs)("p",{className:"mt-2 text-xs text-amber-400",children:["⚠ 일부만 표시됨(",(t.size/1024).toFixed(0),"KB)"]})]})}return null!=t.content?(0,n.jsx)("pre",{className:"whitespace-pre-wrap text-sm",children:t.content}):(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["미리보기 불가(",t.mime,")"]})}function N(e){let{path:t,onClose:r}=e,{client:o}=(0,s.Q)(),i=(0,a.useMemo)(()=>new h(o),[o]),[d,c]=(0,a.useState)(""),[u,m]=(0,a.useState)(!1),[g,f]=(0,a.useState)("split"),[v,b]=(0,a.useState)("clean"),[y,j]=(0,a.useState)(null),w=(0,a.useRef)(void 0),N=(0,a.useRef)(null),k=(0,a.useRef)(null),[C,S]=(0,a.useState)("outline"),[M,z]=(0,a.useState)([]),[D,E]=(0,a.useState)(null),I=(0,a.useMemo)(()=>(function(e){let t=[],r=!1;return e.split("\n").forEach((e,n)=>{let a=e.trimEnd();if(/^```/.test(a.trim())){r=!r;return}if(r)return;let s=/^(#{1,6})\s+(.+)$/.exec(a);s&&t.push({level:s[1].length,text:s[2].trim(),line:n})}),t})(p(d).body),[d]);(0,a.useEffect)(()=>{let e=!0;return i.read(t,8388608).then(t=>{var r;e&&(c(null!=(r=t.content)?r:""),w.current=t.mtimeMs,m(!0),b("clean"))}).catch(()=>{e&&(j("노트를 불러오지 못했습니다"),m(!0))}),()=>{e=!1,N.current&&clearTimeout(N.current)}},[i,t]);let P=(0,a.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d;b("saving"),j(null);try{let n=await i.writeNote({path:t,content:r,...e?{}:null!=w.current?{lastKnownMtime:w.current}:{}});if("mtime_conflict"===n.error||n.error&&null!=n.currentMtime)return void b("conflict");if(n.error){b("error"),j(n.error);return}null!=n.mtimeMs&&(w.current=n.mtimeMs),b("saved")}catch(e){b("error"),j(e instanceof Error?e.message:String(e))}},[i,t,d]);(0,a.useEffect)(()=>{var e;let r=!0;return i.backlinks((null!=(e=t.split("/").pop())?e:t).replace(/\.md$/i,""),100).then(e=>{var t;r&&z(null!=(t=e.matches)?t:[])}).catch(()=>{}),()=>{r=!1}},[i,t]);let U=(0,a.useCallback)((e,t)=>{let r=function(e,t){let r=e.slice(0,t),n=r.lastIndexOf("[[");if(n<0)return null;let a=r.slice(n+2);return a.includes("]]")||a.includes("\n")?null:{query:a,start:n+2}}(e,t);if(!r)return void E(null);i.notes(r.query||void 0,8).then(e=>{var n;E({query:r.query,start:r.start,caret:t,items:(null!=(n=e.notes)?n:[]).slice(0,8)})}).catch(()=>E(null))},[i]),R=(0,a.useCallback)((e,t)=>{c(e),b("dirty"),U(e,t),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{P(!1,e)},2500)},[P,U]),$=(0,a.useCallback)(e=>{if(!D)return;let t=function(e,t,r,n){let a=e.slice(0,t),s=e.slice(r),l="".concat(n,"]]");return{text:a+l+s,caret:a.length+l.length}}(d,D.start,D.caret,e.name);c(t.text),b("dirty"),E(null),requestAnimationFrame(()=>{k.current&&(k.current.focus(),k.current.setSelectionRange(t.caret,t.caret))})},[D,d]),_=(0,a.useCallback)(e=>{let t=k.current;if(!t)return;let r=d.split("\n").slice(0,e).join("\n").length;t.focus(),t.setSelectionRange(r,r),t.scrollTop=Math.max(0,20*e-100)},[d]),O=p(d).body;return u?(0,n.jsxs)("div",{className:"mx-auto flex h-[calc(100vh-3rem)] max-w-[1500px] flex-col px-3 py-3",children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,n.jsx)(l.$,{size:"sm",variant:"ghost",onClick:r,children:"← 목록"}),(0,n.jsx)("span",{className:"truncate text-sm font-medium",children:t}),(0,n.jsx)("span",{className:["ml-2 rounded px-2 py-0.5 text-xs",{clean:"text-muted-foreground",dirty:"text-amber-400",saving:"text-sky-400",saved:"text-emerald-400",conflict:"text-rose-400",error:"text-rose-400"}[v]].join(" "),children:{clean:"저장됨",dirty:"● 편집 중",saving:"저장 중…",saved:"✓ 저장됨",conflict:"⚠ 충돌",error:"✗ 오류"}[v]}),(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[["edit","split","preview"].map(e=>(0,n.jsx)("button",{onClick:()=>f(e),className:["rounded px-2 py-1 text-xs ring-1",g===e?"bg-primary/20 ring-primary/40":"bg-muted text-muted-foreground ring-border"].join(" "),children:{edit:"편집",split:"분할",preview:"미리보기"}[e]},e)),(0,n.jsx)(l.$,{size:"sm",variant:"outline",onClick:()=>void P(!1),children:"저장"})]})]}),"conflict"===v&&(0,n.jsxs)("div",{className:"mb-2 flex items-center gap-2 rounded border border-rose-500/40 bg-rose-500/10 px-3 py-2 text-xs text-rose-200",children:[(0,n.jsx)("span",{children:"디스크의 노트가 외부에서 변경됐습니다."}),(0,n.jsx)(l.$,{size:"sm",variant:"outline",onClick:()=>void P(!0),children:"강제 덮어쓰기"}),(0,n.jsx)(l.$,{size:"sm",variant:"ghost",onClick:()=>void i.read(t,8388608).then(e=>{var t;c(null!=(t=e.content)?t:""),w.current=e.mtimeMs,b("clean")}),children:"디스크 버전 로드"})]}),y&&(0,n.jsx)("div",{className:"mb-2 text-xs text-rose-400",children:y}),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 gap-3",children:["preview"!==g&&(0,n.jsxs)("div",{className:"relative min-h-0 flex-1",children:[(0,n.jsx)("textarea",{ref:k,value:d,onChange:e=>R(e.target.value,e.target.selectionStart),onKeyUp:e=>U(d,e.target.selectionStart),onClick:e=>U(d,e.target.selectionStart),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&(e.preventDefault(),P(!1)),"Escape"===e.key&&D&&(e.preventDefault(),E(null)),"Enter"===e.key&&D&&D.items.length&&(e.preventDefault(),$(D.items[0]))},className:"h-full min-h-0 w-full resize-none rounded-lg border border-border bg-background p-3 font-mono text-sm leading-relaxed focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}),D&&D.items.length>0&&(0,n.jsxs)("div",{className:"absolute left-3 top-3 z-20 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover shadow-lg",children:[(0,n.jsxs)("div",{className:"border-b border-border px-2 py-1 text-[11px] text-muted-foreground",children:["[[wikilink: ",D.query||"…"]}),D.items.map(e=>(0,n.jsxs)("button",{className:"block w-full truncate px-2 py-1.5 text-left text-xs hover:bg-muted",onMouseDown:t=>{t.preventDefault(),$(e)},children:[(0,n.jsx)("span",{className:"font-medium",children:e.name})," ",(0,n.jsx)("span",{className:"text-muted-foreground",children:e.relPath})]},e.relPath))]})]}),"edit"!==g&&(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-auto rounded-lg border border-border bg-card/40 p-4",children:(0,n.jsx)(x,{markdown:O})}),(0,n.jsxs)("div",{className:"flex w-[220px] min-w-[180px] flex-col rounded-lg border border-border bg-card/40",children:[(0,n.jsx)("div",{className:"flex border-b border-border text-xs",children:["outline","backlinks"].map(e=>(0,n.jsx)("button",{onClick:()=>S(e),className:["flex-1 px-2 py-1.5",C===e?"border-b-2 border-primary text-foreground":"text-muted-foreground"].join(" "),children:"outline"===e?"개요":"역참조 ".concat(M.length?"(".concat(M.length,")"):"")},e))}),(0,n.jsx)("div",{className:"flex-1 overflow-auto p-1 text-xs",children:"outline"===C?0===I.length?(0,n.jsx)("p",{className:"p-2 text-muted-foreground",children:"heading 없음"}):I.map((e,t)=>(0,n.jsx)("button",{onClick:()=>_(e.line),className:"block w-full truncate rounded px-2 py-1 text-left hover:bg-muted",style:{paddingLeft:"".concat(8*e.level,"px")},children:e.text},t)):0===M.length?(0,n.jsx)("p",{className:"p-2 text-muted-foreground",children:"역참조 없음"}):M.map((e,t)=>(0,n.jsxs)("div",{className:"truncate rounded px-2 py-1",title:e.snippet,children:["\uD83D\uDCCE ",e.path.split("/").pop(),e.headingAnchor?" #".concat(e.headingAnchor):""]},t))})]})]})]}):(0,n.jsx)("div",{className:"p-6 text-sm text-muted-foreground",children:"노트 로딩…"})}function k(){let[e,t]=(0,a.useState)(null);return e?(0,n.jsx)(N,{path:e,onClose:()=>t(null)}):(0,n.jsx)(j,{onEdit:e=>t(e)})}},36581:(e,t,r)=>{"use strict";r.d(t,{C:()=>d,DaemonProvider:()=>c,Q:()=>u});var n=r(54456),a=r(60500),s=r(86704),l=r(1355),o=r(39906),i=r(50733);let d=(0,a.createContext)(null);function c(e){let{children:t}=e,r={baseUrl:"",token:"",provider:""},[c,u]=(0,a.useState)(r),[m,x]=(0,a.useState)(""),[h]=(0,a.useState)(()=>new o.ki(r));(0,a.useEffect)(()=>{let e=(0,s.Fp)();u(e),h.updateConfig(e),x((0,l.oD)()),(0,i.cY)("webterm.provider.daemon.init",{baseUrl:e.baseUrl,hasToken:!!e.token})},[h]),(0,a.useEffect)(()=>{let e=e=>{if("elanous.daemon.token"===e.key||"elanous.nexus.baseUrl"===e.key){let t=(0,s.Fp)();h.updateConfig(t),u(t),(0,i.cY)("webterm.provider.daemon.config-cross-tab",{key:e.key,hasToken:!!t.token});return}"elanous.daemon.sessionId"===e.key&&e.newValue&&x(t=>t===e.newValue?t:((0,i.cY)("webterm.provider.daemon.session-cross-tab",{previous:t||"(empty)",next:e.newValue}),e.newValue))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[h]);let p=e=>{u(t=>{let r={...t,...e};return(0,s.Qc)(e),h.updateConfig(r),(0,i.cY)("webterm.provider.daemon.config-update",{keys:Object.keys(e)}),r})},g=e=>{x(e),localStorage.setItem("elanous.daemon.sessionId",e),(0,i.cY)("webterm.provider.daemon.session-set",{sessionId:e})},f=(0,a.useMemo)(()=>({config:c,setConfig:p,client:h,sessionId:m,setSessionId:g}),[c,h,m]);return(0,n.jsx)(d.Provider,{value:f,children:t})}function u(){let e=(0,a.useContext)(d);if(!e)throw Error("useDaemon must be used inside <DaemonProvider>");return e}},74591:(e,t,r)=>{"use strict";r.d(t,{cn:()=>s});var n=r(49454),a=r(79946);function s(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,a.QP)((0,n.$)(t))}},92590:(e,t,r)=>{Promise.resolve().then(r.bind(r,19785))}},e=>{e.O(0,[7777,3278,5978,8039,9906,6390,3170,7358],()=>e(e.s=92590)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8677],{1355:(e,t,r)=>{"use strict";r.d(t,{Zr:()=>l,f6:()=>a,oD:()=>s});let n="elanous.daemon.sessionId";function a(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():"s-".concat(Date.now().toString(36),"-").concat(Math.random().toString(36).slice(2,10))}function s(){let e=function(){let e=new URLSearchParams(window.location.search).get("session");return e?(localStorage.setItem(n,e),e):localStorage.getItem(n)}();if(e)return e;let t=a();return localStorage.setItem(n,t),t}function l(){let e=a();return localStorage.setItem(n,e),e}},10080:(e,t,r)=>{"use strict";r.d(t,{$:()=>i});var n=r(54456),a=r(80247),s=r(13680),l=r(74591);let o=(0,s.F)("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function i(e){let{className:t,variant:r="default",size:s="default",...i}=e;return(0,n.jsx)(a.$,{"data-slot":"button",className:(0,l.cn)(o({variant:r,size:s,className:t})),...i})}},19785:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>k});var n=r(54456),a=r(60500),s=r(36581),l=r(10080),o=r(31395),i=r(52468),d=r(81573),c=r(15375);let u="wikilink:",m={aliasDivider:"|",pageResolver:e=>[e],hrefTemplate:e=>"".concat(u).concat(encodeURIComponent(e))};function x(e){let{markdown:t,onWikilink:r}=e;return(0,n.jsx)("div",{className:"text-sm text-foreground/90",children:(0,n.jsx)(o.oz,{remarkPlugins:[i.A,c.A,[d.A,m]],components:{h1:e=>{let{children:t}=e;return(0,n.jsx)("h1",{className:"mb-3 mt-5 border-b border-border pb-1 text-2xl font-bold",children:t})},h2:e=>{let{children:t}=e;return(0,n.jsx)("h2",{className:"mb-2 mt-5 text-xl font-bold",children:t})},h3:e=>{let{children:t}=e;return(0,n.jsx)("h3",{className:"mb-2 mt-4 text-lg font-semibold",children:t})},h4:e=>{let{children:t}=e;return(0,n.jsx)("h4",{className:"mb-1 mt-3 text-base font-semibold",children:t})},h5:e=>{let{children:t}=e;return(0,n.jsx)("h5",{className:"mb-1 mt-2 text-sm font-semibold text-muted-foreground",children:t})},h6:e=>{let{children:t}=e;return(0,n.jsx)("h6",{className:"mb-1 mt-2 text-xs font-semibold uppercase text-muted-foreground",children:t})},p:e=>{let{children:t}=e;return(0,n.jsx)("p",{className:"my-2 leading-relaxed",children:t})},ul:e=>{let{children:t}=e;return(0,n.jsx)("ul",{className:"my-2 list-disc space-y-1 pl-6",children:t})},ol:e=>{let{children:t}=e;return(0,n.jsx)("ol",{className:"my-2 list-decimal space-y-1 pl-6",children:t})},li:e=>{let{children:t}=e;return(0,n.jsx)("li",{className:"leading-relaxed",children:t})},blockquote:e=>{let{children:t}=e;return(0,n.jsx)("blockquote",{className:"my-3 border-l-4 border-primary/40 bg-muted/40 py-1 pl-3 text-muted-foreground",children:t})},hr:()=>(0,n.jsx)("hr",{className:"my-4 border-border"}),table:e=>{let{children:t}=e;return(0,n.jsx)("div",{className:"my-3 overflow-x-auto",children:(0,n.jsx)("table",{className:"w-full border-collapse text-sm",children:t})})},thead:e=>{let{children:t}=e;return(0,n.jsx)("thead",{className:"bg-muted/60",children:t})},th:e=>{let{children:t}=e;return(0,n.jsx)("th",{className:"border border-border px-3 py-1.5 text-left font-semibold",children:t})},td:e=>{let{children:t}=e;return(0,n.jsx)("td",{className:"border border-border px-3 py-1.5",children:t})},code:e=>{let{className:t,children:r}=e;return t?(0,n.jsx)("code",{className:"".concat(t," font-mono"),children:r}):(0,n.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[0.85em]",children:r})},pre:e=>{let{children:t}=e;return(0,n.jsx)("pre",{className:"my-3 overflow-x-auto rounded-lg border border-border bg-muted/40 p-3 text-xs",children:t})},img:e=>{let{src:t,alt:r}=e;return(0,n.jsx)("img",{src:"string"==typeof t?t:"",alt:null!=r?r:"",className:"my-2 max-w-full rounded"})},a:e=>{let{href:t,children:a}=e,s=null!=t?t:"";if(s.startsWith(u)){let e=decodeURIComponent(s.slice(u.length));return(0,n.jsx)("button",{type:"button",onClick:()=>null==r?void 0:r(e),className:"text-primary underline decoration-dotted underline-offset-2 hover:decoration-solid",children:a})}return(0,n.jsx)("a",{href:s,target:"_blank",rel:"noreferrer",className:"text-primary underline underline-offset-2",children:a})}},children:t})})}class h{get(e){return this.client.fetchJson(e)}info(){return this.get("/v1/vault/info")}list(e){return this.get("/v1/vault/list".concat(e?"?cwd=".concat(encodeURIComponent(e)):""))}read(e,t){let r=new URLSearchParams({path:e,...t?{maxBytes:String(t)}:{}});return this.get("/v1/vault/read?".concat(r.toString()))}search(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:50;return this.get("/v1/vault/search?q=".concat(encodeURIComponent(e),"&limit=").concat(t))}notes(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;return this.get("/v1/vault/notes?".concat(e?"query=".concat(encodeURIComponent(e),"&"):"","limit=").concat(t))}backlinks(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;return this.get("/v1/vault/backlinks?target=".concat(encodeURIComponent(e),"&limit=").concat(t))}tags(){return this.get("/v1/vault/tags")}templates(){return this.get("/v1/vault/templates")}graph(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500,n=new URLSearchParams({limit:String(r),...e?{focus:e,hops:String(t)}:{}});return this.get("/v1/vault/graph?".concat(n.toString()))}pollChanges(e){return this.get("/v1/vault/poll-changes?sinceMs=".concat(e))}orphans(){return this.get("/v1/vault/orphans")}templateExpand(e,t){return this.client.fetchJson("/v1/vault/template-expand",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({templatePath:e,...t?{title:t}:{}})})}async writeNote(e){var t,r,n,a;let s=await this.client.fetchResponse("/v1/vault/file",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),l=(null!=(t=s.headers.get("content-type"))?t:"").includes("application/json")?await s.json():await s.text();if(!s.ok&&409!==s.status)throw Error(String("string"==typeof l?l:null!=(a=null!=(n=null!=(r=null==l?void 0:l.message)?r:null==l?void 0:l.reason)?n:null==l?void 0:l.error)?a:"".concat(s.status)));return l}async saveNote(e){var t,r,n;let a=await this.client.fetchResponse("/v1/notes/save",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),s=(null!=(t=a.headers.get("content-type"))?t:"").includes("application/json")?await a.json():await a.text();if(!a.ok&&409!==a.status)throw Error(String("string"==typeof s?s:null!=(n=null!=(r=null==s?void 0:s.reason)?r:null==s?void 0:s.error)?n:"".concat(a.status)));return s}constructor(e){this.client=e}}function p(e){let t=/^---\n([\s\S]*?)\n---\n?/.exec(e);return t?{frontmatter:t[1],body:e.slice(t[0].length)}:{frontmatter:null,body:e}}function g(e){let t=e.toLowerCase();return t.endsWith(".md")||t.endsWith(".markdown")?"markdown":/\.(png|jpe?g|gif|webp|svg)$/.test(t)?"image":t.endsWith(".pdf")?"pdf":/\.(txt|json|ya?ml|csv|log)$/.test(t)?"text":"other"}function f(e){let{onPickTag:t}=e,{client:r}=(0,s.Q)(),l=(0,a.useMemo)(()=>new h(r),[r]),[o,i]=(0,a.useState)([]),[d,c]=(0,a.useState)(""),[u,m]=(0,a.useState)(!0),x=(0,a.useCallback)(async()=>{m(!0);try{var e;let t=await l.tags();i((null!=(e=t.tags)?e:[]).sort((e,t)=>t.count-e.count))}catch(e){}finally{m(!1)}},[l]);(0,a.useEffect)(()=>{x()},[x]);let p=d?o.filter(e=>e.tag.toLowerCase().includes(d.toLowerCase())):o;return(0,n.jsxs)("div",{className:"flex h-full flex-col",children:[(0,n.jsx)("div",{className:"border-b border-border p-2",children:(0,n.jsx)("input",{value:d,onChange:e=>c(e.target.value),placeholder:"태그 필터…",className:"w-full rounded border border-border bg-background px-2 py-1 text-xs"})}),(0,n.jsx)("div",{className:"flex-1 overflow-auto p-1",children:u?(0,n.jsx)("p",{className:"p-2 text-xs text-muted-foreground",children:"불러오는 중…"}):0===p.length?(0,n.jsx)("p",{className:"p-2 text-xs text-muted-foreground",children:"태그 없음"}):(0,n.jsx)("ul",{className:"space-y-0.5",children:p.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{onClick:()=>t(e.tag),className:"flex w-full items-center justify-between rounded px-2 py-1 text-left text-xs hover:bg-muted",children:[(0,n.jsxs)("span",{className:"truncate",children:["#",e.tag]}),(0,n.jsx)("span",{className:"ml-2 shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground",children:e.count})]})},e.tag))})})]})}function v(e){var t,r;let{onOpen:o}=e,{client:i}=(0,s.Q)(),d=(0,a.useMemo)(()=>new h(i),[i]),[c,u]=(0,a.useState)(null),[m,x]=(0,a.useState)(null),[p,g]=(0,a.useState)(!0),f=(0,a.useCallback)(async e=>{g(!0);try{u(await d.graph(null!=e?e:void 0,1,e?60:400))}catch(e){}finally{g(!1)}},[d]);(0,a.useEffect)(()=>{f(m)},[f,m]);let v=(0,a.useMemo)(()=>{if(!c)return{nodes:[],edges:[]};let e=c.nodes.map(e=>e.id),t=c.edges.map(e=>({source:e.from,target:e.to}));return{nodes:function(e,t){var r,n,a;let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{width:800,height:600},{width:l,height:o}=s,i=null!=(r=s.iterations)?r:120,d=e.length,c=new Map;for(let e of t)c.set(e.source,(null!=(n=c.get(e.source))?n:0)+1),c.set(e.target,(null!=(a=c.get(e.target))?a:0)+1);let u=l/2,m=o/2,x=.4*Math.min(l,o),h=e.map((e,t)=>{var r;return{id:e,deg:null!=(r=c.get(e))?r:0,x:u+x*Math.cos(2*Math.PI*t/Math.max(1,d)),y:m+x*Math.sin(2*Math.PI*t/Math.max(1,d))}}),p=new Map(h.map((e,t)=>[e.id,t])),g=Math.sqrt(l*o/Math.max(1,d));for(let e=0;e<i;e++){let r=h.map(()=>({x:0,y:0}));for(let e=0;e<d;e++)for(let t=e+1;t<d;t++){let n=h[e].x-h[t].x,a=h[e].y-h[t].y,s=Math.hypot(n,a)||.01,l=g*g/s;n/=s,a/=s,r[e].x+=n*l,r[e].y+=a*l,r[t].x-=n*l,r[t].y-=a*l}for(let e of t){let t=p.get(e.source),n=p.get(e.target);if(null==t||null==n)continue;let a=h[t].x-h[n].x,s=h[t].y-h[n].y,l=Math.hypot(a,s)||.01,o=l*l/g;a/=l,s/=l,r[t].x-=a*o,r[t].y-=s*o,r[n].x+=a*o,r[n].y+=s*o}let n=1-e/i;for(let e=0;e<d;e++){let t=Math.hypot(r[e].x,r[e].y)||.01,a=Math.min(t,30*n);h[e].x=Math.max(20,Math.min(l-20,h[e].x+r[e].x/t*a)),h[e].y=Math.max(20,Math.min(o-20,h[e].y+r[e].y/t*a))}}return h}(e,t,{width:900,height:640,iterations:140}),edges:t}},[c]),b=(0,a.useMemo)(()=>new Map(v.nodes.map(e=>[e.id,e])),[v]),y=Math.max(1,...v.nodes.map(e=>e.deg));return(0,n.jsxs)("div",{className:"flex h-full flex-col",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2 text-sm",children:[(0,n.jsx)("span",{className:"font-medium",children:"노트 그래프"}),m?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:["focus: ",m," (1-hop)"]}),(0,n.jsx)(l.$,{size:"sm",variant:"outline",className:"ml-auto h-6 px-2 text-xs",onClick:()=>x(null),children:"전체 그래프"})]}):(0,n.jsxs)("span",{className:"ml-auto text-xs text-muted-foreground",children:[null!=(t=null==c?void 0:c.nodes.length)?t:0," 노드 \xb7 ",null!=(r=null==c?void 0:c.edges.length)?r:0," 링크",(null==c?void 0:c.truncated)?" (일부)":""]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto p-2",children:p?(0,n.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:"그래프 계산 중…"}):c&&0!==c.nodes.length?(0,n.jsxs)("svg",{viewBox:"0 0 ".concat(900," ").concat(640),className:"h-auto w-full",style:{maxHeight:"78vh"},children:[v.edges.map((e,t)=>{let r=b.get(e.source),a=b.get(e.target);return r&&a?(0,n.jsx)("line",{x1:r.x,y1:r.y,x2:a.x,y2:a.y,stroke:"currentColor",className:"text-border",strokeWidth:.6,opacity:.5},t):null}),v.nodes.map(e=>{let t=3+e.deg/y*9;return(0,n.jsxs)("g",{className:"cursor-pointer",onClick:()=>null==o?void 0:o(e.id),onDoubleClick:()=>x(e.id),children:[(0,n.jsx)("circle",{cx:e.x,cy:e.y,r:t,className:"fill-primary/70 hover:fill-primary"}),(e.deg>=.3*y||m)&&(0,n.jsx)("text",{x:e.x+t+2,y:e.y+3,className:"fill-foreground/70 text-[9px]",children:e.id.split("/").pop()})]},e.id)})]}):(0,n.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:"그래프가 비어있습니다."})}),(0,n.jsx)("p",{className:"border-t border-border px-3 py-1 text-[11px] text-muted-foreground",children:"클릭=노트 열기 \xb7 더블클릭=로컬 그래프(focus)"})]})}function b(e){let{onClose:t,onCreated:r}=e,{client:o}=(0,s.Q)(),i=(0,a.useMemo)(()=>new h(o),[o]),[d,c]=(0,a.useState)(""),[u,m]=(0,a.useState)([]),[x,p]=(0,a.useState)(""),[g,f]=(0,a.useState)(!1),[v,b]=(0,a.useState)(null);(0,a.useEffect)(()=>{i.templates().then(e=>{var t;return m(null!=(t=e.templates)?t:[])}).catch(()=>{})},[i]);let y=(0,a.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};f(!0),b(null);try{let t=e.daily?function(){let e=new Date;return"".concat(e.getFullYear(),"-").concat(String(e.getMonth()+1).padStart(2,"0"),"-").concat(String(e.getDate()).padStart(2,"0"))}():d.trim();if(!t){b("제목을 입력하세요"),f(!1);return}let n="# ".concat(t,"\n\n");if(x){let e=await i.templateExpand(x,t);e.content&&(n=e.content)}else e.daily&&(n="# ".concat(t,"\n\n## 오늘\n\n- \n"));let a=e.daily?"Daily/".concat(t,".md"):"".concat(t,".md"),s=await i.writeNote({path:a,content:n,createOnly:!0});if(s.error){b("file_exists"===s.error?"이미 존재하는 노트입니다":s.error),f(!1);return}r(a)}catch(e){b(e instanceof Error?e.message:String(e)),f(!1)}},[i,d,x,r]);return(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:t,children:(0,n.jsxs)("div",{className:"w-[420px] rounded-lg border border-border bg-card p-4 shadow-xl",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{className:"mb-3 text-sm font-semibold",children:"새 노트"}),(0,n.jsx)("input",{value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&y()},placeholder:"노트 제목…",autoFocus:!0,className:"mb-2 w-full rounded border border-border bg-background px-3 py-2 text-sm"}),u.length>0&&(0,n.jsxs)("select",{value:x,onChange:e=>p(e.target.value),className:"mb-2 w-full rounded border border-border bg-background px-2 py-1.5 text-sm",children:[(0,n.jsx)("option",{value:"",children:"템플릿 없음"}),u.map(e=>(0,n.jsx)("option",{value:e.relPath,children:e.name},e.relPath))]}),v&&(0,n.jsx)("p",{className:"mb-2 text-xs text-rose-400",children:v}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(l.$,{size:"sm",onClick:()=>void y(),disabled:g||!d.trim(),children:"생성"}),(0,n.jsx)(l.$,{size:"sm",variant:"outline",onClick:()=>void y({daily:!0}),disabled:g,children:"오늘 데일리노트"}),(0,n.jsx)(l.$,{size:"sm",variant:"ghost",className:"ml-auto",onClick:t,children:"취소"})]})]})})}let y="elanous.pwa.vaultTreeOpen";function j(e){let{onEdit:t}=e,{client:r}=(0,s.Q)(),o=(0,a.useMemo)(()=>new h(r),[r]),[i,d]=(0,a.useState)(null),[c,u]=(0,a.useState)(""),[m,x]=(0,a.useState)([]),[p,j]=(0,a.useState)(null),[N,k]=(0,a.useState)(null),[C,S]=(0,a.useState)(""),[M,z]=(0,a.useState)(null),[D,E]=(0,a.useState)(!1),[I,P]=(0,a.useState)("view"),[U,R]=(0,a.useState)("files"),[$,_]=(0,a.useState)(!1),[O,T]=(0,a.useState)(0),[q,F]=(0,a.useState)(!0);(0,a.useEffect)(()=>{F(function(e){try{return(null==e?void 0:e.getItem(y))!=="0"}catch(e){return!0}}(window.localStorage))},[]);let L=(0,a.useCallback)(()=>{F(e=>{let t=!e;var r=window.localStorage;try{null==r||r.setItem(y,t?"1":"0")}catch(e){}return t})},[]);(0,a.useEffect)(()=>{let e=Date.now(),t=setInterval(()=>{o.pollChanges(e).then(e=>{var t;return T(null!=(t=e.count)?t:0)}).catch(()=>{})},3e4);return()=>clearInterval(t)},[o]);let K=(0,a.useCallback)(e=>{S("#".concat(e)),R("files"),(async()=>{E(!0);try{var t;let r=await o.search("#".concat(e),50);z(null!=(t=r.matches)?t:[])}catch(e){z([])}finally{E(!1)}})()},[o]),Q=(0,a.useCallback)(async e=>{E(!0),z(null);try{let t=await o.list(e||void 0);t.error||(x(t.entries),u(t.cwd))}catch(e){}finally{E(!1)}},[o]);(0,a.useEffect)(()=>{let e=!0;return o.info().then(t=>{e&&(d(t),t.available&&Q(""))}).catch(()=>{}),()=>{e=!1}},[o,Q]);let W=(0,a.useCallback)(async e=>{j(e),k(null),window.innerWidth<=767&&F(!1);try{k(await o.read(e))}catch(e){}},[o]),A=(0,a.useCallback)(async()=>{let e=C.trim();if(!e)return void z(null);E(!0);try{var t;let r=await o.search(e,50);z(null!=(t=r.matches)?t:[])}catch(e){z([])}finally{E(!1)}},[o,C]),V=c&&(null==i?void 0:i.root)?c.replace(i.root,"").split("/").filter(Boolean):[],Y=(null==i?void 0:i.root)?c.replace(i.root,"").replace(/^\//,""):"";return i&&!i.available?(0,n.jsxs)("div",{className:"p-6 text-sm text-muted-foreground",children:["Obsidian vault를 찾을 수 없습니다 (source: ",i.source,"). ~/.elanous/config.json 의 obsidian.vault 를 확인하세요."]}):(0,n.jsxs)("div",{className:"mx-auto flex h-[calc(100vh-3rem)] max-w-[1920px] gap-3 px-3 py-3",children:[$&&(0,n.jsx)(b,{onClose:()=>_(!1),onCreated:e=>{_(!1),Q(""),null==t||t(e)}}),(0,n.jsxs)("div",{"data-testid":"vault-tree",className:[q?"flex":"hidden","w-full shrink-0 flex-col rounded-lg border border-border bg-card/40 md:w-64 lg:w-72"].join(" "),children:[(0,n.jsxs)("div",{className:"flex items-center gap-1 border-b border-border px-2 py-1.5",children:[["files","tags","graph"].map(e=>(0,n.jsx)("button",{onClick:()=>R(e),className:["rounded px-2 py-0.5 text-xs",U===e?"bg-primary/20 text-foreground":"text-muted-foreground"].join(" "),children:{files:"파일",tags:"태그",graph:"그래프"}[e]},e)),O>0&&(0,n.jsxs)("span",{className:"rounded bg-amber-500/15 px-1.5 py-0.5 text-[10px] text-amber-300",title:"외부 변경 감지",children:["↻ ",O]}),(0,n.jsx)(l.$,{size:"sm",variant:"outline",className:"ml-auto h-6 px-2 text-xs",onClick:()=>_(!0),children:"+ 새 노트"})]}),"graph"===U?(0,n.jsx)(v,{onOpen:e=>{R("files"),W("".concat(e,".md"))}}):"tags"===U?(0,n.jsx)(f,{onPickTag:K}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"border-b border-border p-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{value:C,onChange:e=>S(e.target.value),onKeyDown:e=>{"Enter"===e.key&&A()},placeholder:"vault 전문검색…",className:"min-w-0 flex-1 rounded border border-border bg-background px-2 py-1 text-sm"}),(0,n.jsx)(l.$,{size:"sm",variant:"outline",onClick:()=>void A(),children:"검색"})]}),!M&&(0,n.jsxs)("div",{className:"mt-1.5 flex flex-wrap items-center gap-1 text-xs text-muted-foreground",children:[(0,n.jsx)("button",{className:"hover:text-foreground",onClick:()=>void Q(""),children:"vault"}),V.map((e,t)=>(0,n.jsxs)("span",{children:["/ ",(0,n.jsx)("button",{className:"hover:text-foreground",onClick:()=>void Q("".concat(i.root,"/").concat(V.slice(0,t+1).join("/"))),children:e})]},t))]})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-auto p-1",children:[D&&(0,n.jsx)("p",{className:"p-2 text-xs text-muted-foreground",children:"불러오는 중…"}),M?0===M.length?(0,n.jsx)("p",{className:"p-2 text-xs text-muted-foreground",children:"검색 결과 없음"}):(0,n.jsx)("ul",{className:"space-y-1",children:M.map((e,t)=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{className:"w-full rounded px-2 py-1.5 text-left text-xs hover:bg-muted",onClick:()=>void W(e.path),children:[(0,n.jsx)("span",{className:"font-medium",children:e.path.split("/").pop()})," ",(0,n.jsxs)("span",{className:"text-muted-foreground",children:[":",e.lineNumber]}),(0,n.jsx)("div",{className:"truncate text-muted-foreground",children:e.snippet})]})},t))}):(0,n.jsxs)("ul",{children:[Y&&(0,n.jsx)("li",{children:(0,n.jsx)("button",{className:"w-full rounded px-2 py-1.5 text-left text-sm text-muted-foreground hover:bg-muted",onClick:()=>void Q("".concat(i.root,"/").concat(function(e){let t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}(Y))),children:"\uD83D\uDCC1 .."})}),m.map(e=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{className:["flex w-full items-center gap-1.5 rounded px-2 py-1.5 text-left text-sm hover:bg-muted",p==="".concat(Y?Y+"/":"").concat(e.name)?"bg-muted":""].join(" "),onClick:()=>e.isDir?void Q("".concat(c,"/").concat(e.name)):void W("".concat(Y?Y+"/":"").concat(e.name)),children:[(0,n.jsx)("span",{children:e.isDir?"\uD83D\uDCC1":"markdown"===g(e.name)?"\uD83D\uDCDD":"image"===g(e.name)?"\uD83D\uDDBC️":"\uD83D\uDCC4"}),(0,n.jsx)("span",{className:"truncate",children:e.name})]})},e.relPath))]})]})]})]}),(0,n.jsxs)("div",{className:[q?"hidden md:flex":"flex","min-w-0 flex-1 flex-col rounded-lg border border-border bg-card/40"].join(" "),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("button",{type:"button",onClick:L,"aria-expanded":q,"aria-label":q?"폴더 접기":"폴더 펴기",title:q?"폴더 접기":"폴더 펴기",className:"shrink-0 rounded px-1.5 py-0.5 text-xs text-muted-foreground ring-1 ring-border hover:text-foreground",children:q?"◀ 폴더":"▶ 폴더"}),(0,n.jsx)("span",{className:"truncate text-sm font-medium",children:null!=p?p:"파일을 선택하세요"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[p&&"markdown"===g(p)&&(0,n.jsx)("div",{className:"flex items-center gap-0.5 rounded ring-1 ring-border",children:["view","raw"].map(e=>(0,n.jsx)("button",{onClick:()=>P(e),className:["px-2 py-0.5 text-xs",I===e?"bg-primary/20 text-foreground":"text-muted-foreground"].join(" "),children:"view"===e?"View":"Raw"},e))}),p&&"markdown"===g(p)&&t&&(0,n.jsx)(l.$,{size:"sm",variant:"outline",onClick:()=>t(p),children:"편집"})]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto p-4",children:N?(0,n.jsx)(w,{preview:N,selected:p,mode:I,onWikilink:e=>{W("".concat(Y?Y+"/":"").concat(e,".md"))}}):(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:p?"로딩…":"좌측에서 노트를 선택하면 여기에 표시됩니다."})})]})]})}function w(e){let{preview:t,selected:r,mode:a,onWikilink:s}=e;if(t.error)return(0,n.jsx)("p",{className:"text-sm text-rose-400",children:t.error});let l=g(r);if("image"===l&&t.bytes)return(0,n.jsx)("img",{src:"data:".concat(t.mime,";base64,").concat(t.bytes),alt:r,className:"max-w-full rounded"});if("markdown"===l&&null!=t.content){let{frontmatter:e,body:r}=p(t.content);return"raw"===a?(0,n.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed",children:t.content}):(0,n.jsxs)("div",{children:[e&&(0,n.jsx)("pre",{className:"mb-3 rounded bg-muted/40 p-2 text-[11px] text-muted-foreground",children:e}),(0,n.jsx)(x,{markdown:r,onWikilink:s}),t.truncated&&(0,n.jsxs)("p",{className:"mt-2 text-xs text-amber-400",children:["⚠ 일부만 표시됨(",(t.size/1024).toFixed(0),"KB)"]})]})}return null!=t.content?(0,n.jsx)("pre",{className:"whitespace-pre-wrap text-sm",children:t.content}):(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["미리보기 불가(",t.mime,")"]})}function N(e){let{path:t,onClose:r}=e,{client:o}=(0,s.Q)(),i=(0,a.useMemo)(()=>new h(o),[o]),[d,c]=(0,a.useState)(""),[u,m]=(0,a.useState)(!1),[g,f]=(0,a.useState)("split"),[v,b]=(0,a.useState)("clean"),[y,j]=(0,a.useState)(null),w=(0,a.useRef)(void 0),N=(0,a.useRef)(null),k=(0,a.useRef)(null),[C,S]=(0,a.useState)("outline"),[M,z]=(0,a.useState)([]),[D,E]=(0,a.useState)(null),I=(0,a.useMemo)(()=>(function(e){let t=[],r=!1;return e.split("\n").forEach((e,n)=>{let a=e.trimEnd();if(/^```/.test(a.trim())){r=!r;return}if(r)return;let s=/^(#{1,6})\s+(.+)$/.exec(a);s&&t.push({level:s[1].length,text:s[2].trim(),line:n})}),t})(p(d).body),[d]);(0,a.useEffect)(()=>{let e=!0;return i.read(t,8388608).then(t=>{var r;e&&(c(null!=(r=t.content)?r:""),w.current=t.mtimeMs,m(!0),b("clean"))}).catch(()=>{e&&(j("노트를 불러오지 못했습니다"),m(!0))}),()=>{e=!1,N.current&&clearTimeout(N.current)}},[i,t]);let P=(0,a.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d;b("saving"),j(null);try{let n=await i.writeNote({path:t,content:r,...e?{}:null!=w.current?{lastKnownMtime:w.current}:{}});if("mtime_conflict"===n.error||n.error&&null!=n.currentMtime)return void b("conflict");if(n.error){b("error"),j(n.error);return}null!=n.mtimeMs&&(w.current=n.mtimeMs),b("saved")}catch(e){b("error"),j(e instanceof Error?e.message:String(e))}},[i,t,d]);(0,a.useEffect)(()=>{var e;let r=!0;return i.backlinks((null!=(e=t.split("/").pop())?e:t).replace(/\.md$/i,""),100).then(e=>{var t;r&&z(null!=(t=e.matches)?t:[])}).catch(()=>{}),()=>{r=!1}},[i,t]);let U=(0,a.useCallback)((e,t)=>{let r=function(e,t){let r=e.slice(0,t),n=r.lastIndexOf("[[");if(n<0)return null;let a=r.slice(n+2);return a.includes("]]")||a.includes("\n")?null:{query:a,start:n+2}}(e,t);if(!r)return void E(null);i.notes(r.query||void 0,8).then(e=>{var n;E({query:r.query,start:r.start,caret:t,items:(null!=(n=e.notes)?n:[]).slice(0,8)})}).catch(()=>E(null))},[i]),R=(0,a.useCallback)((e,t)=>{c(e),b("dirty"),U(e,t),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{P(!1,e)},2500)},[P,U]),$=(0,a.useCallback)(e=>{if(!D)return;let t=function(e,t,r,n){let a=e.slice(0,t),s=e.slice(r),l="".concat(n,"]]");return{text:a+l+s,caret:a.length+l.length}}(d,D.start,D.caret,e.name);c(t.text),b("dirty"),E(null),requestAnimationFrame(()=>{k.current&&(k.current.focus(),k.current.setSelectionRange(t.caret,t.caret))})},[D,d]),_=(0,a.useCallback)(e=>{let t=k.current;if(!t)return;let r=d.split("\n").slice(0,e).join("\n").length;t.focus(),t.setSelectionRange(r,r),t.scrollTop=Math.max(0,20*e-100)},[d]),O=p(d).body;return u?(0,n.jsxs)("div",{className:"mx-auto flex h-[calc(100vh-3rem)] max-w-[1500px] flex-col px-3 py-3",children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,n.jsx)(l.$,{size:"sm",variant:"ghost",onClick:r,children:"← 목록"}),(0,n.jsx)("span",{className:"truncate text-sm font-medium",children:t}),(0,n.jsx)("span",{className:["ml-2 rounded px-2 py-0.5 text-xs",{clean:"text-muted-foreground",dirty:"text-amber-400",saving:"text-sky-400",saved:"text-emerald-400",conflict:"text-rose-400",error:"text-rose-400"}[v]].join(" "),children:{clean:"저장됨",dirty:"● 편집 중",saving:"저장 중…",saved:"✓ 저장됨",conflict:"⚠ 충돌",error:"✗ 오류"}[v]}),(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[["edit","split","preview"].map(e=>(0,n.jsx)("button",{onClick:()=>f(e),className:["rounded px-2 py-1 text-xs ring-1",g===e?"bg-primary/20 ring-primary/40":"bg-muted text-muted-foreground ring-border"].join(" "),children:{edit:"편집",split:"분할",preview:"미리보기"}[e]},e)),(0,n.jsx)(l.$,{size:"sm",variant:"outline",onClick:()=>void P(!1),children:"저장"})]})]}),"conflict"===v&&(0,n.jsxs)("div",{className:"mb-2 flex items-center gap-2 rounded border border-rose-500/40 bg-rose-500/10 px-3 py-2 text-xs text-rose-200",children:[(0,n.jsx)("span",{children:"디스크의 노트가 외부에서 변경됐습니다."}),(0,n.jsx)(l.$,{size:"sm",variant:"outline",onClick:()=>void P(!0),children:"강제 덮어쓰기"}),(0,n.jsx)(l.$,{size:"sm",variant:"ghost",onClick:()=>void i.read(t,8388608).then(e=>{var t;c(null!=(t=e.content)?t:""),w.current=e.mtimeMs,b("clean")}),children:"디스크 버전 로드"})]}),y&&(0,n.jsx)("div",{className:"mb-2 text-xs text-rose-400",children:y}),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 gap-3",children:["preview"!==g&&(0,n.jsxs)("div",{className:"relative min-h-0 flex-1",children:[(0,n.jsx)("textarea",{ref:k,value:d,onChange:e=>R(e.target.value,e.target.selectionStart),onKeyUp:e=>U(d,e.target.selectionStart),onClick:e=>U(d,e.target.selectionStart),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&(e.preventDefault(),P(!1)),"Escape"===e.key&&D&&(e.preventDefault(),E(null)),"Enter"===e.key&&D&&D.items.length&&(e.preventDefault(),$(D.items[0]))},className:"h-full min-h-0 w-full resize-none rounded-lg border border-border bg-background p-3 font-mono text-sm leading-relaxed focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}),D&&D.items.length>0&&(0,n.jsxs)("div",{className:"absolute left-3 top-3 z-20 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover shadow-lg",children:[(0,n.jsxs)("div",{className:"border-b border-border px-2 py-1 text-[11px] text-muted-foreground",children:["[[wikilink: ",D.query||"…"]}),D.items.map(e=>(0,n.jsxs)("button",{className:"block w-full truncate px-2 py-1.5 text-left text-xs hover:bg-muted",onMouseDown:t=>{t.preventDefault(),$(e)},children:[(0,n.jsx)("span",{className:"font-medium",children:e.name})," ",(0,n.jsx)("span",{className:"text-muted-foreground",children:e.relPath})]},e.relPath))]})]}),"edit"!==g&&(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-auto rounded-lg border border-border bg-card/40 p-4",children:(0,n.jsx)(x,{markdown:O})}),(0,n.jsxs)("div",{className:"flex w-[220px] min-w-[180px] flex-col rounded-lg border border-border bg-card/40",children:[(0,n.jsx)("div",{className:"flex border-b border-border text-xs",children:["outline","backlinks"].map(e=>(0,n.jsx)("button",{onClick:()=>S(e),className:["flex-1 px-2 py-1.5",C===e?"border-b-2 border-primary text-foreground":"text-muted-foreground"].join(" "),children:"outline"===e?"개요":"역참조 ".concat(M.length?"(".concat(M.length,")"):"")},e))}),(0,n.jsx)("div",{className:"flex-1 overflow-auto p-1 text-xs",children:"outline"===C?0===I.length?(0,n.jsx)("p",{className:"p-2 text-muted-foreground",children:"heading 없음"}):I.map((e,t)=>(0,n.jsx)("button",{onClick:()=>_(e.line),className:"block w-full truncate rounded px-2 py-1 text-left hover:bg-muted",style:{paddingLeft:"".concat(8*e.level,"px")},children:e.text},t)):0===M.length?(0,n.jsx)("p",{className:"p-2 text-muted-foreground",children:"역참조 없음"}):M.map((e,t)=>(0,n.jsxs)("div",{className:"truncate rounded px-2 py-1",title:e.snippet,children:["\uD83D\uDCCE ",e.path.split("/").pop(),e.headingAnchor?" #".concat(e.headingAnchor):""]},t))})]})]})]}):(0,n.jsx)("div",{className:"p-6 text-sm text-muted-foreground",children:"노트 로딩…"})}function k(){let[e,t]=(0,a.useState)(null);return e?(0,n.jsx)(N,{path:e,onClose:()=>t(null)}):(0,n.jsx)(j,{onEdit:e=>t(e)})}},36581:(e,t,r)=>{"use strict";r.d(t,{C:()=>d,DaemonProvider:()=>c,Q:()=>u});var n=r(54456),a=r(60500),s=r(86704),l=r(1355),o=r(39906),i=r(50733);let d=(0,a.createContext)(null);function c(e){let{children:t}=e,r={baseUrl:"",token:"",provider:""},[c,u]=(0,a.useState)(r),[m,x]=(0,a.useState)(""),[h]=(0,a.useState)(()=>new o.ki(r));(0,a.useEffect)(()=>{let e=(0,s.Fp)();u(e),h.updateConfig(e),x((0,l.oD)()),(0,i.cY)("webterm.provider.daemon.init",{baseUrl:e.baseUrl,hasToken:!!e.token})},[h]),(0,a.useEffect)(()=>{let e=e=>{if("elanous.daemon.token"===e.key||"elanous.nexus.baseUrl"===e.key){let t=(0,s.Fp)();h.updateConfig(t),u(t),(0,i.cY)("webterm.provider.daemon.config-cross-tab",{key:e.key,hasToken:!!t.token});return}"elanous.daemon.sessionId"===e.key&&e.newValue&&x(t=>t===e.newValue?t:((0,i.cY)("webterm.provider.daemon.session-cross-tab",{previous:t||"(empty)",next:e.newValue}),e.newValue))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[h]);let p=e=>{u(t=>{let r={...t,...e};return(0,s.Qc)(e),h.updateConfig(r),(0,i.cY)("webterm.provider.daemon.config-update",{keys:Object.keys(e)}),r})},g=e=>{x(e),localStorage.setItem("elanous.daemon.sessionId",e),(0,i.cY)("webterm.provider.daemon.session-set",{sessionId:e})},f=(0,a.useMemo)(()=>({config:c,setConfig:p,client:h,sessionId:m,setSessionId:g}),[c,h,m]);return(0,n.jsx)(d.Provider,{value:f,children:t})}function u(){let e=(0,a.useContext)(d);if(!e)throw Error("useDaemon must be used inside <DaemonProvider>");return e}},44892:(e,t,r)=>{Promise.resolve().then(r.bind(r,19785))},74591:(e,t,r)=>{"use strict";r.d(t,{cn:()=>s});var n=r(49454),a=r(79946);function s(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,a.QP)((0,n.$)(t))}}},e=>{e.O(0,[7777,3278,5978,8039,9906,6390,3170,7358],()=>e(e.s=44892)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4191],{42250:(e,t,s)=>{Promise.resolve().then(s.bind(s,97951))},60287:(e,t,s)=>{"use strict";async function n(e){var t,s;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=null!=(t=n.fetchImpl)?t:fetch,r="".concat(null!=(s=n.origin)?s:"","/v1/workflows/").concat(encodeURIComponent(e),"/chat-config"),o=await a(r);if(404===o.status)return null;if(!o.ok)throw Error("chat-config ".concat(o.status));return await o.json()}async function a(e){var t,s,n,a,o;let i=null!=(t=e.fetchImpl)?t:fetch,l="".concat(null!=(s=e.origin)?s:"","/v1/workflows/chat").concat(e.chatPath),c={"content-type":"application/json"};e.bearer&&e.bearer.length>0&&(c.authorization="Bearer ".concat(e.bearer));let d={message:e.message};e.sessionId&&(d.sessionId=e.sessionId);let u=await i(l,{method:"POST",headers:c,body:JSON.stringify(d),...e.signal?{signal:e.signal}:{}});if(!u.ok){let e=await u.text().catch(()=>"");throw Error("chat ".concat(u.status).concat(e?": "+e:""))}if((null!=(n=u.headers.get("content-type"))?n:"").includes("text/event-stream")&&u.body)return{kind:"streaming",frames:r(u.body)};let h=await u.json();return{kind:"buffered",response:null!=(a=h.response)?a:"",runId:null!=(o=h.runId)?o:""}}async function*r(e){let t=e.getReader(),s=new TextDecoder,n="";try{for(;;){let{value:e,done:a}=await t.read();if(a)break;let r=(n+=s.decode(e,{stream:!0})).indexOf("\n\n");for(;-1!==r;){let e=n.slice(0,r);n=n.slice(r+2);let t=o(e);t&&(yield t),r=n.indexOf("\n\n")}}if(n.trim().length>0){let e=o(n);e&&(yield e)}}finally{t.releaseLock()}}function o(e){let t="message",s=[];for(let n of e.split("\n")){let e=n.endsWith("\r")?n.slice(0,-1):n;if(e.startsWith(":"))continue;let a=e.indexOf(":");if(-1===a)continue;let r=e.slice(0,a),o=e.slice(a+1).replace(/^ /,"");"event"===r?t=o:"data"===r&&s.push(o)}return 0===s.length?null:{event:t,data:s.join("\n")}}s.d(t,{XQ:()=>n,gJ:()=>a})},80581:(e,t,s)=>{"use strict";var n=s(35793);s.o(n,"useParams")&&s.d(t,{useParams:function(){return n.useParams}}),s.o(n,"usePathname")&&s.d(t,{usePathname:function(){return n.usePathname}}),s.o(n,"useRouter")&&s.d(t,{useRouter:function(){return n.useRouter}}),s.o(n,"useSearchParams")&&s.d(t,{useSearchParams:function(){return n.useSearchParams}})},97951:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>l});var n=s(54456),a=s(60500),r=s(80581),o=s(60287);function i(){var e,t;let s=(0,r.useSearchParams)(),i=null!=(e=s.get("workflow"))?e:"",l=null!=(t=s.get("token"))?t:"",[c,d]=(0,a.useState)({kind:"loading"}),[u,h]=(0,a.useState)([]),[f,m]=(0,a.useState)(""),[x,g]=(0,a.useState)(!1),[p]=(0,a.useState)(()=>"hosted-".concat(Date.now().toString(36),"-").concat(Math.random().toString(16).slice(2,6))),w=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=!1;return 0===i.length?void d({kind:"error",reason:"missing ?workflow= query param"}):((0,o.XQ)(i).then(t=>{e||(t?d({kind:"ready",config:t}):d({kind:"not-found"}))}).catch(t=>{e||d({kind:"error",reason:t instanceof Error?t.message:String(t)})}),()=>{e=!0})},[i]),(0,a.useEffect)(()=>{w.current&&(w.current.scrollTop=w.current.scrollHeight)},[u]);let b=async()=>{if("ready"!==c.kind||x)return;let e=f.trim();if(0===e.length)return;let t={id:"u-".concat(Date.now()),role:"user",text:e},s="a-".concat(Date.now());h(e=>[...e,t,{id:s,role:"assistant",text:"",pending:!0}]),m(""),g(!0);try{let t=await (0,o.gJ)({chatPath:c.config.path,message:e,sessionId:"per-session"===c.config.sessionMode?p:void 0,bearer:l.length>0?l:void 0,streaming:c.config.streaming});if("buffered"===t.kind)h(e=>e.map(e=>e.id===s?{...e,text:t.response,pending:!1}:e));else for await(let e of t.frames)if("token"===e.event)h(t=>t.map(t=>t.id===s?{...t,text:t.text+e.data}:t));else if("done"===e.event){let t;try{t=JSON.parse(e.data).response}catch(e){}h(e=>e.map(e=>e.id===s?{...e,text:null!=t?t:e.text,pending:!1}:e))}else"error"===e.event&&h(t=>t.map(t=>t.id===s?{...t,text:t.text+"\n[error: ".concat(e.data,"]"),pending:!1,role:"system"}:t))}catch(t){let e=t instanceof Error?t.message:String(t);h(t=>t.map(t=>t.id===s?{...t,text:"[error: ".concat(e,"]"),pending:!1,role:"system"}:t))}finally{g(!1)}};return"loading"===c.kind?(0,n.jsx)("div",{className:"p-6 text-sm text-slate-500",children:"Loading workflow chat…"}):"not-found"===c.kind?(0,n.jsxs)("div",{className:"p-6 text-sm",children:[(0,n.jsx)("h1",{className:"text-lg font-medium mb-2",children:"Workflow not found"}),(0,n.jsxs)("p",{className:"text-slate-600",children:["The workflow ",(0,n.jsx)("code",{className:"px-1 bg-slate-100 rounded",children:i})," is not available for hosted chat. The workflow author needs to add",(0,n.jsxs)("code",{className:"px-1 bg-slate-100 rounded ml-1",children:["hostedUi: ","{"," enabled: true ","}"]}),"to the chat trigger node."]})]}):"error"===c.kind?(0,n.jsxs)("div",{className:"p-6 text-sm",children:[(0,n.jsx)("h1",{className:"text-lg font-medium mb-2 text-red-600",children:"Connection error"}),(0,n.jsx)("p",{className:"text-slate-600",children:c.reason})]}):(0,n.jsxs)("div",{className:"flex flex-col h-screen max-w-2xl mx-auto px-4",children:[(0,n.jsxs)("header",{className:"py-3 border-b",children:[(0,n.jsx)("h1",{className:"text-base font-medium",children:c.config.workflowName}),(0,n.jsxs)("p",{className:"text-xs text-slate-500",children:[c.config.streaming?"streaming":"buffered"," \xb7 ",c.config.sessionMode,c.config.hostedUi.requiresBearer?" \xb7 bearer required":""]})]}),c.config.hostedUi.requiresBearer&&l.length>0?(0,n.jsx)("div",{className:"text-xs px-3 py-2 bg-amber-50 border-b border-amber-200 text-amber-800",children:"⚠ The bearer token is embedded in this URL. Treat this link as a secret — sharing the URL gives anyone full access to the workflow."}):null,(0,n.jsxs)("div",{ref:w,className:"flex-1 overflow-y-auto py-4 space-y-3",children:[0===u.length?(0,n.jsx)("p",{className:"text-sm text-slate-400 italic",children:"Type a message to start the conversation."}):null,u.map(e=>(0,n.jsxs)("div",{className:"text-sm",children:[(0,n.jsxs)("div",{className:"font-medium text-xs uppercase text-slate-500",children:[e.role,e.pending?" \xb7 typing…":null]}),(0,n.jsx)("pre",{className:"whitespace-pre-wrap font-sans text-slate-800",children:e.text})]},e.id))]}),(0,n.jsxs)("div",{className:"py-3 border-t flex gap-2",children:[(0,n.jsx)("input",{className:"flex-1 px-3 py-2 border rounded text-sm",value:f,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),b())},placeholder:"Message…",disabled:x}),(0,n.jsx)("button",{type:"button",onClick:()=>void b(),disabled:x||0===f.trim().length,className:"px-4 py-2 bg-slate-900 text-white rounded text-sm disabled:opacity-50",children:"Send"})]})]})}function l(){return(0,n.jsx)(a.Suspense,{fallback:(0,n.jsx)("div",{className:"p-6 text-sm text-slate-500",children:"Loading workflow chat…"}),children:(0,n.jsx)(i,{})})}}},e=>{e.O(0,[6390,3170,7358],()=>e(e.s=42250)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4191],{60287:(e,t,s)=>{"use strict";async function n(e){var t,s;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=null!=(t=n.fetchImpl)?t:fetch,r="".concat(null!=(s=n.origin)?s:"","/v1/workflows/").concat(encodeURIComponent(e),"/chat-config"),o=await a(r);if(404===o.status)return null;if(!o.ok)throw Error("chat-config ".concat(o.status));return await o.json()}async function a(e){var t,s,n,a,o;let i=null!=(t=e.fetchImpl)?t:fetch,l="".concat(null!=(s=e.origin)?s:"","/v1/workflows/chat").concat(e.chatPath),c={"content-type":"application/json"};e.bearer&&e.bearer.length>0&&(c.authorization="Bearer ".concat(e.bearer));let d={message:e.message};e.sessionId&&(d.sessionId=e.sessionId);let u=await i(l,{method:"POST",headers:c,body:JSON.stringify(d),...e.signal?{signal:e.signal}:{}});if(!u.ok){let e=await u.text().catch(()=>"");throw Error("chat ".concat(u.status).concat(e?": "+e:""))}if((null!=(n=u.headers.get("content-type"))?n:"").includes("text/event-stream")&&u.body)return{kind:"streaming",frames:r(u.body)};let h=await u.json();return{kind:"buffered",response:null!=(a=h.response)?a:"",runId:null!=(o=h.runId)?o:""}}async function*r(e){let t=e.getReader(),s=new TextDecoder,n="";try{for(;;){let{value:e,done:a}=await t.read();if(a)break;let r=(n+=s.decode(e,{stream:!0})).indexOf("\n\n");for(;-1!==r;){let e=n.slice(0,r);n=n.slice(r+2);let t=o(e);t&&(yield t),r=n.indexOf("\n\n")}}if(n.trim().length>0){let e=o(n);e&&(yield e)}}finally{t.releaseLock()}}function o(e){let t="message",s=[];for(let n of e.split("\n")){let e=n.endsWith("\r")?n.slice(0,-1):n;if(e.startsWith(":"))continue;let a=e.indexOf(":");if(-1===a)continue;let r=e.slice(0,a),o=e.slice(a+1).replace(/^ /,"");"event"===r?t=o:"data"===r&&s.push(o)}return 0===s.length?null:{event:t,data:s.join("\n")}}s.d(t,{XQ:()=>n,gJ:()=>a})},80581:(e,t,s)=>{"use strict";var n=s(35793);s.o(n,"useParams")&&s.d(t,{useParams:function(){return n.useParams}}),s.o(n,"usePathname")&&s.d(t,{usePathname:function(){return n.usePathname}}),s.o(n,"useRouter")&&s.d(t,{useRouter:function(){return n.useRouter}}),s.o(n,"useSearchParams")&&s.d(t,{useSearchParams:function(){return n.useSearchParams}})},95720:(e,t,s)=>{Promise.resolve().then(s.bind(s,97951))},97951:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>l});var n=s(54456),a=s(60500),r=s(80581),o=s(60287);function i(){var e,t;let s=(0,r.useSearchParams)(),i=null!=(e=s.get("workflow"))?e:"",l=null!=(t=s.get("token"))?t:"",[c,d]=(0,a.useState)({kind:"loading"}),[u,h]=(0,a.useState)([]),[f,m]=(0,a.useState)(""),[x,g]=(0,a.useState)(!1),[p]=(0,a.useState)(()=>"hosted-".concat(Date.now().toString(36),"-").concat(Math.random().toString(16).slice(2,6))),w=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=!1;return 0===i.length?void d({kind:"error",reason:"missing ?workflow= query param"}):((0,o.XQ)(i).then(t=>{e||(t?d({kind:"ready",config:t}):d({kind:"not-found"}))}).catch(t=>{e||d({kind:"error",reason:t instanceof Error?t.message:String(t)})}),()=>{e=!0})},[i]),(0,a.useEffect)(()=>{w.current&&(w.current.scrollTop=w.current.scrollHeight)},[u]);let b=async()=>{if("ready"!==c.kind||x)return;let e=f.trim();if(0===e.length)return;let t={id:"u-".concat(Date.now()),role:"user",text:e},s="a-".concat(Date.now());h(e=>[...e,t,{id:s,role:"assistant",text:"",pending:!0}]),m(""),g(!0);try{let t=await (0,o.gJ)({chatPath:c.config.path,message:e,sessionId:"per-session"===c.config.sessionMode?p:void 0,bearer:l.length>0?l:void 0,streaming:c.config.streaming});if("buffered"===t.kind)h(e=>e.map(e=>e.id===s?{...e,text:t.response,pending:!1}:e));else for await(let e of t.frames)if("token"===e.event)h(t=>t.map(t=>t.id===s?{...t,text:t.text+e.data}:t));else if("done"===e.event){let t;try{t=JSON.parse(e.data).response}catch(e){}h(e=>e.map(e=>e.id===s?{...e,text:null!=t?t:e.text,pending:!1}:e))}else"error"===e.event&&h(t=>t.map(t=>t.id===s?{...t,text:t.text+"\n[error: ".concat(e.data,"]"),pending:!1,role:"system"}:t))}catch(t){let e=t instanceof Error?t.message:String(t);h(t=>t.map(t=>t.id===s?{...t,text:"[error: ".concat(e,"]"),pending:!1,role:"system"}:t))}finally{g(!1)}};return"loading"===c.kind?(0,n.jsx)("div",{className:"p-6 text-sm text-slate-500",children:"Loading workflow chat…"}):"not-found"===c.kind?(0,n.jsxs)("div",{className:"p-6 text-sm",children:[(0,n.jsx)("h1",{className:"text-lg font-medium mb-2",children:"Workflow not found"}),(0,n.jsxs)("p",{className:"text-slate-600",children:["The workflow ",(0,n.jsx)("code",{className:"px-1 bg-slate-100 rounded",children:i})," is not available for hosted chat. The workflow author needs to add",(0,n.jsxs)("code",{className:"px-1 bg-slate-100 rounded ml-1",children:["hostedUi: ","{"," enabled: true ","}"]}),"to the chat trigger node."]})]}):"error"===c.kind?(0,n.jsxs)("div",{className:"p-6 text-sm",children:[(0,n.jsx)("h1",{className:"text-lg font-medium mb-2 text-red-600",children:"Connection error"}),(0,n.jsx)("p",{className:"text-slate-600",children:c.reason})]}):(0,n.jsxs)("div",{className:"flex flex-col h-screen max-w-2xl mx-auto px-4",children:[(0,n.jsxs)("header",{className:"py-3 border-b",children:[(0,n.jsx)("h1",{className:"text-base font-medium",children:c.config.workflowName}),(0,n.jsxs)("p",{className:"text-xs text-slate-500",children:[c.config.streaming?"streaming":"buffered"," \xb7 ",c.config.sessionMode,c.config.hostedUi.requiresBearer?" \xb7 bearer required":""]})]}),c.config.hostedUi.requiresBearer&&l.length>0?(0,n.jsx)("div",{className:"text-xs px-3 py-2 bg-amber-50 border-b border-amber-200 text-amber-800",children:"⚠ The bearer token is embedded in this URL. Treat this link as a secret — sharing the URL gives anyone full access to the workflow."}):null,(0,n.jsxs)("div",{ref:w,className:"flex-1 overflow-y-auto py-4 space-y-3",children:[0===u.length?(0,n.jsx)("p",{className:"text-sm text-slate-400 italic",children:"Type a message to start the conversation."}):null,u.map(e=>(0,n.jsxs)("div",{className:"text-sm",children:[(0,n.jsxs)("div",{className:"font-medium text-xs uppercase text-slate-500",children:[e.role,e.pending?" \xb7 typing…":null]}),(0,n.jsx)("pre",{className:"whitespace-pre-wrap font-sans text-slate-800",children:e.text})]},e.id))]}),(0,n.jsxs)("div",{className:"py-3 border-t flex gap-2",children:[(0,n.jsx)("input",{className:"flex-1 px-3 py-2 border rounded text-sm",value:f,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),b())},placeholder:"Message…",disabled:x}),(0,n.jsx)("button",{type:"button",onClick:()=>void b(),disabled:x||0===f.trim().length,className:"px-4 py-2 bg-slate-900 text-white rounded text-sm disabled:opacity-50",children:"Send"})]})]})}function l(){return(0,n.jsx)(a.Suspense,{fallback:(0,n.jsx)("div",{className:"p-6 text-sm text-slate-500",children:"Loading workflow chat…"}),children:(0,n.jsx)(i,{})})}}},e=>{e.O(0,[6390,3170,7358],()=>e(e.s=95720)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7143],{18252:(e,o,r)=>{Promise.resolve().then(r.bind(r,93772))},93772:(e,o,r)=>{"use strict";r.r(o),r.d(o,{default:()=>t});var n=r(54456),s=r(60500);function t(){return(0,s.useEffect)(()=>{window.location.replace("/app/editor/?mode=workflow")},[]),(0,n.jsx)("a",{href:"/app/editor/?mode=workflow",children:"편집기로 이동"})}}},e=>{e.O(0,[6390,3170,7358],()=>e(e.s=18252)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7143],{65750:(e,o,r)=>{Promise.resolve().then(r.bind(r,93772))},93772:(e,o,r)=>{"use strict";r.r(o),r.d(o,{default:()=>t});var n=r(54456),s=r(60500);function t(){return(0,s.useEffect)(()=>{window.location.replace("/app/editor/?mode=workflow")},[]),(0,n.jsx)("a",{href:"/app/editor/?mode=workflow",children:"편집기로 이동"})}}},e=>{e.O(0,[6390,3170,7358],()=>e(e.s=65750)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6364],{4222:(e,t,r)=>{"use strict";r.d(t,{U:()=>x});var s=r(54456),n=r(60500),a=r(36581),l=r(10080),i=r(95564);function o(e){let{items:t}=e;return 0===t.length?(0,s.jsx)("div",{className:"rounded-lg border border-dashed border-border p-6 text-center text-sm text-muted-foreground",children:"No control signals matched the current filter."}):(0,s.jsx)("ul",{className:"space-y-2",children:t.map((e,t)=>{var r,n,a,l,i;let o=[(null==(r=e.scope)?void 0:r.surface)&&"surface=".concat(e.scope.surface),(null==(n=e.scope)?void 0:n.channel)&&"channel=".concat(e.scope.channel),(null==(a=e.scope)?void 0:a.sessionId)&&"session=".concat(e.scope.sessionId)].filter(Boolean).join(" \xb7 ")||"unscoped";return(0,s.jsxs)("li",{className:"rounded-lg border border-border bg-card p-3 shadow-sm",children:[(0,s.jsxs)("div",{className:"text-sm font-medium",children:[e.kind," \xb7 ",e.urgency]}),(0,s.jsxs)("div",{className:"mt-0.5 font-mono text-[10px] text-muted-foreground",children:[function(e){let t=Date.now()-new Date(e).getTime();return t<6e4?"just now":t<36e5?"".concat(Math.floor(t/6e4),"m ago"):t<864e5?"".concat(Math.floor(t/36e5),"h ago"):"".concat(Math.floor(t/864e5),"d ago")}(e.createdAt)," \xb7 ",null!=(l=e.source)?l:"unknown"," \xb7 ",o]}),(0,s.jsx)("pre",{className:"mt-2 overflow-x-auto rounded-md bg-muted p-2 text-[11px]",children:JSON.stringify(null!=(i=e.payload)?i:{},null,2)})]},t)})})}let d=["background","quick-pass","normal","priority","critical"];class c{async list(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new URLSearchParams;Object.entries(e).forEach(e=>{let[r,s]=e;s&&t.set(r,s)});let r=t.toString();return this.client.fetchJson("/v1/control-signals".concat(r?"?".concat(r):""))}emit(e){return this.client.fetchJson("/v1/control-signals",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)})}constructor(e){this.client=e}}var u=r(71829),m=r(50733);function x(){var e,t,r,x;let{client:h}=(0,a.Q)(),p=(0,n.useMemo)(()=>new c(h),[h]),[f,g]=(0,n.useState)({items:[]}),[b,v]=(0,n.useState)(!1),[j,y]=(0,n.useState)(""),[N,k]=(0,n.useState)(""),[w,C]=(0,n.useState)(""),[I,S]=(0,n.useState)(""),[E,D]=(0,n.useState)(""),[T,M]=(0,n.useState)(""),[L,P]=(0,n.useState)("normal"),[A,R]=(0,n.useState)("operator"),[O,K]=(0,n.useState)(""),[z,J]=(0,n.useState)(""),[U,_]=(0,n.useState)(""),[B,F]=(0,n.useState)(""),[q,Y]=(0,n.useState)(!1),$=(0,n.useCallback)(async()=>{(0,m.cY)("webterm.control.list.refresh",{kind:j,surface:N,minUrgency:w,sessionId:I,limit:E}),v(!0);try{let e=await p.list({kind:j||void 0,surface:N||void 0,minUrgency:w||void 0,sessionId:I||void 0,limit:E||void 0});g(e)}catch(e){u.oR.error("signals list failed: ".concat(e instanceof Error?e.message:e))}finally{v(!1)}},[p,j,N,w,I,E]);(0,n.useEffect)(()=>{$()},[$]);let H=async e=>{if(e.preventDefault(),!T.trim())return void u.oR.error("kind required");let t={};if(B.trim())try{t=JSON.parse(B)}catch(e){u.oR.error("payload must be valid JSON");return}let r={kind:T.trim(),urgency:L,source:A.trim()||"operator",mayPreempt:q,payload:t,scope:{...O?{surface:O}:{},...z?{channel:z}:{},...U?{sessionId:U}:{}}};(0,m.cY)("webterm.control.emit",{kind:r.kind,urgency:r.urgency});try{v(!0),await p.emit(r),u.oR.success("signal emitted"),F(""),await $()}catch(e){u.oR.error("emit failed: ".concat(e instanceof Error?e.message:e))}finally{v(!1)}},Q=null!=(e=f.countsByKind)?e:{};return(0,s.jsxs)("div",{className:"mx-auto max-w-5xl space-y-4 p-4",children:[(0,s.jsxs)("header",{className:"space-y-2",children:[(0,s.jsx)("h1",{className:"text-xl font-semibold tracking-tight",children:"Control signals"}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 text-[11px] text-muted-foreground",children:[(0,s.jsxs)("span",{className:"rounded-full border border-border px-2 py-0.5",children:["total ",null!=(t=f.total)?t:0]}),(0,s.jsxs)("span",{className:"rounded-full border border-border px-2 py-0.5",children:["latest ",null!=(r=f.latest)?r:"-"]}),Object.entries(Q).map(e=>{let[t,r]=e;return(0,s.jsxs)("span",{className:"rounded-full border border-border px-2 py-0.5",children:[t," ",r]},t)})]})]}),(0,s.jsxs)("form",{onSubmit:e=>{e.preventDefault(),$()},className:"flex flex-wrap items-center gap-2 rounded-lg border border-border bg-card p-3 shadow-sm",children:[(0,s.jsx)(i.p,{value:j,onChange:e=>y(e.target.value),placeholder:"kind",className:"flex-1 min-w-[140px]"}),(0,s.jsx)(i.p,{value:N,onChange:e=>k(e.target.value),placeholder:"surface",className:"flex-1 min-w-[140px]"}),(0,s.jsxs)("select",{value:w,onChange:e=>C(e.target.value),className:"h-9 flex-1 min-w-[170px] rounded-md border border-input bg-background px-2 text-sm",children:[(0,s.jsx)("option",{value:"",children:"min urgency (any)"}),d.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]}),(0,s.jsx)(i.p,{value:I,onChange:e=>S(e.target.value),placeholder:"session id",className:"flex-1 min-w-[140px]"}),(0,s.jsx)(i.p,{value:E,onChange:e=>D(e.target.value),placeholder:"limit",type:"number",className:"w-[100px]"}),(0,s.jsx)(l.$,{type:"submit",size:"sm",disabled:b,children:"Filter"})]}),(0,s.jsxs)("form",{onSubmit:H,className:"space-y-2 rounded-lg border border-border bg-card p-3 shadow-sm",children:[(0,s.jsx)("h2",{className:"text-sm font-semibold",children:"Emit a signal"}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(i.p,{value:T,onChange:e=>M(e.target.value),placeholder:"kind (required)",className:"flex-1 min-w-[140px]"}),(0,s.jsx)("select",{value:L,onChange:e=>{let t=e.target.value;"string"==typeof t&&d.includes(t)&&P(t)},className:"h-9 rounded-md border border-input bg-background px-2 text-sm",children:d.map(e=>(0,s.jsx)("option",{value:e,children:e},e))}),(0,s.jsx)(i.p,{value:A,onChange:e=>R(e.target.value),placeholder:"source",className:"flex-1 min-w-[120px]"}),(0,s.jsx)(i.p,{value:O,onChange:e=>K(e.target.value),placeholder:"scope.surface",className:"flex-1 min-w-[120px]"}),(0,s.jsx)(i.p,{value:z,onChange:e=>J(e.target.value),placeholder:"scope.channel",className:"flex-1 min-w-[120px]"}),(0,s.jsx)(i.p,{value:U,onChange:e=>_(e.target.value),placeholder:"scope.session",className:"flex-1 min-w-[120px]"}),(0,s.jsxs)("label",{className:"flex items-center gap-1.5 text-xs",children:[(0,s.jsx)("input",{type:"checkbox",checked:q,onChange:e=>Y(e.target.checked)}),"mayPreempt"]})]}),(0,s.jsx)("textarea",{value:B,onChange:e=>F(e.target.value),placeholder:'payload JSON (optional, e.g. {"reason":"manual"})',rows:3,className:"w-full resize-y rounded-md border border-input bg-background px-3 py-2 font-mono text-xs"}),(0,s.jsx)(l.$,{type:"submit",size:"sm",disabled:b,children:"Emit"})]}),(0,s.jsx)(o,{items:null!=(x=f.items)?x:[]})]})}},4563:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>O});var s=r(54456),n=r(60500),a=r(80581),l=r(24685),i=r(74591);function o(e){let{id:t,active:r,children:n}=e;return(0,s.jsx)("div",{role:"tabpanel","data-tab-id":t,"data-active":r?"true":"false",className:(0,i.cn)("h-full min-h-0",r?"block":"hidden"),children:n})}var d=r(45250),c=r(48605),u=r(18834),m=r(84508),x=r(4222),h=r(17758),p=r(46773),f=r(966);function g(e){let{tab:t}=e;switch(t.kind){case"chat":return(0,s.jsx)(d.ChatPanel,{sessionId:t.sessionId,tabId:t.id});case"term":return(0,s.jsx)(c.zV,{});case"intake":return(0,s.jsx)(u.SY,{});case"tasks":return(0,s.jsx)(m.B,{});case"control":return(0,s.jsx)(x.U,{});case"settings":return(0,s.jsx)(h.O,{})}}function b(){return(0,s.jsx)("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:(0,s.jsx)("span",{children:"(이 탭은 절약 모드 — 클릭 시 복원)"})})}function v(){let{state:e,addTab:t,activateTab:r}=(0,l.hA)(),a=(0,p.ub)(e),i=(0,n.useRef)(null);if((0,n.useEffect)(()=>{if(i.current&&!(a.length<=1))return(0,f.gI)(i.current,{shouldIgnore:e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return!!("INPUT"===t||"TEXTAREA"===t||"SELECT"===t||e.closest(".xterm"))||!!e.isContentEditable},onSwipe:t=>{let s=e.activeId?a.findIndex(t=>t.id===e.activeId):-1;if(s<0)return;let n="left"===t?Math.min(a.length-1,s+1):Math.max(0,s-1);n!==s&&r(a[n].id)}})},[a,e.activeId,r]),0===a.length)return(0,s.jsx)("div",{className:"flex h-full flex-col items-center justify-center gap-4 px-6 text-center",children:(0,s.jsxs)("div",{className:"rounded-lg border border-dashed border-border bg-card px-6 py-8 max-w-md",children:[(0,s.jsx)("h2",{className:"text-base font-semibold tracking-tight",children:"워크스페이스 시작"}),(0,s.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["상단 strip 의"," ",(0,s.jsx)("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs",children:"+"})," ","또는 아래 버튼으로 첫 탭을 추가하세요. 비활성 탭은 닫기 전까지 unmount 되지 않아 입력 중 텍스트가 보존됩니다."]}),(0,s.jsxs)("div",{className:"mt-4 flex flex-wrap justify-center gap-2",children:[(0,s.jsx)("button",{type:"button",onClick:()=>t({kind:"chat"}),className:"rounded-md border border-border bg-background px-3 py-1.5 text-sm hover:bg-secondary",children:"+ chat"}),(0,s.jsx)("button",{type:"button",onClick:()=>t({kind:"term"}),className:"rounded-md border border-border bg-background px-3 py-1.5 text-sm hover:bg-secondary",children:"+ terminal"})]})]})});let d=new Set(e.frozenIds);return(0,s.jsx)("div",{ref:i,className:"relative h-full min-h-0 touch-pan-y",children:a.map(t=>(0,s.jsx)(o,{id:t.id,active:e.activeId===t.id,children:d.has(t.id)?(0,s.jsx)(b,{}):(0,s.jsx)(g,{tab:t})},t.id))})}function j(){let e=(0,l.hA)();return(0,n.useEffect)(()=>{let t=t=>{if(!(t.metaKey||t.ctrlKey))return;let r=(0,p.ub)(e.state),s=e.state.activeId?r.findIndex(t=>t.id===e.state.activeId):-1;if(!t.shiftKey&&"t"===t.key.toLowerCase()){t.preventDefault(),e.openPicker({kind:"addNewChat"});return}if(!t.shiftKey&&"w"===t.key.toLowerCase()){t.preventDefault(),e.state.activeId&&r.length>0&&e.closeTab(e.state.activeId);return}if(t.shiftKey&&("]"===t.key||"["===t.key)){if(t.preventDefault(),r.length<=1||s<0)return;let n="]"===t.key?(s+1)%r.length:(s-1+r.length)%r.length;e.activateTab(r[n].id);return}if(!t.shiftKey&&/^[1-9]$/.test(t.key)){t.preventDefault();let s=parseInt(t.key,10)-1;if(s>=r.length)return;e.activateTab(r[s].id);return}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e]),null}var y=r(75361),N=r(91321),k=r(37637),w=r(8286),C=r(36581),I=r(1355),S=r(10037),E=r(79450),D=r(84693);function T(e){var t;let{open:r,session:a,onCancel:l,onConfirm:i,busy:o}=e;if((0,n.useEffect)(()=>{if(!r)return;let e=e=>{"Escape"===e.key&&l()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[r,l]),!r||!a)return null;let d=null!=(t=a.lastMsgPreview)?t:"(빈 대화)";return(0,s.jsx)("div",{role:"alertdialog","aria-modal":"true",className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/40",onClick:l,children:(0,s.jsxs)("div",{onClick:e=>e.stopPropagation(),className:"w-[min(420px,calc(100vw-2rem))] rounded-lg border border-border bg-card p-5 shadow-lg",children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)(w.A,{className:"mt-0.5 h-5 w-5 shrink-0 text-rose-500","aria-hidden":!0}),(0,s.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,s.jsx)("h2",{className:"text-base font-semibold",children:"대화 지우기"}),(0,s.jsxs)("p",{className:"truncate font-mono text-xs text-muted-foreground",children:['"',d,'"']}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:[a.origin&&(0,s.jsx)("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono uppercase mr-1.5",children:a.origin}),a.msgCount," 메시지"]}),(0,s.jsx)("p",{className:"text-sm",children:"이 대화를 영구히 지웁니다. 복구할 수 없습니다. 다른 기기에서 이 대화를 보고 있다면 더 이상 이어갈 수 없습니다."})]})]}),(0,s.jsxs)("div",{className:"mt-4 flex justify-end gap-2",children:[(0,s.jsx)("button",{type:"button",onClick:l,disabled:o,className:"rounded-md border border-border bg-background px-3 py-1.5 text-sm hover:bg-secondary disabled:opacity-50",children:"취소"}),(0,s.jsx)("button",{type:"button",onClick:i,disabled:o,className:"rounded-md bg-rose-500 px-3 py-1.5 text-sm font-medium text-white hover:bg-rose-600 disabled:opacity-50",children:o?"지우는 중…":"지우기"})]})]})})}var M=r(78925);let L={cli:"cli",pwa:"pwa",tg:"tg",dc:"dc"};function P(e){let{open:t,onClose:r,onPick:a,attachedSessions:l}=e,{client:o}=(0,C.Q)(),d=(0,S.hG)(o),c=(0,n.useMemo)(()=>new E.jU(o),[o]),u=(0,D.h)(),[m,x]=(0,n.useState)(""),[h,p]=(0,n.useState)(0),[f,g]=(0,n.useState)(null),[b,v]=(0,n.useState)(!1),[j,P]=(0,n.useState)(!1),[A,R]=(0,n.useState)(null),O=(0,n.useRef)(null),K=(0,n.useRef)(null);(0,n.useEffect)(()=>{t&&(x(""),p(0),R(null),d.forceRefresh())},[t,d]),(0,n.useEffect)(()=>{R(null)},[m]);let z=(0,n.useMemo)(()=>{if(!m.trim())return[...u];let e=m.trim().toLowerCase();return u.filter(t=>!!(t.id.toLowerCase().startsWith(e)||t.lastMsgPreview&&t.lastMsgPreview.toLowerCase().includes(e))||!!t.origin&&e==="[".concat(t.origin,"]")||!!t.origin&&e===t.origin)},[u,m]);if((0,n.useEffect)(()=>{h>=z.length&&p(Math.max(0,z.length-1))},[z.length,h]),(0,n.useEffect)(()=>{var e;if(!t)return;null==(e=O.current)||e.focus();let s=e=>{if("Escape"===e.key){e.preventDefault(),r();return}if((e.metaKey||e.ctrlKey)&&"n"===e.key.toLowerCase()){e.preventDefault(),J();return}if((e.metaKey||e.ctrlKey)&&"f"===e.key.toLowerCase()){var t;e.preventDefault(),null==(t=O.current)||t.focus();return}if("ArrowDown"===e.key)e.preventDefault(),p(e=>Math.min(z.length-1,e+1));else if("ArrowUp"===e.key)e.preventDefault(),p(e=>Math.max(0,e-1));else if("Enter"===e.key){let t=z[h];if(!t){m.trim().length>=4&&(e.preventDefault(),_());return}e.preventDefault(),U(t)}else if("Delete"===e.key||"Backspace"===e.key){if(e.target instanceof HTMLInputElement)return;let t=z[h];t&&(e.preventDefault(),g(t))}};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[t,z,h,r,m,j]),!t)return null;let J=()=>{a({kind:"new",sessionId:(0,I.f6)()})},U=e=>{let t=l.get(e.id);if(t)return void a({kind:"jumpToTab",tabId:t.tabId});a({kind:"existing",sessionId:e.id})},_=async()=>{let e=m.trim().toLowerCase();if(!(e.length<4)&&!j){P(!0);try{var t;let r=await c.list(!0),s=(0,E.nj)(null!=(t=r.sessions)?t:[],e);if("one"===s.kind){let e=l.get(s.id);e?a({kind:"jumpToTab",tabId:e.tabId}):a({kind:"existing",sessionId:s.id})}else"none"===s.kind?R("'".concat(e,"'로 시작하는 대화가 없습니다.")):R("".concat(s.count,"개의 대화가 일치합니다. ID를 더 길게 입력하세요."))}catch(e){R("대화를 찾지 못했습니다: ".concat(e instanceof Error?e.message:String(e)))}finally{P(!1)}}},B=async()=>{if(f){v(!0);try{await d.forget(f.id),g(null)}finally{v(!1)}}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":"대화 선택",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:r,children:(0,s.jsxs)("div",{onClick:e=>e.stopPropagation(),className:"flex max-h-[min(640px,90vh)] w-[min(640px,calc(100vw-2rem))] flex-col rounded-lg border border-border bg-card shadow-lg",children:[(0,s.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,s.jsx)("h2",{className:"text-base font-semibold",children:"대화 선택"}),(0,s.jsx)("button",{type:"button","aria-label":"close",onClick:r,className:"rounded-md p-1 text-muted-foreground hover:bg-secondary hover:text-foreground",children:(0,s.jsx)(y.A,{className:"h-4 w-4"})})]}),(0,s.jsx)("div",{className:"shrink-0 px-4 py-3",children:(0,s.jsxs)("button",{type:"button",onClick:J,className:"flex w-full items-center gap-3 rounded-lg border border-primary/40 bg-primary/10 px-3 py-2.5 text-left hover:bg-primary/15",children:[(0,s.jsx)(N.A,{className:"h-5 w-5 text-primary"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("div",{className:"text-sm font-medium",children:"새 대화 시작"}),(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:"비어있는 새 채팅을 엽니다 (⌘N)"})]})]})}),(0,s.jsx)("div",{className:"shrink-0 border-y border-border bg-muted/30 px-4 py-2",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(k.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,s.jsx)("input",{ref:O,value:m,onChange:e=>x(e.target.value),placeholder:"대화 검색 — 내용 \xb7 ID \xb7 [pwa]/[cli]/[tg]/[dc]",className:"flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground/60"}),m&&(0,s.jsx)("button",{type:"button","aria-label":"clear search",onClick:()=>x(""),className:"rounded p-0.5 text-muted-foreground hover:bg-background",children:(0,s.jsx)(y.A,{className:"h-3 w-3"})})]})}),(0,s.jsx)("div",{ref:K,className:"min-h-0 flex-1 overflow-y-auto",children:0===z.length?(0,s.jsxs)("div",{className:"px-4 py-12 text-center",children:[(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:0!==u.length||m.trim()?"검색과 일치하는 대화가 없습니다.":'아직 대화가 없습니다. 위의 "새 대화 시작"으로 첫 대화를 시작하세요.'}),m.trim().length>=4&&(0,s.jsx)("button",{type:"button",disabled:j,onClick:()=>void _(),className:"mt-3 rounded-md border border-violet-500/40 bg-violet-500/10 px-3 py-1.5 text-xs text-violet-300 hover:bg-violet-500/15 disabled:opacity-50",children:j?"찾는 중…":"ID '".concat(m.trim(),"'로 대화 이어가기 (Enter)")}),A&&(0,s.jsx)("p",{className:"mt-2 text-xs text-amber-400",children:A}),0===u.length&&!m.trim()&&(0,s.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"다른 기기(CLI / Telegram / Discord)에서 대화를 시작하면 여기에 자동으로 나타납니다."})]}):(0,s.jsx)("ul",{className:"divide-y divide-border",children:z.map((e,t)=>{var r;let n=l.get(e.id),a=t===h;return(0,s.jsx)("li",{children:(0,s.jsxs)("div",{className:(0,i.cn)("group flex items-center gap-3 px-4 py-2.5 transition-colors",a?"bg-primary/10 ring-1 ring-inset ring-primary/30":"hover:bg-secondary/50"),onMouseEnter:()=>p(t),children:[(0,s.jsxs)("button",{type:"button",onClick:()=>U(e),className:"flex min-w-0 flex-1 flex-col items-start text-left",children:[(0,s.jsxs)("div",{className:"flex w-full items-center gap-2",children:[(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:null!=(r=e.lastMsgPreview)?r:(0,s.jsx)("span",{className:"text-muted-foreground italic",children:"(빈 대화)"})}),n&&(0,s.jsxs)("span",{className:"ml-auto shrink-0 rounded-full bg-primary/15 px-2 py-0.5 text-[10px] font-medium text-primary",children:["✓ ",n.label,"에서 열림"]})]}),(0,s.jsxs)("div",{className:"mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.origin&&(0,s.jsx)("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono",children:L[e.origin]}),(0,s.jsx)("span",{children:function(e){try{let t=new Date(e).getTime();if(!Number.isFinite(t))return"";let r=Date.now()-t,s=Math.floor(r/6e4);if(s<1)return"방금 전";if(s<60)return"".concat(s,"분 전");let n=Math.floor(s/60);if(n<24)return"".concat(n,"시간 전");let a=Math.floor(n/24);if(a<7)return"".concat(a,"일 전");return new Date(t).toLocaleDateString()}catch(e){return""}}(e.lastTurnAt)}),(0,s.jsxs)("span",{children:["\xb7 ",e.msgCount," 메시지"]}),(0,s.jsx)(M.S,{sessionId:e.id,source:"picker",variant:"subtle",showCopyIcon:!1})]})]}),(0,s.jsx)("button",{type:"button","aria-label":"대화 ".concat(e.id," 지우기"),onClick:t=>{t.stopPropagation(),g(e)},className:(0,i.cn)("shrink-0 rounded p-1.5 text-muted-foreground transition-colors hover:bg-rose-500/10 hover:text-rose-500",a?"opacity-100":"opacity-0 group-hover:opacity-100"),children:(0,s.jsx)(w.A,{className:"h-4 w-4"})})]})},e.id)})})}),(0,s.jsxs)("div",{className:"shrink-0 border-t border-border bg-muted/30 px-4 py-2 text-[10px] text-muted-foreground",children:[(0,s.jsx)("span",{className:"mr-3",children:"↑↓ 이동"}),(0,s.jsx)("span",{className:"mr-3",children:"Enter 선택"}),(0,s.jsx)("span",{className:"mr-3",children:"⌘N 새 대화"}),(0,s.jsx)("span",{className:"mr-3",children:"⌘F 검색"}),(0,s.jsx)("span",{children:"Del 지우기"})]})]})}),(0,s.jsx)(T,{open:null!==f,session:f,busy:b,onCancel:()=>g(null),onConfirm:B})]})}let A=new Set(["chat","term","intake","tasks","control","settings"]);function R(){var e;let t=(0,l.hA)(),r=(0,a.useRouter)(),i=(0,a.useSearchParams)(),o=null!=(e=null==i?void 0:i.get("intent"))?e:null,d=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(o&&d.current!==o){if(!A.has(o))return void r.replace("/workspace");if(d.current=o,"chat"===o){let e=(0,p.ub)(t.state).find(e=>"chat"===e.kind);e?t.activateTab(e.id):t.openPicker({kind:"addNewChat"})}else t.activateOrAdd(o);r.replace("/workspace")}},[o,t,r]);let c=(0,n.useMemo)(()=>{let e=new Map,r=0;for(let s of t.state.order){let n=t.state.tabs.find(e=>e.id===s);n&&"chat"===n.kind&&(r+=1,e.set(n.sessionId,{tabId:n.id,label:"chat#".concat(r)}))}return e},[t.state.order,t.state.tabs]);return(0,s.jsxs)("div",{className:"flex h-full flex-col",children:[(0,s.jsx)(j,{}),(0,s.jsx)("div",{className:"flex-1 min-h-0",children:(0,s.jsx)(v,{})}),(0,s.jsx)(P,{open:null!==t.pickerMode,onClose:t.closePicker,onPick:e=>{let r=t.pickerMode;r&&("jumpToTab"===e.kind?t.activateTab(e.tabId):"addNewChat"===r.kind?t.addTab({kind:"chat",sessionId:e.sessionId}):"attachToTab"===r.kind&&(t.updateChatTab(r.tabId,{sessionId:e.sessionId}),t.activateTab(r.tabId)),t.closePicker())},attachedSessions:c})]})}function O(){return(0,s.jsx)(n.Suspense,{fallback:(0,s.jsx)("div",{className:"h-full"}),children:(0,s.jsx)(R,{})})}},67683:(e,t,r)=>{Promise.resolve().then(r.bind(r,4563))}},e=>{e.O(0,[7777,9538,3278,1829,6048,9656,7551,5978,3454,1159,3735,9906,3869,4215,2176,6588,5845,1394,7274,4685,7758,8605,5250,4508,8834,6390,3170,7358],()=>e(e.s=67683)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2975],{3472:(e,t,s)=>{"use strict";s.d(t,{AF:()=>r});let r={all:["nexus"],health:()=>[...r.all,"health"],snapshot:()=>[...r.all,"snapshot"],tabs:e=>e?[...r.all,"tabs",{kind:e}]:[...r.all,"tabs"],tab:e=>[...r.all,"tab",e],templates:()=>[...r.all,"templates"],template:e=>[...r.all,"template",e],config:()=>[...r.all,"config"],switches:()=>[...r.all,"switches"],switch:e=>[...r.all,"switch",e],secrets:()=>[...r.all,"secrets"],bindingChannels:()=>[...r.all,"bindings","channels"],bindings:e=>[...r.all,"bindings",e],binding:(e,t)=>[...r.all,"binding",e,t],logsTail:(e,t)=>t?[...r.all,"logs",e,{lines:t}]:[...r.all,"logs",e],workflows:()=>[...r.all,"workflows"],workflow:e=>[...r.all,"workflow",e],workflowRun:e=>[...r.all,"workflow-run",e],workflowRuns:()=>[...r.all,"workflow-runs"],pendingApprovals:()=>[...r.all,"workflow-pending-approvals"],platforms:()=>[...r.all,"platforms"],providers:()=>[...r.all,"providers"],worktrees:()=>[...r.all,"worktrees"],designCheck:()=>[...r.all,"design-check"],designPreviews:()=>[...r.all,"design-previews"],designPreview:e=>[...r.all,"design-preview",e],registryCatalog:()=>[...r.all,"registry-catalog"],resolvedView:()=>[...r.all,"resolved-view"]};r.snapshot(),r.tabs(),r.health(),r.snapshot(),r.config(),r.switches()},8286:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(18494).A)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]])},13784:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(18494).A)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},18238:(e,t,s)=>{Promise.resolve().then(s.bind(s,78250))},28042:(e,t,s)=>{"use strict";s.d(t,{Qb:()=>n,SI:()=>o,dJ:()=>l});let r="elanous:auth-required",i=null,a=!1;function n(e){null===i&&(i=e,window.dispatchEvent(new CustomEvent(r,{detail:{path:e}})))}function l(e){let t=window,s=t=>e(t.detail);return t.addEventListener(r,s),null===i||a||e({path:i}),()=>t.removeEventListener(r,s)}function o(){a=!0}},29972:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(18494).A)("git-branch",[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]])},35448:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(18494).A)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},39681:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(18494).A)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},43468:(e,t,s)=>{"use strict";s.d(t,{M1:()=>c,Qj:()=>u,tI:()=>o});var r=s(54456),i=s(60500),a=s(40324),n=s(59405);let l=(0,i.createContext)(null);function o(e){let{client:t,queryClient:s,defaultStaleTimeMs:o,children:c}=e,u=(0,i.useMemo)(()=>null!=s?s:new a.E({defaultOptions:{queries:{staleTime:null!=o?o:2e3,refetchOnWindowFocus:!1}}}),[s,o]);return(0,r.jsx)(l.Provider,{value:t,children:(0,r.jsx)(n.Ht,{client:u,children:c})})}function c(){let e=(0,i.useContext)(l);if(!e)throw Error("useNexusClient must be used within <NexusProvider>");return e}function u(){return(0,i.useContext)(l)}},50733:(e,t,s)=>{"use strict";let r;s.d(t,{cY:()=>u,x8:()=>l});let i={debug:0,info:1,warn:2,error:3},a="/v1/debug-logs/batch",n=null;function l(e){n=e}class o{health(){return{pending:this.queue.length,consecutiveFailures:this.consecutiveFailures,lastOkAt:this.lastOkAt,droppedByCap:this.droppedByCap,fallbackBatches:this.fallbackBatches}}push(e){if(!(i[function(e){let t=e.slice(e.lastIndexOf(".")+1).toLowerCase();return/^(error|exception|crash|fail|failed)$/.test(t)?"error":/^(warn|degraded|timeout)$/.test(t)?"warn":/^(boot|ready|start|begin|open|ok|done|resolve|end|stop|close)$/.test(t)?"info":"debug"}(e.category)]<i[this.minLevel])){if(this.queue.push(e),this.queue.length>500){let e=this.queue.length-500;this.droppedByCap+=e,this.queue.splice(0,e)}if(this.queue.length>=100&&!this.inFlight){null!==this.timer&&(clearTimeout(this.timer),this.timer=null),this.flush();return}null===this.timer&&(this.timer=setTimeout(()=>{this.flush()},this.flushMs))}}async flush(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),this.inFlight||0===this.queue.length)return;let e=this.queue.slice(0,100);this.inFlight=!0;let t=!1,s=JSON.stringify({records:e});try{var r,i;t=await (r=this.fetchFn(s),i=this.postTimeoutMs,new Promise((e,t)=>{let s=setTimeout(()=>t(Error("debug-forward timeout after ".concat(i,"ms"))),i);r.then(t=>{clearTimeout(s),e(t)},e=>{clearTimeout(s),t(e)})}))}catch(e){t=!1}finally{this.inFlight=!1}if(!t){if(this.consecutiveFailures+=1,this.consecutiveFailures>=2&&n)try{await n(JSON.stringify({records:[...e,this.blockedNotice()]}))&&(this.fallbackBatches+=1)}catch(e){}this.wasFailing=!0,this.scheduleRetry();return}let a=this.lastOkAt;this.lastOkAt=Date.now();let l=this.consecutiveFailures;this.consecutiveFailures=0,this.queue.splice(0,e.length),this.wasFailing&&(this.wasFailing=!1,this.queue.push({ts:new Date().toISOString(),category:"pwa.debug-forwarder.recovered",event:"recovered",data:{consecutiveFailures:l,droppedByCap:this.droppedByCap,fallbackBatches:this.fallbackBatches,pending:this.queue.length,previousOkAt:a},source:{platform:"pwa"}})),this.queue.length>0&&null===this.timer&&(this.timer=setTimeout(()=>{this.flush()},this.flushMs))}scheduleRetry(){if(null!==this.timer||0===this.queue.length)return;let e=Math.min(this.flushMs*2**this.consecutiveFailures,3e4);this.timer=setTimeout(()=>{this.flush()},e)}blockedNotice(){return{ts:new Date().toISOString(),category:"pwa.debug-forwarder.http-blocked",event:"http-blocked",data:{consecutiveFailures:this.consecutiveFailures,pending:this.queue.length,droppedByCap:this.droppedByCap,lastOkAt:this.lastOkAt,via:"acp-fallback"},source:{platform:"pwa"}}}beaconFlush(){if(0!==this.queue.length)try{if("undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){let e=this.queue.slice(0,100),t=new Blob([JSON.stringify({records:e})],{type:"application/json"});navigator.sendBeacon(a,t)&&this.queue.splice(0,e.length)}}catch(e){}}get pending(){return this.queue.length}constructor(e=c,t="debug",s=1e4,r=100){this.fetchFn=e,this.minLevel=t,this.postTimeoutMs=s,this.flushMs=r,this.queue=[],this.timer=null,this.inFlight=!1,this.consecutiveFailures=0,this.lastOkAt=null,this.droppedByCap=0,this.fallbackBatches=0,this.wasFailing=!1}}async function c(e){return(await fetch(a,{method:"POST",headers:{"content-type":"application/json"},body:e,keepalive:!0,..."undefined"!=typeof AbortSignal&&"function"==typeof AbortSignal.timeout?{signal:AbortSignal.timeout(1e4)}:{}})).ok}function u(e,t){if("undefined"==typeof console)return;let s=new Date().toISOString();if(void 0!==t){let r="";try{let e=new WeakSet;r=JSON.stringify(t,(t,s)=>{if("bigint"==typeof s)return"".concat(s.toString(),"n");if("function"==typeof s)return"[fn ".concat(s.name||"anon","]");if(s&&"object"==typeof s){if(e.has(s))return"[circular]";e.add(s)}return s})}catch(e){r="[unserializable: ".concat(String(e),"]")}r&&r.length>800&&(r=r.slice(0,797)+"..."),console.debug("[".concat(s,"] ").concat(e," ").concat(r),t),d(s,e,r)}else console.debug("[".concat(s,"] ").concat(e)),d(s,e,void 0)}function d(e,t,s){let i,a=function(){if(void 0!==r)return r;let e=function(){try{let e="off"!==window.localStorage.getItem("elanous.pwa.debug.forward"),t=window.localStorage.getItem("elanous.pwa.debug.forwardLevel");return{forward:e,level:"info"===t||"warn"===t||"error"===t?t:"debug"}}catch(e){return{forward:!0,level:"debug"}}}();if(!e.forward)return r=null,null;let t=new o(c,e.level,1e4,1500);try{window.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&t.beaconFlush()})}catch(e){}return r=t,t}();if(!a)return;let n=t.slice(t.lastIndexOf(".")+1)||t;if(void 0!==s&&""!==s)try{i=JSON.parse(s)}catch(e){i=s}a.push({ts:e,category:t,event:n,...void 0!==i?{data:i}:{},source:{platform:"pwa"}})}},69670:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(18494).A)("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]])},78250:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>O});var r=s(54456),i=s(60500),a=s(35448),n=s(69670),l=s(29972),o=s(18494);let c=(0,o.A)("folder-tree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]);var u=s(39681),d=s(13784);let h=(0,o.A)("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);var p=s(8286),m=s(43468),f=s(81707),x=s(59405),g=s(89762),y=s(3472),b=s(23869);let w={orphan:0,active:1,detached:2,idle:3,main:4},v={orphan:"Orphan",active:"Active",detached:"Detached",idle:"Idle",main:"Main"},k={orphan:"bg-error/10 text-error",active:"bg-green-600/10 text-green-700",detached:"bg-warning/10 text-warning",idle:"bg-muted text-muted-foreground",main:"bg-primary/10 text-primary"},j={orphan:a.A,active:n.A,detached:l.A,idle:c,main:c};function N(){return(0,m.Qj)()?(0,r.jsx)(M,{}):(0,r.jsxs)("div",{className:"mx-auto max-w-2xl space-y-2 p-6",children:[(0,r.jsx)("h1",{className:"text-xl font-semibold tracking-tight",children:"Worktrees"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Connect to a NEXUS daemon to see active worktrees."})]})}function M(){var e,t,s,n;let{data:l,isLoading:o,error:N,refetch:M,isFetching:O}=function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=(0,m.M1)();return(0,f.I)({queryKey:y.AF.worktrees(),queryFn:()=>s.getWorktrees(),enabled:null==(e=t.enabled)||e,refetchInterval:5e3})}(),S=function(){let e=(0,m.M1)(),t=(0,x.jE)();return(0,g.n)({mutationFn:async t=>{try{return await e.disposeWorktree(t)}catch(t){let e=function(e){if(e instanceof b.Iu&&e.body&&"object"==typeof e.body){let t=e.body;if("ok"in t)return t}return null}(t);if(e)return e;throw t}},onSuccess:e=>{e.ok&&t.invalidateQueries({queryKey:y.AF.worktrees()})}})}(),[C,F]=(0,i.useState)(null),q=null!=(e=null==l?void 0:l.repoRoot)?e:null,E=null!=(t=null==l?void 0:l.worktrees)?t:[],R=null!=(s=null==l?void 0:l.orphanedSessions)?s:[],I=E.map(e=>({view:e,status:e.orphan?"orphan":e.isMain?"main":e.isDetached?"detached":e.session&&e.session.alive?"active":"idle"})).sort((e,t)=>{var s,r,i,a;let n=null!=(s=w[e.status])?s:99,l=null!=(r=w[t.status])?r:99;if(n!==l)return n-l;let o=null!=(i=e.view.branch)?i:"~detached",c=null!=(a=t.view.branch)?a:"~detached";return o.localeCompare(c)}),B=function(e){let t={total:e.length,active:0,orphan:0,idle:0,detached:0,main:0};for(let s of e)t[s.status]+=1;return t}(I),P=Date.now(),T=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=!0===t.force,r=s?"Force-remove this worktree (will discard local changes)?\n\n".concat(e):t.locked?"This worktree is locked. Removing it will fail unless you force.\nProceed with --force?\n\n".concat(e):"Remove this worktree?\n\n".concat(e);if(!window.confirm(r))return;let i=await S.mutateAsync({path:e,force:s||!0===t.locked});F({path:e,result:i})};return(0,r.jsxs)("div",{className:"mx-auto max-w-5xl space-y-4 p-6",children:[(0,r.jsxs)("header",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("h1",{className:"flex items-center gap-2 text-xl font-semibold tracking-tight",children:[(0,r.jsx)(c,{className:"h-5 w-5"}),"Worktrees"]}),(0,r.jsxs)("button",{type:"button",onClick:()=>M(),disabled:O,"aria-label":"Refresh worktrees",className:"flex items-center gap-1 rounded-md border border-border px-2 py-1 text-[11px] hover:bg-surface-elevated disabled:opacity-50",children:[(0,r.jsx)(u.A,{className:"h-3 w-3 ".concat(O?"animate-spin":"")}),"Refresh"]})]}),q?(0,r.jsx)("p",{className:"text-[11px] font-mono text-muted-foreground",children:q}):(0,r.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["No repository found. Set ",(0,r.jsx)("code",{className:"font-mono",children:"harness.defaultRepo"})," (absolute path) in Settings, or start NEXUS inside a checkout."]})]}),N&&(0,r.jsxs)("p",{className:"flex items-center gap-1 text-[11px] text-error",children:[(0,r.jsx)(d.A,{className:"h-3 w-3"}),N instanceof Error?N.message:"Failed to load worktrees"]}),o&&!l&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Querying /v1/worktrees…"}),l&&(0,r.jsx)(A,{summary:B}),C&&(0,r.jsx)("div",{"data-testid":"worktree-dispose-result","data-result-status":C.result.ok?"ok":"error",className:"rounded-md border px-2.5 py-1.5 text-[11px] ".concat(C.result.ok?"border-green-600/40 bg-green-600/5 text-green-700":"border-error/40 bg-error/5 text-error"),children:(0,r.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,r.jsxs)("span",{children:[C.result.ok?"".concat("orphan-session-cleanup"===C.result.action?"Cleared orphan session":"Removed worktree"," — ").concat(C.path):"Dispose failed — ".concat(null!=(n=C.result.error)?n:"unknown error"),C.result.detail&&(0,r.jsxs)("span",{className:"ml-1 font-mono text-[10px] opacity-80",children:["(",C.result.detail,")"]})]}),(0,r.jsx)("button",{type:"button",onClick:()=>F(null),className:"text-[10px] underline opacity-70 hover:opacity-100",children:"dismiss"})]})}),l&&I.length>0&&(0,r.jsx)("section",{"data-testid":"worktree-list",className:"overflow-x-auto rounded-md border border-border",children:(0,r.jsxs)("table",{className:"min-w-full text-[11px]",children:[(0,r.jsx)("thead",{className:"bg-surface-elevated",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Status"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Branch"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Path"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"SHA"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Owner"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-left font-medium",children:"Entered"}),(0,r.jsx)("th",{className:"px-2 py-1.5 text-right font-medium",children:"Actions"})]})}),(0,r.jsx)("tbody",{children:I.map(e=>{var t;let{view:s,status:i}=e,a=j[i];return(0,r.jsxs)("tr",{"data-testid":"worktree-row-".concat(s.path),"data-status":i,className:"border-t border-border",children:[(0,r.jsxs)("td",{className:"px-2 py-1.5",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wider ".concat(k[i]),children:[(0,r.jsx)(a,{className:"h-3 w-3"}),v[i]]}),s.isLocked&&(0,r.jsx)("span",{title:"locked",className:"ml-1 inline-flex items-center text-warning",children:(0,r.jsx)(h,{className:"h-3 w-3"})})]}),(0,r.jsx)("td",{className:"px-2 py-1.5 font-mono",children:null!=(t=s.branch)?t:(0,r.jsx)("span",{className:"text-muted-foreground",children:"—"})}),(0,r.jsx)("td",{className:"px-2 py-1.5 font-mono text-[10px] text-muted-foreground",children:s.path}),(0,r.jsx)("td",{className:"px-2 py-1.5 font-mono text-[10px] text-muted-foreground",children:s.sha.slice(0,7)}),(0,r.jsx)("td",{className:"px-2 py-1.5",children:s.session?(0,r.jsxs)("span",{className:"text-[10px] ".concat(s.session.alive?"text-foreground":"text-error"),children:["pid ",s.session.sessionId,s.session.alive?" (alive)":" (dead — orphan)"]}):(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"—"})}),(0,r.jsx)("td",{className:"px-2 py-1.5 text-[10px] text-muted-foreground",children:s.session?function(e,t){if(void 0===t)return"";let s=Math.floor(Math.max(0,e-t)/1e3);if(s<60)return"".concat(s,"s ago");let r=Math.floor(s/60);if(r<60)return"".concat(r,"m ago");let i=Math.floor(r/60);if(i<24)return"".concat(i,"h ago");let a=Math.floor(i/24);return"".concat(a,"d ago")}(P,s.session.enteredAt):""}),(0,r.jsx)("td",{className:"px-2 py-1.5 text-right",children:s.isMain?(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"—"}):(0,r.jsxs)("button",{type:"button","data-testid":"dispose-worktree-".concat(s.path),onClick:()=>T(s.path,{locked:s.isLocked}),disabled:S.isPending,className:"inline-flex items-center gap-1 rounded-md border border-border px-1.5 py-0.5 text-[10px] text-error hover:bg-error/10 disabled:opacity-50","aria-label":"Dispose worktree ".concat(s.path),children:[(0,r.jsx)(p.A,{className:"h-3 w-3"}),"Dispose"]})})]},s.path)})})]})}),l&&0===I.length&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"worktree-empty",children:"No worktrees registered."}),l&&R.length>0&&(0,r.jsxs)("section",{"data-testid":"orphaned-sessions",className:"space-y-1",children:[(0,r.jsxs)("h2",{className:"flex items-center gap-1 text-sm font-medium text-warning",children:[(0,r.jsx)(a.A,{className:"h-4 w-4"}),"Orphaned sessions (",R.length,")"]}),(0,r.jsxs)("p",{className:"text-[10px] text-muted-foreground",children:["Worktree directory was removed (e.g., via ",(0,r.jsx)("code",{children:"git worktree remove"}),") but the session JSON wasn't cleaned. Boot-time stale-cleanup will reap these the next time NEXUS restarts."]}),(0,r.jsx)("ul",{className:"space-y-1 text-[11px]",children:R.map(e=>(0,r.jsxs)("li",{"data-testid":"orphan-session-".concat(e.sessionId),className:"rounded-md border border-warning/40 bg-warning/5 px-2 py-1.5",children:[(0,r.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("span",{className:"font-mono",children:["pid ",e.sessionId]})," ",(0,r.jsxs)("span",{className:"text-muted-foreground",children:["(",e.alive?"alive (unusual)":"dead",")"]})]}),(0,r.jsxs)("button",{type:"button","data-testid":"cleanup-orphan-".concat(e.sessionId),onClick:()=>T(e.worktreePath),disabled:S.isPending,className:"inline-flex items-center gap-1 rounded-md border border-border px-1.5 py-0.5 text-[10px] text-error hover:bg-error/10 disabled:opacity-50","aria-label":"Clear orphan session ".concat(e.sessionId),children:[(0,r.jsx)(p.A,{className:"h-3 w-3"}),"Cleanup"]})]}),(0,r.jsxs)("div",{className:"font-mono text-[10px] text-muted-foreground",children:["branch ",(0,r.jsx)("strong",{children:e.branch})," \xb7 ",e.worktreePath]})]},e.sessionId))})]})]})}function A(e){let{summary:t}=e,s=[{label:"Total",value:t.total,cls:"text-foreground"},{label:"Active",value:t.active,cls:"text-green-700"},{label:"Orphan",value:t.orphan,cls:"text-error"},{label:"Idle",value:t.idle,cls:"text-muted-foreground"},{label:"Detached",value:t.detached,cls:"text-warning"}];return(0,r.jsx)("div",{"data-testid":"worktree-summary",className:"flex flex-wrap items-baseline gap-3 text-[11px]",children:s.map(e=>(0,r.jsxs)("span",{className:"flex items-baseline gap-1",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:e.label}),(0,r.jsx)("span",{className:"font-medium ".concat(e.cls),children:e.value})]},e.label))})}function O(){return(0,r.jsx)(N,{})}},89762:(e,t,s)=>{"use strict";s.d(t,{n:()=>u});var r=s(60500),i=s(12146),a=s(23515),n=s(46484),l=s(5318),o=class extends n.Q{#e;#t=void 0;#s;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),(0,l.f8)(this.options,t)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),t?.mutationKey&&this.options.mutationKey&&(0,l.EN)(t.mutationKey)!==(0,l.EN)(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#s?.removeObserver(this),this.#s=this.#e.getMutationCache().build(this.#e,this.options),this.#s.addObserver(this),this.#s.execute(e)}#i(){let e=this.#s?.state??(0,i.$)();this.#t={...e,isPending:"pending"===e.status,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset}}#a(e){a.jG.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,s=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#r.onSuccess?.(e.data,t,s,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,s,r)}catch(e){Promise.reject(e)}}else if(e?.type==="error"){try{this.#r.onError?.(e.error,t,s,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,s,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},c=s(59405);function u(e,t){let s=(0,c.jE)(t),[i]=r.useState(()=>new o(s,e));r.useEffect(()=>{i.setOptions(e)},[i,e]);let n=r.useSyncExternalStore(r.useCallback(e=>i.subscribe(a.jG.batchCalls(e)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),u=r.useCallback((e,t)=>{i.mutate(e,t).catch(l.lQ)},[i]);if(n.error&&(0,l.GU)(i.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:u,mutateAsync:n.mutate}}}},e=>{e.O(0,[9538,9656,3869,6390,3170,7358],()=>e(e.s=18238)),_N_E=e.O()}]);