@forsion/unit 2.13.5 → 2.13.6

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 (179) hide show
  1. package/README.md +2 -2
  2. package/main.mjs +20 -4
  3. package/package.json +1 -1
  4. package/release.json +6 -5
  5. package/web/assets/{ArtificialView-BD1yHz1N.js → ArtificialView-DHqb9CTL.js} +1 -1
  6. package/web/assets/{AutomationBuilder-B09c-5Bi.js → AutomationBuilder-CzBKmOiw.js} +1 -1
  7. package/web/assets/{CalendarConfigView-Bd-ZDGPO.js → CalendarConfigView-Blw47NCs.js} +1 -1
  8. package/web/assets/CalendarSide-CFSzme3H.js +1 -0
  9. package/web/assets/CalendarView-B8sQfgZt.js +3 -0
  10. package/web/assets/{CapabilityMenu-DyHTEYLr.js → CapabilityMenu-Dzn6RbB1.js} +1 -1
  11. package/web/assets/{Chrome-C7F6fdDp.js → Chrome-owLewFu4.js} +1 -1
  12. package/web/assets/{CodeView-BGOnrGhB.js → CodeView-E18NDilX.js} +3 -3
  13. package/web/assets/{CtxMenuButtons-BYjrbUKS.js → CtxMenuButtons-CAiwQkOK.js} +1 -1
  14. package/web/assets/DashboardGridView-CBbYKcCo.js +25 -0
  15. package/web/assets/EventCard-D9uQe7g4.js +1 -0
  16. package/web/assets/{ExcalidrawCanvas-lwJCN6uB.js → ExcalidrawCanvas-BSOERegJ.js} +1 -1
  17. package/web/assets/{FloatingToc-DO7SH8Ku.js → FloatingToc-iK08Qpjc.js} +1 -1
  18. package/web/assets/GitCloneDialog-DfY0kqhP.js +1 -0
  19. package/web/assets/{HomepageView-CHJEhf9c.js → HomepageView-BCqFe1Ym.js} +3 -3
  20. package/web/assets/{ImageStudioPanels-CgVf0wiq.js → ImageStudioPanels-DdwihAkT.js} +2 -2
  21. package/web/assets/ImageStudioView-gJSYrmu1.js +1 -0
  22. package/web/assets/{InlineAiPanel-CdIPINsA.js → InlineAiPanel-CjYOW0_0.js} +1 -1
  23. package/web/assets/InlineFiles-3g2jMUeA.js +1 -0
  24. package/web/assets/{MarkdownBlock-DSItkLhu.js → MarkdownBlock-DjsGkPZ_.js} +24 -24
  25. package/web/assets/{ModelPill--CU3XTIQ.js → ModelPill-DgyXBsL9.js} +2 -2
  26. package/web/assets/MuseLibraryView-D_HBijmU.js +2 -0
  27. package/web/assets/{MuseView-CvsO62Fo.js → MuseView-BVDlmM6i.js} +3 -3
  28. package/web/assets/{PageHistoryPanel-CDh7nm78.js → PageHistoryPanel-B1EAPZeX.js} +2 -2
  29. package/web/assets/{PdfAnnotator-DafvjP3U.js → PdfAnnotator-bdB9evsY.js} +1 -1
  30. package/web/assets/{PenRow-CEy-s6SF.js → PenRow-DCOIGlfY.js} +1 -1
  31. package/web/assets/PluginToolCard-BXE5vA1h.js +2 -0
  32. package/web/assets/{ProductView-AUqnTwmQ.js → ProductView-l5Q7uBy6.js} +1 -1
  33. package/web/assets/{SettingsPage-B9mmkWaM.js → SettingsPage-fjxfS_Mt.js} +2 -2
  34. package/web/assets/{StudioGuestSurface-OOhRA8nt.js → StudioGuestSurface-360CWUwf.js} +1 -1
  35. package/web/assets/TodoListView-BsPt2GUU.js +1 -0
  36. package/web/assets/{Tooltip-DOYi44eY.js → Tooltip-CuXpWtdJ.js} +1 -1
  37. package/web/assets/UnifiedPage-6xbFLtXT.js +712 -0
  38. package/web/assets/{ViewSelectionBar-WmSWMFsR.js → ViewSelectionBar-C5FDh7fO.js} +2 -2
  39. package/web/assets/{appStore-DDOkzWDA.js → appStore-BskcSDl6.js} +114 -115
  40. package/web/assets/{arrow-up-right-BptN64d-.js → arrow-up-right-DEykpgsH.js} +1 -1
  41. package/web/assets/{astryxBridge-BL56QfEv.js → astryxBridge-B2IZdPvo.js} +1 -1
  42. package/web/assets/automationListSource-Cm09JKkK.js +1 -0
  43. package/web/assets/{boardSurface-CP4HNmcm.js → boardSurface-Dv-aVaUJ.js} +1 -1
  44. package/web/assets/{calendarNavStore-DCi7VBmM.js → calendarNavStore-FKStA7Hh.js} +1 -1
  45. package/web/assets/{canvasPrefs-ArsX3NFO.js → canvasPrefs-CMulOS0k.js} +1 -1
  46. package/web/assets/{chatBoxSurface-DRsDr-MT.js → chatBoxSurface-BR_G6cxG.js} +1 -1
  47. package/web/assets/{chevron-up-ChXNh14u.js → chevron-up-C_EDOZzI.js} +1 -1
  48. package/web/assets/{client-fKy9CWk0.js → client-DD5czSuF.js} +1 -1
  49. package/web/assets/{code-xml-DCCD9eCS.js → code-xml-vTB4LtTf.js} +1 -1
  50. package/web/assets/{codeStudioStore-BgLfCDK2.js → codeStudioStore-OswE1_s0.js} +1 -1
  51. package/web/assets/{contextMenuSurface-BF593l2M.js → contextMenuSurface-DqdYEGuH.js} +1 -1
  52. package/web/assets/{copy-plus-ClKrSgM7.js → copy-plus-CVHqDNny.js} +1 -1
  53. package/web/assets/create-DZWy4zBR.js +14 -0
  54. package/web/assets/{dashboardSurface-C6cbR3oG.js → dashboardSurface-Co4byEQm.js} +1 -1
  55. package/web/assets/dbStore-Bc2lC8ZI.js +2 -0
  56. package/web/assets/deskCapture-BfTzH2aO.js +1 -0
  57. package/web/assets/{diff2html-Di8qIz6O.js → diff2html-0MkNy2ws.js} +1 -1
  58. package/web/assets/{docx-preview-B-URZXdP.js → docx-preview-CwNWZegI.js} +1 -1
  59. package/web/assets/{draft-CBSW5tHx.js → draft-DTzuTatQ.js} +2 -2
  60. package/web/assets/{drawingStore-CGvTqqYW.js → drawingStore-BD5m2eqn.js} +1 -1
  61. package/web/assets/{file-down-Z913cCyQ.js → file-down-Cjo_T6By.js} +1 -1
  62. package/web/assets/{floatingTocSurface-DGwTiqvU.js → floatingTocSurface-D3IIVNnq.js} +1 -1
  63. package/web/assets/{foldActions-DGIPTmE1.js → foldActions-utwZpRrA.js} +1 -1
  64. package/web/assets/{folder-1OJQeDI1.js → folder-DiaFWdCg.js} +1 -1
  65. package/web/assets/{folder-minus-D_j1SwHu.js → folder-minus-DUEOcs12.js} +1 -1
  66. package/web/assets/{folder-plus-DP9sFr26.js → folder-plus-Cmhq0GcR.js} +1 -1
  67. package/web/assets/{gestures-ZhFAENNZ.js → gestures-Bx9M0le5.js} +1 -1
  68. package/web/assets/{git-branch-BMajF2cu.js → git-branch-DzGWffyD.js} +1 -1
  69. package/web/assets/{homeCardStatus-5R7XkxFL.js → homeCardStatus-NAk4A77P.js} +1 -1
  70. package/web/assets/{i18n.generated-DW_l6CkR.js → i18n.generated-D4-Wu9Wh.js} +1 -1
  71. package/web/assets/imageStudio-D67oElIb.js +4 -0
  72. package/web/assets/{index-COzdD7mZ.js → index-3VWZ1rsL.js} +1 -1
  73. package/web/assets/{index-bF04pF8q.js → index-58wBjkHy.js} +1 -1
  74. package/web/assets/{index-Cg1FWM_p.js → index-B9_zH7f5.js} +1 -1
  75. package/web/assets/index-BQrMYjou.js +1 -0
  76. package/web/assets/{index-D-ClOPbg.js → index-BWrWMYua.js} +1 -1
  77. package/web/assets/{index-C--E96Ul.js → index-BdLJBf4-.js} +1 -1
  78. package/web/assets/{index-CI2esW1X.js → index-Bf3W92Hb.js} +1 -1
  79. package/web/assets/{index-B8A3nKeL.js → index-BjmPaLFA.js} +1 -1
  80. package/web/assets/{index-BeW45J9J.js → index-Bv-vJTzF.js} +1 -1
  81. package/web/assets/{index-BnJguNqI.js → index-C7yb62gg.js} +1 -1
  82. package/web/assets/{index-CtRdzpNh.js → index-C9gBBMYv.js} +1 -1
  83. package/web/assets/index-CiQ59Kib.js +1 -0
  84. package/web/assets/{index-DfhEDV2T.js → index-CzTUjEMt.js} +1 -1
  85. package/web/assets/{index-BYKR7EVg.js → index-D4Qx6o3E.js} +1 -1
  86. package/web/assets/{index-jzlU5luC.js → index-DDBcn3UD.js} +1 -1
  87. package/web/assets/{index-CtCYv9bF.js → index-DEADY94l.js} +1 -1
  88. package/web/assets/{index-CWXpOSI2.js → index-DGTKsPAQ.js} +1 -1
  89. package/web/assets/{index-SpegRFQV.js → index-DRwDqvjf.js} +1 -1
  90. package/web/assets/{index-BDZIQnEx.js → index-DexVkoxH.js} +1 -1
  91. package/web/assets/{index-uhvJ8AiJ.js → index-IMOhRWY8.js} +1 -1
  92. package/web/assets/{index-Dr6YmrrT.js → index-XjvpYHIo.js} +1 -1
  93. package/web/assets/{index-fDB1l4d-.js → index-YuejkHoJ.js} +51 -37
  94. package/web/assets/{index-CVLDDD5Z.js → index-pH0266gX.js} +1 -1
  95. package/web/assets/{index-BniT-A2n.js → index-sQl_bGM_.js} +1 -1
  96. package/web/assets/{index-CPfmhZ3Z.js → index-vbNFy5lS.js} +1 -1
  97. package/web/assets/{invitePage-iOT1zBvp.js → invitePage-BT_rFfab.js} +1 -1
  98. package/web/assets/{ipc-SAPDwyQ4.js → ipc-8cxXGSZK.js} +1 -1
  99. package/web/assets/{jszip.min-B3n1FGCb.js → jszip.min-By4OI3XR.js} +1 -1
  100. package/web/assets/launchpad-BX4jQyF4.js +2 -0
  101. package/web/assets/{layout-grid-oIyIGbc5.js → layout-grid-CzxXbCDa.js} +1 -1
  102. package/web/assets/{linkFollow-uke1Xtit.js → linkFollow-J2c0wSgB.js} +4 -4
  103. package/web/assets/{listFold-BeNv2v6M.js → listFold-B_2Xqxn_.js} +1 -1
  104. package/web/assets/{lock-open-D2nMg0ga.js → lock-open-DVWCLSZm.js} +1 -1
  105. package/web/assets/{log-out-D70NCXC4.js → log-out-CdKTS7HC.js} +1 -1
  106. package/web/assets/{magnet-Cqmm97W8.js → magnet-BmVcZ9U4.js} +1 -1
  107. package/web/assets/main-CForzSFD.js +15 -0
  108. package/web/assets/{markdownEditorSurface-zUzFity2.js → markdownEditorSurface-Bs8FJNHu.js} +1 -1
  109. package/web/assets/{mediaPlayer-DB4KUvua.js → mediaPlayer-O9pVRl_k.js} +1 -1
  110. package/web/assets/{message-square-plus-BvUfAAZm.js → message-square-plus-CspBv9iG.js} +1 -1
  111. package/web/assets/{messages-GQUjmbwW.js → messages-CG7ywZ-K.js} +1 -1
  112. package/web/assets/{minimize-2-CMhzL6ZW.js → minimize-2-Bq4vUin-.js} +1 -1
  113. package/web/assets/mobileEntry-CptXQ4Ov.js +13 -0
  114. package/web/assets/modelPickerSurface-C0SkjaPL.js +1 -0
  115. package/web/assets/{nativeDownload-DsGyUSJ5.js → nativeDownload-DlnT8U-y.js} +1 -1
  116. package/web/assets/{nativeSheetMenu--iihXNVd.js → nativeSheetMenu-CVC51DzC.js} +1 -1
  117. package/web/assets/{pageStore-ys8L4rjF.css → pageStore-BC6Z18n7.css} +1 -1
  118. package/web/assets/{pageStore-CyvNZEYX.js → pageStore-D_fKLv-o.js} +7 -7
  119. package/web/assets/{pageTree-Ci2qzrs1.js → pageTree-DtDKozTg.js} +3 -3
  120. package/web/assets/{pen-line-DC3lbEY1.js → pen-line-ho1GgAe2.js} +1 -1
  121. package/web/assets/{pen-tool-DD5_N4lZ.js → pen-tool-CV-FKFEZ.js} +1 -1
  122. package/web/assets/{pencil--sWwxHdP.js → pencil-BgF4Kiqp.js} +1 -1
  123. package/web/assets/{phoneList-DKRMxQHf.js → phoneList-BLVdQcXY.js} +1 -1
  124. package/web/assets/pluginChat-C6t6DWhY.js +2 -0
  125. package/web/assets/{react-b7FrqRQR.js → react-DOzedx9n.js} +1 -1
  126. package/web/assets/recordSurface-C9SRNjy4.js +1 -0
  127. package/web/assets/{redo-2-CqlqhWrI.js → redo-2-DWZTaEz-.js} +1 -1
  128. package/web/assets/{rotate-ccw-D8kni6Ni.js → rotate-ccw-CyZpL7MX.js} +1 -1
  129. package/web/assets/{selectionActions-DIq0xDm8.js → selectionActions-C2a8ImJm.js} +1 -1
  130. package/web/assets/selectionBarSurface-DaXlyy1s.js +1 -0
  131. package/web/assets/{sessionTitle-Ctp4iNKu.js → sessionTitle-BtZ1BteL.js} +1 -1
  132. package/web/assets/settingsPageSurface-Cg8FNZq3.js +1 -0
  133. package/web/assets/{sharePage-CY04XCAf.js → sharePage-vnghra3Q.js} +2 -2
  134. package/web/assets/{shareViewer-DweNF8Ch.js → shareViewer-CWJQHiV-.js} +1 -1
  135. package/web/assets/{star-B0sZEmbj.js → star-ZEpUQwnX.js} +1 -1
  136. package/web/assets/tableSurface-DfEdzVDn.js +1 -0
  137. package/web/assets/{tanguProbe-B8Qv2vcm.js → tanguProbe-BboOas-a.js} +6 -6
  138. package/web/assets/{terminalView-BLGdmdl7.js → terminalView-xp8ARBLi.js} +1 -1
  139. package/web/assets/{type-Dt7RNB9g.js → type-CMyP4cKt.js} +1 -1
  140. package/web/assets/{undo-2-QimgpLBn.js → undo-2-C4ZCsMsx.js} +1 -1
  141. package/web/assets/{unitAccount-DL3jfd84.js → unitAccount-DNxfGo3c.js} +1 -1
  142. package/web/assets/{unitBridge-BSsCy1zP.js → unitBridge-Bq0n1ZM6.js} +1 -1
  143. package/web/assets/{unitCloudTransport-CI_6H0TU.js → unitCloudTransport-CErylgEO.js} +1 -1
  144. package/web/assets/{unitOwnerAccess-CiQ7nD7E.js → unitOwnerAccess-7s-3dfNM.js} +1 -1
  145. package/web/assets/{unitShim-Dl2ksNp-.js → unitShim-BfheyIG8.js} +3 -3
  146. package/web/assets/{upload-Dy7svciS.js → upload-VtCrluEO.js} +1 -1
  147. package/web/assets/userSpaces-BpeYjLni.js +1 -0
  148. package/web/assets/viewportLock-cVUalJAI.js +738 -0
  149. package/web/assets/{zoom-in-DDEtY_Go.js → zoom-in-C7R8s9x-.js} +1 -1
  150. package/web/index.html +2 -2
  151. package/web/assets/CalendarSide-B0RVbOsg.js +0 -1
  152. package/web/assets/CalendarView-BHio-n_r.js +0 -3
  153. package/web/assets/DashboardGridView-CR-R_qV8.js +0 -25
  154. package/web/assets/EventCard-QyYorE1_.js +0 -1
  155. package/web/assets/GitCloneDialog-CbW-RJak.js +0 -1
  156. package/web/assets/ImageStudioView-4WcX0_V4.js +0 -1
  157. package/web/assets/InlineFiles-CAIyTk1n.js +0 -1
  158. package/web/assets/MuseLibraryView-PlS7HAlV.js +0 -2
  159. package/web/assets/PluginToolCard-DCzLhsCA.js +0 -2
  160. package/web/assets/TodoListView-BkgMe44I.js +0 -1
  161. package/web/assets/UnifiedPage-s7-tDSwG.js +0 -712
  162. package/web/assets/automationListSource-B1jz6q0t.js +0 -1
  163. package/web/assets/create-DYmVT68X.js +0 -14
  164. package/web/assets/dbStore-BIG5Mfh2.js +0 -1
  165. package/web/assets/deskCapture-q-jRDIcc.js +0 -1
  166. package/web/assets/imageStudio-DC_syDtx.js +0 -4
  167. package/web/assets/index-CIKPZc3Q.js +0 -1
  168. package/web/assets/index-CmsN2Zm2.js +0 -1
  169. package/web/assets/launchpad-CcmSwlJl.js +0 -2
  170. package/web/assets/main-B9aT0WXG.js +0 -15
  171. package/web/assets/mobileEntry-BnHzrdoC.js +0 -13
  172. package/web/assets/modelPickerSurface-Dtz40Ae2.js +0 -1
  173. package/web/assets/pluginChat-82zZt47Y.js +0 -2
  174. package/web/assets/recordSurface-vUX25Z8R.js +0 -1
  175. package/web/assets/selectionBarSurface-B94e5JW_.js +0 -1
  176. package/web/assets/settingsPageSurface-C9TA3mJg.js +0 -1
  177. package/web/assets/tableSurface-CSBYBw5P.js +0 -1
  178. package/web/assets/userSpaces-oMHIWgYe.js +0 -1
  179. package/web/assets/viewportLock-BZq5PTeN.js +0 -738
