@xopcai/xopc 0.0.176 → 0.0.178

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 (238) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-DsFM1upC.js → activity-store-BzGX__8I.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DvdMLOga.js → agent-avatar-dicebear-BzxntcaZ.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-DC9F12Kw.js +2 -0
  6. package/dist/gateway/static/root/assets/{api-BdPLCCBm.js → api-hi6f2Xtp.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-DMLDOHul.js → app-management-settings-panel-fTY1F7ac.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-DbI9foFR.js → appearance-settings-BZ-IxQfB.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-5bKr05Fa.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-Dfdxuwvb.js → archive-plugin-ZSLLG8wB.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-Dn3RlnYD.js → attachment-load-D4YktqIF.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automation-suggestion-card-Bc0Y7A9u.js → automation-suggestion-card-B7mxFRtf.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-page-Dg6dmt5g.js +6 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-0XtB-xC0.js → binary-plugins-BIkPxfxj.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-C4fXWbEE.js → block-editor-Q3v_YQom.js} +6 -6
  16. package/dist/gateway/static/root/assets/{browser-settings-page-lC86-drr.js → browser-settings-page-BHoo6Rpq.js} +4 -4
  17. package/dist/gateway/static/root/assets/{browser-workflow-inputs-CZmzNymN.js → browser-workflow-inputs-M5lTEW1I.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-workflows-page-CBYM9HqG.js → browser-workflows-page-B3T1KYk4.js} +2 -2
  19. package/dist/gateway/static/root/assets/capabilities-settings-panel-BlsqN8Fu.js +7 -0
  20. package/dist/gateway/static/root/assets/{capability-presets-api-BiJxmmhW.js → capability-presets-api-DE09c0VB.js} +1 -1
  21. package/dist/gateway/static/root/assets/capability-presets-settings-panel-DJeT8_B4.js +1 -0
  22. package/dist/gateway/static/root/assets/{channel-recipient-api-BKTUZDp-.js → channel-recipient-api-CFR5FBfS.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-settings-C4VVjYEm.js +1 -0
  24. package/dist/gateway/static/root/assets/channels-status-swr-vdf8kB16.js +1 -0
  25. package/dist/gateway/static/root/assets/{connector-logo-Pr4RIKjj.js → connector-logo-B1mD-3pM.js} +1 -1
  26. package/dist/gateway/static/root/assets/connectors-page-DNcrDThX.js +2 -0
  27. package/dist/gateway/static/root/assets/desktop-pet-B1urphOZ.js +1 -0
  28. package/dist/gateway/static/root/assets/{desktop-pet-settings-CEQacUDF.js → desktop-pet-settings-DTL6J3EP.js} +1 -1
  29. package/dist/gateway/static/root/assets/{directory-picker-path-field-DWnxdZtc.js → directory-picker-path-field-BYQJ2XUS.js} +1 -1
  30. package/dist/gateway/static/root/assets/{dreaming-settings-D2e2w2Ho.js → dreaming-settings-BXcb8fwx.js} +3 -3
  31. package/dist/gateway/static/root/assets/{extension-debug-page-BLjTGbv3.js → extension-debug-page-O1Xu1r4Q.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-page-D2_UC6hy.js → extension-page-C2Jraq8l.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-settings-page-BsH6o_PX.js → extension-settings-page-DcXQDTpG.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-config-api-C-DkC6UJ.js → gateway-config-api-DmPIZrvg.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-settings-DEOGiimF.js → gateway-settings-DmObBx9b.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-startup-retry-BlSLh1TF.js → gateway-startup-retry-BZEkOdPm.js} +1 -1
  37. package/dist/gateway/static/root/assets/{goal-create-dialog-CSFcRE_N.js → goal-create-dialog-BRhmmBe9.js} +1 -1
  38. package/dist/gateway/static/root/assets/goal-detail-page-C1k7_s_O.js +4 -0
  39. package/dist/gateway/static/root/assets/{goals-config-api-CcdS9qek.js → goals-config-api-Fwu1wjEP.js} +1 -1
  40. package/dist/gateway/static/root/assets/{goals-page-BAcErdch.js → goals-page-hOu9uA3q.js} +2 -2
  41. package/dist/gateway/static/root/assets/{goals-settings-BY7crl0z.js → goals-settings-DY-JjvHz.js} +1 -1
  42. package/dist/gateway/static/root/assets/{heartbeat-settings-DtTkS0gs.js → heartbeat-settings-BtKu2NWT.js} +1 -1
  43. package/dist/gateway/static/root/assets/{image-generation-api-WGgkbwDZ.js → image-generation-api-05Gg8wsU.js} +1 -1
  44. package/dist/gateway/static/root/assets/{index-2UImfRDC.js → index-C0CGebQ1.js} +65 -65
  45. package/dist/gateway/static/root/assets/index-eqq25gvV.css +1 -0
  46. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-C5lpWQ3f.js → keyboard-shortcuts-settings-CfmDR9Sc.js} +1 -1
  47. package/dist/gateway/static/root/assets/local-app-workbench-page-EjsNT7nJ.js +2 -0
  48. package/dist/gateway/static/root/assets/{local-apps-page-b05wWvXG.js → local-apps-page-Df8BW1A_.js} +1 -1
  49. package/dist/gateway/static/root/assets/{locale-store-sToMfHX_.js → locale-store-CTwSy7yW.js} +1 -1
  50. package/dist/gateway/static/root/assets/{logs-page-cDE1jLJv.js → logs-page-Dswjlraa.js} +3 -3
  51. package/dist/gateway/static/root/assets/{markdown-split-0gPVst5y.js → markdown-split-B3FvKbaP.js} +1 -1
  52. package/dist/gateway/static/root/assets/{media-plugins-Rxyq_KTm.js → media-plugins-DsjrvvB6.js} +1 -1
  53. package/dist/gateway/static/root/assets/messages-DP6tPKk-.js +3 -0
  54. package/dist/gateway/static/root/assets/{notes-page-DRhNDl_Q.js → notes-page-tuzIwy3c.js} +1 -1
  55. package/dist/gateway/static/root/assets/notes-workbench-DSh3-hMY.js +4 -0
  56. package/dist/gateway/static/root/assets/{page-tabs-cOEOQqHh.js → page-tabs-ke9s4nYi.js} +1 -1
  57. package/dist/gateway/static/root/assets/{preview-open-alternatives-BopOLFvu.js → preview-open-alternatives-Cp1eI4S9.js} +1 -1
  58. package/dist/gateway/static/root/assets/{product-open-page-DWVPmmOq.js → product-open-page-dXQCMAtH.js} +1 -1
  59. package/dist/gateway/static/root/assets/project-detail-page-D0QPRHR_.js +1 -0
  60. package/dist/gateway/static/root/assets/projects-page-CI5Vz62F.js +1 -0
  61. package/dist/gateway/static/root/assets/remote-access-hub-S1jpzBS5.js +1 -0
  62. package/dist/gateway/static/root/assets/{save-bar-controls-BfZmKe1t.js → save-bar-controls-Bl30zjHc.js} +1 -1
  63. package/dist/gateway/static/root/assets/{schedule-field-Cpi4jCRV.js → schedule-field-DqhmXQKo.js} +1 -1
  64. package/dist/gateway/static/root/assets/{schema-form-OXFkcZQe.js → schema-form-DkUCy6vf.js} +1 -1
  65. package/dist/gateway/static/root/assets/sessions-page-CTm66k7h.js +1 -0
  66. package/dist/gateway/static/root/assets/settings-advanced-gate-CU52AUVD.js +1 -0
  67. package/dist/gateway/static/root/assets/{settings-form-section-BwqkZCHJ.js → settings-form-section-C6ZbNpdy.js} +1 -1
  68. package/dist/gateway/static/root/assets/{settings-loading-skeleton-BbqH_S3Y.js → settings-loading-skeleton-Bk58_cr7.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-page-BoxC-JSa.js → settings-page-k8iE_NdX.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-layout-Ddu2iGaW.js → settings-page-layout-DgFSya2e.js} +1 -1
  71. package/dist/gateway/static/root/assets/{setup-status-panel-z1Lwv0js.js → setup-status-panel-B_KDlyZA.js} +1 -1
  72. package/dist/gateway/static/root/assets/{share-preview-page-CVazOFjy.js → share-preview-page-CV7nL_J9.js} +1 -1
  73. package/dist/gateway/static/root/assets/shares-settings-DK6XK95e.js +1 -0
  74. package/dist/gateway/static/root/assets/skill-reload-api-Bvv_u4ii.js +1 -0
  75. package/dist/gateway/static/root/assets/skills-page-BGHvVbay.js +2 -0
  76. package/dist/gateway/static/root/assets/{skills-page.utils-DgyB1tSo.js → skills-page.utils-kahBIHg0.js} +1 -1
  77. package/dist/gateway/static/root/assets/{system-settings-panel-BoLSQL65.js → system-settings-panel-JV3-MG5F.js} +1 -1
  78. package/dist/gateway/static/root/assets/{theme-store-CBNcGOfj.js → theme-store-DFLyzoLO.js} +1 -1
  79. package/dist/gateway/static/root/assets/{time-picker-gochWrny.js → time-picker-XwpxdZFr.js} +1 -1
  80. package/dist/gateway/static/root/assets/{typed-models-lib-DvRnr7YB.js → typed-models-lib-60Aqo-UJ.js} +1 -1
  81. package/dist/gateway/static/root/assets/{use-channel-catalog-CA9BFVB7.js → use-channel-catalog-CnTkHDnw.js} +1 -1
  82. package/dist/gateway/static/root/assets/user-context-page-DBCMk-Vn.js +1 -0
  83. package/dist/gateway/static/root/assets/{voice-api-key-field-v8tgylEZ.js → voice-api-key-field-CNa8qUgS.js} +1 -1
  84. package/dist/gateway/static/root/assets/work-discovery-page-C1UIdsCl.js +1 -0
  85. package/dist/gateway/static/root/assets/work-item-detail-page-DEAQepB8.js +1 -0
  86. package/dist/gateway/static/root/assets/work-page-D5qYmCTq.js +3 -0
  87. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CC3cJn5k.js → workflow-run-setup-panel-yV_x595t.js} +2 -2
  88. package/dist/gateway/static/root/assets/workflows-page-yrK17ZZ5.js +11 -0
  89. package/dist/gateway/static/root/index.html +7 -7
  90. package/dist/package.js +1 -1
  91. package/dist/src/agent/embedded/model-runtime.js +3 -0
  92. package/dist/src/agent/embedded/run-for-session.js +18 -5
  93. package/dist/src/agent/embedded/run-turn.js +6 -3
  94. package/dist/src/agent/embedded/types.d.ts +2 -0
  95. package/dist/src/automations/service/automation-service.d.ts +3 -0
  96. package/dist/src/automations/service/automation-service.js +37 -7
  97. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  98. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  99. package/dist/src/cli/commands/update.js +1 -1
  100. package/dist/src/connectors/composio-sessions.js +1 -1
  101. package/dist/src/gateway/hono/routes/home.d.ts +18 -2
  102. package/dist/src/gateway/hono/routes/home.js +19 -0
  103. package/dist/src/gateway/hono/routes/index.js +2 -2
  104. package/dist/src/gateway/hono/routes/local-apps.js +1 -1
  105. package/dist/src/gateway/hono/routes/proactive.d.ts +4 -0
  106. package/dist/src/gateway/hono/routes/proactive.js +157 -0
  107. package/dist/src/gateway/hono/routes/projects.js +2 -2
  108. package/dist/src/gateway/hono/routes/update.js +2 -2
  109. package/dist/src/gateway/index.js +1 -1
  110. package/dist/src/gateway/run-loop.js +1 -1
  111. package/dist/src/gateway/service.d.ts +10 -1
  112. package/dist/src/gateway/service.js +36 -36
  113. package/dist/src/infra/gateway-processes.js +1 -1
  114. package/dist/src/infra/update-restart.js +1 -1
  115. package/dist/src/infra/update-runner.js +2 -2
  116. package/dist/src/infra/update-startup.js +1 -1
  117. package/dist/src/mcp/channel-bridge.js +1 -1
  118. package/dist/src/mobile/notification-service.d.ts +1 -0
  119. package/dist/src/mobile/notification-service.js +38 -18
  120. package/dist/src/mobile/notification-types.d.ts +2 -2
  121. package/dist/src/proactive/events/envelope.d.ts +2 -0
  122. package/dist/src/proactive/events/envelope.js +54 -0
  123. package/dist/src/proactive/events/publisher.d.ts +4 -0
  124. package/dist/src/proactive/events/repository.d.ts +9 -0
  125. package/dist/src/proactive/events/repository.js +62 -0
  126. package/dist/src/proactive/events/types.d.ts +44 -0
  127. package/dist/src/proactive/events/types.js +15 -0
  128. package/dist/src/proactive/execution/agent-executor.d.ts +16 -0
  129. package/dist/src/proactive/execution/agent-executor.js +104 -0
  130. package/dist/src/proactive/execution/context.d.ts +31 -0
  131. package/dist/src/proactive/execution/context.js +72 -0
  132. package/dist/src/proactive/execution/insight.d.ts +4 -0
  133. package/dist/src/proactive/execution/insight.js +74 -0
  134. package/dist/src/proactive/execution/repository.d.ts +23 -0
  135. package/dist/src/proactive/execution/repository.js +122 -0
  136. package/dist/src/proactive/execution/types.d.ts +54 -0
  137. package/dist/src/proactive/execution/types.js +1 -0
  138. package/dist/src/proactive/execution/worker.d.ts +15 -0
  139. package/dist/src/proactive/execution/worker.js +96 -0
  140. package/dist/src/proactive/inbox/repository.d.ts +24 -0
  141. package/dist/src/proactive/inbox/repository.js +117 -0
  142. package/dist/src/proactive/inbox/service.d.ts +17 -0
  143. package/dist/src/proactive/inbox/service.js +22 -0
  144. package/dist/src/proactive/inbox/types.d.ts +38 -0
  145. package/dist/src/proactive/inbox/types.js +1 -0
  146. package/dist/src/proactive/inbox/worker.d.ts +12 -0
  147. package/dist/src/proactive/inbox/worker.js +56 -0
  148. package/dist/src/proactive/index.d.ts +17 -0
  149. package/dist/src/proactive/index.js +11 -0
  150. package/dist/src/proactive/routing/batch-repository.d.ts +27 -0
  151. package/dist/src/proactive/routing/batch-repository.js +56 -0
  152. package/dist/src/proactive/routing/matcher.d.ts +5 -0
  153. package/dist/src/proactive/routing/matcher.js +56 -0
  154. package/dist/src/proactive/routing/types.d.ts +44 -0
  155. package/dist/src/proactive/routing/types.js +1 -0
  156. package/dist/src/proactive/scenarios/prompt-composer.d.ts +14 -0
  157. package/dist/src/proactive/scenarios/prompt-composer.js +24 -0
  158. package/dist/src/proactive/scenarios/repository.d.ts +23 -0
  159. package/dist/src/proactive/scenarios/repository.js +162 -0
  160. package/dist/src/proactive/scenarios/service.d.ts +15 -0
  161. package/dist/src/proactive/scenarios/service.js +26 -0
  162. package/dist/src/proactive/scenarios/types.d.ts +36 -0
  163. package/dist/src/proactive/scenarios/types.js +1 -0
  164. package/dist/src/proactive/service.d.ts +18 -0
  165. package/dist/src/proactive/service.js +61 -0
  166. package/dist/src/projects/project-service.d.ts +3 -1
  167. package/dist/src/projects/project-service.js +62 -32
  168. package/dist/src/providers/provider-auth-service.js +3 -0
  169. package/dist/src/providers/register-bundled-oauth-flows.d.ts +2 -0
  170. package/dist/src/providers/register-bundled-oauth-flows.js +16 -0
  171. package/dist/src/session/store.d.ts +2 -0
  172. package/dist/src/session/store.js +30 -0
  173. package/dist/src/storage/sqlite/migrations/068_proactive_event_spine.sql +71 -0
  174. package/dist/src/storage/sqlite/migrations/069_proactive_scenario_control.sql +69 -0
  175. package/dist/src/storage/sqlite/migrations/070_proactive_execution.sql +55 -0
  176. package/dist/src/storage/sqlite/migrations/071_proactive_inbox.sql +45 -0
  177. package/dist/src/storage/sqlite/migrations/072_proactive_judgments.sql +14 -0
  178. package/dist/src/storage/sqlite/migrations/073_enable_default_proactive_scenarios.sql +13 -0
  179. package/dist/src/storage/sqlite/migrations/074_deduplicate_blocked_work_routing.sql +5 -0
  180. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  181. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  182. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  183. package/dist/src/storage/sqlite/schema.js +1 -1
  184. package/dist/src/work-discovery/thread-service.d.ts +1 -3
  185. package/dist/src/work-discovery/thread-service.js +13 -25
  186. package/dist/src/work-items/work-item-service.d.ts +3 -1
  187. package/dist/src/work-items/work-item-service.js +67 -36
  188. package/package.json +3 -11
  189. package/dist/gateway/static/root/assets/agents-BVjlpbeZ.js +0 -2
  190. package/dist/gateway/static/root/assets/api-Bop4IQRW.js +0 -1
  191. package/dist/gateway/static/root/assets/apps-page-njqxLWYD.js +0 -1
  192. package/dist/gateway/static/root/assets/automations-page-D-eweHZJ.js +0 -6
  193. package/dist/gateway/static/root/assets/capabilities-settings-panel-6tYNfHqJ.js +0 -7
  194. package/dist/gateway/static/root/assets/capability-presets-settings-panel-Co-ymbd9.js +0 -1
  195. package/dist/gateway/static/root/assets/channels-settings-D46eVjaQ.js +0 -1
  196. package/dist/gateway/static/root/assets/channels-status-swr-BMRAO4zZ.js +0 -1
  197. package/dist/gateway/static/root/assets/connectors-page-Dw1eYbRi.js +0 -2
  198. package/dist/gateway/static/root/assets/copy-VueTIC2x.js +0 -1
  199. package/dist/gateway/static/root/assets/desktop-pet-B8cZuQUt.js +0 -1
  200. package/dist/gateway/static/root/assets/focus-detail-page-BBXUtxRB.js +0 -1
  201. package/dist/gateway/static/root/assets/goal-detail-page-VjRArfAJ.js +0 -4
  202. package/dist/gateway/static/root/assets/index-CS9sVShT.css +0 -1
  203. package/dist/gateway/static/root/assets/local-app-workbench-page-Cl0fcPL4.js +0 -2
  204. package/dist/gateway/static/root/assets/messages-CarlxqXV.js +0 -3
  205. package/dist/gateway/static/root/assets/notes-workbench-BKNBk0Uf.js +0 -4
  206. package/dist/gateway/static/root/assets/project-detail-page-BhjEXNQW.js +0 -1
  207. package/dist/gateway/static/root/assets/projects-page-B80e69PH.js +0 -1
  208. package/dist/gateway/static/root/assets/remote-access-hub-CwdVob6H.js +0 -1
  209. package/dist/gateway/static/root/assets/sessions-page-BGt3Asj6.js +0 -1
  210. package/dist/gateway/static/root/assets/settings-advanced-gate-BnTdM9Nn.js +0 -1
  211. package/dist/gateway/static/root/assets/shares-settings-C4lXuyQj.js +0 -1
  212. package/dist/gateway/static/root/assets/skill-reload-api-DSuIDkeI.js +0 -1
  213. package/dist/gateway/static/root/assets/skills-page-xgZczqVe.js +0 -2
  214. package/dist/gateway/static/root/assets/user-context-page-CEfIy4WZ.js +0 -1
  215. package/dist/gateway/static/root/assets/work-discovery-page-B-3MClaf.js +0 -1
  216. package/dist/gateway/static/root/assets/work-item-detail-page-CEsFEdax.js +0 -1
  217. package/dist/gateway/static/root/assets/work-page-CT9AHnq6.js +0 -3
  218. package/dist/gateway/static/root/assets/workflows-page-C-1-_Zp1.js +0 -11
  219. package/dist/src/focuses/candidate-repository.d.ts +0 -15
  220. package/dist/src/focuses/candidate-repository.js +0 -91
  221. package/dist/src/focuses/index.d.ts +0 -7
  222. package/dist/src/focuses/index.js +0 -7
  223. package/dist/src/focuses/insight-repository.d.ts +0 -22
  224. package/dist/src/focuses/insight-repository.js +0 -77
  225. package/dist/src/focuses/prompts.d.ts +0 -2
  226. package/dist/src/focuses/prompts.js +0 -18
  227. package/dist/src/focuses/reconciler.d.ts +0 -5
  228. package/dist/src/focuses/reconciler.js +0 -26
  229. package/dist/src/focuses/repository.d.ts +0 -61
  230. package/dist/src/focuses/repository.js +0 -214
  231. package/dist/src/focuses/run-processor.d.ts +0 -18
  232. package/dist/src/focuses/run-processor.js +0 -162
  233. package/dist/src/focuses/service.d.ts +0 -42
  234. package/dist/src/focuses/service.js +0 -241
  235. package/dist/src/focuses/types.d.ts +0 -89
  236. package/dist/src/gateway/hono/routes/focuses.d.ts +0 -3
  237. package/dist/src/gateway/hono/routes/focuses.js +0 -319
  238. /package/dist/src/{focuses/types.js → proactive/events/publisher.js} +0 -0
