@forsion/unit 2.13.0 → 2.13.2

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 (184) hide show
  1. package/main.mjs +23 -3
  2. package/package.json +1 -1
  3. package/release.json +5 -5
  4. package/web/assets/{ArtificialView-BSv3Mx5C.js → ArtificialView-Bs_6B211.js} +1 -1
  5. package/web/assets/{AutomationBuilder-BuiHtVB-.js → AutomationBuilder-C-IFaaBp.js} +1 -1
  6. package/web/assets/CalendarConfigView-DEsNvVkD.js +1 -0
  7. package/web/assets/CalendarView-D7ZUE_dr.js +1 -0
  8. package/web/assets/{CapabilityMenu-kx1TIJYN.js → CapabilityMenu-CrsaTtDe.js} +1 -1
  9. package/web/assets/{CheckboxInput-eW7xdiRS.js → CheckboxInput-DVO2-1J7.js} +1 -1
  10. package/web/assets/{Chrome-B77-lQyh.js → Chrome-BvpbCvo1.js} +1 -1
  11. package/web/assets/{CodeView-Df3AiSIi.js → CodeView-CB4kG7Y6.js} +3 -3
  12. package/web/assets/DashboardGridView-hpRmBr9B.css +1 -0
  13. package/web/assets/DashboardGridView-tgaj9-SM.js +17 -0
  14. package/web/assets/{EventCard-CDmeCbI8.js → EventCard-c6s4uGBu.js} +1 -1
  15. package/web/assets/ExcalidrawCanvas-NdV86AR3.js +1 -0
  16. package/web/assets/{FloatingToc-tART_jC4.js → FloatingToc-ldOYWe2C.js} +1 -1
  17. package/web/assets/HomepageView-4joJWYlg.js +1 -0
  18. package/web/assets/HomepageView-Cxf3AWBu.css +1 -0
  19. package/web/assets/ImageStudioPanels-DgMYAsHj.js +3 -0
  20. package/web/assets/{ImageStudioView-KJhx0wJk.js → ImageStudioView-_CYHoOoG.js} +1 -1
  21. package/web/assets/InlineFiles-BIfsx3R-.js +1 -0
  22. package/web/assets/MarkdownBlock-wYEaBBOr.js +58 -0
  23. package/web/assets/ModelPill-DveHcLqq.js +2 -0
  24. package/web/assets/MuseLibraryView-Do9RnKiq.js +2 -0
  25. package/web/assets/{MuseView-Cb6R_l4i.js → MuseView-3GL4Ltoj.js} +2 -2
  26. package/web/assets/{PageHistoryPanel-BQs9IWTP.js → PageHistoryPanel-BMQC-V_l.js} +2 -2
  27. package/web/assets/{PdfAnnotator-BFTBkxvO.js → PdfAnnotator-CyAw8sgq.js} +1 -1
  28. package/web/assets/PenRow-BSB-h5Pb.js +1 -0
  29. package/web/assets/{ProductView-mB-S0j81.js → ProductView-B96OeHOP.js} +1 -1
  30. package/web/assets/{RightPanel-BVZeVO3c.js → RightPanel-BgSeCLnw.js} +3 -3
  31. package/web/assets/RunLocationPicker-CEmFio4n.css +1 -0
  32. package/web/assets/RunLocationPicker-M1UoJyjf.js +38 -0
  33. package/web/assets/{SketchCard-CAAr_cqF.js → SketchCard-DAD0jR0i.js} +212 -8
  34. package/web/assets/{StudioGuestSurface-DthpuVGg.js → StudioGuestSurface-DlUKXBXv.js} +1 -1
  35. package/web/assets/TodoListView-_yFkPUrw.js +1 -0
  36. package/web/assets/{Tooltip-D9Dt9ZTr.js → Tooltip-DXuy9-1_.js} +1 -1
  37. package/web/assets/UnifiedPage-EJNWKzxN.js +68 -0
  38. package/web/assets/{amadeus-manual.en-D5wZKuag.js → amadeus-manual.en-DzRWr4BL.js} +15 -15
  39. package/web/assets/{amadeus-manual.zh-Br5fidrj.js → amadeus-manual.zh-DW32DkL7.js} +15 -15
  40. package/web/assets/{appStore-B1ynyt42.js → appStore-CidPWYa0.js} +242 -134
  41. package/web/assets/appStore-DeaC1U32.css +1 -0
  42. package/web/assets/{arrow-up-right-R10mR2I6.js → arrow-up-right-KPFbRA41.js} +1 -1
  43. package/web/assets/{astryxBridge-CU_kQTEl.js → astryxBridge-Bupzouso.js} +3 -3
  44. package/web/assets/{automationListSource-B8EIRmDW.js → automationListSource-1aOVKBLw.js} +1 -1
  45. package/web/assets/boardSurface-BHuMoQN-.js +1 -0
  46. package/web/assets/{book-open-DBJ3dDpw.js → book-open-CBeNsIpo.js} +1 -1
  47. package/web/assets/{calendarNavStore-DGvUlU5N.js → calendarNavStore-Duyhbmm_.js} +1 -1
  48. package/web/assets/{canvasPrefs-DwL_OAAo.js → canvasPrefs-CxfyDTMT.js} +1 -1
  49. package/web/assets/{chatBoxSurface-Lq-2qfd3.js → chatBoxSurface-OBzO1Z5E.js} +1 -1
  50. package/web/assets/{circle-question-mark-HPZpZQxd.js → circle-question-mark-M8QUJJYk.js} +1 -1
  51. package/web/assets/{circle-x-BZfe7d6S.js → circle-x-Szwop5L_.js} +1 -1
  52. package/web/assets/{client-DxGbwZLy.js → client-CPUljePZ.js} +1 -1
  53. package/web/assets/{code-xml-joKQ-qGS.js → code-xml-n9mgGgkv.js} +1 -1
  54. package/web/assets/{codeStudioStore-C7rGKlOC.js → codeStudioStore-DXMQwRzG.js} +1 -1
  55. package/web/assets/codingNavigation-CCjs1kon.js +53 -0
  56. package/web/assets/codingNavigation-yp19w6uu.css +1 -0
  57. package/web/assets/{create-BjBRKATq.js → create-C19zqt5N.js} +2 -2
  58. package/web/assets/dashboardSurface-BwcH16Qc.js +1 -0
  59. package/web/assets/{deskCapture-DnGWk1iq.js → deskCapture-B_LKZSPt.js} +1 -1
  60. package/web/assets/{diff2html-Cd1rVi_Z.js → diff2html-DrCCWvpR.js} +1 -1
  61. package/web/assets/{docx-preview-CK0k1mUD.js → docx-preview-Bi7wekSM.js} +1 -1
  62. package/web/assets/{emoji-Cjm3bKiF.js → emoji-DczIG8SO.js} +1 -1
  63. package/web/assets/{floatingTocSurface-Dd1pT5j5.js → floatingTocSurface-rc1ZC7-I.js} +1 -1
  64. package/web/assets/foldActions-BGocXE-o.js +1 -0
  65. package/web/assets/{folder-CvZyHIgb.js → folder-CoOsfQ64.js} +1 -1
  66. package/web/assets/{folder-plus-BRScGQ9m.js → folder-plus-d5MwIMlf.js} +1 -1
  67. package/web/assets/{gestures-CZQVefU0.js → gestures-CXFaEydn.js} +1 -1
  68. package/web/assets/{hand-D3QspKYq.js → hand-fuehbnkI.js} +1 -1
  69. package/web/assets/{hard-drive-BQsHSala.js → hard-drive-Bh1DmZg0.js} +1 -1
  70. package/web/assets/i18n-DjziAw8r.css +1 -0
  71. package/web/assets/{i18n.generated-BZRHO2Nc.js → i18n.generated-BiQFRL2U.js} +1 -1
  72. package/web/assets/{imageStudio-Cy3_437s.js → imageStudio-Dgl1wZNB.js} +2 -2
  73. package/web/assets/{index-0AYHATDX.js → index-2tD0kijW.js} +1 -1
  74. package/web/assets/{index-DJLWTPtq.js → index-38xsQSS9.js} +1 -1
  75. package/web/assets/{index-B5GxvbNm.js → index-7kdR1oL8.js} +1 -1
  76. package/web/assets/index-B5UW6SaE.js +297 -0
  77. package/web/assets/{index-D6mpAJ9S.js → index-B8Co6KG3.js} +1 -1
  78. package/web/assets/{index-C9yo04Ck.js → index-BCG8Wnc4.js} +1 -1
  79. package/web/assets/{index-Bpc3R3DS.js → index-BPqoEOV_.js} +1 -1
  80. package/web/assets/{index-BaRySZ-M.js → index-BqGpbntz.js} +1 -1
  81. package/web/assets/{index-Dj-PygjB.js → index-CPLtf9Vc.js} +1 -1
  82. package/web/assets/{index-8ag1K7AZ.js → index-Ce1sNSS8.js} +1 -1
  83. package/web/assets/{index-BgDZGDqt.js → index-Ch0FIsJX.js} +1 -1
  84. package/web/assets/{index-CcOag8eb.js → index-CnDAYLti.js} +1 -1
  85. package/web/assets/{index-Dkd-nl1u.js → index-D4CSH-v1.js} +1 -1
  86. package/web/assets/{index-BnWj6ggb.js → index-Dc8iMctf.js} +1 -1
  87. package/web/assets/{index-D0FLFLfh.js → index-DcRyQ3eU.js} +1 -1
  88. package/web/assets/{index-DElrDw66.js → index-Df9jregv.js} +1 -1
  89. package/web/assets/{index-4E9nrhwf.js → index-Dff-DL1v.js} +1 -1
  90. package/web/assets/{index-BdZaheMZ.js → index-DvOrTnw2.js} +1 -1
  91. package/web/assets/{index-BPhwi4-v.js → index-Dx9aIoyo.js} +1 -1
  92. package/web/assets/{index-BcVGjCAJ.js → index-Dy07SBfH.js} +1 -1
  93. package/web/assets/{index-GjLSlygt.js → index-QjVOA7QM.js} +1 -1
  94. package/web/assets/{index-BgtO11q8.js → index-YRWOePBS.js} +1 -1
  95. package/web/assets/{index-9BmmlTjY.js → index-e-MxdHFO.js} +1 -1
  96. package/web/assets/{index-DNE_PBJt.js → index-fViJsYjM.js} +1 -1
  97. package/web/assets/{index-1FhRiJ_X.js → index-lfow5R3O.js} +1 -1
  98. package/web/assets/{invitePage-B4gMvEKi.js → invitePage-Dgl3-c_m.js} +1 -1
  99. package/web/assets/{ipc-CPhL3bPp.js → ipc-CNlIRMtU.js} +1 -1
  100. package/web/assets/{jszip.min-DAJT9RUA.js → jszip.min-tyV0GaJg.js} +1 -1
  101. package/web/assets/{layout-grid-DfUfnvDS.js → layout-grid-DFmwM9NU.js} +1 -1
  102. package/web/assets/linkFollow-iP2zfbA3.js +8 -0
  103. package/web/assets/{list-tree-DaGpnIYu.js → list-tree-i07HsP3D.js} +1 -1
  104. package/web/assets/{listFold-Q_8mh5ZG.js → listFold-Aea6I0Sa.js} +1 -1
  105. package/web/assets/{lock-DQ_yL4nF.js → lock-TSDKuCod.js} +1 -1
  106. package/web/assets/{log-out-DFwTeh2X.js → log-out-DK84lW5n.js} +1 -1
  107. package/web/assets/{main-NgUPPqDn.css → main-BiS_5wrB.css} +1 -1
  108. package/web/assets/main-D7CEGndC.js +20 -0
  109. package/web/assets/markdownEditorSurface-DISu_twy.js +3 -0
  110. package/web/assets/{message-square-plus-CEHkduIL.js → message-square-plus-3wFslIMY.js} +1 -1
  111. package/web/assets/{messages-CBtmbpur.js → messages-DEAGRsC3.js} +1 -1
  112. package/web/assets/minus-BBdfT_sc.js +1 -0
  113. package/web/assets/mobileEntry-5UaAITwY.js +13 -0
  114. package/web/assets/{nativeDownload-CziEyW_p.js → nativeDownload-B3JGkABw.js} +1 -1
  115. package/web/assets/pageChrome-BDHHmRnt.css +1 -0
  116. package/web/assets/{pageChrome-DFz_AAzZ.js → pageChrome-DFi9zs6F.js} +1 -1
  117. package/web/assets/{pageTree-yVO1_fSy.js → pageTree-DZ7Eiro-.js} +4 -4
  118. package/web/assets/{pen-tool-uxsFELYC.js → pen-tool-ChGmX6g_.js} +1 -1
  119. package/web/assets/{pencil-BSbra1Ra.js → pencil-CJsJD7M_.js} +1 -1
  120. package/web/assets/phoneList-DrxIwJxQ.js +9 -0
  121. package/web/assets/phoneList-DvpzD3zT.css +1 -0
  122. package/web/assets/pluginChat-0QI9a8Q1.js +2 -0
  123. package/web/assets/{redo-2-BK5LMNa5.js → redo-2-CI57sDFr.js} +1 -1
  124. package/web/assets/{rotate-ccw-HedfU4na.js → rotate-ccw-xgT_0UN9.js} +1 -1
  125. package/web/assets/{sharePage-CpzDpuU1.js → sharePage-C2Yqx0NQ.js} +2 -2
  126. package/web/assets/{shareViewer-BwzH2bIs.js → shareViewer-DKPWhTJv.js} +2 -2
  127. package/web/assets/{star-CgYon3z4.js → star-C9KTji9N.js} +1 -1
  128. package/web/assets/tableSurface-cYs6dX6B.js +1 -0
  129. package/web/assets/{terminal-krsPf1mc.js → terminal-DPZazOQ2.js} +1 -1
  130. package/web/assets/{terminalView-4e2_u5_I.js → terminalView-CsJmxE_m.js} +1 -1
  131. package/web/assets/{theme-C6D3tMGV.css → theme-Dgqst5S9.css} +1 -1
  132. package/web/assets/{type-GJYLEhY-.js → type-C5J875vb.js} +1 -1
  133. package/web/assets/{undo-2-DCTs4Ro4.js → undo-2-BOUt5qks.js} +1 -1
  134. package/web/assets/{unitAccount-D3xjX3cu.js → unitAccount-BIAIxKNp.js} +1 -1
  135. package/web/assets/unitBridge-b2C6zb3a.js +1 -0
  136. package/web/assets/{unitCloudTransport-B44L3x6M.js → unitCloudTransport-NGtDDKWo.js} +1 -1
  137. package/web/assets/{unitOwnerAccess-CRUHWGpf.js → unitOwnerAccess-CwH9ApZT.js} +1 -1
  138. package/web/assets/{unitShim-_VzxvdEG.js → unitShim-CY8EVkKD.js} +3 -3
  139. package/web/assets/{upload-MVVRQtkj.js → upload-CrbEAW8C.js} +1 -1
  140. package/web/assets/userSpaces-B_Njvel_.js +1 -0
  141. package/web/assets/viewportLock-Bi3orrUs.css +1 -0
  142. package/web/assets/viewportLock-DZ927PNz.js +629 -0
  143. package/web/assets/{workflow-DzeW9OXR.js → workflow-DY2Cnaei.js} +1 -1
  144. package/web/assets/{zoom-in-CovPsw4g.js → zoom-in-BcuPvIYd.js} +1 -1
  145. package/web/index.html +28 -11
  146. package/web/assets/CalendarConfigView-BJtG6cqN.js +0 -1
  147. package/web/assets/CalendarView-C-FX1RED.js +0 -1
  148. package/web/assets/DashboardGridView-Ck3LKkOb.css +0 -1
  149. package/web/assets/DashboardGridView-MlO1dpuo.js +0 -17
  150. package/web/assets/ExcalidrawCanvas-D9vkBh_5.js +0 -1
  151. package/web/assets/HomepageView-BNabJQfP.css +0 -1
  152. package/web/assets/HomepageView-Trqmd3RV.js +0 -1
  153. package/web/assets/ImageStudioPanels-BfCVTnKC.js +0 -3
  154. package/web/assets/InlineFiles-BHwivGbQ.js +0 -1
  155. package/web/assets/MarkdownBlock-D8LgHFYY.js +0 -58
  156. package/web/assets/ModelPill-DrW2cG0l.js +0 -2
  157. package/web/assets/MuseLibraryView-CW78Uivf.js +0 -2
  158. package/web/assets/RunLocationPicker-BE5mxnab.css +0 -1
  159. package/web/assets/RunLocationPicker-CyVa0RJa.js +0 -38
  160. package/web/assets/SidebarRow-CsWEqPKX.css +0 -1
  161. package/web/assets/SidebarRow-D77yrSLf.js +0 -9
  162. package/web/assets/TodoListView-C3ZkMIIf.js +0 -1
  163. package/web/assets/UnifiedPage-C75y-MKT.js +0 -68
  164. package/web/assets/appStore-BC_CQv-L.css +0 -1
  165. package/web/assets/codingNavigation-CZB4v1ZW.css +0 -1
  166. package/web/assets/codingNavigation-CjeWG4xm.js +0 -47
  167. package/web/assets/dashboardSurface-Cojgf_-U.js +0 -1
  168. package/web/assets/foldActions-Dm-uAt3L.js +0 -1
  169. package/web/assets/i18n-ecQQxiMQ.css +0 -1
  170. package/web/assets/index-Bh_nLVTc.js +0 -298
  171. package/web/assets/linkFollow-C6PHGUxk.js +0 -8
  172. package/web/assets/main-CwqZ_ymb.js +0 -19
  173. package/web/assets/markdownEditorSurface-e_oMhqx-.js +0 -3
  174. package/web/assets/mdMarkStore-DjN4bf1T.js +0 -2
  175. package/web/assets/mdMarks-cmL6vzR-.js +0 -1
  176. package/web/assets/minus-BUT48dAC.js +0 -1
  177. package/web/assets/mobileEntry-qR7BAROr.js +0 -13
  178. package/web/assets/pageChrome-CovzZPdb.css +0 -1
  179. package/web/assets/pluginChat-BMFnf_j2.js +0 -2
  180. package/web/assets/tableSurface-CmDwnKnd.js +0 -1
  181. package/web/assets/unitBridge-D5JcIkAP.js +0 -1
  182. package/web/assets/userSpaces-CI4eqEgh.js +0 -1
  183. package/web/assets/viewportLock-BH26xHQO.js +0 -611
  184. package/web/assets/viewportLock-IP1zaVkz.css +0 -1