@@ -1 +0,0 @@
1
- import{t as w,a as q,u as R,r as N,j as t,a_ as J}from"./index-fDB1l4d-.js";import{u as X,ad as G,h as Q,a7 as Z}from"./pageStore-CyvNZEYX.js";import"./client-fKy9CWk0.js";import{pQ as O,eR as z,pR as S,pS as F,k$ as ee,pT as U,pU as P,pV as ae,pW as te,pX as I,pY as ne,pZ as B,p_ as se,p$ as D,q0 as V,oG as re,q1 as ce,q2 as le,q3 as ie,oF as oe,q4 as de,ow as _,m2 as H,q5 as ue,q6 as me,V as pe,eH as xe}from"./appStore-DDOkzWDA.js";import{u as T}from"./dbStore-BIG5Mfh2.js";import{n as K}from"./nativeDownload-DsGyUSJ5.js";import{C as he}from"./chevron-up-ChXNh14u.js";q({"calevtact.deleted":{zh:"已删除「{title}」",en:"Deleted “{title}”"},"calevtact.moved":{zh:"已改时间「{title}」",en:"Rescheduled “{title}”"},"calevtact.untitled":{zh:"未命名",en:"Untitled"},"calevtact.undo":{zh:"撤销",en:"Undo"},"calevtact.conflict":{zh:"事件已发生变化,未覆盖后续编辑。",en:"The event changed. Later edits were kept."}});const g=[],C=[],$e=()=>g.at(-1)?.vault===j(),Ae=()=>C.at(-1)?.vault===j();function ve(){const e=g.at(-1);return!e||e.vault!==j()?!1:(g.pop(),e.undo()?(e.redo&&C.push(e),!0):(W(),!1))}function Fe(){const e=C.at(-1);return!e||e.vault!==j()?!1:(C.pop(),e.redo?.()?(g.push(e),!0):(W(),!1))}const W=()=>{K({level:"warning",text:w("calevtact.conflict")})};function Pe(){return j()}function k(e,n){if(e.isNoteView)return ee(e.path)?.rows.find(c=>c.rowId===n);if(e.readonly){const c=z.getState().marks.find(s=>`${s.path}:${s.line}`===n);return c?{rowId:n,name:c.text,cells:{name:c.text,date:U(c),note:c.title}}:void 0}const a=T.getState().entries[e.path]?.data?.rows.find(c=>c.id===n);return a?{rowId:a.id,cells:a.cells,body:a.body,name:String(a.cells[e.columns[0]?.id]??"")}:void 0}const Y=(e,n)=>JSON.stringify(e??null)===JSON.stringify(n??null);function fe(e,n,a){const c=T.getState().entries[e.path]?.data?.columns??e.columns;return!!n&&n.body===a.body&&c.filter(s=>s.type!=="updated").every(s=>Y(n.cells[s.id],a.cells[s.id]))}const j=()=>{const e=X.getState();return`${e.vaultSide}:${e.vaultRoot}`};function M(e,n,a){const c=j(),s={vault:c,undo:n,redo:a};g.push(s),g.length>20&&g.shift(),C.length=0;const o=()=>g.at(-1)!==s||j()!==c?!1:ve();K({text:e,level:"info",dedupeKey:"calendar-undo",durationMs:8e3,action:{label:w("calevtact.undo"),run:()=>{o()}}})}function ge(e,n,a){if(e.readonly)return;const c=structuredClone(k(e,n.rowId)??n);let s=P(e,n.rowId);e.isNoteView||M(w("calevtact.deleted",{title:a||w("calevtact.untitled")}),()=>k(e,n.rowId)?!1:(ae(e,c,s),!0),()=>fe(e,k(e,n.rowId),c)?(s=P(e,n.rowId,c),!0):!1)}function we(e,n,a,c,s,o){if(c===s||O(e.columns.find(l=>l.id===a)?.type??"")||e.readonly&&!e.writeCell)return;if(e.writeCell){const l=z.getState().marks.find(u=>`${u.path}:${u.line}`===n.rowId);l&&je(l,c,s,o);return}if(!k(e,n.rowId))return;S(e,n.rowId,a,s);const d=(l,u)=>{const r=k(e,n.rowId);return!r||!Y(r.cells[a],l||void 0)?!1:(S(e,n.rowId,a,u||void 0,{value:l||void 0}),!0)};M(w("calevtact.moved",{title:o||w("calevtact.untitled")}),()=>d(s,c),()=>d(c,s))}function je(e,n,a,c){n===a||!a||F(e,{due:a})&&M(w("calevtact.moved",{title:c||w("calevtact.untitled")}),()=>{const s=te(z.getState().marks,e);return s&&U(s)===a?F(s,{due:n}):!1})}q({"evcard.editEvent":{zh:"编辑事件:{title}",en:"Edit event: {title}"},"evcard.untitled":{zh:"未命名",en:"Untitled"},"evcard.close":{zh:"关闭",en:"Close"},"evcard.name":{zh:"名称",en:"Name"},"evcard.done":{zh:"完成",en:"Done"},"evcard.openNote":{zh:"打开笔记",en:"Open note"},"evcard.openDb":{zh:"打开多维表",en:"Open database"},"evcard.delete":{zh:"删除",en:"Delete"},"evcard.actions":{zh:"事件操作",en:"Event actions"},"evcard.expand":{zh:"展开详情",en:"Expand details"},"evcard.rowlinkReadonly":{zh:"关联表列请在表格里编辑",en:"Edit related rows in the table"},"evcard.noOptions":{zh:"(无选项,请在表格里添加)",en:"(No options — add them in the table)"}});function ye(e,{w:n=360,h:a=380,maxRight:c}={}){const s=e.zoom||1,o=Math.min(n,window.innerWidth/s-16),d=a,l=8*s;let u=e.right+l;u+o*s>(c??window.innerWidth)&&(u=Math.max(l,e.left-o*s-l));const r=Math.max(l,Math.min(e.top,window.innerHeight-d*s-l));return{left:u/s,top:r/s,...o<n?{width:o}:{}}}const Ne={text:_,number:de,checkbox:oe,date:B,select:ie,multiselect:le,url:ce,page:re};function be({col:e}){const n=V(e.type);if(n?.icon)return t.jsx(t.Fragment,{children:n.icon});const a=Ne[H(e.type)]??_;return t.jsx(a,{})}function qe({ev:e,at:n,onClose:a,maxRight:c,calendar:s=!1,onActions:o,actions:d,collapsed:l=!1,onExpand:u,focusTitle:r=!1}){const{t:m}=R(),x=s&&(G==="mobile"||!!window.tangu?.mobile),h=ye(n,{maxRight:c}),p=N.useRef(null),f=N.useRef(null),y=N.useRef(a);return y.current=a,Q(x?{mode:"page",title:e.db.name,back:m("evcard.close"),onBack:()=>{!window.dispatchEvent(new Event("forsion:mobile-back",{cancelable:!0}))||a()}}:null),N.useEffect(()=>{const i=document.activeElement instanceof HTMLElement?document.activeElement:null,b=window.requestAnimationFrame(()=>{const v=p.current?.querySelector(".amx-cal-card-title:not(.amx-cal-card-title-ro)");(!s||r)&&(v??f.current)?.focus()}),L=v=>{if(v.key==="Escape"){v.preventDefault(),y.current();return}if(s||v.key!=="Tab"||!p.current)return;const E=Array.from(p.current.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(!E.length)return;const $=E[0],A=E[E.length-1];v.shiftKey&&document.activeElement===$?(v.preventDefault(),A.focus()):!v.shiftKey&&document.activeElement===A&&(v.preventDefault(),$.focus())};return window.addEventListener("keydown",L),()=>{window.cancelAnimationFrame(b),window.removeEventListener("keydown",L),i?.focus()}},[s,r]),t.jsx("div",{className:`amx-cal-cardcatch${s?" calendar":""}${x?" mobile":""}`,onMouseDown:s?void 0:a,children:t.jsxs("div",{className:`amx-cal-cardwrap${x?" amx-cal-drawer":""}${l?" collapsed":""}`,ref:p,role:"dialog","aria-modal":!s,"aria-label":m("evcard.editEvent",{title:e.title||m("evcard.untitled")}),"data-kb-rise":x?"bar":void 0,style:x?void 0:h,onMouseDown:i=>i.stopPropagation(),children:[x&&t.jsx("button",{className:"amx-cal-drawer-grab","aria-label":m("evcard.expand"),onClick:u,onPointerDown:i=>{i.currentTarget.dataset.y=String(i.clientY),i.currentTarget.setPointerCapture(i.pointerId)},onPointerUp:i=>{i.clientY-Number(i.currentTarget.dataset.y)>55?a():u?.()},children:t.jsx("span",{})}),d??(l?t.jsxs("div",{className:"amx-cal-drawer-summary",children:[t.jsx("button",{className:"amx-cal-card-x",onClick:u,"aria-label":m("evcard.expand"),children:t.jsx(he,{size:18})}),t.jsxs("div",{children:[t.jsx("strong",{children:e.title||m("evcard.untitled")}),t.jsxs("span",{children:[I(e.raw)?.head," ",I(e.raw)?.badge]})]}),t.jsx("button",{className:"amx-cal-card-x",onClick:a,"aria-label":m("evcard.close"),children:"×"})]}):t.jsx(ke,{ev:e,onClose:a,closeRef:f,onActions:o}))]})})}function ke({ev:e,onClose:n,closeRef:a,onActions:c}){const{t:s}=R(),{db:o,row:d,title:l}=e,u=!o.readonly,r=e.color??"var(--accent, #6c5ce7)",m=!o.readonly||!!o.openRow;return t.jsxs("div",{className:"amx-cal-cardin",children:[t.jsxs("div",{className:"amx-cal-card-top",children:[t.jsxs("span",{className:"amx-cal-card-src",children:[t.jsx("span",{className:"amx-cal-card-dot",style:{background:r}}),o.name]}),t.jsxs("span",{className:"amx-cal-card-buttons",children:[c&&t.jsx("button",{className:"amx-cal-card-x",onClick:c,"aria-label":s("evcard.actions"),children:t.jsx(Z,{size:18})}),t.jsx("button",{className:"amx-cal-card-x",ref:a,onClick:n,"aria-label":s("evcard.close"),children:"×"})]})]}),t.jsx(Ce,{db:o,row:d,colId:e.colId??void 0,title:l,raw:e.raw}),(m||u)&&t.jsxs("div",{className:"amx-cal-card-foot",children:[m&&t.jsxs("button",{className:"amx-cal-card-open",onClick:()=>{o.openRow?o.openRow(d.rowId):xe(o.path),n()},children:[t.jsx(pe,{size:13})," ",o.openRow?s("evcard.openNote"):s("evcard.openDb")]}),u&&!c&&t.jsx("button",{className:"amx-cal-card-del",onClick:()=>{ge(o,d,l),n()},children:s("evcard.delete")})]})]})}function Ce({db:e,row:n,colId:a,title:c=n.name,raw:s,lock:o=!1}){const{t:d}=R(),l=o||!!e.readonly&&!e.writeCell||O(e.columns.find(i=>i.id===a)?.type??""),u=!o&&!e.readonly,r=e.columns[0],m=u&&!(e.isNoteView&&r?.type==="page"),x=e.columns.filter(i=>i.id!==r?.id&&i.id!==a),h=s??(a&&typeof n.cells[a]=="string"?n.cells[a]:""),p=a?I(h):null,[f,y]=N.useState(!1);return N.useEffect(()=>{if(!f)return;const i=b=>{b.preventDefault(),b.stopImmediatePropagation(),b.detail?.probe||y(!1)};return window.addEventListener("forsion:mobile-back",i,!0),()=>window.removeEventListener("forsion:mobile-back",i,!0)},[f]),t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"amx-cal-card-head",children:m?t.jsx("input",{className:"amx-cal-card-title","aria-label":d("evcard.name"),value:c,placeholder:d("evcard.untitled"),onChange:i=>ne(e,n.rowId,i.target.value)}):t.jsx("div",{className:"amx-cal-card-title amx-cal-card-title-ro",children:c||d("evcard.untitled")})}),a&&t.jsxs("div",{className:"amx-cal-card-row amx-cal-card-timerow",children:[t.jsx("span",{className:"amx-cal-card-ico",children:t.jsx(B,{})}),t.jsxs("div",{className:"amx-cal-card-timebody",children:[p&&!(f&&!l)&&t.jsxs("button",{type:"button",className:"amx-cal-card-timebtn",disabled:l,onClick:()=>y(!0),children:[t.jsxs("span",{className:"amx-cal-card-timehead",children:[p.head,p.badge&&t.jsx("span",{className:"amx-cal-card-badge",children:p.badge})]}),p.date&&t.jsx("span",{className:"amx-cal-card-timesub",children:p.date})]}),!l&&(f||!p)&&t.jsxs("div",{className:"amx-cal-card-timeedit",children:[t.jsx(se,{value:h,onChange:i=>we(e,n,a,h,i??"",c),autoFocus:f}),p&&t.jsx("button",{type:"button",className:"amx-cal-card-timedone",onClick:()=>y(!1),children:d("evcard.done")})]})]})]}),x.length>0&&t.jsx("div",{className:"amx-cal-card-props",children:x.map(i=>t.jsxs("div",{className:"amx-cal-card-row amx-cal-card-prop",children:[t.jsxs("span",{className:"amx-cal-card-key",children:[t.jsx("span",{className:"amx-cal-card-ico",children:t.jsx(be,{col:i})}),t.jsx("span",{className:"amx-cal-card-keyt",children:i.name})]}),t.jsx("div",{className:"amx-cal-card-ctl",children:u?t.jsx(Re,{db:e,row:n,col:i}):t.jsx("span",{className:"amx-cal-card-val",children:D(n.cells[i.id])||"—"})})]},i.id))})]})}const Ee=new Set(["rowlink","lookup","formula","file"]);function Re({db:e,row:n,col:a}){const{t:c}=R(),s=V(a.type),o=H(a.type),d=J(n.cells[a.id],o),l=r=>S(e,n.rowId,a.id,r),u=T(r=>a.type==="rowlink"&&a.refDb?r.entries[a.refDb]?.data??null:null);if(s){const r=s.Cell;return t.jsx(r,{value:d,column:a,onChange:l})}if(Ee.has(a.type)){const r=n.cells[a.id];let m=D(r);return a.type==="rowlink"&&u&&(m=ue(r).map(x=>{const h=u.rows.find(p=>p.id===x);return h?me(u,h,a.titleCol):"已失联"}).join(", ")),t.jsx("span",{className:"amx-cal-card-val",title:a.type==="rowlink"?c("evcard.rowlinkReadonly"):void 0,children:m||"—"})}switch(o){case"checkbox":return t.jsx("input",{"aria-label":a.name,className:"amx-cal-card-check",type:"checkbox",checked:d===!0,onChange:r=>l(r.target.checked?!0:void 0)});case"number":return t.jsx("input",{className:"amx-cal-card-input","aria-label":a.name,type:"number",value:d??"",onChange:r=>r.target.value===""?l(void 0):Number.isFinite(Number(r.target.value))&&l(Number(r.target.value))});case"date":return t.jsx("input",{"aria-label":a.name,className:"amx-cal-card-input",type:"date",value:d,onChange:r=>l(r.target.value||void 0)});case"select":return t.jsxs("select",{"aria-label":a.name,className:"amx-cal-card-input amx-cal-card-select",value:d,onChange:r=>l(r.target.value||void 0),children:[t.jsx("option",{value:"",children:"—"}),(a.options??[]).map(r=>t.jsx("option",{value:r,children:r},r))]});case"multiselect":{const r=d??[];return t.jsxs("div",{className:"amx-cal-card-chips",children:[(a.options??[]).map(m=>{const x=r.includes(m);return t.jsx("button",{className:`amx-cal-card-chip${x?" on":""}`,"aria-pressed":x,onClick:()=>{const h=x?r.filter(p=>p!==m):[...r,m];l(h.length?h:void 0)},children:m},m)}),(a.options??[]).length===0&&t.jsx("span",{className:"amx-cal-card-key",children:c("evcard.noOptions")})]})}case"page":return t.jsx("span",{className:"amx-cal-card-val",children:D(n.cells[a.id])||"—"});default:return t.jsx("input",{"aria-label":a.name,className:"amx-cal-card-input",value:d,onChange:r=>l(r.target.value||void 0)})}}export{qe as E,Ce as R,Ae as a,Pe as b,$e as c,k as d,ye as e,Fe as f,ge as g,je as h,M as o,we as r,fe as s,ve as u};
@@ -1 +0,0 @@
1
- import{a as U,j as t,u as E,r}from"./index-fDB1l4d-.js";import{ev as q,Y as z,dn as R,iM as P,kO as T,l as w,kP as D}from"./appStore-DDOkzWDA.js";import{c as A}from"./react-b7FrqRQR.js";import{G as M}from"./git-branch-BMajF2cu.js";import"./pageStore-CyvNZEYX.js";import"./client-fKy9CWk0.js";import"./ipc-SAPDwyQ4.js";import"./nativeDownload-DsGyUSJ5.js";import"./dbStore-BIG5Mfh2.js";import"./drawingStore-CGvTqqYW.js";U({"gitClone.title":{zh:"从 Git 克隆",en:"Clone from Git"},"gitClone.subtitle":{zh:"把仓库克隆到这台电脑上,并加成一个项目。",en:"Clones the repository to this computer and adds it as a project."},"gitClone.tabUrl":{zh:"网址",en:"URL"},"gitClone.urlPlaceholder":{zh:"仓库地址,以 https:// 或 git@ 开头",en:"Repository address, starting with https:// or git@"},"gitClone.loading":{zh:"正在读取仓库列表…",en:"Loading repositories…"},"gitClone.empty":{zh:"这个账号下还没有仓库。",en:"This account has no repositories yet."},"gitClone.noHost":{zh:"这里用不了。登录 Forsion 后再试,或者用「网址」。",en:"Not available here. Sign in to Forsion and try again, or use URL."},"gitClone.githubUnlinked":{zh:"还没绑定 GitHub 账号。绑定后这里会列出你的仓库。",en:"No GitHub account is linked yet. Link one to list your repositories here."},"gitClone.link":{zh:"去绑定",en:"Link GitHub"},"gitClone.listFailed":{zh:"没能读到仓库列表。可以用「网址」直接贴地址。",en:"Could not load the repository list. You can paste an address under URL instead."},"gitClone.private":{zh:"私有",en:"Private"},"gitClone.public":{zh:"公开",en:"Public"},"gitClone.folderName":{zh:"文件夹名",en:"Folder name"},"gitClone.into":{zh:"放在",en:"Location"},"gitClone.choose":{zh:"选择文件夹…",en:"Choose folder…"},"gitClone.change":{zh:"更改…",en:"Change…"},"gitClone.confirm":{zh:"克隆",en:"Clone"},"gitClone.cloning":{zh:"正在克隆…",en:"Cloning…"},"gitClone.cloningHint":{zh:"大的仓库要等一会儿,别关掉这个窗口。",en:"Large repositories take a while. Keep this window open."},"gitClone.err.invalid_remote_url":{zh:"这个地址用不了。仓库地址要以 https:// 或 git@ 开头,而且不能把密码写在地址里。",en:"That address cannot be used. A repository address must start with https:// or git@ and must not contain a password."},"gitClone.err.invalid_folder_name":{zh:"文件夹名不能用。不要带斜杠或冒号,也不要以 - 开头。",en:"That folder name cannot be used. Leave out slashes and colons, and do not start it with a hyphen."},"gitClone.err.invalid_folder":{zh:"要放进去的文件夹不存在,重新选一个。",en:"The folder to clone into does not exist. Choose another one."},"gitClone.err.target_exists":{zh:"这个文件夹里已经有同名的东西了。换个文件夹名,或者换个位置。",en:"There is already something with that name in this folder. Use another folder name or another location."},"gitClone.err.remote_unreachable":{zh:"没能克隆:地址不对、没有权限,或者网络不通。",en:"Could not clone: the address is wrong, you have no access, or the network is down."},"gitClone.err.git_timeout":{zh:"克隆超时了。仓库很大时,可以在终端里克隆,再用「添加项目」把文件夹加进来。",en:"Cloning timed out. For a very large repository, clone it in a terminal, then add the folder as a project."},"gitClone.err.git_unavailable":{zh:"这台电脑上没有可用的 git。",en:"git is not available on this computer."},"gitClone.err.github_not_linked":{zh:"GitHub 没有接受这次请求:这台电脑上没有可用的 GitHub 凭据,你的 Forsion 账号也还没有绑定 GitHub 账号。",en:"GitHub refused this request: this computer has no working GitHub credentials, and your Forsion account has no GitHub account linked."},"gitClone.err.github_relink_required":{zh:"绑定的 GitHub 账号已经失效。在账户中心的「账号安全」里重新绑定后再试。",en:"The linked GitHub account no longer works. Link it again under Security in the account centre, then try again."},"gitClone.err.github_unavailable":{zh:"暂时领不到绑定的 GitHub 账号的凭据。确认已登录 Forsion 并且网络正常,稍后再试。",en:"Credentials for the linked GitHub account are unavailable right now. Check that you are signed in to Forsion and online, then try again."},"gitClone.err.forsion_git_unavailable":{zh:"暂时领不到 Forsion Git 的凭据。确认已登录 Forsion 并且网络正常,稍后再试。",en:"Forsion Git credentials are unavailable right now. Check that you are signed in to Forsion and online, then try again."},"gitClone.err.forsion_git_needs_setup":{zh:"你的 Forsion 账号还没有开通 Forsion Git。先在网页上登录一次 Forsion Git,再回来重试。",en:"Your Forsion account is not set up on Forsion Git yet. Sign in to Forsion Git on the web once, then try again."},"gitClone.err.unsupported":{zh:"当前连接的引擎不支持克隆,更新引擎后再试。",en:"The connected engine does not support cloning yet. Update it and try again."}});const $=new Set(["invalid_remote_url","invalid_folder_name","invalid_folder","target_exists","remote_unreachable","git_timeout","git_unavailable","github_not_linked","github_relink_required","github_unavailable","forsion_git_unavailable","forsion_git_needs_setup"]),O=a=>(a.trim().replace(/[/\\]+$/,"").split(/[/\\:]/).pop()??"").replace(/\.git$/i,"").replace(/^-+/,""),m=A(()=>({req:null}));function te(){return m.getState().req?Promise.resolve(null):new Promise(a=>{m.setState({req:{resolve:a}})})}function ne(){const a=m(o=>o.req);if(!a)return null;const n=o=>{m.getState().req===a&&(m.setState({req:null}),a.resolve(o))};return t.jsx("div",{className:"am-app tangu-lovable",style:{display:"contents"},children:t.jsx(Y,{onDone:n})})}function Y({onDone:a}){const{t:n}=E(),[o,k]=r.useState("forsion"),[p,f]=r.useState({}),[c,G]=r.useState(""),[b,x]=r.useState(""),[F,H]=r.useState(!1),[d,S]=r.useState(""),[l,_]=r.useState(!1),[u,h]=r.useState(null),C=window.tangu?.openAccountCenter?()=>{window.tangu.openAccountCenter("security")}:void 0,v=()=>{l||a(null)};q(v);const j=e=>{f(i=>({...i,[e]:{state:"loading"}})),T(w(),e).then(i=>{f(g=>({...g,[e]:i?{state:"ok",repos:i}:{state:"none"}})),!i&&e==="forsion"&&k(g=>g==="forsion"?"url":g)},i=>f(g=>({...g,[e]:{state:i?.code==="github_not_linked"||i?.code==="github_relink_required"?"unlinked":"failed"}})))};r.useEffect(()=>{o!=="url"&&!p[o]&&j(o)},[o]),r.useEffect(()=>{const e=()=>{p.github?.state==="unlinked"&&j("github")};return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)},[p.github?.state]);const y=e=>{G(e),h(null),F||x(O(e))},L=async()=>{const e=await window.tangu?.pickDirectory?.({purpose:"project"});e&&(S(e),h(null))},N=async()=>{if(!(l||!c.trim()||!b.trim()||!d)){_(!0),h(null);try{a(await D(w(),c.trim(),d,b.trim()))}catch(e){const i=typeof e?.code=="string"?e.code:"";h({message:$.has(i)?n(`gitClone.err.${i}`):e?.status===404?n("gitClone.err.unsupported"):String(e?.message||e),info:typeof e?.info=="string"&&e.info&&i==="remote_unreachable"?e.info:void 0,link:i==="github_not_linked"||i==="github_relink_required"}),_(!1)}}},s=o==="url"?null:p[o];return t.jsx("div",{className:"dialog-overlay",onMouseDown:v,children:t.jsxs("div",{className:"dialog git-clone-dialog",role:"dialog","aria-modal":"true","aria-label":n("gitClone.title"),"data-git-clone":!0,onMouseDown:e=>e.stopPropagation(),children:[t.jsxs("div",{children:[t.jsx("div",{className:"dialog-title",children:n("gitClone.title")}),t.jsx("div",{className:"dialog-msg",children:n("gitClone.subtitle")})]}),t.jsx("div",{className:"git-clone-tabs",role:"tablist",children:["forsion","github","url"].map(e=>t.jsx("button",{type:"button",role:"tab","aria-selected":o===e,className:o===e?"on":"","data-git-clone-tab":e,disabled:l,onClick:()=>k(e),children:e==="forsion"?"Forsion Git":e==="github"?"GitHub":n("gitClone.tabUrl")},e))}),o==="url"?t.jsx("input",{className:"dialog-input",autoFocus:!0,spellCheck:!1,value:c,disabled:l,placeholder:n("gitClone.urlPlaceholder"),"data-git-clone-url":!0,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key==="Enter"&&N()}}):t.jsxs("div",{className:"dialog-list git-clone-list","data-git-clone-list":s?.state??"loading",children:[(!s||s.state==="loading")&&t.jsxs("div",{className:"dialog-msg git-clone-note",children:[t.jsx(z,{size:13,className:"spin"}),n("gitClone.loading")]}),s?.state==="none"&&t.jsx("div",{className:"dialog-msg git-clone-note",children:n("gitClone.noHost")}),s?.state==="failed"&&t.jsx("div",{className:"dialog-msg git-clone-note",children:n("gitClone.listFailed")}),s?.state==="unlinked"&&t.jsxs("div",{className:"dialog-msg git-clone-note",children:[n("gitClone.githubUnlinked"),C&&t.jsx("button",{type:"button",className:"dialog-btn","data-git-clone-link":!0,onClick:C,children:n("gitClone.link")})]}),s?.state==="ok"&&!s.repos.length&&t.jsx("div",{className:"dialog-msg git-clone-note",children:n("gitClone.empty")}),s?.state==="ok"&&s.repos.map(e=>t.jsxs("button",{type:"button",className:`dialog-listitem git-clone-repo${c===e.cloneUrl?" on":""}`,"aria-pressed":c===e.cloneUrl,disabled:l,onClick:()=>y(e.cloneUrl),children:[e.private?t.jsx(R,{size:13}):t.jsx(M,{size:13}),t.jsx("strong",{children:e.fullName}),t.jsx("span",{className:"git-clone-chip",children:n(e.private?"gitClone.private":"gitClone.public")}),e.updatedAt&&t.jsx("small",{children:P(e.updatedAt)})]},e.cloneUrl))]}),t.jsxs("div",{className:"git-clone-where",children:[t.jsx("label",{htmlFor:"git-clone-name",children:n("gitClone.folderName")}),t.jsx("input",{id:"git-clone-name",className:"dialog-input",spellCheck:!1,value:b,disabled:l,maxLength:100,onChange:e=>{x(e.target.value),H(!0),h(null)}}),t.jsx("span",{children:n("gitClone.into")}),t.jsxs("div",{className:"git-clone-parent",children:[t.jsx("code",{title:d||void 0,children:t.jsx("bdi",{children:d||"—"})}),t.jsx("button",{type:"button",className:"dialog-btn","data-git-clone-parent":!0,disabled:l,onClick:()=>{L()},children:n(d?"gitClone.change":"gitClone.choose")})]})]}),u&&t.jsxs("div",{className:"git-clone-error",role:"alert","data-git-clone-error":!0,children:[t.jsx("p",{children:u.message}),u.info&&t.jsx("pre",{children:u.info}),u.link&&C&&t.jsx("button",{type:"button",className:"dialog-btn",onClick:C,children:n("gitClone.link")})]}),l&&t.jsx("div",{className:"dialog-msg git-clone-note",children:n("gitClone.cloningHint")}),t.jsxs("div",{className:"dialog-actions",children:[t.jsx("button",{className:"dialog-btn",disabled:l,onClick:v,children:n("common.cancel")}),t.jsxs("button",{className:"dialog-btn","data-primary":!0,"data-git-clone-confirm":!0,disabled:l||!c.trim()||!b.trim()||!d,onClick:()=>{N()},children:[l&&t.jsx(z,{size:13,className:"spin"}),n(l?"gitClone.cloning":"gitClone.confirm")]})]})]})})}export{ne as GitCloneHost,te as askGitClone,O as cloneFolderName};
@@ -1 +0,0 @@
1
- import{u as U,r as o,j as t}from"./index-fDB1l4d-.js";import{ah as xe,M as J,bo as fe,a6 as Oe,f as Re,b7 as $e,ba as _,am as Ae,L as Be,bv as Ue,q as qe,b9 as Fe}from"./pageStore-CyvNZEYX.js";import"./client-fKy9CWk0.js";import{Y as te,Z as $,bb as Se,aU as He,aV as Ve,dn as _e,aW as je,R as Ke,S as We,dm as Ye,mH as Ge,a0 as Xe,u as Qe,db as Ze,aJ as Je,n6 as et}from"./appStore-DDOkzWDA.js";import{u as tt}from"./gestures-ZhFAENNZ.js";import{C as st,a as it}from"./Chrome-C7F6fdDp.js";import{s as at,d as ee,r as nt,b as D,i as ve,h as rt,u as r,a as ot,c as be,e as ye,p as B,f as ce,m as lt,g as Ce,j as dt,k as we,I as ct,l as ut,n as mt,o as gt,q as pt,t as A,v as ue,w as me,x as ht,S as ge,y as xt,z as K,L as ft,A as St,B as jt,C as vt,D as bt,E as yt}from"./imageStudio-DC_syDtx.js";import{C as Ct,a as wt}from"./launchpad-CcmSwlJl.js";import{a as kt,C as zt}from"./copy-plus-ClKrSgM7.js";import{L as Nt}from"./lock-open-D2nMg0ga.js";import{U as W}from"./upload-Dy7svciS.js";import{F as It}from"./file-down-Z913cCyQ.js";import{U as Et}from"./undo-2-QimgpLBn.js";import{R as Pt}from"./redo-2-CqlqhWrI.js";import{L as Lt}from"./layout-grid-oIyIGbc5.js";import{A as Tt}from"./arrow-up-right-BptN64d-.js";import{H as Dt,T as Mt,F as Ot}from"./type-Dt7RNB9g.js";import"./react-b7FrqRQR.js";import"./ipc-SAPDwyQ4.js";import"./nativeDownload-DsGyUSJ5.js";import"./dbStore-BIG5Mfh2.js";import"./drawingStore-CGvTqqYW.js";import"./magnet-Cqmm97W8.js";import"./InlineFiles-CAIyTk1n.js";import"./pencil--sWwxHdP.js";import"./folder-plus-DP9sFr26.js";import"./folder-1OJQeDI1.js";function Rt({board:s,selection:i,onClose:j}){const{t:c}=U(),[g,v]=o.useState("png"),[b,w]=o.useState(1),[l,p]=o.useState("transparent"),[S,y]=o.useState(.92),[N,C]=o.useState(!1),[u,d]=o.useState(""),z=at(s,i),P=z?.bounds,L=Math.round((P?.w||0)*b),M=Math.round((P?.h||0)*b),O=!P||L<1||M<1||L*M>4e7||Math.max(L,M)>16384;return t.jsxs("section",{className:"ims-export ims-panel","aria-label":c("imageStudio.exportOptions"),children:[t.jsxs("div",{className:"ims-section-head",children:[t.jsx("h3",{children:c("imageStudio.exportOptions")}),t.jsx("button",{"aria-label":c("imageStudio.close"),onClick:j,children:t.jsx(xe,{size:15})})]}),t.jsxs("div",{className:"ims-fields",children:[t.jsxs("label",{children:[c("imageStudio.format"),t.jsx("select",{"aria-label":c("imageStudio.format"),value:g,onChange:h=>v(h.target.value),children:["png","jpeg","webp","svg"].map(h=>t.jsx("option",{value:h,children:h.toUpperCase()},h))})]}),t.jsxs("label",{children:[c("imageStudio.scale"),t.jsx("select",{"aria-label":c("imageStudio.scale"),value:b,onChange:h=>w(Number(h.target.value)),children:[.5,1,2,3].map(h=>t.jsxs("option",{value:h,children:[h,"×"]},h))})]}),t.jsxs("label",{children:[c("imageStudio.background"),t.jsxs("select",{"aria-label":c("imageStudio.background"),value:l,onChange:h=>p(h.target.value),children:[t.jsx("option",{value:"transparent",children:c("imageStudio.transparent")}),t.jsx("option",{value:"#ffffff",children:c("imageStudio.white")}),t.jsx("option",{value:"#000000",children:c("imageStudio.black")})]})]}),(g==="jpeg"||g==="webp")&&t.jsxs("label",{children:[c("imageStudio.quality"),t.jsx("input",{"aria-label":c("imageStudio.quality"),type:"range",min:".1",max:"1",step:".05",value:S,onChange:h=>y(Number(h.target.value))})]})]}),t.jsxs("p",{children:[L," × ",M," px · ",c(i.length?"imageStudio.selectedOnly":"imageStudio.allVisible")]}),g==="svg"&&t.jsx("p",{children:c("imageStudio.svgHint")}),g==="jpeg"&&l==="transparent"&&t.jsx("p",{children:c("imageStudio.jpegHint")}),O&&t.jsx("p",{role:"alert",children:c("imageStudio.exportLimit")}),t.jsxs("button",{className:"ims-primary",disabled:N||O,onClick:async()=>{C(!0),d("");try{ee(await nt(s,i,{format:g,scale:b,background:l,quality:S}),`${s.name}.${g==="jpeg"?"jpg":g}`)}catch(h){d(String(h))}finally{C(!1)}},children:[N?t.jsx(te,{className:"ims-spin",size:15}):t.jsx($,{size:15}),c("imageStudio.download")]}),u&&t.jsx("p",{role:"alert",children:c("imageStudio.error",{error:u})})]})}function $t({target:s,board:i,busy:j,onClose:c,onImport:g,onExport:v,onInspect:b,run:w}){const{t:l}=U(),p=i?D(i).filter(d=>s.ids.includes(d.id)):[],S=p.length===1&&ve(p[0])?p[0]:void 0,y=p.filter(d=>!d.locked).map(d=>d.id),N=/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl+",C=d=>()=>{i&&r.getState().activeId!==i.id||(r.setState({selection:p.map(z=>z.id)}),d())},u=[];return S&&u.push({label:l("imageStudio.downloadImage"),icon:t.jsx($,{size:14}),disabled:j,run:C(()=>{w(async()=>ee(await ot([S],!0),S.name.replace(/\.[^.]+$/,"")+".png"))})},{label:l("imageStudio.downloadOriginal"),icon:t.jsx($,{size:14}),run:C(()=>{const d={"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif"}[S.blob.type]||"png";ee(S.blob,S.name.replace(/\.[^.]+$/,"")+"-original."+d)})}),p.length&&i?u.push({label:l("imageStudio.exportSelection"),icon:t.jsx($,{size:14}),disabled:j,run:C(v)},{label:l("imageStudio.reference"),icon:t.jsx(J,{size:14}),separatorBefore:!0,disabled:j||p.length>8,run:C(()=>{w(be)})},{label:l("imageStudio.inspector"),icon:t.jsx(fe,{size:14}),run:C(b)},{label:l("imageStudio.copyObjects"),icon:t.jsx(Se,{size:14}),shortcut:`${N}C`,separatorBefore:!0,run:C(ye)},{label:l("imageStudio.duplicate"),icon:t.jsx(kt,{size:14}),shortcut:`${N}D`,run:C(()=>B(!0))},{label:l("imageStudio.layerUp"),icon:t.jsx(He,{size:14}),separatorBefore:!0,disabled:!y.length,run:C(()=>r.getState().update(i.id,d=>ce(d,y,"up")))},{label:l("imageStudio.layerDown"),icon:t.jsx(Ve,{size:14}),disabled:!y.length,run:C(()=>r.getState().update(i.id,d=>ce(d,y,"down")))},{label:l(y.length?"imageStudio.lock":"imageStudio.unlock"),icon:y.length?t.jsx(_e,{size:14}):t.jsx(Nt,{size:14}),run:C(()=>r.getState().update(i.id,d=>lt(d,z=>s.ids.includes(z.id)?{...z,locked:!!y.length}:z)))},{label:l("imageStudio.remove"),icon:t.jsx(je,{size:14}),shortcut:"⌫",separatorBefore:!0,danger:!0,disabled:!y.length,run:C(Ce)}):u.push({label:l("imageStudio.import"),icon:t.jsx(W,{size:14}),disabled:j,run:g},{label:l("imageStudio.pasteObjects"),icon:t.jsx(zt,{size:14}),shortcut:`${N}V`,disabled:!i||!rt(),run:C(()=>B())},{label:l("imageStudio.selectAll"),icon:t.jsx(Ct,{size:14}),disabled:!i?.images.length&&!i?.elements?.length,run:()=>r.setState({selection:i?D(i).filter(d=>!d.hidden).map(d=>d.id):[]})},{label:l("imageStudio.exportBoard"),icon:t.jsx($,{size:14}),separatorBefore:!0,disabled:j||!i||!D(i).some(d=>!d.hidden),run:C(v)}),t.jsx(wt,{menu:{x:s.x,y:s.y,items:u},onClose:c,autoFocus:!0})}const pe=4/3,At=.05;function Bt({board:s}){const i=dt(s,2);if(!i.length)return t.jsx("span",{className:"ims-cover is-empty",children:t.jsx("span",{className:"ims-cover-in",children:t.jsx(Ge,{size:22,strokeWidth:1.4})})});const j=i.map(g=>{const v=we(g);return v.w/v.h}),c=Math.min(1,(1-At*(i.length-1))*pe/j.reduce((g,v)=>g+v,0));return t.jsx("span",{className:"ims-cover",children:t.jsx("span",{className:"ims-cover-in",children:i.map((g,v)=>t.jsx("span",{className:"ims-cover-img",style:{width:`${j[v]*c/pe*100}%`,aspectRatio:String(j[v])},children:t.jsx(ct,{image:g})},g.id))})})}function Ut(){const{t:s,locale:i}=U(),j=r(u=>u.boards),[c,g]=o.useState(""),[v,b]=o.useState(!1),[w,l]=o.useState(""),p=o.useRef(null),S=o.useMemo(()=>Object.values(j).sort((u,d)=>d.updatedAt-u.updatedAt),[j]),y=c.trim().toLocaleLowerCase(),N=y?S.filter(u=>u.name.toLocaleLowerCase().includes(y)):S,C=async u=>{b(!0),l("");try{const d=await ut(u),z=r.getState().create(d.name);r.getState().update(z,P=>({...d,id:P.id}))}catch(d){l(String(d))}finally{b(!1)}};return t.jsx("div",{className:"csl-launchpad ims-launch",children:t.jsx("div",{className:"csl-inner",children:t.jsxs("main",{className:"csl-catalog",children:[t.jsxs("header",{className:"csl-catalog-header",children:[t.jsxs("div",{children:[t.jsx("h1",{children:s("imageStudio.projects")}),t.jsx("p",{children:s("imageStudio.launch.subtitle")})]}),t.jsxs("div",{className:"csl-catalog-actions",children:[t.jsxs("button",{type:"button",className:"csl-import",disabled:v,onClick:()=>p.current?.click(),children:[t.jsx(Ke,{size:15}),s("imageStudio.restore")]}),t.jsxs("button",{type:"button",className:"csl-new",onClick:()=>r.getState().create(s("imageStudio.untitled")),children:[t.jsx(Oe,{size:16}),s("imageStudio.new")]})]})]}),w&&t.jsx("div",{className:"ims-error",role:"alert",children:s("imageStudio.error",{error:w})}),S.length>0&&t.jsx("div",{className:"csl-catalog-toolbar",children:t.jsxs("label",{className:"csl-search",children:[t.jsx(We,{size:15}),t.jsx("input",{type:"search","aria-label":s("imageStudio.launch.search"),placeholder:s("imageStudio.launch.search"),value:c,onChange:u=>g(u.target.value)})]})}),N.length?t.jsx("div",{className:"ims-launch-grid",role:"group","aria-label":s("imageStudio.projects"),children:N.map(u=>t.jsxs("button",{type:"button",className:"ims-launch-card","data-project-id":u.id,onClick:()=>r.getState().open(u.id),children:[t.jsx(Bt,{board:u}),t.jsxs("span",{className:"ims-launch-meta",children:[t.jsx("strong",{children:u.name}),t.jsxs("small",{children:[s("imageStudio.itemCount",{count:D(u).length})," · ",Ye(u.updatedAt,{locale:i})]})]})]},u.id))}):t.jsxs("div",{className:"csl-empty",children:[t.jsx("strong",{children:s(S.length?"imageStudio.launch.noMatch":"imageStudio.launch.empty")}),!S.length&&t.jsx("p",{children:s("imageStudio.launch.emptyHint")})]}),t.jsx("input",{ref:p,type:"file",accept:".json",hidden:!0,onChange:u=>{const d=u.target.files?.[0];u.target.value="",d&&C(d)}})]})})})}const he=[];function xs(s){const{t:i}=U(),j=r(l=>l.ready),c=r(l=>l.error),g=r(l=>l.activeId);o.useEffect(()=>{r.getState().hydrate();const l=()=>{r.getState().flush()},p=S=>{const y=r.getState();(y.saving||y.ready&&y.error)&&(l(),S.preventDefault(),S.returnValue="")};return window.addEventListener("pagehide",l),window.addEventListener("beforeunload",p),()=>{window.removeEventListener("pagehide",l),window.removeEventListener("beforeunload",p),l()}},[]);const v=Re(l=>l.activeSpaceId==="image-studio")&&Xe()==="main",b=!!g,w=o.useRef(!1);return o.useEffect(()=>{!j||!v||(b?mt():gt(w.current),w.current=b)},[j,v,b]),j?g?t.jsx(qt,{},g):t.jsx(Ut,{}):t.jsx("div",{className:"ims-panel ims-panel-empty",children:c?t.jsxs(t.Fragment,{children:[t.jsx("p",{role:"alert",children:i("imageStudio.error",{error:c})}),t.jsx("button",{onClick:()=>{r.getState().hydrate()},children:i("imageStudio.retry")})]}):t.jsx(te,{className:"ims-spin"})})}function qt(){const{t:s}=U(),i=r(e=>e.activeId?e.boards[e.activeId]:void 0),j=r(e=>e.saving),c=r(e=>e.error),g=r(e=>i&&e.past[i.id]?.length||0),v=r(e=>i&&e.future[i.id]?.length||0),b=r(e=>e.selection),w=r(e=>i&&e.placeholders[i.id]||he),l=Qe(e=>!!(i?.sessionId&&e.runningBySession[i.sessionId])),[p,S]=o.useState(!1),[y,N]=o.useState(""),[C,u]=o.useState(0),[d,z]=o.useState(!1),[P,L]=o.useState(!1),[M,O]=o.useState(!1),h=o.useRef(null),[se,ke]=o.useState(!0),[ie,ze]=o.useState(!1),[Ne,Y]=o.useState(!1),I=o.useRef(null),q=o.useRef(null),[ae,ne]=o.useState(null),Ie=o.useCallback(()=>{ne(null),I.current?.focus({preventScroll:!0})},[]),m=$e(I,`image-studio:${i?.id||""}`,void 0,{x:56,y:64,z:1}),F=i?.images||[],T=i?D(i):[],H=T.filter(e=>!e.hidden),Ee=!T.length&&!g&&!v,G=[...H,...w],V=o.useRef(!0);o.useEffect(()=>(V.current=!0,()=>{V.current=!1}),[]);const re=o.useCallback(e=>{V.current&&N(e)},[]);pt(i||Ft,re,C);const x=tt(I,m,{boxes:()=>new Map(H.map(e=>[e.id,e])),identity:()=>i?.id,commit:e=>{i&&r.getState().update(i.id,a=>me(a,e))},constrain:(e,a)=>{if(a.kind!=="resize")return e;const n=F.find(Me=>Me.id===a.key),f=e.get(a.key);if(!n||!f)return e;const k=we(n),E=Math.max(48,f.w),De=E*k.h/k.w;return new Map(e).set(a.key,{...f,w:E,h:De})},hitKey:e=>e.closest("[data-image-id]")?.dataset.imageId||null,isEditing:e=>!!T.find(a=>a.id===e)?.locked,hitEdge:e=>e.dataset.resize||null,onDelete:e=>{i&&r.getState().update(i.id,a=>ue(a,D(a).filter(n=>n.locked||!e.includes(n.id))))},onDoubleClick:e=>{e&&(r.setState({selection:[e]}),A(K))},onContextMenu:(e,a)=>{const n=e?x.sel.includes(e)?x.sel:[e]:[];x.setSel(n),r.setState({selection:n}),ne({x:a.clientX,y:a.clientY,ids:n})},minW:48,minH:48,repel:!1},se);o.useEffect(()=>x.bind(I.current),[x.bind]),o.useEffect(()=>m.bindWheel(I.current),[m.bindWheel]),o.useEffect(()=>{const e=()=>{O(!1),h.current=null};return window.addEventListener("blur",e),()=>window.removeEventListener("blur",e)},[]);const oe=o.useRef(x.sel);o.useEffect(()=>{oe.current!==x.sel&&(oe.current=x.sel,r.setState({selection:x.sel}))},[x.sel]),o.useEffect(()=>{if(b.join("|")!==x.sel.join("|")){x.setSel(b);const e=T.find(a=>a.id===b[0]);if(e){const{w:a,h:n}=_(I.current),f=m.vpRef.current,k=(e.x+e.w/2)*f.z+f.x,E=(e.y+e.h/2)*f.z+f.y;(k<0||k>a||E<0||E>n)&&m.centerOn(e.x+e.w/2,e.y+e.h/2)}}},[b,x.setSel]);const le=o.useRef(0);o.useEffect(()=>{const e=T.length+w.length;e>le.current&&m.fitTo(G,64),le.current=e},[T,w,m.fitTo]);const R=async e=>{S(!0),N("");try{await e()}catch(a){re(String(a))}finally{V.current&&S(!1)}},X=()=>i?.id||r.getState().create(s("imageStudio.untitled")),de=async e=>{const a=await Promise.all(e.map(f=>bt(f,f.name,"import")));if(!a.length)return;const n=X();r.getState().update(n,f=>{const k=[...f.images];for(const E of a)k.push({...E,...yt(E.width,E.height,k)});return{...f,images:k}})},Pe=e=>{R(async()=>{const a=X();await St(a,s(e))})},Q=T.filter(e=>b.includes(e.id)),Le=i&&x.live?D(me(i,x.live)):T,Z=e=>{const a=X(),{w:n,h:f}=_(I.current),k=jt(e,s(`imageStudio.new.${e}`),(n/2-m.vp.x)/m.vp.z,(f/2-m.vp.y)/m.vp.z);k.x-=k.w/2,k.y-=k.h/2,r.getState().update(a,E=>ue(E,[...D(E),k])),r.setState({selection:[k.id]}),A(K)},Te=e=>{const{w:a,h:n}=_(I.current);m.setVp(Fe(m.vp,m.vp.z*e,a/2,n/2))};return t.jsxs("div",{className:"ims",onKeyDownCapture:e=>{if(e.target.closest('input, select, textarea, button, [contenteditable="true"]'))return;const a=e.metaKey||e.ctrlKey,n=e.key.toLowerCase();let f=!0;a&&n==="z"&&i?r.getState().undo(i.id,e.shiftKey):a&&n==="c"?ye():a&&n==="v"?B():a&&n==="d"?B(!0):a&&n==="e"?z(!0):!a&&n==="t"?Z("text"):!a&&n==="f"?Z("frame"):!a&&n==="h"?L(!0):!a&&n==="v"?L(!1):n===" "?O(!0):(n==="escape"&&(L(!1),z(!1)),f=!1),f&&(e.preventDefault(),e.stopPropagation())},onKeyUpCapture:e=>{e.key===" "&&(O(!1),e.preventDefault(),e.stopPropagation())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(O(!1),h.current=null)},children:[t.jsxs("header",{className:"ims-header",children:[t.jsxs("button",{className:"ims-back",title:s("imageStudio.back"),onClick:()=>r.getState().close(),children:[t.jsx(Ae,{size:15}),t.jsx("span",{children:i?.name})]}),t.jsxs("div",{className:"ims-head-actions",children:[i&&t.jsx("button",{disabled:p,title:s("imageStudio.backup"),"aria-label":s("imageStudio.backup"),onClick:()=>{R(()=>vt(i))},children:t.jsx(It,{size:16})}),t.jsxs("button",{className:"ims-primary",disabled:!H.length||p,onClick:()=>z(!d),children:[t.jsx($,{size:14}),t.jsx("span",{children:s("imageStudio.exportOptions")})]})]})]}),t.jsxs("div",{className:"ims-toolbar",role:"toolbar","aria-label":s("imageStudio.title"),children:[t.jsxs("button",{disabled:p,onClick:()=>q.current?.click(),children:[t.jsx(W,{size:15}),t.jsx("span",{children:s("imageStudio.import")})]}),!Ee&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"ims-divider"}),t.jsx("button",{disabled:!g,title:s("imageStudio.undo"),"aria-label":s("imageStudio.undo"),onClick:()=>i&&r.getState().undo(i.id),children:t.jsx(Et,{size:15})}),t.jsx("button",{disabled:!v,title:s("imageStudio.redo"),"aria-label":s("imageStudio.redo"),onClick:()=>i&&r.getState().undo(i.id,!0),children:t.jsx(Pt,{size:15})}),t.jsx("button",{disabled:!F.some(e=>!e.locked&&!e.hidden),title:s("imageStudio.arrange"),"aria-label":s("imageStudio.arrange"),onClick:()=>{if(i){const e=ht(F.filter(a=>!a.locked&&!a.hidden));r.getState().update(i.id,a=>({...a,images:a.images.map(n=>e.find(f=>f.id===n.id)||n)})),m.fitTo(e)}},children:t.jsx(Lt,{size:15})}),t.jsx("button",{disabled:!Q.length,title:s("imageStudio.remove"),"aria-label":s("imageStudio.remove"),onClick:Ce,children:t.jsx(je,{size:15})}),t.jsx("button",{disabled:!Q.length,title:s("imageStudio.duplicate"),"aria-label":s("imageStudio.duplicate"),onClick:()=>B(!0),children:t.jsx(Se,{size:15})}),t.jsx("button",{disabled:!Q.length||p,title:s("imageStudio.reference"),"aria-label":s("imageStudio.reference"),onClick:()=>{R(be)},children:t.jsx(J,{size:15})})]}),t.jsx("span",{className:"ims-toolbar-space"}),[[ge,J,"imageStudio.chat"],[xt,Be,"imageStudio.layers"],[K,fe,"imageStudio.inspector"]].map(([e,a,n])=>t.jsx("button",{title:s(n),"aria-label":s(n),onClick:()=>A(e),children:t.jsx(a,{size:16})},e))]}),d&&i&&t.jsx(Rt,{board:i,selection:b,onClose:()=>z(!1)}),c&&t.jsxs("div",{className:"ims-error",role:"alert",children:[s("imageStudio.saveError"),t.jsx("button",{onClick:()=>{r.getState().flush()},children:s("imageStudio.retry")})]}),y&&t.jsxs("div",{className:"ims-error",role:"alert",children:[s("imageStudio.error",{error:y}),t.jsx("button",{onClick:()=>{N(""),u(e=>e+1)},children:s("imageStudio.retry")})]}),t.jsxs("div",{ref:I,className:`ims-stage${P||M?" is-panning":""}`,tabIndex:0,onContextMenu:e=>e.stopPropagation(),onPointerDownCapture:e=>{e.button===2||!(P||M)||e.target.closest(".amx-stage-tools, .amx-stage-hud, .amx-stage-minimap")||(e.stopPropagation(),e.preventDefault(),e.currentTarget.focus(),e.currentTarget.setPointerCapture(e.pointerId),h.current={id:e.pointerId,x:e.clientX,y:e.clientY,vx:m.vp.x,vy:m.vp.y})},onPointerMoveCapture:e=>{const a=h.current;if(!a||a.id!==e.pointerId)return;e.stopPropagation();const{u:n}=_(I.current);m.setVp({...m.vp,x:a.vx+(e.clientX-a.x)/n,y:a.vy+(e.clientY-a.y)/n})},onPointerUpCapture:e=>{h.current?.id===e.pointerId&&(e.stopPropagation(),h.current=null)},onPointerCancel:()=>{h.current=null},"aria-label":s("imageStudio.title"),onDragOver:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),Y(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||Y(!1)},onDrop:e=>{e.preventDefault(),Y(!1),p||R(()=>de(Array.from(e.dataTransfer.files)))},children:[t.jsx("div",{className:"ims-grid",style:Ue(m.vp)}),t.jsxs("div",{className:"ims-world",style:{transform:`translate(${m.vp.x}px, ${m.vp.y}px) scale(${m.vp.z})`},children:[H.map(e=>{const a=Le.find(n=>n.id===e.id)||e;return t.jsxs("div",{"data-image-id":e.id,className:`ims-layer ${ve(e)?"ims-image":`ims-${e.kind}`}${x.sel.includes(e.id)?" is-selected":""}${e.locked?" is-locked":""}`,style:{left:a.x,top:a.y,width:a.w,height:a.h},children:[t.jsx(ft,{item:e}),t.jsx("div",{className:"ims-image-label",children:e.name}),x.sel.includes(e.id)&&!e.locked&&t.jsx("div",{className:"ims-resize","data-resize":"se"})]},e.id)}),w.map(e=>{const a=F.find(n=>n.id===e.sourceIds[0]);return t.jsxs("div",{"data-generation-id":e.id,className:`ims-generation${e.status==="failed"?" is-failed":""}`,style:{left:e.x,top:e.y,width:e.w,height:e.h},role:e.status==="failed"?"alert":"status","aria-live":"polite",onPointerDown:n=>n.stopPropagation(),children:[t.jsx("div",{className:"ims-generation-sheen"}),t.jsxs("div",{className:"ims-generation-copy",children:[t.jsx(qe,{size:20,strokeWidth:1.5}),t.jsx("strong",{children:s(e.kind==="edit"?"imageStudio.generation.editing":"imageStudio.generation.creating")}),t.jsx("span",{children:e.status==="failed"?s("imageStudio.generation.failed"):s(e.status==="preparing"?"imageStudio.generation.preparing":"imageStudio.generation.running")}),a&&t.jsx("small",{children:s("imageStudio.generation.versionOf",{name:a.name})}),e.count>1&&t.jsxs("small",{children:[e.index+1," / ",e.count]})]}),e.status==="failed"&&t.jsxs("div",{className:"ims-generation-actions amx-stage-tools",children:[t.jsx("button",{onClick:()=>A(ge),children:s("imageStudio.generation.openChat")}),t.jsx("button",{title:s("imageStudio.generation.dismiss"),"aria-label":s("imageStudio.generation.dismiss"),onClick:()=>r.getState().removeGeneration(i.id,e.id),children:t.jsx(xe,{size:14})})]})]},e.id)}),x.marquee&&t.jsx("div",{className:"ims-marquee",style:{left:x.marquee.x,top:x.marquee.y,width:x.marquee.w,height:x.marquee.h}})]}),!T.length&&!w.length&&t.jsxs("div",{className:"ims-empty amx-stage-tools",children:[t.jsxs("div",{className:"ims-eyebrow",children:[s("imageStudio.title")," ",t.jsx("span",{children:"/"})," ",s("imageStudio.new")]}),t.jsx("h1",{children:s("imageStudio.headline")}),t.jsx("p",{children:s("imageStudio.intro")}),t.jsx("div",{className:"ims-starters",children:["poster","product","illustration"].map(e=>t.jsxs("button",{disabled:p,onClick:()=>Pe(`imageStudio.${e}Prompt`),children:[t.jsx("span",{children:s(`imageStudio.${e}`)}),t.jsx(Tt,{size:14})]},e))}),t.jsxs("button",{className:"ims-empty-import",disabled:p,onClick:()=>q.current?.click(),children:[t.jsx(W,{size:16}),s("imageStudio.import")]}),t.jsx("small",{children:s("imageStudio.importLimit")})]}),!w.length&&(l||p)&&t.jsxs("div",{className:"ims-progress amx-stage-tools",role:"status",children:[t.jsx(te,{size:15,className:"ims-spin"}),s(l?"imageStudio.generating":"imageStudio.busy")]}),Ne&&t.jsxs("div",{className:"ims-drop",children:[t.jsx(W,{size:28}),s("imageStudio.drop")]}),t.jsxs("div",{className:"ims-create-tools amx-stage-tools",role:"toolbar","aria-label":s("imageStudio.canvasTools"),children:[t.jsx("button",{title:s("imageStudio.selectTool"),"aria-label":s("imageStudio.selectTool"),"aria-pressed":!P,onClick:()=>{L(!1),I.current?.focus()},children:t.jsx(Ze,{size:17})}),t.jsx("button",{title:s("imageStudio.handTool"),"aria-label":s("imageStudio.handTool"),"aria-pressed":P,onClick:()=>{L(!0),I.current?.focus()},children:t.jsx(Dt,{size:17})}),t.jsx("span",{}),[["text",Mt],["rectangle",Je],["ellipse",et],["frame",Ot]].map(([e,a])=>t.jsx("button",{title:s(`imageStudio.add.${e}`),"aria-label":s(`imageStudio.add.${e}`),onClick:()=>Z(e),children:t.jsx(a,{size:17})},e))]}),ie&&t.jsx(st,{hostRef:I,vp:m.vp,items:G.map(e=>({key:e.id,kind:"card",box:e})),onCenter:m.centerOn}),t.jsx(it,{zoom:m.vp.z,onZoomBy:Te,onFit:()=>m.fitTo(G),snap:se,onSnap:ke,mini:ie,onMini:ze})]}),t.jsxs("footer",{className:"ims-footer",children:[t.jsx("span",{title:s("imageStudio.hint"),children:s(i?c?"imageStudio.unsaved":j?"imageStudio.saving":"imageStudio.local":"imageStudio.empty")}),i&&t.jsx("input",{"aria-label":s("imageStudio.name"),value:i.name,onChange:e=>r.getState().update(i.id,a=>({...a,name:e.target.value}),!1)}),t.jsx("span",{children:s("imageStudio.itemCount",{count:T.length})})]}),ae&&t.jsx($t,{target:ae,board:i,busy:p,onClose:Ie,onImport:()=>q.current?.click(),onExport:()=>z(!0),onInspect:()=>A(K),run:R}),t.jsx("input",{ref:q,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",multiple:!0,hidden:!0,onChange:e=>{const a=Array.from(e.target.files||[]);e.target.value="",R(()=>de(a))}})]})}const Ft={version:1,id:"",name:"",updatedAt:0,sessionId:null,images:[],collected:[]};export{xs as ImageStudioView};
@@ -1 +0,0 @@
1
- import{j as s,r as b,t as f}from"./index-fDB1l4d-.js";import{pK as v,hZ as x,bw as y,h$ as u,h_ as T,pL as z,fO as L,g_ as S}from"./appStore-DDOkzWDA.js";import{n as R}from"./nativeDownload-DsGyUSJ5.js";import"./react-b7FrqRQR.js";import"./pageStore-CyvNZEYX.js";import"./client-fKy9CWk0.js";import"./ipc-SAPDwyQ4.js";import"./dbStore-BIG5Mfh2.js";import"./drawingStore-CGvTqqYW.js";const k=t=>(t.mime?.startsWith("image/")??!1)||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(t.name);function E(t){const n=t.match(/^data:([^;]+);base64,(.*)$/),e=u(n?.[2]||"");return{mimeType:n?.[1]||"application/octet-stream",bytes:e,size:e.length}}function N(t,n,e,i){e=t.sourceSessionId||e;const o=i==="host"?v(e):null,l=r=>{R({text:r?.message||String(r),level:"error"})},a=o?.downloadHostFile;return{name:t.name,path:o?.local&&t.path&&/^([/~]|[A-Za-z]:[\\/])/.test(t.path)?t.path:void 0,load:async()=>{if(t.dataUrl)return E(t.dataUrl);if(!t.path)return null;if(o){const c=await o.readHostFile(t.path);return c.tooLarge?{tooLarge:!0,size:c.size}:{mimeType:c.mimeType,bytes:u(c.content),size:c.size}}const r=await T(y(e),e,t.path);return{mimeType:r.mimeType,bytes:u(r.content),size:r.size}},download:t.path?i==="host"?a?()=>{a(t.path,t.name).catch(l)}:void 0:()=>{x(y(e),e,t.path).catch(l)}:void 0}}const U=({f:t,onClick:n})=>{const e=S(t.mime||"",t.name);return s.jsxs("button",{className:"inline-file-card",title:t.name,onClick:n,children:[s.jsx(e,{size:15}),s.jsx("span",{className:"inline-file-name",children:t.name})]})},D=({f:t,cfg:n,sessionId:e,execMode:i,onClick:o})=>{e=t.sourceSessionId||e;const l=t.dataUrl||(t.path&&i!=="host"?z(y(e),e,t.path):null),[a,r]=b.useState(l),[c,h]=b.useState(!1),g=b.useRef(null);return b.useEffect(()=>{if(h(!1),l){r(l);return}let p=!1;return(async()=>{if(!t.path)return;const F=i==="host"?v(e):null;try{let d=null,w="";if(F){const m=await F.readHostFile(t.path);if(p)return;if(m.tooLarge){h(!0);return}d=u(m.content),w=m.mimeType}else if(i!=="host"){const m=await T(y(e),e,t.path);if(p)return;d=u(m.content),w=m.mimeType}if(!d||p)return;const j=URL.createObjectURL(new Blob([d],{type:w||t.mime||"image/png"}));g.current=j,r(j)}catch{p||h(!0)}})(),()=>{p=!0,g.current&&(URL.revokeObjectURL(g.current),g.current=null)}},[t.path,t.dataUrl]),c?s.jsx(U,{f:t,onClick:o}):a?s.jsx("img",{className:"inline-file-img",src:a,alt:t.name,title:t.name,draggable:!1,onError:()=>h(!0),...L({name:t.name,alt:{label:f("viewer.openTab"),run:o}})}):null},K=({files:t,cfg:n,sessionId:e,execMode:i,onOpenPreview:o})=>{if(!t.length)return null;const l=a=>o?.(N(a,n,e,i));return s.jsx("div",{className:"inline-file-grid",children:t.map((a,r)=>k(a)?s.jsx(D,{f:a,cfg:n,sessionId:e,execMode:i,onClick:()=>l(a)},r):s.jsx(U,{f:a,onClick:()=>l(a)},r))})};export{K as InlineFiles,N as targetFor};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./UnifiedPage-s7-tDSwG.js","./index-fDB1l4d-.js","./MarkdownBlock-DSItkLhu.js","./appStore-DDOkzWDA.js","./react-b7FrqRQR.js","./pageStore-CyvNZEYX.js","./client-fKy9CWk0.js","./pageStore-ys8L4rjF.css","./ipc-SAPDwyQ4.js","./nativeDownload-DsGyUSJ5.js","./dbStore-BIG5Mfh2.js","./drawingStore-CGvTqqYW.js","./appStore-iy8_Tmac.css","./index-CmsN2Zm2.js","./linkFollow-uke1Xtit.js","./selectionActions-DIq0xDm8.js","./listFold-BeNv2v6M.js","./FloatingToc-DO7SH8Ku.js","./MarkdownBlock-Cqfk5DhC.css","./type-Dt7RNB9g.js","./upload-Dy7svciS.js","./arrow-up-right-BptN64d-.js","./Chrome-C7F6fdDp.js","./magnet-Cqmm97W8.js","./canvasPrefs-ArsX3NFO.js","./InlineAiPanel-CdIPINsA.js","./InlineAiPanel-DZZijfif.css","./foldActions-DGIPTmE1.js","./undo-2-QimgpLBn.js","./code-xml-DCCD9eCS.js","./message-square-plus-BvUfAAZm.js","./UnifiedPage-CTmQpf2T.css"])))=>i.map(i=>d[i]);
2
- import{u as N,r as l,j as t,_ as k}from"./index-fDB1l4d-.js";import{q as T,F as L,l as C}from"./pageStore-CyvNZEYX.js";import"./client-fKy9CWk0.js";import{u as I,_ as M,R as A,V as F,aC as W,lf as H,l as O,fw as P}from"./appStore-DDOkzWDA.js";import"./react-b7FrqRQR.js";import"./ipc-SAPDwyQ4.js";import"./nativeDownload-DsGyUSJ5.js";import"./dbStore-BIG5Mfh2.js";import"./drawingStore-CGvTqqYW.js";const D=P(()=>k(()=>import("./UnifiedPage-s7-tDSwG.js").then(a=>a.q),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]),import.meta.url).then(a=>({default:a.UnifiedPage}))),U=/\.(md|markdown|txt|json|yaml|yml|toml|csv|log)$/i,V=5e3,J=/!\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/g;function R(a){const p=a.filter(r=>!r.dir),s=r=>r.startsWith("Journal/");return p.sort((r,m)=>s(r.path)!==s(m.path)?s(r.path)?-1:1:s(r.path)?m.path.localeCompare(r.path):r.path.localeCompare(m.path))}function q(a){try{const p=atob(a),s=Uint8Array.from(p,r=>r.charCodeAt(0));return new TextDecoder("utf-8").decode(s)}catch{return""}}function B(a){return a.replace(J,(p,s,r)=>`[image${s?`: ${s}`:""} — ${r}]`)}const ie=()=>{const{t:a}=N(),p=I(e=>e.cfg),[s,r]=l.useState(""),[m,_]=l.useState([]),[i,y]=l.useState(""),[b,u]=l.useState(""),[h,x]=l.useState(""),f=l.useRef(""),g=l.useRef(null),j=l.useRef(0),S=l.useMemo(()=>R(m),[m]),w=async(e,n)=>{const c=++j.current;if(!U.test(n.path)){u(""),g.current={path:n.path,mtime:n.mtime};return}const d=window.tangu?.readHostFile;if(!d){u("");return}try{const o=await d(`${e}/${n.path}`);if(c!==j.current)return;u(o.tooLarge?`(${o.size} bytes)`:q(String(o.content||""))),x(""),g.current={path:n.path,mtime:n.mtime}}catch(o){c===j.current&&x(o?.message||String(o))}},$=async()=>{try{const e=await H(O()),n=Array.isArray(e?.files)?e.files:[];r(e?.root||""),_(n),x("");const c=R(n),d=c.find(o=>o.path===f.current);if(d){const o=g.current;(!o||o.path!==d.path||o.mtime!==d.mtime)&&await w(e.root,d)}else c.length?(f.current=c[0].path,y(c[0].path),await w(e.root,c[0])):(f.current="",y(""),u(""),g.current=null)}catch(e){x(e?.message||String(e))}};l.useEffect(()=>{let e=!0,n=null;const c=async()=>{e&&(await $(),e&&(n=setTimeout(()=>{c()},V)))};return c(),()=>{e=!1,n&&clearTimeout(n)}},[p]);const z=e=>{f.current=e.path,y(e.path),w(s,e)},E=()=>{!s||!i||C.getState().openView("wsfile",{path:`${s}/${i}`,name:i.split(/[\\/]/).pop()||i},"main",{newTab:!0})},v=l.useMemo(()=>B(b),[b]);return t.jsxs("div",{className:"muse-lib",style:{display:"flex",height:"100%",minHeight:0,minWidth:0},children:[t.jsxs("div",{className:"muse-lib-list",style:{display:"flex",flexDirection:"column",minHeight:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"10px 12px",fontWeight:600,fontSize:"var(--ui-font-body, 13px)"},children:[t.jsx(T,{size:14})," ",a("view.museLibrary"),t.jsx("span",{style:{flex:1}}),t.jsx("button",{className:"icon-btn",title:a("muse.lib.refresh"),onClick:()=>{$()},children:t.jsx(M,{size:13})})]}),t.jsxs("div",{style:{overflowY:"auto",flex:1,padding:"0 6px 8px"},children:[S.length===0&&t.jsx("div",{className:"hint",style:{padding:"4px 6px"},children:h||a("muse.lib.empty")}),S.map(e=>t.jsxs("div",{className:"file-row",onClick:()=>z(e),style:{alignItems:"center",background:e.path===i?"var(--overlay-light, rgba(127,127,127,.1))":void 0,borderRadius:"var(--radius-sm)"},children:[e.path.startsWith("Journal/")?t.jsx(L,{size:13}):t.jsx(A,{size:13}),t.jsx("span",{className:"file-name",style:{flex:1,fontSize:"var(--ui-font-meta, 12px)"},children:e.path})]},e.path))]})]}),t.jsxs("div",{className:"muse-lib-preview",style:{flex:1,minWidth:0,flexDirection:"column",minHeight:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 14px",borderBottom:"var(--border-width, 1px) solid var(--border)",fontSize:"var(--ui-font-meta, 12px)",color:"var(--text-muted)"},children:[t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:i?`${s}/${i}`:"",children:i}),i&&t.jsxs("button",{className:"btn ghost sm",onClick:E,children:[t.jsx(F,{size:12})," ",a("muse.lib.openEditor")]})]}),t.jsxs("div",{style:{overflowY:"auto",flex:1,padding:"14px 24px 40px"},children:[h&&t.jsx("div",{className:"hint",style:{color:"var(--danger)"},children:h}),i&&v&&(/\.md$/i.test(i)?t.jsx("div",{className:"am-app tangu-lovable amx-pane amx-editor","data-muse-lib-preview":"amadeus",children:t.jsx(l.Suspense,{fallback:t.jsx("div",{className:"hint",children:i}),children:t.jsx(D,{path:`${s}/${i}`,initial:v,readOnly:!0},`${s}/${i}`)})}):t.jsx(W,{content:v})),i&&!v&&!h&&t.jsx("div",{className:"hint",children:i})]})]})]})};export{ie as MuseLibraryView,B as neutralizeRemoteImages,R as orderFiles};
@@ -1,2 +0,0 @@
1
- import{a as $,t as k,r as w,j as u,u as B}from"./index-fDB1l4d-.js";import{a0 as F,u as y,kQ as G,bw as T,kR as j,gm as X,bC as Y,aI as Z,kS as ee,kT as O,gp as te,kU as ne,kV as oe,hB as ae,c1 as b,gC as U,dH as se,l as re,a8 as ie,X as le,kW as ce,kX as de,cf as ue}from"./appStore-DDOkzWDA.js";import{c as V}from"./react-b7FrqRQR.js";import{l as he,bF as ge,ad as pe}from"./pageStore-CyvNZEYX.js";import"./client-fKy9CWk0.js";$({"btw.title":{zh:"顺便问",en:"By the way"},"btw.windowTitle":{zh:"顺便问 · {title}",en:"By the way · {title}"},"btw.context":{zh:"当前对话",en:"Conversation"},"btw.hint":{zh:"带着本会话上下文提问,不会加入对话,也不打断正在跑的任务",en:"Uses this conversation as context. Not added to it, and never interrupts a running task."},"btw.sideEmpty":{zh:"打开一个对话后,可以在这里顺便问",en:"Open a conversation to ask side questions here"},"btw.empty":{zh:"问点与当前对话有关的事:概念、代码、刚才那步为什么这么做……",en:"Ask about anything in this conversation: a concept, some code, why a step was taken…"},"btw.placeholder":{zh:"顺便问点什么…",en:"Ask a side question…"},"btw.defaultQuestion":{zh:"解释一下这段",en:"Explain this"},"btw.send":{zh:"发送",en:"Send"},"btw.stop":{zh:"停止",en:"Stop"},"btw.clear":{zh:"清空旁聊",en:"Clear side chat"},"btw.copy":{zh:"复制",en:"Copy"},"btw.copied":{zh:"已复制",en:"Copied"},"btw.quoteToChat":{zh:"带回这里",en:"Bring back"},"btw.quoted":{zh:"已带回输入框",en:"Brought back to the chat box"},"btw.removeQuote":{zh:"移除引用",en:"Remove quote"},"btw.thinking":{zh:"思考中…",en:"Thinking…"},"btw.stopped":{zh:"已停止",en:"Stopped"},"btw.noTools":{zh:"旁聊不能用工具,上面提到的操作都没有执行。",en:"Side chats have no tools. Nothing mentioned above was run."},"btw.errCut":{zh:"连接中断,回答不完整",en:"The connection dropped before the answer finished"},"btw.errUnsupported":{zh:"当前引擎还不支持旁聊,请更新 Forsion",en:"This engine does not support side questions yet. Update Forsion."},"btw.close":{zh:"关闭",en:"Close"},"btw.selectionAction":{zh:"顺便问",en:"Ask aside"},"btw.cmd":{zh:"顺便问(旁聊)",en:"Ask a side question"}});const m=new Map,v=new Set,N=new Set,x=new Map;let fe=0;function Me(e){return N.has(e.nonce)?!1:(N.add(e.nonce),!0)}function Ie(e,n){return!!e&&(!e.scope||e.scope===n)}function $e(e){const n=a=>typeof e?.[a]=="string"&&e[a]?e[a]:void 0,t=n("sessionId"),o=n("nonce");return t&&o?{sessionId:t,nonce:o,scope:n("scope"),title:n("title"),quote:n("quote"),question:n("question"),modelId:n("modelId"),messageId:n("messageId"),asideId:n("asideId")}:null}const me=V((e,n)=>({threads:{},webOpen:null,compose:{},anchors:{},saved:{},setCompose:(t,o)=>e(a=>({compose:{...a.compose,[t]:{...a.compose[t]??{draft:""},...o}}})),loadSaved:(t,o)=>{!o&&(v.has(t)||n().saved[t])||(v.add(t),j(T(t),t).then(a=>e(r=>({saved:{...r.saved,[t]:a}}))).catch(()=>{}).finally(()=>v.delete(t)))},applySeed:(t,o)=>{const a=t.sessionId;if(m.has(a)){x.set(a,t);return}const r=n().anchors[a]||{};if(t.asideId){if(r.asideId===t.asideId)return;const d=n().saved[a]?.find(i=>i.id===t.asideId);if(!d){o||j(T(a),a).then(i=>{e(l=>({saved:{...l.saved,[a]:i}})),n().applySeed(t,!0)}).catch(()=>{});return}const g=d.turns.map((i,l)=>({id:`${d.id}-${l}`,question:i.question,quote:i.quote,answer:i.answer,status:"done"}));e(i=>({threads:{...i.threads,[a]:g},anchors:{...i.anchors,[a]:{asideId:d.id,messageId:d.message_id||void 0}}}));return}t.messageId&&t.messageId!==r.messageId&&e(d=>({threads:{...d.threads,[a]:[]},anchors:{...d.anchors,[a]:{messageId:t.messageId}}}))},ask:async(t,o,a,r)=>{if(!o.trim()||m.has(t))return;const d=n().threads[t]||[],g=`btw-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`,i=s=>e(c=>({threads:{...c.threads,[t]:(c.threads[t]||[]).map(f=>f.id===g?{...f,...s(f)}:f)}}));e(s=>({threads:{...s.threads,[t]:[...d,{id:g,question:o,quote:a,answer:"",status:"streaming"}]}}));const l=new AbortController;m.set(t,l);const p=d.filter(s=>s.status==="done"&&s.answer).slice(-20).map(s=>({question:s.question,quote:s.quote,answer:s.answer})),h=n().anchors[t]||{};try{await we(t,{question:o,quote:a,thread:p,model_id:r||void 0,message_id:h.messageId,aside_id:h.asideId},s=>{s.type==="delta"?i(c=>({answer:c.answer+String(s.text??"")})):s.type==="done"?(i(c=>({answer:String(s.content||c.answer),status:"done",toolCallText:!!s.toolCallText})),s.asideId&&(e(c=>({anchors:{...c.anchors,[t]:{messageId:s.asideMessageId||c.anchors[t]?.messageId,asideId:s.asideId}}})),n().loadSaved(t,!0))):s.type==="error"&&i(()=>({status:"error",error:P(String(s.error||""))}))},l.signal),i(s=>s.status==="streaming"?{status:"error",error:k("btw.errCut")}:{})}catch(s){i(c=>c.status!=="streaming"?{}:l.signal.aborted?{status:"stopped"}:{status:"error",error:P(String(s?.message||s))})}finally{m.get(t)===l&&m.delete(t);const s=x.get(t);s&&!m.has(t)&&(x.delete(t),n().applySeed(s))}},stop:t=>m.get(t)?.abort(),clear:t=>{m.get(t)?.abort(),m.delete(t);const{asideId:o,messageId:a}=n().anchors[t]||{};e(r=>({threads:{...r.threads,[t]:[]},anchors:{...r.anchors,[t]:{messageId:a}}})),o&&(e(r=>({saved:{...r.saved,[t]:(r.saved[t]||[]).filter(d=>d.id!==o)}})),G(T(t),t,o).catch(()=>{}))},closeWeb:()=>e({webOpen:null})})),P=e=>/token_quota_exceeded/i.test(e)?k("chat.err.quota"):e;async function we(e,n,t,o){const a=T(e);let r;try{r=await X(a,`/agent/sessions/${encodeURIComponent(e)}/aside`,{method:"POST",signal:o,body:JSON.stringify({...n,app_id:Z,client:Y()})})}catch(l){if(a.via==="unit"&&!o.aborted){const p=ee(l);throw new Error(O(a,p,l?.code)||String(l?.message||l))}throw l}if(!r.ok||!r.body){const l=await r.text().catch(()=>"");let p="",h,s=null;try{s=JSON.parse(l),p=String(s?.detail||"");const c=s?.code;h=typeof c=="string"?c:void 0}catch{}if(a.via==="unit"){const c=te(r.status,{code:h});ne(a.key,c,oe(s));const f=O(a,c,h,s);if(f&&c!=="fatal")throw new Error(f)}throw new Error(p||(r.status===404?k("btw.errUnsupported"):`HTTP ${r.status}`))}const d=r.body.getReader(),g=new TextDecoder;let i="";for(;;){const{done:l,value:p}=await d.read();if(l)break;i+=g.decode(p,{stream:!0});const h=i.split(`
2
- `);i=h.pop()||"";for(const s of h)if(s.startsWith("data:"))try{t(JSON.parse(s.slice(5)))}catch{}}}function Be(e){const n=F()==="main"?y.getState().activeId:null,t={...e,title:e.title||void 0,scope:n,nonce:`${Date.now().toString(36)}-${++fe}`};if(n&&!window.tangu?.mobile){ae.getState().open(n,{id:`aside:${e.sessionId}`,title:k("btw.title"),aside:t});return}const o=window.tangu;if(o?.openFloatingPanel){o.openFloatingPanel({id:`btw:${e.sessionId}`,title:k("btw.windowTitle",{title:e.title||k("btw.title")}),builtin:"btw",params:{...t},...n?{sessionId:n}:{}});return}me.setState({webOpen:t})}function be(e){const n=e.trim().slice(0,2e4);if(!n)return;if(F()!=="main"&&window.tangu?.requestMainAction){window.tangu.requestMainAction("chat-quote",n);return}const t=he.getState(),o=t.rightVisible&&t.rightTabs.some(a=>a.type==="chat-panel"&&a.active);y.getState().setPendingChatQuote(o?"chat-panel":"chat",n),o||t.openView("chat",{followActive:!0,reuseKey:"primary"},"main")}function ye(e,n,t,o){return e.find(a=>a.item.tool===o&&(n.find(r=>r.id===a.pluginId)?.bundle?.enginePlugins??[]).some(r=>t[r]?.includes(o)))}const ke=e=>e.done&&!e.isError&&!e.parked&&e.result!==void 0,E=V(()=>({byEngine:{}}));let C=null,R=!1;function S(){return C?(R=!0,C):(C=(async()=>{let e={};try{if(await U()?.waitBackend?.(15e3)){const t=await se(re());e=Object.fromEntries(t.filter(o=>o.enabled&&o.active!==!1&&o.tools?.length).map(o=>[o.id,o.tools]))}}catch(n){console.warn("[amadeus] 拉引擎插件名下工具失败",n)}finally{E.setState({byEngine:e}),C=null,R&&(R=!1,S())}})(),C)}const Se=1e4;let A=0,_=!1;function Ce(){if(_)return;_=!0;let e;b.subscribe((n,t)=>{n.toolResultRenderers===t.toolResultRenderers||!n.toolResultRenderers.length||(clearTimeout(e),e=setTimeout(()=>{S()},300))}),U()?.subscribeReady?.(()=>{b.getState().toolResultRenderers.length&&S()}),b.getState().toolResultRenderers.length&&S()}function W(e,n,t,o){if(!ke(o))return;const a=ye(e,n,t,o.name);return!a&&e.some(r=>r.item.tool===o.name)&&Date.now()-A>Se&&(A=Date.now(),S()),a}function Te(){const e=b(o=>o.toolResultRenderers),n=b(o=>o.plugins),t=E(o=>o.byEngine);return w.useEffect(Ce,[]),w.useMemo(()=>e.length?o=>W(e,n,t,o):()=>{},[e,n,t])}function M(e){const n=b.getState();return n.toolResultRenderers.length?W(n.toolResultRenderers,n.plugins,E.getState().byEngine,e):void 0}const I=new Map;function ze(e){return{get:()=>I.get(e),set:n=>{I.set(e,n)}}}function ve(e){if(!e)return{};try{return JSON.parse(e)}catch{return e}}function J(e){try{const n=typeof e.title=="function"?e.title():e.title;return typeof n=="string"&&n.trim()||e.tool}catch{return e.tool}}$({"toolCard.openInDesk":{zh:"在 Desk 打开",en:"Open in Desk"},"toolCard.backToChat":{zh:"收回到对话",en:"Back to chat"},"toolCard.putBack":{zh:"放回对话",en:"Move back to chat"},"toolCard.showingInDesk":{zh:"正在 Desk 中显示",en:"Showing in Desk"},"toolCard.notLoaded":{zh:"这次调用的记录还没加载",en:"This call isn’t loaded yet"},"toolCard.noRenderer":{zh:"插件没在运行,先显示原始结果",en:"The plugin isn’t running. Showing the raw result."}});const L=w.createContext(null);function xe(e){return e.sessionId&&e.takesFiles&&!e.canvas&&e.width>=760&&!(e.childOpen&&e.deskOpen)?e.sessionId:null}const Re=2e4,q=e=>y.getState().deskBySession[e]?.items??[];function D(e,n,t){const o=y.getState(),a=o.deskBySession[e],r={key:`tool:${n}`,path:"",name:t,at:Date.now(),tool:{callId:n}},d=de(q(e).filter(g=>g.tool?.callId!==n),r);o.patchDesk(e,{items:d,mode:"open",...a?.userResized?{}:{size:"half"}})}function Q(e,n){const t=q(e).filter(o=>o.tool?.callId!==n);y.getState().patchDesk(e,{items:t,...t.length?{}:{mode:void 0}})}const z=new Set;async function Ee(e,n){if(z.has(n)||pe==="mobile"||!ce(!!y.getState().desktopConfig?.agentDeskEnabled))return;const t=H(e,n);if(!t)return;let o=M(t);if(!o&&b.getState().toolResultRenderers.some(a=>a.item.tool===t.name&&a.item.surface==="desk")){if(await S(),z.has(n))return;o=M(t)}!o||o.item.surface!=="desk"||(z.add(n),D(e,n,J(o.item)))}const qe=()=>z.clear();function H(e,n){for(const t of y.getState().messagesBySession[e]||[]){const o=t.toolEvents?.find(a=>a.id===n);if(o)return o}}function De(e){const{locale:n}=B(),t=b(o=>o.plugins.find(a=>a.id===e));return t?ue(t,n):e}function K({event:e,claim:n,surface:t,onQuote:o,fallback:a}){const r=w.useRef(null),[d,g]=w.useState(null),i=w.useRef(o);i.current=o;const{item:l}=n,p=d===l;return w.useEffect(()=>{const h=r.current;if(!h)return;h.textContent="";let s;try{s=l.mount(h,{id:e.id,tool:e.name,args:ve(e.arguments),result:e.result??"",surface:t,state:ze(e.id),quote:c=>{const f=String(c??"").trim().slice(0,Re);f&&(i.current?i.current(f):be(f))}})}catch(c){console.error(`[plugin:${n.pluginId}] 工具结果卡片挂载失败(${e.name})`,c),g(l)}return()=>{try{s?.()}catch(c){console.warn(`[plugin:${n.pluginId}] 工具结果卡片清理失败`,c)}h.textContent=""}},[l,p,e.id,e.name,e.arguments,e.result,t]),p?u.jsx(u.Fragment,{children:a}):u.jsx("div",{ref:r,className:`plugin-tool-card-body ${t}`,"data-plugin-tool-card-body":t})}function je({event:e,claim:n,onQuote:t,fallback:o}){const{t:a}=B(),r=w.useContext(L),d=y(l=>!!r&&!!l.deskBySession[r]?.items.some(p=>p.tool?.callId===e.id)),g=De(n.pluginId),i=J(n.item);return r&&d?u.jsxs("div",{className:"sketch-card plugin-tool-card is-stub","data-plugin-tool-stub":e.name,children:[u.jsx(ie,{size:14,className:"plugin-tool-stub-ic"}),u.jsxs("span",{className:"plugin-tool-stub-copy",children:[u.jsx("span",{className:"plugin-tool-stub-name",children:i}),u.jsxs("span",{className:"plugin-tool-stub-meta",children:[g," · ",a("toolCard.showingInDesk")]})]}),u.jsxs("button",{type:"button",className:"plugin-tool-stub-back","data-act":"tool-card-back",onClick:()=>Q(r,e.id),children:[u.jsx(le,{size:13}),a("toolCard.backToChat")]})]}):u.jsxs("div",{className:"sketch-card plugin-tool-card","data-plugin-tool-card":e.name,children:[u.jsxs("div",{className:"sketch-card-head",children:[u.jsxs("span",{className:"sketch-card-title",children:[i,u.jsxs("span",{className:"plugin-tool-card-by",children:[" · ",g]})]}),r&&u.jsx("button",{type:"button",className:"t2-iconbtn","data-act":"tool-card-desk",title:a("toolCard.openInDesk"),"aria-label":a("toolCard.openInDesk"),onClick:()=>D(r,e.id,i),children:u.jsx(ge,{size:14})})]}),u.jsx(K,{event:e,claim:n,surface:"inline",onQuote:t,fallback:o})]})}const Fe=Object.freeze(Object.defineProperty({__proto__:null,CardMount:K,PluginToolCard:je,ToolCardDeskContext:L,__resetToolCardPlacement:qe,deskItemsOf:q,findToolEvent:H,placeLiveToolCard:Ee,returnToolCardToChat:Q,showToolCardInDesk:D,toolCardDeskFor:xe,useToolCardOf:Te},Symbol.toStringTag,{value:"Module"}));export{K as C,je as P,L as T,$e as a,Ie as b,Me as c,Te as d,Fe as e,Be as o,be as q,Q as r,xe as t,me as u};
@@ -1 +0,0 @@
1
- import{j as t,r as l,u as xt,a as mt}from"./index-fDB1l4d-.js";import{p as K,A as ht}from"./astryxBridge-BL56QfEv.js";import{qA as Ye,qB as J,qj as Je,qk as kt,qP as pt,qQ as ft,ql as bt,qo as fe,qR as Re,qS as Pe,qm as gt,qT as be,qU as ie,qV as Se,nn as wt,D as Ve,qW as ge,qX as Fe,qY as He,qx as yt,V as jt,eS as vt,qZ as zt,pR as Nt,pS as $t}from"./appStore-DDOkzWDA.js";import{as as Ke,u as St,aE as Ct,aj as re,F as we,a6 as Tt,aA as Dt,R as qt}from"./pageStore-CyvNZEYX.js";import{r as Mt,I as It,m as le,t as ce,u as Et,c as At,S as Lt,a as se,D as ye,T as je}from"./draft-CBSW5tHx.js";import{E as Wt,r as Ot,h as Rt}from"./EventCard-QyYorE1_.js";import"./client-fKy9CWk0.js";import{Tooltip as Pt}from"./Tooltip-DOYi44eY.js";import"./react-b7FrqRQR.js";import"./ipc-SAPDwyQ4.js";import"./nativeDownload-DsGyUSJ5.js";import"./dbStore-BIG5Mfh2.js";import"./drawingStore-CGvTqqYW.js";import"./chevron-up-ChXNh14u.js";function Qe({label:r,inputID:x,labelID:d,isGroupLabel:n=!1,isLabelHidden:a=!1,isDisabled:g=!1,isOptional:p=!1,isRequired:h=!1,labelIcon:f,labelTooltip:N,description:m,descriptionID:M,ref:D}){const o=p?"Optional":h?"Required":null,k=n?"span":"label",b=t.jsxs(t.Fragment,{children:[f&&Mt(f,{size:"sm",color:"inherit"}),r,o&&t.jsxs("span",{className:"x1sodnla x141an7d x1ltkj2j xv1l7n4",children:[t.jsx("span",{"aria-hidden":"true",children:" ∙ "}),o]}),N&&t.jsx(Pt,{content:N,placement:"above",children:t.jsx(It,{icon:"info",size:"sm",color:"inherit"})})]});return t.jsxs(t.Fragment,{children:[t.jsx(k,{ref:D,id:d,htmlFor:n?void 0:x,...le(ce("field-label"),{0:{className:"x78zum5 x6s0dn4 xzye2dw x9ynric xcr08ib x1kq96og x1e4wzip xv1l7n4 x1ypdohk"},2:{className:"x78zum5 x6s0dn4 xzye2dw x9ynric xcr08ib x1kq96og x1e4wzip xnbbluu x1h6gzvc"},1:{className:"x78zum5 x6s0dn4 xzye2dw x9ynric xcr08ib x1kq96og x1e4wzip xv1l7n4 x1ypdohk xng3xce xzpqnlu xjm9jq1 xu96u03 xkdpibf xb3r6kr x1717udv x47corl x10l6tqk x13vifvy x87ps6o xuxw1ft x1i1rx1s"},3:{className:"x78zum5 x6s0dn4 xzye2dw x9ynric xcr08ib x1kq96og x1e4wzip xnbbluu x1h6gzvc xng3xce xzpqnlu xjm9jq1 xu96u03 xkdpibf xb3r6kr x1717udv x47corl x10l6tqk x13vifvy x87ps6o xuxw1ft x1i1rx1s"}}[!!g<<1|!!a<<0]),children:b}),m&&t.jsx("span",{id:M,...{0:{className:"x9ynric x141an7d x1ltkj2j x1sodnla xv1l7n4"},1:{className:"x9ynric x141an7d x1ltkj2j x1sodnla xv1l7n4 xng3xce xzpqnlu xjm9jq1 xu96u03 xkdpibf xb3r6kr x1717udv x47corl x10l6tqk x13vifvy x87ps6o xuxw1ft x1i1rx1s"}}[!!a<<0],children:m})]})}Qe.displayName="FieldLabel";let et=!1;typeof window<"u"&&requestAnimationFrame(()=>{et=!0});const Vt={slideDown:{kKVMdj:"x1srr2gu x1aquc0h",k44tkh:"x9uej1z",kyAemX:"x128ha8g",kWV6AL:"xskzprw",$$css:!0},slideUp:{kKVMdj:"x1dvww92 x1aquc0h",k44tkh:"x9uej1z",kyAemX:"x128ha8g",kWV6AL:"xskzprw",$$css:!0},fadeIn:{kKVMdj:"xqcmdr3 x1aquc0h",k44tkh:"x9uej1z",kyAemX:"x128ha8g",kWV6AL:"xskzprw",$$css:!0},scaleIn:{kKVMdj:"x97zbip x1aquc0h",k44tkh:"x9uej1z",kyAemX:"x128ha8g",kWV6AL:"xskzprw",$$css:!0}};function Ft(r="slideDown"){const[x]=l.useState(()=>et);return x?Vt[r]:null}const ve={base:{kMv6JI:"x9ynric",kGuDYH:"x141an7d",kLWn49:"x1ltkj2j",$$css:!0},attached:{keoZOQ:"x1c40v9y",kLKAdn:"x1ak3mig",kGO01o:"x1wesfrj",kg3NbH:"xf314gf",kqGeR4:"x14lggfu",kYm2EN:"xtufxuj",$$css:!0},detached:{keoZOQ:"xcsaf9d",k8WAf4:"xce4md1",kg3NbH:"xf314gf",kaIpWk:"xh6dtrn",$$css:!0}},Ht={warning:{kWkggS:"x24i8r5",kMwMTN:"xdhq94a",$$css:!0},error:{kWkggS:"x1pritpl",kMwMTN:"x1joocv1",$$css:!0},success:{kWkggS:"xu13z74",kMwMTN:"xltfdvo",$$css:!0}};function tt({ref:r,type:x,message:d,id:n,variant:a="attached",xstyle:g,className:p,style:h,...f}){const N=Ft("slideDown");return t.jsx("div",{ref:r,id:n,role:x==="error"?"alert":"status","aria-live":x==="error"?"assertive":"polite",...f,...le(ce("field-status",{type:x,variant:a}),K(ve.base,N,a==="attached"?ve.attached:ve.detached,Ht[x],g),p,h),children:d})}tt.displayName="FieldStatus";const Kt={x1tspnpo:"x1tspnpo",$$css:!0},st=l.createContext(null);st.displayName="CheckboxListContext";const v={container:{k1xSpc:"x78zum5",kGNEyG:"x6s0dn4",kOIVth:"x1txdalj",$$css:!0},containerLabelHidden:{kOIVth:"xxhr3t",$$css:!0},checkboxWrapper:{kVAEAm:"x1n2onr6",k1xSpc:"x78zum5",kGNEyG:"x6s0dn4",kjj79g:"xl56j7k",kmuXW:"x2lah0s",kHBbk8:"xc8icb0",$$css:!0},input:{kVAEAm:"x10l6tqk",kogj98:"x1ghz6dp",kmVPX3:"x1717udv",kSiTet:"xg01cxk",kkrTdU:"x1ypdohk",kY2c9j:"x1vjfegm",$$css:!0},inputDisabled:{kkrTdU:"x1h6gzvc",$$css:!0},checkbox:{k1xSpc:"x78zum5",kGNEyG:"x6s0dn4",kjj79g:"xl56j7k",kMzoRj:"x1litavf",ksu8eU:"x1y0btm7",kaIpWk:"xx3sua9",k1ekBW:"xts7igz",kIyJzY:"xuedmi6 x12w9bfk",kAMwcw:"xlr8y92",$$css:!0},checkboxFocus:{kI3sdo:"x1a2a7pz xkri23q",kInvED:"x81n7kt",$$css:!0},checkboxUnchecked:{kMwMTN:"xqwr325",kVAM5u:"xvy26l8 x1jtjlen",kWkggS:"x10xzikg xrsv7h",$$css:!0},checkboxChecked:{kMwMTN:"x17wrial",kVAM5u:"xad5do x1od6ugu",kWkggS:"x1ewilqj x6aeo4j",$$css:!0},checkboxDisabled:{kSiTet:"xbyyjgo",kVAM5u:"x14i3s5s xmt8yqp",$$css:!0},checkboxDisabledUnchecked:{kWkggS:"xwmxj5m x1cjfj8k",$$css:!0},checkmark:{k1xSpc:"x1s85apg",kMwMTN:"x17wrial",$$css:!0},checkmarkVisible:{k1xSpc:"x1lliihq",$$css:!0},indeterminateMark:{k1xSpc:"x1s85apg",kWkggS:"x1azo05",kaIpWk:"x1nj7uno",$$css:!0},indeterminateMarkVisible:{k1xSpc:"x1lliihq",$$css:!0}},Xe={sm:{kzqmXN:"xw4jnvo",kZKoxP:"x1qx5ct2",$$css:!0},md:{kzqmXN:"xvy4d1p",kZKoxP:"xxk0z11",$$css:!0}},Xt={sm:{kzqmXN:"x1xp8n7a",kZKoxP:"xmix8c7",$$css:!0},md:{kzqmXN:"x17z2i9w",kZKoxP:"x17rw0jw",$$css:!0}},Bt={sm:{kzqmXN:"xsmyaan",kZKoxP:"x1kpxq89",$$css:!0},md:{kzqmXN:"x6jxa94",kZKoxP:"x1v9usgg",$$css:!0}},Ut={sm:{kzqmXN:"x1fsd2vl",kZKoxP:"x36qwtl",$$css:!0},md:{kzqmXN:"xsmyaan",kZKoxP:"x36qwtl",$$css:!0}},_t={width:r=>[{kzqmXN:r!=null?"x5lhr3w":r,$$css:!0},{"--x-width":(x=>typeof x=="number"?x+"px":x??void 0)(r)}]};function Ce({label:r,isLabelHidden:x=!1,description:d,onChange:n,changeAction:a,isLoading:g=!1,value:p,isDisabled:h=!1,htmlName:f,disabledMessage:N,isReadOnly:m=!1,isOptional:M=!1,isRequired:D=!1,size:o="md",onFocus:k,onBlur:b,labelIcon:S,status:W,width:q,xstyle:Q,className:oe,style:ee,ref:ne}){const O=l.useId(),I=l.useId(),_=l.useId(),[,Z]=l.useTransition(),[R,ae]=l.useOptimistic(p),X=g||R!==p,C=h&&!!N,E=l.use(st),T=h&&(C||(E?.hasDisabledMessage??!1)),z=Et({placement:"above",focusTrigger:"always",isEnabled:C}),P=R==="indeterminate",V=R===!0,A=V||P,F=l.useCallback(w=>{w&&(w.indeterminate=P)},[P]),B=[];d&&!x&&B.push(I),W?.message&&B.push(_),C&&B.push(z.describedBy);const te=B.length>0?B.join(" "):void 0;return t.jsxs("div",{...le(ce("checkbox-input",{size:o}),K(q!=null&&_t.width(q),Q),oe,ee),children:[t.jsxs("div",{ref:w=>{z.interactionRef(w)},...K(v.container,x&&v.containerLabelHidden,!h&&Kt),children:[t.jsxs("div",{...K(v.checkboxWrapper,Xe[o]),children:[t.jsx("input",{ref:At(ne,F,z.positionRef),id:O,type:"checkbox",name:h?void 0:f,checked:V,disabled:h&&!T,"aria-disabled":T?"true":void 0,readOnly:m,required:D,onChange:w=>{if(h||X||m)return;const G=w.target.checked;n?.(G,w),a&&!w.defaultPrevented&&Z(async()=>{ae(G),await a(G,w)})},onFocus:k,onBlur:b,"aria-readonly":m||void 0,"aria-describedby":te,"aria-invalid":W?.type==="error"?!0:void 0,"aria-busy":X||void 0,...K(v.input,Xe[o],h&&v.inputDisabled)}),t.jsx("div",{"aria-hidden":"true",...le(ce("checkbox",{size:o,checked:V?"checked":P?"indeterminate":null,disabled:h?"disabled":null}),K(v.checkbox,Xt[o],!h&&v.checkboxFocus,A?v.checkboxChecked:v.checkboxUnchecked,h&&v.checkboxDisabled,h&&!A&&v.checkboxDisabledUnchecked)),children:X?t.jsx(Lt,{size:"sm",shade:"inherit"}):t.jsxs(t.Fragment,{children:[t.jsx("svg",{viewBox:"0 0 10 10",...K(v.checkmark,Bt[o],V&&v.checkmarkVisible),children:t.jsx("path",{d:"M8.5 2.5L4 7.5L1.5 5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}),t.jsx("div",{...K(v.indeterminateMark,Ut[o],P&&v.indeterminateMarkVisible)})]})})]}),t.jsx("div",{className:"x78zum5 xdt5ytf x1lsbc85",children:t.jsx(Qe,{label:r,inputID:O,isLabelHidden:x,isDisabled:h,isOptional:M,isRequired:D,labelIcon:S,description:d,descriptionID:I})})]}),W?.message&&t.jsx(tt,{type:W.type,message:W.message,id:_,variant:"detached"}),C&&z.renderTooltip(N)]})}Ce.displayName="CheckboxInput";const Be={日:0,天:0,一:1,二:2,三:3,四:4,五:5,六:6},Ue={sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6},_e="sunday|monday|tuesday|wednesday|thursday|friday|saturday|sun|mon|tues|tue|wed|thurs|thur|thu|fri|sat",ze={一:1,二:2,两:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10};function Zt(r){return/^\d+$/.test(r)?Number(r):r.startsWith("十")?10+(ze[r.slice(1)]??0):r.endsWith("十")?(ze[r[0]]??0)*10:ze[r]??NaN}function Ne(r,x,d=!1){const n=(x-r.getDay()+7)%7;return J(r,n===0&&d?7:n)}function Gt(r,x){const d=J(r,-((r.getDay()+6)%7));return J(d,7+(x+6)%7)}function Yt(r,x=new Date){const d=Ye(x);let n=` ${r} `,a=null,g=null;const p=(o,k)=>{const b=n.match(o);!b||b.index===void 0||!k(b)||(n=`${n.slice(0,b.index)} ${n.slice(b.index+b[0].length)}`)},h=(o,k,b)=>{const S=new Date(o,k-1,b);return S.getMonth()!==k-1||S.getDate()!==b?!1:(a=S,!0)},f=(o,k)=>h(d.getFullYear(),o,k)?(a<d&&h(d.getFullYear()+1,o,k),!0):!1;p(/(\d{4})-(\d{1,2})-(\d{1,2})/,o=>h(+o[1],+o[2],+o[3])),a||p(/(\d{1,2})月(\d{1,2})[日号]?/,o=>f(+o[1],+o[2])),a||p(new RegExp("(?<![\\d/:])(\\d{1,2})\\/(\\d{1,2})(?![\\d/:])"),o=>f(+o[1],+o[2])),a||p(/大后天/,()=>!!(a=J(d,3))),a||p(/后天/,()=>!!(a=J(d,2))),a||p(/明天|明日|\btomorrow\b/i,()=>!!(a=J(d,1))),a||p(/今天|今日|\btoday\b/i,()=>!!(a=d)),a||p(/下(?:个)?(?:周|星期|礼拜)([一二三四五六日天])/,o=>!!(a=Gt(d,Be[o[1]]))),a||p(/(?:周|星期|礼拜)([一二三四五六日天])/,o=>!!(a=Ne(d,Be[o[1]]))),a||p(new RegExp(`\\bnext\\s+(${_e})\\b`,"i"),o=>!!(a=Ne(d,Ue[o[1].slice(0,3).toLowerCase()],!0))),a||p(new RegExp(`\\b(?:on\\s+)?(${_e})\\b`,"i"),o=>!!(a=Ne(d,Ue[o[1].slice(0,3).toLowerCase()])));const N=(o,k)=>o&&/下午|晚上|傍晚|今晚/.test(o)&&k<12||o==="中午"&&k<11?k+12:k;if(p(/(上午|早上|早晨|中午|下午|傍晚|晚上|今晚)?\s*(\d{1,2}|[一二两三四五六七八九十]{1,3})[点點](半|(\d{1,2})分?)?/,o=>{const k=N(o[1],Zt(o[2])),b=o[3]==="半"?30:o[4]?+o[4]:0;return k>=0&&k<24&&b<60?(g=k*60+b,o[1]==="今晚"&&!a&&(a=d),!0):!1}),g===null&&p(/\b(?:at\s+)?(\d{1,2})(?::(\d{2}))?\s*(am|pm)\b/i,o=>{let k=+o[1]%12;o[3].toLowerCase()==="pm"&&(k+=12);const b=o[2]?+o[2]:0;return+o[1]>12||b>=60?!1:(g=k*60+b,!0)}),g===null&&p(new RegExp("(上午|下午|晚上)?\\s*(?:\\bat\\s+)?(?<![\\d:])(\\d{1,2}):(\\d{2})(?![\\d:])"),o=>{const k=N(o[1],+o[2]);return k>=24||+o[3]>=60?!1:(g=k*60+ +o[3],!0)}),!a&&g===null)return{title:r.trim(),value:null};const m=n.replace(/\s+/g," ").trim().replace(/^(?:at|on|by)\s+|\s+(?:at|on|by)$/i,"").trim(),M=Je(a??d,!0);if(g===null)return{title:m,value:M};const D=g;return{title:m,value:`${M}T${String(Math.floor(D/60)).padStart(2,"0")}:${String(D%60).padStart(2,"0")}`}}mt({"todolist.title":{zh:"待办",en:"To-dos"},"todolist.untitled":{zh:"未命名",en:"Untitled"},"todolist.done":{zh:"已完成",en:"Completed"},"todolist.openInNote":{zh:"在笔记中打开",en:"Open in note"},"todolist.clickToEdit":{zh:"点击编辑",en:"Click to edit"},"todolist.addPlaceholder":{zh:"新建待办,如「明天下午3点」",en:'New to-do, e.g. "tomorrow 3pm"'},"todolist.addPlaceholderShort":{zh:"新建待办",en:"New to-do"},"todolist.addTo":{zh:"加到「{name}」",en:'Adds to "{name}"'},"todolist.addTarget":{zh:"加到哪张表",en:"Add to"},"todolist.dragHint":{zh:"拖进日历排时段",en:"Drag into the calendar to schedule"},"todolist.dragHintGroups":{zh:"拖到「今天」「明天」或「未排期」上改日期",en:"Drag onto Today, Tomorrow or Unscheduled to change the date"},"todolist.allDone":{zh:"全部完成了。",en:"All done."},"todolist.emptyTitle":{zh:"还没有待办。",en:"No to-dos yet."},"todolist.emptyHintA":{zh:"在笔记里写 ",en:"Write "},"todolist.emptyExample":{zh:"- [ ] 事项 @2026-09-01",en:"- [ ] Task @2026-09-01"},"todolist.emptyHintB":{zh:"(打 ",en:" in a note (type "},"todolist.emptyHintC":{zh:" 有候选),或在上面直接加一条。",en:" for suggestions), or add one above."},"todolist.emptyHintCNoAdd":{zh:" 有候选)。",en:" for suggestions)."},"todolist.view.today":{zh:"今天",en:"Today"},"todolist.view.plan":{zh:"计划",en:"Scheduled"},"todolist.view.all":{zh:"全部",en:"All"},"todolist.viewsLabel":{zh:"筛选",en:"Filter"},"todolist.allLists":{zh:"所有清单",en:"All lists"},"todolist.noteTasks":{zh:"笔记里的任务",en:"Tasks in notes"},"todolist.filterLabel":{zh:"{view} · {list}",en:"{view} · {list}"},"todolist.mdAddHint":{zh:"笔记里的任务在笔记里写:",en:"Write tasks in a note: "},"todolist.todayDone":{zh:"今天的都做完了。",en:"Nothing left for today."},"todolist.planEmpty":{zh:"没有排了日期的待办。",en:"No scheduled to-dos."},"todolist.listEmpty":{zh:"这张清单里没有待办。",en:"No to-dos in this list."},"todolist.restItem":{zh:"{label} {n} 条",en:"{label} {n}"},"todolist.restSep":{zh:"、",en:" · "},"todolist.showAll":{zh:"看全部",en:"Show all"}});const Ze="done",Ge=480,$e="application/x-forsion-todo-md";function Jt(r){const x=a=>typeof a=="string"?a:typeof a=="number"?String(a):"",d=x(r?.src),n=x(r?.view);return{db:x(r?.db)||void 0,src:d==="db"||d==="md"?d:"all",side:r?.side===!0||r?.side==="true",view:Se.includes(n)?n:"all"}}function Qt(r){const[x,d]=l.useState(!1);return l.useLayoutEffect(()=>{const n=r.current;if(!n||typeof ResizeObserver>"u")return;d(n.offsetWidth>=Ge);const a=new ResizeObserver(([g])=>d(g.contentRect.width>=Ge));return a.observe(n),()=>a.disconnect()},[r]),x}function hs({params:r,leaf:x}={}){const d=Jt(r),{t:n}=xt(),a=kt(),g=pt(),p=l.useRef(null),h=Qt(p);l.useEffect(()=>{x?.loc==="main"&&!r?.miniSurface&&Ke("todo.open")},[]);const[f,N]=l.useState(d.view),[m,M]=l.useState({db:d.db,src:d.src}),D=e=>{N(e),x?.setParams({view:e})};l.useEffect(()=>{N(d.view)},[d.view]),l.useEffect(()=>{M(e=>e.db===d.db&&e.src===d.src?e:{db:d.db,src:d.src}),ee(null)},[d.db,d.src]);const o=e=>{M(e),ee(null),x?.setParams({db:e.db??"",src:e.src})},[k,b]=l.useState(new Set([...ft,Ze])),[S,W]=l.useState(null),[q,Q]=l.useState(""),[oe,ee]=l.useState(null),[ne,O]=l.useState(null),I=l.useRef(null),[_,Z]=l.useState(null);l.useEffect(()=>{if(!_)return;const e=()=>{window.setTimeout(()=>{I.current=null,Z(null),O(null)},0)};return window.addEventListener("drop",e,!0),window.addEventListener("dragend",e,!0),()=>{window.removeEventListener("drop",e,!0),window.removeEventListener("dragend",e,!0)}},[_]);const[R,ae]=l.useState(new Set),X=l.useRef(null),C=St(e=>e.vaultRoot)??"",E=bt(e=>e.byVault),T=l.useMemo(()=>Ye(new Date),[]),z=l.useMemo(()=>a.filter(e=>e.checkboxCol),[a]),P=l.useMemo(()=>z.filter(e=>!m.db||e.db.path===m.db),[z,m.db]),V=e=>fe(C,E,e.db.path,a.indexOf(e)),A=l.useMemo(()=>{const e=[];for(const s of z){const u=s.checkboxCol,c=fe(C,E,s.db.path,a.indexOf(s));for(const i of s.db.rows){const y=typeof i.cells[s.dateCol]=="string"?i.cells[s.dateCol]:"";e.push({key:`db:${s.db.path}:${i.rowId}`,name:i.name||n("todolist.untitled"),checked:i.cells[u]===!0,raw:y,source:s.db.name,short:s.db.name,color:c,db:s,rowId:i.rowId})}}for(const s of g.filter(u=>u.isTask))e.push({key:`md:${s.path}:${s.line}`,name:s.text,checked:s.checked,raw:s.due,source:s.heading?`${s.title} › ${s.heading}`:s.title,short:s.title,note:{path:s.path,heading:s.heading},mark:s});return e},[z,a,g,C,E,n]),F=l.useMemo(()=>A.filter(e=>e.db?m.src!=="md"&&(!m.db||e.db.db.path===m.db):m.src!=="db"&&!m.db),[A,m]),B=e=>e.checked&&!R.has(e.key),te=l.useMemo(()=>F.filter(e=>e.checked&&!R.has(e.key)),[F,R]),w=l.useMemo(()=>{const e=new Map;for(const s of F){if(B(s))continue;const u=Re(s.raw,T),c=e.get(u);c?c.push(s):e.set(u,[s])}for(const s of e.values())s.sort((u,c)=>{const i=Pe(u.raw),y=Pe(c.raw);return(i===y?0:i<y?-1:1)||u.source.localeCompare(c.source,"zh")||u.name.localeCompare(c.name,"zh")});return e},[F,T,R]),G=(e,s,u)=>{u(),s&&(Ke("todo.done"),ae(c=>new Set(c).add(e.key)),setTimeout(()=>ae(c=>{const i=new Set(c);return i.delete(e.key),i}),1e3))},ue=e=>be.reduce((s,u)=>s+(ie(e,u)?w.get(u)?.length??0:0),0),xe=ue(f),Te=e=>A.filter(s=>!s.checked&&e(s)).length,De=A.some(e=>e.mark),ot=new Set(F.map(e=>e.db?.db.path??"md")).size>1,nt=e=>b(s=>{const u=new Set(s);return u.has(e)?u.delete(e):u.add(e),u}),qe=l.useMemo(()=>{if(!S)return null;const e=z.find(c=>c.db.path===S.dbPath),s=e?.db.rows.find(c=>c.rowId===S.rowId);if(!e||!s)return null;const u=typeof s.cells[e.dateCol]=="string"?s.cells[e.dateCol]:"";return{db:e.db,row:s,colId:e.dateCol,title:s.name,raw:u,color:fe(C,E,e.db.path,a.indexOf(e))}},[S,z,a,C,E]),U=l.useMemo(()=>P.filter(e=>!e.db.readonly&&!e.db.isNoteView),[P]),L=l.useMemo(()=>{const e=gt(C,E);return U.find(s=>s.db.path===oe)??U.find(s=>s.db.path===m.db)??U.find(s=>s.db.path===e)??U[0]},[U,oe,m.db,C,E]),H=l.useMemo(()=>q.trim()?Yt(q):null,[q]),at=()=>{if(!H||!L)return;const e=H.title||q.trim();yt(L.db,L.dateCol,H.value??Je(T,!0),e),Q("")};l.useEffect(()=>{const e=s=>{if(s.key!=="n"&&s.key!=="N"||s.metaKey||s.ctrlKey||s.altKey||s.defaultPrevented||s.target?.closest("input, textarea, select, [contenteditable]"))return;const c=X.current,i=p.current;if(!c||!i||!c.getClientRects().length)return;const y=document.activeElement;(!y||y===document.body||i.contains(y)||d.side&&y.closest(".amx-cal")||!d.side&&!y.closest(".dv-react-part"))&&(s.preventDefault(),c.focus())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[d.side]);const dt=(e,s)=>{if(e.note){vt(e.note.path,e.note.heading);return}if(!e.db||!e.rowId)return;const c=(s.currentTarget.querySelector(".amx-todo-name")??s.currentTarget).getBoundingClientRect();W({dbPath:e.db.db.path,rowId:e.rowId,at:{left:c.left,top:c.top,right:c.right,bottom:c.bottom,zoom:qt(s.currentTarget)||1}})},it=e=>{if(e.key==="ArrowDown"||e.key==="ArrowUp"){const s=[...p.current?.querySelectorAll(".amx-todo-reveal.is-open .amx-todo-main")??[]],u=s.indexOf(e.currentTarget),c=s[u+(e.key==="ArrowDown"?1:-1)];c&&(e.preventDefault(),c.focus())}else e.key===" "&&(e.preventDefault(),e.currentTarget.closest("li")?.querySelector('input[type="checkbox"]')?.click())},me=!!Ct?.patchMark,rt=(e,s)=>{const u=He(s,T);if(u===void 0)return;const c=zt(e.raw,u);if(e.db&&e.rowId){const i=e.db.db.rows.find(y=>y.rowId===e.rowId);i&&Ot(e.db.db,i,e.db.dateCol,e.raw,c,e.name)}else e.mark&&me&&Rt(e.mark,e.raw,c,e.name)},Y=(e,s)=>!e||He(s,T)===void 0||Re(e.raw,T)===s?!1:e.mark?me&&s!=="undated":!!(e.db&&e.rowId&&!e.db.db.readonly),Me=e=>ot?h?t.jsxs("span",{className:"amx-todo-srctag",title:e.source,children:[e.mark?t.jsx(we,{size:12}):t.jsx("i",{className:"amx-todo-dot",style:{background:e.color}}),t.jsx("span",{className:"amx-todo-srcname",children:e.short})]}):e.mark?t.jsx(we,{className:"amx-todo-srcic",size:11,"aria-label":e.source}):t.jsx("i",{className:"amx-todo-dot",style:{background:e.color},title:e.source}):null,Ie=e=>{const s=ge(e.raw,T),u=!!(d.side&&e.db&&e.rowId&&!e.db.db.readonly),c=!e.checked&&(u||Y(e,"today")||Y(e,"tomorrow")||Y(e,"undated"));return t.jsxs("li",{className:"amx-todo-item",draggable:c||void 0,title:c?n(u?"todolist.dragHint":"todolist.dragHintGroups"):void 0,onDragStart:c?i=>{I.current=e,requestAnimationFrame(()=>Z(e)),e.db&&e.rowId?i.dataTransfer.setData(je,JSON.stringify({dbPath:e.db.db.path,rowId:e.rowId})):i.dataTransfer.setData($e,e.key),i.dataTransfer.effectAllowed="move",i.currentTarget.classList.add("dragging")}:void 0,onDragEnd:c?i=>{i.currentTarget.classList.remove("dragging"),I.current=null,Z(null),O(null)}:void 0,onClick:i=>{i.target.closest(".amx-todo-main, .astryx-checkbox-input, .amx-todo-box")||i.currentTarget.querySelector(".amx-todo-main")?.click()},children:[e.db&&e.rowId?t.jsx(Ce,{label:e.name,isLabelHidden:!0,size:"sm",value:e.checked,onChange:i=>G(e,i,()=>Nt(e.db.db,e.rowId,e.db.checkboxCol,i?!0:void 0))}):e.mark&&me?t.jsx(Ce,{label:e.name,isLabelHidden:!0,size:"sm",value:e.checked,onChange:i=>G(e,i,()=>$t(e.mark,{checked:i}))}):t.jsx("span",{className:`amx-todo-box${e.checked?" on":""}`,"aria-hidden":"true"}),t.jsxs("button",{className:"amx-todo-main",title:e.note?n("todolist.openInNote"):n("todolist.clickToEdit"),onClick:i=>dt(e,i),onKeyDown:it,children:[t.jsx("span",{className:`amx-todo-name${e.checked?" done":""}`,children:e.name}),e.note?t.jsx(jt,{className:"amx-todo-jump",size:12}):null]}),h&&Me(e),t.jsxs("span",{className:"amx-todo-duecell",children:[!h&&Me(e),e.raw?t.jsxs("span",{className:`amx-todo-due ${s.tone}`,children:[e.raw.includes("T")&&t.jsx(Ve,{size:11}),s.label]}):null]})]},e.key)},Ee=(e,s,u,c,i)=>{const y=!k.has(e),pe=j=>{const $=j.dataTransfer.types;return $.includes(je)||$.includes($e)},ct=(j,$)=>{if(!($.db&&$.rowId))return j.dataTransfer.getData($e)===$.key;try{const Oe=JSON.parse(j.dataTransfer.getData(je)||"{}");return Oe.dbPath===$.db?.db.path&&Oe.rowId===$.rowId}catch{return!1}},ut=i?{onDragOver:j=>{pe(j)&&Y(I.current,i)&&(j.preventDefault(),j.dataTransfer.dropEffect="move",ne!==i&&O(i))},onDragLeave:()=>O(j=>j===i?null:j),onDrop:j=>{j.preventDefault();const $=I.current;I.current=null,Z(null),O(null),$&&pe(j)&&ct(j,$)&&Y($,i)&&rt($,i)}}:{};return t.jsxs("section",{className:"amx-todo-group",children:[t.jsxs("button",{className:`amx-todo-ghead${y?" is-open":""}${ne===i&&i?" is-drop":""}`,onClick:()=>nt(e),"aria-expanded":y,...ut,children:[t.jsx(Dt,{className:"amx-todo-caret",size:12}),t.jsx("span",{className:"amx-todo-gname",children:s}),t.jsx("span",{className:"amx-todo-gcount",children:u.length})]}),t.jsx("div",{className:`amx-todo-reveal${y?" is-open":""}`,children:t.jsx("div",{className:"amx-todo-reveal-in",children:c})})]},e)},de=e=>n(`todolist.view.${e}`),he=m.src==="md"?n("todolist.noteTasks"):m.db?z.find(e=>e.db.path===m.db)?.db.name??m.db:"",Ae=e=>e?t.jsx(re,{size:14}):t.jsx("span",{style:{display:"inline-block",width:14}}),Le=t.jsxs(t.Fragment,{children:[t.jsx(se,{icon:Ae(!m.db&&m.src==="all"),label:n("todolist.allLists"),onClick:()=>o({src:"all"})}),z.map(e=>t.jsx(se,{icon:m.db===e.db.path?t.jsx(re,{size:14}):t.jsx("i",{className:"amx-todo-dot amx-todo-menudot",style:{background:V(e)}}),label:e.db.name,endContent:t.jsx("span",{className:"amx-todo-menun",children:Te(s=>s.db===e)}),onClick:()=>o({db:e.db.path,src:"all"})},e.db.path)),De&&t.jsx(se,{icon:m.src==="md"?t.jsx(re,{size:14}):t.jsx(we,{size:14}),label:n("todolist.noteTasks"),endContent:t.jsx("span",{className:"amx-todo-menun",children:Te(e=>!!e.mark)}),onClick:()=>o({src:"md"})})]}),ke=z.length+(De?1:0)>1,lt=be.filter(e=>ie(f,e)&&w.get(e)?.length||Y(_,e)),We=f==="today"?be.filter(e=>!ie("today",e)&&w.get(e)?.length):[];return t.jsx(ht,{children:t.jsxs("div",{className:`amx-todo${h?" is-wide":""}`,ref:p,children:[t.jsxs("div",{className:"amx-todo-col",children:[t.jsxs("div",{className:"amx-todo-bar",children:[t.jsx("span",{className:"amx-todo-title",children:n("todolist.title")}),xe>0&&t.jsx("span",{className:"amx-todo-total",children:xe}),t.jsx("span",{className:"amx-todo-grow"}),h?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"seg seg-sm amx-todo-seg",role:"group","aria-label":n("todolist.viewsLabel"),children:Se.map(e=>t.jsxs("button",{className:f===e?"active":"","aria-pressed":f===e,onClick:()=>D(e),children:[de(e),t.jsx("em",{children:ue(e)})]},e))}),ke&&t.jsx(ye,{button:{label:he||n("todolist.allLists"),variant:"ghost",size:"sm",icon:t.jsx(wt,{size:13})},menuWidth:220,children:Le})]}):t.jsxs(ye,{button:{label:he?n("todolist.filterLabel",{view:de(f),list:he}):de(f),variant:"ghost",size:"sm"},menuWidth:220,children:[Se.map(e=>t.jsx(se,{icon:Ae(f===e),label:de(e),endContent:t.jsx("span",{className:"amx-todo-menun",children:ue(e)}),onClick:()=>D(e)},e)),ke&&t.jsx("div",{className:"amx-cal-menusep",role:"separator"}),ke&&Le]})]}),m.src==="md"?t.jsxs("div",{className:"amx-todo-addhint",children:[n("todolist.mdAddHint"),t.jsx("code",{children:n("todolist.emptyExample")})]}):L&&t.jsxs("div",{className:`amx-todo-add${q?" typing":""}`,children:[t.jsx(Tt,{className:"amx-todo-addicon",size:13}),t.jsx("input",{ref:X,className:"amx-todo-addinput",placeholder:n(h?"todolist.addPlaceholder":"todolist.addPlaceholderShort"),value:q,onChange:e=>Q(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key==="Enter"&&(e.preventDefault(),at()),e.key==="Escape"&&(Q(""),e.currentTarget.blur()))}}),U.length>1&&t.jsx("span",{className:"amx-todo-target",children:t.jsx(ye,{button:{label:h?L.db.name:n("todolist.addTarget"),isIconOnly:!h,variant:"ghost",size:"sm",icon:t.jsx("i",{className:"amx-todo-dot",style:{background:V(L)}})},menuWidth:200,children:U.map(e=>t.jsx(se,{icon:t.jsx("i",{className:"amx-todo-dot amx-todo-menudot",style:{background:V(e)}}),label:e.db.name,endContent:e===L?t.jsx(re,{size:14}):void 0,onClick:()=>{ee(e.db.path),X.current?.focus()}},e.db.path))})}),!q&&t.jsx("kbd",{className:"amx-cal-panel-kbd",children:"N"}),H&&t.jsxs("div",{className:"amx-todo-addprev",children:[H.value&&t.jsxs("span",{className:`amx-todo-due ${ge(H.value,T).tone}`,children:[H.value.includes("T")&&t.jsx(Ve,{size:11}),ge(H.value,T).label]}),t.jsx("span",{children:n("todolist.addTo",{name:L.db.name})})]})]}),A.length===0&&t.jsxs("div",{className:"amx-todo-empty",children:[n("todolist.emptyTitle"),!r?.miniSurface&&t.jsxs(t.Fragment,{children:[t.jsx("br",{}),n("todolist.emptyHintA"),t.jsx("code",{children:n("todolist.emptyExample")}),n("todolist.emptyHintB"),t.jsx("code",{children:"@"}),n(L?"todolist.emptyHintC":"todolist.emptyHintCNoAdd")]})]}),A.length>0&&xe===0&&t.jsx("div",{className:"amx-todo-empty",children:f==="today"?n("todolist.todayDone"):f==="plan"?n("todolist.planEmpty"):F.length===0?n("todolist.listEmpty"):n("todolist.allDone")}),lt.map(e=>Ee(e,Fe[e],w.get(e)??[],t.jsx("ul",{className:"amx-todo-list",children:ie(f,e)?(w.get(e)??[]).map(Ie):null}),e)),We.length>0&&t.jsxs("div",{className:"amx-todo-rest",children:[We.map(e=>n("todolist.restItem",{label:Fe[e],n:w.get(e).length})).join(n("todolist.restSep"))," · ",t.jsx("button",{className:"amx-todo-link",onClick:()=>D("all"),children:n("todolist.showAll")})]}),f==="all"&&te.length>0&&Ee(Ze,n("todolist.done"),te,t.jsx("ul",{className:"amx-todo-list",children:te.map(Ie)}))]}),qe&&S&&t.jsx(Wt,{ev:qe,at:S.at,onClose:()=>W(null)})]})})}export{hs as TodoListView,Jt as readTodoParams};