elanous 0.2.16 → 0.2.17

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 (228) 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/{1307-b46d45b705e8c9ae.js → 1307-aac7332576c4d6fc.js} +1 -1
  4. package/apps/pwa/out/_next/static/chunks/{6877-7c6208705c284124.js → 6877-fe94e76a5841ee9b.js} +1 -1
  5. package/apps/pwa/out/_next/static/chunks/8401-4ce1c42c8d89903f.js +1 -0
  6. package/apps/pwa/out/_next/static/chunks/899-f41be85e8a680651.js +1 -0
  7. package/apps/pwa/out/_next/static/chunks/9247-269e4464cc4b491c.js +1 -0
  8. package/apps/pwa/out/_next/static/chunks/app/approvals/page-3143b07a817d1da9.js +1 -0
  9. package/apps/pwa/out/_next/static/chunks/app/autopilot/{page-3cb52e5ea8fc2fa5.js → page-17ba086ef82d339b.js} +1 -1
  10. package/apps/pwa/out/_next/static/chunks/app/board/page-7eb661ff23af7da2.js +1 -0
  11. package/apps/pwa/out/_next/static/chunks/app/botlab/page-6b8444914da74ca6.js +1 -0
  12. package/apps/pwa/out/_next/static/chunks/app/bots/{page-482c5dbde699947c.js → page-6e5c3a867557298b.js} +1 -1
  13. package/apps/pwa/out/_next/static/chunks/app/ceo/{page-1e962b31d1f11081.js → page-7110f732f45bf944.js} +1 -1
  14. package/apps/pwa/out/_next/static/chunks/app/chat/{page-8c2d9526164f5d09.js → page-9a41d65355fc25b9.js} +1 -1
  15. package/apps/pwa/out/_next/static/chunks/app/consult/page-5e77cd1802567c89.js +1 -0
  16. package/apps/pwa/out/_next/static/chunks/app/control/page-41afec0b255ed2bb.js +1 -0
  17. package/apps/pwa/out/_next/static/chunks/app/design-check/{page-c53598cfce6156f2.js → page-4187666132fc98c4.js} +1 -1
  18. package/apps/pwa/out/_next/static/chunks/app/editor/{page-13a63953f53c6a23.js → page-09328d499162bae4.js} +1 -1
  19. package/apps/pwa/out/_next/static/chunks/app/exec/{page-5d3c8429d04f3831.js → page-29ff3a8f84f03b6a.js} +1 -1
  20. package/apps/pwa/out/_next/static/chunks/app/field/{page-3193bdc0bbab047a.js → page-80ec7401bc83f511.js} +1 -1
  21. package/apps/pwa/out/_next/static/chunks/app/inside/{page-76270efaee638f17.js → page-ab93b240f687d69a.js} +1 -1
  22. package/apps/pwa/out/_next/static/chunks/app/intake/{page-6107ca8ddd5e3bdd.js → page-fc7d86467291ae38.js} +1 -1
  23. package/apps/pwa/out/_next/static/chunks/app/{layout-dce686e582c23937.js → layout-de43a186e5ba5683.js} +1 -1
  24. package/apps/pwa/out/_next/static/chunks/app/live/{page-d3d53b146416e422.js → page-8b08cafad27759c9.js} +1 -1
  25. package/apps/pwa/out/_next/static/chunks/app/loops/page-0e2d6985fb42cd2f.js +1 -0
  26. package/apps/pwa/out/_next/static/chunks/app/market/page-13e4108999f58d13.js +1 -0
  27. package/apps/pwa/out/_next/static/chunks/app/missions/[id]/page-e8296ee284aa1293.js +1 -0
  28. package/apps/pwa/out/_next/static/chunks/app/morning/{page-4167348049166852.js → page-043a9111e74f6b24.js} +1 -1
  29. package/apps/pwa/out/_next/static/chunks/app/{not-found-de52e8fdf9095f7a.js → not-found-23a4601ceb7f452e.js} +1 -1
  30. package/apps/pwa/out/_next/static/chunks/app/observatory/page-1ed1324b1dc36754.js +1 -0
  31. package/apps/pwa/out/_next/static/chunks/app/ops/checklist/{page-ca3952cd78a83ca2.js → page-10d958605a77b3bd.js} +1 -1
  32. package/apps/pwa/out/_next/static/chunks/app/ops/release/{page-5b042736aa113756.js → page-166745e51ac0c7b0.js} +1 -1
  33. package/apps/pwa/out/_next/static/chunks/app/ops/seats/{page-acb749f1e432bcf3.js → page-a04260b8ccc968d4.js} +1 -1
  34. package/apps/pwa/out/_next/static/chunks/app/outputs/page-7a1d85e121065cc8.js +1 -0
  35. package/apps/pwa/out/_next/static/chunks/app/page-1f50e3d4e13435f4.js +1 -0
  36. package/apps/pwa/out/_next/static/chunks/app/reflection/{page-1ebfe049c640e171.js → page-12916918988ac97e.js} +1 -1
  37. package/apps/pwa/out/_next/static/chunks/app/scheduler/page-d8a3347a9d0c3f4a.js +1 -0
  38. package/apps/pwa/out/_next/static/chunks/app/sessions/page-a9117d2cd3093d36.js +1 -0
  39. package/apps/pwa/out/_next/static/chunks/app/settings/devices/{page-31fa1ce4c4aff9ae.js → page-5a64cb5208c6a8fd.js} +1 -1
  40. package/apps/pwa/out/_next/static/chunks/app/settings/{page-0f5cd57ca928f42b.js → page-1407ec83ea64c1f9.js} +1 -1
  41. package/apps/pwa/out/_next/static/chunks/app/setup/done/{page-abe8e3b74bea1ffc.js → page-1d824510df025d18.js} +1 -1
  42. package/apps/pwa/out/_next/static/chunks/app/setup/page-6e878ebbe1737d00.js +1 -0
  43. package/apps/pwa/out/_next/static/chunks/app/share/{page-d28573d6792b4275.js → page-7f49fe645d5132f7.js} +1 -1
  44. package/apps/pwa/out/_next/static/chunks/app/showroom/{page-59f03fda76c03d22.js → page-81a4e7f8dbfe74cb.js} +1 -1
  45. package/apps/pwa/out/_next/static/chunks/app/tasks/{page-d751de5f8062ff5e.js → page-27d71f131acd9320.js} +1 -1
  46. package/apps/pwa/out/_next/static/chunks/app/term/page-3ab59d19913b200e.js +1 -0
  47. package/apps/pwa/out/_next/static/chunks/app/today/page-bf85b2f5bf077925.js +1 -0
  48. package/apps/pwa/out/_next/static/chunks/app/trace/page-424659bacfb8cdd7.js +1 -0
  49. package/apps/pwa/out/_next/static/chunks/app/vault/page-ab32a8f522a60371.js +1 -0
  50. package/apps/pwa/out/_next/static/chunks/app/workflows/chat-ui/{page-d4aef67abf264874.js → page-fc2df261f8a2c7df.js} +1 -1
  51. package/apps/pwa/out/_next/static/chunks/app/workflows/{page-1ea64acadd704ace.js → page-09461366af82ef13.js} +1 -1
  52. package/apps/pwa/out/_next/static/chunks/app/workspace/{page-3544f154c87b43ee.js → page-5d4fef9ccd7d406b.js} +1 -1
  53. package/apps/pwa/out/_next/static/chunks/app/worktrees/{page-30c2073bfc21c004.js → page-ea90a8ac73ce2749.js} +1 -1
  54. package/apps/pwa/out/approvals/index.html +1 -1
  55. package/apps/pwa/out/approvals/index.txt +13 -13
  56. package/apps/pwa/out/autopilot/index.html +1 -1
  57. package/apps/pwa/out/autopilot/index.txt +13 -13
  58. package/apps/pwa/out/board/index.html +1 -1
  59. package/apps/pwa/out/board/index.txt +13 -13
  60. package/apps/pwa/out/botlab/index.html +1 -1
  61. package/apps/pwa/out/botlab/index.txt +13 -13
  62. package/apps/pwa/out/bots/index.html +1 -1
  63. package/apps/pwa/out/bots/index.txt +13 -13
  64. package/apps/pwa/out/ceo/index.html +1 -1
  65. package/apps/pwa/out/ceo/index.txt +13 -13
  66. package/apps/pwa/out/chat/index.html +1 -1
  67. package/apps/pwa/out/chat/index.txt +13 -13
  68. package/apps/pwa/out/consult/index.html +1 -1
  69. package/apps/pwa/out/consult/index.txt +13 -13
  70. package/apps/pwa/out/control/index.html +1 -1
  71. package/apps/pwa/out/control/index.txt +13 -13
  72. package/apps/pwa/out/design-check/index.html +1 -1
  73. package/apps/pwa/out/design-check/index.txt +13 -13
  74. package/apps/pwa/out/editor/index.html +1 -1
  75. package/apps/pwa/out/editor/index.txt +13 -13
  76. package/apps/pwa/out/exec/index.html +1 -1
  77. package/apps/pwa/out/exec/index.txt +13 -13
  78. package/apps/pwa/out/field/index.html +1 -1
  79. package/apps/pwa/out/field/index.txt +13 -13
  80. package/apps/pwa/out/healthz +1 -1
  81. package/apps/pwa/out/index.html +1 -1
  82. package/apps/pwa/out/index.txt +13 -13
  83. package/apps/pwa/out/inside/index.html +1 -1
  84. package/apps/pwa/out/inside/index.txt +13 -13
  85. package/apps/pwa/out/intake/index.html +1 -1
  86. package/apps/pwa/out/intake/index.txt +13 -13
  87. package/apps/pwa/out/live/index.html +1 -1
  88. package/apps/pwa/out/live/index.txt +13 -13
  89. package/apps/pwa/out/loops/index.html +1 -1
  90. package/apps/pwa/out/loops/index.txt +13 -13
  91. package/apps/pwa/out/market/index.html +1 -1
  92. package/apps/pwa/out/market/index.txt +13 -13
  93. package/apps/pwa/out/missions/placeholder/index.html +1 -1
  94. package/apps/pwa/out/missions/placeholder/index.txt +13 -13
  95. package/apps/pwa/out/morning/index.html +1 -1
  96. package/apps/pwa/out/morning/index.txt +13 -13
  97. package/apps/pwa/out/observatory/index.html +1 -1
  98. package/apps/pwa/out/observatory/index.txt +13 -13
  99. package/apps/pwa/out/ops/checklist/index.html +1 -1
  100. package/apps/pwa/out/ops/checklist/index.txt +13 -13
  101. package/apps/pwa/out/ops/release/index.html +1 -1
  102. package/apps/pwa/out/ops/release/index.txt +13 -13
  103. package/apps/pwa/out/ops/seats/index.html +1 -1
  104. package/apps/pwa/out/ops/seats/index.txt +13 -13
  105. package/apps/pwa/out/outputs/index.html +1 -1
  106. package/apps/pwa/out/outputs/index.txt +13 -13
  107. package/apps/pwa/out/reflection/index.html +1 -1
  108. package/apps/pwa/out/reflection/index.txt +14 -14
  109. package/apps/pwa/out/scheduler/index.html +1 -1
  110. package/apps/pwa/out/scheduler/index.txt +13 -13
  111. package/apps/pwa/out/sessions/index.html +1 -1
  112. package/apps/pwa/out/sessions/index.txt +13 -13
  113. package/apps/pwa/out/settings/devices/index.html +1 -1
  114. package/apps/pwa/out/settings/devices/index.txt +13 -13
  115. package/apps/pwa/out/settings/index.html +1 -1
  116. package/apps/pwa/out/settings/index.txt +13 -13
  117. package/apps/pwa/out/setup/done/index.html +1 -1
  118. package/apps/pwa/out/setup/done/index.txt +13 -13
  119. package/apps/pwa/out/setup/index.html +1 -1
  120. package/apps/pwa/out/setup/index.txt +13 -13
  121. package/apps/pwa/out/share/index.html +1 -1
  122. package/apps/pwa/out/share/index.txt +13 -13
  123. package/apps/pwa/out/showroom/index.html +1 -1
  124. package/apps/pwa/out/showroom/index.txt +13 -13
  125. package/apps/pwa/out/tasks/index.html +1 -1
  126. package/apps/pwa/out/tasks/index.txt +13 -13
  127. package/apps/pwa/out/term/index.html +1 -1
  128. package/apps/pwa/out/term/index.txt +13 -13
  129. package/apps/pwa/out/today/index.html +1 -1
  130. package/apps/pwa/out/today/index.txt +13 -13
  131. package/apps/pwa/out/trace/index.html +1 -1
  132. package/apps/pwa/out/trace/index.txt +13 -13
  133. package/apps/pwa/out/vault/index.html +1 -1
  134. package/apps/pwa/out/vault/index.txt +13 -13
  135. package/apps/pwa/out/workflows/chat-ui/index.html +1 -1
  136. package/apps/pwa/out/workflows/chat-ui/index.txt +13 -13
  137. package/apps/pwa/out/workflows/index.html +1 -1
  138. package/apps/pwa/out/workflows/index.txt +13 -13
  139. package/apps/pwa/out/workspace/index.html +1 -1
  140. package/apps/pwa/out/workspace/index.txt +13 -13
  141. package/apps/pwa/out/worktrees/index.html +1 -1
  142. package/apps/pwa/out/worktrees/index.txt +13 -13
  143. package/graphs/intake/intake-daily.yaml +9 -2
  144. package/graphs/intake/news-sources.yaml +4 -0
  145. package/graphs/intake/recipes.yaml +6 -1
  146. package/package.json +1 -1
  147. package/scripts/__fixtures__/intake-news.xml +7 -0
  148. package/scripts/intake-news.ts +169 -0
  149. package/scripts/release-loop/docs-land-node.ts +69 -10
  150. package/scripts/release-loop/publish-node.ts +2 -2
  151. package/scripts/release-loop/release-docs.ts +134 -0
  152. package/scripts/release-loop/version-node.ts +7 -4
  153. package/scripts/release-story/draft.ts +42 -14
  154. package/src/agent-mission/driver.ts +53 -10
  155. package/src/autopilot/track-agent.ts +5 -3
  156. package/src/cli/autopilot-cli.ts +66 -0
  157. package/src/cli/decisions-cli.ts +4 -1
  158. package/src/cli/intake-cli.ts +1 -1
  159. package/src/cli/log-event-names.ts +1 -0
  160. package/src/cli/pr-cli.ts +12 -1
  161. package/src/cli/provider-cli.ts +14 -0
  162. package/src/cli/self-update-canary.ts +46 -0
  163. package/src/cli/self-update.ts +200 -1
  164. package/src/context-card/index.ts +45 -0
  165. package/src/context-card/task.ts +76 -0
  166. package/src/dashboard/slash-runtime/dashboard-handlers.ts +2 -0
  167. package/src/decisions/decision-ledger.ts +10 -1
  168. package/src/harness/harness-cli-command.ts +142 -10
  169. package/src/harness/harness-pod-dispatch.ts +11 -0
  170. package/src/harness/harness-queue.ts +86 -7
  171. package/src/harness/nested-elanous-policy.ts +23 -4
  172. package/src/hq/fence-wrapper.ts +123 -0
  173. package/src/hq/hq.ts +8 -0
  174. package/src/index.ts +57 -8
  175. package/src/intake-plane/digest.ts +39 -4
  176. package/src/nexus/api/grid.ts +61 -0
  177. package/src/nexus/api/http-server.ts +19 -1
  178. package/src/nexus/api/task-cards-api.ts +19 -0
  179. package/src/oauth/codex.ts +82 -2
  180. package/src/release-loop/landing-freeze.ts +18 -10
  181. package/src/seat-loop/seat-loop.ts +95 -31
  182. package/src/self-dev/ask-launch-flow.ts +26 -7
  183. package/src/self-dev/run-store.ts +5 -1
  184. package/src/self-dev/run-supervisor.ts +7 -1
  185. package/src/self-dev/supervisor-verdict-edges.ts +46 -0
  186. package/src/self-implement/frozen-merges.ts +25 -20
  187. package/src/self-implement/goal-author-clarification.ts +81 -0
  188. package/src/self-implement/goal-author-cli.ts +33 -5
  189. package/src/self-implement/goal-author.ts +88 -12
  190. package/src/self-implement/goal-clarification-escalation.ts +37 -1
  191. package/src/self-implement/goal-document-write.ts +28 -0
  192. package/src/self-implement/heal-intake.ts +4 -0
  193. package/src/self-implement/host-regate.ts +3 -1
  194. package/src/self-implement/orchestrator.ts +19 -1
  195. package/src/task-agent/actions.ts +118 -0
  196. package/src/task-agent/judge.ts +96 -0
  197. package/src/task-cards/card-store.ts +4 -1
  198. package/src/task-orchestrator/surfaces/pod-failure-reason.ts +33 -4
  199. package/src/task-orchestrator/surfaces/pod-lease.ts +5 -2
  200. package/src/task-orchestrator/surfaces/pod-pool.ts +81 -13
  201. package/src/task-orchestrator/surfaces/self-implement-pod.ts +151 -29
  202. package/src/telegram-commands.ts +1 -1
  203. package/src/telegram-loops-command.ts +21 -14
  204. package/src/user-config.ts +25 -3
  205. package/src/version/packed-revision.json +1 -1
  206. package/apps/pwa/out/_next/static/chunks/8827-e2f5b09a8d37e83b.js +0 -1
  207. package/apps/pwa/out/_next/static/chunks/899-46946fe8363e1262.js +0 -1
  208. package/apps/pwa/out/_next/static/chunks/9247-29d889b809288e65.js +0 -1
  209. package/apps/pwa/out/_next/static/chunks/app/approvals/page-79c3ed84baaedd03.js +0 -1
  210. package/apps/pwa/out/_next/static/chunks/app/board/page-a424ef80885d1743.js +0 -1
  211. package/apps/pwa/out/_next/static/chunks/app/botlab/page-c1e20d7d338713f1.js +0 -1
  212. package/apps/pwa/out/_next/static/chunks/app/consult/page-ffff6d819fbc6e0f.js +0 -1
  213. package/apps/pwa/out/_next/static/chunks/app/control/page-a0e2a6d1bfb52fc5.js +0 -1
  214. package/apps/pwa/out/_next/static/chunks/app/loops/page-1a61c7ca1ceb3ae7.js +0 -1
  215. package/apps/pwa/out/_next/static/chunks/app/market/page-51f811fa119308b6.js +0 -1
  216. package/apps/pwa/out/_next/static/chunks/app/missions/[id]/page-dacff46049e1557e.js +0 -1
  217. package/apps/pwa/out/_next/static/chunks/app/observatory/page-36a7d994f4ca0299.js +0 -1
  218. package/apps/pwa/out/_next/static/chunks/app/outputs/page-cd78862707999911.js +0 -1
  219. package/apps/pwa/out/_next/static/chunks/app/page-54b9ef8afe6278fd.js +0 -1
  220. package/apps/pwa/out/_next/static/chunks/app/scheduler/page-57924393e3e4e539.js +0 -1
  221. package/apps/pwa/out/_next/static/chunks/app/sessions/page-9e0ce6c8129fa641.js +0 -1
  222. package/apps/pwa/out/_next/static/chunks/app/setup/page-4364ef9f4e7c7f0f.js +0 -1
  223. package/apps/pwa/out/_next/static/chunks/app/term/page-fe1759f94003b32b.js +0 -1
  224. package/apps/pwa/out/_next/static/chunks/app/today/page-d64c984e855c8c68.js +0 -1
  225. package/apps/pwa/out/_next/static/chunks/app/trace/page-86914b0dee8ab7f8.js +0 -1
  226. package/apps/pwa/out/_next/static/chunks/app/vault/page-9afdee66b820c76e.js +0 -1
  227. /package/apps/pwa/out/_next/static/{rv9cierV0jSOvDBm1g0XB → yRA5ur6DcPl0YHSRheH2O}/_buildManifest.js +0 -0
  228. /package/apps/pwa/out/_next/static/{rv9cierV0jSOvDBm1g0XB → yRA5ur6DcPl0YHSRheH2O}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8827],{2021:(e,t,n)=>{n.d(t,{F:()=>d});var r=n(55539);n(46124);var a=n(245),s=n(48105),l=n(66901),o=n(83001),i=n(4333),c=n(44373);function d(e){let{className:t,children:n,...o}=e;return(0,r.jsxs)(a.V,{"data-slot":"scroll-area",className:(0,c.cn)("relative",t),...o,children:[(0,r.jsx)(s.B,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:n}),(0,r.jsx)(u,{}),(0,r.jsx)(l.I,{})]})}function u(e){let{className:t,orientation:n="vertical",...a}=e;return(0,r.jsx)(o.V,{"data-slot":"scroll-area-scrollbar","data-orientation":n,orientation:n,className:(0,c.cn)("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",t),...a,children:(0,r.jsx)(i.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},9851:(e,t,n)=>{n.d(t,{V:()=>_});var r=n(55539),a=n(46124),s=n(85535),l=n(69147),o=n(94226),i=n(16190),c=n(87433),d=n(67327),u=n(9734),m=n(8114),f=n(65194),p=n(44373),x=n(53314),h=n(71633),g=n(36485),b=n(76573),v=n(25042),j=n(15151),y=n(72215),w=n(46923);function k(e){let{open:t,image:n,filename:s="photo.jpg",onClose:l}=e,{config:o}=(0,j.Q)(),[i,c]=(0,a.useState)("idle"),[m,f]=(0,a.useState)(""),[p,x]=(0,a.useState)("minimal"),[h,g]=(0,a.useState)("minimal"),k=(0,w.hn)(),[N,S]=(0,a.useState)(k.defaultUseLlmVision),[I,C]=(0,a.useState)(k.defaultPreferHandwriting),[D,E]=(0,a.useState)(""),[L,A]=(0,a.useState)(""),[M,T]=(0,a.useState)("");async function R(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:N,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:I;if(!n)return;if(!o.baseUrl){A("Daemon URL 미설정 — Settings 에서 입력"),c("error");return}c("ocr"),A("");let a=new FormData;a.append("image",n,s),a.append("polishMode",e);let l=[];t&&l.push("context-aware","diagrams"),r&&l.push("handwriting"),l.length>0&&a.append("strengths",l.join(",")),(0,y.cY)("notes.ocr.start",{polishMode:e,vision:t,handwriting:r,filename:s,size:n.size});try{let t=await fetch("".concat(o.baseUrl,"/v1/notes/from-image"),{method:"POST",body:a,...o.token?{headers:{authorization:"Bearer ".concat(o.token)}}:{}});if(!t.ok){let e=await t.text().catch(()=>"");A("OCR 실패 (HTTP ".concat(t.status,") ").concat(e.slice(0,160))),c("error"),(0,y.cY)("notes.ocr.error",{status:t.status,detail:e.slice(0,200)});return}let n=await t.json(),r=n.usedLlmPolish?n.polishMode:"minimal";if(0===n.markdown.trim().length){A(n.usedLlmPolish?"이미지에서 텍스트를 추출하지 못했습니다. 다른 사진으로 다시 시도해주세요.":"이미지에서 텍스트를 추출하지 못했습니다. 다른 사진을 사용하거나 polishMode를 'enrich'로 바꾸어 LLM polish를 시도해주세요."),x(n.polishMode),g(r),E(n.provider),c("error"),(0,y.cY)("notes.ocr.empty",{provider:n.provider,requested:e,applied:r,usedLlmPolish:n.usedLlmPolish});return}f(n.markdown),T(n.markdown),E(n.provider),x(n.polishMode),g(r),c("review"),(0,y.cY)("notes.ocr.ok",{provider:n.provider,requested:e,applied:r,usedLlmPolish:n.usedLlmPolish,chars:n.markdown.length})}catch(e){A("OCR 실패: ".concat(String(e instanceof Error?e.message:e))),c("error"),(0,y.cY)("notes.ocr.exception",{reason:String(e)})}}async function U(){if(!o.baseUrl){A("Daemon URL 미설정"),c("error");return}let e=m!==M;c("saving"),(0,y.cY)("notes.save.start",{provider:D,selectedPolishMode:p,appliedPolishMode:h,edited:e,chars:m.length}),e&&P("edit");try{let e=await fetch("".concat(o.baseUrl,"/v1/notes/save"),{method:"POST",headers:{"content-type":"application/json",...o.token?{authorization:"Bearer ".concat(o.token)}:{}},body:JSON.stringify({markdown:m,sourceProvider:D,polishMode:h})});if(!e.ok){let t=await e.text().catch(()=>"");A("저장 실패 (HTTP ".concat(e.status,") ").concat(t.slice(0,160))),c("error"),(0,y.cY)("notes.save.error",{status:e.status,detail:t.slice(0,200)});return}let t=await e.json();c("saved"),d.oR.success("\uD83D\uDCDD 저장됨 — ".concat(t.vaultLabel," \xb7 ").concat(t.knowledgeId)),(0,y.cY)("notes.save.ok",{knowledgeId:t.knowledgeId,vaultLabel:t.vaultLabel}),setTimeout(l,400)}catch(e){A("저장 실패: ".concat(String(e instanceof Error?e.message:e))),c("error"),(0,y.cY)("notes.save.exception",{reason:String(e)})}}function P(e){o.baseUrl&&fetch("".concat(o.baseUrl,"/v1/metrics/notes-event"),{method:"POST",headers:{"content-type":"application/json",...o.token?{authorization:"Bearer ".concat(o.token)}:{}},body:JSON.stringify({type:e,polishMode:p})}).catch(()=>{})}function _(){let e=m!==M;(0,y.cY)("notes.cancel",{phase:i,edited:e,chars:m.length}),P("cancel"),e&&"review"===i&&P("discard"),l()}return(0,a.useEffect)(()=>{if(!t){c("idle"),f(""),T(""),E(""),A(""),x("minimal"),g("minimal");let e=(0,w.hn)();S(e.defaultUseLlmVision),C(e.defaultPreferHandwriting)}},[t]),(0,a.useEffect)(()=>{t&&n&&"idle"===i&&R(p)},[t,n]),(0,r.jsx)(v.lG,{open:t,onOpenChange:e=>{e||_()},children:(0,r.jsxs)(v.Cf,{className:"sm:max-w-lg",children:[(0,r.jsxs)(v.c7,{children:[(0,r.jsx)(v.L3,{children:"사진 → 마크다운 노트"}),(0,r.jsx)(v.rr,{children:"OCR 로 추출한 본문을 검토 + 편집 후 저장합니다."})]}),"ocr"===i&&(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 py-12 text-muted-foreground",children:[(0,r.jsx)(b.A,{className:"h-4 w-4 animate-spin"}),(0,r.jsx)("span",{children:"OCR 인식 중…"})]}),"saving"===i&&(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 py-12 text-muted-foreground",children:[(0,r.jsx)(b.A,{className:"h-4 w-4 animate-spin"}),(0,r.jsx)("span",{children:"저장 중…"})]}),"saved"===i&&(0,r.jsx)("div",{className:"flex items-center justify-center py-12 text-emerald-600",children:"✓ 저장 완료"}),"error"===i&&(0,r.jsxs)("div",{className:"space-y-3 py-4",children:[(0,r.jsx)("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive",children:L}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(u.$,{variant:"ghost",onClick:_,children:"닫기"}),n&&(0,r.jsx)(u.$,{onClick:()=>R(p),children:"다시 시도"})]})]}),"review"===i&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{children:["provider: ",(0,r.jsx)("code",{children:D||"?"})]}),(0,r.jsx)("span",{children:"\xb7"}),(0,r.jsxs)("label",{className:"flex items-center gap-1",children:["polish:",(0,r.jsxs)("select",{value:p,onChange:e=>{let t=e.target.value;x(t),t!==h&&R(t)},className:"rounded border border-input bg-background px-1 py-0.5","aria-label":"polish mode",children:[(0,r.jsx)("option",{value:"minimal",children:"minimal (raw)"}),(0,r.jsx)("option",{value:"enrich",children:"enrich (polished)"})]})]}),(0,r.jsx)("span",{children:"\xb7"}),(0,r.jsxs)("label",{className:"flex items-center gap-1",title:"LLM 비전 우선시 — 더 정확하지만 느림 + 비쌈",children:[(0,r.jsx)("input",{type:"checkbox",checked:N,onChange:e=>{let t=e.target.checked;S(t),R(p,t,I)},"aria-label":"prefer LLM vision"}),"LLM 비전"]}),(0,r.jsx)("span",{children:"\xb7"}),(0,r.jsxs)("label",{className:"flex items-center gap-1",title:"손글씨 우선시 — handwriting strength 추가 (registry 점수 boost)",children:[(0,r.jsx)("input",{type:"checkbox",checked:I,onChange:e=>{let t=e.target.checked;C(t),R(p,N,t)},"aria-label":"prefer handwriting"}),"손글씨"]}),(0,r.jsx)("span",{children:"\xb7"}),(0,r.jsxs)("span",{"data-testid":"notes-applied-polish",children:["applied: ",(0,r.jsx)("code",{children:h}),"enrich"===p&&"minimal"===h&&(0,r.jsx)("span",{className:"ml-1 text-amber-600",children:"(LLM polish 비활성)"})]}),(0,r.jsx)(u.$,{type:"button",variant:"ghost",size:"sm",className:"ml-auto text-xs",onClick:()=>R(p),"aria-label":"re-run OCR",children:"Re-OCR"})]}),(0,r.jsx)("textarea",{value:m,onChange:e=>f(e.target.value),rows:12,placeholder:"markdown 본문…","aria-label":"markdown editor",className:"w-full resize-y rounded-md border border-input bg-background px-3 py-2 font-mono text-xs shadow-xs focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,r.jsxs)(v.Es,{children:[(0,r.jsx)(u.$,{variant:"outline",onClick:_,children:"취소"}),(0,r.jsx)(u.$,{onClick:()=>void U(),disabled:0===m.trim().length,children:"저장"})]})]})]})})}function N(){let e=(0,a.useRef)(null),[t,n]=(0,a.useState)(!1),[s,l]=(0,a.useState)(null),[o,i]=(0,a.useState)("photo.jpg");return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",onClick:()=>{var t;return null==(t=e.current)?void 0:t.click()},"aria-label":"save photo as note",title:"사진 → 마크다운 노트로 저장",className:"rounded p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground",children:(0,r.jsx)(g.A,{className:"h-3.5 w-3.5"})}),(0,r.jsx)("input",{ref:e,type:"file",accept:"image/*",capture:"environment",className:"hidden",onChange:function(e){var t;let r=null==(t=e.target.files)?void 0:t[0];e.target.value="",r&&(l(r),i(r.name),n(!0))}}),(0,r.jsx)(k,{open:t,image:s,filename:o,onClose:function(){n(!1),l(null)}})]})}var S=n(37100),I=n(56540);function C(){var e,t,n;let{client:s}=(0,j.Q)(),[l,o]=(0,a.useState)([]),[i,c]=(0,a.useState)(""),[u,m]=(0,a.useState)(!1),f=(0,a.useCallback)(async()=>{try{var e,t;let n=await s.fetchJson("/v1/setup/llm-providers");o(null!=(e=n.providers)?e:[]),c(null!=(t=n.activeProvider)?t:"")}catch(e){}},[s]);(0,a.useEffect)(()=>{f()},[f]);let p=l.filter(e=>"apiKey"===e.flow&&e.hasSavedKey||"auto"===e.flow),x=(0,a.useCallback)(async()=>{if(u||0===p.length)return;let e=p.findIndex(e=>e.provider===i),t=p[(e+1)%p.length];if(t.provider!==i||1!==p.length){m(!0);try{let e=await s.fetchJson("/v1/setup/llm-provider",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({provider:t.provider})});if(e&&e.error)d.oR.error("provider 전환 실패: ".concat(e.error));else{var n,r;c(null!=(r=null==e||null==(n=e.active)?void 0:n.provider)?r:t.provider)}}catch(e){d.oR.error("provider 전환 실패: ".concat(e instanceof Error?e.message:e))}finally{m(!1)}}},[u,p,i,s]);if(0===p.length)return null;let h=null!=(n=null!=(t=null==(e=l.find(e=>e.provider===i))?void 0:e.label)?t:i)?n:p[0].label;return(0,r.jsx)("button",{type:"button",onClick:()=>void x(),disabled:u||p.length<2,className:"rounded-full border border-border bg-card px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground disabled:opacity-60",title:p.length<2?"LLM provider: ".concat(h):"클릭하면 다음 provider 로 순환 (현재 ".concat(h,")"),children:h})}var D=n(51281),E=n(18060);function L(e){let{seats:t,selected:n,onSelect:a,disabled:s}=e;return 0===t.length?null:(0,r.jsx)("div",{className:"mb-2 flex flex-wrap items-center gap-1.5","aria-label":"요청할 자리",children:t.map(e=>(0,r.jsx)("button",{type:"button",disabled:s,"aria-pressed":n===e.id,onClick:()=>a(n===e.id?null:e.id),className:(0,p.cn)("rounded-full border px-2.5 py-1 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",n===e.id?"border-accent bg-accent/15 font-semibold text-foreground":"border-border text-muted-foreground hover:bg-muted",s&&"opacity-60"),children:e.title},e.id))})}let A=[],M="elanous.seat-ask.client",T=null;function R(e){return/^\s*CTO\s*에게\s*물어봐(?:\s*[::]\s*|\s+)\S/i.test(e)}let U="elanous.pwa.chat.promptHistory.v1";function P(e,t){let n=e.lastIndexOf(t);if(n<0)return null;let r=e.slice(n+1);if(/[\s]/.test(r))return null;if(n>0){let t=e[n-1];if(!/\s/.test(t))return null}return r}function _(e){let{onSubmit:t,disabled:n,attachments:g=A,onAttached:b,onRemoveAttachment:v,tabId:w,voice:k,onListFiles:_,onListSkills:O,prefill:F}=e,{client:z,config:Y}=(0,j.Q)(),[q,H]=(0,a.useState)([]),[J,$]=(0,a.useState)(null),[B,K]=(0,a.useState)([]),[V,W]=(0,a.useState)([]),G=(0,a.useRef)(null);G.current||(G.current=function(){let e=null;try{e=window.sessionStorage.getItem(M)}catch(e){}try{var t,n;null!=e||(e=null!=(n=null==(t=/(?:^|; )elanous\.seat-ask\.client=([a-f0-9-]{36})(?:;|$)/i.exec(document.cookie))?void 0:t[1])?n:null)}catch(e){}null!=e||(e=null!=T?T:crypto.randomUUID()),T=e;try{window.sessionStorage.setItem(M,e)}catch(e){}try{document.cookie="".concat(M,"=").concat(e,"; Path=/; SameSite=Lax; Max-Age=2592000")}catch(e){}return e}()),(0,a.useEffect)(()=>{if("function"!=typeof(null==z?void 0:z.listSeatAskAnswers))return()=>{};let e=!0;if(!G.current)return()=>{e=!1};let t=!1;try{var n;let e=JSON.parse(null!=(n=window.sessionStorage.getItem("elanous.seat-ask.messages"))?n:"[]");e.length&&W(t=>[...t.filter(t=>{let{id:n}=t;return!e.some(e=>e.id===n)}),...e])}catch(e){}let r=async()=>{if(!t){t=!0;try{let{items:t}=await z.listSeatAskAnswers(G.current);if(!e||!t.length)return;let r=t.map(e=>{let{id:t,text:n}=e;return{id:t,text:n}});W(e=>[...e,...r.filter(t=>{let{id:n}=t;return!e.some(e=>e.id===n)})]);try{var n;let a=JSON.parse(null!=(n=window.sessionStorage.getItem("elanous.seat-ask.messages"))?n:"[]"),s=[...a,...r.filter(e=>{let{id:t}=e;return!a.some(e=>e.id===t)})];window.sessionStorage.setItem("elanous.seat-ask.messages",JSON.stringify(s)),e&&await z.acknowledgeSeatAskAnswers(G.current,t.map(e=>{let{id:t}=e;return t}))}catch(e){}}catch(e){}finally{t=!1}}},a=setInterval(r,1e4);return r(),()=>{e=!1,clearInterval(a)}},[z]);let[Q,Z]=(0,a.useState)(""),[X,ee]=(0,a.useState)(!1),et=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=!0;return"function"!=typeof(null==z?void 0:z.listSeatRequests)?()=>{e=!1}:(z.listSeatRequests().then(t=>{e&&H(t.seats)}).catch(()=>{}),()=>{e=!1})},[z]);let en=(0,I.o1)("chatInput",w),[er,ea]=(0,a.useState)(()=>{let e=(0,I.N2)(en);return"string"==typeof e?e:""}),[es,el]=(0,a.useState)(()=>(function(){try{let e=window.localStorage.getItem(U);if(!e)return[];let t=JSON.parse(e);if(!Array.isArray(t))return[];return t.filter(e=>"string"==typeof e)}catch(e){return[]}})()),[eo,ei]=(0,a.useState)(-1),ec=(0,a.useRef)(""),ed=!er.startsWith("/")||/\s/.test(er)?null:er.slice(1),eu=null!==ed?function(e){let t=e.trim().toLowerCase();return 0===t.length?m.bK:m.bK.filter(e=>e.name.toLowerCase().startsWith(t))}(ed):[],[em,ef]=(0,a.useState)(0);(0,a.useEffect)(()=>{ef(0)},[ed]);let ep=_?P(er,"@"):null,[ex,eh]=(0,a.useState)([]),[eg,eb]=(0,a.useState)(""),[ev,ej]=(0,a.useState)(0);(0,a.useEffect)(()=>{if(null===ep||!_)return;ej(0);let e=setTimeout(()=>{_(ep).then(e=>{eh(e.entries),eb(e.cwd)}).catch(()=>{})},200);return()=>clearTimeout(e)},[ep,_]),(0,a.useEffect)(()=>{null===ep&&(eh([]),eb(""),ej(0))},[ep]);let[ey,ew]=(0,a.useState)(!1),[ek,eN]=(0,a.useState)(0),eS=(0,a.useRef)(""),eI=ey?0===er.trim().length?es:es.filter(e=>e.toLowerCase().includes(er.trim().toLowerCase())):[],eC=()=>{ea(eS.current),ew(!1),eN(0),eS.current=""},eD=O?P(er,"$"):null,[eE,eL]=(0,a.useState)([]),[eA,eM]=(0,a.useState)(0),[eT,eR]=(0,a.useState)(D.kv);(0,a.useEffect)(()=>(eR((0,D.Vm)()),(0,D.$L)(eR)),[]);let{prediction:eU,predict:eP,clear:e_}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{baseUrl:t,token:n,enabled:r=!0,debounceMs:s=300}=e,[l,o]=(0,a.useState)(null),[i,c]=(0,a.useState)(!1),[d,u]=(0,a.useState)(null),m=(0,a.useRef)(null),f=(0,a.useRef)(null),p=(0,a.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),f.current&&(f.current.abort(),f.current=null)},[]),x=(0,a.useCallback)(()=>{p(),o(null),u(null)},[p]),h=(0,a.useCallback)(function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(p(),!r||!t||0===e.trim().length&&0===a.length)return void o(null);m.current=setTimeout(async()=>{m.current=null;let r=new AbortController;f.current=r,c(!0);try{let s="".concat(t,"/v1/llm/route/predict"),l={"Content-Type":"application/json"};n&&n.length>0&&(l.Authorization="Bearer ".concat(n));let i=await fetch(s,{method:"POST",headers:l,body:JSON.stringify({text:e,attachments:a.map(e=>({kind:e}))}),signal:r.signal});if(r.signal.aborted)return;if(!i.ok)return void u("http-".concat(i.status));let c=await i.json();o(c),u(null)}catch(e){if(r.signal.aborted)return;u(e instanceof Error?e.message:String(e))}finally{f.current===r&&(f.current=null),c(!1)}},s)},[t,n,r,s,p]);return(0,a.useEffect)(()=>()=>p(),[p]),{prediction:l,inflight:i,error:d,predict:h,clear:x}}({baseUrl:Y.baseUrl,token:Y.token,enabled:eT.autoRouting});(0,a.useEffect)(()=>{if(!eT.autoRouting)return void e_();eP(er,g.map(e=>{var t;return(null==(t=e.mediaType)?void 0:t.startsWith("image/"))?"image":"document"}))},[er,eT.autoRouting,g,eP,e_]),(0,a.useEffect)(()=>{if(null===eD||!O)return;eM(0);let e=setTimeout(()=>{O(eD).then(e=>{eL(e.entries)}).catch(()=>{})},200);return()=>clearTimeout(e)},[eD,O]),(0,a.useEffect)(()=>{null===eD&&(eL([]),eM(0))},[eD]),(0,a.useEffect)(()=>{let e=(0,f.ht)();e&&(ea(e),d.oR.success("\uD83D\uDCE5 공유 받음 — 검토 후 보내세요"))},[]),(0,a.useEffect)(()=>{F&&(ea(F.text),(0,f.ht)())},[F]);let eO=(0,a.useRef)(null);(0,a.useEffect)(()=>(eO.current&&clearTimeout(eO.current),eO.current=setTimeout(()=>{0===er.length?(0,I.yd)(en):(0,I.Os)(en,er)},300),()=>{eO.current&&clearTimeout(eO.current)}),[er,en]);let eF=async e=>{ee(!0),Z("");try{if(R(e.text)){let t=await z.submitSeatAsk(e.text,G.current);W(e=>[...e,{id:crypto.randomUUID(),text:t.reply}]),ea(""),(0,I.yd)(en);return}let t=await z.submitSeatRequest({seat:e.seat,text:e.text,...e.attachments.length?{attachments:e.attachments}:{}},e.key);for(let n of((0,y.cY)("pwa.seat-request.sent",{seat:t.seat,attachments:e.attachments.length}),K(e=>[...e,t]),et.current=null,e.attachments))null==v||v(n.id);ea(""),(0,I.yd)(en)}catch(t){et.current=e,t instanceof E.J_&&"unknown-seat"===t.code?(H(t.seats),J&&!t.seats.some(e=>e.id===J)&&($(null),et.current=null),Z("그 자리를 찾지 못했습니다 — ".concat(t.seats.map(e=>e.title).join(", ")))):t instanceof E.J_&&"attachments-unsupported"===t.code?Z("이 자리는 첨부를 받지 않습니다"):t instanceof E.J_&&"unknown-attachment"===t.code?Z("첨부가 만료됐습니다 — 다시 올려 주세요"):Z("접수하지 못했습니다 — 잠시 뒤 다시")}finally{ee(!1)}},ez=()=>eY(er),eY=e=>{if(n||X)return;let r=e.trim();if(R(r))return g.length?void Z("질문에는 첨부를 넣을 수 없습니다"):void eF({seat:"TC",text:r,attachments:[],key:crypto.randomUUID()});let a=/^@\S+\s+[\s\S]*\S$/.test(e.trimEnd());if((a||J)&&g.length>4)return void Z("자리 요청 첨부는 4개까지");if(J&&!r&&g.length)return void Z("자리 요청 내용을 입력해 주세요");if((a||J)&&r){let e=a?{text:r,attachments:[...g],key:crypto.randomUUID()}:{seat:J,text:r,attachments:[...g],key:crypto.randomUUID()},t=et.current;eF(t&&t.seat===e.seat&&t.text===e.text&&t.attachments.length===e.attachments.length&&t.attachments.every((t,n)=>{var r;return t.id===(null==(r=e.attachments[n])?void 0:r.id)})?t:e);return}(r||0!==g.length)&&(r.length>0&&(el(e=>{if(e[0]===r)return e;let t=[r,...e].slice(0,50);try{window.localStorage.setItem(U,JSON.stringify(t))}catch(e){}return t}),ei(-1),ec.current=""),t(r),ea(""),(0,I.yd)(en))},eq=e=>{let t=er.lastIndexOf("@");if(t<0)return;let n=er.slice(0,t),r=e.isDir?"".concat(e.relPath,"/"):e.relPath;ea("".concat(n,"@").concat(r).concat(e.isDir?"":" "))},eH=e=>{let t=er.lastIndexOf("$");if(t<0)return;let n=er.slice(0,t);ea("".concat(n,"/run-skill ").concat(e.name," "))},eJ=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eu[Math.min(Math.max(em,0),eu.length-1)];e&&ea(":".concat(e.name," "))};(0,a.useEffect)(()=>{!(eo<0)&&es[eo]&&er!==es[eo]&&(ei(-1),ec.current="")},[er]);let e$=(0,m.FM)(er);return(0,r.jsxs)("div",{className:"border-t border-border bg-background p-3",children:[B.map(e=>{var t,n;return(0,r.jsxs)("div",{role:"status",className:"mb-2 rounded-md border border-border bg-card px-3 py-2 text-sm",children:["\uD83D\uDCE8 ",null!=(n=null==(t=q.find(t=>t.id===e.seat))?void 0:t.title)?n:e.seat," 접수 ",e.receiptId," \xb7 방금 \xb7 받음",e.attachments?" \xb7 첨부 ".concat(e.attachments):"",e.channel?" \xb7 채널 ".concat(e.channel):""]},e.receiptId)}),V.map(e=>(0,r.jsx)("p",{role:"status",className:"mb-2 rounded-md border border-border px-3 py-2 text-sm",children:e.text},e.id)),Q&&(0,r.jsx)("p",{role:"alert",className:"mb-2 text-sm text-destructive",children:Q}),(0,r.jsx)(L,{seats:q,selected:J,onSelect:e=>{$(e),Z("")},disabled:n||X}),ey&&(0,r.jsxs)("div",{className:"mb-2 overflow-hidden rounded-md border border-border bg-card shadow-md",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:[(0,r.jsx)("span",{children:"\uD83D\uDD0E reverse-i-search"}),(0,r.jsxs)("span",{className:"text-xs font-semibold",children:[eI.length," match",1===eI.length?"":"es"]})]}),0===eI.length?(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:0===er.length?"history 가 비어 있음":"일치 없음 — '".concat(er,"'")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("ul",{className:"divide-y divide-border",children:eI.slice(0,8).map((e,t)=>{let n=t===ek;return(0,r.jsx)("li",{role:"button",tabIndex:-1,onMouseDown:n=>{n.preventDefault(),eN(t),requestAnimationFrame(()=>{ew(!1),eS.current="",ea(e)})},className:(0,p.cn)("flex cursor-pointer items-center gap-2 px-3 py-1.5 text-sm",n?"bg-accent/15 font-semibold":"hover:bg-accent/8"),children:(0,r.jsx)("span",{className:"line-clamp-2",children:e})},"".concat(e,"-").concat(t))})}),eI.length>8&&(0,r.jsxs)("div",{className:"px-3 py-1 text-[10px] text-muted-foreground",children:["+ ",eI.length-8," more (refine query)"]})]})]}),null!==ep&&ex.length>0&&(0,r.jsxs)("div",{className:"mb-2 overflow-hidden rounded-md border border-border bg-card shadow-md",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:[(0,r.jsxs)("span",{title:eg,children:["\uD83D\uDCC1 ",eg.length>48?"…"+eg.slice(-45):eg]}),(0,r.jsx)("span",{className:"text-xs font-semibold",children:ex.length})]}),(0,r.jsx)("ul",{className:"divide-y divide-border",children:ex.slice(0,12).map((e,t)=>{let n=t===ev;return(0,r.jsxs)("li",{role:"button",tabIndex:-1,onMouseDown:n=>{n.preventDefault(),ej(t),requestAnimationFrame(()=>eq(e))},className:(0,p.cn)("flex cursor-pointer items-center gap-2 px-3 py-1.5 text-sm",n?"bg-accent/15":"hover:bg-accent/8"),children:[(0,r.jsx)("span",{className:"text-xs",children:e.isDir?"\uD83D\uDCC2":"\uD83D\uDCC4"}),(0,r.jsxs)("span",{className:(0,p.cn)("font-mono",n?"font-semibold":"font-normal"),children:[e.name,e.isDir?"/":""]}),e.isDir&&(0,r.jsx)("span",{className:"ml-auto text-[10px] uppercase text-muted-foreground",children:"dir"})]},e.relPath)})}),ex.length>12&&(0,r.jsxs)("div",{className:"px-3 py-1 text-[10px] text-muted-foreground",children:["+ ",ex.length-12," more (refine query)"]})]}),null!==eD&&eE.length>0&&(0,r.jsxs)("div",{className:"mb-2 overflow-hidden rounded-md border border-border bg-card shadow-md",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:[(0,r.jsx)("span",{children:"✨ skills"}),(0,r.jsx)("span",{className:"text-xs font-semibold",children:eE.length})]}),(0,r.jsx)("ul",{className:"divide-y divide-border",children:eE.map((e,t)=>{let n=t===eA;return(0,r.jsxs)("li",{role:"button",tabIndex:-1,onMouseDown:n=>{n.preventDefault(),eM(t),requestAnimationFrame(()=>eH(e))},className:(0,p.cn)("flex cursor-pointer flex-col gap-0.5 px-3 py-1.5",n?"bg-accent/15":"hover:bg-accent/8"),children:[(0,r.jsx)("span",{className:(0,p.cn)("font-mono text-sm",n?"font-semibold":"font-normal"),children:e.name}),e.description.length>0&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:e.description})]},e.name)})})]}),null!==ed&&(0,r.jsxs)("div",{className:"mb-2 overflow-hidden rounded-md border border-border bg-card shadow-md",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:[(0,r.jsx)("span",{children:"slash commands"}),(0,r.jsx)("span",{className:"text-xs font-semibold",children:eu.length})]}),0===eu.length?(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"일치하는 명령 없음"}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:eu.map((e,t)=>{let n=t===em;return(0,r.jsxs)("li",{role:"button",tabIndex:-1,onMouseDown:n=>{n.preventDefault(),ef(t),eJ(e)},className:(0,p.cn)("flex cursor-pointer items-center gap-2 px-3 py-1.5 text-sm",n?"bg-accent/15":"hover:bg-accent/8"),children:[(0,r.jsxs)("span",{className:(0,p.cn)("font-mono",n?"font-semibold text-foreground":"text-foreground/86"),children:[":",e.name]}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:e.description})]},e.name)})})]}),g.length>0&&(0,r.jsx)("ul",{className:"mb-2 flex flex-wrap gap-1.5",children:g.map(e=>{var t,n;let a="string"==typeof e.mediaType&&e.mediaType.startsWith("image/");return(0,r.jsxs)("li",{className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-card px-1.5 py-0.5 text-[11px]",title:null!=(t=e.path)?t:e.filename,children:[a?(0,r.jsx)("img",{src:function(e,t,n){if(!e)return"";let r=e.includes("?")?"&":"?",a=n?"".concat(r,"auth=").concat(encodeURIComponent(n)):"";return"".concat(null!=t?t:"").concat(e).concat(a)}(e.downloadUrl,Y.baseUrl,Y.token),alt:e.filename,className:"h-6 w-6 rounded-sm object-cover",loading:"lazy"}):(0,r.jsx)(s.A,{className:"h-3 w-3 text-muted-foreground","aria-hidden":!0}),(0,r.jsx)("span",{className:"max-w-[160px] truncate font-mono",children:e.filename}),(0,r.jsx)("span",{className:"text-muted-foreground",children:(n=e.size)<1024?"".concat(n," B"):n<1048576?"".concat((n/1024).toFixed(1)," kB"):"".concat((n/1024/1024).toFixed(1)," MB")}),v&&(0,r.jsx)("button",{type:"button",onClick:()=>v(e.id),"aria-label":"remove ".concat(e.filename),className:"rounded text-muted-foreground hover:text-rose-500",children:(0,r.jsx)(l.A,{className:"h-3 w-3"})})]},e.id)})}),(0,r.jsxs)("div",{className:"relative flex flex-wrap items-end gap-2 sm:flex-nowrap",children:[(0,r.jsxs)("div",{className:"flex shrink-0 basis-full items-center gap-0.5 pb-1 sm:basis-auto","data-elanous-composer-tools":!0,children:[(0,r.jsx)(x.T,{onAttached:b?e=>b([e]):void 0}),(0,r.jsx)(h.u,{onAttached:b}),(0,r.jsx)(N,{}),(0,r.jsx)(S.z,{}),(0,r.jsx)(C,{}),eT.autoRouting&&eU&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",title:"입력 의도 분류 \xb7 ACP 송신 경로는 변경하지 않습니다",children:eU.mission})]}),(0,r.jsx)("textarea",{value:er,onChange:e=>ea(e.target.value),onKeyDown:e=>{if(e.ctrlKey&&("r"===e.key||"R"===e.key)){e.preventDefault(),ey||(eS.current=er,ew(!0),eN(0),ea(""));return}if(ey){if("Enter"===e.key&&!e.shiftKey){e.preventDefault(),(()=>{if(0===eI.length)return eC();let e=Math.min(Math.max(ek,0),eI.length-1),t=eI[e];ew(!1),eN(0),eS.current="",ea(t)})();return}if("ArrowUp"===e.key){e.preventDefault(),eN(e=>Math.max(0,e-1));return}if("ArrowDown"===e.key){e.preventDefault(),eN(e=>Math.min(eI.length-1,e+1));return}if("Escape"===e.key){e.preventDefault(),eC();return}}if("Tab"===e.key&&!e.shiftKey&&(()=>{if(null!==ep&&ex.length>0){let e=Math.min(Math.max(ev,0),ex.length-1),t=ex[e],n=er.lastIndexOf("@");if(n<0)return!1;let r=er.slice(0,n),a=t.isDir?"".concat(t.name,"/"):t.name;return ea("".concat(r,"@").concat(a)),!0}if(null!==eD&&eE.length>0){let e=Math.min(Math.max(eA,0),eE.length-1),t=eE[e],n=er.lastIndexOf("$");if(n<0)return!1;let r=er.slice(0,n);return ea("".concat(r,"$").concat(t.name)),!0}if(null!==ed&&eu.length>0){let e=Math.min(Math.max(em,0),eu.length-1);return eJ(eu[e]),!0}return!1})())return void e.preventDefault();if(null!==ep&&ex.length>0){if("Enter"===e.key&&!e.shiftKey){e.preventDefault(),(()=>{if(0===ex.length)return;let e=Math.min(Math.max(ev,0),ex.length-1);eq(ex[e])})();return}if("ArrowUp"===e.key){e.preventDefault(),ej(e=>Math.max(0,e-1));return}if("ArrowDown"===e.key){e.preventDefault(),ej(e=>Math.min(ex.length-1,e+1));return}if("Escape"===e.key){e.preventDefault();let t=er.lastIndexOf("@");t>=0&&ea(er.slice(0,t));return}}if(null!==eD&&eE.length>0){if("Enter"===e.key&&!e.shiftKey){e.preventDefault(),(()=>{if(0===eE.length)return;let e=Math.min(Math.max(eA,0),eE.length-1);eH(eE[e])})();return}if("ArrowUp"===e.key){e.preventDefault(),eM(e=>Math.max(0,e-1));return}if("ArrowDown"===e.key){e.preventDefault(),eM(e=>Math.min(eE.length-1,e+1));return}if("Escape"===e.key){e.preventDefault();let t=er.lastIndexOf("$");t>=0&&ea(er.slice(0,t));return}}if(null!==ed&&eu.length>0){if("Enter"===e.key&&!e.shiftKey){e.preventDefault();let t=function(e,t,n){let r=t.find(t=>t.name.toLowerCase()===e.trim().toLowerCase());if(r)return{kind:"run",line:":".concat(r.name)};let a=t[Math.min(Math.max(n,0),t.length-1)];return a?{kind:"complete",value:":".concat(a.name," ")}:null}(ed,eu,em);(null==t?void 0:t.kind)==="run"?eY(t.line):t&&ea(t.value);return}if("ArrowUp"===e.key){e.preventDefault(),ef(e=>Math.max(0,e-1));return}if("ArrowDown"===e.key){e.preventDefault(),ef(e=>Math.min(eu.length-1,e+1));return}if("Escape"===e.key){e.preventDefault(),ea("");return}}if("Enter"===e.key&&!e.shiftKey){e.preventDefault(),ez();return}if("ArrowUp"===e.key){(()=>{if(0===es.length||er.includes("\n"))return!1;-1===eo&&(ec.current=er);let e=Math.min(eo+1,es.length-1);return e===eo||(ei(e),ea(es[e]),!0)})()&&e.preventDefault();return}if("ArrowDown"===e.key){(()=>{if(eo<0||er.includes("\n"))return!1;if(0===eo)return ei(-1),ea(ec.current),!0;let e=eo-1;return ei(e),ea(es[e]),!0})()&&e.preventDefault();return}},placeholder:"메시지 \xb7 :help 명령 목록",rows:2,disabled:n||X,className:(0,p.cn)("min-h-[44px] max-h-[180px] min-w-0 flex-1 resize-y rounded-md border border-input bg-background px-3 py-2 text-sm shadow-xs focus:outline-none focus:ring-2 focus:ring-ring",e$&&"border-accent text-accent-foreground bg-accent/10",n&&"opacity-60")}),k&&(0,r.jsx)("button",{type:"button",onClick:k.onToggle,disabled:k.disabled,title:k.disabled?"daemon URL 미설정":k.phaseLabel,"data-elanous-action":"chat-voice-toggle-inline",className:(0,p.cn)("inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-md border transition-colors",k.active?"border-rose-500/40 bg-rose-500/10 text-rose-600 hover:bg-rose-500/20":"border-input bg-background text-foreground hover:bg-muted",k.disabled&&"cursor-not-allowed opacity-50"),children:(0,r.jsxs)("span",{className:"relative inline-flex",children:[k.active?(0,r.jsx)(o.A,{className:"h-4 w-4"}):(0,r.jsx)(i.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{"aria-hidden":!0,className:(0,p.cn)("absolute -right-0.5 -top-0.5 h-1.5 w-1.5 rounded-full",k.dotColor,("listening"===k.phase||"speaking"===k.phase)&&"animate-pulse")})]})}),(0,r.jsx)(u.$,{onClick:ez,disabled:n||X||!er.trim()&&0===g.length,size:"sm",children:(0,r.jsx)(c.A,{className:"h-4 w-4"})})]}),e$&&(0,r.jsx)("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"meta command — handled locally, not sent to LLM"})]})}},25042:(e,t,n)=>{n.d(t,{Cf:()=>g,Es:()=>v,L3:()=>j,c7:()=>b,lG:()=>p,rr:()=>y});var r=n(55539);n(46124);var a=n(52537),s=n(44974),l=n(60606),o=n(53405),i=n(3456),c=n(39692),d=n(77532),u=n(44373),m=n(9734),f=n(69147);function p(e){let{...t}=e;return(0,r.jsx)(a.D,{"data-slot":"dialog",...t})}function x(e){let{...t}=e;return(0,r.jsx)(s.Z,{"data-slot":"dialog-portal",...t})}function h(e){let{className:t,...n}=e;return(0,r.jsx)(l.X,{"data-slot":"dialog-overlay",className:(0,u.cn)("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",t),...n})}function g(e){let{className:t,children:n,showCloseButton:a=!0,...s}=e;return(0,r.jsxs)(x,{children:[(0,r.jsx)(h,{}),(0,r.jsxs)(o.h,{"data-slot":"dialog-content",className:(0,u.cn)("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",t),...s,children:[n,a&&(0,r.jsxs)(i.H,{"data-slot":"dialog-close",render:(0,r.jsx)(m.$,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm"}),children:[(0,r.jsx)(f.A,{}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function b(e){let{className:t,...n}=e;return(0,r.jsx)("div",{"data-slot":"dialog-header",className:(0,u.cn)("flex flex-col gap-2",t),...n})}function v(e){let{className:t,showCloseButton:n=!1,children:a,...s}=e;return(0,r.jsxs)("div",{"data-slot":"dialog-footer",className:(0,u.cn)("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",t),...s,children:[a,n&&(0,r.jsx)(i.H,{render:(0,r.jsx)(m.$,{variant:"outline"}),children:"Close"})]})}function j(e){let{className:t,...n}=e;return(0,r.jsx)(c.L,{"data-slot":"dialog-title",className:(0,u.cn)("font-heading text-base leading-none font-medium",t),...n})}function y(e){let{className:t,...n}=e;return(0,r.jsx)(d.r,{"data-slot":"dialog-description",className:(0,u.cn)("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",t),...n})}},25503:(e,t,n)=>{n.d(t,{h:()=>o,t:()=>l});var r=n(46124),a=n(15151),s=n(3155);function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{client:t}=(0,a.Q)(),n=(0,s.hG)(t),l=()=>n.list(),o=(0,r.useSyncExternalStore)(e=>n.subscribe(e),l,l);return(0,r.useEffect)(()=>{if(e.activePoll)return n.enterActive()},[n,e.activePoll]),o}function o(){let{client:e}=(0,a.Q)(),t=(0,s.hG)(e),n=l({activePoll:!0}),[,o]=(0,r.useState)(0);return(0,r.useEffect)(()=>{t.forceRefresh().then(()=>o(e=>e+1))},[t]),n}},29039:(e,t,n)=>{n.d(t,{S:()=>d});var r=n(55539),a=n(46124),s=n(96395),l=n(92988),o=n(44373),i=n(64667),c=n(72215);function d(e){let{sessionId:t,source:n="inline",variant:d="default",className:u,showCopyIcon:m=!0}=e,[f,p]=(0,a.useState)(!1),x=(0,a.useRef)(null);(0,a.useEffect)(()=>()=>{x.current&&clearTimeout(x.current)},[]);let h=async()=>{if(!t)return;let e=await (0,i.lW)(t);(0,c.cY)("webterm.session-id-chip.copy",{sessionId:t,ok:e,source:n}),e&&(p(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>p(!1),1200))},g=(0,i.o)(t),b=!t,v=t?"대화 ID 전체 (".concat(t.length,"자): ").concat(t,"\n\xb7 누르면 자동으로 복사됩니다 — 앞 8자만 표시합니다 (… 표시는 생략됨)\n\xb7 새 대화를 시작하면 다른 ID가 발급됩니다"):"대화가 선택되지 않았습니다";return(0,r.jsxs)("span",{role:"button",tabIndex:b?-1:0,"aria-disabled":b,onClick:b?void 0:e=>{e.stopPropagation(),h()},onKeyDown:b?void 0:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),e.stopPropagation(),h())},title:v,"aria-label":t?"대화 ID ".concat(t," 복사"):"대화가 선택되지 않았습니다","data-elanous-session-id":null!=t?t:"","data-elanous-action":"session-id-copy",className:(0,o.cn)("inline-flex items-center gap-1 rounded font-mono transition-colors select-none focus:outline-none focus:ring-1 focus:ring-ring","default"===d?"px-1 py-0.5 hover:bg-secondary":"opacity-70 hover:opacity-100 hover:bg-muted/40 px-0.5",f&&"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",b&&"cursor-not-allowed opacity-40",!b&&"cursor-copy",u),children:[(0,r.jsx)("span",{children:g}),m&&(f?(0,r.jsx)(s.A,{className:"h-3 w-3","aria-hidden":!0}):(0,r.jsx)(l.A,{className:"h-3 w-3 opacity-60","aria-hidden":!0}))]})}},36898:(e,t,n)=>{n.d(t,{D:()=>d});var r=n(55539),a=n(46124),s=n(94226),l=n(15151),o=n(44373),i=n(72215);function c(e){return!Number.isFinite(e)||e<0?"$0.00":"$".concat(e.toFixed(2))}function d(){let{client:e,config:t}=(0,l.Q)(),[n,d]=(0,a.useState)(null),[u,m]=(0,a.useState)(!1),f=!!t.baseUrl,p=(0,a.useCallback)(async()=>{if(f)try{let t=await e.voiceCost();d(t),m(!1)}catch(e){m(!0),(0,i.cY)("chat.voice.cost-pill.error",{reason:e instanceof Error?e.message:String(e)})}},[e,f]);if((0,a.useEffect)(()=>{if(!f)return;p();let e=setInterval(()=>void p(),6e4);return()=>clearInterval(e)},[f,p]),!f)return null;if(u&&!n)return(0,r.jsxs)("div",{className:"inline-flex items-center gap-1 rounded-md border border-border bg-muted/40 px-2 py-1 text-[11px] text-muted-foreground",title:"voice cost — daemon /v1/voice/cost 응답 없음","data-elanous-pill":"voice-cost",children:[(0,r.jsx)(s.A,{className:"h-3 w-3","aria-hidden":!0}),(0,r.jsx)("span",{children:"—"})]});if(!n)return(0,r.jsxs)("div",{className:"inline-flex items-center gap-1 rounded-md border border-border bg-muted/40 px-2 py-1 text-[11px] text-muted-foreground","data-elanous-pill":"voice-cost",children:[(0,r.jsx)(s.A,{className:"h-3 w-3","aria-hidden":!0}),(0,r.jsx)("span",{children:"…"})]});let x=n.totalUsd>0;return(0,r.jsxs)("div",{className:(0,o.cn)("inline-flex items-center gap-1 rounded-md border px-2 py-1 text-[11px]",x?"border-emerald-500/30 bg-emerald-500/5 text-emerald-700 dark:text-emerald-400":"border-border bg-muted/40 text-muted-foreground"),title:"voice cost ".concat(n.monthYYYYMM," \xb7 STT ").concat(c(n.sttUsd)," \xb7 TTS ").concat(c(n.ttsUsd)),"data-elanous-pill":"voice-cost",children:[(0,r.jsx)(s.A,{className:"h-3 w-3","aria-hidden":!0}),(0,r.jsx)("span",{children:c(n.totalUsd)}),(0,r.jsx)("span",{className:"text-muted-foreground",children:"/mo"})]})}},46923:(e,t,n)=>{n.d(t,{hn:()=>s,qv:()=>l,sg:()=>o});let r="elanous.ocr.prefs",a={defaultUseLlmVision:!1,defaultPreferHandwriting:!1};function s(){if("undefined"==typeof localStorage)return{...a};try{let e=localStorage.getItem(r);if(!e)return{...a};let t=JSON.parse(e);return{defaultUseLlmVision:"boolean"==typeof t.defaultUseLlmVision?t.defaultUseLlmVision:a.defaultUseLlmVision,defaultPreferHandwriting:"boolean"==typeof t.defaultPreferHandwriting?t.defaultPreferHandwriting:a.defaultPreferHandwriting}}catch(e){return{...a}}}function l(e){if("undefined"==typeof localStorage)return{...a,...e};let t={...s(),...e};try{localStorage.setItem(r,JSON.stringify(t))}catch(e){}return t}function o(){if("undefined"==typeof localStorage)return{...a};try{localStorage.removeItem(r)}catch(e){}return{...a}}},51281:(e,t,n)=>{n.d(t,{$L:()=>i,Kz:()=>o,Vm:()=>l,kv:()=>s});let r="elanous.pwa.chat.autoRouting",a="elanous-chat-routing-changed",s={autoRouting:!1};function l(){return{autoRouting:function(e,t){try{let n=window.localStorage.getItem(e);if("1"===n)return!0;if("0"===n)return!1;return t}catch(e){return t}}(r,s.autoRouting)}}function o(e){try{window.localStorage.setItem(r,e?"1":"0")}catch(e){}window.dispatchEvent(new CustomEvent(a))}function i(e){let t=()=>e(l()),n=t=>{t.key===r&&e(l())};return window.addEventListener(a,t),window.addEventListener("storage",n),()=>{window.removeEventListener(a,t),window.removeEventListener("storage",n)}}},53314:(e,t,n)=>{n.d(t,{T:()=>u});var r=n(55539),a=n(46124),s=n(76573),l=n(5358),o=n(15151),i=n(67327),c=n(72215),d=n(61897);function u(e){let{onAttached:t}=e,{config:n}=(0,o.Q)(),[u,m]=(0,a.useState)(!1),f=(0,a.useRef)(null),p=async e=>{var r;let a=null==(r=e.target.files)?void 0:r[0];if(e.target.value="",a){if(!n.baseUrl)return void i.oR.error("Daemon URL 미설정 — Settings 에서 입력");m(!0),(0,c.cY)("webterm.attach.pick",{filename:a.name,size:a.size,type:a.type});try{let e=await (0,d.v)({baseUrl:n.baseUrl,...n.token?{token:n.token}:{},file:a,filename:a.name});if(!e.ok){(0,c.cY)("webterm.attach.error",{status:e.status,detail:e.reason.slice(0,200)}),i.oR.error("업로드 실패 (".concat(e.status,")"));return}let{meta:r}=e;(0,c.cY)("webterm.attach.ok",{id:r.id,size:r.size}),i.oR.success("\uD83D\uDCCE ".concat(r.filename," (").concat((r.size/1024).toFixed(1)," kB)")),null==t||t(r)}catch(e){(0,c.cY)("webterm.attach.exception",{reason:String(e)}),i.oR.error("업로드 실패: ".concat(String(e instanceof Error?e.message:e)))}finally{m(!1)}}};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",onClick:()=>{var e;return null==(e=f.current)?void 0:e.click()},disabled:u,"aria-label":"attach photo",title:"attach photo (camera or file)",className:"rounded p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-50",children:u?(0,r.jsx)(s.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(l.A,{className:"h-3.5 w-3.5"})}),(0,r.jsx)("input",{ref:f,type:"file",accept:"image/*",capture:"environment",className:"hidden",onChange:p})]})}},56540:(e,t,n)=>{function r(e,t){return"".concat("elanous.pwa.snapshot.").concat(e,".").concat(t&&t.length>0?t:"singleton")}function a(){try{return window.localStorage}catch(e){return null}}function s(e){let t=a();if(!t)return null;try{let n=t.getItem(e);if(null===n)return null;return JSON.parse(n)}catch(n){try{t.removeItem(e)}catch(e){}return null}}function l(e,t){let n,r=a();if(r){try{n=JSON.stringify(t)}catch(e){return}if(!(n.length>262144))try{r.setItem(e,n)}catch(e){}}}function o(e){let t=a();if(t)try{t.removeItem(e)}catch(e){}}n.d(t,{N2:()=>s,Os:()=>l,o1:()=>r,yd:()=>o})},60750:(e,t,n)=>{n.d(t,{g:()=>a,x:()=>r});let r={idle:"bg-slate-400",connecting:"bg-amber-500",listening:"bg-emerald-500",processing:"bg-sky-500",speaking:"bg-fuchsia-500",error:"bg-rose-600"},a={idle:"음성 대기",connecting:"연결 중…",listening:"듣는 중",processing:"생각 중",speaking:"말하는 중",error:"음성 오류"}},64667:(e,t,n)=>{n.d(t,{Qh:()=>y,lW:()=>v,o:()=>j});var r=n(55539),a=n(46124),s=n(15151),l=n(5997),o=n(25503),i=n(73746),c=n(88069),d=n(53539),u=n(77242),m=n(16199),f=n(96395),p=n(92988),x=n(45876),h=n(72215),g=n(29039);let b={cli:"cli",pwa:"pwa",tg:"tg",dc:"dc"};async function v(e){if(!e||"undefined"==typeof navigator||!navigator.clipboard)return!1;try{return await navigator.clipboard.writeText(e),!0}catch(e){return!1}}function j(e){return e?e.length<=8?e:"".concat(e.slice(0,8),"…"):"—"}function y(){var e,t,n,j,y;let w=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},k=(0,s.Q)(),N=(0,o.t)(),[S,I]=(0,a.useState)(!1),[C,D]=(0,a.useState)(!1),[E,L]=(0,a.useState)(!1),A=(0,a.useRef)(null),M=(0,a.useRef)(null),T=(0,a.useRef)(null),R=null!=(e=w.sessionId)?e:k.sessionId,U=N.find(e=>e.id===R);(0,a.useEffect)(()=>()=>{A.current&&clearTimeout(A.current),M.current&&clearTimeout(M.current)},[]),(0,a.useEffect)(()=>{if(!C)return;let e=e=>{T.current&&!T.current.contains(e.target)&&D(!1)},t=e=>{"Escape"===e.key&&D(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[C]);let P=async()=>{if(!R)return;let e=await v(R);(0,h.cY)("webterm.session-pill.copy",{sessionId:R,ok:e,source:"dropdown"}),e&&(L(!0),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>L(!1),1200))},_=S?"한 번 더 누르면 새 대화가 시작됩니다 — 지금 대화는 그대로 저장되고 대화 목록에 남습니다":"새 대화 시작 (두 번 클릭) — 빈 대화에서 새로 시작합니다",O=null!=(t=null==U?void 0:U.lastMsgPreview)?t:null;return(0,r.jsxs)("div",{ref:T,className:"relative flex items-center",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 rounded-md border border-border bg-card px-2 py-1 text-[11px]",children:[(0,r.jsx)("span",{className:"text-muted-foreground font-mono",children:"대화:"}),(0,r.jsx)(g.S,{sessionId:R,source:"pill"}),(null==U?void 0:U.origin)&&(0,r.jsx)("span",{className:"ml-1 rounded bg-muted px-1 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:null!=(n=b[U.origin])?n:U.origin}),O&&(0,r.jsx)("span",{className:"ml-1 max-w-[180px] truncate border-l border-border pl-2 text-muted-foreground",title:O,children:O}),(0,r.jsxs)("span",{className:"ml-1 flex items-center gap-1 border-l border-border pl-1.5",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{if(!S){I(!0),(0,h.cY)("webterm.session-pill.fork-armed",{sessionId:R}),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{I(!1),(0,h.cY)("webterm.session-pill.fork-disarmed-timeout",{sessionId:R})},4e3);return}A.current&&(clearTimeout(A.current),A.current=null),I(!1);let e=(0,l.Zr)();(0,h.cY)("webterm.session-pill.fork-confirmed",{previous:R,next:e}),k.setSessionId(e)},className:S?"rounded p-0.5 bg-destructive text-destructive-foreground hover:bg-destructive/90":"rounded p-0.5 hover:bg-secondary",title:_,"aria-label":_,children:(0,r.jsx)(i.A,{className:"h-3 w-3"})}),S?(0,r.jsx)("span",{className:"text-[10px] text-destructive","aria-live":"polite",children:"새 대화?"}):null,(0,r.jsx)("button",{type:"button",onClick:()=>D(e=>!e),"aria-label":"대화 메뉴",className:"rounded p-0.5 hover:bg-secondary",title:"대화 메뉴",children:(0,r.jsx)(c.A,{className:"h-3 w-3"})})]})]}),C&&(0,r.jsxs)("div",{role:"menu",className:"absolute left-0 top-7 z-50 w-72 rounded-md border border-border bg-popover py-1 text-xs shadow-md",children:[(0,r.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>{let e=(0,l.Zr)();(0,h.cY)("webterm.session-pill.new-chat",{previous:R,next:e,source:"menu"}),k.setSessionId(e),D(!1)},className:"flex w-full items-start gap-2 px-3 py-1.5 text-left hover:bg-secondary",children:[(0,r.jsx)(d.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,r.jsxs)("span",{children:["새 대화 시작",(0,r.jsx)("span",{className:"block text-[10px] text-muted-foreground",children:"빈 대화에서 새로 시작합니다 \xb7 지금 대화는 대화 목록에 남습니다"})]})]}),w.onAttachRequest&&(0,r.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>{w.onAttachRequest(),D(!1)},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-secondary",children:[(0,r.jsx)(u.A,{className:"h-3.5 w-3.5 text-muted-foreground"}),"다른 대화로 전환"]}),(0,r.jsxs)("div",{className:"px-3 py-1.5 text-muted-foreground",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(m.A,{className:"h-3 w-3 shrink-0"}),(0,r.jsx)("span",{className:"text-[10px] uppercase tracking-wide",children:"대화 ID"})]}),(0,r.jsxs)("div",{className:"mt-1 flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"flex-1 select-all break-all font-mono text-[11px] text-foreground",title:R||"",children:R||"(미설정)"}),(0,r.jsx)("button",{type:"button",onClick:()=>void P(),disabled:!R,className:"shrink-0 rounded p-1 hover:bg-secondary disabled:cursor-not-allowed disabled:opacity-50",title:E?"복사됨":"대화 ID 전체 복사","aria-label":"대화 ID 복사","data-elanous-action":"session-id-copy-dropdown",children:E?(0,r.jsx)(f.A,{className:"h-3 w-3 text-emerald-500"}):(0,r.jsx)(p.A,{className:"h-3 w-3"})})]}),(0,r.jsxs)("div",{className:"mt-1 text-[10px]",children:[null!=(j=null==U?void 0:U.msgCount)?j:0," 메시지",(null==U?void 0:U.origin)&&" \xb7 ".concat(null!=(y=b[U.origin])?y:U.origin)]})]}),w.onForgetRequest&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"my-1 border-t border-border"}),(0,r.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>{w.onForgetRequest(),D(!1)},className:"flex w-full items-center gap-2 px-3 py-1.5 text-rose-500 hover:bg-rose-500/10",children:[(0,r.jsx)(x.A,{className:"h-3.5 w-3.5"}),"이 대화 지우기"]})]})]})]})}},65194:(e,t,n)=>{n.d(t,{ht:()=>s,vn:()=>a});let r="elanous.pwa.sharePrefill";function a(e){try{window.sessionStorage.setItem(r,e)}catch(e){}}function s(){try{var e;let t=null!=(e=window.sessionStorage.getItem(r))?e:"";return window.sessionStorage.removeItem(r),t}catch(e){return""}}},67903:(e,t,n)=>{n.d(t,{rm:()=>o});var r=n(55539),a=n(46124),s=n(15151),l=n(65238);function o(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{loadStatus:n=l.gh,pollMs:o=6e4,initialStatus:i}=t,{config:c}=(0,s.Q)(),[d,u]=(0,a.useState)(void 0===i?void 0:i);if((0,a.useEffect)(()=>{let e=!1,t=async()=>{if(!c.baseUrl){e||u(null);return}let t=await n({baseUrl:c.baseUrl,...c.token?{token:c.token}:{}});e||u(t)};if(t(),o<=0)return()=>{e=!0};let r=setInterval(()=>{t()},o);return()=>{e=!0,clearInterval(r)}},[c.baseUrl,c.token,n,o]),void 0===d)return null;if(null===d)return(0,r.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-2 py-1 text-[11px] text-muted-foreground",title:"예산 상태를 읽지 못했습니다","data-elanous-pill":"budget","data-budget-status":"unread",children:"budget —"});let m="warning"===(e=d.status)||"cap-exceeded"===e;return(0,r.jsx)("div",{className:m?"rounded-md border border-amber-500/50 bg-amber-500/10 px-2 py-1 text-[11px] font-medium text-amber-700 dark:text-amber-300":"rounded-md border border-border bg-muted/40 px-2 py-1 text-[11px] text-muted-foreground",title:"".concat(d.monthYYYYMM," \xb7 ").concat(d.status),"data-elanous-pill":"budget","data-budget-status":d.status,"data-budget-emphasis":m?"true":"false",children:function(e){let t="이번 달 ".concat(function(e){let t=Number.isFinite(e)?e:0;return"$".concat(t.toFixed(2))}(e.monthSoFarUsd));return null!=e.percent&&Number.isFinite(e.percent)?"".concat(t," \xb7 ").concat(e.percent,"%"):t}(d)})}},71923:(e,t,n)=>{n.d(t,{K:()=>i,u:()=>a});var r=n(46124);let a=932,s="elanous.pwa.wideView",l="elanous:wide-view";function o(){try{return"1"===window.localStorage.getItem(s)}catch(e){return!1}}function i(){let[e,t]=(0,r.useState)(null),[n,i]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{t(window.innerWidth),i(o());let e=()=>t(window.innerWidth),n=e=>{let t=e.detail;i("boolean"==typeof t?t:o())};return window.addEventListener("resize",e),window.addEventListener(l,n),window.addEventListener("storage",n),()=>{window.removeEventListener("resize",e),window.removeEventListener(l,n),window.removeEventListener("storage",n)}},[]),{compact:null!==e&&e<=a&&!n,setWide:(0,r.useCallback)(e=>{i(e);try{e?window.localStorage.setItem(s,"1"):window.localStorage.removeItem(s)}catch(e){}window.dispatchEvent(new CustomEvent(l,{detail:e}))},[])}}},84968:(e,t,n)=>{n.d(t,{D:()=>ep});var r=n(55539),a=n(46124),s=n(2021),l=n(65761);let o=[n(77362).A];var i=n(73532);let c={"coo-admin":"운영 할 일","release-schedule":"판 일정","release-checklist":"판별 칸"};function d(e){let{card:t}=e,[n,s]=(0,a.useState)(!1),l=t.items.map((e,t)=>({item:e,index:t})).sort((e,t)=>{var n,r;return(null!=(n=e.item.daysLeft)?n:1/0)-(null!=(r=t.item.daysLeft)?r:1/0)||e.index-t.index}),o=n?l:l.slice(0,12);return(0,r.jsxs)("section",{className:"rounded-lg border border-border bg-card p-3 text-card-foreground","data-elanous-card-kind":t.kind,children:[(0,r.jsxs)("h3",{className:"mb-2 text-sm font-semibold",children:[c[t.kind]," ",(0,r.jsxs)("span",{className:"font-normal text-muted-foreground",children:["\xb7 ",t.items.length]})]}),0===t.items.length&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"항목이 없습니다"}),(0,r.jsx)("ul",{className:"space-y-2",children:o.map(e=>{var t;let{item:n,index:a}=e,s=n.url?function(e){let t=e.trim();if(!t.includes("\\")){if(/^https?:\/\//i.test(t))try{let e=new URL(t);return"http:"===e.protocol||"https:"===e.protocol?t:void 0}catch(e){return}return/^\/(?!\/)/.test(t)?t:void 0}}(n.url):void 0,l=function(e){if(null!==e)return e<0?{label:"".concat(-e,"일 지남"),tone:"overdue"}:0===e?{label:"오늘",tone:"soon"}:{label:"D-".concat(e),tone:e<=3?"soon":void 0}}(n.daysLeft);return(0,r.jsxs)("li",{className:"rounded border border-border/60 px-2 py-1.5 text-sm","data-elanous-card-item":a,children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-baseline gap-2",children:[l&&(0,r.jsx)("span",{"data-due-status":l.tone,className:"overdue"===l.tone?"font-semibold text-red-600 dark:text-red-400":"soon"===l.tone?"font-semibold text-orange-600 dark:text-orange-400":"text-muted-foreground",children:l.label}),s?(0,r.jsx)("a",{className:"font-medium text-primary underline underline-offset-2",href:s,target:"_blank",rel:"noopener noreferrer",children:n.title}):(0,r.jsx)("span",{className:"font-medium",children:n.title})]}),(0,r.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[n.state,n.owner,null!=(t=n.due)?t:void 0].filter(Boolean).join(" \xb7 ")})]},a)})}),t.items.length>12&&!n&&(0,r.jsxs)("button",{type:"button",className:"mt-2 text-xs font-medium text-primary underline underline-offset-2",onClick:()=>s(!0),children:[t.items.length-12,"개 더 보기"]})]})}function u(e){let{sources:t}=e;return(null==t?void 0:t.length)?(0,r.jsx)("ul",{"aria-label":"출처",className:"mt-1 space-y-0.5 rounded border border-border/60 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:t.map((e,t)=>(0,r.jsxs)("li",{title:e.source,className:"break-words",children:[e.label,null!==e.ago?" \xb7 ".concat(e.ago):""]},"".concat(e.source,"-").concat(t)))}):null}var m=n(15151),f=n(2555),p=n(23196);function x(e){var t;let{acceptanceId:n}=e,{client:s}=(0,m.Q)(),[l,o]=(0,a.useState)(null),[i,c]=(0,a.useState)(null);(0,a.useEffect)(()=>{let e;o(null),c(null);let t=!0,r=Date.now(),a=async()=>{if(!(!t||Date.now()-r>=36e5)){try{let e=await (0,p.PM)(s,n);if(!t||(o(e),c(null),(0,f.rr)(e.phase)))return}catch(n){if(!t)return;let e=n instanceof Error?n.message:String(n);if("harness ask not found"===e||/^HTTP 404\b/.test(e))return void c("접수 기록을 못 찾았습니다(데몬 재시작이면 사라질 수 있음)");c("상태 확인 실패 — ".concat(e.split(/\r?\n/,1)[0].slice(0,200)))}t&&Date.now()-r<36e5&&(e=setTimeout(()=>void a(),5e3))}};return a(),()=>{t=!1,e&&clearTimeout(e)}},[s,n]);let d="number"==typeof(null==l?void 0:l.elapsedSeconds)&&Number.isFinite(l.elapsedSeconds)?Math.max(0,Math.floor(l.elapsedSeconds)):0,u="string"==typeof(null==l?void 0:l.goalFile)?l.goalFile.split(/[\\/]/).pop():void 0;return(0,r.jsxs)("section",{"aria-label":"하니스 진행",className:"rounded-md border border-border bg-card px-3 py-2 text-xs not-italic text-card-foreground",children:[(0,r.jsx)("span",{className:"font-medium",children:(0,f.SK)(null!=(t=null==l?void 0:l.phase)?t:"accepted")}),(null==l?void 0:l.runId)&&(0,r.jsxs)("span",{className:"ml-2 font-mono",children:["런 ",l.runId.slice(0,8)]}),u&&(0,r.jsx)("span",{className:"ml-2 break-all",children:u}),(0,r.jsxs)("span",{className:"ml-2 text-muted-foreground",children:["경과 ",d>=60?"".concat(Math.floor(d/60),"분"):"".concat(d,"초")]}),i&&(0,r.jsx)("p",{role:"status",className:"mt-1 text-destructive",children:i})]})}var h=n(44373),g=n(96395),b=n(92988),v=n(43926),j=n(88069),y=n(72215);function w(e){let{block:t}=e,{msg:n,done:a,metrics:s}=t,l=[];if(s){let e=function(e){let t=Math.max(0,Math.round(e/1e3));return t<60?"".concat(t,"s"):t<3600?"".concat(Math.floor(t/60),"m ").concat(t%60,"s"):"".concat(Math.floor(t/3600),"h ").concat(Math.floor(t%3600/60),"m")}(s.elapsedMs);e&&s.elapsedMs>0&&l.push(e);let t=function(e){if(e<=0)return"";let t=e/1e3;return t>=1?"".concat(t.toFixed(1),"k tokens"):"".concat(e," tokens")}(s.tokenCount);t&&l.push(t)}let o=l.length?" (".concat(l.join(" \xb7 "),")"):"";return(0,r.jsxs)("div",{"data-elanous-block-kind":"agent_thinking","data-elanous-block-id":t.blockId,"data-elanous-done":a?"true":"false",className:(0,h.cn)("inline-flex items-center gap-1.5 rounded-full border bg-muted/30 px-2 py-0.5 text-[11px] font-mono",a?"border-border text-muted-foreground":"border-border/60 text-foreground"),children:[(0,r.jsx)("span",{"aria-hidden":"true",className:(0,h.cn)("inline-block h-1.5 w-1.5 rounded-full",a?"bg-emerald-500":"bg-amber-400 motion-safe:animate-pulse")}),(0,r.jsxs)("span",{children:[a?"✓ ":"",n,a?"":"…",(0,r.jsx)("span",{className:"text-muted-foreground",children:o})]})]})}let k={running:"●",queued:"◌",done:"✓",error:"✗"},N={running:"border-amber-400/50 text-amber-300",queued:"border-border text-muted-foreground",done:"border-emerald-500/40 text-emerald-300",error:"border-destructive/50 text-destructive"};function S(e){let{block:t}=e,n=k[t.status],a=N[t.status];return(0,r.jsxs)("div",{"data-elanous-block-kind":"agent_status","data-elanous-block-id":t.blockId,"data-monad-agent-id":t.agentId,"data-elanous-status":t.status,className:(0,h.cn)("inline-flex items-center gap-1.5 rounded border bg-muted/20 px-2 py-0.5 text-[11px] font-mono",a),children:[(0,r.jsx)("span",{"aria-hidden":"true",className:(0,h.cn)("running"===t.status?"motion-safe:animate-pulse":void 0),children:n}),(0,r.jsx)("span",{className:"font-semibold",children:t.agentId}),(0,r.jsx)("span",{className:"uppercase tracking-wide text-[10px] text-muted-foreground",children:t.status}),t.lastEvent&&(0,r.jsxs)("span",{className:"ml-1 truncate text-muted-foreground",children:["\xb7 ",t.lastEvent]})]})}let I={pending:"○","in-progress":"◐",done:"●",skipped:"⊘"},C={pending:"text-muted-foreground","in-progress":"text-amber-300",done:"text-emerald-400",skipped:"text-muted-foreground/60 line-through"};function D(e){let{block:t}=e;return(0,r.jsxs)("div",{"data-elanous-block-kind":"agent_plan","data-elanous-block-id":t.blockId,"data-elanous-plan-ref":t.ref,className:"rounded border border-border bg-muted/20 px-2 py-1.5 text-xs font-mono",children:[(0,r.jsxs)("div",{className:"mb-1 flex items-center justify-between text-[10px] uppercase tracking-wide text-muted-foreground",children:[(0,r.jsxs)("span",{children:["Plan \xb7 ",t.ref]}),"number"==typeof t.activeIndex&&t.steps.length>0&&(0,r.jsxs)("span",{children:[t.activeIndex+1,"/",t.steps.length]})]}),(0,r.jsx)("ol",{className:"m-0 list-none space-y-0.5 p-0",children:t.steps.map((e,n)=>{let a=n===t.activeIndex;return(0,r.jsxs)("li",{"data-elanous-step-index":n,"data-elanous-step-status":e.status,className:(0,h.cn)("flex items-start gap-2 leading-snug",C[e.status],a&&"done"!==e.status?"font-semibold motion-safe:animate-pulse":void 0),children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"select-none",children:I[e.status]}),(0,r.jsx)("span",{className:"flex-1 whitespace-pre-wrap",children:e.text})]},n)})})]})}let E={add:"bg-emerald-500/10 text-emerald-300",del:"bg-rose-500/10 text-rose-300",ctx:"text-muted-foreground"},L={add:"+",del:"-",ctx:" "};function A(e){let{block:t}=e,[n,s]=(0,a.useState)(!1),{adds:l,dels:o}=function(e){let t=0,n=0;for(let r of e.hunks)for(let e of r.lines)"add"===e.kind?t+=1:"del"===e.kind&&(n+=1);return{adds:t,dels:n}}(t),i=t.hunks.length;return(0,r.jsxs)("div",{"data-elanous-block-kind":"tool_diff","data-elanous-block-id":t.blockId,"data-elanous-file-path":t.filePath,className:"rounded border border-border bg-muted/20 px-2 py-1 text-xs font-mono",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>s(!n),"aria-expanded":n,className:"flex w-full items-center gap-2 text-left",children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"⌥"}),(0,r.jsx)("span",{className:"font-semibold truncate",children:t.filePath}),t.language&&(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:["\xb7",t.language]}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-1.5 text-[10px]",children:[l>0&&(0,r.jsxs)("span",{className:"text-emerald-300",children:["+",l]}),o>0&&(0,r.jsxs)("span",{className:"text-rose-300",children:["-",o]}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[i," hunk",1===i?"":"s"]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:n?"▾":"▸"})]})]}),n&&(0,r.jsx)("div",{className:"mt-1 overflow-x-auto rounded bg-background/40",children:t.hunks.map((e,t)=>(0,r.jsxs)("div",{"data-elanous-hunk-index":t,className:"border-t border-border/40 first:border-t-0",children:[(0,r.jsxs)("div",{className:"px-2 py-0.5 text-[10px] text-muted-foreground bg-muted/30",children:["@@ -",e.oldStart,",",e.oldLines," +",e.newStart,",",e.newLines," @@"]}),(0,r.jsx)("pre",{className:"m-0 whitespace-pre p-0 text-[11px] leading-tight",children:e.lines.map((e,t)=>(0,r.jsxs)("div",{"data-elanous-line-kind":e.kind,className:(0,h.cn)("flex items-baseline px-2 py-px",E[e.kind]),children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"w-3 shrink-0 select-none",children:L[e.kind]}),(0,r.jsx)("span",{className:"flex-1",children:e.text})]},t))})]},t))})]})}function M(e){var t,n,a,s;let{hit:l}=e;return(0,r.jsx)("li",{"data-elanous-search-hit-file":l.filePath,"data-elanous-search-hit-line":l.line,className:"rounded px-2 py-1 hover:bg-muted/30",children:(0,r.jsxs)("a",{href:function(e){var t;let n=null!=(t=e.column)?t:1;return"vscode://file/".concat(e.filePath,":").concat(e.line,":").concat(n)}(l),className:"block",target:"_blank",rel:"noopener",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2 text-[11px]",children:[(0,r.jsx)("span",{className:"font-semibold truncate",children:l.filePath}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[":",l.line]}),void 0!==l.column&&(0,r.jsxs)("span",{className:"text-muted-foreground",children:[":",l.column]})]}),(null!=(a=null==(t=l.contextBefore)?void 0:t.length)?a:0)>0&&(0,r.jsx)("pre",{className:"m-0 mt-0.5 whitespace-pre-wrap break-words text-[10px] text-muted-foreground/70",children:l.contextBefore.join("\n")}),(0,r.jsx)("pre",{className:"m-0 whitespace-pre-wrap break-words text-[10px] text-foreground",children:l.snippet}),(null!=(s=null==(n=l.contextAfter)?void 0:n.length)?s:0)>0&&(0,r.jsx)("pre",{className:"m-0 whitespace-pre-wrap break-words text-[10px] text-muted-foreground/70",children:l.contextAfter.join("\n")})]})})}function T(e){let{block:t}=e,[n,s]=(0,a.useState)(!1),l=t.hits.length,o=n?t.hits:t.hits.slice(0,5),i=l-o.length;return(0,r.jsxs)("div",{"data-elanous-block-kind":"tool_search_hits","data-elanous-block-id":t.blockId,"data-elanous-search-query":t.query,"data-elanous-accum-count":t.accumCount,className:(0,h.cn)("rounded border border-border bg-muted/20 px-2 py-1 text-xs font-mono"),children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2 mb-1",children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"\uD83D\uDD0E"}),(0,r.jsx)("span",{className:"font-semibold",children:t.query}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[t.accumCount," hit",1===t.accumCount?"":"s"]}),t.truncated&&(0,r.jsx)("span",{className:"text-[10px] text-amber-300",children:"truncated"})]}),0===l?(0,r.jsx)("div",{className:"text-[10px] text-muted-foreground italic",children:"(no hits yet)"}):(0,r.jsx)("ul",{className:"m-0 list-none space-y-0.5 p-0",children:o.map((e,t)=>(0,r.jsx)(M,{hit:e},"".concat(e.filePath,":").concat(e.line,":").concat(t)))}),i>0&&(0,r.jsxs)("button",{type:"button",onClick:()=>s(!0),className:"mt-1 w-full rounded bg-muted/40 px-2 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/60",children:["+ ",i," more"]}),n&&l>5&&(0,r.jsx)("button",{type:"button",onClick:()=>s(!1),className:"mt-1 w-full rounded bg-muted/40 px-2 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/60",children:"collapse"})]})}let R={stdout:"text-foreground",stderr:"text-rose-300",http:"text-amber-300",generic:"text-muted-foreground"},U={stdout:"▌",stderr:"▌",http:"↹",generic:"\xb7"};function P(e){var t;let{block:n}=e,[s,l]=(0,a.useState)(!1),o=n.lines.length,i=0===o?"":n.lines[o-1],c=void 0===n.exitCode?"":0===n.exitCode?"text-emerald-300":"text-rose-300";return(0,r.jsxs)("div",{"data-elanous-block-kind":"tool_progress","data-elanous-block-id":n.blockId,"data-elanous-stream":n.stream,"data-elanous-done":n.done?"true":"false",className:"rounded border border-border bg-muted/20 px-2 py-1 text-xs font-mono",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>l(!s),"aria-expanded":s,className:"flex w-full items-center gap-2 text-left",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:(0,h.cn)(R[n.stream],!n.done&&"motion-safe:animate-pulse"),children:U[n.stream]}),(0,r.jsx)("span",{className:"uppercase tracking-wide text-[10px] text-muted-foreground",children:n.stream}),!s&&i&&(0,r.jsx)("span",{className:(0,h.cn)("flex-1 truncate",R[n.stream]),children:i}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-1.5 text-[10px] text-muted-foreground",children:[(0,r.jsxs)("span",{children:[o," line",1===o?"":"s"]}),void 0!==n.bytesSoFar&&(0,r.jsxs)("span",{children:["\xb7 ",(t=n.bytesSoFar)<1024?"".concat(t,"B"):t<1048576?"".concat((t/1024).toFixed(1),"KB"):"".concat((t/1048576).toFixed(1),"MB")]}),void 0!==n.exitCode&&(0,r.jsxs)("span",{className:c,children:["\xb7 exit ",n.exitCode]}),n.done&&!n.exitCode&&(0,r.jsx)("span",{className:"text-emerald-300",children:"\xb7 ✓"}),(0,r.jsx)("span",{"aria-hidden":"true",children:s?"▾":"▸"})]})]}),s&&(0,r.jsx)("pre",{className:(0,h.cn)("m-0 mt-1 max-h-64 overflow-auto rounded bg-background/40 p-1.5 text-[11px] leading-tight whitespace-pre",R[n.stream]),children:0===n.lines.length?"(no output yet)":n.lines.join("\n")})]})}function _(e){var t;let{group:n}=e,a=function(e){if(0===e.samples.length)return"";if(1===e.samples.length)return"M0,".concat(9," L").concat(80,",").concat(9);let t=e.max-e.min||1,n=e.samples.map((n,r)=>{let a=r/(e.samples.length-1)*80,s=(n.value-e.min)/t;return"".concat(a.toFixed(1),",").concat((18-18*s).toFixed(1))});return"M".concat(n[0]," L").concat(n.slice(1).join(" L"))}(n);return(0,r.jsxs)("div",{"data-elanous-perf-metric":n.metric,"data-elanous-perf-latest":n.latest,className:"flex items-center gap-2 text-[10px] font-mono",children:[(0,r.jsx)("span",{className:"text-muted-foreground truncate min-w-[120px]",children:n.metric}),(0,r.jsx)("svg",{width:80,height:18,viewBox:"0 0 ".concat(80," ").concat(18),className:"shrink-0","aria-label":"".concat(n.metric," sparkline"),children:(0,r.jsx)("path",{d:a,fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinejoin:"round",strokeLinecap:"round",className:"text-amber-400"})}),(0,r.jsx)("span",{className:"text-foreground tabular-nums",children:(t=n.latest)>=1e3?(t/1e3).toFixed(1)+"k":t>=10?t.toFixed(0):t.toFixed(1)}),n.unit&&(0,r.jsx)("span",{className:"text-muted-foreground",children:n.unit})]})}function O(e){let{block:t}=e,n=(0,a.useMemo)(()=>(function(e){let t=new Map;for(let n of e){let e=t.get(n.metric);e?e.push(n):t.set(n.metric,[n])}let n=[];for(let[e,r]of t.entries()){let t=1/0,a=-1/0;for(let e of r)e.value<t&&(t=e.value),e.value>a&&(a=e.value);let s=r[r.length-1].value,l={metric:e,samples:r,latest:s,min:t,max:a},o=r[r.length-1].unit;void 0!==o&&(l.unit=o),n.push(l)}return n.sort((e,t)=>t.samples.length-e.samples.length),n})(t.samples),[t.samples]);return 0===n.length?(0,r.jsx)("div",{"data-elanous-block-kind":"perf_session","data-elanous-block-id":t.blockId,className:"rounded border border-border bg-muted/20 px-2 py-1 text-[10px] text-muted-foreground italic",children:"(no perf samples yet)"}):(0,r.jsx)("div",{"data-elanous-block-kind":"perf_session","data-elanous-block-id":t.blockId,"data-elanous-perf-metric-count":n.length,className:(0,h.cn)("rounded border border-border bg-muted/20 px-2 py-1","flex flex-col gap-0.5"),children:n.map(e=>(0,r.jsx)(_,{group:e},e.metric))})}let F="'none'";function z(e){let t=function(e){if(!e)return[];let t=new Set;for(let n of e)if("string"==typeof n)try{let e=new URL(n);if("http:"!==e.protocol&&"https:"!==e.protocol||e.username||e.password||"/"!==e.pathname||e.search||e.hash)continue;t.add(e.origin)}catch(e){}return[...t]}(e);return t.length>0?t.join(" "):F}let Y="ui/notifications/tool-result",q=(e,t,n)=>"".concat(e,":").concat(t,":").concat(typeof n,":").concat(String(n));function H(e,t,n){return{jsonrpc:"2.0",id:e,error:{code:t,message:n}}}function J(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function $(e){return{frames:{...e.frames},pending:{...e.pending},pushes:[...e.pushes],unmatched:[...e.unmatched],nextGeneration:e.nextGeneration}}function B(e){return{jsonrpc:"2.0",method:Y,params:{content:[],_meta:{"elanous/resultOmittedReason":e}}}}function K(e){let{message:t,omitted:n,bytes:r}=function(e){if(!(J(e)&&(!("content"in e)||Array.isArray(e.content))))return{message:B("not_a_tool_result"),omitted:"not_a_tool_result",bytes:-1};let t={jsonrpc:"2.0",method:Y,params:e};try{structuredClone(t);let e=new TextEncoder().encode(JSON.stringify(t)).byteLength;if(e<=65536)return{message:t,bytes:e};return{message:B("too_large"),omitted:"too_large",bytes:e}}catch(e){return{message:B("unserializable"),omitted:"unserializable",bytes:-1}}}(e.result);return{kind:"notify",frameId:e.frameId,message:t,bytes:r,...n?{omitted:n}:{}}}function V(e,t){for(let[n,r]of(delete e.frames[t],Object.entries(e.pending)))r.frameId===t&&delete e.pending[n];e.pushes=e.pushes.filter(e=>e.frameId!==t)}function W(e){return{frames:{},pending:{},pushes:[],unmatched:[],nextGeneration:e.nextGeneration}}function G(e,t,n,r,a){let s=q(t,n,r),l=e.frames[t];if(!e.pending[s]||!l||l.generation!==n)return{state:e,actions:[]};let o=$(e);return delete o.pending[s],{state:o,actions:[{kind:"respond",frameId:t,message:"result"in a?{jsonrpc:"2.0",id:r,result:a.result}:{jsonrpc:"2.0",id:r,error:{code:-32603,message:"Daemon tool call failed",data:a.error}}}]}}let Q=new WeakMap;function Z(e){let{html:t,connectDomains:n,resourceDomains:s,server:l,tool:o,toolCallId:i,toolResult:c}=e,d=function(){let{connectDomains:e,resourceDomains:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=z(e),r=z(t);return["default-src ".concat(F),"connect-src ".concat(n),"img-src ".concat(r),"media-src ".concat(r),"style-src ".concat(r),"font-src ".concat(r),"script-src 'unsafe-inline' ".concat(r),"base-uri ".concat(F),"form-action ".concat(F),"navigate-to ".concat(F)].join("; ")}({connectDomains:n,resourceDomains:s}),u='<meta http-equiv="Content-Security-Policy" content="'.concat(d,'">').concat(t),f=(0,a.useRef)(null),p=(0,a.useId)(),x=(0,a.useContext)(m.C),[h,g]=(0,a.useState)(!1),[b,v]=(0,a.useState)(null),j=(0,a.useCallback)(()=>{var e,t;g(!0),v(null!=(t=null==(e=f.current)?void 0:e.contentWindow)?t:null)},[]);return(0,a.useEffect)(()=>{if(b&&x)return function(e,t){let n=e.register({frameId:t.frameId,source:t.source,server:t.server,...void 0!==t.tool?{tool:t.tool}:{},...void 0!==t.toolCallId?{toolCallId:t.toolCallId}:{}}),r=void 0!==t.toolResult&&void 0!==t.tool;return(0,y.cY)("mcp-app.bridge.attach",{frameId:t.frameId,server:t.server,hasTool:void 0!==t.tool,hasToolCallId:void 0!==t.toolCallId,hasToolResult:void 0!==t.toolResult,published:r,...r?{}:{skipped:void 0===t.tool?"no-tool":"no-tool-result"}}),r&&e.publish({server:t.server,tool:t.tool,...void 0!==t.toolCallId?{toolCallId:t.toolCallId}:{},result:t.toolResult}),n}(function(e,t){let n=Q.get(e);if(n)return n;let r=function(e,t){let n={frames:{},pending:{},pushes:[],unmatched:[],nextGeneration:1},r=(e,t)=>{var r;let a=null==(r=n.frames[e])?void 0:r.source;if("function"!=typeof(null==a?void 0:a.postMessage))return"no-target";try{return a.postMessage(t,"*"),"posted"}catch(e){return"threw"}},a=e=>{for(let s of e){if("observe"===s.kind&&(0,y.cY)("mcp-app.bridge.discard",{reason:s.reason,...s.method?{method:s.method}:{}}),"notify"===s.kind){let e=r(s.frameId,s.message);(0,y.cY)("mcp-app.bridge.push",{frameId:s.frameId,post:e,bytes:s.bytes,maxBytes:65536,...s.omitted?{omitted:s.omitted}:{}})}"respond"===s.kind&&r(s.frameId,s.message),"daemon-tool-call"===s.kind&&t.callWidgetTool({server:s.server,tool:s.tool,arguments:s.arguments}).then(e=>{let t=G(n,s.frameId,s.generation,s.id,{result:e});n=t.state,a(t.actions)},e=>{let t=G(n,s.frameId,s.generation,s.id,{error:String(e)});n=t.state,a(t.actions)})}},s=e=>{let t=function(e,t,n){let r=Object.values(e.frames).find(e=>e.source===t);if(!r)return{state:e,actions:[{kind:"observe",reason:"untrusted-source"}]};if(!J(n)||"2.0"!==n.jsonrpc||"string"!=typeof n.method)return{state:e,actions:[{kind:"observe",reason:"malformed-message"}]};if("notifications/initialized"===n.method||"ui/notifications/initialized"===n.method){var a;if(r.ready)return{state:e,actions:[]};let t=$(e);t.frames[r.frameId]={...r,ready:!0};let n=t.pushes.filter(e=>e.frameId===r.frameId&&e.generation===r.generation);return t.pushes=t.pushes.filter(e=>e.frameId!==r.frameId||e.generation!==r.generation),{state:t,actions:n.map(K)}}if(!("string"==typeof(a=n.id)||"number"==typeof a&&Number.isFinite(a)))return{state:e,actions:[]};if("ui/initialize"===n.method)return{state:e,actions:[{kind:"respond",frameId:r.frameId,message:{jsonrpc:"2.0",id:n.id,result:{protocolVersion:"2025-11-21",hostInfo:{name:"elanous",version:"1"},hostCapabilities:{serverTools:{}},hostContext:{}}}}]};if("ui/open-link"===n.method||"tools/call"!==n.method)return{state:e,actions:[{kind:"observe",reason:"unknown-method",method:n.method},{kind:"respond",frameId:r.frameId,message:H(n.id,-32601,"Method not found")}]};if(!J(n.params)||"string"!=typeof n.params.name)return{state:e,actions:[{kind:"respond",frameId:r.frameId,message:H(n.id,-32602,"Invalid params")}]};let s=q(r.frameId,r.generation,n.id);if(e.pending[s])return{state:e,actions:[{kind:"respond",frameId:r.frameId,message:H(n.id,-32600,"Duplicate request id")}]};let l=$(e);return l.pending[s]={frameId:r.frameId,id:n.id,generation:r.generation},{state:l,actions:[{kind:"daemon-tool-call",frameId:r.frameId,id:n.id,generation:r.generation,server:r.server,tool:n.params.name,arguments:n.params.arguments}]}}(n,e.source,e.data);n=t.state,a(t.actions)};return e.addEventListener("message",s),{register(e){var t;let r=function(e,t){let n=$(e);for(let[e,r]of Object.entries(n.frames))(e===t.frameId||r.source===t.source)&&V(n,e);let r=n.nextGeneration++;n.frames[t.frameId]={...t,generation:r,ready:!1};let a=n.unmatched.filter(e=>e.server===t.server&&e.tool===t.tool&&void 0!==e.toolCallId&&e.toolCallId===t.toolCallId);for(let e of(n.unmatched=n.unmatched.filter(e=>!a.includes(e)),a))n.pushes.push({...e,frameId:t.frameId,generation:r});return{state:n,actions:[]}}(n,e);n=r.state,a(r.actions);let s=null==(t=n.frames[e.frameId])?void 0:t.generation;return()=>{void 0!==s&&(n=function(e,t,n){let r=e.frames[t];if(!r||void 0!==n&&r.generation!==n)return{state:e,actions:[]};let a=$(e);return V(a,t),{state:a,actions:[]}}(n,e.frameId,s).state)}},publish(e){let t=function(e,t){let n=e,r=[],a=!1;for(let s of Object.values(e.frames)){if(s.server!==t.server||s.tool!==t.tool||(void 0!==t.toolCallId||void 0!==s.toolCallId)&&t.toolCallId!==s.toolCallId)continue;a=!0;let e=function(e,t){let n=e.frames[t.frameId];if(!n||n.generation!==t.generation)return{state:e,actions:[]};if(n.ready)return{state:e,actions:[K(t)]};let r=$(e);return r.pushes.push(t),{state:r,actions:[]}}(n,{...t,frameId:s.frameId,generation:s.generation});n=e.state,r.push(...e.actions)}if(!a&&void 0!==t.toolCallId){let e=$(n);e.unmatched=[...e.unmatched,t],n=e}return{state:n,actions:r}}(n,e);n=t.state,a(t.actions)},disposeConversation(){n=W(n)},close(){e.removeEventListener("message",s),n=W(n)}}}(t,{async callWidgetTool(t){let{tool:n,arguments:r}=t;return e.fetchJson("/v1/mcp/widgets/call",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({toolName:n,args:null!=r?r:{}})})}});return Q.set(e,r),r}(x.client,window),{frameId:p,source:b,server:null!=l?l:"",...void 0!==o?{tool:o}:{},...void 0!==i?{toolCallId:i}:{},...void 0!==c?{toolResult:c}:{}})},[b,x,p,l,o,i,c]),(0,r.jsx)("iframe",{ref:f,"data-elanous-mcp-app-frame":"true","data-elanous-mcp-server":null!=l?l:"",sandbox:"allow-scripts",srcDoc:u,title:"MCP App",onLoad:j,className:"mt-2 w-full rounded border border-border bg-background transition-[height] ".concat(h?"h-96":"h-10")})}function X(e,t){let n=e.headers.get(t);if(null!==n)return n.split(",").map(e=>e.trim()).filter(e=>e.length>0)}async function ee(e,t){if(!t.server||!t.uri)return null;try{let n=await e.fetchResponse(function(e,t){let n=new URLSearchParams({server:e,uri:t});return"".concat("/v1/mcp/resources","?").concat(n.toString())}(t.server,t.uri),t.signal?{signal:t.signal}:void 0);if(!n.ok)return null;let r=await n.text();if(0===r.length)return null;let a=X(n,"x-elanous-mcp-app-connect-domains"),s=X(n,"x-elanous-mcp-app-resource-domains");return{html:r,...a?{connectDomains:a}:{},...s?{resourceDomains:s}:{}}}catch(e){return null}}let et=["__","."];function en(e){var t,n,s,l,o,i;let{block:c}=e,d=function(e){for(let t of et){let n=e.indexOf(t);if(n>0)return e.slice(0,n)}return""}(c.toolName),u=(0,a.useContext)(m.C),[f,p]=(0,a.useState)(null);(0,a.useEffect)(()=>{if(c.html||!u||!d||!c.screenUrl)return;let e=new AbortController,t=!0,n=Date.now();return(0,y.cY)("mcp-app.body.fetch",{server:d,uri:c.screenUrl,reason:"not-embedded"}),ee(u.client,{server:d,uri:c.screenUrl,signal:e.signal}).then(e=>{var r,a,s,l,o;t&&((0,y.cY)("mcp-app.body.fetched",{server:d,elapsedMs:Date.now()-n,ok:null!==e,bytes:null!=(s=null==e?void 0:e.html.length)?s:0,connectDomains:null!=(l=null==e||null==(r=e.connectDomains)?void 0:r.length)?l:null,resourceDomains:null!=(o=null==e||null==(a=e.resourceDomains)?void 0:a.length)?o:null}),p(e))}).catch(e=>{t&&(0,y.cY)("mcp-app.body.fetched",{server:d,elapsedMs:Date.now()-n,ok:!1,threw:!0,reason:e instanceof Error?e.message.slice(0,200):String(e).slice(0,200)})}),()=>{t=!1,e.abort()}},[c.html,c.screenUrl,u,d]);let x=null!=(n=null!=(t=c.html)?t:null==f?void 0:f.html)?n:void 0,{connectDomains:h,resourceDomains:g}={...(null!=(s=c.connectDomains)?s:null==f?void 0:f.connectDomains)?{connectDomains:null!=(l=c.connectDomains)?l:null==f?void 0:f.connectDomains}:{},...(null!=(o=c.resourceDomains)?o:null==f?void 0:f.resourceDomains)?{resourceDomains:null!=(i=c.resourceDomains)?i:null==f?void 0:f.resourceDomains}:{}};return(0,r.jsxs)("section",{"data-elanous-block-kind":"mcp_app","data-elanous-tool-id":c.toolId,"data-elanous-tool-name":c.toolName,className:"rounded border border-border bg-muted/40 px-3 py-2 text-sm",children:[(0,r.jsx)("div",{className:"font-medium",children:c.toolName}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:c.toolId}),(0,r.jsx)("div",{className:"mt-1 break-all font-mono text-xs",children:c.screenUrl}),x&&(0,r.jsx)(Z,{html:x,connectDomains:h,resourceDomains:g,server:d,tool:c.toolName,toolCallId:c.toolId,toolResult:c.toolResult}),c.fallbackText&&(0,r.jsx)("p",{className:"mt-2 whitespace-pre-wrap text-sm",children:c.fallbackText})]})}let er={pre:function(e){let{children:t}=e,n=(0,a.useMemo)(()=>(function e(t){if(null==t||"boolean"==typeof t)return"";if("string"==typeof t||"number"==typeof t)return String(t);if(Array.isArray(t))return t.map(e).join("");if("object"==typeof t&&"props"in t){let n=t.props;return e(null==n?void 0:n.children)}return""})(t),[t]),s=(0,a.useMemo)(()=>(function e(t){if(null==t||"object"!=typeof t)return null;if(Array.isArray(t)){for(let n of t){let t=e(n);if(t)return t}return null}let n=t.props;if((null==n?void 0:n.className)&&"string"==typeof n.className){var r;let e=/language-([\w+-]+)/.exec(n.className);if(e)return null!=(r=e[1])?r:null}return(null==n?void 0:n.children)?e(n.children):null})(t),[t]),l=(0,a.useMemo)(()=>"string"==typeof n&&0!==n.length&&(n.length>800||n.split("\n").length>12),[n]),[o,i]=(0,a.useState)(!l),[c,d]=(0,a.useState)(!1);if(!l)return(0,r.jsx)("pre",{children:t});let u=function(e){let t=e.split("\n");return t.length<=8?e:t.slice(0,8).join("\n")+"\n…"}(n),m=n.split("\n").length,f=async()=>{try{var e;await (null==(e=navigator.clipboard)?void 0:e.writeText(n)),d(!0),(0,y.cY)("pwa.code-block.copy",{lang:s,lineCount:m}),setTimeout(()=>d(!1),1500)}catch(e){(0,y.cY)("pwa.code-block.copy-error",{reason:String(e)})}};return(0,r.jsxs)("div",{className:"my-2 overflow-hidden rounded-md border border-border bg-muted/40","data-testid":"collapsible-code-block",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b border-border bg-muted/60 px-2 py-1 text-[11px] text-muted-foreground",children:[(0,r.jsxs)("span",{className:"font-mono",children:[null!=s?s:"code"," \xb7 ",m," lines \xb7 ",n.length," chars"]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{f()},"aria-label":"copy code",className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 hover:bg-muted hover:text-foreground",children:[c?(0,r.jsx)(g.A,{className:"h-3 w-3"}):(0,r.jsx)(b.A,{className:"h-3 w-3"}),c?"copied":"copy"]}),(0,r.jsxs)("button",{type:"button",onClick:()=>i(e=>!e),"aria-label":o?"collapse code":"expand code",className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 hover:bg-muted hover:text-foreground",children:[o?(0,r.jsx)(v.A,{className:"h-3 w-3"}):(0,r.jsx)(j.A,{className:"h-3 w-3"}),o?"collapse":"show all"]})]})]}),(0,r.jsx)("pre",{className:"!my-0 overflow-x-auto !rounded-none !bg-transparent !p-2 !text-[13px]",children:o?t:u})]})}};function ea(e){let{text:t,showCards:n}=e;if(!n)return(0,r.jsx)(es,{text:t});let a=(0,i.g)(t);return(0,r.jsxs)(r.Fragment,{children:[a.text.trim()&&(0,r.jsx)(es,{text:a.text}),a.cards.map((e,t)=>(0,r.jsx)(d,{card:e},t))]})}function es(e){let{text:t}=e;return(0,r.jsx)("div",{className:"prose prose-sm max-w-none break-words [&_pre]:bg-muted [&_pre]:p-2 [&_pre]:rounded [&_code]:font-mono [&_code]:text-xs [&_p]:my-1 [&_table]:text-xs",children:(0,r.jsx)(l.oz,{remarkPlugins:o,components:er,children:t})})}function el(e){let{block:t}=e,[n,s]=(0,a.useState)(!1),l="running"===t.status?"⋯":"done"===t.status?"✓":"✗",o="running"===t.status?"text-muted-foreground border-border":"error"===t.status?"text-destructive border-destructive/40":"text-foreground border-border",i=!!t.args&&Object.keys(t.args).length>0,c=[t.startedAt,t.endedAt].filter(e=>"number"==typeof e).map(e=>new Date(e).toLocaleTimeString()).join(" → ");return(0,r.jsxs)("div",{"data-elanous-block-kind":"tool_use","data-elanous-tool-name":t.name,"data-elanous-tool-status":t.status,className:(0,h.cn)("rounded border bg-muted/40 px-2 py-1 text-xs font-mono",o),children:[(0,r.jsxs)("button",{type:"button",onClick:i?()=>s(!n):void 0,className:(0,h.cn)("flex w-full items-center gap-2 text-left",i?"cursor-pointer":"cursor-default"),"aria-expanded":i?n:void 0,children:[(0,r.jsx)("span",{"aria-hidden":"true",children:l}),(0,r.jsx)("span",{className:"font-semibold",children:t.name}),t.summary&&(0,r.jsx)("span",{className:"ml-1 truncate text-muted-foreground",children:t.summary}),c&&(0,r.jsx)("span",{className:"ml-auto text-muted-foreground",children:c}),i&&(0,r.jsx)("span",{className:"ml-auto text-muted-foreground","aria-hidden":"true",children:n?"▾":"▸"})]}),n&&i&&(0,r.jsx)("pre",{className:"mt-1 overflow-x-auto rounded bg-background/60 p-1.5 text-[10px] leading-tight",children:JSON.stringify(t.args,null,2)})]})}function eo(e){let{blocks:t,showCards:n}=e;return(0,r.jsx)("div",{className:"flex flex-col gap-2",children:t.map((e,t)=>{if("harness_ask"===e.kind)return(0,r.jsx)(x,{acceptanceId:e.acceptanceId},"".concat(e.acceptanceId,"-").concat(t));if("text"===e.kind)return(0,r.jsx)(ea,{text:e.text,showCards:n},t);if("image"===e.kind){var a;return(0,r.jsx)("img",{src:e.src,alt:null!=(a=e.alt)?a:"inline image (".concat(e.mediaType,")"),className:"max-w-full rounded border border-border","data-elanous-block-kind":"image","data-elanous-media-type":e.mediaType},t)}return"tool_use"===e.kind?(0,r.jsxs)("div",{children:[(0,r.jsx)(el,{block:e}),(0,r.jsx)(u,{sources:e.sources})]},"".concat(e.id,"-").concat(t)):"mcp_app"===e.kind?(0,r.jsx)(en,{block:e},"".concat(e.toolId,"-").concat(t)):"agent_thinking"===e.kind?(0,r.jsx)(w,{block:e},"thinking-".concat(e.blockId)):"agent_status"===e.kind?(0,r.jsx)(S,{block:e},"status-".concat(e.blockId)):"agent_plan"===e.kind?(0,r.jsx)(D,{block:e},"plan-".concat(e.blockId)):"tool_diff"===e.kind?(0,r.jsx)(A,{block:e},"diff-".concat(e.blockId)):"tool_search_hits"===e.kind?(0,r.jsx)(T,{block:e},"search-".concat(e.blockId)):"tool_progress"===e.kind?(0,r.jsx)(P,{block:e},"progress-".concat(e.blockId)):"perf_session"===e.kind?(0,r.jsx)(O,{block:e},"perf-".concat(e.blockId)):null})})}function ei(e){var t,n,a,s,l;let{message:o}=e,i="user"===o.role,c="meta"===o.role,d="system"===o.role,u=new Date(o.timestamp).toLocaleTimeString();if(c)return(0,r.jsxs)("div",{className:"px-2 py-1 text-[11px] text-muted-foreground italic",children:[(0,r.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px]",children:o.text}),(null==(a=o.blocks)?void 0:a.some(e=>"harness_ask"===e.kind))&&(0,r.jsx)(eo,{blocks:o.blocks,showCards:!1})]});if(d){let e="error"===(null!=(l=null==(s=o.meta)?void 0:s.systemLevel)?l:"note");return(0,r.jsx)("div",{className:"px-3 py-2",children:(0,r.jsxs)("div",{className:(0,h.cn)("rounded-md border px-3 py-2 text-xs font-mono",e?"border-rose-500/60 bg-rose-500/10 text-rose-300":"border-border/60 bg-muted/40 text-muted-foreground italic"),children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,r.jsx)("span",{className:(0,h.cn)("shrink-0 text-[10px] font-semibold uppercase tracking-wide",e?"text-rose-400":"text-muted-foreground/70"),children:e?"⚠ Error":"Note"}),(0,r.jsx)("pre",{className:"flex-1 whitespace-pre-wrap break-all",children:o.text})]}),(0,r.jsx)("div",{className:"mt-1 text-[10px] text-muted-foreground/80",children:u})]})})}let m=Array.isArray(o.blocks)&&o.blocks.length>0;return(0,r.jsx)("div",{className:(0,h.cn)("flex gap-3 px-4 py-3",i?"justify-end":"justify-start"),children:(0,r.jsxs)("div",{className:(0,h.cn)("max-w-[85%] rounded-lg px-3 py-2 text-sm shadow-sm",i?"bg-primary text-primary-foreground":"bg-card text-card-foreground border border-border"),children:[m?(0,r.jsx)(eo,{blocks:o.blocks,showCards:!i}):(0,r.jsx)(ea,{text:o.text,showCards:!i}),(0,r.jsxs)("div",{className:"mt-1 flex items-center gap-2 text-[10px] text-muted-foreground",children:[(0,r.jsx)("span",{children:u}),o.terminalId&&(0,r.jsx)("span",{title:"이 메시지가 나눈 터미널",className:"rounded border border-border/60 bg-muted/60 px-1 font-mono text-[9px] leading-4",children:o.terminalId}),(null==(t=o.meta)?void 0:t.provider)&&(0,r.jsxs)("span",{title:"답한 LLM",children:["\xb7 ",o.meta.provider,o.meta.model?" \xb7 ".concat(o.meta.model):""]}),(null==(n=o.meta)?void 0:n.stopReason)&&(0,r.jsxs)("span",{children:["\xb7 ",o.meta.stopReason]})]})]})})}function ec(e){return ed(e)>240}function ed(e){return Math.max(0,e.scrollHeight-e.clientHeight-e.scrollTop)}function eu(e){var t;return null!=(t=null==e?void 0:e.querySelector('[data-slot="scroll-area-viewport"],[data-radix-scroll-area-viewport]'))?t:null}let em=["wheel","touchmove","pointerdown","keydown"];var ef=n(56540);function ep(e){let{messages:t,pending:n,tabId:l}=e,o=(0,a.useRef)(null),i=(0,a.useRef)(null),c=(0,ef.o1)("chatScroll",l);(0,a.useEffect)(()=>{let e=eu(i.current);if(!e)return;let t=(0,ef.N2)(c);"number"==typeof t&&t>0&&(e.scrollTop=t)},[c]),(0,a.useEffect)(()=>{let e=eu(i.current);if(!e)return;let t=null,n=()=>{t&&clearTimeout(t),t=setTimeout(()=>{(0,ef.Os)(c,e.scrollTop)},250)};return e.addEventListener("scroll",n,{passive:!0}),()=>{e.removeEventListener("scroll",n),t&&clearTimeout(t)}},[c]);let[d,u]=(0,a.useState)(!1),m=(0,a.useRef)({stuck:!0}),f=(0,a.useRef)(!1),p=(0,a.useRef)(t.length);(0,a.useEffect)(()=>{let e=t[t.length-1];t.length>p.current&&(null==e?void 0:e.role)==="user"&&(f.current=!0),p.current=t.length},[t]),(0,a.useEffect)(()=>{var e,t;let n=eu(i.current),r=null==(e=o.current)?void 0:e.parentElement;if(!n||!r)return;let a=!1,s=e=>{var t;!a&&(u(ec({scrollTop:n.scrollTop,scrollHeight:n.scrollHeight,clientHeight:n.clientHeight})),t=m.current,(f.current||t.stuck)&&(f.current=!1,n.scrollTo({top:n.scrollHeight,behavior:e?"auto":"smooth"})))};s(!1);let l=()=>({scrollTop:n.scrollTop,scrollHeight:n.scrollHeight,clientHeight:n.clientHeight}),c=null,d=()=>{let e=l();m.current=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:96;return{stuck:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:96;return ed(e)<=t}(t,n)}}(m.current,e),u(ec(e))},p=()=>{u(ec(l()))},x=e=>{var t;if("keydown"!==e.type||"PageUp"===(t=e.key)||"PageDown"===t||"Home"===t||"End"===t||"ArrowUp"===t||"ArrowDown"===t||" "===t||"Spacebar"===t){if("pointerdown"===e.type){a=!0,n.scrollTo({top:n.scrollTop,behavior:"auto"});return}"function"==typeof requestAnimationFrame?(null!==c&&cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=null,d()})):d()}},h=()=>{a&&(a=!1,d())};n.addEventListener("scroll",p,{passive:!0});let g=null!=(t=i.current)?t:n;for(let e of em)g.addEventListener(e,x,{passive:!0});let b=window;null==b||b.addEventListener("pointerup",h,{passive:!0}),null==b||b.addEventListener("pointercancel",h,{passive:!0});let v=()=>{for(let e of(null!==c&&"function"==typeof cancelAnimationFrame&&(cancelAnimationFrame(c),c=null),n.removeEventListener("scroll",p),em))g.removeEventListener(e,x);null==b||b.removeEventListener("pointerup",h),null==b||b.removeEventListener("pointercancel",h)};if("undefined"==typeof ResizeObserver)return v;let j=new ResizeObserver(()=>{s(!0)});return j.observe(r),()=>{j.disconnect(),v()}},[t.length,n]);let x=(0,a.useCallback)(()=>{let e=eu(i.current);m.current={stuck:!0},null==e||e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[]);return 0!==t.length||n?(0,r.jsxs)("div",{ref:i,className:"relative flex-1 min-h-0",children:[(0,r.jsx)(s.F,{className:"h-full",children:(0,r.jsxs)("div",{className:"flex flex-col gap-1 pt-2 ".concat("pb-24"),children:[t.map(e=>(0,r.jsx)(ei,{message:e},e.id)),n&&(0,r.jsx)("div",{className:"flex justify-start px-4 py-3",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-border bg-card px-3 py-2 text-sm text-muted-foreground",children:[(0,r.jsx)("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-primary"}),"thinking…"]})}),(0,r.jsx)("div",{ref:o})]})}),d&&(0,r.jsx)("button",{type:"button",onClick:x,"data-elanous-jump-to-bottom":"true",className:"absolute bottom-3 left-1/2 -translate-x-1/2 rounded-full border border-border bg-card/95 px-3 py-1.5 text-xs shadow-lg backdrop-blur transition-colors hover:bg-accent",children:"맨 아래로 ↓"})]}):(0,r.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 p-8 text-center text-sm text-muted-foreground",children:[(0,r.jsx)("p",{children:"무엇이든 말을 걸어 보세요."}),(0,r.jsxs)("p",{className:"text-xs",children:[(0,r.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono",children:":help"})," 를 치면 명령 목록이 나옵니다."]})]})}},87969:(e,t,n)=>{n.d(t,{$:()=>l});var r=n(46124);let a=/[.!?。!?]+\s*/g;function s(){return void 0!==window.speechSynthesis}function l(e){var t;let[n,l]=(0,r.useState)(!1);(0,r.useEffect)(()=>{l(s())},[]);let[,o]=(0,r.useState)({}),i=(0,r.useRef)(""),c=(0,r.useRef)(e.enabled);c.current=e.enabled;let d=null!=(t=e.maxBufferChars)?t:80,u=(0,r.useRef)(e.language);u.current=e.language,(0,r.useEffect)(()=>{var e,t;if(!n)return;let r=()=>o({});return window.speechSynthesis.getVoices(),null==(e=(t=window.speechSynthesis).addEventListener)||e.call(t,"voiceschanged",r),()=>{var e,t;null==(e=(t=window.speechSynthesis).removeEventListener)||e.call(t,"voiceschanged",r)}},[n]),(0,r.useEffect)(()=>{n&&(e.enabled||(window.speechSynthesis.cancel(),i.current=""))},[e.enabled,n]);let m=(0,r.useCallback)(e=>{if(!n||!c.current)return;let t=e.trim();if(!t)return;let r=new SpeechSynthesisUtterance(t),a=function(e){var t;if(!s()||!e)return null;let n=window.speechSynthesis.getVoices();if(0===n.length)return null;let r=e.toLowerCase(),a=n.find(e=>e.lang.toLowerCase()===r);if(a)return a;let l=r.split("-")[0];return null!=(t=n.find(e=>e.lang.toLowerCase().startsWith(l)))?t:null}(u.current);a&&(r.voice=a),u.current&&(r.lang=u.current),window.speechSynthesis.speak(r)},[n]),f=(0,r.useCallback)(e=>{if(!e||!c.current)return;i.current+=e;let{sentences:t,remainder:n}=function(e){let t,n=[],r=0;for(a.lastIndex=0;null!==(t=a.exec(e));){let a=t.index+t[0].length,s=e.slice(r,a).trim();s&&n.push(s),r=a}return{sentences:n,remainder:e.slice(r)}}(i.current);for(let e of(i.current=n,t))m(e);if(i.current.length>=d){let e=i.current;i.current="",m(e)}},[d,m]);return{pushText:f,flush:(0,r.useCallback)(()=>{let e=i.current.trim();i.current="",e&&m(e)},[m]),cancel:(0,r.useCallback)(()=>{n&&(window.speechSynthesis.cancel(),i.current="")},[n]),supported:n}}},92156:(e,t,n)=>{n.d(t,{vG:()=>s});var r=n(55539),a=n(46124);function s(e){let{children:t}=e;return!function(){let[e,t]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{"public"===new URLSearchParams(window.location.search).get("capture")&&t(!0)},[]),e}()?(0,r.jsx)(r.Fragment,{children:t}):null}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[899],{12958:(e,t,n)=>{n.d(t,{a:()=>o});var r=n(55539),a=n(46124),l=n(74780);let s=e=>JSON.stringify([e.graphId,e.runId]);function o(e){let{client:t,approvals:n,onDecided:o,onPendingChange:i}=e,c=(0,a.useMemo)(()=>(0,l.ll)({client:t}),[t]),[d,u]=(0,a.useState)([]),[m,h]=(0,a.useState)({}),[p,f]=(0,a.useState)(null),[g,x]=(0,a.useState)(""),b=(0,a.useRef)(0),v=n.map(s).join("|");function y(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:m;u(e),i(n.filter(n=>!t[s(n)]&&e.some(e=>s(e)===s(n))).length)}async function w(e,t){let r=s(e);if(p||m[r]||!n.some(e=>s(e)===r)||!d.some(e=>s(e)===r))return;let a=b.current;f(r),x("");try{if(await c.decide(e.graphId,e.runId,t),b.current!==a)return;let n={...m,[r]:t};h(n),y(d,n),o();let l=await c.list();b.current===a&&y(l.items,n)}catch(e){b.current===a&&x((0,l.LP)(e,"decide"))}finally{b.current===a&&f(null)}}return((0,a.useEffect)(()=>{let e=++b.current;return(u([]),x(""),v)?(c.list().then(t=>{b.current===e&&y(t.items)}).catch(t=>{b.current===e&&x((0,l.LP)(t,"list"))}),()=>{b.current+=1}):(i(0),()=>{b.current+=1})},[c,v]),0===n.length)?null:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("h3",{className:"font-semibold",children:"게시 승인"}),g&&(0,r.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:g}),(0,r.jsx)("ul",{className:"space-y-2",children:n.map(e=>{let t=s(e),n=d.some(e=>s(e)===t);return(0,r.jsxs)("li",{className:"rounded-lg border border-border bg-background px-4 py-3 text-sm",children:[(0,r.jsx)("p",{children:e.message}),m[t]?(0,r.jsx)("p",{className:"mt-2 text-muted-foreground",children:"approved"===m[t]?"승인됨":"보류됨"}):n?(0,r.jsxs)("div",{className:"mt-2 flex gap-2",children:[(0,r.jsx)("button",{type:"button",disabled:null!==p,onClick:()=>void w(e,"approved"),className:"rounded-lg bg-primary px-3 py-1 text-primary-foreground disabled:opacity-50",children:"승인"}),(0,r.jsx)("button",{type:"button",disabled:null!==p,onClick:()=>void w(e,"rejected"),className:"rounded-lg border border-border px-3 py-1 disabled:opacity-50",children:"보류"})]}):(0,r.jsx)("p",{className:"mt-2 text-muted-foreground",children:"대기 중인 승인이 아닙니다."})]},t)})})]})}},33626:(e,t,n)=>{async function r(e){let t=await e.fetchResponse("/v1/decisions?status=open");if(!t.ok)throw Error("decisions list failed: ".concat(t.status));return(await t.json()).decisions}async function a(e,t,n){let r=await e.fetchResponse("/v1/decisions/".concat(encodeURIComponent(t),"/decide"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({choice:n})});if(!r.ok)throw Error("decision failed: ".concat(r.status))}n.d(t,{L:()=>a,q:()=>r})},43537:(e,t,n)=>{function r(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function a(e){return"string"==typeof e}function l(e){return a(e)&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/.test(e)&&Number.isFinite(Date.parse(e))&&new Date(e).toISOString().slice(0,19)===e.slice(0,19)}function s(e){return r(e)&&a(e.nodeId)&&(null===e.ok||"boolean"==typeof e.ok)&&a(e.summary)}function o(e){return r(e)&&a(e.runId)&&a(e.status)&&a(e.startedAt)&&(null===e.version||a(e.version))&&Array.isArray(e.path)&&e.path.every(a)&&Array.isArray(e.nodes)&&e.nodes.every(s)}function i(e){return r(e)&&a(e.id)&&a(e.title)&&a(e.status)&&(void 0===e.owner||a(e.owner))&&a(e.updatedAt)&&(void 0===e.evidence||a(e.evidence))}n.d(t,{HG:()=>g,Kh:()=>f,Nn:()=>h,oc:()=>p});let c=e=>Number.isInteger(e)&&e>=0;function d(e){return r(e)&&a(e.id)&&a(e.title)&&(null===e.open||c(e.open))&&(null===e.landed||c(e.landed))&&(null===e.blocked||Array.isArray(e.blocked)&&e.blocked.every(e=>r(e)&&a(e.id)&&a(e.title)))}function u(e){return r(e)&&["OP","MK","TC","UX"].includes(e.seat)&&(void 0===e.role||a(e.role))&&(null===e.now||r(e.now)&&a(e.now.text)&&a(e.now.at))&&(null===e.landed||Array.isArray(e.landed)&&e.landed.every(e=>r(e)&&c(e.pr)&&a(e.title)&&a(e.at)&&(null===e.checklistId||a(e.checklistId))))&&(null===e.blocked||Array.isArray(e.blocked)&&e.blocked.every(e=>r(e)&&a(e.id)&&a(e.title)&&"red"===e.status))&&(null===e.pendingDecisions||c(e.pendingDecisions))&&(null===e.checklist||r(e.checklist)&&["green","yellow","red","done"].every(t=>c(e.checklist[t])))&&(void 0===e.subSeats||null===e.subSeats||Array.isArray(e.subSeats)&&e.subSeats.every(d))}async function m(e,t,n){try{let r=await e.fetchResponse(t,{method:"GET"});if(403===r.status)return{kind:"forbidden"};if(!r.ok)return{kind:"error",status:r.status};let a=n(await r.json());return null===a?{kind:"error",status:r.status}:{kind:"ready",data:a}}catch(e){return{kind:"error",status:0}}}function h(e,t){return m(e,"/v1/ops/seats".concat(t?"?date=".concat(encodeURIComponent(t)):""),e=>r(e)&&a(e.date)&&Array.isArray(e.seats)&&e.seats.every(u)&&new Set(e.seats.map(e=>e.seat)).size===e.seats.length?{date:e.date,seats:e.seats}:null)}function p(e,t){return m(e,"/v1/ops/release/runs".concat(t?"?version=".concat(encodeURIComponent(t)):""),e=>Array.isArray(e)&&e.every(o)?e:null)}function f(e,t,n){return m(e,"/v1/ops/release/runs/".concat(encodeURIComponent(t),"/nodes/").concat(encodeURIComponent(n),"/log"),e=>r(e)&&a(e.log)?{log:e.log}:null)}function g(e,t){return m(e,"/v1/ops/checklist?version=".concat(encodeURIComponent(t)),e=>{var t,n,s,o;if(!(r(e)&&a(e.version)&&(void 0===e.codename||a(e.codename))&&Array.isArray(e.items)&&e.items.every(i)&&["green","yellow","red","done"].every(t=>void 0===e[t]||Number.isInteger(e[t])&&e[t]>=0)&&(void 0===e.blocked||Array.isArray(e.blocked)&&e.blocked.every(a))&&(void 0===e.byOwner||r(e.byOwner)&&Object.values(e.byOwner).every(e=>Number.isInteger(e)&&e>=0))&&(void 0===e.history||Array.isArray(e.history))))return null;let c={green:0,yellow:0,red:0,done:0};for(let t of e.items)t.status in c&&c[t.status]++;return{version:e.version,...void 0!==e.codename?{codename:e.codename}:{},schedule:r(e.schedule)&&l(e.schedule.cutAt)&&(null===e.schedule.landBy||l(e.schedule.landBy))?{cutAt:e.schedule.cutAt,landBy:e.schedule.landBy}:null,items:e.items,green:null!=(t=e.green)?t:c.green,yellow:null!=(n=e.yellow)?n:c.yellow,red:null!=(s=e.red)?s:c.red,done:null!=(o=e.done)?o:c.done,...void 0!==e.blocked?{blocked:e.blocked}:{},...void 0!==e.byOwner?{byOwner:e.byOwner}:{},...void 0!==e.history?{history:e.history}:{}}})}},50899:(e,t,n)=>{n.d(t,{ChatPanel:()=>e1});var r=n(55539),a=n(46124),l=n(92156),s=n(94226),o=n(16190),i=n(46586),c=n(71923),d=n(15151),u=n(43537),m=n(37768);function h(){let{client:e}=(0,d.Q)(),[t,n]=(0,a.useState)([]);if((0,a.useEffect)(()=>{if("undefined"==typeof document)return;let t=!0,r=!1,a=async()=>{if(!t||r||document.hidden)return;r=!0;let a=new Intl.DateTimeFormat("sv-SE",{timeZone:"Asia/Seoul"}).format(new Date),l=await (0,u.Nn)(e,a);r=!1,t&&n((0,m.z)("ready"===l.kind?l.data:null,Date.now()))};n([]),a();let l=globalThis.setInterval(()=>{a()},6e4),s=()=>{document.hidden||a()};return document.addEventListener("visibilitychange",s),()=>{t=!1,globalThis.clearInterval(l),document.removeEventListener("visibilitychange",s)}},[e]),0===t.length)return null;let l=t.map(e=>{let{seat:t,text:n,ago:r}=e;return"".concat(t," ").concat(n," \xb7 ").concat(r)}).join(" | ");return(0,r.jsx)("div",{role:"status","aria-label":"지금 자리들이 하는 일",title:l,className:"h-8 min-h-8 min-w-0 shrink-0 overflow-hidden text-ellipsis whitespace-nowrap border-b border-border bg-background px-3 text-xs leading-8 text-muted-foreground",children:t.map((e,t)=>{let{seat:n,text:a,ago:l}=e;return(0,r.jsxs)("span",{children:[t>0&&" | ",n," ",a," \xb7 ",l]},n)})})}var p=n(3180),f=n(72215);function g(){let{client:e}=(0,d.Q)(),[t,n]=(0,a.useState)(!1),[l,s]=(0,a.useState)(!1),[o,i]=(0,a.useState)(""),c=(0,a.useRef)(!1),u=(0,a.useRef)(0),m=(0,a.useRef)(!1);(0,a.useEffect)(()=>(n("speechSynthesis"in window&&"undefined"!=typeof SpeechSynthesisUtterance),()=>{u.current++,m.current&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}),[]);let h=async()=>{if(c.current||!t)return;c.current=!0;let n=++u.current;s(!0),i(""),m.current&&window.speechSynthesis.cancel(),m.current=!1;try{let t=await e.fetchResponse("/v1/context/now?format=voice",{method:"GET"});if(!t.ok)throw Error("HTTP ".concat(t.status));let r=await t.json();if(!r||"object"!=typeof r||!("text"in r)||"string"!=typeof r.text||!r.text.trim())throw Error("invalid voice summary");if(n!==u.current)return;let a=new SpeechSynthesisUtterance(r.text);a.lang="ko-KR",a.onend=()=>{n===u.current&&(m.current=!1)},a.onerror=()=>{n===u.current&&(m.current=!1)},m.current=!0,window.speechSynthesis.speak(a),(0,f.cY)("chat.now.speak",{outcome:"spoken"})}catch(e){if(n!==u.current)return;m.current=!1,i("지금 상황을 읽지 못했습니다. 다시 시도해 주세요."),(0,f.cY)("chat.now.speak",{outcome:"error",reason:String(e)})}finally{n===u.current&&(c.current=!1,s(!1))}};return(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,r.jsxs)("button",{type:"button","data-elanous-action":"chat-now-speak","aria-label":"지금 상황 듣기",title:t?"지금 상황 두 문장 듣기":"이 브라우저는 음성 읽기를 지원하지 않습니다",disabled:!t||l,onClick:()=>void h(),className:"inline-flex min-h-9 items-center gap-1.5 rounded-full border border-border bg-background px-3 text-xs font-medium text-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50",children:[(0,r.jsx)(p.A,{className:"h-4 w-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:"지금 상황 듣기"})]}),o&&(0,r.jsx)("span",{role:"alert",className:"text-xs text-rose-600",children:o})]})}var x=n(12958),b=n(74780);function v(){let{client:e}=(0,d.Q)(),t=(0,a.useMemo)(()=>(0,b.ll)({client:e}),[e]),[n,l]=(0,a.useState)({client:e,items:[],pending:0,expanded:!1}),s=(0,a.useRef)(e);s.current=e;let o=(0,a.useRef)(!1),i=(0,a.useRef)(0),c=n.client===e?n:null,u=(0,a.useCallback)(async()=>{if(!o.current||s.current!==e||"undefined"!=typeof document&&document.hidden)return;let n=++i.current;try{let r=await t.list();if(!o.current||s.current!==e||i.current!==n)return;l(t=>s.current===e&&i.current===n?{client:e,items:r.items,pending:r.items.length,expanded:r.items.length>0&&t.client===e&&t.expanded}:t)}catch(t){if(!o.current||s.current!==e||i.current!==n)return;l(t=>s.current===e&&i.current===n?{client:e,items:[],pending:0,expanded:!1}:t)}},[t,e]);return((0,a.useEffect)(()=>{o.current=!0,l({client:e,items:[],pending:0,expanded:!1}),u();let t=globalThis.setInterval(()=>{u()},3e4),n=()=>{document.hidden||u()};return"undefined"!=typeof document&&document.addEventListener("visibilitychange",n),()=>{o.current=!1,i.current+=1,globalThis.clearInterval(t),"undefined"!=typeof document&&document.removeEventListener("visibilitychange",n)}},[e,u]),(0,a.useEffect)(()=>{var e,t;(0,f.cY)("chat.approvals",{pending:null!=(e=null==c?void 0:c.pending)?e:0,expanded:null!=(t=null==c?void 0:c.expanded)&&t})},[null==c?void 0:c.pending,null==c?void 0:c.expanded]),null==c?void 0:c.pending)?(0,r.jsxs)("div",{className:"shrink-0 border-b border-border bg-background px-3 py-1.5 text-sm",children:[(0,r.jsxs)("button",{type:"button","aria-expanded":c.expanded,"aria-controls":"chat-approvals-panel",onClick:()=>l(t=>t.client===e?{...t,expanded:!t.expanded}:t),className:"rounded-full border border-border bg-muted px-3 py-1 font-medium text-foreground hover:bg-muted/70",children:["승인 대기 ",c.pending]}),c.expanded&&(0,r.jsx)("div",{id:"chat-approvals-panel",className:"mt-2 max-h-[min(50vh,24rem)] overflow-y-auto rounded-lg border border-border p-3",children:(0,r.jsx)(x.a,{client:e,approvals:c.items,onDecided:()=>{u()},onPendingChange:t=>{s.current===e&&l(n=>n.client===e?{...n,pending:t,...0===t?{items:[],expanded:!1}:{}}:n)}})})]}):null}var y=n(33626);function w(){var e;let{client:t}=(0,d.Q)(),[n,l]=(0,a.useState)({client:t,items:[],expanded:!1,decided:{},busy:null}),s=(0,a.useRef)(t);s.current=t;let o=(0,a.useRef)(!1),i=(0,a.useRef)(0),c=(0,a.useRef)(null),u=n.client===t?n:null,m=(0,a.useCallback)(async()=>{if(!o.current||s.current!==t||"undefined"!=typeof document&&document.hidden)return;let e=++i.current;try{let n=await (0,y.q)(t);if(!o.current||s.current!==t||i.current!==e)return;l(e=>e.client===t?{...e,items:[...n,...e.items.filter(t=>e.decided[t.id]&&!n.some(e=>e.id===t.id))],expanded:e.expanded&&(n.length>0||e.items.some(t=>e.decided[t.id]))}:e)}catch(n){if(!o.current||s.current!==t||i.current!==e)return;l(e=>e.client===t?{...e,items:[],expanded:!1}:e)}},[t]);(0,a.useEffect)(()=>{o.current=!0,c.current=null,l({client:t,items:[],expanded:!1,decided:{},busy:null}),m();let e=globalThis.setInterval(()=>{m()},3e4),n=()=>{document.hidden||m()};return"undefined"!=typeof document&&document.addEventListener("visibilitychange",n),()=>{o.current=!1,c.current=null,i.current+=1,globalThis.clearInterval(e),"undefined"!=typeof document&&document.removeEventListener("visibilitychange",n)}},[t,m]);let h=async(e,r)=>{if(!c.current&&!n.busy&&!n.decided[e.id]){c.current=e.id,l(n=>n.client===t?{...n,busy:e.id}:n);try{if(await (0,y.L)(t,e.id,r.id),!o.current||s.current!==t)return;c.current=null,l(n=>n.client===t?{...n,busy:null,decided:{...n.decided,[e.id]:r.label}}:n),await m()}catch(e){o.current&&s.current===t&&(c.current=null,l(e=>e.client===t?{...e,busy:null}:e))}}},p=null!=(e=null==u?void 0:u.items.filter(e=>!u.decided[e.id]).length)?e:0;return u&&(p||u.expanded&&u.items.some(e=>u.decided[e.id]))?(0,r.jsxs)("div",{className:"shrink-0 border-b border-border bg-background px-3 py-1.5 text-sm",children:[(0,r.jsxs)("button",{type:"button","aria-expanded":u.expanded,"aria-controls":"chat-decisions-panel",onClick:()=>l(e=>e.client===t?{...e,expanded:!e.expanded}:e),className:"rounded-full border border-border bg-muted px-3 py-1 font-medium text-foreground hover:bg-muted/70",children:["대표 결정 ",p]}),u.expanded&&(0,r.jsx)("ul",{id:"chat-decisions-panel",className:"mt-2 max-h-[min(50vh,24rem)] space-y-2 overflow-y-auto rounded-lg border border-border p-3",children:u.items.map(e=>(0,r.jsxs)("li",{className:"rounded-lg border border-border p-3",children:[(0,r.jsx)("h3",{className:"font-semibold",children:e.title}),(0,r.jsx)("p",{className:"truncate text-muted-foreground",title:e.situation,children:e.situation}),u.decided[e.id]?(0,r.jsxs)("p",{role:"status",children:["결정함 — ",u.decided[e.id]]}):(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:e.options.map(t=>(0,r.jsxs)("button",{type:"button",disabled:!!u.busy,onClick:()=>{h(e,t)},className:"rounded-md border border-border px-2 py-1 hover:bg-muted disabled:opacity-50",children:[t.label,"option"in e.recommendation&&e.recommendation.option===t.id&&(0,r.jsx)("span",{className:"ml-1 text-primary",children:"추천"})]},t.id))})]},e.id))})]}):null}var j=n(84968),k=n(9851);function N(e){let{queue:t,onRemove:n,onClear:a}=e;return 0===t.length?null:(0,r.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center gap-1.5 border-t border-border bg-background px-3 py-2","aria-label":"보낼 차례",children:[t.map((e,t)=>(0,r.jsxs)("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full border border-border bg-muted px-2 py-1 text-xs",children:[(0,r.jsxs)("span",{className:"max-w-[160px] truncate",title:e.text,children:[t+1," \xb7 ",Array.from(e.text).slice(0,20).join("")]}),(0,r.jsx)("button",{type:"button",onClick:()=>n(e.id),"aria-label":"".concat(t+1,"번 지우기"),className:"rounded-full px-1 hover:bg-background",children:"\xd7"})]},e.id)),(0,r.jsx)("button",{type:"button",onClick:a,className:"rounded px-2 py-1 text-xs text-muted-foreground hover:bg-muted",children:"모두 지우기"})]})}function S(e){let t={files:[],tooLarge:0,tooMany:0};for(let n of e)n.file.size>0x1400000?t.tooLarge+=1:t.files.length>=10?t.tooMany+=1:t.files.push(n);return t}function I(e){return!!(e&&Array.from(e.types).includes("Files"))}function C(){return(0,r.jsx)("div",{role:"status","aria-label":"여기에 놓으면 첨부","data-elanous-chat-drop-overlay":"",className:"pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-background/80 backdrop-blur-sm",children:(0,r.jsxs)("div",{className:"mx-4 rounded-2xl border-2 border-dashed border-primary/60 bg-card/90 px-8 py-6 text-center shadow-lg",children:[(0,r.jsx)("p",{className:"text-lg font-semibold text-foreground",children:"여기에 놓으면 첨부"}),(0,r.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["파일 ",10,"개까지 \xb7 큰 파일은 빠집니다"]})]})})}function A(e,t,n){if("drop"===t||"end"===t||!n)return{visible:!1,depth:0};let r="enter"===t?e.depth+1:Math.max(0,e.depth-1);return{visible:r>0,depth:r}}var E=n(64667),R=n(3155),D=n(25503);class T{list(){return this.client.fetchJson("/v1/projects")}create(e){return this.client.fetchJson("/v1/projects",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:e})})}assign(e,t){return this.client.fetchJson("/v1/sessions/store/".concat(encodeURIComponent(e)),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({projectId:t})})}constructor(e){this.client=e}}let q="elanous.chat.projectSelection",L="elanous-chat-pending-projects-changed",U="elanous-chat-projects-changed";function O(){window.dispatchEvent(new Event(U))}let M="elanous.chat.pendingProjects";function F(){try{var e;let t=JSON.parse(null!=(e=localStorage.getItem(M))?e:"{}");if(t&&"object"==typeof t&&!Array.isArray(t))return Object.fromEntries(Object.entries(t).filter(e=>{let[t,n]=e;return t&&"string"==typeof n&&n}))}catch(e){}return{}}function P(e){try{localStorage.setItem(M,JSON.stringify(e))}catch(e){return!1}return window.dispatchEvent(new Event(L)),!0}function Y(e){let{projects:t,selection:n,onChange:l,onCreate:s}=e,[o,i]=(0,a.useState)(!1),[c,d]=(0,a.useState)(""),[u,m]=(0,a.useState)(!1);return(0,r.jsxs)("div",{className:"space-y-2",children:[0===t.length&&!o&&(0,r.jsx)("button",{type:"button",onClick:()=>i(!0),className:"text-sm text-muted-foreground hover:text-foreground",children:"+ 프로젝트 만들기"}),t.length>0&&(0,r.jsxs)("select",{"aria-label":"프로젝트 바꾸기",value:n,onChange:e=>{if("create"===e.target.value)return void i(!0);l(e.target.value)},className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm",children:[(0,r.jsx)("option",{value:"all",children:"모든 대화"}),(0,r.jsx)("option",{value:"none",children:"받은 대화(프로젝트 없음)"}),t.map(e=>(0,r.jsx)("option",{value:e.id,children:e.name},e.id)),(0,r.jsx)("option",{value:"create",children:"+ 프로젝트 만들기"})]}),o&&(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault();let t=c.trim();t&&s(t).then(()=>{i(!1),d(""),m(!1)}).catch(()=>m(!0))},className:"flex gap-2",children:[(0,r.jsx)("input",{"aria-label":"프로젝트 이름",autoFocus:!0,value:c,maxLength:80,onChange:e=>d(e.target.value),className:"min-w-0 flex-1 rounded-lg border border-border bg-background px-2 py-1 text-sm"}),(0,r.jsx)("button",{type:"submit",className:"rounded-lg border border-border px-2 text-sm",children:"만들기"}),u&&(0,r.jsx)("span",{role:"alert",children:"프로젝트를 만들지 못했습니다"})]})]})}function _(e){var t,n;let{compact:l=!1}=e,{client:s,sessionId:o}=(0,d.Q)(),i=(0,D.t)(),[c,u]=(0,a.useState)([]),[m,h]=(0,a.useState)(!0),[p,f]=(0,a.useState)(!1),[g,x]=(0,a.useState)(0),[b,v]=(0,a.useState)(!1),[y,w]=(0,a.useState)(null),[j,k]=(0,a.useState)(!1),[N,S]=(0,a.useState)(!0),[I,C]=(0,a.useState)([]),[A,E]=(0,a.useState)(0),[q,M]=(0,a.useState)(null),Y=(0,a.useRef)(null),_=(0,a.useRef)(null),J=(0,a.useRef)(null),z=(0,a.useRef)(new Set),$=!!(o&&I.includes(o)),Q=(0,a.useRef)(null),G=(0,a.useRef)(o);G.current=o;let[K,B]=(0,a.useState)(""),[H,W]=(0,a.useState)(!1),[Z,V]=(0,a.useState)("");(0,a.useEffect)(()=>{let e=!0,t=0;u([]),f(!1);let n=()=>{let n=++t;h(!0),new T(s).list().then(r=>{let{projects:a}=r;e&&n===t&&(u(null!=a?a:[]),f(!1))}).catch(()=>{e&&n===t&&f(!0)}).finally(()=>{e&&n===t&&h(!1)})};return n(),window.addEventListener(U,n),()=>{e=!1,window.removeEventListener(U,n)}},[s,g]),(0,a.useEffect)(()=>{let e=!0;return(S(!0),M(null),k(!1),Q.current=null,w(null),o)?(s.fetchJson("/v1/sessions/store/".concat(encodeURIComponent(o),"?ifExists=1")).then(t=>{var n,r,a,l;e&&(k(!!t.meta),Q.current=null!=(r=null==(n=t.meta)?void 0:n.projectId)?r:null,z.current.has(o)||w(t.meta?null!=(a=t.meta.projectId)?a:null:null!=(l=F()[o])?l:null),M(o),S(!1))}).catch(()=>{e&&(M(null),B("프로젝트를 확인하지 못했습니다"),S(!1))}),()=>{e=!1}):void S(!1)},[s,o,A]),(0,a.useEffect)(()=>{B(""),W(!1),Y.current=null,J.current=null},[o]),(0,a.useEffect)(()=>{if(!o)return;let e=()=>{let e=F()[o];e&&(J.current=null),z.current.has(o)||(q===o&&j&&e!==Q.current?E(e=>e+1):q===o&&w(null!=e?e:null))};return window.addEventListener(L,e),()=>window.removeEventListener(L,e)},[o,q,j]),(0,a.useEffect)(()=>{o&&q===o&&!j&&!$&&Y.current!==o&&i.some(e=>e.id===o)&&(Y.current=o,M(null),E(e=>e+1))},[o,q,j,$,i]),(0,a.useEffect)(()=>{if(!o||!j||N||$)return;let e=F()[o];!e||z.current.has(o)||_.current===o||J.current==="".concat(o,":").concat(e)||(_.current=o,new T(s).assign(o,e).then(()=>{G.current===o&&(Q.current=e);let t=F();t[o]===e&&(delete t[o],P(t),G.current!==o||z.current.has(o)||w(e)),(0,R.hG)(s).forceRefresh()}).catch(()=>{J.current="".concat(o,":").concat(e);let t=F();t[o]===e&&(delete t[o],P(t)),G.current===o&&(w(Q.current),B("프로젝트를 바꾸지 못했습니다"))}).finally(()=>{_.current=null}))},[s,o,j,N,$,A]);let X=async function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!o||q!==o||N||p&&!t||z.current.has(o)||_.current===o)return!1;z.current.add(o),C(e=>[...e,o]),B("");try{if(j){await new T(s).assign(o,e),G.current===o&&(Q.current=e),(0,R.hG)(s).forceRefresh();let t=F();t[o]&&(delete t[o],P(t))}else{let t=F();if(e?t[o]=e:delete t[o],!P(t))throw Error("pending project storage unavailable")}return G.current===o&&w(e),!0}catch(e){return G.current===o&&B("프로젝트를 바꾸지 못했습니다"),!1}finally{z.current.delete(o),C(e=>e.filter(e=>e!==o))}},ee=y?null!=(n=null==(t=c.find(e=>e.id===y))?void 0:t.name)?n:"알 수 없는 프로젝트":"프로젝트 없음";return(0,r.jsxs)("div",{className:l?"relative flex min-w-0 items-center gap-1.5 text-xs":"flex min-w-0 items-center gap-1.5 text-xs",children:[(0,r.jsx)("label",{htmlFor:"chat-current-project",className:l?"sr-only":"shrink-0 text-muted-foreground",children:"프로젝트"}),(0,r.jsxs)("select",{id:"chat-current-project","aria-label":"현재 대화 프로젝트",title:o&&q===o&&!N?"현재 프로젝트: ".concat(ee):"프로젝트 확인 중…",value:o&&q===o&&!N?null!=y?y:"":"loading",disabled:!o||q!==o||N||m||$||_.current===o||p,onChange:e=>{if("create"===e.target.value){m||p||W(!0);return}X(e.target.value||null)},className:"".concat(l?"w-20 max-w-[24vw]":"max-w-36"," min-w-0 truncate rounded-md border border-border bg-background px-2 py-1 text-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring"),children:[(!o||q!==o||N)&&(0,r.jsx)("option",{value:"loading",children:"프로젝트 확인 중…"}),(0,r.jsx)("option",{value:"",children:"프로젝트 없음"}),y&&!c.some(e=>e.id===y)&&(0,r.jsx)("option",{value:y,children:"알 수 없는 프로젝트"}),c.map(e=>(0,r.jsx)("option",{value:e.id,children:e.name},e.id)),l&&(0,r.jsx)("option",{value:"create",children:"+ 프로젝트 만들기"})]}),!l&&(0,r.jsx)("button",{type:"button","aria-label":"프로젝트 만들기",title:"프로젝트 만들기",disabled:!o||q!==o||N||m||$||p,onClick:()=>W(e=>!e),className:"shrink-0 rounded px-1 hover:bg-muted",children:"+"}),H&&(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault();let t=Z.trim();!t||!o||q!==o||N||m||p||$||b||(v(!0),B(""),new T(s).create(t).then(async e=>{let{project:t}=e;u(e=>[...e,t]);let n=await X(t.id,!0);O(),n&&(W(!1),V(""))}).catch(()=>B("프로젝트를 만들지 못했습니다")).finally(()=>v(!1)))},className:l?"absolute right-0 top-full z-50 mt-1 flex items-center gap-1 rounded-lg border border-border bg-popover p-2 shadow-lg":"flex min-w-0 items-center gap-1",children:[(0,r.jsx)("input",{"aria-label":"새 프로젝트 이름",autoFocus:!0,maxLength:80,value:Z,onChange:e=>V(e.target.value),className:"w-24 rounded border border-border bg-background px-1 py-1"}),(0,r.jsx)("button",{type:"submit",disabled:$||b||!o||q!==o||m||p,className:"rounded border border-border px-1",children:"만들기"})]}),(o&&q!==o&&!N||p)&&(0,r.jsx)("button",{type:"button","aria-label":"프로젝트 다시 확인",onClick:()=>{B(""),E(e=>e+1),p&&x(e=>e+1)},className:"rounded border border-border px-1",children:"다시 시도"}),(K||p)&&(0,r.jsx)("span",{role:"alert",className:"text-destructive",children:K||"프로젝트 목록을 불러오지 못했습니다"})]})}var J=n(44373),z=n(8114);function $(e){let{segmentKey:t,value:n,glyph:a}=e,l=function(e){var t;let n=/(\d{1,3})\s*%/.exec(e);if(!n)return null;let r=Number.parseInt(null!=(t=n[1])?t:"",10);return Number.isFinite(r)?Math.max(0,Math.min(100,r)):null}(n);if(null===l)return(0,r.jsxs)("span",{"data-elanous-hud-key":t,"data-elanous-hud-gauge":"false",className:"inline-flex items-center gap-1 font-mono text-[11px] text-muted-foreground",children:[a?(0,r.jsx)("span",{"aria-hidden":"true",children:a}):null,(0,r.jsx)("span",{children:n})]});let{bar:s,text:o}=l>=80?{bar:"bg-pink-400",text:"text-pink-300"}:l>=60?{bar:"bg-amber-400",text:"text-amber-300"}:{bar:"bg-emerald-500",text:"text-emerald-300"};return(0,r.jsxs)("span",{"data-elanous-hud-key":t,"data-elanous-hud-gauge":"true","data-elanous-hud-percent":String(l),className:"inline-flex items-center gap-1.5 font-mono text-[11px]",children:[a?(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:a}):null,(0,r.jsx)("span",{role:"progressbar","aria-valuenow":l,"aria-valuemin":0,"aria-valuemax":100,"aria-label":"".concat(t," ").concat(l,"%"),className:"relative h-2 w-20 overflow-hidden rounded bg-muted/30",children:(0,r.jsx)("span",{"aria-hidden":"true",style:{width:"".concat(l,"%")},className:(0,J.cn)("block h-full",s)})}),(0,r.jsx)("span",{className:(0,J.cn)("tabular-nums",o),children:n})]})}let Q=new Set(["variant","workspace","model","token-gauge","ctx","agent-activity","agents"]),G=new Set(["token-gauge","ctx"]),K={normal:"text-foreground",warn:"text-amber-300",danger:"text-pink-300",success:"text-emerald-300",info:"text-sky-300",muted:"text-muted-foreground"};function B(e){var t,n;let{segment:a}=e;if(G.has(a.key))return(0,r.jsx)($,{segmentKey:a.key,value:a.value,...void 0!==a.glyph?{glyph:a.glyph}:{}});let l=a.tone?K[a.tone]:K.normal;return(0,r.jsxs)("span",{"data-elanous-hud-key":a.key,"data-elanous-hud-tone":null!=(t=a.tone)?t:"normal","data-elanous-hud-priority":String(null!=(n=a.priority)?n:50),className:(0,J.cn)("inline-flex items-center gap-1 font-mono text-[11px]",l),children:[a.glyph?(0,r.jsx)("span",{"aria-hidden":"true",children:a.glyph}):null,(0,r.jsx)("span",{children:a.value})]})}function H(e){let{segments:t,row:n,className:a}=e;return 0===t.length?null:(0,r.jsx)("div",{"data-elanous-hud-row":n,className:(0,J.cn)("flex flex-wrap items-center gap-x-3 gap-y-1",a),children:t.map((e,t)=>(0,r.jsxs)("span",{className:"flex items-center gap-x-3",children:[t>0?(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\xb7"}):null,(0,r.jsx)(B,{segment:e})]},e.key))})}function W(e){let{segments:t}=e;if(0===t.length)return null;let{top:n,bottom:a}=function(e){let t=[],n=[];for(let r of e)Q.has(r.key)?t.push(r):n.push(r);return{top:t,bottom:n}}(t);return(0,r.jsxs)("div",{"data-elanous-hud":"strip",role:"status","aria-label":"HUD status",className:"flex flex-col gap-0.5 border-b border-border/40 bg-muted/10 px-3 py-1.5",children:[(0,r.jsx)(H,{segments:n,row:"top"}),(0,r.jsx)(H,{segments:a,row:"bottom",className:"hidden sm:flex"})]})}let Z=[];function V(){return Z}function X(){let e=(0,a.useSyncExternalStore)(z.er,z.Wl,V);return(0,r.jsx)(W,{segments:e})}function ee(e,t){if("string"!=typeof e)return t;let n=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/.exec(e);if(!n)return t;let[,r,a,l,s,o,i,c,d]=n,u=Number(r),m=Number(a),h=Number(l),p=[31,u%4==0&&(u%100!=0||u%400==0)?29:28,31,30,31,30,31,31,30,31,30,31][m-1];if(h<1||void 0===p||h>p||Number(s)>23||Number(o)>59||Number(i)>59||void 0!==c&&(Number(c)>23||Number(d)>59))return t;let f=Date.parse(e);return Number.isFinite(f)?f:t}var et=n(5997),en=n(65194),er=n(67903),ea=n(36898),el=n(56360),es=n(76573),eo=n(75342),ei=n(14222);let ec={idle:"음성 대기",connecting:"데몬 연결 중…",listening:"듣는 중",processing:"생각 중…",speaking:"말하는 중",error:"음성 오류"},ed={idle:"마이크를 켜서 대화를 시작하세요.",connecting:"잠시만 기다려주세요.",listening:"문장이 끝나면 자동으로 전송됩니다.",processing:"서버가 응답을 생성하는 중입니다.",speaking:"음성 응답을 재생하는 중입니다.",error:"아래 메시지를 확인하고 다시 시도하세요."},eu={idle:"bg-slate-400",connecting:"bg-amber-500",listening:"bg-emerald-500",processing:"bg-sky-500",speaking:"bg-fuchsia-500",error:"bg-rose-600"};function em(e){let{active:t,phase:n,errorMsg:a,onToggle:l,ttsSupported:i=!1,ttsMuted:c=!1,onTtsToggle:d,onInterrupt:u}=e,m="speaking"===n&&"function"==typeof u;return(0,r.jsxs)("div",{"data-elanous-voice-overlay":!0,"aria-hidden":!t,className:(0,J.cn)("pointer-events-none absolute inset-0 z-10 flex items-center justify-center transition-opacity duration-300",t?"pointer-events-auto opacity-100":"opacity-0"),children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-background/60 backdrop-blur-md"}),(0,r.jsxs)("div",{className:"relative mx-4 flex w-full max-w-sm flex-col items-center gap-5 rounded-xl border border-border bg-card px-6 py-7 text-center shadow-xl",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,r.jsx)("span",{className:(0,J.cn)("h-2.5 w-2.5 rounded-full",eu[n],("listening"===n||"speaking"===n||"connecting"===n)&&"animate-pulse"),"aria-hidden":!0}),(0,r.jsx)("span",{className:"font-medium tracking-wide",children:ec[n]})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:ed[n]}),(0,r.jsx)("button",{type:"button",onClick:m?u:l,"data-elanous-action":m?"voice-overlay-interrupt":"voice-overlay-toggle",className:(0,J.cn)("inline-flex h-16 w-16 items-center justify-center rounded-full text-white transition-colors",m?"bg-amber-500 hover:bg-amber-400 animate-pulse":"connecting"===n||"processing"===n?"bg-sky-500 hover:bg-sky-400":"error"===n?"bg-rose-600 hover:bg-rose-500":"bg-rose-500 hover:bg-rose-400"),"aria-label":m?"끼어들기":"마이크 끄기",children:m?(0,r.jsx)(el.A,{className:"h-7 w-7"}):"connecting"===n||"processing"===n?(0,r.jsx)(es.A,{className:"h-7 w-7 animate-spin"}):"error"===n?(0,r.jsx)(eo.A,{className:"h-7 w-7"}):(0,r.jsx)(s.A,{className:"h-7 w-7"})}),a&&(0,r.jsx)("p",{className:"max-w-xs text-xs text-rose-500",children:a}),(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[i&&d&&(0,r.jsxs)("button",{type:"button",onClick:d,"data-elanous-action":"voice-overlay-tts-toggle",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground","aria-label":c?"음성 응답 켜기":"음성 응답 끄기","aria-pressed":!c,children:[c?(0,r.jsx)(ei.A,{className:"h-3.5 w-3.5"}):(0,r.jsx)(p.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:c?"음성 응답 OFF":"음성 응답 ON"})]}),(0,r.jsxs)("button",{type:"button",onClick:l,className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground","aria-label":"음성 닫고 텍스트로 돌아가기",children:[(0,r.jsx)(o.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:"음성 끄기"})]})]})]})]})}function eh(e){let{open:t,onClose:n,lines:l}=e,[s,o]=(0,a.useState)(""),i=(0,a.useMemo)(()=>{if(!s.trim())return null;try{return RegExp(s,"i")}catch(e){return null}},[s]),c=(0,a.useMemo)(()=>s.trim().toLowerCase(),[s]),d=(0,a.useMemo)(()=>{let e=l.length>200?l.slice(l.length-200):l;return i?e.filter(e=>i.test(e.category)||i.test(e.event)):c?e.filter(e=>e.category.toLowerCase().includes(c)||e.event.toLowerCase().includes(c)):e},[l,i,c]);return(0,r.jsx)("div",{"data-elanous-debug-tap-drawer":t?"open":"closed",className:(0,J.cn)("fixed bottom-0 left-0 right-0 z-50 transition-transform duration-200 ease-out","pointer-events-none",t?"translate-y-0":"translate-y-full"),role:"region","aria-label":"Debug Tap Drawer","aria-hidden":!t,children:(0,r.jsxs)("div",{className:(0,J.cn)("pointer-events-auto mx-auto flex max-h-[60vh] w-full max-w-[1100px] flex-col","rounded-t-md border border-b-0 border-border bg-card shadow-xl"),children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border/60 px-3 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Debug Tap"}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground/70","data-elanous-debug-tap-count":d.length,"data-elanous-debug-tap-total":l.length,children:[d.length,"/",l.length]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"text",placeholder:"regex filter…",value:s,onChange:e=>o(e.target.value),spellCheck:!1,autoComplete:"off",className:(0,J.cn)("w-40 rounded border border-border bg-background px-2 py-1 text-[11px] font-mono","focus:outline-none focus:ring-1 focus:ring-primary"),"data-elanous-debug-tap-filter":"","aria-label":"Filter debug lines"}),(0,r.jsx)("button",{type:"button",onClick:n,className:"rounded px-2 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Close debug drawer","data-elanous-debug-tap-close":"",children:"✕"})]})]}),(0,r.jsx)("ul",{className:"flex-1 overflow-y-auto px-3 py-2 text-[11px] font-mono","data-elanous-debug-tap-list":"",children:0===d.length?(0,r.jsx)("li",{className:"italic text-muted-foreground/60",children:0===l.length?"(no debug lines yet)":"(no matches for filter)"}):d.map((e,t)=>(0,r.jsx)(ep,{line:e},"".concat(e.loggedAt,"-").concat(e.seq,"-").concat(t)))})]})})}function ep(e){let{line:t}=e,n=new Date(t.loggedAt).toISOString().slice(11,23);return(0,r.jsxs)("li",{"data-elanous-debug-tap-line":"","data-elanous-category":t.category,"data-elanous-event":t.event,className:"py-0.5",children:[(0,r.jsxs)("span",{className:"text-muted-foreground/70",children:["[",n,"]"]})," ",(0,r.jsxs)("span",{className:"text-amber-400",children:["[",t.category,"]"]})," ",(0,r.jsx)("span",{className:"text-foreground",children:t.event}),void 0!==t.data&&(0,r.jsxs)("details",{className:"ml-4 text-muted-foreground",children:[(0,r.jsx)("summary",{className:"cursor-pointer select-none text-[10px]",children:"data"}),(0,r.jsx)("pre",{className:"m-0 mt-1 whitespace-pre-wrap break-all text-[10px] text-muted-foreground/80",children:function(e){try{return JSON.stringify(e,null,2)}catch(t){return String(e)}}(t.data)})]})]})}var ef=n(60516),eg=n(56974),ex=n(87969),eb=n(25042),ev=n(9734),ey=n(30158),ew=n(2021);let ej="Other";function ek(e){let{request:t,onSubmit:n,onCancel:a,onChatAboutThis:l}=e;return(0,r.jsx)(eb.lG,{open:null!==t,onOpenChange:e=>{e||a()},children:(0,r.jsx)(eb.Cf,{className:"max-w-2xl",children:t?(0,r.jsx)(eN,{request:t,onSubmit:n,onCancel:a,onChatAboutThis:l}):null})})}function eN(e){let{request:t,onSubmit:n,onCancel:l,onChatAboutThis:s}=e,[o,i]=(0,a.useState)(()=>Object.fromEntries(t.questions.map(e=>[e.id,new Set]))),[c,d]=(0,a.useState)({}),[u,m]=(0,a.useState)({}),h=1===t.questions.length?t.questions[0].header:"Pick options",p=(0,a.useMemo)(()=>{for(let n of t.questions){var e;let t=null!=(e=o[n.id])?e:new Set,r=eC(n,o,u);if(0===t.size&&!r)return!1}return!0},[t.questions,o,u]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(eb.c7,{children:[(0,r.jsx)(eb.L3,{children:h}),1===t.questions.length?(0,r.jsx)(eb.rr,{children:t.questions[0].question}):(0,r.jsxs)(eb.rr,{children:[t.questions.length," questions"]})]}),(0,r.jsx)(ew.F,{className:"max-h-[60vh] pr-2",children:(0,r.jsx)("div",{className:"flex flex-col gap-6 py-2",children:t.questions.map(e=>{var t;return(0,r.jsx)(eS,{question:e,isSelected:t=>{var n,r,a;return n=e.id,null!=(a=null==(r=o[n])?void 0:r.has(t))&&a},onToggle:t=>{i(n=>{var r;let a={...n},l=new Set(null!=(r=a[e.id])?r:[]);return e.multiSelect?l.has(t)?l.delete(t):l.add(t):(l.clear(),l.add(t),m(t=>({...t,[e.id]:!1}))),a[e.id]=l,a})},otherActive:eC(e,o,u),onToggleOther:()=>{e.multiSelect?m(t=>{var n;return{...t,[e.id]:!(null!=(n=t[e.id])&&n)}}):i(t=>{let n={...t};return n[e.id]=new Set([ej]),n})},otherText:null!=(t=c[e.id])?t:"",onOtherText:t=>d(n=>({...n,[e.id]:t}))},e.id)})})}),(0,r.jsxs)(eb.Es,{className:"flex-wrap gap-2 sm:justify-between",children:[(0,r.jsx)(ev.$,{variant:"ghost",onClick:s,"aria-label":"Chat about this",children:"\uD83D\uDCAC Chat about this"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(ev.$,{variant:"outline",onClick:l,children:"Cancel"}),(0,r.jsx)(ev.$,{onClick:function(){let e={},r={};for(let n of t.questions){var a,l;let t=Array.from(null!=(a=o[n.id])?a:[]);if(eC(n,o,u)&&!t.includes(ej)&&t.push(ej),0!==t.length&&(n.multiSelect?e[n.id]=t:e[n.id]=t[0],t.includes(ej))){let e=(null!=(l=c[n.id])?l:"").trim();e.length>0&&(r[n.id]=e)}}let s={answers:e};Object.keys(r).length>0&&(s.otherText=r),n(s)},disabled:!p,children:"Submit"})]})]})]})}function eS(e){var t,n;let{question:a}=e;return(0,r.jsxs)("section",{className:"flex flex-col gap-2",children:[""!==e.question.id?(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"rounded-full bg-primary/15 px-2 py-0.5 text-xs font-medium text-primary",children:a.header}),a.multiSelect?(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"multi-select"}):null]}):null,(0,r.jsxs)("div",{className:"flex flex-col gap-1.5",children:[a.options.map(t=>{var n;return(0,r.jsx)(eI,{multi:null!=(n=a.multiSelect)&&n,option:t,selected:e.isSelected(t.label),onToggle:()=>e.onToggle(t.label)},t.label)}),null==(t=a.includeOther)||t?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eI,{multi:null!=(n=a.multiSelect)&&n,option:{label:"Other",description:"Type your own response"},selected:e.otherActive,onToggle:e.onToggleOther}),e.otherActive?(0,r.jsx)(ey.p,{value:e.otherText,onChange:t=>e.onOtherText(t.target.value),placeholder:"Type your own response","aria-label":"Other response",className:"ml-8"}):null]}):null]})]})}function eI(e){let{multi:t,option:n,selected:a,onToggle:l}=e;return(0,r.jsxs)("button",{type:"button",role:t?"checkbox":"radio","aria-checked":a,onClick:l,className:"\n flex items-start gap-3 rounded-md border p-3 text-left\n transition-colors\n ".concat(a?"border-primary bg-primary/10":"border-border hover:bg-muted/40","\n "),children:[(0,r.jsx)("span",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center ".concat(t?"rounded":"rounded-full"," border ").concat(a?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/40"),"aria-hidden":"true",children:a?t?"✓":"●":null}),(0,r.jsxs)("span",{className:"flex flex-col gap-0.5",children:[(0,r.jsx)("span",{className:"font-medium",children:n.label}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:n.description}),n.preview?(0,r.jsx)("span",{className:"mt-1 rounded bg-muted/40 px-2 py-1 text-xs font-mono text-muted-foreground",children:n.preview}):null]})]})}function eC(e,t,n){var r,a,l;return e.multiSelect?null!=(a=n[e.id])&&a:null!=(l=null==(r=t[e.id])?void 0:r.has(ej))&&l}function eA(e){if(void 0===e)return"";if("string"==typeof e)return e;try{var t;return null!=(t=JSON.stringify(e,null,2))?t:""}catch(e){return""}}function eE(e){let{request:t,receivedAt:n,onChoose:l,onCancel:s}=e,[o,i]=(0,a.useState)(()=>Date.now());(0,a.useEffect)(()=>{if(!t)return;i(Date.now());let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[t]);let c=t?eA(t.toolCall.rawInput):"",d=t?function(e){if(e&&"object"==typeof e&&!Array.isArray(e)){for(let t of["file_path","filePath","path","command","cmd"])if("string"==typeof e[t])return e[t].slice(0,80)}return eA(e).replace(/\s+/g," ").slice(0,80)}(t.toolCall.rawInput):"",u=Math.max(0,Math.ceil((n+6e4-o)/1e3));return(0,r.jsx)(eb.lG,{open:null!==t,onOpenChange:e=>{!e&&t&&s(t)},children:(0,r.jsx)(eb.Cf,{className:"max-w-lg",children:t&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(eb.c7,{children:[(0,r.jsx)(eb.L3,{children:"이 작업을 실행할까요?"}),(0,r.jsxs)(eb.rr,{children:["도구: ",t.toolCall.title]})]}),d&&(0,r.jsx)("p",{className:"truncate font-mono text-sm",title:d,children:d}),c&&(0,r.jsxs)("details",{className:"text-sm",children:[(0,r.jsx)("summary",{className:"cursor-pointer",children:"자세히"}),(0,r.jsx)("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-all rounded bg-muted p-2",children:c})]}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground","aria-live":"off",children:["남은 시간: ",u,"초"]}),(0,r.jsxs)(eb.Es,{className:"flex-wrap gap-2",children:[(0,r.jsx)(ev.$,{onClick:()=>l(t,"allow_once"),children:"이번만 허용"}),(0,r.jsx)(ev.$,{variant:"outline",onClick:()=>l(t,"allow_always"),children:"이 도구는 항상 허용"}),(0,r.jsx)(ev.$,{variant:"outline",onClick:()=>l(t,"reject_once"),children:"거절"})]})]})})})}let eR={outcome:{outcome:"cancelled"}},eD=["allow_once","allow_always","reject_once","reject_always"],eT="unverified";var eq=n(60750),eL=n(67327);function eU(e,t){var n;return"error"!==t.kind?null:null!=(n=function(e){if(!e||"object"!=typeof e)return null;let{error:t,message:n,holder:r}=e;return"turn_busy"!==t?null:{message:"string"==typeof n?n:"This session is currently receiving input. Please try again when that turn finishes.",holder:"string"==typeof r&&r.trim()?r:null}}(t.payload))?n:e}var eO=n(61897);function eM(e){return"string"==typeof e.mediaType&&e.mediaType.toLowerCase().startsWith("image/")}async function eF(e,t){let n=e.downloadUrl.startsWith("http")?e.downloadUrl:"".concat(t.baseUrl.replace(/\/$/,"")).concat(e.downloadUrl),r={};t.token&&(r.authorization="Bearer ".concat(t.token));let a=await fetch(n,{headers:r});if(!a.ok)throw Error("fetch attachment ".concat(e.id," failed: ").concat(a.status));return function(e){let t=new Uint8Array(e),n="";for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)}(await a.arrayBuffer())}async function eP(e,t,n){if(0===t.length)return null;let r=[];for(let a of(e.length>0&&r.push({type:"text",text:e}),t))if(eM(a))try{let e=await eF(a,n);r.push({type:"image",mimeType:a.mediaType,data:e})}catch(t){let e=t instanceof Error?t.message:String(t);r.push({type:"text",text:"[image fetch failed: ".concat(a.filename," — ").concat(e,"]")})}else r.push({type:"resource_link",uri:a.path?"file://".concat(a.path):a.downloadUrl,mimeType:a.mediaType,name:a.filename});return r}let eY="elanous.pwa.pendingCardFollowups";function e_(e,t){try{var n;let r=JSON.parse(null!=(n=e.getItem(eY))?n:"[]");if(!Array.isArray(r))return[];return r.filter(e=>!!e&&"object"==typeof e&&"string"==typeof e.sessionId&&e.sessionId.length>0&&"string"==typeof e.id&&e.id.length>0&&"number"==typeof e.startedAt&&Number.isFinite(e.startedAt)&&e.startedAt<=t&&t-e.startedAt<9e5)}catch(e){return[]}}function eJ(e,t){try{t.length?e.setItem(eY,JSON.stringify(t)):e.removeItem(eY)}catch(e){}}function ez(){try{return window.localStorage}catch(e){return}}async function e$(e,t,n,r){let a=await e.fetchResponse("/v1/card-followup",{...r?{signal:r}:{},method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({attachmentId:t,...void 0===n?{}:{context:n}})});if(!a.ok)throw Error("card followup start failed: ".concat(a.status));let l=await a.json();if("string"!=typeof l.id||!l.id)throw Error("card followup start returned no id");return l.id}async function eQ(e,t){let n,{intervalMs:r=3e3,signal:a,onStatus:l,startedAt:s}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=void 0===s?6e5:Math.max(0,s+9e5-Date.now()),i=Date.now()+o,c={status:"failed"},d=new AbortController,u=a?AbortSignal.any([a,d.signal]):d.signal,m=!1,h=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Promise((n,r)=>{let l;if(u.aborted){var s;r(null!=(s=null==a?void 0:a.reason)?s:Error("aborted"));return}let o="undefined"==typeof document?void 0:document,i=()=>{clearTimeout(l),null==o||o.removeEventListener("visibilitychange",c),u.removeEventListener("abort",d)},c=()=>{(null==o?void 0:o.visibilityState)!=="hidden"&&(i(),n())},d=()=>{var e;i(),r(null!=(e=null==a?void 0:a.reason)?e:Error("aborted"))};l=setTimeout(()=>{i(),n()},e),t&&(null==o||o.addEventListener("visibilitychange",c)),u.addEventListener("abort",d,{once:!0})})},p=async()=>{for(;Date.now()<i;){var n,s;if(null==a?void 0:a.aborted)throw null!=(n=a.reason)?n:Error("aborted");if("undefined"!=typeof document&&"hidden"===document.visibilityState){await h(i-Date.now(),!0);continue}let o=await e.fetchResponse("/v1/card-followup/".concat(encodeURIComponent(t)),{signal:u});if(!o.ok)throw Error("card followup poll failed: ".concat(o.status));let d=await o.json();if(null==a?void 0:a.aborted)throw null!=(s=a.reason)?s:Error("aborted");if(m)return c;if(null==l||l(d.status),"done"===d.status||"not-card"===d.status||"failed"===d.status)return d;await h(Math.min(Math.max(0,r),Math.max(0,i-Date.now())))}return null==l||l("failed"),c};try{return await Promise.race([p(),new Promise(e=>{n=setTimeout(()=>{m=!0,d.abort(),null==l||l("failed"),e(c)},o)})])}finally{clearTimeout(n)}}function eG(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{compact:n}=(0,c.K)(),[u,m]=(0,a.useState)(!1),p=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(!u)return;let e=e=>{p.current&&p.current.contains(e.target)||m(!1)},t=e=>{"Escape"===e.key&&m(!1)};return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[u]),(0,a.useEffect)(()=>{n||m(!1)},[n]);let{client:x,config:b,sessionId:y,setSessionId:R}=(0,d.Q)(),[D,T]=(0,a.useState)([]),[q,L]=(0,a.useState)(),[U,O]=(0,a.useState)(!1),[M,F]=(0,a.useState)([]),P=(0,a.useRef)([]),Y=(0,a.useRef)(y),$=(0,a.useRef)(y),Q=(0,a.useRef)(null),G=(0,a.useRef)(0),K=(0,a.useRef)(0),B=(0,a.useRef)(!1),[H,W]=(0,a.useState)(null),Z=Y.current!==y&&Q.current!==y?[]:M;(0,a.useLayoutEffect)(()=>{$.current=y,Y.current!==y&&(Q.current!==y&&(G.current++,P.current=[],F([]),T([]),eu.current&&O(!1)),Y.current=y,Q.current=null)},[y]);let V=e=>{P.current=e,F(e)},[el,es]=(0,a.useState)(null),[eo,ei]=(0,a.useState)(null),[ec,ed]=(0,a.useState)([]),eu=(0,a.useRef)(null),ep=(0,a.useRef)(null);(0,a.useEffect)(()=>()=>{var e;ep.current!==$.current&&(null==(e=eu.current)||e.abort())},[y]),(0,a.useEffect)(()=>()=>{var e;null==(e=eu.current)||e.abort()},[]);let[eb,ev]=(0,a.useState)({visible:!1,depth:0});(0,a.useEffect)(()=>{let e=()=>ev(e=>A(e,"end",!1));return window.addEventListener("dragend",e),()=>window.removeEventListener("dragend",e)},[]);let ey=(0,a.useRef)(!1),ew=(0,a.useRef)(null),ej=(0,a.useRef)(null),[eN,eS]=(0,a.useState)(null),eI=(0,a.useMemo)(()=>{try{let e=new URLSearchParams(window.location.search);return"on"===e.get("debug-tap")}catch(e){return!1}},[]),[eC,eA]=(0,a.useState)(eI),eF=(0,a.useMemo)(()=>{let e=[];for(let t of D)if(Array.isArray(t.blocks)){for(let n of t.blocks)if("debug_session"===n.kind)for(let t of n.lines)e.push({seq:t.seq,category:t.category,event:t.event,...void 0!==t.data?{data:t.data}:{},loggedAt:t.loggedAt})}return e},[D]),eY=(0,a.useRef)(async()=>{}),eG=(0,a.useRef)(!1);eG.current=U;let eK=(0,a.useRef)(async()=>{}),eB=x.voiceWsUrl(),eH=(0,a.useCallback)(e=>{let t=e.trim();if(t){if(eG.current)return void(0,f.cY)("chat.voice.skip-pending",{len:t.length});(0,f.cY)("chat.voice.auto-send",{len:t.length}),eY.current(t)}},[]),eW=(0,eg.sS)({wsUrl:eB,...b.token?{token:b.token}:{},onTranscript:eH}),eZ=!!b.baseUrl;eK.current=()=>eW.toggle();let[eV,eX]=(0,a.useState)(!1),e0=(0,ex.$)({enabled:eW.active&&!eV,language:"ko-KR"}),e1=(0,a.useCallback)(()=>{null==eo||eo.abort(),(0,f.cY)("webterm.chat.stop",{had:!!eo})},[eo]);(0,a.useEffect)(()=>{if(!eo)return;let e=e=>{var t;if("Escape"!==e.key)return;let n=e.target,r=null==n||null==(t=n.tagName)?void 0:t.toLowerCase();"input"===r||"textarea"===r||null!=n&&n.isContentEditable||(e.preventDefault(),e1())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[eo,e1]),(0,a.useEffect)(()=>{let e=e=>{"m"===e.key.toLowerCase()&&e.shiftKey&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),(0,f.cY)("chat.voice.shortcut.toggle"),eK.current())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);let e2=(0,a.useCallback)(e=>{ed(t=>[...t,...e]),(0,f.cY)("webterm.chat.attach.queue",{added:e.length,filenames:e.map(e=>e.filename)})},[]),e3=async e=>{let{files:t,tooLarge:n,tooMany:r}=e;if(n&&eL.oR.error("".concat(n," files exceed the 20 MB attachment limit")),r&&eL.oR.error("".concat(r," files exceed the 10-file attachment limit")),0===t.length)return;if(!b.baseUrl)return void eL.oR.error("Daemon URL 미설정 — Settings 에서 입력");let a=await (0,eO.K)(t,{baseUrl:b.baseUrl,...b.token?{token:b.token}:{}}),l=a.filter(e=>e.ok).map(e=>e.meta),s=a.filter(e=>!e.ok);l.length&&(e2(l),eL.oR.success(1===l.length?"\uD83D\uDCCE ".concat(l[0].filename):"\uD83D\uDCCE ".concat(l.length," files attached"))),s.length&&eL.oR.error(1===s.length?"업로드 실패: ".concat(s[0].reason.slice(0,80)):"".concat(s.length," 파일 업로드 실패"))};(0,a.useEffect)(()=>{try{let e=window.sessionStorage.getItem("elanous.pwa.shareAttachments");if(!e)return;window.sessionStorage.removeItem("elanous.pwa.shareAttachments");let t=JSON.parse(e);if(!Array.isArray(t)||0===t.length)return;ed(e=>[...e,...t]);let n=1===t.length?"1 file shared from another app":"".concat(t.length," files shared from another app");eL.oR.success(n),(0,f.cY)("pwa.chat.share-attachments.consume",{count:t.length})}catch(e){(0,f.cY)("pwa.chat.share-attachments.parse-failed",{reason:e instanceof Error?e.message:String(e)})}},[]),(0,a.useEffect)(()=>{if(!y)return;let e=!0;return(async()=>{try{let t=await x.fetchJson("/v1/sessions/store/".concat(encodeURIComponent(y),"?ifExists=1"));if(!e||!(null==t?void 0:t.messages)||0===t.messages.length)return;T(e=>e.some(e=>!e.id.startsWith("m-card-resume-"))?e:[...function(e,t){let n,r,a=[],l=[];for(let o of e){var s;if("tool"===o.role){for(let e of(0===l.length&&(r=o.ts),function(e,t){let n,r=function(e,t){var n,r;let a,l=String(null!=(n=e.toolName)?n:"");try{a=JSON.parse(String(null!=(r=e.toolResult)?r:""))}catch(e){a=void 0}let s=a&&"object"==typeof a&&!Array.isArray(a)?a:void 0,o=null==s?void 0:s._meta,i=o&&"object"==typeof o&&!Array.isArray(o)?o.ui:void 0,c=i&&"object"==typeof i&&!Array.isArray(i)?i.resourceUri:void 0,d=null==s?void 0:s["ui/resourceUri"],u="string"==typeof c?c:"string"==typeof d?d:void 0;return void 0!==u&&""!==u.trim()?{kind:"mcp_app",toolId:t,toolName:l,screenUrl:u,...void 0!==a?{toolResult:a}:{}}:{kind:"tool_use",id:t,name:l,status:"done",...void 0!==s&&void 0!==e.toolArgs?{args:{raw:String(e.toolArgs)}}:{}}}(e,t);try{var a;n=JSON.parse(String(null!=(a=e.toolResult)?a:""))}catch(e){n=void 0}let l=(0,z.uS)(n).map(e=>({kind:"image",...e})),s=[];return(0,z.ki)(s,null!=n?n:e.toolResult),[...l,r,...s]}(o,"restore-tool-".concat(l.length,"-").concat(a.length))))"image"===e.kind&&l.some(t=>"image"===t.kind&&t.src===e.src)||l.push(e);continue}if("user"!==o.role&&"assistant"!==o.role)continue;let e=String(null!=(s=o.content)?s:""),i=String(null!=e?e:"").split("\n").filter(e=>!/^\[tool_(use|result)\]$/.test(e.trim())).join("\n"),c="assistant"===o.role?"assistant":"user";if(""===i.trim()){l.length>0&&"assistant"===c&&(a.push({id:"restore-".concat(a.length),role:c,text:"",blocks:l,timestamp:ee(r,t+a.length)}),l=[],r=void 0);continue}let d=i!==e,u=void 0!==n&&n.role===c&&n.text===i&&(d||n.wasStripped)&&0===l.length;if(n={role:c,text:i,wasStripped:d},u)continue;let m=l.length>0&&"assistant"===c?[...l,{kind:"text",text:i}]:void 0,h=ee(void 0!==m?r:o.ts,t+a.length);void 0!==m&&(l=[],r=void 0),a.push({id:"restore-".concat(a.length),role:c,text:i,...void 0!==m?{blocks:m}:{},timestamp:h})}return l.length>0&&a.push({id:"restore-".concat(a.length),role:"assistant",text:"",blocks:l,timestamp:ee(r,t+a.length)}),a}(t.messages,Date.now()),...e])}catch(e){}})(),()=>{e=!1}},[y,x]);let e5=(0,a.useCallback)(e=>{ed(t=>t.filter(t=>t.id!==e))},[]),e4={client:x,sessionId:y,provider:b.provider,setSessionId:R,daemon:{baseUrl:b.baseUrl,...b.token?{token:b.token}:{}},messages:D},e6=e=>{T(t=>[...t,e])},e8=async(e,t,n,r,a)=>{var l;let s=await eQ(x,e,{signal:r.signal,...void 0===a?{}:{startedAt:a},onStatus:e=>(0,f.cY)("pwa.chat.card-followup",{phase:"poll",status:e})});if(r.signal.aborted||$.current!==t)return"terminal";let o=ez();return(o&&function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Date.now();eJ(e,e_(e,r).filter(e=>e.sessionId!==t||e.id!==n))}(o,t,e),"not-card"===s.status)?(T(e=>e.filter(e=>e.id!==n)),(0,f.cY)("pwa.chat.card-followup",{phase:"fallback",status:s.status}),"not-card"):("done"===s.status&&(null==(l=s.replies)?void 0:l.length)===3&&s.replies.every(e=>"string"==typeof e)?(T(e=>[...e.filter(e=>e.id!==n),...s.replies.map((e,t)=>({id:"".concat(n,"-").concat(t),role:"assistant",text:e,timestamp:Date.now(),meta:{provider:b.provider}}))]),(0,f.cY)("pwa.chat.card-followup",{phase:"complete",status:"done"})):(T(e=>e.map(e=>e.id===n?{...e,text:"명함 정리에 실패했습니다 — 다시 보내 주세요"}:e)),(0,f.cY)("pwa.chat.card-followup",{phase:"complete",status:"failed"})),"terminal")};(0,a.useEffect)(()=>{if(!y)return;let e=ez();if(!e)return;let t=(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Date.now(),r=e_(e,n);return eJ(e,r),r.filter(e=>e.sessionId===t)})(e,y).map(e=>{let{id:t,startedAt:n}=e,r=new AbortController,a="m-card-resume-".concat(t);return T(e=>e.some(e=>e.id===a)?e:[...e,{id:a,role:"assistant",text:"명함 읽는 중… 조사 중…",timestamp:n,meta:{provider:b.provider}}]),e8(t,y,a,r,n).catch(()=>{r.signal.aborted||$.current!==y||T(e=>e.map(e=>e.id===a?{...e,text:"명함 정리에 실패했습니다 — 다시 보내 주세요"}:e))}),r});return()=>{t.forEach(e=>e.abort())}},[x,y]);let e7=async function(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];es(e=>eU(e,{kind:"turn-begin"})),(0,f.cY)("webterm.chat.input",{len:e.length,attachCount:ec.length});let r=n?[]:ec;n||ed([]);let a=n?{ok:!1}:function(e,t){if(1!==t.length||!t[0]||!eM(t[0])||!t[0].id)return{ok:!1};let n=e.trim();if(!n)return{ok:!0,attachmentId:t[0].id};let r=n.replace(/메일\s*초안/g,"메일초안").split(/[\s,]+/).filter(Boolean);return!r.length||r.some(e=>!/^(?:명함|전략|메일초안|crm)$/i.test(e))?{ok:!1}:{ok:!0,attachmentId:t[0].id,context:n}}(e,r),l=!1;if(a.ok){let n=$.current;if(!n){var s;Q.current=n=(0,et.f6)(),$.current=n,null==(s=t.onSessionAdopt)||s.call(t,n),R(n)}let o=new AbortController;eu.current=o,ep.current=n,l=!0,e.length>0&&e6((0,z.tw)(e)),e6((0,z.$Q)("\uD83D\uDCCE attached: ".concat(r.map(e=>e.filename).join(", "))));let i="m-card-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,6));e6({id:i,role:"assistant",text:"명함 읽는 중… 조사 중…",timestamp:Date.now(),meta:{provider:b.provider}}),O(!0),(0,f.cY)("pwa.chat.card-followup",{phase:"start",status:"judging"});try{let e=await e$(x,a.attachmentId,a.context,o.signal);if(o.signal.aborted||$.current!==n)return;let t=ez(),r=Date.now();t&&function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Date.now(),r=e_(e,n).filter(e=>e.sessionId!==t.sessionId||e.id!==t.id);if(!t.sessionId||!t.id||!Number.isFinite(t.startedAt)||t.startedAt>n||n-t.startedAt>=9e5)return eJ(e,r);eJ(e,[...r,t])}(t,{sessionId:n,id:e,startedAt:r});let l=await e8(e,n,i,o,r);if("terminal"===l||o.signal.aborted||$.current!==n)return}catch(e){if(o.signal.aborted||$.current!==n)return;T(e=>e.map(e=>e.id===i?{...e,text:"명함 정리에 실패했습니다 — 다시 보내 주세요"}:e)),(0,f.cY)("pwa.chat.card-followup",{phase:"complete",status:"failed"});return}finally{eu.current===o&&(eu.current=null),o.signal.aborted||$.current!==n||(O(!1),es(e=>eU(e,{kind:"turn-end"})))}}let o=r.filter(eM),i=r.filter(e=>!eM(e)),c=function(e){if(!e)return!0;let t=e.toLowerCase();return!!("auto"===t||t.startsWith("anthropic")||"anthropic"===t||t.startsWith("codex")||"openai-codex"===t||t.startsWith("openai")||"openai"===t||t.startsWith("gemini")||"gemini"===t||t.startsWith("grok")||"grok"===t||t.startsWith("local"))}(b.provider),d=o.length>0&&c;o.length>0&&!c&&eL.oR.warning("이 모델은 이미지 입력을 지원하지 않습니다 — ".concat(o.length,"개 이미지가 무시됩니다. (vision 모델로 전환 후 재첨부)"));let u=i.map(e=>e.path?"[attached] ".concat(e.path):"").filter(e=>e.length>0),m=u.length>0?"".concat(u.join("\n"),"\n\n").concat(e).trimEnd():e,h=null;if(d&&b.baseUrl)try{h=await eP(m,o,{baseUrl:b.baseUrl,token:b.token})}catch(t){let e=t instanceof Error?t.message:String(t);(0,f.cY)("webterm.chat.attach.contentblock.error",{msg:e}),eL.oR.error("이미지 첨부 변환 실패 — 텍스트만 전송: ".concat(e)),h=null}!l&&(e.length>0&&e6((0,z.tw)(e)),r.length>0&&e6((0,z.$Q)("\uD83D\uDCCE attached: ".concat(r.map(e=>e.filename).join(", ")))));let p=e?await (0,z.yN)(e,e4):null;if(p){if("__CLEAR__"===p.text)T([]);else{let e=(0,z.$Q)(p.text);p.harnessAsk&&(e.blocks=[{kind:"harness_ask",acceptanceId:p.harnessAsk.acceptanceId}]),e6(e)}p.newSessionId&&(G.current++,V([]),Y.current=p.newSessionId,$.current=p.newSessionId,R(p.newSessionId));return}if(!b.baseUrl)return void e6((0,z.$Q)("error: daemon baseUrl not configured. Visit /settings."));O(!0),ey.current=!0;let g="m-stream-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,6));e6({id:g,role:"assistant",text:"",timestamp:Date.now(),meta:{provider:b.provider}});let v=new AbortController;ei(v);let w=0,j=ej.current,k=!!(j&&y&&b.baseUrl),N=null;(0,f.cY)("webterm.chat.runturn.path",{useAcpPath:k,hasAcp:!!j,hasSession:!!y});let S=e=>{T(t=>t.map(t=>t.id===g?{...t,text:e}:t)),e.length>w&&(e0.pushText(e.slice(w)),w=e.length)},I=e=>{T(t=>t.map(t=>t.id===g?{...t,blocks:e}:t))};try{k&&(N=x.connectAcp({sessionId:y}));let{message:e,newSessionId:t}=k?await (0,z.py)(N,m,{...e4,sessionId:await N.ready||y},{signal:v.signal,...h?{userContent:h}:{},onPartial:S,onPartialBlocks:I}):await (0,z.HD)(m,e4,{signal:v.signal,...h?{userContent:h}:{},...eC?{debugTap:!0}:{},onPartial:S,onPartialBlocks:I,onError:e=>es(t=>eU(t,{kind:"error",payload:e}))});es(e=>eU(e,{kind:"turn-end"})),T(t=>t.map(t=>t.id===g?e:t)),t&&t!==y&&$.current===y&&(Q.current=t,$.current=t,R(t)),e0.flush()}catch(n){let e=v.signal.aborted,t=n instanceof Error?n.message:String(n);e0.cancel(),e?(T(e=>e.map(e=>e.id===g?{...e,meta:{...e.meta,stopReason:"aborted"}}:e)),(0,f.cY)("webterm.chat.runturn.stream.abort",{reason:t})):(T(e=>e.filter(e=>e.id!==g)),e6((0,z.$Q)("error: ".concat(t))),eL.oR.error("chat failed: ".concat(t)),(0,f.cY)("webterm.chat.runturn.error",{reason:t,useAcpPath:k}))}finally{null==N||N.close(),O(!1),ei(null),ey.current=!1}},e9=async function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(B.current||!t&&P.current.length>0){var n,r;if(!t&&(ec.length>0||/^[\s]*[:/]/.test(e))){eL.oR.info("답이 끝난 뒤 보내 주세요"),L(t=>{var n;return{text:e,id:(null!=(n=null==t?void 0:t.id)?n:0)+1}});return}let a=(n=P.current,(r={id:++K.current,text:e}).text.trim()?n.length>=5?{queue:[...n],error:"줄이 찼습니다"}:{queue:[...n,{...r,text:r.text.trim()}]}:{queue:[...n]});a.error?(eL.oR.info(a.error),L(t=>{var n;return{text:e,id:(null!=(n=null==t?void 0:t.id)?n:0)+1}})):V(a.queue);return}B.current=!0;let a=G.current,l=$.current;try{await e7(e,t)}finally{B.current=!1,a!==G.current&&(0,f.cY)("webterm.chat.queue.session-changed",{turnSessionId:l,currentSessionId:$.current}),W({generation:G.current,sessionId:$.current})}};(0,a.useEffect)(()=>{var e;if(B.current||0===P.current.length||!H||H.generation!==G.current||H.sessionId!==y)return;let{entry:t,queue:n}={entry:(e=P.current)[0],queue:e.slice(1)};t&&(V(n),eY.current(t.text,!0))},[H]),eY.current=e9,(0,a.useEffect)(()=>{es(e=>eU(e,{kind:"session-change"}))},[y]),(0,a.useEffect)(()=>{if(!y||!b.baseUrl)return;let e=(0,z.lY)(x,y,{isLocalTurnInFlight:()=>ey.current,provider:b.provider,onPlaceholder:e=>{let{sessionId:t}=e;es(e=>eU(e,{kind:"turn-begin"}));let n="m-obs-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,6)),r={id:n,role:"assistant",text:"",timestamp:Date.now(),meta:{provider:b.provider}};return(0,f.cY)("webterm.chat.observer.placeholder",{id:n,turnSessionId:t}),T(e=>[...e,r]),ew.current=n,n},onPartialBlocks:(e,t)=>{T(n=>n.map(n=>n.id===e?{...n,blocks:t}:n))},onFinalize:(e,t)=>{es(e=>eU(e,{kind:"turn-end"})),T(n=>n.map(n=>n.id===e?t:n)),ew.current===e&&(ew.current=null)},onError:(e,t)=>{es(e=>eU(e,{kind:"error",payload:t})),(0,f.cY)("webterm.chat.observer.error",{placeholderId:e,error:t.error}),T(n=>n.map(n=>n.id===e?{...n,meta:{...n.meta,stopReason:t.error}}:n)),ew.current===e&&(ew.current=null)}});return()=>{e()}},[x,y,b.baseUrl,b.provider]),(0,a.useEffect)(()=>{if(!y||!b.baseUrl)return;let e=x.subscribeChatFeedbackEvents(y,{agentStatus:{onFeedback:e=>{T(t=>{if(0===t.length)return t;for(let n=t.length-1;n>=0;n--){if("assistant"!==t[n].role)continue;let r=t[n],a=Array.isArray(r.blocks)?[...r.blocks]:[];if("applied"!==(0,ef.K4)(a,e))break;let l={...r,blocks:a};return[...t.slice(0,n),l,...t.slice(n+1)]}return t})},onError:e=>{(0,f.cY)("webterm.agent-status.error",e)}},hudSegment:{onFeedback:e=>(0,z.Ju)(e),onError:e=>{(0,f.cY)("webterm.hud-segment.error",e)}}});return()=>{e()}},[x,y,b.baseUrl]),(0,a.useEffect)(()=>{if(!y||!b.baseUrl)return;let e=null;try{e=x.connectAcp({sessionId:y,onSession:e=>{if(e&&e!==y){var n;(0,f.cY)("webterm.chat.acp.session-adopt",{previous:y,issued:e}),$.current===y&&(Q.current=e,$.current=e,null==(n=t.onSessionAdopt)||n.call(t,e),R(e))}}})}catch(e){(0,f.cY)("webterm.chat.acp.connect-failed",{reason:String(e)});return}ej.current=e,eS(e);let n=e;(0,f.x8)(async e=>{let t=JSON.parse(e);return await n.send("elanous/debug-logs/ingest",{records:t.records}),!0});let r=(0,z.ZH)(e,y,{isLocalTurnInFlight:()=>ey.current,isRemoteSseTurnInFlight:()=>null!==ew.current,onPlaceholder:e=>{let{sessionId:t}=e;es(e=>eU(e,{kind:"turn-begin"}));let n="m-acp-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,6)),r={id:n,role:"assistant",text:"",timestamp:Date.now(),meta:{provider:b.provider}};return(0,f.cY)("webterm.chat.acp.foreign-placeholder",{id:n,turnSessionId:t}),T(e=>[...e,r]),n},onPartialBlocks:(e,t)=>{let n=t.find(e=>"text"===e.kind),r=t.some(e=>"image"===e.kind||"tool_use"===e.kind);T(a=>a.map(a=>a.id===e?{...a,...n?{text:n.text}:{},...r?{blocks:t}:{}}:a))},onFinalize:e=>{(0,f.cY)("webterm.chat.acp.foreign-finalize",{placeholderId:e})}});return()=>{r(),(0,f.x8)(null);try{null==e||e.close()}catch(e){}ej.current===e&&(ej.current=null),eS(null)}},[x,y,b.baseUrl,b.provider]);let te=function(e){var t;let{acp:n,onComposerPrefill:r}=e,[l,s]=(0,a.useState)(null),o=(0,a.useRef)(null),i=(0,a.useCallback)(e=>{o.current=e,s(e)},[]),c=(0,a.useCallback)(e=>{let t=o.current;t&&(t.resolve(e),i(null))},[i]);(0,a.useEffect)(()=>{if(!n)return;let e=n.onRequest("elanous/ask/request",async e=>{let t=function(e){if(!e||"object"!=typeof e||"string"!=typeof e.id||!e.id||!e.request||"object"!=typeof e.request)return null;let t=e.request;return Array.isArray(t.questions)&&0!==t.questions.length?{id:e.id,request:e.request}:null}(e);if(!t)return{answers:{},cancelled:!0};let n=o.current;return n&&n.resolve({answers:{},cancelled:!0}),await new Promise(e=>{i({request:t.request,resolve:e,askId:t.id})})}),t=n.on("sessionUpdate",()=>{}),r=n.onAny(e=>{var t;if("elanous/ask/cancel"!==e.method||void 0!==e.id)return;let n=(t=e.params)&&"object"==typeof t&&"string"==typeof t.id&&t.id?{id:t.id,..."string"==typeof t.reason?{reason:t.reason}:{}}:null;if(!n)return;let r=o.current;r&&r.askId===n.id&&c({answers:{},cancelled:!0})});return()=>{e(),t(),r();let n=o.current;n&&(n.resolve({answers:{},cancelled:!0}),o.current=null)}},[n,i,c]);let d=(0,a.useCallback)(e=>{c(e)},[c]),u=(0,a.useCallback)(()=>{c({answers:{},cancelled:!0})},[c]),m=(0,a.useCallback)(()=>{let e=o.current;e&&r&&r(e.request),c({answers:{},cancelled:!0})},[c,r]);return{pendingRequest:null!=(t=null==l?void 0:l.request)?t:null,submit:d,cancel:u,chatAboutThis:m}}({acp:eN,onComposerPrefill:e=>{let t=e.questions[0];if(!t)return;let n="[ Q: ".concat(t.question.trim()," ]\n\n");(0,en.vn)(n),L(e=>{var t;return{text:n,id:(null!=(t=null==e?void 0:e.id)?t:0)+1}}),eL.oR.info("\uD83D\uDCAC 입력 영역에 질문 prefill 됨 (Chat about this)")}}),tt=function(e){var t,n;let{acp:r,sessionId:l}=e,[s,o]=(0,a.useState)(null),i=(0,a.useRef)(null),c=(0,a.useRef)(l);c.current=l;let d=(0,a.useCallback)((e,t,n)=>{let r=i.current;r&&(!n||r.request===n)&&(i.current=null,clearTimeout(r.timer),o(null),(0,f.cY)("pwa.tool-approval.".concat("cancelled"===t?"cancelled":"decided"),{tool:eT,choice:t}),r.resolve(e))},[]);(0,a.useEffect)(()=>{if(!r)return;let e=r.onRequest("session/request_permission",e=>{let t=function(e){try{if(!e||"object"!=typeof e)return null;let t=e.toolCall;if(!t||"object"!=typeof t||"string"!=typeof e.sessionId||!e.sessionId||"string"!=typeof t.toolCallId||!t.toolCallId||"string"!=typeof t.title||!t.title||!Array.isArray(e.options))return null;let n=e.options.map(e=>{if(!e||"object"!=typeof e||"string"!=typeof e.optionId||!e.optionId||"string"!=typeof e.kind||!eD.includes(e.kind))throw Error("invalid option");return{optionId:e.optionId,kind:e.kind}});if(new Set(n.map(e=>e.optionId)).size!==n.length||new Set(n.map(e=>e.kind)).size!==n.length||["allow_once","allow_always","reject_once"].some(e=>!n.some(t=>t.kind===e)))return null;return{sessionId:e.sessionId,toolCall:{toolCallId:t.toolCallId,title:t.title,...void 0!==t.rawInput?{rawInput:t.rawInput}:{}},options:n}}catch(e){return null}}(e);return t&&t.sessionId===c.current?((0,f.cY)("pwa.tool-approval.requested",{tool:eT,choice:null}),d(eR,"cancelled"),new Promise(e=>{let n={request:t,receivedAt:Date.now(),resolve:e,timer:setTimeout(()=>{i.current===n&&d(eR,"cancelled")},6e4)};i.current=n,o(n)})):((0,f.cY)("pwa.tool-approval.cancelled",{tool:eT,choice:"cancelled"}),eR)}),t="function"==typeof r.onState?r.onState(e=>{("CLOSED"===e||"FAILED"===e)&&d(eR,"cancelled")}):()=>{};return()=>{e(),t(),d(eR,"cancelled")}},[r,d]),(0,a.useEffect)(()=>{i.current&&i.current.request.sessionId!==l&&d(eR,"cancelled")},[l,d]);let u=(0,a.useCallback)((e,t)=>{var n;if((null==(n=i.current)?void 0:n.request)!==e)return;let r=e.options.find(e=>e.kind===t);r&&d({outcome:{outcome:"selected",optionId:r.optionId}},t,e)},[d]),m=(0,a.useCallback)(e=>d(eR,"cancelled",e),[d]);return{pendingRequest:null!=(t=null==s?void 0:s.request)?t:null,receivedAt:null!=(n=null==s?void 0:s.receivedAt)?n:0,choose:u,cancel:m}}({acp:eN,sessionId:y}),tn=(0,r.jsxs)("button",{type:"button",onClick:()=>void eW.toggle(),disabled:!eZ,title:eZ?null!=(e=eW.errorMsg)?e:eq.g[eW.phase]:"daemon URL 미설정 — Settings 에서 Base URL 입력","data-elanous-action":"chat-voice-toggle",className:(0,J.cn)("inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors",eW.active?"border-rose-500/40 bg-rose-500/10 text-rose-600 hover:bg-rose-500/20":"border-border bg-background text-foreground hover:bg-muted",!eZ&&"cursor-not-allowed opacity-50"),children:[(0,r.jsx)("span",{className:(0,J.cn)("h-2 w-2 rounded-full",eq.x[eW.phase],("listening"===eW.phase||"speaking"===eW.phase)&&"animate-pulse"),"aria-hidden":!0}),eW.active?(0,r.jsx)(s.A,{className:"h-3.5 w-3.5"}):(0,r.jsx)(o.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:eq.g[eW.phase]})]});return(0,r.jsxs)("div",{className:"relative flex h-full flex-col",onPaste:e=>{let t=function(e,t){if(!e)return S([]);let n=[];if(e.items.length>0)for(let t of Array.from(e.items)){if("file"!==t.kind)continue;let e=t.getAsFile();e&&n.push(e)}else n.push(...Array.from(e.files));return S(n.map(e=>({file:e,filename:e.name||"paste-".concat(t,".png")})))}(e.clipboardData,Date.now());(0!==t.files.length||0!==t.tooLarge||0!==t.tooMany)&&(e.preventDefault(),e3(t))},onDragEnter:e=>{ev(t=>A(t,"enter",I(e.dataTransfer)))},onDragLeave:e=>{ev(t=>A(t,"leave",I(e.dataTransfer)))},onDragOver:e=>{I(e.dataTransfer)&&e.preventDefault()},onDrop:e=>{var t;ev(t=>A(t,"drop",I(e.dataTransfer)));let n=S((t=e.dataTransfer)?Array.from(t.files,e=>({file:e,filename:e.name})):[]);(0!==n.files.length||0!==n.tooLarge||0!==n.tooMany)&&(e.preventDefault(),e3(n))},children:[eb.visible&&(0,r.jsx)(C,{}),n?(0,r.jsxs)("div",{"data-elanous-chat-compact-header":"",className:"flex h-11 max-h-11 min-w-0 shrink-0 items-center gap-2 border-b border-border bg-background px-3 whitespace-nowrap",children:[t.leading&&(0,r.jsx)("div",{className:"shrink-0",children:t.leading}),(0,r.jsx)("div",{className:"min-w-0 flex-1 [&>div]:min-w-0 [&>div]:max-w-full [&>div>div:first-child]:min-w-0 [&>div>div:first-child]:max-w-full [&>div>div:first-child]:overflow-hidden [&>div>div:first-child>span:last-child]:shrink-0 [&>div>div:first-child_span]:min-w-0 [&>div>div:first-child_span]:truncate [&>div>div[role=menu]]:max-w-[calc(100vw-4rem)]",children:(0,r.jsx)(E.Qh,{sessionId:y,...t.onAttachRequest?{onAttachRequest:t.onAttachRequest}:{},...t.onForgetRequest?{onForgetRequest:t.onForgetRequest}:{}})}),(0,r.jsx)("div",{className:"min-w-0 shrink-0",children:(0,r.jsx)(_,{compact:!0})}),(0,r.jsx)(g,{}),(0,r.jsxs)("div",{ref:p,className:"relative shrink-0",children:[(0,r.jsx)("button",{type:"button","aria-label":"채팅 더보기","aria-expanded":u,"aria-controls":"chat-header-more",onClick:()=>m(e=>!e),className:"inline-flex h-8 w-8 items-center justify-center rounded-lg hover:bg-muted",children:(0,r.jsx)(i.A,{className:"h-5 w-5","aria-hidden":"true"})}),u&&(0,r.jsxs)("div",{id:"chat-header-more",className:"absolute right-0 top-full z-50 mt-1 flex max-w-[calc(100vw-1.5rem)] flex-col gap-2 rounded-lg border border-border bg-popover p-3 shadow-lg",children:[(0,r.jsx)(l.vG,{children:(0,r.jsx)(er.rm,{})}),(0,r.jsx)(l.vG,{children:(0,r.jsx)(ea.D,{})}),tn]})]})]}):(0,r.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-4 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(E.Qh,{sessionId:y,...t.onAttachRequest?{onAttachRequest:t.onAttachRequest}:{},...t.onForgetRequest?{onForgetRequest:t.onForgetRequest}:{}}),(0,r.jsx)(l.vG,{children:(0,r.jsx)(er.rm,{})}),(0,r.jsx)(l.vG,{children:(0,r.jsx)(ea.D,{})})]}),(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)(_,{}),(0,r.jsx)(g,{}),tn]})]}),(0,r.jsx)(h,{}),(0,r.jsx)(v,{}),(0,r.jsx)(w,{}),(0,r.jsx)(X,{}),(0,r.jsxs)("div",{className:"relative flex flex-1 min-h-0 flex-col",children:[(0,r.jsx)(j.D,{messages:D,pending:U,...t.tabId?{tabId:t.tabId}:{}}),el&&(0,r.jsxs)("div",{role:"alert",className:"mx-4 mb-3 flex shrink-0 items-start justify-between gap-3 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-foreground","data-elanous-turn-busy-banner":"",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"font-medium",children:"이 대화는 지금 응답 중입니다"}),(0,r.jsx)("p",{className:"text-muted-foreground",children:el.message}),(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:el.holder?"Current input holder: ".concat(el.holder):"The current input holder is not available."})]}),(0,r.jsx)("button",{type:"button",onClick:()=>es(null),className:"rounded px-2 py-1 text-xs text-muted-foreground hover:bg-amber-500/10 hover:text-foreground","aria-label":"응답 중 알림 닫기",children:"Dismiss"})]}),(0,r.jsx)(em,{active:eW.active,phase:eW.phase,errorMsg:eW.errorMsg,onToggle:()=>void eW.toggle(),ttsSupported:e0.supported,ttsMuted:eV,onTtsToggle:()=>eX(e=>!e),onInterrupt:()=>{try{e0.cancel()}catch(e){}eW.interrupt()}})]}),U&&eo&&(0,r.jsxs)("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t border-border bg-muted/30 px-4 py-1.5 text-xs",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"streaming…"}),(0,r.jsx)("button",{type:"button",onClick:e1,className:"rounded border border-border bg-background px-2 py-0.5 font-mono hover:bg-muted","data-elanous-action":"chat-stop",title:"Stop the running turn (Esc)",children:"Stop ⎋"})]}),(0,r.jsx)(N,{queue:Z,onRemove:e=>{var t;return V((t=P.current,t.filter(t=>t.id!==e)))},onClear:()=>V([])}),(0,r.jsx)(k.V,{onSubmit:e9,prefill:q,attachments:ec,onAttached:e2,onRemoveAttachment:e5,voice:{active:eW.active,phase:eW.phase,dotColor:eq.x[eW.phase],phaseLabel:eq.g[eW.phase],disabled:!eZ,onToggle:()=>void eW.toggle()},...t.tabId?{tabId:t.tabId}:{},onListFiles:eN&&y?async e=>{var t,n;let r=await eN.send("elanous/fs/list",{sessionId:y,query:e,limit:50}),a=(null!=(t=r.entries)?t:[]).filter(e=>"string"==typeof(null==e?void 0:e.name)&&"boolean"==typeof(null==e?void 0:e.isDir)&&"string"==typeof(null==e?void 0:e.relPath)).map(e=>({name:e.name,isDir:e.isDir,relPath:e.relPath}));return{cwd:null!=(n=r.cwd)?n:"",entries:a}}:void 0,onListSkills:eN&&y?async e=>{var t;return{entries:(null!=(t=(await eN.send("elanous/skills/list",{sessionId:y,query:e})).entries)?t:[]).filter(e=>"string"==typeof(null==e?void 0:e.name)&&"string"==typeof(null==e?void 0:e.description)).map(e=>({name:e.name,description:e.description}))}}:void 0}),eI&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eh,{open:eC,onClose:()=>eA(!1),lines:eF}),!eC&&(0,r.jsxs)("button",{type:"button",onClick:()=>eA(!0),"data-elanous-debug-tap-reopen":"",className:(0,J.cn)("fixed bottom-3 right-3 z-40 rounded-full border border-border bg-card px-3 py-1.5","text-[11px] font-mono text-muted-foreground shadow hover:bg-muted hover:text-foreground"),"aria-label":"Reopen debug drawer",title:"Reopen Debug Tap drawer",children:["⌁ debug (",eF.length,")"]})]}),(0,r.jsx)(ek,{request:te.pendingRequest,onSubmit:te.submit,onCancel:te.cancel,onChatAboutThis:te.chatAboutThis}),(0,r.jsx)(eE,{request:tt.pendingRequest,receivedAt:tt.receivedAt,onChoose:tt.choose,onCancel:tt.cancel})]})}var eK=n(8819),eB=n(21383);function eH(e,t){var n,r;return(null==t?void 0:t.trim())||(null==(r=e.lastMsgPreview)||null==(n=r.trim().split(/\r?\n/)[0])?void 0:n.trim())||"대화"}function eW(e,t){try{"undefined"!=typeof localStorage&&localStorage.setItem(e,t)}catch(e){}}function eZ(e){let{onSelect:t}=e,n=(0,d.Q)(),l=(0,D.t)({activePoll:!0}),[s,o]=(0,a.useState)({}),[i,c]=(0,a.useState)(""),[u,m]=(0,a.useState)([]),[h,p]=(0,a.useState)("all"),[f,g]=(0,a.useState)([]),[x,b]=(0,a.useState)(F);(0,a.useEffect)(()=>{let e=()=>{b(F()),j({})};return window.addEventListener(L,e),()=>window.removeEventListener(L,e)},[]);let[v,y]=(0,a.useState)({}),[w,j]=(0,a.useState)({}),k=(0,a.useRef)(new Set),N=e=>{let t=e(F());P(t),b(t)};(0,a.useEffect)(()=>{var e;p(null!=(e=function(e){try{return"undefined"==typeof localStorage?null:localStorage.getItem(e)}catch(e){return null}}(q))?e:"all");let t=!0,r=0,a=()=>{let e=++r;new T(n.client).list().then(n=>{var a;t&&e===r&&m(null!=(a=n.projects)?a:[])}).catch(()=>{})};return a(),window.addEventListener(U,a),()=>{t=!1,window.removeEventListener(U,a)}},[n.client]),(0,a.useEffect)(()=>{let e=!0,t=u.length>0&&"all"!==h&&"none"!==h?"?projectId=".concat(encodeURIComponent(h)):"";return n.client.fetchJson("/v1/sessions/store".concat(t)).then(t=>{var n;if(!e)return;let r=null!=(n=t.sessions)?n:[];g(r),o(Object.fromEntries(r.map(e=>[e.id,e.title])))}).catch(()=>{}),()=>{e=!1}},[n.client,l,u,h]),(0,a.useEffect)(()=>{let e=Object.keys(x).filter(e=>l.some(t=>t.id===e)&&!f.some(t=>t.id===e));if(0===e.length)return;let t=!0;for(let r of e)n.client.fetchJson("/v1/sessions/store/".concat(encodeURIComponent(r),"?ifExists=1")).then(e=>{t&&e.meta&&g(t=>t.some(e=>e.id===r)?t:[...t,e.meta])}).catch(()=>{});return()=>{t=!1}},[f,n.client,x,l]),(0,a.useEffect)(()=>{for(let[e,t]of Object.entries(x)){if(e===n.sessionId||w[e]===t||!l.some(t=>t.id===e)||k.current.has(e))continue;let r=f.find(t=>t.id===e);if(r&&F()[e]===t){if(r.projectId===t||v[e]===t){N(t=>{let n={...t};return delete n[e],n});continue}k.current.add(e),new T(n.client).assign(e,t).then(()=>{y(n=>({...n,[e]:t})),g(n=>n.map(n=>n.id===e?{...n,projectId:t}:n)),F()[e]===t&&N(t=>{let n={...t};return delete n[e],n})}).catch(()=>{j(n=>({...n,[e]:t})),F()[e]===t&&N(t=>{let n={...t};return delete n[e],n})}).finally(()=>{k.current.delete(e)})}}},[v,w,f,n.client,n.sessionId,x,l]);let S=u.some(e=>e.id===h)||"none"===h?h:"all",I=0===u.length||"all"===S?l:l.filter(e=>x[e.id]?x[e.id]===S:"none"===S?!f.some(t=>t.id===e.id&&t.projectId)&&!v[e.id]:v[e.id]===S||f.some(t=>t.id===e.id&&t.projectId===S)),C=[...I].filter(e=>{var t;return"".concat(eH(e,s[e.id])," ").concat(null!=(t=e.lastMsgPreview)?t:"").toLocaleLowerCase().includes(i.trim().toLocaleLowerCase())}).sort((e,t)=>Date.parse(t.lastTurnAt)-Date.parse(e.lastTurnAt)),A=()=>{let e=(0,et.Zr)();u.length>0&&"all"!==S&&"none"!==S&&N(t=>({...t,[e]:S})),n.setSessionId(e),null==t||t()};return(0,r.jsxs)("nav",{"aria-label":"대화 목록",className:"flex h-full min-h-0 flex-col bg-background",children:[(0,r.jsxs)("div",{className:"shrink-0 space-y-3 border-b border-border p-3",children:[(0,r.jsx)(Y,{projects:u,selection:S,onChange:e=>{p(e),eW(q,e)},onCreate:async e=>{let{project:t}=await new T(n.client).create(e);m(e=>[...e,t]),p(t.id),eW(q,t.id),O()}}),(0,r.jsxs)("button",{type:"button",onClick:A,className:"flex w-full items-center gap-2 rounded-lg bg-primary px-3 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90",children:[(0,r.jsx)(eK.A,{className:"h-4 w-4","aria-hidden":"true"})," 새 대화"]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 rounded-lg border border-border bg-muted/30 px-2.5 py-2 focus-within:ring-2 focus-within:ring-ring",children:[(0,r.jsx)(eB.A,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,r.jsx)("input",{"aria-label":"대화 검색",type:"search",value:i,onChange:e=>c(e.target.value),placeholder:"대화 검색",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]})]}),(0,r.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:0===I.length?(0,r.jsxs)("div",{className:"space-y-3 px-2 py-8 text-center text-sm text-muted-foreground",children:[(0,r.jsx)("p",{children:"아직 대화가 없습니다"}),(0,r.jsx)("button",{type:"button",onClick:A,className:"rounded-lg border border-border px-3 py-2 text-foreground hover:bg-muted",children:"+ 새 대화"})]}):0===C.length?(0,r.jsx)("p",{className:"px-2 py-8 text-center text-sm text-muted-foreground",children:"검색 결과가 없습니다"}):(0,r.jsx)("ul",{className:"space-y-1",children:C.map(e=>(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button","aria-current":n.sessionId===e.id?"page":void 0,onClick:()=>{O(),n.setSessionId(e.id),null==t||t()},className:"w-full rounded-lg px-3 py-2.5 text-left transition-colors ".concat(n.sessionId===e.id?"bg-primary/10 text-primary ring-1 ring-inset ring-primary/25":"text-foreground hover:bg-muted"),children:[(0,r.jsx)("span",{className:"block truncate text-sm font-medium",children:eH(e,s[e.id])}),(0,r.jsxs)("span",{className:"mt-1 block truncate text-xs text-muted-foreground",children:[function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),n=Date.parse(e);if(!Number.isFinite(n))return"";let r=Math.max(0,Math.floor((t-n)/6e4));if(r<1)return"방금 전";if(r<60)return"".concat(r,"분 전");let a=Math.floor(r/60);if(a<24)return"".concat(a,"시간 전");let l=Math.floor(a/24);return l<7?"".concat(l,"일 전"):new Date(n).toLocaleDateString()}(e.lastTurnAt)," \xb7 ",e.msgCount,"개 메시지"]})]})},e.id))})})]})}var eV=n(35622),eX=n(69147),e0=n(44614);function e1(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{compact:n}=(0,c.K)(),l=(0,e0.tg)(),{client:s,sessionId:o,setSessionId:i}=(0,d.Q)(),[u,m]=(0,a.useState)(o||"default"),[h,p]=(0,a.useState)(!1);(0,a.useEffect)(()=>{if(!h)return;let e=e=>{"Escape"===e.key&&p(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[h]);let f=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(f.current===o){f.current=null;return}f.current=null,m(o||"default")},[o]);let g=(0,a.useRef)(t.sessionId),x=(0,a.useRef)(o),b=null!=(e=null==l?void 0:l.state.activeId)?e:null;(0,a.useEffect)(()=>{let e=t.sessionId;if(l&&t.tabId&&e&&o){var n,r;let a=function(e){if(!e.isActive||e.tabSessionId===e.daemonSessionId)return"none";let t=e.prevTabSessionId!==e.tabSessionId,n=e.prevDaemonSessionId!==e.daemonSessionId;return t||!n?"adopt-tab":"record-global"}({isActive:b===t.tabId,tabSessionId:e,daemonSessionId:o,prevTabSessionId:null!=(n=g.current)?n:e,prevDaemonSessionId:null!=(r=x.current)?r:o});"adopt-tab"===a?i(e):"record-global"===a&&l.updateChatTab(t.tabId,{sessionId:o})}g.current=t.sessionId,x.current=o},[l,b,t.tabId,t.sessionId,o,i]);let v=l&&t.tabId?()=>l.openPicker({kind:"attachToTab",tabId:t.tabId}):void 0,y=l&&t.sessionId?async()=>{let e=(0,R.hG)(s);await e.forget(t.sessionId)}:void 0,w=(0,r.jsx)("button",{type:"button",onClick:()=>p(!0),"aria-label":"대화 목록","aria-expanded":h,"aria-controls":"chat-conversation-drawer",className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg hover:bg-muted",children:(0,r.jsx)(eV.A,{className:"h-4 w-4","aria-hidden":"true"})}),j=(0,r.jsx)(eG,{onSessionAdopt:e=>{f.current=e},...t.showConversationList&&n?{leading:w}:{},...v?{onAttachRequest:v}:{},...y?{onForgetRequest:y}:{},...t.tabId?{tabId:t.tabId}:{}},u);return t.showConversationList?(0,r.jsxs)("div",{className:"flex h-full min-h-0 min-w-0",children:[(0,r.jsx)("aside",{className:n?"hidden":"hidden h-full w-[260px] shrink-0 border-r border-border md:block",children:(0,r.jsx)(eZ,{})}),(0,r.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[!n&&(0,r.jsx)("div",{className:"shrink-0 border-b border-border bg-background px-3 py-2 md:hidden",children:(0,r.jsxs)("button",{type:"button",onClick:()=>p(!0),"aria-label":"대화 목록","aria-expanded":h,"aria-controls":"chat-conversation-drawer",className:"inline-flex items-center gap-2 rounded-lg px-2 py-1.5 text-sm font-medium hover:bg-muted",children:[(0,r.jsx)(eV.A,{className:"h-4 w-4","aria-hidden":"true"})," 대화 목록"]})}),(0,r.jsx)("div",{className:"min-h-0 min-w-0 flex-1",children:j})]}),h&&(0,r.jsxs)("div",{className:n?"fixed inset-0 z-50":"fixed inset-0 z-50 md:hidden",children:[(0,r.jsx)("button",{type:"button","aria-label":"대화 목록 닫기",onClick:()=>p(!1),className:"absolute inset-0 bg-black/50"}),(0,r.jsxs)("aside",{id:"chat-conversation-drawer",role:"dialog","aria-modal":"true","aria-label":"대화 목록",className:"relative h-full w-[min(260px,85vw)] bg-background shadow-xl",children:[(0,r.jsx)("button",{type:"button","aria-label":"대화 목록 닫기",onClick:()=>p(!1),className:"absolute right-2 top-2 z-10 rounded p-1 hover:bg-muted",children:(0,r.jsx)(eX.A,{className:"h-4 w-4"})}),(0,r.jsx)(eZ,{onSelect:()=>p(!1)})]})]})]}):j}},74780:(e,t,n)=>{function r(e){return{slides:e.slides.map(e=>{let{image:t,caption:n,include:r}=e;return{image:t,caption:n,include:r}}),caption:{hook:e.caption.hook,body:e.caption.body},hashtags:[...e.hashtags],cover:{text:e.cover.text,sub:e.cover.sub},location:e.location}}n.d(t,{$Y:()=>s,LP:()=>i,Mz:()=>r,ll:()=>d,rH:()=>o});class a extends Error{constructor(e,t){super(t),this.status=e,this.name="GraphApprovalsApiError"}}let l={list:"목록을 보려면",decide:"승인하려면",save:"초안을 저장하려면"},s="/app/settings/#bearer-token";function o(e){return e instanceof a&&(401===e.status||403===e.status)}function i(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"decide";return e instanceof a?401===e.status||403===e.status?"".concat(l[t]," 이 기기를 데몬에 연결해야 합니다 — 설정 › 데몬 연결 › 연결 토큰 칸에 토큰을 넣어 주세요."):404===e.status?"이 실행을 찾지 못했습니다. 목록을 다시 확인해 주세요.":409===e.status?"이미 결정된 실행입니다. 목록을 다시 확인해 주세요.":400===e.status?"결정 내용을 확인한 뒤 다시 시도해 주세요.":"승인 요청을 처리하지 못했습니다. 잠시 뒤 다시 시도해 주세요.":e instanceof TypeError?"서버에 연결하지 못했습니다. 연결 상태를 확인해 주세요.":"승인 요청을 처리하지 못했습니다. 잠시 뒤 다시 시도해 주세요."}let c="/v1/graph-approvals";function d(e){var t,n;let r=(null!=(t=e.baseUrl)?t:"").replace(/\/+$/,""),l=null!=(n=e.fetchImpl)?n:fetch;async function s(t,n){let s={...n,headers:{"content-type":"application/json",...e.authHeader?{authorization:e.authHeader}:{}}},o=e.client?await e.client.fetchResponse(t,s):await l("".concat(r).concat(t),s),i=await o.json().catch(()=>null);if(!o.ok){let e=i&&"object"==typeof i&&"error"in i&&"string"==typeof i.error?i.error:"request-failed";throw new a(o.status,e)}return i}return{list:()=>s(c),decide:(e,t,n)=>s("".concat(c,"/").concat(encodeURIComponent(e),"/").concat(encodeURIComponent(t)),{method:"POST",body:JSON.stringify({decision:n})}),saveFeedDraft:(e,t,n)=>s("".concat(c,"/").concat(encodeURIComponent(e),"/").concat(encodeURIComponent(t),"/feed-draft"),{method:"PUT",body:JSON.stringify(n)}),feedMedia:async(t,n,s)=>{let o="".concat(c,"/").concat(encodeURIComponent(t),"/").concat(encodeURIComponent(n),"/media?path=").concat(encodeURIComponent(s)),i={headers:e.authHeader?{authorization:e.authHeader}:{}},d=e.client?await e.client.fetchResponse(o,i):await l("".concat(r).concat(o),i);if(!d.ok)throw new a(d.status,"media-failed");return d.blob()}}}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9247],{79247:(e,t,n)=>{n.d(t,{I7:()=>c,Iu:()=>a,xX:()=>i});var o=n(18068),r=n(72215);let s="/v1/task-cards";class a extends Error{constructor(e,t,n){super("nexus ".concat(e," on ").concat(t,": ").concat(function(e){try{return JSON.stringify(e)}catch(t){return String(e)}}(n))),this.status=e,this.path=t,this.body=n,this.name="NexusApiError"}}class c extends a{constructor(e,t){super(400,e,t),this.name="MissingUpstreamError",this.nodes=t.nodes}}class l extends Error{constructor(e,t){super("NEXUS 가 ".concat(t/1e3,"초 안에 답하지 않았습니다 (").concat(e,") — 방금 켰다면 잠시 뒤 다시 시도하세요.")),this.path=e,this.timeoutMs=t,this.name="NexusTimeoutError"}}function i(e){var t,n;let i=e.baseUrl.replace(/\/$/,""),d=null!=(t=e.fetchImpl)?t:fetch,v=null!=(n=e.timeoutMs)?n:8e3,u=e.token;async function p(e,t,n,r){let s="".concat(i).concat(t);for(let i=0;;i++){let p=v>0||(null==r?void 0:r.signal)?new AbortController:null,g=!1,w=null;if(p&&(null==r?void 0:r.signal)){let e=r.signal;if(e.aborted)p.abort();else{let t=()=>p.abort();e.addEventListener("abort",t),w=()=>e.removeEventListener("abort",t)}}let T=p&&v>0?setTimeout(()=>{p.signal.aborted||(g=!0,p.abort())},v):null;try{let r=await d(s,{method:e,...p?{signal:p.signal}:{},...void 0!==n||u?{headers:{...void 0!==n?{"content-type":"application/json"}:{},...u?{authorization:"Bearer ".concat(u)}:{}}}:{},...void 0!==n?{body:JSON.stringify(n)}:{}});401===r.status&&(0,o.Qb)(t);let l=null;try{l=await r.json()}catch(e){if(!(e instanceof SyntaxError))throw e}if(!r.ok){if(400===r.status&&t.startsWith("/v1/workflows/")&&t.endsWith("/run")&&l&&"object"==typeof l&&"error"in l&&"missing-upstream"===l.error&&"nodes"in l&&Array.isArray(l.nodes)&&l.nodes.every(e=>"string"==typeof e))throw new c(t,l);throw new a(r.status,t,l)}return l}catch(n){if(!g||!(n instanceof Error)||"AbortError"!==n.name)throw n;if("GET"!==e||i>0)throw new l(t,v)}finally{null!=T&&clearTimeout(T),null==w||w()}await new Promise((e,t)=>{let n=null==r?void 0:r.signal;if(null==n?void 0:n.aborted)return void t(new DOMException("aborted","AbortError"));let o=()=>{clearTimeout(s),null==n||n.removeEventListener("abort",o),t(new DOMException("aborted","AbortError"))},s=setTimeout(()=>{null==n||n.removeEventListener("abort",o),e()},100);null==n||n.addEventListener("abort",o,{once:!0})})}}async function g(e,t,n){let r="/v1/plugins/install",s=await d("".concat(i).concat(r),{method:"POST",headers:{"content-type":"application/json",...u?{authorization:"Bearer ".concat(u)}:{}},body:JSON.stringify({spec:e,acceptedCapabilities:t})});if(401===s.status&&(0,o.Qb)(r),!s.ok)throw new a(s.status,r,await s.json());if(!s.body)throw Error("설치 진행 정보를 읽을 수 없습니다.");let c=s.body.getReader(),l=new TextDecoder,v="";try{for(;;){let e,{done:t,value:o}=await c.read();if(t)break;for(v+=l.decode(o,{stream:!0});-1!==(e=v.indexOf("\n"));){let t=v.slice(0,e).trim();v=v.slice(e+1),t&&n(t)}}(v+=l.decode()).trim()&&n(v.trim())}finally{c.releaseLock()}}return{baseUrl:i,getHealth:()=>p("GET","/v1/health"),getNexus:()=>p("GET","/v1/nexus"),getTabs:e=>{let t=(null==e?void 0:e.kind)?"?kind=".concat(encodeURIComponent(e.kind)):"";return p("GET","/v1/nexus/tabs".concat(t))},getTab:e=>p("GET","/v1/nexus/tabs/".concat(encodeURIComponent(e))),getTaskCards:()=>p("GET",s),getTaskCard:e=>p("GET","".concat(s,"/").concat(encodeURIComponent(e))),getChatBackendDetection:()=>p("GET","/v1/nexus/chat-backend-detection"),mintConnectToken:()=>p("POST","/v1/nexus/connect-info/mint-token",{}),createTab:e=>p("POST","/v1/nexus/tabs",e),deleteTab:e=>p("DELETE","/v1/nexus/tabs/".concat(encodeURIComponent(e))),patchTab:(e,t)=>p("PATCH","/v1/nexus/tabs/".concat(encodeURIComponent(e)),t),startTab:e=>p("POST","/v1/nexus/tabs/".concat(encodeURIComponent(e),"/start")),stopTab:(e,t)=>{let n=(null==t?void 0:t.graceMs)!==void 0?"?graceMs=".concat(t.graceMs):"";return p("POST","/v1/nexus/tabs/".concat(encodeURIComponent(e),"/stop").concat(n))},restartTab:(e,t)=>{let n=(null==t?void 0:t.graceMs)!==void 0?"?graceMs=".concat(t.graceMs):"";return p("POST","/v1/nexus/tabs/".concat(encodeURIComponent(e),"/restart").concat(n))},getTemplates:()=>p("GET","/v1/nexus/templates"),getTemplate:e=>p("GET","/v1/nexus/templates/".concat(encodeURIComponent(e))),saveTemplate:e=>p("POST","/v1/nexus/templates",e),getPluginsIndex:()=>p("GET","/v1/plugins/index"),getInstalledPlugins:()=>p("GET","/v1/plugins"),refreshPluginMarket:e=>p("POST","/v1/plugins/markets/".concat(encodeURIComponent(e),"/refresh"),{}),installMarketPlugin:g,removeMarketPlugin:e=>p("DELETE","/v1/plugins/".concat(encodeURIComponent(e))),getPluginCredentials:e=>p("GET","/v1/plugins/".concat(encodeURIComponent(e),"/credentials")),putPluginCredentials:(e,t)=>p("PUT","/v1/plugins/".concat(encodeURIComponent(e),"/credentials"),{fields:t}),getRunGraphs:()=>p("GET","/v1/graphs"),getRunGraph:e=>p("GET","/v1/graphs/".concat(encodeURIComponent(e))),getRunGraphYaml:e=>p("GET","/v1/graphs/".concat(encodeURIComponent(e),"/yaml")),putRunGraphYaml:(e,t)=>p("PUT","/v1/graphs/".concat(encodeURIComponent(e),"/yaml"),{yaml:t}),cloneRunGraph:(e,t)=>p("POST","/v1/graphs/".concat(encodeURIComponent(e),"/clone"),{newId:t}),getGraphKinds:e=>p("GET","/v1/graph/kinds?graph=".concat(e)),validateGraph:async(e,t)=>{try{return await p("POST","/v1/graphs/validate",{graph:e,yaml:t})}catch(e){if(e instanceof a&&422===e.status&&e.body&&"object"==typeof e.body&&"ok"in e.body)return e.body;throw e}},getWorkflows:()=>p("GET","/v1/workflows"),getWorkflow:e=>p("GET","/v1/workflows/".concat(encodeURIComponent(e))),getWorkflowHistory:e=>p("GET","/v1/workflows/".concat(encodeURIComponent(e),"/history")),getWorkflowHistoryVersion:(e,t)=>p("GET","/v1/workflows/".concat(encodeURIComponent(e),"/history/").concat(encodeURIComponent(t))),getWorkflowPins:e=>p("GET","/v1/workflows/".concat(encodeURIComponent(e),"/pins")),putWorkflowPin:(e,t,n,o)=>p("PUT","/v1/workflows/".concat(encodeURIComponent(e),"/pins/").concat(encodeURIComponent(t)),{value:n,...void 0!==o?{note:o}:{}}),deleteWorkflowPin:(e,t)=>p("DELETE","/v1/workflows/".concat(encodeURIComponent(e),"/pins/").concat(encodeURIComponent(t))),saveWorkflow:(e,t)=>p("PUT","/v1/workflows/".concat(encodeURIComponent(e)),t),deleteWorkflow:(e,t)=>{let n=(null==t?void 0:t.scope)?"?scope=".concat(encodeURIComponent(t.scope)):"";return p("DELETE","/v1/workflows/".concat(encodeURIComponent(e)).concat(n))},validateWorkflow:(e,t)=>p("POST","/v1/workflows/validate",{yaml:e},t),generateWorkflow:(e,t)=>p("POST","/v1/workflows/generate",e,t),synthesizeWorkflow:(e,t)=>p("POST","/v1/workflows/synth",e,t),getTriggersSnapshot:e=>p("GET","/v1/triggers",void 0,e),getWorkflowTemplates:e=>p("GET","/v1/workflows/templates",void 0,e),runWorkflow:(e,t,n)=>p("POST","/v1/workflows/".concat(encodeURIComponent(e),"/run"),{arguments:t,...(null==n?void 0:n.dryRun)?{dryRun:!0}:{},...(null==n?void 0:n.onlyNode)!==void 0?{onlyNode:n.onlyNode}:{},...(null==n?void 0:n.fromNode)!==void 0?{fromNode:n.fromNode}:{},...(null==n?void 0:n.fromRunId)!==void 0?{fromRunId:n.fromRunId}:{}}),getWorkflowRun:e=>p("GET","/v1/workflows/runs/".concat(encodeURIComponent(e))),getWorkflowRuns:()=>p("GET","/v1/workflows/runs"),workflowsEventsUrl:()=>i?"".concat(i,"/v1/workflows/events"):null,getPendingApprovals:()=>p("GET","/v1/workflows/runs/pending"),approveRun:(e,t)=>p("POST","/v1/workflows/runs/".concat(encodeURIComponent(e),"/approve"),null!=t?t:{}),rejectRun:(e,t)=>p("POST","/v1/workflows/runs/".concat(encodeURIComponent(e),"/reject"),null!=t?t:{}),getConfig:()=>p("GET","/v1/config"),getChatFastPath:()=>p("GET","/v1/config/chat-fast-path"),getSwitches:()=>p("GET","/v1/config/switches"),getSwitch:e=>p("GET","/v1/config/switches/".concat(encodeURIComponent(e))),putSwitch:(e,t)=>p("PUT","/v1/config/switches/".concat(encodeURIComponent(e)),t),postSecret:e=>p("POST","/v1/config/secrets",e),deleteSecret:e=>p("DELETE","/v1/config/secrets/".concat(encodeURIComponent(e))),getSecrets:()=>p("GET","/v1/config/secrets"),getModelTier:()=>p("GET","/v1/config/model-tier"),putModelTier:e=>p("PUT","/v1/config/model-tier",e),getPlatforms:()=>p("GET","/v1/platforms"),getLlmProviders:()=>p("GET","/v1/setup/llm-providers"),setLlmProvider:e=>p("POST","/v1/setup/llm-provider",e),getObsidianSkills:()=>p("GET","/v1/setup/obsidian-skills"),setObsidian:e=>p("POST","/v1/setup/obsidian",e),setSkills:e=>p("POST","/v1/setup/skills",e),getChannelBots:()=>p("GET","/v1/setup/channel-bots"),setChannelBot:e=>p("POST","/v1/setup/channel-bot",e),getChildLlmPreference:()=>p("GET","/v1/setup/child-llm"),setChildLlmPreference:e=>p("POST","/v1/setup/child-llm",e),getAnswerPriority:()=>p("GET","/v1/setup/answer-priority"),setAnswerPriority:e=>p("POST","/v1/setup/answer-priority",{value:e}),getPersonas:()=>p("GET","/v1/personas"),getPersonaPresets:()=>p("GET","/v1/persona-presets"),createPersona:e=>p("POST","/v1/personas",e),patchPersona:(e,t)=>p("PATCH","/v1/personas/".concat(encodeURIComponent(e)),t),patchPersonaDescription:(e,t)=>p("PATCH","/v1/personas/".concat(encodeURIComponent(e)),{description:t}),getRegistryCatalog:()=>p("GET","/v1/registry/catalog"),getWorktrees:()=>p("GET","/v1/worktrees"),getDesignCheck:()=>p("GET","/v1/design-check"),getHarnessRuns:()=>p("GET","/v1/harness/runs"),getLogs:e=>{let t=new URLSearchParams;for(let[n,o]of Object.entries(e))void 0!==o&&""!==o&&t.set(n,String(o));return p("GET","/v1/logs?".concat(t.toString()))},getLogInstances:()=>p("GET","/v1/logs/instances"),getLiveDetail:()=>p("GET","/v1/live/detail"),getTrace:e=>{let t=new URLSearchParams({level:e.level});return e.runId&&t.set("runId",e.runId),e.store&&t.set("store",e.store),e.limit&&t.set("limit",String(e.limit)),e.kind&&t.set("kind",e.kind),e.q&&t.set("q",e.q),e.from&&t.set("from",new Date(e.from).toISOString()),p("GET","/v1/trace?".concat(t))},getTraceEvidence:e=>p("GET","/v1/trace/evidence/".concat(e)),getLiveShipped:e=>p("GET","/v1/live/shipped?since=".concat(encodeURIComponent(e))),getRunScreen:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:60;return p("GET","/v1/harness/run-screen?runId=".concat(encodeURIComponent(e),"&lines=").concat(t))},stopHarness:e=>p("POST","/v1/harness/stop",{spaceId:e}),setLiveDetail:e=>p("POST","/v1/live/detail",e),setDesignDirection:e=>p("POST","/v1/design-direction",{id:e}),createDesignSystem:e=>p("POST","/v1/design-system",e),listDesignPreviews:()=>p("GET","/v1/design-previews"),getDesignPreview:e=>p("GET","/v1/design-previews/".concat(encodeURIComponent(e))),disposeWorktree:e=>p("POST","/v1/worktrees/dispose",e),getLogsTail:(e,t)=>{let n=(null==t?void 0:t.lines)!==void 0?"?lines=".concat(t.lines):"";return p("GET","/v1/nexus/tabs/".concat(encodeURIComponent(e),"/logs").concat(n))},subscribeEvents:e=>{var t,n;let o=null!=(t=e.EventSourceImpl)?t:globalThis.EventSource;if(!o)throw Error("EventSource not available \xb7 pass EventSourceImpl");let s=(null!=(n=e.topics)?n:[]).join(","),a="".concat(i,"/v1/events").concat(s?"?topics=".concat(encodeURIComponent(s)):""),c=new o(a),l=t=>{try{let n=JSON.parse(t.data);e.onEvent(n)}catch(t){var n;null==(n=e.onError)||n.call(e,t)}},d=["nexus.boot","nexus.shutdown","tab.created","tab.up","tab.down","tab.unhealthy","tab.restart","tab.halt","config.changed","workflow.approval.pending","workflow.approval.resolved","workflow.run.started","workflow.run.node-started","workflow.run.node-skipped","workflow.run.node-done","workflow.run.completed","workflow.run.failed","hitl.banner.show","hitl.banner.cancel","intent-prediction.ranking"],v=e.kinds?[...new Set([...d,...e.kinds])]:d;for(let e of(c.addEventListener("message",l),v))c.addEventListener(e,l);return c.addEventListener("error",()=>{var t;try{(0,r.cY)("nexus.sse.error",{url:a,readyState:c.readyState,connectionState:0===c.readyState?"reconnecting":2===c.readyState?"closed":"open"})}catch(e){}null==(t=e.onError)||t.call(e,Error("SSE error"))}),()=>{try{c.close()}catch(e){}}},subscribeLogs:(e,t)=>{var n;let o=null!=(n=t.EventSourceImpl)?n:globalThis.EventSource;if(!o)throw Error("EventSource not available \xb7 pass EventSourceImpl");let s="".concat(i,"/v1/nexus/tabs/").concat(encodeURIComponent(e),"/logs?stream=1"),a=new o(s),c=e=>{try{let n=JSON.parse(e.data);t.onLine(n)}catch(e){var n;null==(n=t.onError)||n.call(t,e)}};return a.addEventListener("message",c),a.addEventListener("log",c),a.addEventListener("error",()=>{var e;try{(0,r.cY)("nexus.sse.error",{url:s,readyState:a.readyState,connectionState:0===a.readyState?"reconnecting":2===a.readyState?"closed":"open"})}catch(e){}null==(e=t.onError)||e.call(t,Error("SSE error"))}),()=>{try{a.close()}catch(e){}}}}}}}]);