@@ -1,4 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-C4fXWbEE.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-2UImfRDC.js","assets/preload-helper-zJ_50EbN.js","assets/Combination-14nmIgxH.js","assets/vendor-react-BOUWij0V.js","assets/dist-CxGUk8J-.js","assets/dist-C230izr8.js","assets/chunk-KS7C4IRE-BMhrPKJC.js","assets/vendor-swr-BIWyz7Rc.js","assets/createLucideIcon-DPHK1VkS.js","assets/check-DUBLcKHA.js","assets/circle-alert-BEjgurr2.js","assets/middleware-Pd0e8Igk.js","assets/locale-store-sToMfHX_.js","assets/messages-CarlxqXV.js","assets/cn-JdwAhgNB.js","assets/schemas-DgQq6Z5S.js","assets/product-delivery-BTRT9kCS.js","assets/config-reload-event-Bjh2zoKp.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/gateway-startup-retry-BlSLh1TF.js","assets/activity-store-DsFM1upC.js","assets/theme-store-CBNcGOfj.js","assets/index-CS9sVShT.css","assets/vendor-codemirror--gTq3YAI.js","assets/with-selector-aYPsXwdl.js","assets/block-editor-D4ZIVQbk.css","assets/markdown-editor-BvUebh3C.js","assets/code-editor-D4_k-6QN.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{l as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-CarlxqXV.js";import{l as c,n as l}from"./locale-store-sToMfHX_.js";import{i as u}from"./theme-store-CBNcGOfj.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{$c as f,$n as p,Bo as m,Bu as h,Cc as g,Ci as _,Cl as v,Cr as y,Ei as b,Er as x,Eu as S,Fc as C,Go as w,Ho as T,Ic as E,Iu as D,Js as O,Ks as k,Lc as A,Lu as j,Nc as M,Ns as N,Nt as P,Pu as F,Si as I,Ti as ee,To as te,U as ne,Uo as re,Vc as L,Vo as R,Wl as ie,Wo as z,Yc as ae,_ as oe,_r as se,ac as B,ar as V,bl as H,br as U,cr as W,dr as G,ec as K,er as ce,fr as le,gc as ue,gl as de,gr as fe,hc as pe,hr as me,is as he,iu as ge,jc as _e,lr as q,mr as ve,nl as J,ns as ye,oc as be,or as xe,pr as Se,ql as Ce,qo as we,qs as Te,rc as Y,sr as Ee,tr as De,tu as Oe,ur as ke,vr as Ae,wi as je,wl as Me,wr as Ne,xi as X,xl as Pe,xr as Fe,yr as Ie,zc as Le,zl as Re,zo as ze}from"./index-2UImfRDC.js";import{t as Be}from"./automation-suggestion-card-Bc0Y7A9u.js";var Z=n(),Q=e(t(),1),$=r(),Ve=(0,Q.createContext)(null);function He(){let e=(0,Z.c)(1),t=(0,Q.useContext)(Ve);if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={openImage:Ue},e[0]=t):t=e[0],t}return t}function Ue(){}function We(e){let t=(0,Z.c)(22),{children:n,closeLabel:r}=e,i=r===void 0?`Close`:r,[a,s]=(0,Q.useState)(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(e,t)=>{s({src:e,alt:t})},t[0]=c):c=t[0];let l=c,u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u={openImage:l},t[1]=u):u=t[1];let d=u,f=a!==null,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>{e||s(null)},t[2]=p):p=t[2];let h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(re,{className:`fixed inset-0 z-[70] bg-scrim/90 backdrop-blur-sm`}),t[3]=h):h=t[3];let g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=o(`fixed inset-0 z-[71] flex items-center justify-center p-4 outline-none`,`data-[state=open]:animate-in data-[state=closed]:animate-out`),t[4]=g):g=t[4];let _=a?.alt||`Image preview`,v;t[5]===_?v=t[6]:(v=(0,$.jsx)(w,{className:`sr-only`,children:_}),t[5]=_,t[6]=v);let y;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(N,{className:`size-5`,"aria-hidden":!0}),t[7]=y):y=t[7];let b;t[8]===i?b=t[9]:(b=(0,$.jsx)(m,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":i,className:`absolute right-4 top-4 z-10 rounded-lg bg-surface-panel/80 p-2 text-fg-muted backdrop-blur transition-colors hover:bg-surface-hover hover:text-fg`,children:y})}),t[8]=i,t[9]=b);let x;t[10]===a?x=t[11]:(x=a?(0,$.jsx)(`img`,{src:a.src,alt:a.alt??``,className:`max-h-[min(90vh,900px)] max-w-[min(95vw,1200px)] rounded-lg object-contain shadow-lg`}):null,t[10]=a,t[11]=x);let S;t[12]!==b||t[13]!==x||t[14]!==v?(S=(0,$.jsxs)(z,{children:[h,(0,$.jsxs)(R,{className:g,"aria-describedby":void 0,children:[v,b,x]})]}),t[12]=b,t[13]=x,t[14]=v,t[15]=S):S=t[15];let C;t[16]!==S||t[17]!==f?(C=(0,$.jsx)(ze,{open:f,onOpenChange:p,children:S}),t[16]=S,t[17]=f,t[18]=C):C=t[18];let T;return t[19]!==n||t[20]!==C?(T=(0,$.jsxs)(Ve.Provider,{value:d,children:[n,C]}),t[19]=n,t[20]=C,t[21]=T):T=t[21],T}function Ge(e){let t=(0,Z.c)(15),{noteId:n,attachmentId:r,className:i}=e,[a,s]=(0,Q.useState)(!1),c;t[0]!==r||t[1]!==n?(c=x(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c;if(a){let e;t[3]===i?e=t[4]:(e=o(`flex size-12 shrink-0 items-center justify-center rounded-lg border border-edge-subtle bg-surface-hover text-fg-muted`,i),t[3]=i,t[4]=e);let n;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(v,{className:`size-4`}),t[5]=n):n=t[5];let r;return t[6]===e?r=t[7]:(r=(0,$.jsx)(`div`,{className:e,"aria-hidden":!0,children:n}),t[6]=e,t[7]=r),r}let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>s(!0),t[8]=u):u=t[8];let d;t[9]===i?d=t[10]:(d=o(`size-12 shrink-0 rounded-lg border border-edge-subtle bg-surface-hover object-cover`,i),t[9]=i,t[10]=d);let f;return t[11]!==n||t[12]!==l||t[13]!==d?(f=(0,$.jsx)(Ne,{src:l,expectedNoteId:n,alt:``,loading:`lazy`,draggable:!1,onLoadFailed:u,className:d}),t[11]=n,t[12]=l,t[13]=d,t[14]=f):f=t[14],f}var Ke=6e4,qe=36e5,Je=864e5;function Ye(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function Xe(e,t,n){let r=t-e;if(r<Ke)return n.justNow;if(r<qe){let e=Math.floor(r/Ke);return n.minutesAgo.replace(`{{n}}`,String(e))}let i=Ye(t);if(e>=i)return n.today+` `+new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});if(e>=i-Je)return n.yesterday+` `+new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});if(r<7*Je){let e=Math.floor(r/Je);return n.daysAgo.replace(`{{n}}`,String(e))}return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Ze(e,t,n){let r=Ye(t);if(e>=r)return n.today;if(e>=r-Je)return n.yesterday;let i=new Date(e),a=new Date(t);return i.getFullYear()===a.getFullYear()?i.toLocaleDateString(void 0,{month:`long`,day:`numeric`}):i.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function Qe(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function $e(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${String(n).padStart(2,`0`)}`}function et(e){let t=(0,Z.c)(38),{noteId:n,attachmentId:r,durationSec:i,className:a}=e,{playing:s,loading:c,currentTime:l,duration:u,noteId:d,attachmentId:f}=De(),p=De(nt),m=d===n&&f===r,h=m&&s,g=m&&c,_=m?l:0,v=m&&u>0?u:i??0,y=v>0?Math.min(_/v*100,100):0,b;t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==p?(b=e=>{e.stopPropagation(),p(n,r,i)},t[0]=r,t[1]=i,t[2]=n,t[3]=p,t[4]=b):b=t[4];let x=b,S;t[5]!==r||t[6]!==i||t[7]!==n||t[8]!==p?(S=e=>{(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),p(n,r,i))},t[5]=r,t[6]=i,t[7]=n,t[8]=p,t[9]=S):S=t[9];let C=S,w;t[10]===a?w=t[11]:(w=o(`flex items-center gap-2`,a),t[10]=a,t[11]=w);let T=h?`bg-accent text-white`:`bg-accent/10 text-accent hover:bg-accent/20`,E;t[12]===T?E=t[13]:(E=o(`flex size-7 shrink-0 items-center justify-center rounded-full transition-colors`,T),t[12]=T,t[13]=E);let D=h?`Pause`:`Play`,O;t[14]!==g||t[15]!==h?(O=g?(0,$.jsx)(J,{className:`size-3.5 animate-spin`}):h?(0,$.jsx)(Le,{className:`size-3.5`}):(0,$.jsx)(M,{className:`size-3.5 ml-0.5`}),t[14]=g,t[15]=h,t[16]=O):O=t[16];let k;t[17]!==x||t[18]!==C||t[19]!==E||t[20]!==D||t[21]!==O?(k=(0,$.jsx)(`button`,{type:`button`,onClick:x,onKeyDown:C,className:E,"aria-label":D,children:O}),t[17]=x,t[18]=C,t[19]=E,t[20]=D,t[21]=O,t[22]=k):k=t[22];let A=`${y}%`,j;t[23]===A?j=t[24]:(j=(0,$.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-accent/10`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-200 ease-linear`,style:{width:A}})}),t[23]=A,t[24]=j);let N;t[25]!==v||t[26]!==m||t[27]!==_?(N=$e(m&&_>0?_:v),t[25]=v,t[26]=m,t[27]=_,t[28]=N):N=t[28];let P;t[29]===N?P=t[30]:(P=(0,$.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-muted`,children:N}),t[29]=N,t[30]=P);let F;t[31]!==j||t[32]!==P?(F=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[j,P]}),t[31]=j,t[32]=P,t[33]=F):F=t[33];let I;return t[34]!==F||t[35]!==w||t[36]!==k?(I=(0,$.jsxs)(`div`,{className:w,onClick:tt,children:[k,F]}),t[34]=F,t[35]=w,t[36]=k,t[37]=I):I=t[37],I}function tt(e){return e.stopPropagation()}function nt(e){return e.toggle}function rt(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function it(e){let t=(0,Z.c)(80),{note:n,selected:r,onPress:i,onPin:a,onArchive:s,onDelete:c,labels:l,timeLabels:u}=e,d=r===void 0?!1:r,f;t[0]!==l||t[1]!==n?(f=rt(n,l),t[0]=l,t[1]=n,t[2]=f):f=t[2];let p=f,m=!n.snippet?.trim(),[h]=(0,Q.useState)(ct),g;t[3]!==n.createdAt||t[4]!==h||t[5]!==u?(g=Xe(n.createdAt,h,u),t[3]=n.createdAt,t[4]=h,t[5]=u,t[6]=g):g=t[6];let v=g,y,x;t[7]!==n.id||t[8]!==i?(y=()=>i(n.id),x=e=>{(e.key===`Enter`||e.key===` `)&&i(n.id)},t[7]=n.id,t[8]=i,t[9]=y,t[10]=x):(y=t[9],x=t[10]);let S=d?`bg-surface-active hover:bg-surface-active`:`bg-surface-base hover:bg-surface-hover`,w;t[11]===S?w=t[12]:(w=o(`group relative flex cursor-pointer flex-col gap-2 rounded-lg px-3 py-2.5`,`transition-colors duration-150 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,S),t[11]=S,t[12]=w);let T=d?`true`:void 0,D;t[13]!==n.coverAttachmentId||t[14]!==n.id||t[15]!==n.kind||t[16]!==n.voiceAttachmentId||t[17]!==n.voiceDurationSec?(D=n.coverAttachmentId?(0,$.jsx)(Ge,{noteId:n.id,attachmentId:n.coverAttachmentId}):n.kind===`voice`&&n.voiceAttachmentId?(0,$.jsx)(et,{noteId:n.id,attachmentId:n.voiceAttachmentId,durationSec:n.voiceDurationSec,className:`mt-0.5 w-28 shrink-0`}):null,t[13]=n.coverAttachmentId,t[14]=n.id,t[15]=n.kind,t[16]=n.voiceAttachmentId,t[17]=n.voiceDurationSec,t[18]=D):D=t[18];let O;t[19]===n.title?O=t[20]:(O=n.title&&(0,$.jsx)(`h3`,{className:`mb-0.5 truncate text-sm font-semibold text-fg`,children:n.title}),t[19]=n.title,t[20]=O);let A=n.title?`text-fg-muted`:m?`italic text-fg-muted`:`text-fg`,M;t[21]===A?M=t[22]:(M=o(`truncate text-sm leading-5`,A),t[21]=A,t[22]=M);let N;t[23]!==p||t[24]!==M?(N=(0,$.jsx)(`p`,{className:M,children:p}),t[23]=p,t[24]=M,t[25]=N):N=t[25];let P;t[26]!==O||t[27]!==N?(P=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[O,N]}),t[26]=O,t[27]=N,t[28]=P):P=t[28];let F;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(b,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:st,className:`shrink-0 rounded-md p-1 text-fg-muted opacity-0 transition-opacity group-hover:opacity-100 hover:bg-surface-panel focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":`Actions`,children:(0,$.jsx)(Ce,{className:`size-4`})})}),t[29]=F):F=t[29];let te;t[30]!==n.id||t[31]!==n.pinned||t[32]!==a?(te=()=>a(n.id,!n.pinned),t[30]=n.id,t[31]=n.pinned,t[32]=a,t[33]=te):te=t[33];let ne;t[34]===n.pinned?ne=t[35]:(ne=n.pinned?(0,$.jsx)(C,{className:`size-4`}):(0,$.jsx)(E,{className:`size-4`}),t[34]=n.pinned,t[35]=ne);let re=n.pinned?l.unpin:l.pin,L;t[36]!==te||t[37]!==ne||t[38]!==re?(L=(0,$.jsxs)(I,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:te,children:[ne,re]}),t[36]=te,t[37]=ne,t[38]=re,t[39]=L):L=t[39];let R;t[40]!==n.id||t[41]!==s?(R=()=>s(n.id),t[40]=n.id,t[41]=s,t[42]=R):R=t[42];let ie;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(j,{className:`size-4`}),t[43]=ie):ie=t[43];let z;t[44]!==l.archive||t[45]!==R?(z=(0,$.jsxs)(I,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:R,children:[ie,l.archive]}),t[44]=l.archive,t[45]=R,t[46]=z):z=t[46];let ae;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(ee,{className:`my-1 h-px bg-edge-subtle`}),t[47]=ae):ae=t[47];let oe;t[48]!==n.id||t[49]!==c?(oe=()=>c(n.id),t[48]=n.id,t[49]=c,t[50]=oe):oe=t[50];let se;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(k,{className:`size-4`}),t[51]=se):se=t[51];let B;t[52]!==l.delete||t[53]!==oe?(B=(0,$.jsxs)(I,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-red-500 outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:oe,children:[se,l.delete]}),t[52]=l.delete,t[53]=oe,t[54]=B):B=t[54];let V;t[55]!==L||t[56]!==z||t[57]!==B?(V=(0,$.jsxs)(je,{children:[F,(0,$.jsx)(_,{children:(0,$.jsxs)(X,{className:`z-50 min-w-[140px] rounded-xl border border-edge bg-surface-panel p-1 shadow-lg`,sideOffset:4,align:`end`,onClick:ot,children:[L,z,ae,B]})})]}),t[55]=L,t[56]=z,t[57]=B,t[58]=V):V=t[58];let H;t[59]!==P||t[60]!==V||t[61]!==D?(H=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[D,P,V]}),t[59]=P,t[60]=V,t[61]=D,t[62]=H):H=t[62];let U;t[63]===n.pinned?U=t[64]:(U=n.pinned&&(0,$.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-accent/10 px-1.5 py-0.5 text-xs font-medium text-accent`,children:(0,$.jsx)(E,{className:`size-3`})}),t[63]=n.pinned,t[64]=U);let W;t[65]===n.tags?W=t[66]:(W=n.tags?.slice(0,2).map(at),t[65]=n.tags,t[66]=W);let G;t[67]===v?G=t[68]:(G=(0,$.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:v}),t[67]=v,t[68]=G);let K;t[69]!==U||t[70]!==W||t[71]!==G?(K=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[U,W,G]}),t[69]=U,t[70]=W,t[71]=G,t[72]=K):K=t[72];let ce;return t[73]!==H||t[74]!==K||t[75]!==y||t[76]!==x||t[77]!==w||t[78]!==T?(ce=(0,$.jsxs)(`article`,{role:`button`,tabIndex:0,onClick:y,onKeyDown:x,className:w,"aria-current":T,children:[H,K]}),t[73]=H,t[74]=K,t[75]=y,t[76]=x,t[77]=w,t[78]=T,t[79]=ce):ce=t[79],ce}function at(e){return(0,$.jsx)(`span`,{className:`max-w-24 truncate rounded-md bg-surface-hover px-1.5 py-0.5 text-xs text-fg-muted`,children:e},e)}function ot(e){return e.stopPropagation()}function st(e){return e.stopPropagation()}function ct(){return Date.now()}var lt={edit:A,ai_edit:be,sync:g,restore:D};function ut(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function dt({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let a=s(l(e=>e.language)).notes,c=a,{data:u}=d(e?[`note-history`,e]:null,()=>G(e)),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),g=(0,Q.useCallback)(async t=>{p(!0);try{await U(e,t),h(null),i()}catch{we({type:`error`,title:a.restoreFailed})}finally{p(!1)}},[e,a.restoreSuccess,a.restoreFailed,i]),_=Date.now();return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(Me,{className:`size-4`,"aria-hidden":!0}),a.history]}),(0,$.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg p-1 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,$.jsx)(N,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:u?.length?(0,$.jsx)(`ul`,{className:`divide-y divide-edge`,children:u.map(e=>{let r=lt[e.trigger]??A,i=t===e.timestamp,s=m===e.timestamp;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:o(`w-full px-4 py-3 text-left transition-colors`,i?`bg-accent/10`:`hover:bg-surface-hover`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(r,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:ut(e.trigger,a)}),(0,$.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:Xe(e.timestamp,_,c)})]}),e.snippet&&(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,$.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:s?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:a.restoreConfirm}),(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),g(e.timestamp)},disabled:f,className:`shrink-0 rounded-lg bg-accent px-3 py-1 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:opacity-50`,children:f?`...`:a.restore}),(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),h(null)},className:`shrink-0 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,children:`Cancel`})]}):(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),h(e.timestamp)},className:`rounded-lg bg-surface-hover px-3 py-1 text-xs font-medium text-fg transition-colors hover:bg-accent hover:text-on-accent`,children:a.restore})})]},e.timestamp)})}):(0,$.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:a.historyEmpty}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:a.historyEmptyDescription})]})})]})}function ft(e){let t=(0,Z.c)(10),{noteId:n,note:r,catalyzing:i,onCatalyze:c,onClose:u,noteThreads:p,openingChat:m,onOpenChat:h,onOpenNewChat:g}=e,_=s(l(yt)).notes,v=a(),y=r?.aiDeep?.catalysis,b=y?.report??null,x;t[0]===n?x=t[1]:(x=n?[`note-agent-context-status`,n]:null,t[0]=n,t[1]=x);let S;t[2]===n?S=t[3]:(S=()=>q(n),t[2]=n,t[3]=S);let C;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(C={revalidateOnFocus:!1},t[4]=C):C=t[4];let{data:w,mutate:T,isLoading:E}=d(x,S,C),D;t[5]===n?D=t[6]:(D=async e=>{try{await Ie(n,e)}catch{}},t[5]=n,t[6]=D);let k=D,A;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(be,{className:`size-4 text-accent`,"aria-hidden":!0}),t[7]=A):A=t[7];let j;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(F,{className:`size-4 rotate-180`,"aria-hidden":!0}),t[8]=j):j=t[8];let M;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(f,{className:`size-4 text-accent`,"aria-hidden":!0}),t[9]=M):M=t[9],(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[A,(0,$.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:_.catalysisSectionTitle})]}),(0,$.jsx)(`button`,{type:`button`,onClick:u,"aria-label":_.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:j})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,$.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:_.catalysisSectionDescription}),w?(0,$.jsxs)(`section`,{className:`mb-4 rounded-xl bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:_.contextStatusTitle}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void T(()=>Ae(n),{revalidate:!1}),disabled:E,className:`rounded-md px-1.5 py-0.5 text-[11px] font-medium text-accent transition-colors hover:bg-accent/10 disabled:cursor-not-allowed disabled:opacity-50`,children:_.contextRebuild}),(0,$.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5 text-[11px] font-medium`,w.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:w.status===`partial`?`bg-amber-500/10 text-amber-600 dark:text-amber-300`:`bg-red-500/10 text-red-600 dark:text-red-300`),children:w.status})]}),(0,$.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:_.contextStatusDetail.replace(`{{attachments}}`,String(w.attachments.length)).replace(`{{tokens}}`,String(w.tokenEstimate??0))}),w.attachments.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:w.attachments.slice(0,5).map(vt)}):null]}):null,(0,$.jsx)(`button`,{type:`button`,onClick:c,disabled:i,className:`w-full rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:i?_.processing:b?_.recatalyze:_.catalyzeAction}),b?(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:_.valueHypothesis}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:b.valueHypothesis})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:_.targetUsers}),(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:b.targetUsers.slice(0,5).map(_t)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:_.keyQuestions}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:b.keyQuestions.slice(0,3).map(gt)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:_.mvpPathLabel}),(0,$.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:b.mvpPath.slice(0,3).map(ht)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:_.risks}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:b.risks.slice(0,3).map(mt)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:_.nextActions}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:b.nextActions.slice(0,4).map(pt)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:_.confidenceLabel.replace(`{{percent}}`,String(Math.round(b.confidence*100)))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void k(`helpful`),className:o(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,y?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":_.feedbackHelpfulAria,children:(0,$.jsx)(Te,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void k(`not_helpful`),className:o(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,y?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":_.feedbackNotHelpfulAria,children:(0,$.jsx)(O,{className:`size-3.5`,"aria-hidden":!0})})]})]})]}):(0,$.jsx)(`div`,{className:`mt-4 rounded-lg border border-dashed border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:_.noCatalysisReportHint}),(0,$.jsxs)(`section`,{className:`mt-6 rounded-xl bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[M,_.relatedThreadsTitle]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:_.relatedThreadsDescription})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:h,disabled:m,className:`rounded-lg border border-edge px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,children:m?_.openingChat:_.openThread}),(0,$.jsx)(`button`,{type:`button`,onClick:g,disabled:m,className:`rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:_.newThread})]})]}),p.length>0?(0,$.jsx)(`div`,{className:`space-y-2`,children:p.slice(0,5).map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>v(`/chat/${encodeURIComponent(e.key)}`),className:`w-full rounded-lg border border-edge-subtle px-3 py-2 text-left transition-colors hover:bg-surface-hover`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||_.noteDiscussionFallback}),(0,$.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:_.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,$.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-5 text-center text-sm text-fg-muted`,children:_.noThreads})]})]})]})}function pt(e){return(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,$.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`)}function mt(e){return(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-fg-muted`}),(0,$.jsx)(`span`,{children:e})]},e)}function ht(e,t){return(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,$.jsx)(`span`,{children:e})]},e)}function gt(e){return(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-accent`}),(0,$.jsx)(`span`,{children:e})]},e)}function _t(e){return(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e)}function vt(e){return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,$.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId)}function yt(e){return e.language}var bt=()=>i(()=>import(`./block-editor-C4fXWbEE.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27])),xt=()=>i(()=>import(`./markdown-editor-BvUebh3C.js`).then(e=>e.n),__vite__mapDeps([28,1,3,25,5,29])),St=(0,Q.lazy)(()=>bt().then(e=>({default:e.BlockEditor}))),Ct=(0,Q.lazy)(()=>xt().then(e=>({default:e.MarkdownEditor})));function wt(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,$.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function Tt(e){let t=(0,Z.c)(14),{mode:n,onModeChange:r,labels:i}=e,a;t[0]===i.edit?a=t[1]:(a={id:`wysiwyg`,label:i.edit,Icon:Re},t[0]=i.edit,t[1]=a);let s;t[2]===i.source?s=t[3]:(s={id:`source`,label:i.source,Icon:Oe},t[2]=i.source,t[3]=s);let c;t[4]===i.preview?c=t[5]:(c={id:`preview`,label:i.preview,Icon:ie},t[4]=i.preview,t[5]=c);let l;t[6]!==a||t[7]!==s||t[8]!==c?(l=[a,s,c],t[6]=a,t[7]=s,t[8]=c,t[9]=l):l=t[9];let u=l,d;return t[10]!==n||t[11]!==u||t[12]!==r?(d=(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg border border-edge p-0.5`,children:u.map(e=>{let{id:t,label:i,Icon:a}=e;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),onMouseEnter:()=>{t===`wysiwyg`&&bt(),t===`source`&&xt()},onFocus:()=>{t===`wysiwyg`&&bt(),t===`source`&&xt()},className:o(`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium transition-colors`,n===t?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,$.jsx)(a,{className:`size-3.5`,"aria-hidden":!0}),i]},t)})}),t[10]=n,t[11]=u,t[12]=r,t[13]=d):d=t[13],d}function Et(e){let t=(0,Z.c)(15),{noteId:n,onBack:r,onSaved:i,showBackButton:a,backButtonClassName:o,clearHeaderOnCleanup:c,onOpenSearch:u,autoFocus:d,onAutoFocusConsumed:f}=e,p=a===void 0?!0:a,m=c===void 0?!0:c,h=d===void 0?!1:d,g=l(Dt),_;t[0]===g?_=t[1]:(_=s(g),t[0]=g,t[1]=_);let v=_.notes.lightboxClose,y;t[2]!==h||t[3]!==o||t[4]!==m||t[5]!==n||t[6]!==f||t[7]!==r||t[8]!==u||t[9]!==i||t[10]!==p?(y=(0,$.jsx)(Ot,{noteId:n,onBack:r,onSaved:i,showBackButton:p,backButtonClassName:o,clearHeaderOnCleanup:m,onOpenSearch:u,autoFocus:h,onAutoFocusConsumed:f}),t[2]=h,t[3]=o,t[4]=m,t[5]=n,t[6]=f,t[7]=r,t[8]=u,t[9]=i,t[10]=p,t[11]=y):y=t[11];let b;return t[12]!==v||t[13]!==y?(b=(0,$.jsx)(We,{closeLabel:v,children:y}),t[12]=v,t[13]=y,t[14]=b):b=t[14],b}function Dt(e){return e.language}function Ot({noteId:e,onBack:t,onSaved:n,showBackButton:r=!0,backButtonClassName:i,clearHeaderOnCleanup:c=!0,onOpenSearch:m,autoFocus:g=!1,onAutoFocusConsumed:_}){let v=l(e=>e.language),b=s(v).notes,x=s(v).automations.suggestions,S=a(),C=u(e=>e.resolved)===`dark`,{openImage:w}=He(),[T,E]=(0,Q.useState)(`wysiwyg`),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(``),[I,ee]=(0,Q.useState)(360),[re,L]=(0,Q.useState)(!1),[R,ie]=(0,Q.useState)(!1),[z,ae]=(0,Q.useState)(!1),se=(0,Q.useRef)(!1),B=(0,Q.useRef)(!1),H=(0,Q.useRef)(null),U=(0,Q.useRef)(null),G=(0,Q.useRef)(null),K=(0,Q.useRef)(null),de=(0,Q.useRef)(null),fe=(0,Q.useRef)(null),pe=(0,Q.useRef)(null),me=(0,Q.useRef)(null),he=(0,Q.useRef)(null),ge=te(e=>e.setPageHeader),_e=te(e=>e.clearPageHeader),{data:q,mutate:J}=d(e?[`note-detail`,e]:null,()=>W(e)),{data:ye=[],mutate:xe}=d(e?[`note-threads`,e]:null,()=>le(e),{revalidateOnFocus:!1}),Se=k!==null;(0,Q.useEffect)(()=>{if(!e)return;let t=t=>{t.detail?.noteId===e&&J()};return window.addEventListener(`note-updated`,t),()=>window.removeEventListener(`note-updated`,t)},[J,e]),(0,Q.useEffect)(()=>{se.current=!1,P(``),A(null),O(null),B.current=!1,he.current=null},[e]),(0,Q.useEffect)(()=>{!q||se.current||(P(q.title??``),se.current=!0)},[q]),(0,Q.useEffect)(()=>{if(!g||!q||Se||he.current===e)return;let t=window.requestAnimationFrame(()=>{me.current?.focus(),_?.()});return he.current=e,()=>window.cancelAnimationFrame(t)},[g,Se,q,e,_]);let Ce=q?new Date(q.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,Te=(0,Q.useMemo)(()=>r?(0,$.jsx)(`button`,{type:`button`,onClick:t,"aria-label":b.back,className:o(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,h,i),children:(0,$.jsx)(F,{className:`size-4`,"aria-hidden":!0})}):null,[i,b.back,t,r]),Y=(0,Q.useCallback)(t=>{P(t),e&&(K.current=t,U.current&&clearTimeout(U.current),U.current=setTimeout(async()=>{let t=K.current;if(K.current=null,t!==null){M(!0);try{await Fe(e,{title:t}),await J(),n?.()}catch{}finally{M(!1)}}},600))},[e,J,n]),Ee=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:o(`flex min-w-0 items-center gap-2`,h),children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:N||Ce||void 0,children:N||Ce}),j?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:b.saving}):null]}),[b.saving,j,Ce,N]),De=(0,Q.useCallback)(async(t=!1)=>{ae(!0);try{let n=await ve(e,{forceNew:t});await J(),await xe(),S(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){we({type:`error`,title:b.chatOpenFailedTitle,message:e instanceof Error?e.message:b.chatOpenFailedMessage})}finally{ae(!1)}},[J,xe,S,e,b.chatOpenFailedMessage,b.chatOpenFailedTitle]),Oe=(0,Q.useCallback)(async()=>{ie(!0);try{await V(e),await J()}catch(e){we({type:`error`,title:b.catalysisFailed,message:e instanceof Error?e.message:b.chatOpenFailedMessage})}finally{ie(!1)}},[J,e]),Ae=(0,Q.useCallback)(()=>{O(D===`breakdown`?null:`breakdown`),!q?.aiDeep?.catalysis?.report&&!R&&Oe()},[D,R,Oe,q?.aiDeep?.catalysis?.report]),je=(0,Q.useCallback)(()=>{let t=k?.markdown??G.current??q?.markdown??``,n=k?.title??N,r=p([n,t].filter(Boolean).join(`
3
-
4
- `));return{source:{type:`note`,id:e,title:n||b.titlePlaceholder},text:r,language:ce(r,v)}},[v,b.titlePlaceholder,q?.markdown,e,k,N]),Ne=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:o(`flex items-center gap-2`,h),children:[m?(0,$.jsx)(`button`,{type:`button`,onClick:m,"aria-label":b.searchDialogTitle,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(ue,{className:`size-4`,"aria-hidden":!0})}):null,(0,$.jsx)(ne,{input:je,labels:{read:b.readAloud,preparing:b.readAloudPreparing,pause:b.readAloudPause,resume:b.readAloudResume,retry:b.readAloudRetry},showLabel:!0}),(0,$.jsxs)(`button`,{type:`button`,onClick:Ae,disabled:R,"aria-label":b.catalysisSectionTitle,className:o(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50`,D===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,$.jsx)(be,{className:`size-3.5`,"aria-hidden":!0}),R?b.catalyzing:b.catalyzeButton]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>De(!1),disabled:z,className:o(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,`border border-edge text-fg-muted hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,$.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),z?b.openingChat:b.openChatButton]}),(0,$.jsx)(Tt,{mode:T,onModeChange:E,labels:{edit:b.modeEdit,source:b.modeSource,preview:b.modePreview}}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>O(D===`history`?null:`history`),"aria-label":b.history,className:o(`rounded-lg p-1.5 transition-colors`,D===`history`?`bg-accent/10 text-accent`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:(0,$.jsx)(Me,{className:`size-4`,"aria-hidden":!0})})]}),[R,Ae,De,T,b.history,b.modeEdit,b.modePreview,b.modeSource,z,D,m,b.searchDialogTitle,b.readAloud,b.readAloudPause,b.readAloudPreparing,b.readAloudResume,b.readAloudRetry,je]);(0,Q.useLayoutEffect)(()=>(ge({startExtra:Te,main:q?Ee:null,end:q?Ne:null}),()=>{c&&_e()}),[c,_e,Ne,Ee,Te,q,ge]);let X=(0,Q.useCallback)(t=>{e&&(G.current=t,H.current&&clearTimeout(H.current),H.current=setTimeout(async()=>{let t=G.current;if(G.current=null,t!==null){M(!0);try{await Fe(e,{markdown:t}),await J(),n?.()}catch(e){we({type:`error`,title:b.saveFailed,message:e instanceof Error?e.message:b.saveFailedHint})}finally{M(!1)}}},600))},[e,J,b.saveFailed,b.saveFailedHint,n]),Pe=(0,Q.useCallback)(t=>{ke(e,t.timestamp).then(e=>{e&&A(e)})},[e]),Ie=(0,Q.useCallback)(()=>{O(null),A(null)},[]),Le=(0,Q.useCallback)(()=>{O(null),A(null),J(),n?.()},[J,n]);if((0,Q.useEffect)(()=>()=>{H.current&&clearTimeout(H.current),U.current&&clearTimeout(U.current);let t=G.current,n=K.current;G.current=null,K.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&Fe(e,r)},[e]),q===void 0)return(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,$.jsx)(`div`,{className:`size-6 animate-spin rounded-full border-2 border-accent border-t-transparent`})});if(q===null)return(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:b.notFoundTitle}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:b.notFoundDescription}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg border border-edge px-3 py-1.5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:b.back})]});let Re=Se?k.title??``:N,ze=Se?k.markdown??``:q.markdown??``,Z=new Date(q.createdAt).getTime(),Ve=Number.isFinite(Z)&&Date.now()-Z<3600*1e3?(0,$.jsx)(Be,{title:x.noteCreatedTitle,description:x.noteCreatedDescription,prompt:x.noteCreatedPrompt,coverage:{eventType:`note.created`,source:`notes`,eventPayload:{noteId:e}},variant:`titleAction`,className:`ml-3 hidden max-w-[18rem] shrink-0 md:flex`}):null;return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 gap-3 p-4 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(oe,{eventType:`note.created`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,$.jsx)(oe,{eventType:`note.updated`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,$.jsx)(`div`,{ref:de,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:Se?(0,$.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,children:[Re&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:Re}),ze?(0,$.jsx)(y,{noteId:e,content:ze,className:`opacity-80`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:b.emptyPreview})]}):(0,$.jsxs)($.Fragment,{children:[T===`wysiwyg`&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,$.jsx)(`input`,{ref:me,type:`text`,value:N,onChange:e=>Y(e.target.value),onCompositionStart:()=>{B.current=!0},onCompositionEnd:()=>{B.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!B.current&&!t.isComposing&&(e.preventDefault(),(de.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:b.titlePlaceholder,className:`min-w-0 flex-1 border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`}),Ve]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(wt,{}),children:(0,$.jsx)(St,{initialContent:q.markdown??``,onChange:X,noteId:e},`wysiwyg-${e}`)})})]}),T===`source`&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,$.jsx)(`input`,{ref:me,type:`text`,value:N,onChange:e=>Y(e.target.value),placeholder:b.titlePlaceholder,className:`min-w-0 flex-1 border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`}),Ve]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(wt,{}),children:(0,$.jsx)(Ct,{initialContent:q.markdown??``,onChange:X,isDark:C},`source-${e}`)})})]}),T===`preview`&&(0,$.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&w(t.currentSrc||t.src,t.alt)},children:[N&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:N}),q.markdown?(0,$.jsx)(y,{noteId:e,content:q.markdown,className:`[&_img]:cursor-zoom-in`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:b.emptyPreview})]})]})})]}),(0,$.jsx)(`div`,{ref:fe,className:o(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!re&&`transition-[width] duration-300 ease-in-out`),style:{width:D?I:0},children:(0,$.jsxs)(`div`,{ref:pe,className:`flex min-h-0 flex-1 flex-col`,style:{width:I},children:[(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),L(!0);let n=e.clientX,r=I,i=e.pointerId,a=0,o=I,s=I,c=()=>{a=0,s=o,D&&fe.current?.style.setProperty(`width`,`${s}px`),pe.current?.style.setProperty(`width`,`${s}px`)},l=e=>{let t=r-(e.clientX-n);o=Math.max(280,Math.min(600,Math.round(t))),a===0&&(a=window.requestAnimationFrame(c))},u=()=>{a!==0&&(window.cancelAnimationFrame(a),c());try{t.releasePointerCapture(i)}catch{}L(!1),ee(s),window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),window.removeEventListener(`pointercancel`,u)};window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u),window.addEventListener(`pointercancel`,u)},className:o(`absolute left-0 top-0 z-10 h-full w-2 -translate-x-1/2 cursor-col-resize`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,re&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:D===`history`?(0,$.jsx)(dt,{noteId:e,activeTimestamp:k?.timestamp??null,onSelect:Pe,onClose:Ie,onRestored:Le}):D===`breakdown`?(0,$.jsx)(ft,{noteId:e,note:q??null,catalyzing:R,onCatalyze:Oe,onClose:()=>O(null),noteThreads:ye,openingChat:z,onOpenChat:()=>De(!1),onOpenNewChat:()=>De(!0)}):null})]})})]})}var kt=3e4;function At(){if(!(typeof MediaRecorder>`u`))return[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`].find(e=>MediaRecorder.isTypeSupported(e))}function jt({placeholder:e,sendLabel:t,onCapture:n,onImagePick:r,onVoiceCapture:i,recordingLabel:a=`Recording…`,imageDisabled:s=!1,voiceDisabled:c=!1}){let[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(0),[_,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(null),b=(0,Q.useRef)(null),x=(0,Q.useRef)(null),S=(0,Q.useRef)([]),C=(0,Q.useRef)(0),w=(0,Q.useRef)(null),T=(0,Q.useRef)(null),E=(0,Q.useCallback)(()=>{w.current&&=(clearInterval(w.current),null),T.current&&=(clearTimeout(T.current),null),x.current?.getTracks().forEach(e=>e.stop()),x.current=null,b.current=null,S.current=[],m(!1),g(0)},[]);(0,Q.useEffect)(()=>()=>E(),[E]);let D=(0,Q.useCallback)(async()=>{let e=b.current;if(!e||e.state!==`recording`)return;v(!0),await new Promise(t=>{e.addEventListener(`stop`,()=>t(),{once:!0}),e.stop()});let t=Math.max(1,Math.round((Date.now()-C.current)/1e3)),n=e.mimeType||At()||`audio/webm`,r=new Blob(S.current,{type:n});if(E(),r.size>0&&i){let e=n.includes(`mp4`)?`m4a`:n.includes(`ogg`)?`ogg`:`webm`,a=new File([r],`voice-${Date.now()}.${e}`,{type:n});try{await i(a,t)}finally{v(!1)}return}v(!1)},[E,i]),O=(0,Q.useCallback)(async()=>{if(!(!i||_||p)&&!(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`))try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=At(),n=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);x.current=e,b.current=n,S.current=[],C.current=Date.now(),n.ondataavailable=e=>{e.data.size>0&&S.current.push(e.data)},n.start(),m(!0),g(0),w.current=setInterval(()=>{g(Math.round((Date.now()-C.current)/1e3))},250),T.current=setTimeout(()=>{D()},kt)}catch{E()}},[E,i,p,D,_]),k=(0,Q.useCallback)(()=>{if(p){D();return}O()},[p,O,D]),A=(0,Q.useCallback)(async e=>{let t=l.trim();if(!(!t||d)){f(!0),u(``);try{await n(t,e)}catch{u(t)}finally{f(!1),y.current?.focus()}}},[l,d,n]),j=(0,Q.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),A()),e.key===`Enter`&&e.shiftKey&&(e.preventDefault(),A({navigate:!1}))},[A]),M=d||_;return(0,$.jsxs)(`div`,{className:o(`flex items-center gap-1.5 rounded-2xl border border-edge bg-surface-panel p-2 shadow-float dark:shadow-elevated`,`focus-within:border-accent focus-within:ring-1 focus-within:ring-accent`,p&&`border-danger ring-1 ring-danger/40`),children:[r&&(0,$.jsx)(`button`,{type:`button`,onClick:r,disabled:M||s||p,className:`shrink-0 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":`Image`,children:(0,$.jsx)(Pe,{className:`size-4`})}),i&&(0,$.jsx)(`button`,{type:`button`,onClick:k,disabled:M||c||d,className:o(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,p?`bg-danger-soft text-danger hover:bg-danger-soft`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-label":p?`Stop recording`:`Voice`,"aria-pressed":p,children:p?(0,$.jsx)(Y,{className:`size-4 fill-current`}):(0,$.jsx)(ae,{className:`size-4`})}),p?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate py-1.5 text-sm text-danger`,children:a.replace(`{{seconds}}`,String(h))}):(0,$.jsx)(`textarea`,{ref:y,value:l,onChange:e=>u(e.target.value),onKeyDown:j,placeholder:e,rows:1,disabled:M,className:`min-h-8 flex-1 resize-none bg-transparent py-1.5 text-sm leading-5 text-fg placeholder:text-fg-muted focus:outline-none disabled:opacity-60`,style:{fieldSizing:`content`}}),(0,$.jsx)(`button`,{type:`button`,disabled:!l.trim()||M||p,onClick:e=>void A({navigate:!e.shiftKey}),"aria-label":t,className:o(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,l.trim()&&!M&&!p?`text-accent hover:bg-accent-soft`:`text-fg-disabled`),children:(0,$.jsx)(pe,{className:`size-4`})})]})}var Mt={statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1},Nt=240,Pt=320,Ft=520,It=560;function Lt(e){if(globalThis.localStorage===void 0)return Pt;try{let t=globalThis.localStorage.getItem(e);if(!t)return Pt;let n=Number(t);return Number.isFinite(n)?n:Pt}catch{return Pt}}function Rt(e,t){if(globalThis.localStorage!==void 0)try{globalThis.localStorage.setItem(e,String(Math.round(t)))}catch{}}var zt={thought:K,todo:B,voice:ae,media:Pe,bookmark:S,mixed:K,task:B};function Bt(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function Vt(e,t){return e.statusFilter===t.patch.statusFilter&&e.kindFilter===t.patch.kindFilter&&e.pinnedOnly===t.patch.pinnedOnly}function Ht(e,t){return`${e.replace(/\/$/,``)}/${encodeURIComponent(t)}`}function Ut({selectedNoteId:e,basePath:t,managePageHeader:n=!1,showLibrary:r=!0,allowMediaCapture:i=!0,listTag:u,captureTags:f=[],listTitle:p,listDescription:g,emptyText:_,emptyDescription:v,listWidthStorageKey:y=`xopc.notes.listWidth`}){let b=s(l(e=>e.language)).notes,x=!!c(e=>e.token),[C,D]=(0,Q.useReducer)(P,Mt),[O,k]=(0,Q.useState)(!1),[A,M]=(0,Q.useState)(``),[F,I]=(0,Q.useState)(0),[ee,ne]=(0,Q.useState)(()=>Lt(y)),[ie,oe]=(0,Q.useState)(!1),[V,U]=(0,Q.useState)(!1),[W,G]=(0,Q.useState)(!1),[ce,le]=(0,Q.useState)(null),pe=(0,Q.useRef)(null),q=(0,Q.useRef)(null),[ve]=(0,Q.useState)(()=>Date.now()),J=a(),be=(0,Q.useCallback)(e=>{let t=pe.current?.clientWidth??window.innerWidth,n=Math.max(Nt,t-It);return Math.max(Nt,Math.min(Math.min(Ft,n),e))},[]),Ce=(0,Q.useCallback)(e=>{let t=be(e);ne(t),Rt(y,t)},[be,y]);(0,Q.useLayoutEffect)(()=>{ne(e=>be(e))},[be]);let{data:Te,mutate:Y,isLoading:De}=d((0,Q.useMemo)(()=>x?[`notes-list`,u,C.statusFilter,C.kindFilter,C.pinnedOnly]:null,[x,u,C.statusFilter,C.kindFilter,C.pinnedOnly]),()=>Se({status:C.statusFilter===`all`?void 0:C.statusFilter,kind:C.kindFilter===`all`?void 0:C.kindFilter,tag:u,pinned:C.pinnedOnly?!0:void 0,limit:100,sortBy:`createdAt`,sortOrder:`desc`}),{keepPreviousData:!0}),Oe=De&&!Te,ke=Te?.items??[],Ae=Te?.total??0,je=A.trim(),{data:Me,isLoading:Ne}=d(x&&O&&je?[`notes-search`,u,je]:null,()=>Se({search:je,tag:u,limit:30,sortBy:`updatedAt`,sortOrder:`desc`})),X=Me?.items??[],Ie=e?ke.some(t=>t.id===e):!0;(0,Q.useEffect)(()=>{I(0)},[je]),(0,Q.useEffect)(()=>{F>=X.length&&I(Math.max(0,X.length-1))},[F,X.length]),(0,Q.useEffect)(()=>{let e=()=>{Y()};return window.addEventListener(`note-updated`,e),()=>window.removeEventListener(`note-updated`,e)},[Y]);let Le=te(e=>e.setPageHeader),Re=te(e=>e.clearPageHeader),Be=Ae>0?b.noteCount.replace(`{{count}}`,String(Ae)):null,Z=b.searchDialogTitle,Ve=b.searchClose,He=b.searchClear,Ue=(0,Q.useMemo)(()=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>k(!0),className:o(`inline-flex h-9 items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,h),"aria-label":Z,children:[(0,$.jsx)(ue,{className:`size-4`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:Z})]}),[Z]);(0,Q.useLayoutEffect)(()=>{if(n)return x?(Le({startExtra:null,main:(0,$.jsxs)(`div`,{className:o(`flex min-w-0 items-center gap-2`,h),children:[(0,$.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:p??b.title}),Be?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:Be}):null]}),end:Ue}),()=>Re()):(Re(),()=>Re())},[Re,x,Ue,p,n,b.title,Be,e,Le]);let We=(0,Q.useMemo)(()=>({justNow:b.justNow,minutesAgo:b.minutesAgo,today:b.today,yesterday:b.yesterday,daysAgo:b.daysAgo}),[b.justNow,b.minutesAgo,b.today,b.yesterday,b.daysAgo]),Ge=(0,Q.useMemo)(()=>[{id:`recent`,label:b.viewRecent,description:b.viewRecentDescription,icon:ge,patch:{statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1}},{id:`inbox`,label:b.filterInbox,description:b.viewInboxDescription,icon:H,patch:{statusFilter:`inbox`,kindFilter:`all`,pinnedOnly:!1}},{id:`pinned`,label:b.pinned,description:b.viewPinnedDescription,icon:E,patch:{statusFilter:`all`,kindFilter:`all`,pinnedOnly:!0}},{id:`tasks`,label:b.viewTasks,description:b.viewTasksDescription,icon:B,patch:{statusFilter:`all`,kindFilter:`todo`,pinnedOnly:!1}},{id:`voice`,label:b.kindVoice,description:b.viewVoiceDescription,icon:ae,patch:{statusFilter:`all`,kindFilter:`voice`,pinnedOnly:!1}},{id:`media`,label:b.kindMedia,description:b.viewMediaDescription,icon:Pe,patch:{statusFilter:`all`,kindFilter:`media`,pinnedOnly:!1}},{id:`bookmarks`,label:b.kindBookmark,description:b.viewBookmarksDescription,icon:S,patch:{statusFilter:`all`,kindFilter:`bookmark`,pinnedOnly:!1}},{id:`processed`,label:b.filterProcessed,description:b.viewProcessedDescription,icon:de,patch:{statusFilter:`processed`,kindFilter:`all`,pinnedOnly:!1}},{id:`archive`,label:b.filterArchived,description:b.viewArchiveDescription,icon:j,patch:{statusFilter:`archived`,kindFilter:`all`,pinnedOnly:!1}}],[b.filterArchived,b.filterInbox,b.filterProcessed,b.kindBookmark,b.kindMedia,b.kindVoice,b.pinned,b.viewArchiveDescription,b.viewBookmarksDescription,b.viewInboxDescription,b.viewMediaDescription,b.viewPinnedDescription,b.viewProcessedDescription,b.viewRecent,b.viewRecentDescription,b.viewTasks,b.viewTasksDescription,b.viewVoiceDescription]),Ke=Ge.find(e=>Vt(C,e))??Ge[0],qe=p??Ke.label,Je=g??Ke.description,Ye=(0,Q.useCallback)(async(e,n)=>{let r=f.length?await xe({markdown:e,kind:`thought`,tags:f,channel:`web`}):await me(e,`web`);await Y(),n?.navigate!==!1&&J(Ht(t,r.id))},[t,f,Y,J]),$e=(0,Q.useCallback)(async()=>{if(!W){G(!0);try{let e=await xe({markdown:``,kind:`thought`,tags:f,channel:`web`});D({type:`patch`,patch:Mt}),await Y(),le(e.id),J(Ht(t,e.id))}catch(e){we({type:`error`,title:b.createBlankFailed,message:e instanceof Error?e.message:b.createBlankFailedHint})}finally{G(!1)}}},[t,f,W,Y,b.createBlankFailed,b.createBlankFailedHint,J]),et=(0,Q.useCallback)(()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`image/*`,e.onchange=async()=>{let t=e.files?.[0];if(t)try{await fe(t,`web`),await Y()}catch(e){we({type:`error`,title:b.imageUploadFailed,message:e instanceof Error?e.message:b.imageUploadFailedHint})}},e.click()},[Y,b.imageUploadFailed,b.imageUploadFailedHint]),tt=(0,Q.useCallback)(async(e,t)=>{try{await se(e,t,`web`),await Y()}catch(e){we({type:`error`,title:b.voiceUploadFailed,message:e instanceof Error?e.message:b.voiceUploadFailedHint})}},[Y,b.voiceUploadFailed,b.voiceUploadFailedHint]),nt=(0,Q.useCallback)(async(e,t)=>{await Fe(e,{pinned:t}),await Y()},[Y]),rt=(0,Q.useCallback)(async e=>{await Fe(e,{status:`archived`}),await Y()},[Y]),at=(0,Q.useCallback)(async e=>{await Ee(e),await Y()},[Y]),ot=(0,Q.useCallback)(e=>{J(Ht(t,e))},[t,J]),st=(0,Q.useCallback)(e=>{J(Ht(t,e)),k(!1)},[t,J]),ct=(0,Q.useCallback)(e=>{if(X.length){if(e.key===`ArrowDown`)e.preventDefault(),I(e=>Math.min(X.length-1,e+1));else if(e.key===`ArrowUp`)e.preventDefault(),I(e=>Math.max(0,e-1));else if(e.key===`Enter`){e.preventDefault();let t=X[F]??X[0];t&&st(t.id)}}},[F,st,X]),lt=(0,Q.useCallback)(e=>{e.preventDefault();let t=e.currentTarget,n=q.current;t.setPointerCapture(e.pointerId),oe(!0);let r=pe.current?.clientWidth??window.innerWidth,i=Math.max(Nt,r-It),a=Math.min(Ft,i),o=e=>Math.max(Nt,Math.min(a,e)),s=e.clientX,c=o(ee),l=e.pointerId,u=0,d=c,f=c;n&&(n.style.transition=`none`,n.style.width=`${c}px`);let p=()=>{u=0,f=d,n&&(n.style.width=`${f}px`)},m=e=>{d=o(c+e.clientX-s),u===0&&(u=window.requestAnimationFrame(p))},h=()=>{u!==0&&(window.cancelAnimationFrame(u),p());try{t.releasePointerCapture(l)}catch{}oe(!1),pe.current?.style.setProperty(`--notes-list-width`,`${f}px`),n&&(n.style.removeProperty(`transition`),n.style.removeProperty(`width`)),ne(f),Rt(y,f),window.removeEventListener(`pointermove`,m),window.removeEventListener(`pointerup`,h),window.removeEventListener(`pointercancel`,h)};window.addEventListener(`pointermove`,m),window.addEventListener(`pointerup`,h),window.addEventListener(`pointercancel`,h)},[y,ee]);(0,Q.useEffect)(()=>{let e=e=>{e.defaultPrevented||e.repeat||e.key.toLowerCase()!==`n`||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey||(e.preventDefault(),$e())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[$e]);let ut=(0,Q.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),Ce(ee-16)):e.key===`ArrowRight`?(e.preventDefault(),Ce(ee+16)):e.key===`Home`?(e.preventDefault(),Ce(Nt)):e.key===`End`&&(e.preventDefault(),Ce(Ft))},[Ce,ee]);return x?(0,$.jsxs)(`div`,{ref:pe,className:`flex h-full min-h-0 w-full flex-1 overflow-hidden bg-surface-panel`,style:{"--notes-list-width":`${ee}px`},children:[(0,$.jsxs)(`section`,{ref:q,className:o(`relative flex min-h-0 w-full shrink-0 flex-col overflow-hidden bg-surface-panel`,!ie&&`lg:transition-[width] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,V?`lg:w-0 lg:min-w-0 lg:max-w-0 lg:pointer-events-none`:`lg:w-[var(--notes-list-width)]`,e&&`hidden lg:flex`),"aria-hidden":V?!0:void 0,children:[(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[r?(0,$.jsx)(ye,{value:Ke.id,onChange:e=>{let t=Ge.find(t=>t.id===e.target.value);t&&D({type:`patch`,patch:t.patch})},className:`-ml-1 block max-w-44 truncate rounded-lg border border-transparent bg-transparent px-1 py-0.5 text-sm font-semibold text-fg transition-colors hover:border-edge hover:bg-surface-base focus:border-accent focus:bg-surface-base focus:outline-none focus:ring-1 focus:ring-accent`,"aria-label":b.libraryTitle,children:Ge.map(e=>(0,$.jsx)(he,{value:e.id,children:e.label},e.id))}):(0,$.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:qe}),(0,$.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:Be??Je})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>U(!0),className:`hidden size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent lg:inline-flex`,"aria-label":b.collapseNotesList,title:b.collapseNotesList,children:(0,$.jsx)(L,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:$e,disabled:W,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":b.createBlankNote,title:b.createBlankShortcut,children:(0,$.jsx)(_e,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>k(!0),className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":b.searchDialogTitle,children:(0,$.jsx)(ue,{className:`size-4`,"aria-hidden":!0})})]})]})}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 py-3 [scrollbar-gutter:stable]`,children:Oe?(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3,4].map(e=>(0,$.jsx)(`div`,{className:`h-20 animate-pulse rounded-lg bg-surface-hover`},e))}):ke.length===0?(0,$.jsxs)(`div`,{className:`flex min-h-[min(40vh,20rem)] flex-col items-center justify-center gap-2 px-6 py-16 text-center`,children:[(0,$.jsx)(K,{className:`size-8 text-fg-muted`}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:e&&!Ie?b.noteOutsideCurrentView:_??b.noNotes}),e&&!Ie?null:(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:v??b.noNotesDescription})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e&&!Ie?(0,$.jsx)(`div`,{className:`mb-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-xs leading-5 text-fg-muted`,children:b.noteOutsideCurrentView}):null,ke.map((t,n)=>{let r=n>0?Qe(ke[n-1].createdAt):null;return(0,$.jsxs)(`div`,{children:[Qe(t.createdAt)!==r&&(0,$.jsx)(`div`,{className:o(`px-3 pb-1.5 pt-2 text-xs font-medium text-fg-muted`,n===0&&`pt-0`),children:Ze(t.createdAt,ve,We)}),(0,$.jsx)(it,{note:t,selected:t.id===e,onPress:ot,onPin:nt,onArchive:rt,onDelete:at,timeLabels:We,labels:{pin:b.pin,unpin:b.unpin,archive:b.archive,delete:b.delete,imageNote:b.imageNote,noText:b.noText}})]},t.id)})]})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge-subtle p-3`,children:(0,$.jsx)(jt,{placeholder:b.quickCapturePlaceholder,sendLabel:b.send,onCapture:Ye,onImagePick:i?et:void 0,onVoiceCapture:i?tt:void 0,recordingLabel:b.recording})})]}),(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":b.resizeNotesList,"aria-valuemin":Nt,"aria-valuemax":Ft,"aria-valuenow":Math.round(ee),tabIndex:0,onPointerDown:lt,onDoubleClick:()=>Ce(Pt),onKeyDown:ut,title:b.resizeNotesList,className:o(`group relative hidden shrink-0 cursor-col-resize touch-none select-none items-center justify-center lg:flex`,`lg:transition-[width,opacity] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,V?`lg:w-0 lg:opacity-0 lg:pointer-events-none`:`lg:w-3 lg:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-0`),children:(0,$.jsx)(`span`,{"aria-hidden":!0,className:o(`h-8 w-1 rounded-pill opacity-0 transition-[background-color,opacity,transform] duration-150`,`bg-edge-strong/55 group-hover:opacity-100 group-focus-visible:opacity-100`,`group-hover:scale-y-110 group-focus-visible:scale-y-110`,ie&&`bg-accent opacity-100 scale-y-125`)})}),(0,$.jsxs)(`section`,{className:o(`relative min-w-0 flex-1 bg-surface-panel`,!e&&`hidden lg:flex`),children:[V?(0,$.jsx)(`button`,{type:`button`,onClick:()=>U(!1),className:`absolute left-3 top-3 z-10 hidden size-8 items-center justify-center rounded-lg border border-edge bg-surface-base text-fg-muted shadow-surface transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent lg:inline-flex`,"aria-label":b.expandNotesList,title:b.expandNotesList,children:(0,$.jsx)(L,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}):null,e?(0,$.jsx)(Et,{noteId:e,onBack:()=>J(t),onSaved:()=>void Y(),backButtonClassName:`lg:hidden`,clearHeaderOnCleanup:!1,onOpenSearch:()=>k(!0),autoFocus:e===ce,onAutoFocusConsumed:()=>le(null)}):(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 items-center justify-center px-8 text-center`,children:(0,$.jsxs)(`div`,{className:`max-w-sm`,children:[(0,$.jsx)(K,{className:`mx-auto size-9 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-fg`,children:b.emptyEditorTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:b.emptyEditorDescription}),(0,$.jsxs)(`button`,{type:`button`,onClick:$e,disabled:W,className:`mt-5 inline-flex items-center gap-2 rounded-lg bg-accent px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,$.jsx)(_e,{className:`size-4`,"aria-hidden":!0}),W?b.creatingBlankNote:b.createBlankNote]})]})})]}),(0,$.jsx)(ze,{open:O,onOpenChange:k,children:(0,$.jsxs)(z,{children:[(0,$.jsx)(re,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(R,{className:`fixed left-1/2 top-24 z-[90] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,$.jsx)(w,{className:`text-sm font-semibold text-fg`,children:Z}),(0,$.jsx)(T,{className:`sr-only`,children:b.searchPlaceholder}),(0,$.jsx)(m,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":Ve,children:(0,$.jsx)(N,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`p-4`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(ue,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,value:A,onChange:e=>M(e.target.value),onKeyDown:ct,placeholder:b.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-10 text-sm text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`}),A?(0,$.jsx)(`button`,{type:`button`,onClick:()=>M(``),className:`absolute right-2 top-1/2 inline-flex size-7 -translate-y-1/2 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":He,children:(0,$.jsx)(N,{className:`size-3.5`,"aria-hidden":!0})}):null]}),(0,$.jsx)(`div`,{className:`mt-4 max-h-[min(28rem,calc(100vh-14rem))] overflow-y-auto [scrollbar-gutter:stable]`,children:je?Ne&&!Me?(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3].map(e=>(0,$.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-surface-hover`},e))}):X.length===0?(0,$.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,$.jsx)(K,{className:`size-7 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:b.searchNoResults}),(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:b.searchNoResultsDescription})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`p`,{className:`px-2 pb-1 text-xs text-fg-muted`,children:b.searchResultsCount.replace(`{{count}}`,String(Me?.total??X.length))}),X.map((e,t)=>{let n=zt[e.kind]||K,r=Bt(e,{imageNote:b.imageNote,noText:b.noText});return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>st(e.id),onMouseEnter:()=>I(t),className:o(`flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors`,t===F?`bg-surface-active`:`hover:bg-surface-hover`),children:[(0,$.jsx)(n,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title||r}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:Xe(e.updatedAt,ve,We)})]}),e.title?(0,$.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-xs leading-5 text-fg-muted`,children:r}):null,e.tags?.length?(0,$.jsx)(`span`,{className:`mt-1 flex min-w-0 flex-wrap gap-1`,children:e.tags.slice(0,3).map(e=>(0,$.jsx)(`span`,{className:`max-w-24 truncate rounded-md bg-surface-hover px-1.5 py-0.5 text-xs text-fg-muted`,children:e},e))}):null]})]},e.id)})]}):(0,$.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,$.jsx)(ue,{className:`size-7 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:b.searchEmptyTitle}),(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:b.searchEmptyDescription})]})})]})]})]})})]}):(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,$.jsx)(K,{className:`size-10 text-fg-muted`}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:b.needToken})]})}export{He as n,Ut as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a,t as o}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./circle-alert-BEjgurr2.js";import{t as l}from"./cn-JdwAhgNB.js";import{t as u}from"./copy-to-clipboard-HOJ79TWv.js";import{t as d}from"./messages-CarlxqXV.js";import{l as f,n as p,o as m,r as h,s as g}from"./locale-store-sToMfHX_.js";import{$i as _,$s as v,A as y,Aa as b,As as x,Ba as S,Bc as C,Bo as w,C as T,F as E,Fc as D,Ga as O,Gl as k,Go as A,Gr as j,Ha as M,Ho as N,Hs as P,Ia as F,Ic as I,Ka as L,Kl as R,Ks as z,La as B,Lu as V,M as H,Ma as ee,Ms as te,Na as ne,Nc as U,Nl as W,Ns as re,Oi as ie,Ot as ae,Pa as oe,Pl as se,Pu as ce,Qi as le,Ql as ue,Qn as de,Ra as fe,Rl as pe,Rr as me,To as he,Ua as ge,Uo as _e,Va as ve,Vo as ye,Wa as be,Wo as xe,Xa as Se,Xs as Ce,Yl as we,Za as Te,Zc as Ee,Zi as De,_u as Oe,a as ke,aa as Ae,c as je,d as Me,ea as Ne,eo as Pe,f as Fe,fc as Ie,fs as Le,gc as Re,gs as G,gu as ze,h as Be,hl as Ve,hs as He,i as Ue,ia as We,is as Ge,ja as Ke,jc as qe,jl as Je,ka as Ye,ll as Xe,m as Ze,ms as Qe,mu as $e,na as et,ns as tt,o as nt,oa as rt,oc as it,ps as at,qa as ot,ra as st,rc as ct,ro as lt,rr as ut,ru as dt,s as ft,sa as pt,ta as mt,tt as ht,u as gt,vt as _t,vu as vt,wl as yt,x as bt,xc as xt,yc as St,za as Ct,zc as wt,zl as Tt,zo as Et}from"./index-2UImfRDC.js";import{t as Dt}from"./notes-workbench-BKNBk0Uf.js";import{t as Ot}from"./page-tabs-cOEOQqHh.js";import{t as kt}from"./directory-picker-path-field-DWnxdZtc.js";import{t as At}from"./goals-config-api-CcdS9qek.js";import{n as jt,t as Mt}from"./goal-create-dialog-CSFcRE_N.js";import{f as Nt,o as Pt,r as Ft}from"./skills-page.utils-DgyB1tSo.js";var K=e(t(),1),q=n();function It(e){return g(h(`/api/projects/${encodeURIComponent(e)}/skills`))}function Lt(e,t){return g(h(`/api/projects/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`))}function Rt(e,t){let n=new FormData;return n.set(`file`,t),g(h(`/api/projects/${encodeURIComponent(e)}/skills/upload`),{method:`POST`,body:n})}function zt(e,t,n={}){return g(h(`/api/projects/${encodeURIComponent(e)}/skills/marketplace/install`),{method:`POST`,body:JSON.stringify({name:t,...n})})}function Bt(e,t){return g(h(`/api/projects/${encodeURIComponent(e)}/skills/source/install`),{method:`POST`,body:JSON.stringify({source:t})})}function Vt(e,t){return g(h(`/api/projects/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`),{method:`DELETE`})}var J=r();function Ht({projectId:e,copy:t}){let[n,r]=(0,K.useState)([]),[i,a]=(0,K.useState)(``),[o,s]=(0,K.useState)(!0),[c,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(null),[h,g]=(0,K.useState)(null),[_,y]=(0,K.useState)(``),[b,S]=(0,K.useState)(1),[C,T]=(0,K.useState)(null),[E,D]=(0,K.useState)(!1),[O,j]=(0,K.useState)(``),[M,N]=(0,K.useState)(``),F=(0,K.useRef)(null),I=(0,K.useCallback)(async()=>{s(!0),f(``);try{let t=await It(e);r(t.items),a(t.skillsRoot)}catch(e){f(e instanceof Error?e.message:String(e))}finally{s(!1)}},[e]);(0,K.useEffect)(()=>{I()},[I]),(0,K.useEffect)(()=>{if(p!==`marketplace`)return;let e=new AbortController,t=window.setTimeout(()=>{D(!0),j(``),Nt({q:_,page:b,pageSize:8,sort:`downloads`,signal:e.signal}).then(T).catch(t=>{e.signal.aborted||j(t instanceof Error?t.message:String(t))}).finally(()=>{e.signal.aborted||D(!1)})},250);return()=>{window.clearTimeout(t),e.abort()}},[p,b,_]);async function L(e){u(!0),f(``);try{await e(),m(null),N(``),await I()}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}}async function R(t){f(``);try{g((await Lt(e,t)).skill)}catch(e){f(e instanceof Error?e.message:String(e))}}async function B(n){if(window.confirm(t.removeConfirm.replace(`{{name}}`,n.name))){u(!0);try{await Vt(e,n.id),await I()}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}}}return(0,J.jsxs)(`section`,{id:`project-panel-skills`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-skills`,className:`grid content-start gap-4`,children:[(0,J.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.title}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.description})]}),(0,J.jsxs)(He,{children:[(0,J.jsx)(G,{asChild:!0,children:(0,J.jsxs)(x,{type:`button`,children:[(0,J.jsx)(qe,{className:`size-4`,"aria-hidden":!0}),t.add,(0,J.jsx)(vt,{className:`size-3.5`,"aria-hidden":!0})]})}),(0,J.jsx)(Qe,{children:(0,J.jsxs)(at,{align:`end`,sideOffset:8,className:`z-50 w-72 rounded-lg border border-edge bg-surface-panel p-1.5 shadow-xl`,children:[(0,J.jsx)(Ut,{icon:v,title:t.marketplace,hint:t.marketplaceHint,onClick:()=>m(`marketplace`)}),(0,J.jsx)(Ut,{icon:Je,title:t.source,hint:t.sourceHint,onClick:()=>m(`source`)}),(0,J.jsx)(Ut,{icon:P,title:t.upload,hint:t.uploadHint,onClick:()=>F.current?.click()})]})})]}),(0,J.jsx)(`input`,{ref:F,type:`file`,accept:`.zip,application/zip`,className:`hidden`,onChange:t=>{let n=t.target.files?.[0];n&&L(()=>Rt(e,n)),t.target.value=``}})]}),i?(0,J.jsxs)(`p`,{className:`mt-3 break-all font-mono text-xs text-fg-subtle`,children:[t.path,`: `,i]}):null]}),d?(0,J.jsx)(`p`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:d}):null,o?(0,J.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:[0,1,2].map(e=>(0,J.jsx)(lt,{className:`h-36 rounded-lg`},e))}):n.length?(0,J.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:n.map(e=>(0,J.jsxs)(`article`,{className:`flex min-h-36 flex-col rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(V,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,J.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:e.name})]}),(0,J.jsx)(`p`,{className:`mt-2 line-clamp-2 flex-1 text-sm leading-5 text-fg-muted`,children:e.description||e.id}),(0,J.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,J.jsxs)(x,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>void R(e.id),children:[(0,J.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),t.view]}),(0,J.jsxs)(x,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs text-red-600`,disabled:c,onClick:()=>void B(e),children:[(0,J.jsx)(z,{className:`size-3.5`,"aria-hidden":!0}),t.remove]})]})]},e.id))}):(0,J.jsxs)(`div`,{className:`rounded-lg border border-dashed border-edge bg-surface-panel px-6 py-12 text-center`,children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.empty}),(0,J.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.emptyHint})]}),(0,J.jsx)(Et,{open:p!==null,onOpenChange:e=>{e||m(null)},children:(0,J.jsxs)(xe,{children:[(0,J.jsx)(_e,{className:`fixed inset-0 z-50 bg-black/45`}),(0,J.jsxs)(ye,{className:l(`fixed left-1/2 top-1/2 z-50 flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-xl`,p===`marketplace`?`h-[min(46rem,calc(100vh-2rem))] w-[min(58rem,calc(100vw-2rem))]`:`h-[min(22rem,calc(100vh-2rem))] w-[min(36rem,calc(100vw-2rem))]`),children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,J.jsx)(A,{className:`text-base font-semibold text-fg`,children:p===`marketplace`?t.marketplace:t.source}),(0,J.jsx)(w,{asChild:!0,children:(0,J.jsx)(x,{type:`button`,variant:`ghost`,className:`size-9 p-0`,children:(0,J.jsx)(re,{className:`size-4`})})})]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:p===`marketplace`?(0,J.jsxs)(`section`,{children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.marketplace}),(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.marketplaceHint}),(0,J.jsxs)(`div`,{className:`relative mt-3`,children:[(0,J.jsx)(Re,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`input`,{className:`h-10 w-full rounded-md border border-edge bg-surface-base pl-9 pr-3 text-sm outline-none focus:border-accent`,value:_,onChange:e=>{y(e.target.value),S(1)},placeholder:t.marketplacePlaceholder,autoFocus:!0})]}),O?(0,J.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-300`,children:O}):null,E&&!C?(0,J.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[0,1,2,3].map(e=>(0,J.jsx)(lt,{className:`h-32 rounded-lg`},e))}):C?.items.length?(0,J.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:C.items.map(r=>{let i=r.providerId??C.provider,a=Ft(r,i),o=n.some(e=>e.id===r.id||e.id===a||e.name===r.name);return(0,J.jsxs)(`article`,{className:`group flex min-h-32 gap-3 rounded-lg border border-edge bg-surface-base p-3`,children:[(0,J.jsx)(Pt,{name:r.name,className:`size-10`}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,J.jsx)(`h4`,{className:`truncate text-sm font-semibold text-fg`,children:r.name}),(0,J.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:r.description||`—`}),(0,J.jsxs)(`div`,{className:`mt-auto flex items-end justify-between gap-2 pt-2`,children:[(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-fg-subtle`,children:[(0,J.jsx)(we,{className:`size-3.5`,"aria-hidden":!0}),t.marketplaceDownloads,` `,r.downloads]}),(0,J.jsx)(x,{type:`button`,className:`h-8 px-2.5 text-xs`,variant:o?`secondary`:`primary`,disabled:c||o,onClick:()=>void L(()=>zt(e,a,{provider:i})),children:o?t.marketplaceInstalled:c?t.installing:t.install})]})]})]},`${i??`default`}:${r.id}`)})}):E?null:(0,J.jsx)(`p`,{className:`mt-6 text-center text-sm text-fg-muted`,children:t.marketplaceEmpty}),C&&C.meta.totalPages>1?(0,J.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,J.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t.marketplacePage.replace(`{{page}}`,String(C.meta.page)).replace(`{{total}}`,String(C.meta.totalPages))}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsxs)(x,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:E||b<=1,onClick:()=>S(e=>Math.max(1,e-1)),children:[(0,J.jsx)(Oe,{className:`size-4`}),t.marketplacePrevious]}),(0,J.jsxs)(x,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:E||b>=C.meta.totalPages,onClick:()=>S(e=>e+1),children:[t.marketplaceNext,(0,J.jsx)(ze,{className:`size-4`})]})]})]}):null]}):(0,J.jsxs)(`section`,{className:`flex h-full flex-col`,children:[(0,J.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:t.sourceHint}),(0,J.jsx)(`input`,{className:`mt-4 h-10 w-full rounded-md border border-edge bg-surface-base px-3 text-sm outline-none focus:border-accent`,value:M,onChange:e=>N(e.target.value),placeholder:t.sourcePlaceholder,autoFocus:!0}),(0,J.jsxs)(`div`,{className:`mt-auto flex justify-end gap-2 border-t border-edge pt-4`,children:[(0,J.jsx)(w,{asChild:!0,children:(0,J.jsx)(x,{type:`button`,variant:`secondary`,children:t.close})}),(0,J.jsx)(x,{type:`button`,disabled:c||!M.trim(),onClick:()=>void L(()=>Bt(e,M.trim())),children:c?t.installing:t.install})]})]})})]})]})}),(0,J.jsx)(Et,{open:!!h,onOpenChange:e=>{e||g(null)},children:(0,J.jsxs)(xe,{children:[(0,J.jsx)(_e,{className:`fixed inset-0 z-50 bg-black/45`}),(0,J.jsxs)(ye,{className:`fixed left-1/2 top-1/2 z-50 flex h-[min(42rem,calc(100vh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-xl`,children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,J.jsx)(A,{className:`text-base font-semibold text-fg`,children:h?.name}),(0,J.jsx)(w,{asChild:!0,children:(0,J.jsx)(x,{type:`button`,variant:`ghost`,className:`size-9 p-0`,children:(0,J.jsx)(re,{className:`size-4`})})})]}),(0,J.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-5 text-sm leading-6 text-fg-muted`,children:h?.bodyMarkdown})]})]})})]})}function Ut(e){let t=(0,q.c)(13),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,J.jsx)(n,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,J.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=(0,J.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,J.jsxs)(`span`,{className:`min-w-0`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==a||t[10]!==o||t[11]!==l?(u=(0,J.jsx)(Le,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 rounded-md px-3 py-2.5 text-left hover:bg-surface-hover`,onClick:a,children:[o,l]})}),t[9]=a,t[10]=o,t[11]=l,t[12]=u):u=t[12],u}var Wt=`application/x-xopc-work-item`,Gt=[`backlog`,`todo`,`in_progress`,`blocked`,`needs_input`,`in_review`,`done`],Kt=[`low`,`normal`,`high`,`urgent`];function qt(e){return e===`done`||e===`in_review`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`blocked`||e===`needs_input`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`in_progress`?`bg-accent-soft text-accent-fg`:e===`backlog`||e===`todo`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-muted text-fg-subtle`}function Jt(e){return e?_t(new Date(e)):``}function Yt(e){return!Number.isFinite(e)||e<=0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(+(e<10*1024))} KB`:`${(e/(1024*1024)).toFixed(+(e<10*1024*1024))} MB`}function Xt(e){return`${e.name}:${e.size}:${e.lastModified}`}function Zt(e,t){return De(e,t)!==`unsupported`}function Qt(e,t){return e.startsWith(`image/`)?`image`:e.startsWith(`audio/`)?`audio`:t===`image`||t===`audio`||t===`video`?t:`document`}function $t(e,t){return{id:e.id,name:e.fileName,type:Qt(e.mimeType,e.type),mimeType:e.mimeType,size:e.size,...t?{content:t,preview:e.mimeType.startsWith(`image/`)?t:void 0}:{}}}async function en(e,t){let n=_(e.name||`upload`,e.type||`application/octet-stream`),r=Se(await e.arrayBuffer());return{id:t,name:e.name||`upload`,type:Qt(n),mimeType:n,size:e.size,content:r,preview:n.startsWith(`image/`)?r:void 0}}function tn(e){let t=(0,q.c)(3),[n,r]=(0,K.useState)(``),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e){r(``);return}let t=URL.createObjectURL(e);return r(t),()=>URL.revokeObjectURL(t)},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,K.useEffect)(i,a),n}function nn(e,t){let n=(0,q.c)(5),[r,i]=(0,K.useState)(``),a,o;return n[0]!==t.id||n[1]!==t.mimeType||n[2]!==e?(a=()=>{if(!e||!t.mimeType.startsWith(`image/`)){i(``);return}let n=!1,r=``;return(async()=>{let a=await m(Be(e,t.id));if(!a.ok||n)return;let o=await a.blob();n||(r=URL.createObjectURL(o),i(r))})().catch(()=>{n||i(``)}),()=>{n=!0,r&&URL.revokeObjectURL(r)}},o=[t.id,t.mimeType,e],n[0]=t.id,n[1]=t.mimeType,n[2]=e,n[3]=a,n[4]=o):(a=n[3],o=n[4]),(0,K.useEffect)(a,o),r}function rn(e){let t=(0,q.c)(11),{name:n,mimeType:r,thumbnailUrl:i,previewable:a,disabled:o,onOpen:s}=e,c;t[0]===r?c=t[1]:(c=r.startsWith(`image/`),t[0]=r,t[1]=c);let l=c,u;t[2]!==l||t[3]!==n||t[4]!==i?(u=l&&i?(0,J.jsx)(`img`,{src:i,alt:n,className:`size-10 rounded-md object-cover`}):(0,J.jsx)(`span`,{className:`inline-flex size-10 items-center justify-center rounded-md border border-edge bg-surface-muted`,children:(0,J.jsx)(Tt,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),t[2]=l,t[3]=n,t[4]=i,t[5]=u):u=t[5];let d=u;if(!a)return d;let f;return t[6]!==d||t[7]!==o||t[8]!==n||t[9]!==s?(f=(0,J.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel disabled:cursor-wait disabled:opacity-70`,title:n,"aria-label":n,disabled:o,onClick:s,children:d}),t[6]=d,t[7]=o,t[8]=n,t[9]=s,t[10]=f):f=t[10],f}function Y(e){return e.kind===`chat`?`/chat/${encodeURIComponent(e.targetId)}`:e.kind===`goal`?`/goals/${encodeURIComponent(e.targetId)}`:e.kind===`workflow_run`?`/workflows?run=${encodeURIComponent(e.targetId)}`:e.kind===`automation`?`/automations?automationId=${encodeURIComponent(e.targetId)}`:`#`}function an(e){return e instanceof Element?!!e.closest(`a,button,input,select,textarea,[contenteditable="true"],[draggable="true"],[data-board-pan-skip="true"]`):!0}function on(e,t){return e.nextAction||e.blockedReason||e.description||t.noNextAction}function sn(e){let t=(0,q.c)(63),{item:n,dragging:r,onOpen:i,onToggleDone:a,onDragStart:s,onDragEnd:c,t:u}=e,d=n.status===`done`,f;t[0]!==n||t[1]!==s?(f=e=>s(n,e),t[0]=n,t[1]=s,t[2]=f):f=t[2];let p=u.dragToUpdate,m=r&&`opacity-50`,h;t[3]===m?h=t[4]:(h=l(`flex min-h-24 w-full min-w-0 max-w-full cursor-grab flex-col overflow-hidden rounded-lg bg-surface-panel p-3 shadow-surface transition-colors hover:bg-surface-hover active:cursor-grabbing`,m),t[3]=m,t[4]=h);let g=d?`border-success bg-success text-white`:`border-edge bg-surface-base hover:border-accent/50`,_;t[5]===g?_=t[6]:(_=l(`mt-0.5 inline-flex size-3.5 shrink-0 items-center justify-center rounded border transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,g),t[5]=g,t[6]=_);let v=d?u.markTodo:u.markDone,y=d?u.markTodo:u.markDone,b;t[7]!==n||t[8]!==a?(b=()=>a(n),t[7]=n,t[8]=a,t[9]=b):b=t[9];let x;t[10]===d?x=t[11]:(x=d?(0,J.jsx)($e,{className:`size-3`,"aria-hidden":!0}):null,t[10]=d,t[11]=x);let S;t[12]!==x||t[13]!==_||t[14]!==v||t[15]!==y||t[16]!==b?(S=(0,J.jsx)(`button`,{type:`button`,className:_,"aria-label":v,title:y,onClick:b,children:x}),t[12]=x,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=S):S=t[17];let w;t[18]!==n||t[19]!==i?(w=()=>i(n),t[18]=n,t[19]=i,t[20]=w):w=t[20];let T;t[21]===n.title?T=t[22]:(T=(0,J.jsx)(`h4`,{className:`min-w-0 flex-1 basis-0 text-sm font-medium leading-5 text-fg line-clamp-2`,children:n.title}),t[21]=n.title,t[22]=T);let E;t[23]!==n||t[24]!==u?(E=on(n,u),t[23]=n,t[24]=u,t[25]=E):E=t[25];let D;t[26]===E?D=t[27]:(D=(0,J.jsx)(`p`,{className:`mt-2 max-w-full break-words text-xs leading-5 text-fg-muted line-clamp-1`,children:E}),t[26]=E,t[27]=D);let O;t[28]!==w||t[29]!==T||t[30]!==D?(O=(0,J.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,onClick:w,children:[T,D]}),t[28]=w,t[29]=T,t[30]=D,t[31]=O):O=t[31];let A;t[32]!==S||t[33]!==O?(A=(0,J.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-start gap-2`,children:[S,O]}),t[32]=S,t[33]=O,t[34]=A):A=t[34];let j;t[35]===n.status?j=t[36]:(j=l(`rounded-full px-2 py-0.5 text-[11px] font-medium`,qt(n.status)),t[35]=n.status,t[36]=j);let M=u.statuses[n.status],N;t[37]!==j||t[38]!==M?(N=(0,J.jsx)(`span`,{className:j,children:M}),t[37]=j,t[38]=M,t[39]=N):N=t[39];let P=u.priorities[n.priority],F;t[40]===P?F=t[41]:(F=(0,J.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-[11px] text-fg-muted`,children:P}),t[40]=P,t[41]=F);let I;t[42]===n.attachments?I=t[43]:(I=n.attachments?.length?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-surface-muted px-2 py-0.5 text-[11px] text-fg-muted`,children:[(0,J.jsx)(C,{className:`size-3`,"aria-hidden":!0}),n.attachments.length]}):null,t[42]=n.attachments,t[43]=I);let L;t[44]===n.links?L=t[45]:(L=n.links?.length?(0,J.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-[11px] text-fg-muted`,children:n.links.length}):null,t[44]=n.links,t[45]=L);let R=`/work-items/${encodeURIComponent(n.id)}`,z;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,J.jsx)(k,{className:`size-3`,"aria-hidden":!0}),t[46]=z):z=t[46];let B;t[47]!==u.detail.openItem||t[48]!==R?(B=(0,J.jsxs)(o,{to:R,className:`ml-auto inline-flex shrink-0 items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium text-accent hover:bg-accent-soft hover:text-accent-fg`,children:[u.detail.openItem,z]}),t[47]=u.detail.openItem,t[48]=R,t[49]=B):B=t[49];let V;t[50]!==N||t[51]!==F||t[52]!==I||t[53]!==L||t[54]!==B?(V=(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[N,F,I,L,B]}),t[50]=N,t[51]=F,t[52]=I,t[53]=L,t[54]=B,t[55]=V):V=t[55];let H;return t[56]!==c||t[57]!==u.dragToUpdate||t[58]!==f||t[59]!==A||t[60]!==V||t[61]!==h?(H=(0,J.jsxs)(`article`,{draggable:!0,onDragStart:f,onDragEnd:c,title:p,className:h,children:[A,V]}),t[56]=c,t[57]=u.dragToUpdate,t[58]=f,t[59]=A,t[60]=V,t[61]=h,t[62]=H):H=t[62],H}function cn(){let e=(0,q.c)(3),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`div`,{className:`size-3.5 shrink-0 rounded-full bg-surface-muted`}),(0,J.jsx)(`div`,{className:`h-3 w-36 rounded bg-surface-muted`})]}),n=(0,J.jsx)(`div`,{className:`mt-3 h-3 w-48 rounded bg-surface-muted`}),e[0]=t,e[1]=n):(t=e[0],n=e[1]);let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,J.jsxs)(`article`,{className:`flex h-24 w-full min-w-0 max-w-full flex-col overflow-hidden rounded-lg bg-surface-panel px-3 pt-3 pb-0 shadow-surface`,children:[t,n,(0,J.jsxs)(`div`,{className:`mt-3 flex gap-1.5`,children:[(0,J.jsx)(`div`,{className:`h-5 w-16 rounded-full bg-surface-muted`}),(0,J.jsx)(`div`,{className:`h-5 w-10 rounded-full bg-surface-muted`})]})]}),e[2]=r):r=e[2],r}function ln(e){let t=(0,q.c)(44),{file:n,index:r,busy:i,previewBusy:a,t:o,onOpen:s,onRemove:c}=e,u,d,f,p;t[0]===n?(u=t[1],d=t[2],f=t[3],p=t[4]):(u=_(n.name||`upload`,n.type||`application/octet-stream`),d=Zt(n.name||`upload`,u),f=tn,p=u.startsWith(`image/`)?n:null,t[0]=n,t[1]=u,t[2]=d,t[3]=f,t[4]=p);let m=f(p),h=n.name||`upload`,g=i||a,v;t[5]!==n||t[6]!==s?(v=()=>s(n),t[5]=n,t[6]=s,t[7]=v):v=t[7];let y;t[8]!==u||t[9]!==d||t[10]!==h||t[11]!==g||t[12]!==v||t[13]!==m?(y=(0,J.jsx)(rn,{name:h,mimeType:u,thumbnailUrl:m,previewable:d,disabled:g,onOpen:v}),t[8]=u,t[9]=d,t[10]=h,t[11]=g,t[12]=v,t[13]=m,t[14]=y):y=t[14];let b=d?`rounded-md hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`:`cursor-default`,x;t[15]===b?x=t[16]:(x=l(`min-w-0 flex-1 text-left`,b),t[15]=b,t[16]=x);let S=!d||i||a,C;t[17]!==n||t[18]!==s?(C=()=>s(n),t[17]=n,t[18]=s,t[19]=C):C=t[19];let w=n.name||`upload`,T;t[20]===w?T=t[21]:(T=(0,J.jsx)(`div`,{className:`truncate font-medium text-fg`,children:w}),t[20]=w,t[21]=T);let E;t[22]===n.size?E=t[23]:(E=Yt(n.size),t[22]=n.size,t[23]=E);let D;t[24]===E?D=t[25]:(D=(0,J.jsx)(`div`,{className:`text-xs text-fg-subtle`,children:E}),t[24]=E,t[25]=D);let O;t[26]!==C||t[27]!==T||t[28]!==D||t[29]!==x||t[30]!==S?(O=(0,J.jsxs)(`button`,{type:`button`,className:x,disabled:S,onClick:C,children:[T,D]}),t[26]=C,t[27]=T,t[28]=D,t[29]=x,t[30]=S,t[31]=O):O=t[31];let k;t[32]!==r||t[33]!==c?(k=()=>c(r),t[32]=r,t[33]=c,t[34]=k):k=t[34];let A;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,J.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),t[35]=A):A=t[35];let j;t[36]!==i||t[37]!==o.attachments.remove||t[38]!==k?(j=(0,J.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,title:o.attachments.remove,"aria-label":o.attachments.remove,disabled:i,onClick:k,children:A}),t[36]=i,t[37]=o.attachments.remove,t[38]=k,t[39]=j):j=t[39];let M;return t[40]!==O||t[41]!==j||t[42]!==y?(M=(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-panel p-2 text-sm`,children:[y,O,j]}),t[40]=O,t[41]=j,t[42]=y,t[43]=M):M=t[43],M}function un(e){let t=(0,q.c)(56),{item:n,attachment:r,busy:i,previewBusy:a,t:o,onOpen:s,onDownload:c,onRemove:u}=e,d;t[0]!==r.fileName||t[1]!==r.mimeType?(d=Zt(r.fileName,r.mimeType),t[0]=r.fileName,t[1]=r.mimeType,t[2]=d):d=t[2];let f=d,p=nn(n.id,r),m=i||a,h;t[3]!==r||t[4]!==n||t[5]!==s?(h=()=>s(n,r),t[3]=r,t[4]=n,t[5]=s,t[6]=h):h=t[6];let g;t[7]!==r.fileName||t[8]!==r.mimeType||t[9]!==f||t[10]!==m||t[11]!==h||t[12]!==p?(g=(0,J.jsx)(rn,{name:r.fileName,mimeType:r.mimeType,thumbnailUrl:p,previewable:f,disabled:m,onOpen:h}),t[7]=r.fileName,t[8]=r.mimeType,t[9]=f,t[10]=m,t[11]=h,t[12]=p,t[13]=g):g=t[13];let _=f?`rounded-md hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`:`cursor-default`,v;t[14]===_?v=t[15]:(v=l(`min-w-0 flex-1 text-left`,_),t[14]=_,t[15]=v);let y=!f||i||a,b;t[16]!==r||t[17]!==n||t[18]!==s?(b=()=>s(n,r),t[16]=r,t[17]=n,t[18]=s,t[19]=b):b=t[19];let x;t[20]===r.fileName?x=t[21]:(x=(0,J.jsx)(`div`,{className:`truncate font-medium text-fg`,children:r.fileName}),t[20]=r.fileName,t[21]=x);let S=r.mimeType,C;t[22]===r.size?C=t[23]:(C=Yt(r.size),t[22]=r.size,t[23]=C);let w;t[24]!==r.mimeType||t[25]!==C?(w=(0,J.jsxs)(`div`,{className:`truncate text-xs text-fg-subtle`,children:[S,` · `,C]}),t[24]=r.mimeType,t[25]=C,t[26]=w):w=t[26];let T;t[27]!==w||t[28]!==v||t[29]!==y||t[30]!==b||t[31]!==x?(T=(0,J.jsxs)(`button`,{type:`button`,className:v,disabled:y,onClick:b,children:[x,w]}),t[27]=w,t[28]=v,t[29]=y,t[30]=b,t[31]=x,t[32]=T):T=t[32];let E;t[33]!==r||t[34]!==n||t[35]!==c?(E=()=>c(n,r),t[33]=r,t[34]=n,t[35]=c,t[36]=E):E=t[36];let D;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,J.jsx)(we,{className:`size-3.5`,"aria-hidden":!0}),t[37]=D):D=t[37];let O;t[38]!==i||t[39]!==o.attachments.download||t[40]!==E?(O=(0,J.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,title:o.attachments.download,"aria-label":o.attachments.download,disabled:i,onClick:E,children:D}),t[38]=i,t[39]=o.attachments.download,t[40]=E,t[41]=O):O=t[41];let k;t[42]!==r||t[43]!==n||t[44]!==u?(k=()=>u(n,r),t[42]=r,t[43]=n,t[44]=u,t[45]=k):k=t[45];let A;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,J.jsx)(z,{className:`size-3.5`,"aria-hidden":!0}),t[46]=A):A=t[46];let j;t[47]!==i||t[48]!==o.attachments.remove||t[49]!==k?(j=(0,J.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-danger`,title:o.attachments.remove,"aria-label":o.attachments.remove,disabled:i,onClick:k,children:A}),t[47]=i,t[48]=o.attachments.remove,t[49]=k,t[50]=j):j=t[50];let M;return t[51]!==T||t[52]!==O||t[53]!==j||t[54]!==g?(M=(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-panel p-2 text-sm`,children:[g,T,O,j]}),t[51]=T,t[52]=O,t[53]=j,t[54]=g,t[55]=M):M=t[55],M}function dn({mode:e,item:t,pendingFiles:n,busy:r,t:i,onPendingFilesChange:a,onUpload:o,onRemove:s,onDownload:c,onPreviewError:u}){let d=(0,K.useRef)(null),[p,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(!1),[v,y]=(0,K.useState)(null),[b,S]=(0,K.useState)(null),w=f(e=>e.token),T=t?.attachments??[];function E(r){if(!r.length)return;if(e===`detail`&&t){o(t,r);return}let i=new Set(n.map(Xt)),s=[...n];for(let e of r){let t=Xt(e);i.has(t)||(i.add(t),s.push(e))}a(s)}function D(e){a(n.filter((t,n)=>n!==e))}async function O(e){let t=Xt(e);S(`pending:${t}`);try{y(await en(e,`pending:${t}`)),_(!0)}catch(e){u(e instanceof Error?e.message:String(e))}finally{S(null)}}async function k(e,t){S(`saved:${t.id}`);try{let n=await m(Be(e.id,t.id));if(!n.ok)throw Error(`HTTP ${n.status}`);y($t(t,Se(await n.arrayBuffer()))),_(!0)}catch(e){u(e instanceof Error?e.message:String(e))}finally{S(null)}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`section`,{className:l(`grid gap-3 rounded-lg border border-edge bg-surface-base p-3`,p&&`border-accent bg-accent-soft/40`),onDragOver:e=>{e.preventDefault(),h(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||h(!1)},onDrop:e=>{e.preventDefault(),h(!1),E(Array.from(e.dataTransfer.files))},children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsxs)(`h3`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,J.jsx)(C,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`truncate`,children:i.attachments.title})]}),(0,J.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:r,onClick:()=>d.current?.click(),children:[(0,J.jsx)(qe,{className:`size-3.5`,"aria-hidden":!0}),i.attachments.add]}),(0,J.jsx)(`input`,{ref:d,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{E(Array.from(e.target.files??[])),e.currentTarget.value=``}})]}),n.length?(0,J.jsx)(`div`,{className:`grid gap-2`,children:n.map((e,t)=>(0,J.jsx)(ln,{file:e,index:t,busy:r,previewBusy:b===`pending:${Xt(e)}`,t:i,onOpen:e=>void O(e),onRemove:D},Xt(e)))}):null,t&&T.length?(0,J.jsx)(`div`,{className:`grid gap-2`,children:T.map(e=>(0,J.jsx)(un,{item:t,attachment:e,busy:r,previewBusy:b===`saved:${e.id}`,t:i,onOpen:(e,t)=>void k(e,t),onDownload:c,onRemove:s},e.id))}):null,!n.length&&!T.length?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.attachments.empty}):null]}),(0,J.jsx)(ae,{open:g,attachment:v,authToken:w,layerClassName:`z-[100]`,onClose:()=>{_(!1),y(null)}})]})}function fn(e){let t=(0,q.c)(169),{mode:n,item:r,initialStatus:i,events:a,busy:s,error:c,notice:u,t:d,onClose:f,onCreate:p,onSave:m,onStartChat:h,onCreateGoal:g,onAddAttachments:_,onRemoveAttachment:v,onDownloadAttachment:y,onPreviewError:b}=e,S=n!==null,[C,T]=(0,K.useState)(``),[E,D]=(0,K.useState)(``),[O,j]=(0,K.useState)(`todo`),[M,P]=(0,K.useState)(`normal`),[F,I]=(0,K.useState)(``),[L,R]=(0,K.useState)(``),z;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(z=[],t[0]=z):z=t[0];let[B,V]=(0,K.useState)(z),H,ee;t[1]!==i||t[2]!==r||t[3]!==n?(H=()=>{if(n===`create`){T(``),D(``),j(i),P(`normal`),I(``),R(``),V([]);return}n===`detail`&&r&&(T(r.title),D(r.description??``),j(r.status),P(r.priority),I(r.nextAction??``),R(r.blockedReason??``),V([]))},ee=[i,r,n],t[1]=i,t[2]=r,t[3]=n,t[4]=H,t[5]=ee):(H=t[4],ee=t[5]),(0,K.useEffect)(H,ee);let te;t[6]!==L||t[7]!==E||t[8]!==r||t[9]!==n||t[10]!==F||t[11]!==p||t[12]!==m||t[13]!==B||t[14]!==M||t[15]!==O||t[16]!==C?(te=function(e){e.preventDefault();let t=C.trim();if(t){if(n===`create`){p({title:t,description:E.trim()||void 0,priority:M,status:O,nextAction:F.trim()||void 0,blockedReason:L.trim()||void 0,attachments:B});return}r&&m(r,{title:t,description:E.trim()||null,status:O,priority:M,nextAction:F.trim()||null,blockedReason:L.trim()||null})}},t[6]=L,t[7]=E,t[8]=r,t[9]=n,t[10]=F,t[11]=p,t[12]=m,t[13]=B,t[14]=M,t[15]=O,t[16]=C,t[17]=te):te=t[17];let ne=te,U;t[18]===f?U=t[19]:(U=e=>!e&&f(),t[18]=f,t[19]=U);let W;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,J.jsx)(_e,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[20]=W):W=t[20];let ie=n===`create`?d.create.title:r?.title||d.title,ae;t[21]===ie?ae=t[22]:(ae=(0,J.jsx)(A,{className:`truncate text-base font-semibold text-fg`,children:ie}),t[21]=ie,t[22]=ae);let oe;t[23]===d.detail.description?oe=t[24]:(oe=(0,J.jsx)(N,{className:`mt-1 text-sm text-fg-muted`,children:d.detail.description}),t[23]=d.detail.description,t[24]=oe);let se;t[25]!==ae||t[26]!==oe?(se=(0,J.jsxs)(`div`,{className:`min-w-0`,children:[ae,oe]}),t[25]=ae,t[26]=oe,t[27]=se):se=t[27];let ce;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,J.jsx)(re,{className:`size-4`,"aria-hidden":!0}),t[28]=ce):ce=t[28];let le;t[29]===s?le=t[30]:(le=(0,J.jsx)(w,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,disabled:s,children:ce})}),t[29]=s,t[30]=le);let ue;t[31]!==se||t[32]!==le?(ue=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[se,le]}),t[31]=se,t[32]=le,t[33]=ue):ue=t[33];let de;t[34]===c?de=t[35]:(de=c?(0,J.jsx)(`div`,{className:`rounded-lg border border-danger/30 bg-danger-soft px-3 py-2 text-sm text-danger`,children:c}):null,t[34]=c,t[35]=de);let fe;t[36]!==c||t[37]!==u?(fe=!c&&u?(0,J.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-success/30 bg-success-soft px-3 py-2 text-sm text-fg`,role:`status`,"aria-live":`polite`,children:[(0,J.jsx)($e,{className:`mt-0.5 size-4 shrink-0 text-success`,"aria-hidden":!0}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`font-medium text-success`,children:u.title}),(0,J.jsx)(`div`,{className:`mt-1 text-fg-muted`,children:u.message})]})]}):null,t[36]=c,t[37]=u,t[38]=fe):fe=t[38];let pe;t[39]===d.create.titleLabel?pe=t[40]:(pe=(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:d.create.titleLabel}),t[39]=d.create.titleLabel,t[40]=pe);let me;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(me=e=>T(e.target.value),t[41]=me):me=t[41];let he;t[42]===C?he=t[43]:(he=(0,J.jsx)(`input`,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:C,onChange:me}),t[42]=C,t[43]=he);let ge;t[44]!==pe||t[45]!==he?(ge=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[pe,he]}),t[44]=pe,t[45]=he,t[46]=ge):ge=t[46];let ve;t[47]===d.detail.status?ve=t[48]:(ve=(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:d.detail.status}),t[47]=d.detail.status,t[48]=ve);let be;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(be=e=>j(e.target.value),t[49]=be):be=t[49];let Se;t[50]===d.statuses?Se=t[51]:(Se=Gt.map(e=>(0,J.jsx)(Ge,{value:e,children:d.statuses[e]},e)),t[50]=d.statuses,t[51]=Se);let we;t[52]!==O||t[53]!==Se?(we=(0,J.jsx)(tt,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:O,onChange:be,children:Se}),t[52]=O,t[53]=Se,t[54]=we):we=t[54];let Te;t[55]!==ve||t[56]!==we?(Te=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[ve,we]}),t[55]=ve,t[56]=we,t[57]=Te):Te=t[57];let De;t[58]===d.create.priorityLabel?De=t[59]:(De=(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:d.create.priorityLabel}),t[58]=d.create.priorityLabel,t[59]=De);let Oe;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=e=>P(e.target.value),t[60]=Oe):Oe=t[60];let ke;t[61]===d.priorities?ke=t[62]:(ke=Kt.map(e=>(0,J.jsx)(Ge,{value:e,children:d.priorities[e]},e)),t[61]=d.priorities,t[62]=ke);let Ae;t[63]!==M||t[64]!==ke?(Ae=(0,J.jsx)(tt,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:M,onChange:Oe,children:ke}),t[63]=M,t[64]=ke,t[65]=Ae):Ae=t[65];let je;t[66]!==De||t[67]!==Ae?(je=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[De,Ae]}),t[66]=De,t[67]=Ae,t[68]=je):je=t[68];let Me;t[69]!==Te||t[70]!==je?(Me=(0,J.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Te,je]}),t[69]=Te,t[70]=je,t[71]=Me):Me=t[71];let Ne;t[72]===d.create.descriptionLabel?Ne=t[73]:(Ne=(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:d.create.descriptionLabel}),t[72]=d.create.descriptionLabel,t[73]=Ne);let Pe;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=e=>D(e.target.value),t[74]=Pe):Pe=t[74];let Fe;t[75]===E?Fe=t[76]:(Fe=(0,J.jsx)(`textarea`,{className:`min-h-28 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:E,onChange:Pe}),t[75]=E,t[76]=Fe);let Ie;t[77]!==Ne||t[78]!==Fe?(Ie=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[Ne,Fe]}),t[77]=Ne,t[78]=Fe,t[79]=Ie):Ie=t[79];let Le;t[80]!==s||t[81]!==r||t[82]!==n||t[83]!==_||t[84]!==y||t[85]!==b||t[86]!==v||t[87]!==B||t[88]!==d?(Le=(0,J.jsx)(dn,{mode:n,item:r,pendingFiles:B,busy:s,t:d,onPendingFilesChange:V,onUpload:_,onRemove:v,onDownload:y,onPreviewError:b}),t[80]=s,t[81]=r,t[82]=n,t[83]=_,t[84]=y,t[85]=b,t[86]=v,t[87]=B,t[88]=d,t[89]=Le):Le=t[89];let Re;t[90]!==L||t[91]!==n||t[92]!==F||t[93]!==O||t[94]!==d.blockedReason||t[95]!==d.nextAction?(Re=n===`detail`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:d.nextAction}),(0,J.jsx)(`textarea`,{className:`min-h-20 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:F,onChange:e=>I(e.target.value)})]}),(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,J.jsx)(`span`,{className:l(`font-medium`,O===`blocked`||O===`needs_input`?`text-red-700 dark:text-red-300`:`text-fg-muted`),children:d.blockedReason}),(0,J.jsx)(`textarea`,{className:l(`min-h-20 rounded-lg border bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,O===`blocked`||O===`needs_input`?`border-red-500/40`:`border-edge`),value:L,onChange:e=>R(e.target.value)})]})]}):null,t[90]=L,t[91]=n,t[92]=F,t[93]=O,t[94]=d.blockedReason,t[95]=d.nextAction,t[96]=Re):Re=t[96];let G;t[97]!==de||t[98]!==fe||t[99]!==ge||t[100]!==Me||t[101]!==Ie||t[102]!==Le||t[103]!==Re?(G=(0,J.jsxs)(`div`,{className:`grid content-start gap-4`,children:[de,fe,ge,Me,Ie,Le,Re]}),t[97]=de,t[98]=fe,t[99]=ge,t[100]=Me,t[101]=Ie,t[102]=Le,t[103]=Re,t[104]=G):G=t[104];let ze;t[105]!==s||t[106]!==r||t[107]!==n||t[108]!==g||t[109]!==h||t[110]!==d.detail.actions||t[111]!==d.detail.createGoal||t[112]!==d.detail.openItem||t[113]!==d.detail.startChat?(ze=n===`detail`&&r?(0,J.jsxs)(`section`,{children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:d.detail.actions}),(0,J.jsxs)(`div`,{className:`mt-2 grid gap-2`,children:[(0,J.jsxs)(x,{type:`button`,variant:`secondary`,className:`justify-start rounded-lg`,disabled:s,onClick:()=>h(r),children:[(0,J.jsx)(Ee,{className:`size-4`,"aria-hidden":!0}),d.detail.startChat]}),(0,J.jsxs)(x,{type:`button`,variant:`secondary`,className:`justify-start rounded-lg`,disabled:s,onClick:()=>g(r),children:[(0,J.jsx)(Ce,{className:`size-4`,"aria-hidden":!0}),d.detail.createGoal]}),(0,J.jsx)(x,{asChild:!0,variant:`secondary`,className:`justify-start rounded-lg`,children:(0,J.jsxs)(o,{to:`/work-items/${encodeURIComponent(r.id)}`,children:[(0,J.jsx)(k,{className:`size-4`,"aria-hidden":!0}),d.detail.openItem]})})]})]}):null,t[105]=s,t[106]=r,t[107]=n,t[108]=g,t[109]=h,t[110]=d.detail.actions,t[111]=d.detail.createGoal,t[112]=d.detail.openItem,t[113]=d.detail.startChat,t[114]=ze):ze=t[114];let Be;t[115]===d.detail.links?Be=t[116]:(Be=(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:d.detail.links}),t[115]=d.detail.links,t[116]=Be);let Ve;t[117]!==r||t[118]!==d.detail.noLinks||t[119]!==d.linkKinds?(Ve=r?.links?.length?r.links.slice(0,6).map(e=>(0,J.jsxs)(o,{to:Y(e),className:`flex min-w-0 items-center justify-between gap-3 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title||e.targetId}),(0,J.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[d.linkKinds[e.kind],(0,J.jsx)(k,{className:`size-3.5`,"aria-hidden":!0})]})]},e.id)):(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.detail.noLinks}),t[117]=r,t[118]=d.detail.noLinks,t[119]=d.linkKinds,t[120]=Ve):Ve=t[120];let He;t[121]===Ve?He=t[122]:(He=(0,J.jsx)(`div`,{className:`mt-2 grid gap-2 text-sm`,children:Ve}),t[121]=Ve,t[122]=He);let Ue;t[123]!==Be||t[124]!==He?(Ue=(0,J.jsxs)(`section`,{children:[Be,He]}),t[123]=Be,t[124]=He,t[125]=Ue):Ue=t[125];let We;t[126]===d.detail.activity?We=t[127]:(We=(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:d.detail.activity}),t[126]=d.detail.activity,t[127]=We);let Ke;t[128]!==a||t[129]!==d.detail.noActivity||t[130]!==d.eventTypes?(Ke=a.length?a.slice(0,5).map(e=>(0,J.jsxs)(`div`,{className:`text-sm`,children:[(0,J.jsx)(`div`,{className:`font-medium text-fg`,children:d.eventTypes[e.type]??e.type}),(0,J.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:Jt(e.createdAt)})]},e.id)):(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.detail.noActivity}),t[128]=a,t[129]=d.detail.noActivity,t[130]=d.eventTypes,t[131]=Ke):Ke=t[131];let Je;t[132]===Ke?Je=t[133]:(Je=(0,J.jsx)(`div`,{className:`mt-2 grid gap-2`,children:Ke}),t[132]=Ke,t[133]=Je);let Ye;t[134]!==We||t[135]!==Je?(Ye=(0,J.jsxs)(`section`,{children:[We,Je]}),t[134]=We,t[135]=Je,t[136]=Ye):Ye=t[136];let Xe;t[137]!==ze||t[138]!==Ue||t[139]!==Ye?(Xe=(0,J.jsxs)(`aside`,{className:`grid content-start gap-5`,children:[ze,Ue,Ye]}),t[137]=ze,t[138]=Ue,t[139]=Ye,t[140]=Xe):Xe=t[140];let Ze;t[141]!==G||t[142]!==Xe?(Ze=(0,J.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-6 overflow-y-auto px-5 py-4 lg:grid-cols-[minmax(0,1fr)_16rem]`,children:[G,Xe]}),t[141]=G,t[142]=Xe,t[143]=Ze):Ze=t[143];let Qe;t[144]!==s||t[145]!==f||t[146]!==d.create.cancel?(Qe=(0,J.jsx)(x,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:f,disabled:s,children:d.create.cancel}),t[144]=s,t[145]=f,t[146]=d.create.cancel,t[147]=Qe):Qe=t[147];let et;t[148]!==s||t[149]!==C?(et=s||!C.trim(),t[148]=s,t[149]=C,t[150]=et):et=t[150];let nt;t[151]===n?nt=t[152]:(nt=n===`create`?(0,J.jsx)(qe,{className:`size-4`,"aria-hidden":!0}):null,t[151]=n,t[152]=nt);let rt=n===`create`?d.create.submit:d.detail.save,it;t[153]!==et||t[154]!==nt||t[155]!==rt?(it=(0,J.jsxs)(x,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:et,children:[nt,rt]}),t[153]=et,t[154]=nt,t[155]=rt,t[156]=it):it=t[156];let at;t[157]!==Qe||t[158]!==it?(at=(0,J.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[Qe,it]}),t[157]=Qe,t[158]=it,t[159]=at):at=t[159];let ot;t[160]!==ne||t[161]!==ue||t[162]!==Ze||t[163]!==at?(ot=(0,J.jsxs)(xe,{children:[W,(0,J.jsx)(ye,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(86dvh,48rem)] w-[min(60rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:(0,J.jsxs)(`form`,{onSubmit:ne,className:`flex min-h-0 flex-1 flex-col`,children:[ue,Ze,at]})})]}),t[160]=ne,t[161]=ue,t[162]=Ze,t[163]=at,t[164]=ot):ot=t[164];let st;return t[165]!==S||t[166]!==U||t[167]!==ot?(st=(0,J.jsx)(Et,{open:S,onOpenChange:U,children:ot}),t[165]=S,t[166]=U,t[167]=ot,t[168]=st):st=t[168],st}function pn({projectId:e,createRequestKey:t=0}){let n=a(),r=d(p(e=>e.language)).projectDetailPage.workItems,i=(0,K.useRef)(null),o=(0,K.useRef)(null),[s,c]=(0,K.useState)([]),[u,f]=(0,K.useState)(!0),[m,h]=(0,K.useState)(null),[g,_]=(0,K.useState)(null),[v,y]=(0,K.useState)(!1),[b,S]=(0,K.useState)(null),[C,w]=(0,K.useState)(null),[T,E]=(0,K.useState)(!1),[D,O]=(0,K.useState)(!1),[k,A]=(0,K.useState)(!1),[j,M]=(0,K.useState)(`todo`),[N,P]=(0,K.useState)(null),[F,I]=(0,K.useState)([]),L=(0,K.useCallback)(async(t=`replace`,n=0)=>{f(!0),h(null);try{let r=await je(e,{limit:100,offset:n});c(e=>t===`append`?[...e,...r.items]:r.items),O(r.hasMore)}catch(e){h(e instanceof Error?e.message:String(e))}finally{f(!1)}},[e]);(0,K.useEffect)(()=>{L(`replace`,0)},[L]),(0,K.useEffect)(()=>{t&&(P(null),I([]),h(null),_(null),M(`todo`),A(!0))},[t]);let z=(0,K.useMemo)(()=>Gt.map(e=>({status:e,title:r.statuses[e],items:s.filter(t=>t.status===e)})),[s,r.statuses]),B=(0,K.useCallback)(e=>{c(t=>t.map(t=>t.id===e.id?e:t)),P(t=>t?.id===e.id?e:t)},[]),V=(0,K.useCallback)(async(e,t)=>{y(!0),h(null),_(null);try{let n=await Me(e.id,t);n.item.archivedAt?(c(e=>e.filter(e=>e.id!==n.item.id)),P(null)):(B(n.item),_({title:r.feedback.savedTitle,message:r.feedback.savedNext}))}catch(e){h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[r.feedback.savedNext,r.feedback.savedTitle,B]),H=(0,K.useCallback)(async e=>{P(e),I([]),h(null),_(null);let t=await gt(e.id).catch(()=>null);t&&I(t.events)},[]),ee=(0,K.useCallback)(async t=>{y(!0),h(null),_(null);try{let n=await Ue(e,t);c(e=>[n.item,...e]),A(!1),P(n.item),I((await gt(n.item.id).catch(()=>({events:[]}))).events),_({title:r.feedback.createdTitle,message:r.feedback.createdNext})}catch(e){h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e,r.feedback.createdNext,r.feedback.createdTitle]),te=(0,K.useCallback)(async(e,t)=>{if(t.length){y(!0),h(null),_(null);try{let n=await Ze(e.id,t);B(n.item),I((await gt(n.item.id).catch(()=>({events:[]}))).events)}catch(e){h(e instanceof Error?e.message:String(e))}finally{y(!1)}}},[B]),ne=(0,K.useCallback)(async(e,t)=>{y(!0),h(null),_(null);try{let n=await nt(e.id,t.id);B(n.item),I((await gt(n.item.id).catch(()=>({events:[]}))).events)}catch(e){h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[B]),U=(0,K.useCallback)(async(e,t)=>{h(null),_(null);try{await ft(e.id,t)}catch(e){h(e instanceof Error?e.message:String(e))}},[]),W=(0,K.useCallback)(async e=>{y(!0),h(null),_(null);try{let t=await Fe(e.id);B(t.item),await H(t.item),n(`/chat/${encodeURIComponent(t.session.key)}`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[n,H,B]),re=(0,K.useCallback)(async e=>{y(!0),h(null),_(null);try{let t=await ke(e.id);B(t.item),await H(t.item),n(`/goals/${encodeURIComponent(t.goal.id)}`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[n,H,B]),ie=(0,K.useCallback)((e,t)=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(Wt,e.id),S(e.id)},[]),ae=(0,K.useCallback)((e,t)=>{t.preventDefault();let n=t.dataTransfer.getData(Wt)||b;w(null),S(null);let r=s.find(e=>e.id===n);!r||r.status===e||V(r,{status:e})},[b,s,V]),oe=(0,K.useCallback)(e=>{V(e,{status:e.status===`done`?`todo`:`done`})},[V]),se=(0,K.useCallback)(e=>{P(null),I([]),h(null),_(null),M(e),A(!0)},[]),ce=(0,K.useCallback)(e=>{let t=o.current;!t||t.pointerId!==e.pointerId||(o.current=null,E(!1),e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},[]),le=(0,K.useCallback)(e=>{if(e.button!==0||b||an(e.target))return;let t=i.current;t&&(o.current={pointerId:e.pointerId,startX:e.clientX,scrollLeft:t.scrollLeft,active:!1},e.currentTarget.setPointerCapture(e.pointerId))},[b]),ue=(0,K.useCallback)(e=>{let t=o.current,n=i.current;if(!t||!n||t.pointerId!==e.pointerId)return;let r=e.clientX-t.startX;!t.active&&Math.abs(r)<5||(t.active||(t.active=!0,E(!0)),e.preventDefault(),n.scrollLeft=t.scrollLeft-r)},[]);return(0,J.jsxs)(`section`,{id:`project-panel-work-items`,role:`tabpanel`,"aria-labelledby":`project-tab-work-items`,className:`flex h-full min-h-0 flex-col`,children:[m?(0,J.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-3 text-sm text-red-700 dark:text-red-300`,children:m}):null,(0,J.jsx)(`section`,{ref:i,className:l(`min-h-0 flex-1 overflow-x-auto rounded-lg p-2 transition-opacity`,u&&`opacity-60`,T?`cursor-grabbing select-none`:`cursor-grab`),"aria-label":r.boardAria,"aria-busy":u,onPointerDown:le,onPointerMove:ue,onPointerUp:ce,onPointerCancel:ce,onLostPointerCapture:e=>{o.current?.pointerId===e.pointerId&&(o.current=null,E(!1))},children:(0,J.jsx)(`div`,{className:`flex min-h-full min-w-max items-start gap-3 pr-4`,children:z.map(e=>(0,J.jsxs)(`section`,{className:l(`flex max-h-full w-72 min-w-72 max-w-72 shrink-0 flex-col overflow-y-auto rounded-lg bg-surface-base shadow-surface`,C===e.status&&`bg-surface-active`),"aria-label":e.title,onDragOver:t=>{b&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,w(e.status))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||w(null)},onDrop:t=>ae(e.status,t),children:[(0,J.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 p-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,J.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.title}),(0,J.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:e.items.length})]}),(0,J.jsx)(R,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),(0,J.jsxs)(`div`,{className:`mx-2 mt-3 grid min-h-0 min-w-0 content-start gap-2 pb-2 pr-1 [scrollbar-gutter:stable]`,children:[e.items.length?e.items.map(e=>(0,J.jsx)(sn,{item:e,dragging:b===e.id,onOpen:H,onToggleDone:oe,onDragStart:ie,onDragEnd:()=>{S(null),w(null)},t:r},e.id)):u?(0,J.jsxs)(`div`,{className:`grid gap-2 animate-pulse motion-reduce:animate-none`,children:[(0,J.jsx)(cn,{}),(0,J.jsx)(cn,{})]}):(0,J.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-6 text-center text-xs text-fg-subtle`,children:r.emptyColumn}),u?null:(0,J.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-full items-center justify-center rounded-lg bg-surface-panel/85 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-muted`,"aria-label":r.create.addToColumn.replace(`{{status}}`,e.title),title:r.create.addToColumn.replace(`{{status}}`,e.title),onClick:()=>se(e.status),children:(0,J.jsx)(qe,{className:`size-4`,"aria-hidden":!0})})]})]},e.status))})}),!u&&D?(0,J.jsx)(x,{type:`button`,variant:`secondary`,className:`justify-self-center`,onClick:()=>void L(`append`,s.length),children:r.loadMore}):null,(0,J.jsx)(fn,{mode:k?`create`:N?`detail`:null,item:N,initialStatus:j,events:F,busy:v,error:m,notice:g,t:r,onClose:()=>{A(!1),P(null),I([]),h(null),_(null)},onCreate:ee,onSave:(e,t)=>void V(e,t),onStartChat:W,onCreateGoal:re,onAddAttachments:(e,t)=>void te(e,t),onRemoveAttachment:(e,t)=>void ne(e,t),onDownloadAttachment:(e,t)=>void U(e,t),onPreviewError:e=>{_(null),h(e)}})]})}var mn=[{id:`overview`,icon:Ve},{id:`work-items`,icon:Xe},{id:`sessions`,icon:Ee},{id:`goals`,icon:Ce},{id:`workflows`,icon:U},{id:`files`,icon:W},{id:`activity`,icon:yt},{id:`automations`,icon:te},{id:`notes`,icon:pe},{id:`skills`,icon:it},{id:`settings`,icon:Ie}],hn=new Set([`work-items`,`goals`,`workflows`,`automations`]),gn=new Set(mn.map(e=>e.id)),X=`xopc.projectFiles.panelWidthPx`,_n=320,vn=220,yn=560;function bn(e){return Math.min(yn,Math.max(vn,Math.round(e)))}function xn(){try{let e=window.localStorage.getItem(X);if(e==null)return _n;let t=Number.parseInt(e,10);return Number.isFinite(t)?bn(t):_n}catch{return _n}}function Sn(e){try{window.localStorage.setItem(X,String(bn(e)))}catch{}}function Cn(e){return!!(e&&gn.has(e))}function wn(e){return hn.has(e)}function Tn(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function En(e,t=``){if(!e)return t;let n=new Date(e);return Number.isNaN(n.getTime())?String(e):_t(n)}function Dn(e){return e===`active`?`bg-accent-soft text-accent-fg`:e===`done`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`paused`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`archived`?`bg-surface-muted text-fg-subtle`:`bg-surface-hover text-fg-muted`}function On(e){return e===`succeeded`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`||e===`cancelled`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`running`||e===`queued`?`bg-accent-soft text-accent-fg`:`bg-surface-hover text-fg-muted`}function kn(e){let t=(0,q.c)(8),{label:n,hint:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,J.jsx)(`span`,{className:`text-xs leading-5 text-fg-subtle`,children:r}):null,t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function An(e=!1){return l(`w-full rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,e?`min-h-24 py-2 leading-5`:`min-h-10`)}function jn(e){let t=(0,q.c)(10),{label:n,value:r,mono:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=(0,J.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n}),t[0]=n,t[1]=o);let s=a&&`font-mono text-xs`,c;t[2]===s?c=t[3]:(c=l(`mt-1 min-w-0 truncate text-sm text-fg`,s),t[2]=s,t[3]=c);let u;t[4]!==c||t[5]!==r?(u=(0,J.jsx)(`div`,{className:c,title:r,children:r}),t[4]=c,t[5]=r,t[6]=u):u=t[6];let d;return t[7]!==o||t[8]!==u?(d=(0,J.jsxs)(`div`,{className:`min-w-0 rounded-md bg-surface-base px-3 py-2`,children:[o,u]}),t[7]=o,t[8]=u,t[9]=d):d=t[9],d}function Mn(e){return[e.name,e.slug,e.workspaceRoot,e.description,e.brief].filter(Boolean).join(` `).toLowerCase()}function Nn(e){let t=e.lastActiveAt??e.updatedAt??e.createdAt,n=t?new Date(t).getTime():0;return Number.isFinite(n)?n:0}function Pn(e){return e.trim().replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??``}function Fn(e){let t=e?.body;return t?.code===`workspace_root_missing`&&t.workspaceRoot?t.workspaceRoot:null}function In(e){let t=e.actor;return t.name?t.name:t.agentId?t.agentId:t.id?t.id:t.sessionKey?t.sessionKey:t.kind}function Ln(e){return e.primaryObject.title?.trim()||e.primaryObject.id}function Rn(e){let t=e.source;return t.toolCallId?`${t.kind} · ${t.toolCallId}`:t.runId?`${t.kind} · ${t.runId}`:t.requestId?`${t.kind} · ${t.requestId}`:t.kind}function zn(e){let t=e.sourceChannel?.trim();if(t)return Bn(t);let n=e.key.split(`:`).filter(Boolean),r=(n[0]?.toLowerCase()===`agent`?n.slice(2).join(`:`):e.key).split(`:`)[0]?.split(/[-_]/)[0]?.trim();return Bn(r||``)}function Bn(e){let t=e.trim().toLowerCase();return t?t===`tui`?`TUI`:t===`acp`?`ACP`:t===`webchat`?`Webchat`:t:``}function Vn(e){let t=e.payload.changes;if(Array.isArray(t)&&t.length)return t.filter(e=>typeof e==`string`).join(`, `);let n=e.payload.contentPreview;if(typeof n==`string`&&n.trim())return n.trim();let r=e.payload.title??e.payload.name;return typeof r==`string`&&r.trim()?r.trim():``}function Hn(e){return e.map(e=>({name:e.name,path:e.path,absolutePath:e.absolutePath,isDirectory:e.type===`directory`,children:e.type===`directory`?[]:void 0}))}function Un(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:Un(e.children,t,n)}:e)}function Wn({currentProject:e,pm:t,projectsText:n,wd:r}){let i=a(),[o,c]=(0,K.useState)(!1),[u,d]=(0,K.useState)([e]),[f,p]=(0,K.useState)(``),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(null),[v,y]=(0,K.useState)(!1),[S,C]=(0,K.useState)(`new`),[T,E]=(0,K.useState)(``),[D,O]=(0,K.useState)(``),[k,j]=(0,K.useState)(!1),[M,P]=(0,K.useState)(null),[F,I]=(0,K.useState)(null),L=(0,K.useCallback)(async()=>{h(!0),_(null);try{let t=await ve({limit:100});d(n=>{let r=new Map;r.set(e.id,e);for(let e of n)r.set(e.id,e);for(let e of t.items)r.set(e.id,e);return Array.from(r.values())})}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}},[e]);(0,K.useEffect)(()=>{d(t=>[e,...t.filter(t=>t.id!==e.id)])},[e]),(0,K.useEffect)(()=>{o&&L()},[L,o]);let R=(0,K.useMemo)(()=>{let t=f.trim().toLowerCase().split(/\s+/).filter(Boolean);return u.filter(t=>t.id!==e.id).filter(e=>{if(t.length===0)return!0;let n=Mn(e);return t.every(e=>n.includes(e))}).sort((e,t)=>Nn(t)-Nn(e))},[e.id,u,f]),z=e=>t.statuses[e.status]??e.status,B=e=>e.workspaceRoot||e.effectiveWorkspaceRoot||e.description||e.brief||t.common.defaultWorkspace,V=e=>{C(e),E(``),O(``),P(null),y(!0),c(!1)},H=(0,K.useCallback)(async(e={})=>{let t=D.trim(),n=T.trim()||(S===`directory`?Pn(t):``);if(n){j(!0),P(null),I(null);try{let r=await b({name:n,...t?{workspaceRoot:t}:{},...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}});y(!1),E(``),O(``),d(e=>[r,...e.filter(e=>e.id!==r.id)]),i(`/projects/${encodeURIComponent(r.id)}`)}catch(e){let t=Fn(e);t?(I(t),y(!1)):P(e instanceof Error?e.message:String(e))}finally{j(!1)}}},[S,T,i,D]),ee=(0,K.useCallback)(e=>{e.preventDefault(),H()},[H]),te=(0,K.useCallback)(()=>{H({createWorkspaceRoot:!0})},[H]),ne=(0,K.useCallback)(()=>{I(null),y(!0)},[]),U=e=>{O(e),S===`directory`&&!T.trim()&&E(Pn(e))},re=(e,t)=>(0,J.jsxs)(`button`,{type:`button`,className:l(`grid w-full grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-2 rounded-md p-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,t&&`bg-accent-soft/55 hover:bg-accent-soft/70`),onClick:()=>{c(!1),t||i(`/projects/${encodeURIComponent(e.id)}`)},children:[(0,J.jsx)(s,{className:l(`size-4 text-accent-fg`,!t&&`invisible`),"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,J.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:B(e)})]}),(0,J.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,Dn(e.status)),children:z(e)})]},e.id);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(He,{open:o,onOpenChange:c,children:[(0,J.jsx)(G,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`group flex max-w-full min-w-0 items-center gap-2 rounded-lg px-2 py-1 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":t.projectSwitcher.switchProject,title:t.projectSwitcher.switchProject,children:[(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:e.name}),(0,J.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,Dn(e.status)),children:z(e)})]}),(0,J.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:B(e)})]}),(0,J.jsx)(vt,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-data-[state=open]:rotate-180`,"aria-hidden":!0})]})}),(0,J.jsx)(Qe,{children:(0,J.jsxs)(at,{side:`bottom`,align:`start`,sideOffset:6,className:`z-[70] w-[min(26rem,calc(100vw-2rem))] overflow-hidden rounded-xl border border-edge bg-surface-panel p-1.5 shadow-popover outline-none`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,J.jsxs)(`label`,{className:`relative block`,children:[(0,J.jsx)(Re,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`search`,className:`h-9 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:f,onChange:e=>p(e.target.value),placeholder:t.projectSwitcher.searchPlaceholder,"aria-label":t.projectSwitcher.searchPlaceholder})]}),(0,J.jsxs)(`div`,{className:`mt-1 max-h-[min(54vh,24rem)] overflow-y-auto pr-0.5 [scrollbar-gutter:stable]`,children:[(0,J.jsx)(`div`,{className:`px-2 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.current}),re(e,!0),(0,J.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.recent}),g?(0,J.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:g}):null,m&&R.length===0?(0,J.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.loading}):null,!m&&R.length===0?(0,J.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.noMatches}):null,R.map(e=>re(e,!1))]}),(0,J.jsxs)(`div`,{className:`mt-1 border-t border-edge-subtle pt-1`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>V(`new`),children:[(0,J.jsx)(qe,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.newProject})]}),(0,J.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>V(`directory`),children:[(0,J.jsx)(W,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.openDirectory})]}),(0,J.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>{c(!1),i(`/projects`)},children:[(0,J.jsx)(Ie,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.manageProjects})]})]})]})})]}),(0,J.jsx)(Et,{open:v,onOpenChange:e=>!k&&y(e),children:(0,J.jsxs)(xe,{children:[(0,J.jsx)(_e,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,J.jsxs)(ye,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(32rem,calc(100vh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,J.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,J.jsx)(A,{className:`text-base font-semibold text-fg`,children:S===`directory`?t.projectSwitcher.createFromDirectoryTitle:n.createTitle}),(0,J.jsx)(N,{className:`mt-1 text-sm text-fg-muted`,children:S===`directory`?t.projectSwitcher.createFromDirectoryDescription:n.createDescription})]}),(0,J.jsxs)(`form`,{onSubmit:ee,className:`flex min-h-0 flex-1 flex-col`,children:[(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[M?(0,J.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:M}):null,(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.projectName}),(0,J.jsx)(`input`,{className:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:T,onChange:e=>E(e.target.value),placeholder:`xopc`})]}),(0,J.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.workspaceRoot}),(0,J.jsx)(kt,{value:D,onChange:U,disabled:k,wd:r,placeholder:n.workspacePlaceholder,inputClassName:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`}),(0,J.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.workspaceHint})]})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,J.jsx)(w,{asChild:!0,children:(0,J.jsx)(x,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:k,children:n.cancel})}),(0,J.jsxs)(x,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:k||!(T.trim()||S===`directory`&&Pn(D)),children:[(0,J.jsx)(qe,{className:`size-4`,"aria-hidden":!0}),n.create]})]})]})]})]})}),(0,J.jsx)(Et,{open:!!F,onOpenChange:e=>{e||I(null)},children:(0,J.jsxs)(xe,{children:[(0,J.jsx)(_e,{className:`fixed inset-0 z-[100] bg-scrim backdrop-blur-[2px]`}),(0,J.jsxs)(ye,{className:`fixed left-1/2 top-1/2 z-[110] flex w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,J.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,J.jsx)(A,{className:`text-base font-semibold text-fg`,children:n.workspaceMissingTitle}),(0,J.jsx)(N,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:F?Tn(n.workspaceMissingDescription,{workspace:F}):null})]}),F?(0,J.jsx)(`div`,{className:`px-5 py-4`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,J.jsx)(W,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:F})]})}):null,(0,J.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,J.jsx)(x,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:ne,disabled:k,children:n.workspaceMissingBack}),(0,J.jsxs)(x,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:te,disabled:k,children:[(0,J.jsx)(se,{className:`size-4`,"aria-hidden":!0}),n.workspaceMissingCreate]})]})]})]})})]})}function Gn(){let{projectId:e=``,tabId:t,noteId:n}=i(),r=a(),s=d(p(e=>e.language)),f=s.chat.workingDirectory,m=s.projectDetailPage,h=s.projectsPage,g=he(e=>e.setPageHeader),_=he(e=>e.clearPageHeader),[v,b]=(0,K.useState)(null),[C,k]=(0,K.useState)(null),[P,R]=(0,K.useState)([]),[ae,ve]=(0,K.useState)(``),[Se,we]=(0,K.useState)([]),[Oe,ke]=(0,K.useState)([]),[je,Me]=(0,K.useState)([]),[Fe,Le]=(0,K.useState)([]),[G,ze]=(0,K.useState)([]),[Be,He]=(0,K.useState)(!1),[Ue,Je]=(0,K.useState)(null),[Ze,Qe]=(0,K.useState)([]),[$e,nt]=(0,K.useState)(0),[at,ft]=(0,K.useState)(!1),[gt,_t]=(0,K.useState)(!1),[vt,Tt]=(0,K.useState)(!1),[Nt,Pt]=(0,K.useState)([]),Ft=(0,K.useRef)(new Set),[q,It]=(0,K.useState)(null),[Lt,Rt]=(0,K.useState)(xn),[zt,Bt]=(0,K.useState)(!1),[Vt,Ut]=(0,K.useState)(!1),[Wt,Gt]=(0,K.useState)(``),[Kt,qt]=(0,K.useState)([]),[Jt,Yt]=(0,K.useState)(!1),[Xt,Zt]=(0,K.useState)(null),[Qt,$t]=(0,K.useState)(!1),[en,tn]=(0,K.useState)(null),[nn,rn]=(0,K.useState)([]),[Y,an]=(0,K.useState)(``),[on,sn]=(0,K.useState)(!0),[cn,ln]=(0,K.useState)(!1),[un,dn]=(0,K.useState)(!1),[fn,mn]=(0,K.useState)(null),[hn,gn]=(0,K.useState)(!1),[X,_n]=(0,K.useState)(`fixed`),[vn,yn]=(0,K.useState)(``),[Mn,Nn]=(0,K.useState)(null),[Pn,Bn]=(0,K.useState)(!1),[Gn,Kn]=(0,K.useState)(!1),[qn,Jn]=(0,K.useState)(0),[Yn,Xn]=(0,K.useState)(!1),[Zn,Qn]=(0,K.useState)(null),[$n,er]=(0,K.useState)(!1),[tr,nr]=(0,K.useState)(!1),[rr,ir]=(0,K.useState)(!1),[ar,Z]=(0,K.useState)(null),[or,sr]=(0,K.useState)({defaultAgentId:``,agents:[],models:[],checklistDecomposePolicy:`empty_only`}),[cr,lr]=(0,K.useState)({title:``,reason:``}),[Q,ur]=(0,K.useState)({name:``,description:``,status:`active`,defaultAgentId:``,workspaceRoot:``,brief:``,instructions:``}),dr=`overview`,$=n?`notes`:Cn(t)?t:dr,fr=(0,K.useCallback)(t=>{e&&r(`/projects/${encodeURIComponent(e)}/${t}`)},[r,e]),pr=(0,K.useCallback)(t=>e?`/projects/${encodeURIComponent(e)}/${t}`:`/projects`,[e]),mr=(0,K.useCallback)(e=>{let t=pr(`goals`);return`/goals/${encodeURIComponent(e)}?returnTo=${encodeURIComponent(t)}`},[pr]),hr=(0,K.useCallback)(t=>{e&&r(pr(t),{replace:!0})},[r,e,pr]),gr=(0,K.useCallback)((e,t)=>{hr(e),r(t)},[r,hr]),_r=(0,K.useCallback)(e=>t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||hr(e)},[hr]),vr=(0,K.useCallback)(e=>e.startsWith(`/goals/`)?`goals`:e.startsWith(`/chat/`)?`sessions`:e.startsWith(`/workflows`)?`workflows`:e.startsWith(`/automations`)?`automations`:e.startsWith(`/notes`)?`notes`:$,[$]);(0,K.useEffect)(()=>{!e||!t||Cn(t)||r(`/projects/${encodeURIComponent(e)}/${dr}`,{replace:!0})},[dr,r,e,t]),(0,K.useEffect)(()=>{if(!e)return;let t=!1;return sn(!0),Z(null),Promise.all([Ct(e),S(e),fe(e),j().catch(()=>null)]).then(([e,n,r,i])=>{if(t)return;let a=e.project;b(a),k(e),R(n),we(r),rn(i?.agents??[]),an(a.defaultAgentId??``),ur({name:a.name,description:a.description??``,status:a.status,defaultAgentId:a.defaultAgentId??``,workspaceRoot:a.workspaceRoot??``,brief:a.brief??``,instructions:a.instructions??``})}).catch(e=>{t||Z(e instanceof Error?e.message:String(e))}).finally(()=>{t||sn(!1)}),()=>{t=!0}},[e]),(0,K.useEffect)(()=>{let e=!1;async function t(){let[t,n,r]=await Promise.allSettled([j(),de(),Pe()]);e||sr(e=>{let i=t.status===`fulfilled`?t.value.defaultId:e.defaultAgentId,a=v?.defaultAgentId||Y||i,o=t.status===`fulfilled`?t.value.agents:e.agents,s=n.status===`fulfilled`?n.value:e.models,c=r.status===`fulfilled`?At(r.value.payload?.config).checklistDecomposePolicy:e.checklistDecomposePolicy;return{defaultAgentId:a,agents:o.length?o:[{id:a||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],models:s,checklistDecomposePolicy:c}})}return t(),()=>{e=!0}},[v?.defaultAgentId,Y]);let yr=(0,K.useCallback)(async()=>{if(v){Xn(!0),Z(null);try{let[e,t]=await Promise.all([y(),H(100,{ownerAgentId:Y||void 0,projectId:v.id})]);ke(e),Me(t)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Xn(!1)}}},[v,Y]);(0,K.useEffect)(()=>{v&&yr()},[v,yr]);let br=(0,K.useCallback)(async()=>{if(v){He(!0),Z(null);try{let[e,t]=await Promise.all([bt.list({projectId:v.id}),bt.runs(50,void 0,{projectId:v.id})]);Le(e.automations),ze(t.runs)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{He(!1)}}},[v]);(0,K.useEffect)(()=>{$===`automations`&&br()},[br,$]);let xr=(0,K.useCallback)(async()=>{if(v){ft(!0),Z(null);try{let e=await F(v.id,{includeRelated:gt,limit:100});Qe(e.items),nt(e.total)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{ft(!1)}}},[v,gt]);(0,K.useEffect)(()=>{$===`activity`&&xr()},[xr,$]);let Sr=(0,K.useCallback)(async e=>{Je(`run:${e.id}`),Z(null);try{await bt.runNow(e.id),await br()}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Je(null)}},[br]),Cr=(0,K.useCallback)(async e=>{Je(`toggle:${e.id}`),Z(null);try{e.enabled?await bt.pause(e.id):await bt.resume(e.id),await br()}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Je(null)}},[br]),wr=(0,K.useCallback)(async()=>{if(!v?.effectiveWorkspaceRoot?.trim()){Pt([]),Ft.current.clear(),tn(null);return}$t(!0),tn(null),Ft.current.clear();try{Pt(Hn((await B(v.id,``)).entries)),Ft.current.add(``)}catch(e){Pt([]),Ft.current.clear(),tn(e instanceof Error?e.message:String(e))}finally{$t(!1)}},[v]),Tr=(0,K.useCallback)(async e=>{if(!(!v?.effectiveWorkspaceRoot?.trim()||Ft.current.has(e))){Ft.current.add(e),tn(null);try{let t=await B(v.id,e);Pt(n=>Un(n,e,Hn(t.entries)))}catch(t){Ft.current.delete(e),tn(t instanceof Error?t.message:String(t))}}},[v]);(0,K.useEffect)(()=>{$===`files`&&wr()},[wr,$]);let Er=Wt.trim();(0,K.useEffect)(()=>{if($!==`files`||!v||!Vt||!Er){qt([]),Yt(!1),Zt(null);return}let e=!1;Yt(!0),Zt(null),qt([]);let t=window.setTimeout(()=>{O(v.id,Er,50).then(t=>{e||qt(t)}).catch(t=>{e||Zt(t instanceof Error?t.message:String(t))}).finally(()=>{e||Yt(!1)})},180);return()=>{e=!0,window.clearTimeout(t)}},[Er,v,Vt,$]);let Dr=(0,K.useCallback)(async()=>{if(v){Kn(!0),Z(null);try{let e=await ne(v.id);gr(`sessions`,`/chat/${encodeURIComponent(e.key)}`)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Kn(!1)}}},[gr,v]),Or=(0,K.useCallback)(()=>{fr(`work-items`),Jn(e=>e+1)},[fr]),kr=(0,K.useCallback)(async()=>{if(!v)return;let[e,t]=await Promise.all([Ct(v.id),fe(v.id)]);k(e),b(e.project),we(t)},[v]),Ar=(0,K.useCallback)(async e=>{if(!v||!e.title.trim())return;let t=Number.parseInt(e.maxTurns,10),n=e.deadline?new Date(e.deadline).getTime():void 0;er(!0),Z(null);try{await ee(v.id,{title:e.title.trim(),description:e.description.trim()||void 0,attachments:e.attachments.length?e.attachments:void 0,priority:e.priority,deadlineAt:Number.isFinite(n)?n:void 0,maxTurns:Number.isFinite(t)?t:void 0,agentId:e.agentId.trim()||void 0,judgeModelRef:e.judgeModelRef.trim()||void 0,contract:{objective:e.objective.trim()||e.title.trim(),scopeBoundary:e.scopeBoundary.trim()||void 0,evidencePlan:jt(e.evidencePlan),criteria:jt(e.checklist)}}),ir(!1),fr(`goals`),await kr()}catch(e){throw Z(e instanceof Error?e.message:String(e)),e}finally{er(!1)}},[fr,v,kr]),jr=(0,K.useCallback)(async e=>{if(e.preventDefault(),!(!v||!cr.title.trim())){nr(!0),Z(null);try{await Ke(v.id,{title:cr.title.trim(),reason:cr.reason.trim()||void 0}),lr({title:``,reason:``}),await kr()}catch(e){Z(e instanceof Error?e.message:String(e))}finally{nr(!1)}}},[cr.reason,cr.title,v,kr]),Mr=(0,K.useCallback)(async e=>{if(v){Qn(`retry:${e.id}`),Z(null);try{let t=await E(e.id,{ownerAgentId:Y||e.metadata?.agentId,projectId:e.metadata?.projectId||v.id});await yr(),gr(`workflows`,ht(t.runId,{ownerAgentId:Y||e.metadata?.agentId||v.defaultAgentId}))}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Qn(null)}}},[gr,v,yr,Y]),Nr=(0,K.useCallback)(async e=>{Qn(`cancel:${e.id}`),Z(null);try{await T(e.id,{ownerAgentId:Y||e.metadata?.agentId}),await yr()}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Qn(null)}},[yr,Y]),Pr=(0,K.useMemo)(()=>(0,J.jsx)(o,{to:`/projects`,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":m.backToProjects,children:(0,J.jsx)(ce,{className:`size-4`,"aria-hidden":!0})}),[m.backToProjects]),Fr=(0,K.useMemo)(()=>v?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(x,{variant:`secondary`,className:`h-9 rounded-lg`,onClick:Or,children:[(0,J.jsx)(qe,{className:`size-4`,"aria-hidden":!0}),m.workItems.create.header]}),(0,J.jsxs)(x,{variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>void Dr(),disabled:Gn,children:[(0,J.jsx)(Ee,{className:`size-4`,"aria-hidden":!0}),m.common.newChat]})]}):null,[Or,m.common.newChat,m.workItems.create.header,v,Dr,Gn]);(0,K.useLayoutEffect)(()=>(g({startExtra:Pr,main:v?(0,J.jsx)(Wn,{currentProject:v,pm:m,projectsText:h,wd:f}):(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:m.fallbackTitle}),(0,J.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:m.fallbackContext})]}),end:Fr}),()=>_()),[_,Fr,Pr,m,v,h,g,f]);function Ir(e){b(t=>t?{...t,...e}:null),k(t=>t?{...t,project:{...t.project,...e}}:null),an(e.defaultAgentId??``),ur(t=>({...t,name:e.name,description:e.description??``,status:e.status,defaultAgentId:e.defaultAgentId??``,workspaceRoot:e.workspaceRoot??``,brief:e.brief??``,instructions:e.instructions??``})),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}async function Lr(){if(!(!v||!Q.name.trim())){ln(!0),Z(null),mn(null);try{Ir(await ot(v.id,{name:Q.name.trim(),status:Q.status,description:Q.description,defaultAgentId:Q.defaultAgentId,brief:Q.brief,instructions:Q.instructions}))}catch(e){let t=Fn(e);t?mn(t):Z(e instanceof Error?e.message:String(e))}finally{ln(!1)}}}function Rr(e){e.preventDefault(),Lr()}let zr=(0,K.useCallback)(()=>{if(!v)return;let e=v.workspaceRoot?.trim()??``;_n(e?`fixed`:`follow`),yn(e||v.effectiveWorkspaceRoot||``),gn(!0)},[v]);async function Br(e={}){if(!v)return;let t=X===`fixed`?vn.trim():``;if(!(X===`fixed`&&!t)){ln(!0),Z(null),mn(null);try{Ir(await ot(v.id,{workspaceRoot:t,...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}})),gn(!1),mn(null)}catch(e){let t=Fn(e);t?(mn(t),gn(!1)):Z(e instanceof Error?e.message:String(e))}finally{ln(!1)}}}async function Vr(){if(!(!v||Mn)){Nn(`pin`),Z(null);try{Ir(v.pinnedAt?await L(v.id):await M(v.id))}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Nn(null)}}}async function Hr(){if(!(!v||Mn)){Nn(`archive`),Z(null);try{Ir(v.status===`archived`?await ge(v.id):await Ye(v.id))}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Nn(null)}}}async function Ur(){if(v){Bn(!0),Z(null);try{await oe(v.id),dn(!1),r(`/projects`)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Bn(!1)}}}async function Wr(){if(!(!v||vt)){Tt(!0),Z(null);try{await be(v.id)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Tt(!1)}}}let Gr=(0,K.useCallback)(e=>{It(e)},[]),Kr=(0,K.useCallback)((e,t)=>{t||It(e)},[]),qr=(0,K.useCallback)(async(e,t,n)=>{let r=v?.id;if(r)switch(e){case`preview`:t.isDirectory||It(t.path);break;case`download`:if(t.isDirectory)return;try{let e=le(t.path);if(Ne(De(e))!==`text`){let n=await st(t.path,{projectId:r}),i=Te(e)??`application/octet-stream`;mt(e,await n.arrayBuffer(),i)}else{let{content:n}=await We(t.path,{projectId:r});et(e,n)}}catch(e){pt(`warning`,e instanceof Error?e.message:String(e),void 0,{duration:4e3})}break;case`copyPath`:try{await u(t.absolutePath??t.path)&&pt(`success`,s.workspace.pathCopied,void 0,{duration:2500})}catch{pt(`warning`,s.clipboard.copyFailed,void 0,{duration:4e3})}break;case`openDefault`:if(!t.absolutePath||!window.electronAPI?.shell?.openPath)return;await window.electronAPI.shell.openPath(t.absolutePath);break;case`openWith`:if(!t.absolutePath||!window.electronAPI?.shell?.chooseAppAndOpenPath)return;await window.electronAPI.shell.chooseAppAndOpenPath(t.absolutePath);break;case`openWithApp`:if(!t.absolutePath||!n||!window.electronAPI?.shell?.openPathWithApp)return;await window.electronAPI.shell.openPathWithApp(t.absolutePath,n);break;case`revealInFolder`:if(!t.absolutePath||!window.electronAPI?.shell?.showItemInFolder)return;await window.electronAPI.shell.showItemInFolder(t.absolutePath);break;default:break}},[s.clipboard.copyFailed,s.workspace.pathCopied,v?.id]),Jr=(0,K.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;e.preventDefault();let t=e.currentTarget,n=t.closest(`[data-project-files-grid]`);if(!n)return;t.setPointerCapture(e.pointerId),Bt(!0);let r=e.clientX,i=Lt,a=e.pointerId,o=0,s=i,c=i,l=()=>{o=0,c=s,n.style.setProperty(`--project-files-panel-width`,`${c}px`)},u=e=>{s=bn(i+(e.clientX-r)),o===0&&(o=window.requestAnimationFrame(l))},d=()=>{o!==0&&(window.cancelAnimationFrame(o),l());try{t.releasePointerCapture(a)}catch{}Bt(!1),Rt(c),Sn(c),window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d)};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},[Lt]);if((0,K.useEffect)(()=>{$!==`files`&&It(null)},[e,$]),on)return(0,J.jsx)(`main`,{className:`w-full flex-1 p-3 text-sm text-fg-muted sm:px-5 sm:py-4 xl:px-6`,children:m.loading});if(!v)return(0,J.jsxs)(`main`,{className:`w-full flex-1 p-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,J.jsxs)(o,{to:`/projects`,className:`inline-flex items-center gap-2 text-sm text-accent-fg hover:underline`,children:[(0,J.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),m.backToProjects]}),(0,J.jsx)(`p`,{className:`mt-6 rounded-lg bg-surface-panel p-4 shadow-surface text-sm text-fg-muted`,children:ar||m.notFound})]});let Yr=C?.recentSessions.length?C.recentSessions:v.recentSessions,Xr=C?.attentionItems??[],Zr=e=>m.statuses[e]??e,Qr=e=>Tn(m.common.messages,{count:e}),$r=ae.trim().toLowerCase(),ei=$r?P.filter(e=>{let t=En(e.updatedAt),n=e.routing?.agentId||e.agentId||m.common.agent,r=e.name?.trim()||m.sessions.fallbackTitle,i=Qr(e.messageCount??0),a=zn(e);return[r,e.key,n,a,t,i].filter(Boolean).join(` `).toLowerCase().includes($r)}):P,ti=P.length>0&&ei.length===0,ni=nn.find(e=>e.id===Q.defaultAgentId)?.name||Q.defaultAgentId||m.settings.globalDefaultAgent,ri=nn.find(e=>e.id===Q.defaultAgentId),ii=v.workspaceRoot?.trim()||``,ai=v.status===`archived`,oi=!!v.pinnedAt,si=!ii,ci=ii||ri?.workspace||v.effectiveWorkspaceRoot||m.common.defaultWorkspace,li=X===`fixed`?vn.trim()||m.settings.workspacePlaceholder:ri?.workspace||v.effectiveWorkspaceRoot||m.common.defaultWorkspace,ui=(X===`fixed`?vn.trim():``)!==ii&&(X===`follow`||!!vn.trim()),di=[{id:`overview`,icon:Ve,label:m.tabs.overview},{id:`work`,icon:Xe,label:m.tabs.work},{id:`files`,icon:W,label:m.tabs.files},{id:`notes`,icon:pe,label:m.tabs.notes},{id:`skills`,icon:it,label:m.tabs.skills},{id:`sessions`,icon:Ee,label:m.tabs.sessions},{id:`activity`,icon:yt,label:m.tabs.activity}],fi=[{id:`work-items`,icon:Xe,label:m.tabs.workItems},{id:`goals`,icon:Ce,label:m.tabs.goals},{id:`workflows`,icon:U,label:m.tabs.workflows},{id:`automations`,icon:te,label:m.tabs.automations}],pi=wn($)?`work`:$;async function mi(){if(!ci)return;let e=await u(ci);pt(e?`success`:`warning`,e?s.workspace.pathCopied:s.clipboard.copyFailed,void 0,{duration:e?2500:4e3})}function hi(){mn(null),gn(!0)}return(0,J.jsxs)(`main`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden p-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3`,children:[(0,J.jsx)(Ot,{items:di,activeTab:pi,onChange:e=>fr(e===`work`?`work-items`:e),ariaLabel:m.navAria,tabIdPrefix:`project-primary-tab`,className:`min-w-0 flex-1`}),(0,J.jsxs)(x,{id:`project-primary-tab-settings`,type:`button`,variant:$===`settings`?`secondary`:`ghost`,className:`h-9 shrink-0 rounded-lg px-3`,"aria-current":$===`settings`?`page`:void 0,onClick:()=>fr(`settings`),children:[(0,J.jsx)(Ie,{className:`size-4`,"aria-hidden":!0}),m.tabs.settings]})]}),ar?(0,J.jsx)(`p`,{className:`mt-3 shrink-0 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:ar}):null,wn($)?(0,J.jsx)(`div`,{className:`mt-3 shrink-0 rounded-xl border border-edge-subtle bg-surface-panel px-2 py-1 shadow-surface`,children:(0,J.jsx)(Ot,{items:fi,activeTab:$,onChange:fr,ariaLabel:m.workNavAria,tabIdPrefix:`project-work-tab`,panelIdPrefix:`project-panel`,buttonClassName:`h-8 px-2.5 py-1.5 text-xs`})}):null,(0,J.jsxs)(`div`,{className:l(`mt-3 min-h-0 flex-1`,$===`work-items`?`-mx-3 -mb-3 overflow-hidden sm:-mx-5 sm:-mb-4 xl:-mx-6`:$===`overview`?`overflow-y-auto pr-1 [scrollbar-gutter:stable] xl:overflow-hidden xl:pr-0`:`overflow-y-auto pr-1 [scrollbar-gutter:stable]`),children:[$===`overview`?(0,J.jsxs)(`section`,{id:`project-panel-overview`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-overview`,className:`grid min-h-full gap-4 xl:h-full xl:min-h-0 xl:grid-cols-[minmax(0,1fr)_20rem] xl:overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`grid min-w-0 content-start gap-4 xl:min-h-0 xl:overflow-y-auto xl:pr-1 xl:[scrollbar-gutter:stable]`,children:[(0,J.jsx)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel p-4 shadow-surface`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.overview.directionTitle}),(0,J.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:C?.digest?.summary||C?.recommendedAction||v.description||v.brief||m.overview.directionFallback}),C?.digest?.nextAction?(0,J.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm font-medium leading-6 text-fg`,children:Tn(m.overview.recommendedNext,{action:C.digest.nextAction})}):null]}),(0,J.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:(0,J.jsxs)(x,{type:`button`,variant:`secondary`,onClick:()=>void Wr(),disabled:vt,children:[(0,J.jsx)(St,{className:`size-4`,"aria-hidden":!0}),vt?m.overview.savingDigest:m.overview.saveDigest]})})]})}),(0,J.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.overview.nextActions}),(0,J.jsxs)(x,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,onClick:()=>ir(!0),children:[(0,J.jsx)(qe,{className:`size-4`,"aria-hidden":!0}),m.overview.goal]})]}),(0,J.jsx)(`div`,{className:`divide-y divide-edge`,children:C?.nextActions.length?C.nextActions.map(e=>(0,J.jsxs)(o,{to:mr(e.goalId),onClick:_r(`goals`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,J.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Dn(e.status)),children:Zr(e.status)})]}),(0,J.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e.nextAction})]},e.goalId)):(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:m.overview.noNextActions})})]})]}),(0,J.jsxs)(`aside`,{className:`grid min-w-0 content-start gap-4 xl:min-h-0 xl:overflow-y-auto xl:pr-1 xl:[scrollbar-gutter:stable]`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.overview.attention}),Xr.length?(0,J.jsx)(`div`,{className:`mt-3 grid gap-3`,children:Xr.map(e=>{let t=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(c,{className:`size-4 text-amber-600 dark:text-amber-300`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title})]}),(0,J.jsxs)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:[m.overview.attentionKinds[e.kind]??e.kind,e.detail?` · ${e.detail}`:e.status?` · ${Zr(e.status)}`:``]})]});return e.href?(0,J.jsx)(o,{to:e.href,onClick:_r(vr(e.href)),className:`min-w-0 rounded-md bg-surface-base p-3 hover:bg-surface-hover`,children:t},e.id):(0,J.jsx)(`div`,{className:`min-w-0 rounded-md bg-surface-base p-3`,children:t},e.id)})}):(0,J.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:m.overview.noBlockedGoals}),(0,J.jsxs)(`form`,{onSubmit:jr,className:`mt-4 flex gap-2 border-t border-edge pt-4`,children:[(0,J.jsx)(`input`,{className:`min-h-9 min-w-0 flex-1 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:cr.title,onChange:e=>lr(t=>({...t,title:e.target.value})),placeholder:m.overview.blockerTitlePlaceholder}),(0,J.jsx)(x,{type:`submit`,variant:`secondary`,className:`shrink-0 rounded-lg px-3`,disabled:tr||!cr.title.trim(),"aria-label":tr?m.overview.addingBlocker:m.overview.addBlocker,title:tr?m.overview.addingBlocker:m.overview.addBlocker,children:(0,J.jsx)(qe,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,J.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(dt,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:m.overview.recentSessions})]}),(0,J.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>fr(`sessions`),children:m.common.viewAll})]}),(0,J.jsx)(`div`,{className:`divide-y divide-edge`,children:Yr.length?Yr.map(e=>(0,J.jsxs)(o,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:_r(`sessions`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.name||e.key}),(0,J.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:En(e.updatedAt)})]}),(0,J.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.agentId||m.common.agent})]},e.key)):(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:m.overview.noSessions})})]})]})]}):null,$===`work-items`?(0,J.jsx)(`section`,{id:`project-panel-work-items`,className:`flex h-full min-h-0 flex-col`,role:`tabpanel`,"aria-labelledby":`project-work-tab-work-items`,children:(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,J.jsx)(pn,{projectId:v.id,createRequestKey:qn})})}):null,$===`workflows`?(0,J.jsxs)(`section`,{id:`project-panel-workflows`,role:`tabpanel`,"aria-labelledby":`project-work-tab-workflows`,className:`grid h-full min-h-[28rem] gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,J.jsx)(`div`,{className:`min-h-0`,children:(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.workflows.runsTitle}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:m.workflows.runsHint})]}),(0,J.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:()=>void yr(),disabled:Yn,children:[(0,J.jsx)(xt,{className:`size-4`,"aria-hidden":!0}),m.common.refresh]})]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 divide-y divide-edge overflow-y-auto`,children:Yn&&je.length===0?(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:m.workflows.loadingRuns}):je.length?je.map(e=>{let t=e.status===`queued`||e.status===`running`,n=e.status===`failed`||e.status===`timeout`||e.status===`cancelled`;return(0,J.jsxs)(`div`,{className:`grid gap-2 px-4 py-3 hover:bg-surface-hover`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`button`,{type:`button`,className:`min-w-0 truncate text-left text-sm font-medium text-fg hover:text-accent-fg`,onClick:()=>gr(`workflows`,ht(e.id,{ownerAgentId:Y||e.metadata?.agentId||v.defaultAgentId})),children:e.title||e.definitionId}),(0,J.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,On(e.status)),children:Zr(e.status)})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:Tn(m.workflows.runMeta,{definitionId:e.definitionId,done:e.metrics.doneAgentCount,total:e.metrics.agentCount,time:En(e.createdAtMs)})}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(x,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,onClick:()=>gr(`workflows`,ht(e.id,{ownerAgentId:Y||e.metadata?.agentId||v.defaultAgentId})),children:m.common.open}),n?(0,J.jsxs)(x,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:Zn===`retry:${e.id}`,onClick:()=>void Mr(e),children:[(0,J.jsx)(xt,{className:`size-3.5`,"aria-hidden":!0}),m.common.retry]}):null,t?(0,J.jsxs)(x,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:Zn===`cancel:${e.id}`,onClick:()=>void Nr(e),children:[(0,J.jsx)(ct,{className:`size-3.5`,"aria-hidden":!0}),m.common.cancel]}):null]})]})]},e.id)}):(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:m.workflows.emptyRuns})})]})}),(0,J.jsx)(`aside`,{className:`min-h-0`,children:(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-4 py-3`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.workflows.startTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:m.workflows.startHint})]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:(0,J.jsx)(`div`,{className:`grid gap-2`,children:Oe.length?Oe.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`grid gap-1 rounded-md bg-surface-base p-3 text-left hover:bg-surface-hover focus:outline-none focus:ring-2 focus:ring-accent/30`,onClick:()=>r(`/workflows/${e.id}?projectId=${encodeURIComponent(v.id)}${Y?`&agentId=${encodeURIComponent(Y)}`:``}`),children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,J.jsx)(U,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}),(0,J.jsx)(`span`,{className:`line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description||e.metadata.whenToUse||e.name})]},e.id)):(0,J.jsx)(`div`,{className:`px-1 py-3 text-sm text-fg-muted`,children:m.workflows.emptyDefinitions})})})]})})]}):null,$===`automations`?(0,J.jsxs)(`section`,{id:`project-panel-automations`,role:`tabpanel`,"aria-labelledby":`project-work-tab-automations`,className:`grid h-full min-h-[28rem] overflow-hidden gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.automations.title}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:m.automations.hint})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:()=>void br(),disabled:Be,children:[(0,J.jsx)(xt,{className:`size-4`,"aria-hidden":!0}),m.common.refresh]}),(0,J.jsxs)(x,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>gr(`automations`,`/automations?projectId=${encodeURIComponent(v.id)}&action=create`),children:[(0,J.jsx)(qe,{className:`size-4`,"aria-hidden":!0}),m.common.new]})]})]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 divide-y divide-edge overflow-y-auto`,children:Be&&Fe.length===0?(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:m.automations.loading}):Fe.length?Fe.map(e=>{let t=G.find(t=>t.automationId===e.id),n=e.state.runningRunId?G.find(t=>t.id===e.state.runningRunId):null;return(0,J.jsxs)(`div`,{className:`grid gap-2 px-4 py-3 hover:bg-surface-hover`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`button`,{type:`button`,className:`min-w-0 truncate text-left text-sm font-medium text-fg hover:text-accent-fg`,onClick:()=>gr(`automations`,`/automations?automation=${encodeURIComponent(e.id)}`),children:e.name}),(0,J.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,e.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`),children:e.enabled?m.automations.enabled:m.automations.paused})]}),(0,J.jsx)(`p`,{className:`line-clamp-2 text-sm leading-5 text-fg-muted`,children:e.description||e.action.kind}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:Tn(m.common.lastRun,{trigger:e.trigger.kind,action:e.action.kind,time:t?En(t.createdAtMs):m.common.never})}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsxs)(x,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:Ue===`run:${e.id}`||!!n,onClick:()=>void Sr(e),children:[(0,J.jsx)(U,{className:`size-3.5`,"aria-hidden":!0}),m.automations.run]}),(0,J.jsxs)(x,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:Ue===`toggle:${e.id}`,onClick:()=>void Cr(e),children:[e.enabled?(0,J.jsx)(wt,{className:`size-3.5`,"aria-hidden":!0}):(0,J.jsx)(U,{className:`size-3.5`,"aria-hidden":!0}),e.enabled?m.automations.pause:m.automations.resume]})]})]})]},e.id)}):(0,J.jsxs)(`div`,{className:`grid gap-3 px-4 py-6 text-sm text-fg-muted`,children:[(0,J.jsx)(`p`,{children:m.automations.empty}),(0,J.jsx)(`div`,{children:(0,J.jsxs)(x,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:()=>gr(`automations`,`/automations?projectId=${encodeURIComponent(v.id)}&action=create`),children:[(0,J.jsx)(te,{className:`size-4`,"aria-hidden":!0}),m.automations.create]})})]})})]}),(0,J.jsxs)(`aside`,{className:`grid min-h-0 min-w-0 content-start gap-4 overflow-y-auto pr-1 [scrollbar-gutter:stable]`,children:[(0,J.jsxs)(`div`,{className:`rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsx)(`div`,{className:`border-b border-edge px-4 py-3`,children:(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.automations.recentRuns})}),(0,J.jsx)(`div`,{className:`divide-y divide-edge`,children:G.length?G.slice(0,8).map(e=>(0,J.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.automationName}),(0,J.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,On(e.status)),children:Zr(e.status)})]}),(0,J.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:En(e.createdAtMs)})]},e.id)):(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:m.automations.emptyRuns})})]}),(0,J.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.automations.contextTitle}),(0,J.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:m.automations.contextHint}),(0,J.jsx)(`p`,{className:`mt-3 break-all text-xs text-fg-subtle`,children:v.workspaceRoot||v.effectiveWorkspaceRoot||m.common.defaultWorkspace})]})]})]}):null,$===`notes`?(0,J.jsx)(`section`,{id:`project-panel-notes`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-notes`,className:`flex h-full min-h-[28rem] overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:(0,J.jsx)(Dt,{selectedNoteId:n,basePath:`/projects/${encodeURIComponent(v.id)}/notes`,showLibrary:!1,allowMediaCapture:!1,listTag:`project:${v.id}`,captureTags:[`project:${v.id}`,v.slug],listTitle:m.notes.title,listDescription:m.notes.hint,emptyText:m.notes.emptyTitle,emptyDescription:m.notes.emptyDescription,listWidthStorageKey:`xopc.projectNotes.listWidth.${v.id}`})}):null,$===`skills`?(0,J.jsx)(Ht,{projectId:v.id,copy:m.skills}):null,$===`files`?(0,J.jsx)(`section`,{id:`project-panel-files`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-files`,className:`flex h-full min-h-[28rem] flex-col`,children:(0,J.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:v.effectiveWorkspaceRoot?(0,J.jsxs)(`div`,{"data-project-files-grid":!0,className:l(`grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[var(--project-files-panel-width)_6px_minmax(0,1fr)]`,zt&&`cursor-col-resize select-none`),style:{"--project-files-panel-width":`${Lt}px`},children:[(0,J.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-b border-edge lg:border-b-0 lg:border-r`,children:[(0,J.jsxs)(`div`,{className:`flex h-11 items-center gap-1 border-b border-edge bg-surface-muted/50 px-3 text-sm`,children:[(0,J.jsx)(ie,{workspacePath:ci}),(0,J.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[(0,J.jsx)(`button`,{type:`button`,className:l(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,Vt&&`bg-surface-hover text-fg`),onClick:()=>Ut(!0),"aria-label":m.files.search,title:m.files.search,"aria-pressed":Vt,children:(0,J.jsx)(Re,{className:`size-3.5`,"aria-hidden":!0})}),(0,J.jsx)(rt,{className:`size-7 shrink-0 rounded-md p-0`,loading:Qt,label:s.cron.refresh,onClick:()=>void wr()})]})]}),Vt?(0,J.jsx)(`div`,{className:`shrink-0 border-b border-edge bg-surface-muted/40 px-3 py-2`,children:(0,J.jsxs)(`div`,{className:`flex h-8 items-center gap-2 rounded-md border border-edge bg-surface-panel px-2 focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/20`,children:[(0,J.jsx)(Re,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`text`,role:`searchbox`,value:Wt,onChange:e=>Gt(e.target.value),placeholder:m.files.searchPlaceholder,"aria-label":m.files.searchPlaceholder,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none placeholder:text-fg-subtle`}),(0,J.jsx)(`button`,{type:`button`,className:`flex size-6 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":m.files.clearSearch,title:m.files.clearSearch,onClick:()=>{Gt(``),Ut(!1)},children:(0,J.jsx)(re,{className:`size-3.5`,"aria-hidden":!0})})]})}):null,en?(0,J.jsx)(`div`,{className:`border-b border-edge bg-red-500/10 px-4 py-3 text-sm text-red-700 dark:text-red-300`,children:en}):null,Er?(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:Jt?(0,J.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,J.jsx)(lt,{className:`h-11 w-full`}),(0,J.jsx)(lt,{className:`h-11 w-full`}),(0,J.jsx)(lt,{className:`h-11 w-full`})]}):Xt?(0,J.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[s.workspace.loadError,`: `,Xt]}):Kt.length===0?(0,J.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:m.files.noSearchResults}):Kt.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:l(`flex w-full min-w-0 items-center gap-2 px-3 py-2 text-left hover:bg-surface-hover`,q===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>It(e.path),title:e.path,children:[(0,J.jsx)(pe,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.name}),(0,J.jsx)(`span`,{className:`block truncate text-xs text-fg-subtle`,children:e.path})]})]},e.path))}):Qt&&Nt.length===0?(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:m.files.loading}):(0,J.jsx)(Ae,{tree:Nt,selectedPath:q,onSelectFile:Gr,onSelectEntry:Kr,onExpandDir:e=>void Tr(e),onAction:qr,actionLabels:{preview:s.workspace.preview,download:s.workspace.download,copyPath:s.workspace.copyPath,openDefault:s.workspace.openSystemApp,openWith:s.workspace.openWith,revealInFolder:s.workspace.revealInFolder,recommendedApps:s.workspace.recommendedApps},emptyHint:m.files.emptyDirectory})]}),(0,J.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":m.files.resizeHandle,className:l(`hidden cursor-col-resize touch-none items-stretch justify-center bg-surface-panel transition-colors hover:bg-surface-hover lg:flex`,zt&&`bg-surface-hover`),onPointerDown:Jr,children:(0,J.jsx)(`div`,{className:`my-3 w-px rounded-full bg-edge-strong/70`})}),(0,J.jsx)(`div`,{className:`min-h-0 min-w-0 overflow-hidden bg-surface-base`,children:q?(0,J.jsx)(ut,{filePath:q,projectId:v.id,agentId:v.defaultAgentId||Y||void 0,onClose:()=>It(null)}):(0,J.jsx)(`div`,{className:`flex h-full min-h-[18rem] items-center justify-center px-6 text-center`,children:(0,J.jsxs)(`div`,{className:`max-w-sm`,children:[(0,J.jsx)(W,{className:`mx-auto size-8 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:m.files.previewEmptyTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:m.files.previewEmptyDescription})]})})})]}):(0,J.jsxs)(`div`,{className:`grid gap-3 px-4 py-8 text-sm text-fg-muted`,children:[(0,J.jsx)(`p`,{children:m.files.needWorkspace}),(0,J.jsx)(`div`,{children:(0,J.jsx)(x,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:()=>fr(`settings`),children:m.files.openSettings})})]})})}):null,$===`sessions`?(0,J.jsxs)(`section`,{id:`project-panel-sessions`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-sessions`,className:`grid min-h-full content-start gap-3`,children:[P.length?(0,J.jsxs)(`label`,{className:`relative flex min-h-9 w-full max-w-lg cursor-text items-center rounded-lg bg-surface-panel py-1.5 pl-9 pr-9 shadow-surface`,children:[(0,J.jsx)(Re,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:ae,onChange:e=>ve(e.currentTarget.value),placeholder:m.sessions.searchPlaceholder,"aria-label":m.sessions.searchPlaceholder,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),ae?(0,J.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":m.sessions.clearSearch,onClick:()=>ve(``),children:(0,J.jsx)(re,{className:`size-3.5`,"aria-hidden":!0})}):null]}):null,ei.length?(0,J.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:ei.map(e=>{let t=En(e.updatedAt),n=e.routing?.agentId||e.agentId||m.common.agent,r=zn(e),i=e.name?.trim()||m.sessions.fallbackTitle,a=Qr(e.messageCount??0);return(0,J.jsxs)(o,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:_r(`sessions`),className:`group flex min-h-[8.75rem] min-w-0 flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,J.jsx)(`span`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-base text-fg-muted`,children:(0,J.jsx)(Ee,{className:`size-4`,"aria-hidden":!0})}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-fg`,children:i}),r?(0,J.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-base px-2 py-0.5 text-[11px] font-medium leading-5 text-fg-muted`,children:r}):null]})})]}),(0,J.jsxs)(`div`,{className:`mt-auto grid gap-2 pt-4 text-xs text-fg-muted`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`span`,{className:`min-w-0 max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[m.sessions.agent,`: `,n]}),(0,J.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:a})]}),t?(0,J.jsxs)(`span`,{className:`truncate rounded-md bg-surface-base px-2 py-1`,children:[m.sessions.updated,`: `,t]}):null]})]},e.key)})}):ti?(0,J.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:m.sessions.noMatches})}):(0,J.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:m.sessions.emptyTitle}),(0,J.jsx)(`p`,{className:`mx-auto mt-1 max-w-md text-sm leading-6 text-fg-muted`,children:m.sessions.emptyDescription})]})})]}):null,$===`goals`?(0,J.jsxs)(`section`,{id:`project-panel-goals`,role:`tabpanel`,"aria-labelledby":`project-work-tab-goals`,className:`grid min-h-full content-start gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.goals.title})}),(0,J.jsxs)(x,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3`,disabled:$n,onClick:()=>ir(!0),children:[(0,J.jsx)(qe,{className:`size-4`,"aria-hidden":!0}),m.goals.new]})]}),(0,J.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:Se.length?Se.map(e=>(0,J.jsxs)(o,{to:mr(e.id),onClick:_r(`goals`),className:`grid gap-1 border-b border-edge px-4 py-3 last:border-b-0 hover:bg-surface-hover`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,J.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Dn(e.status)),children:Zr(e.status)})]}),(0,J.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:e.nextAction||e.description||m.goals.noNextAction})]},e.id)):(0,J.jsx)(`p`,{className:`p-4 text-sm text-fg-muted`,children:m.goals.empty})})]}):null,$===`activity`?(0,J.jsxs)(`section`,{id:`project-panel-activity`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-activity`,className:`grid min-h-full content-start gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.activity.title}),(0,J.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Tn(m.activity.count,{count:$e})})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`label`,{className:`inline-flex min-h-9 items-center gap-2 rounded-lg bg-surface-panel px-3 text-sm text-fg-muted shadow-surface`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:gt,onChange:e=>_t(e.currentTarget.checked),className:`size-4 rounded border-edge text-accent focus:ring-accent/30`}),m.activity.includeRelated]}),(0,J.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3`,onClick:()=>void xr(),disabled:at,children:[(0,J.jsx)(xt,{className:l(`size-4`,at&&`animate-spin`),"aria-hidden":!0}),m.common.refresh]})]})]}),(0,J.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:at&&Ze.length===0?(0,J.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:m.activity.loading}):Ze.length?(0,J.jsx)(`div`,{className:`divide-y divide-edge`,children:Ze.map(e=>{let t=m.activity.types[e.type]??e.type,n=m.activity.objectKinds[e.primaryObject.kind]??e.primaryObject.kind,r=Vn(e),i=e.relatedProjects.length>0&&!e.scopes.some(e=>e.scopeKind===`project`&&e.scopeId===v.id);return(0,J.jsxs)(`article`,{className:`grid gap-2 px-4 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:t}),i?(0,J.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-xs font-medium text-fg-muted`,children:m.activity.related}):null]}),(0,J.jsxs)(`p`,{className:`mt-1 min-w-0 truncate text-sm text-fg-muted`,children:[n,`: `,Ln(e)]})]}),(0,J.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,dateTime:new Date(e.createdAt).toISOString(),children:En(e.createdAt)})]}),r?(0,J.jsx)(`p`,{className:`line-clamp-2 text-sm leading-5 text-fg-muted`,children:r}):null,(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,J.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[m.activity.actor,`: `,In(e)]}),(0,J.jsxs)(`span`,{className:`max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[m.activity.source,`: `,Rn(e)]})]})]},e.id)})}):(0,J.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:m.activity.empty})})]}):null,$===`settings`?(0,J.jsxs)(`form`,{id:`project-panel-settings`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-settings`,onSubmit:Rr,className:`grid min-h-full content-start gap-4`,children:[(0,J.jsxs)(`section`,{className:`grid gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.settings.summaryTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:m.settings.summaryHint})]}),(0,J.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Dn(Q.status)),children:m.settings.statuses[Q.status]})]}),(0,J.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-5`,children:[(0,J.jsx)(jn,{label:m.settings.workspaceRoot,value:ci,mono:!0}),(0,J.jsx)(jn,{label:m.settings.defaultAgent,value:ni}),(0,J.jsx)(jn,{label:m.settings.pinState,value:oi?m.settings.pinned:m.settings.notPinned}),(0,J.jsx)(jn,{label:m.settings.createdAt,value:En(v.createdAt)||m.common.never}),(0,J.jsx)(jn,{label:m.settings.updatedAt,value:En(v.updatedAt)||m.common.never})]})]}),(0,J.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.settings.detailsTitle})}),(0,J.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,J.jsx)(kn,{label:m.settings.name,children:(0,J.jsx)(`input`,{className:An(),value:Q.name,onChange:e=>ur(t=>({...t,name:e.target.value}))})}),(0,J.jsx)(kn,{label:m.settings.defaultAgent,children:(0,J.jsxs)(tt,{className:An(),value:Q.defaultAgentId,onChange:e=>ur(t=>({...t,defaultAgentId:e.target.value})),children:[(0,J.jsx)(Ge,{value:``,children:m.settings.globalDefaultAgent}),nn.map(e=>(0,J.jsx)(Ge,{value:e.id,children:me(e,s.agentsSettings)},e.id))]})}),(0,J.jsx)(kn,{label:m.settings.status,children:ai?(0,J.jsx)(`div`,{className:`grid min-h-10 content-center rounded-md border border-edge bg-surface-muted px-3 text-sm text-fg-muted`,children:m.settings.statuses.archived}):(0,J.jsxs)(tt,{className:An(),value:Q.status===`archived`?`active`:Q.status,onChange:e=>ur(t=>({...t,status:e.target.value})),children:[(0,J.jsx)(Ge,{value:`active`,children:m.settings.statuses.active}),(0,J.jsx)(Ge,{value:`paused`,children:m.settings.statuses.paused})]})}),(0,J.jsx)(kn,{label:m.settings.description,hint:m.settings.descriptionHint,children:(0,J.jsx)(`textarea`,{className:An(!0),value:Q.description,onChange:e=>ur(t=>({...t,description:e.target.value}))})})]})]}),(0,J.jsx)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:(0,J.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:m.settings.workspaceRoot}),(0,J.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,J.jsx)(`span`,{className:`rounded-md bg-surface-muted px-2 py-0.5 text-xs font-medium text-fg-muted`,children:si?m.settings.workspaceModeFollow:m.settings.workspaceModeFixed})}),(0,J.jsx)(`div`,{className:`mt-2 break-all font-mono text-xs leading-5 text-fg`,title:ci,children:ci})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,J.jsxs)(x,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:()=>void mi(),children:[(0,J.jsx)(ue,{className:`size-4`,"aria-hidden":!0}),m.settings.copyWorkspacePath]}),(0,J.jsx)(ie,{workspacePath:ci}),(0,J.jsxs)(x,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:zr,children:[(0,J.jsx)(se,{className:`size-4`,"aria-hidden":!0}),m.settings.migrateWorkspace]})]})]}),(0,J.jsx)(`p`,{className:`text-xs leading-5 text-fg-subtle`,children:m.settings.workspaceMigrationHint})]})]})}),(0,J.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.settings.projectGuidanceTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:m.settings.projectGuidanceHint})]}),(0,J.jsx)(kn,{label:m.settings.brief,hint:m.settings.briefHint,children:(0,J.jsx)(`textarea`,{className:An(!0),value:Q.brief,onChange:e=>ur(t=>({...t,brief:e.target.value}))})}),(0,J.jsx)(kn,{label:m.settings.instructions,hint:m.settings.instructionsHint,children:(0,J.jsx)(`textarea`,{className:An(!0),value:Q.instructions,onChange:e=>ur(t=>({...t,instructions:e.target.value}))})})]}),(0,J.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.settings.managementTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:m.settings.managementHint})]}),(0,J.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,J.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:oi?m.settings.pinnedTitle:m.settings.pinTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:m.settings.pinHint})]}),(0,J.jsxs)(x,{type:`button`,variant:`ghost`,className:`w-fit rounded-lg`,disabled:Mn===`pin`,onClick:()=>void Vr(),children:[oi?(0,J.jsx)(D,{className:`size-4`,"aria-hidden":!0}):(0,J.jsx)(I,{className:`size-4`,"aria-hidden":!0}),oi?m.settings.unpinProject:m.settings.pinProject]})]}),(0,J.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:ai?m.settings.restoreTitle:m.settings.archiveTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:ai?m.settings.restoreHint:m.settings.archiveHint})]}),(0,J.jsxs)(x,{type:`button`,variant:ai?`primary`:`ghost`,className:`w-fit rounded-lg`,disabled:Mn===`archive`,onClick:()=>void Hr(),children:[ai?(0,J.jsx)(xt,{className:`size-4`,"aria-hidden":!0}):(0,J.jsx)(V,{className:`size-4`,"aria-hidden":!0}),ai?m.settings.restoreProject:m.settings.archiveProject]})]})]})]}),(0,J.jsxs)(`section`,{className:`grid gap-3 rounded-lg border border-red-500/20 bg-red-500/5 p-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-red-700 dark:text-red-300`,children:m.settings.dangerTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-red-700/80 dark:text-red-200/80`,children:m.settings.dangerHint})]}),(0,J.jsxs)(x,{type:`button`,variant:`ghost`,className:`w-fit text-red-600 hover:bg-red-500/10 hover:text-red-700 focus-visible:ring-red-500 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>dn(!0),children:[(0,J.jsx)(z,{className:`size-4`,"aria-hidden":!0}),m.settings.deleteConfirmAction]})]}),(0,J.jsx)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-edge pt-4`,children:(0,J.jsxs)(x,{type:`submit`,variant:`primary`,disabled:cn||!Q.name.trim(),children:[(0,J.jsx)(St,{className:`size-4`,"aria-hidden":!0}),m.common.save]})})]}):null]}),(0,J.jsx)(Et,{open:un,onOpenChange:e=>{Pn||dn(e)},children:(0,J.jsxs)(xe,{children:[(0,J.jsx)(_e,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,J.jsxs)(ye,{className:`fixed left-1/2 top-1/2 z-[90] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-5 shadow-float focus:outline-none`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,J.jsx)(`span`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-red-500/10 text-red-600 dark:text-red-400`,children:(0,J.jsx)(c,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(A,{className:`text-base font-semibold text-fg`,children:m.settings.deleteConfirmTitle}),(0,J.jsx)(N,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:v?Tn(m.settings.deleteConfirm,{name:v.name}):m.settings.deleteConfirmFallback})]})]}),(0,J.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,J.jsx)(w,{asChild:!0,children:(0,J.jsx)(x,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:Pn,children:m.common.cancel})}),(0,J.jsxs)(x,{type:`button`,variant:`ghost`,className:`rounded-lg text-red-600 hover:bg-red-500/10 hover:text-red-700 focus-visible:ring-red-500 dark:text-red-400 dark:hover:text-red-300`,disabled:Pn||!v,onClick:()=>void Ur(),children:[(0,J.jsx)(z,{className:`size-4`,"aria-hidden":!0}),m.settings.deleteConfirmAction]})]})]})]})}),(0,J.jsx)(Et,{open:hn,onOpenChange:e=>{cn||gn(e)},children:(0,J.jsxs)(xe,{children:[(0,J.jsx)(_e,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,J.jsxs)(ye,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(34rem,calc(100vh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,J.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,J.jsx)(A,{className:`text-base font-semibold text-fg`,children:m.settings.workspaceMigrationTitle}),(0,J.jsx)(N,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:m.settings.workspaceMigrationDescription})]}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,J.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:m.settings.workspaceMode}),(0,J.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,J.jsxs)(`label`,{className:l(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,X===`fixed`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,J.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:X===`fixed`,onChange:()=>_n(`fixed`),disabled:cn}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block font-medium`,children:m.settings.workspaceModeFixed}),(0,J.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:m.settings.workspaceMigrationFixedHint})]})]}),(0,J.jsxs)(`label`,{className:l(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,X===`follow`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,J.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:X===`follow`,onChange:()=>_n(`follow`),disabled:cn}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block font-medium`,children:m.settings.workspaceModeFollow}),(0,J.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:m.settings.workspaceHint})]})]})]})]}),X===`fixed`?(0,J.jsx)(kt,{value:vn,onChange:yn,disabled:cn,wd:f,placeholder:m.settings.workspacePlaceholder,inputClassName:An(),autoFocus:!0}):null,(0,J.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm leading-6 text-amber-800 dark:text-amber-200`,children:m.settings.workspaceMigrationImpact}),(0,J.jsx)(`div`,{className:`rounded-lg bg-surface-muted px-3 py-2 text-xs leading-5 text-fg-subtle`,children:Tn(m.settings.workspaceCurrent,{workspace:li})})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,J.jsx)(w,{asChild:!0,children:(0,J.jsx)(x,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:cn,children:m.common.cancel})}),(0,J.jsxs)(x,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:cn||!ui,onClick:()=>void Br(),children:[(0,J.jsx)(se,{className:`size-4`,"aria-hidden":!0}),m.settings.workspaceMigrationConfirm]})]})]})]})}),(0,J.jsx)(Et,{open:!!fn,onOpenChange:e=>{e||mn(null)},children:(0,J.jsxs)(xe,{children:[(0,J.jsx)(_e,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,J.jsxs)(ye,{className:`fixed left-1/2 top-1/2 z-[90] flex w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,J.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,J.jsx)(A,{className:`text-base font-semibold text-fg`,children:m.settings.workspaceMissingTitle}),(0,J.jsx)(N,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:fn?Tn(m.settings.workspaceMissingDescription,{workspace:fn}):null})]}),fn?(0,J.jsx)(`div`,{className:`px-5 py-4`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,J.jsx)(W,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:fn})]})}):null,(0,J.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,J.jsx)(x,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:hi,disabled:cn,children:m.settings.workspaceMissingBack}),(0,J.jsxs)(x,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:()=>void Br({createWorkspaceRoot:!0}),disabled:cn,children:[(0,J.jsx)(se,{className:`size-4`,"aria-hidden":!0}),m.settings.workspaceMissingCreate]})]})]})]})}),(0,J.jsx)(Mt,{open:rr,t:s.goalsPage,chat:s.chat,busy:$n,options:or,onClose:()=>!$n&&ir(!1),onCreate:Ar})]})}export{Gn as ProjectDetailPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as ee}from"./messages-CarlxqXV.js";import{n as o}from"./locale-store-sToMfHX_.js";import{Aa as s,As as c,At as l,Bo as u,Fc as d,Fl as f,Go as p,Ha as m,Ho as h,Ic as g,Il as _,Ka as v,Lu as y,Nu as b,Pt as x,To as S,Ua as C,Uo as w,Va as T,Vo as E,Wo as D,_t as O,gc as k,jc as A,ka as j,nl as M,ro as N,xc as P,zo as F}from"./index-2UImfRDC.js";var I=n(),L=e(t(),1),R=r();function z(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:O(n)}function te(e){return[...e].sort((e,t)=>{let n=Number(!!t.pinnedAt)-Number(!!e.pinnedAt);return n===0?new Date(t.lastActiveAt??t.updatedAt).getTime()-new Date(e.lastActiveAt??e.updatedAt).getTime():n})}function ne(){let e=(0,I.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,R.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,"aria-busy":!0,children:Array.from({length:6},B)}),e[0]=t):t=e[0],t}function B(e,t){return(0,R.jsx)(N,{className:`h-40 rounded-xl`},t)}function re(e){let t=(0,I.c)(59),{project:n,busy:r,onTogglePin:a,onToggleArchive:s}=e,l=o(ie),u,f,p,m,h,v,x,S;if(t[0]!==l||t[1]!==n.brief||t[2]!==n.description||t[3]!==n.id||t[4]!==n.lastActiveAt||t[5]!==n.name||t[6]!==n.status||t[7]!==n.updatedAt||t[8]!==n.workspaceRoot){let e=ee(l).projectsPage;u=e.management,x=`flex h-full flex-col rounded-xl border border-edge-subtle bg-surface-base p-4`;let r;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,R.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent`,children:(0,R.jsx)(_,{className:`size-4`,"aria-hidden":!0})}),t[17]=r):r=t[17];let a;t[18]===n.name?a=t[19]:(a=(0,R.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[18]=n.name,t[19]=a);let o=(0,R.jsxs)(`div`,{className:`min-w-0`,children:[a,(0,R.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:e.statuses[n.status]})]}),s;t[20]===o?s=t[21]:(s=(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[r,o]}),t[20]=o,t[21]=s);let c;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,R.jsx)(b,{className:`mt-2 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[22]=c):c=t[22];let d;t[23]===s?d=t[24]:(d=(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[s,c]}),t[23]=s,t[24]=d),S=(0,R.jsxs)(i,{to:`/projects/${encodeURIComponent(n.id)}`,className:`group flex min-w-0 flex-1 flex-col rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[d,(0,R.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-10 text-xs leading-5 text-fg-muted`,children:n.description||n.brief||e.noDescription})]}),v=`mt-3 flex shrink-0 items-end justify-between gap-3 border-t border-edge-subtle pt-3`,m=`min-w-0 text-[11px] text-fg-subtle`,h=(0,R.jsx)(`p`,{className:`truncate`,children:n.workspaceRoot||e.agentDefault}),f=`mt-1`,p=z(n.lastActiveAt??n.updatedAt,e.never),t[0]=l,t[1]=n.brief,t[2]=n.description,t[3]=n.id,t[4]=n.lastActiveAt,t[5]=n.name,t[6]=n.status,t[7]=n.updatedAt,t[8]=n.workspaceRoot,t[9]=u,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=v,t[15]=x,t[16]=S}else u=t[9],f=t[10],p=t[11],m=t[12],h=t[13],v=t[14],x=t[15],S=t[16];let C;t[25]!==f||t[26]!==p?(C=(0,R.jsx)(`p`,{className:f,children:p}),t[25]=f,t[26]=p,t[27]=C):C=t[27];let w;t[28]!==m||t[29]!==h||t[30]!==C?(w=(0,R.jsxs)(`div`,{className:m,children:[h,C]}),t[28]=m,t[29]=h,t[30]=C,t[31]=w):w=t[31];let T=n.pinnedAt?u.unpin:u.pin,E=n.pinnedAt?u.unpin:u.pin,D;t[32]===n.pinnedAt?D=t[33]:(D=n.pinnedAt?(0,R.jsx)(d,{className:`size-4`,"aria-hidden":!0}):(0,R.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t[32]=n.pinnedAt,t[33]=D);let O;t[34]!==r||t[35]!==a||t[36]!==T||t[37]!==E||t[38]!==D?(O=(0,R.jsx)(c,{type:`button`,variant:`ghost`,className:`size-8 p-0`,disabled:r,onClick:a,"aria-label":T,title:E,children:D}),t[34]=r,t[35]=a,t[36]=T,t[37]=E,t[38]=D,t[39]=O):O=t[39];let k=n.status===`archived`?u.restore:u.archive,A=n.status===`archived`?u.restore:u.archive,j;t[40]===n.status?j=t[41]:(j=n.status===`archived`?(0,R.jsx)(P,{className:`size-4`,"aria-hidden":!0}):(0,R.jsx)(y,{className:`size-4`,"aria-hidden":!0}),t[40]=n.status,t[41]=j);let M;t[42]!==r||t[43]!==s||t[44]!==k||t[45]!==A||t[46]!==j?(M=(0,R.jsx)(c,{type:`button`,variant:`ghost`,className:`size-8 p-0`,disabled:r,onClick:s,"aria-label":k,title:A,children:j}),t[42]=r,t[43]=s,t[44]=k,t[45]=A,t[46]=j,t[47]=M):M=t[47];let N;t[48]!==O||t[49]!==M?(N=(0,R.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[O,M]}),t[48]=O,t[49]=M,t[50]=N):N=t[50];let F;t[51]!==N||t[52]!==v||t[53]!==w?(F=(0,R.jsxs)(`div`,{className:v,children:[w,N]}),t[51]=N,t[52]=v,t[53]=w,t[54]=F):F=t[54];let L;return t[55]!==F||t[56]!==x||t[57]!==S?(L=(0,R.jsxs)(`article`,{className:x,children:[S,F]}),t[55]=F,t[56]=x,t[57]=S,t[58]=L):L=t[58],L}function ie(e){return e.language}function ae(){let e=ee(o(e=>e.language)),t=e.projectsPage,n=t.management,r=e.chat.workingDirectory,i=S(e=>e.setPageHeader),d=S(e=>e.clearPageHeader),[g,y]=(0,L.useState)([]),[b,O]=(0,L.useState)(!0),[N,P]=(0,L.useState)(null),[I,z]=(0,L.useState)(``),[B,ie]=(0,L.useState)(`active`),[ae,V]=(0,L.useState)(null),[oe,H]=(0,L.useState)(!1),[U,W]=(0,L.useState)(null),[G,K]=(0,L.useState)(!1),[q,J]=(0,L.useState)(``),[Y,X]=(0,L.useState)(``),[Z,se]=(0,L.useState)(``),Q=x({initialPath:Z,onPicked:se}),$=(0,L.useCallback)(async()=>{O(!0),P(null);try{y(te((await T({limit:100,sortBy:`updatedAt`,sortOrder:`desc`})).items))}catch(e){P(e instanceof Error?e.message:String(e))}finally{O(!1)}},[]);(0,L.useEffect)(()=>{$()},[$]);let ce=(0,L.useMemo)(()=>{let e=I.trim().toLocaleLowerCase();return g.filter(e=>B===`all`||e.status===B).filter(t=>!e||[t.name,t.description,t.brief,t.workspaceRoot].filter(Boolean).some(t=>t.toLocaleLowerCase().includes(e)))},[B,g,I]),le=(0,L.useMemo)(()=>(0,R.jsxs)(c,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>H(!0),children:[(0,R.jsx)(A,{className:`size-4`,"aria-hidden":!0}),t.create]}),[t.create]);(0,L.useLayoutEffect)(()=>(i({startExtra:null,main:(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,R.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.subtitle})]}),end:le}),()=>d()),[d,le,n.subtitle,n.title,i]);let ue=(0,L.useCallback)(async e=>{e.preventDefault();let t=q.trim(),n=Z.trim();if(!(!t||!n||G)){K(!0),W(null);try{let e=await s({name:t,...Y.trim()?{description:Y.trim()}:{},workspaceRoot:n});y(t=>[e,...t.filter(t=>t.id!==e.id)]),J(``),X(``),se(``),H(!1),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){W(e instanceof Error?e.message:String(e))}finally{K(!1)}}},[G,Y,q,Z]),de=(0,L.useCallback)(async(e,t)=>{V(e.id),P(null);try{let n;n=t===`pin`?e.pinnedAt?await v(e.id):await m(e.id):e.status===`archived`?await C(e.id):await j(e.id),y(e=>e.map(e=>e.id===n.id?n:e)),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){P(e instanceof Error?e.message:String(e))}finally{V(null)}},[]),fe=[{id:`active`,label:t.statuses.active},{id:`paused`,label:t.statuses.paused},{id:`archived`,label:t.statuses.archived},{id:`all`,label:t.all}];return(0,R.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,R.jsx)(F,{open:oe,onOpenChange:e=>{H(e),e||W(null)},children:(0,R.jsxs)(D,{children:[(0,R.jsx)(w,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,R.jsxs)(E,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(34rem,calc(100vh-2rem))] w-[min(38rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,R.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,R.jsx)(p,{className:`text-base font-semibold text-fg`,children:t.createTitle}),(0,R.jsx)(h,{className:`mt-1 text-sm text-fg-muted`,children:t.createDescription})]}),(0,R.jsxs)(`form`,{onSubmit:ue,className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.projectName,(0,R.jsx)(`input`,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 font-normal outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:q,onChange:e=>J(e.target.value),maxLength:160})]}),(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[n.descriptionLabel,(0,R.jsx)(`textarea`,{className:`min-h-28 resize-none rounded-lg border border-edge bg-surface-base px-3 py-2 font-normal leading-6 outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:Y,onChange:e=>X(e.target.value),maxLength:2e3,placeholder:n.descriptionPlaceholder})]}),(0,R.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,R.jsx)(`span`,{className:`font-medium text-fg`,children:t.workspaceRoot}),(0,R.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full items-center gap-3 rounded-lg border border-edge bg-surface-base px-3 py-2 text-left outline-none transition-colors hover:bg-surface-hover focus-visible:border-accent focus-visible:ring-2 focus-visible:ring-accent/20 disabled:cursor-not-allowed disabled:opacity-60`,onClick:Q.pick,disabled:G||Q.picking,children:[Q.picking?(0,R.jsx)(M,{className:`size-5 shrink-0 animate-spin text-accent`,"aria-hidden":!0}):(0,R.jsx)(f,{className:`size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:Z?r.chooseFolder:r.selectWorkingDirectory}),(0,R.jsx)(`span`,{className:a(`mt-0.5 block truncate font-mono text-xs font-normal`,Z?`text-fg-muted`:`text-fg-subtle`),title:Z||void 0,children:Z||t.workspaceSelectionPlaceholder})]})]}),(0,R.jsx)(`p`,{className:`text-xs font-normal text-fg-subtle`,children:t.workspaceSelectionHint})]}),U?(0,R.jsx)(`p`,{className:`rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:U}):null]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,R.jsx)(u,{asChild:!0,children:(0,R.jsx)(c,{type:`button`,variant:`ghost`,children:t.cancel})}),(0,R.jsx)(c,{type:`submit`,variant:`primary`,disabled:G||!q.trim()||!Z.trim(),children:G?t.workHome.creating:t.create})]})]})]})]})}),Q.hasNativePicker?null:(0,R.jsx)(l,{open:Q.modalOpen,onOpenChange:Q.setModalOpen,initialAbsolutePath:Z||void 0,onConfirm:Q.confirmPick,wd:r}),(0,R.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-base p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1`,"aria-label":n.filterLabel,children:fe.map(e=>(0,R.jsx)(`button`,{type:`button`,className:a(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,B===e.id?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>ie(e.id),children:e.label},e.id))}),(0,R.jsxs)(`label`,{className:`relative block min-w-0 sm:w-64`,children:[(0,R.jsx)(k,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,R.jsx)(`input`,{className:`h-9 w-full rounded-lg border border-edge bg-surface-panel pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:I,onChange:e=>z(e.target.value),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder})]})]}),N?(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,role:`alert`,children:[(0,R.jsx)(`span`,{children:N}),(0,R.jsx)(c,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void $(),children:t.workHome.retry})]}):null,b?(0,R.jsx)(ne,{}):ce.length?(0,R.jsx)(`section`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:ce.map(e=>(0,R.jsx)(re,{project:e,busy:ae===e.id,onTogglePin:()=>void de(e,`pin`),onToggleArchive:()=>void de(e,`archive`)},e.id))}):(0,R.jsxs)(`section`,{className:`rounded-xl border border-dashed border-edge p-10 text-center`,children:[(0,R.jsx)(_,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,R.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-fg`,children:n.emptyTitle}),(0,R.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint})]})]})}export{ae as ProjectsPage};