@forsion/unit 2.13.5 → 2.13.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/main.mjs +20 -4
- package/package.json +1 -1
- package/release.json +6 -5
- package/web/assets/{ArtificialView-BD1yHz1N.js → ArtificialView-DHqb9CTL.js} +1 -1
- package/web/assets/{AutomationBuilder-B09c-5Bi.js → AutomationBuilder-CzBKmOiw.js} +1 -1
- package/web/assets/{CalendarConfigView-Bd-ZDGPO.js → CalendarConfigView-Blw47NCs.js} +1 -1
- package/web/assets/CalendarSide-CFSzme3H.js +1 -0
- package/web/assets/CalendarView-B8sQfgZt.js +3 -0
- package/web/assets/{CapabilityMenu-DyHTEYLr.js → CapabilityMenu-Dzn6RbB1.js} +1 -1
- package/web/assets/{Chrome-C7F6fdDp.js → Chrome-owLewFu4.js} +1 -1
- package/web/assets/{CodeView-BGOnrGhB.js → CodeView-E18NDilX.js} +3 -3
- package/web/assets/{CtxMenuButtons-BYjrbUKS.js → CtxMenuButtons-CAiwQkOK.js} +1 -1
- package/web/assets/DashboardGridView-CBbYKcCo.js +25 -0
- package/web/assets/EventCard-D9uQe7g4.js +1 -0
- package/web/assets/{ExcalidrawCanvas-lwJCN6uB.js → ExcalidrawCanvas-BSOERegJ.js} +1 -1
- package/web/assets/{FloatingToc-DO7SH8Ku.js → FloatingToc-iK08Qpjc.js} +1 -1
- package/web/assets/GitCloneDialog-DfY0kqhP.js +1 -0
- package/web/assets/{HomepageView-CHJEhf9c.js → HomepageView-BCqFe1Ym.js} +3 -3
- package/web/assets/{ImageStudioPanels-CgVf0wiq.js → ImageStudioPanels-DdwihAkT.js} +2 -2
- package/web/assets/ImageStudioView-gJSYrmu1.js +1 -0
- package/web/assets/{InlineAiPanel-CdIPINsA.js → InlineAiPanel-CjYOW0_0.js} +1 -1
- package/web/assets/InlineFiles-3g2jMUeA.js +1 -0
- package/web/assets/{MarkdownBlock-DSItkLhu.js → MarkdownBlock-DjsGkPZ_.js} +24 -24
- package/web/assets/{ModelPill--CU3XTIQ.js → ModelPill-DgyXBsL9.js} +2 -2
- package/web/assets/MuseLibraryView-D_HBijmU.js +2 -0
- package/web/assets/{MuseView-CvsO62Fo.js → MuseView-BVDlmM6i.js} +3 -3
- package/web/assets/{PageHistoryPanel-CDh7nm78.js → PageHistoryPanel-B1EAPZeX.js} +2 -2
- package/web/assets/{PdfAnnotator-DafvjP3U.js → PdfAnnotator-bdB9evsY.js} +1 -1
- package/web/assets/{PenRow-CEy-s6SF.js → PenRow-DCOIGlfY.js} +1 -1
- package/web/assets/PluginToolCard-BXE5vA1h.js +2 -0
- package/web/assets/{ProductView-AUqnTwmQ.js → ProductView-l5Q7uBy6.js} +1 -1
- package/web/assets/{SettingsPage-B9mmkWaM.js → SettingsPage-fjxfS_Mt.js} +2 -2
- package/web/assets/{StudioGuestSurface-OOhRA8nt.js → StudioGuestSurface-360CWUwf.js} +1 -1
- package/web/assets/TodoListView-BsPt2GUU.js +1 -0
- package/web/assets/{Tooltip-DOYi44eY.js → Tooltip-CuXpWtdJ.js} +1 -1
- package/web/assets/UnifiedPage-6xbFLtXT.js +712 -0
- package/web/assets/{ViewSelectionBar-WmSWMFsR.js → ViewSelectionBar-C5FDh7fO.js} +2 -2
- package/web/assets/{appStore-DDOkzWDA.js → appStore-BskcSDl6.js} +114 -115
- package/web/assets/{arrow-up-right-BptN64d-.js → arrow-up-right-DEykpgsH.js} +1 -1
- package/web/assets/{astryxBridge-BL56QfEv.js → astryxBridge-B2IZdPvo.js} +1 -1
- package/web/assets/automationListSource-Cm09JKkK.js +1 -0
- package/web/assets/{boardSurface-CP4HNmcm.js → boardSurface-Dv-aVaUJ.js} +1 -1
- package/web/assets/{calendarNavStore-DCi7VBmM.js → calendarNavStore-FKStA7Hh.js} +1 -1
- package/web/assets/{canvasPrefs-ArsX3NFO.js → canvasPrefs-CMulOS0k.js} +1 -1
- package/web/assets/{chatBoxSurface-DRsDr-MT.js → chatBoxSurface-BR_G6cxG.js} +1 -1
- package/web/assets/{chevron-up-ChXNh14u.js → chevron-up-C_EDOZzI.js} +1 -1
- package/web/assets/{client-fKy9CWk0.js → client-DD5czSuF.js} +1 -1
- package/web/assets/{code-xml-DCCD9eCS.js → code-xml-vTB4LtTf.js} +1 -1
- package/web/assets/{codeStudioStore-BgLfCDK2.js → codeStudioStore-OswE1_s0.js} +1 -1
- package/web/assets/{contextMenuSurface-BF593l2M.js → contextMenuSurface-DqdYEGuH.js} +1 -1
- package/web/assets/{copy-plus-ClKrSgM7.js → copy-plus-CVHqDNny.js} +1 -1
- package/web/assets/create-DZWy4zBR.js +14 -0
- package/web/assets/{dashboardSurface-C6cbR3oG.js → dashboardSurface-Co4byEQm.js} +1 -1
- package/web/assets/dbStore-Bc2lC8ZI.js +2 -0
- package/web/assets/deskCapture-BfTzH2aO.js +1 -0
- package/web/assets/{diff2html-Di8qIz6O.js → diff2html-0MkNy2ws.js} +1 -1
- package/web/assets/{docx-preview-B-URZXdP.js → docx-preview-CwNWZegI.js} +1 -1
- package/web/assets/{draft-CBSW5tHx.js → draft-DTzuTatQ.js} +2 -2
- package/web/assets/{drawingStore-CGvTqqYW.js → drawingStore-BD5m2eqn.js} +1 -1
- package/web/assets/{file-down-Z913cCyQ.js → file-down-Cjo_T6By.js} +1 -1
- package/web/assets/{floatingTocSurface-DGwTiqvU.js → floatingTocSurface-D3IIVNnq.js} +1 -1
- package/web/assets/{foldActions-DGIPTmE1.js → foldActions-utwZpRrA.js} +1 -1
- package/web/assets/{folder-1OJQeDI1.js → folder-DiaFWdCg.js} +1 -1
- package/web/assets/{folder-minus-D_j1SwHu.js → folder-minus-DUEOcs12.js} +1 -1
- package/web/assets/{folder-plus-DP9sFr26.js → folder-plus-Cmhq0GcR.js} +1 -1
- package/web/assets/{gestures-ZhFAENNZ.js → gestures-Bx9M0le5.js} +1 -1
- package/web/assets/{git-branch-BMajF2cu.js → git-branch-DzGWffyD.js} +1 -1
- package/web/assets/{homeCardStatus-5R7XkxFL.js → homeCardStatus-NAk4A77P.js} +1 -1
- package/web/assets/{i18n.generated-DW_l6CkR.js → i18n.generated-D4-Wu9Wh.js} +1 -1
- package/web/assets/imageStudio-D67oElIb.js +4 -0
- package/web/assets/{index-COzdD7mZ.js → index-3VWZ1rsL.js} +1 -1
- package/web/assets/{index-bF04pF8q.js → index-58wBjkHy.js} +1 -1
- package/web/assets/{index-Cg1FWM_p.js → index-B9_zH7f5.js} +1 -1
- package/web/assets/index-BQrMYjou.js +1 -0
- package/web/assets/{index-D-ClOPbg.js → index-BWrWMYua.js} +1 -1
- package/web/assets/{index-C--E96Ul.js → index-BdLJBf4-.js} +1 -1
- package/web/assets/{index-CI2esW1X.js → index-Bf3W92Hb.js} +1 -1
- package/web/assets/{index-B8A3nKeL.js → index-BjmPaLFA.js} +1 -1
- package/web/assets/{index-BeW45J9J.js → index-Bv-vJTzF.js} +1 -1
- package/web/assets/{index-BnJguNqI.js → index-C7yb62gg.js} +1 -1
- package/web/assets/{index-CtRdzpNh.js → index-C9gBBMYv.js} +1 -1
- package/web/assets/index-CiQ59Kib.js +1 -0
- package/web/assets/{index-DfhEDV2T.js → index-CzTUjEMt.js} +1 -1
- package/web/assets/{index-BYKR7EVg.js → index-D4Qx6o3E.js} +1 -1
- package/web/assets/{index-jzlU5luC.js → index-DDBcn3UD.js} +1 -1
- package/web/assets/{index-CtCYv9bF.js → index-DEADY94l.js} +1 -1
- package/web/assets/{index-CWXpOSI2.js → index-DGTKsPAQ.js} +1 -1
- package/web/assets/{index-SpegRFQV.js → index-DRwDqvjf.js} +1 -1
- package/web/assets/{index-BDZIQnEx.js → index-DexVkoxH.js} +1 -1
- package/web/assets/{index-uhvJ8AiJ.js → index-IMOhRWY8.js} +1 -1
- package/web/assets/{index-Dr6YmrrT.js → index-XjvpYHIo.js} +1 -1
- package/web/assets/{index-fDB1l4d-.js → index-YuejkHoJ.js} +51 -37
- package/web/assets/{index-CVLDDD5Z.js → index-pH0266gX.js} +1 -1
- package/web/assets/{index-BniT-A2n.js → index-sQl_bGM_.js} +1 -1
- package/web/assets/{index-CPfmhZ3Z.js → index-vbNFy5lS.js} +1 -1
- package/web/assets/{invitePage-iOT1zBvp.js → invitePage-BT_rFfab.js} +1 -1
- package/web/assets/{ipc-SAPDwyQ4.js → ipc-8cxXGSZK.js} +1 -1
- package/web/assets/{jszip.min-B3n1FGCb.js → jszip.min-By4OI3XR.js} +1 -1
- package/web/assets/launchpad-BX4jQyF4.js +2 -0
- package/web/assets/{layout-grid-oIyIGbc5.js → layout-grid-CzxXbCDa.js} +1 -1
- package/web/assets/{linkFollow-uke1Xtit.js → linkFollow-J2c0wSgB.js} +4 -4
- package/web/assets/{listFold-BeNv2v6M.js → listFold-B_2Xqxn_.js} +1 -1
- package/web/assets/{lock-open-D2nMg0ga.js → lock-open-DVWCLSZm.js} +1 -1
- package/web/assets/{log-out-D70NCXC4.js → log-out-CdKTS7HC.js} +1 -1
- package/web/assets/{magnet-Cqmm97W8.js → magnet-BmVcZ9U4.js} +1 -1
- package/web/assets/main-CForzSFD.js +15 -0
- package/web/assets/{markdownEditorSurface-zUzFity2.js → markdownEditorSurface-Bs8FJNHu.js} +1 -1
- package/web/assets/{mediaPlayer-DB4KUvua.js → mediaPlayer-O9pVRl_k.js} +1 -1
- package/web/assets/{message-square-plus-BvUfAAZm.js → message-square-plus-CspBv9iG.js} +1 -1
- package/web/assets/{messages-GQUjmbwW.js → messages-CG7ywZ-K.js} +1 -1
- package/web/assets/{minimize-2-CMhzL6ZW.js → minimize-2-Bq4vUin-.js} +1 -1
- package/web/assets/mobileEntry-CptXQ4Ov.js +13 -0
- package/web/assets/modelPickerSurface-C0SkjaPL.js +1 -0
- package/web/assets/{nativeDownload-DsGyUSJ5.js → nativeDownload-DlnT8U-y.js} +1 -1
- package/web/assets/{nativeSheetMenu--iihXNVd.js → nativeSheetMenu-CVC51DzC.js} +1 -1
- package/web/assets/{pageStore-ys8L4rjF.css → pageStore-BC6Z18n7.css} +1 -1
- package/web/assets/{pageStore-CyvNZEYX.js → pageStore-D_fKLv-o.js} +7 -7
- package/web/assets/{pageTree-Ci2qzrs1.js → pageTree-DtDKozTg.js} +3 -3
- package/web/assets/{pen-line-DC3lbEY1.js → pen-line-ho1GgAe2.js} +1 -1
- package/web/assets/{pen-tool-DD5_N4lZ.js → pen-tool-CV-FKFEZ.js} +1 -1
- package/web/assets/{pencil--sWwxHdP.js → pencil-BgF4Kiqp.js} +1 -1
- package/web/assets/{phoneList-DKRMxQHf.js → phoneList-BLVdQcXY.js} +1 -1
- package/web/assets/pluginChat-C6t6DWhY.js +2 -0
- package/web/assets/{react-b7FrqRQR.js → react-DOzedx9n.js} +1 -1
- package/web/assets/recordSurface-C9SRNjy4.js +1 -0
- package/web/assets/{redo-2-CqlqhWrI.js → redo-2-DWZTaEz-.js} +1 -1
- package/web/assets/{rotate-ccw-D8kni6Ni.js → rotate-ccw-CyZpL7MX.js} +1 -1
- package/web/assets/{selectionActions-DIq0xDm8.js → selectionActions-C2a8ImJm.js} +1 -1
- package/web/assets/selectionBarSurface-DaXlyy1s.js +1 -0
- package/web/assets/{sessionTitle-Ctp4iNKu.js → sessionTitle-BtZ1BteL.js} +1 -1
- package/web/assets/settingsPageSurface-Cg8FNZq3.js +1 -0
- package/web/assets/{sharePage-CY04XCAf.js → sharePage-vnghra3Q.js} +2 -2
- package/web/assets/{shareViewer-DweNF8Ch.js → shareViewer-CWJQHiV-.js} +1 -1
- package/web/assets/{star-B0sZEmbj.js → star-ZEpUQwnX.js} +1 -1
- package/web/assets/tableSurface-DfEdzVDn.js +1 -0
- package/web/assets/{tanguProbe-B8Qv2vcm.js → tanguProbe-BboOas-a.js} +6 -6
- package/web/assets/{terminalView-BLGdmdl7.js → terminalView-xp8ARBLi.js} +1 -1
- package/web/assets/{type-Dt7RNB9g.js → type-CMyP4cKt.js} +1 -1
- package/web/assets/{undo-2-QimgpLBn.js → undo-2-C4ZCsMsx.js} +1 -1
- package/web/assets/{unitAccount-DL3jfd84.js → unitAccount-DNxfGo3c.js} +1 -1
- package/web/assets/{unitBridge-BSsCy1zP.js → unitBridge-Bq0n1ZM6.js} +1 -1
- package/web/assets/{unitCloudTransport-CI_6H0TU.js → unitCloudTransport-CErylgEO.js} +1 -1
- package/web/assets/{unitOwnerAccess-CiQ7nD7E.js → unitOwnerAccess-7s-3dfNM.js} +1 -1
- package/web/assets/{unitShim-Dl2ksNp-.js → unitShim-BfheyIG8.js} +3 -3
- package/web/assets/{upload-Dy7svciS.js → upload-VtCrluEO.js} +1 -1
- package/web/assets/userSpaces-BpeYjLni.js +1 -0
- package/web/assets/viewportLock-cVUalJAI.js +738 -0
- package/web/assets/{zoom-in-DDEtY_Go.js → zoom-in-C7R8s9x-.js} +1 -1
- package/web/index.html +2 -2
- package/web/assets/CalendarSide-B0RVbOsg.js +0 -1
- package/web/assets/CalendarView-BHio-n_r.js +0 -3
- package/web/assets/DashboardGridView-CR-R_qV8.js +0 -25
- package/web/assets/EventCard-QyYorE1_.js +0 -1
- package/web/assets/GitCloneDialog-CbW-RJak.js +0 -1
- package/web/assets/ImageStudioView-4WcX0_V4.js +0 -1
- package/web/assets/InlineFiles-CAIyTk1n.js +0 -1
- package/web/assets/MuseLibraryView-PlS7HAlV.js +0 -2
- package/web/assets/PluginToolCard-DCzLhsCA.js +0 -2
- package/web/assets/TodoListView-BkgMe44I.js +0 -1
- package/web/assets/UnifiedPage-s7-tDSwG.js +0 -712
- package/web/assets/automationListSource-B1jz6q0t.js +0 -1
- package/web/assets/create-DYmVT68X.js +0 -14
- package/web/assets/dbStore-BIG5Mfh2.js +0 -1
- package/web/assets/deskCapture-q-jRDIcc.js +0 -1
- package/web/assets/imageStudio-DC_syDtx.js +0 -4
- package/web/assets/index-CIKPZc3Q.js +0 -1
- package/web/assets/index-CmsN2Zm2.js +0 -1
- package/web/assets/launchpad-CcmSwlJl.js +0 -2
- package/web/assets/main-B9aT0WXG.js +0 -15
- package/web/assets/mobileEntry-BnHzrdoC.js +0 -13
- package/web/assets/modelPickerSurface-Dtz40Ae2.js +0 -1
- package/web/assets/pluginChat-82zZt47Y.js +0 -2
- package/web/assets/recordSurface-vUX25Z8R.js +0 -1
- package/web/assets/selectionBarSurface-B94e5JW_.js +0 -1
- package/web/assets/settingsPageSurface-C9TA3mJg.js +0 -1
- package/web/assets/tableSurface-CSBYBw5P.js +0 -1
- package/web/assets/userSpaces-oMHIWgYe.js +0 -1
- package/web/assets/viewportLock-BZq5PTeN.js +0 -738
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as i}from"./index-fDB1l4d-.js";import{l as I}from"./pageStore-CyvNZEYX.js";import"./client-fKy9CWk0.js";import{a0 as M,k5 as s,u as p,c1 as C,pd as D,l as g,pg as N,ph as $,hb as E,j3 as K,b_ as _,pi as L,i$ as P,kb as U,j2 as x,pj as W}from"./appStore-DDOkzWDA.js";import{n as j}from"./nativeDownload-DsGyUSJ5.js";import"./messages-GQUjmbwW.js";const Q="plugin:automation:rules",d=t=>t?JSON.stringify(t):null,m=()=>I.getState().openView("automation-detail",{},"main"),f=async t=>{try{return await t(),s.getState().bump(),!0}catch(n){return p.getState().toast(String(n instanceof Error?n.message:n),!0),!1}},w=5e3,B=6e4,S=new Set,A=new Map,y=t=>S.has(t)||Date.now()-(A.get(t)??-1/0)<B,X=t=>y(d(t));function v(t,n,u,a){const o=d(t);if(y(o))return;const e=M()==="main";if(!e&&!window.confirm(i("automation.deleteConfirm",{name:n})))return;S.add(o);const r=s.getState();d(r.sel)===o&&r.setSel(null),r.bump();const c=()=>{S.delete(o),s.getState().bump()};let l=!1;const h=()=>{l||(l=!0,f(u).then(O=>{O&&(A.set(o,Date.now()),a?.())}).finally(c))};if(!e){h();return}j({text:i("automation.deleted",{name:n}),level:"info",dedupeKey:`automation.delete:${o}`,receipt:!0,durationMs:w,onClose:h,action:{label:i("automation.undo"),run(){l||(l=!0,c())}}})||setTimeout(h,w)}let k=0,b;function J(t){const n=s.subscribe(t),u=W(t);if(k++===0){const a=()=>{s.getState().refresh(p.getState().cfg)},o=s.subscribe((c,l)=>{c.refreshNonce!==l.refreshNonce&&a()}),e=p.subscribe((c,l)=>{c.cfg!==l.cfg&&a()}),r=setInterval(a,8e3);b=()=>{clearInterval(r),o(),e()},a()}return()=>{n(),u(),--k===0&&(b?.(),b=void 0)}}const T={id:"rules",get title(){return i("space.automation")},search:!0,activeKey:()=>s.getState().builder?null:d(s.getState().sel),subscribe:J,items(t){const n=s.getState(),u=L(),a=t?.query?.trim().toLowerCase(),o=n.triggers.map(e=>({key:d({kind:"trigger",triggerId:e.id}),title:e.desc,icon:"today",category:x(e)?"finished":e.cond.type==="manual"?"buttons":"rules",hint:i(x(e)?"automation.finished":e.enabled?"automation.ux.on":"automation.ux.off"),searchText:`${P(i,e.cond)} ${U(i,u,e)}`}));for(const e of n.schedules)for(const r of e.entries)r.date&&r.prompt&&o.push({key:d({kind:"schedule",slug:e.slug,rowId:r.id}),title:r.name,icon:"calendar",category:"schedules",searchText:e.name,hint:i(r.auto?"automation.ux.on":"automation.ux.off")});for(const e of["muse","historian"])o.push({key:d({kind:e}),title:i(`automation.${e}.title`),icon:e==="muse"?"sparkles":"history",category:"system",hint:i(n.specialCfg?.[e].enabled?"automation.ux.on":"automation.ux.off")});return o.filter(e=>!y(e.key)&&(t?.group?e.category===t.group:a||e.category!=="finished")&&(!a||`${e.title} ${e.searchText||""}`.toLowerCase().includes(a)))},groups:()=>["rules","buttons","schedules","system","finished"].map(t=>({key:t,title:i(t==="rules"?"automation.ux.myWorkflows":t==="finished"?"automation.finished":`automation.group.${t}`),count:T.items({group:t}).length})).filter(t=>t.count>0||t.key==="rules"),open(t){s.getState().setSel(JSON.parse(t.key)),m()},actions:[{id:"new",get label(){return i("automation.new")},run(){s.getState().openBuilder(),m()}},{id:"overview",get label(){return i("automation.ux.overview")},run(){s.getState().setSel(null),m()}}],itemMenu(t){const n=JSON.parse(t.key),u=s.getState();if(p.getState().cfg,n.kind==="trigger"){const o=u.triggers.find(e=>e.id===n.triggerId);return o?[{id:"edit",label:i("common.edit"),run(){u.openBuilder(o.id),m()}},{id:"toggle",label:i(o.enabled?"automation.ux.pause":"automation.ux.enable"),run(){f(()=>D(g(),{...N(o),enabled:!o.enabled,actor:"user"}))}},{id:"delete",label:i("common.delete"),danger:!0,run(){v(n,o.desc,()=>$(g(),o.id))}}]:[]}if(n.kind==="schedule"){const o=u.schedules.find(e=>e.slug===n.slug)?.entries.find(e=>e.id===n.rowId);return o?[{id:"toggle",label:i(o.auto?"automation.ux.pause":"automation.ux.enable"),run(){f(()=>E(g(),n.slug,{id:o.id,name:o.name,date:o.date,repeat:o.repeat,auto:!o.auto,prompt:o.prompt,description:o.description,todo:o.todo}))}},{id:"delete",label:i("common.delete"),danger:!0,run(){v(n,o.name,()=>K(g(),n.slug,o.id))}}]:[]}const a=u.specialCfg?.[n.kind];return a?[{id:"toggle",label:i(a.enabled?"automation.ux.pause":"automation.ux.enable"),run(){f(()=>_(g(),{[n.kind]:{...a,enabled:!a.enabled}}))}}]:[]}};function Y(){C.setState(t=>({listSources:[...t.listSources.filter(n=>!(n.pluginId==="automation"&&n.item.id==="rules")),{pluginId:"automation",item:T}]}))}export{Q as A,T as a,v as d,X as i,Y as r,J as s};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./diff2html-Di8qIz6O.js","./index-fDB1l4d-.js","./appStore-DDOkzWDA.js","./react-b7FrqRQR.js","./pageStore-CyvNZEYX.js","./client-fKy9CWk0.js","./pageStore-ys8L4rjF.css","./ipc-SAPDwyQ4.js","./nativeDownload-DsGyUSJ5.js","./dbStore-BIG5Mfh2.js","./drawingStore-CGvTqqYW.js","./appStore-iy8_Tmac.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as x,_ as D,j as y}from"./index-fDB1l4d-.js";import{Y as N}from"./appStore-DDOkzWDA.js";function F(){const[o,e]=x.useState(()=>document.documentElement.classList.contains("dark"));return x.useEffect(()=>{const t=document.documentElement,n=new MutationObserver(()=>e(t.classList.contains("dark")));return n.observe(t,{attributes:!0,attributeFilter:["class"]}),()=>n.disconnect()},[]),o}const W=({text:o,side:e})=>{const t=F(),[n,i]=x.useState(null),[c,s]=x.useState(!1);return x.useEffect(()=>{let l=!1;return i(null),s(!1),(async()=>{try{const a=await D(()=>import("./diff2html-Di8qIz6O.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]),import.meta.url),f=(a.html||a.default?.html)(o,{outputFormat:e?"side-by-side":"line-by-line",drawFileList:!1,matching:"lines"});l||i(f)}catch{l||s(!0)}})(),()=>{l=!0}},[o,e]),c?y.jsx("pre",{className:"wsfile-diff-raw",children:o}):n==null?y.jsx(N,{size:14,className:"spin",style:{color:"var(--text-faint)",margin:8}}):y.jsx("div",{className:`wsfile-doc wsfile-diff${t?" d2h-dark-color-scheme":""}`,dangerouslySetInnerHTML:{__html:n}})};class S{diff(e,t,n={}){let i;typeof n=="function"?(i=n,n={}):"callback"in n&&(i=n.callback);const c=this.castInput(e,n),s=this.castInput(t,n),l=this.removeEmpty(this.tokenize(c,n)),a=this.removeEmpty(this.tokenize(s,n));return this.diffWithOptionsObj(l,a,n,i)}diffWithOptionsObj(e,t,n,i){var c;const s=r=>{if(r=this.postProcess(r,n),i){setTimeout(function(){i(r)},0);return}else return r},l=t.length,a=e.length;let f=1,u=l+a;n.maxEditLength!=null&&(u=Math.min(u,n.maxEditLength));const L=(c=n.timeout)!==null&&c!==void 0?c:1/0,P=Date.now()+L,m=[{oldPos:-1,lastComponent:void 0}];let w=this.extractCommon(m[0],t,e,0,n);if(m[0].oldPos+1>=a&&w+1>=l)return s(this.buildValues(m[0].lastComponent,t,e));let p=-1/0,v=1/0;const C=()=>{for(let r=Math.max(p,-f);r<=Math.min(v,f);r+=2){let d;const h=m[r-1],g=m[r+1];h&&(m[r-1]=void 0);let k=!1;if(g){const j=g.oldPos-r;k=g&&0<=j&&j<l}const b=h&&h.oldPos+1<a;if(!k&&!b){m[r]=void 0;continue}if(!b||k&&h.oldPos<g.oldPos?d=this.addToPath(g,!0,!1,0,n):d=this.addToPath(h,!1,!0,1,n),w=this.extractCommon(d,t,e,r,n),d.oldPos+1>=a&&w+1>=l)return s(this.buildValues(d.lastComponent,t,e))||!0;m[r]=d,d.oldPos+1>=a&&(v=Math.min(v,r-1)),w+1>=l&&(p=Math.max(p,r+1))}f++};if(i)(function r(){setTimeout(function(){if(f>u||Date.now()>P)return i(void 0);C()||r()},0)})();else for(;f<=u&&Date.now()<=P;){const r=C();if(r)return r}}addToPath(e,t,n,i,c){const s=e.lastComponent;return s&&!c.oneChangePerToken&&s.added===t&&s.removed===n?{oldPos:e.oldPos+i,lastComponent:{count:s.count+1,added:t,removed:n,previousComponent:s.previousComponent}}:{oldPos:e.oldPos+i,lastComponent:{count:1,added:t,removed:n,previousComponent:s}}}extractCommon(e,t,n,i,c){const s=t.length,l=n.length;let a=e.oldPos,f=a-i,u=0;for(;f+1<s&&a+1<l&&this.equals(n[a+1],t[f+1],c);)f++,a++,u++,c.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return u&&!c.oneChangePerToken&&(e.lastComponent={count:u,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=a,f}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){const t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join("")}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){const i=[];let c;for(;e;)i.push(e),c=e.previousComponent,delete e.previousComponent,e=c;i.reverse();const s=i.length;let l=0,a=0,f=0;for(;l<s;l++){const u=i[l];if(u.removed)u.value=this.join(n.slice(f,f+u.count)),f+=u.count;else{if(!u.added&&this.useLongestToken){let L=t.slice(a,a+u.count);L=L.map(function(P,m){const w=n[f+m];return w.length>P.length?w:P}),u.value=this.join(L)}else u.value=this.join(t.slice(a,a+u.count));a+=u.count,u.added||(f+=u.count)}}return i}}class _ extends S{constructor(){super(...arguments),this.tokenize=A}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
3
|
-
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
4
|
-
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
5
|
-
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
6
|
-
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}}const H=new _;function I(o,e,t){return H.diff(o,e,t)}function A(o,e){e.stripTrailingCr&&(o=o.replace(/\r\n/g,`
|
|
7
|
-
`));const t=[],n=o.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(let i=0;i<n.length;i++){const c=n[i];i%2&&!e.newlineIsToken?t[t.length-1]+=c:t.push(c)}return t}const M={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function T(o,e,t,n,i,c,s){let l;s?typeof s=="function"?l={callback:s}:l=s:l={},typeof l.context>"u"&&(l.context=4);const a=l.context;if(l.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(l.callback){const{callback:u}=l;I(t,n,Object.assign(Object.assign({},l),{callback:L=>{const P=f(L);u(P)}}))}else return f(I(t,n,l));function f(u){if(!u)return;u.push({value:"",lines:[]});function L(r){return r.map(function(d){return" "+d})}const P=[];let m=0,w=0,p=[],v=1,C=1;for(let r=0;r<u.length;r++){const d=u[r],h=d.lines||R(d.value);if(d.lines=h,d.added||d.removed){if(!m){const g=u[r-1];m=v,w=C,g&&(p=a>0?L(g.lines.slice(-a)):[],m-=p.length,w-=p.length)}for(const g of h)p.push((d.added?"+":"-")+g);d.added?C+=h.length:v+=h.length}else{if(m)if(h.length<=a*2&&r<u.length-2)for(const g of L(h))p.push(g);else{const g=Math.min(h.length,a);for(const b of L(h.slice(0,g)))p.push(b);const k={oldStart:m,oldLines:v-m+g,newStart:w,newLines:C-w+g,lines:p};P.push(k),m=0,w=0,p=[]}v+=h.length,C+=h.length}}for(const r of P)for(let d=0;d<r.lines.length;d++)r.lines[d].endsWith(`
|
|
8
|
-
`)?r.lines[d]=r.lines[d].slice(0,-1):(r.lines.splice(d+1,0,"\"),d++);return{oldFileName:o,newFileName:e,oldHeader:i,newHeader:c,hunks:P}}}function E(o,e){if(e||(e=M),Array.isArray(o)){if(o.length>1&&!e.includeFileHeaders)throw new Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");return o.map(n=>E(n,e)).join(`
|
|
9
|
-
`)}const t=[];e.includeIndex&&o.oldFileName==o.newFileName&&t.push("Index: "+o.oldFileName),e.includeUnderline&&t.push("==================================================================="),e.includeFileHeaders&&(t.push("--- "+o.oldFileName+(typeof o.oldHeader>"u"?"":" "+o.oldHeader)),t.push("+++ "+o.newFileName+(typeof o.newHeader>"u"?"":" "+o.newHeader)));for(let n=0;n<o.hunks.length;n++){const i=o.hunks[n];i.oldLines===0&&(i.oldStart-=1),i.newLines===0&&(i.newStart-=1),t.push("@@ -"+i.oldStart+","+i.oldLines+" +"+i.newStart+","+i.newLines+" @@");for(const c of i.lines)t.push(c)}return t.join(`
|
|
10
|
-
`)+`
|
|
11
|
-
`}function V(o,e,t,n,i,c,s){if(typeof s=="function"&&(s={callback:s}),s?.callback){const{callback:l}=s;T(o,e,t,n,i,c,Object.assign(Object.assign({},s),{callback:a=>{l(a?E(a,s.headerOptions):void 0)}}))}else{const l=T(o,e,t,n,i,c,s);return l?E(l,s?.headerOptions):void 0}}function R(o){const e=o.endsWith(`
|
|
12
|
-
`),t=o.split(`
|
|
13
|
-
`).map(n=>n+`
|
|
14
|
-
`);return e?t.pop():t.push(t.pop().slice(0,-1)),t}export{W as D,S as a,V as c,F as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aE as p,u as A,bc as E}from"./pageStore-CyvNZEYX.js";import{c as M}from"./react-b7FrqRQR.js";const P="updated",_=(t=new Date)=>{const n=e=>String(e).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`};function j(t,n,e){if(t.cells===n.cells)return!1;const a=o=>{const s=Object.keys(o.cells).filter(i=>!e.has(i)&&o.cells[i]!=null).sort();return JSON.stringify(s.map(i=>[i,o.cells[i]]))};return a(t)!==a(n)}function $(t,n,e=new Date){const a=n.columns.filter(u=>u.type===P).map(u=>u.id);if(!a.length||t.rows===n.rows)return n;const o=new Set(a),s=new Map(t.rows.map(u=>[u.id,u])),i=_(e);let r=!1;const g=n.rows.map(u=>{const m=s.get(u.id);if(!m||m.body===u.body&&!j(m,u,o))return u;r=!0;const b={...u.cells};for(const O of a)b[O]=i;return{...u,cells:b}});return r?{...n,rows:g}:n}let y=null,w=null;function F(t){y=t}function C(){!y||w||(w=setTimeout(()=>{w=null,y?.()},1500))}const d=new Map,R=500,c=new Map,f=new Map;function k(t,n){const e=c.get(t);if(!e)return;const a=e.slice(n.length);a.length?c.set(t,a):c.delete(t)}const Y=3;function v(t,n){return n.reduce((e,a)=>a(e),t)}function D(t){const n=f.get(t);if(n)return n;const e=T(t,0).finally(()=>{f.get(t)===e&&f.delete(t)});return f.set(t,e),e}async function T(t,n,e=l.getState().gen){if(e!==l.getState().gen)return;const a=l.getState().entries[t];if(!a||a.status!=="ok"||!a.path||!a.data)return;const o=[...c.get(t)??[]];try{if(!p.writeDatabaseCas||!a.version){if(await p.writeDatabase(a.path,a.data),e!==l.getState().gen)return;k(t,o);return}const s=await p.writeDatabaseCas(a.path,a.data,a.version);if(e!==l.getState().gen)return;if(s.ok){k(t,o),S(t,r=>({...r,version:s.version})),C(),c.get(t)?.length&&h(t);return}if(n>=Y){h(t);return}if(await l.getState().reload(a.path,t),e!==l.getState().gen)return;const i=l.getState().entries[t];if(!i||i.status!=="ok"||!i.data)return;S(t,r=>({...r,data:v(i.data,c.get(t)??[])})),await T(t,n+1,e)}catch{e===l.getState().gen&&h(t)}}function h(t){const n=d.get(t);n&&clearTimeout(n),d.set(t,setTimeout(()=>{d.delete(t),D(t)},R))}function S(t,n){l.setState(e=>{const a=e.entries[t];return a?{entries:{...e.entries,[t]:n(a)}}:e})}const l=M((t,n)=>({entries:{},gen:0,async load(e,a){const o=n().entries[a];o&&o.status!=="missing"||await n().reload(e,a)},async reload(e,a){const o=n().gen;t(s=>({entries:{...s.entries,[a]:{status:"loading",path:null,data:null}}}));try{const s=await p.readDatabase(e,a);if(o!==n().gen)return;const i=s.status==="ok"?{status:"ok",path:s.path,data:s.data,version:s.version}:s.status==="corrupt"?{status:"corrupt",path:s.path,data:null,message:s.message}:{status:"missing",path:null,data:null};t(r=>({entries:{...r.entries,[a]:i}}))}catch{if(o!==n().gen)return;t(s=>({entries:{...s.entries,[a]:{status:"missing",path:null,data:null}}}))}},async reloadByPath(e){const a=n().gen,o=Object.entries(n().entries).filter(([,s])=>s.path===e).map(([s])=>s);await Promise.all(o.map(async s=>{if(await n().reload(e,s),a!==n().gen)return;const i=c.get(s),r=n().entries[s];i?.length&&r?.status==="ok"&&r.data&&S(s,g=>({...g,data:v(r.data,i)}))}))},mutate(e,a){const o=n().entries[e];if(!o||o.status!=="ok"||!o.data)return;const s=r=>$(r,a(r)),i=s(o.data);c.set(e,[...c.get(e)??[],s]),t(r=>({entries:{...r.entries,[e]:{...o,data:i}}})),h(e)},async flushAll(e=!1){const a=[...new Set([...d.keys(),...c.keys(),...f.keys()])];for(const o of d.values())clearTimeout(o);if(d.clear(),await Promise.all(a.map(o=>D(o))),e&&c.size)throw new Error(`Database changes could not be saved: ${[...c.keys()].join(", ")}`)},dropByPath(e){const a=Object.entries(n().entries).filter(([,o])=>o.path===e).map(([o])=>o);if(a.length){for(const o of a){const s=d.get(o);s&&clearTimeout(s),d.delete(o),c.delete(o)}t(o=>{const s={...o.entries};for(const i of a)delete s[i];return{entries:s}})}}}));A.subscribe((t,n)=>{t.vaultRoot!==n.vaultRoot&&l.setState(e=>({entries:{},gen:e.gen+1}))});l.subscribe((t,n)=>{if(t.gen!==n.gen){for(const e of d.values())clearTimeout(e);d.clear(),c.clear(),f.clear()}});E((t,n,e)=>{const a=s=>!!s&&(n==="file"?s===t:s===t||s.startsWith(`${t}/`)),o=Object.keys(l.getState().entries).filter(s=>a(l.getState().entries[s].path));if(o.length){if(!e)for(const s of o)clearTimeout(d.get(s)),d.delete(s),c.delete(s);l.setState(s=>{const i={...s.entries};for(const r of o){const g=i[r];i[r]=e?{...g,path:n==="file"?e:e+g.path.slice(t.length)}:{status:"missing",path:null,data:null}}return{entries:i}})}});typeof window<"u"&&window.addEventListener("beforeunload",()=>{l.getState().flushAll()});typeof window<"u"&&window.amadeus&&p.onDbExternalChange?.(t=>{l.getState().reloadByPath(t)});const L=Object.freeze(Object.defineProperty({__proto__:null,useDbStore:l},Symbol.toStringTag,{value:"Module"}));export{L as d,C as k,F as s,l as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{kY as d,bw as u}from"./appStore-DDOkzWDA.js";import"./index-fDB1l4d-.js";import"./react-b7FrqRQR.js";import"./pageStore-CyvNZEYX.js";import"./client-fKy9CWk0.js";import"./ipc-SAPDwyQ4.js";import"./nativeDownload-DsGyUSJ5.js";import"./dbStore-BIG5Mfh2.js";import"./drawingStore-CGvTqqYW.js";const m=400,p=1500;function l(a,n=document){const t=(e,o,r)=>{for(const s of Array.from(n.querySelectorAll(e))){if(s.dataset.deskSession!==a)continue;const i=s.querySelector(o);if(!i)continue;const c=i.querySelector(".agent-desk-companion");return{el:i,mode:r,companion:c?c.querySelector("[data-companion]")?.dataset.companion||"plugin":null}}return null};return t(".agent-desk.open",".agent-desk-body","open")||t(".agent-desk-card:not(.gone)",".agent-desk-card-body","card")}function f(a,n,t){const e=a.getBoundingClientRect(),o=Math.max(0,Math.floor(e.left)),r=Math.max(0,Math.floor(e.top)),s=Math.floor(Math.min(e.right,n)-o),i=Math.floor(Math.min(e.bottom,t)-r);return s>=16&&i>=16?{x:o,y:r,width:s,height:i}:null}async function h(a){const n=window.tangu?.captureRect;if(!n)return{error:"screenshots need the Forsion desktop app"};await new Promise(r=>setTimeout(r,m));const t=l(a);if(!t)return await new Promise(r=>setTimeout(r,p)),{error:"the Agent Desk panel is not on screen (turned off, hidden, or the window is too narrow)"};const e=f(t.el,window.innerWidth,window.innerHeight);if(!e)return{error:"the Agent Desk panel is too small / scrolled out of view"};const o=await n(e);return o?t.companion?{dataUrl:o,mode:t.mode,companion:t.companion}:{dataUrl:o,mode:t.mode}:{error:"the screenshot failed"}}async function A(a,n,t){let e;try{e=await h(n)}catch(o){e={error:String(o?.message||o)}}await d(u(n),a,t,e)}export{A as answerDeskCapture,h as captureDesk,f as deskRect,l as findDeskTarget};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{t as p,r as k,j as $,_ as pe}from"./index-fDB1l4d-.js";import{l4 as me,l5 as we,u as j,iy as ye,iz as xe,l7 as Se,l as ve}from"./appStore-DDOkzWDA.js";import{targetFor as Ie}from"./InlineFiles-CAIyTk1n.js";import{c as be}from"./react-b7FrqRQR.js";import{c_ as Y,l as S,f as $e}from"./pageStore-CyvNZEYX.js";import"./client-fKy9CWk0.js";const L=new Set(["image/png","image/jpeg","image/webp","image/gif"]),_=20*1024*1024;function Z(e){return{version:2,id:crypto.randomUUID(),name:e,updatedAt:Date.now(),sessionId:null,images:[],elements:[],order:[],collected:[]}}function it(e,s){return e.images.filter(t=>!t.hidden).sort((t,r)=>t.x-r.x||t.y-r.y).slice(0,s)}function Me(e,s,t){const r=Math.min(1,360/Math.max(e,s));return{x:t.length?Math.max(...t.map(n=>n.x+n.w))+32:0,y:0,w:e*r,h:s*r}}function Ee(e){const s=new Map;let t="";for(const r of e){r.role==="user"&&(t=r.content);for(const[n,o]of(r.displayFiles||[]).entries()){if(!L.has(o.mime||"")&&!/\.(png|jpe?g|webp|gif)$/i.test(o.name)||!o.path&&!o.dataUrl)continue;const a=o.path?`${o.sourceSessionId||""}:${o.path}`:`${r.id}:${n}:${o.name}`;s.set(a,{key:a,file:o,prompt:t})}}return[...s.values()]}function ct(e){const s=Math.max(1,Math.ceil(Math.sqrt(e.length)));return e.map((t,r)=>{const n=b(t),o=300/Math.max(n.w,n.h);return{...t,x:r%s*340,y:Math.floor(r/s)*360,w:n.w*o,h:n.h*o}})}function ee(e){return`brightness(${e.brightness}%) contrast(${e.contrast}%) saturate(${e.saturation}%)`}function te(e){const s=e;if(!s||s.version!==1&&s.version!==2||typeof s.id!="string"||typeof s.name!="string"||!((s.sessionId===null||typeof s.sessionId=="string")&&Number.isFinite(s.updatedAt)&&Array.isArray(s.collected)&&s.collected.every(n=>typeof n=="string")&&Array.isArray(s.images)&&s.images.every(n=>ne(n)&&n.blob instanceof Blob&&L.has(n.blob.type)&&n.blob.size<=_&&[n.x,n.y,n.w,n.h,n.width,n.height,n.brightness,n.contrast,n.saturation].every(Number.isFinite)&&n.w>0&&n.h>0&&n.width>0&&n.height>0&&[n.brightness,n.contrast,n.saturation].every(o=>o>=0&&o<=200)&&(n.crop===void 0||ke(n.crop,n.width,n.height))&&(n.rotation===void 0||Number.isFinite(n.rotation)&&n.rotation>=0&&n.rotation<360)&&(n.parentId===void 0||typeof n.parentId=="string")&&[n.flipX,n.flipY].every(o=>o===void 0||typeof o=="boolean"))&&(s.elements===void 0||Array.isArray(s.elements)&&s.elements.every(Ae))&&(s.order===void 0||Array.isArray(s.order)&&s.order.every(n=>typeof n=="string"))))return!1;const r=[...s.images,...s.elements||[]].map(n=>n.id);return new Set(r).size===r.length}const v=e=>"blob"in e&&e.blob instanceof Blob,I=e=>!v(e)&&e.kind==="frame",ne=e=>!!e&&typeof e.id=="string"&&typeof e.name=="string"&&[e.x,e.y,e.w,e.h].every(s=>Number.isFinite(s)&&Math.abs(s)<=1e6)&&e.w>0&&e.h>0&&[e.locked,e.hidden].every(s=>s===void 0||typeof s=="boolean"),ke=(e,s,t)=>!!e&&[e.x,e.y,e.w,e.h].every(Number.isFinite)&&e.x>=0&&e.y>=0&&e.w>=1&&e.h>=1&&e.x+e.w<=s&&e.y+e.h<=t;function Ae(e){return ne(e)&&!("blob"in e)&&["text","rectangle","ellipse","frame"].includes(e.kind)&&[e.fill,e.stroke].every(s=>typeof s=="string"&&/^(#[\da-f]{6}|transparent)$/i.test(s))&&[e.strokeWidth,e.radius,e.fontSize].every(Number.isFinite)&&e.strokeWidth>=0&&e.strokeWidth<=100&&e.radius>=0&&e.radius<=1e3&&e.fontSize>=6&&e.fontSize<=500&&typeof e.text=="string"&&e.text.length<=1e4&&["sans-serif","serif","monospace"].includes(e.fontFamily)&&typeof e.bold=="boolean"&&["left","center","right"].includes(e.align)}function b(e){const s=e.crop||{w:e.width,h:e.height},t=(e.rotation||0)*Math.PI/180;return{w:Math.round((Math.abs(s.w*Math.cos(t))+Math.abs(s.h*Math.sin(t)))*1e8)/1e8,h:Math.round((Math.abs(s.w*Math.sin(t))+Math.abs(s.h*Math.cos(t)))*1e8)/1e8}}function lt(e,s){const t={...e,...s},r=b(t),n=b(e),o=e.w/n.w,a=r.w*o,i=r.h*o;return{...t,x:e.x+(e.w-a)/2,y:e.y+(e.h-i)/2,w:a,h:i}}function y(e){const s=[...e.images,...e.elements||[]],t=new Map((e.order||[]).map((r,n)=>[r,n]));return s.sort((r,n)=>Number(I(n))-Number(I(r))||(t.get(r.id)??1e9)-(t.get(n.id)??1e9))}function T(e,s){return{...e,version:2,images:s.filter(v),elements:s.filter(t=>!v(t)),order:s.map(t=>t.id)}}function Te(e,s){return T(e,y(e).map(s))}const se=(e,s)=>s.x>=e.x&&s.y>=e.y&&s.x+s.w<=e.x+e.w+.01&&s.y+s.h<=e.y+e.h+.01;function Ue(e,s){const t=y(e),r=new Map(s);for(const n of t.filter(I)){const o=s.get(n.id);if(!(!o||n.locked||o.x===n.x&&o.y===n.y))for(const a of t)!I(a)&&!a.locked&&!r.has(a.id)&&se(n,a)&&r.set(a.id,{...a,x:a.x+o.x-n.x,y:a.y+o.y-n.y})}return Te(e,n=>n.locked||!r.has(n.id)?n:{...n,...r.get(n.id)})}function dt(e,s,t=0,r=0){return{id:crypto.randomUUID(),kind:e,name:s,x:t,y:r,w:e==="frame"?1080:320,h:e==="frame"?1080:e==="text"?120:240,fill:e==="frame"?"#ffffff":e==="text"?"#242424":"#c9c4b8",stroke:"#242424",strokeWidth:0,radius:0,text:e==="text"?s:"",fontSize:40,fontFamily:"sans-serif",bold:!1,align:"left"}}function je(e,s=32,t=32){return e.map(r=>({...r,id:crypto.randomUUID(),locked:!1,x:r.x+s,y:r.y+t}))}function ut(e,s,t){const r=y(e),n=new Set(s);if(t==="front"||t==="back"){const a=r.filter(c=>n.has(c.id)),i=r.filter(c=>!n.has(c.id));return T(e,t==="front"?[...i,...a]:[...a,...i])}const o=t==="up"?1:-1;for(let a=o===1?r.length-2:1;a>=0&&a<r.length;a-=o)n.has(r[a].id)&&r[a+o]&&!n.has(r[a+o].id)&&([r[a],r[a+o]]=[r[a+o],r[a]]);return T(e,r)}const Pe=["1:1","4:5","5:4","2:3","3:2","16:9","9:16"],Le=["1:1","2:3","3:2","16:9","9:16"],A=e=>{const[s,t]=e.split(":").map(Number);return s>0&&t>0?s/t:1};function _e(e,s){const t=e>0&&s>0?e/s:1,r=Pe.find(n=>Math.abs(Math.log(A(n)/t))<.012);return r||(t>=1?`${Number(t.toFixed(2))}:1`:`1:${Number((1/t).toFixed(2))}`)}function ft(e,s){const t=b(e),r=_e(t.w,t.h),n=s==="original"?r:s,o=s==="original"?t.w/t.h:A(n),a=Le.reduce((i,c)=>Math.abs(Math.log(A(c)/o))<Math.abs(Math.log(A(i)/o))?c:i);return{aspect:o,requested:n,engine:a,originalLabel:r}}function Be(e,s,t){if(!(e>0&&s>0&&t>0))return;const r=e/s;if(Math.abs(Math.log(r/t))<.001)return;if(r>t){const o=s*t;return{x:(e-o)/2,y:0,w:o,h:s}}const n=e/t;return{x:0,y:(s-n)/2,w:e,h:n}}function ze(e,s,t=[]){const r=new Set(s.sourceIds||[]),n=e.images.filter(d=>r.has(d.id)),o=[...y(e),...t],a=n.length?Math.min(360,Math.max(n[0].w,n[0].h)):320,i=Math.max(.2,Math.min(5,s.aspect||1)),c=i>=1?a:a*i,u=i>=1?a/i:a,l=n.length?Math.max(...n.map(d=>d.x+d.w)):o.length?Math.max(...o.map(d=>d.x+d.w)):-32,f=n.length?Math.min(...n.map(d=>d.y)):0;return Array.from({length:Math.max(1,Math.min(4,Math.round(s.count)||1))},(d,h)=>({x:l+32+h*(c+32),y:f,w:c,h:u}))}function Re(e,s){if(e!=="generate_image"&&e!=="edit_image")return null;let t={};try{t=s?JSON.parse(s):{}}catch{}const r=typeof t.size=="string"&&/^\d+(?:\.\d+)?:\d+(?:\.\d+)?$/.test(t.size)?t.size:"1:1",n=Number.isInteger(t.n)?Number(t.n):1;return{count:Math.max(1,Math.min(4,n)),aspect:A(r),ratio:r,kind:e==="edit_image"?"edit":"generate"}}let z;function re(){return z??=new Promise((e,s)=>{const t=indexedDB.open("forsion-image-studio",1);t.onupgradeneeded=()=>t.result.createObjectStore("boards",{keyPath:"id"}),t.onsuccess=()=>e(t.result),t.onerror=()=>{z=void 0,s(t.error)},t.onblocked=()=>{z=void 0,s(new Error("Image Studio storage is blocked by another window"))}})}async function Oe(){const e=await re();return new Promise((s,t)=>{const r=e.transaction("boards").objectStore("boards").getAll();r.onsuccess=()=>{if(!r.result.every(te)){t(new Error("Image Studio contains an unreadable project"));return}s(r.result)},r.onerror=()=>t(r.error)})}async function De(e){const s=await re();return new Promise((t,r)=>{const n=s.transaction("boards","readwrite");n.objectStore("boards").put(e),n.oncomplete=()=>t(),n.onerror=()=>r(n.error),n.onabort=()=>r(n.error||new Error("Image Studio save was interrupted"))})}let K,F,Ne=0;const E=new Set;let M;function R(e){E.add(e),g.setState({saving:!0}),clearTimeout(F),F=setTimeout(()=>{g.getState().flush()},250)}const g=be((e,s)=>({boards:{},activeId:null,ready:!1,error:"",saving:!1,selection:[],past:{},future:{},placeholders:{},generationTools:{},pending:null,hydrate:()=>K??=(async()=>{try{const t=await Oe();let r=null;try{r=localStorage.getItem("image-studio.active")}catch{}e({boards:Object.fromEntries(t.map(n=>[n.id,n])),activeId:t.find(n=>n.id===r)?.id||null,ready:!0,error:""})}catch(t){e({error:String(t),ready:!1}),K=void 0}})(),create:t=>{if(!s().ready)return"";const r=Z(t);return e(n=>({boards:{...n.boards,[r.id]:r}})),s().open(r.id),R(r.id),r.id},open:t=>{if(s().boards[t]){e({activeId:t,selection:[],pending:null});try{localStorage.setItem("image-studio.active",t)}catch{}}},close:()=>{if(s().activeId){e({activeId:null,selection:[],pending:null});try{localStorage.removeItem("image-studio.active")}catch{}}},update:(t,r,n=!0)=>{const o=s().boards[t];if(!o)return;const a=r(o);a!==o&&(e(i=>({boards:{...i.boards,[t]:{...a,updatedAt:Date.now()}},...n?{past:{...i.past,[t]:[...(i.past[t]||[]).slice(-29),o]},future:{...i.future,[t]:[]}}:{}})),R(t))},undo:(t,r=!1)=>{const n=r?"future":"past",o=r?"past":"future",a=s()[n][t]||[],i=s().boards[t],c=a.at(-1);!i||!c||(e(u=>({boards:{...u.boards,[t]:{...c,sessionId:i.sessionId,collected:i.collected,updatedAt:Date.now()}},[n]:{...u[n],[t]:a.slice(0,-1)},[o]:{...u[o],[t]:[...u[o][t]||[],i]},selection:[]})),R(t))},flush:async()=>{if(clearTimeout(F),M)return M;M=(async()=>{try{for(;E.size;){const t=E.values().next().value,r=s().boards[t];E.delete(t);try{r&&await De(r)}catch(n){throw E.add(t),n}}e({saving:!1,error:""})}catch(t){e({saving:!1,error:String(t)})}})();try{await M}finally{M=void 0}},queue:(t,r,n=[])=>e(o=>({pending:{sessionId:t,text:o.pending?.sessionId===t?`${o.pending.text}
|
|
2
|
-
|
|
3
|
-
${r}`:r,attachments:[...o.pending?.sessionId===t?o.pending.attachments:[],...n],seq:++Ne}})),consume:t=>s().pending?.seq!==t?!1:(e({pending:null}),!0),beginGeneration:(t,r,n)=>{const o=s().boards[t];if(!o)return[];const a=s().placeholders[t]||[],i=ze(o,n,a),c=crypto.randomUUID(),u=Date.now(),l=i.map((f,d)=>({...f,id:crypto.randomUUID(),generationId:c,boardId:t,sessionId:r,sourceIds:n.sourceIds||[],kind:n.kind,status:"preparing",aspect:n.aspect,ratio:n.ratio,index:d,count:i.length,createdAt:u}));return e(f=>({placeholders:{...f.placeholders,[t]:[...f.placeholders[t]||[],...l]}})),l.map(f=>f.id)},activateGeneration:t=>{const r=new Set(t);e(n=>({placeholders:Object.fromEntries(Object.entries(n.placeholders).map(([o,a])=>[o,a.map(i=>r.has(i.id)&&i.status==="preparing"?{...i,status:"running"}:i)]))}))},bindGenerationTool:(t,r,n,o)=>{if((s().generationTools[t]||[]).includes(n))return;e(l=>({generationTools:{...l.generationTools,[t]:[...(l.generationTools[t]||[]).slice(-199),n]}}));const i=(s().placeholders[t]||[]).find(l=>l.sessionId===r&&!l.toolId&&l.status!=="failed");if(i){e(l=>({placeholders:{...l.placeholders,[t]:(l.placeholders[t]||[]).map(f=>f.generationId===i.generationId?{...f,toolId:n,status:"running"}:f)}}));return}const c=s().beginGeneration(t,r,o),u=new Set(c);e(l=>({placeholders:{...l.placeholders,[t]:(l.placeholders[t]||[]).map(f=>u.has(f.id)?{...f,toolId:n,status:"running"}:f)}}))},failGeneration:(t,r)=>{const n=r.ids?new Set(r.ids):null;e(o=>({placeholders:{...o.placeholders,[t]:(o.placeholders[t]||[]).map(a=>(!n||n.has(a.id))&&(!r.sessionId||a.sessionId===r.sessionId)&&(!r.toolId||a.toolId===r.toolId)?{...a,status:"failed"}:a)}}))},takeGeneration:(t,r)=>{const o=(s().placeholders[t]||[]).filter(a=>a.sessionId===r&&a.status!=="failed").sort((a,i)=>a.createdAt-i.createdAt||a.index-i.index)[0];if(o)return e(a=>({placeholders:{...a.placeholders,[t]:(a.placeholders[t]||[]).filter(i=>i.id!==o.id)}})),o},removeGeneration:(t,r)=>e(n=>({placeholders:{...n.placeholders,[t]:(n.placeholders[t]||[]).filter(o=>o.id!==r)}}))}));me({claim:({card:e,sessionId:s})=>{const t=g.getState().pending;return!t||t.sessionId!==s||!e.closest("[data-image-studio-chat]")||!e.getClientRects().length||!g.getState().consume(t.seq)?null:{texts:[t.text],attachments:t.attachments}}});g.subscribe((e,s)=>{e.pending!==s.pending&&we()});const oe=e=>e.replace(/[<>&"']/g,s=>({"<":"<",">":">","&":"&",'"':""","'":"'"})[s]),Fe=e=>`${e.bold?"700":"400"} ${e.fontSize}px ${e.fontFamily}`;function Ce(e){const s=document.createElement("canvas").getContext("2d");s.font=Fe(e);const t=[];for(const r of e.text.split(`
|
|
4
|
-
`)){let n="";for(const o of Array.from(r))n&&s.measureText(n+o).width>e.w&&(t.push(n),n=""),n+=o;t.push(n)}return t}function ae(e){const{w:s,h:t,fill:r,stroke:n,strokeWidth:o}=e,a=`fill="${r}" stroke="${n}" stroke-width="${o}"`;if(e.kind==="ellipse")return`<ellipse cx="${s/2}" cy="${t/2}" rx="${Math.max(0,(s-o)/2)}" ry="${Math.max(0,(t-o)/2)}" ${a}/>`;if(e.kind!=="text")return`<rect x="${o/2}" y="${o/2}" width="${Math.max(0,s-o)}" height="${Math.max(0,t-o)}" rx="${e.radius}" ${a}/>`;const i=e.align==="center"?s/2:e.align==="right"?s:0,c=e.align==="center"?"middle":e.align==="right"?"end":"start";return`<text fill="${r}" font-family="${e.fontFamily}" font-size="${e.fontSize}" font-weight="${e.bold?700:400}" text-anchor="${c}" xml:space="preserve">${Ce(e).map((u,l)=>`<tspan x="${i}" y="${e.fontSize+l*e.fontSize*1.25}">${oe(u)}</tspan>`).join("")}</text>`}function Ge(e,s){const t=y(e).filter(a=>!a.hidden),r=t.filter(a=>s.includes(a.id));if(r.length===1&&I(r[0])){const a=r[0];return{bounds:a,items:[a,...t.filter(i=>!I(i)&&i.x<a.x+a.w&&i.x+i.w>a.x&&i.y<a.y+a.h&&i.y+i.h>a.y)]}}const n=s.length?r:t,o=Y(n);return o?{items:n,bounds:o}:null}function ht(e,s,t){const r=y(e),n=r.filter(i=>s.includes(i.id)&&!i.locked),o=Y(n);if(!o||n.length<2)return e;const a=new Map(n.map(i=>[i.id,{...i,x:t==="left"?o.x:t==="center"?o.x+(o.w-i.w)/2:t==="right"?o.x+o.w-i.w:i.x,y:t==="top"?o.y:t==="middle"?o.y+(o.h-i.h)/2:t==="bottom"?o.y+o.h-i.h:i.y}]));return Ue(e,a)}const gt=e=>v(e)?"image":e.kind;async function V(e){if(!L.has(e.type)||e.size>_)throw new Error(p("imageStudio.importLimit"));const s=await createImageBitmap(e);if(s.width*s.height>4e7)throw s.close(),new Error(p("imageStudio.tooLarge"));return s}async function q(e,s,t){if(!L.has(e.type)||e.size>_)throw new Error(p("imageStudio.importLimit"));e=new Blob([await e.arrayBuffer()],{type:e.type});const r=await V(e),n={id:crypto.randomUUID(),name:s,blob:e,width:r.width,height:r.height,x:0,y:0,w:0,h:0,source:t,brightness:100,contrast:100,saturation:100};return r.close(),n}function B(e){return new Promise((s,t)=>{const r=new FileReader;r.onload=()=>s(String(r.result)),r.onerror=()=>t(r.error),r.readAsDataURL(e)})}async function C(e,s="current"){const t=s==="original"?{...e,crop:void 0,rotation:0,flipX:!1,flipY:!1,brightness:100,contrast:100,saturation:100}:e,r=await W([t],!0,1536);if(r.size>59e5)throw new Error(p("imageStudio.referenceBytes"));const n=await B(r);return{name:e.name.replace(/\.[^.]+$/,"")+".png",mimeType:"image/png",data:n.split(",")[1],size:r.size}}function ie(e,s){const t=URL.createObjectURL(e),r=document.createElement("a");r.href=t,r.download=s,r.click(),setTimeout(()=>URL.revokeObjectURL(t),3e4)}async function W(e,s=!1,t){const r=s&&e.length===1?[{...e[0],x:0,y:0,...b(e[0])}]:e,n=Y(r);if(!n)throw new Error(p("imageStudio.select"));const o=t?Math.min(1,t/Math.max(n.w,n.h)):1,a=Math.ceil(n.w*o),i=Math.ceil(n.h*o);if(a*i>4e7||Math.max(a,i)>16384)throw new Error(p("imageStudio.exportLimit"));const c=document.createElement("canvas");c.width=a,c.height=i;const u=c.getContext("2d");if(!u)throw new Error("Canvas unavailable");for(const l of r){const f=await V(l.blob),d=l.crop||{x:0,y:0,w:l.width,h:l.height},h=b(l);u.save(),u.filter=ee(l),u.translate((l.x-n.x+l.w/2)*o,(l.y-n.y+l.h/2)*o),u.scale(l.w*o/h.w,l.h*o/h.h),u.rotate((l.rotation||0)*Math.PI/180),u.scale(l.flipX?-1:1,l.flipY?-1:1),u.drawImage(f,d.x,d.y,d.w,d.h,-d.w/2,-d.h/2,d.w,d.h),u.restore(),f.close()}return new Promise((l,f)=>c.toBlob(d=>d?l(d):f(new Error("PNG export failed")),"image/png"))}async function Ye(e){const s=await Promise.all(e.images.map(async({blob:t,...r})=>({...r,dataUrl:await B(t)})));ie(new Blob([JSON.stringify({...e,version:2,images:s,sessionId:null,collected:[]})],{type:"application/json"}),`${e.name}.forsion-image.json`)}async function Ve(e){if(e.size>128*1024*1024)throw new Error(p("imageStudio.tooLarge"));const s=JSON.parse(await e.text());if(!s||![1,2].includes(s.version)||!Array.isArray(s.images)||s.images.length>200||s.elements!==void 0&&(!Array.isArray(s.elements)||s.elements.length>500))throw new Error("Unsupported Image Studio project");const t=await Promise.all(s.images.map(async n=>{if(typeof n.dataUrl!="string"||!/^data:image\/(png|jpeg|webp|gif);base64,/.test(n.dataUrl))throw new Error("Invalid image data");const[o,a]=n.dataUrl.split(",");if(a.length>_*1.4)throw new Error(p("imageStudio.importLimit"));const i=atob(a),c=new Blob([Uint8Array.from(i,l=>l.charCodeAt(0))],{type:o.slice(5,-7)});return{...await q(c,String(n.name||""),"import"),id:n.id,source:n.source==="generated"?"generated":"import",parentId:typeof n.parentId=="string"?n.parentId:void 0,prompt:typeof n.prompt=="string"?n.prompt:void 0,x:n.x,y:n.y,w:n.w,h:n.h,brightness:n.brightness,contrast:n.contrast,saturation:n.saturation,crop:n.crop,rotation:n.rotation,flipX:n.flipX,flipY:n.flipY,locked:n.locked,hidden:n.hidden}})),r={...Z(String(s.name||p("imageStudio.untitled"))),images:t,elements:s.elements||[],order:s.order||[]};if(!te(r))throw new Error("Invalid Image Studio project");return r}function ce(e,s){const t=Ge(e,s);if(t?.items.length===1&&v(t.items[0])){const r={...t.items[0],x:0,y:0,...b(t.items[0])};return{items:[r],bounds:r}}return t}async function le(e,s,t){const r=ce(e,s);if(!r)throw new Error(p("imageStudio.select"));const{bounds:n,items:o}=r,a=Math.round(n.w*t.scale),i=Math.round(n.h*t.scale);if(a<1||i<1||a*i>4e7||Math.max(a,i)>16384)throw new Error(p("imageStudio.exportLimit"));const c=t.format==="jpeg"&&t.background==="transparent"?"#ffffff":t.background;if(!/^(#[\da-f]{6}|transparent)$/i.test(c))throw new Error("Invalid background");const u=[];c!=="transparent"&&u.push(`<rect x="${n.x}" y="${n.y}" width="${n.w}" height="${n.h}" fill="${c}"/>`);for(const h of o)if(v(h)){const w=await B(await W([h],!0));u.push(`<image x="${h.x}" y="${h.y}" width="${h.w}" height="${h.h}" preserveAspectRatio="none" href="${w}"/>`)}else u.push(`<svg x="${h.x}" y="${h.y}" width="${h.w}" height="${h.h}" viewBox="0 0 ${h.w} ${h.h}" overflow="hidden">${ae(h)}</svg>`);const l=new Blob([`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${i}" viewBox="${n.x} ${n.y} ${n.w} ${n.h}"><title>${oe(e.name)}</title>${u.join("")}</svg>`],{type:"image/svg+xml"});if(t.format==="svg")return l;const f=URL.createObjectURL(l),d=new Image;try{d.src=f,await d.decode();const h=document.createElement("canvas");h.width=a,h.height=i;const w=h.getContext("2d");if(!w)throw new Error("Canvas unavailable");return w.drawImage(d,0,0),await new Promise((m,U)=>h.toBlob(x=>x?m(x):U(new Error("Export failed")),`image/${t.format}`,t.quality))}finally{URL.revokeObjectURL(f)}}const qe=Object.freeze(Object.defineProperty({__proto__:null,blobDataUrl:B,decodeImage:V,downloadBlob:ie,exportProject:Ye,imageAttachment:C,importProject:Ve,makeImage:q,renderBoard:le,renderImages:W,sceneForExport:ce},Symbol.toStringTag,{value:"Module"})),Q=[],O=new Set;function We(e){const[s,t]=k.useState("");return k.useEffect(()=>{const r=URL.createObjectURL(e);return t(r),()=>URL.revokeObjectURL(r)},[e]),s}function pt(e,s,t){const r=j(o=>e.sessionId&&o.messagesBySession[e.sessionId]||Q),n=j(o=>!!(e.sessionId&&o.runningBySession[e.sessionId]));k.useEffect(()=>{if(e.sessionId)for(const o of r.flatMap(a=>a.toolEvents||[])){const a=Re(o.name,o.arguments);a&&(o.done?(o.isError||/^Error:/i.test(o.result||""))&&g.getState().failGeneration(e.id,{sessionId:e.sessionId,toolId:o.id}):g.getState().bindGenerationTool(e.id,e.sessionId,o.id,a))}},[e.id,e.sessionId,r]),k.useEffect(()=>{if(!e.sessionId||n)return;const o=window.setTimeout(()=>{const a=g.getState(),i=(a.placeholders[e.id]||[]).filter(c=>c.sessionId===e.sessionId&&c.status==="running").map(c=>c.id);i.length&&a.failGeneration(e.id,{ids:i})},800);return()=>window.clearTimeout(o)},[e.id,e.sessionId,r,n]),k.useEffect(()=>{const o=e.sessionId;if(!o)return;let a=!1;const i=Ee(r);return(async()=>{for(const c of i){if(a)return;const u=g.getState().boards[e.id];if(!(!u||u.collected.includes(c.key)||O.has(c.key))){O.add(c.key);try{const l=j.getState(),f=l.configBySession[c.file.sourceSessionId||o]?.execMode||"sandbox",d=await Ie(c.file,l.cfg,o,f).load();if(a)return;if(!d||"tooLarge"in d)throw new Error(c.file.name);const h=new Blob([d.bytes],{type:d.mimeType||c.file.mime}),w=await q(h,c.file.name,"generated");if(a)return;const m=g.getState().takeGeneration(e.id,o),U=m?Be(w.width,w.height,m.aspect):void 0;g.getState().update(e.id,x=>x.collected.includes(c.key)?x:{...x,collected:[...x.collected,c.key],images:[...x.images,{...w,...m?{x:m.x,y:m.y,w:m.w,h:m.h}:Me(w.width,w.height,x.images),...U?{crop:U}:{},...m?.sourceIds[0]?{parentId:m.sourceIds[0]}:{},sourceKey:c.key,prompt:c.prompt}]})}catch(l){a||s(String(l))}finally{O.delete(c.key)}}}})(),()=>{a=!0}},[e.id,e.sessionId,r,s,t])}function Xe({image:e,className:s}){const t=We(e.blob),r=b(e),n=e.crop||{x:0,y:0,w:e.width,h:e.height};return $.jsx("svg",{className:`ims-raster ${s||""}`,role:"img","aria-label":e.name,"data-original-width":e.width,viewBox:`0 0 ${r.w} ${r.h}`,preserveAspectRatio:"xMidYMid meet",style:{filter:ee(e)},children:$.jsx("g",{transform:`translate(${r.w/2} ${r.h/2}) rotate(${e.rotation||0}) scale(${e.flipX?-1:1} ${e.flipY?-1:1})`,children:$.jsx("svg",{x:-n.w/2,y:-n.h/2,width:n.w,height:n.h,viewBox:`${n.x} ${n.y} ${n.w} ${n.h}`,overflow:"hidden",children:t&&$.jsx("image",{href:t,width:e.width,height:e.height})})})})}function mt({item:e}){return v(e)?$.jsx(Xe,{image:e}):$.jsx("svg",{role:"img","aria-label":e.name,viewBox:`0 0 ${e.w} ${e.h}`,preserveAspectRatio:"xMidYMid meet",overflow:"hidden",dangerouslySetInnerHTML:{__html:ae(e)}})}const Je="image-studio-nav",He="image-studio-chat",P="image-studio-assets",wt="image-studio-inspector",D=(e,s)=>e.some(t=>t.type===s);function Ke(e){const s=S.getState();if(D(s.mainTabs,e)){s.openView(e,{},"main");return}const t=D(s.leftTabs,e)?"left":D(s.rightTabs,e)?"right":e===P?"left":"right";(t==="left"?s.leftVisible:s.rightVisible)||s.toggleSidebar(t),S.getState().openView(e,{},t)}let de=!1,X=!1,ue=0,J=!1,G;const Qe=2e3,fe=()=>"bottomVisible"in S.getState();function he(){if(clearTimeout(G),!J||$e.getState().activeSpaceId!=="image-studio")return;const e=S.getState();if(e.syncPanelState(),!S.getState().rightVisible)e.toggleSidebar("right");else if(Date.now()-ue<Qe){G=setTimeout(he,50);return}de=!0,X=!1}function yt(){const e=S.getState();J=!0;let s=!1;e.remapLeaves(t=>{t===P&&(s=!0)}),s||e.replaceViewsOfType(Je,P),fe()&&(de&&!X||he())}function xt(e){const s=S.getState();J=!1,clearTimeout(G),s.remapLeaves(t=>t===P?null:void 0),fe()&&e&&S.getState().rightVisible&&(S.getState().toggleSidebar("right"),X=!0,ue=Date.now())}const N=new Map;async function Ze(e){const s=g.getState().boards[e];if(!s)throw new Error("Project no longer available");if(s.sessionId)return s.sessionId;const t=N.get(e);if(t)return t;const r=(async()=>{const n=j.getState(),o={...ye({...xe(n.desktopConfig,!1),execMode:"sandbox"},void 0),agentSlug:n.defaultAgentSlug},a=await Se(ve(),{title:s.name,projectless:!0,agent_config:o});return n.adoptSession({...a,agent_config:a.agent_config||o},{fresh:!0}),g.getState().update(e,i=>({...i,sessionId:a.id}),!1),a.id})();N.set(e,r);try{return await r}finally{N.delete(e)}}async function et(e,s,t=[]){const r=await Ze(e);g.getState().activeId===e&&(Ke(He),g.getState().queue(r,s,t))}let H=[];function ge(e=!1){const{activeId:s,boards:t,selection:r}=g.getState(),n=s?t[s]:void 0;if(!n)return[];const o=y(n),a=o.filter(i=>r.includes(i.id)&&I(i));return o.filter(i=>r.includes(i.id)||e&&!I(i)&&a.some(c=>se(c,i)))}function St(){H=ge(!0)}function vt(){return H.length>0}function It(e=!1){const s=g.getState(),t=s.activeId;if(!t)return;const r=je(e?ge(!0):H);r.length&&(s.update(t,n=>T(n,[...y(n),...r])),g.setState({selection:r.map(n=>n.id)}))}function bt(){const e=g.getState(),s=e.activeId,t=new Set(e.selection);s&&(e.update(s,r=>T(r,y(r).filter(n=>n.locked||!t.has(n.id)))),g.setState({selection:[]}))}async function $t(){const{activeId:e,boards:s,selection:t}=g.getState(),r=e?s[e]:void 0;if(!r)return;const n=y(r).filter(a=>t.includes(a.id)&&!a.hidden);if(!n.length)return;if(n.length>8)throw new Error(p("imageStudio.referenceLimit"));const o=n.every(v)?await Promise.all(n.map(a=>C(a))):await(async()=>{const a=await le(r,t,{format:"png",scale:1,background:"transparent",quality:.92}),{makeImage:i}=await pe(async()=>{const{makeImage:c}=await Promise.resolve().then(()=>qe);return{makeImage:c}},void 0,import.meta.url);return[await C(await i(a,`${r.name}.png`,"import"))]})();await et(r.id,p("imageStudio.referencePrompt"),o)}export{et as A,dt as B,Ye as C,q as D,Me as E,We as F,ke as G,Pe as H,Xe as I,C as J,V as K,mt as L,B as M,ft as N,Ze as O,gt as P,ht as Q,lt as R,He as S,W as a,y as b,$t as c,ie as d,St as e,ut as f,bt as g,vt as h,v as i,it as j,b as k,Ve as l,Te as m,yt as n,xt as o,It as p,pt as q,le as r,ce as s,Ke as t,g as u,T as v,Ue as w,ct as x,P as y,wt as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as u,u as g,j as r}from"./index-fDB1l4d-.js";import{l3 as h,u as p,jz as k,aF as f,li as v}from"./appStore-DDOkzWDA.js";import"./client-fKy9CWk0.js";import"./pageStore-CyvNZEYX.js";import{a as x}from"./ModelPill--CU3XTIQ.js";const M=h;function y(o){const s=p(k),n=p(i=>i.agentDefs.find(l=>l.slug===o)),[t,d]=u.useState({});return[{modelId:t.modelId??(n?.model||s||""),thinkingLevel:t.thinkingLevel??(n?.thinkingLevel||"medium")},d]}function C({selection:o,onSelectionChange:s,controls:n,...t}){const{t:d}=g(),a=p(e=>e.modelsResp),i=f(),l=u.useMemo(()=>(a?.models||[]).filter(e=>(e.modelType||"llm")==="llm"),[a]),c=u.useMemo(()=>M(l,i).map(e=>({key:e.key,label:e.provider,source:e.source,options:e.models.map(m=>({...m,description:`${m.provider} · ${m.id}`}))})),[l,i]);return r.jsx(v,{...t,controls:r.jsxs(r.Fragment,{children:[r.jsx(x,{menuPortal:!0,groups:c,modelId:o.modelId,disabled:t.disabled,onSelectionChange:e=>s({...o,...e}),onSelect:e=>s({...o,modelId:e}),thinkingLevel:o.thinkingLevel,onThinkingChange:e=>s({...o,thinkingLevel:e}),supportedThinking:l.find(e=>e.id===o.modelId)?.thinkingLevels,emptyLabel:d("pill.noModels")}),n]})})}export{C,M as g,y as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{pv as y,oc as d,oa as b,pw as f,o2 as C,px as j,o9 as A,py as g,pz as O,n0 as m,pA as v,pB as K,pC as h,pD as P,pE as E,pF as $,pG as w}from"./appStore-DDOkzWDA.js";import{ck as I}from"./index-fDB1l4d-.js";I("abcedfghicklmn",10);function N(a,s){const t=v(a),n=e=>async()=>{n.key=t,await e.wait(O);const r=s(e);return e.get(m).create(t,r),n.run=o=>e.get(m).call(a,o),()=>{e.get(m).remove(t)}};return n}function q(a){const s=t=>async()=>{await t.wait(y);const n=a(t);return t.update($,e=>[...e,n]),s.inputRule=n,()=>{t.update($,e=>e.filter(r=>r!==n))}};return s}function H(a){const s=t=>async()=>{await t.wait(y);const n=a(t);return t.update(w,e=>[...e,n]),s.pasteRule=n,()=>{t.update(w,e=>e.filter(r=>r!==n))}};return s}function T(a,s){const t=n=>async()=>{const e=s(n);return n.update(h,r=>[...r.filter(o=>o[0]!==a),[a,e]]),t.id=a,t.schema=e,()=>{n.update(h,r=>r.filter(([o])=>o!==a))}};return t.type=n=>{const e=n.get(C).marks[a];if(!e)throw K(a);return e},t}function D(a,s){const t=n=>async()=>{const e=s(n);return n.update(g,r=>[...r.filter(o=>o[0]!==a),[a,e]]),t.id=a,t.schema=e,()=>{n.update(g,r=>r.filter(([o])=>o!==a))}};return t.type=n=>{const e=n.get(C).nodes[a];if(!e)throw j(a);return e},t}function J(a){let s;const t=n=>async()=>(await n.wait(y),s=a(n),n.update(d,e=>[...e,s]),()=>{n.update(d,e=>e.filter(r=>r!==s))});return t.plugin=()=>s,t.key=()=>s.spec.key,t}function M(a){const s=t=>async()=>{await t.wait(P);const n=t.get(E),e=a(t),r=n.addObjectKeymap(e);return s.keymap=e,()=>{r()}};return s}function p(a,s){const t=A(a,s),n=e=>(e.inject(t),()=>()=>{e.remove(t)});return n.key=t,n}function z(a,s){const t=p(s,a),n=D(a,r=>r.get(t.key)(r)),e=[t,n];return e.id=n.id,e.node=n,e.type=r=>n.type(r),e.ctx=t,e.key=t.key,e.extendSchema=r=>z(a,r(s)),e}function B(a,s){const t=p(s,a),n=T(a,r=>r.get(t.key)(r)),e=[t,n];return e.id=n.id,e.mark=n,e.type=r=>n.type(r),e.ctx=t,e.key=t.key,e.extendSchema=r=>B(a,r(s)),e}function L(a,s){const t=p(Object.fromEntries(Object.entries(s).map(([r,{shortcuts:o,priority:u}])=>[r,{shortcuts:o,priority:u}])),`${a}Keymap`),n=M(r=>{const o=r.get(t.key),u=Object.entries(s).flatMap(([c,{command:i}])=>{const l=o[c],S=[l.shortcuts].flat(),R=l.priority;return S.map(k=>[k,{key:k,onRun:i,priority:R}])});return Object.fromEntries(u)}),e=[t,n];return e.ctx=t,e.shortcuts=n,e.key=t.key,e.keymap=n.keymap,e}var Q=(a,s=()=>({}))=>p(s,`${a}Attr`),U=(a,s=()=>({}))=>p(s,`${a}Attr`);function V(a,s,t){const n=p({},a),e=o=>async()=>{await o.wait(b);const u={plugin:s(o),options:o.get(n.key)};return o.update(f,c=>[...c,u]),()=>{o.update(f,c=>c.filter(i=>i!==u))}},r=[n,e];return r.id=a,r.plugin=e,r.options=n,r}export{J as $,V as a,z as b,N as c,B as d,U as e,L as f,D as g,Q as h,p as i,q as j,H as k};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{p as ie,a8 as G,aA as J,aj as ce,r as Ce,B as ze,dB as Fe,T as Le,X as Ee,M as Ae,ah as Me,I as de,F as ue,n as Te}from"./pageStore-CyvNZEYX.js";import{a as Pe,j as e,u as I,r as l,R as Re,cj as He}from"./index-fDB1l4d-.js";import{b3 as Oe,pk as pe,l as O,pl as se,Y as $,_ as Z,aC as V,pm as $e,X as Ie,fB as Be,pn as _e,bw as W,R as We,nn as Ke,bO as qe,V as ae,fN as me,hY as Ue,po as Ve,pp as Ye,aT as he,aW as ge,pq as Xe,hZ as re,h_ as Ge,h$ as fe,Z as Je,pr as Ze,i3 as Qe}from"./appStore-DDOkzWDA.js";import{P as xe}from"./pencil--sWwxHdP.js";import"./client-fKy9CWk0.js";import{F as et}from"./folder-plus-DP9sFr26.js";import{F as oe}from"./folder-1OJQeDI1.js";import{U as tt}from"./upload-Dy7svciS.js";const nt=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],St=ie("check-check",nt);const st=[["path",{d:"M14 9 9 4 4 9",key:"1af5af"}],["path",{d:"M20 20h-7a4 4 0 0 1-4-4V4",key:"1blwi3"}]],at=ie("corner-left-up",st);Pe({"agentLog.days":{zh:"{count} 天有记录",en:"{count} days on record"},"agentLog.older":{zh:"更早的 {count} 天",en:"{count} earlier days"},"agentLog.today":{zh:"今天",en:"Today"},"agentLog.editDay":{zh:"编辑 {date} 的日志",en:"Edit the log for {date}"},"agentLog.rawHint":{zh:"这是这一天的原文。每条以「### 09:30」这样的时间行开头;「@」后面那一串是写入设备的标记,不用改。",en:'This is the raw file for the day. Each entry starts with a time line like "### 09:30"; the code after "@" marks the device that wrote it and can stay as it is.'},"agentLog.error":{zh:"日志操作失败",en:"The log could not be updated"},"agentLog.changed":{zh:"这一天的日志已有新版本,这次没有保存。",en:"This day’s log has a newer version, so nothing was saved."},"agentLog.discardAndReload":{zh:"放弃草稿并载入当前版本",en:"Discard draft and load the current version"}});const le=7,rt=()=>{const n=new Date;return`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`},ve=n=>n.replace(/^# \d{4}-\d{2}-\d{2}[ \t]*\n+/,"").replace(/^(### \d{2}:\d{2}\n)@[0-9a-f]{8} /gm,"$1"),Dt=n=>e.jsx(ot,{...n},JSON.stringify([Oe(n.cfg),n.slug])),ot=({slug:n,active:s=!0})=>{const{t:r}=I(),[i,p]=l.useState(null),[a,y]=l.useState(null),[o,m]=l.useState(null),[u,h]=l.useState(null),[g,d]=l.useState(!1),[f,w]=l.useState(!1),[T,j]=l.useState(""),[F,L]=l.useState(!1),[c,k]=l.useState(0),[b,M]=l.useState(!1),C=l.useRef(0),E=l.useRef(!1),q=l.useRef(!0),B=l.useRef(s),z=u!==null;l.useEffect(()=>{let N=!0;return pe(O(),n).then(D=>{if(!N)return;const P=D.slice().sort((Y,X)=>X.localeCompare(Y));p(P),q.current&&(q.current=!1,y(P[0]??null))}).catch(D=>{N&&(p(P=>P??[]),j(D?.message||r("agentLog.error")))}),()=>{N=!1}},[n,c]),l.useEffect(()=>{const N=++C.current;if(m(null),w(!1),j(""),L(!1),!a){d(!1);return}return d(!0),se(O(),n,a).then(D=>{N===C.current&&m({content:D.content,version:D.version})}).catch(D=>{N===C.current&&j(D?.message||r("agentLog.error"))}).finally(()=>{N===C.current&&d(!1)}),()=>{++C.current}},[a,n,c]),l.useEffect(()=>{s&&!B.current&&!z&&k(N=>N+1),B.current=s},[s]);const H=async()=>{if(!a||!o||u===null||g||E.current)return;E.current=!0;const N=C.current;d(!0),w(!1),j(""),L(!1);try{await $e(O(),n,a,u,o.version);const D=await se(O(),n,a);N===C.current&&(m({content:D.content,version:D.version}),h(null),w(!0))}catch(D){N===C.current&&(D?.status===409?L(!0):j(D?.message||r("agentLog.error")))}finally{E.current=!1,N===C.current&&d(!1)}};if(i===null)return e.jsx("p",{className:"profile-empty","data-testid":"agent-log-panel",children:e.jsx($,{size:14,className:"spin"})});const K=rt(),A=i.slice(le),R=b||a!==null&&A.includes(a),U=N=>{const D=a===N;return e.jsxs("div",{className:"agentmem-log","data-log-date":N,children:[e.jsxs("div",{className:"agentmem-log-row",children:[e.jsxs("button",{type:"button",className:"agentmem-log-head","aria-expanded":D,disabled:z,onClick:()=>y(D?null:N),children:[D?e.jsx(G,{size:12}):e.jsx(J,{size:12}),e.jsx("span",{children:N}),N===K&&e.jsx("small",{children:r("agentLog.today")}),D&&f&&e.jsxs("small",{className:"agentmem-log-saved",children:[e.jsx(ce,{size:11}),r("settings.agents.memSaved")]})]}),D&&o&&!z&&e.jsx("button",{type:"button",className:"harness-undo",title:r("common.edit"),"aria-label":r("agentLog.editDay",{date:N}),onClick:()=>{h(o.content),w(!1)},children:e.jsx(xe,{size:13})})]}),D&&(z?e.jsxs("div",{className:"field agentmem-log-edit",children:[e.jsx("textarea",{"aria-label":r("agentLog.editDay",{date:N}),rows:12,value:u,disabled:g,onChange:P=>h(P.target.value)}),e.jsx("p",{className:"hint",children:r("agentLog.rawHint")}),F&&e.jsxs("p",{role:"alert",className:"agentmem-log-error",children:[r("agentLog.changed")," ",e.jsx("button",{type:"button",className:"profile-text-action",onClick:()=>{h(null),k(P=>P+1)},children:r("agentLog.discardAndReload")})]}),e.jsxs("div",{className:"agentmem-log-actions",children:[e.jsxs("button",{type:"button",className:"btn primary sm",disabled:g,onClick:()=>{H()},children:[g?e.jsx($,{size:13,className:"spin"}):null," ",r("common.save")]}),e.jsx("button",{type:"button",className:"btn sm",disabled:g,onClick:()=>{h(null),j(""),L(!1)},children:r("common.cancel")})]})]}):o&&e.jsx("div",{className:"agentmem-log-body msg-content",children:e.jsx(V,{content:ve(o.content)})}))]},N)};return e.jsxs("div",{className:"profile-log","data-testid":"agent-log-panel","data-agent-slug":n,children:[e.jsxs("div",{className:"harness-summary",children:[e.jsx("span",{children:r("agentLog.days",{count:i.length})}),e.jsxs("button",{type:"button",className:"profile-text-action",disabled:g||z,onClick:()=>k(N=>N+1),children:[e.jsx(Z,{size:12}),r("common.refresh")]})]}),T&&e.jsx("p",{role:"alert",className:"agentmem-log-error",children:T}),i.length?e.jsxs(e.Fragment,{children:[i.slice(0,le).map(U),A.length>0&&e.jsx("div",{className:"agentmem-log agentmem-log-more",children:e.jsx("div",{className:"agentmem-log-row",children:e.jsxs("button",{type:"button",className:"agentmem-log-head","aria-expanded":R,disabled:z,onClick:()=>{R&&a&&A.includes(a)&&y(null),M(!R)},children:[R?e.jsx(G,{size:12}):e.jsx(J,{size:12}),e.jsx("span",{children:r("agentLog.older",{count:A.length})})]})})}),R&&A.map(U)]}):!T&&e.jsx("p",{className:"profile-empty",children:r("settings.agents.noLog")})]})},lt=({containerRef:n,scanTrigger:s})=>{const{t:r}=I(),[i,p]=l.useState([]),[a,y]=l.useState(null),o=l.useCallback(()=>{const u=n.current;if(!u){p(d=>d.length?[]:d);return}const h=u.querySelectorAll('[data-toc-msg-role="user"], [data-toc-level]'),g=[];h.forEach(d=>{if(d.id){if(d.dataset.tocMsgRole==="user"){const f=(d.dataset.tocTitle||d.textContent||"").trim();f&&g.push({id:d.id,level:0,kind:"user",text:f})}else if(d.dataset.tocLevel){const f=(d.textContent||"").trim();f&&g.push({id:d.id,level:Number(d.dataset.tocLevel)||1,kind:"heading",text:f})}}}),p(d=>d.length===g.length&&d.every((f,w)=>f.id===g[w].id&&f.text===g[w].text)?d:g)},[n]);l.useEffect(()=>{o();const u=n.current;if(!u)return;let h=0;const g=new MutationObserver(()=>{cancelAnimationFrame(h),h=requestAnimationFrame(o)});return g.observe(u,{childList:!0,subtree:!0,characterData:!0}),()=>{cancelAnimationFrame(h),g.disconnect()}},[o,n,s]),l.useEffect(()=>{const u=n.current;if(!u||i.length===0)return;const h=new Set,g=new IntersectionObserver(d=>{for(const w of d)w.isIntersecting?h.add(w.target.id):h.delete(w.target.id);const f=i.find(w=>h.has(w.id));f&&y(f.id)},{root:u,rootMargin:"0px 0px -65% 0px",threshold:0});for(const d of i)try{const f=u.querySelector(`#${CSS.escape(d.id)}`);f&&g.observe(f)}catch{}return()=>g.disconnect()},[i,n]);const m=l.useCallback(u=>{const h=n.current;if(!h)return;let g=null;try{g=h.querySelector(`#${CSS.escape(u)}`)}catch{return}if(!g)return;const d=g.getBoundingClientRect().top-h.getBoundingClientRect().top+h.scrollTop;h.scrollTo({top:Math.max(0,d-16),behavior:"smooth"}),y(u)},[n]);return i.length===0?e.jsx("div",{className:"panel-note",children:r("toc.emptyNote")}):e.jsx("div",{className:"toc-list",children:i.map(u=>e.jsxs("button",{type:"button",className:`toc-item${u.kind==="user"?" user":""}${a===u.id?" active":""}`,style:{paddingLeft:6+u.level*14},title:u.text,onClick:()=>m(u.id),children:[u.kind==="user"?e.jsx(Ie,{size:12,className:"toc-ico"}):e.jsx(Be,{size:11,className:"toc-ico"}),e.jsx("span",{className:"toc-text",children:u.text})]},u.id))})};function it(n){if(n==="__host__")return"#b8860b";let s=0;for(let r=0;r<n.length;r++)s=s*31+n.charCodeAt(r)>>>0;return`hsl(${s%360} 62% 45%)`}const ye=({segs:n})=>e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:n.map((s,r)=>s.t==="tool"?e.jsxs("div",{className:"panel-note",style:{fontSize:"var(--ui-font-caption, 11px)",opacity:s.error?.95:.7},children:["🔧 ",e.jsx("b",{children:s.name}),s.preview?` — ${s.preview.slice(0,200)}`:""]},r):s.t==="vote"?e.jsxs("div",{className:"panel-note",style:{fontSize:"var(--ui-font-caption, 11px)"},children:["🗳 ",s.text]},r):e.jsxs("div",{children:[s.speaker&&e.jsxs("div",{className:"msg-role-with-avatar",style:{color:s.color,fontSize:12,fontWeight:600,marginBottom:2,display:"flex",alignItems:"center",gap:4},children:[e.jsx("span",{className:"msg-avatar fallback",style:{background:s.color,width:16,height:16,fontSize:10},children:s.speaker.slice(0,1)}),e.jsx("span",{children:s.speaker})]}),e.jsx("div",{className:"msg-content",style:{fontSize:"var(--ui-font-meta, 12px)"},children:e.jsx(V,{content:s.text||""})})]},r))}),ct=({sessionId:n,runId:s})=>{const{t:r}=I(),[i,p]=l.useState([]),[a,y]=l.useState(!0),o=l.useRef(null);return l.useEffect(()=>{const m=new AbortController;p([]),y(!0);let u="",h="";const g=d=>p(f=>{const w=f[f.length-1];return w&&w.t==="text"?[...f.slice(0,-1),{...w,text:w.text+d}]:[...f,{t:"text",speaker:u,color:h,text:d}]});return _e(W(n),s,d=>{const f=d.payload||{};switch(d.type){case"group_speaker":f.phase==="start"&&(u=f.name||f.slug||"",h=it(String(f.slug||"")),p(w=>[...w,{t:"text",speaker:u,color:h,text:""}]));break;case"token":f.delta&&g(String(f.delta));break;case"tool_call":p(w=>[...w,{t:"tool",name:String(f.name||"")}]);break;case"group_vote":p(w=>[...w,{t:"vote",text:`${f.endCount}/${f.total} ${r("panel.subchats.voteEnd")}`}]);break;case"group_ended":case"done":case"error":y(!1);break}},m.signal).catch(()=>y(!1)),()=>m.abort()},[n,s,r]),l.useEffect(()=>{o.current?.scrollIntoView({block:"end"})},[i]),e.jsxs("div",{children:[i.length===0&&a&&e.jsxs("div",{className:"panel-note",style:{fontSize:11.5},children:[e.jsx($,{size:12,className:"spin"})," ",r("panel.subchats.connecting")]}),e.jsx(ye,{segs:i}),a&&i.length>0&&e.jsxs("div",{className:"panel-note",style:{fontSize:11.5,marginTop:6},children:[e.jsx($,{size:12,className:"spin"})," ",r("panel.subchats.live")]}),e.jsx("div",{ref:o})]})},dt=({sessionId:n,subChats:s})=>{const{t:r}=I(),i=s||[],[p,a]=l.useState(null),y=i.find(o=>o.id===p)||i[i.length-1]||null;return i.length?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2,maxHeight:140,overflowY:"auto"},children:i.map(o=>e.jsxs("div",{role:"button",tabIndex:0,className:`file-row${y?.id===o.id?" selected":""}`,onClick:()=>a(o.id),children:[o.kind==="discussion"?e.jsx(Ce,{size:13}):e.jsx(ze,{size:13}),e.jsx("span",{className:"file-name",title:o.title,children:o.title||o.id.slice(0,8)}),o.streaming&&e.jsx($,{size:12,className:"spin",style:{opacity:.6}})]},o.id))}),e.jsx("div",{style:{height:1,background:"var(--border)"}}),y&&e.jsx("div",{style:{padding:"0 4px"},children:y.kind==="discussion"&&y.runId?e.jsx(ct,{sessionId:n,runId:y.runId}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{segs:y.segs}),y.segs.length===0&&e.jsx("div",{className:"panel-note",style:{fontSize:"var(--ui-font-caption, 11px)"},children:r("panel.subchats.starting")}),y.streaming&&y.segs.length>0&&e.jsxs("div",{className:"panel-note",style:{fontSize:11.5,marginTop:6},children:[e.jsx($,{size:12,className:"spin"})," ",r("panel.subchats.live")]})]})})]}):e.jsx("div",{className:"panel-note",children:r("panel.subchats.empty")})},ut="application/x-tangu-paths",Ct=n=>{const{t:s}=I(),[r,i]=l.useState("workspace"),p=n.view??r,a=e.jsxs(e.Fragment,{children:[p==="workspace"&&e.jsx(pt,{...n}),p==="toc"&&e.jsx(lt,{containerRef:n.chatScrollRef,scanTrigger:n.messages.length}),p==="memory"&&e.jsx(gt,{...n}),p==="subchats"&&e.jsx(dt,{sessionId:n.sessionId,subChats:n.subChats})]});return n.view?e.jsx("div",{className:"right-panel-body",children:a}):e.jsxs("aside",{className:"right-panel",children:[e.jsxs("div",{className:"right-panel-tabs",children:[e.jsxs("button",{className:r==="workspace"?"active":"",onClick:()=>i("workspace"),children:[e.jsx(We,{size:13})," ",s("panel.tab.workspace")]}),e.jsxs("button",{className:r==="toc"?"active":"",onClick:()=>i("toc"),children:[e.jsx(Ke,{size:13})," ",s("panel.tab.toc")]}),e.jsxs("button",{className:r==="memory"?"active":"",onClick:()=>i("memory"),children:[e.jsx(qe,{size:13})," ",s("panel.tab.memory")]}),e.jsxs("button",{className:r==="subchats"?"active":"",onClick:()=>i("subchats"),children:[e.jsx(Ae,{size:13})," ",s("panel.tab.subchats"),n.subChats&&n.subChats.length>0&&e.jsx("span",{style:{marginLeft:3,fontSize:"var(--ui-font-caption, 11px)",fontWeight:700,background:"var(--action-fill)",color:"var(--on-action)",borderRadius:"var(--radius-sm, 6px)",padding:"0 4px",lineHeight:"14px"},children:n.subChats.length})]})]}),e.jsx("div",{className:"right-panel-body",children:a})]})};function we(n){const[s,r]=l.useState(new Set),i=l.useRef(null),p=n.join(`
|
|
2
|
-
`);l.useEffect(()=>{r(m=>{const u=new Set([...m].filter(h=>n.includes(h)));return u.size===m.size?m:u})},[p]);const a=m=>{r(new Set([m])),i.current=m};return{selected:s,onClick:(m,u)=>{if(u.metaKey||u.ctrlKey)r(h=>{const g=new Set(h);return g.has(m)?g.delete(m):g.add(m),g}),i.current=m;else if(u.shiftKey&&i.current){const h=n.indexOf(i.current),g=n.indexOf(m);if(h>=0&&g>=0){const[d,f]=h<g?[h,g]:[g,h];r(new Set(n.slice(d,f+1)))}else a(m)}else a(m)},only:a,clear:()=>{r(new Set),i.current=null}}}const je=({menu:n,onClose:s,autoFocus:r=!1})=>{const[i,p]=l.useState(()=>!Te()),a=l.useRef({menu:n,onClose:s});a.current={menu:n,onClose:s},l.useEffect(()=>{if(i)return;const o=new AbortController;return Fe(a.current.menu.items,{signal:o.signal}).then(m=>{if(!o.signal.aborted){if(!m.handled){p(!0);return}a.current.onClose(),m.value?.run()}}),()=>o.abort()},[i,n.x,n.y]);const y=l.useRef(null);return l.useEffect(()=>{i&&r&&y.current?.focus({preventScroll:!0})},[i,r,n.x,n.y]),l.useEffect(()=>{if(!i)return;const o=performance.now(),m=h=>{h.timeStamp>=o&&s()},u=h=>{h.key==="Escape"&&s()};return window.addEventListener("pointerdown",m),window.addEventListener("contextmenu",m),window.addEventListener("keydown",u),window.addEventListener("blur",m),()=>{window.removeEventListener("pointerdown",m),window.removeEventListener("contextmenu",m),window.removeEventListener("keydown",u),window.removeEventListener("blur",m)}},[s,i]),i?Le.createPortal(e.jsx(Ee,{className:"ctx-menu",role:"menu",x:n.x,y:n.y,onPointerDown:o=>o.stopPropagation(),onContextMenu:o=>{o.preventDefault(),o.stopPropagation()},onKeyDown:o=>{if(o.key==="Escape"||o.key==="Tab"){o.preventDefault(),o.stopPropagation(),s();return}if(!["ArrowDown","ArrowUp","Home","End"].includes(o.key))return;o.preventDefault(),o.stopPropagation();const m=Array.from(o.currentTarget.querySelectorAll("button:not(:disabled)")),u=m.indexOf(document.activeElement),h=o.key==="Home"?0:o.key==="End"?m.length-1:(u+(o.key==="ArrowDown"?1:-1)+m.length)%m.length;m[h]?.focus()},children:n.items.map((o,m)=>e.jsxs(Re.Fragment,{children:[o.separatorBefore&&e.jsx("div",{className:"ctx-separator",role:"separator"}),e.jsxs("button",{ref:m===n.items.findIndex(u=>!u.disabled)?y:void 0,role:"menuitem","aria-label":o.label,disabled:o.disabled,className:`ctx-item${o.danger?" danger":""}`,onClick:()=>{s(),o.run()},children:[o.icon,e.jsx("span",{children:o.label}),o.shortcut&&e.jsx("kbd",{className:"ctx-shortcut","aria-hidden":"true",children:o.shortcut})]})]},m))}),document.body):null},be=(n,s)=>({x:n.clientX,y:n.clientY}),pt=n=>n.sessionConfig?.execMode==="host"&&n.sessionConfig.cwd&&window.tangu?.listDir?e.jsx(mt,{cwd:n.sessionConfig.cwd,running:n.running,onToast:n.onToast,onOpenPreview:n.onOpenPreview}):e.jsx(ht,{...n}),mt=({cwd:n,running:s,onToast:r,onOpenPreview:i})=>{const{t:p}=I(),[a,y]=l.useState(n),[o,m]=l.useState([]),[u,h]=l.useState(!1),[g,d]=l.useState(null),[f,w]=l.useState(""),[T,j]=l.useState(!1),[F,L]=l.useState(""),[c,k]=l.useState(null),[b,M]=l.useState(null),[C,E]=l.useState(null),[q,B]=l.useState(!1),z=we(o.map(t=>t.path)),H=!!window.tangu?.mkdirHost,K=!!window.tangu?.revealHostPath;l.useEffect(()=>{y(n),d(null),j(!1)},[n]);const A=l.useCallback(async()=>{if(window.tangu?.listDir){h(!0);try{m(await window.tangu.listDir(a))}catch(t){r(p("panel.toast.listDirFail",{err:t?.message||t}),!0)}finally{h(!1)}}},[a,r]);l.useEffect(()=>{A()},[A,s]);const R=t=>{const x=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return x>0?t.slice(0,x):t},U=a===n,N=a.startsWith(n)?a.slice(n.length).replace(/^[/\\]+/,""):a,D=t=>{t.isDir||!window.tangu?.readHostFile||i({name:t.name,path:t.path,load:async()=>{const x=await window.tangu.readHostFile(t.path);return x.tooLarge?{tooLarge:!0,size:x.size}:{mimeType:x.mimeType,bytes:fe(x.content),size:x.size,mtimeMs:x.mtimeMs}},download:K?()=>{window.tangu?.revealHostPath?.(t.path)}:void 0})},P=t=>{t.isDir?y(t.path):D(t)},Y=t=>{d(t.path),w(t.name)},X=async t=>{const x=f.trim();if(d(null),!(!x||x===t.name||!window.tangu?.renameHostPath))try{await window.tangu.renameHostPath(t.path,x),A()}catch(S){r(p("panel.toast.renameFail",{err:S?.message||S}),!0)}},Q=async()=>{const t=F.trim();if(j(!1),L(""),!(!t||!window.tangu?.mkdirHost))try{await window.tangu.mkdirHost(a,t),A()}catch(x){r(p("panel.toast.mkdirFail",{err:x?.message||x}),!0)}},ke=async t=>{if(!(!t.length||!window.tangu?.trashHostPath||!window.confirm(t.length===1?p("panel.confirm.trash",{name:t[0].split(/[/\\]/).pop()||""}):p("panel.confirm.trashN",{n:String(t.length)}))))try{for(const S of t)await window.tangu.trashHostPath(S);z.clear(),A()}catch(S){r(p("panel.toast.deleteFail",{err:S?.message||S}),!0)}},Ne=async(t,x)=>{const S=x.filter(v=>v!==t);if(!(!S.length||!window.tangu?.moveHostPath))try{for(const v of S)await window.tangu.moveHostPath(v,t);z.clear(),A()}catch(v){r(p("panel.toast.moveFail",{err:v?.message||v}),!0)}},ee=async(t,x)=>{if(!window.tangu?.copyHostFiles||!window.tangu?.getPathForFile)return;const S=Array.from(t).map(v=>{try{return window.tangu.getPathForFile(v)}catch{return""}}).filter(Boolean);if(S.length)try{const v=await window.tangu.copyHostFiles(S,x);r(p("panel.toast.copied",{n:String(v.copied)})),A()}catch(v){r(p("panel.toast.copyFail",{err:v?.message||v}),!0)}},Se=(t,x)=>{t.preventDefault(),t.stopPropagation();const S=z.selected.has(x.path)?[...z.selected]:[x.path];z.selected.has(x.path)||z.only(x.path);const v=S.length>1,_=[];!v&&!x.isDir&&_.push({label:p("panel.action.preview"),icon:e.jsx(he,{size:13}),run:()=>D(x)}),!v&&H&&_.push({label:p("panel.action.rename"),icon:e.jsx(xe,{size:13}),run:()=>Y(x)}),!v&&K&&_.push({label:p("panel.action.revealInFileManager"),icon:e.jsx(ae,{size:13}),run:()=>window.tangu?.revealHostPath?.(x.path)}),H&&_.push({label:v?p("panel.action.deleteN",{n:String(S.length)}):p("panel.action.moveToTrash"),icon:e.jsx(ge,{size:13}),danger:!0,run:()=>{ke(S)}}),_.length&&k({...be(t,_.length),items:_})},De=(t,x)=>{if(t.altKey&&window.tangu?.startHostDrag){t.preventDefault(),window.tangu.startHostDrag(x.path);return}const S=z.selected.has(x.path)?[...z.selected]:[x.path];M(S),t.dataTransfer.setData(ut,JSON.stringify(S)),t.dataTransfer.effectAllowed="copyMove"},te=(t,x)=>{const S=H&&t.dataTransfer.types.includes("Files");!b&&!S||b?.includes(x)||(t.preventDefault(),t.stopPropagation(),E(x),B(!1))},ne=(t,x)=>{t.preventDefault(),t.stopPropagation();const S=t.dataTransfer.files,v=b;E(null),M(null),S?.length?ee(S,x):v?.length&&Ne(x,v)};return e.jsxs("div",{className:q?"wsfiles dragover":"wsfiles",onClick:t=>{t.target===t.currentTarget&&z.clear()},onDragOver:t=>{H&&t.dataTransfer.types.includes("Files")&&!b&&(t.preventDefault(),B(!0))},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||B(!1)},onDrop:t=>{t.preventDefault(),B(!1),E(null),t.dataTransfer.files?.length&&!b&&ee(t.dataTransfer.files,a)},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:6},children:[e.jsx("span",{className:"panel-section-title",style:{flex:1,padding:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:a,children:N?`…/${N}`:n.split(/[/\\]/).filter(Boolean).pop()||n}),H&&e.jsx("button",{className:"icon-btn",style:{width:24,height:24},onClick:()=>{j(!0),L("")},title:p("panel.action.newFolder"),children:e.jsx(et,{size:13})}),K&&e.jsx("button",{className:"icon-btn",style:{width:24,height:24},onClick:()=>window.tangu?.revealHostPath?.(a),title:p("panel.action.openCurDirInFileManager"),children:e.jsx(ae,{size:13})}),e.jsx("button",{className:"icon-btn",style:{width:24,height:24},onClick:()=>{A()},title:p("panel.action.refresh"),children:u?e.jsx($,{size:13,className:"spin"}):e.jsx(Z,{size:13})})]}),T&&e.jsxs("div",{className:"file-row",style:{cursor:"default"},children:[e.jsx(oe,{size:13,style:{color:"var(--accent-ink)"}}),e.jsx("input",{autoFocus:!0,className:"file-rename-input",value:F,placeholder:p("panel.placeholder.newFolderName"),onChange:t=>L(t.target.value),onKeyDown:t=>{t.key==="Enter"?Q():t.key==="Escape"&&(j(!1),L(""))},onBlur:()=>{j(!1),L("")}}),e.jsxs("span",{className:"file-act",style:{opacity:1},children:[e.jsx("button",{className:"icon-btn",style:{width:22,height:22},title:p("panel.action.create"),onMouseDown:t=>{t.preventDefault(),Q()},children:e.jsx(ce,{size:12})}),e.jsx("button",{className:"icon-btn",style:{width:22,height:22},title:p("panel.action.cancel"),onMouseDown:t=>{t.preventDefault(),j(!1),L("")},children:e.jsx(Me,{size:12})})]})]}),!U&&e.jsxs("div",{className:`file-row${C===R(a)?" drop-target":""}`,role:"button",tabIndex:0,onClick:()=>y(R(a)),onDragOver:t=>te(t,R(a)),onDragLeave:()=>E(null),onDrop:t=>ne(t,R(a)),children:[e.jsx(at,{size:13}),e.jsx("span",{className:"file-name",children:p("panel.parentDir")})]}),o.length===0&&!u&&!T&&e.jsx("div",{className:"panel-note",children:p("panel.emptyDir")}),o.map(t=>{const x=z.selected.has(t.path),S=t.isDir&&C===t.path;return e.jsxs("div",{className:`file-row${x?" selected":""}${S?" drop-target":""}`,role:"button",tabIndex:0,draggable:H&&g!==t.path,onDragStart:v=>De(v,t),onDragEnd:()=>{M(null),E(null)},onDragOver:t.isDir?v=>te(v,t.path):void 0,onDragLeave:t.isDir?()=>E(null):void 0,onDrop:t.isDir?v=>ne(v,t.path):void 0,onClick:v=>{g!==t.path&&z.onClick(t.path,v)},onDoubleClick:()=>{g!==t.path&&P(t)},onContextMenu:v=>Se(v,t),onKeyDown:v=>{g!==t.path&&v.key==="Enter"&&(v.preventDefault(),P(t))},children:[t.isDir?e.jsx(oe,{size:13,style:{color:"var(--accent-ink)"}}):/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(t.name)?e.jsx(de,{size:13}):e.jsx(ue,{size:13}),g===t.path?e.jsx("input",{autoFocus:!0,className:"file-rename-input",value:f,onClick:v=>v.stopPropagation(),onChange:v=>w(v.target.value),onKeyDown:v=>{v.stopPropagation(),v.key==="Enter"?X(t):v.key==="Escape"&&d(null)},onBlur:()=>d(null)}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"file-name",children:t.name}),!t.isDir&&e.jsx("span",{className:"file-size",children:me(t.size)})]})]},t.path)}),c&&e.jsx(je,{menu:c,onClose:()=>k(null)})]})},ht=({cfg:n,sessionId:s,running:r,onToast:i,onOpenPreview:p})=>{const{t:a}=I(),[y,o]=l.useState([]),[m,u]=l.useState(!1),[h,g]=l.useState(null),d=we(y.map(c=>c.path)),f=l.useCallback(async()=>{u(!0);try{o(await Ue(W(s),s))}catch(c){i(a("panel.toast.workspaceLoadFail",{err:c?.message||c}),!0)}finally{u(!1)}},[n,s,i]);l.useEffect(()=>{f()},[f,r]);const w=c=>{p({name:c.path,load:async()=>{const k=await Ge(W(s),s,c.path);return{mimeType:k.mimeType,bytes:fe(k.content),size:k.size}},download:()=>{re(W(s),s,c.path).catch(k=>i(k.message,!0))}})},T=c=>{re(W(s),s,c).catch(k=>i(k.message,!0))},j=async c=>{if(!(!c.length||!window.confirm(c.length===1?a("panel.confirm.delete",{name:c[0].replace(/^\//,"")}):a("panel.confirm.deleteN",{n:String(c.length)}))))try{for(const b of c)await Qe(W(s),s,b);d.clear(),f()}catch(b){i(b.message,!0)}},F=async c=>{if(!c?.length)return;const k=await Promise.all(Array.from(c).map(async b=>{const M=new Uint8Array(await b.arrayBuffer());let C="";for(let E=0;E<M.length;E+=32768)C+=String.fromCharCode(...M.subarray(E,E+32768));return{path:b.name,content:btoa(C),encoding:"base64",mimeType:b.type}}));try{const b=await Xe(W(s),s,k);i(a("panel.toast.uploaded",{saved:b.saved,total:b.total})),f()}catch(b){i(a("panel.toast.uploadFail",{err:b?.message||b}),!0)}},L=(c,k)=>{c.preventDefault(),c.stopPropagation();const b=d.selected.has(k.path)?[...d.selected]:[k.path];d.selected.has(k.path)||d.only(k.path);const M=b.length>1,C=[];M||C.push({label:a("panel.action.preview"),icon:e.jsx(he,{size:13}),run:()=>w(k)}),M||C.push({label:a("panel.action.download"),icon:e.jsx(Je,{size:13}),run:()=>T(k.path)}),C.push({label:M?a("panel.action.deleteN",{n:String(b.length)}):a("panel.action.delete"),icon:e.jsx(ge,{size:13}),danger:!0,run:()=>{j(b)}}),g({...be(c,C.length),items:C})};return e.jsxs("div",{onClick:c=>{c.target===c.currentTarget&&d.clear()},onDragOver:c=>c.preventDefault(),onDrop:c=>{c.preventDefault(),F(c.dataTransfer.files)},children:[e.jsxs("div",{style:{display:"flex",gap:4,marginBottom:6},children:[e.jsx("span",{className:"panel-section-title",style:{flex:1,padding:0},children:a("panel.sessionFiles")}),e.jsxs("label",{className:"icon-btn",style:{width:24,height:24},title:a("panel.action.uploadFile"),children:[e.jsx(tt,{size:13}),e.jsx("input",{type:"file",multiple:!0,hidden:!0,onChange:c=>{F(c.target.files),c.target.value=""}})]}),e.jsx("button",{className:"icon-btn",style:{width:24,height:24},onClick:()=>{f()},title:a("panel.action.refresh"),children:m?e.jsx($,{size:13,className:"spin"}):e.jsx(Z,{size:13})})]}),y.length===0&&e.jsx("div",{className:"panel-note",children:a("panel.noFilesYet")}),y.map(c=>{const k=d.selected.has(c.path);return e.jsxs("div",{className:`file-row${k?" selected":""}`,role:"button",tabIndex:0,onClick:b=>d.onClick(c.path,b),onDoubleClick:()=>w(c),onContextMenu:b=>L(b,c),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),w(c))},children:[c.mimeType.startsWith("image/")?e.jsx(de,{size:13}):e.jsx(ue,{size:13}),e.jsx("span",{className:"file-name",children:c.path.replace(/^\//,"")}),e.jsx("span",{className:"file-size",children:me(c.size)})]},c.path)}),h&&e.jsx(je,{menu:h,onClose:()=>g(null)})]})},gt=({cfg:n,sessionConfig:s,onToast:r})=>{const i=s?.groupChat&&s.groupAgents?.length?Array.from(new Set(s.groupAgents)):[s?.agentSlug||He];return e.jsx("div",{children:i.map(p=>e.jsx(ft,{cfg:n,slug:p,onToast:r,showName:i.length>1,canAppend:i.length===1},p))})},ft=({cfg:n,slug:s,onToast:r,showName:i,canAppend:p})=>{const{t:a}=I(),[y,o]=l.useState(null),[m,u]=l.useState([]),[h,g]=l.useState(null),[d,f]=l.useState(""),w=l.useCallback(async()=>{try{o(await Ve(O(),s))}catch(j){o(null),r(a("panel.toast.memoryLoadFail",{err:j?.message||j}),!0)}try{const j=(await pe(O(),s)).slice().sort((c,k)=>k.localeCompare(c)).slice(0,3),L=(await Promise.all(j.map(async c=>({date:c,content:await Ye(O(),s,c)})))).filter(c=>c.content.trim());u(L)}catch{u([])}},[n,s,r,a]);l.useEffect(()=>{w()},[w]);const T=async()=>{const j=d.trim();if(j)try{const F=await Ze(O(),j,s);r(F.appended?a("panel.toast.memorySaved"):a("panel.toast.memoryNotWritten")),f(""),w()}catch(F){r(a("panel.toast.appendFail",{err:F?.message||F}),!0)}};return e.jsxs("div",{className:"agentmem",children:[i&&e.jsx("div",{className:"agentmem-agent",children:s}),e.jsx("div",{className:"panel-section-title",children:a("panel.memory.currentAgent")}),y===null&&e.jsx("div",{className:"panel-note",children:a("panel.memory.notConnected")}),y!==null&&(y.trim()?e.jsx("div",{style:{fontSize:"var(--ui-font-meta, 12px)",padding:"0 8px"},className:"msg-content",children:e.jsx(V,{content:y})}):e.jsx("div",{className:"panel-note",children:a("panel.memory.empty")})),p&&e.jsxs("div",{style:{display:"flex",gap:6,padding:"8px 8px 0"},children:[e.jsx("input",{type:"text",value:d,placeholder:a("panel.memory.appendPlaceholder"),onChange:j=>f(j.target.value),onKeyDown:j=>j.key==="Enter"&&void T(),style:{flex:1,fontSize:"var(--ui-font-meta, 12px)",padding:"5px 8px",background:"var(--bg-card)",border:"var(--border-width) solid var(--border)",borderRadius:"var(--radius-sm)",outline:"none"}}),e.jsx("button",{className:"btn ghost sm",onClick:()=>{T()},children:a("panel.memory.append")})]}),e.jsx("div",{className:"panel-section-title",style:{marginTop:14},children:a("panel.memory.recentLogs")}),m.length===0&&e.jsx("div",{className:"panel-note",children:a("panel.log.none")}),m.map(j=>{const F=h===j.date;return e.jsxs("div",{className:"agentmem-log",children:[e.jsxs("button",{className:"agentmem-log-head",onClick:()=>g(F?null:j.date),children:[F?e.jsx(G,{size:12}):e.jsx(J,{size:12}),e.jsx("span",{children:j.date})]}),F&&e.jsx("div",{className:"agentmem-log-body msg-content",children:e.jsx(V,{content:ve(j.content)})})]},j.date)})]})};export{Dt as A,St as C,Ct as R,je as a,be as m};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./pageStore-CyvNZEYX.js","./index-fDB1l4d-.js","./react-b7FrqRQR.js","./client-fKy9CWk0.js","./pageStore-ys8L4rjF.css","./dbStore-BIG5Mfh2.js","./drawingStore-CGvTqqYW.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as c,j as t,a as mt,u as be,t as es,_ as Be,b as Us,L as Ks}from"./index-fDB1l4d-.js";import{c as Xs}from"./client-fKy9CWk0.js";import{n as qs,p as Gs,L as ts,q as Zs,C as Ln,t as Qs,v as Ct,w as Js,u as eo,x as to,c as no,y as so,z as oo,D as Mn,e as io,h as ns,F as ao,A as ss,G as $e,S as os,M as is,j as as,B as ro,W as co,T as lo,P as rs,k as uo,N as mo,H as po,I as fo,l as ho,m as go,E as bo}from"./viewportLock-BZq5PTeN.js";import{M as wo,I as vo,F as ko,S as yo,U as xo,C as So,D as jo,G as Eo,E as Co,W as No,J as Io,P as To,K as Lo,L as Mo,N as zo,R as Po,T as fe,V as Do,u as N,X as zn,Y as Pn,Z as Ro,_ as At,$ as Oo,a0 as Ye,a1 as Ao,a2 as Fo,a3 as _o,a4 as Ft,a5 as Bo,a6 as Dn,a7 as $o,a8 as Vo,a9 as Ho,aa as Wo,ab as Yo,ac as cs,ad as Uo,ae as _t,l as Bt,af as Ko,j as pt,k as Xo,ag as ls,ah as qo,ai as Rn,s as Go,aj as ds,h as Zo,ak as Qo,Q as Jo,al as ei,O as ti,am as On,an as ni,i as $t,ao as si,ap as oi,aq as ii,ar as ai,as as ri,r as ci,t as li,v as di,w as ui,at as mi,y as pi,z as fi,A as hi,B as gi,au as bi}from"./appStore-DDOkzWDA.js";import{p as Ue,B as us,D as wi,L as vi,P as ki,q as yi,r as xi,M as Si,C as ji,I as Ei,F as Pt,t as Ci,Z as ms,k as ae,v as Ni,f as K,w as Ii,x as Ti,y as ps,l as W,z as Ee,A as ge,U as An,E as Li,G as Mi,H as Fn,J as _n,K as zi,O as Pi,Q as Nt,R as ct,T as Di,V as Ri,W as Oi,X as Bn,Y as Ai,_ as $n,$ as Fi,a0 as it,a1 as Vn,a2 as _i,a3 as je,a4 as Bi,a5 as $i,a6 as Dt,a7 as Vi,a8 as Rt,a9 as Hi,aa as Wi,ab as Yi,ac as Ui,ad as fs,S as Ki,ae as ft,af as Ve,ag as Xi,ah as Vt,ai as hs,s as Ke,aj as gs,ak as ut,al as Ht,am as qi,an as Gi,ao as Zi,ap as Qi,aq as Hn,ar as Ji,as as ea,at as ta,au as na,av as sa,aw as oa,ax as ia}from"./pageStore-CyvNZEYX.js";import{P as aa}from"./pen-tool-DD5_N4lZ.js";import{T as ra,R as ca,V as la,M as da,C as ua,a as ma,H as pa,f as fa}from"./userSpaces-oMHIWgYe.js";import{M as ha}from"./Chrome-C7F6fdDp.js";import{P as ga,W as ba,H as wa,A as Se}from"./DashboardGridView-CR-R_qV8.js";import{S as va}from"./star-B0sZEmbj.js";import{F as bs}from"./folder-1OJQeDI1.js";import{C as ka}from"./chevron-up-ChXNh14u.js";import{F as ws}from"./UnifiedPage-s7-tDSwG.js";import{n as Wn}from"./nativeDownload-DsGyUSJ5.js";import{q as ya,a as xa}from"./PluginToolCard-DCzLhsCA.js";import"./i18n.generated-DW_l6CkR.js";import{n as Sa}from"./codeStudioStore-BgLfCDK2.js";import"./ModelPill--CU3XTIQ.js";import"./nativeSheetMenu--iihXNVd.js";import"./upload-Dy7svciS.js";import"./MuseView-CvsO62Fo.js";import"./automationListSource-B1jz6q0t.js";import"./messages-GQUjmbwW.js";import"./message-square-plus-BvUfAAZm.js";import"./rotate-ccw-D8kni6Ni.js";import"./undo-2-QimgpLBn.js";import"./git-branch-BMajF2cu.js";import"./selectionActions-DIq0xDm8.js";import"./mediaPlayer-DB4KUvua.js";import"./react-b7FrqRQR.js";import"./arrow-up-right-BptN64d-.js";import"./CapabilityMenu-DyHTEYLr.js";import"./folder-plus-DP9sFr26.js";import"./layout-grid-oIyIGbc5.js";import"./SettingsPage-B9mmkWaM.js";import"./ipc-SAPDwyQ4.js";import"./lock-open-D2nMg0ga.js";import"./MarkdownBlock-DSItkLhu.js";import"./index-CmsN2Zm2.js";import"./linkFollow-uke1Xtit.js";import"./listFold-BeNv2v6M.js";import"./FloatingToc-DO7SH8Ku.js";import"./canvasPrefs-ArsX3NFO.js";import"./type-Dt7RNB9g.js";import"./file-down-Z913cCyQ.js";import"./AutomationBuilder-B09c-5Bi.js";import"./dbStore-BIG5Mfh2.js";import"./gestures-ZhFAENNZ.js";import"./pencil--sWwxHdP.js";import"./tanguProbe-B8Qv2vcm.js";import"./sessionTitle-Ctp4iNKu.js";import"./index-CIKPZc3Q.js";import"./create-DYmVT68X.js";import"./launchpad-CcmSwlJl.js";import"./CtxMenuButtons-BYjrbUKS.js";import"./phoneList-DKRMxQHf.js";import"./pdf.worker.min-CGb3BKV9.js";import"./code-xml-DCCD9eCS.js";import"./zoom-in-DDEtY_Go.js";import"./minimize-2-CMhzL6ZW.js";import"./InlineFiles-CAIyTk1n.js";import"./pen-line-DC3lbEY1.js";import"./ViewSelectionBar-WmSWMFsR.js";import"./InlineAiPanel-CdIPINsA.js";import"./GitCloneDialog-CbW-RJak.js";import"./log-out-D70NCXC4.js";import"./StudioGuestSurface-OOhRA8nt.js";/* empty css */import"./drawingStore-CGvTqqYW.js";import"./magnet-Cqmm97W8.js";import"./pageTree-Ci2qzrs1.js";import"./pluginExt-Byb64tQO.js";import"./folder-minus-D_j1SwHu.js";import"./redo-2-CqlqhWrI.js";import"./foldActions-DGIPTmE1.js";const ja=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],Ea=Ue("box",ja);const Ca=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Na=Ue("calendar",Ca);const Ia=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],Ta=Ue("chevrons-left",Ia);const La=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],Ma=Ue("chevrons-right",La);const za=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],Pa=Ue("tag",za),vs={folder:bs,"folder-open":Po,star:va,heart:pa,home:zo,zap:ms,bookmark:Ci,bell:Mo,tag:Pa,flag:Lo,pin:ga,box:Ea,package:To,settings:Io,wrench:No,terminal:ma,code:ua,"file-text":Pt,image:Ei,music:da,video:la,camera:Co,globe:Eo,compass:ji,map:ha,calendar:Na,clock:jo,mail:So,"message-circle":Si,users:xi,user:xo,search:yo,filter:ko,sparkles:yi,rocket:ca,target:ra,trophy:Zs,lightbulb:ts,coffee:Gs,palette:ki,layers:vi,database:wi,"pen-tool":aa,inbox:vo,bot:us,command:qs,moon:wo},Da=Object.keys(vs),It=n=>n?vs[n]:void 0;function Ra(n,i,o){const d=n.target.closest("button")??i;let a=!1,v=!1,p,g;const w=parseFloat(getComputedStyle(document.body).zoom)||1,m=n.clientX,k=n.clientY;d.setPointerCapture(n.pointerId);const f=(j=!1)=>{if(v=!0,window.removeEventListener("pointermove",I,!0),window.removeEventListener("pointerup",C,!0),window.removeEventListener("pointercancel",b,!0),window.removeEventListener("keydown",h,!0),window.removeEventListener("blur",b),d.removeEventListener("lostpointercapture",b),d.hasPointerCapture(n.pointerId)&&d.releasePointerCapture(n.pointerId),document.documentElement.classList.remove("rb-pointer-dragging"),p?.remove(),g?.remove(),a){const A=y=>{y.preventDefault(),y.stopImmediatePropagation(),_()},L=()=>{clearTimeout(X),X=window.setTimeout(_,0)},_=()=>{window.removeEventListener("click",A,!0),window.removeEventListener("pointerup",L,!0),clearTimeout(X)};window.addEventListener("click",A,!0),j||window.addEventListener("pointerup",L,{capture:!0,once:!0});let X=window.setTimeout(_,j?0:1e4)}},b=()=>{v||(f(),a&&o.cancel())},h=j=>{j.key==="Escape"&&(j.preventDefault(),j.stopImmediatePropagation(),b())},I=j=>{if(!(j.pointerId!==n.pointerId||v)){if(!(j.buttons&1)){b();return}if(!(!a&&Math.hypot(j.clientX-m,j.clientY-k)<6)){a||(a=!0,document.documentElement.classList.add("rb-pointer-dragging"),g=document.createElement("div"),g.className="rb-pointer-shield",g.style.width=`${window.innerWidth/w}px`,g.style.height=`${window.innerHeight/w}px`,g.setAttribute("aria-hidden","true"),document.body.appendChild(g),p=i.cloneNode(!0),p.removeAttribute("data-id"),p.querySelectorAll("[id]").forEach(A=>A.removeAttribute("id")),p.className="rb-pointer-ghost",p.setAttribute("aria-hidden","true"),p.style.width=`${i.getBoundingClientRect().width/w}px`,document.body.appendChild(p),o.start()),j.preventDefault(),p.style.left=`${(j.clientX+12)/w}px`,p.style.top=`${(j.clientY+12)/w}px`,g.style.pointerEvents="none";try{o.move(j)}finally{g.style.pointerEvents=""}}}},C=j=>{j.pointerId!==n.pointerId||j.button!==0||v||(f(!0),a&&(j.preventDefault(),o.drop(j)))};return window.addEventListener("pointermove",I,!0),window.addEventListener("pointerup",C,!0),window.addEventListener("pointercancel",b,!0),window.addEventListener("keydown",h,!0),window.addEventListener("blur",b),d.addEventListener("lostpointercapture",b),b}const Oa=300,Aa=150;function Fa(n){const i=d=>n.known(d.type),o=n.active?n.stash.filter(i):[];return o.length?o:n.defaults.filter(i)}function _a(n){return n.zone==="shell"&&n.buttons===0&&!n.typing}const Tt=4,Yn=5,Un=5,Ba=1e3,$a=100;function Kn(n){if(n>=9)return"";const i=Hi({id:`space-slot-${n+1}`,hotkey:`mod+${n+1}`});return i?Wi(i,Yi()):""}function He({item:n,expanded:i,dot:o}){if(n.component){const v=n.component;return t.jsx(v,{expanded:i})}const d=n.icon,a=n.tooltip?je(n.tooltip):"";return t.jsxs("button",{className:"rb-btn","aria-label":a||void 0,"data-rb-tip":i?void 0:a||void 0,onClick:n.onClick,children:[d&&t.jsx(d,{size:18}),o&&t.jsx("span",{className:"rb-badge rb-dot","aria-hidden":"true"}),i&&t.jsx("span",{className:"rb-label",children:a})]})}function Va({cmd:n,expanded:i,overrideIcon:o}){const[,d]=c.useReducer(g=>g+1,0),a=o??n.icon??ms,v=je(n.title);let p;if(n.checked)try{p=!!n.checked()}catch{p=void 0}return t.jsxs("button",{className:`rb-btn${p?" is-on":""}`,"aria-pressed":p,"aria-label":v,"data-rb-tip":i?void 0:v,onMouseEnter:n.checked?d:void 0,onMouseLeave:n.checked?d:void 0,onClick:()=>{const g=n.run();n.checked&&(d(),g&&typeof g.then=="function"&&g.then(d,d))},children:[t.jsx(a,{size:18}),i&&t.jsx("span",{className:"rb-label",children:v})]})}const at=24,We=n=>n.startsWith("space:")?n.slice(6):null,Ha=600;function Wa(){const n=ae(e=>e.items),i=Ni(n),o=ae(e=>e.expanded),d=ae(e=>e.order),a=ae(e=>e.bottomOrder),v=ae(e=>e.folders),p=ae(e=>e.commandItems),g=ae(e=>e.commandIcons),w=ae(e=>e.recentCount),m=K(e=>e.recent),k=Ii(e=>e.commands);Ti(e=>e.overrides);const{t:f}=ps(),b=()=>ae.getState(),[h,I]=c.useState(null),C=c.useRef(void 0);c.useEffect(()=>()=>C.current?.(),[]);const[j,A]=c.useState(null),[L,_]=c.useState(null),[X,y]=c.useState(null),[z,M]=c.useState(null),[V,B]=c.useState(null),[$,G]=c.useState(null),[q,Ce]=c.useState(99),P=c.useRef(null),le=c.useRef(null),Ne=c.useRef(null),re=c.useRef(null),D=c.useRef(null),de=c.useRef(null),se=c.useRef(void 0),we=c.useRef(null),[Q,Ie]=c.useState({top:0,bottom:0}),[Y,qe]=c.useState(null),[Te,S]=c.useState({}),F=c.useRef({}),oe=c.useRef({});c.useEffect(()=>()=>{for(const e of Object.values(F.current))window.clearTimeout(e?.timer)},[]);const[Z,ve]=c.useState(!1),ue=c.useRef(void 0);c.useEffect(()=>()=>window.clearTimeout(ue.current),[]);const Le=e=>{for(const r of["top","bottom"]){const u=F.current[r];if(!u)continue;window.clearTimeout(u.timer);const l=oe.current[r];l&&(l.style.transform=u.from?`translateY(${-u.from*H}px)`:""),delete F.current[r]}S({}),window.clearTimeout(ue.current);const s=!window.matchMedia("(prefers-reduced-motion: reduce)").matches;ve(s),s&&(ue.current=window.setTimeout(()=>ve(!1),240)),qe(e)},[Me,Wt]=c.useState(null),ze=c.useRef(null),ht=c.useRef(void 0),Ge=c.useRef(!1),Yt=c.useRef(0),Pe=()=>{window.clearTimeout(ht.current),ze.current=null,Ge.current&&(Ge.current=!1,Yt.current=Date.now()),Wt(null)},Ts=!W(e=>e.leftVisible),[U,Ut]=c.useState(null),Kt=K(e=>U?e.spaces.find(s=>s.id===U.spaceId):void 0),gt=c.useRef(null),Ze=c.useRef(null),ke=c.useRef(void 0),De=c.useRef(void 0),Xt=c.useRef(null),[,Qe]=c.useReducer(e=>e+1,0),Je=()=>{window.clearTimeout(De.current),De.current=void 0},me=()=>{window.clearTimeout(ke.current),Je(),Ut(null)},bt=!!h||!!V||!!$||!!z,Ls=e=>W.getState().leftVisible&&e===K.getState().activeSpaceId,qt=K(e=>!!U&&e.activeSpaceId===U.spaceId)&&!Ts;c.useEffect(()=>{(bt||qt)&&me()},[bt,qt]),c.useEffect(()=>U?Ee(()=>{U.views.some(e=>!ge(e.type))&&me()}):void 0,[U]),c.useEffect(()=>()=>{window.clearTimeout(ke.current),window.clearTimeout(De.current)},[]);const Gt=e=>{if(Ls(e)){me();return}const{spaces:s,activeSpaceId:r}=K.getState(),u=s.find(R=>R.id===e),l=W.getState(),x=e===r,E=u?Fa({active:x,stash:l.stash.left,defaults:x?l.sidebarDefaults.left:u.sidebarDefaults.left,known:R=>!!ge(R)}):[];Je(),Ut(E.length?{spaceId:e,views:E}:null)},Ms=e=>{const s=e.target.closest("[data-space-id]")?.dataset.spaceId??null;s!==Ze.current&&(window.clearTimeout(ke.current),Ze.current=s,s&&(bt||(U?.spaceId===s?Je():U?Gt(s):ke.current=window.setTimeout(()=>{Ze.current===s&&Gt(s)},Oa))))},Zt=!!U;c.useEffect(()=>{if(!Zt)return;const e=T=>{const O=T instanceof Element?T:null;return O?gt.current?.contains(O)?"card":P.current?.contains(O)&&O.closest("[data-space-id]")?"trigger":O.closest(".shell")?"shell":"overlay":"overlay"},s=()=>{const T=document.activeElement;return!!T&&!!gt.current?.contains(T)&&T.matches('input, textarea, select, [contenteditable]:not([contenteditable="false"])')};let r=null;const u=(T,O)=>{const te=e(T);_a({zone:te,buttons:O,typing:te==="shell"&&s()})?De.current===void 0&&(De.current=window.setTimeout(me,Aa)):Je()},l=T=>{r=T.target,u(T.target,T.buttons)},x=()=>{window.setTimeout(()=>u(r,0),0)},E=T=>{const O=e(T.target);(O==="shell"||O==="trigger")&&me()},R=T=>{T.key==="Escape"&&!s()&&me()};return document.addEventListener("mousemove",l),document.addEventListener("mouseover",l),document.addEventListener("mouseup",l),document.addEventListener("focusout",x),document.addEventListener("mousedown",E,!0),window.addEventListener("keydown",R),window.addEventListener("resize",Qe),window.addEventListener(An,Qe),()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseover",l),document.removeEventListener("mouseup",l),document.removeEventListener("focusout",x),document.removeEventListener("mousedown",E,!0),window.removeEventListener("keydown",R),window.removeEventListener("resize",Qe),window.removeEventListener(An,Qe)}},[Zt]);const zs=()=>{const e=P.current,s=ct(e),r=e?.getBoundingClientRect(),u=e?.parentElement?.querySelector(".shell-work"),l=u?.getBoundingClientRect(),E=(u?.querySelector(".dv-prefix--edge")?.closest(".dv-tabs-and-actions-container")?.getBoundingClientRect()?.bottom??l?.top??0)+4,R=(l?.bottom??window.innerHeight)-8,T=W.getState(),O=Bi((l?.width??1200)/s,"left",{free:T.sideFree.left,saved:T.sideWidths.left,scale:T.sideScale.left}),te=T.leftVisible?T.api?.panels.find(Fe=>Fe.params?.__loc==="left")?.group.element.getBoundingClientRect():void 0;return te?.height?{left:te.left/s,top:te.top/s,height:te.height/s,width:O,"--rb-peek-lights":"26px"}:{left:((r?.right??44)+4)/s,top:E/s,height:Math.max(160,R-E)/s,width:O}},wt=!!h||!!V||!!$||!!z||!!U;c.useEffect(()=>{(wt||o)&&Pe()},[wt,o]),c.useEffect(()=>()=>window.clearTimeout(ht.current),[]);const Ps=e=>{const s=e.target.closest("[data-rb-tip]");if(s===ze.current)return;const r=Ge.current||Date.now()-Yt.current<=$a;if(Pe(),!s||wt||o)return;ze.current=s;const u=()=>{if(ze.current!==s||!s.isConnected||!s.dataset.rbTip)return;const l=s.getBoundingClientRect();Ge.current=!0,Wt({text:s.dataset.rbTip,mid:l.top+l.height/2})};r?u():ht.current=window.setTimeout(u,Ba)},Ds=new Set(v.flatMap(e=>e.items)),et=new Map,Qt=e=>{const s=[];for(const u of n)(u.side??"top")===e&&!u.pinned&&s.push({kind:"item",id:u.id,item:u});if(e==="bottom")for(const u of p){const l=k.find(x=>x.id===u);l&&s.push({kind:"cmd",id:`cmd:${u}`,cmd:l})}for(const u of v)u.zone===e&&s.push({kind:"folder",id:u.id,folder:u});for(const u of s)et.set(u.id,u);return Ai(s.map(u=>u.id),e==="top"?d:a).map(u=>et.get(u)).filter(u=>!Ds.has(u.id))},J=Qt("top"),ee=Qt("bottom"),Jt=e=>e.items.reduce((s,r)=>s+(et.has(r)?1:0),0),Rs=n.filter(e=>e.side==="bottom"&&e.pinned),Os=n.filter(e=>e.side==="head"),en=n.filter(e=>e.side==="home");c.useEffect(()=>{const e=[...en.map(s=>s.id),...[...J,...ee].flatMap(s=>s.kind==="folder"?s.folder.items:[s.id])];Li(e.filter(s=>s.startsWith("space:")).map(s=>s.slice(6)))});const H=(o?34:32)+Tt;c.useLayoutEffect(()=>{const e=P.current;if(!e)return;const s=()=>{const u=getComputedStyle(e),l=(le.current?.offsetHeight??0)+(re.current?.offsetHeight??0),x=e.clientHeight-parseFloat(u.paddingTop)-parseFloat(u.paddingBottom)-l-(Ne.current?.offsetHeight??0)-2*H-48;Ce(Math.max(2,Math.floor(x/H)))};s();const r=new ResizeObserver(s);return r.observe(e),re.current&&r.observe(re.current),()=>r.disconnect()},[o,H,n.length,v.length,p.length,Y]);const tn=(e,s)=>e<=s?e:s+1,nn=tn(J.length,Yn),vt=tn(ee.length,Un);let ce=nn,pe=vt;if(Y)Y==="top"?ce=q:pe=q;else if(ce+pe>q)if(J.length===0)ce=0,pe=q;else if(ee.length===0)ce=q,pe=0;else{const e=Math.floor(q/2);ce=Math.max(1,Math.min(nn,Math.max(e,q-vt))),pe=Math.max(1,Math.min(vt,q-ce))}const sn=(e,s,r,u,l)=>{if(e.length<=s&&e.length<=l)return{shown:e,tail:[],start:0,max:0};const x=Math.max(0,s-1),E=e.length-x,R=Math.min(Math.max(0,u),E),T=r?e.length-x-R:R;return{shown:e.slice(T,T+x),tail:[...e.slice(0,T),...e.slice(T+x)],start:T,max:E}},Re=sn(J,ce,!1,Q.top,Y==="top"?1/0:Yn),Oe=sn(ee,pe,!0,Q.bottom,Y==="bottom"?1/0:Un),on=m.map(e=>n.find(s=>s.id===`space:${e}`)).filter(e=>!!e).slice(0,Mi(w,q,ce,pe,!!Y)),As=(e,s)=>r=>{const u=oe.current[e];if(!s.max||h||!r.deltaY||!u)return;window.clearTimeout(se.current);let l=F.current[e];l||(l=F.current[e]={px:s.start*H,from:s.start,timer:0},S(E=>({...E,[e]:!0}))),window.clearTimeout(l.timer);const x=r.deltaMode?Math.sign(r.deltaY)*H:Math.max(-H,Math.min(H,r.deltaY));l.px=Math.max(0,Math.min(s.max*H,l.px+x)),u.style.transform=`translateY(${-l.px}px)`,l.timer=window.setTimeout(()=>Fs(e,s),120)},Fs=(e,s)=>{const r=F.current[e],u=oe.current[e];if(!r||!u)return;const l=r.at??r.from,x=r.px-l*H;let E=Math.round(r.px/H);E===l&&x&&(E+=Math.sign(x)),an(e,s,Math.max(0,Math.min(s.max,E)))},an=(e,s,r)=>{const u=oe.current[e];if(!u)return;let l=F.current[e];l||(l=F.current[e]={px:s.start*H,from:s.start,timer:0},S(x=>({...x,[e]:!0}))),window.clearTimeout(l.timer),l.px=r*H,l.at=r,u.style.transform=r?`translateY(${-r*H}px)`:"",l.timer=window.setTimeout(()=>{delete F.current[e],S(x=>({...x,[e]:!1})),Ie(x=>({...x,[e]:e==="top"?r:s.max-r}))},240)};c.useEffect(()=>()=>window.clearTimeout(se.current),[]);const rn=c.useRef(()=>{});rn.current=()=>{if(!h)for(const[e,s]of[["top",Re],["bottom",Oe]])Q[e]&&(s.max&&oe.current[e]?an(e,s,e==="top"?0:s.max):Ie(r=>({...r,[e]:0})))};const cn=!!(Q.top||Q.bottom||Te.top||Te.bottom);c.useEffect(()=>{if(!cn)return;const e=()=>{$n()&&(window.clearTimeout(se.current),se.current=window.setTimeout(()=>{$n()&&rn.current()},Ha))},s=r=>{const u=r.target;r.button!==0||u?.closest?.(".rb-menu, .rb-iconpick, [data-rb-overlay]")||u&&(P.current?.contains(u)||u.closest(".rb-fly"))&&!u.closest(".rb-btn:not(.rb-more, .rb-plus, .rb-toggle, .rb-folder)")||e()};return window.addEventListener("click",s,!0),window.addEventListener("blur",e),()=>{window.removeEventListener("click",s,!0),window.removeEventListener("blur",e)}},[cn]);const ie=z?.folderId?v.find(e=>e.id===z.folderId):void 0,tt=()=>{de.current&&(window.clearTimeout(de.current),de.current=null)},ln=()=>{tt(),de.current=window.setTimeout(()=>{h||M(null)},150)},kt=(e,s,r,u)=>{tt(),M({key:e,zone:s,folderId:u,top:r.getBoundingClientRect().top})};c.useLayoutEffect(()=>{const e=D.current;if(!e||!z)return;const s=e.getBoundingClientRect().bottom-(window.innerHeight-8);s>0&&M({...z,top:Math.max(8,z.top-s)})},[z?.key,ie?.items.length]);const dn=!!z;c.useEffect(()=>{if(!dn)return;const e=r=>{r.key==="Escape"&&M(null)},s=r=>{const u=r.target;!D.current?.contains(u)&&!P.current?.contains(u)&&M(null)};return window.addEventListener("keydown",e),window.addEventListener("mousedown",s),()=>{window.removeEventListener("keydown",e),window.removeEventListener("mousedown",s)}},[dn]),c.useEffect(()=>{if(!Y)return;const e=()=>Le(null),s=u=>{if(u.button!==0)return;const l=u.target;l?.closest?.(".rb-menu, .rb-iconpick, .rb-fly, [data-rb-overlay]")||l&&P.current?.contains(l)&&l.closest("button")||e()},r=u=>{u.key==="Escape"&&e()};return window.addEventListener("pointerdown",s,!0),window.addEventListener("keydown",r),window.addEventListener("blur",e),()=>{window.removeEventListener("pointerdown",s,!0),window.removeEventListener("keydown",r),window.removeEventListener("blur",e)}},[Y,H]);const yt=c.useRef(new Map),un=c.useRef(()=>{});c.useEffect(()=>{un.current=e=>{const s=J[e];if(s){if(s.kind==="folder"){const r=yt.current.get(s.id)??P.current;r&&kt(s.id,"top",r,s.id);return}M(null),s.kind==="cmd"?s.cmd.run():s.id.startsWith("space:")?Fn(s.id.slice(6)):s.item.onClick?.()}}});const mn=Math.min(9,J.length);c.useEffect(()=>{for(let e=1;e<=9;e++){if(e>mn){_n(`space-slot-${e}`);continue}zi({id:`space-slot-${e}`,title:()=>Pi("lcl.ribbon.switchSpace",{n:e}),keywords:`space switch ${e} 切换 空间`,hotkey:`mod+${e}`,run:()=>un.current(e-1)})}return()=>{for(let e=1;e<=9;e++)_n(`space-slot-${e}`)}},[mn]);const pn=(e,s,r,u)=>{e.dataTransfer.effectAllowed="move";const l=e.currentTarget.getBoundingClientRect();e.dataTransfer.setDragImage(e.currentTarget,e.clientX-l.left,e.clientY-l.top),I({id:s,zone:r,from:u})},ye=()=>{we.current=null,I(null),A(null),_(null),y(null)},Ae=h&&fe()?.openSpace?We(h.id):null,fn=c.useRef({dropped:!1,gone:!1}),xt=(e,s)=>{const r=P.current?.getBoundingClientRect();if(!r)return!0;const u=x=>e>=x.left-at&&e<=x.right+at&&s>=x.top-at&&s<=x.bottom+at,l=D.current?.getBoundingClientRect();return u(r)||!!l&&u(l)},hn=e=>{const s=e.target;return!!s&&(!!P.current?.contains(s)||!!D.current?.contains(s))};c.useLayoutEffect(()=>{if(!Ae)return;const e={dropped:!1,gone:!1};fn.current=e;const s=l=>{e.gone=!1,!hn(l)&&(l.preventDefault(),l.stopPropagation(),l.dataTransfer&&(l.dataTransfer.dropEffect="move"),_(x=>x&&null),y(x=>x&&null))},r=l=>{e.dropped=!0,!hn(l)&&(l.preventDefault(),l.stopPropagation(),xt(l.clientX,l.clientY)||fe()?.openSpace?.(Ae,{screenX:l.screenX,screenY:l.screenY}))},u=l=>{(l.clientX<=0||l.clientY<=0||l.clientX>=window.innerWidth||l.clientY>=window.innerHeight)&&(e.gone=!0)};return window.addEventListener("dragover",s,!0),window.addEventListener("drop",r,!0),window.addEventListener("dragleave",u,!0),()=>{window.removeEventListener("dragover",s,!0),window.removeEventListener("drop",r,!0),window.removeEventListener("dragleave",u,!0)}},[Ae]);const gn=e=>{const s=fn.current;if(Ae&&!s.dropped){const{clientX:r,clientY:u}=e,l=r<0||u<0||r>window.innerWidth||u>window.innerHeight,x=!l&&/^(IFRAME|WEBVIEW)$/.test(document.elementFromPoint(r,u)?.tagName??"");(l||!xt(r,u)&&(s.gone||x))&&fe()?.openSpace?.(Ae,e.screenX||e.screenY?{screenX:e.screenX,screenY:e.screenY}:void 0)}ye()},xe=(e,s,r)=>{s&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move",r?.())},bn=(e,s)=>{const r=e.querySelectorAll(".rb-slot"),u=r[0]?.getBoundingClientRect().top??0,l=r.length>1?r[1].getBoundingClientRect().top-u:0;return{top:u,pitch:l,grabDy:s??l/2}},wn=(e,s,r)=>_i(s,r,we.current??bn(e)),vn=(e,s)=>{const r=e.parentElement;r&&(we.current=bn(r,s-e.getBoundingClientRect().top))},nt=(e,s,r=h)=>{const u=r;if(ye(),!u||u.zone!==e||u.id===s)return;u.from&&b().moveOutOfFolder(u.id);const l=e==="top"?b().order:b().bottomOrder,x=Fi(l,(e==="top"?J:ee).map(R=>R.id)),E=s?x.indexOf(s):-1;b().setZoneOrder(e,it(x,u.id,E>=0?E:x.length))},st=(e,s,r=h)=>{const u=r;if(ye(),!(!u||u.zone!==e.zone||u.id.startsWith("folder:"))){if(u.from===e.id)b().setFolderItems(e.id,it(e.items,u.id,s??e.items.length));else if(b().moveIntoFolder(e.id,u.id),u.from||b().setZoneOrder(e.zone,Vn(e.zone==="top"?b().order:b().bottomOrder,(e.zone==="top"?J:ee).map(l=>l.id),u.id)),s!==void 0){const l=b().folders.find(x=>x.id===e.id);l&&b().setFolderItems(e.id,it(l.items,u.id,s))}}},St=c.useRef(null);St.current={target:(e,s)=>{const r=document.elementFromPoint(e.clientX,e.clientY),u=!!r&&(!!P.current?.contains(r)||!!D.current?.contains(r));if(u){const x=r.closest("[data-rb-folder]")?.dataset.rbFolder,E=v.find(O=>O.id===x);if(E&&E.zone===s.zone){const O=r.closest("[data-rb-folder-index]");return _(null),y(E.id),A(O?.dataset.id??null),O||kt(E.id,E.zone,r.closest("[data-rb-folder]"),E.id),{kind:"folder",folder:E,at:O?Number(O.dataset.rbFolderIndex):void 0}}const R=r.closest("[data-rb-more]")?.dataset.rbMore;if(R===s.zone)return _(null),y(`more:${R}`),{kind:"bar",zone:s.zone,id:s.zone==="bottom"?ee[0]?.id??null:null};const T=r.closest(".rb-top, .rb-bottom");if(T){const O=T.classList.contains("rb-top")?"top":"bottom";if(O!==s.zone)return{kind:"cancel"};const te=(O==="top"?Re:Oe).shown.map(_e=>_e.id),Fe=wn(T,e.clientY,te.length);return y(null),A(null),_(_e=>_e?.zone===O&&_e.index===Fe?_e:{zone:O,index:Fe}),{kind:"bar",zone:O,id:te[Fe]??null}}}return _(null),y(null),A(null),{kind:e.clientX<0||e.clientY<0||e.clientX>=window.innerWidth||e.clientY>=window.innerHeight||!u&&!xt(e.clientX,e.clientY)?"tear":"cancel"}},drop:(e,s,r)=>{if(r.kind==="bar")nt(r.zone,r.id,s);else if(r.kind==="folder")st(r.folder,r.at,s);else if(ye(),r.kind==="tear"){const u=fe(),l=We(s.id);l&&u?.openSpace?.(l,u.cursorScreenPoint?.()??{screenX:e.screenX,screenY:e.screenY})}}};const kn=(e,s,r,u)=>{if(!fe()?.ribbonPointerDrag||!We(s)||e.button!==0||!e.isPrimary)return;e.stopPropagation(),C.current?.();const l=e.currentTarget,x={id:s,zone:r,from:u};u||vn(l,e.clientY);let E={kind:"cancel"};C.current=Ra(e.nativeEvent,l,{start:()=>{Pe(),tt(),I(x)},move:R=>{E=St.current.target(R,x)},drop:R=>{St.current.drop(R,x,E)},cancel:ye})},yn=e=>!(fe()?.ribbonPointerDrag&&We(e)),xn=Nt.prompt??((e,s)=>Promise.resolve(window.prompt(e,s))),_s=e=>{xn(f("lcl.ribbon.newFolder"),f("lcl.ribbon.folderDefaultName")).then(s=>{const r=s?.trim();r&&b().addFolder(e,r)})},ot=e=>[...e==="top"&&Nt.newSpace?[{label:f("lcl.ribbon.newSpace"),onClick:Nt.newSpace}]:[],...e==="bottom"?[{label:f("lcl.ribbon.addCommand"),onClick:()=>$i(s=>b().addCommandItem(s))}]:[],{label:f(e==="top"?"lcl.ribbon.newFolderSpaces":"lcl.ribbon.newFolderCommands"),onClick:()=>_s(e)}],Bs=e=>s=>{s.defaultPrevented||(s.preventDefault(),B({x:s.clientX,y:s.clientY,entries:ot(e)}))},$s=e=>{e.defaultPrevented||e.nativeEvent===Xt.current||(e.preventDefault(),B({x:e.clientX,y:e.clientY,entries:[...ot("top"),...ot("bottom")]}))},Sn=(e,s,r,u)=>{B(null),G({x:e,y:s,current:r,apply:u})},Vs=e=>s=>{s.preventDefault(),s.stopPropagation();const r=s.clientX,u=s.clientY;B({x:r,y:u,entries:[{label:f("lcl.ribbon.changeIcon"),onClick:()=>Sn(r,u,e.icon,l=>b().setFolderIcon(e.id,l))},{label:f("lcl.ribbon.rename"),onClick:()=>{xn(f("lcl.ribbon.renameFolder"),e.name).then(l=>{const x=l?.trim();x&&b().renameFolder(e.id,x)})}},{label:f("lcl.ribbon.dissolveFolder"),onClick:()=>b().removeFolder(e.id)}]})},jn=e=>{const s=We(e.id),r=fe()?.openSpace;return[...s&&r?[{label:f("lcl.ribbon.openInNewWindow"),onClick:()=>r(s)}]:[],...e.menu?.()??[]]},En=e=>s=>{if(s.defaultPrevented)return;const r=jn(e);r.length&&(s.preventDefault(),s.stopPropagation(),B({x:s.clientX,y:s.clientY,entries:r}))},Cn=e=>s=>{s.preventDefault(),s.stopPropagation();const r=s.clientX,u=s.clientY;B({x:r,y:u,entries:[{label:f("lcl.ribbon.setIcon"),onClick:()=>Sn(r,u,b().commandIcons[e],l=>b().setCommandIcon(e,l))},{label:f("lcl.ribbon.removeCommand"),onClick:()=>b().removeCommandItem(e)}]})},Hs=e=>{const s=It(e.icon)??bs;return t.jsxs("button",{ref:r=>{r?yt.current.set(e.id,r):yt.current.delete(e.id)},className:`rb-btn rb-folder${X===e.id?" drag-into":""}`,"data-rb-folder":e.id,"aria-label":`${e.name} (${Jt(e)})`,onMouseEnter:r=>kt(e.id,e.zone,r.currentTarget,e.id),onMouseLeave:ln,onContextMenu:Vs(e),onDragOver:r=>xe(r,!!h&&h.zone===e.zone&&!h.id.startsWith("folder:"),()=>{_(null),y(e.id)}),onDragLeave:()=>{X===e.id&&y(null)},onDrop:r=>{!h||h.id.startsWith("folder:")||(r.preventDefault(),r.stopPropagation(),st(e))},children:[t.jsx(s,{size:18}),e.items.some(r=>i.has(r))&&t.jsx("span",{className:"rb-badge rb-dot","aria-hidden":"true"}),o&&t.jsx("span",{className:"rb-label",children:e.name})]})},Nn=e=>{const s=Y===e,r=f(s?"lcl.ribbon.less":"lcl.ribbon.more"),u=s?e==="top"?ka:Rt:Vi;return t.jsxs("button",{className:`rb-btn rb-more${s?" is-open":""}${X===`more:${e}`?" drag-into":""}`,"data-rb-more":e,"aria-label":r,"aria-expanded":s,"data-rb-tip":o?void 0:r,onClick:()=>Le(s?null:e),onDragOver:l=>xe(l,!!h&&h.zone===e,()=>{_(null),y(`more:${e}`)}),onDragLeave:()=>{X===`more:${e}`&&y(null)},onDrop:l=>{l.preventDefault(),l.stopPropagation(),nt(e,e==="bottom"?ee[0]?.id??null:null)},children:[t.jsx(u,{size:18}),!s&&(e==="top"?Re:Oe).tail.some(l=>l.kind==="item"?i.has(l.id):l.kind==="folder"&&l.folder.items.some(x=>i.has(x)))&&t.jsx("span",{className:"rb-badge rb-dot","aria-hidden":"true"}),o&&t.jsx("span",{className:"rb-label",children:r})]})},jt=(e,s)=>{const r=s??o;return e.kind==="item"?t.jsx(He,{item:e.item,expanded:r,dot:i.has(e.id)}):e.kind==="cmd"?t.jsx(Va,{cmd:e.cmd,expanded:r,overrideIcon:It(g[e.cmd.id])}):Hs(e.folder)},Ws=(e,s,r,u,l,x)=>{const E=u?u.indexOf(e.id):r;return t.jsxs("div",{"data-id":e.id,className:`rb-slot${h?.id===e.id?" dragging":""}${l?" drag-over":""}`,style:E!==r?{transform:`translateY(${(E-r)*H}px)`}:void 0,draggable:yn(e.id),onPointerDown:R=>kn(R,e.id,s,null),onDragStart:R=>{vn(R.currentTarget,R.clientY),pn(R,e.id,s,null)},onDragEnd:gn,onContextMenu:e.kind==="cmd"?Cn(e.cmd.id):e.kind==="item"?En(e.item):void 0,children:[jt(e),s==="top"&&o&&Kn(x)&&t.jsx("span",{className:"rb-key",children:Kn(x)})]},e.id)},Et=e=>f(e==="top"?"lcl.ribbon.addSpaceOrFolder":"lcl.ribbon.addCommand"),In=e=>t.jsxs("button",{className:"rb-btn rb-plus","aria-label":Et(e),"data-rb-tip":o?void 0:Et(e),onClick:s=>{const r=s.currentTarget.getBoundingClientRect();B({x:r.right+6,y:r.top,entries:ot(e)})},children:[t.jsx(Dt,{size:16}),o&&t.jsx("span",{className:"rb-label",children:Et(e)})]}),Tn=(e,s)=>{const r=s.shown.map(l=>l.id),u=h&&L?.zone===e&&r.includes(h.id)?it(r,h.id,L.index):null;return t.jsxs("div",{className:`rb-group rb-${e}`,onContextMenu:Bs(e),onWheel:As(e,s),onDragOver:l=>{const x=wn(l.currentTarget,l.clientY,r.length);xe(l,!!h&&h.zone===e,()=>{y(null),_(E=>E?.zone===e&&E.index===x?E:{zone:e,index:x})})},onDrop:l=>{l.preventDefault(),l.stopPropagation(),nt(e,(L?.zone===e?r[L.index]:null)??null)},children:[e==="bottom"&&t.jsxs(t.Fragment,{children:[In(e),(s.tail.length>0||Y===e)&&Nn(e)]}),t.jsx("div",{className:"rb-strip","data-guide-anchor":e==="top"?"ribbon-spaces":void 0,style:{height:Math.max(0,s.shown.length*H-Tt)},children:t.jsx("div",{ref:l=>{oe.current[e]=l},className:"rb-strip-in",style:s.start?{transform:`translateY(${-s.start*H}px)`}:void 0,children:(e==="top"?J:ee).map((l,x)=>{const E=x-s.start;return E>=0&&E<s.shown.length?Ws(l,e,E,u,!u&&L?.zone===e&&L.index===E,x):t.jsx("div",{className:"rb-cell","aria-hidden":!0,inert:!0,style:{height:H-Tt},children:(Te[e]||Z)&&jt(l)},l.id)})})}),e==="top"&&t.jsxs(t.Fragment,{children:[(s.tail.length>0||Y===e)&&Nn(e),In(e)]})]})},Ys=(e,s,r,u)=>t.jsx("div",{"data-id":e.id,className:`rb-fly-row${h?.id===e.id?" dragging":""}${j===e.id&&h?.id!==e.id?` drag-over${h&&u.indexOf(h.id)>=0&&u.indexOf(h.id)<r?" below":""}`:""}`,"data-rb-folder":s.id,"data-rb-folder-index":r,draggable:yn(e.id),onPointerDown:l=>kn(l,e.id,s.zone,s.id),onDragStart:l=>{l.stopPropagation(),pn(l,e.id,s.zone,s.id)},onDragOver:l=>xe(l,!!h&&h.zone===s.zone&&h.id!==e.id&&!h.id.startsWith("folder:"),()=>A(e.id)),onDragLeave:()=>{j===e.id&&A(null)},onDrop:l=>{l.preventDefault(),l.stopPropagation(),st(s,r)},onDragEnd:gn,onContextMenu:e.kind==="cmd"?Cn(e.cmd.id):l=>{l.preventDefault(),l.stopPropagation(),B({x:l.clientX,y:l.clientY,entries:[...e.kind==="item"?jn(e.item):[],{label:f("lcl.ribbon.moveOut"),onClick:()=>{b().moveOutOfFolder(e.id);const x=s.zone==="top"?b().order:b().bottomOrder;b().setZoneOrder(s.zone,[...Vn(x,(s.zone==="top"?J:ee).map(E=>E.id),e.id),e.id])}}]})},children:jt(e,!0)},e.id);return t.jsxs("div",{ref:P,className:`rb${o?" rb-expanded":""}${h?" rb-dragging":""}${Y?` rb-open-${Y}`:""}`,onContextMenu:$s,onMouseOver:e=>{Ps(e),Ms(e)},onMouseLeave:()=>{Pe(),window.clearTimeout(ke.current),Ze.current=null},onMouseDownCapture:e=>{Pe(),window.clearTimeout(ke.current),ze.current=e.target.closest("[data-rb-tip]")},onDragOver:e=>xe(e,!!h),onDrop:e=>{if(!h)return;e.preventDefault();const s=h.zone,r=L?.zone===s?(s==="top"?Re:Oe).shown[L.index]?.id:void 0;if(r===void 0){ye();return}nt(s,r)},children:[t.jsxs("div",{ref:le,className:"rb-head",children:[t.jsxs("button",{className:"rb-btn rb-toggle","aria-label":f(o?"lcl.ribbon.iconsOnly":"lcl.ribbon.showLabels"),"aria-expanded":o,"data-rb-tip":o?void 0:f("lcl.ribbon.showLabels"),onClick:()=>b().toggleExpanded(),children:[o?t.jsx(Ta,{size:18}):t.jsx(Ma,{size:18}),o&&t.jsx("span",{className:"rb-label",children:f("lcl.ribbon.iconsOnly")})]}),Os.map(e=>t.jsx(He,{item:e,expanded:o},e.id))]}),t.jsx("div",{ref:Ne,className:"rb-group rb-home",children:en.map(e=>t.jsx(He,{item:e,expanded:o},e.id))}),Y!=="bottom"&&Tn("top",Re),on.length>0&&t.jsx("div",{className:"rb-group rb-recent",role:"group","aria-label":f("lcl.ribbon.recentSpaces"),children:on.map(e=>t.jsx("div",{className:"rb-recent-slot","data-recent-id":e.id,onContextMenu:En(e),children:t.jsx(He,{item:e,expanded:o})},e.id))}),Y!=="top"&&Tn("bottom",Oe),t.jsx("div",{ref:re,className:"rb-group rb-pinned",children:Rs.map(e=>t.jsx(He,{item:e,expanded:o},e.id))}),z&&ie&&t.jsxs("div",{ref:D,className:"rb-fly","data-rb-folder":ie.id,style:(()=>{const e=ct(P.current);return{left:((P.current?.getBoundingClientRect().right??44)+4)/e,top:z.top/e}})(),onMouseEnter:tt,onMouseLeave:ln,onDragOver:e=>xe(e,!!h&&h.zone===z.zone&&!h.id.startsWith("folder:")&&e.target===e.currentTarget),onDrop:e=>{e.target===e.currentTarget&&(e.preventDefault(),st(ie))},children:[t.jsx("div",{className:"rb-fly-head",children:ie.name}),Jt(ie)===0&&t.jsx("div",{className:"rb-fly-empty",children:f("lcl.ribbon.folderEmpty")}),ie.items.map((e,s)=>{const r=et.get(e);return r?Ys(r,ie,s,ie.items):null})]}),U&&Kt&&P.current?.parentElement&&Di.createPortal(t.jsx(Ri,{ref:gt,space:Kt,views:U.views,style:zs(),onContextMenuCapture:e=>{Xt.current=e.nativeEvent},onBeforeClick:()=>{U.spaceId!==K.getState().activeSpaceId&&Oi()},onEnter:U.spaceId===K.getState().activeSpaceId?void 0:()=>{me(),Fn(U.spaceId)}}),P.current.parentElement),Me&&!o&&t.jsx("div",{className:"rb-tip",role:"tooltip",style:(()=>{const e=ct(P.current);return{left:((P.current?.getBoundingClientRect().right??44)+6)/e,top:Me.mid/e}})(),children:Me.text}),V&&t.jsx("div",{className:"rb-menu-backdrop",onMouseDown:()=>B(null),onContextMenu:e=>{e.preventDefault(),B(null)},children:t.jsx(Bn,{className:"rb-menu",x:V.x,y:V.y,onMouseDown:e=>e.stopPropagation(),children:V.entries.map((e,s)=>t.jsx("button",{onClick:()=>{B(null),e.onClick()},children:e.label},s))})}),$&&t.jsx("div",{className:"rb-menu-backdrop",onMouseDown:()=>G(null),onContextMenu:e=>{e.preventDefault(),G(null)},children:t.jsxs(Bn,{className:"rb-iconpick",x:$.x,y:$.y,onMouseDown:e=>e.stopPropagation(),children:[t.jsx("button",{className:"rb-iconpick-reset",onClick:()=>{const e=$.apply;G(null),e("")},children:f("lcl.ribbon.defaultIcon")}),t.jsx("div",{className:"rb-iconpick-grid",children:Da.map(e=>{const s=It(e);return t.jsx("button",{className:`rb-iconpick-btn${$.current===e?" on":""}`,title:e,onClick:()=>{const r=$.apply;G(null),r(e)},children:t.jsx(s,{size:17})},e)})})]})})]})}const Xn=8,Ya=n=>n.dataset.lclShift==="end"?Xn:n.dataset.lclShift==="start"?-Xn:0;function Ua(){const n=Array.from(document.querySelectorAll(".dv-groupview")).map(o=>({r:o.getBoundingClientRect(),papery:!o.querySelector(".wb-tab--icon")})).filter(o=>o.r.width>0&&o.r.height>0),i=3;for(const o of document.querySelectorAll(".dv-sash")){const d=!!o.closest(".dv-split-view-container.dv-horizontal"),a=o.getBoundingClientRect();if(!a.width&&!a.height)continue;const v=d?a.left+a.width/2:a.top+a.height/2,[p,g]=d?[a.top,a.bottom]:[a.left,a.right];let w=null,m=null;for(const f of n){const[b,h,I,C]=d?[f.r.left,f.r.right,f.r.top,f.r.bottom]:[f.r.top,f.r.bottom,f.r.left,f.r.right];C<=p||I>=g||(w===null&&Math.abs(h-v)<=i&&(w=f.papery),m===null&&Math.abs(b-v)<=i&&(m=f.papery))}const k=w===!1&&m===!0?"end":w===!0&&m===!1?"start":"";k?o.dataset.lclShift=k:delete o.dataset.lclShift}}function Ka(){const n=document.createElement("div");n.className="lcl-sash-tick",document.body.appendChild(n);let i=null,o=0;const d=(b,h)=>{const I=!!b.closest(".dv-split-view-container.dv-horizontal"),C=b.getBoundingClientRect(),j=Ya(b);cancelAnimationFrame(o),o=requestAnimationFrame(()=>{n.classList.add("show"),n.classList.toggle("h",!I);const A=ct(n);I?(n.style.left=`${(C.left+C.width/2+j)/A}px`,n.style.top=`${Math.min(Math.max(h.clientY,C.top),C.bottom)/A}px`):(n.style.left=`${Math.min(Math.max(h.clientX,C.left),C.right)/A}px`,n.style.top=`${(C.top+C.height/2+j)/A}px`)})},a=b=>b instanceof Element?b.closest(".dv-sash"):null,v=b=>{const h=i instanceof HTMLElement?i:a(b.target);h?d(h,b):n.classList.contains("show")&&(cancelAnimationFrame(o),n.classList.remove("show"))},p=b=>{i=a(b.target)},g=b=>{i&&(i=null,a(b.target)||(cancelAnimationFrame(o),n.classList.remove("show")))};let w=0;const m=()=>{window.clearTimeout(w),w=window.setTimeout(Ua,120)},k=b=>b instanceof Element&&(b.matches(".dv-sash, .dv-view, .dv-groupview")||!!b.querySelector(".dv-sash, .dv-groupview")),f=new MutationObserver(b=>{for(const h of b)for(const I of[...h.addedNodes,...h.removedNodes])if(k(I)){m();return}});return f.observe(document.body,{childList:!0,subtree:!0}),m(),document.addEventListener("pointermove",v,{passive:!0}),document.addEventListener("pointerdown",p,{passive:!0}),document.addEventListener("pointerup",g,{passive:!0}),()=>{f.disconnect(),window.clearTimeout(w),cancelAnimationFrame(o),document.removeEventListener("pointermove",v),document.removeEventListener("pointerdown",p),document.removeEventListener("pointerup",g),n.remove()}}const ks=({dark:n,soft:i,buildDefault:o,header:d,noRibbon:a,footer:v})=>(c.useEffect(()=>Ui(),[]),c.useEffect(()=>Ka(),[]),fs==="mobile"?t.jsxs(t.Fragment,{children:[t.jsx(Ki,{dark:n,soft:i,buildDefault:o}),t.jsx(Ln,{})]}):t.jsxs("div",{className:`shell${a?" shell--noribbon":""}`,children:[d,t.jsxs("div",{className:"shell-top",children:[!a&&t.jsx(Wa,{}),t.jsxs("div",{className:"shell-work",children:[t.jsx(ba,{dark:n,soft:i,buildDefault:o}),v]})]}),t.jsx(Ln,{})]})),Xa=["n","s","e","w","ne","nw","se","sw"],Lt=n=>{const i=n.currentTarget,o=i.dataset.edge,d={x:n.screenX,y:n.screenY};if(n.type==="pointerdown"){if(n.button!==0)return;i.setPointerCapture(n.pointerId),window.tangu?.miniResize?.(o,!0,d)}else n.type==="pointermove"?i.hasPointerCapture(n.pointerId)&&window.tangu?.miniResize?.(o,!1,d):(n.type==="pointerup"&&i.hasPointerCapture(n.pointerId)&&window.tangu?.miniResize?.(o,!1,d),window.tangu?.miniResize?.(null))},ys=({buildDefault:n,direct:i,resizable:o})=>{const d=K(y=>y.spaces),a=K(y=>y.activeSpaceId),[,v]=c.useReducer(y=>y+1,0);c.useEffect(()=>Ee(v),[]);const p=d.filter(ft),g=p.find(y=>y.id===a),w=Ve(y=>y.mainLeaves.find(z=>z.id===y.activeMainId)),[m,k]=c.useState(null),f=Qs();c.useEffect(()=>k(null),[w?.id,w?.type]);const b=m==="picker"&&!f?null:m,{t:h}=ps(),I=g?.icon,C=i?ge(i.view.type):void 0,j=c.useRef(!1);C&&(j.current=!0),c.useEffect(()=>{i&&j.current&&!C&&window.tangu?.closeSelf?.()},[i,C]);const A=i?.title||(C?je(C.displayName):g?je(g.mini?.name??g.name):"Mini Panel");c.useEffect(()=>{const y=Ve.getState();if(y.setDefaultBuilder(n),!i)if(g)y.getActiveLeaf()?.type!==g.mini.view.type&&y.resetLayout();else{const z=p.find(M=>M.id==="tangu")??p[0];z&&Xi(z.id),y.resetLayout()}},[d,a,g,n,i]),c.useEffect(()=>{const y=z=>{z.key==="Escape"&&k(null)};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[]);const L=w&&(i?w.type===i.view.type:g&&w.type===g.mini.view.type)?Ve.getState().getActiveLeaf():null,_=L?ge(L.type):null,X=()=>{if(i){ut({type:i.mainView.type,params:{...i.mainView.params,...Ve.getState().getActiveLeaf()?.params}});return}const y=Ht();y?.mini&&ut({spaceId:y.id,type:y.mini.mainView.type,params:{...y.mini.mainView.params,...Ve.getState().getActiveLeaf()?.params}})};return t.jsxs("div",{className:"mini-card-shell mini-card-floating","data-space":i?"direct":g?.id,children:[t.jsxs("header",{className:"mini-card-chrome",children:[t.jsxs("div",{className:"mini-card-cap",children:[t.jsxs("button",{className:"mini-card-space","aria-label":h("lcl.mini.switchSpace"),"aria-expanded":b==="space",disabled:!!i||p.length<2,onClick:()=>k(b==="space"?null:"space"),children:[!i&&I&&t.jsx(I,{size:15}),(i||!f)&&t.jsx("span",{children:A}),!i&&p.length>1&&t.jsx(Rt,{size:12})]}),f&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mini-card-cap-div"}),t.jsxs("button",{className:"mini-card-picker","aria-label":f.label,"aria-expanded":b==="picker",onClick:()=>k(b==="picker"?null:"picker"),children:[t.jsx("span",{children:f.items.find(y=>y.id===f.value)?.label||f.placeholder}),t.jsx(Rt,{size:12})]})]})]}),t.jsx("div",{className:"mini-card-drag-title"}),t.jsxs("div",{className:"mini-card-cap",children:[f?.create&&t.jsx("button",{className:"mini-card-action","aria-label":f.create.label,title:f.create.label,disabled:f.create.disabled,onClick:()=>Ct()?.create?.onCreate(),children:t.jsx(Dt,{size:15})}),t.jsx("button",{className:"mini-card-action","aria-label":h("lcl.mini.showMain"),title:h("lcl.mini.showMain"),disabled:!i&&!g,onClick:X,children:t.jsx(Do,{size:15})}),t.jsx("button",{className:"mini-card-action mini-card-close","aria-label":h("lcl.mini.close"),onClick:()=>window.tangu?.closeSelf?.(),children:t.jsx(Vt,{size:15})})]})]}),t.jsx("main",{className:"mini-card-main",children:L&&_?t.jsx("div",{className:"mini-panel-view","data-view":L.type,children:t.jsx(hs,{children:t.jsx(c.Suspense,{fallback:null,children:_.factory({leaf:L,params:L.params})})})},`${L.id}:${L.type}`):t.jsx("div",{className:"mini-panel-empty",children:h("lcl.mini.empty")})}),b&&t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"mini-card-dismiss","aria-label":h("lcl.mini.closeMenu"),onClick:()=>k(null)}),b==="space"&&t.jsx("section",{className:"mini-card-popover","aria-label":h("lcl.mini.switchSpace"),children:t.jsx("div",{className:"mini-card-popover-list",children:p.map(y=>{const z=y.icon;return t.jsxs("button",{className:`mini-card-row${y.id===a?" active":""}`,onClick:()=>{Ke(y.id),k(null)},children:[z&&t.jsx(z,{size:15}),t.jsx("span",{className:"mini-card-row-label",children:je(y.mini.name??y.name)})]},y.id)})})}),b==="picker"&&f&&t.jsxs("section",{className:"mini-card-popover mini-card-popover--picker","aria-label":f.label,children:[t.jsx("div",{className:"mini-card-popover-title",children:f.label}),t.jsxs("div",{className:"mini-card-popover-list",children:[f.create&&t.jsxs("button",{className:"mini-card-row mini-card-row-new",disabled:f.create.disabled,onClick:()=>{k(null),Ct()?.create?.onCreate()},children:[t.jsx(Dt,{size:15}),t.jsx("span",{className:"mini-card-row-label",children:f.create.label})]}),f.items.map(y=>t.jsxs("button",{className:`mini-card-row${y.id===f.value?" active":""}`,onClick:()=>{k(null),Ct()?.onSelect(y.id)},children:[t.jsx("span",{className:"mini-card-row-label",children:y.label}),y.id===f.value&&t.jsx(gs,{size:14})]},y.id))]})]})]}),o&&Xa.map(y=>t.jsx("div",{className:"mini-card-edge","data-edge":y,onPointerDown:Lt,onPointerMove:Lt,onLostPointerCapture:Lt},y))]})};function qa(){return t.jsx("div",{className:"mac-titlebar"})}const Mt=9e3,lt=5*1024*1024;function Ot(n){return typeof n=="string"?n.replace(/\bBearer\s+[A-Za-z0-9._~+\/-]+=*/gi,"Bearer [redacted]").replace(/\b(sk-[a-zA-Z0-9_-]{12,})\b/g,"[redacted]").replace(/((?:["']?)(?:api[_-]?key|access[_-]?token|refresh[_-]?token|token|password|secret|authorization|cookie)(?:["']?)\s*[:=]\s*["']?)([^\s,"';&}]+)/gi,"$1[redacted]"):Array.isArray(n)?n.map(Ot):n&&typeof n=="object"?Object.fromEntries(Object.entries(n).map(([i,o])=>[i,/^(?:token|.*api[_-]?key|access[_-]?token|refresh[_-]?token|password|secret|authorization|cookie|set-cookie)$/i.test(i)?"[redacted]":Ot(o)])):n}async function Ga(n,i,o){const d=await Js(n,i,{...o,maxBytes:lt});let a=Ot({...d,feedbackSelection:o});const v=w=>{const m=JSON.stringify(w,null,2);return{json:m,bytes:new TextEncoder().encode(m).byteLength}};let p=v(a);const g=a.messages||[];if(p.bytes>lt&&g.length){const w=f=>({...a,messageCount:f,messagesTruncated:!0,messages:g.slice(g.length-f)});let m=0,k=g.length-1;for(;m<k;){const f=Math.ceil((m+k)/2);v(w(f)).bytes<=lt?m=f:k=f-1}a=w(m),p=v(a)}return{...p,filename:`tangu-feedback-${i?.id.slice(0,8)||"app"}-${new Date().toISOString().slice(0,10)}.json`,missing:Object.entries(d.sources).filter(([,w])=>w!=="included").map(([w])=>w),truncated:!!a.messagesTruncated||!!a.activityLogTruncated}}mt({"feedback.subtitle":{zh:"告诉我们哪里可以做得更好。",en:"Tell us what could work better."},"feedback.kind":{zh:"反馈类型",en:"Feedback type"},"feedback.bug":{zh:"遇到问题",en:"Report a problem"},"feedback.idea":{zh:"功能建议",en:"Suggest a feature"},"feedback.other":{zh:"其他反馈",en:"Something else"},"feedback.description":{zh:"具体发生了什么?",en:"What happened?"},"feedback.bugPlaceholder":{zh:`你当时在做什么?预期的结果是什么,实际又发生了什么?
|
|
3
|
-
如果可以,请写下重现步骤。`,en:`What were you doing? What did you expect, and what happened instead?
|
|
4
|
-
Include steps to reproduce it if you can.`},"feedback.ideaPlaceholder":{zh:"你想完成什么?哪项改进会对你有帮助?",en:"What are you trying to do? What change would help?"},"feedback.otherPlaceholder":{zh:"分享你的使用体验或想法……",en:"Share your experience or thoughts…"},"feedback.context":{zh:"附带诊断信息",en:"Include diagnostic information"},"feedback.diagnostics":{zh:"应用与运行日志",en:"App and runtime logs"},"feedback.diagnosticsHint":{zh:"版本、界面状态、错误、运行时间线与用量;进程日志可能涉及其他会话。",en:"Version, interface state, errors, run timeline and usage. Process logs may include other sessions."},"feedback.conversation":{zh:"当前会话内容",en:"Current conversation"},"feedback.conversationHint":{zh:"整段对话,包含工具输入与输出;附件超过 5 MB 时保留最新的部分。",en:"The whole conversation, including tool inputs and outputs. If the attachment exceeds 5 MB, the most recent part is kept."},"feedback.activity":{zh:"近期活动记录",en:"Recent activity"},"feedback.activityHint":{zh:"近 2 天内最新 500 行,可能包含文件名与操作路径。",en:"The latest 500 lines from the last 2 days; may contain file names and paths."},"feedback.sessionContext":{zh:"关联会话:{name}",en:"Linked conversation: {name}"},"feedback.withoutSession":{zh:"未关联会话,仍可提交应用问题。",en:"No linked conversation. You can still report an app issue."},"feedback.privacy":{zh:"已过滤常见凭据字段。日志仍可能包含路径或内容片段,请按需选择并预览。",en:"Common credential fields are filtered. Logs may still contain paths or content excerpts; choose what to include and review the preview."},"feedback.preview":{zh:"预览附件",en:"Preview attachment"},"feedback.export":{zh:"导出日志文件",en:"Export log file"},"feedback.backToForm":{zh:"返回反馈",en:"Back to feedback"},"feedback.preparing":{zh:"正在准备诊断信息…",en:"Preparing diagnostics…"},"feedback.sending":{zh:"正在提交…",en:"Sending…"},"feedback.ready":{zh:"诊断附件已就绪 · {size}",en:"Diagnostics ready · {size}"},"feedback.textOnly":{zh:"仅提交反馈文字",en:"Only your feedback text will be sent"},"feedback.partial":{zh:"部分诊断来源不可用:{sources}。将提交已获取的内容。",en:"Some diagnostic sources are unavailable: {sources}. Available information will be sent."},"feedback.source.appVersion":{zh:"应用版本",en:"app version"},"feedback.source.messages":{zh:"会话内容",en:"conversation"},"feedback.source.agentConfig":{zh:"会话设置",en:"session settings"},"feedback.source.backendLogs":{zh:"运行输出",en:"runtime output"},"feedback.source.connection":{zh:"连接信息",en:"connection details"},"feedback.source.backendStatus":{zh:"引擎状态",en:"engine status"},"feedback.source.usage":{zh:"用量",en:"usage"},"feedback.source.timeline":{zh:"运行时间线",en:"run timeline"},"feedback.source.activityLog":{zh:"活动记录",en:"activity"},"feedback.truncated":{zh:"较早的部分记录因达到上限未附带,附件内已标记。",en:"Some older records were left out because of collection limits; this is marked in the attachment."},"feedback.tooLarge":{zh:"附件超过 5 MB,请减少勾选的内容后再提交。",en:"The attachment exceeds 5 MB. Deselect some information before sending."},"feedback.prepareFailed":{zh:"诊断信息准备失败。请重试,或取消勾选后仅提交文字。",en:"Could not prepare diagnostics. Retry, or deselect the options to send text only."},"feedback.refresh":{zh:"重新收集",en:"Collect again"},"feedback.successTitle":{zh:"反馈已收到",en:"Feedback received"},"feedback.successHint":{zh:"感谢你帮助我们改进 Tangu。你可以在账户中心查看回复。",en:"Thanks for helping improve Tangu. You can view replies in your account center."},"feedback.ticket":{zh:"反馈编号:{id}",en:"Reference: {id}"},"feedback.viewFeedback":{zh:"查看我的反馈",en:"View my feedback"},"feedback.done":{zh:"完成",en:"Done"},"feedback.limit":{zh:"反馈内容不能超过 {max} 字。",en:"Feedback cannot exceed {max} characters."},"feedback.retry":{zh:"重试提交",en:"Try again"},"feedback.diagnosePrompt":{zh:`我在使用 Tangu 时遇到一个问题,想请你帮我诊断:
|
|
5
|
-
|
|
6
|
-
{description}
|
|
7
|
-
|
|
8
|
-
请结合当前会话的上下文分析可能的原因,并给出排查步骤。`,en:`I ran into a problem while using Tangu and would like your help diagnosing it:
|
|
9
|
-
|
|
10
|
-
{description}
|
|
11
|
-
|
|
12
|
-
Using the context of this session, analyze the likely causes and suggest troubleshooting steps.`}});function xs(n){N.getState().setPendingDraft(n),W.getState().openView("chat",{followActive:!0,reuseKey:"primary"},"main")}const Ss=({cfg:n,activeSession:i,onClose:o,surface:d="modal"})=>{const{t:a}=be(),[v]=c.useState(()=>({cfg:n,session:i})),p=N(S=>S.feedbackDraft),[g,w]=c.useState("bug"),[m,k]=c.useState(!0),[f,b]=c.useState(!1),[h,I]=c.useState(!1),[C,j]=c.useState(0),[A,L]=c.useState(null),[_,X]=c.useState(!1),[y,z]=c.useState(!1),[M,V]=c.useState(null),[B,$]=c.useState(""),G=c.useRef(null),q=c.useRef(!1),Ce=c.useRef(o);Ce.current=o;const P=m||f||h,le=`${m}:${f}:${h}:${C}`,Ne=A?.key===le?A:null,re=P&&!Ne,D=P?Ne?.report:void 0,de=!!D&&D.bytes>lt,se=p.trim().length>Mt,we=!!p.trim()&&!se&&!y&&!M&&!re&&!de&&(!P||!!D),Q=()=>{q.current||Ce.current()};c.useEffect(()=>{if(!P)return;let S=!0;return Ga(v.cfg,v.session,{diagnostics:m,conversation:f,activity:h}).then(F=>{S&&L({key:le,report:F})}).catch(()=>{S&&L({key:le,failed:!0})}),()=>{S=!1}},[v,m,f,h,C,le,P]),c.useEffect(()=>{const S=document.activeElement,F=requestAnimationFrame(()=>G.current?.querySelector("textarea")?.focus()),oe=Z=>{if(Z.key==="Escape"&&(Z.preventDefault(),Z.stopImmediatePropagation(),q.current||Ce.current()),Z.key==="Tab"){const ve=Array.from(G.current?.querySelectorAll('button:not(:disabled), textarea:not(:disabled), input:not(:disabled), [tabindex="0"]')||[]).filter(Me=>Me.getClientRects().length>0),ue=ve[0],Le=ve[ve.length-1];if(!ue){Z.preventDefault(),G.current?.focus();return}Z.shiftKey&&(document.activeElement===ue||!G.current?.contains(document.activeElement))?(Z.preventDefault(),Le.focus()):!Z.shiftKey&&(document.activeElement===Le||!G.current?.contains(document.activeElement))&&(Z.preventDefault(),ue.focus())}};return document.addEventListener("keydown",oe,!0),()=>{cancelAnimationFrame(F),document.removeEventListener("keydown",oe,!0),S?.focus()}},[]);const Ie=async()=>{if(!(!we||q.current)){if(!window.tangu?.submitFeedback){$(a("feedback.errUnavailable"));return}q.current=!0,z(!0),$("");try{const S=await window.tangu.submitFeedback({description:`[Tangu · ${a(`feedback.${g}`)}]
|
|
13
|
-
|
|
14
|
-
${p.trim()}`,...D?{sessionLogJson:D.json,sessionLogName:D.filename}:{}});S.ok?(V(S),N.setState({feedbackDraft:""})):$(S.error==="attachment-too-large"?a("feedback.tooLarge"):a("feedback.errFail",{err:S.error==="not-logged-in"?a("feedback.errNotLoggedIn"):S.error||"Unknown error"}))}catch(S){$(a("feedback.errFail",{err:String(S?.message||S)}))}finally{q.current=!1,z(!1)}}},Y=()=>{if(!p.trim()||y)return;const S=a("feedback.diagnosePrompt",{description:p.trim()});window.tangu?.requestMainAction?window.tangu.requestMainAction("chat-draft",S):xs(S),Q()},qe=D?`${(D.bytes/1024).toFixed(1)} KB`:"",Te=()=>{if(!D)return;const S=URL.createObjectURL(new Blob([D.json],{type:"application/json;charset=utf-8"})),F=document.createElement("a");F.href=S,F.download=D.filename,F.click(),setTimeout(()=>URL.revokeObjectURL(S),1e4)};return t.jsx("div",{className:d==="panel"?"feedback-panel-surface":"memv-modal feedback-overlay",onClick:S=>{d==="modal"&&S.target===S.currentTarget&&Q()},children:t.jsxs("div",{ref:G,className:"modal feedback-modal",role:"dialog","aria-modal":"true","aria-labelledby":"feedback-title",tabIndex:-1,onKeyDown:S=>{(S.metaKey||S.ctrlKey)&&S.key==="Enter"&&!S.nativeEvent.isComposing&&(S.preventDefault(),Ie())},children:[t.jsxs("div",{className:"modal-head feedback-head",children:[t.jsxs("div",{className:"feedback-heading",children:[t.jsx(zn,{size:19}),t.jsxs("div",{children:[t.jsx("h2",{id:"feedback-title",children:a("feedback.title")}),t.jsx("p",{children:a("feedback.subtitle")})]})]}),t.jsx("button",{className:"icon-btn",onClick:Q,disabled:y,"aria-label":a("settings.btn.cancel"),children:t.jsx(Vt,{size:18})})]}),M?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"modal-body feedback-success",role:"status",children:[t.jsx("span",{className:"feedback-success-icon",children:t.jsx(gs,{size:28})}),t.jsx("h3",{children:a("feedback.successTitle")}),t.jsx("p",{children:a("feedback.successHint")}),M.id&&t.jsx("code",{children:a("feedback.ticket",{id:M.id})}),M.attachmentSkipped&&t.jsx("p",{className:"feedback-warning",children:a("feedback.okNoLog")}),B&&t.jsx("p",{className:"feedback-warning",role:"alert",children:B})]}),t.jsxs("div",{className:"feedback-footer",children:[window.tangu?.openAccountCenter&&t.jsx("button",{className:"btn ghost",onClick:()=>{$(""),window.tangu.openAccountCenter("feedback").catch(()=>$(a("feedback.errUnavailable")))},children:a("feedback.viewFeedback")}),t.jsx("span",{className:"grow"}),t.jsx("button",{autoFocus:!0,className:"btn primary",onClick:Q,children:a("feedback.done")})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"modal-body feedback-body",children:[_?t.jsxs(t.Fragment,{children:[t.jsxs("button",{className:"btn ghost sm feedback-back",onClick:()=>X(!1),children:[t.jsx(qi,{size:14}),a("feedback.backToForm")]}),t.jsxs("div",{className:"feedback-file",children:[t.jsx(Pt,{size:15}),t.jsx("span",{children:D?.filename}),t.jsx("span",{children:qe})]}),t.jsx("pre",{className:"feedback-preview",tabIndex:0,children:D?.json})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"feedback-kinds",role:"group","aria-label":a("feedback.kind"),children:[{id:"bug",Icon:Gi},{id:"idea",Icon:ts},{id:"other",Icon:zn}].map(({id:S,Icon:F})=>t.jsxs("button",{className:"btn ghost","aria-pressed":g===S,disabled:y,onClick:()=>w(S),children:[t.jsx(F,{size:15}),a(`feedback.${S}`)]},S))}),t.jsxs("div",{className:"feedback-description",children:[t.jsx("label",{htmlFor:"feedback-description",children:a(g==="bug"?"feedback.description":"feedback.label")}),t.jsx("textarea",{id:"feedback-description",value:p,onChange:S=>{N.setState({feedbackDraft:S.target.value}),$("")},placeholder:a(`feedback.${g}Placeholder`),disabled:y,"aria-invalid":se,"aria-describedby":"feedback-count"}),t.jsxs("span",{id:"feedback-count",className:se?"feedback-warning":"feedback-count",children:[p.trim().length.toLocaleString()," / ",Mt.toLocaleString()]})]}),t.jsxs("section",{className:"feedback-context","aria-labelledby":"feedback-context-title",children:[t.jsxs("div",{className:"feedback-section-heading",children:[t.jsx("h3",{id:"feedback-context-title",children:a("feedback.context")}),t.jsx("code",{children:"/feedback"})]}),t.jsx("p",{className:"feedback-session",children:v.session?a("feedback.sessionContext",{name:v.session.title||v.session.id.slice(0,8)}):a("feedback.withoutSession")}),[{id:"diagnostics",checked:m,change:k,unavailable:!1},{id:"conversation",checked:f,change:b,unavailable:!v.session},{id:"activity",checked:h,change:I,unavailable:!window.tangu?.exportActivity}].map(S=>t.jsxs("label",{className:"feedback-option","data-disabled":S.unavailable||void 0,children:[t.jsx("input",{type:"checkbox",checked:S.checked,onChange:F=>S.change(F.target.checked),disabled:y||S.unavailable}),t.jsxs("span",{children:[t.jsx("strong",{children:a(`feedback.${S.id}`)}),t.jsx("small",{children:a(`feedback.${S.id}Hint`)})]})]},S.id))]}),t.jsxs("div",{className:"feedback-report-status",role:"status",children:[t.jsx("span",{children:re?t.jsxs(t.Fragment,{children:[t.jsx(Pn,{size:13,className:"spin"}),a("feedback.preparing")]}):D?t.jsxs(t.Fragment,{children:[t.jsx(Pt,{size:13}),a("feedback.ready",{size:qe})]}):a(P?"feedback.prepareFailed":"feedback.textOnly")}),t.jsxs("div",{children:[D&&t.jsx("button",{className:"btn ghost sm",onClick:()=>X(!0),disabled:y,children:a("feedback.preview")}),D&&t.jsxs("button",{className:"btn ghost sm",onClick:Te,disabled:y,children:[t.jsx(Ro,{size:13}),a("feedback.export")]}),P&&t.jsx("button",{className:"icon-btn",onClick:()=>j(S=>S+1),disabled:y||re,"aria-label":a("feedback.refresh"),title:a("feedback.refresh"),children:t.jsx(At,{size:13})})]})]}),!!D?.missing.length&&t.jsx("p",{className:"feedback-warning",children:a("feedback.partial",{sources:D.missing.map(S=>a(`feedback.source.${S}`)).join(", ")})}),D?.truncated&&t.jsx("p",{className:"feedback-note",children:a("feedback.truncated")}),P&&t.jsx("p",{className:"feedback-note",children:a("feedback.privacy")})]}),de&&t.jsx("p",{className:"feedback-warning",role:"alert",children:a("feedback.tooLarge")}),se&&t.jsx("p",{className:"feedback-warning",role:"alert",children:a("feedback.limit",{max:Mt})}),B&&t.jsx("p",{className:"feedback-warning",role:"alert",children:B})]}),t.jsxs("div",{className:"feedback-footer",children:[t.jsxs("button",{className:"btn ghost feedback-diagnose",onClick:Y,disabled:y||!p.trim(),title:a("feedback.diagnoseViaChatHint"),children:[t.jsx(Zi,{size:15}),a("feedback.diagnoseViaChat")]}),t.jsx("span",{className:"grow"}),t.jsxs("button",{className:"btn primary",onClick:()=>{Ie()},disabled:!we,children:[y&&t.jsx(Pn,{size:14,className:"spin"}),a(y?"feedback.sending":B?"feedback.retry":"feedback.submit")]})]})]})]})})};mt({"syncSetup.title":{zh:"把这台电脑同步到蓬洲云",en:"Sync this computer to Penzor Cloud"},"syncSetup.lead":{zh:"已登录「{name}」。勾着的会和你的其他设备保持一致,以后随时可以在蓬洲云 › 同步里关。",en:"Signed in as {name}. Checked items stay in sync with your other devices. You can turn them off anytime in Penzor Cloud › Sync."},"syncSetup.notes":{zh:"智库「{name}」",en:'Notes vault "{name}"'},"syncSetup.notesAny":{zh:"这台电脑的智库",en:"Notes vault on this computer"},"syncSetup.notesSize":{zh:"{size} · 用掉设备同步 {max} 里的 {pct}%",en:"{size} · {pct}% of your {max} device sync storage"},"syncSetup.notesOver":{zh:"{size},超过设备同步的 {max}:放不下的先留在这台电脑,不会删除",en:"{size}, more than your {max} device sync storage. What doesn't fit stays on this computer. Nothing is deleted."},"syncSetup.notesHint":{zh:"整个本机智库,和你的其他电脑保持一致",en:"Your whole local vault, kept the same on your other computers"},"syncSetup.agents":{zh:"Agents 与记忆",en:"Agents & memory"},"syncSetup.agentsHint":{zh:"Agents 的记忆、日志、技能和协作说明",en:"Your agents' memory, logs, skills and collaboration notes"},"syncSetup.plugins":{zh:"插件数据",en:"Plugin data"},"syncSetup.pluginsHint":{zh:"插件自己存的设置和数据",en:"Settings and data your plugins save"},"syncSetup.footHint":{zh:"另一台电脑登录同一账号,就会自动出现",en:"Sign in on another computer and it appears there too"},"syncSetup.later":{zh:"稍后",en:"Later"},"syncSetup.start":{zh:"开始同步",en:"Start syncing"},"syncSetup.progress":{zh:"正在同步到蓬洲云 · 智库 {done} / {total} 个文件",en:"Syncing to Penzor Cloud · notes {done} / {total} files"},"syncSetup.view":{zh:"查看",en:"View"},"syncSetup.decide":{zh:"云端已经有一份智库,去蓬洲云 › 同步里选怎么合并。",en:"Penzor Cloud already has a notes vault. Choose how to combine them in Penzor Cloud › Sync."},"syncSetup.failed":{zh:"有一项没开成:{error}",en:"One item couldn't be turned on: {error}"}});const qn="forsion-penzor",zt=1024**3,rt=n=>n>=zt?`${(n/zt).toFixed(n>=10*zt?0:1)} GB`:n>=1024**2?`${Math.round(n/1024**2)} MB`:`${Math.max(1,Math.round(n/1024))} KB`,Za=()=>c.useSyncExternalStore(Yo,cs);function Qa(){K.getState().spaces.some(n=>n.id===qn)&&Ke(qn)}function Ja(){const{t:n}=be(),[i,o]=c.useState("");c.useEffect(()=>Oo(o),[]);const d=Za(),[a,v]=c.useState(!1),[p,g]=c.useState(!1),[w,m]=c.useState({notes:!0,agents:!0,plugins:!0}),[k,f]=c.useState(!1),b=Ye()==="main",h=Ao("syncSetup",a,Fo.syncSetup);c.useEffect(()=>{b&&window.remoteSync&&_o()},[b]);let I=!1;try{I=localStorage.getItem(Ft)==="1"}catch{}const C=b&&Bo(d,I),j=C&&!a,A=b&&!!d&&d.signedIn&&!d.decided&&I&&d.notes.available&&!j&&!a;c.useEffect(()=>{A&&Dn()},[A]),c.useEffect(()=>{if(!j)return;const M=setTimeout(()=>v(!0),2500);return()=>clearTimeout(M)},[j]),c.useEffect(()=>{a&&!C&&!p&&v(!1)},[a,C,p]);const L=d?.notes.progress;if(c.useEffect(()=>{if(k&&d&&!d.notes.running&&d.notes.last){const M=setTimeout(()=>f(!1),1500);return()=>clearTimeout(M)}},[k,d]),!b||!d)return null;const _=async()=>{g(!0);const M=await Uo(w);g(!1),v(!1);const V=M.find($=>!$.ok);V&&Wn({text:n("syncSetup.failed",{error:V.error??""}),level:"warning"}),cs()?.notes.pending?(Wn({text:n("syncSetup.decide"),level:"info"}),Qa()):w.notes&&f(!0)},X=()=>{Dn(),v(!1)},y=(()=>{const{localBytes:M,maxBytes:V}=d.notes;return M==null||!V?n("syncSetup.notesHint"):M>V?n("syncSetup.notesOver",{size:rt(M),max:rt(V)}):n("syncSetup.notesSize",{size:rt(M),max:rt(V),pct:String(Math.max(1,Math.round(M/V*100)))})})(),z=[["notes",t.jsx($o,{size:15}),d.notes.rootName?n("syncSetup.notes",{name:d.notes.rootName}):n("syncSetup.notesAny"),y],["agents",t.jsx(us,{size:15}),n("syncSetup.agents"),n("syncSetup.agentsHint")],["plugins",t.jsx(Vo,{size:15}),n("syncSetup.plugins"),n("syncSetup.pluginsHint")]];return t.jsxs(t.Fragment,{children:[h&&t.jsx("div",{className:"u-backdrop sync-setup-backdrop",children:t.jsxs("div",{className:"modal modal-sm sync-setup",role:"dialog","aria-modal":"true","aria-label":n("syncSetup.title"),children:[t.jsxs("div",{className:"modal-head",children:[t.jsx(Ho,{size:16}),t.jsx("span",{className:"sync-setup-title",children:n("syncSetup.title")})]}),t.jsxs("div",{className:"sync-setup-body",children:[t.jsx("p",{className:"sync-setup-lead",children:n("syncSetup.lead",{name:i})}),z.map(([M,V,B,$])=>t.jsxs("label",{className:"sync-setup-row",children:[t.jsx("input",{type:"checkbox",checked:w[M],disabled:p,onChange:G=>m({...w,[M]:G.target.checked})}),t.jsx("span",{className:"sync-setup-tile",children:V}),t.jsxs("span",{className:"sync-setup-copy",children:[t.jsx("b",{children:B}),t.jsx("small",{children:$})]})]},M))]}),t.jsxs("div",{className:"sync-setup-foot",children:[t.jsx("span",{className:"sync-setup-hint",children:n("syncSetup.footHint")}),t.jsxs("span",{className:"sync-setup-acts",children:[t.jsx("button",{className:"btn",disabled:p,onClick:X,children:n("syncSetup.later")}),t.jsx("button",{className:"btn primary",disabled:p,onClick:()=>{_()},children:n("syncSetup.start")})]})]})]})}),k&&d.notes.running&&L&&L.total>0&&t.jsxs("div",{className:"sync-setup-progress",role:"status",children:[t.jsx(At,{size:14,className:"spin"}),t.jsx("span",{children:n("syncSetup.progress",{done:String(L.done),total:String(L.total)})}),t.jsx("span",{className:"sync-setup-bar",children:t.jsx("i",{style:{width:`${Math.round(L.done/L.total*100)}%`}})}),t.jsx("button",{type:"button",className:"sync-setup-link",onClick:Wo,children:n("syncSetup.view")})]})]})}function Gn(n){return Array.from(n.dataTransfer?.types??[]).includes("Files")}function Xe(){const n=o=>{!Gn(o)||o.defaultPrevented||(o.preventDefault(),o.dataTransfer&&(o.dataTransfer.dropEffect="none"))},i=o=>{Gn(o)&&!o.defaultPrevented&&o.preventDefault()};return document.addEventListener("dragover",n),document.addEventListener("drop",i),()=>{document.removeEventListener("dragover",n),document.removeEventListener("drop",i)}}function js({target:n,onUnavailable:i}){const[,o]=c.useReducer(m=>m+1,0),[d,a]=c.useState(()=>({...n.params??{}})),v=c.useRef(d);v.current=d;const p=c.useRef(!1);c.useEffect(()=>Ee(o),[]),c.useEffect(()=>a({...n.params??{}}),[n]);const g=ge(n.type);g&&(p.current=!0),c.useEffect(()=>{p.current&&!g&&i?.()},[g,i]);const w=c.useMemo(()=>({id:`floating:${n.type}`,type:n.type,loc:"main",get params(){return v.current},setTitle:m=>{document.title=m},setParams:m=>a({...m}),close:()=>i?.()}),[n.type,i]);return g?t.jsx("div",{className:"floating-plugin-view","data-view":n.type,children:t.jsx(hs,{children:t.jsx(c.Suspense,{fallback:null,children:g.factory({leaf:w,params:d})})})}):t.jsx("div",{className:"floating-panel-empty",children:"Loading panel…"})}const er=[[390,"iPhone"],[414,"Max"],[768,"iPad"]];function tr({children:n}){const[i,o]=c.useState(390);return fs!=="mobile"?t.jsx(t.Fragment,{children:n}):window.innerWidth<=820?t.jsx(t.Fragment,{children:n}):t.jsxs("div",{className:"sc-frame",children:[t.jsx("div",{className:"sc-bar",children:er.map(([d,a])=>t.jsxs("button",{className:`sc-size${i===d?" on":""}`,onClick:()=>o(d),children:[a," · ",d]},d))}),t.jsx("div",{className:"sc-device",style:{width:i},children:n})]})}function nr(){eo(),c.useEffect(()=>Xe(),[]),c.useEffect(()=>{to(),no()},[]),c.useEffect(()=>window.tangu?.onMainAction?.((m,k)=>{m==="onboarding"&&N.getState().setOnboarding(!0),m==="dev-commands"&&so(),m==="test-notification"&&oo(),m==="reset-layout"&&W.getState().resetLayout({undoable:!0}),m==="achievement-toast"&&Qi(),m==="space-removed"&&k&&fa(k),m==="chat-draft"&&k&&xs(k),m==="chat-quote"&&k&&ya(k),m==="agents-changed"&&(N.getState().refreshAgents(),window.dispatchEvent(new Event("forsion:agents-changed"))),m==="skills-changed"&&(_t(Bt()).then(f=>N.setState({skillsList:f})).catch(()=>{}),window.dispatchEvent(new Event("forsion:skills-changed"))),m==="open-agents"&&Mn(N.getState().defaultAgentSlug||""),m==="open-agent"&&k&&/^[a-z0-9][a-z0-9-]{0,63}$/.test(k)&&Mn(k),m==="unit-route"&&k&&Ko(k),m==="open-space"&&k&&K.getState().spaces.some(f=>f.id===k)&&Ke(k)}),[]);const n=pt(),i=Xo();io();const o=N(ls(m=>({sessions:m.sessions,archivedSessions:m.archivedSessions,activeId:m.activeId,settingsOpen:m.settingsOpen,settingsTab:m.settingsTab,settingsSkillKey:m.settingsSkillKey,settingsNonce:m.settingsNonce,onboarding:m.onboarding,feedbackOpen:m.feedbackOpen,marketOpen:m.marketOpen,marketTarget:m.marketTarget,closeMarket:m.closeMarket,achievementsOpen:m.achievementsOpen,cfg:m.cfg,tr:m.tr,openSettings:m.openSettings,closeSettings:m.closeSettings,patchConfig:m.patchConfig,connect:m.connect,setOnboarding:m.setOnboarding,closeFeedback:m.closeFeedback}))),d=o.sessions.find(m=>m.id===o.activeId)||o.archivedSessions.find(m=>m.id===o.activeId)||null,a=c.useSyncExternalStore(qo,Rn,Rn),[v,p]=c.useState(!1),g=c.useRef(o.onboarding);c.useEffect(()=>{const m=g.current;if(g.current=o.onboarding,m&&!o.onboarding){p(!0);const k=setTimeout(()=>p(!1),650);return()=>clearTimeout(k)}},[o.onboarding]),c.useEffect(()=>Go(!!o.onboarding),[o.onboarding]);const w=o.settingsOpen||o.marketOpen||o.achievementsOpen||o.feedbackOpen||!!a||o.onboarding;return t.jsxs(tr,{children:[t.jsx("div",{className:`shell-host${v?" main-enter":""}`,style:o.onboarding?{visibility:"hidden"}:void 0,children:t.jsx(ks,{dark:i.mode==="dark",soft:!!ds(i.lang)?.manifest.panelGap,buildDefault:ns,header:t.jsx(qa,{}),footer:t.jsx(ao,{})})}),Zo()&&t.jsx(ss,{}),t.jsx(Qo,{}),t.jsx(Jo,{}),t.jsx(ws,{}),t.jsx(wa,{}),t.jsx(Se,{children:o.settingsOpen&&t.jsx($e,{title:o.tr("settings.title"),onClose:()=>o.closeSettings(),children:t.jsx(os,{open:!0,initialTab:o.settingsTab??void 0,initialSkillKey:o.settingsSkillKey??void 0,cfg:o.cfg,activeSession:d,themeLang:n.lang,themeSkin:n.skin,themeMode:n.mode,themeModePref:n.modePref,flatOn:n.flat,glassOn:n.glass,themeSeed:n.seed,onClose:()=>o.closeSettings(),onConfigChange:o.patchConfig,onThemeChange:(m,k,f)=>n.setTheme(m,k,n.bg,f),onFlatChange:n.setFlat,onGlassChange:m=>n.setGlass(m),onSeedChange:m=>n.setSeedValue(m),onReloadThemes:()=>n.reloadThemes(),onReconnect:m=>{o.connect({...o.cfg,...m||{}})},onRelaunchOnboarding:()=>{o.closeSettings();try{localStorage.removeItem(Ft)}catch{}o.setOnboarding(!0)}},o.settingsNonce)},"settings")}),t.jsx(Se,{children:o.onboarding&&t.jsx(ei.div,{style:{position:"fixed",inset:0,zIndex:60,background:"var(--bg)"},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,scale:1.06},transition:{duration:.45,ease:[.2,.8,.2,1]},children:t.jsx(ti,{themeLang:n.lang,themeSkin:n.skin,themeMode:n.mode,themeModePref:n.modePref,themeSeed:n.seed,onThemeChange:(m,k,f)=>n.setTheme(m,k,n.bg,f),onSeedChange:m=>n.setSeedValue(m),onReconnect:()=>{window.tangu?.getConfig().then(m=>{const k={backendUrl:m.backendUrl,token:m.token,modelId:m.modelId};N.setState({cfg:k,desktopMode:"managed"}),N.getState().connect(k)})},onFinish:()=>{o.setOnboarding(!1),window.tangu?.getConfig().then(m=>{const k={backendUrl:m.backendUrl,token:m.token,modelId:m.modelId};N.setState({cfg:k,homeDir:m.homeDir,defaultWsDir:m.defaultWorkspaceDir||""}),N.getState().connect(k)})}})},"onboarding")}),t.jsx(Se,{children:o.marketOpen&&t.jsx($e,{title:o.tr("market.title"),onClose:()=>o.closeMarket(),children:t.jsx(is,{initialQuery:o.marketTarget?.q,initialItemId:o.marketTarget?.itemId,initialDetailTab:o.marketTarget?.detailTab,onClose:()=>o.closeMarket()},o.marketTarget?.nonce)},"market")}),t.jsx(Se,{children:o.achievementsOpen&&t.jsx($e,{title:o.tr("achievements.title"),onClose:()=>N.getState().closeAchievements(),children:t.jsx(as,{onClose:()=>N.getState().closeAchievements()})},"achievements")}),t.jsx(Se,{children:o.feedbackOpen&&t.jsx($e,{compact:!0,title:o.tr("feedback.title"),onClose:()=>o.closeFeedback(),children:t.jsx(Ss,{surface:"panel",cfg:o.cfg,activeSession:d,onClose:()=>o.closeFeedback()})},"feedback")}),t.jsx(ro,{}),t.jsx(co,{}),t.jsx(lo,{}),t.jsx(Ja,{}),t.jsx(Se,{children:a?.view&&t.jsx($e,{title:a.title,onClose:On,children:t.jsx(js,{target:a.view,onUnavailable:On})},a.id)}),!w&&t.jsx(rs,{}),!w&&t.jsx(uo,{onOpen:()=>N.getState().openAchievements()}),!o.onboarding&&t.jsx(mo,{})]})}function sr(){W.getState().openView("home",{},"main")}mt({"spaceWindow.stuck":{zh:"这个 Space 还没准备好。它所属的插件可能还在加载,或已被停用、卸载。准备好后这里会自动打开,也可以直接关掉这扇窗。",en:"This Space is not ready yet. Its plugin may still be loading, or may have been disabled or removed. It will open here once it is ready, or you can close this window."}});const Zn=6e3;function or(){const[n,i]=c.useState(Hn?"wait":"plain");return c.useEffect(()=>{const o=Hn;if(!o)return;const d=Date.now();let a=null,v=!1;const p=()=>{const k=K.getState().spaces.find(b=>b.id===o);if(a){k!==a&&!v&&(v=!0,location.reload());return}if(!k||!Ji()&&Date.now()-d<Zn)return;a=k;const f=W.getState();f.setSidebarDefaults(k.sidebarDefaults),f.setSideProfile(k.id,k.resizableSides??{},k.sideDefaultScale,k.bottomSpan),f.setPinned(k.pinned),document.title=je(k.name),i("ready")};p();const g=K.subscribe(p),w=Ee(p),m=window.setTimeout(()=>{p(),a||i("stuck")},Zn+50);return()=>{g(),w(),window.clearTimeout(m)}},[]),n}function ir(){const{t:n}=be(),i=pt(),o=or();c.useEffect(()=>{N.getState().setTr((a,v)=>n(a,v))},[n]),c.useEffect(()=>{N.getState().boot()},[]),c.useEffect(()=>Xe(),[]),c.useEffect(()=>window.tangu?.onMainAction?.(a=>{a==="agents-changed"&&(N.getState().refreshAgents(),window.dispatchEvent(new Event("forsion:agents-changed"))),a==="skills-changed"&&(_t(Bt()).then(v=>N.setState({skillsList:v})).catch(()=>{}),window.dispatchEvent(new Event("forsion:skills-changed")))}),[]),c.useEffect(()=>{window.tangu?.detachedReady?.(ni()).then(a=>{if(!a?.length)return;const v=W.getState();for(const p of a)v.openView(p.type,p.params??{},"main")})},[]);const d=(()=>{try{return window.tangu?.platform==="darwin"}catch{return!1}})();return o==="wait"||o==="stuck"?t.jsxs("div",{className:"shell-host",style:{display:"flex",flexDirection:"column"},children:[d&&t.jsx("div",{style:{height:38,flex:"0 0 auto",WebkitAppRegion:"drag"}}),o==="stuck"&&t.jsx("div",{className:"space-window-wait",role:"status",style:{flex:1,display:"grid",placeItems:"center",padding:32,textAlign:"center",color:"var(--text-muted)",fontSize:"var(--ui-font-body, 13px)",lineHeight:1.6},children:t.jsx("span",{style:{maxWidth:420},children:n("spaceWindow.stuck")})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"shell-host",children:t.jsx(ks,{noRibbon:!0,dark:i.mode==="dark",soft:!!ds(i.lang)?.manifest.panelGap,buildDefault:o==="ready"?ns:sr})}),window.amadeus&&t.jsx(ss,{}),t.jsx(ws,{})]})}mt({"dock.pickTitle":{zh:"贴到哪个窗口旁边",en:"Dock beside a window"},"dock.pickHint":{zh:"选一个窗口,对话面板会贴在它旁边,一起移动和缩放。",en:"Pick a window. The chat panel docks beside it and moves and resizes with it."},"dock.loading":{zh:"正在查找窗口…",en:"Looking for windows…"},"dock.empty":{zh:"屏幕上没有可以贴靠的窗口。",en:"No windows on screen to dock beside."},"dock.refresh":{zh:"刷新",en:"Refresh"},"dock.close":{zh:"关闭",en:"Close"},"dock.selectedIn":{zh:"在 {app} 里选中的:",en:"Selected in {app}:"},"dock.err.helper_not_installed":{zh:"还没装好「电脑操作」的本机 helper。让 Agent 用一次电脑操作,它会自动装好。",en:"The Computer Use helper is not installed yet. Ask the agent to use Computer Use once and it installs itself."},"dock.err.helper_not_running":{zh:"「电脑操作」的本机 helper 没有启动。",en:"The Computer Use helper is not running."},"dock.err.unsupported_helper":{zh:"本机的「电脑操作」helper 是旧版,不支持侧边拼接。让 Agent 用一次电脑操作,它会自动更新。",en:"The Computer Use helper is out of date and cannot dock. Ask the agent to use Computer Use once and it updates itself."},"dock.err.window_gone":{zh:"这个窗口已经关了。",en:"That window has been closed."},"dock.err.generic":{zh:"没能贴过去({code})。",en:"Could not dock ({code})."}});const ar=new Set(["helper_not_installed","helper_not_running","unsupported_helper","window_gone"]);function rr(n,i,o){return n?.text?n.text:n?.items?.length?[o("dock.selectedIn",{app:i}),...n.items.map(d=>`- ${d}`)].join(`
|
|
15
|
-
`):""}function cr(){const{t:n}=be(),[i,o]=c.useState(!1),[d,a]=c.useState(null);c.useEffect(()=>{N.getState().setTr((p,g)=>n(p,g))},[n]),c.useEffect(()=>{N.getState().boot().finally(()=>{N.setState({sessionMode:"work"}),o(!0)});const p=window.tangu?.onAppDockState?.(g=>a(g.target));return window.tangu?.appDockReady?.().then(g=>a(g.target)),()=>p?.()},[]),c.useEffect(()=>{window.amadeus&&$t()},[]),c.useEffect(()=>Xe(),[]),c.useEffect(()=>{if(!i||!d)return;const p={type:"chat",params:{miniSurface:!0,appRef:d}};ur({view:p,mainView:{type:"chat"}}),N.getState().setActiveId(null),W.getState().openView("chat",p.params,"main")},[i,d?.pid,d?.windowId]);const v=c.useRef(n);return v.current=n,c.useEffect(()=>{if(!d)return;let p="";const g=async()=>{const w=rr(await window.tangu?.appDockSelection?.(),d.app,v.current);!w||w===p||(p=w,N.getState().setPendingChatQuote("chat",w))};return window.addEventListener("focus",g),()=>window.removeEventListener("focus",g)},[d?.pid,d?.windowId]),d?t.jsx(ys,{buildDefault:()=>{},direct:{title:d.app,view:{type:"chat",params:{miniSurface:!0,appRef:d}},mainView:{type:"chat"}}}):t.jsx(lr,{})}function lr(){const{t:n}=be(),[i,o]=c.useState(null),[d,a]=c.useState(""),v=async()=>{o(null),a("");const w=await window.tangu?.appDockCandidates?.();o(w?.windows??[]),w?.error&&a(w.error)};c.useEffect(()=>{v()},[]);const p=async w=>{a("");const m=await window.tangu?.appDockAttach?.({pid:w.pid,windowId:w.windowId,app:w.app,bundleId:w.bundleId,title:w.title});m&&!m.ok&&m.error!=="superseded"&&a(m.error||"unavailable")},g=d?ar.has(d)?n(`dock.err.${d}`):n("dock.err.generic",{code:d}):"";return t.jsxs("div",{className:"mini-card-shell","data-space":"dock",children:[t.jsxs("header",{className:"mini-card-chrome",children:[t.jsx("div",{className:"mini-card-drag-title dock-picker-title",children:n("dock.pickTitle")}),t.jsx("button",{className:"mini-card-action","aria-label":n("dock.refresh"),title:n("dock.refresh"),onClick:()=>{v()},children:t.jsx(At,{size:15})}),t.jsx("button",{className:"mini-card-action mini-card-close","aria-label":n("dock.close"),onClick:()=>window.tangu?.closeSelf?.(),children:t.jsx(Vt,{size:15})})]}),t.jsxs("main",{className:"mini-card-main dock-picker",children:[t.jsx("p",{className:"dock-picker-hint",children:n("dock.pickHint")}),g&&t.jsx("p",{className:"dock-picker-error",role:"alert",children:g}),i===null?t.jsx("div",{className:"mini-panel-empty",children:n("dock.loading")}):i.length===0?!g&&t.jsx("div",{className:"mini-panel-empty",children:n("dock.empty")}):t.jsx("div",{className:"dock-picker-list",children:i.map(w=>t.jsxs("button",{className:"mini-card-row dock-picker-row","data-window-id":w.windowId,onClick:()=>{p(w)},children:[t.jsx(si,{size:15}),t.jsxs("span",{className:"mini-card-row-label",children:[t.jsx("span",{className:"dock-picker-app",children:w.app}),w.title&&t.jsx("span",{className:"dock-picker-window",children:w.title})]})]},`${w.pid}:${w.windowId}`))})]})]})}function dr(){let n,i=0;const o=window.tangu?.onMiniDockMotion?.(d=>{const a=document.querySelector(".mini-card-shell");if(!a)return;i=d.id;const v=getComputedStyle(a).transform;n?.cancel();const p=d.x||d.y?`translate3d(calc(${d.x}px / var(--uiz, 1)), calc(${d.y}px / var(--uiz, 1)), 0)`:"none";a.style.transform=p;const g=()=>{i===d.id&&(n?.cancel(),n=void 0,p==="none"&&a.style.removeProperty("transform"),window.tangu?.miniDockMotionDone?.(d.id))};if(!d.animate||matchMedia("(prefers-reduced-motion: reduce)").matches){g();return}n=a.animate([{transform:v},{transform:p}],{duration:220,easing:"cubic-bezier(.22, .8, .25, 1)"}),n.finished.then(g,()=>{})});return()=>{i++,n?.cancel(),o?.()}}let ne=null;function ur(n){ne=n}Ye()==="mini"&&(ta(async n=>{n.type==="amadeus-editor"&&await sa();const i={...n.params};delete i.miniSurface,n.type==="chat"&&(i.sessionId||=N.getState().activeId||void 0,i.followActive=!i.sessionId),window.tangu?.showMainPanel?.({...n,params:i})}),na(n=>{if(ne?.view)return n.type===ne.view.type?n:n.type===(ne.mainView?.type||ne.view.type)?{type:ne.view.type,params:{...ne.view.params,...n.params}}:(ut({...n}),null);const i=Ht();if(!i||!ft(i))return null;const o=i.mini;return n.type===o.view.type?n:n.type===o.mainView.type?{type:o.view.type,params:{...o.view.params,...n.params}}:(ut({...n}),null)}));function mr(){const n=Ht();n&&ft(n)&&W.getState().openView(n.mini.view.type,n.mini.view.params??{},"main")}function pr(){return oi()?t.jsx(cr,{}):t.jsx(fr,{})}function fr(){const{t:n}=be();c.useEffect(dr,[]);const[i,o]=c.useState(null);return c.useEffect(()=>{N.getState().setTr((d,a)=>n(d,a))},[n]),c.useEffect(()=>{let d=!1,a=!1;const v=new URLSearchParams(location.search);let p=v.get("sessionId")?{sessionId:v.get("sessionId")}:null;const g=()=>{if(!d||!p)return;if(p.view){const C=p.view;if(!ge(C.type)){a&&window.tangu?.closeSelf?.();return}a=!0;const j=p;p=null,ne=j,o(j),W.getState().openView(C.type,{...C.params,...j.params},"main");return}const f=p.spaceId||(p.sessionId?"tangu":void 0),b=K.getState().spaces.find(C=>C.id===f);if(!b||!ft(b))return;const h=p;p=null,ne=null,o(null),Ke(b.id);const I={...b.mini.view.params,...h.params,...h.sessionId?{sessionId:h.sessionId,followActive:!1}:{}};W.getState().openView(b.mini.view.type,I,"main"),h.sessionId&&N.getState().setActiveId(h.sessionId)},w=window.tangu?.onMiniTarget?.(f=>{p=f,g()});window.tangu?.miniReady?.();const m=K.subscribe(g),k=Ee(g);return N.getState().boot().finally(()=>{d=!0,g()}),()=>{w?.(),m(),k(),d=!1,ne=null}},[]),c.useEffect(()=>{window.amadeus&&$t()},[]),c.useEffect(()=>Xe(),[]),c.useEffect(()=>{new URLSearchParams(location.search).has("transient")||ea("mini.open")},[]),t.jsx(ys,{buildDefault:mr,resizable:!!window.tangu?.miniResize&&!new URLSearchParams(location.search).has("transient"),direct:i?.view?{title:i.title,view:i.view,mainView:i.mainView??i.view}:null})}const hr={settings:"settings.title",market:"market.title",achievements:"achievements.title",feedback:"feedback.title",btw:"btw.title"};function gr(n,i){return n.builtin?i(hr[n.builtin]):n.title}function br(){const{t:n}=be(),i=pt(),[o,d]=c.useState(null),a=N(ls(h=>({cfg:h.cfg,cfgLoaded:h.cfgLoaded,closeSettings:h.closeSettings,closeMarket:h.closeMarket,closeAchievements:h.closeAchievements,closeFeedback:h.closeFeedback,patchConfig:h.patchConfig,connect:h.connect}))),v=o?.params?.session?.id?o.params.session:null,p=()=>window.tangu?.closeSelf?.(),g=o?.builtin==="btw"?xa(o.params):null,w=o?gr(o,n):"";if(c.useEffect(()=>{o?.builtin&&w&&(document.title=w)},[o?.builtin,w]),c.useEffect(()=>{N.getState().setTr((h,I)=>n(h,I))},[n]),c.useEffect(()=>{N.getState().boot()},[]),c.useEffect(()=>{window.amadeus&&$t()},[]),c.useEffect(()=>Xe(),[]),c.useEffect(()=>window.tangu?.onMainAction?.(h=>{h==="agents-changed"&&(N.getState().refreshAgents(),window.dispatchEvent(new Event("forsion:agents-changed"))),h==="skills-changed"&&(_t(Bt()).then(I=>N.setState({skillsList:I})).catch(()=>{}),window.dispatchEvent(new Event("forsion:skills-changed")))}),[]),c.useEffect(()=>{const h=ii(),I=window.tangu?.onFloatingTarget?.(d);return window.tangu?.floatingReady?.(h).then(C=>{C&&d(C)}),()=>I?.()},[]),c.useEffect(()=>{o?.builtin==="feedback"&&typeof o.params?.description=="string"&&N.setState({feedbackDraft:o.params.description})},[o]),!o)return t.jsx("div",{className:"floating-native-root"});const m=()=>{a.closeSettings(),p()},k=()=>{a.closeMarket(),p()},f=()=>{a.closeAchievements(),p()},b=()=>{a.closeFeedback(),p()};return t.jsxs("div",{className:"floating-native-root",children:[window.tangu?.platform==="darwin"&&t.jsx("header",{className:"floating-native-chrome",children:t.jsx("span",{title:w,children:w})}),t.jsxs("main",{className:"floating-native-content",children:[o.builtin==="settings"&&t.jsx(os,{open:!0,initialTab:typeof o.params?.tab=="string"?o.params.tab:void 0,initialSkillKey:typeof o.params?.skillKey=="string"?o.params.skillKey:void 0,cfg:a.cfg,activeSession:v,themeLang:i.lang,themeSkin:i.skin,themeMode:i.mode,themeModePref:i.modePref,flatOn:i.flat,glassOn:i.glass,themeSeed:i.seed,onClose:m,onConfigChange:a.patchConfig,onThemeChange:(h,I,C)=>i.setTheme(h,I,i.bg,C),onFlatChange:i.setFlat,onGlassChange:i.setGlass,onSeedChange:i.setSeedValue,onReloadThemes:i.reloadThemes,onReconnect:h=>{a.connect({...a.cfg,...h||{}})},onRelaunchOnboarding:()=>{try{localStorage.removeItem(Ft)}catch{}window.tangu?.requestMainAction?.("onboarding"),p()}},JSON.stringify(o.params??{})),o.builtin==="market"&&t.jsx(is,{initialItemId:typeof o.params?.itemId=="string"?o.params.itemId:void 0,initialDetailTab:typeof o.params?.detailTab=="string"?o.params.detailTab:void 0,initialQuery:typeof o.params?.q=="string"?o.params.q:void 0,onClose:k},String(o.params?.nonce??o.params?.itemId??o.params?.q??"")),o.builtin==="achievements"&&t.jsx(as,{onClose:f}),o.builtin==="feedback"&&a.cfgLoaded&&t.jsx(Ss,{surface:"panel",cfg:a.cfg,activeSession:v,onClose:b},v?.id||""),o.builtin==="btw"&&a.cfgLoaded&&g&&t.jsx(po,{seed:g,onClose:p}),o.view&&t.jsx(js,{target:o.view,onUnavailable:p})]}),(o.builtin==="settings"||o.builtin==="market")&&t.jsx(rs,{}),o.builtin==="settings"&&t.jsx(ai,{})]})}let he=null;function Qn(n){if(!n){he&&(he.style.display="none");return}he||(he=document.createElement("div"),Object.assign(he.style,{position:"fixed",inset:"0",pointerEvents:"none",zIndex:"99998",boxSizing:"border-box",border:"3px solid var(--accent, #4d8794)",background:"color-mix(in srgb, var(--accent, #4d8794) 8%, transparent)"}),document.body.appendChild(he)),he.style.display="block"}function wr(){const n=window.tangu;if(n?.openDetached){if(Ye()==="main"){let i="";const o=()=>{const p=N.getState(),g=p.activeId,w={sessionId:g,runId:g?p.runningBySession[g]??null:null},m=JSON.stringify(w);m!==i&&(i=m,n.reportMiniSession?.(w))};N.subscribe(o),o();let d=null;const a=()=>{if(!W.getState().api||!d||!ge(d.type))return;const g=d;d=null,g.spaceId&&Ke(g.spaceId);const w=W.getState().openView(g.type,g.params??{},"main");w&&g.params&&w.setParams({...w.params,...g.params})};n.onMainPanelTarget?.(p=>{d=p,a()}),Ee(a);let v=!1;W.subscribe(p=>{p.api&&(v||(v=!0,n.mainPanelReady?.()),a())})}ri({ribbonPointerDrag:n.platform==="win32",cursorScreenPoint:n.cursorScreenPoint,detach:(i,o)=>{n.openDetached?.(i,o)},openSpace:(i,o)=>{Ye()==="main"&&oa()===i&&K.getState().activeSpaceId===i&&W.getState().saveNamed(ia(i)),n.openDetached?.([],o,{space:i})},dragUpdate:(i,o,d)=>n.dragUpdate?.(i,o,d),drop:async(i,o,d)=>(await n.dropView?.(i,o,d))?.routed??!1}),n.onAcceptView?.(i=>{Qn(null),W.getState().openView(i.type,i.params??{},"main")}),n.onDragPreview?.(i=>Qn(i))}}function vr(){const n=window.tangu;if(!n?.reportRunningSessions)return;const i=o=>n.reportRunningSessions(Object.keys(o).length);i(N.getState().runningBySession),N.subscribe((o,d)=>{o.runningBySession!==d.runningBySession&&i(o.runningBySession)})}const Jn=n=>Sa(n).toLowerCase(),Es=(n,i)=>n.configBySession[i]?.cwd||n.sessions.find(o=>o.id===i)?.project_path||"",Cs=(n,i)=>Object.keys(n.runningBySession).some(o=>Jn(Es(n,o))===Jn(i));function kr(){const n=window.tangu;if(!(!n?.codeStudioGitCommit||!n.codeStudioGitStatus||!n.productsIsCreation))return N.subscribe((i,o)=>{if(i.runningBySession!==o.runningBySession)for(const d of Object.keys(o.runningBySession)){if(i.runningBySession[d])continue;const a=Es(i,d);!a||Cs(i,a)||yr(a,d)}})}async function yr(n,i){try{if(!await window.tangu.productsIsCreation(n))return;const o=await window.tangu.codeStudioGitStatus(n);if(!(o?.auto??o?.writable)||Cs(N.getState(),n))return;const d=fo(N.getState().messagesBySession[i]||[]);await window.tangu.codeStudioGitCommit(n,{name:d,auto:!0,untitled:es("studio.history.untitled")})}catch(o){console.warn("[creations] 自动存版本失败",o)}}function xr(){if(!window.tangu?.onAuthWillChange)return()=>{};let n=!1,i=null,o=!1,d=0,a=Promise.resolve(),v=!1;const p=()=>{i&&(i.inert=o),i=null},g=window.tangu.onAuthWillChange(async()=>{const m=++d;i||(i=document.body,o=i?.inert??!1,i&&(i.inert=!0));try{if(await a,m!==d||v||!window.amadeus)return;const[{flushAllScopes:k,resetAllScopeDocs:f,usePageStore:b},{useDbStore:h},{useDrawStore:I},C]=await Promise.all([Be(()=>import("./pageStore-CyvNZEYX.js").then(j=>j.dI),__vite__mapDeps([0,1,2,3,4]),import.meta.url),Be(()=>import("./dbStore-BIG5Mfh2.js").then(j=>j.d),__vite__mapDeps([5,0,1,2,3,4]),import.meta.url),Be(()=>import("./drawingStore-CGvTqqYW.js").then(j=>j.m),__vite__mapDeps([6,1,0,2,3,4]),import.meta.url),Be(()=>import("./index-fDB1l4d-.js").then(j=>j.cw),[],import.meta.url)]);if(await Promise.all([k(!0),h.getState().flushAll(!0),I.getState().flushAll(!0)]),m!==d)return;n=b.getState().vaultSide==="cloud",n&&(C.retireAllUnifiedScopes(),f(),b.setState({vaultRoot:null,pages:[],folders:[],files:[],icons:{}}))}catch(k){throw m===d&&p(),k}}),w=window.tangu.onAuthChanged?.(()=>{const m=++d;if(!n){a.finally(()=>{m===d&&p()});return}n=!1,a=a.then(async()=>{const{usePageStore:k}=await Be(async()=>{const{usePageStore:f}=await import("./pageStore-CyvNZEYX.js").then(b=>b.dI);return{usePageStore:f}},__vite__mapDeps([0,1,2,3,4]),import.meta.url);v||(await k.getState().restoreVault(),await k.getState().initVaultSide())}).catch(k=>console.error("[auth] Cannot restore vault after account change:",k)).finally(()=>{m===d&&p()})});return()=>{v=!0,++d,g(),w?.(),p()}}xr();window.addEventListener("error",n=>{console.error("[tangu] window error:",n.error||n.message)});window.addEventListener("unhandledrejection",n=>{console.error("[tangu] unhandledrejection:",n.reason)});const Sr=(()=>{try{return location.hash==="#preview"}catch{return!1}})(),dt=Ye();try{document.documentElement.dataset.window=dt}catch{}try{document.documentElement.lang=Us()==="zh"?"zh-CN":"en"}catch{}try{window.tangu?.platform==="darwin"&&(document.documentElement.dataset.platform="mac")}catch{}let Ns,Is=null;try{Ns=localStorage.getItem("forsion_theme_seed")||void 0}catch{}try{Is=localStorage.getItem("forsion_theme_lang")}catch{}try{ci(li(),di(),ui(),mi(),{customColor:Ns}),pi(),document.documentElement.style.removeProperty("background"),pt.getState().initThemes(Is),N.getState().setTr(es),ho(),wr(),vr(),kr(),fi(),go(),hi()}catch(n){console.error("[tangu] init failed, continue to mount:",n),gi("init",n)}function jr(){const n=bi()?.Preview;return n?t.jsx(n,{}):null}Xs.createRoot(document.getElementById("root")).render(t.jsx(Ks,{children:t.jsx(bo,{children:Sr?t.jsx(jr,{}):dt==="mini"?t.jsx(pr,{}):dt==="floating"?t.jsx(br,{}):dt==="detached"?t.jsx(ir,{}):t.jsx(nr,{})})}));
|