pisper 0.6.4 → 0.6.5

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 (95) hide show
  1. package/package.json +6 -6
  2. package/web/.vite/manifest.json +315 -377
  3. package/web/assets/{AppDialog-BOGrPFbo.js → AppDialog-DW5knado.js} +1 -1
  4. package/web/assets/{AppOverlays-D1vfPPIC.js → AppOverlays-Bp8RcUF5.js} +1 -1
  5. package/web/assets/AppSelect-D149YYg1.js +1 -0
  6. package/web/assets/{AppShortcuts-Dd4gu7qz.js → AppShortcuts-D1jjdZDS.js} +1 -1
  7. package/web/assets/{AssetsPage-BPhPo5eU.js → AssetsPage-C7AlHS3s.js} +1 -1
  8. package/web/assets/{ChannelsPage-Cu4v-GU2.js → ChannelsPage-BJltcbA8.js} +1 -1
  9. package/web/assets/ChatAppearancePage-BXvAK8yY.js +2 -0
  10. package/web/assets/{ChatHistoryPage-BYqJFbY5.js → ChatHistoryPage-D3fm9Tw9.js} +1 -1
  11. package/web/assets/ChatPage-BFJm1sNL.js +554 -0
  12. package/web/assets/{ConfigPage-Z-BQwP2X.js → ConfigPage-DLgNJdgQ.js} +1 -1
  13. package/web/assets/{DecisionsPage-Db6MIGD2.js → DecisionsPage-57a_ZuRk.js} +1 -1
  14. package/web/assets/{DesktopWindowControls-CBYGv94u.js → DesktopWindowControls-xHry1hUJ.js} +1 -1
  15. package/web/assets/{FloatingWidgets-dzsQIxAO.js → FloatingWidgets-CJQjpX-U.js} +1 -1
  16. package/web/assets/{GitDiffViewer-m5aLB7Li.js → GitDiffViewer-91SrTCWo.js} +1 -1
  17. package/web/assets/{MarkdownMessage-CA9ODRKk.js → MarkdownMessage-DeTzbwid.js} +1 -1
  18. package/web/assets/{McpPage-rerFxjYZ.js → McpPage-CTJ_aKOo.js} +1 -1
  19. package/web/assets/{MemoryPage-cukfU824.js → MemoryPage-DRTc4YT9.js} +1 -1
  20. package/web/assets/MobileContextScreen-CnaR6ssx.js +2 -0
  21. package/web/assets/{MobileNavigation-CEVgs1Ke.js → MobileNavigation-Cw7L9pSg.js} +1 -1
  22. package/web/assets/{PageHeader-DIs9bESb.js → PageHeader-B2qhKXvC.js} +1 -1
  23. package/web/assets/{PluginsPage-09Um3mY4.js → PluginsPage-DVCWLVRB.js} +1 -1
  24. package/web/assets/{QuickPromptIdeas-DGIL0nN7.js → QuickPromptIdeas-xQFMgSGF.js} +1 -1
  25. package/web/assets/{SchedulesPage-C75QUeB5.js → SchedulesPage-B_YjdfoV.js} +1 -1
  26. package/web/assets/SessionContextPanel-BwHEDkJE.js +1 -0
  27. package/web/assets/{SessionFilesPane-DPijesqH.js → SessionFilesPane-CUhqwp87.js} +2 -2
  28. package/web/assets/{SidebarMoreTools-D1nDS3i0.js → SidebarMoreTools-BHJuLoCs.js} +1 -1
  29. package/web/assets/SidebarRecentSessions-CVIFZ66b.js +2 -0
  30. package/web/assets/{SidebarSettingsButton-CRdV0Vft.js → SidebarSettingsButton-5N0RlmoI.js} +1 -1
  31. package/web/assets/{SidebarUpdateStatus-DgNJBwgT.js → SidebarUpdateStatus-CVxo4zaS.js} +1 -1
  32. package/web/assets/{SkillsPage-DLirgTyX.js → SkillsPage-KsP2YFgx.js} +1 -1
  33. package/web/assets/{TerminalPanel-CJPy4Qhs.js → TerminalPanel-PK0ubUYF.js} +1 -1
  34. package/web/assets/{ThemeToggleButton-C5QA5Kf2.js → ThemeToggleButton-BFby07PX.js} +1 -1
  35. package/web/assets/{WebDesktopPet-DgyHLE9y.js → WebDesktopPet-juirMq3L.js} +1 -1
  36. package/web/assets/{WorkbenchSidebarToggle-CcO1Al5A.js → WorkbenchSidebarToggle-B-YDZEZn.js} +1 -1
  37. package/web/assets/WorkflowsPage-Bsw_TnA6.js +1 -0
  38. package/web/assets/WorkspacePicker-CDJPgjpW.js +1 -0
  39. package/web/assets/{api-YI8_cHpR.js → api-DmuPqjXK.js} +1 -1
  40. package/web/assets/{app-primitives-SxfoFmHc.js → app-primitives-BBXY6U2S.js} +1 -1
  41. package/web/assets/catalog-Cs8cjmnr.js +1 -0
  42. package/web/assets/{chat-api-CqF-FICX.js → chat-api-cEcUMaNX.js} +1 -1
  43. package/web/assets/{client-store-BP_3-plw.js → client-store-CV7NgPf7.js} +1 -1
  44. package/web/assets/{component-api-CN9Tcn5p.js → component-api-guxJtKAP.js} +1 -1
  45. package/web/assets/{config-search-DOIJENN1.js → config-search-DzgcCirf.js} +1 -1
  46. package/web/assets/dist-DAs5KRGl.js +1 -0
  47. package/web/assets/dist-swnK7PHk.js +1 -0
  48. package/web/assets/{dropdown-menu-pKRdLJUe.js → dropdown-menu-DmL4pJTo.js} +1 -1
  49. package/web/assets/{events-KqdUtjsm.js → events-DjkpUZEu.js} +1 -1
  50. package/web/assets/{floating-widgets-store-Pjm1AdvO.js → floating-widgets-store-C3frcaki.js} +2 -2
  51. package/web/assets/{http-Be2GB6DH.js → http-C4bTWPzF.js} +1 -1
  52. package/web/assets/i18n-DKgrgj0w.js +1 -0
  53. package/web/assets/index-DJAtBVyc.css +2 -0
  54. package/web/assets/{index-AF29hfx9.js → index-Dm1UDg72.js} +2 -2
  55. package/web/assets/mount-app-Brtj-l-d.js +9 -0
  56. package/web/assets/panels-top-left-K8n2CefH.js +1 -0
  57. package/web/assets/{popover-CQqAaq-c.js → popover-BgmMy1PJ.js} +1 -1
  58. package/web/assets/public-BDXsCmtv.js +1 -0
  59. package/web/assets/{public-components-C4ndcOCF.js → public-components-w2PENGYg.js} +1 -1
  60. package/web/assets/{runtime-capabilities-store-CiL3ZPEo.js → runtime-capabilities-store-1N8axw9r.js} +1 -1
  61. package/web/assets/{session-change-summary-api--7cl4LDn.js → session-change-summary-api-BQILNzT4.js} +1 -1
  62. package/web/assets/{session-context-store-DJnHgWwb.js → session-context-store-DQHmNaRN.js} +1 -1
  63. package/web/assets/{session-list-DkNhT87s.js → session-list-JA31_Ff4.js} +1 -1
  64. package/web/assets/{settings-navigation-CI7Yt4Or.js → settings-navigation-dqR4yOPY.js} +1 -1
  65. package/web/assets/{shortcuts-C_Cph88H.js → shortcuts-CAX2SVZi.js} +1 -1
  66. package/web/assets/{side-chat-context-Dn8w9ut8.js → side-chat-context-B0oP2eS-.js} +2 -2
  67. package/web/assets/{speech-session-CoUr4n9Q.js → speech-session-C-vI4YXQ.js} +1 -1
  68. package/web/assets/{startup-queries-ByepQfGF.js → startup-queries-Ci3kCPI9.js} +1 -1
  69. package/web/assets/tabs-DQYVDdOp.js +1 -0
  70. package/web/assets/{ui-store-BGs-dEVz.js → ui-store-DLloh4Rv.js} +1 -1
  71. package/web/assets/{use-i18n-a84Zp9dV.js → use-i18n-C7st2Mx5.js} +1 -1
  72. package/web/assets/{useCustomUiComponents-BaQ_fwbr.js → useCustomUiComponents-B5fflBrn.js} +1 -1
  73. package/web/index.html +2 -2
  74. package/web/assets/AppSelect-BCexz4Ty.js +0 -1
  75. package/web/assets/ChatAppearancePage-BLRQ7aH6.js +0 -2
  76. package/web/assets/ChatPage-tqAIj2Go.js +0 -554
  77. package/web/assets/MobileContextScreen-W8V4H3Xv.js +0 -2
  78. package/web/assets/SessionContextPanel-oaKXyi7k.js +0 -1
  79. package/web/assets/SidebarRecentSessions-a7z2ZvDv.js +0 -2
  80. package/web/assets/WorkflowsPage-DrKHzJvb.js +0 -1
  81. package/web/assets/WorkspacePicker-B3liZkwe.js +0 -1
  82. package/web/assets/arrow-up-DST6-qVQ.js +0 -1
  83. package/web/assets/catalog-BPCnu3F8.js +0 -1
  84. package/web/assets/dist-B7rNRXig.js +0 -1
  85. package/web/assets/dist-C3P9WH0T.js +0 -1
  86. package/web/assets/dist-CXiO_DNx.js +0 -1
  87. package/web/assets/dist-D8Wfxh48.js +0 -1
  88. package/web/assets/folder-DPM8D8cf.js +0 -1
  89. package/web/assets/house-BNrzTkx9.js +0 -1
  90. package/web/assets/i18n-8nTnthu6.js +0 -1
  91. package/web/assets/index-BAmsg90v.css +0 -2
  92. package/web/assets/mount-app-WW5hteuX.js +0 -9
  93. package/web/assets/panels-top-left-BlZftvhg.js +0 -1
  94. package/web/assets/public-c36e4881.js +0 -1
  95. package/web/assets/tabs-B60r4YwO.js +0 -1
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AssetsPage-BPhPo5eU.js","assets/rolldown-runtime-B0Z9INg1.js","assets/index-AF29hfx9.js","assets/vendor-router-CZg2bCPV.js","assets/vendor-react-DwNgTV1j.js","assets/index-BAmsg90v.css","assets/use-i18n-a84Zp9dV.js","assets/i18n-8nTnthu6.js","assets/storage-BpAqa-YY.js","assets/vendor-state-GkUciC5H.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/download-BCfIiuaL.js","assets/external-link-CEQqPcqc.js","assets/file-Bllajneu.js","assets/link-2-mgasYn21.js","assets/paperclip-BCXrwYpb.js","assets/plus-fQbSqB1n.js","assets/refresh-cw-TbWxTY4K.js","assets/trash-2-CNrPOoPR.js","assets/triangle-alert-CE1q54ci.js","assets/x-07u4-129.js","assets/api-YI8_cHpR.js","assets/http-Be2GB6DH.js","assets/abort-signal-f4JsiYKX.js","assets/button-CQA36izu.js","assets/vendor-ui-DvrYggeS.js","assets/dist-Cfh4kzCK.js","assets/utils-C8uzG5AZ.js","assets/field-3bN8nouy.js","assets/label-BzlNatZM.js","assets/dist-B_a0oV4U.js","assets/separator-BDICnhEL.js","assets/format-BRFKAYMT.js","assets/app-primitives-SxfoFmHc.js","assets/switch-Ci_hmu39.js","assets/dist-TksYpDID.js","assets/tabs-B60r4YwO.js","assets/dist-B7rNRXig.js","assets/dist-C3P9WH0T.js","assets/card-BdUpL1KB.js","assets/StarOrbit-BAAjh-hY.js","assets/usePagePrimaryAction-CWPC0C_f.js","assets/MarkdownMessage-CA9ODRKk.js","assets/vendor-markdown-plugins-DisoihU3.js","assets/vendor-shiki-runtime-UFMr0O-Q.js","assets/vendor-markdown-plugins-DEcVZfaU.css","assets/vendor-markdown-Ck4Y_w0n.js","assets/check-2vYc6QaP.js","assets/copy-DHmIFc52.js","assets/route-context-DvWDul4T.js","assets/mobile-runtime-recovery-tbTyacip.js","assets/PluginsPage-09Um3mY4.js","assets/dist-BdkTa5R3.js","assets/es2015-0QT3KgdC.js","assets/AppSelect-BCexz4Ty.js","assets/dist-BlIIpW6W.js","assets/dist-alOyD2Bh.js","assets/dist-D8Wfxh48.js","assets/chevron-down-CxtxIjiP.js","assets/use-mobile-YXncArOq.js","assets/circle-check-iEdCm3Pw.js","assets/earth-Ddy13fHh.js","assets/shield-alert-CvFOTe9h.js","assets/file-code-corner-BnE1ljT0.js","assets/folder-open-FIShC5Qk.js","assets/image-BY_c3FYU.js","assets/loader-circle-BOwQzHB-.js","assets/plug-BsIeHRwC.js","assets/search-D0mqDaf_.js","assets/server-BgNvmqwJ.js","assets/dialog-D-ER2p-D.js","assets/runtime-capabilities-store-CiL3ZPEo.js","assets/tool-labels-DJzY62Yr.js","assets/pick-system-directory-BnIFt85A.js","assets/TerminalPanel-CJPy4Qhs.js","assets/minus-BuutOHSj.js","assets/square-terminal-BVG6cUT1.js","assets/events-KqdUtjsm.js","assets/TerminalPanel-BrP-ENHg.css"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{p as t}from"./vendor-router-CZg2bCPV.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{t as i}from"./use-i18n-a84Zp9dV.js";import{t as a}from"./utils-C8uzG5AZ.js";import{t as o}from"./blocks-Olsdp5Lp.js";import{t as s}from"./file-diff-GxOMJkLj.js";import{t as c}from"./file-Bllajneu.js";import{t as l}from"./folder-open-FIShC5Qk.js";import{n as u,t as d}from"./panels-top-left-BlZftvhg.js";import{t as f}from"./folder-DPM8D8cf.js";import{t as p}from"./square-terminal-BVG6cUT1.js";import{i as m}from"./http-Be2GB6DH.js";import{t as h}from"./api-YI8_cHpR.js";import{t as g}from"./button-CQA36izu.js";import{t as _}from"./SessionFilesPane-DPijesqH.js";import{n as v}from"./MobileShellContext-D8qX-BlM.js";var y=e(n(),1);function b(e){let t=typeof e==`string`?e:e&&typeof e==`object`&&typeof e.name==`string`?e.name:``;return!t||t===`.`||t===`..`||t.includes(`/`)||t.includes(`\\`)?``:t}function x(e){if(!e||typeof e!=`object`||Array.isArray(e))throw m();let t=e,n=[],r=Array.isArray(t.directories)?t.directories:null,i=Array.isArray(t.files)?t.files:null;if(r||i){for(let e of r??[]){let t=b(e);t&&n.push({name:t,kind:`directory`})}for(let e of i??[]){let t=b(e);t&&n.push({name:t,kind:`file`})}return n}if(!Array.isArray(t.entries))throw m();for(let e of t.entries){if(!e||typeof e!=`object`)throw m();let t=e,r=b(t.name);if(!r||![`directory`,`file`].includes(String(t.type??t.kind)))throw m();n.push({name:r,kind:t.type===`directory`||t.kind===`directory`?`directory`:`file`})}return n.sort((e,t)=>e.kind===t.kind?e.name.localeCompare(t.name):e.kind===`directory`?-1:1)}function S(e,t){if(!t||t===`.`||t===`..`||t.includes(`/`)||t.includes(`\\`))return e;let n=e.replace(/[\\/]+$/,``);return n?`${n}/${t}`:t}function C(e){let t=e.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<0?``:t.slice(0,n)}async function w(e,t){let n=await h(`/api/workspace-entries?path=${encodeURIComponent(e)}`,{signal:t}),r=x(n),i=n,a=i.path??i.root,o=i.parent;if(typeof a!=`string`||!a||o!=null&&typeof o!=`string`)throw m();return{path:a,parent:o===null?``:o??C(a),entries:r}}var T=r(),E=(0,y.lazy)(()=>t(()=>import(`./AssetsPage-BPhPo5eU.js`).then(e=>({default:e.AssetsPage})),__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,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50]))),D=(0,y.lazy)(()=>t(()=>import(`./PluginsPage-09Um3mY4.js`).then(e=>({default:e.PluginsPage})),__vite__mapDeps([51,1,4,6,7,3,2,5,8,9,26,30,52,53,54,55,37,38,56,35,57,27,25,10,47,58,59,60,61,12,62,63,64,65,66,67,17,68,69,18,19,21,22,23,24,70,20,33,34,36,39,71,41,72,73]))),O=(0,y.lazy)(()=>t(()=>import(`./TerminalPanel-CJPy4Qhs.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([74,1,4,10,58,75,16,76,20,21,22,3,7,2,5,8,23,24,25,26,27,77,78]))),k=[{id:`assets`,icon:l},{id:`changes`,icon:s},{id:`session-tools`,icon:d},{id:`extensions`,icon:o},{id:`files`,icon:c},{id:`terminal`,icon:p}];function A(){let[e,t]=(0,y.useState)(null);return{action:e,register:(0,y.useCallback)(e=>(t(()=>e),()=>t(t=>t===e?null:t)),[])}}function j({sessionId:e,resolveSessionCwd:t}){let{t:n}=i(),[r,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(null),[l,d]=(0,y.useState)(``),[p,m]=(0,y.useState)([]),[h,g]=(0,y.useState)(!0),[_,v]=(0,y.useState)(``);return(0,y.useEffect)(()=>{let n=!1;return t(e).then(e=>{n||s(e)}).catch(e=>{n||(v(e instanceof Error?e.message:String(e)),g(!1))}),()=>{n=!0}},[t,e]),(0,y.useEffect)(()=>{if(o===null)return;let e=new AbortController;return g(!0),v(``),w(o,e.signal).then(t=>{e.signal.aborted||(m(t.entries),a(t.path),d(t.parent))}).catch(t=>{e.signal.aborted||(m([]),v(t instanceof Error?t.message:String(t)))}).finally(()=>{e.signal.aborted||g(!1)}),()=>e.abort()},[o]),(0,T.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,"data-swipe-ignore":!0,children:[(0,T.jsxs)(`div`,{className:`flex flex-none items-center gap-2 border-b border-[var(--stroke-soft)] px-3 py-2`,children:[(0,T.jsx)(`button`,{type:`button`,className:`grid size-8 place-items-center rounded-md text-muted-foreground enabled:hover:bg-muted disabled:opacity-40`,disabled:!l||h,"aria-label":n(`navigation:mobileShell.filesUp`),onClick:()=>s(l),children:(0,T.jsx)(u,{size:16})}),(0,T.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:r||n(`navigation:mobileShell.workspaceRoot`)})]}),(0,T.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:h?(0,T.jsx)(`p`,{className:`px-2 py-3 text-sm text-muted-foreground`,children:n(`navigation:mobileShell.filesLoading`)}):_?(0,T.jsx)(`p`,{className:`px-2 py-3 text-sm text-[var(--danger)]`,role:`alert`,children:_}):p.length===0?(0,T.jsx)(`p`,{className:`px-2 py-3 text-sm text-muted-foreground`,children:n(`navigation:mobileShell.filesEmpty`)}):(0,T.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:p.map(e=>(0,T.jsx)(`li`,{children:e.kind===`directory`?(0,T.jsxs)(`button`,{type:`button`,className:`flex h-10 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-muted`,onClick:()=>s(S(r,e.name)),children:[(0,T.jsx)(f,{size:16,"aria-hidden":`true`}),(0,T.jsx)(`span`,{className:`truncate`,children:e.name})]}):(0,T.jsxs)(`div`,{className:`flex h-10 items-center gap-2 px-2 text-sm text-muted-foreground`,children:[(0,T.jsx)(c,{size:16,"aria-hidden":`true`}),(0,T.jsx)(`span`,{className:`truncate`,children:e.name})]})},`${e.kind}:${e.name}`))})})]})}function M({visible:e,sessionStreaming:t,onCloseTerminal:n,onOpenChat:r,tab:o,onTabChange:s,activeSessionId:c,query:l,notify:u,requestConfirm:d,requestText:f,onUseAsset:m,terminalSupported:h,terminalLabels:b,resolveSessionCwd:x}){let{t:S}=i(),{setSessionToolsHost:C}=v(),w={assets:S(`navigation:navigation.assets`),changes:S(`navigation:mobileShell.changes`),"session-tools":S(`navigation:mobileShell.sessionTools`),extensions:S(`navigation:mobileShell.extensions`),files:S(`navigation:mobileShell.files`),terminal:S(`navigation:mobileShell.terminal`)},M=A(),N=A(),[P,F]=(0,y.useState)(()=>new Set([o]));(0,y.useEffect)(()=>{F(e=>e.has(o)?e:new Set([...e,o]))},[o]);let I=e=>P.has(e)||o===e;return(0,T.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,"data-mobile-context-screen":!0,children:[(0,T.jsx)(`div`,{className:`flex flex-none gap-1 overflow-x-auto border-b border-[var(--stroke-soft)] px-2 py-1.5 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,role:`tablist`,"aria-label":S(`navigation:mobileShell.context`),"data-swipe-ignore":!0,children:k.map(({id:e,icon:t})=>{let n=o===e;return(0,T.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n,className:a(`flex h-8 flex-none items-center gap-1.5 rounded-full px-2.5 text-[12px] font-medium`,n?`bg-[var(--star-soft)] text-[var(--star-strong)]`:`text-[var(--text-muted)]`),onClick:()=>s(e),children:[(0,T.jsx)(t,{size:14,"aria-hidden":`true`}),w[e]]},e)})}),(0,T.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:[(0,T.jsx)(`div`,{ref:C,hidden:o!==`session-tools`||t===null,className:`h-full min-h-0`,"data-mobile-session-tools-host":!0}),o===`session-tools`&&t===null&&(0,T.jsx)(g,{className:`m-3`,variant:`outline`,onClick:r,children:S(`navigation:mobileShell.toolsOpenChat`)}),I(`assets`)&&(0,T.jsxs)(`div`,{hidden:o!==`assets`,className:`h-full overflow-auto px-3 py-3 [&_.asset-grid]:!grid-cols-1`,children:[(0,T.jsx)(g,{className:`mb-3`,disabled:!M.action,onClick:()=>M.action?.(),children:S(`assets:assetsPage.addLink`)}),(0,T.jsx)(y.Suspense,{fallback:null,children:(0,T.jsx)(E,{query:l,notify:u,registerPrimaryAction:M.register,requestConfirm:d,onUse:m},c)})]}),o===`changes`&&(c?t===null?(0,T.jsx)(g,{className:`m-3`,variant:`outline`,onClick:r,children:S(`navigation:mobileShell.changesOpenChat`)}):(0,T.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:(0,T.jsx)(_,{sessionId:c,streaming:t,requestConfirm:d},c)}):(0,T.jsx)(`p`,{className:`px-4 py-6 text-sm text-muted-foreground`,children:S(`navigation:mobileShell.noSessionChanges`)})),I(`extensions`)&&(0,T.jsxs)(`div`,{hidden:o!==`extensions`,className:`h-full overflow-auto px-3 py-3`,children:[(0,T.jsx)(g,{className:`mb-3`,disabled:!N.action,onClick:()=>N.action?.(),children:S(`plugins:pluginsPage.savePolicy`)}),(0,T.jsx)(y.Suspense,{fallback:null,children:(0,T.jsx)(D,{query:l,notify:u,registerPrimaryAction:N.register,requestText:f,requestConfirm:d})})]}),o===`files`&&(0,T.jsx)(j,{sessionId:c,resolveSessionCwd:x},c||`workspace`),I(`terminal`)&&(0,T.jsx)(`div`,{hidden:o!==`terminal`,className:`h-full min-h-0`,children:h?(0,T.jsx)(y.Suspense,{fallback:null,children:(0,T.jsx)(O,{layout:`fill`,open:e&&o===`terminal`,height:480,labels:b,activeSessionId:c,resolveSessionCwd:x,onOpenChange:e=>{e||n()},onHeightChange:()=>{}})}):(0,T.jsxs)(`div`,{className:`grid h-full place-content-center gap-2 px-6 text-center text-sm text-muted-foreground`,children:[(0,T.jsx)(p,{className:`mx-auto`,size:22,"aria-hidden":`true`}),(0,T.jsx)(`p`,{children:S(`navigation:mobileShell.terminalUnavailable`)})]})})]})]})}export{M as MobileContextScreen};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-a84Zp9dV.js";import{o as i}from"./vendor-state-GkUciC5H.js";import"./collapsible-C__hRcbA.js";import{a,n as o,r as s,t as c}from"./dropdown-menu-pKRdLJUe.js";import"./tooltip-Bxq7c2mZ.js";import{t as l}from"./utils-C8uzG5AZ.js";import{t as u}from"./createLucideIcon-Cd-3GVxJ.js";import{t as d}from"./arrow-up-DST6-qVQ.js";import{t as f}from"./earth-Ddy13fHh.js";import{t as p}from"./external-link-CEQqPcqc.js";import{a as m,h,i as g,k as _,m as v,o as y,r as b,s as x}from"./side-chat-context-Dn8w9ut8.js";import{t as S}from"./loader-circle-BOwQzHB-.js";import{t as C}from"./message-square-SKjZyY3v.js";import{t as w}from"./plus-fQbSqB1n.js";import{t as T}from"./square-bHHVTT3G.js";import{t as E}from"./x-07u4-129.js";import{t as D}from"./button-CQA36izu.js";import{t as O}from"./SessionFilesPane-DPijesqH.js";import"./input-CvjGYteF.js";import{r as k,s as A}from"./shortcuts-C_Cph88H.js";import{a as j,i as M,n as N,t as P}from"./sheet--Om3LZxh.js";import{t as F}from"./web-preview-B7L-G6kp.js";var I=u(`files`,[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]),L=e(t(),1);function R(e=`files`){return{pages:[{id:`page-1`,kind:e,draft:``,url:``}],activeId:`page-1`,nextId:2}}function z(e,t){if(t.type===`add`){let n=e.pages.find(e=>e.kind===`side-chat`);if(t.kind===`side-chat`&&n)return{...e,activeId:n.id};if(e.pages.length>=12)return e;let r={id:`page-${e.nextId}`,kind:t.kind,draft:``,url:``};return{pages:[...e.pages,r],activeId:r.id,nextId:e.nextId+1}}let n=e.pages.findIndex(e=>e.id===t.id);if(n<0)return e;if(t.type===`select`)return{...e,activeId:t.id};if(t.type===`close`){let r=e.pages.filter(e=>e.id!==t.id);return r.length?{...e,pages:r,activeId:e.activeId===t.id?r[Math.min(n,r.length-1)].id:e.activeId}:R()}return{...e,pages:e.pages.map(e=>e.id===t.id?t.type===`kind`?{...e,kind:t.kind}:{...e,...t.draft===void 0?{}:{draft:t.draft},...t.url===void 0?{}:{url:t.url}}:e)}}var B=i(e=>({sessions:{},update:(t,n,r)=>e(e=>{let i=Object.prototype.hasOwnProperty.call(e.sessions,t)?e.sessions[t]:R(n),a=Object.entries(e.sessions).filter(([e])=>e!==t).slice(-31);return{sessions:Object.fromEntries([...a,[t,z(i,r)]])}})})),V=n(),H=(0,L.createContext)(null),U=()=>{let e=(0,L.useContext)(H);if(!e)throw Error(`WebPreview components must be used within a WebPreview`);return e},W=({className:e,children:t,defaultUrl:n=``,onUrlChange:r,...i})=>{let[a,o]=(0,L.useState)(n),[s,c]=(0,L.useState)(!1),u=(0,L.useCallback)(e=>{o(e),r?.(e)},[r]),d=(0,L.useMemo)(()=>({consoleOpen:s,setConsoleOpen:c,setUrl:u,url:a}),[s,u,a]);return(0,V.jsx)(H.Provider,{value:d,children:(0,V.jsx)(`div`,{className:l(`flex size-full min-h-0 flex-col rounded-lg border bg-card`,e),...i,children:t})})},G=({className:e,loading:t,src:n,...r})=>{let{url:i}=U();return(0,V.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden bg-background`,children:[(0,V.jsx)(`iframe`,{className:l(`block size-full border-0 bg-background`,e),loading:`lazy`,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-presentation`,src:(n??i)||void 0,title:`Preview`,...r}),t]})};function K({parentId:e,active:t}){let{t:n}=r(),{entry:i,runtime:a,load:o,setDraft:s}=b(e),c=i.session?.id??``,l=(0,L.useMemo)(()=>e=>a.subscribeSessionState(c,e),[a,c]),u=(0,L.useMemo)(()=>()=>a.getSessionState(c),[a,c]),f=(0,L.useSyncExternalStore)(l,u),[p,_]=(0,L.useState)(!1),[v,w]=(0,L.useState)(!1),[E,O]=(0,L.useState)(``),j=(0,L.useRef)(!1),M=(0,L.useRef)(!1),N=(0,L.useRef)(i.draft);N.current=i.draft;let P=(0,L.useRef)(null),F=A(e=>e.bindings),I=g(f,i.session);(0,L.useEffect)(()=>{t&&o(e)},[t,o,e]);let R=async t=>{t.preventDefault();let n=N.current.trim();if(!(!n||j.current||I||i.expired)){j.current=!0,_(!0),O(``);try{let t=await o(e,!i.session);if(!t?.session)return;let r=t.session.id;if(a.getSessionState(r).streaming)return;N.current.trim()===n&&s(e,``),_(!1),await a.send(r,n),await o(e)}catch(e){O(x(e))}finally{j.current=!1,_(!1)}}},z=(0,L.useCallback)(async()=>{if(!(!c||a.getSessionState(c).streaming)){O(``);try{await a.retry(c),await o(e)}catch(e){O(x(e))}}},[o,e,a,c]),B=async()=>{if(!(!c||v)){w(!0);try{O(``),await a.abort(c)}catch(e){O(x(e))}finally{w(!1)}}},H=(0,V.jsxs)(`div`,{className:`grid h-full min-h-36 place-content-center justify-items-center gap-3 px-3 text-center text-sm text-muted-foreground`,children:[(0,V.jsx)(C,{size:22,"aria-hidden":`true`}),(0,V.jsx)(`p`,{className:`max-w-64 leading-relaxed`,children:i.expired?n(`chat:sideChat.expired`):n(`chat:sideChat.empty`)}),i.expired&&(0,V.jsxs)(D,{variant:`outline`,size:`sm`,disabled:i.loading,onClick:async()=>{(await o(e,!0))?.session&&P.current?.focus()},children:[i.loading&&(0,V.jsx)(S,{className:`size-4 animate-spin`}),n(`chat:sideChat.restart`)]})]}),U=E||i.error||f.error;return(0,V.jsxs)(`section`,{"data-side-chat-parent":e,"aria-label":n(`chat:sideChat.title`),className:`flex h-full min-h-0 min-w-0 flex-1 flex-col [container-type:inline-size]`,children:[(0,V.jsx)(`p`,{className:`shrink-0 border-b border-border/50 px-3 py-2 text-xs leading-relaxed text-muted-foreground`,children:n(`chat:sideChat.retention`)}),c?(0,V.jsx)(y,{sessionId:c,messages:f.messages,transcriptLoadState:f.loaded?`ready`:f.error?`error`:`loading`,emptyState:H,messageStart:f.messageStart,hasOlder:f.hasOlder,loadingOlder:f.loadingOlder,olderError:f.olderError,activityFeed:f.activityFeed,tools:f.tools,thinkingText:f.thinkingText,currentActivity:f.currentActivity,compaction:f.compaction,streaming:I,runStartedAt:f.runStartedAt,lastActivityAt:f.lastActivityAt,runFinishedAt:f.runFinishedAt,runStopped:f.runStopped,runNotice:f.runNotice,error:f.error,cwd:i.session?.cwd,onLoadOlder:()=>a.loadOlderMessages(c),onRetryLastTurn:z}):(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:H}),(0,V.jsxs)(`form`,{className:`flex shrink-0 flex-col gap-2 border-t border-border/50 p-3`,onSubmit:R,children:[U&&(0,V.jsx)(h,{error:U,onRetry:i.error||!f.loaded?async()=>{await o(e)}:z}),(0,V.jsx)(m,{approvals:f.approvals,onResolve:async(e,t)=>{try{await a.approve(c,e,t)}catch{}}}),(0,V.jsxs)(`div`,{className:`flex min-w-0 items-end gap-2 rounded-xl border border-border/70 bg-muted/40 p-2 focus-within:border-ring/50`,children:[(0,V.jsx)(`textarea`,{ref:P,rows:2,value:i.draft,"aria-label":n(`chat:sideChat.message`),placeholder:n(`chat:sideChat.placeholder`),className:`max-h-40 min-h-14 min-w-0 flex-1 resize-y border-0 bg-transparent px-1 py-1 text-sm leading-relaxed text-foreground outline-none placeholder:text-muted-foreground`,onChange:t=>s(e,t.target.value),onCompositionStart:()=>{M.current=!0},onCompositionEnd:()=>{M.current=!1},onKeyDown:e=>{!M.current&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&k(e.nativeEvent,F.sendMessage)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,V.jsx)(D,{type:I?`button`:`submit`,size:`icon`,className:`size-9 shrink-0 rounded-full`,"aria-label":n(I?`chat:sideChat.stop`:`chat:sideChat.send`),disabled:I?v:p||i.loading||i.expired||!i.draft.trim(),onClick:I?()=>void B():void 0,children:p||v?(0,V.jsx)(S,{className:`size-4 animate-spin`}):I?(0,V.jsx)(T,{size:13,fill:`currentColor`}):(0,V.jsx)(d,{size:17})})]})]})]})}function q({page:e,onChange:t}){let{t:n}=r(),{draft:i,url:a}=e,[o,s]=(0,L.useState)(!1);return(0,V.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col gap-2 p-3`,"aria-label":n(`common:webPreview.title`),children:[(0,V.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault();let n=F(i,window.location.href);s(!n),n&&t({url:n})},children:[(0,V.jsx)(`input`,{"aria-label":n(`common:webPreview.url`),className:`min-w-0 flex-1 rounded-md border border-[var(--stroke)] bg-[var(--solid)] px-2 text-[length:var(--app-font-size)]`,value:i,onChange:e=>t({draft:e.target.value}),placeholder:n(`common:webPreview.urlPlaceholder`),maxLength:2048}),(0,V.jsx)(D,{type:`submit`,variant:`outline`,size:`sm`,children:n(`chat:sessionContext.openUrl`)})]}),o&&(0,V.jsx)(`p`,{role:`alert`,className:`text-[length:var(--app-small-size)] text-[var(--text-secondary)]`,children:n(`chat:sessionContext.invalidUrl`)}),a?(0,V.jsx)(W,{className:`min-h-0 flex-1 overflow-hidden rounded-md`,defaultUrl:a,children:(0,V.jsx)(G,{src:a,title:n(`common:webPreview.title`)})},a):(0,V.jsxs)(`div`,{className:`grid min-h-0 flex-1 place-content-center justify-items-center gap-2 rounded-md border border-dashed border-[var(--stroke-soft)] text-center text-[length:var(--app-font-size)] text-[var(--text-muted)]`,children:[(0,V.jsx)(f,{size:24,"aria-hidden":`true`}),(0,V.jsx)(`p`,{children:n(`chat:sessionContext.browserEmpty`)})]}),a&&(0,V.jsxs)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>window.open(a,`_blank`,`noopener,noreferrer`),children:[(0,V.jsx)(p,{size:14}),n(`common:webPreview.openExternal`)]}),(0,V.jsx)(`p`,{className:`text-[length:var(--app-small-size)] text-[var(--text-muted)]`,children:n(`common:webPreview.embedNotice`)})]})}function J({panelId:e,compact:t,embedded:n=!1,sessionId:i,tab:l,plan:u,streaming:d,plansAvailable:p,requestConfirm:m,onTabChange:h,onClose:g}){let{t:y}=r(),b=[{id:`files`,icon:I,label:y(`chat:focusSession.fileChanges`)},...p?[{id:`plan`,icon:_,label:y(`chat:sessionContext.plan`)}]:[],{id:`browser`,icon:f,label:y(`common:webPreview.title`)},{id:`side-chat`,icon:C,label:y(`chat:sideChat.title`)}],x=(0,L.useMemo)(()=>R(l),[l]),S=B(e=>Object.prototype.hasOwnProperty.call(e.sessions,i)?e.sessions[i]:void 0)??x,T=(0,L.useRef)(null),D=S.pages.find(e=>e.id===S.activeId)??S.pages[0],k=e=>b.find(t=>t.id===e.kind)??b[0],A=t=>requestAnimationFrame(()=>document.getElementById(`${e}-${t}-tab`)?.focus()),F=e=>{let t=z(S,e);B.getState().update(i,l,e);let n=t.pages.find(e=>e.id===t.activeId);n&&h(n.kind),(e.type===`add`||e.type===`select`||e.type===`close`)&&A(t.activeId),e.type===`close`&&S.pages.length===1&&g()},H=y(`chat:sessionContext.addPage`),U=y(`chat:sessionContext.pageLimit`),W=(0,V.jsxs)(c,{children:[(0,V.jsx)(a,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`grid size-7 shrink-0 place-items-center rounded-md text-muted-foreground hover:bg-muted disabled:opacity-40`,disabled:S.pages.length>=12,"aria-label":H,title:S.pages.length>=12?U:H,children:(0,V.jsx)(w,{size:15})})}),(0,V.jsx)(o,{align:`end`,className:`min-w-40`,children:b.map(({id:e,icon:t,label:n})=>(0,V.jsxs)(s,{onSelect:()=>F({type:`add`,kind:e}),children:[(0,V.jsx)(t,{size:14}),n]},e))})]}),G=(0,V.jsxs)(`div`,{"data-session-context-panel":!0,className:`flex h-full min-h-0 min-w-0 flex-col bg-background text-foreground`,children:[(0,V.jsxs)(`header`,{"data-window-drag-region":!0,className:`auxiliary-page-header flex h-12 shrink-0 items-center gap-0.5 border-b border-border/60 px-1.5`,children:[(0,V.jsx)(`div`,{ref:T,className:`flex min-w-0 flex-1 items-center overflow-x-auto`,role:`tablist`,"aria-label":y(`chat:sessionContext.title`),onKeyDown:e=>{if(!(e.target instanceof HTMLElement)||e.target.getAttribute(`role`)!==`tab`)return;if(e.key===`Delete`){e.preventDefault(),F({type:`close`,id:D.id});return}if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=S.pages.findIndex(e=>e.id===D.id),n=e.key===`Home`?0:e.key===`End`?S.pages.length-1:(t+(e.key===`ArrowRight`?1:-1)+S.pages.length)%S.pages.length;F({type:`select`,id:S.pages[n].id})},children:S.pages.map(t=>{let{icon:n,label:r}=k(t);return(0,V.jsxs)(`div`,{className:`group flex max-w-40 min-w-20 shrink-0 items-center rounded-md ${t.id===D.id?`bg-muted`:`text-muted-foreground`}`,children:[(0,V.jsxs)(`button`,{id:`${e}-${t.id}-tab`,type:`button`,role:`tab`,"aria-selected":t.id===D.id,"aria-controls":`${e}-${t.id}-content`,tabIndex:t.id===D.id?0:-1,className:`flex h-8 min-w-0 flex-1 items-center gap-1.5 px-2 text-xs`,onClick:()=>F({type:`select`,id:t.id}),children:[(0,V.jsx)(n,{size:13,className:`shrink-0`}),(0,V.jsx)(`span`,{className:`truncate`,children:r})]}),(0,V.jsx)(`button`,{type:`button`,className:`mr-0.5 grid size-5 shrink-0 place-items-center rounded hover:bg-foreground/10`,"aria-label":`${y(`chat:sessionContext.closePage`)} · ${r}`,onClick:()=>F({type:`close`,id:t.id}),children:(0,V.jsx)(E,{size:11})})]},t.id)})}),W]}),S.pages.map(t=>{let n=k(t),r=D.id===t.id;return(0,V.jsx)(`div`,{id:`${e}-${t.id}-content`,role:`tabpanel`,"aria-labelledby":`${e}-${t.id}-tab`,className:r?`flex min-h-0 flex-1 flex-col`:`hidden`,hidden:!r,children:n.id===`side-chat`?(0,V.jsx)(K,{parentId:i,active:r}):n.id===`browser`?(0,V.jsx)(q,{page:t,onChange:e=>F({type:`browser`,id:t.id,...e})}):r&&(n.id===`files`?(0,V.jsx)(O,{sessionId:i,streaming:d,requestConfirm:m}):(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:u?.items?.length?(0,V.jsx)(v,{plan:u}):(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:y(`chat:sessionContext.planEmpty`)})}))},t.id)})]});return t?(0,V.jsx)(P,{open:!0,onOpenChange:e=>!e&&g(),children:(0,V.jsxs)(N,{id:e,side:`right`,showCloseButton:!1,className:`gap-0 overflow-hidden p-0`,style:{top:`var(--pisper-safe-area-top)`,right:`var(--pisper-safe-area-right)`,bottom:`var(--pisper-safe-area-bottom)`,height:`auto`,width:`min(calc(100vw - var(--pisper-safe-area-left) - var(--pisper-safe-area-right)), 420px)`,maxWidth:`none`},children:[(0,V.jsx)(M,{className:`sr-only`,children:(0,V.jsx)(j,{children:y(`chat:sessionContext.title`)})}),G]})}):(0,V.jsx)(`aside`,{id:e,tabIndex:n?-1:void 0,className:`h-full min-h-0 w-full overflow-hidden border-l border-border/60`,"aria-label":y(`chat:sessionContext.title`),children:G})}export{J as SessionContextPanel};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WorkspacePicker-B3liZkwe.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-DwNgTV1j.js","assets/use-i18n-a84Zp9dV.js","assets/i18n-8nTnthu6.js","assets/vendor-router-CZg2bCPV.js","assets/index-AF29hfx9.js","assets/index-BAmsg90v.css","assets/storage-BpAqa-YY.js","assets/vendor-state-GkUciC5H.js","assets/dist-Cfh4kzCK.js","assets/dist-B_a0oV4U.js","assets/dist-C3P9WH0T.js","assets/dist-D8Wfxh48.js","assets/utils-C8uzG5AZ.js","assets/vendor-ui-DvrYggeS.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/arrow-up-DST6-qVQ.js","assets/check-2vYc6QaP.js","assets/chevron-right-C3t2Rckj.js","assets/folder-DPM8D8cf.js","assets/house-BNrzTkx9.js","assets/loader-circle-BOwQzHB-.js","assets/refresh-cw-TbWxTY4K.js","assets/triangle-alert-CE1q54ci.js","assets/api-YI8_cHpR.js","assets/http-Be2GB6DH.js","assets/abort-signal-f4JsiYKX.js","assets/button-CQA36izu.js","assets/alert-QoPGoIY6.js","assets/dialog-D-ER2p-D.js","assets/dist-BdkTa5R3.js","assets/es2015-0QT3KgdC.js","assets/x-07u4-129.js","assets/input-CvjGYteF.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{p as t}from"./vendor-router-CZg2bCPV.js";import{t as n}from"./index-AF29hfx9.js";import{i as r,r as i}from"./vendor-react-DwNgTV1j.js";import{t as a}from"./use-i18n-a84Zp9dV.js";import{a as o,i as s,o as c}from"./vendor-state-GkUciC5H.js";import{t as l}from"./storage-BpAqa-YY.js";import{c as u,i as d,o as f,s as p}from"./dist-B_a0oV4U.js";import{a as m,c as h,i as g,l as ee,n as te,r as _,s as v,t as y,u as b}from"./dist-CXiO_DNx.js";import{t as x}from"./utils-C8uzG5AZ.js";import{t as S}from"./createLucideIcon-Cd-3GVxJ.js";import{n as ne,t as re}from"./pin-off-DRR1KEvN.js";import{a as ie,c as ae,d as oe,l as se,u as ce}from"./session-list-DkNhT87s.js";import{t as C}from"./chevron-right-C3t2Rckj.js";import{t as le}from"./circle-alert-DCChabnT.js";import{t as ue}from"./loader-circle-BOwQzHB-.js";import{t as de}from"./message-square-SKjZyY3v.js";import{a as fe}from"./sidebar-C3YJQV72.js";import{t as pe}from"./pencil-U08v_vV9.js";import{t as me}from"./plus-fQbSqB1n.js";import{t as he}from"./rotate-ccw-C0v8V77_.js";import{t as ge}from"./search-D0mqDaf_.js";import{t as w}from"./trash-2-CNrPOoPR.js";import{t as _e}from"./api-YI8_cHpR.js";import{t as ve}from"./button-CQA36izu.js";import{t as ye}from"./useQuery-D3P5wO_Z.js";import{a as be,t as T}from"./startup-queries-ByepQfGF.js";import{n as xe}from"./QueryClientProvider-CHJtxoX1.js";import{i as Se,r as Ce}from"./format-BRFKAYMT.js";import{_ as we,a as Te,m as Ee,o as De,p as Oe,s as ke,t as Ae}from"./events-KqdUtjsm.js";var E=e(r(),1),D=i(),O=Object.defineProperty,k=(e,t)=>O(e,`name`,{value:t,configurable:!0}),A=`ContextMenu`,[je,j]=p(A,[b]),M=b(),[N,P]=je(A),F=k(e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,dir:a,modal:o=!0}=e,s=E.useRef(!1),[c,l]=d({prop:i,defaultProp:!1,onChange:r,caller:A}),u=M(t);return(0,D.jsx)(N,{scope:t,open:c,onOpenChange:l,modal:o,hasInteractedRef:s,children:(0,D.jsx)(m,{...u,dir:a,open:c,onOpenChange:l,modal:o,children:n})})},`ContextMenu`),I=`ContextMenuTrigger`,L=E.forwardRef(k(function(e,t){let{__scopeContextMenu:n,disabled:r=!1,...i}=e,a=P(I,n),o=M(n),[s,c]=E.useState({x:0,y:0}),l=E.useMemo(()=>({current:{getBoundingClientRect:k(()=>DOMRect.fromRect({width:0,height:0,...s}),`getBoundingClientRect`)}}),[s]),d=E.useRef(0),p=E.useCallback(()=>window.clearTimeout(d.current),[]),m=k(e=>{a.hasInteractedRef.current=!0,c({x:e.clientX,y:e.clientY}),a.onOpenChange(!0)},`handleOpen`);return E.useEffect(()=>p,[p]),E.useEffect(()=>void(r&&p()),[r,p]),(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(y,{...o,virtualRef:l}),(0,D.jsx)(u.span,{"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:f(e.onContextMenu,e=>{p(),m(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:f(e.onPointerDown,W(e=>{p(),a.open&&a.onOpenChange(!1),d.current=window.setTimeout(()=>m(e),700)})),onPointerMove:r?e.onPointerMove:f(e.onPointerMove,W(p)),onPointerCancel:r?e.onPointerCancel:f(e.onPointerCancel,W(p)),onPointerUp:r?e.onPointerUp:f(e.onPointerUp,W(p))})]})},`ContextMenuTrigger`)),R=k(e=>{let{__scopeContextMenu:t,...n}=e,r=M(t);return(0,D.jsx)(g,{...r,...n})},`ContextMenuPortal`),z=`ContextMenuContent`,Me=E.forwardRef(k(function(e,t){let{__scopeContextMenu:n,...r}=e,i=P(z,n),a=M(n),o=E.useRef(!1);return(0,D.jsx)(te,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`ContextMenuContent`)),Ne=E.forwardRef(k(function(e,t){let{__scopeContextMenu:n,...r}=e,i=M(n);return(0,D.jsx)(_,{...i,...r,ref:t})},`ContextMenuItem`)),B=`ContextMenuSub`,V=k(e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,defaultOpen:a}=e,o=M(t),[s,c]=d({prop:i,defaultProp:a??!1,onChange:r,caller:B});return(0,D.jsx)(v,{...o,open:s,onOpenChange:c,children:n})},`ContextMenuSub`),H=E.forwardRef(k(function(e,t){let{__scopeContextMenu:n,...r}=e,i=M(n);return(0,D.jsx)(ee,{...i,...r,ref:t})},`ContextMenuSubTrigger`)),U=E.forwardRef(k(function(e,t){let{__scopeContextMenu:n,...r}=e,i=M(n);return(0,D.jsx)(h,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`ContextMenuSubContent`));function W(e){return t=>t.pointerType===`mouse`?void 0:e(t)}k(W,`whenTouchOrPen`);var G=F,K=L,Pe=R,Fe=Me,q=Ne,Ie=V,J=H,Le=U,Re=S(`folder-closed`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M2 10h20`,key:`1ir3d8`}]]),ze=S(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]);function Y(e=``){let t=e.trim().replace(/\\/g,`/`),n=/^\/+$/u.test(t)?`/`:t.replace(/\/+$/,``);return/^[A-Za-z]:(?:\/|$)/.test(n)?n.toLowerCase():n}function X(e){return Y(e.cwd)||`\0`}function Be(e){let t=new Map;for(let n of e){let e=X(n),r=t.get(e)||{key:e,cwd:n.cwd||``,sessions:[]};r.sessions.push(n),t.set(e,r)}return[...t.values()]}function Ve(e,t,n=``){let r=new Set(e.slice(0,t).map(e=>e.id));return Be(e).map(e=>({...e,sessions:e.sessions.filter((e,t)=>t===0||r.has(e.id)||e.id===n)}))}function Z(e){return Array.isArray(e)?[...new Set(e.filter(e=>typeof e==`string`).map(Y))].filter(e=>e===`\0`||e.length>0&&!e.includes(`\0`)):[]}function He(e,t){return Z([...e,...t])}function Ue(e,t){let n=new Map(t.map((e,t)=>[e,t]));return[...e].sort((e,r)=>(n.get(e.key)??t.length)-(n.get(r.key)??t.length))}function We(e,t){return e.filter(e=>X(e)===t)}function Ge(e,t,n,r){return!e||!n.has(e)&&(!r||t.some(t=>t.id===e))?null:t[0]?.id||``}async function Ke(e,t){let n=[];for(let r of e)try{await t(r),n.push(r)}catch(e){return{deletedIds:n,failedId:r,error:e}}return{deletedIds:n,failedId:null,error:null}}function qe(e){let t=Y(e);return t&&t!==`\0`&&!t.includes(`\0`)?t:null}function Je(e){let t=Object.create(null);if(!e||typeof e!=`object`||Array.isArray(e))return t;for(let[n,r]of Object.entries(e)){let e=qe(n);if(!e||typeof r!=`string`)continue;let i=r.trim();i&&Array.from(i).length<=120&&(t[e]=i)}return t}var Ye=s(()=>n),Q=c()(o((e,t)=>({order:[],names:Je(void 0),rememberWorkspaces:n=>{let r=t().order,i=He(r,n);i.length===r.length&&i.every((e,t)=>e===r[t])||e({order:i})},setWorkspaceName:(n,r)=>{let i=typeof n==`string`?qe(n):null;if(!i||typeof r!=`string`)throw TypeError(`Invalid workspace name`);let a=r.trim();if(Array.from(a).length>120)throw RangeError(`Workspace name is too long`);let o=t().names;if((o[i]||``)===a)return;if(!Ye)throw Error(`Workspace preferences storage is unavailable`);let s=Je(o);a?s[i]=a:delete s[i];try{e({names:s})}catch(t){try{e({names:o})}catch{}throw t}}}),{name:`pisper-workspace-order`,storage:Ye,version:1,partialize:({order:e,names:t})=>({order:e,names:t}),merge:(e,t)=>({...t,order:Z(e&&typeof e==`object`&&`order`in e?e.order:void 0),names:Je(e&&typeof e==`object`&&`names`in e?e.names:void 0)})}));function Xe({...e}){return(0,D.jsx)(G,{"data-slot":`context-menu`,...e})}function Ze({className:e,...t}){return(0,D.jsx)(K,{"data-slot":`context-menu-trigger`,className:x(`select-none`,e),...t})}function Qe({...e}){return(0,D.jsx)(Ie,{"data-slot":`context-menu-sub`,...e})}function $e({className:e,...t}){return(0,D.jsx)(Pe,{children:(0,D.jsx)(Fe,{"data-slot":`context-menu-content`,className:x(`z-[200] max-h-(--radix-context-menu-content-available-height) min-w-36 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...t})})}function $({className:e,inset:t,variant:n=`default`,...r}){return(0,D.jsx)(q,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:x(`group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function et({className:e,inset:t,children:n,...r}){return(0,D.jsxs)(J,{"data-slot":`context-menu-sub-trigger`,"data-inset":t,className:x(`flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,D.jsx)(C,{className:`ml-auto`})]})}function tt({className:e,...t}){return(0,D.jsx)(Le,{"data-slot":`context-menu-sub-content`,className:x(`z-[200] min-w-32 origin-(--radix-context-menu-content-transform-origin) overflow-hidden rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...t})}var nt=(0,E.lazy)(()=>t(()=>import(`./WorkspacePicker-B3liZkwe.js`).then(e=>({default:e.WorkspacePicker})),__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,32,33,34]))),rt=24;function it({label:e,onClick:t,children:n}){return(0,D.jsx)(ve,{type:`button`,variant:`ghost`,className:`opacity-0 group-hover/workspace:opacity-100 group-focus-within/workspace:opacity-100 focus-visible:opacity-100 pointer-coarse:opacity-100 !size-7 !min-h-7 !shrink-0 !p-0 !text-[var(--text-muted)] hover:!bg-[var(--surface-hover)] hover:!text-[var(--text)] max-[650px]:!size-11 max-[650px]:!min-h-11`,title:e,"aria-label":e,onClick:t,children:n})}function at({navigate:e,requestText:t,requestConfirm:r,notify:i}){let{t:o,language:s}=a(),c=xe(),{isMobile:u,setOpenMobile:d}=fe(),[f,p]=(0,E.useState)(!0),[m,h]=(0,E.useState)(``),[g,ee]=(0,E.useState)(!1),[te,_]=(0,E.useState)(()=>new Set),v=Q(e=>e.order),y=Q(e=>e.rememberWorkspaces),b=Q(e=>e.names),x=Q(e=>e.setWorkspaceName),[S,O]=(0,E.useState)(()=>n.getItem(l.activeSession)||``),[k,A]=(0,E.useState)(``),[je,j]=(0,E.useState)(``),[M,N]=(0,E.useState)(!1),[P,F]=(0,E.useState)(``),{data:I}=ye({...be(`sessions`),refetchInterval:2e3});(0,E.useEffect)(()=>we(window,({deletedIds:e})=>{let t=new Set(e);c.setQueryData([`sessions`],e=>e&&{...e,sessions:e.sessions.filter(e=>!t.has(e.id))})}),[c]);let L=(0,E.useMemo)(()=>ie(I?.sessions||[]),[I]),R=(0,E.useMemo)(()=>{let e=m.trim().toLocaleLowerCase(s);return e?L.filter(t=>`${t.name||``} ${t.cwd||``} ${b[X(t)]||``}`.toLocaleLowerCase(s).includes(e)):L.filter(e=>!e.archived)},[s,m,L,b]),z=(0,E.useMemo)(()=>Be(L),[L]);(0,E.useEffect)(()=>{y(z.map(e=>e.key))},[z,y]);let Me=(0,E.useMemo)(()=>Ue(Ve(R,rt,S),v),[R,v,S]),Ne=(0,E.useMemo)(()=>new Map(z.map(e=>[e.key,e.sessions.length])),[z]),B=z.find(e=>e.key===k)||null,V=L.find(e=>e.id===je)||null,H=e=>e.cwd?b[e.key]||Se(e.cwd,s):o(`navigation:appSidebar.noWorkspace`);(0,E.useEffect)(()=>{let e=()=>{T(`sessions`,!0).catch(()=>{})},t=()=>{document.visibilityState===`visible`&&e()},r=e=>{let t=e.detail;O(t?.id||n.getItem(l.activeSession)||``)};return document.addEventListener(`visibilitychange`,t),window.addEventListener(Te,r),window.addEventListener(Ae,r),()=>{document.removeEventListener(`visibilitychange`,t),window.removeEventListener(Te,r),window.removeEventListener(Ae,r)}},[]);let U=t=>{O(t),Ee(t),e(`chat`),u&&d(!1)},W=t=>{Oe(t)&&(h(``),p(!0),_(e=>{let n=new Set(e);return n.delete(X({id:``,cwd:t})),n}),e(`chat`),u&&d(!1))},G=async(e,t=L)=>{let r=await Ke(e.map(e=>e.id),e=>_e(`/api/sessions/${encodeURIComponent(e)}`,{method:`DELETE`}));ke(r.deletedIds.length?{deletedIds:r.deletedIds}:void 0);let i=null;try{i=(await T(`sessions`,!0)).sessions}catch{}let a=new Set(r.deletedIds),o=i??t.filter(e=>!a.has(e.id)),s=Ge(n.getItem(l.activeSession)||S,o,a,i!==null);return s!==null&&(O(s),s?Ee(s):(n.removeItem(l.activeSession),De(``))),{...r,sessions:o,verified:i!==null}},K=async e=>{if(P)return;let t=e.cwd?`${H(e)} · ${e.cwd}`:H(e);F(e.key);try{let n=(await T(`sessions`,!0)).sessions,a=We(n,e.key);if(!a.length){i(o(`navigation:appSidebar.projectNoChats`,{project:t}),`info`);return}if(!await r({title:o(`navigation:appSidebar.deleteProject`),message:o(`navigation:appSidebar.deleteProjectConfirm`,{project:t,count:a.length}),confirmLabel:o(`navigation:appSidebar.deleteProjectAction`)}))return;let s=await G(a,n);if(!s.verified){i(o(`navigation:appSidebar.projectDeleteUnverified`,{project:t,deleted:s.deletedIds.length}),`error`);return}let c=We(s.sessions,e.key).length;if(s.failedId!==null||c){i(o(`navigation:appSidebar.projectDeletePartial`,{project:t,deleted:s.deletedIds.length,remaining:c}),`error`);return}i(o(`navigation:appSidebar.projectDeleted`,{project:t}))}catch(e){i(e instanceof ae?o(`chat:chatHistoryPage.sessionUpdateFailed`):e instanceof Error?e.message:String(e),`error`)}finally{F(``)}},Pe=async e=>{if(P)return;let t=e.name||o(`navigation:appSidebar.untitledChat`);if(await r({title:o(`chat:chatHistoryPage.deleteChat`),message:o(`chat:chatHistoryPage.deleteChatNameThisAlsoRemovesLocalChatHistory`,{name:t}),confirmLabel:o(`chat:chatHistoryPage.delete`)})){F(e.id);try{let t=await G([e]);if(t.failedId!==null)throw t.error??Error(o(`navigation:appSidebar.chatDeleteFailed`));i(o(`chat:chatHistoryPage.chatDeleted`))}catch(e){i(e instanceof Error?e.message:String(e),`error`)}finally{F(``)}}},Fe=async e=>{let n=await t({title:o(`chat:chatHistoryPage.renameChat`),inputLabel:o(`chat:chatHistoryPage.chatTitle`),value:e.name,confirmLabel:o(`chat:chatHistoryPage.save`)});if(n!==null&&n!==e.name)try{let t=await _e(`/api/sessions/${encodeURIComponent(e.id)}`,{method:`PATCH`,body:JSON.stringify({name:n})});ke({id:e.id,name:t.name}),T(`sessions`,!0).catch(()=>{}),i(o(`chat:chatHistoryPage.chatTitleUpdated`))}catch(e){i(e instanceof Error?e.message:String(e),`error`)}},q=(e,t)=>{try{x(e.cwd,t),i(o(`navigation:appSidebar.projectNameUpdated`))}catch{i(o(`navigation:appSidebar.projectNameSaveFailed`),`error`)}},Ie=async e=>{if(!e.cwd)return;let n=H(e),r=await t({title:o(`navigation:appSidebar.renameProject`),message:o(`navigation:appSidebar.renameProjectDescription`),inputLabel:o(`navigation:appSidebar.projectName`),value:n,maxLength:120,confirmLabel:o(`chat:chatHistoryPage.save`)});r===null||!r.trim()||r.trim()===n||q(e,r.trim())},J=async(e,t,n)=>{if(!P)try{let r=await se(e.id,t);c.setQueryData([`sessions`],e=>e&&{...e,sessions:e.sessions.map(e=>e.id===r.id?{...e,...r}:e)}),i(n)}catch(e){i(e instanceof Error?e.message:String(e),`error`)}},Le=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Y=(e=``,t=``)=>{A(e),j(t)},Z=(e,t=``,n=``)=>{e.pointerType!==`mouse`&&Y(t,n)},He=t=>{e(t),u&&d(!1)};return(0,D.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col px-2 pt-3`,"aria-label":o(`navigation:appSidebar.recentChats`),children:[(0,D.jsxs)(`div`,{className:`mb-1 flex h-8 shrink-0 items-center gap-1 px-1.5`,children:[(0,D.jsxs)(`button`,{className:`mr-auto flex min-w-0 items-center gap-1 rounded-md px-1 py-1 text-xs text-muted-foreground hover:text-foreground`,"aria-controls":`sidebar-recent-sessions`,"aria-expanded":f,onClick:()=>p(e=>!e),children:[(0,D.jsx)(`span`,{children:o(`navigation:workbench.projects`)}),(0,D.jsx)(C,{className:f?`rotate-90`:``,size:12})]}),(0,D.jsx)(ve,{variant:`ghost`,size:`icon-sm`,className:`size-6 text-muted-foreground`,title:o(`navigation:workbench.filterSessions`),"aria-label":o(`navigation:workbench.filterSessions`),"aria-expanded":g,onClick:()=>ee(e=>!e),children:(0,D.jsx)(ge,{size:13})}),(0,D.jsx)(ve,{variant:`ghost`,size:`icon-sm`,className:`size-6 text-muted-foreground`,title:o(`navigation:appSidebar.newProject`),"aria-label":o(`navigation:appSidebar.newProject`),"aria-haspopup":`dialog`,"aria-expanded":M,onClick:()=>N(!0),children:(0,D.jsx)(ze,{size:14})}),(0,D.jsx)(`button`,{className:`rounded-md px-1 py-1 text-[11px] text-muted-foreground hover:text-foreground`,"aria-label":o(`navigation:appSidebar.viewAllCountChats`,{count:L.length}),onClick:()=>He(`chatHistory`),children:o(`navigation:appSidebar.viewAll`)})]}),(g||m)&&(0,D.jsxs)(`label`,{className:`mx-2 mb-2 flex h-8 shrink-0 items-center gap-2 rounded-lg border border-border px-2 text-muted-foreground focus-within:ring-1 focus-within:ring-ring`,children:[(0,D.jsx)(ge,{size:13,"aria-hidden":`true`}),(0,D.jsx)(`input`,{className:`min-w-0 flex-1 border-0 bg-transparent text-xs outline-none`,value:m,onChange:e=>h(e.target.value),placeholder:o(`navigation:appSidebar.searchChats`),"aria-label":o(`navigation:appSidebar.searchChats`)})]}),f&&(0,D.jsxs)(Xe,{onOpenChange:e=>{e||(A(``),j(``))},children:[(0,D.jsx)(Ze,{asChild:!0,children:(0,D.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-[2px] [padding-bottom:2px] overflow-y-auto [animation:page-in_var(--d1)_var(--ease-out)]`,id:`sidebar-recent-sessions`,onPointerDownCapture:e=>Z(e),onContextMenuCapture:()=>Y(),children:[Me.map(e=>{let t=te.has(e.key),n=H(e);return(0,D.jsxs)(`div`,{className:`nav-workspace-group [.nav-workspace-group_+_&]:mt-[3px]`,children:[(0,D.jsxs)(`div`,{className:`group/workspace flex min-w-0 items-center gap-[2px]`,onContextMenu:()=>A(e.key),onPointerDown:t=>Z(t,e.key),children:[(0,D.jsxs)(`button`,{className:`flex h-8 min-w-0 flex-1 items-center gap-1.5 rounded-lg px-2 text-left text-sm text-foreground hover:bg-sidebar-accent [&_span]:min-w-0 [&_span]:flex-1 [&_span]:truncate [&_small]:hidden [&_.is-open]:rotate-90`,"aria-expanded":!t,onClick:()=>Le(e.key),title:e.cwd||n,children:[(0,D.jsx)(C,{className:t?``:`is-open`,size:13}),(0,D.jsx)(Re,{size:13}),(0,D.jsx)(`span`,{children:n}),(0,D.jsx)(`small`,{children:Ne.get(e.key)||e.sessions.length})]}),e.cwd&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(it,{label:o(`navigation:appSidebar.renameProjectNamed`,{project:n}),onClick:()=>void Ie(e),children:(0,D.jsx)(pe,{size:14,"aria-hidden":`true`})}),(0,D.jsx)(it,{label:o(`navigation:appSidebar.newChatInWorkspace`,{workspace:e.cwd}),onClick:()=>W(e.cwd),children:(0,D.jsx)(me,{size:14})})]})]}),!t&&e.sessions.map(e=>(0,D.jsxs)(`button`,{className:`flex h-8 w-full items-center gap-1 rounded-lg pl-8 pr-2.5 text-left text-sm font-normal text-muted-foreground hover:bg-sidebar-accent hover:text-foreground ${e.id===S?`active-session bg-sidebar-accent text-foreground`:``}`,"aria-current":e.id===S?`page`:void 0,title:`${e.name||o(`navigation:appSidebar.untitledChat`)} · ${Ce(e.modified,s)}`,onClick:()=>U(e.id),onContextMenu:()=>j(e.id),onPointerDown:t=>Z(t,``,e.id),children:[e.streaming&&(0,D.jsx)(ue,{className:`mr-1 size-3.5 shrink-0 animate-spin text-foreground`,"aria-label":o(`navigation:appSidebar.running`)}),e.pinned&&(0,D.jsx)(ce,{className:`mr-1 size-3 shrink-0`,"aria-label":o(`navigation:appSidebar.pinned`)}),e.needsAttention&&(0,D.jsx)(le,{className:`mr-1 size-3 shrink-0`,"aria-label":o(`navigation:appSidebar.needsAttention`)}),e.unread&&(0,D.jsx)(`span`,{className:`mr-1 size-1.5 shrink-0 rounded-full bg-[var(--brand-blue)]`,"aria-label":o(`navigation:appSidebar.unread`)}),(0,D.jsx)(`span`,{className:`min-w-0 flex-1 select-none truncate`,children:e.name||o(`navigation:appSidebar.untitledChat`)}),(0,D.jsx)(`time`,{className:`shrink-0 text-xs text-muted-foreground/70`,dateTime:e.modified,children:Ce(e.modified,s)}),e.archived&&(0,D.jsx)(`span`,{className:`ml-auto text-[11px] font-normal text-muted-foreground`,children:o(`navigation:appSidebar.archived`)})]},e.id))]},e.key)}),!R.length&&(0,D.jsx)(`span`,{className:`[padding:8px] text-[var(--text-muted)] text-xs font-normal`,children:m.trim()?o(`navigation:appSidebar.noMatchingChats`):L.length?o(`navigation:appSidebar.noActiveChats`):o(`navigation:appSidebar.noChatHistoryYet`)})]})}),(0,D.jsx)($e,{className:`w-[220px]`,children:V?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)($,{onSelect:()=>U(V.id),children:[(0,D.jsx)(de,{size:13}),o(`navigation:appSidebar.openSession`)]}),(0,D.jsxs)($,{onSelect:()=>void Fe(V),children:[(0,D.jsx)(pe,{size:13}),o(`chat:chatHistoryPage.renameChat`)]}),(0,D.jsxs)($,{onSelect:()=>void J(V,{pinned:!V.pinned},V.pinned?o(`navigation:appSidebar.unpinned`):o(`navigation:appSidebar.pinned`)),children:[V.pinned?(0,D.jsx)(re,{size:13}):(0,D.jsx)(ce,{size:13}),V.pinned?o(`navigation:appSidebar.unpin`):o(`navigation:appSidebar.pin`)]}),(0,D.jsxs)($,{onSelect:()=>void J(V,{archived:!V.archived},V.archived?o(`navigation:appSidebar.restored`):o(`navigation:appSidebar.movedToArchive`)),children:[V.archived?(0,D.jsx)(ne,{size:13}):(0,D.jsx)(oe,{size:13}),V.archived?o(`navigation:appSidebar.restore`):o(`navigation:appSidebar.archive`)]}),V.unread&&(0,D.jsx)($,{onSelect:()=>void J(V,{read:!0},o(`navigation:appSidebar.markedRead`)),children:o(`navigation:appSidebar.markRead`)}),(0,D.jsxs)($,{variant:`destructive`,disabled:!!P,onSelect:()=>void Pe(V),children:[(0,D.jsx)(w,{size:13}),o(`chat:chatHistoryPage.delete`)]})]}):B?(0,D.jsxs)(D.Fragment,{children:[B.cwd&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)($,{onSelect:()=>W(B.cwd),children:[(0,D.jsx)(me,{size:13}),o(`navigation:appSidebar.newChat`)]}),(0,D.jsxs)($,{onSelect:()=>void Ie(B),children:[(0,D.jsx)(pe,{size:13}),o(`navigation:appSidebar.renameProject`)]}),b[B.key]&&(0,D.jsxs)($,{onSelect:()=>q(B,``),children:[(0,D.jsx)(he,{size:13}),o(`navigation:appSidebar.resetProjectName`)]})]}),(0,D.jsxs)($,{variant:`destructive`,disabled:!!P||!B.sessions.length,onSelect:()=>void K(B),children:[(0,D.jsx)(w,{size:13}),o(`navigation:appSidebar.deleteProject`)]})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)($,{onSelect:()=>N(!0),children:[(0,D.jsx)(ze,{size:13}),o(`navigation:appSidebar.newProject`)]}),(0,D.jsxs)(Qe,{children:[(0,D.jsxs)(et,{disabled:!z.length||!!P,children:[(0,D.jsx)(w,{size:13}),o(`navigation:appSidebar.deleteProject`)]}),(0,D.jsx)(tt,{className:`max-h-[70vh] max-w-[280px] overflow-y-auto`,children:z.map(e=>(0,D.jsx)($,{onSelect:()=>void K(e),children:(0,D.jsx)(`span`,{className:`truncate`,title:e.cwd||H(e),children:H(e)})},e.key))})]})]})})]}),M&&(0,D.jsx)(E.Suspense,{fallback:null,children:(0,D.jsx)(nt,{open:!0,description:o(`navigation:appSidebar.newProjectPickerDescription`),onOpenChange:N,onSelect:e=>{N(!1),W(e)}})})]})}export{at as SidebarRecentSessions};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{c as t,f as n,u as r}from"./vendor-router-CZg2bCPV.js";import{i,r as a}from"./vendor-react-DwNgTV1j.js";import{u as o}from"./i18n-8nTnthu6.js";import{t as s}from"./use-i18n-a84Zp9dV.js";import{n as c,r as l,t as u}from"./collapsible-C__hRcbA.js";import{t as d}from"./label-BzlNatZM.js";import{t as f}from"./AppSelect-BCexz4Ty.js";import{a as p,i as m,n as h,o as g,t as _}from"./popover-CQqAaq-c.js";import{i as v,n as y,r as b,t as x}from"./progress-C_G6VqQ_.js";import{t as S}from"./switch-Ci_hmu39.js";import{i as C,r as w,t as T}from"./tabs-B60r4YwO.js";import{t as E}from"./utils-C8uzG5AZ.js";import{t as D}from"./createLucideIcon-Cd-3GVxJ.js";import{t as O}from"./arrow-left-B8oVrQ2S.js";import{i as k,n as A,r as j,t as M}from"./zap-3wDb3GcJ.js";import{t as N}from"./arrow-up-DST6-qVQ.js";import{t as P}from"./bell-BjONAtgH.js";import{t as F}from"./bot-B3TaBp_T.js";import{t as ee}from"./check-2vYc6QaP.js";import{t as I}from"./chevron-down-CxtxIjiP.js";import{t as L}from"./chevron-right-C3t2Rckj.js";import{t as te}from"./circle-check-iEdCm3Pw.js";import{t as ne}from"./circle-x-Ba4QL7Ec.js";import{t as re}from"./code-xml-BrUXrBax.js";import{t as ie}from"./copy-DHmIFc52.js";import{t as R}from"./download-BCfIiuaL.js";import{t as ae}from"./file-code-corner-BnE1ljT0.js";import{t as oe}from"./file-Bllajneu.js";import{t as se}from"./grip-vertical-B__LYT0s.js";import{t as z}from"./image-BY_c3FYU.js";import{t as ce}from"./loader-circle-BOwQzHB-.js";import{t as le}from"./message-circle-D-XrK6Ft.js";import{t as ue}from"./paperclip-BCXrwYpb.js";import{t as B}from"./pencil-U08v_vV9.js";import{t as V}from"./play-DNDjDNGn.js";import{t as de}from"./plus-fQbSqB1n.js";import{t as H}from"./refresh-cw-TbWxTY4K.js";import{t as fe}from"./rocket-BgLSjoHY.js";import{t as pe}from"./search-D0mqDaf_.js";import{t as me}from"./send-Cj-W03w_.js";import{t as he}from"./server-BgNvmqwJ.js";import{t as ge}from"./settings-2-CXJjXJS9.js";import{t as _e}from"./square-bHHVTT3G.js";import{t as ve}from"./trash-2-CNrPOoPR.js";import{t as ye}from"./triangle-alert-CE1q54ci.js";import{t as be}from"./x-07u4-129.js";import{i as U,n as W,o as xe,t as Se}from"./http-Be2GB6DH.js";import{t as G}from"./api-YI8_cHpR.js";import{t as K}from"./button-CQA36izu.js";import{t as Ce}from"./useQuery-D3P5wO_Z.js";import{n as we}from"./QueryClientProvider-CHJtxoX1.js";import{n as Te,t as Ee}from"./alert-QoPGoIY6.js";import{a as De,c as Oe,i as ke,o as Ae,r as je,s as Me,t as Ne}from"./dialog-D-ER2p-D.js";import{t as q}from"./input-CvjGYteF.js";import{t as J}from"./field-3bN8nouy.js";import{r as Pe}from"./format-BRFKAYMT.js";import{n as Fe,r as Ie,t as Le}from"./card-BdUpL1KB.js";import{a as Re,r as ze}from"./app-primitives-SxfoFmHc.js";import{a as Be,i as Ve,n as He,r as Ue,t as We}from"./sheet--Om3LZxh.js";import{t as Ge}from"./usePagePrimaryAction-CWPC0C_f.js";import{n as Ke,r as qe,t as Je}from"./browser-notifications-DBS0oXqN.js";import{a as Ye,c as Xe,i as Ze,n as Qe,o as $e,r as et,s as tt,t as nt}from"./sprite-engine-catalog-D1HQWa1X.js";import{t as rt}from"./textarea-bYCRTyEt.js";import{a as it,c as at,d as ot,f as st,i as ct,l as lt,n as ut,o as dt,r as ft,s as pt,t as mt,u as ht}from"./vendor-xyflow-hxQFvEHK.js";import{n as gt,o as _t}from"./routes-C4kwUiVG.js";var vt=D(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),yt=D(`film`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M3 7.5h4`,key:`zfgn84`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 16.5h4`,key:`1230mu`}],[`path`,{d:`M17 3v18`,key:`in4fa5`}],[`path`,{d:`M17 7.5h4`,key:`myr1c1`}],[`path`,{d:`M17 16.5h4`,key:`go4c1d`}]]),bt=D(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),xt=D(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Y=e(i(),1),St=Object.freeze([`media-input`,`media-background`,`media-inpaint`,`media-generate`,`media-frames`,`media-transform`,`media-preview`,`media-export`]);function Ct(e){return typeof e==`string`&&St.some(t=>t===e)}var X=a(),wt=({className:e,...t})=>(0,X.jsx)(ft,{className:E(`gap-px overflow-hidden rounded-md border bg-card p-1 shadow-none!`,`[&>button]:rounded-md [&>button]:border-none! [&>button]:bg-transparent! [&>button]:hover:bg-secondary!`,e),...t}),Tt=[`trigger`,`prompt`,`skill`,`file`,`mcp`,`notification`,`condition`,`parallel`,`approval`,...St];function Et({data:e,selected:t}){return(0,X.jsxs)(`div`,{className:E(`flow-node relative flex w-40 min-h-16 cursor-grab flex-col justify-center gap-1 rounded-xl border border-border bg-card px-3 py-2.5 text-left shadow-sm transition-shadow [&_small]:text-[11px] [&_small]:font-normal [&_small]:text-muted-foreground [&_strong]:text-[13px] [&_strong]:font-medium [&.active]:border-primary [&.active]:ring-2 [&.active]:ring-[var(--brand-blue-border)] [&.type-condition]:border-amber-500/40 [&.type-parallel]:border-violet-500/40 [&.type-approval]:border-emerald-500/40 [&.compact]:w-28 [&.compact]:min-h-10 [&.compact]:px-2 [&.compact]:py-1`,`type-${e.kind}`,t&&`active`,e.compact&&`compact`),children:[!e.compact&&e.kind!==`trigger`&&(0,X.jsx)(ct,{id:`input`,className:`flow-port after:absolute after:[content:''] after:inset-[-8px] absolute z-[3] w-[12px] h-[12px] [border:2px_solid_var(--solid)] rounded-[50%] bg-[var(--text)] [cursor:crosshair] input [.flow-port&]:top-[50%] [.flow-port&]:left-[-7px] [.flow-port&]:[transform:translateY(-50%)]`,type:`target`,position:st.Left,title:e.inputLabel,"aria-label":e.inputLabel}),!e.compact&&e.kind===`condition`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ct,{id:`true`,className:`flow-port after:absolute after:[content:''] after:inset-[-8px] absolute z-[3] w-[12px] h-[12px] [border:2px_solid_var(--solid)] rounded-[50%] bg-[var(--text)] [cursor:crosshair] output [.flow-port&]:top-[50%] [.flow-port&]:right-[-7px] [.flow-port&]:[transform:translateY(-50%)] condition-true`,type:`source`,position:st.Right,title:`true`,"aria-label":`true`}),(0,X.jsx)(ct,{id:`false`,className:`flow-port after:absolute after:[content:''] after:inset-[-8px] absolute z-[3] w-[12px] h-[12px] [border:2px_solid_var(--solid)] rounded-[50%] bg-[var(--text)] [cursor:crosshair] output [.flow-port&]:top-[50%] [.flow-port&]:right-[-7px] [.flow-port&]:[transform:translateY(-50%)] condition-false`,type:`source`,position:st.Bottom,title:`false`,"aria-label":`false`})]}):!e.compact&&(0,X.jsx)(ct,{id:`output`,className:`flow-port after:absolute after:[content:''] after:inset-[-8px] absolute z-[3] w-[12px] h-[12px] [border:2px_solid_var(--solid)] rounded-[50%] bg-[var(--text)] [cursor:crosshair] output [.flow-port&]:top-[50%] [.flow-port&]:right-[-7px] [.flow-port&]:[transform:translateY(-50%)]`,type:`source`,position:st.Right,title:e.outputLabel,"aria-label":e.outputLabel}),(0,X.jsx)(`small`,{children:e.typeLabel}),(0,X.jsx)(`strong`,{children:e.label})]})}var Dt={workflow:Et};function Ot(e){return typeof e==`string`&&Tt.includes(e)}function kt(e){return e.data.kind===`condition`?`var(--warning-strong)`:e.data.kind===`parallel`?`var(--workflow-violet)`:e.data.kind===`approval`?`var(--success)`:e.data.kind===`notification`?`var(--notification-border)`:`var(--star-strong)`}function At({nodes:e,edges:t,selectedNodeId:n,selectedEdgeId:r,hint:i,inputLabel:a,outputLabel:o,nodeTypeLabel:s,onAddNode:c,onConnect:l,onMoveNode:u,onSelectNode:d,onSelectEdge:f,onClearSelection:p,onDeleteNodes:m,onDeleteEdges:h}){let{screenToFlowPosition:g}=lt(),_=(0,Y.useMemo)(()=>e.map(e=>({id:e.id,type:`workflow`,position:{x:e.x,y:e.y},selected:e.id===n,data:{kind:e.kind,label:e.label,typeLabel:s(e.kind),inputLabel:a,outputLabel:o}})),[a,s,e,o,n]),v=(0,Y.useRef)(new Set),y=(0,Y.useRef)(new Map),b=(0,Y.useRef)(null),[x,S,C]=at(_);(0,Y.useEffect)(()=>{S(e=>{let t=new Map(e.map(e=>[e.id,e])),n=e.length!==_.length,r=_.map(e=>{let r=t.get(e.id);if(!r)return n=!0,e;let i=v.current.has(e.id)?r.position:e.position,a=r.data.kind===e.data.kind&&r.data.label===e.data.label&&r.data.typeLabel===e.data.typeLabel&&r.data.inputLabel===e.data.inputLabel&&r.data.outputLabel===e.data.outputLabel&&r.data.compact===e.data.compact;return i.x===r.position.x&&i.y===r.position.y&&r.selected===e.selected&&a?r:(n=!0,{...r,position:i,selected:e.selected,data:e.data})});return n?r:e})},[_,S]);let w=(0,Y.useCallback)(()=>{b.current=null,y.current.forEach((e,t)=>u(t,e)),y.current.clear()},[u]),T=(0,Y.useCallback)((e,t)=>{y.current.set(e,t),b.current??=requestAnimationFrame(w)},[w]);(0,Y.useEffect)(()=>()=>{b.current!==null&&cancelAnimationFrame(b.current)},[]);let E=(0,Y.useMemo)(()=>t.map(e=>({id:e.id,source:e.source,sourceHandle:e.sourcePort,target:e.target,targetHandle:e.targetPort,selected:e.id===r,markerEnd:{type:ot.ArrowClosed,width:16,height:16,color:`var(--canvas-edge)`},style:{stroke:`var(--canvas-edge)`,strokeWidth:2}})),[t,r]),D=(0,Y.useCallback)(e=>{!e.source||!e.target||l(e.source,e.target,e.sourceHandle||`output`)},[l]),O=(0,Y.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),k=(0,Y.useCallback)(e=>{e.preventDefault();let t={};try{t=JSON.parse(e.dataTransfer.getData(`text/plain`)||`{}`)}catch{return}if(!Ot(t.kind))return;let n=g({x:e.clientX,y:e.clientY});c(t.kind,typeof t.label==`string`?t.label:s(t.kind),n)},[s,c,g]);return(0,X.jsxs)(`div`,{className:`workflow-react-flow absolute inset-0`,children:[(0,X.jsxs)(pt,{nodes:x,edges:E,nodeTypes:Dt,onNodesChange:C,connectionMode:ht.Strict,deleteKeyCode:[`Backspace`,`Delete`],fitView:!0,fitViewOptions:{padding:.18,minZoom:.6,maxZoom:1,nodes:x.length>8?x.slice(0,3).map(({id:e})=>({id:e})):void 0},minZoom:.15,maxZoom:1.8,snapToGrid:!0,snapGrid:[20,20],panOnDrag:!0,zoomOnDoubleClick:!1,onConnect:D,onNodeClick:(e,t)=>d(t.id),onEdgeClick:(e,t)=>f(t.id),onPaneClick:p,onNodeDragStart:(e,t)=>v.current.add(t.id),onNodeDrag:(e,t)=>T(t.id,t.position),onNodeDragStop:(e,t)=>{v.current.delete(t.id),y.current.delete(t.id),u(t.id,t.position)},onNodesDelete:e=>m(e.map(e=>e.id)),onEdgesDelete:e=>h(e.map(e=>e.id)),onDragOver:O,onDrop:k,children:[(0,X.jsx)(mt,{variant:ut.Dots,gap:20,size:1.2,color:`var(--canvas-grid)`}),(0,X.jsx)(it,{className:`workflow-react-flow-minimap !m-3 !h-24 !w-36 overflow-hidden rounded-lg border border-border !bg-card shadow-sm [&_svg]:h-full [&_svg]:w-full @max-[640px]/workflow:hidden`,nodeColor:kt,nodeStrokeWidth:3,pannable:!0,zoomable:!0}),(0,X.jsx)(wt,{position:`top-left`,showInteractive:!1})]}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute bottom-3 left-3 z-[5] hidden max-w-[calc(100%-180px)] rounded-md bg-card px-2 py-1 text-[11px] leading-relaxed text-muted-foreground @min-[640px]/workflow:block`,children:i})]})}function jt(e){return(0,X.jsx)(dt,{children:(0,X.jsx)(At,{...e})})}function Mt(e){return new Map(e.map((e,t)=>[e.id,t]))}function Nt(e=[],t){return e.slice(1).map((n,r)=>{let i=e[r];return{id:t?.(r,i.id,n.id)||`edge-${r}-${i.id}-${n.id}`,source:i.id,sourcePort:`output`,target:n.id,targetPort:`input`}})}function Pt(e=[],t=[]){let n=e.filter(e=>e.enabled!==!1),r=new Set(n.map(e=>e.id)),i=t.filter(e=>r.has(e.source)&&r.has(e.target)),a=new Map(n.map(e=>[e.id,[]])),o=new Map(n.map(e=>[e.id,[]])),s=new Map(n.map(e=>[e.id,0])),c=Mt(n);for(let e of i)a.get(e.target)?.push(e),o.get(e.source)?.push(e),s.set(e.target,(s.get(e.target)||0)+1);let l=n.filter(e=>s.get(e.id)===0),u=[];for(;l.length;){l.sort((e,t)=>c.get(e.id)-c.get(t.id));let e=l.shift();u.push(e);for(let t of o.get(e.id)||[]){let e=(s.get(t.target)||0)-1;s.set(t.target,e),e===0&&l.push(n.find(e=>e.id===t.target))}}let d=n.filter(e=>(a.get(e.id)||[]).length===0),f=d.find(e=>e.kind===`trigger`)||d[0];return{nodes:n,edges:i,incoming:a,outgoing:o,order:u,roots:d,unconnected:n.filter(e=>e.id!==f?.id&&(a.get(e.id)||[]).length===0),invalidTriggerTargets:n.filter(e=>e.kind===`trigger`&&(a.get(e.id)||[]).length>0),hasCycle:u.length!==n.length}}function Ft(e,t,n,r,i=`output`){return Pt(e,[...t,{id:`__candidate__`,source:n,sourcePort:i,target:r,targetPort:`input`}]).hasCycle}var It={trigger:`触发器`,prompt:`任务`,skill:`Skill`,file:`文件`,mcp:`MCP`,notification:`通知`,condition:`判断`,parallel:`并行`,approval:`审批`,"media-input":`图片输入`,"media-inpaint":`区域修补`,"media-background":`去背景`,"media-generate":`动作生成`,"media-frames":`拆分帧`,"media-transform":`帧处理`,"media-preview":`动画预览`,"media-export":`图集输出`},Lt=[{kind:`trigger`,label:`手动触发`,Icon:M},{kind:`prompt`,label:`运行 Prompt`,Icon:F},{kind:`skill`,label:`调用 Skill`,Icon:v},{kind:`file`,label:`读写文件`,Icon:ae},{kind:`mcp`,label:`调用 MCP`,Icon:he},{kind:`condition`,label:`条件分支`,Icon:b},{kind:`parallel`,label:`并行汇合`,Icon:j},{kind:`approval`,label:`人工审批`,Icon:te},{kind:`notification`,label:`发送通知`,Icon:P},{kind:`media-inpaint`,label:`区域修补`,Icon:z},{kind:`media-input`,label:`图片输入`,Icon:z},{kind:`media-background`,label:`去背景`,Icon:z},{kind:`media-generate`,label:`动作生成`,Icon:z},{kind:`media-frames`,label:`拆分帧`,Icon:z},{kind:`media-transform`,label:`帧处理`,Icon:z},{kind:`media-preview`,label:`动画预览`,Icon:z},{kind:`media-export`,label:`图集输出`,Icon:z}];function Rt(e,t){return t(e===`media-inpaint`?`workflows:imageNodes.inpaint`:e===`media-input`?`workflows:imageNodes.input`:e===`media-background`?`workflows:imageNodes.background`:e===`media-generate`?`workflows:imageNodes.generate`:e===`media-frames`?`workflows:imageNodes.frames`:e===`media-transform`?`workflows:imageNodes.transform`:e===`media-preview`?`workflows:imageNodes.preview`:e===`media-export`?`workflows:imageNodes.export`:e===`trigger`?`workflows:workflowsPage.triggerNode`:e===`skill`?`workflows:workflowsPage.skillNode`:e===`file`?`workflows:workflowsPage.fileNode`:e===`mcp`?`workflows:workflowsPage.mcpNode`:e===`notification`?`workflows:workflowsPage.notificationNode`:e===`condition`?`workflows:workflowsPage.conditionNode`:e===`parallel`?`workflows:workflowsPage.parallelNode`:e===`approval`?`workflows:workflowsPage.approvalNode`:`workflows:workflowsPage.task`)}function zt(e,t){return Ct(e)?Rt(e,t):t(e===`trigger`?`workflows:workflowsPage.manualTrigger`:e===`skill`?`workflows:workflowsPage.callSkill`:e===`file`?`workflows:workflowsPage.readWriteFiles`:e===`mcp`?`workflows:workflowsPage.callMcp`:e===`condition`?`workflows:workflowsPage.conditionBranch`:e===`parallel`?`workflows:workflowsPage.parallelJoin`:e===`approval`?`workflows:workflowsPage.humanApproval`:e===`notification`?`workflows:workflowsPage.sendNotification`:`workflows:workflowsPage.runPrompt`)}function Bt(e,t){return t(e===`sprite`?`workflows:imageNodes.templateName`:e===`pr-fix`?`workflows:workflowsPage.prFix`:e===`research`?`workflows:workflowsPage.research`:e===`report`?`workflows:workflowsPage.dailyWeeklyReport`:e===`asset`?`workflows:workflowsPage.assetGeneration`:e===`release`?`workflows:workflowsPage.releasePreparation`:`workflows:workflowsPage.codeReview`)}function Vt(e,t){return t(e===`sprite`?`workflows:imageNodes.templateDescription`:e===`pr-fix`?`workflows:workflowsPage.prFixDescription`:e===`research`?`workflows:workflowsPage.researchDescription`:e===`report`?`workflows:workflowsPage.reportDescription`:e===`asset`?`workflows:workflowsPage.assetDescription`:e===`release`?`workflows:workflowsPage.releaseDescription`:`workflows:workflowsPage.codeReviewDescription`)}function Z(e,t,n,r,i,a,o={}){return{id:e,kind:t,label:n,prompt:r,x:i,y:a,model:null,executionMode:`full-access`,retries:0,timeoutMinutes:20,failurePolicy:`stop`,enabled:!0,outputFormat:`text`,skillName:``,requestedToolNames:[],condition:{source:`previous`,operator:`exists`,value:``},approval:{message:``,timeoutMinutes:60},notification:{title:``,content:``},notificationTargets:[],...Ct(t)?{image:et()}:{},...o}}function Ht(e){return Nt(e,()=>crypto.randomUUID())}function Ut(e){return[{id:`input-task`,name:`task`,label:e?e(`workflows:inputs.task`):`本次任务`,description:e?e(`workflows:inputs.taskHint`):`描述这次运行需要完成的目标。`,type:`text`,required:!0,defaultValue:``},{id:`input-materials`,name:`materials`,label:e?e(`workflows:inputs.materials`):`参考材料`,description:e?e(`workflows:inputs.materialsHint`):`填写文件路径、链接、代码片段或需要处理的内容。`,type:`text`,required:!1,defaultValue:``},{id:`input-constraints`,name:`constraints`,label:e?e(`workflows:inputs.constraints`):`约束与输出要求`,description:e?e(`workflows:inputs.constraintsHint`):`说明范围、格式、禁止操作及验收条件。`,type:`text`,required:!1,defaultValue:``}]}function Wt(e){return`${e}\n\n本次任务:{{inputs.task}}\n参考材料:{{inputs.materials}}\n约束与输出要求:{{inputs.constraints}}\n以本次运行输入限定任务范围,节点只规定处理方法;不要把节点示例或工作流名称当作本次任务。`}var Gt=[{id:`code-review`,name:`代码审查`,description:`读取 diff → 运行测试 → 生成 review`,Icon:re,nodes:[Z(`review-trigger`,`trigger`,`手动触发`,``,65,45),Z(`review-diff`,`file`,`读取 diff`,`读取当前工作区的 git diff,识别改动范围与高风险文件。`,235,45),Z(`review-test`,`prompt`,`运行检查`,`运行适合当前项目的测试与 lint,记录失败原因。`,405,45),Z(`review-report`,`prompt`,`生成 review`,`结合 diff 和验证结果,输出按严重度排序的代码审查结论。`,235,180),Z(`review-notify`,`notification`,`发送结果`,``,405,180)]},{id:`pr-fix`,name:`PR 修复`,description:`定位失败 → 修改代码 → 回归测试`,Icon:b,nodes:[Z(`fix-trigger`,`trigger`,`手动触发`,``,65,45),Z(`fix-find`,`prompt`,`定位失败`,`检查项目状态与失败信息,定位最可能的根因。`,235,45),Z(`fix-code`,`prompt`,`修改代码`,`修复已定位的问题,保留用户已有改动,不执行破坏性命令。`,405,45),Z(`fix-test`,`prompt`,`回归测试`,`运行针对性测试和构建,确认修复没有引入回归。`,235,180),Z(`fix-notify`,`notification`,`通知结果`,``,405,180)]},{id:`research`,name:`资料调研`,description:`搜索资料 → 提取引用 → 点亮星忆`,Icon:pe,nodes:[Z(`research-trigger`,`trigger`,`手动输入`,``,65,45),Z(`research-search`,`prompt`,`搜索资料`,`围绕工作流描述中的主题检索项目内资料与可用信息源。`,235,45),Z(`research-summary`,`prompt`,`整理引用`,`整理关键结论、证据、限制和下一步建议。`,405,45),Z(`research-memory`,`prompt`,`保存星忆`,`把适合长期保留的结论写入 Agent 记忆。`,320,180)]},{id:`report`,name:`日报周报`,description:`汇总会话 → 生成摘要 → 渠道通知`,Icon:oe,nodes:[Z(`report-trigger`,`trigger`,`手动触发`,``,65,45),Z(`report-collect`,`prompt`,`汇总进展`,`汇总当前项目近期完成事项、风险与待办。`,235,45),Z(`report-write`,`prompt`,`生成报告`,`将汇总内容整理为清晰的日报或周报。`,405,45),Z(`report-notify`,`notification`,`渠道通知`,``,320,180)]},{id:`asset`,name:`资产生成`,description:`生成图片 → 存入资产库 → 通知验收`,Icon:z,nodes:[Z(`asset-trigger`,`trigger`,`手动输入`,``,65,45),Z(`asset-generate`,`prompt`,`生成视觉资产`,`根据工作流描述生成需要的视觉资产,并保存生成文件。`,235,45),Z(`asset-check`,`prompt`,`检查产物`,`检查生成资产是否完整、可访问并符合需求。`,405,45),Z(`asset-notify`,`notification`,`通知验收`,``,320,180)]},{id:`release`,name:`发布准备`,description:`版本检查 → changelog → 创建发布单`,Icon:fe,nodes:[Z(`release-trigger`,`trigger`,`手动触发`,``,65,45),Z(`release-check`,`prompt`,`版本检查`,`检查工作区、测试、构建和版本信息是否满足发布要求。`,235,45),Z(`release-log`,`prompt`,`生成 changelog`,`根据近期提交和改动生成 changelog 与发布说明。`,405,45),Z(`release-report`,`prompt`,`发布清单`,`生成最终发布检查清单并标记阻塞项。`,320,180)]}].map(e=>({...e,inputs:Ut(),nodes:e.nodes.map(e=>[`prompt`,`file`,`skill`,`mcp`].includes(e.kind)?{...e,prompt:Wt(e.prompt)}:e)}));function Kt(){let e=[Z(`sprite-trigger`,`trigger`,`手动触发`,``,0,180),Z(`sprite-source`,`media-input`,`参考图片`,``,180,180)],t=[{id:`sprite-input`,source:`sprite-trigger`,target:`sprite-source`,sourcePort:`output`,targetPort:`input`}];return[{id:`idle`,label:`待机呼吸`,prompt:`Subtle breathing idle cycle. Preserve the reference style; the feet stay planted.`},{id:`walk`,label:`走路`,prompt:`Walking cycle: alternating foot contact, passing pose and opposite contact. Keep the character in place.`},{id:`run`,label:`跑步`,prompt:`Running cycle: contact, compression, passing and flight. Preserve proportions and keep the character in place.`},{id:`attack`,label:`攻击`,prompt:`Attack sequence: anticipation, wind-up, strike and recovery. Use only the equipment visible in the reference.`}].forEach((n,r)=>{let i=r*140,a=[Z(`${n.id}-generate`,`media-generate`,n.label,`${n.prompt}\n{{inputs.task}}`,380,i,{image:et({action:n.id,frameCount:4,directions:[...Qe]})}),Z(`${n.id}-background`,`media-background`,`色键去背景`,``,560,i),Z(`${n.id}-frames`,`media-frames`,`拆分连续帧`,``,740,i),Z(`${n.id}-align`,`media-transform`,`裁边与脚底对齐`,``,920,i)];e.push(...a);let o=[`sprite-source`,...a.map(e=>e.id),`sprite-preview`];for(let e=1;e<o.length;e++)t.push({id:`${n.id}-edge-${e}`,source:o[e-1],target:o[e],sourcePort:`output`,targetPort:`input`})}),e.push(Z(`sprite-preview`,`media-preview`,`动画预览`,``,1100,180),Z(`sprite-export`,`media-export`,`输出精灵图集`,``,1280,180)),t.push({id:`sprite-output`,source:`sprite-preview`,target:`sprite-export`,sourcePort:`output`,targetPort:`input`}),{id:`sprite`,name:`游戏精灵图生成`,description:`参考图 → 分方向动作 → 去背景 → 拆帧对齐 → 动画预览 → 图集`,Icon:z,nodes:e,edges:t,inputs:[{id:`sprite-reference`,name:`reference`,type:`image`,required:!0,label:`角色参考图`,description:`上传图片并保留原图风格。`,defaultValue:null},{id:`sprite-task`,name:`task`,type:`text`,required:!1,label:`角色与动作要求`,description:`本次运行的角色特征、动作及其他要求。`,defaultValue:``}]}}Gt.push(Kt());function qt(e){return e.nodes.reduce((e,t)=>e+(t.enabled&&t.kind===`media-generate`?et(t.image).directions.length:0),0)}function Jt(e=``,t){let n=[Z(crypto.randomUUID(),`trigger`,`手动触发`,``,65,45),Z(crypto.randomUUID(),`prompt`,`运行 Prompt`,Wt(`按本次输入完成任务,结合材料执行所需步骤,验证产物并报告结果。`),235,45)];return{id:``,name:`未命名工作流`,description:``,status:`draft`,revision:1,cwd:e,model:null,inputs:Ut(t),tags:[],visibility:`private`,notifications:[],nodes:n,edges:Ht(n)}}function Yt(e,t){if(e.kind===`media-generate`){if(e.image?.action===`idle`)return t(`workflows:imageNodes.idle`);if(e.image?.action===`walk`)return t(`workflows:imageNodes.walk`);if(e.image?.action===`run`)return t(`workflows:imageNodes.run`);if(e.image?.action===`attack`)return t(`workflows:imageNodes.attack`)}return zt(e.kind,t)}function Xt(e,t=``,n){let r=e.nodes.map(t=>({...structuredClone(t),...e.id===`sprite`&&n?{label:Yt(t,n)}:{},id:crypto.randomUUID()})),i=Gt.includes(e)?Ut(n):[],a=new Map(e.nodes.map((e,t)=>[e.id,r[t].id]));return{...Jt(t,n),name:n&&Gt.includes(e)?Bt(e.id,n):e.name,description:n&&Gt.includes(e)?Vt(e.id,n):e.description,inputs:e.inputs.map(t=>{let r=i.find(e=>e.name===t.name);return{...structuredClone(t),...r?{label:r.label,description:r.description}:{},...e.id===`sprite`&&t.name===`reference`&&n?{label:n(`workflows:imageNodes.reference`),description:n(`workflows:imageNodes.referenceHint`)}:{},id:crypto.randomUUID()}}),nodes:r,edges:e.edges?e.edges.map(e=>({...e,id:crypto.randomUUID(),source:a.get(e.source)??``,target:a.get(e.target)??``})):Ht(r)}}function Zt({nodeCount:e,t,onAddNode:n}){let[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(``),s=[{label:t(`workflows:editor.flowNodes`),match:e=>[`trigger`,`condition`,`parallel`,`approval`].includes(e)},{label:t(`workflows:editor.agentNodes`),match:e=>[`prompt`,`skill`,`file`,`mcp`,`notification`].includes(e)},{label:t(`workflows:editor.imageNodes`),match:Ct}],c=Lt.filter(({kind:e})=>zt(e,t).toLocaleLowerCase().includes(a.trim().toLocaleLowerCase()));return(0,X.jsxs)(_,{open:r,onOpenChange:i,children:[(0,X.jsx)(m,{asChild:!0,children:(0,X.jsxs)(K,{variant:`outline`,size:`sm`,children:[(0,X.jsx)(de,{}),t(`workflows:editor.addNode`)]})}),(0,X.jsxs)(h,{align:`end`,className:`w-72 max-w-[calc(100vw-2rem)] p-2`,"aria-label":t(`workflows:workflowsPage.nodeLibrary`),children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(pe,{className:`pointer-events-none absolute left-2.5 top-2.5 size-4 text-muted-foreground`}),(0,X.jsx)(q,{value:a,onChange:e=>o(e.target.value),className:`pl-8`,placeholder:t(`workflows:editor.searchNodes`),"aria-label":t(`workflows:editor.searchNodes`)})]}),(0,X.jsxs)(`div`,{className:`node-library max-h-[min(420px,60vh)] overflow-y-auto overscroll-contain supports-[height:100dvh]:max-h-[min(420px,60dvh)]`,children:[s.map(r=>{let a=c.filter(({kind:e})=>r.match(e));return a.length===0?null:(0,X.jsxs)(`section`,{className:`py-1`,children:[(0,X.jsx)(`h3`,{className:`px-2 py-1.5 text-xs font-medium text-muted-foreground`,children:r.label}),a.map(({kind:r,Icon:a})=>(0,X.jsxs)(`button`,{type:`button`,draggable:!0,className:`flex min-h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>{n(r,zt(r,t),{x:160+e%4*180,y:100+Math.floor(e/4)*100}),i(!1)},onDragStart:e=>e.dataTransfer.setData(`text/plain`,JSON.stringify({kind:r,label:zt(r,t)})),onDragEnd:()=>i(!1),children:[(0,X.jsx)(a,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`flex-1`,children:zt(r,t)}),(0,X.jsx)(se,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]},r))]},r.label)}),c.length===0&&(0,X.jsx)(`p`,{className:`p-3 text-xs text-muted-foreground`,children:t(`workflows:editor.noMatchingNodes`)})]})]})]})}function Qt({draft:e,selectedNodeId:t,selectedEdgeId:n,t:r,onAddNode:i,onConnect:a,onMoveNode:o,onSelectNode:s,onSelectEdge:c,onClearSelection:l,onDeleteNodes:u,onDeleteEdges:d}){return(0,X.jsx)(`section`,{className:`builder-canvas relative h-full min-h-0 min-w-0 overflow-hidden bg-[var(--canvas-bg)]`,"aria-label":r(`workflows:editor.canvas`),children:(0,X.jsx)(jt,{nodes:e.nodes,edges:e.edges,selectedNodeId:t,selectedEdgeId:n,hint:r(`workflows:workflowsPage.dragFromANodeOutputToTheTargetInputToConnectThem`),inputLabel:r(`workflows:workflowsPage.inputPort`),outputLabel:r(`workflows:workflowsPage.outputPort`),nodeTypeLabel:e=>Rt(e,r),onAddNode:i,onConnect:a,onMoveNode:o,onSelectNode:s,onSelectEdge:c,onClearSelection:l,onDeleteNodes:u,onDeleteEdges:d})})}function $t(e){if(e.size>134217728)throw new xe(`Workflow package exceeds 128 MiB`,{kind:`protocol`,data:{code:`workflow_bundle_too_large`}})}function en(e){return e instanceof xe&&e.data?.code===`workflow_bundle_too_large`}function tn(e,t){return Se(`/api/workflows/${encodeURIComponent(e)}/bundle`,{signal:t,timeout:12e4})}async function nn(e,t){return $t(e),W(`/api/workflows/import-bundle`,{method:`POST`,data:e,signal:t,timeout:12e4,parse:e=>{if(!e||typeof e!=`object`||!(`workflow`in e))throw U();let t=e.workflow;if(!t||typeof t!=`object`||!(`id`in t)||typeof t.id!=`string`)throw U()}})}var rn={workflows:[],runs:[],limits:{maxConcurrent:4,running:0},notificationTargets:{browser:{enabled:!1},feishu:{enabled:!1},weixin:{enabled:!1},qq:{enabled:!1},telegram:{enabled:!1}},models:[],skills:[],cwd:``};function Q(e){let t=e instanceof xe?e.data?.code:typeof e==`string`?e:e&&typeof e==`object`&&`code`in e?e.code:``;return t===`workflow_image_source_stale`?o(`workflows:imageNodes.sourceStale`):t===`workflow_image_source_required`?o(`workflows:imageNodes.sourceRequired`):t===`workflow_image_engine_missing`?o(`workflows:imageNodes.engineMissing`):t===`workflow_image_generation_failed`?o(`workflows:imageNodes.generationFailed`):t===`workflow_image_too_large`?o(`workflows:imageNodes.tooLarge`):t===`workflow_image_timeout`?o(`workflows:imageNodes.timeout`):typeof t==`string`&&t.startsWith(`workflow_image_`)?o(`workflows:imageNodes.invalidOutput`):e instanceof Error?e.message:String(e)}function an({notify:e,requestConfirm:t,query:n}){let{t:r}=s(),[i,a]=(0,Y.useState)(rn),[o,c]=(0,Y.useState)(`all`),[l,u]=(0,Y.useState)(!0),[d,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(``),h=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>h.current?.abort(),[]);let g=(0,Y.useCallback)(async()=>{try{a(await G(`/api/workflows`)),m(``)}catch(e){m(Q(e))}finally{u(!1)}},[]);(0,Y.useEffect)(()=>{g()},[g]),(0,Y.useEffect)(()=>{let e=window.setInterval(()=>{g()},i.limits.running?1500:8e3);return()=>window.clearInterval(e)},[i.limits.running,g]);let _=(0,Y.useCallback)(e=>i.runs.filter(t=>t.workflowId===e).sort((e,t)=>Date.parse(t.startedAt)-Date.parse(e.startedAt))[0],[i.runs]);return{data:i,filter:o,setFilter:c,loading:l,busyId:d,error:p,visibleWorkflows:(0,Y.useMemo)(()=>i.workflows.filter(e=>{let t=_(e.id);return`${e.name} ${e.description}`.toLowerCase().includes(n.toLowerCase())?o===`running`?t?.status===`running`:o===`failed`?t?.status===`failed`:o===`draft`?e.status===`draft`:o!==`presets`:!1}),[i.workflows,o,_,n]),latestRun:_,runWorkflow:(0,Y.useCallback)(async(t,n={})=>{f(t.id),m(``);try{return await G(`/api/workflows/${encodeURIComponent(t.id)}/run`,{method:`POST`,body:JSON.stringify({inputs:n})}),await g(),e(r(`workflows:workflowsPage.workflowStarted`)),!0}catch(t){let n=Q(t);return m(n),e(n,`error`),!1}finally{f(``)}},[g,e,r]),stopRun:(0,Y.useCallback)(async t=>{f(t.id),m(``);try{await G(`/api/workflow-runs/${encodeURIComponent(t.id)}/stop`,{method:`POST`,body:`{}`}),await g(),e(r(`workflows:workflowsPage.stoppingWorkflow`),`info`)}catch(t){let n=Q(t);m(n),e(n,`error`)}finally{f(``)}},[g,e,r]),retryRun:(0,Y.useCallback)(async t=>{f(t.id);try{await G(`/api/workflow-runs/${encodeURIComponent(t.id)}/retry`,{method:`POST`,body:`{}`}),await g(),e(r(`workflows:workflowsPage.workflowStarted`))}catch(t){let n=Q(t);m(n),e(n,`error`)}finally{f(``)}},[g,e,r]),resolveApproval:(0,Y.useCallback)(async(t,n,r)=>{f(n);try{await G(`/api/workflow-runs/${encodeURIComponent(t.id)}/approvals/${encodeURIComponent(n)}`,{method:`POST`,body:JSON.stringify({approved:r})}),await g()}catch(t){let n=Q(t);m(n),e(n,`error`)}finally{f(``)}},[g,e]),duplicateWorkflow:(0,Y.useCallback)(async t=>{f(t.id);try{await G(`/api/workflows/${encodeURIComponent(t.id)}/duplicate`,{method:`POST`,body:`{}`}),await g(),e(r(`workflows:workflowsPage.workflowDuplicated`))}catch(t){let n=Q(t);m(n),e(n,`error`)}finally{f(``)}},[g,e,r]),exportWorkflow:(0,Y.useCallback)(async t=>{if(h.current)return;let n=new AbortController;h.current=n,f(t.id);try{let e=await tn(t.id,n.signal);if(n.signal.aborted)return;let r=URL.createObjectURL(e),i=document.createElement(`a`);i.href=r,i.download=`${t.name.replace(/[\\/:*?"<>|]/g,`-`)}.pisper-workflow.zip`,i.click(),window.setTimeout(()=>URL.revokeObjectURL(r),1e3)}catch{n.signal.aborted||e(r(`workflows:workflowsPage.packageFailed`),`error`)}finally{h.current=null,n.signal.aborted||f(``)}},[e,r]),importWorkflow:(0,Y.useCallback)(async t=>{if(h.current)return;let n=new AbortController;h.current=n,f(`import`);try{if(await nn(t,n.signal),n.signal.aborted||(await g(),n.signal.aborted))return;e(r(`workflows:workflowsPage.workflowImported`))}catch(t){if(n.signal.aborted)return;let i=en(t)?r(`workflows:workflowsPage.packageTooLarge`):r(`workflows:workflowsPage.packageFailed`);m(i),e(i,`error`)}finally{h.current=null,n.signal.aborted||f(``)}},[g,e,r]),removeWorkflow:(0,Y.useCallback)(async n=>{if(await t?.({title:r(`workflows:workflowsPage.deleteWorkflow`),message:r(`workflows:workflowsPage.deleteWorkflowNameAndItsRunHistory`,{name:n.name}),confirmLabel:r(`workflows:workflowsPage.delete`),tone:`danger`})){f(n.id);try{await G(`/api/workflows/${encodeURIComponent(n.id)}`,{method:`DELETE`}),await g(),e(r(`workflows:workflowsPage.workflowDeleted`))}catch(t){let n=Q(t);m(n),e(n,`error`)}finally{f(``)}}},[g,e,t,r])}}function on(e){let t=Math.max(0,Math.round((Number(e)||0)/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function sn(e,t){return t(e===`running`?`workflows:workflowsPage.running`:e===`waiting_approval`?`workflows:workflowsPage.waitingApproval`:e===`completed`?`workflows:workflowsPage.completed`:e===`failed`?`workflows:workflowsPage.failed`:e===`cancelled`?`workflows:workflowsPage.stopped`:e===`interrupted`?`workflows:workflowsPage.interrupted`:`workflows:workflowsPage.draft`)}function cn({value:e,onChange:t,t:n}){return(0,X.jsx)(T,{value:e,onValueChange:e=>t(e),children:(0,X.jsxs)(w,{className:`[&_[data-slot='tabs-trigger']]:min-w-[56px] [&_[data-slot='tabs-trigger']]:flex-none [&_[data-slot='tabs-trigger']]:[padding-inline:12px] [&_[data-slot='tabs-trigger']]:text-[12px] [&_[data-slot='tabs-trigger']]:after:hidden w-fit max-w-full justify-start overflow-x-auto overflow-y-hidden [scrollbar-width:none]! [&::-webkit-scrollbar]:hidden`,children:[(0,X.jsx)(C,{value:`workflows`,children:n(`workflows:workflowsPage.workflows`)}),(0,X.jsx)(C,{value:`runs`,children:n(`workflows:workflowsPage.runHistory`)}),(0,X.jsx)(C,{value:`templates`,children:n(`workflows:workflowsPage.templates`)})]})})}function ln({workflows:e,runs:t,busyId:n,language:r,t:i,onRun:a,onEdit:o,onDuplicate:s,onExport:c,onImport:l,onDelete:u}){let d=(0,Y.useRef)(null),f=e=>t.filter(t=>t.workflowId===e).sort((e,t)=>Date.parse(t.startedAt)-Date.parse(e.startedAt))[0];return(0,X.jsx)(Le,{size:`sm`,className:`workflow-card [&_h2]:text-[16px] [&_h2]:tracking-[-.02em] [.detail-stack_>_&]:[flex:0_0_auto] [border:1px_solid_var(--stroke)] rounded-[var(--r-xs)] bg-[var(--panel)] text-[var(--text)] shadow-[0_1px_2px_var(--sh-edge),0_14px_32px_-24px_var(--shadow)] workflow-assets-panel overflow-hidden gap-0 py-0`,children:(0,X.jsxs)(Fe,{className:`p-0`,children:[(0,X.jsxs)(`div`,{className:`workflow-table-head [&_>_div]:flex [&_>_div]:min-w-0 [&_>_div]:flex-col [&_>_div]:gap-[2px] [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] flex min-h-[58px] items-center justify-between gap-[12px] [border-bottom:1px_solid_var(--stroke-soft)] [padding:10px_14px]`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(Ie,{className:`workflow-section-title [.selection-list_&]:mb-[8px] [.node-library_&]:mb-[8px] text-[var(--text-soft)] text-[13px] font-[700] leading-[1.4]`,children:i(`workflows:workflowsPage.workflows`)}),(0,X.jsx)(`small`,{children:i(`workflows:workflowsPage.countWorkflows`,{count:e.length})})]}),(0,X.jsxs)(K,{size:`sm`,variant:`outline`,onClick:()=>d.current?.click(),children:[(0,X.jsx)(vt,{"data-icon":`inline-start`}),i(`workflows:workflowsPage.import`)]}),(0,X.jsx)(`input`,{ref:d,className:`sr-only`,type:`file`,accept:`application/zip,.zip`,onChange:e=>{let t=e.target.files?.[0];e.currentTarget.value=``,t&&l(t)}})]}),e.length?(0,X.jsx)(`div`,{className:`flex flex-col`,children:e.map(e=>{let t=f(e.id),l=[`running`,`waiting_approval`].includes(t?.status||``);return(0,X.jsxs)(`div`,{className:`workflow-asset-row first:[border-top:0] max-[650px]:grid-cols-[minmax(0,1fr)_92px] max-[650px]:gap-[8px_12px] max-[650px]:[padding-block:10px] grid min-h-[62px] grid-cols-[minmax(220px,1fr)_110px_150px_auto] items-center gap-[14px] [border-top:1px_solid_var(--stroke-soft)] [padding:8px_12px_8px_14px]`,children:[(0,X.jsxs)(`button`,{className:`workflow-asset-main [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] flex min-w-0 flex-col gap-[3px] border-0 bg-transparent text-[var(--text)] text-left cursor-pointer`,onClick:()=>o(e.id),children:[(0,X.jsx)(`strong`,{children:e.name}),(0,X.jsx)(`small`,{children:e.description||e.cwd})]}),(0,X.jsxs)(`span`,{className:`workflow-state [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[10px] [&_small]:font-[400] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&.running]:text-[var(--warning-strong)] [&.waiting_approval]:text-[var(--warning-strong)] [&.completed]:text-[var(--success)] [&.published]:text-[var(--success)] [&.failed]:text-[var(--danger)] max-[650px]:[.workflow-asset-row_>_&:nth-of-type(2)]:[grid-column:1] flex min-w-0 flex-col gap-[2px] text-[var(--text-secondary)] text-[11px] font-[600] ${e.status}`,children:[e.status===`published`?i(`workflows:workflowsPage.published`):i(`workflows:workflowsPage.draft`),(0,X.jsxs)(`small`,{children:[`v`,e.revision]})]}),(0,X.jsxs)(`span`,{className:`workflow-state [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[10px] [&_small]:font-[400] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&.running]:text-[var(--warning-strong)] [&.waiting_approval]:text-[var(--warning-strong)] [&.completed]:text-[var(--success)] [&.published]:text-[var(--success)] [&.failed]:text-[var(--danger)] max-[650px]:[.workflow-asset-row_>_&:nth-of-type(2)]:[grid-column:1] flex min-w-0 flex-col gap-[2px] text-[var(--text-secondary)] text-[11px] font-[600] ${t?.status||`idle`}`,children:[t?sn(t.status,i):i(`workflows:workflowsPage.neverRun`),(0,X.jsx)(`small`,{children:t?Pe(t.startedAt,r):e.visibility})]}),(0,X.jsxs)(`div`,{className:`workflow-row-actions max-[650px]:[grid-column:2] max-[650px]:[grid-row:1/3] max-[650px]:flex-wrap flex items-center justify-end gap-[3px]`,children:[(0,X.jsx)(K,{size:`icon-xs`,variant:l?`secondary`:`outline`,disabled:l||n===e.id,title:i(`workflows:workflowsPage.run`),"aria-label":`${i(`workflows:workflowsPage.run`)}: ${e.name}`,onClick:()=>a(e),children:n===e.id?(0,X.jsx)(H,{className:`animate-spin`}):(0,X.jsx)(V,{fill:`currentColor`})}),(0,X.jsx)(K,{size:`icon-xs`,variant:`ghost`,title:i(`workflows:workflowsPage.edit`),"aria-label":`${i(`workflows:workflowsPage.edit`)}: ${e.name}`,onClick:()=>o(e.id),children:(0,X.jsx)(B,{})}),(0,X.jsx)(K,{size:`icon-xs`,variant:`ghost`,title:i(`workflows:workflowsPage.duplicateWorkflow`),"aria-label":`${i(`workflows:workflowsPage.duplicateWorkflow`)}: ${e.name}`,onClick:()=>s(e),children:(0,X.jsx)(ie,{})}),(0,X.jsx)(K,{size:`icon-xs`,variant:`ghost`,title:i(`workflows:workflowsPage.export`),"aria-label":`${i(`workflows:workflowsPage.export`)}: ${e.name}`,onClick:()=>c(e),children:(0,X.jsx)(R,{})}),(0,X.jsx)(K,{size:`icon-xs`,variant:`ghost`,disabled:l,title:i(`workflows:workflowsPage.delete`),"aria-label":`${i(`workflows:workflowsPage.delete`)}: ${e.name}`,onClick:()=>u(e),children:(0,X.jsx)(ve,{})})]})]},e.id)})}):(0,X.jsx)(`div`,{className:`channel-route-empty [&_strong]:mt-[9px] [&_strong]:text-[var(--text)] [&_strong]:text-[12px] [&_span]:mt-[4px] [&_span]:text-[13px] [&.compact]:min-h-[110px] [.workflow-assets-panel_&]:min-h-[150px] [.workflow-assets-panel_&]:border-0 [.workflow-assets-panel_&]:bg-transparent grid min-h-[185px] place-content-center justify-items-center text-[var(--text-muted)] text-center compact`,children:(0,X.jsx)(`strong`,{children:i(`workflows:workflowsPage.noMatchingWorkflows`)})})]})})}function un({runs:e,busyId:t,language:n,t:r,onStop:i,onRetry:a,onApproval:o}){let[s,c]=(0,Y.useState)(e[0]?.id||``),l=[...e].sort((e,t)=>Date.parse(t.startedAt)-Date.parse(e.startedAt));return(0,X.jsxs)(`div`,{className:`flex flex-col gap-[8px]`,children:[l.map(e=>{let l=s===e.id,u=Math.round((Number(e.completedNodes)||0)/Math.max(1,Number(e.totalNodes)||1)*100);return(0,X.jsx)(Le,{size:`sm`,className:`workflow-card [&_h2]:text-[16px] [&_h2]:tracking-[-.02em] [.detail-stack_>_&]:[flex:0_0_auto] [border:1px_solid_var(--stroke)] rounded-[var(--r-xs)] bg-[var(--panel)] text-[var(--text)] shadow-[0_1px_2px_var(--sh-edge),0_14px_32px_-24px_var(--shadow)] overflow-hidden gap-0 py-0`,children:(0,X.jsxs)(Fe,{className:`p-0`,children:[(0,X.jsxs)(`button`,{className:`workflow-run-summary hover:bg-[var(--surface-hover)] [&_>_span]:flex [&_>_span]:min-w-0 [&_>_span]:flex-col [&_>_span]:gap-[2px] [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] [&_small]:[font-style:normal] [&_em]:text-[var(--text-muted)] [&_em]:text-[11px] [&_em]:[font-style:normal] [&_[data-slot='progress']]:h-[5px] max-[650px]:grid-cols-[18px_minmax(0,1fr)_54px] max-[650px]:gap-[8px] max-[650px]:[&_[data-slot='progress']]:[grid-column:2/4] grid w-full min-h-[58px] grid-cols-[18px_minmax(180px,1fr)_minmax(120px,240px)_70px] items-center gap-[12px] border-0 bg-transparent [padding:9px_14px] text-[var(--text)] text-left cursor-pointer`,onClick:()=>c(l?``:e.id),children:[l?(0,X.jsx)(I,{size:15}):(0,X.jsx)(L,{size:15}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:e.workflowName||e.workflowId}),(0,X.jsxs)(`small`,{children:[sn(e.status,r),` · `,Pe(e.startedAt,n),` · v`,e.workflowRevision||1]})]}),(0,X.jsx)(x,{value:e.status===`completed`?100:u}),(0,X.jsx)(`em`,{children:on(e.durationMs)})]}),l&&(0,X.jsxs)(`div`,{className:`workflow-run-detail max-[650px]:pl-[14px] flex flex-col gap-[10px] [border-top:1px_solid_var(--stroke-soft)] [padding:12px_14px_14px_44px]`,children:[(e.summary||e.error)&&(0,X.jsx)(`div`,{className:`workflow-run-result [&.failed]:border-[var(--danger)] [&.failed]:text-[var(--danger)] [border-left:2px_solid_var(--success)] [padding:4px_8px] text-[var(--text-secondary)] text-[12px] whitespace-pre-wrap ${e.error?`failed`:``}`,children:e.error?Q(e.error):e.summary}),(0,X.jsx)(`div`,{className:`flex flex-col`,children:(e.nodes||[]).map(n=>(0,X.jsxs)(`div`,{className:`workflow-run-node first:[border-top:0] [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_>_span:nth-child(2)]:gap-[2px] [&_strong]:text-[12px] [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] [&_p]:text-[var(--text-muted)] [&_p]:text-[11px] [&_p]:mt-[3px] [&_p]:whitespace-pre-wrap max-[650px]:grid-cols-[18px_minmax(0,1fr)] max-[650px]:[&_>_div]:[grid-column:2] grid min-h-[46px] grid-cols-[20px_minmax(0,1fr)_auto] items-center gap-[8px] [border-top:1px_solid_var(--stroke-soft)] [padding:6px_0] ${n.status}`,children:[(0,X.jsx)(`span`,{className:`workflow-node-status [.workflow-run-node.completed_&]:text-[var(--success)] [.workflow-run-node.failed_&]:text-[var(--danger)] grid place-items-center text-[var(--text-muted)]`,children:n.status===`completed`?(0,X.jsx)(ee,{size:14}):n.status===`failed`?(0,X.jsx)(ne,{size:14}):n.status===`running`||n.status===`waiting_approval`?(0,X.jsx)(H,{className:n.status===`running`?`animate-spin`:``,size:14}):(0,X.jsx)(_e,{size:12})}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:n.label}),(0,X.jsxs)(`small`,{children:[sn(n.status,r),` · `,on(n.durationMs),` ·`,` `,r(`workflows:workflowsPage.countAttempts`,{count:n.attempts||0})]}),(n.error||n.summary)&&(0,X.jsx)(`p`,{children:n.error?Q(n.error):n.summary})]}),n.status===`waiting_approval`&&(0,X.jsxs)(`div`,{className:`workflow-approval-actions flex gap-[6px]`,children:[(0,X.jsxs)(K,{size:`xs`,disabled:t===n.id,onClick:()=>o(e,n.id,!0),children:[(0,X.jsx)(ee,{"data-icon":`inline-start`}),r(`workflows:workflowsPage.approve`)]}),(0,X.jsxs)(K,{size:`xs`,variant:`destructive`,disabled:t===n.id,onClick:()=>o(e,n.id,!1),children:[(0,X.jsx)(ne,{"data-icon":`inline-start`}),r(`workflows:workflowsPage.reject`)]})]})]},n.id))}),(0,X.jsx)(`div`,{className:`workflow-run-detail-actions flex gap-[6px]`,children:[`running`,`waiting_approval`].includes(e.status)?(0,X.jsxs)(K,{size:`sm`,variant:`destructive`,onClick:()=>i(e),children:[(0,X.jsx)(_e,{"data-icon":`inline-start`}),r(`workflows:workflowsPage.stop`)]}):[`failed`,`cancelled`,`interrupted`].includes(e.status)?(0,X.jsxs)(K,{size:`sm`,variant:`outline`,onClick:()=>a(e),children:[(0,X.jsx)(H,{"data-icon":`inline-start`}),r(`workflows:workflowsPage.retryRun`)]}):null})]})]})},e.id)}),!l.length&&(0,X.jsx)(ze,{size:`sm`,className:`workflow-card [&_h2]:text-[16px] [&_h2]:tracking-[-.02em] [.detail-stack_>_&]:[flex:0_0_auto] [border:1px_solid_var(--stroke)] rounded-[var(--r-xs)] bg-[var(--panel)] text-[var(--text)] shadow-[0_1px_2px_var(--sh-edge),0_14px_32px_-24px_var(--shadow)]`,children:(0,X.jsx)(`strong`,{children:r(`workflows:workflowsPage.noRunHistory`)})})]})}function dn({t:e,onOpenTemplate:t}){return(0,X.jsx)(`div`,{className:`workflow-template-gallery [&_>_button]:grid [&_>_button]:min-h-[72px] [&_>_button]:grid-cols-[34px_minmax(0,1fr)_18px] [&_>_button]:items-center [&_>_button]:gap-[10px] [&_>_button]:[border:1px_solid_var(--stroke)] [&_>_button]:rounded-[var(--r-sm)] [&_>_button]:bg-[var(--panel)] [&_>_button]:p-[11px] [&_>_button]:text-[var(--text)] [&_>_button]:text-left [&_>_button]:cursor-pointer [&_>_button:hover]:border-[var(--accent-border)] [&_>_button:hover]:bg-[var(--surface-hover)] [&_button_>_span:nth-child(2)]:flex [&_button_>_span:nth-child(2)]:min-w-0 [&_button_>_span:nth-child(2)]:flex-col [&_button_>_span:nth-child(2)]:gap-[3px] [&_strong]:text-[13px] [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap max-[650px]:grid-cols-[1fr] grid grid-cols-[repeat(2,minmax(0,1fr))] gap-[8px]`,children:Gt.map(n=>{let r=n.Icon;return(0,X.jsxs)(`button`,{onClick:()=>t(n.id),children:[(0,X.jsx)(`span`,{className:`list-icon [.chat-resource-list_&]:grid [.chat-resource-list_&]:w-[28px] [.chat-resource-list_&]:h-[28px] [.chat-resource-list_&]:place-items-center [.chat-resource-list_&]:rounded-[var(--r-sm)] [.chat-resource-list_&]:bg-[var(--surface-subtle)] [.chat-resource-list_&]:text-[var(--star-strong)] [.session-workflow-summary_&]:grid [.session-workflow-summary_&]:w-[28px] [.session-workflow-summary_&]:h-[28px] [.session-workflow-summary_&]:place-items-center [.session-workflow-summary_&]:rounded-[var(--r-sm)] [.session-workflow-summary_&]:bg-[var(--surface-subtle)] [.session-workflow-summary_&]:text-[var(--star-strong)] grid w-[27px] h-[27px] place-items-center rounded-[var(--r-sm)] bg-[var(--accent-soft)] text-[var(--star-strong)] [.workflow-template-gallery_&]:grid [.workflow-template-gallery_&]:w-[32px] [.workflow-template-gallery_&]:h-[32px] [.workflow-template-gallery_&]:place-items-center [.workflow-template-gallery_&]:rounded-[var(--r-sm)] [.workflow-template-gallery_&]:bg-[var(--surface-subtle)] [.workflow-template-gallery_&]:text-[var(--star-strong)]`,children:(0,X.jsx)(r,{size:16})}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:Bt(n.id,e)}),(0,X.jsx)(`small`,{children:Vt(n.id,e)})]}),(0,X.jsx)(L,{size:15})]},n.id)})})}function fn({data:e,t}){let n=e.runs.filter(e=>e.status===`failed`).length,r=e.runs.filter(e=>e.status===`waiting_approval`).length,i=e.runs.filter(e=>e.status===`completed`),a=i.length?i.reduce((e,t)=>e+(t.durationMs||0),0)/i.length:0;return(0,X.jsxs)(`div`,{className:`workflow-operations-strip [&_>_span]:inline-flex [&_>_span]:[align-items:baseline] [&_>_span]:gap-[5px] [&_>_span]:text-[var(--text-muted)] [&_>_span]:text-[11px] [&_>_span]:whitespace-nowrap [&_strong]:text-[var(--text)] [&_strong]:text-[13px] [&_strong]:[font-variant-numeric:tabular-nums] max-[650px]:justify-between max-[650px]:gap-[6px] max-[650px]:overflow-x-auto max-[650px]:[&_>_span]:flex-col max-[650px]:[&_>_span]:gap-[0] flex min-w-0 items-center gap-[18px]`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:e.limits.running}),t(`workflows:workflowsPage.running`)]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:r}),t(`workflows:workflowsPage.waitingApproval`)]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:n}),t(`workflows:workflowsPage.failed`)]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:on(a)}),t(`workflows:workflowsPage.averageDuration`)]})]})}function pn({value:e=``,onValueChange:t,files:n=[],onFilesSelected:r,onRemoveFile:i,accept:a=`media`,allowFiles:o=!0,allowText:s=!0,multiple:c=!1,disabled:l=!1,label:u,placeholder:f,attachmentLabel:p,removeLabel:m,children:h,className:g,maxLength:_}){let v=(0,Y.useId)(),b=(0,Y.useRef)(null),x=a===`image`?`image/png,image/jpeg,image/webp`:a===`video`?`video/mp4,video/webm`:`image/png,image/jpeg,image/webp,video/mp4,video/webm`;return(0,X.jsxs)(`div`,{className:E(`flex min-w-0 flex-col gap-2`,g),children:[(0,X.jsx)(d,{htmlFor:s?`${v}-text`:`${v}-picker`,children:u}),(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl border bg-background focus-within:ring-2 focus-within:ring-ring/25`,onDragOver:e=>{o&&e.preventDefault()},onDrop:e=>{o&&(e.preventDefault(),!l&&e.dataTransfer.files.length&&r?.(Array.from(e.dataTransfer.files)))},children:[s&&(0,X.jsx)(rt,{id:`${v}-text`,value:e,onChange:e=>t?.(e.target.value),placeholder:f,disabled:l,maxLength:_,className:`min-h-28 resize-y border-0 bg-transparent shadow-none focus-visible:ring-0`}),n.length>0&&(0,X.jsx)(`ul`,{className:E(`grid min-w-0 gap-2 p-3`,n.length>1&&`sm:grid-cols-2`),children:n.map(e=>(0,X.jsxs)(`li`,{className:`relative min-w-0 rounded-lg border bg-muted/20 p-2`,children:[e.url&&e.mimeType.startsWith(`image/`)?(0,X.jsx)(`img`,{src:e.url,alt:e.name,className:`h-32 w-full rounded object-contain`}):e.url&&e.mimeType.startsWith(`video/`)?(0,X.jsx)(`video`,{src:e.url,controls:!0,preload:`metadata`,className:`h-32 w-full rounded object-contain`,"aria-label":e.name}):(0,X.jsx)(`div`,{className:`flex h-12 items-center justify-center text-muted-foreground`,children:e.mimeType.startsWith(`video/`)?(0,X.jsx)(A,{}):(0,X.jsx)(y,{})}),(0,X.jsx)(`p`,{className:`mt-2 truncate pr-8 text-xs`,title:e.name,children:e.name}),i&&(0,X.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:l,className:`absolute right-1 bottom-1`,"aria-label":`${m} ${e.name}`,onClick:()=>i(e.id),children:(0,X.jsx)(be,{className:`size-3.5`})})]},e.id))}),o&&(0,X.jsxs)(`div`,{className:`p-2`,children:[(0,X.jsx)(`input`,{id:`${v}-picker`,ref:b,className:`sr-only`,type:`file`,accept:x,multiple:c,disabled:l,"aria-label":p,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,t.length&&r?.(t)}}),(0,X.jsxs)(K,{type:`button`,variant:`ghost`,size:`sm`,disabled:l,onClick:()=>b.current?.click(),children:[(0,X.jsx)(ue,{className:`size-4`}),p]})]})]}),h]})}function mn(e){if(!e||typeof e!=`object`||!(`models`in e)||!Array.isArray(e.models))throw U();return e.models.map(e=>{if(!e||typeof e!=`object`||!(`id`in e)||typeof e.id!=`string`||!(`name`in e)||typeof e.name!=`string`||!(`providerId`in e)||typeof e.providerId!=`string`||!(`providerName`in e)||typeof e.providerName!=`string`||!e.id.startsWith(`${e.providerId}/`))throw U();return{id:e.id,name:e.name,providerId:e.providerId,providerName:e.providerName}})}function hn(e){if(!e||typeof e!=`object`||!(`started`in e)||e.started!==!0||!(`run`in e)||!e.run||typeof e.run!=`object`||!(`id`in e.run)||typeof e.run.id!=`string`||!(`workflowId`in e.run)||typeof e.run.workflowId!=`string`)throw U();return{started:!0,run:{id:e.run.id,workflowId:e.run.workflowId}}}var gn={runNode:(e,t,n,r)=>W(`/api/workflows/${encodeURIComponent(e)}/nodes/${encodeURIComponent(t)}/run`,{method:`POST`,data:{sourceRunId:n},signal:r,parse:hn}),models:e=>W(`/api/workflow-image-models`,{signal:e,parse:mn})},_n=[`workflows`,`sprite-engines`];function vn(e){try{return nt(e)}catch{throw U()}}var yn={catalog:e=>W(`/api/sprite-engines`,{signal:e,parse:vn}),download:(e,t)=>W(`/api/sprite-engines/${e}/download`,{method:`POST`,data:{},signal:t,parse:vn}),cancel:(e,t)=>W(`/api/sprite-engines/${e}/cancel`,{method:`POST`,data:{},signal:t,parse:vn}),remove:(e,t)=>W(`/api/sprite-engines/${e}`,{method:`DELETE`,signal:t,parse:vn})};function $({label:e,value:t,min:n,max:r,step:i=1,onChange:a}){return(0,X.jsxs)(J,{variant:`control`,children:[e,(0,X.jsx)(q,{type:`number`,value:t,min:n,max:r,step:i,onChange:e=>{if(!e.target.value)return;let t=e.target.valueAsNumber;Number.isFinite(t)&&a(Math.max(n,Math.min(r,t)))}})]})}function bn({t:e,id:t=`background`}){let n=we(),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!1),s=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>s.current?.abort(),[]);let c=Ce({queryKey:_n,queryFn:({signal:e})=>yn.catalog(e),refetchInterval:e=>e.state.data?.engines.some(e=>e.status===`downloading`)?1e3:!1}),l=c.data?.engines.find(e=>e.id===t),u=async()=>{if(s.current)return;let e=new AbortController;s.current=e,o(!0),i(!1);try{n.setQueryData(_n,await yn.download(t,e.signal))}catch{e.signal.aborted||i(!0)}finally{e.signal.aborted||o(!1),s.current===e&&(s.current=null)}};return(0,X.jsxs)(`div`,{className:`space-y-2 rounded-lg border p-3 text-xs`,children:[(0,X.jsx)(`p`,{children:e(`workflows:imageNodes.modelHint`)}),(0,X.jsx)(`p`,{children:l?.status===`ready`?e(`workflows:imageNodes.engineReady`):l?.status===`downloading`?e(`workflows:imageNodes.engineDownloading`,{percent:Math.round(l.total?100*l.received/l.total:0)}):e(`workflows:imageNodes.engineMissing`)}),(r||c.isError||l?.status===`failed`)&&(0,X.jsx)(`p`,{role:`alert`,children:e(`workflows:imageNodes.engineFailed`)}),l?.status!==`ready`&&(0,X.jsxs)(K,{size:`sm`,variant:`outline`,disabled:a||l?.status===`downloading`,onClick:()=>void u(),children:[a||l?.status===`downloading`?(0,X.jsx)(ce,{className:`animate-spin`}):(0,X.jsx)(R,{}),e(`workflows:imageNodes.download`)]})]})}function xn({node:e,inputs:t,t:n,onChange:r}){let i=et(e.image),a=e=>r({image:{...i,...e}}),o=Ce({queryKey:[`workflows`,`image-models`],queryFn:({signal:e})=>gn.models(e),enabled:e.kind===`media-generate`}),[s,c]=(0,Y.useState)(0);(0,Y.useEffect)(()=>c(0),[e.id]);let l=i.transforms.find(e=>e.index===s)??{index:s,x:0,y:0,rotation:0,scale:1,opacity:1,durationMs:i.durationMs,enabled:!0},u=e=>a({transforms:[...i.transforms.filter(e=>e.index!==s),{...l,...e}]}),d=i.frameOrder,p=(e,t)=>{let n=[...d],r=e+t;r<0||r>=n.length||([n[e],n[r]]=[n[r],n[e]],a({frameOrder:n}))};return(0,X.jsxs)(`div`,{className:`my-3 space-y-3 border-y py-3`,children:[e.kind===`media-input`&&(0,X.jsxs)(J,{variant:`control`,children:[n(`workflows:imageNodes.inputField`),(0,X.jsxs)(f,{value:i.inputName,onChange:e=>a({inputName:e.target.value}),children:[!t.some(e=>e.type===`image`&&e.name===i.inputName)&&(0,X.jsx)(`option`,{value:i.inputName,children:n(`workflows:imageNodes.chooseInput`)}),t.filter(e=>e.type===`image`).map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.label},e.id))]}),(0,X.jsx)(`small`,{children:n(`workflows:imageNodes.inputHint`)})]}),e.kind===`media-generate`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(J,{variant:`control`,children:[n(`workflows:imageNodes.imageModel`),(0,X.jsxs)(f,{value:e.model?`${e.model.provider}/${e.model.model}`:``,onChange:e=>{let t=o.data?.find(t=>t.id===e.target.value);r({model:t?{provider:t.providerId,model:t.id.slice(t.providerId.length+1)}:null})},children:[(0,X.jsx)(`option`,{value:``,children:n(`workflows:imageNodes.defaultImageModel`)}),o.data?.map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[e.providerName,` / `,e.name]},e.id))]}),o.isError&&(0,X.jsx)(`small`,{role:`alert`,children:n(`workflows:imageNodes.modelsFailed`)})]}),(0,X.jsxs)(J,{variant:`control`,children:[n(`workflows:imageNodes.action`),(0,X.jsx)(q,{value:i.action,maxLength:160,onChange:e=>a({action:e.target.value})})]}),(0,X.jsx)(pn,{label:n(`workflows:imageNodes.prompt`),value:e.prompt,onValueChange:e=>r({prompt:e}),allowFiles:!1,maxLength:16e3,attachmentLabel:n(`workflows:inputs.chooseImage`),removeLabel:n(`workflows:inputs.removeMedia`)}),(0,X.jsx)($,{label:n(`workflows:imageNodes.frameCount`),value:i.frameCount,min:1,max:16,onChange:e=>a({frameCount:e})}),(0,X.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,X.jsx)(`legend`,{className:`text-sm`,children:n(`workflows:imageNodes.directions`)}),(0,X.jsx)(`div`,{className:`grid grid-cols-4 gap-1`,children:Qe.map(e=>(0,X.jsx)(K,{size:`sm`,variant:i.directions.includes(e)?`secondary`:`outline`,"aria-pressed":i.directions.includes(e),disabled:i.directions.length===1&&i.directions[0]===e,onClick:()=>a({directions:i.directions.includes(e)?i.directions.filter(t=>t!==e):Qe.filter(t=>i.directions.includes(t)||t===e)}),children:e},e))})]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`workflows:imageNodes.generateHint`,{count:i.directions.length})})]}),e.kind===`media-background`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(J,{variant:`control`,children:[n(`workflows:imageNodes.method`),(0,X.jsxs)(f,{value:i.method,onChange:e=>a({method:e.target.value===`model`?`model`:`color`}),children:[(0,X.jsx)(`option`,{value:`color`,children:n(`workflows:imageNodes.colorKey`)}),(0,X.jsx)(`option`,{value:`model`,children:n(`workflows:imageNodes.localModel`)})]})]}),i.method===`model`?(0,X.jsx)(bn,{t:n}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{className:`text-sm`,children:n(`workflows:imageNodes.colors`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`workflows:imageNodes.colorsHint`)}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:i.colors.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`input`,{className:`h-8 w-10 cursor-pointer rounded border`,type:`color`,value:e,"aria-label":n(`workflows:imageNodes.colorAt`,{index:t+1}),onChange:e=>a({colors:i.colors.map((n,r)=>r===t?e.target.value:n)})}),(0,X.jsx)(K,{size:`icon-xs`,variant:`ghost`,"aria-label":n(`workflows:imageNodes.removeColor`),onClick:()=>a({colors:i.colors.filter((e,n)=>n!==t)}),children:(0,X.jsx)(ve,{})})]},t))}),(0,X.jsxs)(K,{size:`sm`,variant:`outline`,disabled:i.colors.length>=8,onClick:()=>a({colors:[...i.colors,`#00ff00`]}),children:[(0,X.jsx)(de,{}),n(`workflows:imageNodes.addColor`)]})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,X.jsx)($,{label:n(`workflows:imageNodes.tolerance`),value:i.tolerance,min:0,max:255,onChange:e=>a({tolerance:e})}),(0,X.jsx)($,{label:n(`workflows:imageNodes.softness`),value:i.softness,min:0,max:64,onChange:e=>a({softness:e})})]}),(0,X.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm`,children:[n(`workflows:imageNodes.edgeConnected`),(0,X.jsx)(S,{checked:i.edgeConnected,onCheckedChange:e=>a({edgeConnected:e})})]})]})]}),e.kind===`media-inpaint`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`workflows:imageNodes.regionHint`)}),(0,X.jsx)(bn,{t:n,id:`inpaint`}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,X.jsx)($,{label:n(`workflows:imageNodes.regionX`),value:i.region.x,min:0,max:99,onChange:e=>a({region:{...i.region,x:e}})}),(0,X.jsx)($,{label:n(`workflows:imageNodes.regionY`),value:i.region.y,min:0,max:99,onChange:e=>a({region:{...i.region,y:e}})}),(0,X.jsx)($,{label:n(`workflows:imageNodes.regionWidth`),value:i.region.width,min:1,max:100,onChange:e=>a({region:{...i.region,width:e}})}),(0,X.jsx)($,{label:n(`workflows:imageNodes.regionHeight`),value:i.region.height,min:1,max:100,onChange:e=>a({region:{...i.region,height:e}})})]})]}),e.kind===`media-frames`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`workflows:imageNodes.gridHint`)}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,X.jsx)($,{label:n(`workflows:imageNodes.columns`),value:i.columns,min:1,max:16,onChange:e=>a({columns:e})}),(0,X.jsx)($,{label:n(`workflows:imageNodes.rows`),value:i.rows,min:1,max:16,onChange:e=>a({rows:e})})]}),(0,X.jsx)($,{label:n(`workflows:imageNodes.duration`),value:i.durationMs,min:16,max:1e4,onChange:e=>a({durationMs:e})})]}),e.kind===`media-transform`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm`,children:[n(`workflows:imageNodes.trim`),(0,X.jsx)(S,{checked:i.trim,onCheckedChange:e=>a({trim:e})})]}),(0,X.jsxs)(J,{variant:`control`,children:[n(`workflows:imageNodes.align`),(0,X.jsxs)(f,{value:i.align,onChange:e=>a({align:e.target.value===`center`?`center`:e.target.value===`none`?`none`:`bottom-center`}),children:[(0,X.jsx)(`option`,{value:`bottom-center`,children:n(`workflows:imageNodes.bottomCenter`)}),(0,X.jsx)(`option`,{value:`center`,children:n(`workflows:imageNodes.center`)}),(0,X.jsx)(`option`,{value:`none`,children:n(`workflows:imageNodes.noAlign`)})]})]}),(0,X.jsx)($,{label:n(`workflows:imageNodes.maxFrameSize`),value:i.maxFrameSize,min:16,max:1024,onChange:e=>a({maxFrameSize:Math.round(e)})}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`workflows:imageNodes.maxFrameSizeHint`,{size:i.maxFrameSize})}),(0,X.jsx)($,{label:n(`workflows:imageNodes.padding`),value:i.padding,min:0,max:64,onChange:e=>a({padding:e})}),(0,X.jsxs)(`details`,{className:`rounded-lg border p-3`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:n(`workflows:imageNodes.frameEdits`)}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,X.jsx)($,{label:n(`workflows:imageNodes.frameNumber`),value:s+1,min:1,max:512,onChange:e=>c(Math.round(e)-1)}),(0,X.jsxs)(`label`,{className:`flex justify-between text-sm`,children:[n(`workflows:imageNodes.frameEnabled`),(0,X.jsx)(S,{checked:l.enabled,onCheckedChange:e=>u({enabled:e})})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,X.jsx)($,{label:`X`,value:l.x,min:-4096,max:4096,onChange:e=>u({x:e})}),(0,X.jsx)($,{label:`Y`,value:l.y,min:-4096,max:4096,onChange:e=>u({y:e})}),(0,X.jsx)($,{label:n(`workflows:imageNodes.rotation`),value:l.rotation,min:-360,max:360,onChange:e=>u({rotation:e})}),(0,X.jsx)($,{label:n(`workflows:imageNodes.scale`),value:l.scale,min:.05,max:8,step:.05,onChange:e=>u({scale:e})}),(0,X.jsx)($,{label:n(`workflows:imageNodes.opacity`),value:l.opacity,min:0,max:1,step:.05,onChange:e=>u({opacity:e})}),(0,X.jsx)($,{label:n(`workflows:imageNodes.duration`),value:l.durationMs,min:16,max:1e4,onChange:e=>u({durationMs:e})})]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`workflows:imageNodes.orderHint`)}),(0,X.jsx)(K,{size:`sm`,variant:`outline`,disabled:d.includes(s),onClick:()=>a({frameOrder:[...d,s]}),children:n(`workflows:imageNodes.addToOrder`)}),d.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`mr-auto text-xs`,children:n(`workflows:imageNodes.frameAt`,{index:e+1})}),(0,X.jsx)(K,{size:`icon-xs`,variant:`ghost`,"aria-label":n(`workflows:imageNodes.earlier`),disabled:t===0,onClick:()=>p(t,-1),children:(0,X.jsx)(N,{})}),(0,X.jsx)(K,{size:`icon-xs`,variant:`ghost`,"aria-label":n(`workflows:imageNodes.later`),disabled:t===d.length-1,onClick:()=>p(t,1),children:(0,X.jsx)(g,{})}),(0,X.jsx)(K,{size:`icon-xs`,variant:`ghost`,"aria-label":n(`workflows:imageNodes.resetOrder`),onClick:()=>a({frameOrder:d.filter(t=>t!==e)}),children:(0,X.jsx)(ve,{})})]},e))]})]})]}),e.kind===`media-preview`&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`workflows:imageNodes.previewHint`)}),e.kind===`media-export`&&(0,X.jsxs)(J,{variant:`control`,children:[n(`workflows:imageNodes.filename`),(0,X.jsx)(q,{value:i.filename,maxLength:100,onChange:e=>a({filename:e.target.value})}),(0,X.jsx)(`small`,{children:n(`workflows:imageNodes.exportHint`)})]})]})}var Sn={upload:(e,t)=>W(`/api/workflow-media?name=${encodeURIComponent(e.name)}`,{method:`POST`,data:e,headers:{"Content-Type":e.type},signal:t,timeout:12e4,parse:e=>{try{return $e(e)}catch{throw U()}}}),preview:(e,t)=>Se(`/api/workflow-media/${encodeURIComponent(e)}/content`,{signal:t})};function Cn(e){try{return Ze(e)}catch{return null}}function wn(e){let[t,n]=(0,Y.useState)({id:``,image:null,error:!1}),r=e?.media.id;return(0,Y.useEffect)(()=>{if(n({id:r??``,image:null,error:!1}),!r)return;let e=new AbortController,t=``,i=null;return Sn.preview(r,e.signal).then(a=>{if(e.signal.aborted)return;t=URL.createObjectURL(a),i=new Image;let o=i;i.onload=()=>{e.signal.aborted||n({id:r,image:o,error:!1})},i.onerror=()=>{e.signal.aborted||n({id:r,image:null,error:!0})},i.src=t}).catch(()=>{e.signal.aborted||n({id:r,image:null,error:!0})}),()=>{e.abort(),i&&(i.onload=null,i.onerror=null,i.src=``),t&&URL.revokeObjectURL(t)}},[r]),t.id===r?t:{id:r??``,image:null,error:!1}}function Tn(e,t){return t(e===`workflow_image_source_stale`?`workflows:imageNodes.sourceStale`:e===`workflow_image_source_required`?`workflows:imageNodes.sourceRequired`:e===`workflow_image_engine_missing`?`workflows:imageNodes.engineMissing`:e===`workflow_image_decode_failed`?`workflows:imageNodes.decodeFailed`:e===`workflow_image_generation_failed`?`workflows:imageNodes.generationFailed`:e===`workflow_image_too_large`?`workflows:imageNodes.tooLarge`:e===`workflow_image_cancelled`?`workflows:imageNodes.cancelled`:e===`workflow_image_timeout`?`workflows:imageNodes.timeout`:`workflows:imageNodes.invalidOutput`)}function En({value:e,previousValue:t,error:n,t:r}){let i=(0,Y.useMemo)(()=>Cn(e),[e]),a=(0,Y.useMemo)(()=>Cn(t),[t]),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(0),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(!1),T=(0,Y.useRef)(null),E=(0,Y.useRef)(null),D=[...new Set(i?.frames.map(e=>e.action).filter(Boolean)??[])],O=[...new Set(i?.frames.map(e=>e.direction).filter(Boolean)??[])],k=D.includes(o)?o:D[0]??``,A=O.includes(c)?c:O[0]??``,j=(0,Y.useMemo)(()=>i?.frames.filter(e=>(!k||e.action===k)&&(!A||e.direction===A))??[],[i,k,A]),M=Math.min(u,Math.max(0,j.length-1)),N=a?.frames.filter(e=>e.action===j[M]?.action&&e.direction===j[M]?.direction),P=N?.[M]??N?.[0]??a?.frames[0],F=wn(v?P:j[M]),ee=wn(g&&!v?j[(M+j.length-1)%j.length]:void 0),I=wn(g&&!v?j[(M+1)%j.length]:void 0);(0,Y.useEffect)(()=>{d(0),h(!1),y(!1)},[k,A,e]),(0,Y.useEffect)(()=>()=>T.current?.abort(),[]),(0,Y.useEffect)(()=>{if(!m||j.length<2)return;let e=window.setTimeout(()=>{document.hidden||d((M+1)%j.length)},j[M]?.durationMs??125),t=()=>{document.hidden&&h(!1)};return document.addEventListener(`visibilitychange`,t),()=>{window.clearTimeout(e),document.removeEventListener(`visibilitychange`,t)}},[m,j,M]),(0,Y.useEffect)(()=>{let e=E.current?.getContext(`2d`);if(!e)return;e.clearRect(0,0,512,384);let t=[ee.image,F.image,I.image].filter(e=>!!e),n=Math.min(1,512/Math.max(1,...t.map(e=>e.naturalWidth)),384/Math.max(1,...t.map(e=>e.naturalHeight)))*.9,r=(t,r)=>{if(!t)return;e.save(),e.imageSmoothingEnabled=!1,e.globalAlpha=r;let i=t.naturalWidth*n,a=t.naturalHeight*n;e.drawImage(t,(512-i)/2,384*.95-a,i,a),e.restore()};r(ee.image,.2),r(I.image,.15),r(F.image,1)},[F.image,ee.image,I.image]);let te=async e=>{if(!i||T.current)return;let t=new AbortController;T.current=t,w(!0),x(!1);let n=``;try{let r=e===`atlas`?i.atlas?.media:j[M]?.media,a=e===`json`?new Blob([JSON.stringify(i.atlas??i,null,2)],{type:`application/json`}):r?await Sn.preview(r.id,t.signal):null;if(!a||t.signal.aborted)return;n=URL.createObjectURL(a);let o=document.createElement(`a`);o.href=n,o.download=e===`json`?`animation.frames.json`:(r?.name??`animation.png`).replace(/[\\/:*?"<>|\p{Cc}]/gu,`_`),o.click()}catch{t.signal.aborted||x(!0)}finally{n&&URL.revokeObjectURL(n),t.signal.aborted||w(!1),T.current===t&&(T.current=null)}};return!i&&!n?(0,X.jsx)(`p`,{className:`my-3 text-xs text-muted-foreground`,children:r(`workflows:imageNodes.noResult`)}):(0,X.jsxs)(`section`,{className:`my-3 space-y-3 rounded-xl border p-3`,"aria-label":r(`workflows:imageNodes.result`),children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium`,children:r(`workflows:imageNodes.result`)}),n&&(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-muted-foreground`,children:Tn(n,r)}),j.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[D.length>0&&(0,X.jsx)(f,{"aria-label":r(`workflows:imageNodes.action`),value:k,onChange:e=>s(e.target.value),children:D.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))}),O.length>0&&(0,X.jsx)(f,{"aria-label":r(`workflows:imageNodes.directions`),value:A,onChange:e=>l(e.target.value),children:O.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))})]}),(0,X.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border bg-[repeating-conic-gradient(#d4d4d8_0%_25%,#fafafa_0%_50%)] bg-size-[16px_16px] dark:bg-[repeating-conic-gradient(#27272a_0%_25%,#3f3f46_0%_50%)]`,children:[(0,X.jsx)(`canvas`,{width:512,height:384,ref:E,className:`w-full`,role:`img`,"aria-label":r(`workflows:imageNodes.frameAt`,{index:M+1})}),!F.image&&!F.error&&(0,X.jsx)(ce,{className:`absolute top-1/2 left-1/2 size-5 animate-spin`})]}),F.error&&(0,X.jsx)(`p`,{role:`alert`,className:`text-xs`,children:r(`workflows:inputs.previewFailed`)}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-1`,children:[(0,X.jsx)(K,{size:`icon-sm`,variant:`outline`,"aria-label":r(`workflows:imageNodes.previousFrame`),disabled:j.length<2,onClick:()=>{h(!1),d((M+j.length-1)%j.length)},children:(0,X.jsx)(p,{})}),(0,X.jsx)(K,{size:`icon-sm`,variant:`outline`,"aria-label":r(m?`workflows:imageNodes.pause`:`workflows:imageNodes.play`),disabled:j.length<2,onClick:()=>h(!m),children:m?(0,X.jsx)(xt,{}):(0,X.jsx)(V,{})}),(0,X.jsx)(K,{size:`icon-sm`,variant:`outline`,"aria-label":r(`workflows:imageNodes.nextFrame`),disabled:j.length<2,onClick:()=>{h(!1),d((M+1)%j.length)},children:(0,X.jsx)(L,{})}),(0,X.jsxs)(`span`,{className:`px-1 text-xs tabular-nums`,children:[M+1,` / `,j.length]})]}),(0,X.jsx)(`input`,{className:`w-full`,type:`range`,min:0,max:Math.max(0,j.length-1),value:M,"aria-label":r(`workflows:imageNodes.frameNumber`),onChange:e=>{h(!1),d(Number(e.target.value))}}),(0,X.jsxs)(`label`,{className:`flex items-center justify-between text-xs`,children:[r(`workflows:imageNodes.onionSkin`),(0,X.jsx)(S,{checked:g,onCheckedChange:_})]}),P&&(0,X.jsxs)(`label`,{className:`flex items-center justify-between text-xs`,children:[r(`workflows:imageNodes.showInput`),(0,X.jsx)(S,{checked:v,onCheckedChange:y})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsxs)(K,{size:`sm`,variant:`outline`,disabled:C,onClick:()=>void te(`frame`),children:[(0,X.jsx)(R,{}),r(`workflows:imageNodes.saveFrame`)]}),i?.atlas&&(0,X.jsxs)(K,{size:`sm`,variant:`outline`,disabled:C,onClick:()=>void te(`atlas`),children:[(0,X.jsx)(R,{}),`PNG`]}),(0,X.jsxs)(K,{size:`sm`,variant:`outline`,disabled:C,onClick:()=>void te(`json`),children:[(0,X.jsx)(R,{}),`JSON`]})]})]}),b&&(0,X.jsx)(`p`,{role:`alert`,className:`text-xs`,children:r(`workflows:imageNodes.downloadFailed`)})]})}function Dn(e){let t=Math.max(0,Math.round((Number(e)||0)/1e3));return t<60?`${t} 秒`:`${Math.floor(t/60)} 分 ${t%60} 秒`}function On({run:e,t}){return(0,X.jsxs)(Re,{role:`status`,children:[(0,X.jsx)(H,{className:`animate-spin`,size:16}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:t(`workflows:workflowsPage.workflowRunning`)}),(0,X.jsx)(`small`,{children:t(`workflows:workflowsPage.runningNodeCompletedTotalCompleted`,{node:e.currentNodeLabel||t(`workflows:workflowsPage.preparing`),completed:e.completedNodes,total:e.totalNodes})})]})]})}function kn({run:e,language:t,t:n}){return(0,X.jsx)(Le,{size:`sm`,className:`workflow-card [&_h2]:text-[16px] [&_h2]:tracking-[-.02em] [.detail-stack_>_&]:[flex:0_0_auto] [border:1px_solid_var(--stroke)] rounded-[var(--r-xs)] bg-[var(--panel)] text-[var(--text)] shadow-[0_1px_2px_var(--sh-edge),0_14px_32px_-24px_var(--shadow)] gap-0 py-0`,children:(0,X.jsxs)(Fe,{className:`p-3.5`,children:[(0,X.jsx)(Ie,{className:`workflow-section-title [.selection-list_&]:mb-[8px] [.node-library_&]:mb-[8px] text-[var(--text-soft)] text-[13px] font-[700] leading-[1.4]`,children:n(`workflows:workflowsPage.latestRun`)}),e?(0,X.jsxs)(`div`,{className:`activity-row [&_span]:flex [&_span]:min-w-0 [&_span]:flex-col [&_span]:gap-[3px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] [&_span]:text-[var(--text)] [&.failed]:text-[var(--danger)] [&.running]:text-[var(--star-strong)] grid grid-cols-[auto_minmax(0,1fr)] items-center gap-[9px] [border-top:1px_solid_var(--stroke-soft)] [padding:9px_2px] text-[var(--success)] ${e.status}`,children:[e.status===`running`||e.status===`waiting_approval`?(0,X.jsx)(H,{className:`animate-spin`,size:15}):e.status===`completed`?(0,X.jsx)(te,{size:15}):(0,X.jsx)(ye,{size:15}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:e.status===`completed`?e.summary||n(`workflows:workflowsPage.workflowCompleted`):e.status===`waiting_approval`?n(`workflows:workflowsPage.waitingApproval`):e.status===`running`?e.currentNodeLabel||n(`workflows:workflowsPage.running`):e.error?Q(e.error):n(`workflows:workflowsPage.workflowFailed`)}),(0,X.jsxs)(`small`,{children:[Pe(e.startedAt,t),` · `,Dn(e.durationMs)]})]})]}):(0,X.jsx)(`p`,{className:`muted-copy m-[8px_0_14px] text-[var(--text-muted)] text-[12px] leading-[1.55]`,children:n(`workflows:workflowsPage.noRunHistory`)})]})})}function An({input:e,value:t,onChange:n,label:r,disabled:i=!1,onBusyChange:a}){let{t:o}=s(),[c,l]=(0,Y.useState)({id:``,url:``}),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(``),m=(0,Y.useRef)(null),h=(0,Y.useRef)(!0),g=(0,Y.useRef)(a);g.current=a;let _=(0,Y.useRef)({onChange:n,id:e.id,type:e.type});_.current={onChange:n,id:e.id,type:e.type};let v=e.type,y=(()=>{try{return $e(t)}catch{return null}})(),b=y?.id;(0,Y.useEffect)(()=>(h.current=!0,d(!1),p(``),()=>{h.current=!1,m.current?.abort(),m.current=null,g.current?.(e.id,!1)}),[e.id,v]),(0,Y.useEffect)(()=>{if(l({id:``,url:``}),!b)return;let e=new AbortController,t=``;return Sn.preview(b,e.signal).then(n=>{e.signal.aborted||(t=URL.createObjectURL(n),l({id:b,url:t}))}).catch(()=>{e.signal.aborted||p(o(`workflows:inputs.previewFailed`))}),()=>{e.abort(),t&&URL.revokeObjectURL(t)}},[b,o]);let x=async(t,n)=>{if(!t.length||i||m.current||n!==`image`&&n!==`video`)return;if(t.length!==1){p(o(`workflows:inputs.oneFile`));return}let r=t[0];if(!(n===`image`?[`image/png`,`image/jpeg`,`image/webp`]:[`video/mp4`,`video/webm`]).includes(r.type)){p(o(`workflows:inputs.mediaType`));return}if(r.size>(n===`image`?8:64)*1024*1024){p(o(n===`image`?`workflows:inputs.imageLimit`:`workflows:inputs.videoLimit`));return}let a=new AbortController;m.current=a,d(!0),g.current?.(e.id,!0),p(``);try{let t=await Sn.upload(r,a.signal);h.current&&!a.signal.aborted&&m.current===a&&_.current.id===e.id&&_.current.type===n&&_.current.onChange(t)}catch{h.current&&!a.signal.aborted&&p(o(`workflows:inputs.uploadFailed`))}finally{m.current===a&&(m.current=null,h.current&&(d(!1),g.current?.(e.id,!1)))}};return(0,X.jsxs)(pn,{label:r,value:typeof t==`string`?t:``,onValueChange:n,files:y?[{...y,url:c.id===y.id?c.url:void 0}]:[],onFilesSelected:e=>void x(e,v),onRemoveFile:()=>n(``),accept:v===`image`?`image`:`video`,allowFiles:v===`image`||v===`video`,allowText:v!==`image`&&v!==`video`,disabled:i||u,maxLength:16e3,attachmentLabel:o(v===`image`?`workflows:inputs.chooseImage`:`workflows:inputs.chooseVideo`),removeLabel:o(`workflows:inputs.removeMedia`),children:[u&&(0,X.jsxs)(`p`,{role:`status`,className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,X.jsx)(ce,{className:`size-3 animate-spin`}),o(`workflows:inputs.uploading`)]}),f&&(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:f})]})}function jn(e){return e===`number`||e===`boolean`||e===`text`||e===`image`||e===`video`?e:`string`}function Mn(e){if(e.type===`image`||e.type===`video`)try{return $e(e.defaultValue)}catch{return null}return e.type===`boolean`?e.defaultValue===!0||e.defaultValue===`true`:typeof e.defaultValue==`number`||typeof e.defaultValue==`string`?e.defaultValue:``}function Nn(e,t){if(!(e instanceof Ye))return t(`workflows:inputs.invalidDefinition`);let n=e.label||e.inputName;return e.code===`workflow_input_unsafe_name`?t(`workflows:inputs.invalidName`):e.code===`workflow_input_duplicate_name`?t(`workflows:inputs.duplicateName`,{name:n}):e.code===`workflow_input_required`?t(`workflows:inputs.requiredValue`,{name:n}):e.code===`workflow_input_type`?t(`workflows:inputs.invalidValue`,{name:n}):e.code===`workflow_input_too_long`?t(`workflows:inputs.valueTooLong`,{name:n}):e.code===`workflow_input_unknown`?t(`workflows:inputs.unknownInput`,{name:n}):t(`workflows:inputs.invalidDefinition`)}function Pn(e,t){try{return tt(e),``}catch(e){return Nn(e,t)}}function Fn(e,t,n){try{return Xe(e,t),``}catch(e){return Nn(e,n)}}function In(e,t){return Xe(e,t)}function Ln(e,t){return e.type===`text`?t(`workflows:inputs.longText`):e.type===`number`?t(`workflows:inputs.number`):e.type===`boolean`?t(`workflows:inputs.boolean`):e.type===`image`?t(`workflows:inputs.image`):e.type===`video`?t(`workflows:inputs.video`):t(`workflows:inputs.shortText`)}function Rn({inputs:e,onChange:t,t:n,onUploadBusy:r}){let i=(0,Y.useId)(),[a,o]=(0,Y.useState)(null),s=Pn(e,n),p=(n,r)=>t(e.map(e=>e.id===n?{...e,...r}:e));return(0,X.jsxs)(`section`,{className:`mt-4 min-w-0 space-y-3`,"aria-labelledby":`${i}-title`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`h3`,{id:`${i}-title`,className:`text-sm font-medium`,children:n(`workflows:workflowsPage.inputParameters`)}),(0,X.jsxs)(K,{variant:`ghost`,size:`sm`,disabled:e.length>=30,onClick:()=>{let r=e.length+1;for(;e.some(e=>e.name===`input_${r}`);)r+=1;let i=crypto.randomUUID();t([...e,{id:i,name:`input_${r}`,label:n(`workflows:workflowsPage.newInput`),type:`string`,required:!1,defaultValue:``,description:``}]),o(i)},children:[(0,X.jsx)(de,{}),n(`workflows:workflowsPage.addInput`)]})]}),(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:n(`workflows:inputs.definitionHint`)}),s&&(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:s}),e.length===0&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`workflows:inputs.emptyDefinition`)}),e.map(s=>(0,X.jsxs)(u,{className:`min-w-0 rounded-lg border`,open:a===s.id,onOpenChange:e=>o(e?s.id:null),children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 p-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,X.jsx)(`p`,{className:`truncate text-sm font-medium`,children:s.label||s.name}),(0,X.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[Ln(s,n),` ·`,` `,s.required?n(`workflows:workflowsPage.required`):n(`workflows:inputs.optional`)]})]}),(0,X.jsx)(l,{asChild:!0,children:(0,X.jsxs)(K,{variant:`ghost`,size:`sm`,"aria-label":n(`workflows:inputs.editNamedInput`,{name:s.label||s.name}),children:[(0,X.jsx)(B,{}),n(`workflows:inputs.editInput`)]})})]}),(0,X.jsxs)(c,{className:`space-y-3 border-t p-3`,children:[(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(d,{htmlFor:`${i}-${s.id}-label`,className:`text-xs`,children:n(`workflows:inputs.label`)}),(0,X.jsx)(q,{id:`${i}-${s.id}-label`,value:s.label,maxLength:120,onChange:e=>p(s.id,{label:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(d,{id:`${i}-${s.id}-type`,className:`text-xs`,children:n(`workflows:workflowsPage.parameterType`)}),(0,X.jsxs)(f,{"aria-labelledby":`${i}-${s.id}-type`,value:s.type,onChange:e=>{let t=jn(e.target.value);p(s.id,{type:t,defaultValue:t!==`boolean`&&``})},children:[(0,X.jsx)(`option`,{value:`string`,children:n(`workflows:inputs.shortText`)}),(0,X.jsx)(`option`,{value:`text`,children:n(`workflows:inputs.longText`)}),(0,X.jsx)(`option`,{value:`number`,children:n(`workflows:inputs.number`)}),(0,X.jsx)(`option`,{value:`boolean`,children:n(`workflows:inputs.boolean`)}),(0,X.jsx)(`option`,{value:`image`,children:n(`workflows:inputs.image`)}),(0,X.jsx)(`option`,{value:`video`,children:n(`workflows:inputs.video`)})]})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(d,{htmlFor:`${i}-${s.id}-description`,className:`text-xs`,children:n(`workflows:inputs.description`)}),(0,X.jsx)(rt,{id:`${i}-${s.id}-description`,value:s.description,maxLength:300,rows:2,className:`min-h-14`,onChange:e=>p(s.id,{description:e.target.value})})]}),(0,X.jsxs)(`details`,{className:`group rounded-md border p-2`,children:[(0,X.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 text-xs font-medium [&::-webkit-details-marker]:hidden`,children:[n(`workflows:inputs.advancedSettings`),(0,X.jsx)(I,{className:`size-3.5 transition-transform group-open:rotate-180`})]}),(0,X.jsxs)(`div`,{className:`space-y-3 pt-3`,children:[(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(d,{htmlFor:`${i}-${s.id}-name`,className:`text-xs`,children:n(`workflows:workflowsPage.parameterName`)}),(0,X.jsx)(q,{id:`${i}-${s.id}-name`,value:s.name,maxLength:80,onChange:e=>p(s.id,{name:e.target.value})}),(0,X.jsx)(`code`,{className:`block break-all text-xs text-muted-foreground`,children:`{{inputs.`+s.name+`}}`})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[s.type!==`text`&&s.type!==`image`&&s.type!==`video`&&(0,X.jsx)(d,{htmlFor:`${i}-${s.id}-default`,className:`text-xs`,children:n(`workflows:inputs.defaultValue`)}),s.type===`boolean`?(0,X.jsx)(S,{id:`${i}-${s.id}-default`,checked:Mn(s)===!0,onCheckedChange:e=>p(s.id,{defaultValue:e})}):s.type===`text`||s.type===`image`||s.type===`video`?(0,X.jsx)(An,{input:s,value:s.defaultValue,label:n(`workflows:inputs.defaultValue`),onBusyChange:r,onChange:e=>p(s.id,{defaultValue:e})}):(0,X.jsx)(q,{id:`${i}-${s.id}-default`,type:s.type===`number`?`number`:`text`,value:String(Mn(s)),onChange:e=>p(s.id,{defaultValue:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(d,{htmlFor:`${i}-${s.id}-required`,className:`text-xs`,children:n(`workflows:workflowsPage.required`)}),(0,X.jsx)(S,{id:`${i}-${s.id}-required`,checked:s.required,onCheckedChange:e=>p(s.id,{required:e})})]})]})]}),(0,X.jsxs)(K,{variant:`ghost`,size:`sm`,"aria-label":n(`workflows:inputs.deleteInput`,{name:s.label}),onClick:()=>{t(e.filter(e=>e.id!==s.id)),o(null)},children:[(0,X.jsx)(ve,{}),n(`workflows:inputs.removeInput`)]})]})]},s.id))]})}var zn={browser:{Icon:P},feishu:{Icon:F},weixin:{Icon:le},qq:{Icon:le},telegram:{Icon:me}},Bn=[`workspace-write`,`full-access`];function Vn(e,t){return t(e===`workspace-write`?`workflows:workflowsPage.workspaceWrite`:`workflows:workflowsPage.fullAccess`)}function Hn(e,t){return t(e===`workspace-write`?`workflows:workflowsPage.workspaceWriteHelp`:`workflows:workflowsPage.fullAccessHelp`)}function Un(e,t){return t(e===`feishu`?`workflows:workflowsPage.feishu`:e===`weixin`?`workflows:workflowsPage.weChat`:e===`qq`?`workflows:workflowsPage.qq`:e===`telegram`?`workflows:workflowsPage.telegram`:`workflows:workflowsPage.browserNotification`)}function Wn({draft:e,catalog:t,t:n,onUpdateDraft:r,onInputUploadBusy:i}){return(0,X.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[(0,X.jsxs)(J,{variant:`control`,children:[n(`workflows:workflowsPage.name`),(0,X.jsx)(q,{value:e.name,onChange:e=>r({name:e.target.value})})]}),(0,X.jsxs)(J,{variant:`control`,children:[n(`workflows:workflowsPage.description`),(0,X.jsx)(rt,{value:e.description,onChange:e=>r({description:e.target.value})})]}),(0,X.jsxs)(J,{variant:`control`,children:[n(`workflows:workflowsPage.workingDirectory`),(0,X.jsx)(q,{value:e.cwd,onChange:e=>r({cwd:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,X.jsxs)(J,{variant:`control`,children:[n(`workflows:workflowsPage.visibility`),(0,X.jsxs)(f,{value:e.visibility,onChange:e=>r({visibility:e.target.value===`shared`?`shared`:`private`}),children:[(0,X.jsx)(`option`,{value:`private`,children:n(`workflows:workflowsPage.private`)}),(0,X.jsx)(`option`,{value:`shared`,children:n(`workflows:workflowsPage.shared`)})]})]}),(0,X.jsxs)(J,{variant:`control`,children:[n(`workflows:workflowsPage.tags`),(0,X.jsx)(q,{value:e.tags.join(`, `),onChange:e=>r({tags:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)})})]}),(0,X.jsxs)(J,{variant:`control`,children:[n(`workflows:workflowsPage.revision`),(0,X.jsx)(q,{value:`v${e.revision}`,disabled:!0})]})]}),(0,X.jsxs)(J,{variant:`control`,children:[n(`workflows:workflowsPage.defaultModel`),(0,X.jsxs)(f,{value:e.model?`${e.model.provider}/${e.model.model}`:``,onChange:e=>{let n=t.models.find(t=>`${t.provider}/${t.model}`===e.target.value);r({model:n?{provider:n.provider,model:n.model}:null})},children:[(0,X.jsx)(`option`,{value:``,children:n(`workflows:workflowsPage.useSystemDefault`)}),t.models.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.model}`,children:e.label},`${e.provider}/${e.model}`))]})]}),(0,X.jsx)(Rn,{inputs:e.inputs,t:n,onUploadBusy:i,onChange:e=>r({inputs:e})})]})}function Gn({node:e,catalog:t,t:n,systemNotificationPermission:r,onUpdateNode:i,onToggleNotification:a,onOpenChannels:o,onOpenSystemNotificationSettings:s}){let c=[`feishu`,`weixin`,`qq`,`telegram`].some(e=>t.notificationTargets[e]?.enabled),l=r==="default"||r===`granted`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(J,{variant:`control`,children:[n(`workflows:workflowsPage.notificationTitle`),(0,X.jsx)(q,{value:e.notification.title,onChange:t=>i({notification:{...e.notification,title:t.target.value}}),placeholder:`{{workflow.name}}`})]}),(0,X.jsxs)(J,{variant:`control`,children:[n(`workflows:workflowsPage.notificationContent`),(0,X.jsx)(rt,{value:e.notification.content,onChange:t=>i({notification:{...e.notification,content:t.target.value}}),placeholder:`{{inputs.name}} · {{previous.summary}}`})]}),(0,X.jsx)(`strong`,{className:`block [margin-top:12px] text-[var(--text-secondary)] text-[12px]`,children:n(`workflows:workflowsPage.notificationChannels`)}),!c&&(0,X.jsxs)(Ee,{className:`workflow-notification-alert [&_[data-slot='alert-description']]:flex [&_[data-slot='alert-description']]:items-center [&_[data-slot='alert-description']]:gap-[4px] [&_[data-slot='alert-description']]:text-[11px] [&_[data-slot='alert-description']]:leading-[1.4] [margin:10px_0_6px] [border-color:color-mix(in_srgb,var(--warning)_35%,var(--border))] bg-[color-mix(in_srgb,var(--warning)_7%,var(--card))] text-[var(--text-secondary)]`,children:[(0,X.jsx)(ye,{}),(0,X.jsxs)(Te,{children:[n(`workflows:workflowsPage.noExternalNotificationChannelsEnabled`),(0,X.jsx)(K,{type:`button`,variant:`link`,size:`sm`,onClick:o,children:n(`workflows:workflowsPage.openChannelSettings`)})]})]}),(r===`denied`||r===`unsupported`)&&(0,X.jsxs)(Ee,{className:`workflow-notification-alert [&_[data-slot='alert-description']]:flex [&_[data-slot='alert-description']]:items-center [&_[data-slot='alert-description']]:gap-[4px] [&_[data-slot='alert-description']]:text-[11px] [&_[data-slot='alert-description']]:leading-[1.4] [margin:10px_0_6px] [border-color:color-mix(in_srgb,var(--warning)_35%,var(--border))] bg-[color-mix(in_srgb,var(--warning)_7%,var(--card))] text-[var(--text-secondary)]`,children:[(0,X.jsx)(ye,{}),(0,X.jsxs)(Te,{children:[n(r===`unsupported`?`workflows:workflowsPage.systemNotificationsUnsupported`:`workflows:workflowsPage.systemNotificationPermissionRequired`),(0,X.jsx)(K,{type:`button`,variant:`link`,size:`sm`,onClick:s,children:n(`workflows:workflowsPage.openSystemNotificationSettings`)})]})]}),Object.entries(zn).map(([i,o])=>{let s=o.Icon,c=i===`browser`?l:!!t.notificationTargets[i]?.enabled;return(0,X.jsxs)(`div`,{className:`toggle-line [&_>_span]:flex [&_>_span]:items-center [&_>_span]:gap-[7px] [&_>_span]:text-[12px] flex min-h-[34px] items-center justify-between [border-top:1px_solid_var(--stroke-soft)]`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(s,{size:15}),Un(i,n)]}),(0,X.jsx)(S,{checked:c&&(i!==`browser`||r===`granted`&&t.notificationTargets.browser.enabled)&&e.notificationTargets.includes(i),disabled:!c,"aria-label":Un(i,n),title:i===`browser`?c?t.notificationTargets.browser.enabled?n(`workflows:workflowsPage.systemNotificationsEnabled`):n(`workflows:workflowsPage.systemNotificationReady`):n(`workflows:workflowsPage.systemNotificationPermissionRequired`):n(c?`workflows:workflowsPage.notificationChannelEnabled`:`workflows:workflowsPage.notificationChannelNotEnabled`),onCheckedChange:()=>void a(i)})]},i)})]})}function Kn({edge:e,nodes:t,t:n,onDelete:r}){let i=new Map(t.map(e=>[e.id,e]));return(0,X.jsxs)(`section`,{className:`min-w-0 space-y-3`,children:[(0,X.jsxs)(`div`,{className:`workflow-edge-summary [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_span]:text-[var(--text-muted)] grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-[8px] [margin:10px_0]`,children:[(0,X.jsx)(`strong`,{children:i.get(e.source)?.label||n(`workflows:workflowsPage.unknownNode`)}),(0,X.jsx)(`span`,{children:`→`}),(0,X.jsx)(`strong`,{children:i.get(e.target)?.label||n(`workflows:workflowsPage.unknownNode`)})]}),(0,X.jsx)(`p`,{className:`muted-copy m-[8px_0_14px] text-[var(--text-muted)] text-[12px] leading-[1.55]`,children:n(`workflows:workflowsPage.pressDeleteOrBackspaceToRemoveThisConnection`)}),(0,X.jsxs)(K,{size:`sm`,variant:`destructive`,onClick:r,children:[(0,X.jsx)(ve,{"data-icon":`inline-start`}),n(`workflows:workflowsPage.deleteConnection`)]})]})}function qn({node:e,inputs:t,selectedEdge:n,catalog:r,t:i,onUpdateNode:a,systemNotificationPermission:o,onToggleNotification:s,onCopy:c,onDelete:l,onOpenChannels:u,onOpenSystemNotificationSettings:d}){let p=(0,Y.useRef)(null);return(0,X.jsx)(`section`,{className:`min-w-0 space-y-3`,children:e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(J,{variant:`control`,children:[i(`workflows:workflowsPage.nodeName`),(0,X.jsx)(q,{value:e.label,onChange:e=>a({label:e.target.value})})]}),[`prompt`,`skill`,`file`,`mcp`].includes(e.kind)&&(0,X.jsxs)(J,{variant:`control`,children:[i(`workflows:workflowsPage.nodeModel`),(0,X.jsxs)(f,{value:e.model?`${e.model.provider}/${e.model.model}`:``,onChange:e=>{let t=r.models.find(t=>`${t.provider}/${t.model}`===e.target.value);a({model:t?{provider:t.provider,model:t.model}:null})},children:[(0,X.jsx)(`option`,{value:``,children:i(`workflows:workflowsPage.inheritWorkflowDefaultModel`)}),r.models.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.model}`,children:e.label},`${e.provider}/${e.model}`))]})]}),e.kind===`trigger`&&(0,X.jsx)(`p`,{className:`rounded-lg bg-[var(--surface-subtle)] p-3 text-xs leading-relaxed text-muted-foreground`,children:i(`workflows:editor.manualTriggerHint`)}),e.kind===`parallel`&&(0,X.jsx)(`p`,{className:`rounded-lg bg-[var(--surface-subtle)] p-3 text-xs leading-relaxed text-muted-foreground`,children:i(`workflows:editor.parallelHint`)}),![`trigger`,`parallel`,`condition`,`approval`].includes(e.kind)&&(0,X.jsxs)(`details`,{className:`rounded-lg border p-3`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium`,children:i(`workflows:editor.executionSettings`)}),(0,X.jsxs)(`div`,{className:`grid gap-3 pt-3`,children:[(0,X.jsxs)(J,{variant:`control`,children:[i(`workflows:workflowsPage.retryCount`),(0,X.jsx)(q,{type:`number`,min:`0`,max:`3`,value:e.retries,onChange:e=>a({retries:Number(e.target.value)})})]}),(0,X.jsxs)(J,{variant:`control`,children:[i(`workflows:workflowsPage.timeoutMinutes`),(0,X.jsx)(q,{type:`number`,min:`1`,max:`240`,value:e.timeoutMinutes,onChange:e=>a({timeoutMinutes:Number(e.target.value)})})]}),(0,X.jsxs)(J,{variant:`control`,children:[i(`workflows:workflowsPage.failureHandling`),(0,X.jsxs)(f,{value:e.failurePolicy,onChange:e=>a({failurePolicy:e.target.value===`skip`?`skip`:`stop`}),children:[(0,X.jsx)(`option`,{value:`stop`,children:i(`workflows:workflowsPage.stopImmediately`)}),(0,X.jsx)(`option`,{value:`skip`,children:i(`workflows:workflowsPage.skipThisNode`)})]})]})]})]}),Ct(e.kind)&&(0,X.jsx)(xn,{node:e,inputs:t,t:i,onChange:a}),[`prompt`,`skill`,`file`,`mcp`].includes(e.kind)&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(J,{variant:`control`,children:[i(`workflows:workflowsPage.executionMode`),(0,X.jsx)(f,{value:e.executionMode,onChange:e=>a({executionMode:e.target.value}),children:Bn.map(e=>(0,X.jsx)(`option`,{value:e,children:Vn(e,i)},e))}),(0,X.jsx)(`small`,{children:Hn(e.executionMode,i)})]}),e.kind===`skill`&&(0,X.jsxs)(J,{variant:`control`,children:[`Skill`,(0,X.jsxs)(f,{value:e.skillName,onChange:e=>a({skillName:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:i(`workflows:workflowsPage.chooseSkill`)}),r.skills.map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.name},e.id))]})]}),e.kind===`mcp`&&(0,X.jsxs)(J,{variant:`control`,children:[i(`workflows:workflowsPage.mcpToolNames`),(0,X.jsx)(q,{value:e.requestedToolNames.join(`, `),onChange:e=>a({requestedToolNames:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)}),placeholder:`server.tool_name`})]}),(0,X.jsxs)(J,{variant:`control`,children:[i(`workflows:inputs.nodeRules`),(0,X.jsx)(rt,{ref:p,value:e.prompt,onChange:e=>a({prompt:e.target.value}),placeholder:i(`workflows:workflowsPage.describeTheWorkTheAgentShouldCompleteInThisNode`)})]}),(0,X.jsxs)(`div`,{className:`space-y-2 py-2`,children:[(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:i(`workflows:inputs.nodeRulesHint`)}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(t=>(0,X.jsx)(K,{type:`button`,variant:`outline`,size:`xs`,title:i(`workflows:inputs.insertVariable`,{name:t.label}),onClick:()=>{let n=p.current,r=n?.selectionStart??e.prompt.length,i=n?.selectionEnd??r,o=`{{inputs.`+t.name+`}}`;a({prompt:e.prompt.slice(0,r)+o+e.prompt.slice(i)}),requestAnimationFrame(()=>{n?.focus(),n?.setSelectionRange(r+o.length,r+o.length)})},children:(0,X.jsx)(`code`,{children:`{{inputs.`+t.name+`}}`})},t.id))})]}),(0,X.jsxs)(J,{variant:`control`,children:[i(`workflows:workflowsPage.outputFormat`),(0,X.jsxs)(f,{value:e.outputFormat,onChange:e=>a({outputFormat:e.target.value===`json`?`json`:`text`}),children:[(0,X.jsx)(`option`,{value:`text`,children:`Text`}),(0,X.jsx)(`option`,{value:`json`,children:`JSON`})]})]})]}),e.kind===`condition`&&(0,X.jsxs)(`div`,{className:`grid gap-3`,children:[(0,X.jsxs)(J,{variant:`control`,children:[i(`workflows:workflowsPage.dataPath`),(0,X.jsx)(q,{value:e.condition.source,onChange:t=>a({condition:{...e.condition,source:t.target.value}}),placeholder:`inputs.approved`})]}),(0,X.jsxs)(J,{variant:`control`,children:[i(`workflows:workflowsPage.operator`),(0,X.jsx)(f,{value:e.condition.operator,onChange:t=>a({condition:{...e.condition,operator:t.target.value}}),children:[`exists`,`not_exists`,`equals`,`not_equals`,`contains`,`greater_than`,`less_than`].map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))})]}),(0,X.jsxs)(J,{variant:`control`,children:[i(`workflows:workflowsPage.comparisonValue`),(0,X.jsx)(q,{value:String(e.condition.value??``),onChange:t=>a({condition:{...e.condition,value:t.target.value}})})]})]}),e.kind===`notification`&&(0,X.jsx)(Gn,{node:e,catalog:r,t:i,systemNotificationPermission:o,onUpdateNode:a,onToggleNotification:s,onOpenChannels:u,onOpenSystemNotificationSettings:d}),e.kind===`approval`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(J,{variant:`control`,children:[i(`workflows:workflowsPage.approvalMessage`),(0,X.jsx)(rt,{value:e.approval.message,onChange:t=>a({approval:{...e.approval,message:t.target.value}})})]}),(0,X.jsxs)(J,{variant:`control`,children:[i(`workflows:workflowsPage.approvalTimeout`),(0,X.jsx)(q,{type:`number`,min:`1`,max:`10080`,value:e.approval.timeoutMinutes,onChange:t=>a({approval:{...e.approval,timeoutMinutes:Number(t.target.value)}})})]})]}),(0,X.jsxs)(`div`,{className:`mt-[15px] flex gap-2 max-[650px]:flex-wrap`,children:[(0,X.jsxs)(K,{size:`sm`,variant:`secondary`,onClick:c,children:[(0,X.jsx)(ie,{"data-icon":`inline-start`}),i(`workflows:workflowsPage.duplicateNode`)]}),(0,X.jsxs)(K,{size:`sm`,variant:`destructive`,onClick:l,children:[(0,X.jsx)(ve,{"data-icon":`inline-start`}),i(`workflows:workflowsPage.deleteNode`)]})]})]}):(0,X.jsx)(`p`,{className:`muted-copy m-[8px_0_14px] text-[var(--text-muted)] text-[12px] leading-[1.55]`,children:i(n?`workflows:workflowsPage.aConnectionIsCurrentlySelected`:`workflows:workflowsPage.dragNodesFromTheLeftToStartBuildingTheWorkflow`)})})}function Jn({draft:e,catalog:t,selectedNode:n,selectedEdge:r,currentRun:i,language:a,t:o,onUpdateNode:s,systemNotificationPermission:c,onToggleNotification:l,onDeleteEdge:u,onCopyNode:d,onDeleteNode:f,onOpenChannels:p,onOpenSystemNotificationSettings:m,onRunImageNode:h,imageRunBusy:g=!1}){let _=e.edges.filter(e=>e.target===n?.id).map(e=>e.source),v=(i?[i]:[]).find(t=>t.workflowId===e.id&&(n?.kind===`media-input`?!!t.inputs:_.length>0&&_.every(e=>t.nodes?.some(t=>t.id===e&&t.status===`completed`&&t.output)))),y=i;return(0,X.jsxs)(`div`,{className:`detail-stack min-w-0 space-y-5`,children:[r&&(0,X.jsx)(Kn,{edge:r,nodes:e.nodes,t:o,onDelete:u}),!r&&(0,X.jsx)(qn,{node:n,inputs:e.inputs,selectedEdge:r,catalog:t,t:o,onUpdateNode:s,systemNotificationPermission:c,onToggleNotification:l,onCopy:d,onDelete:f,onOpenChannels:p,onOpenSystemNotificationSettings:m}),n&&Ct(n.kind)&&h&&(0,X.jsxs)(`div`,{className:`space-y-2 rounded-lg border p-3`,children:[(0,X.jsxs)(K,{className:`w-full`,variant:`outline`,disabled:!e.id||!v||g,onClick:()=>{v&&h(n.id,v.id)},children:[(0,X.jsx)(V,{}),o(`workflows:imageNodes.runNode`)]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`workflows:imageNodes.runNodeHint`)})]}),n&&Ct(n.kind)&&(0,X.jsx)(En,{value:y?.nodes?.find(e=>e.id===n.id)?.output,previousValue:v?.nodes?.find(t=>t.id===e.edges.find(e=>e.target===n.id)?.source)?.output,error:y?.nodes?.find(e=>e.id===n.id)?.error,t:o},n.id),e.id&&i&&(0,X.jsxs)(`details`,{className:`rounded-lg border p-3`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:o(`workflows:workflowsPage.latestRun`)}),(0,X.jsx)(`div`,{className:`mt-3`,children:(0,X.jsx)(kn,{run:i,language:a,t:o})})]})]})}function Yn({workflowId:e,templateId:t,notify:n,onCreated:r}){let{t:i}=s(),[a,o]=(0,Y.useState)(rn),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(!0),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(``),b=(0,Y.useRef)(null),x=(0,Y.useRef)(new Set),[S,C]=(0,Y.useState)(!1),w=(0,Y.useRef)(null),T=(0,Y.useRef)(!0);(0,Y.useEffect)(()=>{let e=x.current;return T.current=!0,_(!1),C(!1),()=>{T.current=!1,w.current?.abort(),w.current=null,e.clear()}},[e,t]);let E=(0,Y.useCallback)((e,t)=>{t?x.current.add(e):x.current.delete(e),T.current&&C(x.current.size>0)},[]),D=!!window.pisperDesktop?.showNotification,[O,k]=(0,Y.useState)(()=>D?`checking`:Je()),A=(0,Y.useCallback)(async()=>{if(!D){k(Je());return}let e=window.pisperDesktop?.getNotificationStatus;if(!e){k(`granted`);return}try{let t=await e(),n=t?.permission;k(n==="default"||n===`denied`||n===`granted`||n===`checking`||n===`unsupported`?n:t?.supported===!1?`unsupported`:`granted`)}catch{k(`unsupported`)}},[D]),j=(0,Y.useCallback)(async n=>{try{let r=await G(`/api/workflows`,{signal:n});if(n.aborted)return;o(r);let a=e===`new`?null:r.workflows.find(t=>t.id===e),s=Gt.find(e=>e.id===t),c=a?structuredClone(a):s?Xt(s,r.cwd,i):Jt(r.cwd,i);l(c),d(e=>c.nodes.some(t=>t.id===e)?e:c.nodes[0]?.id||``),p(``),y(a||e===`new`?``:i(`workflows:workflowsPage.workflowNotFoundABlankEditorWasOpened`))}catch(e){n.aborted||y(Q(e))}finally{n.aborted||h(!1)}},[i,t,e]),M=(0,Y.useCallback)(()=>{b.current?.abort();let e=new AbortController;b.current=e,h(!0),y(``),j(e.signal)},[j]);(0,Y.useEffect)(()=>(M(),()=>b.current?.abort()),[M]),(0,Y.useEffect)(()=>{A();let e=()=>void A();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[A]);let N=(0,Y.useMemo)(()=>a.runs.filter(e=>e.workflowId===c?.id).sort((e,t)=>Date.parse(t.startedAt)-Date.parse(e.startedAt))[0],[a.runs,c?.id]),P=N?.status===`running`||N?.status===`waiting_approval`;(0,Y.useEffect)(()=>{if(!P)return;let e=new AbortController,t=!1,n=window.setInterval(async()=>{if(!t){t=!0;try{let t=await G(`/api/workflows`,{signal:e.signal});e.signal.aborted||o(t)}catch{}finally{t=!1}}},1500);return()=>{e.abort(),window.clearInterval(n)}},[P,e]);let F=(0,Y.useMemo)(()=>c?.nodes.find(e=>e.id===u)||null,[c?.nodes,u]),ee=(0,Y.useMemo)(()=>c?.edges.find(e=>e.id===f)||null,[c?.edges,f]),I=(0,Y.useCallback)(e=>{l(t=>t&&{...t,...e})},[]),L=(0,Y.useCallback)(e=>{l(t=>t&&{...t,nodes:t.nodes.map(t=>t.id===u?{...t,...e}:t)})},[u]),te=(0,Y.useCallback)(e=>{d(e),p(``)},[]),ne=(0,Y.useCallback)(e=>{p(e),d(``)},[]),re=(0,Y.useCallback)(()=>{d(``),p(``)},[]),ie=(0,Y.useCallback)((e,t,r=`output`)=>{if(!c||e===t)return;let a=c.nodes.find(e=>e.id===t);if(!a||a.kind===`trigger`){n(i(`workflows:workflowsPage.aTriggerCannotHaveAnUpstreamConnection`),`error`);return}if(c.edges.some(n=>n.source===e&&n.target===t&&n.sourcePort===r)){n(i(`workflows:workflowsPage.thisConnectionAlreadyExists`),`info`);return}if(Ft(c.nodes,c.edges,e,t,r)){n(i(`workflows:workflowsPage.aWorkflowCannotContainCyclicConnections`),`error`);return}let o={id:crypto.randomUUID(),source:e,sourcePort:r,target:t,targetPort:`input`};l(e=>e&&{...e,edges:[...e.edges,o]}),p(o.id),d(``),n(i(`workflows:workflowsPage.connectionCreated`),`info`)},[c,n,i]),R=(0,Y.useCallback)(e=>{if(!e.length)return;let t=new Set(e);l(e=>e&&{...e,edges:e.edges.filter(e=>!t.has(e.id))}),p(``),n(i(`workflows:workflowsPage.connectionDeleted`),`info`)},[n,i]),ae=(0,Y.useCallback)(()=>{f&&R([f])},[R,f]),oe=(0,Y.useCallback)(e=>{if(!e.length)return;let t=new Set(e);l(e=>e&&{...e,nodes:e.nodes.filter(e=>!t.has(e.id)),edges:e.edges.filter(e=>!t.has(e.source)&&!t.has(e.target))}),re(),n(i(`workflows:workflowsPage.nodeDeleted`),`info`)},[re,n,i]),se=(0,Y.useCallback)((e,t,n)=>{let r=crypto.randomUUID();l(i=>i&&{...i,nodes:[...i.nodes,Z(r,e,t||It[e],``,n.x,n.y)]}),d(r),p(``)},[]),z=(0,Y.useCallback)((e,t)=>{l(n=>n&&{...n,nodes:n.nodes.map(n=>n.id===e&&(n.x!==t.x||n.y!==t.y)?{...n,x:t.x,y:t.y}:n)})},[]),ce=(0,Y.useCallback)(()=>{if(!F)return;let e=crypto.randomUUID();l(t=>t&&{...t,nodes:[...t.nodes,{...F,id:e,label:`${F.label} 副本`,x:F.x+25,y:F.y+25}]}),d(e),p(``),n(i(`workflows:workflowsPage.nodeDuplicated`),`info`)},[n,F,i]),le=(0,Y.useCallback)(()=>{F&&oe([F.id])},[oe,F]),ue=(0,Y.useCallback)(async e=>{if(!F||F.kind!==`notification`)return;let t=F.notificationTargets;if(e!==`browser`){if(t.includes(e)){L({notificationTargets:t.filter(t=>t!==e)});return}if(!a.notificationTargets[e]?.enabled)return;L({notificationTargets:[...t,e]});return}if(t.includes(e)&&a.notificationTargets.browser.enabled&&O===`granted`){L({notificationTargets:t.filter(t=>t!==e)});return}let r=O;if(D){await A();let e=await window.pisperDesktop?.getNotificationStatus?.();r=e?.permission||(e?.supported===!1?`unsupported`:`granted`)}else if(r=await qe(),k(r),r===`granted`)try{await Ke()}catch(e){n(Q(e),`error`);return}if(r!==`granted`){n(i(r===`unsupported`?`workflows:workflowsPage.systemNotificationsUnsupported`:`workflows:workflowsPage.systemNotificationPermissionRequired`),`error`);return}try{let r=await G(`/api/settings/notifications/browser`,{method:`PATCH`,body:JSON.stringify({enabled:!0})});o(e=>({...e,notificationTargets:{...e.notificationTargets,browser:{enabled:r.browser.enabled}}})),L({notificationTargets:t.includes(e)?t:[...t,e]}),n(i(`workflows:workflowsPage.systemNotificationsEnabled`))}catch(e){n(Q(e),`error`)}},[a.notificationTargets,D,n,A,F,O,i,L]),B=(0,Y.useCallback)(async(t=`draft`,s=!1)=>{if(!c||!T.current||w.current)return null;if(x.current.size)return n(i(`workflows:inputs.uploading`),`info`),null;let u=Pn(c.inputs,i);if(u)return y(u),n(u,`error`),null;_(!0),y(``);let d=new AbortController;w.current=d;try{let u=new Set(Object.entries(a.notificationTargets).filter(([e,t])=>t.enabled&&(e!==`browser`||O===`granted`||O===`checking`)).map(([e])=>e)),f={...c,status:t,notifications:c.notifications.filter(e=>u.has(e)),nodes:c.nodes.map(e=>({...e,notificationTargets:e.notificationTargets.filter(e=>u.has(e))}))},p=c.id?await G(`/api/workflows/${encodeURIComponent(c.id)}`,{method:`PATCH`,body:JSON.stringify(f),signal:d.signal}):await G(`/api/workflows`,{method:`POST`,body:JSON.stringify(f),signal:d.signal});return d.signal.throwIfAborted(),o(p.state),l(e=>e===c?structuredClone(p.workflow):e&&{...e,id:p.workflow.id,revision:p.workflow.revision}),e===`new`&&!s&&r(p.workflow.id,!1),s||n(i(t===`published`?`workflows:workflowsPage.workflowPublished`:`workflows:workflowsPage.workflowDraftSaved`)),p.workflow}catch(e){if(d.signal.aborted)return null;let t=Q(e);return y(t),n(t,`error`),null}finally{w.current===d&&(w.current=null,T.current&&_(!1))}},[a.notificationTargets,c,n,r,O,i,e]),V=(0,Y.useCallback)(async(t,a)=>{let s=await B(c?.status||`draft`,!0);if(!s||!T.current)return!1;if(x.current.size)return n(i(`workflows:inputs.uploading`),`info`),!1;let l=new AbortController;w.current=l,_(!0);try{a?await gn.runNode(s.id,a.nodeId,a.sourceRunId,l.signal):await G(`/api/workflows/${encodeURIComponent(s.id)}/run`,{method:`POST`,body:JSON.stringify({inputs:t}),signal:l.signal}),l.signal.throwIfAborted();let e=await G(`/api/workflows`,{signal:l.signal});return l.signal.throwIfAborted(),o(e),n(i(`workflows:workflowsPage.workflowStarted`)),!0}catch(e){if(l.signal.aborted)return!1;let t=Q(e);return y(t),n(t,`error`),!1}finally{w.current===l&&(w.current=null,T.current&&_(!1)),T.current&&!l.signal.aborted&&e===`new`&&r(s.id,!0)}},[c?.status,n,r,B,i,e]),de=(0,Y.useCallback)(e=>V(e),[V]),H=(0,Y.useCallback)((e,t)=>V(void 0,{nodeId:e,sourceRunId:t}),[V]),fe=(0,Y.useCallback)(async()=>{if(!T.current||w.current||!N||![`running`,`waiting_approval`].includes(N.status))return;let e=new AbortController;w.current=e,_(!0);try{await G(`/api/workflow-runs/${encodeURIComponent(N.id)}/stop`,{method:`POST`,body:`{}`,signal:e.signal}),e.signal.throwIfAborted();let t=await G(`/api/workflows`,{signal:e.signal});e.signal.throwIfAborted(),o(t),n(i(`workflows:workflowsPage.stoppingWorkflow`),`info`)}catch(t){if(e.signal.aborted)return;let r=Q(t);y(r),n(r,`error`)}finally{w.current===e&&(w.current=null,T.current&&_(!1))}},[N,n,i]),pe=(0,Y.useCallback)(()=>B(`published`),[B]);return{catalog:a,draft:c,selectedNode:F,selectedEdge:ee,selectedNodeId:u,selectedEdgeId:f,currentRun:N,loading:m,retryLoad:M,busy:g||S,inputUploadsPending:S,onInputUploadBusy:E,running:P,error:v,systemNotificationPermission:O,updateDraft:I,updateNode:L,addEdge:ie,removeEdges:R,removeSelectedEdge:ae,removeNodes:oe,addNode:se,moveNode:z,copyNode:ce,deleteNode:le,toggleNotification:ue,selectNode:te,selectEdge:ne,clearSelection:re,saveWorkflow:B,runWorkflow:de,runImageNode:H,stopWorkflow:fe,publishWorkflow:pe}}function Xn({workflow:e,onClose:t,onRun:n}){let{t:r}=s(),i=(0,Y.useId)(),a={id:`task`,name:`task`,label:r(`workflows:inputs.task`),description:r(`workflows:inputs.contextHint`),type:`text`,required:!1,defaultValue:``},o=e.inputs.length?e.inputs:[a],[c,l]=(0,Y.useState)(()=>Object.fromEntries(o.map(e=>[e.name,Mn(e)]))),[u,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(``),[h,g]=(0,Y.useState)([]),_=(0,Y.useRef)(new Set),v=(0,Y.useRef)(c);v.current=c;let y=(0,Y.useRef)(!0);(0,Y.useEffect)(()=>(y.current=!0,()=>{y.current=!1}),[]);let b=(e,t)=>{let n={...v.current,[e]:t};v.current=n,l(n)},x=(0,Y.useCallback)((e,t)=>{t?_.current.add(e):_.current.delete(e),y.current&&g([..._.current])},[]),C=(0,Y.useRef)(!1),w=async()=>{if(C.current||_.current.size)return;let e=v.current,i=Fn(o,e,r);if(i){m(i);return}C.current=!0,f(!0),m(``);try{let i=await n(In(o,e));if(!y.current)return;i?t():m(r(`workflows:inputs.startFailed`))}catch{y.current&&m(r(`workflows:inputs.startFailed`))}finally{C.current=!1,y.current&&f(!1)}};return(0,X.jsx)(Ne,{open:!0,onOpenChange:e=>{!e&&!C.current&&t()},children:(0,X.jsxs)(je,{className:`max-h-[85vh] overflow-y-auto supports-[height:100dvh]:max-h-[85dvh] sm:max-w-xl`,showCloseButton:!u,children:[(0,X.jsxs)(Ae,{children:[(0,X.jsx)(Me,{children:r(`workflows:inputs.runTitle`,{name:e.name})}),(0,X.jsx)(ke,{children:r(`workflows:inputs.runHint`)})]}),(0,X.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),w()},children:[qt(e)>0&&(0,X.jsx)(`p`,{className:`rounded-lg bg-muted p-3 text-sm`,children:r(`workflows:imageNodes.requestEstimate`,{count:qt(e)})}),o.map(e=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[e.type!==`text`&&e.type!==`image`&&e.type!==`video`&&(0,X.jsxs)(d,{htmlFor:`${i}-${e.id}`,className:`flex items-center gap-1`,children:[e.label,e.required&&(0,X.jsx)(`span`,{className:`text-destructive`,"aria-hidden":`true`,children:`*`})]}),e.type===`boolean`?(0,X.jsx)(S,{id:`${i}-${e.id}`,checked:c[e.name]===!0,disabled:u,onCheckedChange:t=>b(e.name,t)}):e.type===`text`||e.type===`image`||e.type===`video`?(0,X.jsx)(An,{input:e,value:c[e.name],disabled:u,label:`${e.label}${e.required?` *`:``}`,onBusyChange:x,onChange:t=>b(e.name,t)}):(0,X.jsx)(q,{id:`${i}-${e.id}`,type:e.type===`number`?`number`:`text`,step:e.type===`number`?`any`:void 0,value:String(c[e.name]??``),required:e.required,disabled:u,"aria-describedby":e.description?`${i}-${e.id}-description`:void 0,onChange:t=>b(e.name,t.target.value)}),e.description&&(0,X.jsx)(`p`,{id:`${i}-${e.id}-description`,className:`text-xs leading-relaxed text-muted-foreground`,children:e.description})]},e.id)),p&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:p}),(0,X.jsxs)(De,{children:[(0,X.jsx)(K,{type:`button`,variant:`outline`,disabled:u,onClick:()=>{C.current||t()},children:r(`workflows:sprite.cancel`)}),(0,X.jsxs)(K,{type:`submit`,disabled:u||h.length>0,children:[u?(0,X.jsx)(ce,{className:`animate-spin`}):(0,X.jsx)(V,{}),r(`workflows:workflowsPage.run`)]})]})]})]})})}function Zn({message:e}){return e?(0,X.jsxs)(Ee,{variant:`destructive`,children:[(0,X.jsx)(ye,{}),(0,X.jsx)(Te,{children:e})]}):null}function Qn({label:e}){return(0,X.jsxs)(ze,{size:`sm`,className:`workflow-card [&_h2]:text-[16px] [&_h2]:tracking-[-.02em] [.detail-stack_>_&]:[flex:0_0_auto] [border:1px_solid_var(--stroke)] rounded-[var(--r-xs)] bg-[var(--panel)] text-[var(--text)] shadow-[0_1px_2px_var(--sh-edge),0_14px_32px_-24px_var(--shadow)] gap-2 py-4`,children:[(0,X.jsx)(H,{className:`animate-spin`,size:23}),(0,X.jsx)(`h2`,{children:e})]})}function $n({notify:e,requestConfirm:r,query:i=``}){let{t:a,language:o}=s(),c=t(),[l,u]=n(),d=l.get(`view`),f=d===`runs`||d===`templates`?d:`workflows`,p=()=>c(`${_t(`new`)}?template=sprite`),m=e=>u(t=>{let n=new URLSearchParams(t);return e===`workflows`?n.delete(`view`):n.set(`view`,e),n}),h=an({notify:e,requestConfirm:r,query:i}),[g,_]=(0,Y.useState)(null);return h.loading?(0,X.jsx)(Qn,{label:a(`workflows:workflowsPage.loadingWorkflows`)}):(0,X.jsxs)(`div`,{className:`workflows-page flex min-h-[100%] flex-col gap-[12px]`,children:[g&&(0,X.jsx)(Xn,{workflow:g,onClose:()=>_(null),onRun:e=>h.runWorkflow(g,e)}),(0,X.jsx)(Zn,{message:h.error}),(0,X.jsxs)(`div`,{className:`workflow-page-toolbar max-[650px]:items-stretch max-[650px]:flex-col max-[650px]:gap-[8px] flex min-w-0 items-center justify-between gap-[16px]`,children:[(0,X.jsx)(cn,{value:f,t:a,onChange:m}),(0,X.jsx)(fn,{data:h.data,t:a})]}),f===`workflows`&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 rounded-2xl border bg-card p-5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`grid size-11 shrink-0 place-items-center rounded-xl bg-[var(--brand-blue-soft)] text-[var(--star-strong)]`,children:(0,X.jsx)(yt,{className:`size-5`})}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-medium`,children:a(`workflows:sprite.title`)}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a(`workflows:sprite.description`)})]})]}),(0,X.jsxs)(K,{variant:`outline`,onClick:p,children:[a(`workflows:sprite.openStudio`),(0,X.jsx)(k,{className:`size-4`})]})]}),f===`workflows`?(0,X.jsx)(ln,{workflows:h.visibleWorkflows,runs:h.data.runs,busyId:h.busyId,language:o,t:a,onRun:_,onEdit:e=>c(_t(e)),onDuplicate:e=>void h.duplicateWorkflow(e),onExport:e=>void h.exportWorkflow(e),onImport:e=>void h.importWorkflow(e),onDelete:e=>void h.removeWorkflow(e)}):f===`runs`?(0,X.jsx)(un,{runs:h.data.runs,busyId:h.busyId,language:o,t:a,onStop:e=>void h.stopRun(e),onRetry:e=>void h.retryRun(e),onApproval:(e,t,n)=>void h.resolveApproval(e,t,n)}):(0,X.jsx)(dn,{t:a,onOpenTemplate:e=>c(`${_t(`new`)}?template=${encodeURIComponent(e)}`)})]})}function er({notify:e,registerPrimaryAction:i,registerWorkflowActions:a}){let{t:o,language:c}=s(),l=t(),{workflowId:u=`new`}=r(),[d]=n(),f=(0,Y.useCallback)(e=>{l(_t(e),{replace:!0})},[l]),p=Yn({workflowId:u,templateId:d.get(`template`),notify:e,onCreated:f}),{busy:m,publishWorkflow:h,runWorkflow:g,running:_,saveWorkflow:v,stopWorkflow:y}=p,[b,x]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(!1),D=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let e=D.current;if(!e)return;let t=()=>T(e.clientWidth>=1e3);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[p.loading]);let k=(0,Y.useCallback)(()=>{!m&&!_&&x(!0)},[m,_]);if(Ge(i,h),(0,Y.useEffect)(()=>a?.({save:()=>v(`draft`),run:_?y:k,busy:m||p.loading||!p.draft,running:_}),[m,p.draft,p.loading,a,k,_,v,y]),p.loading)return(0,X.jsx)(Qn,{label:o(`workflows:workflowsPage.loadingWorkflowEditor`)});if(!p.draft)return(0,X.jsxs)(ze,{size:`sm`,className:`gap-4 rounded-xl border bg-card p-6`,children:[(0,X.jsx)(ye,{className:`size-6 text-destructive`,"aria-hidden":`true`}),(0,X.jsx)(`h2`,{children:o(`workflows:workflowsPage.workflowEditorLoadFailed`)}),(0,X.jsx)(Zn,{message:p.error}),(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[(0,X.jsxs)(K,{onClick:p.retryLoad,children:[(0,X.jsx)(H,{className:`size-4`}),o(`workflows:workflowsPage.retryLoading`)]}),(0,X.jsx)(K,{variant:`outline`,onClick:()=>l(gt.workflows),children:o(`workflows:workflowsPage.backToWorkflows`)})]})]});let A=(0,X.jsx)(Jn,{draft:p.draft,catalog:p.catalog,selectedNode:p.selectedNode,selectedEdge:p.selectedEdge,currentRun:p.currentRun,onRunImageNode:(e,t)=>{p.runImageNode(e,t)},imageRunBusy:p.busy||p.running,language:c,t:o,systemNotificationPermission:p.systemNotificationPermission,onUpdateNode:p.updateNode,onToggleNotification:p.toggleNotification,onDeleteEdge:p.removeSelectedEdge,onCopyNode:p.copyNode,onDeleteNode:p.deleteNode,onOpenChannels:()=>l(gt.channels),onOpenSystemNotificationSettings:()=>{if(window.pisperDesktop?.openNotificationSettings){window.pisperDesktop.openNotificationSettings();return}l(`/config/notifications`)}}),j=p.selectedEdge?o(`workflows:workflowsPage.selectedConnection`):o(`workflows:editor.nodeProperties`);return(0,X.jsxs)(`div`,{ref:D,className:`workflow-editor-page @container/workflow flex min-w-0 flex-col gap-3`,children:[b&&(0,X.jsx)(Xn,{workflow:p.draft,onClose:()=>x(!1),onRun:g}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 rounded-xl border bg-card p-2`,children:[(0,X.jsx)(`nav`,{"aria-label":o(`workflows:workflowsPage.editorNavigation`),children:(0,X.jsxs)(K,{variant:`ghost`,size:`sm`,onClick:()=>l(gt.workflows),children:[(0,X.jsx)(O,{}),o(`workflows:workflowsPage.backToWorkflows`)]})}),(0,X.jsx)(`div`,{className:`hidden h-5 w-px bg-border @min-[640px]/workflow:block`}),(0,X.jsx)(`p`,{className:`min-w-0 flex-1 truncate px-1 text-sm font-medium`,title:p.draft.name,children:p.draft.name}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 max-[480px]:w-full max-[480px]:justify-end`,children:[(0,X.jsx)(Zt,{nodeCount:p.draft.nodes.length,t:o,onAddNode:p.addNode}),(0,X.jsxs)(Ne,{children:[(0,X.jsx)(Oe,{asChild:!0,children:(0,X.jsxs)(K,{variant:`ghost`,size:`sm`,children:[(0,X.jsx)(ge,{}),o(`workflows:workflowsPage.workflowSettings`)]})}),(0,X.jsxs)(je,{className:`sm:max-w-xl`,children:[(0,X.jsxs)(Ae,{children:[(0,X.jsx)(Me,{children:o(`workflows:workflowsPage.workflowSettings`)}),(0,X.jsx)(ke,{children:o(`workflows:editor.settingsDescription`)})]}),(0,X.jsx)(Wn,{draft:p.draft,catalog:p.catalog,t:o,onUpdateDraft:p.updateDraft,onInputUploadBusy:p.onInputUploadBusy})]})]}),!w&&(0,X.jsxs)(K,{variant:`ghost`,size:`sm`,onClick:()=>C(!0),children:[(0,X.jsx)(bt,{}),o(`workflows:editor.nodeProperties`)]})]})]}),(0,X.jsx)(Zn,{message:p.error}),p.running&&p.currentRun&&(0,X.jsx)(On,{run:p.currentRun,t:o}),(0,X.jsxs)(`div`,{className:E(`builder-layout grid h-[max(440px,calc(100vh-220px))] min-h-[440px] min-w-0 overflow-hidden rounded-xl border bg-card supports-[height:100dvh]:h-[max(440px,calc(100dvh-220px))]`,w?`grid-cols-[minmax(0,1fr)_320px]`:`grid-cols-1`),children:[(0,X.jsx)(Qt,{draft:p.draft,selectedNodeId:p.selectedNodeId,selectedEdgeId:p.selectedEdgeId,t:o,onAddNode:p.addNode,onConnect:p.addEdge,onMoveNode:p.moveNode,onSelectNode:e=>{p.selectNode(e),C(!0)},onSelectEdge:e=>{p.selectEdge(e),C(!0)},onClearSelection:p.clearSelection,onDeleteNodes:p.removeNodes,onDeleteEdges:p.removeEdges}),w&&(0,X.jsxs)(`aside`,{className:`flex min-h-0 min-w-0 flex-col border-l bg-card`,"aria-label":j,children:[(0,X.jsx)(`header`,{className:`border-b px-4 py-3`,children:(0,X.jsx)(`h2`,{className:`text-sm font-medium`,children:j})}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4`,children:A})]})]}),!w&&(0,X.jsx)(We,{open:S,onOpenChange:C,children:(0,X.jsxs)(He,{className:`gap-0 data-[side=right]:w-[min(400px,100vw)] data-[side=right]:sm:max-w-[400px]`,children:[(0,X.jsxs)(Ve,{className:`border-b pr-12`,children:[(0,X.jsx)(Be,{children:j}),(0,X.jsx)(Ue,{className:`sr-only`,children:o(`workflows:editor.inspectorDescription`)})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4`,children:A})]})})]})}export{er as WorkflowBuilder,$n as WorkflowsPage};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-a84Zp9dV.js";import{i}from"./dist-Cfh4kzCK.js";import{a,c as o,o as s,r as c,s as l,t as u}from"./dist-B_a0oV4U.js";import{t as d}from"./dist-C3P9WH0T.js";import{t as f}from"./dist-D8Wfxh48.js";import{t as p}from"./utils-C8uzG5AZ.js";import{t as m}from"./createLucideIcon-Cd-3GVxJ.js";import{t as h}from"./arrow-up-DST6-qVQ.js";import{t as g}from"./check-2vYc6QaP.js";import{t as _}from"./chevron-right-C3t2Rckj.js";import{t as v}from"./folder-DPM8D8cf.js";import{t as y}from"./house-BNrzTkx9.js";import{t as b}from"./loader-circle-BOwQzHB-.js";import{t as x}from"./refresh-cw-TbWxTY4K.js";import{t as S}from"./triangle-alert-CE1q54ci.js";import{t as C}from"./api-YI8_cHpR.js";import{t as w}from"./button-CQA36izu.js";import{n as T,t as E}from"./alert-QoPGoIY6.js";import{a as D,i as O,o as k,r as ee,s as te,t as ne}from"./dialog-D-ER2p-D.js";import{t as re}from"./input-CvjGYteF.js";var A=e(t(),1),j=n(),M=Object.defineProperty,N=(e,t)=>M(e,`name`,{value:t,configurable:!0});function P(e,t){return A.useReducer((e,n)=>t[e][n]??e,e)}N(P,`useStateMachine`);var F=`ScrollArea`,[I,ie]=l(F),[L,R]=I(F),z=A.forwardRef(N(function(e,t){let{__scopeScrollArea:n,type:r=`hover`,dir:a,scrollHideDelay:s=600,...c}=e,[l,u]=A.useState(null),[f,p]=A.useState(null),[m,h]=A.useState(null),[g,_]=A.useState(null),[v,y]=A.useState(null),[b,x]=A.useState(0),[S,C]=A.useState(0),[w,T]=A.useState(!1),[E,D]=A.useState(!1),O=i(t,u),k=d(a);return(0,j.jsx)(L,{scope:n,type:r,dir:k,scrollHideDelay:s,scrollArea:l,viewport:f,onViewportChange:p,content:m,onContentChange:h,scrollbarX:g,onScrollbarXChange:_,scrollbarXEnabled:w,onScrollbarXEnabledChange:T,scrollbarY:v,onScrollbarYChange:y,scrollbarYEnabled:E,onScrollbarYEnabledChange:D,onCornerWidthChange:x,onCornerHeightChange:C,children:(0,j.jsx)(o.div,{dir:k,...c,ref:O,style:{position:`relative`,"--radix-scroll-area-corner-width":b+`px`,"--radix-scroll-area-corner-height":S+`px`,...e.style}})})},`ScrollArea`)),B=`ScrollAreaViewport`,V=A.forwardRef(N(function(e,t){let{__scopeScrollArea:n,children:r,nonce:a,...s}=e,c=R(B,n),l=A.useRef(null),u=i(t,l,c.onViewportChange);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(ae,{nonce:a}),(0,j.jsx)(o.div,{"data-radix-scroll-area-viewport":``,...s,ref:u,style:{overflowX:c.scrollbarXEnabled?`scroll`:`hidden`,overflowY:c.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,j.jsx)(`div`,{ref:c.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})},`ScrollAreaViewport`)),ae=A.memo(N(function({nonce:e}){return(0,j.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:e})},`ScrollAreaViewportStyle`),(e,t)=>e.nonce===t.nonce),H=`ScrollAreaScrollbar`,oe=A.forwardRef(N(function(e,t){let{forceMount:n,...r}=e,i=R(H,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return A.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,j.jsx)(se,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,j.jsx)(ce,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,j.jsx)(le,{...r,ref:t,forceMount:n}):i.type===`always`?(0,j.jsx)(U,{...r,ref:t,"data-state":`visible`}):null},`ScrollAreaScrollbar`)),se=A.forwardRef(N(function(e,t){let{forceMount:n,...r}=e,i=R(H,e.__scopeScrollArea),[a,o]=A.useState(!1);return A.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=N(()=>{window.clearTimeout(t),o(!0)},`handlePointerEnter`),r=N(()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)},`handlePointerLeave`);return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,j.jsx)(c,{present:n||a,children:(0,j.jsx)(le,{"data-state":a?`visible`:`hidden`,...r,ref:t})})},`ScrollAreaScrollbarHover`)),ce=A.forwardRef(N(function(e,t){let{forceMount:n,...r}=e,i=R(H,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=Z(()=>u(`SCROLL_END`),100),[l,u]=P(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return A.useEffect(()=>{if(l===`idle`){let e=window.setTimeout(()=>u(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[l,i.scrollHideDelay,u]),A.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=N(()=>{let r=e[t];n!==r&&(u(`SCROLL`),o()),n=r},`handleScroll`);return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,u,o]),(0,j.jsx)(c,{present:n||l!==`hidden`,children:(0,j.jsx)(U,{"data-state":l===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:s(e.onPointerEnter,()=>u(`POINTER_ENTER`)),onPointerLeave:s(e.onPointerLeave,()=>u(`POINTER_LEAVE`))})})},`ScrollAreaScrollbarScroll`)),le=A.forwardRef(N(function(e,t){let n=R(H,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=A.useState(!1),s=e.orientation===`horizontal`,l=Z(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return Q(n.viewport,l),Q(n.content,l),(0,j.jsx)(c,{present:r||a,children:(0,j.jsx)(U,{"data-state":a?`visible`:`hidden`,...i,ref:t})})},`ScrollAreaScrollbarAuto`)),U=A.forwardRef(N(function(e,t){let{orientation:n=`vertical`,...r}=e,i=R(H,e.__scopeScrollArea),a=A.useRef(null),o=A.useRef(0),[s,c]=A.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=K(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:N(e=>a.current=e,`onThumbChange`),onThumbPointerUp:N(()=>o.current=0,`onThumbPointerUp`),onThumbPointerDown:N(e=>o.current=e,`onThumbPointerDown`)};function d(e,t){return be(e,o.current,s,t)}return N(d,`getScrollPosition`),n===`horizontal`?(0,j.jsx)(ue,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=J(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,j.jsx)(de,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=J(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null},`ScrollAreaScrollbarVisible`)),ue=A.forwardRef(N(function(e,t){let{sizes:n,onSizesChange:r,...a}=e,o=R(H,e.__scopeScrollArea),[s,c]=A.useState(),l=A.useRef(null),u=i(t,l,o.onScrollbarXChange);return A.useEffect(()=>{l.current&&c(getComputedStyle(l.current))},[l]),(0,j.jsx)(me,{"data-orientation":`horizontal`,...a,ref:u,sizes:n,style:{bottom:0,left:o.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:o.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":q(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(o.viewport){let r=o.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),X(r,n)&&t.preventDefault()}},onResize:()=>{l.current&&o.viewport&&s&&r({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:G(s.paddingLeft),paddingEnd:G(s.paddingRight)}})}})},`ScrollAreaScrollbarX`)),de=A.forwardRef(N(function(e,t){let{sizes:n,onSizesChange:r,...a}=e,o=R(H,e.__scopeScrollArea),[s,c]=A.useState(),l=A.useRef(null),u=i(t,l,o.onScrollbarYChange);return A.useEffect(()=>{l.current&&c(getComputedStyle(l.current))},[l]),(0,j.jsx)(me,{"data-orientation":`vertical`,...a,ref:u,sizes:n,style:{top:0,right:o.dir===`ltr`?0:void 0,left:o.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":q(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(o.viewport){let r=o.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),X(r,n)&&t.preventDefault()}},onResize:()=>{l.current&&o.viewport&&s&&r({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:G(s.paddingTop),paddingEnd:G(s.paddingBottom)}})}})},`ScrollAreaScrollbarY`)),[fe,pe]=I(H),me=A.forwardRef(N(function(e,t){let{__scopeScrollArea:n,sizes:r,hasThumb:a,onThumbChange:c,onThumbPointerUp:l,onThumbPointerDown:d,onThumbPositionChange:f,onDragScroll:p,onWheelScroll:m,onResize:h,...g}=e,_=R(H,n),[v,y]=A.useState(null),b=i(t,y),x=A.useRef(null),S=A.useRef(``),C=_.viewport,w=r.content-r.viewport,T=u(m),E=u(f),D=Z(h,10);function O(e){if(x.current){let t=e.clientX-x.current.left,n=e.clientY-x.current.top;p({x:t,y:n})}}return N(O,`handleDragScroll`),A.useEffect(()=>{let e=N(e=>{let t=e.target;v?.contains(t)&&T(e,w)},`handleWheel`);return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[C,v,w,T]),A.useEffect(E,[r,E]),Q(v,D),Q(_.content,D),(0,j.jsx)(fe,{scope:n,scrollbar:v,hasThumb:a,onThumbChange:u(c),onThumbPointerUp:u(l),onThumbPositionChange:E,onThumbPointerDown:u(d),children:(0,j.jsx)(o.div,{...g,ref:b,style:{position:`absolute`,...g.style},onPointerDown:s(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),x.current=v.getBoundingClientRect(),S.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,_.viewport&&(_.viewport.style.scrollBehavior=`auto`),O(e))}),onPointerMove:s(e.onPointerMove,O),onPointerUp:s(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=S.current,_.viewport&&(_.viewport.style.scrollBehavior=``),x.current=null})})})},`ScrollAreaScrollbarImpl`)),W=`ScrollAreaThumb`,he=A.forwardRef(N(function(e,t){let{forceMount:n,...r}=e,i=pe(W,e.__scopeScrollArea);return(0,j.jsx)(c,{present:n||i.hasThumb,children:(0,j.jsx)(ge,{ref:t,...r})})},`ScrollAreaThumb`)),ge=A.forwardRef(N(function(e,t){let{__scopeScrollArea:n,style:r,...a}=e,c=R(W,n),l=pe(W,n),{onThumbPositionChange:u}=l,d=i(t,l.onThumbChange),f=A.useRef(void 0),p=Z(()=>{f.current&&=(f.current(),void 0)},100);return A.useEffect(()=>{let e=c.viewport;if(e){let t=N(()=>{if(p(),!f.current){let t=xe(e,u);f.current=t,u()}},`handleScroll`);return u(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[c.viewport,p,u]),(0,j.jsx)(o.div,{"data-state":l.hasThumb?`visible`:`hidden`,...a,ref:d,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:s(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;l.onThumbPointerDown({x:n,y:r})}),onPointerUp:s(e.onPointerUp,l.onThumbPointerUp)})},`ScrollAreaThumbImpl`)),_e=`ScrollAreaCorner`,ve=A.forwardRef(N(function(e,t){let n=R(_e,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,j.jsx)(ye,{...e,ref:t}):null},`ScrollAreaCorner`)),ye=A.forwardRef(N(function(e,t){let{__scopeScrollArea:n,...r}=e,i=R(_e,n),[a,s]=A.useState(0),[c,l]=A.useState(0),u=!!(a&&c),{onCornerWidthChange:d,onCornerHeightChange:f}=i;return Q(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),l(e)}),Q(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),s(e)}),A.useEffect(()=>()=>{d(0),f(0)},[d,f]),u?(0,j.jsx)(o.div,{...r,ref:t,style:{width:a,height:c,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null},`ScrollAreaCornerImpl`));function G(e){return e?parseInt(e,10):0}N(G,`toInt`);function K(e,t){let n=e/t;return isNaN(n)?0:n}N(K,`getThumbRatio`);function q(e){let t=K(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}N(q,`getThumbSize`);function be(e,t,n,r=`ltr`){let i=q(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return Y([c,l],d)(e)}N(be,`getScrollPositionFromPointer`);function J(e,t,n=`ltr`){let r=q(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=n===`ltr`?[0,o]:[o*-1,0],l=f(e,c);return Y([0,o],[0,s])(l)}N(J,`getThumbOffsetFromScroll`);function Y(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}N(Y,`linearScale`);function X(e,t){return e>0&&e<t}N(X,`isScrollingWithinScrollbarBounds`);var xe=N((e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return N((function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)}),`loop`)(),()=>window.cancelAnimationFrame(r)},`addUnlinkedScrollListener`);function Z(e,t){let n=u(e),r=A.useRef(0);return A.useEffect(()=>()=>window.clearTimeout(r.current),[]),A.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}N(Z,`useDebounceCallback`);function Q(e,t){let n=u(t);a(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}N(Q,`useResizeObserver`);var Se=z,Ce=V,we=ve,Te=m(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),Ee=m(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]);function De({className:e,children:t,...n}){return(0,j.jsxs)(Se,{"data-slot":`scroll-area`,className:p(`relative`,e),...n,children:[(0,j.jsx)(Ce,{"data-slot":`scroll-area-viewport`,className:`size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1`,children:t}),(0,j.jsx)(Oe,{}),(0,j.jsx)(we,{})]})}function Oe({className:e,orientation:t=`vertical`,...n}){return(0,j.jsx)(oe,{"data-slot":`scroll-area-scrollbar`,"data-orientation":t,orientation:t,className:p(`flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent`,e),...n,children:(0,j.jsx)(he,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}function $(e){let t=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return t?t(e):Promise.reject(Error(`native bridge unavailable`))}async function ke(){return window.__PISPER_MOBILE_APP__?(await $(`mobile_state`)).mode:null}async function Ae(){if(window.__PISPER_MOBILE_PLATFORM__!==`android`)throw Error(`workspace_import_unsupported`);let e=await $(`mobile_state`);if(e.mode!==`local`||!e.onDevice?.running)throw Error(`workspace_import_requires_local_runtime`);let t=await $(`mobile_import_workspace_directory`);if(t.path===null)return null;if(typeof t.path!=`string`||!t.path.startsWith(`/`))throw Error(`workspace_import_invalid_path`);return t.path}function je({open:e,initialPath:t=``,description:n,onOpenChange:i,onSelect:a}){let{t:o}=r(),[s,c]=(0,A.useState)(t),[l,u]=(0,A.useState)(null),[d,f]=(0,A.useState)(!1),[p,m]=(0,A.useState)(!1),[M,N]=(0,A.useState)(!1),[P,F]=(0,A.useState)(!1),[I,ie]=(0,A.useState)(null),[L,R]=(0,A.useState)(``),z=(0,A.useRef)(0),B=(0,A.useRef)(0),V=M||P,ae=I===`local`&&window.__PISPER_MOBILE_PLATFORM__===`android`,H=(0,A.useCallback)(async e=>{let t=++z.current;m(!0),R(``);try{let n=await C(`/api/directories?path=${encodeURIComponent(e.trim())}`);if(t!==z.current)return;if(!n||typeof n.path!=`string`||!n.path.trim()||n.parent!=null&&(typeof n.parent!=`string`||!n.parent.trim())||!Array.isArray(n.directories)||n.directories.some(e=>!e||typeof e.name!=`string`||!e.name.trim()||typeof e.path!=`string`||!e.path.trim()))throw Error(o(`common:workspacePicker.invalidListing`));c(n.path),u(n),f(!1)}catch(e){if(t!==z.current)return;R(e instanceof Error?e.message:String(e))}finally{t===z.current&&m(!1)}},[o]);(0,A.useEffect)(()=>{let n=++B.current;return e&&(c(t),u(null),N(!1),F(!1),f(!1),ie(null),H(t),ke().then(e=>{n===B.current&&ie(e)}).catch(e=>{n===B.current&&R(e instanceof Error?e.message:String(e))})),()=>{z.current+=1,B.current+=1}},[H,t,e]);let oe=e=>{e.preventDefault(),!V&&!p&&H(s)},se=async()=>{let e=B.current;F(!0),R(``);try{let t=await Ae();e===B.current&&t&&await H(t)}catch(t){e===B.current&&R(t instanceof Error?t.message:String(t))}finally{e===B.current&&F(!1)}},ce=async()=>{if(!(!l||V||p||L||s!==l.path)){N(!0),R(``);try{await a(l.path),i(!1)}catch(e){R(e instanceof Error?e.message:String(e))}finally{N(!1)}}};return(0,j.jsx)(ne,{open:e,onOpenChange:e=>!V&&i(e),children:(0,j.jsxs)(ee,{showCloseButton:!V,className:`max-w-[calc(100vw-24px)]! gap-0 overflow-hidden p-0 sm:max-w-[620px]!`,children:[(0,j.jsxs)(k,{className:`border-b px-4 py-3 pr-12`,children:[(0,j.jsx)(te,{children:o(`common:workspacePicker.setWorkingDirectory`)}),(0,j.jsx)(O,{children:n||o(`common:workspacePicker.selectDirectoryDescription`)})]}),ae&&(0,j.jsx)(`div`,{className:`border-b px-4 py-3`,children:(0,j.jsxs)(w,{type:`button`,variant:`outline`,className:`h-auto min-h-10 w-full whitespace-normal`,disabled:V||p,onClick:()=>void se(),children:[P?(0,j.jsx)(b,{className:`animate-spin`}):(0,j.jsx)(Te,{}),o(P?`common:workspacePicker.importingFolder`:`common:workspacePicker.importFolderCopy`)]})}),(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-4 py-3`,children:[(0,j.jsx)(w,{type:`button`,variant:`outline`,size:`icon`,title:o(`common:workspacePicker.parentFolder`),"aria-label":o(`common:workspacePicker.parentFolder`),disabled:p||V||!l?.parent,onClick:()=>l?.parent&&void H(l.parent),children:(0,j.jsx)(h,{})}),(0,j.jsx)(w,{type:`button`,variant:`outline`,size:`icon`,title:o(`common:workspacePicker.defaultFolder`),"aria-label":o(`common:workspacePicker.defaultFolder`),disabled:p||V,onClick:()=>void H(``),children:(0,j.jsx)(y,{})}),(0,j.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,j.jsx)(`div`,{className:`truncate text-[11px] text-content-muted`,children:o(I===`remote`?`common:workspacePicker.serverFolder`:`common:workspacePicker.workingDirectoryPath`)}),(0,j.jsx)(`div`,{className:`truncate font-mono text-xs`,title:l?.path||``,children:l?.path||o(`common:workspacePicker.defaultFolder`)})]}),(0,j.jsx)(w,{type:`button`,variant:`ghost`,size:`icon`,title:o(`common:workspacePicker.enterPath`),"aria-label":o(`common:workspacePicker.enterPath`),"aria-expanded":d,disabled:V||p,onClick:()=>{c(l?.path||t),f(e=>!e)},children:(0,j.jsx)(Ee,{})}),(0,j.jsx)(w,{type:`button`,variant:`ghost`,size:`icon`,title:o(`common:workspacePicker.refreshFolder`),"aria-label":o(`common:workspacePicker.refreshFolder`),disabled:V||p,onClick:()=>void H(l?.path||t),children:p?(0,j.jsx)(b,{className:`animate-spin`}):(0,j.jsx)(x,{})})]}),d&&(0,j.jsxs)(`form`,{className:`flex min-w-0 items-center gap-2 px-4 pb-3`,onSubmit:oe,children:[(0,j.jsx)(re,{className:`min-w-0 flex-1 font-mono text-[12px]`,value:s,disabled:V||p,"aria-label":o(`common:workspacePicker.workingDirectoryPath`),placeholder:o(`common:workspacePicker.enterAbsolutePath`),onChange:e=>c(e.target.value)}),(0,j.jsxs)(w,{type:`submit`,variant:`secondary`,disabled:p||V||!s.trim(),children:[(0,j.jsx)(_,{}),o(`common:workspacePicker.go`)]})]}),(0,j.jsx)(De,{className:`h-[min(340px,40dvh)] border-y bg-muted/20`,children:(0,j.jsxs)(`div`,{className:`p-2`,children:[!p&&l?.directories.map(e=>(0,j.jsxs)(`button`,{type:`button`,className:`grid min-h-11 w-full grid-cols-[24px_minmax(0,1fr)_20px] items-center rounded-md px-2 py-2 text-left text-[13px] hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,title:e.path,disabled:V,onClick:()=>void H(e.path),children:[(0,j.jsx)(v,{className:`size-4 text-content-muted`}),(0,j.jsx)(`span`,{className:`truncate`,children:e.name}),(0,j.jsx)(_,{className:`size-4 text-content-muted`})]},e.path)),p&&(0,j.jsxs)(`div`,{role:`status`,className:`flex h-32 items-center justify-center gap-2 text-content-muted`,children:[(0,j.jsx)(b,{className:`size-4 animate-spin`}),(0,j.jsx)(`span`,{children:o(`common:workspacePicker.readingFolder`)})]}),!p&&!L&&l&&!l.directories.length&&(0,j.jsx)(`div`,{className:`flex h-32 items-center justify-center text-sm text-content-muted`,children:o(`common:workspacePicker.thisFolderHasNoSubfolders`)})]})}),L&&(0,j.jsxs)(E,{variant:`destructive`,className:`mx-4 mt-3 w-auto`,children:[(0,j.jsx)(S,{}),(0,j.jsx)(T,{className:`min-w-0 break-words`,children:L})]}),(0,j.jsxs)(D,{className:`m-0 border-t-0 bg-transparent px-4 py-3`,children:[(0,j.jsx)(w,{type:`button`,variant:`outline`,disabled:V,onClick:()=>i(!1),children:o(`common:ui.cancel`)}),(0,j.jsxs)(w,{type:`button`,variant:`secondary`,disabled:p||V||!l||!!L||s!==l.path,onClick:()=>void ce(),children:[M?(0,j.jsx)(b,{className:`animate-spin`}):(0,j.jsx)(g,{}),o(M?`common:workspacePicker.switching`:`common:workspacePicker.useThisFolder`)]})]})]})})}export{je as WorkspacePicker,De as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-Cd-3GVxJ.js";var t=e(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]);export{t};
@@ -1 +0,0 @@
1
- import"./floating-widgets-store-Pjm1AdvO.js";import{i as e}from"./useCustomUiComponents-BaQ_fwbr.js";export{e as listCustomUiComponents};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{i as r,n as i}from"./dist-Cfh4kzCK.js";import{a,c as o,i as s,n as c,o as l,s as u,t as d}from"./dist-B_a0oV4U.js";import{t as f}from"./dist-C3P9WH0T.js";var p=e(t(),1),m=n(),h=Object.defineProperty,g=(e,t)=>h(e,`name`,{value:t,configurable:!0});function _(e){let t=e+`CollectionProvider`,[n,a]=u(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=g(e=>{let{scope:t,children:n}=e,r=p.useRef(null),i=p.useRef(new Map).current;return(0,m.jsx)(o,{scope:t,itemMap:i,collectionRef:r,children:n})},`CollectionProvider`);c.displayName=t;let l=e+`CollectionSlot`,d=i(l),f=p.forwardRef((e,t)=>{let{scope:n,children:i}=e,a=s(l,n),o=r(t,a.collectionRef);return(0,m.jsx)(d,{ref:o,children:i})});f.displayName=l;let h=e+`CollectionItemSlot`,_=`data-radix-collection-item`,v=i(h),y=p.forwardRef((e,t)=>{let{scope:n,children:i,...a}=e,o=p.useRef(null),c=r(t,o),l=s(h,n);return p.useEffect(()=>(l.itemMap.set(o,{ref:o,...a}),()=>void l.itemMap.delete(o))),(0,m.jsx)(v,{[_]:``,ref:c,children:i})});y.displayName=h;function b(t){let n=s(e+`CollectionConsumer`,t);return p.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${_}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return g(b,`useCollection`),[{Provider:c,Slot:f,ItemSlot:y},b,a]}g(_,`createCollection`);var v=new WeakMap,y=class e extends Map{static#e=g(this,`OrderedDict`);#t;constructor(e){super(e),this.#t=[...super.keys()],v.set(this,!0)}set(e,t){return v.get(this)&&(this.has(e)?this.#t[this.#t.indexOf(e)]=e:this.#t.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#t.length,a=S(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#t],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#t.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#t.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#t.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#t.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#t=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#t.splice(this.#t.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=b(this.#t,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=b(this.#t,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#t.indexOf(e)}keyAt(e){return b(this.#t,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function b(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=x(e,t);return n===-1?void 0:e[n]}g(b,`at`);function x(e,t){let n=e.length,r=S(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}g(x,`toSafeIndex`);function S(e){return e!==e||e===0?0:Math.trunc(e)}g(S,`toSafeInteger`);function C(e){let t=e+`CollectionProvider`,[n,a]=u(t),[o,s]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new y,setItemMap:g(()=>void 0,`setItemMap`)}),c=g(({state:e,...t})=>e?(0,m.jsx)(d,{...t,state:e}):(0,m.jsx)(l,{...t}),`CollectionProvider`);c.displayName=t;let l=g(e=>{let t=S();return(0,m.jsx)(d,{...e,state:t})},`CollectionInit`);l.displayName=t+`Init`;let d=g(e=>{let{scope:t,children:n,state:i}=e,a=p.useRef(null),[s,c]=p.useState(null),l=r(a,c),[u,d]=i;return p.useEffect(()=>{if(!s)return;let e=D(()=>{});return e.observe(s,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[s]),(0,m.jsx)(o,{scope:t,itemMap:u,setItemMap:d,collectionRef:l,collectionRefObject:a,collectionElement:s,children:n})},`CollectionProviderImpl`);d.displayName=t+`Impl`;let f=e+`CollectionSlot`,h=i(f),_=p.forwardRef((e,t)=>{let{scope:n,children:i}=e,a=s(f,n),o=r(t,a.collectionRef);return(0,m.jsx)(h,{ref:o,children:i})});_.displayName=f;let v=e+`CollectionItemSlot`,b=i(v),x=p.forwardRef((e,t)=>{let{scope:n,children:i,...a}=e,o=p.useRef(null),[c,l]=p.useState(null),u=r(t,o,l),{setItemMap:d}=s(v,n),f=p.useRef(a);w(f.current,a)||(f.current=a);let h=f.current;return p.useEffect(()=>{let e=h;return d(t=>c?t.has(c)?t.set(c,{...e,element:c}).toSorted(E):(t.set(c,{...e,element:c}),t.toSorted(E)):t),()=>{d(e=>!c||!e.has(c)?e:(e.delete(c),new y(e)))}},[c,h,d]),(0,m.jsx)(b,{"data-radix-collection-item":``,ref:u,children:i})});x.displayName=v;function S(){return p.useState(new y)}g(S,`useInitCollection`);function C(t){let{itemMap:n}=s(e+`CollectionConsumer`,t);return n}return g(C,`useCollection`),[{Provider:c,Slot:_,ItemSlot:x},{createCollectionScope:a,useCollection:C,useInitCollection:S}]}g(C,`createCollection`);function w(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}g(w,`shallowEqual`);function T(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}g(T,`isElementPreceding`);function E(e,t){return!e[1].element||!t[1].element?0:T(e[1].element,t[1].element)?-1:1}g(E,`sortByDocumentPosition`);function D(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}g(D,`getChildListObserver`);var O=Object.defineProperty,k=(e,t)=>O(e,`name`,{value:t,configurable:!0}),A=!1;function j(){let[e,t]=p.useState(A);return p.useEffect(()=>{A||(A=!0,t(!0))},[]),e}k(j,`useIsHydrated`);var M=p.useSyncExternalStore;function N(){return()=>{}}k(N,`subscribe`);function P(){return M(N,()=>!0,()=>!1)}k(P,`useIsHydratedModern`);var F=typeof M==`function`?P:j,ee=Object.defineProperty,I=(e,t)=>ee(e,`name`,{value:t,configurable:!0}),L=`rovingFocusGroup.onEntryFocus`,R={bubbles:!1,cancelable:!0},z=`RovingFocusGroup`,[B,V,H]=_(z),[U,W]=u(z,[H]),[G,K]=U(z),q=p.forwardRef(I(function(e,t){return(0,m.jsx)(B.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,m.jsx)(B.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,m.jsx)(J,{...e,ref:t})})})},`RovingFocusGroup`)),J=p.forwardRef(I(function(e,t){let{__scopeRovingFocusGroup:n,orientation:i,loop:a=!1,dir:c,currentTabStopId:u,defaultCurrentTabStopId:h,onCurrentTabStopIdChange:g,onEntryFocus:_,preventScrollOnEntryFocus:v=!1,...y}=e,b=p.useRef(null),x=r(t,b),S=f(c),[C,w]=s({prop:u,defaultProp:h??null,onChange:g,caller:z}),[T,E]=p.useState(!1),D=d(_),O=V(n),k=p.useRef(!1),[A,j]=p.useState(0);return p.useEffect(()=>{let e=b.current;if(e)return e.addEventListener(L,D),()=>e.removeEventListener(L,D)},[D]),(0,m.jsx)(G,{scope:n,orientation:i,dir:S,loop:a,currentTabStopId:C,onItemFocus:p.useCallback(e=>w(e),[w]),onItemShiftTab:p.useCallback(()=>E(!0),[]),onFocusableItemAdd:p.useCallback(()=>j(e=>e+1),[]),onFocusableItemRemove:p.useCallback(()=>j(e=>e-1),[]),children:(0,m.jsx)(o.div,{tabIndex:T||A===0?-1:0,"data-orientation":i,...y,ref:x,style:{outline:`none`,...e.style},onMouseDown:l(e.onMouseDown,()=>{k.current=!0}),onFocus:l(e.onFocus,e=>{let t=!k.current;if(e.target===e.currentTarget&&t&&!T){let t=new CustomEvent(L,R);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=O().filter(e=>e.focusable);Q([e.find(e=>e.active),e.find(e=>e.id===C),...e].filter(Boolean).map(e=>e.ref.current),v)}}k.current=!1}),onBlur:l(e.onBlur,()=>E(!1))})})},`RovingFocusGroupImpl`)),Y=`RovingFocusGroupItem`,te=p.forwardRef(I(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:u,...d}=e,f=c(),h=s||f,g=K(Y,n),_=g.currentTabStopId===h,v=V(n),{onFocusableItemAdd:y,onFocusableItemRemove:b,currentTabStopId:x}=g,S=F();return a(()=>{if(!(!S||!r))return y(),()=>b()},[S,r,y,b]),p.useEffect(()=>{if(!(S||!r))return y(),()=>b()},[S,r,y,b]),(0,m.jsx)(B.ItemSlot,{scope:n,id:h,focusable:r,active:i,children:(0,m.jsx)(o.span,{tabIndex:_?0:-1,"data-orientation":g.orientation,...d,ref:t,onMouseDown:l(e.onMouseDown,e=>{r?g.onItemFocus(h):e.preventDefault()}),onFocus:l(e.onFocus,()=>g.onItemFocus(h)),onKeyDown:l(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){g.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Z(e,g.orientation,g.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=v().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=g.loop?$(n,r+1):n.slice(r+1)}setTimeout(()=>Q(n))}}),children:typeof u==`function`?u({isCurrentTabStop:_,hasTabStop:x!=null}):u})})},`RovingFocusGroupItem`)),ne={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function X(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}I(X,`getDirectionAwareKey`);function Z(e,t,n){let r=X(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return ne[r]}I(Z,`getFocusIntent`);function Q(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}I(Q,`focusFirst`);function $(e,t){return e.map((n,r)=>e[(t+r)%e.length])}I($,`wrapArray`);var re=q,ie=te;export{_ as i,re as n,W as r,ie as t};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";var r=e(t(),1);n();var i=Object.defineProperty,a=(e,t)=>i(e,`name`,{value:t,configurable:!0}),o=r.createContext(void 0);function s(e){let t=r.useContext(o);return e||t||`ltr`}a(s,`useDirection`);export{s as t};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{i as r,n as i}from"./dist-Cfh4kzCK.js";import{c as a,l as o,n as s,o as c,r as l,s as u,t as d}from"./dist-B_a0oV4U.js";import{i as f,n as p,r as m,t as ee}from"./dist-B7rNRXig.js";import{t as h}from"./dist-C3P9WH0T.js";import{a as g,i as _,n as te,r as ne,s as re,t as v}from"./es2015-0QT3KgdC.js";import{a as y,i as b,r as ie,t as x}from"./dist-alOyD2Bh.js";var S=e(t(),1),C=n(),w=Object.defineProperty,T=(e,t)=>w(e,`name`,{value:t,configurable:!0}),E=[`Enter`,` `],ae=[`ArrowDown`,`PageUp`,`Home`],D=[`ArrowUp`,`PageDown`,`End`],oe=[...ae,...D],O={ltr:[...E,`ArrowRight`],rtl:[...E,`ArrowLeft`]},k={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},A=`Menu`,[j,se,M]=f(A),[N,P]=u(A,[M,y,m]),F=y(),ce=m(),[I,L]=N(A),[R,z]=N(A),le=T(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=F(t),[c,l]=S.useState(null),u=S.useRef(!1),f=d(a),p=h(i);return S.useEffect(()=>{let e=T(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=T(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),S.useEffect(()=>{if(!n)return;let e=T(()=>f(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,f]),(0,C.jsx)(b,{...s,children:(0,C.jsx)(I,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:l,children:(0,C.jsx)(R,{scope:t,onClose:S.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:u,dir:p,modal:o,children:r})})})},`Menu`),B=S.forwardRef(T(function(e,t){let{__scopeMenu:n,...r}=e,i=F(n);return(0,C.jsx)(x,{...i,...r,ref:t})},`MenuAnchor`)),V=`MenuPortal`,[H,U]=N(V,{forceMount:void 0}),ue=T(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=L(V,t);return(0,C.jsx)(H,{scope:t,forceMount:n,children:(0,C.jsx)(l,{present:n||a.open,children:(0,C.jsx)(_,{asChild:!0,container:i,children:r})})})},`MenuPortal`),W=`MenuContent`,[de,G]=N(W),fe=S.forwardRef(T(function(e,t){let n=U(W,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=L(W,e.__scopeMenu),o=z(W,e.__scopeMenu);return(0,C.jsx)(j.Provider,{scope:e.__scopeMenu,children:(0,C.jsx)(l,{present:r||a.open,children:(0,C.jsx)(j.Slot,{scope:e.__scopeMenu,children:o.modal?(0,C.jsx)(pe,{...i,ref:t}):(0,C.jsx)(me,{...i,ref:t})})})})},`MenuContent`)),pe=S.forwardRef(T(function(e,t){let n=L(W,e.__scopeMenu),i=S.useRef(null),a=r(t,i);return S.useEffect(()=>{let e=i.current;if(e)return v(e)},[]),(0,C.jsx)(K,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:c(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),me=S.forwardRef(T(function(e,t){let n=L(W,e.__scopeMenu);return(0,C.jsx)(K,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),he=i(`MenuContent.ScrollLock`),K=S.forwardRef(T(function(e,t){let{__scopeMenu:n,loop:i=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:l,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:m,onInteractOutside:ee,onDismiss:h,disableOutsideScroll:_,...v}=e,y=L(W,n),b=z(W,n),x=F(n),w=ce(n),E=se(n),[ae,O]=S.useState(null),k=S.useRef(null),A=r(t,k,y.onContentChange),j=S.useRef(0),M=S.useRef(``),N=S.useRef(0),P=S.useRef(null),I=S.useRef(`right`),R=S.useRef(0),le=_?te:S.Fragment,B=_?{as:he,allowPinchZoom:!0}:void 0,V=T(e=>{let t=M.current+e,n=E().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Me(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;T((function e(t){M.current=t,window.clearTimeout(j.current),t!==``&&(j.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);S.useEffect(()=>()=>window.clearTimeout(j.current),[]),ne();let H=S.useCallback(e=>I.current===P.current?.side&&Pe(e,P.current?.area),[]);return(0,C.jsx)(de,{scope:n,searchRef:M,onItemEnter:S.useCallback(e=>{H(e)&&e.preventDefault()},[H]),onItemLeave:S.useCallback(e=>{H(e)||(k.current?.focus(),O(null))},[H]),onTriggerLeave:S.useCallback(e=>{H(e)&&e.preventDefault()},[H]),pointerGraceTimerRef:N,onPointerGraceIntentChange:S.useCallback(e=>{P.current=e},[]),children:(0,C.jsx)(le,{...B,children:(0,C.jsx)(g,{asChild:!0,trapped:a,onMountAutoFocus:c(o,e=>{e.preventDefault(),k.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:(0,C.jsx)(re,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:m,onInteractOutside:ee,onDismiss:h,children:(0,C.jsx)(p,{asChild:!0,...w,dir:b.dir,orientation:`vertical`,loop:i,currentTabStopId:ae,onCurrentTabStopIdChange:O,onEntryFocus:c(u,e=>{b.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,C.jsx)(ie,{role:`menu`,"aria-orientation":`vertical`,"data-state":Q(y.open),"data-radix-menu-content":``,dir:b.dir,...x,...v,ref:A,style:{outline:`none`,...v.style},onKeyDown:c(v.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&V(e.key));let i=k.current;if(e.target!==i||!oe.includes(e.key))return;e.preventDefault();let a=E().filter(e=>!e.disabled).map(e=>e.ref.current);D.includes(e.key)&&a.reverse(),Ae(a)}),onBlur:c(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(j.current),M.current=``)}),onPointerMove:c(e.onPointerMove,$(e=>{let t=e.target,n=R.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>R.current?`right`:`left`;I.current=t,R.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),q=`MenuItem`,J=`menu.itemSelect`,ge=S.forwardRef(T(function(e,t){let{disabled:n=!1,onSelect:i,...a}=e,s=S.useRef(null),l=z(q,e.__scopeMenu),u=G(q,e.__scopeMenu),d=r(t,s),f=S.useRef(!1),p=T(()=>{let e=s.current;if(!n&&e){let t=new CustomEvent(J,{bubbles:!0,cancelable:!0});e.addEventListener(J,e=>i?.(e),{once:!0}),o(e,t),t.defaultPrevented?f.current=!1:l.onClose()}},`handleSelect`);return(0,C.jsx)(Y,{...a,ref:d,disabled:n,onClick:c(e.onClick,p),onPointerDown:t=>{e.onPointerDown?.(t),f.current=!0},onPointerUp:c(e.onPointerUp,e=>{f.current||e.currentTarget?.click()}),onKeyDown:c(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(u.searchRef.current===``||e.key!==` `)&&E.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),Y=S.forwardRef(T(function(e,t){let{__scopeMenu:n,disabled:i=!1,textValue:o,...s}=e,l=G(q,n),u=ce(n),d=S.useRef(null),f=r(t,d),[p,m]=S.useState(!1),[h,g]=S.useState(``);return S.useEffect(()=>{let e=d.current;e&&g((e.textContent??``).trim())},[s.children]),(0,C.jsx)(j.ItemSlot,{scope:n,disabled:i,textValue:o??h,children:(0,C.jsx)(ee,{asChild:!0,...u,focusable:!i,children:(0,C.jsx)(a.div,{role:`menuitem`,"data-highlighted":p?``:void 0,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,...s,ref:f,onPointerMove:c(e.onPointerMove,$(e=>{i?l.onItemLeave(e):(l.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:c(e.onPointerLeave,$(e=>l.onItemLeave(e))),onFocus:c(e.onFocus,()=>m(!0)),onBlur:c(e.onBlur,()=>m(!1))})})})},`MenuItemImpl`)),[_e,ve]=N(`MenuRadioGroup`,{value:void 0,onValueChange:T(()=>{},`onValueChange`)}),[ye,be]=N(`MenuItemIndicator`,{checked:!1}),xe=S.forwardRef(T(function(e,t){let{__scopeMenu:n,...r}=e;return(0,C.jsx)(a.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),X=`MenuSub`,[Se,Ce]=N(X),we=T(e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=L(X,t),o=F(t),[c,l]=S.useState(null),[u,f]=S.useState(null),p=d(i);return S.useEffect(()=>(a.open===!1&&p(!1),()=>p(!1)),[a.open,p]),(0,C.jsx)(b,{...o,children:(0,C.jsx)(I,{scope:t,open:r,onOpenChange:p,content:u,onContentChange:f,children:(0,C.jsx)(Se,{scope:t,contentId:s(),triggerId:s(),trigger:c,onTriggerChange:l,children:n})})})},`MenuSub`),Z=`MenuSubTrigger`,Te=S.forwardRef(T(function(e,t){let n=L(Z,e.__scopeMenu),i=z(Z,e.__scopeMenu),a=Ce(Z,e.__scopeMenu),o=G(Z,e.__scopeMenu),s=S.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:u}=o,d={__scopeMenu:e.__scopeMenu},f=S.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);S.useEffect(()=>f,[f]),S.useEffect(()=>{let e=l.current;return()=>{window.clearTimeout(e),u(null)}},[l,u]);let p=r(t,a.onTriggerChange);return(0,C.jsx)(B,{asChild:!0,...d,children:(0,C.jsx)(Y,{id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?a.contentId:void 0,"data-state":Q(n.open),...e,ref:p,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:c(e.onPointerMove,$(t=>{o.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!s.current&&(o.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:c(e.onPointerLeave,$(e=>{f();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,a=i?-5:5,s=t[i?`left`:`right`],c=t[i?`right`:`left`];o.onPointerGraceIntentChange({area:[{x:e.clientX+a,y:e.clientY},{x:s,y:t.top},{x:c,y:t.top},{x:c,y:t.bottom},{x:s,y:t.bottom}],side:r}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(e),e.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:c(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||(o.searchRef.current===``||t.key!==` `)&&O[i.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})},`MenuSubTrigger`)),Ee=`MenuSubContent`,De=S.forwardRef(T(function(e,t){let n=U(W,e.__scopeMenu),{forceMount:i=n.forceMount,align:a=`start`,...o}=e,s=L(W,e.__scopeMenu),u=z(W,e.__scopeMenu),d=Ce(Ee,e.__scopeMenu),f=S.useRef(null),p=r(t,f);return(0,C.jsx)(j.Provider,{scope:e.__scopeMenu,children:(0,C.jsx)(l,{present:i||s.open,children:(0,C.jsx)(j.Slot,{scope:e.__scopeMenu,children:(0,C.jsx)(K,{id:d.contentId,"aria-labelledby":d.triggerId,...o,ref:p,align:a,side:u.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{u.isUsingKeyboardRef.current&&f.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:c(e.onFocusOutside,e=>{e.target!==d.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:c(e.onEscapeKeyDown,e=>{u.onClose(),e.preventDefault()}),onKeyDown:c(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=k[u.dir].includes(e.key);t&&n&&(s.onOpenChange(!1),d.trigger?.focus(),e.preventDefault())})})})})})},`MenuSubContent`));function Q(e){return e?`open`:`closed`}T(Q,`getOpenState`);function Oe(e){return e===`indeterminate`}T(Oe,`isIndeterminate`);function ke(e){return Oe(e)?`indeterminate`:e?`checked`:`unchecked`}T(ke,`getCheckedState`);function Ae(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}T(Ae,`focusFirst`);function je(e,t){return e.map((n,r)=>e[(t+r)%e.length])}T(je,`wrapArray`);function Me(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=je(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}T(Me,`getNextMatch`);function Ne(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}T(Ne,`isPointInPolygon`);function Pe(e,t){return t?Ne({x:e.clientX,y:e.clientY},t):!1}T(Pe,`isPointerInGraceArea`);function $(e){return t=>t.pointerType===`mouse`?e(t):void 0}T($,`whenMouse`);var Fe=le,Ie=B,Le=ue,Re=fe,ze=ge,Be=xe,Ve=we,He=Te,Ue=De;export{Fe as a,Ue as c,Le as i,He as l,Re as n,Be as o,ze as r,Ve as s,Ie as t,P as u};
@@ -1 +0,0 @@
1
- var e=Object.defineProperty,t=(t,n)=>e(t,`name`,{value:n,configurable:!0});function n(e,[t,n]){return Math.min(n,Math.max(t,e))}t(n,`clamp`);export{n as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-Cd-3GVxJ.js";var t=e(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]);export{t};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-Cd-3GVxJ.js";var t=e(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]]);export{t};