package/main.mjs CHANGED
@@ -730,9 +730,12 @@ var ENGINE_ROUTES = [
730
730
  { method: "PUT", path: "/agent/project-context/doc", access: "deny-remote", src: "routes/projectContext.ts", why: "project instruction write (design appendix C)" },
731
731
  { method: "POST", path: "/agent/project-context/git/branch", access: "deny-remote", src: "routes/projectContext.ts", why: "git repository write" },
732
732
  { method: "POST", path: "/agent/project-context/git/commit", access: "deny-remote", src: "routes/projectContext.ts", why: "git commit (runs repository hooks)" },
733
+ { method: "GET", path: "/agent/project-context/git/hosting", access: "deny-remote", src: "routes/projectContext.ts", why: "host-only: whether this project can be published to Forsion Git (the publish action is host-only)" },
733
734
  { method: "POST", path: "/agent/project-context/git/init", access: "deny-remote", src: "routes/projectContext.ts", why: "git repository write" },
734
735
  { method: "POST", path: "/agent/project-context/git/message", access: "deny-remote", src: "routes/projectContext.ts", why: "spends model quota; may run trusted repo filters" },
735
736
  { method: "POST", path: "/agent/project-context/git/pending", access: "deny-remote", src: "routes/projectContext.ts", why: "may run trusted repo filters (trust=true)" },
737
+ { method: "POST", path: "/agent/project-context/git/publish", access: "deny-remote", src: "routes/projectContext.ts", why: "adds a remote and pushes with the signed-in account credentials" },
738
+ { method: "POST", path: "/agent/project-context/git/pull", access: "deny-remote", src: "routes/projectContext.ts", why: "git fetch + fast-forward with local credentials (runs repository hooks)" },
736
739
  { method: "POST", path: "/agent/project-context/git/push", access: "deny-remote", src: "routes/projectContext.ts", why: "git push with local credentials" },
737
740
  { method: "POST", path: "/agent/project-context/git/trust", access: "deny-remote", src: "routes/projectContext.ts", why: "trusts repo-provided executable git config" },
738
741
  { method: "DELETE", path: "/agent/project-context/icon", access: "deny-remote", src: "routes/projectContext.ts", why: "project icon write" },
@@ -780,6 +783,8 @@ var ENGINE_ROUTES = [
780
783
  { method: "GET", path: "/agent/sessions/:id/detail", access: "allow", src: "routes/sessions.ts", why: "session detail" },
781
784
  { method: "GET", path: "/agent/sessions/:id/messages", access: "allow", src: "routes/sessions.ts", why: "session messages" },
782
785
  { method: "POST", path: "/agent/sessions/:id/messages/delete", access: "deny-remote", src: "routes/sessions.ts", why: "irreversible deletion of local conversation history" },
786
+ { method: "GET", path: "/agent/sessions/:id/status", access: "allow", src: "routes/sessions.ts", why: "live run status (context / tokens / steps)" },
787
+ { method: "POST", path: "/agent/sessions/:id/suggest", access: "allow", src: "routes/sessions.ts", why: "next-message suggestion for the input box (reads a one-shot in-memory snapshot of the run that just ended; writes nothing)" },
783
788
  { method: "POST", path: "/agent/sessions/:id/team-members/:slug", access: "allow", src: "routes/sessions.ts", why: "open a team member child session (taint propagates, C5)" },
784
789
  { method: "GET", path: "/agent/sessions/:id/timeline", access: "allow", src: "routes/sessions.ts", why: "session timeline" },
785
790
  { method: "GET", path: "/agent/sessions/:id/usage", access: "allow", src: "routes/sessions.ts", why: "session usage" },
@@ -3265,7 +3270,7 @@ init_control();
3265
3270
  // desktop/package.json
3266
3271
  var package_default = {
3267
3272
  name: "forsion-desktop",
3268
- version: "2.13.0",
3273
+ version: "2.13.2",
3269
3274
  description: "Forsion Desktop \u2014 AI \u9A71\u52A8\u7684\u5E94\u7528\u751F\u6001\u7CFB\u7EDF\u7684\u684C\u9762\u7AEF(Electron):Tangu Agent \u5F15\u64CE + LCL \u53EF\u505C\u9760\u5DE5\u4F5C\u533A\u6846\u67B6 + \u53EF\u63D2\u62D4\u529F\u80FD\u7A7A\u95F4(\u5BF9\u8BDD/\u7B14\u8BB0/\u65E5\u5386/\u6536\u4EF6\u7BB1/\u7F16\u7801),\u6309\u4EA7\u54C1\u6863\u6848\u88C1\u51FA\u5168\u5BB6\u6876\u4E0E\u5355\u54C1\u53D1\u884C\u7248",
3270
3275
  author: "Forsion",
3271
3276
  private: true,
@@ -3276,6 +3281,10 @@ var package_default = {
3276
3281
  predev: "node scripts/dev-version.check.cjs",
3277
3282
  dev: "electron-vite dev --noSandbox",
3278
3283
  "check:visualize": "node scripts/visualize.check.cjs",
3284
+ "check:intelligent-ui": "node scripts/intelligent-ui.e2e.cjs",
3285
+ "e2e:intelligent-live": "cd ../tangu-agent && node scripts/live-harness.mjs --only intelligentusers --model codex/gpt-6-luna --timeout 1800000",
3286
+ "demo:intelligent-ui": "node scripts/intelligent-ui.e2e.cjs --preview",
3287
+ "demo:sketch": "node scripts/sketch-demo.record.cjs",
3279
3288
  "check:version": "node scripts/dev-version.check.cjs",
3280
3289
  build: "electron-vite build",
3281
3290
  preview: "electron-vite preview",
@@ -3291,6 +3300,7 @@ var package_default = {
3291
3300
  "e2e:editor": "node scripts/e2e-editor.cjs",
3292
3301
  "e2e:dnd": "node scripts/block-dnd.e2e.cjs",
3293
3302
  "e2e:sidebardrop": "node scripts/sidebar-drop.e2e.cjs",
3303
+ "e2e:notemove": "node scripts/note-move-assets.e2e.cjs",
3294
3304
  "e2e:ribbon": "node scripts/ribbon-dnd.e2e.cjs",
3295
3305
  "e2e:spacewindow": "node scripts/space-window.e2e.cjs",
3296
3306
  "e2e:spacewindow-input": "node scripts/space-window-input.e2e.cjs",
@@ -3306,6 +3316,7 @@ var package_default = {
3306
3316
  "e2e:recall": "node scripts/recall-rewind.e2e.cjs",
3307
3317
  "e2e:chatevents": "node scripts/chat-events.e2e.cjs",
3308
3318
  "e2e:computerhistory": "node scripts/computer-history.e2e.cjs",
3319
+ "e2e:appdock": "node scripts/app-dock.e2e.cjs",
3309
3320
  "e2e:remotesafety": "node scripts/remote-safety.e2e.cjs",
3310
3321
  "e2e:chatshimmer": "node scripts/chat-shimmer.e2e.cjs",
3311
3322
  "e2e:runstats": "node scripts/chat-runstats.e2e.cjs",
@@ -3313,11 +3324,14 @@ var package_default = {
3313
3324
  "e2e:ctxlimit": "node scripts/ctxlimit-menu.e2e.cjs",
3314
3325
  "e2e:livewait": "node scripts/chat-livewait.e2e.cjs",
3315
3326
  "e2e:queue": "node scripts/queued-commands.e2e.cjs",
3327
+ "e2e:composerdraft": "node scripts/composer-draft.e2e.cjs",
3316
3328
  "e2e:musespace": "node scripts/muse-space.e2e.cjs",
3317
3329
  "e2e:coreplugins": "node scripts/core-plugins.e2e.cjs",
3318
3330
  "e2e:restart-update": "node scripts/restart-update.e2e.cjs",
3319
3331
  "e2e:market-submissions": "node scripts/market-submissions.e2e.cjs",
3332
+ "e2e:storepages": "node scripts/store-pages.e2e.cjs",
3320
3333
  "e2e:market-auto-update": "node scripts/market-auto-update.e2e.cjs",
3334
+ "e2e:market-open-settings": "node scripts/market-open-settings.e2e.cjs",
3321
3335
  "e2e:account": "node scripts/account-center.shot.cjs",
3322
3336
  "e2e:accountpopups": "node scripts/account-popups.shot.cjs",
3323
3337
  "e2e:extend": "node scripts/extend-seam.e2e.cjs",
@@ -3329,6 +3343,7 @@ var package_default = {
3329
3343
  "live:harness": "cd ../tangu-agent && npm run live:harness",
3330
3344
  "probe:gzipupload": "node scripts/gzip-upload.probe.cjs",
3331
3345
  "e2e:realtimevoice": "node scripts/realtime-voice.e2e.cjs",
3346
+ "e2e:cloudvoice": "node scripts/cloud-voice-default.e2e.cjs",
3332
3347
  "e2e:voicestudio": "node scripts/voice-studio.e2e.cjs",
3333
3348
  "e2e:dashdrag": "node scripts/dash3-drag.e2e.cjs",
3334
3349
  "e2e:pathgone": "node scripts/vault-pathgone.e2e.cjs",
@@ -3336,6 +3351,7 @@ var package_default = {
3336
3351
  "check:feedback": "node scripts/feedback.check.cjs",
3337
3352
  "check:floatingsession": "node scripts/floating-session.check.cjs",
3338
3353
  "check:btw": "node scripts/btw.check.cjs",
3354
+ "check:promptsuggest": "node scripts/prompt-suggest.check.cjs",
3339
3355
  "check:chatlayout": "node scripts/chat-layout.check.cjs",
3340
3356
  "check:sessionemoji": "node scripts/session-emoji.check.cjs",
3341
3357
  "check:messageactions": "node scripts/chat-message-actions.check.cjs",
@@ -3365,6 +3381,7 @@ var package_default = {
3365
3381
  "check:spellctx": "node scripts/e2e-editor.cjs --check=unified-spellctx",
3366
3382
  "check:unifiedkeys": "node scripts/e2e-editor.cjs --check=unified-keys",
3367
3383
  "check:taskbox": "node scripts/e2e-editor.cjs --check=taskbox",
3384
+ "check:focuscost": "node scripts/e2e-editor.cjs --check=focus-cost",
3368
3385
  "check:table": "node scripts/e2e-editor.cjs --check=unified-table",
3369
3386
  "check:unifiedsync": "node scripts/e2e-editor.cjs --check=unified-sync",
3370
3387
  "check:editorai": "node scripts/e2e-editor.cjs --check=editor-ai",
@@ -3412,6 +3429,7 @@ var package_default = {
3412
3429
  "e2e:ftoverride": "node scripts/filetype-override.e2e.cjs",
3413
3430
  "e2e:pathgoneunmounted": "node scripts/vault-pathgone-unmounted.e2e.cjs",
3414
3431
  "check:textfrag": "electron scripts/text-fragment.check.cjs",
3432
+ "check:sourceopen": "electron scripts/source-open.check.cjs -ApplePersistenceIgnoreState YES",
3415
3433
  "check:assetfetch": "electron scripts/asset-fetch.check.cjs",
3416
3434
  "check:rtc": "electron scripts/rtc-capability.check.cjs",
3417
3435
  "check:rtcsdk": "electron scripts/rtc-sdk.check.cjs",
@@ -3443,6 +3461,7 @@ var package_default = {
3443
3461
  "check:quietfocus": "node scripts/quiet-focus.check.cjs",
3444
3462
  "check:persistignore": "node scripts/persist-ignore.check.cjs",
3445
3463
  "check:spaceicon": "node scripts/space-icon.check.cjs",
3464
+ "check:spacehidden": "node scripts/plugin-space-hidden.check.cjs",
3446
3465
  "check:onboarding": "node scripts/plugin-onboarding.check.cjs",
3447
3466
  "check:plugindeps": "node scripts/plugin-deps.check.cjs",
3448
3467
  "check:pluginsync": "node scripts/plugin-install-sync.check.cjs",
@@ -3489,6 +3508,7 @@ var package_default = {
3489
3508
  "check:deskshot": "node scripts/desk-shot.check.cjs",
3490
3509
  "check:splash": "node scripts/splash-loop.check.cjs",
3491
3510
  "probe:startup-windows": "node scripts/startup-windows.probe.cjs",
3511
+ "probe:startup-trace": "node scripts/startup-trace.probe.cjs",
3492
3512
  "check:parity": "node scripts/platform-parity.check.cjs",
3493
3513
  "check:vitecache": "node scripts/vite-cachedir.check.cjs",
3494
3514
  "check:enginetarget": "node scripts/engine-target.check.cjs",
@@ -3588,8 +3608,8 @@ var package_default = {
3588
3608
  "@dnd-kit/sortable": "^10.0.0",
3589
3609
  "@dnd-kit/utilities": "^3.2.2",
3590
3610
  "@excalidraw/excalidraw": "npm:@zsviczian/excalidraw@0.18.122",
3591
- "@forsion/extend": "0.7.1",
3592
- "@forsion/tangu-computer-use": "0.6.1",
3611
+ "@forsion/extend": "0.8.1",
3612
+ "@forsion/tangu-computer-use": "0.6.2",
3593
3613
  "@milkdown/kit": "^7.21.2",
3594
3614
  "@milkdown/plugin-math": "^7.5.9",
3595
3615
  "@milkdown/react": "^7.21.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsion/unit",
3
- "version": "2.13.0",
3
+ "version": "2.13.2",
4
4
  "type": "module",
5
5
  "description": "Forsion Unit: the independently runnable Forsion framework (plugin host and Web UI), prebuilt.",
6
6
  "license": "SEE LICENSE IN LICENSE",
package/release.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
- "desktopVersion": "2.13.0",
3
- "desktopTag": "v2.13.0",
4
- "desktopCommit": "a3ff47a34939b04600374b8b242b9916853a105c",
2
+ "desktopVersion": "2.13.2",
3
+ "desktopTag": "v2.13.2",
4
+ "desktopCommit": "7872b6a2ace971410307577f30cabe125121e7b5",
5
5
  "unitRevision": 0,
6
6
  "prerelease": false,
7
- "sourceCommit": "a3ff47a34939b04600374b8b242b9916853a105c",
7
+ "sourceCommit": "7872b6a2ace971410307577f30cabe125121e7b5",
8
8
  "sourceDirty": false,
9
- "builtAt": "2026-10-06T10:15:03.149Z",
9
+ "builtAt": "2026-10-10T23:37:25.751Z",
10
10
  "commercialServerIncluded": false
11
11
  }
@@ -1 +1 @@
1
- import{u as P,d,j as t}from"./index-Bh_nLVTc.js";import{F as D,a5 as T,aB as M,mm as R,eQ as V,hh as W,br as q,aa as y,mn as N,bn as B,a4 as U,bI as _,d_ as H,aq as $,mo as J,fJ as K,p as O,u as Q}from"./appStore-B1ynyt42.js";import"./client-DxGbwZLy.js";import{u as X}from"./codeStudioStore-C7rGKlOC.js";import{C as G}from"./CapabilityMenu-kx1TIJYN.js";import{c as Y}from"./nativeDownload-CziEyW_p.js";/* empty css */import{C as Z}from"./code-xml-joKQ-qGS.js";import{P as aa}from"./pencil-BSbra1Ra.js";import{A as ta}from"./arrow-up-right-R10mR2I6.js";import"./ipc-CPhL3bPp.js";const ia=[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"m15 10-3 3-3-3",key:"lzhmyn"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]],ea=D("monitor-down",ia);let v=0;const f=Y((i,l)=>({items:[],status:"loading",async load(){const m=window.tangu?.productsList;if(!m){i({status:"error"});return}const r=++v;l().status!=="ready"&&i({status:"loading"});try{const n=await m();r===v&&i({items:n,status:"ready"})}catch{r===v&&l().status!=="ready"&&i({status:"error"})}}})),b=i=>i instanceof Error?i.message:String(i);function wa(){const{t:i,locale:l}=P(),m=f(a=>a.items),r=f(a=>a.status),n=f(a=>a.load),[k]=d.useState(()=>f.getState().status!=="ready"),[S,o]=d.useState(null),w=T(a=>a.spaces.some(e=>e.id==="coding"))&&!!M("code-studio"),[z,g]=d.useState(()=>Date.now());d.useEffect(()=>{n();const a=()=>{g(Date.now()),n()};return window.addEventListener("focus",a),()=>{window.removeEventListener("focus",a)}},[n]),d.useEffect(()=>{const a=setInterval(()=>{document.hidden||g(Date.now())},6e4);return()=>clearInterval(a)},[]);const u=(a,e,s=!1)=>Q.getState().toast(i(a,e),s),L=a=>{O.getState().openView("product",{id:a.id},"main",{newTab:!0})},C=a=>{window.tangu?.openDetached?.([{type:"product",params:{id:a.id}}])},p=a=>{y("coding"),requestAnimationFrame(()=>{X.getState().openProject(a.root,a.name)})},E=async a=>{const e=window.tangu?.productsShortcut;if(e){o(a.id);try{const{key:s,error:c,vars:h}=J(await e(a.id,i("artificial.shortcut.fallbackName")));u(s,h,c)}catch(s){u("artificial.toast.shortcutFailed",{detail:b(s)},!0)}finally{o(null)}}},I=async a=>{const e=window.tangu?.productsUpdate;if(!e)return;const s=(await K(i("artificial.rename.title"),a.name,{label:i("artificial.rename.label")}))?.trim();if(!(!s||s===a.name)){o(a.id);try{await e(a.id,{name:s}),await n()}catch(c){u("artificial.toast.renameFailed",{detail:b(c)},!0)}finally{o(null)}}},A=async a=>{const e=window.tangu?.productsTrash;if(!(!e||!window.confirm(i(a.external?"artificial.remove.confirm":"artificial.trash.confirm",{name:a.name})))){o(a.id);try{await e(a.id,{action:a.external?"unregister":"trash",dirId:a.dirId}),await n()}catch(s){u("artificial.toast.trashFailed",{detail:b(s)},!0)}finally{o(null)}}},F=a=>{const e=N(a.kind),s=e.icon,c=S===a.id,h=[...e.canLaunch&&window.tangu?.openDetached?[{id:"open-window",label:i("artificial.action.openWindow"),icon:t.jsx(B,{size:14}),onSelect:()=>C(a)}]:[],...w?[{id:"edit",label:i("artificial.action.edit"),icon:t.jsx(Z,{size:14}),onSelect:()=>p(a)}]:[],...e.canShortcut&&window.tangu?.productsShortcut?[{id:"shortcut",label:i("artificial.action.shortcut"),icon:t.jsx(ea,{size:14}),onSelect:()=>{E(a)}}]:[],...window.tangu?.revealHostPath?[{id:"reveal",label:i("artificial.action.reveal"),icon:t.jsx(U,{size:14}),onSelect:()=>{window.tangu?.revealHostPath?.(a.root)}}]:[],...window.tangu?.productsUpdate?[{id:"rename",label:i("artificial.action.rename"),icon:t.jsx(aa,{size:14}),onSelect:()=>{I(a)}}]:[],...window.tangu?.productsTrash?[{id:"trash",label:i(a.external?"artificial.action.remove":"artificial.action.trash"),icon:t.jsx(_,{size:14}),danger:!0,onSelect:()=>{A(a)}}]:[]],j=c||!e.canLaunch&&!w;return t.jsxs("div",{className:"newtab-card art-card","data-artificial-card":!0,"data-product-id":a.id,"data-kind":a.kind,children:[t.jsxs("button",{className:"art-card-main","data-action":"open",disabled:j,"aria-label":e.canLaunch?i("artificial.action.open",{name:a.name}):`${i("artificial.action.edit")} · ${a.name}`,onClick:()=>e.canLaunch?L(a):p(a),children:[t.jsx("span",{className:"newtab-card-ic",children:t.jsx(s,{size:18})}),t.jsx("span",{className:"art-card-name",title:a.name,children:a.name}),!j&&t.jsx(ta,{size:14,className:"art-card-go","aria-hidden":!0})]}),t.jsxs("div",{className:"art-card-foot",children:[t.jsxs("div",{className:"art-card-meta",children:[t.jsx("span",{children:H(a.updatedAt,{now:z,locale:l})}),a.published&&t.jsx("span",{className:"art-badge","data-badge":"published",children:i("artificial.badge.published")}),a.kind==="plugin"&&a.devLoad&&t.jsx("span",{className:"art-badge","data-badge":"devload",children:i("artificial.badge.devLoad")})]}),h.length>0&&t.jsx(G,{label:i("artificial.action.more",{name:a.name}),className:"icon-btn art-card-more",disabled:c,items:h,children:t.jsx($,{size:14})})]})]},a.id)},x=R(m);return t.jsx("div",{className:"art-root","data-artificial-root":!0,children:t.jsxs("div",{className:"art-inner",children:[t.jsxs("div",{className:"art-head",children:[t.jsx(V,{size:18}),t.jsxs("div",{className:"art-titles",children:[t.jsx("div",{className:"art-title",children:i("view.artificial")}),t.jsx("div",{className:"art-sub",children:i("artificial.subtitle")})]}),t.jsx("button",{className:"icon-btn","data-action":"refresh",title:i("artificial.refresh"),"aria-label":i("artificial.refresh"),onClick:()=>{n()},children:t.jsx(W,{size:14})})]}),r==="loading"&&t.jsxs("div",{className:"art-loading","data-state":"loading",children:[t.jsx(q,{variant:"list"}),t.jsx("span",{className:"art-sr-only",role:"status",children:i("artificial.loading")})]}),r==="error"&&t.jsxs("div",{className:"art-state",role:"alert","data-state":"error",children:[t.jsx("div",{className:"art-state-title",children:i("artificial.loadFailed")}),t.jsx("button",{className:"btn sm","data-action":"retry",onClick:()=>{n()},children:i("common.retry")})]}),r==="ready"&&!x.length&&t.jsxs("div",{className:"art-state","data-state":"empty",children:[t.jsx("div",{className:"art-state-title",children:i("artificial.empty.title")}),t.jsx("p",{children:i("artificial.empty.body")}),w&&t.jsx("button",{className:"btn primary sm","data-action":"go-coding",onClick:()=>y("coding"),children:i("artificial.empty.cta")})]}),r==="ready"&&x.length>0&&t.jsx("div",{className:k?"sk-fade-in":void 0,children:x.map(a=>t.jsxs("div",{className:"newtab-sec","data-kind-group":a.kind,children:[t.jsx("div",{className:"newtab-sec-title",children:i(N(a.kind).labelKey)}),t.jsx("div",{className:"newtab-grid art-grid",children:a.items.map(F)})]},a.kind))})]})})}export{wa as ArtificialView};
1
+ import{u as D,d,j as t}from"./index-B5UW6SaE.js";import{G as F,a6 as T,aC as M,n3 as V,e_ as R,hx as W,bt as q,ab as y,n4 as N,b1 as U,a5 as _,bK as B,e3 as H,as as K,n5 as $,fV as G,q as O,u as X}from"./appStore-CidPWYa0.js";import"./client-CPUljePZ.js";import{u as J}from"./codeStudioStore-DXMQwRzG.js";import{C as Q}from"./CapabilityMenu-CrsaTtDe.js";import{c as Y}from"./nativeDownload-B3JGkABw.js";/* empty css */import{C as Z}from"./code-xml-n9mgGgkv.js";import{P as aa}from"./pencil-CJsJD7M_.js";import{A as ta}from"./arrow-up-right-KPFbRA41.js";import"./ipc-CNlIRMtU.js";const ia=[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"m15 10-3 3-3-3",key:"lzhmyn"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]],ea=F("monitor-down",ia);let v=0;const f=Y((i,l)=>({items:[],status:"loading",async load(){const m=window.tangu?.productsList;if(!m){i({status:"error"});return}const r=++v;l().status!=="ready"&&i({status:"loading"});try{const n=await m();r===v&&i({items:n,status:"ready"})}catch{r===v&&l().status!=="ready"&&i({status:"error"})}}})),b=i=>i instanceof Error?i.message:String(i);function wa(){const{t:i,locale:l}=D(),m=f(a=>a.items),r=f(a=>a.status),n=f(a=>a.load),[k]=d.useState(()=>f.getState().status!=="ready"),[S,c]=d.useState(null),w=T(a=>a.spaces.some(e=>e.id==="coding"))&&!!M("code-studio"),[z,g]=d.useState(()=>Date.now());d.useEffect(()=>{n();const a=()=>{g(Date.now()),n()};return window.addEventListener("focus",a),()=>{window.removeEventListener("focus",a)}},[n]),d.useEffect(()=>{const a=setInterval(()=>{document.hidden||g(Date.now())},6e4);return()=>clearInterval(a)},[]);const u=(a,e,s=!1)=>X.getState().toast(i(a,e),s),C=a=>{O.getState().openView("product",{id:a.id},"main",{newTab:!0})},L=a=>{window.tangu?.openDetached?.([{type:"product",params:{id:a.id}}])},j=a=>{y("coding"),requestAnimationFrame(()=>{J.getState().openProject(a.root,a.name)})},E=async a=>{const e=window.tangu?.productsShortcut;if(e){c(a.id);try{const{key:s,error:o,vars:h}=$(await e(a.id,i("artificial.shortcut.fallbackName")));u(s,h,o)}catch(s){u("artificial.toast.shortcutFailed",{detail:b(s)},!0)}finally{c(null)}}},A=async a=>{const e=window.tangu?.productsUpdate;if(!e)return;const s=(await G(i("artificial.rename.title"),a.name,{label:i("artificial.rename.label")}))?.trim();if(!(!s||s===a.name)){c(a.id);try{await e(a.id,{name:s}),await n()}catch(o){u("artificial.toast.renameFailed",{detail:b(o)},!0)}finally{c(null)}}},I=async a=>{const e=window.tangu?.productsTrash;if(!(!e||!window.confirm(i(a.external?"artificial.remove.confirm":"artificial.trash.confirm",{name:a.name})))){c(a.id);try{await e(a.id,{action:a.external?"unregister":"trash",dirId:a.dirId}),await n()}catch(s){u("artificial.toast.trashFailed",{detail:b(s)},!0)}finally{c(null)}}},P=a=>{const e=N(a.kind),s=e.icon,o=S===a.id,h=[...e.canLaunch&&window.tangu?.openDetached?[{id:"open-window",label:i("artificial.action.openWindow"),icon:t.jsx(U,{size:14}),onSelect:()=>L(a)}]:[],...w?[{id:"edit",label:i("artificial.action.edit"),icon:t.jsx(Z,{size:14}),onSelect:()=>j(a)}]:[],...e.canShortcut&&window.tangu?.productsShortcut?[{id:"shortcut",label:i("artificial.action.shortcut"),icon:t.jsx(ea,{size:14}),onSelect:()=>{E(a)}}]:[],...window.tangu?.revealHostPath?[{id:"reveal",label:i("artificial.action.reveal"),icon:t.jsx(_,{size:14}),onSelect:()=>{window.tangu?.revealHostPath?.(a.root)}}]:[],...window.tangu?.productsUpdate?[{id:"rename",label:i("artificial.action.rename"),icon:t.jsx(aa,{size:14}),onSelect:()=>{A(a)}}]:[],...window.tangu?.productsTrash?[{id:"trash",label:i(a.external?"artificial.action.remove":"artificial.action.trash"),icon:t.jsx(B,{size:14}),danger:!0,onSelect:()=>{I(a)}}]:[]],p=o||!e.canLaunch&&!w;return t.jsxs("div",{className:"newtab-card art-card","data-artificial-card":!0,"data-product-id":a.id,"data-kind":a.kind,children:[t.jsxs("button",{className:"art-card-main","data-action":"open",disabled:p,"aria-label":e.canLaunch?i("artificial.action.open",{name:a.name}):`${i("artificial.action.edit")} · ${a.name}`,onClick:()=>e.canLaunch?C(a):j(a),children:[t.jsx("span",{className:"newtab-card-ic",children:t.jsx(s,{size:18})}),t.jsx("span",{className:"art-card-name",title:a.name,children:a.name}),!p&&t.jsx(ta,{size:14,className:"art-card-go","aria-hidden":!0})]}),t.jsxs("div",{className:"art-card-foot",children:[t.jsxs("div",{className:"art-card-meta",children:[t.jsx("span",{children:H(a.updatedAt,{now:z,locale:l})}),a.published&&t.jsx("span",{className:"art-badge","data-badge":"published",children:i("artificial.badge.published")}),a.kind==="plugin"&&a.devLoad&&t.jsx("span",{className:"art-badge","data-badge":"devload",children:i("artificial.badge.devLoad")})]}),h.length>0&&t.jsx(Q,{label:i("artificial.action.more",{name:a.name}),className:"icon-btn art-card-more",disabled:o,items:h,children:t.jsx(K,{size:14})})]})]},a.id)},x=V(m);return t.jsx("div",{className:"art-root","data-artificial-root":!0,children:t.jsxs("div",{className:"art-inner",children:[t.jsxs("div",{className:"art-head",children:[t.jsx(R,{size:18}),t.jsxs("div",{className:"art-titles",children:[t.jsx("div",{className:"art-title",children:i("view.artificial")}),t.jsx("div",{className:"art-sub",children:i("artificial.subtitle")})]}),t.jsx("button",{className:"icon-btn","data-action":"refresh",title:i("artificial.refresh"),"aria-label":i("artificial.refresh"),onClick:()=>{n()},children:t.jsx(W,{size:14})})]}),r==="loading"&&t.jsxs("div",{className:"art-loading","data-state":"loading",children:[t.jsx(q,{variant:"list"}),t.jsx("span",{className:"art-sr-only",role:"status",children:i("artificial.loading")})]}),r==="error"&&t.jsxs("div",{className:"art-state",role:"alert","data-state":"error",children:[t.jsx("div",{className:"art-state-title",children:i("artificial.loadFailed")}),t.jsx("button",{className:"btn sm","data-action":"retry",onClick:()=>{n()},children:i("common.retry")})]}),r==="ready"&&!x.length&&t.jsxs("div",{className:"art-state","data-state":"empty",children:[t.jsx("div",{className:"art-state-title",children:i("artificial.empty.title")}),t.jsx("p",{children:i("artificial.empty.body")}),w&&t.jsx("button",{className:"btn primary sm","data-action":"go-coding",onClick:()=>y("coding"),children:i("artificial.empty.cta")})]}),r==="ready"&&x.length>0&&t.jsx("div",{className:k?"sk-fade-in":void 0,children:x.map(a=>t.jsxs("div",{className:"newtab-sec","data-kind-group":a.kind,children:[t.jsx("div",{className:"newtab-sec-title",children:i(N(a.kind).labelKey)}),t.jsx("div",{className:"newtab-grid art-grid",children:a.items.map(P)})]},a.kind))})]})})}export{wa as ArtificialView};
@@ -1 +1 @@
1
- import{d as o,j as e,u as pe}from"./index-Bh_nLVTc.js";import{F as Ye,bo as Qe,qI as le,fy as Ze,kn as et,aJ as tt,dC as at,fL as nt,fH as it,hB as lt,hw as st,gK as ot,hE as rt,qJ as dt,h as ut,b as ct,fl as ie,aS as mt,qK as ht,qL as $e,qM as Ie,qN as Fe,a2 as Re,K as qe,hy as be,ap as bt,aK as xt,qO as pt,bI as xe,qP as vt,qQ as gt,bG as jt,bH as ft,G as yt,J as Nt,_ as _t,gE as Ct,qR as kt,qS as wt,s as St,qT as Et,qU as Pt,u as $t}from"./appStore-B1ynyt42.js";import{C as Ft}from"./CapabilityMenu-kx1TIJYN.js";import{u as Rt}from"./gestures-CZQVefU0.js";import{a as qt,C as Dt}from"./Chrome-B77-lQyh.js";import{d as Tt,e as zt,f as It,g as Mt}from"./canvasPrefs-DwL_OAAo.js";import{R as At}from"./rotate-ccw-HedfU4na.js";import"./messages-CBtmbpur.js";import{W as De}from"./workflow-DzeW9OXR.js";import{C as Ht}from"./circle-question-mark-HPZpZQxd.js";const Lt=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Vt=Ye("bell",Lt);function Wt({controller:i,open:c,title:b,onClose:C,children:h}){const[g]=o.useState(()=>document.createElement("div"));g.className="auto-extension";const a=o.useRef(null),k=o.useRef(C);k.current=C;const v=o.useRef(b);return v.current=b,o.useEffect(()=>{if(!(!i||!c)){try{a.current=i.open({id:"automation-context",title:()=>v.current,mount:f=>(f.appendChild(g),()=>g.remove()),onClose:()=>k.current()})}catch{k.current()}return()=>{a.current?.close(),a.current=null}}},[i,c,g]),c?i?Qe.createPortal(h,g):e.jsx("div",{className:"auto-extension auto-extension-inline",children:h}):null}const sa=["reminder","briefing","table","button"];function Ot(i,c){return i?i==="briefing"||i==="button"?[{...le("agent_run"),prompt:c(`automation.ux.${i}.prompt`)}]:[{...le("notify"),title:c(`automation.ux.${i}.name`),body:c(`automation.ux.${i}.body`)}]:[le("notify")]}function Te(i,c,b){if(i.type==="notify")return i.title.trim()?null:"notify";if(i.type==="agent_run")return i.agentSlug?i.prompt.trim()?null:"prompt":"agent";if(i.type==="db_row_add"||i.type==="db_row_edit"){if(!/\.db$/i.test(i.dbPath.trim()))return"table";if(!i.cells.some(h=>h.k.trim()))return"cells";if(i.type==="db_row_edit"){if(c!=="db_changed"&&(!i.rowId.trim()&&!i.matchColumn.trim()||i.rowFrom.trim()))return"row";if(i.matchColumn.trim()&&!i.matchValue.trim())return"match"}return null}const C=b.find(h=>h.name===i.tool);if(!C)return"tool";if((C.parameters.required||[]).some(h=>!(i.argValues[h]||"").trim()))return"args";for(const[h,g]of Object.entries(i.argValues)){if(!g.trim())continue;const a=C.parameters.properties?.[h];if(a?.type==="number"&&!Number.isFinite(Number(g)))return"args";if(a?.type==="object"||a?.type==="array")try{const k=JSON.parse(g);if(a.type==="array"?!Array.isArray(k):!k||typeof k!="object"||Array.isArray(k))return"json"}catch{return"json"}}return null}function Bt(i){return(i||[]).map(c=>({value:`{{row.${c.id}}}`,label:c.name}))}const Kt=i=>({x:0,y:i*132,w:244,h:84}),Ut=({nodes:i,selected:c,onSelect:b,children:C})=>{const{t:h}=pe(),g=o.useId().replace(/:/g,""),a=o.useRef(null),[k,v]=o.useState({}),[f,$]=o.useState(Tt),[I,F]=o.useState(zt),x=Ze(a),m=new Map(i.map((n,s)=>[n.id,k[n.id]||Kt(s)])),P=i.map(n=>n.id).join(","),p=Rt(a,x,{boxes:()=>m,identity:()=>P,commit:n=>v(s=>({...s,...Object.fromEntries(n)})),hitKey:n=>n.closest("[data-flow-node]")?.dataset.flowNode||null,onEnterEdit:b,onDoubleClick:n=>{n&&b(n)},minW:244,minH:84,repel:!0},f);o.useEffect(()=>p.bind(a.current),[p.bind]),o.useEffect(()=>x.bindWheel(a.current),[x.bindWheel]);const q=o.useRef(()=>x.fitTo([...m.values()],64));q.current=()=>x.fitTo([...m.values()],64),o.useEffect(()=>{v({});const n=requestAnimationFrame(()=>q.current());return()=>cancelAnimationFrame(n)},[P]),o.useEffect(()=>{const n=new ResizeObserver(()=>q.current());return a.current&&n.observe(a.current),()=>n.disconnect()},[]);const M=n=>p.live?.get(n)||m.get(n);return e.jsx("div",{className:"auto-canvas-shell am-app",children:e.jsxs("div",{className:"auto-canvas amx-stage",ref:a,tabIndex:0,"aria-label":h("automation.ux.flow"),onPointerUpCapture:n=>{if(p.busy)return;const s=document.elementFromPoint(n.clientX,n.clientY)?.closest("[data-flow-node]");s&&a.current?.contains(s)&&b(s.dataset.flowNode)},children:[e.jsx("div",{className:"amx-stage-grid",style:et(x.vp)}),e.jsxs("div",{className:"auto-canvas-world",style:{transform:`translate(${x.vp.x}px, ${x.vp.y}px) scale(${x.vp.z})`},children:[e.jsxs("svg",{className:"auto-canvas-edges","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsx("marker",{id:g,markerWidth:"8",markerHeight:"8",refX:"6",refY:"3",orient:"auto",children:e.jsx("path",{d:"M0,0 L6,3 L0,6",fill:"none",stroke:"currentColor"})})}),i.slice(1).map((n,s)=>{const y=M(i[s].id),w=M(n.id),A=y.x+y.w/2,H=y.y+y.h,X=w.x+w.w/2,V=w.y;return e.jsx("path",{d:`M${A},${H} C${A},${H+28} ${X},${V-28} ${X},${V}`,markerEnd:`url(#${g})`},n.id)})]}),i.map(n=>{const s=M(n.id);return e.jsxs("div",{"data-flow-node":n.id,role:"button",tabIndex:0,"aria-pressed":c===n.id,className:`auto-flow-node ${c===n.id?"selected":""}`,style:{left:s.x,top:s.y,width:s.w,height:s.h},onClick:()=>b(n.id),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),b(n.id))},children:[e.jsx("span",{className:"auto-flow-icon",children:n.icon}),e.jsx("strong",{children:n.title}),e.jsx("span",{className:"auto-flow-status",title:h(n.ready?"automation.ux.ready":"automation.ux.incomplete"),children:n.ready?e.jsx(tt,{size:13}):e.jsx(at,{size:13})}),e.jsx("span",{className:"auto-flow-subtitle",children:n.subtitle})]},n.id)}),p.marquee&&e.jsx("div",{className:"amx-stage-marquee",style:{left:p.marquee.x,top:p.marquee.y,width:p.marquee.w,height:p.marquee.h}})]}),C&&e.jsx("div",{className:"amx-stage-tools auto-canvas-tools",children:C}),e.jsx(qt,{zoom:x.vp.z,onZoomBy:n=>{const{w:s,h:y}=nt(a.current);x.setVp(it(x.vp,x.vp.z*n,s/2,y/2))},onFit:()=>q.current(),snap:f,onSnap:n=>{$(n),Mt(n)},mini:I,onMini:n=>{F(n),It(n)},extra:e.jsx("button",{type:"button",title:h("automation.ux.arrange"),onClick:()=>{v({}),requestAnimationFrame(()=>q.current())},children:e.jsx(At,{size:12})})}),I&&e.jsx(Dt,{hostRef:a,vp:x.vp,items:i.map(n=>({key:n.id,kind:"card",box:M(n.id)})),onCenter:x.centerOn})]})})},ze=({label:i,value:c,onChange:b,multiline:C,maxLength:h=4e3,placeholder:g,columns:a,hasRow:k})=>{const{t:v}=pe(),f=o.useId(),$=o.useRef(null),I=o.useRef({start:c.length,end:c.length}),F=m=>{if(!m)return;const{start:P,end:p}=I.current;c.length-(p-P)+m.length>h||(b(c.slice(0,P)+m+c.slice(p)),requestAnimationFrame(()=>{$.current?.focus(),$.current?.setSelectionRange(P+m.length,P+m.length)}))},x={id:f,ref:$,value:c,maxLength:h,placeholder:g,onChange:m=>b(m.target.value),onSelect:m=>{I.current={start:m.currentTarget.selectionStart??c.length,end:m.currentTarget.selectionEnd??c.length}}};return e.jsxs("div",{className:"field auto-template-field",children:[e.jsxs("div",{className:"auto-field-heading",children:[e.jsx("label",{htmlFor:f,children:i}),e.jsxs("select",{"aria-label":v("automation.ux.insertVariable",{field:i}),value:"",onChange:m=>F(m.target.value),children:[e.jsx("option",{value:"",children:v("automation.ux.variables")}),e.jsx("option",{value:"{{today}}",children:v("automation.ux.today")}),e.jsx("option",{value:"{{now}}",children:v("automation.ux.now")}),k&&e.jsxs("optgroup",{label:v("automation.ux.triggerRow"),children:[e.jsx("option",{value:"{{row.id}}",children:v("automation.ux.rowId")}),Bt(a).map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))]})]})]}),C?e.jsx("textarea",{...x}):e.jsx("input",{type:"text",...x})]})};function Gt(){const i=new Date(Date.now()+36e5);i.setMinutes(0,0,0);const c=b=>String(b).padStart(2,"0");return`${i.getFullYear()}-${c(i.getMonth()+1)}-${c(i.getDate())}T${c(i.getHours())}:00`}const Jt=({editing:i,starter:c,fixedManual:b,onSaved:C,onCancel:h,extendView:g})=>{const{t:a}=pe(),k=lt(),v=st(),f=v.actionsCatalog,[$,I]=o.useState(i?.desc||(c?a(`automation.ux.${c}.name`):"")),[F,x]=o.useState("trigger"),[m,P]=o.useState(!1),p=t=>{x(t),P(!0)},[q,M]=o.useState(i?.enabled??!!b),n=i?.cond,[s,y]=o.useState(n?n.type==="event_seen"?"event_seen":n.type==="file_chars_gte"?"file_chars_gte":n.type==="manual"?"manual":n.type==="db_changed"?"db_changed":"timer":b||c==="button"?"manual":c==="table"?"db_changed":"timer"),[w,A]=o.useState(n?.type==="at"?"at":n?.type==="every"?"every":"daily_at"),[H,X]=o.useState(n?.type==="daily_at"?n.time:"09:00"),V=!!i&&ot(i),[Y,Me]=o.useState(n?.type==="at"&&!V?n.datetime.replace(" ","T"):Gt()),Q=n?.type==="every"?/^(\d+)([mhd])$/.exec(n.interval):null,[Z,Ae]=o.useState(Q?Q[1]:"1"),[ve,He]=o.useState(Q?Q[2]:"h"),[se,Le]=o.useState(n?.type==="event_seen"?n.match:""),[oe,Ve]=o.useState(n?.type==="file_chars_gte"?n.path:""),[re,We]=o.useState(n?.type==="file_chars_gte"?String(n.n):"100"),[R,Oe]=o.useState(n?.type==="db_changed"?n.path:""),[T,ge]=o.useState(n?.type==="db_changed"?n.event:"row_added"),[L,je]=o.useState(()=>rt(n)),fe=(t,u)=>je(r=>u?r.includes(t)?r:[...r,t]:r.filter(l=>l!==t)),[de,Be]=o.useState(n?.type==="db_changed"&&n.equals||""),[W,ue]=o.useState(()=>dt(n)),ce=(t,u)=>ue(r=>r.map((l,d)=>d===t?{...l,...u}:l));o.useEffect(()=>{ut()},[]);const ye=ct(t=>t.files),O=o.useMemo(()=>ye.filter(t=>/\.db$/i.test(t)),[ye]);o.useEffect(()=>{for(const t of O)ie.getState().load(t,t)},[O]);const Ne=ie(mt(t=>O.filter(u=>t.entries[u]?.data?.source!==void 0))),ee=o.useMemo(()=>O.filter(t=>!Ne.includes(t)),[O,Ne]),B=ie(t=>s==="db_changed"&&R?t.entries[R]?.data?.columns:void 0),K=o.useMemo(()=>B?.filter(t=>t.type!=="formula"&&t.type!=="lookup"),[B]),[S,te]=o.useState(()=>i?ht(i):Ot(c,a)),[me,Ke]=o.useState(i&&!i.actions?.length&&!i.agentSlug&&i.prompt||""),[U,_e]=o.useState(()=>$e(i,s)),Ce=o.useRef(!1);o.useEffect(()=>{!i&&!Ce.current&&_e($e(null,s))},[s,i]);const[G,ke]=o.useState(!1),[we,ae]=o.useState(""),Ue=t=>{if(S.length>=24)return;const u=le(t);te(r=>[...r,u]),p(String(u.key))},Se=S.some(t=>t.type==="agent_run"),j=(t,u)=>te(r=>r.map(l=>l.key===t?{...l,...u}:l)),Ee=(t,u)=>te(r=>{const l=t+u;if(l<0||l>=r.length)return r;const d=[...r];return[d[t],d[l]]=[d[l],d[t]],d});if(Ie(i))return e.jsxs("div",{className:"auto-builder",children:[e.jsxs("div",{className:"auto-builder-title",children:[e.jsx(De,{size:17})," ",a("automation.builder.editTitle")]}),e.jsx("div",{className:"auto-node",children:e.jsx("div",{className:"auto-hint",children:a("automation.builder.unsupported")})}),e.jsx("div",{className:"auto-builder-actions",children:e.jsx("button",{className:"btn ghost",onClick:()=>h?h():v.closeBuilder(),children:a("common.cancel")})})]});const Pe=!(s==="timer"&&(w==="daily_at"&&!/^\d{1,2}:\d{2}$/.test(H)||w==="at"&&!Y||w==="every"&&(!Number.isInteger(Number(Z))||Number(Z)<1))||s==="event_seen"&&!se.trim()||s==="file_chars_gte"&&(!oe.trim()||!(Number(re)>0))||s==="db_changed"&&(!/\.db$/i.test(R.trim())||T==="cell_changed"&&!L.length||W.length>Fe||W.some(t=>t.column.trim()&&(t.op==="eq"||t.op==="ne")&&!t.value.trim()))),E=[];$.trim()||E.push({node:"trigger",text:a("automation.ux.issue.name")}),Pe||E.push({node:"trigger",text:a("automation.ux.issue.trigger")}),!S.length&&(!i||s==="manual")&&E.push({node:"review",text:a("automation.ux.issue.steps")}),S.forEach((t,u)=>{const r=Te(t,s,f);r&&E.push({node:String(t.key),text:`${u+1}. ${a(`automation.ux.issue.${r}`)}`})}),s!=="timer"&&s!=="manual"&&(!U.trim()||!Number.isFinite(Number(U))||Number(U)<0)&&E.push({node:"review",text:a("automation.ux.issue.cooldown")});const ne=E.length===0,Ge=async()=>{if(!ne||G)return;const t=s==="timer"?w:s;if(t==="at"&&(Ct(Y)?.getTime()??0)<Date.now()-5*6e4){ae(a("automation.builder.atPast"));return}const u=d=>ie.getState().entries[d]?.data?.source!==void 0;if([...t==="db_changed"?[R.trim()]:[],...S.filter(d=>d.type==="db_row_add"||d.type==="db_row_edit").map(d=>d.dbPath.trim())].filter(Boolean).some(u)){ae(a("automation.builder.dbNoteView"));return}ke(!0),ae("");const l=kt(S,f);try{const d=await wt(St(),{id:i?.id,actor:"user",desc:$.trim(),cond_type:t,time:t==="daily_at"?H:void 0,datetime:t==="at"?Y:void 0,interval:t==="every"?`${Math.floor(Number(Z))}${ve}`:void 0,match:t==="event_seen"?se.trim():void 0,path:t==="file_chars_gte"?oe.trim():t==="db_changed"?R.trim():void 0,n:t==="file_chars_gte"?Number(re):void 0,event:t==="db_changed"?T:void 0,column_id:t==="db_changed"&&T==="cell_changed"?L[0]:void 0,column_ids:t==="db_changed"&&T==="cell_changed"&&L.length>1?L:void 0,equals:t==="db_changed"&&T==="cell_changed"&&de.trim()?de.trim():void 0,where:t==="db_changed"?Pt(W):void 0,vault:t==="db_changed"&&i?.cond.type==="db_changed"?i.cond.vault:void 0,prompt:S.length?void 0:me.trim()||void 0,cooldown_hours:Et(s,U),actions:S.length?l:null,enabled:q});if(C){v.bump(),C(d);return}v.acceptSaved(d),$t.getState().toast(a("automation.ux.saved"))}catch(d){ae(String(d?.message||d))}finally{ke(!1)}},he=t=>t==="notify"?e.jsx(Vt,{size:14}):t==="agent_run"?e.jsx(yt,{size:14}):t==="db_row_add"||t==="db_row_edit"?e.jsx(Nt,{size:14}):e.jsx(_t,{size:14}),Je=[{id:"trigger",title:a("automation.builder.trigger"),subtitle:a(`automation.builder.${s==="timer"?"condTimer":s==="manual"?"condManual":s==="db_changed"?"condDb":s==="event_seen"?"condEvent":"condFile"}`),icon:e.jsx(Re,{size:17}),ready:Pe&&!!$.trim()},...S.map((t,u)=>({id:String(t.key),title:`${u+1}. ${a(`automation.step.${t.type}`)}`,subtitle:t.title||t.prompt||t.dbPath||t.tool||a("automation.ux.setupHint"),icon:he(t.type),ready:!Te(t,s,f)})),...!S.length&&i&&s!=="manual"?[{id:"muse",title:a("automation.builder.museFallback"),subtitle:me||a("automation.builder.museFallbackHint"),icon:e.jsx(qe,{size:17}),ready:!0}]:[],{id:"review",title:a("automation.ux.finish"),subtitle:a(ne?"automation.ux.allReady":"automation.ux.finishHint"),icon:e.jsx(be,{size:17}),ready:ne}],Xe=e.jsxs(e.Fragment,{children:[e.jsxs(Ft,{label:a("automation.ux.addStep"),className:"btn ghost sm",disabled:G||S.length>=24,items:["notify","agent_run","db_row_add","db_row_edit","tool_call"].map(t=>({id:t,label:a(`automation.step.${t}`),icon:he(t),disabled:t==="tool_call"&&!f.length,onSelect:()=>Ue(t)})),children:[e.jsx(bt,{size:14}),a("automation.ux.addStep")]}),e.jsx("button",{className:"icon-btn",title:a("automation.ux.help"),onClick:()=>p("help"),children:e.jsx(Ht,{size:15})})]});return e.jsxs("div",{className:`auto-builder auto-workflow-builder ${b?"auto-builder-embedded":""}`,children:[e.jsxs("div",{className:"auto-builder-title",children:[e.jsx(De,{size:17}),e.jsx("span",{children:a(i?"automation.builder.editTitle":"automation.builder.title")}),e.jsx("button",{className:"btn ghost sm",disabled:G,onClick:()=>h?h():v.closeBuilder(),children:a("common.cancel")})]}),e.jsx("div",{className:"auto-builder-workspace",hidden:!g&&m,children:e.jsx(Ut,{nodes:Je,selected:m?F:"",onSelect:p,children:Xe})}),e.jsxs(Wt,{controller:g,open:m,title:a("automation.ux.setup"),onClose:()=>P(!1),children:[!g&&e.jsxs("button",{className:"btn ghost sm auto-inline-back",onClick:()=>P(!1),children:[e.jsx(xt,{size:14}),a("automation.ux.flow")]}),e.jsxs("div",{className:"auto-inspector","aria-label":a("automation.ux.setup"),children:[e.jsxs("div",{className:"auto-node",hidden:F!=="trigger",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:e.jsx(Re,{size:14})}),a("automation.builder.trigger")]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.desc")}),e.jsx("input",{"aria-label":a("automation.builder.desc"),type:"text",value:$,maxLength:200,placeholder:a("automation.builder.descPh"),onChange:t=>I(t.target.value)})]}),!b&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.condType")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:s==="timer"?"active":"",onClick:()=>y("timer"),children:a("automation.builder.condTimer")}),e.jsx("button",{className:s==="event_seen"?"active":"",onClick:()=>y("event_seen"),children:a("automation.builder.condEvent")}),e.jsx("button",{className:s==="file_chars_gte"?"active":"",onClick:()=>y("file_chars_gte"),children:a("automation.builder.condFile")}),e.jsx("button",{className:s==="db_changed"?"active":"",onClick:()=>y("db_changed"),children:a("automation.builder.condDb")}),e.jsx("button",{className:s==="manual"?"active":"",onClick:()=>y("manual"),children:a("automation.builder.condManual")})]})]}),s==="db_changed"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbPath")}),e.jsxs("select",{value:R,onChange:t=>{Oe(t.target.value),je([])},children:[e.jsx("option",{value:"",children:a("automation.builder.dbPickDb")}),ee.map(t=>e.jsx("option",{value:t,children:t},t)),R&&!ee.includes(R)&&e.jsx("option",{value:R,children:R})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbEvent")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:T==="row_added"?"active":"",onClick:()=>ge("row_added"),children:a("automation.builder.dbEventRow")}),e.jsx("button",{className:T==="cell_changed"?"active":"",onClick:()=>ge("cell_changed"),children:a("automation.builder.dbEventCell")})]})]}),T==="cell_changed"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbColumn")}),e.jsxs("div",{className:"auto-checks",children:[(K??[]).map(t=>e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:L.includes(t.id),onChange:u=>fe(t.id,u.target.checked)}),t.name]},t.id)),L.filter(t=>!(K??[]).some(u=>u.id===t)).map(t=>e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:!0,onChange:()=>fe(t,!1)}),"(",t,")"]},t)),!K&&e.jsx("span",{className:"auto-hint",children:a("automation.builder.dbColsLoading")})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbColumnsHint")})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbEquals")}),e.jsx("input",{type:"text",value:de,maxLength:200,placeholder:a("automation.builder.dbEqualsPh"),onChange:t=>Be(t.target.value)})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbWhere")}),W.map((t,u)=>e.jsxs("div",{className:"auto-inline",children:[e.jsxs("select",{value:t.column,onChange:r=>ce(u,{column:r.target.value}),children:[e.jsx("option",{value:"",children:a(B?"automation.builder.dbPickCol":"automation.builder.dbColsLoading")}),(B??[]).map(r=>e.jsx("option",{value:r.id,children:r.name},r.id)),t.column&&!(B??[]).some(r=>r.id===t.column)&&e.jsxs("option",{value:t.column,children:["(",t.column,")"]})]}),e.jsx("select",{value:t.op,onChange:r=>ce(u,{op:r.target.value}),children:pt.map(r=>e.jsx("option",{value:r,children:a(r==="eq"?"automation.builder.dbWhereOpEq":r==="ne"?"automation.builder.dbWhereOpNe":r==="empty"?"automation.builder.dbWhereOpEmpty":"automation.builder.dbWhereOpNotEmpty")},r))}),e.jsx("input",{type:"text",value:t.value,maxLength:200,disabled:t.op==="empty"||t.op==="notempty",placeholder:a("automation.builder.dbWhereValPh"),onChange:r=>ce(u,{value:r.target.value})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),onClick:()=>ue(r=>r.filter((l,d)=>d!==u)),children:e.jsx(xe,{size:12})})]},u)),e.jsx("button",{className:"icon-btn",title:a("automation.builder.dbWhereAdd"),disabled:W.length>=Fe,onClick:()=>ue(t=>[...t,{column:"",op:"eq",value:""}]),children:"+"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbWhereHint")})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbHint")})]}),s==="manual"&&e.jsx("div",{className:"auto-hint",children:a("automation.builder.manualHint")}),s==="timer"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.timerMode")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:w==="daily_at"?"active":"",onClick:()=>A("daily_at"),children:a("automation.builder.timerDaily")}),e.jsx("button",{className:w==="at"?"active":"",onClick:()=>A("at"),children:a("automation.builder.timerOnce")}),e.jsx("button",{className:w==="every"?"active":"",onClick:()=>A("every"),children:a("automation.builder.timerEvery")})]})]}),w==="daily_at"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.time")}),e.jsx("input",{type:"time",value:H,onChange:t=>X(t.target.value)})]}),w==="at"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.datetime")}),e.jsx("input",{type:"datetime-local",value:Y,onChange:t=>Me(t.target.value)}),e.jsx("div",{className:"auto-hint",children:a(V?"automation.builder.expiredReset":"automation.builder.onceHint")})]}),w==="every"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.interval")}),e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"number",value:Z,min:1,style:{width:90},onChange:t=>Ae(t.target.value)}),e.jsxs("select",{value:ve,onChange:t=>He(t.target.value),children:[e.jsx("option",{value:"m",children:a("automation.builder.unitM")}),e.jsx("option",{value:"h",children:a("automation.builder.unitH")}),e.jsx("option",{value:"d",children:a("automation.builder.unitD")})]})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.everyHint")})]})]}),s==="event_seen"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.match")}),e.jsx("input",{type:"text",list:"auto-event-catalog",value:se,maxLength:120,placeholder:a("automation.builder.matchPh"),onChange:t=>Le(t.target.value)}),e.jsxs("datalist",{id:"auto-event-catalog",children:[vt.map(t=>e.jsx("option",{value:t},t)),gt().map(t=>e.jsx("option",{value:t.name,label:t.label},t.name))]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.matchHint")})]}),s==="file_chars_gte"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.path")}),e.jsx("input",{type:"text",value:oe,placeholder:"~/Forsion/Notes/xxx.md",onChange:t=>Ve(t.target.value)})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.chars")}),e.jsx("input",{type:"number",value:re,min:1,onChange:t=>We(t.target.value)})]})]})]}),S.map((t,u)=>{const r=t.type==="tool_call"?f.find(l=>l.name===t.tool):void 0;return e.jsxs("div",{className:"auto-node",hidden:F!==String(t.key),children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:he(t.type)}),a("automation.builder.stepN",{n:String(u+1)})," · ",a(`automation.step.${t.type}`),e.jsxs("span",{className:"auto-step-tools",children:[e.jsx("button",{className:"icon-btn",disabled:u===0,title:a("automation.builder.moveUp"),onClick:()=>Ee(u,-1),children:e.jsx(jt,{size:12})}),e.jsx("button",{className:"icon-btn",disabled:u===S.length-1,title:a("automation.builder.moveDown"),onClick:()=>Ee(u,1),children:e.jsx(ft,{size:12})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),onClick:()=>{te(l=>l.filter(d=>d.key!==t.key)),p("trigger")},children:e.jsx(xe,{size:12})})]})]}),t.type==="notify"&&e.jsxs(e.Fragment,{children:[e.jsx(ze,{label:a("automation.builder.notifyTitle"),value:t.title,maxLength:200,placeholder:a("automation.builder.notifyTitlePh"),onChange:l=>j(t.key,{title:l}),columns:K,hasRow:s==="db_changed"}),e.jsx(ze,{label:a("automation.builder.notifyBody"),value:t.body,multiline:!0,onChange:l=>j(t.key,{body:l}),columns:K,hasRow:s==="db_changed"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.notifyHint")})]}),t.type==="agent_run"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.runner")}),e.jsxs("select",{value:t.agentSlug,onChange:l=>j(t.key,{agentSlug:l.target.value}),children:[e.jsx("option",{value:"",children:a("automation.builder.runnerPick")}),k.filter(l=>l.slug!=="muse").map(l=>e.jsx("option",{value:l.slug,children:l.name},l.slug))]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.prompt")}),e.jsx("textarea",{value:t.prompt,maxLength:500,placeholder:a("automation.builder.promptPh"),onChange:l=>j(t.key,{prompt:l.target.value})})]})]}),(t.type==="db_row_add"||t.type==="db_row_edit")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbPath")}),e.jsxs("select",{value:t.dbPath,onChange:l=>j(t.key,{dbPath:l.target.value}),children:[e.jsx("option",{value:"",children:a("automation.builder.dbPickDb")}),ee.map(l=>e.jsx("option",{value:l,children:l},l)),t.dbPath&&!ee.includes(t.dbPath)&&e.jsx("option",{value:t.dbPath,children:t.dbPath})]})]}),t.type==="db_row_edit"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbRowId")}),e.jsx("input",{type:"text",value:t.rowId,placeholder:a(s==="db_changed"?"automation.builder.dbRowIdPh":"automation.builder.dbRowIdRequired"),onChange:l=>j(t.key,{rowId:l.target.value})})]}),t.type==="db_row_edit"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbRowFrom")}),e.jsx("input",{type:"text",value:t.rowFrom,maxLength:200,placeholder:a("automation.builder.dbRowFromPh"),onChange:l=>j(t.key,{rowFrom:l.target.value})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbMatch")}),e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"text",value:t.matchColumn,maxLength:200,placeholder:a("automation.builder.dbCellKey"),style:{width:120},onChange:l=>j(t.key,{matchColumn:l.target.value})}),e.jsx("input",{type:"text",value:t.matchValue,maxLength:2e3,placeholder:a("automation.builder.dbMatchValPh"),onChange:l=>j(t.key,{matchValue:l.target.value})})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbTargetHint")})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbCells")}),t.cells.map((l,d)=>e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"text",value:l.k,placeholder:a("automation.builder.dbCellKey"),style:{width:120},onChange:z=>j(t.key,{cells:t.cells.map((N,D)=>D===d?{...N,k:z.target.value}:N)})}),e.jsx("input",{type:"text",value:l.v,placeholder:a(d===0?"automation.builder.dbCellValPh":"automation.builder.dbCellVal"),onChange:z=>j(t.key,{cells:t.cells.map((N,D)=>D===d?{...N,v:z.target.value}:N)})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),disabled:t.cells.length<=1,onClick:()=>j(t.key,{cells:t.cells.filter((z,N)=>N!==d)}),children:e.jsx(xe,{size:12})})]},d)),e.jsx("button",{className:"icon-btn",title:a("automation.builder.dbCellAdd"),onClick:()=>j(t.key,{cells:[...t.cells,{k:"",v:""}]}),children:"+"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbCellsHint")})]}),t.type==="db_row_add"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbSkipIfEmpty")}),e.jsx("input",{type:"text",value:t.skipIfEmpty,maxLength:200,placeholder:a("automation.builder.dbSkipIfEmptyPh"),onChange:l=>j(t.key,{skipIfEmpty:l.target.value})})]})]}),t.type==="tool_call"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.tool")}),e.jsxs("select",{value:t.tool,onChange:l=>{const d=f.find(N=>N.name===l.target.value),z=Object.fromEntries((d?.parameters.required||[]).filter(N=>d?.parameters.properties?.[N]?.type==="boolean").map(N=>[N,"false"]));j(t.key,{tool:l.target.value,argValues:z})},children:[e.jsx("option",{value:"",children:a("automation.builder.toolPick")}),f.map(l=>e.jsxs("option",{value:l.name,children:[l.name,l.dangerous?" ⚠":""]},l.name))]}),r&&e.jsxs("div",{className:"auto-hint",children:[r.description,r.dangerous?` · ${a("automation.builder.dangerous")}`:""]})]}),r&&Object.entries(r.parameters.properties||{}).map(([l,d])=>{const z=(r.parameters.required||[]).includes(l),N=`${l}${z?" *":""}`,D=t.argValues[l]||"",J=_=>j(t.key,{argValues:{...t.argValues,[l]:_}});return e.jsxs("div",{className:"field",children:[e.jsx("label",{title:d.description||"",children:N}),d.enum?.length?e.jsxs("select",{value:D,onChange:_=>J(_.target.value),children:[e.jsx("option",{value:""}),d.enum.map(_=>e.jsx("option",{value:_,children:_},_))]}):d.type==="boolean"?e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:D==="true",onChange:_=>J(_.target.checked?"true":"false")})," ",d.description||""]}):d.type==="number"?e.jsx("input",{type:"number",value:D,onChange:_=>J(_.target.value)}):d.type==="string"?e.jsx("textarea",{rows:2,value:D,placeholder:d.description||"",onChange:_=>J(_.target.value)}):e.jsx("textarea",{rows:2,value:D,placeholder:`JSON — ${d.description||""}`,onChange:_=>J(_.target.value)})]},l)})]})]},t.key)}),S.length===0&&i&&s!=="manual"&&e.jsxs("div",{className:"auto-node auto-node-muse",hidden:F!=="muse",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:e.jsx(qe,{size:14})}),a("automation.builder.museFallback")]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.museFallbackHint")}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.prompt")}),e.jsx("textarea",{value:me,maxLength:500,placeholder:a("automation.builder.promptPh"),onChange:t=>Ke(t.target.value)})]})]}),e.jsxs("div",{className:"auto-node auto-review",hidden:F!=="review",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx(be,{size:16}),a("automation.ux.review")]}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.enableHint")}),e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:q,onChange:t=>M(t.target.checked)}),a("automation.ux.enabledLabel")]}),E.length?e.jsxs("div",{className:"auto-validation",role:"status",children:[e.jsx("strong",{children:a("automation.ux.checklist")}),E.map((t,u)=>e.jsx("button",{onClick:()=>p(t.node),children:t.text},u))]}):e.jsxs("p",{className:"auto-ready",children:[e.jsx(be,{size:14}),a("automation.ux.allReady")]}),s!=="timer"&&s!=="manual"&&e.jsxs("div",{className:"auto-guard",children:[e.jsx("label",{children:a("automation.builder.cooldown")}),e.jsx("input",{type:"number",value:U,min:Se?1:s==="db_changed"?0:.25,step:"1",onChange:t=>{Ce.current=!0,_e(t.target.value)}}),e.jsx("span",{className:"auto-hint",children:a(Se?"automation.builder.cooldownAgentHint":s==="db_changed"?"automation.builder.cooldownDbHint":"automation.builder.cooldownHint")})]})]}),e.jsxs("div",{className:"auto-node",hidden:F!=="help",children:[e.jsx("h3",{children:a("automation.ux.flow")}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.canvasOrder")}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.nativeHint")})]})]})]}),e.jsxs("div",{className:"auto-builder-actions auto-builder-footer",children:[e.jsx("div",{className:"auto-save-status","aria-live":"polite",children:we?e.jsx("span",{role:"alert",children:we}):E.length?e.jsxs("button",{onClick:()=>p(E[0].node),children:[E[0].text,E.length>1?` (+${E.length-1})`:""]}):e.jsx("span",{children:a("automation.ux.allReady")})}),e.jsx("button",{className:"btn ghost sm",onClick:()=>p("review"),children:a("automation.ux.review")}),e.jsx("button",{className:"btn sm",disabled:!ne||G,onClick:()=>{Ge()},children:G?"…":a(q?"automation.ux.saveEnabled":"automation.ux.savePaused")})]})]})},oa=Object.freeze(Object.defineProperty({__proto__:null,AutomationBuilder:Jt,hasUnsupportedParts:Ie},Symbol.toStringTag,{value:"Module"}));export{Wt as A,Vt as B,sa as S,Jt as a,oa as b};
1
+ import{d as o,j as e,u as pe}from"./index-B5UW6SaE.js";import{G as Ye,bq as Ze,rr as le,fK as Qe,kS as et,aK as tt,dH as at,fX as nt,fT as it,h_ as lt,hV as st,gV as ot,i1 as rt,rs as ut,h as dt,b as ct,fx as ie,aT as mt,rt as ht,ru as $e,rv as Ie,rw as Fe,a3 as Re,N as De,hX as be,ar as bt,aL as xt,rx as pt,bK as xe,ry as vt,rz as gt,bI as jt,bJ as ft,I as yt,K as Nt,$ as _t,gP as Ct,rA as kt,rB as wt,t as St,rC as Et,rD as Pt,u as $t}from"./appStore-CidPWYa0.js";import{C as Ft}from"./CapabilityMenu-CrsaTtDe.js";import{u as Rt}from"./gestures-CXFaEydn.js";import{a as Dt,C as Tt}from"./Chrome-BvpbCvo1.js";import{d as zt,e as At,f as It,g as Mt}from"./canvasPrefs-CxfyDTMT.js";import{R as Ht}from"./rotate-ccw-xgT_0UN9.js";import"./messages-DEAGRsC3.js";import{W as Te}from"./workflow-DY2Cnaei.js";import{C as qt}from"./circle-question-mark-M8QUJJYk.js";const Vt=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Lt=Ye("bell",Vt);function Wt({controller:i,open:c,title:b,onClose:C,children:h}){const[g]=o.useState(()=>document.createElement("div"));g.className="auto-extension";const a=o.useRef(null),k=o.useRef(C);k.current=C;const v=o.useRef(b);return v.current=b,o.useEffect(()=>{if(!(!i||!c)){try{a.current=i.open({id:"automation-context",title:()=>v.current,mount:f=>(f.appendChild(g),()=>g.remove()),onClose:()=>k.current()})}catch{k.current()}return()=>{a.current?.close(),a.current=null}}},[i,c,g]),c?i?Ze.createPortal(h,g):e.jsx("div",{className:"auto-extension auto-extension-inline",children:h}):null}const sa=["reminder","briefing","table","button"];function Ot(i,c){return i?i==="briefing"||i==="button"?[{...le("agent_run"),prompt:c(`automation.ux.${i}.prompt`)}]:[{...le("notify"),title:c(`automation.ux.${i}.name`),body:c(`automation.ux.${i}.body`)}]:[le("notify")]}function ze(i,c,b){if(i.type==="notify")return i.title.trim()?null:"notify";if(i.type==="agent_run")return i.agentSlug?i.prompt.trim()?null:"prompt":"agent";if(i.type==="db_row_add"||i.type==="db_row_edit"){if(!/\.db$/i.test(i.dbPath.trim()))return"table";if(!i.cells.some(h=>h.k.trim()))return"cells";if(i.type==="db_row_edit"){if(c!=="db_changed"&&(!i.rowId.trim()&&!i.matchColumn.trim()||i.rowFrom.trim()))return"row";if(i.matchColumn.trim()&&!i.matchValue.trim())return"match"}return null}const C=b.find(h=>h.name===i.tool);if(!C)return"tool";if((C.parameters.required||[]).some(h=>!(i.argValues[h]||"").trim()))return"args";for(const[h,g]of Object.entries(i.argValues)){if(!g.trim())continue;const a=C.parameters.properties?.[h];if(a?.type==="number"&&!Number.isFinite(Number(g)))return"args";if(a?.type==="object"||a?.type==="array")try{const k=JSON.parse(g);if(a.type==="array"?!Array.isArray(k):!k||typeof k!="object"||Array.isArray(k))return"json"}catch{return"json"}}return null}function Bt(i){return(i||[]).map(c=>({value:`{{row.${c.id}}}`,label:c.name}))}const Kt=i=>({x:0,y:i*132,w:244,h:84}),Ut=({nodes:i,selected:c,onSelect:b,children:C})=>{const{t:h}=pe(),g=o.useId().replace(/:/g,""),a=o.useRef(null),[k,v]=o.useState({}),[f,$]=o.useState(zt),[I,F]=o.useState(At),x=Qe(a),m=new Map(i.map((n,s)=>[n.id,k[n.id]||Kt(s)])),P=i.map(n=>n.id).join(","),p=Rt(a,x,{boxes:()=>m,identity:()=>P,commit:n=>v(s=>({...s,...Object.fromEntries(n)})),hitKey:n=>n.closest("[data-flow-node]")?.dataset.flowNode||null,onEnterEdit:b,onDoubleClick:n=>{n&&b(n)},minW:244,minH:84,repel:!0},f);o.useEffect(()=>p.bind(a.current),[p.bind]),o.useEffect(()=>x.bindWheel(a.current),[x.bindWheel]);const D=o.useRef(()=>x.fitTo([...m.values()],64));D.current=()=>x.fitTo([...m.values()],64),o.useEffect(()=>{v({});const n=requestAnimationFrame(()=>D.current());return()=>cancelAnimationFrame(n)},[P]),o.useEffect(()=>{const n=new ResizeObserver(()=>D.current());return a.current&&n.observe(a.current),()=>n.disconnect()},[]);const M=n=>p.live?.get(n)||m.get(n);return e.jsx("div",{className:"auto-canvas-shell am-app",children:e.jsxs("div",{className:"auto-canvas amx-stage",ref:a,tabIndex:0,"aria-label":h("automation.ux.flow"),onPointerUpCapture:n=>{if(p.busy)return;const s=document.elementFromPoint(n.clientX,n.clientY)?.closest("[data-flow-node]");s&&a.current?.contains(s)&&b(s.dataset.flowNode)},children:[e.jsx("div",{className:"amx-stage-grid",style:et(x.vp)}),e.jsxs("div",{className:"auto-canvas-world",style:{transform:`translate(${x.vp.x}px, ${x.vp.y}px) scale(${x.vp.z})`},children:[e.jsxs("svg",{className:"auto-canvas-edges","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsx("marker",{id:g,markerWidth:"8",markerHeight:"8",refX:"6",refY:"3",orient:"auto",children:e.jsx("path",{d:"M0,0 L6,3 L0,6",fill:"none",stroke:"currentColor"})})}),i.slice(1).map((n,s)=>{const y=M(i[s].id),w=M(n.id),H=y.x+y.w/2,q=y.y+y.h,J=w.x+w.w/2,L=w.y;return e.jsx("path",{d:`M${H},${q} C${H},${q+28} ${J},${L-28} ${J},${L}`,markerEnd:`url(#${g})`},n.id)})]}),i.map(n=>{const s=M(n.id);return e.jsxs("div",{"data-flow-node":n.id,role:"button",tabIndex:0,"aria-pressed":c===n.id,className:`auto-flow-node ${c===n.id?"selected":""}`,style:{left:s.x,top:s.y,width:s.w,height:s.h},onClick:()=>b(n.id),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),b(n.id))},children:[e.jsx("span",{className:"auto-flow-icon",children:n.icon}),e.jsx("strong",{children:n.title}),e.jsx("span",{className:"auto-flow-status",title:h(n.ready?"automation.ux.ready":"automation.ux.incomplete"),children:n.ready?e.jsx(tt,{size:13}):e.jsx(at,{size:13})}),e.jsx("span",{className:"auto-flow-subtitle",children:n.subtitle})]},n.id)}),p.marquee&&e.jsx("div",{className:"amx-stage-marquee",style:{left:p.marquee.x,top:p.marquee.y,width:p.marquee.w,height:p.marquee.h}})]}),C&&e.jsx("div",{className:"amx-stage-tools auto-canvas-tools",children:C}),e.jsx(Dt,{zoom:x.vp.z,onZoomBy:n=>{const{w:s,h:y}=nt(a.current);x.setVp(it(x.vp,x.vp.z*n,s/2,y/2))},onFit:()=>D.current(),snap:f,onSnap:n=>{$(n),Mt(n)},mini:I,onMini:n=>{F(n),It(n)},extra:e.jsx("button",{type:"button",title:h("automation.ux.arrange"),onClick:()=>{v({}),requestAnimationFrame(()=>D.current())},children:e.jsx(Ht,{size:12})})}),I&&e.jsx(Tt,{hostRef:a,vp:x.vp,items:i.map(n=>({key:n.id,kind:"card",box:M(n.id)})),onCenter:x.centerOn})]})})},Ae=({label:i,value:c,onChange:b,multiline:C,maxLength:h=4e3,placeholder:g,columns:a,hasRow:k})=>{const{t:v}=pe(),f=o.useId(),$=o.useRef(null),I=o.useRef({start:c.length,end:c.length}),F=m=>{if(!m)return;const{start:P,end:p}=I.current;c.length-(p-P)+m.length>h||(b(c.slice(0,P)+m+c.slice(p)),requestAnimationFrame(()=>{$.current?.focus(),$.current?.setSelectionRange(P+m.length,P+m.length)}))},x={id:f,ref:$,value:c,maxLength:h,placeholder:g,onChange:m=>b(m.target.value),onSelect:m=>{I.current={start:m.currentTarget.selectionStart??c.length,end:m.currentTarget.selectionEnd??c.length}}};return e.jsxs("div",{className:"field auto-template-field",children:[e.jsxs("div",{className:"auto-field-heading",children:[e.jsx("label",{htmlFor:f,children:i}),e.jsxs("select",{"aria-label":v("automation.ux.insertVariable",{field:i}),value:"",onChange:m=>F(m.target.value),children:[e.jsx("option",{value:"",children:v("automation.ux.variables")}),e.jsx("option",{value:"{{today}}",children:v("automation.ux.today")}),e.jsx("option",{value:"{{now}}",children:v("automation.ux.now")}),k&&e.jsxs("optgroup",{label:v("automation.ux.triggerRow"),children:[e.jsx("option",{value:"{{row.id}}",children:v("automation.ux.rowId")}),Bt(a).map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))]})]})]}),C?e.jsx("textarea",{...x}):e.jsx("input",{type:"text",...x})]})};function Xt(){const i=new Date(Date.now()+36e5);i.setMinutes(0,0,0);const c=b=>String(b).padStart(2,"0");return`${i.getFullYear()}-${c(i.getMonth()+1)}-${c(i.getDate())}T${c(i.getHours())}:00`}const Gt=({editing:i,starter:c,fixedManual:b,onSaved:C,onCancel:h,extendView:g})=>{const{t:a}=pe(),k=lt(),v=st(),f=v.actionsCatalog,[$,I]=o.useState(i?.desc||(c?a(`automation.ux.${c}.name`):"")),[F,x]=o.useState("trigger"),[m,P]=o.useState(!1),p=t=>{x(t),P(!0)},[D,M]=o.useState(i?.enabled??!!b),n=i?.cond,[s,y]=o.useState(n?n.type==="event_seen"?"event_seen":n.type==="file_chars_gte"?"file_chars_gte":n.type==="manual"?"manual":n.type==="db_changed"?"db_changed":"timer":b||c==="button"?"manual":c==="table"?"db_changed":"timer"),[w,H]=o.useState(n?.type==="at"?"at":n?.type==="every"?"every":"daily_at"),[q,J]=o.useState(n?.type==="daily_at"?n.time:"09:00"),L=!!i&&ot(i),[Y,Me]=o.useState(n?.type==="at"&&!L?n.datetime.replace(" ","T"):Xt()),Z=n?.type==="every"?/^(\d+)([mhd])$/.exec(n.interval):null,[Q,He]=o.useState(Z?Z[1]:"1"),[ve,qe]=o.useState(Z?Z[2]:"h"),[se,Ve]=o.useState(n?.type==="event_seen"?n.match:""),[oe,Le]=o.useState(n?.type==="file_chars_gte"?n.path:""),[re,We]=o.useState(n?.type==="file_chars_gte"?String(n.n):"100"),[R,Oe]=o.useState(n?.type==="db_changed"?n.path:""),[z,ge]=o.useState(n?.type==="db_changed"?n.event:"row_added"),[V,je]=o.useState(()=>rt(n)),fe=(t,d)=>je(r=>d?r.includes(t)?r:[...r,t]:r.filter(l=>l!==t)),[ue,Be]=o.useState(n?.type==="db_changed"&&n.equals||""),[W,de]=o.useState(()=>ut(n)),ce=(t,d)=>de(r=>r.map((l,u)=>u===t?{...l,...d}:l));o.useEffect(()=>{dt()},[]);const ye=ct(t=>t.files),O=o.useMemo(()=>ye.filter(t=>/\.db$/i.test(t)),[ye]);o.useEffect(()=>{for(const t of O)ie.getState().load(t,t)},[O]);const Ne=ie(mt(t=>O.filter(d=>t.entries[d]?.data?.source!==void 0))),ee=o.useMemo(()=>O.filter(t=>!Ne.includes(t)),[O,Ne]),B=ie(t=>s==="db_changed"&&R?t.entries[R]?.data?.columns:void 0),K=o.useMemo(()=>B?.filter(t=>t.type!=="formula"&&t.type!=="lookup"),[B]),[S,te]=o.useState(()=>i?ht(i):Ot(c,a)),[me,Ke]=o.useState(i&&!i.actions?.length&&!i.agentSlug&&i.prompt||""),[U,_e]=o.useState(()=>$e(i,s)),Ce=o.useRef(!1);o.useEffect(()=>{!i&&!Ce.current&&_e($e(null,s))},[s,i]);const[X,ke]=o.useState(!1),[we,ae]=o.useState(""),Ue=t=>{if(S.length>=24)return;const d=le(t);te(r=>[...r,d]),p(String(d.key))},Se=S.some(t=>t.type==="agent_run"),j=(t,d)=>te(r=>r.map(l=>l.key===t?{...l,...d}:l)),Ee=(t,d)=>te(r=>{const l=t+d;if(l<0||l>=r.length)return r;const u=[...r];return[u[t],u[l]]=[u[l],u[t]],u});if(Ie(i))return e.jsxs("div",{className:"auto-builder",children:[e.jsxs("div",{className:"auto-builder-title",children:[e.jsx(Te,{size:17})," ",a("automation.builder.editTitle")]}),e.jsx("div",{className:"auto-node",children:e.jsx("div",{className:"auto-hint",children:a("automation.builder.unsupported")})}),e.jsx("div",{className:"auto-builder-actions",children:e.jsx("button",{className:"btn ghost",onClick:()=>h?h():v.closeBuilder(),children:a("common.cancel")})})]});const Pe=!(s==="timer"&&(w==="daily_at"&&!/^\d{1,2}:\d{2}$/.test(q)||w==="at"&&!Y||w==="every"&&(!Number.isInteger(Number(Q))||Number(Q)<1))||s==="event_seen"&&!se.trim()||s==="file_chars_gte"&&(!oe.trim()||!(Number(re)>0))||s==="db_changed"&&(!/\.db$/i.test(R.trim())||z==="cell_changed"&&!V.length||W.length>Fe||W.some(t=>t.column.trim()&&(t.op==="eq"||t.op==="ne")&&!t.value.trim()))),E=[];$.trim()||E.push({node:"trigger",text:a("automation.ux.issue.name")}),Pe||E.push({node:"trigger",text:a("automation.ux.issue.trigger")}),!S.length&&(!i||s==="manual")&&E.push({node:"review",text:a("automation.ux.issue.steps")}),S.forEach((t,d)=>{const r=ze(t,s,f);r&&E.push({node:String(t.key),text:`${d+1}. ${a(`automation.ux.issue.${r}`)}`})}),s!=="timer"&&s!=="manual"&&(!U.trim()||!Number.isFinite(Number(U))||Number(U)<0)&&E.push({node:"review",text:a("automation.ux.issue.cooldown")});const ne=E.length===0,Xe=async()=>{if(!ne||X)return;const t=s==="timer"?w:s;if(t==="at"&&(Ct(Y)?.getTime()??0)<Date.now()-5*6e4){ae(a("automation.builder.atPast"));return}const d=u=>ie.getState().entries[u]?.data?.source!==void 0;if([...t==="db_changed"?[R.trim()]:[],...S.filter(u=>u.type==="db_row_add"||u.type==="db_row_edit").map(u=>u.dbPath.trim())].filter(Boolean).some(d)){ae(a("automation.builder.dbNoteView"));return}ke(!0),ae("");const l=kt(S,f);try{const u=await wt(St(),{id:i?.id,actor:"user",desc:$.trim(),cond_type:t,time:t==="daily_at"?q:void 0,datetime:t==="at"?Y:void 0,interval:t==="every"?`${Math.floor(Number(Q))}${ve}`:void 0,match:t==="event_seen"?se.trim():void 0,path:t==="file_chars_gte"?oe.trim():t==="db_changed"?R.trim():void 0,n:t==="file_chars_gte"?Number(re):void 0,event:t==="db_changed"?z:void 0,column_id:t==="db_changed"&&z==="cell_changed"?V[0]:void 0,column_ids:t==="db_changed"&&z==="cell_changed"&&V.length>1?V:void 0,equals:t==="db_changed"&&z==="cell_changed"&&ue.trim()?ue.trim():void 0,where:t==="db_changed"?Pt(W):void 0,vault:t==="db_changed"&&i?.cond.type==="db_changed"?i.cond.vault:void 0,prompt:S.length?void 0:me.trim()||void 0,cooldown_hours:Et(s,U),actions:S.length?l:null,enabled:D});if(C){v.bump(),C(u);return}v.acceptSaved(u),$t.getState().toast(a("automation.ux.saved"))}catch(u){ae(String(u?.message||u))}finally{ke(!1)}},he=t=>t==="notify"?e.jsx(Lt,{size:14}):t==="agent_run"?e.jsx(yt,{size:14}):t==="db_row_add"||t==="db_row_edit"?e.jsx(Nt,{size:14}):e.jsx(_t,{size:14}),Ge=[{id:"trigger",title:a("automation.builder.trigger"),subtitle:a(`automation.builder.${s==="timer"?"condTimer":s==="manual"?"condManual":s==="db_changed"?"condDb":s==="event_seen"?"condEvent":"condFile"}`),icon:e.jsx(Re,{size:17}),ready:Pe&&!!$.trim()},...S.map((t,d)=>({id:String(t.key),title:`${d+1}. ${a(`automation.step.${t.type}`)}`,subtitle:t.title||t.prompt||t.dbPath||t.tool||a("automation.ux.setupHint"),icon:he(t.type),ready:!ze(t,s,f)})),...!S.length&&i&&s!=="manual"?[{id:"muse",title:a("automation.builder.museFallback"),subtitle:me||a("automation.builder.museFallbackHint"),icon:e.jsx(De,{size:17}),ready:!0}]:[],{id:"review",title:a("automation.ux.finish"),subtitle:a(ne?"automation.ux.allReady":"automation.ux.finishHint"),icon:e.jsx(be,{size:17}),ready:ne}],Je=e.jsxs(e.Fragment,{children:[e.jsxs(Ft,{label:a("automation.ux.addStep"),className:"btn ghost sm",disabled:X||S.length>=24,items:["notify","agent_run","db_row_add","db_row_edit","tool_call"].map(t=>({id:t,label:a(`automation.step.${t}`),icon:he(t),disabled:t==="tool_call"&&!f.length,onSelect:()=>Ue(t)})),children:[e.jsx(bt,{size:14}),a("automation.ux.addStep")]}),e.jsx("button",{className:"icon-btn",title:a("automation.ux.help"),onClick:()=>p("help"),children:e.jsx(qt,{size:15})})]});return e.jsxs("div",{className:`auto-builder auto-workflow-builder ${b?"auto-builder-embedded":""}`,children:[e.jsxs("div",{className:"auto-builder-title",children:[e.jsx(Te,{size:17}),e.jsx("span",{children:a(i?"automation.builder.editTitle":"automation.builder.title")}),e.jsx("button",{className:"btn ghost sm",disabled:X,onClick:()=>h?h():v.closeBuilder(),children:a("common.cancel")})]}),e.jsx("div",{className:"auto-builder-workspace",hidden:!g&&m,children:e.jsx(Ut,{nodes:Ge,selected:m?F:"",onSelect:p,children:Je})}),e.jsxs(Wt,{controller:g,open:m,title:a("automation.ux.setup"),onClose:()=>P(!1),children:[!g&&e.jsxs("button",{className:"btn ghost sm auto-inline-back",onClick:()=>P(!1),children:[e.jsx(xt,{size:14}),a("automation.ux.flow")]}),e.jsxs("div",{className:"auto-inspector","aria-label":a("automation.ux.setup"),children:[e.jsxs("div",{className:"auto-node",hidden:F!=="trigger",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:e.jsx(Re,{size:14})}),a("automation.builder.trigger")]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.desc")}),e.jsx("input",{"aria-label":a("automation.builder.desc"),type:"text",value:$,maxLength:200,placeholder:a("automation.builder.descPh"),onChange:t=>I(t.target.value)})]}),!b&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.condType")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:s==="timer"?"active":"",onClick:()=>y("timer"),children:a("automation.builder.condTimer")}),e.jsx("button",{className:s==="event_seen"?"active":"",onClick:()=>y("event_seen"),children:a("automation.builder.condEvent")}),e.jsx("button",{className:s==="file_chars_gte"?"active":"",onClick:()=>y("file_chars_gte"),children:a("automation.builder.condFile")}),e.jsx("button",{className:s==="db_changed"?"active":"",onClick:()=>y("db_changed"),children:a("automation.builder.condDb")}),e.jsx("button",{className:s==="manual"?"active":"",onClick:()=>y("manual"),children:a("automation.builder.condManual")})]})]}),s==="db_changed"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbPath")}),e.jsxs("select",{value:R,onChange:t=>{Oe(t.target.value),je([])},children:[e.jsx("option",{value:"",children:a("automation.builder.dbPickDb")}),ee.map(t=>e.jsx("option",{value:t,children:t},t)),R&&!ee.includes(R)&&e.jsx("option",{value:R,children:R})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbEvent")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:z==="row_added"?"active":"",onClick:()=>ge("row_added"),children:a("automation.builder.dbEventRow")}),e.jsx("button",{className:z==="cell_changed"?"active":"",onClick:()=>ge("cell_changed"),children:a("automation.builder.dbEventCell")})]})]}),z==="cell_changed"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbColumn")}),e.jsxs("div",{className:"auto-checks",children:[(K??[]).map(t=>e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:V.includes(t.id),onChange:d=>fe(t.id,d.target.checked)}),t.name]},t.id)),V.filter(t=>!(K??[]).some(d=>d.id===t)).map(t=>e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:!0,onChange:()=>fe(t,!1)}),"(",t,")"]},t)),!K&&e.jsx("span",{className:"auto-hint",children:a("automation.builder.dbColsLoading")})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbColumnsHint")})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbEquals")}),e.jsx("input",{type:"text",value:ue,maxLength:200,placeholder:a("automation.builder.dbEqualsPh"),onChange:t=>Be(t.target.value)})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbWhere")}),W.map((t,d)=>e.jsxs("div",{className:"auto-inline",children:[e.jsxs("select",{value:t.column,onChange:r=>ce(d,{column:r.target.value}),children:[e.jsx("option",{value:"",children:a(B?"automation.builder.dbPickCol":"automation.builder.dbColsLoading")}),(B??[]).map(r=>e.jsx("option",{value:r.id,children:r.name},r.id)),t.column&&!(B??[]).some(r=>r.id===t.column)&&e.jsxs("option",{value:t.column,children:["(",t.column,")"]})]}),e.jsx("select",{value:t.op,onChange:r=>ce(d,{op:r.target.value}),children:pt.map(r=>e.jsx("option",{value:r,children:a(r==="eq"?"automation.builder.dbWhereOpEq":r==="ne"?"automation.builder.dbWhereOpNe":r==="empty"?"automation.builder.dbWhereOpEmpty":"automation.builder.dbWhereOpNotEmpty")},r))}),e.jsx("input",{type:"text",value:t.value,maxLength:200,disabled:t.op==="empty"||t.op==="notempty",placeholder:a("automation.builder.dbWhereValPh"),onChange:r=>ce(d,{value:r.target.value})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),onClick:()=>de(r=>r.filter((l,u)=>u!==d)),children:e.jsx(xe,{size:12})})]},d)),e.jsx("button",{className:"icon-btn",title:a("automation.builder.dbWhereAdd"),disabled:W.length>=Fe,onClick:()=>de(t=>[...t,{column:"",op:"eq",value:""}]),children:"+"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbWhereHint")})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbHint")})]}),s==="manual"&&e.jsx("div",{className:"auto-hint",children:a("automation.builder.manualHint")}),s==="timer"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.timerMode")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:w==="daily_at"?"active":"",onClick:()=>H("daily_at"),children:a("automation.builder.timerDaily")}),e.jsx("button",{className:w==="at"?"active":"",onClick:()=>H("at"),children:a("automation.builder.timerOnce")}),e.jsx("button",{className:w==="every"?"active":"",onClick:()=>H("every"),children:a("automation.builder.timerEvery")})]})]}),w==="daily_at"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.time")}),e.jsx("input",{type:"time",value:q,onChange:t=>J(t.target.value)})]}),w==="at"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.datetime")}),e.jsx("input",{type:"datetime-local",value:Y,onChange:t=>Me(t.target.value)}),e.jsx("div",{className:"auto-hint",children:a(L?"automation.builder.expiredReset":"automation.builder.onceHint")})]}),w==="every"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.interval")}),e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"number",value:Q,min:1,style:{width:90},onChange:t=>He(t.target.value)}),e.jsxs("select",{value:ve,onChange:t=>qe(t.target.value),children:[e.jsx("option",{value:"m",children:a("automation.builder.unitM")}),e.jsx("option",{value:"h",children:a("automation.builder.unitH")}),e.jsx("option",{value:"d",children:a("automation.builder.unitD")})]})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.everyHint")})]})]}),s==="event_seen"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.match")}),e.jsx("input",{type:"text",list:"auto-event-catalog",value:se,maxLength:120,placeholder:a("automation.builder.matchPh"),onChange:t=>Ve(t.target.value)}),e.jsxs("datalist",{id:"auto-event-catalog",children:[vt.map(t=>e.jsx("option",{value:t},t)),gt().map(t=>e.jsx("option",{value:t.name,label:t.label},t.name))]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.matchHint")})]}),s==="file_chars_gte"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.path")}),e.jsx("input",{type:"text",value:oe,placeholder:"~/Forsion/Notes/xxx.md",onChange:t=>Le(t.target.value)})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.chars")}),e.jsx("input",{type:"number",value:re,min:1,onChange:t=>We(t.target.value)})]})]})]}),S.map((t,d)=>{const r=t.type==="tool_call"?f.find(l=>l.name===t.tool):void 0;return e.jsxs("div",{className:"auto-node",hidden:F!==String(t.key),children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:he(t.type)}),a("automation.builder.stepN",{n:String(d+1)})," · ",a(`automation.step.${t.type}`),e.jsxs("span",{className:"auto-step-tools",children:[e.jsx("button",{className:"icon-btn",disabled:d===0,title:a("automation.builder.moveUp"),onClick:()=>Ee(d,-1),children:e.jsx(jt,{size:12})}),e.jsx("button",{className:"icon-btn",disabled:d===S.length-1,title:a("automation.builder.moveDown"),onClick:()=>Ee(d,1),children:e.jsx(ft,{size:12})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),onClick:()=>{te(l=>l.filter(u=>u.key!==t.key)),p("trigger")},children:e.jsx(xe,{size:12})})]})]}),t.type==="notify"&&e.jsxs(e.Fragment,{children:[e.jsx(Ae,{label:a("automation.builder.notifyTitle"),value:t.title,maxLength:200,placeholder:a("automation.builder.notifyTitlePh"),onChange:l=>j(t.key,{title:l}),columns:K,hasRow:s==="db_changed"}),e.jsx(Ae,{label:a("automation.builder.notifyBody"),value:t.body,multiline:!0,onChange:l=>j(t.key,{body:l}),columns:K,hasRow:s==="db_changed"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.notifyHint")})]}),t.type==="agent_run"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.runner")}),e.jsxs("select",{value:t.agentSlug,onChange:l=>j(t.key,{agentSlug:l.target.value}),children:[e.jsx("option",{value:"",children:a("automation.builder.runnerPick")}),k.filter(l=>l.slug!=="muse").map(l=>e.jsx("option",{value:l.slug,children:l.name},l.slug))]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.prompt")}),e.jsx("textarea",{value:t.prompt,maxLength:500,placeholder:a("automation.builder.promptPh"),onChange:l=>j(t.key,{prompt:l.target.value})})]})]}),(t.type==="db_row_add"||t.type==="db_row_edit")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbPath")}),e.jsxs("select",{value:t.dbPath,onChange:l=>j(t.key,{dbPath:l.target.value}),children:[e.jsx("option",{value:"",children:a("automation.builder.dbPickDb")}),ee.map(l=>e.jsx("option",{value:l,children:l},l)),t.dbPath&&!ee.includes(t.dbPath)&&e.jsx("option",{value:t.dbPath,children:t.dbPath})]})]}),t.type==="db_row_edit"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbRowId")}),e.jsx("input",{type:"text",value:t.rowId,placeholder:a(s==="db_changed"?"automation.builder.dbRowIdPh":"automation.builder.dbRowIdRequired"),onChange:l=>j(t.key,{rowId:l.target.value})})]}),t.type==="db_row_edit"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbRowFrom")}),e.jsx("input",{type:"text",value:t.rowFrom,maxLength:200,placeholder:a("automation.builder.dbRowFromPh"),onChange:l=>j(t.key,{rowFrom:l.target.value})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbMatch")}),e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"text",value:t.matchColumn,maxLength:200,placeholder:a("automation.builder.dbCellKey"),style:{width:120},onChange:l=>j(t.key,{matchColumn:l.target.value})}),e.jsx("input",{type:"text",value:t.matchValue,maxLength:2e3,placeholder:a("automation.builder.dbMatchValPh"),onChange:l=>j(t.key,{matchValue:l.target.value})})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbTargetHint")})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbCells")}),t.cells.map((l,u)=>e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"text",value:l.k,placeholder:a("automation.builder.dbCellKey"),style:{width:120},onChange:A=>j(t.key,{cells:t.cells.map((N,T)=>T===u?{...N,k:A.target.value}:N)})}),e.jsx("input",{type:"text",value:l.v,placeholder:a(u===0?"automation.builder.dbCellValPh":"automation.builder.dbCellVal"),onChange:A=>j(t.key,{cells:t.cells.map((N,T)=>T===u?{...N,v:A.target.value}:N)})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),disabled:t.cells.length<=1,onClick:()=>j(t.key,{cells:t.cells.filter((A,N)=>N!==u)}),children:e.jsx(xe,{size:12})})]},u)),e.jsx("button",{className:"icon-btn",title:a("automation.builder.dbCellAdd"),onClick:()=>j(t.key,{cells:[...t.cells,{k:"",v:""}]}),children:"+"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbCellsHint")})]}),t.type==="db_row_add"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbSkipIfEmpty")}),e.jsx("input",{type:"text",value:t.skipIfEmpty,maxLength:200,placeholder:a("automation.builder.dbSkipIfEmptyPh"),onChange:l=>j(t.key,{skipIfEmpty:l.target.value})})]})]}),t.type==="tool_call"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.tool")}),e.jsxs("select",{value:t.tool,onChange:l=>{const u=f.find(N=>N.name===l.target.value),A=Object.fromEntries((u?.parameters.required||[]).filter(N=>u?.parameters.properties?.[N]?.type==="boolean").map(N=>[N,"false"]));j(t.key,{tool:l.target.value,argValues:A})},children:[e.jsx("option",{value:"",children:a("automation.builder.toolPick")}),f.map(l=>e.jsxs("option",{value:l.name,children:[l.name,l.dangerous?" ⚠":""]},l.name))]}),r&&e.jsxs("div",{className:"auto-hint",children:[r.description,r.dangerous?` · ${a("automation.builder.dangerous")}`:""]})]}),r&&Object.entries(r.parameters.properties||{}).map(([l,u])=>{const A=(r.parameters.required||[]).includes(l),N=`${l}${A?" *":""}`,T=t.argValues[l]||"",G=_=>j(t.key,{argValues:{...t.argValues,[l]:_}});return e.jsxs("div",{className:"field",children:[e.jsx("label",{title:u.description||"",children:N}),u.enum?.length?e.jsxs("select",{value:T,onChange:_=>G(_.target.value),children:[e.jsx("option",{value:""}),u.enum.map(_=>e.jsx("option",{value:_,children:_},_))]}):u.type==="boolean"?e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:T==="true",onChange:_=>G(_.target.checked?"true":"false")})," ",u.description||""]}):u.type==="number"?e.jsx("input",{type:"number",value:T,onChange:_=>G(_.target.value)}):u.type==="string"?e.jsx("textarea",{rows:2,value:T,placeholder:u.description||"",onChange:_=>G(_.target.value)}):e.jsx("textarea",{rows:2,value:T,placeholder:`JSON — ${u.description||""}`,onChange:_=>G(_.target.value)})]},l)})]})]},t.key)}),S.length===0&&i&&s!=="manual"&&e.jsxs("div",{className:"auto-node auto-node-muse",hidden:F!=="muse",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:e.jsx(De,{size:14})}),a("automation.builder.museFallback")]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.museFallbackHint")}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.prompt")}),e.jsx("textarea",{value:me,maxLength:500,placeholder:a("automation.builder.promptPh"),onChange:t=>Ke(t.target.value)})]})]}),e.jsxs("div",{className:"auto-node auto-review",hidden:F!=="review",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx(be,{size:16}),a("automation.ux.review")]}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.enableHint")}),e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:t=>M(t.target.checked)}),a("automation.ux.enabledLabel")]}),E.length?e.jsxs("div",{className:"auto-validation",role:"status",children:[e.jsx("strong",{children:a("automation.ux.checklist")}),E.map((t,d)=>e.jsx("button",{onClick:()=>p(t.node),children:t.text},d))]}):e.jsxs("p",{className:"auto-ready",children:[e.jsx(be,{size:14}),a("automation.ux.allReady")]}),s!=="timer"&&s!=="manual"&&e.jsxs("div",{className:"auto-guard",children:[e.jsx("label",{children:a("automation.builder.cooldown")}),e.jsx("input",{type:"number",value:U,min:Se?1:s==="db_changed"?0:.25,step:"1",onChange:t=>{Ce.current=!0,_e(t.target.value)}}),e.jsx("span",{className:"auto-hint",children:a(Se?"automation.builder.cooldownAgentHint":s==="db_changed"?"automation.builder.cooldownDbHint":"automation.builder.cooldownHint")})]})]}),e.jsxs("div",{className:"auto-node",hidden:F!=="help",children:[e.jsx("h3",{children:a("automation.ux.flow")}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.canvasOrder")}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.nativeHint")})]})]})]}),e.jsxs("div",{className:"auto-builder-actions auto-builder-footer",children:[e.jsx("div",{className:"auto-save-status","aria-live":"polite",children:we?e.jsx("span",{role:"alert",children:we}):E.length?e.jsxs("button",{onClick:()=>p(E[0].node),children:[E[0].text,E.length>1?` (+${E.length-1})`:""]}):e.jsx("span",{children:a("automation.ux.allReady")})}),e.jsx("button",{className:"btn ghost sm",onClick:()=>p("review"),children:a("automation.ux.review")}),e.jsx("button",{className:"btn sm",disabled:!ne||X,onClick:()=>{Xe()},children:X?"…":a(D?"automation.ux.saveEnabled":"automation.ux.savePaused")})]})]})},oa=Object.freeze(Object.defineProperty({__proto__:null,AutomationBuilder:Gt,hasUnsupportedParts:Ie},Symbol.toStringTag,{value:"Module"}));export{Wt as A,Lt as B,sa as S,Gt as a,oa as b};
@@ -0,0 +1 @@
1
+ import{j as a,u as q,d,r as la}from"./index-B5UW6SaE.js";import{q as oa,bo as ra,ju as ia,jp as _,jw as ma,jy as da,ji as ua,kg as fa,jD as F,jN as ha,jz as pa,b as J,jj as ga,jk as xa,jl as ba,jm as ja,kh as j,jo as k,jH as va,jF as Ca,jE as Na,I as wa,X,K as B,ar as ka,at as aa,ai as K,fV as R,fh as Da,ki as ea,kj as Sa,kk as Q,kl as Z,km as za,fx as Ma,kn as ya,ko as Aa,T as Pa,kp as Fa}from"./appStore-CidPWYa0.js";import"./client-CPUljePZ.js";import{A as qa}from"./astryxBridge-Bupzouso.js";import{u as O}from"./calendarNavStore-Duyhbmm_.js";import{C as Ea}from"./CapabilityMenu-CrsaTtDe.js";import{H as Ia}from"./hard-drive-Bh1DmZg0.js";import{S as Ta}from"./star-C9KTji9N.js";import{C as La}from"./CheckboxInput-DVO2-1J7.js";import{U as Ha}from"./upload-CrbEAW8C.js";import"./nativeDownload-B3JGkABw.js";import"./ipc-CNlIRMtU.js";import"./Tooltip-DXuy9-1_.js";la({"calcfg.prevMonth":{zh:"上个月",en:"Previous month"},"calcfg.nextMonth":{zh:"下个月",en:"Next month"},"calcfg.jumpToDay":{zh:"跳转到这一天",en:"Jump to this day"},"calcfg.cloud":{zh:"云端",en:"Cloud"},"calcfg.title":{zh:"日历",en:"Calendars"},"calcfg.empty":{zh:"还没有加入日历的多维表。",en:"No databases added to the calendar yet."},"calcfg.eventColor":{zh:"事件颜色",en:"Event color"},"calcfg.fetchFailed":{zh:"拉取失败",en:"Fetch failed"},"calcfg.isDefaultAria":{zh:"{name} 是新建默认日历",en:"{name} is the default calendar for new events"},"calcfg.setDefaultAria":{zh:"将 {name} 设为新建默认日历",en:"Make {name} the default calendar for new events"},"calcfg.defaultCalendar":{zh:"新建默认日历",en:"Default calendar for new events"},"calcfg.setAsDefault":{zh:"设为新建默认日历",en:"Set as default for new events"},"calcfg.showInCalendar":{zh:"在日历中显示",en:"Show in calendar"},"calcfg.more":{zh:"更多",en:"More"},"calcfg.addCalendar":{zh:"添加日历",en:"Add calendar"},"calcfg.addDatabase":{zh:"添加多维表",en:"Add database"},"calcfg.subscribeExternal":{zh:"订阅外部日历",en:"Subscribe to external calendar"},"calcfg.subscribeHint":{zh:"粘贴 .ics 订阅地址(Google / Outlook / Apple 日历「密钥地址」都行)",en:"Paste an .ics subscription URL (Google, Outlook, or Apple Calendar's private address all work)"},"calcfg.importIcs":{zh:"导入 .ics 文件",en:"Import .ics file"},"calcfg.fileTooLarge":{zh:"文件过大(> {mb}MB)",en:"File too large (over {mb} MB)"},"calcfg.notIcs":{zh:"这不是一个 .ics 日历文件",en:"That isn't an .ics calendar file"},"calcfg.readFailed":{zh:"读取失败:{msg}",en:"Failed to read: {msg}"},"calcfg.renameCalendar":{zh:"重命名日历",en:"Rename calendar"},"calcfg.renameSub":{zh:"重命名订阅",en:"Rename subscription"},"calcfg.rename":{zh:"重命名",en:"Rename"},"calcfg.refreshNow":{zh:"立即刷新",en:"Refresh now"},"calcfg.unsubscribe":{zh:"取消订阅",en:"Unsubscribe"},"calcfg.setDefaultDb":{zh:"设为默认库",en:"Set as default"},"calcfg.openInNewTab":{zh:"在新标签打开",en:"Open in new tab"},"calcfg.columnMapping":{zh:"日历设置(列映射)",en:"Calendar settings (column mapping)"},"calcfg.removeFromCalendar":{zh:"从日历移除",en:"Remove from calendar"},"calcfg.searchDbPlaceholder":{zh:"搜索要加入日历的多维表…",en:"Search databases to add to the calendar…"},"calcfg.noCandidates":{zh:"没有含日期属性的可添加多维表",en:"No databases with a date property available to add"},"calcfg.footHint":{zh:"只有含「日期」属性的多维表会出现在这里",en:"Only databases with a Date property appear here"},"calcfg.weekStart":{zh:"一周开始于",en:"Week starts on"},"calcfg.weekStart.auto":{zh:"跟随语言({day})",en:"Default ({day})"},"calcfg.weekStart.sun":{zh:"周日",en:"Sunday"},"calcfg.weekStart.mon":{zh:"周一",en:"Monday"}});function Ra(){const{t:s}=q(),n=Q(c=>c.pref),p=Q(c=>c.setPref),i=c=>s(c===1?"calcfg.weekStart.mon":"calcfg.weekStart.sun"),u=[{value:"auto",label:s("calcfg.weekStart.auto",{day:i(Fa())})},{value:0,label:i(0)},{value:1,label:i(1)}],f=u.find(c=>c.value===n)??u[0];return a.jsxs("div",{className:"amx-calcfg-weekstart","data-week-start":n,children:[a.jsx("span",{className:"amx-calcfg-weekstart-label",children:s("calcfg.weekStart")}),a.jsxs(Ea,{label:`${s("calcfg.weekStart")} · ${f.label}`,className:"capability-menu-trigger amx-calcfg-weekstart-btn",selection:!0,items:u.map(c=>({id:`week-start:${c.value}`,label:c.label,selected:c.value===n,onSelect:()=>p(c.value)})),children:[a.jsx("span",{children:f.label}),a.jsx(aa,{size:13})]})]})}function se(){return a.jsx(qa,{children:a.jsxs("div",{className:"amx-calside",children:[a.jsx(Oa,{}),a.jsx($a,{})]})})}const $=s=>new Date(s.getFullYear(),s.getMonth(),1);function Oa(){const{t:s}=q(),n=oa(t=>(t.mainTabs,((t.api?ra(t.api):null)?.params??{}).__type==="calendar")),p=O(t=>t.visibleStart),i=O(t=>t.visibleEnd),u=O(t=>t.requestJump),f=d.useMemo(()=>ia(new Date),[]),[c,h]=d.useState(()=>$(f));d.useEffect(()=>{if(n&&p&&i){const t=_(p),b=ma(t,Math.floor(da(_(i),t)/2));h($(b))}},[n,p,i]);const v=ua(),x=d.useMemo(()=>fa(c),[c,v]),C=F(f,!0),o=t=>{if(!n||!p||!i)return!1;const b=F(t,!0);return b>=p&&b<=i},N=t=>{h($(t)),n&&u(F(t,!0))};return a.jsxs("div",{className:"amx-mini",children:[a.jsxs("div",{className:"amx-mini-head",children:[a.jsx("button",{className:"amx-mini-nav",onClick:()=>h(new Date(c.getFullYear(),c.getMonth()-1,1)),"aria-label":s("calcfg.prevMonth"),children:"‹"}),a.jsx("span",{className:"amx-mini-title",children:ha(c)}),a.jsx("button",{className:"amx-mini-nav",onClick:()=>h(new Date(c.getFullYear(),c.getMonth()+1,1)),"aria-label":s("calcfg.nextMonth"),children:"›"})]}),a.jsx("div",{className:"amx-mini-dow",children:pa().map(t=>a.jsx("span",{children:t},t))}),a.jsx("div",{className:"amx-mini-grid",children:x.map(t=>{const b=t.getMonth()!==c.getMonth(),E=F(t,!0)===C;return a.jsx("button",{className:`amx-mini-day${b?" out":""}${E?" today":""}${o(t)?" band":""}`,onClick:()=>N(t),title:n?s("calcfg.jumpToDay"):void 0,children:t.getDate()},+t)})})]})}function $a(){const{t:s}=q(),n=J(e=>e.vaultRoot)??"",i=J(e=>e.vaultSide)==="cloud"?s("calcfg.cloud"):n.split(/[\\/]/).pop()||n,u=ga(),f=xa(),c=ba(),h=ja(),v=j(e=>e.errors),x=k(e=>e.byVault),C=k(e=>e.setColor),o=k(e=>e.toggleHidden),N=k(e=>e.setDefault),t=k(e=>e.addMember),b=k(e=>e.removeMember),[E,I]=d.useState(!1),[T,D]=d.useState(null),[W,M]=d.useState(null),[m,g]=d.useState(null),[S,y]=d.useState(null),sa=d.useMemo(()=>new Set(u.map(e=>e.db.path)),[u]),V=[...u.map(e=>({db:e.db})),...f.map(e=>({db:e,readonly:!0,kind:"agent"})),...c.map(e=>({db:e,readonly:!0,kind:"other"})),...h.map(e=>({db:e,readonly:!0,kind:"ics"}))],G=va(n,x),ta=e=>{g(null),R(s("calcfg.renameCalendar"),e.name).then(r=>{const l=r?.trim();l&&l!==e.name&&Ma.getState().mutate(e.path,A=>({...A,name:l}))})},z=e=>e.slice(6),U=e=>v[z(e)],na=()=>{R(s("calcfg.subscribeExternal"),"",{label:s("calcfg.subscribeHint")}).then(e=>{const r=e?.trim();r&&j.getState().add(r)})},ca=()=>{const e=document.createElement("input");e.type="file",e.accept=".ics,text/calendar",e.onchange=()=>{const r=e.files?.[0];if(r){if(r.size>Z){M(s("calcfg.fileTooLarge",{mb:Z/1024/1024}));return}M(null),r.text().then(l=>{j.getState().importText(za(l)||r.name.replace(/\.ics$/i,""),l)||M(s("calcfg.notIcs"))}).catch(l=>M(s("calcfg.readFailed",{msg:l?.message||String(l)})))}},e.click()};return a.jsxs("div",{className:"amx-calcfg",children:[a.jsx("div",{className:"amx-calcfg-head",children:s("calcfg.title")}),V.length===0&&a.jsx("div",{className:"amx-calcfg-empty",children:s("calcfg.empty")}),a.jsx("div",{className:"amx-calcfg-list",children:V.map(({db:e,readonly:r,kind:l},A)=>{const L=Ca(n,x,e.path,A),H=!Na(n,x,e.path),P=G?G===e.path:A===0;return a.jsxs("div",{className:"amx-calcfg-row",children:[a.jsx("span",{className:"amx-calcfg-type","aria-hidden":"true",children:l==="agent"?a.jsx(wa,{size:14}):l==="ics"?a.jsx(X,{size:14}):l==="other"?a.jsx(Ia,{size:14}):a.jsx(B,{size:14})}),a.jsx("span",{className:"amx-calcfg-swatch",style:{background:H?L:"transparent",borderColor:L},children:a.jsx("input",{type:"color",value:L,onChange:w=>C(n,e.path,w.target.value),title:s("calcfg.eventColor")})}),a.jsxs("span",{className:`amx-calcfg-name${H?"":" off"}`,title:U(e.path)||e.name,children:[e.name,l==="ics"&&U(e.path)&&a.jsxs("span",{className:"amx-cal-vault",children:[" · ",s("calcfg.fetchFailed")]}),(()=>{const w=l==="agent"?"":l==="other"?e.vaultLabel||"":i;return w?a.jsxs("span",{className:"amx-cal-vault",children:[" · ",w]}):null})()]}),!r&&a.jsx("button",{className:`amx-calcfg-def${P?" on":""}`,"aria-label":P?s("calcfg.isDefaultAria",{name:e.name}):s("calcfg.setDefaultAria",{name:e.name}),title:s(P?"calcfg.defaultCalendar":"calcfg.setAsDefault"),onClick:()=>N(n,e.path),children:a.jsx(Ta,{size:13,fill:P?"currentColor":"none"})}),a.jsx(La,{label:s("calcfg.showInCalendar"),isLabelHidden:!0,size:"sm",value:H,onChange:()=>o(n,e.path)}),(!r||l==="ics")&&a.jsx("button",{className:"amx-calcfg-more",title:s("calcfg.more"),onClick:w=>{const Y=w.currentTarget.getBoundingClientRect();g({db:e,ics:l==="ics",x:Math.min(Y.left,window.innerWidth-180),y:Y.bottom+4})},children:"⋯"})]},e.path)})}),a.jsxs("button",{className:"amx-calcfg-add amx-calcfg-add-main",onClick:e=>{const r=e.currentTarget.getBoundingClientRect();D({x:Math.max(12,r.left),y:r.bottom+4})},children:[a.jsx(ka,{size:14})," ",s("calcfg.addCalendar")," ",a.jsx(aa,{size:13})]}),W&&a.jsx("div",{className:"amx-calcfg-hint",style:{color:"var(--danger)"},children:W}),a.jsx(Ra,{}),T&&a.jsx("div",{className:"amx-db-popwrap",onMouseDown:()=>D(null),children:a.jsxs(K,{className:"amx-db-pop amx-calcfg-addmenu",x:T.x,y:T.y,onMouseDown:e=>e.stopPropagation(),children:[a.jsxs("button",{className:"amx-db-opt",onClick:()=>{D(null),I(!0)},children:[a.jsx(B,{size:14})," ",s("calcfg.addDatabase")]}),a.jsxs("button",{className:"amx-db-opt",onClick:()=>{D(null),na()},children:[a.jsx(X,{size:14})," ",s("calcfg.subscribeExternal")]}),a.jsxs("button",{className:"amx-db-opt",onClick:()=>{D(null),ca()},children:[a.jsx(Ha,{size:14})," ",s("calcfg.importIcs")]})]})}),m&&a.jsx("div",{className:"amx-db-popwrap",onMouseDown:()=>g(null),children:a.jsx(K,{className:"amx-db-pop amx-calcfg-menu",x:m.x,y:m.y,onMouseDown:e=>e.stopPropagation(),children:m.ics?a.jsxs(a.Fragment,{children:[!!j.getState().subs.find(e=>e.id===z(m.db.path))?.url&&a.jsx("button",{className:"amx-db-opt",onClick:()=>{j.getState().refresh(z(m.db.path)),g(null)},children:s("calcfg.refreshNow")}),a.jsx("button",{className:"amx-db-opt",onClick:()=>{const e=z(m.db.path),r=m.db.name;g(null),R(s("calcfg.renameSub"),r).then(l=>{l?.trim()&&j.getState().rename(e,l.trim())})},children:s("calcfg.rename")}),a.jsx("button",{className:"amx-db-opt amx-db-opt-danger",onClick:()=>{j.getState().remove(z(m.db.path)),g(null)},children:s("calcfg.unsubscribe")})]}):a.jsxs(a.Fragment,{children:[a.jsx("button",{className:"amx-db-opt",onClick:()=>ta(m.db),children:s("calcfg.rename")}),a.jsx("button",{className:"amx-db-opt",onClick:()=>{N(n,m.db.path),g(null)},children:s("calcfg.setDefaultDb")}),a.jsx("button",{className:"amx-db-opt",onClick:()=>{Da(m.db.path),g(null)},children:s("calcfg.openInNewTab")}),a.jsx("button",{className:"amx-db-opt",onClick:()=>{y(m.db),g(null)},children:s("calcfg.columnMapping")}),a.jsx("button",{className:"amx-db-opt amx-db-opt-danger",onClick:()=>{b(n,m.db.path),g(null)},children:s("calcfg.removeFromCalendar")})]})})}),E&&a.jsx(Ba,{memberPaths:sa,onClose:()=>I(!1),onAdd:(e,r,l)=>{t(n,e.path,r,l),I(!1)}}),S&&a.jsx("div",{className:"amx-db-popwrap",onMouseDown:()=>y(null),children:a.jsx("div",{className:"amx-db-pop amx-calpick-pop",onMouseDown:e=>e.stopPropagation(),children:a.jsx(ea,{dbName:S.name,columns:S.columns,initial:Sa(n,x,S.path),onCancel:()=>y(null),onConfirm:(e,r)=>{t(n,S.path,e,r),y(null)}})})})]})}function Ba({memberPaths:s,onClose:n,onAdd:p}){const{t:i}=q(),u=ya(),[f,c]=d.useState(""),[h,v]=d.useState(null),x=d.useMemo(()=>u.filter(o=>!s.has(o.path)&&o.columns.some(Aa)),[u,s]),C=f?x.filter(o=>o.name.toLowerCase().includes(f.toLowerCase())):x;return a.jsx("div",{className:"amx-qf-scrim",onMouseDown:n,children:h?a.jsx("div",{className:"amx-qf-card",onMouseDown:o=>o.stopPropagation(),children:a.jsx(ea,{dbName:h.name,columns:h.columns,onCancel:()=>v(null),onConfirm:(o,N)=>p(h,o,N)})}):a.jsxs("div",{className:"amx-qf",onMouseDown:o=>o.stopPropagation(),children:[a.jsxs("div",{className:"amx-qf-head",children:[a.jsx(Pa,{size:16,className:"amx-qf-searchicon"}),a.jsx("input",{autoFocus:!0,className:"amx-qf-input",placeholder:i("calcfg.searchDbPlaceholder"),value:f,onChange:o=>c(o.target.value)})]}),a.jsxs("div",{className:"amx-qf-list",children:[C.map(o=>a.jsxs("button",{className:"amx-qf-row",onClick:()=>v(o),children:[a.jsx("span",{className:"amx-qf-icon",children:a.jsx(B,{size:15})}),a.jsx("span",{className:"amx-qf-title",children:o.name||o.path}),a.jsx("span",{className:"amx-qf-sub",children:o.path.replace(/\\/g,"/").split("/").slice(0,-1).join("/")||"/"})]},o.path)),C.length===0&&a.jsx("div",{className:"amx-qf-empty",children:i("calcfg.noCandidates")})]}),a.jsx("div",{className:"amx-qf-foot",children:i("calcfg.footHint")})]})})}export{se as CalendarConfigView};
@@ -0,0 +1 @@
1
+ import{d as s,j as n,t as we,r as Je,u as ze}from"./index-B5UW6SaE.js";import{G as xt,ji as ft,jj as mt,jk as ht,jl as pt,jm as yt,jn as kt,b as gt,jo as bt,jp as me,jq as vt,jr as wt,js as V,jt as be,ju as J,jv as jt,c6 as $t,aK as Mt,jw as ae,jx as Te,jy as $e,jz as Ct,jA as Qe,jB as et,jC as fe,ah as xe,jD as Z,jE as zt,jF as Et,jG as Dt,jH as Tt,jI as St,jJ as Nt,jK as qe,jL as Rt,jM as We,jN as At,jO as He,jP as It,jQ as tt}from"./appStore-CidPWYa0.js";import"./client-CPUljePZ.js";import{u as Lt,p as Q,m as he,t as pe,S as Pt,a as qt,b as Wt,r as Ht,c as Kt,I as Ft,l as Ot,A as Gt}from"./astryxBridge-Bupzouso.js";import{u as ee,H as Bt}from"./calendarNavStore-Duyhbmm_.js";import{E as Vt,d as Yt}from"./EventCard-c6s4uGBu.js";import{Z as Xt,a as Ut}from"./zoom-in-BcuPvIYd.js";import{R as _t}from"./rotate-ccw-xgT_0UN9.js";import"./nativeDownload-B3JGkABw.js";import"./ipc-CNlIRMtU.js";const Zt=[["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M21 12.598V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5",key:"1glfrc"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]],Jt=xt("calendar-plus",Zt);function nt({children:e,as:t="span",ref:o,...i}){return s.createElement(t,{ref:o,...i,className:"x10l6tqk x1i1rx1s xjm9jq1 xkdpibf x1717udv xb3r6kr xzpqnlu xuxw1ft xng3xce x13vifvy x1o0tod x47corl x87ps6o"},e)}nt.displayName="VisuallyHidden";const Qt="data-astryx-edge-comp",Re=s.createContext(null);Re.displayName="SizeContext";function en(e,t="md"){const o=s.use(Re);return e??o??t}Re.Provider;const st=s.createContext(null);st.displayName="ButtonGroupContext";function tn(){return s.use(st)}const rt=s.createContext(null);rt.displayName="LinkContext";function nn(e){function t({href:o,ref:i,...u}){return s.createElement(e,{ref:i,href:o,to:o,...u})}return t.displayName=`LinkWithTo(${typeof e=="string"?e:e.displayName||e.name||"Component"})`,t}function at(e){const t=s.use(rt),o=e??t?.component??"a";return s.useMemo(()=>o==="a"?"a":nn(o),[o])}const re={base:{kVAEAm:"x1n2onr6",k1xSpc:"x3nfvp2",kGNEyG:"x6s0dn4",kjj79g:"xl56j7k",kOIVth:"x1txdalj",k8WAf4:"xce4md1",kg3NbH:"xrrkdod",kMzoRj:"xc342km",ksu8eU:"xng3xce",kaIpWk:"x1jxw6zd",kMv6JI:"xjb2p0i",kGuDYH:"xcr08ib",kLWn49:"x1kq96og",k63SB2:"x1e4wzip",khDVqt:"xuxw1ft",kkrTdU:"x1ypdohk",k1ekBW:"xrafxwg",kIyJzY:"xuedmi6 x12w9bfk",kAMwcw:"xlr8y92",$$css:!0},pressable:{k3aq6I:"x3oybdh xk4oym4",$$css:!0},disabled:{kkrTdU:"x1h6gzvc",kSiTet:"xbyyjgo",kKwaWg:"x18o3ruo",k3aq6I:"x1c071of x1pdlv7q",$$css:!0},ariaDisabled:{kKwaWg:"x18o3ruo x8o3jvd xuqm82a",$$css:!0},iconOnly:{"--button-icon-only-aspect":"x1v15ycx",kOBAk4:"xioom0i",kg3NbH:"xnjsko4",k8WAf4:"xt970qd",$$css:!0},iconWrapper:{k1xSpc:"x3nfvp2",kGNEyG:"x6s0dn4",kjj79g:"xl56j7k",kmuXW:"x2lah0s",$$css:!0},contentWrapper:{k1xSpc:"xjp7ctv",$$css:!0},link:{kybGjl:"x1hl2dhg",$$css:!0}},sn={sm:{kZKoxP:"x6k0iem",$$css:!0},md:{kZKoxP:"x1ueg155",$$css:!0},lg:{kZKoxP:"xssyfek",$$css:!0}},rn={sm:{kzqmXN:"x1kky2od",kZKoxP:"xlup9mm",kGuDYH:"x1j61zf2",$$css:!0},md:{kzqmXN:"x1kky2od",kZKoxP:"xlup9mm",kGuDYH:"x1j61zf2",$$css:!0},lg:{kzqmXN:"xw4jnvo",kZKoxP:"x1qx5ct2",kGuDYH:"xwsyq91",$$css:!0}},an={primary:{kWkggS:"x1ewilqj",kMwMTN:"x17wrial",kKwaWg:"x1ilzqfv xq8i9tn",kI3sdo:"x17nn4n9","--button-focus-offset":"xkzo27j",kInvED:"x1wfwxd8 x13aywxo",$$css:!0},secondary:{kWkggS:"x17x4s8c",kMwMTN:"x1tgivj0",kKwaWg:"x1ilzqfv xq8i9tn",kI3sdo:"x17nn4n9","--button-focus-offset":"xkzo27j",kInvED:"x1wfwxd8 x13aywxo",$$css:!0},ghost:{kWkggS:"xjbqb8w",kMwMTN:"x1tgivj0",kKwaWg:"x1ilzqfv xq8i9tn",kI3sdo:"x17nn4n9","--button-focus-offset":"xkzo27j",kInvED:"x1wfwxd8 x13aywxo",$$css:!0},destructive:{kWkggS:"x1pjz0fi",kMwMTN:"x1m024r3",kKwaWg:"x1ilzqfv xq8i9tn",kI3sdo:"x1p73he7","--button-focus-offset":"xkzo27j",kInvED:"x1wfwxd8 x13aywxo",$$css:!0}},Ke={hiddenContent:{kMwMTN:"x19co3pv",$$css:!0},hiddenContentDelayed:{kKVMdj:"x1ffowhz",k44tkh:"xjlvqhv",kWV6AL:"x10e4vud",kKxzle:"x17yabm6 x14q22ui",$$css:!0}},je={horizontal:{krdFHd:"x15mokao x8eehn2",kVL7Gh:"xbiv7yw x1xrp5p4",kfmiAY:"x1ga7v0g x11xp8u1",kT0f0o:"x16uus16 x747jw7",k2ei4v:"xgbv0en x1pjv70x",kVhnKS:"x1t7ytsu xyf0ibl",kGJrpR:"x1j92z86",$$css:!0},vertical:{krdFHd:"x15mokao x8eehn2",kfmiAY:"x1ga7v0g x2qxyot",kVL7Gh:"xbiv7yw x1yp72r9",kT0f0o:"x16uus16 x747jw7",kEafiO:"x11xkdxz x1g31smg",kPef9Z:"x13fuv20 x1d9v4yf",kLZC3w:"x1pc3f07",$$css:!0},onSolidHorizontal:{kGJrpR:"xrvmtm5",$$css:!0},onSolidVertical:{kLZC3w:"x11npmm7",$$css:!0}};function ce({label:e,variant:t="secondary",size:o,type:i="button",isDisabled:u=!1,isLoading:C=!1,isInterruptible:j=!1,clickAction:y,icon:$,isIconOnly:l=!1,children:d,endContent:p,tooltip:v,href:S,as:z,target:E,rel:k,xstyle:L,className:H,style:A,ref:T,...P}){const h=en(o,"md"),D=tn(),[R,c]=s.useTransition(),x=s.useRef(!1),g=C||R,w=R||j,q=D?.isDisabled??!1,K=u||q||g&&!j,Y=at(z),F=S!=null&&!K,f=v!=null&&K,N=Lt({placement:"above",isEnabled:v!=null}),W=X=>{if(K||x.current&&!j){X.preventDefault();return}P.onClick?.(X),y&&!X.defaultPrevented&&(x.current=!0,c(async()=>{try{await y(X)}finally{x.current=!1}}))},O=f?X=>{X.key==="Enter"||X.key===" "?X.preventDefault():P.onKeyDown?.(X)}:void 0,ne=t==="ghost"?{[Qt]:""}:null,a=Q(re.base,sn[h],an[t],l&&re.iconOnly,K&&re.disabled,f&&re.ariaDisabled,F&&re.link,!D&&re.pressable,D&&(D.orientation==="horizontal"?je.horizontal:je.vertical),D&&(t==="primary"||t==="destructive")&&(D.orientation==="horizontal"?je.onSolidHorizontal:je.onSolidVertical),L),r=he(pe("button",{variant:t,size:h}),a,H,A),m=n.jsxs(n.Fragment,{children:[g&&n.jsx("span",{...{0:{className:"x10l6tqk x13vifvy xu96u03 x3m8u43 x1ey2m1c xrvj5dj x1ku5rj1"},1:{className:"x10l6tqk x13vifvy xu96u03 x3m8u43 x1ey2m1c xrvj5dj x1ku5rj1 xqcmdr3 xb2rp9n xskzprw x17yabm6 x14q22ui"}}[!!w<<0],"aria-hidden":"true",children:n.jsx(Pt,{size:"sm",shade:"inherit"})}),n.jsxs("span",{...Q(re.contentWrapper,g&&(w?Ke.hiddenContentDelayed:Ke.hiddenContent)),"aria-hidden":g||void 0,children:[$&&n.jsx("span",{...Q(re.iconWrapper,rn[h]),children:$}),l?null:n.jsx("span",{className:"xb3r6kr xlyipyv xeuugli",children:d??e}),!l&&p&&n.jsx("span",{className:"x3nfvp2 x6s0dn4 x1heor9g",children:p})]}),n.jsx(nt,{role:"status","aria-live":"polite",children:g?"Loading":""})]}),b=l&&e!==""||g&&!l||d!=null&&d!==e?{"aria-label":e}:null,I=v!=null?{"aria-describedby":[P["aria-describedby"],N.describedBy].filter(Boolean).join(" ")||void 0}:null,B=qt(T,v!=null?N.ref:void 0);let te;return F?te=n.jsx(Y,{ref:B,href:S,target:E,rel:k,...r,...P,...b,...I,...ne,onClick:W,children:m}):te=n.jsx("button",{ref:B,type:i,disabled:f?void 0:K,...r,...P,...b,...I,...ne,"aria-busy":g||void 0,"aria-disabled":f||void 0,onClick:W,...O?{onKeyDown:O}:null,children:m}),v?n.jsxs(n.Fragment,{children:[te,N.renderTooltip(v)]}):te}ce.displayName="Button";const on='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), [contenteditable]:not([contenteditable="false"]), audio[controls], video[controls], iframe, details > summary:first-child',ve=[];function ln(e){ve.push(e)}function cn(e){const t=ve.lastIndexOf(e);t!==-1&&ve.splice(t,1)}function un(e){return ve[ve.length-1]===e}function dn(e){return e.isComposing===!0||e.keyCode===229}function xn(e){if(e.hasAttribute("inert")||e.closest("[inert]")||e.hidden||e.closest("[hidden]"))return!1;if(typeof window<"u"&&window.getComputedStyle){const t=window.getComputedStyle(e);if(t.visibility==="hidden"||t.display==="none")return!1}return!0}function Ae(e){return Array.from(e.querySelectorAll(on)).filter(xn)}function ot(e){try{e.focus()}catch{}return document.activeElement===e}function Fe(e){const t=Ae(e);for(const o of t)if(ot(o))return!0;return!1}function fn(e){const t=Ae(e);for(let o=t.length-1;o>=0;o--)if(ot(t[o]))return!0;return!1}function mn(e){const{isActive:t,onEscape:o}=e,i=s.useRef(null),u=s.useRef(null),C=s.useRef(!1),j=s.useCallback(()=>{i.current&&Fe(i.current)},[]);return s.useEffect(()=>{if(!t)return;const y=$=>{const l=i.current;if(!l)return;const d=$.target;l.contains(d)?u.current=d:C.current&&(Fe(l),u.current===document.activeElement&&fn(l),u.current=document.activeElement),C.current=!1};return document.addEventListener("focus",y,!0),()=>{document.removeEventListener("focus",y,!0)}},[t]),s.useEffect(()=>{if(!t)return;const y=()=>{o?.()};o&&ln(y);const $=l=>{const d=i.current;if(d){if(l.key==="Escape"&&o){if(l.defaultPrevented||dn(l)||!un(y))return;l.preventDefault(),l.stopPropagation(),o();return}if(l.key==="Tab"){C.current=!0;const p=Ae(d);if(p.length===0)return;const v=p[0],S=p[p.length-1];l.shiftKey?document.activeElement===v&&(l.preventDefault(),S.focus()):document.activeElement===S&&(l.preventDefault(),v.focus())}}};return document.addEventListener("keydown",$),()=>{document.removeEventListener("keydown",$),o&&cn(y)}},[t,o]),{containerRef:i,focusFirst:j}}const Oe={surface:{kWkggS:"x1prclbq",kaIpWk:"x1hviunn",kGVxlE:"x1i5ehqx",$$css:!0},contentWrapper:{kVAEAm:"x1n2onr6",$$css:!0}};function hn(e={}){const{onShow:t,onHide:o,xstyle:i,hasLightDismiss:u=!0,hasEscapeDismiss:C=!0,hasAutoFocus:j=!0,hasSurface:y=!0,hasCloseButton:$=!0,closeButtonLabel:l="Close popover",dialogLabel:d,role:p="dialog",isModal:v=!0}=e,S=s.useRef(null),z=s.useRef(!1),E=Wt({mode:"context",lightDismiss:u,onShow:t,onHide:o}),{containerRef:k,focusFirst:L}=mn({isActive:E.isOpen,onEscape:C||u?E.hide:void 0});s.useEffect(()=>{E.isOpen&&j&&!z.current&&requestAnimationFrame(()=>{L()}),E.isOpen||(z.current=!1)},[E.isOpen,j,L]);const H=s.useCallback(R=>{S.current=R,E.ref(R)},[E]),A=s.useCallback(R=>{z.current=R?.skipAutoFocus??!1,E.show()},[E]),T=s.useCallback(()=>{E.isOpen?E.hide():A()},[E,A]),P={"aria-haspopup":p==="dialog"?"dialog":"true","aria-expanded":E.isOpen,"aria-controls":E.id},h=s.useRef(!1);s.useEffect(()=>{p==="dialog"&&!d&&!h.current&&(h.current=!0,console.warn('usePopover: role="dialog" without a `dialogLabel` renders an unnamed dialog. Pass `dialogLabel`, or use `role: "none"` for listbox/menu popups whose content already carries its own role.'))},[p,d]);const D=s.useCallback((R,c)=>E.render(n.jsxs("div",{ref:k,role:p==="dialog"?"dialog":void 0,"aria-modal":p==="dialog"&&v?!0:void 0,"aria-label":p==="dialog"?d:void 0,...Q(Oe.contentWrapper,y&&Oe.surface,i),children:[R,$&&n.jsx("div",{className:"x10l6tqk x1ey2m1c x1nrll8i x31h1t8 x1vjfegm x1i1rx1s x10okhzq xjm9jq1 x132qfvm xb3r6kr x1dordxg x1hyvwdk x10wafsz x47corl xbt4iw xexx8yu x1kw28su",children:n.jsx(ce,{variant:"secondary",label:l,onClick:E.hide})})]}),{...c,xstyle:c?.xstyle}),[E,$,y,l,k,d,p,v,i]);return{triggerRef:H,contentRef:k,anchorId:E.anchorId,show:A,hide:E.hide,toggle:T,isOpen:E.isOpen,id:E.id,render:D,triggerProps:P}}const Ge={horizontal:{k1xSpc:"x78zum5",kGNEyG:"x6s0dn4",kzqmXN:"xh8yej3",$$css:!0},vertical:{k1xSpc:"x3nfvp2",kXwgrk:"xdt5ytf",kGNEyG:"x6s0dn4",kZKoxP:"x5yr21d",$$css:!0}},de={horizontalLine:{kZKoxP:"xsyqizj",kzQI83:"x1iyjqo2",kmuXW:"xs83m0k",$$css:!0},verticalLine:{kzqmXN:"xjk4fl7",kzQI83:"x1iyjqo2",kmuXW:"xs83m0k",$$css:!0},subtle:{kWkggS:"x1m4xfpy",$$css:!0},strong:{kWkggS:"x7njt3n",$$css:!0}},Be={horizontal:{keTefX:"xojxgvx",k71WvV:"x1fcf3bl",kzqmXN:"xx6qvi6",$$css:!0},vertical:{keoZOQ:"x1sa9bsh",k1K539:"x6h7pi7",kZKoxP:"x12qplqi",$$css:!0}};function lt({orientation:e="horizontal",label:t,variant:o="subtle",isFullBleed:i=!1,xstyle:u,className:C,style:j,ref:y,...$}){const l=e==="horizontal";return n.jsxs("div",{ref:y,role:"separator","aria-orientation":e,...he(pe("divider",{variant:o,orientation:e}),Q(l?Ge.horizontal:Ge.vertical,i&&(l?Be.horizontal:Be.vertical),u),C,j),...$,children:[n.jsx("div",{...Q(l?de.horizontalLine:de.verticalLine,de[o])}),t&&n.jsx("div",{...{0:{className:"x2lah0s xrrkdod x141an7d x1ltkj2j xv1l7n4"},1:{className:"x2lah0s x141an7d x1ltkj2j xv1l7n4 xnjsko4 x8o8v82"}}[!l<<0],children:t}),t&&n.jsx("div",{...Q(l?de.horizontalLine:de.verticalLine,de[o])})]})}lt.displayName="Divider";const pn=["noopener","noreferrer"];function yn(e,t){if(e!=="_blank")return{target:e,rel:t};const o=t?.split(/\s+/).filter(Boolean)??[];for(const i of pn)o.includes(i)||o.push(i);return{target:e,rel:o.join(" ")}}const U={root:{k1xSpc:"x78zum5",kGNEyG:"x6s0dn4",kOIVth:"x1txdalj",kg3NbH:"xf314gf",kVAEAm:"x1n2onr6",kB7OPa:"x9f619",k9WMMc:"x1yc453h",kaIpWk:"xh6dtrn",$$css:!0},alignStart:{kGNEyG:"x1cy8zhl",$$css:!0},interactive:{kkrTdU:"x1ypdohk",k1ekBW:"x15406qy",kIyJzY:"xkvfbh3",kAMwcw:"xlr8y92",kWkggS:"xjbqb8w xe9uy6x xyxi2l3",$$css:!0},focusVisibleOutline:{kI3sdo:"x1a2a7pz x1irc7jg",kInvED:"x1wfwxd8 xdjuwb3",$$css:!0},highlighted:{kWkggS:"x1lmrjuc",$$css:!0},selected:{kWkggS:"xgcxg3y",$$css:!0},disabled:{kkrTdU:"x1h6gzvc",kfzvcC:"x47corl",$$css:!0},label:{kMwMTN:"x1tgivj0",kGuDYH:"xjm74w1",kLWn49:"xw6l6zx",$$css:!0},labelSingleTruncate:{kVQacm:"xb3r6kr",kg5iWk:"xlyipyv",khDVqt:"xuxw1ft",$$css:!0},labelMultiTruncate:{kVQacm:"xb3r6kr",k1xSpc:"x104kibb",kgKLqz:"x1ua5tub",$$css:!0},description:{kMwMTN:"xv1l7n4",kGuDYH:"x141an7d",kLWn49:"x1ltkj2j",$$css:!0},descriptionSingleTruncate:{kVQacm:"xb3r6kr",kg5iWk:"xlyipyv",khDVqt:"xuxw1ft",$$css:!0},descriptionMultiTruncate:{kVQacm:"xb3r6kr",k1xSpc:"x104kibb",kgKLqz:"x1ua5tub",$$css:!0}},Ve={lineClamp:e=>[{kJFfOR:e!=null?"x1yhjpo9":e,$$css:!0},{"--x-WebkitLineClamp":e??void 0}]},kn={compact:{k8WAf4:"xu0wf1k",$$css:!0},balanced:{k8WAf4:"xce4md1",$$css:!0},spacious:{k8WAf4:"x8o8v82",kg3NbH:"xrrkdod",$$css:!0}};function ct({as:e="div",marker:t,startContent:o,label:i,description:u,endContent:C,align:j="center",density:y="balanced",labelLines:$,descriptionLines:l,onClick:d,href:p,target:v,rel:S,isHighlighted:z=!1,isSelected:E=!1,isDisabled:k=!1,xstyle:L,className:H,style:A,ref:T,role:P,...h}){const D=at(),R=d!=null||p!=null,{target:c,rel:x}=yn(v,S),g=P!=null,w=typeof i=="string",q=typeof u=="string",K=$!=null?$===1?U.labelSingleTruncate:U.labelMultiTruncate:w?U.labelSingleTruncate:null,Y=l!=null?l===1?U.descriptionSingleTruncate:U.descriptionMultiTruncate:q?U.descriptionSingleTruncate:null,F=n.jsxs(n.Fragment,{children:[n.jsx("span",{...Q(U.label,K,$!=null&&$>1&&Ve.lineClamp($)),children:i}),u!=null&&n.jsx("span",{...Q(U.description,Y,l!=null&&l>1&&Ve.lineClamp(l)),children:u})]}),f=W=>{k||W.target.closest("button, a, input, select, textarea")||d?.(W)},N=n.jsxs(n.Fragment,{children:[t,o!=null&&n.jsx("span",{className:"x3psx0u x78zum5",children:o}),g?n.jsx("span",{...{0:{className:"x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h"},1:{className:"x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h xbyyjgo"}}[!!k<<0],children:F}):p!=null?n.jsx(D,{href:p,target:c,rel:x,"aria-disabled":k||void 0,tabIndex:k?-1:void 0,...{0:{className:"xmper1u xln7xf2 x1heor9g x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h x1hl2dhg x1a2a7pz"},1:{className:"xmper1u xln7xf2 x1heor9g x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h x1hl2dhg x1a2a7pz xbyyjgo"}}[!!k<<0],children:F}):d!=null?n.jsx("button",{type:"button",onClick:d,disabled:k,...{0:{className:"xmper1u xln7xf2 x1heor9g x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h x1a2a7pz"},1:{className:"xmper1u xln7xf2 x1heor9g x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h x1a2a7pz xbyyjgo"}}[!!k<<0],children:F}):n.jsx("span",{...{0:{className:"x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h"},1:{className:"x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h xbyyjgo"}}[!!k<<0],children:F}),C!=null&&n.jsx("span",{...{0:{className:"x3psx0u x78zum5 xvc5jky"},1:{className:"x3psx0u x78zum5 xvc5jky xbyyjgo"}}[!!k<<0],children:C})]});return n.jsx(e,{ref:T,"aria-selected":E||void 0,"aria-disabled":k||void 0,...h,...he(pe("item",{density:y,align:j}),Q(U.root,kn[y],j==="start"&&U.alignStart,R&&U.interactive,R&&U.focusVisibleOutline,z&&U.highlighted,E&&U.selected,k&&!g&&U.disabled,L),H,A),role:P,onClick:g?d:R?f:void 0,children:N})}ct.displayName="Item";const Ie=s.createContext(null);Ie.displayName="DropdownMenuContext";function gn(){return s.use(Ie)}const Ye={root:{kB7OPa:"x9f619",kzqmXN:"xh8yej3",k8WAf4:"xce4md1",kg3NbH:"xf314gf",kaIpWk:"x1ws5lxm",kMv6JI:"x9ynric",kGuDYH:"xcr08ib",kMwMTN:"x1tgivj0",kWkggS:"xjbqb8w x1c52tdz x1uwx2nv",kkrTdU:"x1ypdohk",k9WMMc:"xdpxx8g",kI3sdo:"x1a2a7pz",$$css:!0},disabled:{kSiTet:"xbyyjgo",kkrTdU:"x1h6gzvc",$$css:!0}},bn={sm:{k8WAf4:"xu0wf1k",kg3NbH:"xf314gf",$$css:!0},md:{k8WAf4:"x1vofgu7",$$css:!0},lg:{$$css:!0}};function ie({icon:e,label:t,description:o,onClick:i,isDisabled:u=!1,endContent:C,xstyle:j,className:y,style:$}){const l=gn(),d=l?.menuSize??"md",p=s.useCallback(()=>{u||!i||(i(),l?.closeMenu())},[u,i,l]);return n.jsx(ct,{role:"menuitem",tabIndex:u?void 0:-1,startContent:e?Ht(e,{size:"sm",color:"secondary"}):void 0,label:t,description:o,endContent:C,onClick:p,isDisabled:u,xstyle:[Ye.root,bn[d],u&&Ye.disabled,j],...he(pe("dropdown-menu-item",{size:d}),{className:y,style:$})})}ie.displayName="DropdownMenuItem";const vn={divider:{kqGvvJ:"xsq74q5",$$css:!0}};function Xe(e){return`item-${e.label}`}function wn(e,t){return`section-${e.title??t}`}function jn(e){const t=[];for(let o=0;o<e.length;o++){const i=e[o];"type"in i&&i.type==="divider"?t.push(n.jsx(lt,{xstyle:vn.divider},`divider-${o}`)):"type"in i&&i.type==="section"?t.push(n.jsxs("div",{role:"group","aria-label":i.title,children:[i.title&&n.jsx("div",{className:"xu0wf1k xf314gf x9ynric x141an7d x1ltkj2j xv1l7n4 x87ps6o","aria-hidden":"true",children:i.title}),i.items.map(u=>n.jsx(ie,{icon:u.icon,label:u.label,onClick:u.onClick,isDisabled:u.isDisabled},Xe(u)))]},wn(i,o))):"type"in i||t.push(n.jsx(ie,{icon:i.icon,label:i.label,onClick:i.onClick,isDisabled:i.isDisabled},Xe(i)))}return t}const $n=new Set(["text","search","url","tel","email","password","number"]);function Mn(e){if(e.isContentEditable)return e;const t=e.closest("[contenteditable]");return t&&t.getAttribute("contenteditable")!=="false"?t:null}function Ue(e,t){if(!(e instanceof HTMLElement))return!1;const o=Mn(e);if(o){const l=typeof window<"u"?window.getSelection():null;return l&&l.rangeCount>0&&!l.isCollapsed?!0:(o.textContent??"").length>0}const i=e.tagName==="TEXTAREA",u=e.tagName==="INPUT"&&$n.has(e.type);if(!i&&!u)return!1;const C=e,{selectionStart:j,selectionEnd:y,value:$}=C;return j!==y||j==null?!0:t==="ArrowLeft"||t==="ArrowUp"||t==="Home"?j>0:t==="ArrowRight"||t==="ArrowDown"||t==="End"?j<$.length:!1}function Cn(e={}){const{itemSelector:t='[role="menuitem"]',wrap:o=!0,onEscape:i,orientation:u="vertical",hasHomeEnd:C=!0,isRtl:j=!1,hasRovingTabIndex:y=!1,hasCaretGuard:$=!1}=e,l=s.useRef(null),d=s.useCallback(h=>h.getAttribute("aria-disabled")==="true"||h.disabled===!0||h.hasAttribute("disabled"),[]),p=s.useCallback(()=>l.current?Array.from(l.current.querySelectorAll(t)):[],[t]),v=s.useCallback((h,D,R,c)=>{const x=h.length;if(x===0)return-1;let g=D;for(let w=0;w<x;w++){if(g<0||g>=x){if(!c)return-1;g=(g+x)%x}const q=h[g];if(q&&!d(q))return g;g+=R}return-1},[d]),S=s.useCallback(()=>{const h=p(),D=document.activeElement;return h.findIndex(R=>R===D||R.contains(D))},[p]),z=s.useCallback((h,D)=>{h.getAttribute("tabindex")!==String(D)&&h.setAttribute("tabindex",String(D))},[]),E=s.useCallback(()=>{const h=p(),D=h.filter(x=>!d(x));if(D.length===0)return;const c=D.find(x=>x.getAttribute("tabindex")==="0")??D[0];for(const x of h)z(x,x===c?0:-1)},[p,d,z]);Kt(()=>{y&&E()});const k=s.useCallback((h,D)=>{const R=h[D];if(R){if(y)for(const c of h)z(c,c===R?0:-1);R.focus()}},[y,z]),L=s.useCallback(h=>{const D=p();if(D.length===0)return;const R=Math.max(0,Math.min(h,D.length-1));k(D,R)},[p,k]),H=s.useCallback(()=>{const h=p(),D=v(h,0,1,!1);return D!==-1?(k(h,D),!0):!1},[p,v,k]),A=s.useCallback(()=>{const h=p(),D=v(h,h.length-1,-1,!1);return D!==-1?(k(h,D),!0):!1},[p,v,k]),T=s.useCallback(()=>{y&&E()},[y,E]),P=s.useCallback(h=>{if(h.ctrlKey||h.metaKey||h.altKey)return;if(h.key==="Escape"){h.preventDefault(),i?.();return}const D=u==="horizontal"||u==="both",R=u==="vertical"||u==="both",c=[],x=[];D&&(c.push(j?"ArrowLeft":"ArrowRight"),x.push(j?"ArrowRight":"ArrowLeft")),R&&(c.push("ArrowDown"),x.push("ArrowUp"));const g=c.includes(h.key),w=x.includes(h.key),q=C&&h.key==="Home",K=C&&h.key==="End";if(!g&&!w&&!q&&!K||$&&(Ue(h.target,h.key)||Ue(document.activeElement,h.key)))return;const Y=S(),F=p();if(g){const f=Y===-1?0:Y+1,N=v(F,f,1,o);N!==-1&&k(F,N)}else if(w){const f=Y===-1?F.length-1:Y-1,N=v(F,f,-1,o);N!==-1&&k(F,N)}else q?H():K&&A();h.preventDefault()},[S,p,o,u,j,C,$,v,k,H,A,i]);return{listRef:l,handleKeyDown:P,handleFocus:T,focusItem:L,focusFirst:H,focusLast:A}}function zn(e){return e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key!==" "}function En(e){const{getItemLabels:t,onMatch:o,getCurrentIndex:i,resetMs:u=750,isDisabled:C}=e,j=s.useRef(""),y=s.useRef(void 0),$=s.useCallback(()=>{j.current="",y.current&&(clearTimeout(y.current),y.current=void 0)},[]),l=s.useCallback(()=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{j.current="",y.current=void 0},u)},[u]);return{onKeyDown:s.useCallback(p=>{const v=p.key===" "&&j.current.length>0;if(!zn(p)&&!v)return!1;const S=t();if(S.length===0)return!1;const z=p.key.toLowerCase(),E=j.current.length>0&&j.current.split("").every(T=>T===z),k=E?z:j.current+z;j.current=k,l();const L=i?.()??-1,H=S.length,A=E?1:0;for(let T=0;T<H;T++){const P=(L+A+T+H)%H;if(C?.(P))continue;const h=S[P];if(h!=null&&h.trim().toLowerCase().startsWith(k))return o(P),!0}return!0},[t,o,i,l,C]),reset:$}}const ye={dropdown:{kB7OPa:"x9f619",k1xSpc:"x78zum5",kXwgrk:"xdt5ytf",kOIVth:"x1lsbc85",kskxy:"xuyqlj2",kORKVm:"x1odjw0f","--_dropdown-menu-radius":"x1fcsqxe","--_dropdown-menu-padding":"xgory14",kmVPX3:"x9epnlk",kaIpWk:"x1n97fys",kSiTet:"x1hc1fzr",k1ekBW:"x19991ni",kIyJzY:"xuedmi6",kAMwcw:"xlr8y92",$$css:!0},popover:{k7Eaqz:"xrzjruh",$$css:!0},popoverBlockGap:{keoZOQ:"xcsaf9d",k1K539:"x14cgwvg",$$css:!0},popoverInlineGap:{keTefX:"x11g1kdw",k71WvV:"xnur1sd",$$css:!0},popoverCustomWidth:e=>[{k7Eaqz:(typeof e=="number"?`${e}px`:e)!=null?"xkj4a21":typeof e=="number"?`${e}px`:e,$$css:!0},{"--x-minWidth":(t=>typeof t=="number"?t+"px":t??void 0)(typeof e=="number"?`${e}px`:e)}]},Dn={label:"Menu"};function Se({button:e=Dn,isMenuOpen:t,onOpenChange:o,menuWidth:i,onClick:u,hasChevron:C=!0,placement:j="below",className:y,style:$,xstyle:l,"data-testid":d,...p}){const v=("items"in p?p.items:void 0)??[],S=p.children,z=s.useId(),E=e?.size??"md",k=s.useRef(null),[L,H]=s.useState(!1),A=t!==void 0,T=A?t:L,P=s.useRef(0),h=s.useCallback(()=>{P.current=Date.now(),A?o?.(!1):H(!1),k.current?.focus()},[A,o]),D=s.useRef(!1),R=s.useCallback(()=>{A?o?.(!0):H(!0),D.current&&(D.current=!1)},[A,o]),c=hn({onHide:h,onShow:R,hasLightDismiss:!0,hasCloseButton:!1,hasAutoFocus:!1,role:"none"}),x=s.useCallback(()=>{c.hide()},[c]),{listRef:g,handleKeyDown:w,focusFirst:q,focusItem:K}=Cn({itemSelector:'[role="menuitem"]:not([aria-disabled="true"])',wrap:!1,onEscape:x}),Y=s.useCallback(()=>g.current?Array.from(g.current.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')):[],[g]),F=En({getItemLabels:()=>Y().map(b=>b.textContent),onMatch:K,getCurrentIndex:()=>Y().findIndex(b=>b===document.activeElement||b.contains(document.activeElement))});s.useEffect(()=>{A&&(t&&!c.isOpen?(c.show(),requestAnimationFrame(()=>q())):!t&&c.isOpen&&c.hide())},[t,A,c,q]);const f=s.useCallback(b=>{if(b.key==="Enter"||b.key===" "){b.preventDefault();const I=document.activeElement;I?.getAttribute("role")==="menuitem"&&I.click();return}if(b.key==="Tab"){x();return}if(F.onKeyDown(b)){b.preventDefault();return}w(b)},[w,x,F]),N=s.useCallback(()=>{c.show(),requestAnimationFrame(()=>q())},[c,q]),W=s.useCallback(()=>{Date.now()-P.current<50||(u?.(),A?o?.(!t):c.isOpen?c.hide():N())},[u,A,o,t,c,N]),O=s.useCallback(b=>{c.isOpen||(b.key==="ArrowDown"||b.key==="Enter"||b.key===" ")&&(b.preventDefault(),N())},[c.isOpen,N]),G=e.isIconOnly===!0,ne=e.endContent??(C&&!G?n.jsx(Ft,{icon:"chevronDown",size:"sm",color:"inherit"}):void 0),a=i?ye.popoverCustomWidth(i):ye.popover,r=j==="above"||j==="below"?ye.popoverBlockGap:ye.popoverInlineGap,m=s.useMemo(()=>({closeMenu:x,menuSize:E}),[x,E]),M=p.items!==void 0?jn(v):S;return n.jsxs(n.Fragment,{children:[n.jsx(ce,{...e,ref:b=>{k.current=b,c.triggerRef(b);const I=e.ref;typeof I=="function"?I(b):I&&(I.current=b)},tooltip:T?void 0:e.tooltip,endContent:ne,onClick:W,onKeyDown:O,"aria-haspopup":"menu","aria-expanded":T,"aria-controls":z,"data-testid":d}),c.render(n.jsx("div",{ref:g,id:z,role:"menu","aria-label":e.label,onKeyDown:f,...he(pe("dropdown-menu"),Q(ye.dropdown,l),y,$),children:n.jsx(Ie,{value:m,children:M})}),{placement:j,alignment:"start",xstyle:[a,r,Ot[j]]})]})}Se.displayName="DropdownMenu";const Tn={wrapper:{k1xSpc:"x3nfvp2",kGNEyG:"x6s0dn4",kOIVth:"xzye2dw",kmuXW:"x2lah0s",$$css:!0}},Sn={ctrl:"⌃",alt:"⌥",shift:"⇧",enter:"↵",backspace:"⌫",escape:"Esc",tab:"⇥",up:"↑",down:"↓",left:"←",right:"→",plus:"+"};function Nn(e,t){return e==="mod"?t?"⌘":"Ctrl":Sn[e]??e.toUpperCase()}const Rn={ctrl:"Control",alt:"Alt",shift:"Shift",enter:"Enter",backspace:"Backspace",escape:"Escape",tab:"Tab",up:"Up arrow",down:"Down arrow",left:"Left arrow",right:"Right arrow",plus:"Plus"};function An(e,t){return e==="mod"?t?"Command":"Control":Rn[e]??e.toUpperCase()}function In(){return()=>{}}function Ln(){return!1}function Pn(){if(typeof navigator>"u")return!1;const e="userAgentData"in navigator?navigator.userAgentData:null;return e&&typeof e=="object"&&"platform"in e?/mac/i.test(e.platform??""):/Mac|iPhone|iPad|iPod/.test(navigator.platform??"")}function it({keys:e,ref:t,xstyle:o,className:i,style:u,...C}){const j=s.useSyncExternalStore(In,Pn,Ln),y=e.split("+").map(l=>l.trim().toLowerCase()),$=y.map(l=>An(l,j)).join(" + ");return n.jsx("span",{ref:t,role:"img","aria-label":$,...C,...he(pe("kbd"),Q(Tn.wrapper,o),i,u),children:y.map(l=>n.jsx("kbd",{"aria-hidden":"true",className:"x3nfvp2 x6s0dn4 xl56j7k x16asifk x1grt7ep x7a5moj xx3sua9 x17x4s8c xlxy82 x1q0q8m5 xib2hle xv1l7n4 x9ynric x141an7d x1e4wzip x1ltkj2j x87ps6o",children:Nn(l,j)},l))})}it.displayName="Kbd";Je({"calkeys.modeDay":{zh:"日",en:"Day"},"calkeys.modeWeek":{zh:"周",en:"Week"},"calkeys.mode3day":{zh:"3 日",en:"3 days"},"calkeys.modeMonth":{zh:"月",en:"Month"}});const Ne=[{id:"day",get label(){return we("calkeys.modeDay")},key:"d"},{id:"week",get label(){return we("calkeys.modeWeek")},key:"w"},{id:"3day",get label(){return we("calkeys.mode3day")},key:"3"},{id:"month",get label(){return we("calkeys.modeMonth")},key:"m"}];function qn(e){const t=(e.metaKey||e.ctrlKey)&&!e.altKey;if(t&&(e.key==="c"||e.key==="C"))return{kind:"copy"};if(t&&(e.key==="v"||e.key==="V"))return{kind:"paste"};if(e.metaKey||e.ctrlKey||e.altKey)return null;if(e.key==="Delete"||e.key==="Backspace")return{kind:"delete"};if(e.key==="ArrowLeft")return{kind:"prev"};if(e.key==="ArrowRight")return{kind:"next"};const o=Ne.find(i=>i.key===e.key.toLowerCase());return o?{kind:"mode",mode:o.id}:null}const ke=e=>e.end?.getTime()??e.start.getTime()+3600*1e3;function Wn(e){const t=[...e].sort((i,u)=>i.start.getTime()-u.start.getTime()||ke(i)-ke(u)),o=new Map;for(let i=0;i<t.length;){let u=i+1,C=ke(t[i]);for(;u<t.length&&t[u].start.getTime()<C;)C=Math.max(C,ke(t[u])),u+=1;const j=t.slice(i,u),y=[],$=j.map(d=>{let p=y.findIndex(v=>v<=d.start.getTime());return p<0&&(p=y.length),y[p]=ke(d),{ev:d,lane:p}}),l=Math.max(1,y.length);for(const{ev:d,lane:p}of $)o.set(d.key,{lane:p,laneCount:l,leftPct:p/l*100,widthPct:100/l});i=u}return o}Je({"calview.untitled":{zh:"未命名",en:"Untitled"},"calview.newEventTitle":{zh:"新事件",en:"New event"},"calview.new":{zh:"新建",en:"New"},"calview.newInto":{zh:"新建到「{name}」",en:'New event in "{name}"'},"calview.noDbHint":{zh:"请先在右栏添加一个含日期属性的多维表",en:"Add a calendar database in the right panel first"},"calview.today":{zh:"今天",en:"Today"},"calview.prevPage":{zh:"上一页",en:"Previous"},"calview.nextPage":{zh:"下一页",en:"Next"},"calview.density":{zh:"密度",en:"Density"},"calview.zoomOut":{zh:"缩小时间轴",en:"Zoom out timeline"},"calview.zoomIn":{zh:"放大时间轴",en:"Zoom in timeline"},"calview.densityReset":{zh:"恢复默认密度",en:"Reset to default density"},"calview.empty":{zh:"还没有日历事件。点「新建」,或在右栏添加一个含日期属性的多维表。",en:'No calendar events yet. Click "New", or add a database with a date property in the right panel.'},"calview.emptyNoDb":{zh:"还没有日历。在右栏点「添加日历」,选一个含日期属性的多维表。",en:'No calendars yet. Use "Add calendar" in the right panel to pick a database with a date property.'},"calview.allDay":{zh:"全天",en:"All-day"},"calview.a11yAllDayEvent":{zh:"{title},全天事件",en:"{title}, all-day event"},"calview.allDayDragHint":{zh:"{title}(可拖入时间格设为定时)",en:"{title} (drag into a time slot to schedule it)"},"calview.a11yEvent":{zh:"{title},{time}",en:"{title}, {time}"},"calview.a11yEventRange":{zh:"{title},{start} 至 {end}",en:"{title}, {start} to {end}"},"calview.monthFirst":{zh:"{m}月1",en:"{m}/1"},"calview.moreItems":{zh:"还有 {n} 项",en:"{n} more"},"calview.a11yMoreEvents":{zh:"查看 {m} 月 {d} 日全部 {n} 个事件",en:"View all {n} events on {m}/{d}"},"calview.a11yDayEvents":{zh:"{m} 月 {d} 日事件",en:"Events on {m}/{d}"},"calview.dayHeading":{zh:"{m} 月 {d} 日",en:"{m}/{d}"},"calview.closeAgenda":{zh:"关闭日程列表",en:"Close agenda list"}});const le=26,_e=8.4,ge=150,Ze=40;function Hn(e,t,o){const i=[];return e.forEach(({db:u,dateCol:C},j)=>{if(zt(t,o,u.path))return;const y=Et(t,o,u.path,j);for(const $ of u.rows){const l=typeof $.cells[C]=="string"?$.cells[C]:"",d=Dt(l);d&&i.push({key:`${u.path}::${$.rowId}`,color:y,db:u,row:$,colId:C,title:$.name,raw:l,start:me(d.start),end:d.end?me(d.end):null,allDay:d.allDay,readonly:u.readonly&&!u.writeCell})}}),i}const _=e=>`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`,oe=e=>{const t=e.currentTarget,o=t.getBoundingClientRect();return{left:o.left,top:o.top,right:o.right,bottom:o.bottom,zoom:xe(t)||1}},Kn=(e,t,o)=>t?`${Z(e,o)}/${Z(t,o)}`:Z(e,o),Me=(e,t,o)=>tt(e.db,e.row.rowId,e.colId,Kn(t,o,e.allDay)),Ce=e=>({"--amx-event-color":e}),ut=(e,t)=>{const o=J(t).getTime(),i=J(e.start).getTime()<o,u=J(e.end??e.start).getTime()>o;return`${i?" continues-left":""}${u?" continues-right":""}`};function ts(){const{t:e}=ze(),t=ft(),o=mt(),i=ht(),u=pt(),C=yt(),j=kt(),y=gt(f=>f.vaultRoot)??"",$=bt(f=>f.byVault),l=ee(f=>f.mode),d=ee(f=>f.setMode),p=ee(f=>f.hourPx),v=ee(f=>f.setHourPx),S=ee(f=>f.jumpNonce),[z,E]=s.useState(null),k=s.useRef(null),L=s.useRef(null),H=s.useRef(null);s.useEffect(()=>{l!=="month"&&(H.current=null)},[l]);const A=s.useRef(null),T=s.useRef(null);s.useEffect(()=>{if(!S)return;const f=ee.getState().jumpDate;f&&L.current?.goto(me(f))},[S]),vt();const P=s.useMemo(()=>[...o.map(f=>({db:f.db,dateCol:f.dateCol})),...[...i,...u,...C,...j].map(f=>({db:f,dateCol:wt(f)?.id})).filter(f=>!!f.dateCol)],[o,i,u,C,j]),h=s.useMemo(()=>Hn(P,y,$),[P,y,$]),D=s.useMemo(()=>h.map(f=>f.title?f:{...f,title:e("calview.untitled")}),[h,e]),R=z?h.find(f=>f.key===z.key)??null:null;A.current=R;const c=(f,N)=>E({key:f,at:N}),x=()=>{const f=Tt(y,$),N=o.find(W=>W.db.path===f)??o.find(W=>!W.db.isNoteView)??o[0]??null;return N?{db:N.db,dateCol:N.dateCol}:null},g=x(),w=async(f,N,W)=>{const O=x();if(!O)return;const{db:G,dateCol:ne}=O;let a;if(N===null)a=Z(f,!0);else{const m=V(J(f),N);a=`${Z(m,!1)}/${Z(V(m,30),!1)}`}const r=await Nt(G,ne,a,e("calview.newEventTitle"));c(`${G.path}::${r}`,W)};s.useEffect(()=>{const f=N=>{const W=N.target;if(W&&W.closest("input, textarea, select, [contenteditable]"))return;const O=qn(N);if(!O)return;const G=A.current;switch(O.kind){case"copy":G&&!G.readonly&&(T.current={db:G.db,rowId:G.row.rowId});break;case"paste":T.current&&St(T.current.db,T.current.rowId);break;case"delete":G&&!G.readonly&&(Yt(G.db,G.row,G.title),E(null));break;case"prev":L.current?.prev();break;case"next":L.current?.next();break;case"mode":ee.getState().setMode(O.mode);break}N.preventDefault()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[]);const q=s.useRef(null),[K,Y]=s.useState(7);s.useLayoutEffect(()=>{const f=q.current;if(!f)return;const N=()=>{const O=f.clientWidth-52;Y(O>=784?7:O>=396?3:1)};N();const W=new ResizeObserver(N);return W.observe(f),()=>W.disconnect()},[]);const F=Math.min(l==="week"?7:l==="3day"?3:1,K);return n.jsxs("div",{className:"amx-cal",ref:q,children:[n.jsx(Gt,{children:n.jsxs("header",{className:"amx-cal-bar",children:[n.jsx("div",{className:"amx-cal-nav",children:n.jsx("span",{className:"amx-cal-title",ref:k})}),n.jsxs("div",{className:"amx-cal-modes",children:[n.jsx(ce,{size:"sm",variant:"primary",icon:n.jsx(Jt,{size:14}),label:e("calview.new"),isDisabled:!g,tooltip:g?e("calview.newInto",{name:g.db.name}):e("calview.noDbHint"),onClick:f=>{const N=new Date,W=V(J(N),be(N.getHours()*60+N.getMinutes()+15)),O=oe(f);w(J(W),W.getHours()*60+W.getMinutes(),O)}}),n.jsx(ce,{size:"sm",variant:"secondary",label:e("calview.today"),onClick:()=>L.current?.today()}),n.jsx(ce,{size:"sm",variant:"ghost",isIconOnly:!0,icon:n.jsx(jt,{size:14}),label:e("calview.prevPage"),onClick:()=>L.current?.prev()}),n.jsx(ce,{size:"sm",variant:"ghost",isIconOnly:!0,icon:n.jsx($t,{size:14}),label:e("calview.nextPage"),onClick:()=>L.current?.next()}),n.jsx(Se,{button:{label:Ne.find(f=>f.id===l)?.label??"周",variant:"secondary",size:"sm"},menuWidth:168,children:Ne.map(f=>n.jsx(ie,{icon:l===f.id?n.jsx(Mt,{size:14}):n.jsx("span",{style:{display:"inline-block",width:14}}),label:f.label,endContent:n.jsx(it,{keys:f.key}),onClick:()=>d(f.id)},f.id))}),l!=="month"&&n.jsx("span",{className:"amx-cal-density",children:n.jsxs(Se,{button:{label:e("calview.density"),variant:"ghost",size:"sm"},menuWidth:176,children:[n.jsx(ie,{icon:n.jsx(Xt,{size:14}),label:e("calview.zoomOut"),onClick:()=>v(p-8)}),n.jsx(ie,{icon:n.jsx(Ut,{size:14}),label:e("calview.zoomIn"),onClick:()=>v(p+8)}),n.jsx(ie,{icon:n.jsx(_t,{size:14}),label:e("calview.densityReset"),endContent:`${p}px`,onClick:()=>v(Bt)})]})})]})]})}),D.length===0&&n.jsx("div",{className:"amx-cal-empty",children:e(g?"calview.empty":"calview.emptyNoDb")}),l==="month"?n.jsx(On,{ref:L,anchorRef:H,events:D,selectedKey:z?.key??null,onPick:c,onCreate:(f,N)=>{w(f,null,N)},titleRef:k},`dow${t}`):n.jsx(Fn,{ref:L,n:F,weekStartDow:l==="week"&&F===7?t:null,events:D,selectedKey:z?.key??null,onPick:c,onCreate:(f,N,W)=>{w(f,N,W)},titleRef:k}),R&&z&&n.jsx(Vt,{ev:R,at:z.at,onClose:()=>E(null)})]})}const Fn=s.forwardRef(function({n:t,weekStartDow:o,events:i,selectedKey:u,onPick:C,onCreate:j,titleRef:y},$){const{t:l}=ze(),d=s.useRef(null),p=s.useRef(null),[v,S]=s.useState(0),[z,E]=s.useState(0),k=ee(a=>a.hourPx),L=ee(a=>a.setVisibleRange),H=()=>{p.current&&d.current&&(p.current.style.transform=`translateY(${-d.current.scrollTop}px)`)},A=s.useMemo(()=>J(new Date),[]),T=s.useMemo(()=>{const a=ae(A,-ge);return Array.from({length:ge*2+1},(r,m)=>ae(a,m))},[A]),P=a=>o==null?a:Math.max(0,a-(T[a].getDay()-o+7)%7),h=s.useRef(ge),D=s.useRef(void 0),R=s.useRef(!1),c=s.useRef(""),x=s.useRef(-1),g=s.useRef(null),w=()=>{g.current&&(g.current.style.display="none")},q=s.useRef(null),[K,Y]=s.useState(()=>{const a=new Date;return a.getHours()*60+a.getMinutes()});s.useEffect(()=>{const a=setInterval(()=>{const r=new Date;Y(r.getHours()*60+r.getMinutes())},3e4);return()=>clearInterval(a)},[]),s.useEffect(()=>()=>L(null,null),[L]);const F=()=>{const a=d.current;if(!a||!v)return;const r=Math.max(0,Math.min(T.length-t,Math.round(a.scrollLeft/v)));h.current=r;const m=It(Qe(T[r],t));m!==c.current&&(c.current=m,y.current&&(y.current.textContent=m)),r*8+t!==x.current&&(x.current=r*8+t,L(Z(T[r],!0),Z(T[Math.min(T.length-1,r+t-1)],!0)))};s.useLayoutEffect(()=>{const a=d.current;if(!a)return;const r=t===7?112:t===3?132:180,m=()=>S(Math.max(r,a.clientWidth/t));m();const M=new ResizeObserver(m);return M.observe(a),()=>M.disconnect()},[t]),s.useLayoutEffect(()=>{const a=d.current;if(!a)return;const r=a.querySelector(".amx-cal-daycol2");r&&E(Math.max(0,r.offsetTop-(le+14)))},[i,v,t]),s.useLayoutEffect(()=>{const a=d.current;if(!(!a||!v)){if(!R.current){h.current=ge,R.current=!0;const r=a.querySelector(".amx-cal-daycol2"),m=r?r.offsetTop:le+14;a.scrollTop=Math.max(0,m+K/60*k-a.clientHeight/2)}D.current!==o&&(D.current=o,h.current=P(h.current)),a.scrollLeft=h.current*v,F(),H()}},[v,o]);const f=s.useRef(k);s.useLayoutEffect(()=>{const a=d.current,r=f.current;if(f.current=k,!a||r===k)return;const m=a.querySelector(".amx-cal-daycol2"),M=m?m.offsetTop:le+14,b=a.clientHeight/2,I=(a.scrollTop+b-M)/r;a.scrollTop=Math.max(0,M+I*k-b),H()},[k]),s.useEffect(()=>{const a=d.current;if(!a)return;const r=m=>{if(!m.ctrlKey&&!m.metaKey)return;m.preventDefault();const M=ee.getState();M.setHourPx(M.hourPx*(m.deltaY<0?1.12:1/1.12))};return a.addEventListener("wheel",r,{passive:!1}),()=>a.removeEventListener("wheel",r)},[]),s.useImperativeHandle($,()=>({prev:()=>d.current?.scrollBy({left:-t*v,behavior:"smooth"}),next:()=>d.current?.scrollBy({left:t*v,behavior:"smooth"}),today:()=>d.current?.scrollTo({left:P(ge)*v,behavior:"smooth"}),goto:a=>{if(!v)return;const r=Math.min(T.length-t,P(Math.max(0,Math.min(T.length-1,$e(J(a),T[0])))));d.current?.scrollTo({left:r*v,behavior:"smooth"})}}),[t,v,T,o]);const N=(a,r)=>{if(r.stopPropagation(),a.readonly)return;const m=r.currentTarget,M=m.getBoundingClientRect(),b=xe(m)||1,I=(r.clientY-M.top)/b,B=I<_e?"start":M.height/b-I<_e?"end":"move",te=We(a.start,a.end,k),X=Math.max(14,te.height),ue=m.querySelector(".amx-cal-event-t");m.setPointerCapture(r.pointerId),m.classList.add("dragging"),q.current={mode:B,ev:a,el:m,tEl:ue,t0:ue?.textContent??"",x0:r.clientX,y0:r.clientY,zoom:b,top0:te.top,h0:X,grabOffY:I,durMin:Math.round(X/k*60),msDur:a.end?a.end.getTime()-a.start.getTime():0,dyMin:0,moved:!1,target:null}},W=a=>{const r=q.current;if(!r)return;if(r.mode==="move"){const b=(a.clientX-r.x0)/r.zoom,I=(a.clientY-r.y0)/r.zoom;(Math.abs(b)>3||Math.abs(I)>3)&&(r.moved=!0),r.el.style.transform=`translate(${b}px, ${I}px)`;const B=d.current;if(!B||!v)return;const te=B.getBoundingClientRect(),X=xe(B)||1,ue=Math.max(0,Math.min(T.length-1,Math.floor(((a.clientX-te.left)/X+B.scrollLeft)/v))),Le=le+14+z,dt=(a.clientY-te.top)/X-r.grabOffY+B.scrollTop-Le,Ee=Math.max(0,Math.min(1440-r.durMin,be(dt/k*60)));r.target={iso:Z(T[ue],!0),topMin:Ee};const se=g.current;if(se&&(se.style.display="block",se.style.left=`${ue*v}px`,se.style.width=`${v}px`,se.style.top=`${Le+Ee/60*k}px`,se.style.height=`${r.h0}px`),r.moved){const De=V(J(T[ue]),Ee),Pe=r.msDur?`${_(De)}–${_(new Date(De.getTime()+r.msDur))}`:_(De);r.tEl&&(r.tEl.textContent=Pe),se&&(se.textContent=Pe)}return}const m=be((a.clientY-r.y0)/r.zoom/k*60);r.dyMin=m;const M=m/60*k;if(r.mode==="end"?r.el.style.height=`${Math.max(14,r.h0+M)}px`:(r.el.style.top=`${r.top0+M}px`,r.el.style.height=`${Math.max(14,r.h0-M)}px`),m!==0&&r.tEl){const b=r.ev.end??V(r.ev.start,60);if(r.mode==="end"){let I=V(b,m);I.getTime()<=r.ev.start.getTime()&&(I=V(r.ev.start,15)),r.tEl.textContent=`${_(r.ev.start)}–${_(I)}`}else{let I=V(r.ev.start,m);I.getTime()>=b.getTime()&&(I=V(b,-15)),r.tEl.textContent=`${_(I)}–${_(b)}`}}},O=(a,r)=>{const m=q.current;if(q.current=null,!m){a.readonly&&C(a.key,oe(r));return}if(m.el.classList.remove("dragging"),m.mode==="move"){if(m.el.style.transform="",w(),!m.moved||!m.target){m.tEl&&(m.tEl.textContent=m.t0),m.moved||C(a.key,oe(r));return}const b=V(J(me(m.target.iso)),m.target.topMin);Me(a,b,a.end?new Date(b.getTime()+m.msDur):null);return}if(m.dyMin===0){m.tEl&&(m.tEl.textContent=m.t0);return}const M=a.end??V(a.start,60);if(m.mode==="end"){let b=V(M,m.dyMin);b.getTime()<=a.start.getTime()&&(b=V(a.start,15)),Me(a,a.start,b)}else{let b=V(a.start,m.dyMin);b.getTime()>=M.getTime()&&(b=V(M,-15)),Me(a,b,M)}},G=a=>{a.stopPropagation(),a.currentTarget.setPointerCapture(a.pointerId)},ne=(a,r)=>{if(a.readonly){C(a.key,oe(r));return}const m=document.elementFromPoint(r.clientX,r.clientY)?.closest(".amx-cal-daycol2"),M=m?.getAttribute("data-date");if(m&&M){const b=m.getBoundingClientRect(),I=Math.max(0,Math.min(1410,be((r.clientY-b.top)/(xe(m)||1)/k*60))),B=V(J(me(M)),I);tt(a.db,a.row.rowId,a.colId,`${Z(B,!1)}/${Z(V(B,30),!1)}`);return}C(a.key,oe(r))};return n.jsxs("div",{className:"amx-cal-timerow",style:{"--amx-hour-px":`${k}px`},children:[n.jsx("div",{className:"amx-cal-gutterfixed",children:n.jsxs("div",{className:"amx-cal-gutterinner",children:[n.jsx("div",{className:"amx-cal-gcorner",style:{height:le+14}}),n.jsx("div",{className:"amx-cal-gallday",style:{height:z},children:l("calview.allDay")}),n.jsxs("div",{className:"amx-cal-ghours",ref:p,children:[qe.map(a=>n.jsx("div",{className:"amx-cal-hour",style:{height:k},children:a===0?"":`${a}:00`},a)),n.jsxs("span",{className:"amx-cal-nowlabel",style:{top:K/60*k},children:[String(Math.floor(K/60)).padStart(2,"0"),":",String(K%60).padStart(2,"0")]})]})]})}),n.jsx("div",{className:"amx-cal-tscroll",ref:d,onScroll:()=>{F(),H()},children:n.jsxs("div",{className:"amx-cal-tgrid2",style:{gridTemplateColumns:`repeat(${T.length}, ${v}px)`,gridTemplateRows:`${le+14}px auto ${qe.length*k}px`},children:[T.map(a=>n.jsxs("div",{className:`amx-cal-thead2${fe(a,A)?" today":""}`,children:[n.jsx("span",{className:"amx-cal-tdow",children:Rt(a.getDay())}),n.jsxs("span",{className:"amx-cal-tdate",children:[a.getMonth()+1,"/",a.getDate()]})]},+a)),T.map(a=>n.jsx("div",{className:"amx-cal-allday2",children:i.filter(r=>r.allDay&&et(r.start,r.end,a)).map(r=>n.jsx("button",{className:`amx-cal-chip-ev amx-cal-alldrag${r.readonly?" readonly":""}${u===r.key?" selected":""}${ut(r,a)}`,style:Ce(r.color),"aria-label":l("calview.a11yAllDayEvent",{title:r.title}),title:r.readonly?r.title:l("calview.allDayDragHint",{title:r.title}),onPointerDown:G,onPointerUp:m=>ne(r,m),children:r.title},r.key))},+a)),T.map(a=>n.jsxs("div",{className:"amx-cal-daycol2","data-date":Z(a,!0),onDoubleClick:r=>{if(r.target.closest(".amx-cal-event"))return;const m=r.currentTarget.getBoundingClientRect(),M=xe(r.currentTarget)||1,b=Math.max(0,Math.min(1410,be((r.clientY-m.top)/M/k*60)));j(a,b,{left:r.clientX,top:r.clientY,right:r.clientX,bottom:r.clientY,zoom:M})},children:[(()=>{const r=i.filter(M=>!M.allDay&&fe(M.start,a)),m=Wn(r);return r.map(M=>{const b=We(M.start,M.end,k),I=m.get(M.key)??{leftPct:0,widthPct:100};return n.jsxs("button",{className:`amx-cal-event${M.readonly?" readonly":""}${u===M.key?" selected":""}`,style:{...Ce(M.color),top:b.top,height:Math.max(14,b.height),left:`calc(${I.leftPct}% + 2px)`,width:`calc(${I.widthPct}% - 4px)`},"aria-label":M.end?l("calview.a11yEventRange",{title:M.title,start:_(M.start),end:_(M.end)}):l("calview.a11yEvent",{title:M.title,time:_(M.start)}),title:M.title,onPointerDown:B=>N(M,B),onPointerMove:W,onPointerUp:B=>O(M,B),children:[n.jsxs("span",{className:"amx-cal-event-t",children:[_(M.start),M.end?`–${_(M.end)}`:""]}),n.jsx("span",{className:"amx-cal-event-title",children:M.title})]},M.key)})})(),n.jsx("div",{className:`amx-cal-nowline${fe(a,A)?" today":""}`,style:{top:K/60*k}})]},+a)),n.jsx("div",{className:"amx-cal-dropghost",ref:g})]})})]})}),On=s.forwardRef(function({anchorRef:t,events:o,selectedKey:i,onPick:u,onCreate:C,titleRef:j},y){const{t:$}=ze(),l=s.useRef(null),[d,p]=s.useState(0),v=ee(c=>c.setVisibleRange),S=s.useMemo(()=>J(new Date),[]),z=s.useMemo(()=>{const c=ae(Te(S),-Ze*7);return Array.from({length:Ze*2+1},(x,g)=>ae(c,g*7))},[S]),E=s.useRef(!1),[k,L]=s.useState(null),H=s.useRef(""),A=s.useRef(-1);s.useEffect(()=>()=>v(null,null),[v]);const T=(c,x)=>Math.round($e(Te(new Date(c,x,1)),z[0])/7),P=()=>{const c=l.current;if(!c||!d)return;const x=Math.max(0,Math.min(z.length-1,Math.round(c.scrollTop/d))),g=ae(z[x],3),w=At(g);if(t&&(t.current={y:g.getFullYear(),m:g.getMonth()}),w!==H.current&&(H.current=w,j.current&&(j.current.textContent=w)),x!==A.current){A.current=x;const q=Math.max(1,Math.round(c.clientHeight/d)),K=z[Math.min(z.length-1,x+q-1)];v(Z(z[x],!0),Z(ae(K,6),!0))}};s.useLayoutEffect(()=>{const c=l.current;if(!c)return;const x=()=>p(Math.max(64,(c.clientHeight-le)/6));x();const g=new ResizeObserver(x);return g.observe(c),()=>g.disconnect()},[]),s.useLayoutEffect(()=>{const c=l.current;if(!c||!d||E.current)return;E.current=!0;const x=t?.current;if(x){let g=Math.max(0,Math.min(z.length-1,T(x.y,x.m)));ae(z[g],3).getMonth()!==x.m&&g+1<z.length&&(g+=1),c.scrollTop=g*d}else c.scrollTop=T(S.getFullYear(),S.getMonth())*d;P()},[d]),s.useImperativeHandle(y,()=>({prev:()=>h(-1),next:()=>h(1),today:()=>l.current?.scrollTo({top:T(S.getFullYear(),S.getMonth())*d,behavior:"smooth"}),goto:c=>{if(!d)return;const x=Math.max(0,Math.min(z.length-1,Math.round($e(Te(c),z[0])/7)));l.current?.scrollTo({top:x*d,behavior:"smooth"})}}),[d]);const h=c=>{const x=l.current;if(!x||!d)return;const g=Math.max(0,Math.min(z.length-1,Math.round(x.scrollTop/d))),w=ae(z[g],3);x.scrollTo({top:Math.max(0,T(w.getFullYear(),w.getMonth()+c))*d,behavior:"smooth"})},D=c=>{c.stopPropagation(),c.currentTarget.setPointerCapture(c.pointerId)},R=(c,x)=>{const g=oe(x);if(c.readonly){u(c.key,g);return}const q=document.elementFromPoint(x.clientX,x.clientY)?.closest(".amx-cal-mcell")?.getAttribute("data-date");if(q){const K=$e(me(q),c.start);if(K!==0){Me(c,He(c.start,K),c.end?He(c.end,K):null);return}}u(c.key,g)};return n.jsxs("div",{className:"amx-cal-mscroll",ref:l,onScroll:P,children:[n.jsx("div",{className:"amx-cal-weekhead2",children:Ct().map(c=>n.jsx("div",{children:c},c))}),n.jsx("div",{className:"amx-cal-mweeks",children:z.map(c=>n.jsx("div",{className:"amx-cal-mweek",style:{height:d},children:Qe(c,7).map(x=>{const g=o.filter(w=>et(w.start,w.end,x));return n.jsxs("div",{className:`amx-cal-mcell${fe(x,S)?" today":""}`,"data-date":Z(x,!0),onDoubleClick:w=>{w.target.closest(".amx-cal-chip-ev")||C(x,{left:w.clientX,top:w.clientY,right:w.clientX,bottom:w.clientY,zoom:xe(w.currentTarget)||1})},children:[n.jsx("div",{className:"amx-cal-mnum",children:x.getDate()===1?$("calview.monthFirst",{m:x.getMonth()+1}):x.getDate()}),g.slice(0,3).map(w=>n.jsxs("button",{className:`amx-cal-chip-ev${w.readonly?" readonly":""}${i===w.key?" selected":""}${ut(w,x)}`,style:Ce(w.color),title:w.title,"aria-label":!w.allDay&&fe(w.start,x)?$("calview.a11yEvent",{title:w.title,time:_(w.start)}):w.title,onPointerDown:D,onPointerUp:q=>R(w,q),children:[!w.allDay&&fe(w.start,x)&&n.jsx("span",{className:"amx-cal-chip-t",children:_(w.start)})," ",w.title]},w.key)),g.length>3&&n.jsx("button",{className:"amx-cal-more","aria-label":$("calview.a11yMoreEvents",{m:x.getMonth()+1,d:x.getDate(),n:g.length}),onClick:w=>L({day:x,events:g,at:oe(w)}),children:$("calview.moreItems",{n:g.length-3})})]},+x)})},+c))}),k&&n.jsx(Gn,{day:k.day,events:k.events,at:k.at,onPick:(c,x)=>{L(null),u(c,x)},onClose:()=>L(null)})]})});function Gn({day:e,events:t,at:o,onPick:i,onClose:u}){const{t:C}=ze(),j=292,y=o.zoom||1,$=12*y,l=Math.max($,Math.min(o.left,window.innerWidth-j*y-$))/y,d=Math.max($,Math.min(o.bottom+6*y,window.innerHeight-356*y-$))/y,p=s.useRef(null),v=s.useRef(u);return v.current=u,s.useEffect(()=>{const S=document.activeElement instanceof HTMLElement?document.activeElement:null;p.current?.querySelector(".amx-cal-agenda-list > button")?.focus();const z=E=>{E.key==="Escape"&&(E.preventDefault(),v.current())};return window.addEventListener("keydown",z),()=>{window.removeEventListener("keydown",z),S?.focus()}},[]),n.jsx("div",{className:"amx-cal-agenda-overlay",onMouseDown:u,children:n.jsxs("section",{className:"amx-cal-agenda",ref:p,role:"dialog","aria-modal":"true","aria-label":C("calview.a11yDayEvents",{m:e.getMonth()+1,d:e.getDate()}),style:{left:l,top:d,width:j},onMouseDown:S=>S.stopPropagation(),children:[n.jsxs("header",{children:[n.jsx("strong",{children:C("calview.dayHeading",{m:e.getMonth()+1,d:e.getDate()})}),n.jsx("button",{onClick:u,"aria-label":C("calview.closeAgenda"),children:"×"})]}),n.jsx("div",{className:"amx-cal-agenda-list",children:t.map(S=>n.jsxs("button",{style:Ce(S.color),onClick:z=>i(S.key,oe(z)),children:[n.jsx("span",{className:"amx-cal-agenda-time",children:S.allDay?C("calview.allDay"):_(S.start)}),n.jsx("span",{children:S.title})]},S.key))})]})})}export{ts as CalendarView,On as MonthScroll};