limixbot 0.3.29 → 0.3.31
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/dist/assets/{ActivityPanel-Cv8SavDj.js → ActivityPanel-DPKaOxwD.js} +1 -1
- package/dist/assets/{App-ajUV-Eko.js → App-CXIAAQw4.js} +99 -99
- package/dist/assets/{AppEventEditor-BmuhU4di.js → AppEventEditor-BYUFU-RF.js} +1 -1
- package/dist/assets/{BotSettingsDialog-Djt5Z8_c.js → BotSettingsDialog-CNzHxE5T.js} +1 -1
- package/dist/assets/{BrowserPanel-cwjDpf3J.js → BrowserPanel-BvycPh9Q.js} +1 -1
- package/dist/assets/{BrowserProfilesManager-CzNf4P8c.js → BrowserProfilesManager-C-DSmpiF.js} +1 -1
- package/dist/assets/{CloudAddDialog-CuAJ_n8A.js → CloudAddDialog-C65BNNxP.js} +1 -1
- package/dist/assets/{ComputerFilesPane-CUwmhG4G.js → ComputerFilesPane-y6L4ZrAL.js} +1 -1
- package/dist/assets/ComputerPanel-C8ncdcmm.js +2 -0
- package/dist/assets/{DataPanel-LpZaOwFy.js → DataPanel-B42JmnxF.js} +1 -1
- package/dist/assets/{DesktopViewer-CO6rKDOC.js → DesktopViewer-DbEC8oPW.js} +1 -1
- package/dist/assets/{FilesView-BcPlXY2Z.js → FilesView-BWruPNny.js} +1 -1
- package/dist/assets/{GrokMoveDialog-DPhfPAAd.js → GrokMoveDialog-c5X1j8au.js} +1 -1
- package/dist/assets/{InspectorPanel-l3AppDb0.js → InspectorPanel-BjMcrEJ5.js} +1 -1
- package/dist/assets/{KeyboardShortcutsModal-D78LOnXx.js → KeyboardShortcutsModal-epRIaVPK.js} +1 -1
- package/dist/assets/{LiveDesktop-DCwjKpuh.js → LiveDesktop-B6kJJHn8.js} +1 -1
- package/dist/assets/LocalVmWorkspace-BiZhg9qH.js +1 -0
- package/dist/assets/{MacLocalControl-QdlFsN0H.js → MacLocalControl-D7ByxpUV.js} +1 -1
- package/dist/assets/{MarkdownFilePreview-BQk1kEdI.js → MarkdownFilePreview-BIrbvZT_.js} +1 -1
- package/dist/assets/{MenuMotion-QoOXKNvf.js → MenuMotion-Dj4rtEj4.js} +1 -1
- package/dist/assets/{NewBotDialog-DxwobeWs.js → NewBotDialog-B9SBavIN.js} +1 -1
- package/dist/assets/{PhoneAppDialog-ht-Y64Q_.js → PhoneAppDialog-U09W36YX.js} +1 -1
- package/dist/assets/{PlacesRail-B0r2Van_.js → PlacesRail-bn7tEIBM.js} +1 -1
- package/dist/assets/{PluginsPanel-CUxVDpGZ.js → PluginsPanel-Cc7XMnL0.js} +1 -1
- package/dist/assets/{ProIntroduction-CE4vJUn2.js → ProIntroduction--tZnt9fj.js} +1 -1
- package/dist/assets/{RemoteAgentSettingsPanel-3he4axXK.js → RemoteAgentSettingsPanel-lr4-06Ct.js} +1 -1
- package/dist/assets/{RoomPanel-By9zNgSd.js → RoomPanel-Dc2iAV1X.js} +1 -1
- package/dist/assets/{RoutinesPage-qN6QGEQA.js → RoutinesPage-0ilXXAQg.js} +1 -1
- package/dist/assets/SettingsModal-DOQo4UPP.js +19 -0
- package/dist/assets/{ShareTeamDialog-D2VGoot3.js → ShareTeamDialog-O9ZwVnKj.js} +1 -1
- package/dist/assets/{SignedInSites-UilEy8xN.js → SignedInSites-BlnZihVe.js} +1 -1
- package/dist/assets/{TeamLibraryPanel-iXKP8bHg.js → TeamLibraryPanel-BLrCrURN.js} +1 -1
- package/dist/assets/{TeamMapPage-DXmzzK2K.js → TeamMapPage-DIVPsZwZ.js} +1 -1
- package/dist/assets/{TriggersPage-cCF8IoEn.js → TriggersPage-b2SXuCPa.js} +1 -1
- package/dist/assets/{VisibilitySection-BYBx_roX.js → VisibilitySection-BjcUdV_p.js} +1 -1
- package/dist/assets/{WebhookTrigger-B3HjCzO1.js → WebhookTrigger-BBi06Y-c.js} +1 -1
- package/dist/assets/{WorksOnGrid-Cb8HQTdi.js → WorksOnGrid-B5p2GXxB.js} +1 -1
- package/dist/assets/{abnfDiagram-YUKMZFIV-D3RC58wh.js → abnfDiagram-YUKMZFIV-BcUIfOEe.js} +1 -1
- package/dist/assets/{activity-Dbl6UsX-.js → activity-BNFKxy1b.js} +1 -1
- package/dist/assets/{architectureDiagram-47P4ROYG-Z8fpyY75.js → architectureDiagram-47P4ROYG-C7ht62Bt.js} +1 -1
- package/dist/assets/{blockDiagram-E7TT5TSB-DvE9XpO8.js → blockDiagram-E7TT5TSB-CaczmOHs.js} +1 -1
- package/dist/assets/{c4Diagram-CRA5TL53-BpGfeK2S.js → c4Diagram-CRA5TL53-DSPaJBwh.js} +1 -1
- package/dist/assets/{calendar-days-D_ADHCH2.js → calendar-days-DU-aFzFs.js} +1 -1
- package/dist/assets/channel-BXNHTVIL.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-D67vAX0H.js → chunk-2Q5K7J3B-D4erYHrR.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-CMFiNc6u.js → chunk-5VM5RSS4-D8syTc7K.js} +1 -1
- package/dist/assets/{chunk-7TKQ45FW-CoFLZ60I.js → chunk-7TKQ45FW-qZ8vN88Y.js} +1 -1
- package/dist/assets/{chunk-AW2ZBBNX-gUfW5Adc.js → chunk-AW2ZBBNX-COZ0RY0p.js} +1 -1
- package/dist/assets/{chunk-FVRAUYC3-D1Q069A2.js → chunk-FVRAUYC3-B9WP6gNL.js} +2 -2
- package/dist/assets/{chunk-HTAEGDNF-D3ZZF79x.js → chunk-HTAEGDNF-DpLxKDYN.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-qcqhs_9A.js → chunk-JWPE2WC7-CyI6_v_4.js} +1 -1
- package/dist/assets/{chunk-KQW6MTUR-ChtMO8fh.js → chunk-KQW6MTUR-C3xLM0DV.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-Bx_iNGRg.js → chunk-XXDRQBXY-C7oc9LKJ.js} +1 -1
- package/dist/assets/{classDiagram-v2-K4WV4PDN-BFNAyWC6.js → classDiagram-v2-K4WV4PDN-DtYcyxMZ.js} +1 -1
- package/dist/assets/{coins-DKr1YBNV.js → coins-C8BnHs7A.js} +1 -1
- package/dist/assets/{core-CncVixaG.js → core-8c5YWRlC.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-Bg8ti_oz.js → cose-bilkent-JH36ORCC-BACClH_n.js} +1 -1
- package/dist/assets/{cynefin-EF2NZ3EQ-AzIaeBzO.js → cynefin-EF2NZ3EQ-DZo-gx9_.js} +1 -1
- package/dist/assets/{cynefinDiagram-3GCD6N5R-DkvCNROf.js → cynefinDiagram-3GCD6N5R-CB9Tufy-.js} +1 -1
- package/dist/assets/{dagre-W4DXFKR2-eHc7s4oU.js → dagre-W4DXFKR2-QmMefB-F.js} +1 -1
- package/dist/assets/{diagram-2UJZ2QOL-C7M1j1Z_.js → diagram-2UJZ2QOL-BB9UdSXb.js} +1 -1
- package/dist/assets/{diagram-OVF4WLC6-CsI6LK_l.js → diagram-OVF4WLC6-BT1xV_u3.js} +1 -1
- package/dist/assets/{diagram-PFPMY2P6-Cy-sdnqW.js → diagram-PFPMY2P6-Bb8Gcrwm.js} +1 -1
- package/dist/assets/{diagram-UMYRVEAY-BUJZwO0b.js → diagram-UMYRVEAY-CuhVtw_K.js} +1 -1
- package/dist/assets/{diagram-YEKJPTXX-W-jVXeaq.js → diagram-YEKJPTXX-BKeM2V-v.js} +1 -1
- package/dist/assets/{diagram-ZIFT7M5P-lriD7N0L.js → diagram-ZIFT7M5P-CWJdSX39.js} +1 -1
- package/dist/assets/{ebnfDiagram-VR2GEFS7-BsUEFVYI.js → ebnfDiagram-VR2GEFS7-CQt0qwgC.js} +1 -1
- package/dist/assets/{elk-IJKZMXRS-DaJpjkbS.js → elk-IJKZMXRS-DTpYboxu.js} +1 -1
- package/dist/assets/{erDiagram-O2IAPWRE-BcNSWX_I.js → erDiagram-O2IAPWRE-CRmD7TiT.js} +1 -1
- package/dist/assets/{file-up-W9Ukts61.js → file-up-DA-MGVqh.js} +1 -1
- package/dist/assets/{flowDiagram-OXPTDLAJ-C0yLQ4G-.js → flowDiagram-OXPTDLAJ-C3OIuz51.js} +1 -1
- package/dist/assets/{ganttDiagram-R7TSEDQI-C8zJsAus.js → ganttDiagram-R7TSEDQI-DRztzQgb.js} +1 -1
- package/dist/assets/{gitGraphDiagram-XJZIOB7I-CvM9Ff5h.js → gitGraphDiagram-XJZIOB7I-DljlrTI8.js} +1 -1
- package/dist/assets/{import-name-IKTfLDbm.js → import-name-BCsjPBcL.js} +1 -1
- package/dist/assets/{index-C5PxeCx7.js → index-CdcrwTp5.js} +2 -2
- package/dist/assets/{index-DXcH006d.js → index-DJmQoZKd.js} +1 -1
- package/dist/assets/{infoDiagram-5W2HQ5XZ-EFSHnQLZ.js → infoDiagram-5W2HQ5XZ-sZgtYSBR.js} +1 -1
- package/dist/assets/{ishikawaDiagram-K3B6WC7H-Do-25hEq.js → ishikawaDiagram-K3B6WC7H-C3hf18HZ.js} +1 -1
- package/dist/assets/{journeyDiagram-COXZFDF6-B2ghVJCI.js → journeyDiagram-COXZFDF6-Cx7iVI1Y.js} +1 -1
- package/dist/assets/{kanban-definition-P3RFRI5V-TkPbxRAY.js → kanban-definition-P3RFRI5V-BCfPOAwE.js} +1 -1
- package/dist/assets/{mcp-servers-CLBiWzWC.js → mcp-servers-Dz1aRDIp.js} +1 -1
- package/dist/assets/{mermaid.core-DO0Pzmu4.js → mermaid.core-u5mM9R6c.js} +4 -4
- package/dist/assets/{mindmap-definition-LZFPQGKD-nID_euLE.js → mindmap-definition-LZFPQGKD-Bl1ss-w7.js} +1 -1
- package/dist/assets/{minimize-BYioV8YM.js → minimize-CQhJEKJt.js} +1 -1
- package/dist/assets/{monitor-DGPG5gJh.js → monitor-DUalxLhV.js} +1 -1
- package/dist/assets/{new-bot-CzseIDJe.js → new-bot-CnIvjdzz.js} +1 -1
- package/dist/assets/{org-library-D736oTBO.js → org-library-BIflpykR.js} +1 -1
- package/dist/assets/{package-format-DVPcCWYU.js → package-format-BwQBEF2h.js} +1 -1
- package/dist/assets/{pegDiagram-BGZESJAR-BBY2tvO7.js → pegDiagram-BGZESJAR-DYVS4bK_.js} +1 -1
- package/dist/assets/{pieDiagram-CAPJLFHJ-DX04Xe_e.js → pieDiagram-CAPJLFHJ-Dd2OI03J.js} +1 -1
- package/dist/assets/{quadrantDiagram-GDMTTRAM-DaV-XRR2.js → quadrantDiagram-GDMTTRAM-DftvCum7.js} +1 -1
- package/dist/assets/{rail-B6Von-6v.js → rail-5xabqdtQ.js} +1 -1
- package/dist/assets/{railroadDiagram-SM67HX2B-BszaHa5J.js → railroadDiagram-SM67HX2B-CMUXYZoX.js} +1 -1
- package/dist/assets/{remote-desktop-panel-C_BqZvn5.js → remote-desktop-panel-Doj97m8r.js} +1 -1
- package/dist/assets/{requirementDiagram-X7JNWC4A-mBECwzIc.js → requirementDiagram-X7JNWC4A-TUFFobBi.js} +1 -1
- package/dist/assets/{sankeyDiagram-UM26HJRW-BVYWK2kU.js → sankeyDiagram-UM26HJRW-BoWUtM1O.js} +1 -1
- package/dist/assets/{sequenceDiagram-ZO4K6R2Y-Cm1NiUC3.js → sequenceDiagram-ZO4K6R2Y-BJGhu1J3.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-By1WASi4.js → sizeCapture-INFHLROL-BjWOwFei.js} +1 -1
- package/dist/assets/{stateDiagram-v2-TBUQTH76-BC010wH6.js → stateDiagram-v2-TBUQTH76-BHnqACBE.js} +1 -1
- package/dist/assets/styles-BxpHDI63.css +1 -0
- package/dist/assets/{swimlanes-N4OXWK64-kzfE1u3G.js → swimlanes-N4OXWK64-w7Jh9mLp.js} +1 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-zIHpuU63.js +8 -0
- package/dist/assets/{team-share-Cz-g0ol5.js → team-share-iEP9Zjr-.js} +1 -1
- package/dist/assets/{timeline-definition-YOQAKGHF-DaWipjgK.js → timeline-definition-YOQAKGHF-D0trOSBD.js} +1 -1
- package/dist/assets/{usecaseDiagram-VIAY4XPW-DAGDIl84.js → usecaseDiagram-VIAY4XPW-A_NiPbx_.js} +1 -1
- package/dist/assets/{vennDiagram-BLWOH2XV-DQpd7Brj.js → vennDiagram-BLWOH2XV-iEyMv06N.js} +1 -1
- package/dist/assets/{wardleyDiagram-YMQ3BMBF-CDz0yqs3.js → wardleyDiagram-YMQ3BMBF-yIcnyDG1.js} +1 -1
- package/dist/assets/{xychartDiagram-TAQBALBS-BjjtqaU2.js → xychartDiagram-TAQBALBS-BbKfuPA4.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/rail.html +5 -5
- package/dist-server/container-mcp.js +3 -3
- package/dist-server/index.js +2200 -2186
- package/dist-server/openmausbot.js +311 -310
- package/dist-server/package.json +1 -1
- package/dist-server/pair-cli.js +311 -310
- package/dist-server/server/config.js +4 -0
- package/dist-server/server/container-computer.js +41 -3
- package/dist-server/server/harness/registry.js +8 -3
- package/dist-server/server/index.js +11 -8
- package/dist-server/server/limix-skill-requirements.js +31 -34
- package/dist-server/server/limix-vm-capacity.js +64 -0
- package/dist-server/server/local-vm-settings.js +10 -3
- package/dist-server/server/routes/bot-skills.js +7 -0
- package/dist-server/server/routes/computers.js +12 -13
- package/dist-server/server/routes/instances.js +12 -2
- package/dist-server/shared/limix-vm-capacity.js +1 -0
- package/dist-server/vps-container-mcp.js +3 -3
- package/dist-server/workspace-backup.worker.js +3 -3
- package/package.json +1 -1
- package/dist/assets/ComputerPanel-thbNTglI.js +0 -2
- package/dist/assets/LocalVmWorkspace-DRUmNe2b.js +0 -1
- package/dist/assets/SettingsModal-YpTplGBe.js +0 -19
- package/dist/assets/channel-D_u3gZnK.js +0 -1
- package/dist/assets/styles-D4XTB2mJ.css +0 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-CsEp3kJM.js +0 -8
- /package/dist/assets/{styles-BynTeCUc.js → styles-DnwnyZpR.js} +0 -0
package/dist/assets/{BrowserProfilesManager-CzNf4P8c.js → BrowserProfilesManager-C-DSmpiF.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t,r as y,j as s}from"./styles-
|
|
1
|
+
import{t,r as y,j as s}from"./styles-DnwnyZpR.js";import{_ as Y,u as Z,bc as ee,D as R,G as se,T as te,n as B,A as z}from"./App-CXIAAQw4.js";import{r as ne,i as ie}from"./index-CdcrwTp5.js";import{S as q}from"./SignedInSites-BlnZihVe.js";import{P as re}from"./PlacesRail-bn7tEIBM.js";function G(i){return i.map(({id:l,name:x,browser:c})=>({id:l,name:x,...c?{browser:c}:{}}))}function ae(i,l){return{browserProfiles:G(l),expectedBrowserProfiles:G(i)}}function oe(){return`profile-${Y().replaceAll("-","")}`}function J(i,l){const x=i.filter(g=>g.browserProfile===l&&g.busy);if(!x.length)return null;const c=x.map(g=>g.name).join(", ");return x.length===1?t("settings.profiles.busyOne",{names:c}):t("settings.profiles.busyMany",{names:c})}function le(i,l){return i&&l?{threadId:l}:{}}function ue(i,l){const x=new URLSearchParams(l).toString();return x?`${i}${i.includes("?")?"&":"?"}${x}`:i}function pe({bot:i,onProfileChanged:l,disabled:x=!1}){const{state:c,dispatch:g,flushBotPatches:_}=Z(),r=c.config?.browserProfiles??[],v=c.config?.browserEngine?.myChrome===!0,b=c.config?.browserEngine?.myChromeOn,E=c.config?.browserEngine?.myChromeLendable===!0,w=c.bots??[],o=i?w.find(e=>e.id===i.id)??i:void 0,[O,L]=y.useState(null),[S,f]=y.useState(!1),[N,A]=y.useState(""),[h,j]=y.useState(null),[F,u]=y.useState(""),k=y.useId(),a=S||x||O!==!0;y.useEffect(()=>{let e=!0;return ne().then(n=>{e&&L(ie(n))}),()=>{e=!1}},[]);const T=async e=>{if(u(e instanceof Error?e.message:t("settings.profiles.saveError")),e instanceof z&&e.status===409)try{const n=await B("/api/config");g({type:"configStatus",config:n})}catch{u(t("settings.profiles.refreshError"))}e instanceof z&&(e.status===401||e.status===403)&&L(!1)},C=async e=>{try{const n=await B("/api/config",{method:"PATCH",body:JSON.stringify(ae(r,e))});return g({type:"configStatus",config:n}),!0}catch(n){return await T(n),!1}},K=async()=>{if(!(a||!N.trim()||r.length>=20)){f(!0),u("");try{await C([...r,{id:oe(),name:N.trim()}])&&A("")}finally{f(!1)}}},Q=async()=>{if(!(a||!h?.name.trim())){if(!r.some(e=>e.id===h.id)){u(t("settings.profiles.removed"));return}f(!0),u("");try{await C(r.map(e=>e.id===h.id?{...e,name:h.name.trim()}:e))&&j(null)}finally{f(!1)}}},V=async e=>{if(a)return;const n=J(w,e.id);if(n)return u(n);const p=w.filter(m=>m.browserProfile===e.id),$=p.length?` ${t("settings.profiles.deleteUsers",{names:p.map(m=>m.name).join(", ")})}`:"";if(window.confirm(t("settings.profiles.confirm",{name:e.name,bots:$}))){f(!0),u("");try{await C(r.filter(m=>m.id!==e.id))&&(h?.id===e.id&&j(null),o?.browserProfile===e.id&&l?.())}finally{f(!1)}}},W=async(e,n)=>{if(!(a||(e.browser??"")===n)){f(!0),u("");try{await C(r.map(p=>p.id===e.id?{...p,browser:n==="chrome"?"chrome":void 0}:p))}finally{f(!1)}}},X=async e=>{if(!(a||!o||o.busy||e===(o.browserProfile??""))){f(!0),u("");try{await _(o.id);const n=await B(`/api/bots/${encodeURIComponent(o.id)}`,{method:"PATCH",body:JSON.stringify({browserProfile:e||null})});g({type:"botPatched",bot:n.bot}),l?.()}catch(n){await T(n)}finally{f(!1)}}};if(O===!1)return s.jsx("p",{className:"text-[12px] text-ink-secondary",children:t("settings.profiles.ownerOnly")});const I="min-w-0 flex-1 rounded-md border border-hairline/40 bg-inset px-2.5 py-2 text-[13px] text-ink outline-none focus:border-accent disabled:opacity-50",P="shrink-0 rounded-md bg-control px-2.5 py-2 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-50",d=o?.browserProfile??"",M=r.find(e=>e.id===d),U=e=>w.filter(n=>n.browserProfile===e).map(n=>n.name),D=e=>e?.browser==="chrome"&&(v||E),H=s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeHint")}),b&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeLent",{name:b.name,device:ee(b.device)})}),b?.online===!1&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeLentOffline",{name:b.name})})]});return s.jsxs("div",{className:"flex min-w-0 flex-col gap-3","aria-busy":S,children:[o&&s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:`${k}-profile`,className:"text-[12px] font-medium text-ink",children:t("settings.profiles.browserSession")}),s.jsxs(R,{className:"w-full",id:`${k}-profile`,value:d,disabled:a||o.busy,onChange:e=>{X(e.target.value)},children:[s.jsx("option",{value:"",children:t("settings.profiles.own")}),r.map(e=>s.jsx("option",{value:e.id,children:e.name},e.id)),s.jsx("option",{value:"guest",children:t("settings.profiles.temporary")}),d&&d!=="guest"&&!r.some(e=>e.id===d)?s.jsx("option",{value:d,disabled:!0,children:t("settings.profiles.removed")}):null]}),s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:o.busy?t("settings.profiles.stopToSwitch"):d==="guest"?t("settings.profiles.temporaryHint"):t("settings.profiles.sharedHint")}),D(M)?s.jsxs(s.Fragment,{children:[H,!v&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeShare")})]}):(d===""||M)&&s.jsx(q,{target:{bot:o.id},scope:le(c.config?.team,i?.threadId),sharedBy:d?U(d):[o.name],disabled:a},`${o.id}:${d}`)]}),s.jsxs("details",{open:!o,className:"min-w-0",children:[s.jsx("summary",{className:"cursor-pointer text-[12px] font-medium text-ink-secondary hover:text-ink",children:t("settings.profiles.manage")}),s.jsxs("div",{className:"mt-3 flex flex-col gap-3",children:[s.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:e=>{e.preventDefault(),K()},children:[s.jsx("label",{htmlFor:`${k}-new`,className:"sr-only",children:t("settings.profiles.newName")}),s.jsx("input",{id:`${k}-new`,value:N,onChange:e=>A(e.target.value),maxLength:40,required:!0,disabled:a||r.length>=20,placeholder:t("settings.profiles.newName"),className:I}),s.jsxs("button",{type:"submit",disabled:a||!N.trim()||r.length>=20,className:`${P} flex items-center gap-1`,children:[s.jsx(re,{size:13}),t("settings.profiles.create")]})]}),r.length>=20&&s.jsx("p",{className:"text-[11px] text-ink-secondary",children:t("settings.profiles.limit")}),!v&&r.length>0&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t(E?"settings.profiles.myChromeShare":"settings.profiles.myChromeUnavailable")}),!r.length&&s.jsx("p",{className:"text-[12px] text-ink-secondary",children:t("settings.profiles.sharedEmpty")}),s.jsx("div",{className:"divide-y divide-hairline/30",children:r.map(e=>{const n=U(e.id),p=J(w,e.id),$=D(e);return s.jsxs("div",{className:"flex flex-col gap-1 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(se,{size:14,className:"shrink-0 text-ink-secondary"}),h?.id===e.id?s.jsxs("form",{className:"flex min-w-0 flex-1 flex-wrap gap-2",onSubmit:m=>{m.preventDefault(),Q()},children:[s.jsx("input",{autoFocus:!0,value:h.name,onChange:m=>j({id:e.id,name:m.target.value}),maxLength:40,required:!0,disabled:a,className:I,"aria-label":t("settings.profiles.nameAria")}),s.jsx("button",{type:"submit",disabled:a||!h.name.trim(),className:P,children:t("common.save")}),s.jsx("button",{type:"button",disabled:S,onClick:()=>j(null),className:P,children:t("common.cancel")})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",disabled:a,onClick:()=>{j({id:e.id,name:e.name}),u("")},className:"min-w-0 flex-1 truncate text-left text-[13px] font-medium text-ink hover:underline disabled:opacity-50",title:t("settings.profiles.rename"),children:e.name}),s.jsxs("button",{type:"button",onClick:()=>{V(e)},disabled:a||!!p,title:p??t("settings.profiles.deleteTitle"),"aria-label":`${t("common.delete")} ${e.name}`,className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:bg-control hover:text-danger disabled:opacity-50",children:[s.jsx(te,{size:13}),t("common.delete")]})]})]}),s.jsx("p",{className:"break-words pl-6 text-[11px] text-ink-secondary",children:n.length?t("settings.profiles.usedBy",{names:n.join(", ")}):t("settings.profiles.notInUse")}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-2 pl-6 pt-1",children:[s.jsxs("label",{className:"flex items-center gap-2 text-[12px] text-ink-secondary",children:[t("settings.profiles.browserLabel"),s.jsxs(R,{size:"sm",value:e.browser??"",disabled:a,onChange:m=>{W(e,m.target.value)},children:[s.jsx("option",{value:"",children:t("settings.profiles.builtIn")}),s.jsx("option",{value:"chrome",disabled:!v,children:t("settings.profiles.myChrome")})]})]}),$?H:s.jsx(q,{target:{profile:e.id},sharedBy:n,disabled:a})]})]},e.id)})})]})]}),F&&s.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:F})]})}export{pe as B,le as b,ue as w};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,A as z,B as ve,H as U,t as n,D as se,Q,E as X,F as He,G as pe,I as Ce,J as Ee,K as fe,M as ze,N as Ae,O as Ue,R as qe,T as Me,U as G,a as ue,V as $e,W as Ke,r,Y as We,Z as Ve,$ as we,a0 as Ge,X as Je,a1 as Qe,a2 as Xe,a3 as Ye,a4 as Ze,a5 as et,a6 as Le,a7 as tt}from"./styles-BynTeCUc.js";import{L as nt,z as st,C as lt,y as J,F as at,G as ot,H as dt,S as rt,I as ct,J as it}from"./PlacesRail-B0r2Van_.js";import{u as ut}from"./App-ajUV-Eko.js";import"./monitor-DGPG5gJh.js";import"./index-C5PxeCx7.js";import"./MenuMotion-QoOXKNvf.js";function pt({name:t,color:a,busy:o,interest:d,openFailed:s,onInterest:u,onOpen:p}){return e.jsxs("div",{"data-cloud-add":"has-cloud",className:z,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(ve,{color:a,size:32}),e.jsx(U,{title:n("cloudBuy.one.title"),sub:n("cloudBuy.one.sub",{name:t})})]}),e.jsxs("div",{className:se,children:[d!=="sent"&&e.jsx("button",{type:"button",className:Q,disabled:o,onClick:u,children:n("cloudBuy.one.email")}),e.jsx("button",{type:"button",className:X,disabled:o,onClick:p,children:n("cloudBuy.setup.open",{name:t})})]}),e.jsxs("div",{"aria-live":"polite",className:"text-[13px] leading-[18px] empty:-mt-5",children:[d==="sent"&&e.jsx("p",{className:"text-ink-secondary",children:n("cloudBuy.one.thanks")}),d==="failed"&&e.jsx("p",{role:"alert",className:"text-danger",children:n("cloudBuy.one.failed")}),s&&e.jsx("p",{role:"alert",className:"text-danger",children:n("cloudBuy.openFailed",{name:t})})]})]})}function ie({kind:t,line:a,onRetry:o,onClose:d}){return e.jsxs("div",{"data-cloud-add":t,className:z,children:[e.jsx(U,{title:n("cloudAdd.title")}),a?e.jsx("p",{role:"alert",className:"text-[14px] leading-5 text-ink",children:a}):e.jsxs("p",{role:"status",className:"flex items-center gap-2 text-[13px] leading-[18px] text-ink-secondary",children:[e.jsx(nt,{size:14,className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}),n("cloudAdd.checking")]}),e.jsxs("div",{className:se,children:[e.jsx("button",{type:"button",className:Q,onClick:d,children:n("cloudAdd.close")}),o&&e.jsx("button",{type:"button",className:X,onClick:o,children:n("cloudAdd.tryAgain")})]})]})}function ft({plan:t,offer:a,browser:o,late:d,link:s,email:u,busy:p,copied:v,failed:N,onReopen:k,onCopy:I,onChangePlan:q}){const y=a?.plans.find(M=>M.tier===t)??null,E=y?He(y):pe(t),A=y?.trialDays===1?n("cloudBuy.pay.planTrial.one",{plan:E,due:Ce(0)}):y?.trialDays?n("cloudBuy.pay.planTrial.many",{plan:E,days:y.trialDays,due:Ce(0)}):y?n("cloudBuy.pay.planPaid",{plan:E,price:Ee(y.amount/100)}):E;return e.jsxs("div",{"data-cloud-add":d?"waiting-late":o==="signin"?"waiting-signin":"waiting",className:z,children:[e.jsx(U,{title:d?n("cloudBuy.pay.lateTitle"):n("cloudAdd.browserTitle"),sub:d?n("cloudBuy.pay.lateSub"):n(o==="signin"?"cloudBuy.pay.subSignIn":"cloudBuy.pay.sub")}),e.jsx(fe,{items:[{key:"signed-in",state:"done",title:n("cloudBuy.pay.signedIn"),detail:u},{key:"payment",state:"now",title:n("cloudBuy.pay.waiting"),detail:A},{key:"setup",state:"next",title:n("cloudBuy.pay.setup"),detail:n("cloudBuy.pay.setupHint")}]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",className:d?X:Q,disabled:p,onClick:k,children:[e.jsx(st,{size:14,"aria-hidden":"true"}),n("cloudAdd.reopenCheckout")]}),s&&e.jsxs("button",{type:"button",className:Q,disabled:p,onClick:I,children:[e.jsx(lt,{size:14,"aria-hidden":"true"}),n("cloudBuy.pay.copy")]}),e.jsx("button",{type:"button",className:`${ze} ms-1 px-1 py-1`,onClick:q,children:n("cloudAdd.changePlan")})]}),e.jsxs("div",{"aria-live":"polite",className:"text-[13px] leading-[18px] empty:-mt-5",children:[v&&e.jsx("p",{className:"text-ink-secondary",children:n("cloudBuy.pay.copied")}),N&&e.jsx("p",{role:"alert",className:"text-danger",children:n("cloudBuy.pay.failed")})]})]})}const R=[["reserving","cloudHome.step.reserving"],["storage","cloudHome.step.storage"],["starting","cloudBuy.step.starting"],["checking","cloudHome.step.checking"]];function mt({tier:t,trial:a,credit:o},d){if(d)return n("cloudAdd.receivedTitle");const s=pe(t??a?.tier??void 0);return a?o?n("cloudBuy.setup.badgeCredit",{plan:s,credit:Ee(o.grantedUsd)}):n("cloudBuy.setup.badgeTrial",{plan:s}):n("cloudBuy.setup.badgePaid",{plan:s})}function xt({started:t,received:a,step:o,slow:d,ready:s,sleeps:u=!1,name:p,typed:v,color:N,counting:k,busy:I,openFailed:q,onName:y,onColor:E,onOpen:A,onNotNow:M}){const _=s?R.length:Math.max(0,R.findIndex(([i])=>i===o)),C=pe(t.tier??t.trial?.tier??void 0);return e.jsxs("div",{"data-cloud-add":s?"ready":a?"received":"starting","data-cloud-setup":s?"ready":o??"reserving",className:z,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ue,{children:mt(t,a)}),e.jsx(U,{title:s?n("cloudBuy.ready.title",{name:p}):n("cloudBuy.setup.title"),sub:s?n("cloudBuy.ready.sub"):a?n("cloudAccount.purchaseNoteNoDate"):n("cloudBuy.setup.sub")})]}),e.jsxs("div",{className:"grid gap-6 sm:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ae,{value:_/R.length,label:n("cloudBuy.setup.progress")}),e.jsx(fe,{label:n("cloudBuy.setup.progress"),items:R.map(([i,w],j)=>({key:i,title:n(w,{name:p}),state:j<_?"done":j===_?"now":"next"}))}),d&&!s&&e.jsx("p",{role:"status",className:"px-3 text-[13px] leading-[18px] text-ink-secondary",children:n("cloudHome.slow")})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"cloud-add-name",className:"text-[13px] leading-[18px] text-ink-secondary",children:n("cloudBuy.setup.name")}),e.jsx("input",{id:"cloud-add-name",value:v,maxLength:Me,placeholder:n("cloudSetup.myCloud"),autoComplete:"off",spellCheck:!1,onChange:i=>y(i.target.value),className:qe})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{id:"cloud-add-color",className:"text-[13px] leading-[18px] text-ink-secondary",children:n("cloudBuy.setup.color")}),e.jsx("div",{role:"radiogroup","aria-labelledby":"cloud-add-color",className:"flex flex-wrap gap-2",children:G.map(i=>e.jsx("button",{type:"button",role:"radio","aria-checked":i===N,"aria-label":n(Ke[i]),tabIndex:i===N?0:-1,"data-color":i,onClick:()=>E(i),onKeyDown:w=>{const j=G.indexOf(i),$=w.key==="ArrowRight"||w.key==="ArrowDown"?1:w.key==="ArrowLeft"||w.key==="ArrowUp"?-1:0;if(!$)return;w.preventDefault();const Y=G[(j+$+G.length)%G.length];E(Y),w.currentTarget.parentElement?.querySelector(`[data-color="${Y}"]`)?.focus()},style:{background:$e(i)},className:ue("size-[26px] rounded-lg border-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",i===N?"border-ink shadow-[inset_0_0_0_2px_var(--color-app)]":"border-transparent")},i))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:"text-[13px] leading-[18px] text-ink-secondary",children:n("cloudBuy.setup.preview")}),e.jsxs("span",{"data-cloud-preview":!0,className:"inline-flex max-w-full items-center gap-2 self-start rounded-[12px] border-[0.5px] border-ink/10 bg-menu py-1.5 pe-3 ps-1.5",children:[e.jsx(ve,{color:N}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-[13px] font-medium leading-4 text-ink",children:p}),e.jsx("span",{className:"block truncate text-[12px] text-ink-tertiary",children:n(u?"cloudBuy.setup.previewLineSleeps":"cloudBuy.setup.previewLine",{plan:C})})]})]})]})]})]}),s&&k===null&&e.jsx("p",{className:"text-[13px] leading-[18px] text-ink-tertiary",children:n("cloudBuy.ready.hint",{name:p})}),e.jsxs("div",{className:se,children:[k!==null&&e.jsx("span",{role:"status",className:"me-1 text-[13px] text-ink-secondary",children:n("cloudBuy.setup.openingIn",{seconds:k})}),k!==null&&e.jsx("button",{type:"button",className:Q,onClick:M,children:n("notice.notNow")}),e.jsx("button",{type:"button",className:X,disabled:!s||I,onClick:A,children:n("cloudBuy.setup.open",{name:p})})]}),q&&e.jsx("p",{role:"alert",className:"-mt-2 text-end text-[13px] leading-[18px] text-danger",children:n("cloudBuy.openFailed",{name:p})})]})}function yt({team:t,step:a,slow:o}){const d=Math.max(0,R.findIndex(([u])=>u===a)),s=t??n("cloudBuy.team.unnamed");return e.jsxs("div",{"data-cloud-add":"team-starting","data-cloud-setup":a??"reserving",className:z,children:[e.jsx(U,{title:n("cloudBuy.team.setupTitle"),sub:n("cloudBuy.team.setupSub")}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ae,{value:d/R.length,label:n("cloudBuy.setup.progress")}),e.jsx(fe,{label:n("cloudBuy.setup.progress"),items:R.map(([u,p],v)=>({key:u,title:n(p,{name:s}),state:v<d?"done":v===d?"now":"next"}))}),o&&e.jsx("p",{role:"status",className:"px-3 text-[13px] leading-[18px] text-ink-secondary",children:n("cloudHome.slow")})]})]})}function gt({name:t,busy:a,openFailed:o,onOpen:d}){return e.jsxs("div",{"data-cloud-add":"team-ready",className:z,children:[e.jsx(U,{title:n("cloudBuy.team.readyTitle"),sub:n("cloudBuy.team.readySub",{name:t})}),e.jsx("p",{className:"text-[13px] leading-[18px] text-ink-tertiary",children:n("cloudBuy.ready.hint",{name:t})}),e.jsx("div",{className:se,children:e.jsx("button",{type:"button","data-autofocus":!0,className:X,disabled:a,onClick:d,children:n("cloudBuy.setup.open",{name:t})})}),o&&e.jsx("p",{role:"alert",className:"-mt-2 text-end text-[13px] leading-[18px] text-danger",children:n("cloudBuy.openFailed",{name:t})})]})}function ht({view:t,ui:a,actions:o}){switch(t.kind){case"checking":return e.jsx(ie,{kind:"checking",line:null,onClose:o.close});case"unreachable":return e.jsx(ie,{kind:"unreachable",line:n("cloudAdd.unreachable"),onRetry:o.retry,onClose:o.close});case"error":return e.jsx(ie,{kind:`error-${t.reason}`,line:n(t.reason==="rate-limited"?"cloudAdd.rateLimited":"cloudAdd.failed"),onRetry:o.retry,onClose:o.close});case"offer":return e.jsx(ct,{offer:t.offer,current:a.current,now:a.now,busy:a.busy,signedOut:t.signedOut,notice:t.notice?n(t.notice==="code-expired"?"cloudAdd.codeExpired":t.notice==="signin-ended"?"cloudAdd.signInEnded":t.notice==="terms"?"cloudBuy.termsChanged":"cloudAdd.preparing"):null,onStart:o.start,onSignIn:o.signIn});case"sign-in":return e.jsx(rt,{phase:t.phase,email:a.email,code:a.code,profileEmail:a.profileEmail,busy:a.busy,now:a.now,onBack:o.back,onEmail:o.email,onSend:o.sendCode,onChangeEmail:o.changeEmail,onCode:o.code,onResend:o.resend,onBrowser:o.browser});case"signing-in":return e.jsx(dt,{code:t.code,checkout:t.checkout,busy:a.busy,trial:a.offerShown?!!Le(a.offerShown,a.chosen).trialDays:!1,onReopen:o.reopenBrowser,onCancel:o.cancelSignIn});case"waiting":return e.jsx(ft,{plan:t.plan,offer:a.offerShown,browser:t.browser,late:t.late,link:t.link,email:t.email,busy:a.busy,copied:a.copied,failed:a.payFailed,onReopen:o.reopenCheckout,onCopy:o.copyLink,onChangePlan:o.changePlan});case"starting":case"ready":return e.jsx(xt,{started:t,received:t.kind==="starting"&&t.received,step:t.kind==="starting"?t.step:null,slow:t.kind==="starting"&&t.slow,ready:t.kind==="ready",sleeps:et(t,a.offerShown),name:a.look.name,typed:a.look.typed,color:a.look.color,counting:a.counting,busy:a.busy,openFailed:a.openFailed,onName:o.name,onColor:o.color,onOpen:o.openCloud,onNotNow:o.notNow});case"has-cloud":return e.jsx(pt,{name:a.look.name,color:a.look.color,busy:a.busy,interest:a.interest,openFailed:a.openFailed,onInterest:o.interest,onOpen:o.openCloud});case"team-starting":return e.jsx(yt,{team:t.team,step:t.step,slow:t.slow});case"team-ready":return e.jsx(gt,{name:t.team.name,busy:a.busy,openFailed:a.openFailed,onOpen:()=>o.openTeam(t.team.id)});case"settings":return null}}const bt={offer:"max-w-[920px]",starting:"max-w-[720px]",ready:"max-w-[720px]"};function Be({kind:t,staging:a,onClose:o,children:d}){return e.jsx("div",{className:"ui-scrim fixed inset-0 z-[60] flex items-center justify-center p-4 sm:p-6",onMouseDown:s=>s.stopPropagation(),children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"cloud-add-title","data-cloud-add-dialog":!0,tabIndex:-1,className:ue(Ze,"group/sheet animate-pop-in relative max-h-full w-full overflow-y-auto overscroll-contain outline-none",bt[t]??"max-w-[540px]"),children:[e.jsx("button",{type:"button",onClick:o,"aria-label":n("cloudAdd.close"),className:ue(Xe,Qe,"absolute end-4 top-4 z-10"),children:e.jsx(Je,{size:16})}),a&&e.jsx(Ye,{className:"absolute end-14 top-[22px] z-10 group-has-[[data-night-card]]/sheet:bg-app"}),d]})})}const kt=["offer","checking","unreachable","waiting","sign-in","signing-in"],jt="button:not([disabled]):not([tabindex='-1']), input:not([disabled]):not([tabindex='-1']), [href], [tabindex='0']",St=t=>t.status==="connected"&&t.entitlement?.plan==="free"&&!t.purchase&&!t.machine,Nt=t=>t?.status==="connected"&&t.entitlement?.plan==="pro"&&t.entitlement.status==="active"?t.entitlement.tier??"pro":null;function Lt({now:t=Date.now}){const{state:a,dispatch:o}=ut(),d=a.cloudAdd,s=window.ogb?.remoteClient?.active?void 0:window.ogb?.cloudAccount,[u,p]=r.useState(null),[v,N]=r.useState(void 0),[k,I]=r.useState(null),[q,y]=r.useState(null),[E,A]=r.useState(!1),[M,_]=r.useState(!1),[C,i]=r.useState(!1),[w,j]=r.useState(!1),[$,Y]=r.useState(0),[Z,me]=r.useState([]),[b,h]=r.useState(null),[T,O]=r.useState({email:"",code:""}),[B,ee]=r.useState(null),[F,P]=r.useState(null),[H,S]=r.useState(null),[,Ie]=r.useState(0),[xe,le]=r.useState(!1),[Te,ae]=r.useState(!1),[Oe,Fe]=r.useState(!1),L=!!(d&&s),oe=a.config?.profile?.email?.trim()||null,de=ot();r.useEffect(()=>{if(!L||!s)return;let l=!0,c=!1;const g=s.onState(x=>{c=!0,l&&p(x)});return s.state().then(x=>{l&&!c&&p(x)}).catch(()=>{}),()=>{l=!1,g()}},[L,s]);const m=L?We(u,v,{now:t(),error:q,choosing:M,conflict:E,signIn:b,arrived:xe,terms:Te}):null,ye=L&&m&&kt.includes(m.kind)&&u?`${u.status}:${JSON.stringify(u.offer??null)}:${$}`:null;r.useEffect(()=>{if(!ye||!s?.offer)return;let l=!0;return s.offer().then(c=>{l&&N(c)},()=>{l&&N(null)}),()=>{l=!1}},[ye,s]);const re=n("cloudSetup.myCloud"),K={typed:B?.typed??re,color:B?.color??we,name:Ve(B?.typed??re,re)},D=()=>{b&&s?.signInCancel?.().catch(()=>{}),o({type:"closeCloudAdd"}),y(null),A(!1),_(!1),j(!1),me([]),I(null),h(null),O({email:"",code:""}),ee(null),P(null),S(null),le(!1),ae(!1)};r.useEffect(()=>{if(!L)return;const l=document.activeElement,c=l&&l!==document.body&&typeof l.focus=="function"?l:null;d?.signIn&&(h({step:"email",intent:!1,problem:null}),O({email:oe??"",code:""}));const g=x=>{if(x.key==="Escape"){x.preventDefault(),D();return}if(x.key!=="Tab")return;const V=[...document.querySelector("[data-cloud-add-dialog]")?.querySelectorAll(jt)??[]];if(!V.length)return;x.preventDefault();const Ne=V.indexOf(document.activeElement);V[Ne===-1?0:(Ne+(x.shiftKey?-1:1)+V.length)%V.length].focus()};return window.addEventListener("keydown",g,!0),(document.querySelector("#cloud-add-title")??document.querySelector("[data-cloud-add-dialog]"))?.focus(),()=>{window.removeEventListener("keydown",g,!0),c?.isConnected&&c.focus()}},[L]),r.useEffect(()=>{if(!(!L||!s?.sheet||de))return s.sheet(!0).catch(()=>{}),()=>{s.sheet?.(!1).catch(()=>{})}},[L,s,de]);const f=m?.kind??null,te=m?.kind==="sign-in"?`sign-in-${m.phase.step}`:f;r.useEffect(()=>{!te||te==="checking"||te==="settings"||document.activeElement?.closest?.("[data-cloud-add-dialog]")||(document.querySelector("[data-cloud-add-dialog] [data-autofocus]")??document.querySelector("#cloud-add-title"))?.focus()},[te]),r.useEffect(()=>{(f==="waiting"||f==="starting"||f==="ready")&&!xe&&le(!0),(f==="ready"||f==="team-ready")&&s?.readySeen?.().catch(()=>{})},[f]),r.useEffect(()=>{if(!f||!d)return;if(f==="settings"){D(),o({type:"toggleAppSettings",open:!0,section:"cloudAccount"});return}if(f==="checking")return;const l=Z.length===0;l&&J("cloud_dialog_shown",{source:d.source}),["starting","ready"].includes(f)&&Z.includes(f),(l||!Z.includes(f))&&me([...Z,f])},[f]),r.useEffect(()=>{if(!f||!["starting","ready","has-cloud"].includes(f)||B||!s?.look)return;let l=!0;return s.look().then(c=>{l&&ee({typed:c.name,color:Ge(c.color)??we,dirty:f!=="has-cloud"})},()=>{}),()=>{l=!1}},[f]),r.useEffect(()=>{if(!B?.dirty||!s?.setLook)return;const l=setTimeout(()=>{s.setLook?.(K.name,B.color).catch(()=>{})},400);return()=>clearTimeout(l)},[B?.typed,B?.color]),r.useEffect(()=>{f!=="ready"||F!==null||P(!de&&typeof document.hasFocus=="function"&&document.hasFocus()?3:"off")},[f]);const ge=b?.step==="code"?b.resendAt:0;r.useEffect(()=>{if(!ge||ge<=t())return;const l=setTimeout(()=>Ie(t()),1e3);return()=>clearTimeout(l)}),r.useEffect(()=>{if(H!=="copied")return;const l=setTimeout(()=>S(null),2500);return()=>clearTimeout(l)},[H]);const ne=l=>{C||(i(!0),j(!1),l().catch(()=>y("failed")).finally(()=>i(!1)))},he=()=>{C||!s||(i(!0),j(!1),P("done"),(async()=>{B?.dirty&&s.setLook&&await s.setLook(K.name,B.color).catch(()=>{}),await s.connectHome()})().then(()=>D(),()=>j(!0)).finally(()=>i(!1)))},De=l=>{C||!s?.openTeam||(i(!0),j(!1),s.openTeam(l).then(()=>D(),()=>j(!0)).finally(()=>i(!1)))};r.useEffect(()=>{if(typeof F!="number")return;const l=setTimeout(()=>{F>1?P(F-1):he()},1e3);return()=>clearTimeout(l)},[F]);const be=typeof F=="number";if(r.useEffect(()=>{if(!be)return;const l=()=>P("off");return window.addEventListener("blur",l),()=>window.removeEventListener("blur",l)},[be]),!L||!m||!d||!s||m.kind==="settings")return null;if(m.kind==="has-cloud"&&u?.status==="connected"&&u.clouds&&window.ogb?.cloudAdd&&(u.addCloud?.canAdd!==!1||u.adding&&!u.adding.done))return e.jsx(Be,{kind:Oe?"offer":"has-cloud",staging:u.staging===!0,onClose:D,children:e.jsx(at,{onClose:D,onFirstCloud:()=>{},onWide:Fe,source:d.source})});const W=v??null,ke=()=>m.kind==="waiting"&&!k?m.plan:W?Le(W,k).tier:null,ce=async l=>{if(!l||!s.checkout){y("failed");return}W?.plans.find(x=>x.tier===l)?.trialDays;const c=await s.checkout(l,d.source),g=c.outcome;p(c.state),g==="opened"||g==="signing-in"?(_(!1),y(null),A(!1),S(null),ae(!1),J("cloud_checkout_opened",{source:d.source})):g==="rate-limited"?y("rate-limited"):g==="failed"?y("failed"):A(!0)},je=l=>{h({step:"email",intent:l,problem:null}),O({email:T.email||oe||"",code:""})},Se=()=>{if(C||!s.signInStart||!b||b.step==="done")return;const l=b;i(!0),s.signInStart(T.email).then(c=>{c.outcome==="sent"?(h({step:"code",intent:l.intent,email:c.email,resendAt:c.resendAt,problem:null,triesLeft:null,...c.signupOpen===!1?{signupOpen:!1}:{}}),O({email:c.email,code:""}),J("cloud_signin",{source:d.source})):h({...l,problem:c.outcome})},()=>h({...l,problem:"failed"})).finally(()=>i(!1))},_e=l=>{if(!s.signInVerify||b?.step!=="code")return;const c=b,g=c.intent?ke():null;i(!0),(async()=>{try{const x=await s.signInVerify(l);if(x.outcome!=="signed-in"){O({email:T.email,code:""}),h({...c,problem:x.outcome,triesLeft:x.outcome==="wrong-code"?x.triesLeft:null});return}p(x.state),le(!0),J("cloud_signin",{step:"signed_in",source:d.source}),g&&St(x.state)&&(tt(W,x.state.offer,g)?(h({step:"done",intent:!0}),await ce(g)):(ae(!0),I(g))),h(null),O({email:T.email,code:""})}catch{h({...c,problem:"failed",triesLeft:null})}finally{i(!1)}})()},Re={start:l=>{if(I(l),A(!1),m.kind==="offer"&&m.signedOut&&s.signInStart){je(!0);return}ne(()=>ce(l))},signIn:()=>je(!1),back:()=>{h(null),s.signInCancel?.().catch(()=>{})},email:l=>O({email:l,code:T.code}),sendCode:Se,changeEmail:()=>{b&&(h({step:"email",intent:b.intent,problem:null}),s.signInCancel?.().catch(()=>{}))},code:l=>{const c=it(l);O({email:T.email,code:c}),c.length===8&&!C&&_e(c)},resend:Se,browser:()=>ne(async()=>{const l=b?.intent?ke():null;h(null),await s.signInCancel?.().catch(()=>{}),J("cloud_signin",{source:d.source}),l?await ce(l):p(await s.begin())}),reopenBrowser:()=>ne(async()=>p(await s.reopen())),cancelSignIn:()=>ne(async()=>p(await s.cancel())),reopenCheckout:()=>{if(m.kind!=="waiting"||C)return;i(!0),S(null),(s.reopenCheckout?s.reopenCheckout(m.plan,d.source):s.checkout(m.plan,d.source)).then(c=>{p(c.state),c.outcome!=="opened"&&S("pay-failed")},()=>S("pay-failed")).finally(()=>i(!1))},copyLink:()=>{s.copyCheckoutLink?.().then(l=>S(l?"copied":"pay-failed"),()=>S("pay-failed"))},changePlan:()=>{I(m.kind==="waiting"?m.plan:k),_(!0),S(null)},retry:()=>{y(null),A(!1),N(void 0),Y($+1)},name:l=>ee({typed:l,color:K.color,dirty:!0}),color:l=>ee({typed:K.typed,color:l,dirty:!0}),openCloud:he,openTeam:De,notNow:()=>P("off"),interest:()=>{C||!s.interest||(i(!0),s.interest().then(()=>S("interest-sent"),()=>S("interest-failed")).finally(()=>i(!1)))},close:D},Pe={chosen:k,current:Nt(u),offerShown:W,now:t(),busy:C,openFailed:w,email:T.email,code:T.code,profileEmail:oe,look:K,counting:typeof F=="number"?F:null,copied:H==="copied",payFailed:H==="pay-failed",interest:H==="interest-sent"?"sent":H==="interest-failed"?"failed":null};return e.jsx(Be,{kind:m.kind,staging:u?.staging===!0,onClose:D,children:e.jsx(ht,{view:m,ui:Pe,actions:Re})})}export{Lt as CloudAddDialog,ht as CloudAddPanel,Be as CloudAddSheet};
|
|
1
|
+
import{j as e,A as z,B as ve,H as U,t as n,D as se,Q,E as X,F as He,G as pe,I as Ce,J as Ee,K as fe,M as ze,N as Ae,O as Ue,R as qe,T as Me,U as G,a as ue,V as $e,W as Ke,r,Y as We,Z as Ve,$ as we,a0 as Ge,X as Je,a1 as Qe,a2 as Xe,a3 as Ye,a4 as Ze,a5 as et,a6 as Le,a7 as tt}from"./styles-DnwnyZpR.js";import{L as nt,z as st,C as lt,y as J,F as at,G as ot,H as dt,S as rt,I as ct,J as it}from"./PlacesRail-bn7tEIBM.js";import{u as ut}from"./App-CXIAAQw4.js";import"./monitor-DUalxLhV.js";import"./index-CdcrwTp5.js";import"./MenuMotion-Dj4rtEj4.js";function pt({name:t,color:a,busy:o,interest:d,openFailed:s,onInterest:u,onOpen:p}){return e.jsxs("div",{"data-cloud-add":"has-cloud",className:z,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(ve,{color:a,size:32}),e.jsx(U,{title:n("cloudBuy.one.title"),sub:n("cloudBuy.one.sub",{name:t})})]}),e.jsxs("div",{className:se,children:[d!=="sent"&&e.jsx("button",{type:"button",className:Q,disabled:o,onClick:u,children:n("cloudBuy.one.email")}),e.jsx("button",{type:"button",className:X,disabled:o,onClick:p,children:n("cloudBuy.setup.open",{name:t})})]}),e.jsxs("div",{"aria-live":"polite",className:"text-[13px] leading-[18px] empty:-mt-5",children:[d==="sent"&&e.jsx("p",{className:"text-ink-secondary",children:n("cloudBuy.one.thanks")}),d==="failed"&&e.jsx("p",{role:"alert",className:"text-danger",children:n("cloudBuy.one.failed")}),s&&e.jsx("p",{role:"alert",className:"text-danger",children:n("cloudBuy.openFailed",{name:t})})]})]})}function ie({kind:t,line:a,onRetry:o,onClose:d}){return e.jsxs("div",{"data-cloud-add":t,className:z,children:[e.jsx(U,{title:n("cloudAdd.title")}),a?e.jsx("p",{role:"alert",className:"text-[14px] leading-5 text-ink",children:a}):e.jsxs("p",{role:"status",className:"flex items-center gap-2 text-[13px] leading-[18px] text-ink-secondary",children:[e.jsx(nt,{size:14,className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}),n("cloudAdd.checking")]}),e.jsxs("div",{className:se,children:[e.jsx("button",{type:"button",className:Q,onClick:d,children:n("cloudAdd.close")}),o&&e.jsx("button",{type:"button",className:X,onClick:o,children:n("cloudAdd.tryAgain")})]})]})}function ft({plan:t,offer:a,browser:o,late:d,link:s,email:u,busy:p,copied:v,failed:N,onReopen:k,onCopy:I,onChangePlan:q}){const y=a?.plans.find(M=>M.tier===t)??null,E=y?He(y):pe(t),A=y?.trialDays===1?n("cloudBuy.pay.planTrial.one",{plan:E,due:Ce(0)}):y?.trialDays?n("cloudBuy.pay.planTrial.many",{plan:E,days:y.trialDays,due:Ce(0)}):y?n("cloudBuy.pay.planPaid",{plan:E,price:Ee(y.amount/100)}):E;return e.jsxs("div",{"data-cloud-add":d?"waiting-late":o==="signin"?"waiting-signin":"waiting",className:z,children:[e.jsx(U,{title:d?n("cloudBuy.pay.lateTitle"):n("cloudAdd.browserTitle"),sub:d?n("cloudBuy.pay.lateSub"):n(o==="signin"?"cloudBuy.pay.subSignIn":"cloudBuy.pay.sub")}),e.jsx(fe,{items:[{key:"signed-in",state:"done",title:n("cloudBuy.pay.signedIn"),detail:u},{key:"payment",state:"now",title:n("cloudBuy.pay.waiting"),detail:A},{key:"setup",state:"next",title:n("cloudBuy.pay.setup"),detail:n("cloudBuy.pay.setupHint")}]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",className:d?X:Q,disabled:p,onClick:k,children:[e.jsx(st,{size:14,"aria-hidden":"true"}),n("cloudAdd.reopenCheckout")]}),s&&e.jsxs("button",{type:"button",className:Q,disabled:p,onClick:I,children:[e.jsx(lt,{size:14,"aria-hidden":"true"}),n("cloudBuy.pay.copy")]}),e.jsx("button",{type:"button",className:`${ze} ms-1 px-1 py-1`,onClick:q,children:n("cloudAdd.changePlan")})]}),e.jsxs("div",{"aria-live":"polite",className:"text-[13px] leading-[18px] empty:-mt-5",children:[v&&e.jsx("p",{className:"text-ink-secondary",children:n("cloudBuy.pay.copied")}),N&&e.jsx("p",{role:"alert",className:"text-danger",children:n("cloudBuy.pay.failed")})]})]})}const R=[["reserving","cloudHome.step.reserving"],["storage","cloudHome.step.storage"],["starting","cloudBuy.step.starting"],["checking","cloudHome.step.checking"]];function mt({tier:t,trial:a,credit:o},d){if(d)return n("cloudAdd.receivedTitle");const s=pe(t??a?.tier??void 0);return a?o?n("cloudBuy.setup.badgeCredit",{plan:s,credit:Ee(o.grantedUsd)}):n("cloudBuy.setup.badgeTrial",{plan:s}):n("cloudBuy.setup.badgePaid",{plan:s})}function xt({started:t,received:a,step:o,slow:d,ready:s,sleeps:u=!1,name:p,typed:v,color:N,counting:k,busy:I,openFailed:q,onName:y,onColor:E,onOpen:A,onNotNow:M}){const _=s?R.length:Math.max(0,R.findIndex(([i])=>i===o)),C=pe(t.tier??t.trial?.tier??void 0);return e.jsxs("div",{"data-cloud-add":s?"ready":a?"received":"starting","data-cloud-setup":s?"ready":o??"reserving",className:z,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ue,{children:mt(t,a)}),e.jsx(U,{title:s?n("cloudBuy.ready.title",{name:p}):n("cloudBuy.setup.title"),sub:s?n("cloudBuy.ready.sub"):a?n("cloudAccount.purchaseNoteNoDate"):n("cloudBuy.setup.sub")})]}),e.jsxs("div",{className:"grid gap-6 sm:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ae,{value:_/R.length,label:n("cloudBuy.setup.progress")}),e.jsx(fe,{label:n("cloudBuy.setup.progress"),items:R.map(([i,w],j)=>({key:i,title:n(w,{name:p}),state:j<_?"done":j===_?"now":"next"}))}),d&&!s&&e.jsx("p",{role:"status",className:"px-3 text-[13px] leading-[18px] text-ink-secondary",children:n("cloudHome.slow")})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"cloud-add-name",className:"text-[13px] leading-[18px] text-ink-secondary",children:n("cloudBuy.setup.name")}),e.jsx("input",{id:"cloud-add-name",value:v,maxLength:Me,placeholder:n("cloudSetup.myCloud"),autoComplete:"off",spellCheck:!1,onChange:i=>y(i.target.value),className:qe})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{id:"cloud-add-color",className:"text-[13px] leading-[18px] text-ink-secondary",children:n("cloudBuy.setup.color")}),e.jsx("div",{role:"radiogroup","aria-labelledby":"cloud-add-color",className:"flex flex-wrap gap-2",children:G.map(i=>e.jsx("button",{type:"button",role:"radio","aria-checked":i===N,"aria-label":n(Ke[i]),tabIndex:i===N?0:-1,"data-color":i,onClick:()=>E(i),onKeyDown:w=>{const j=G.indexOf(i),$=w.key==="ArrowRight"||w.key==="ArrowDown"?1:w.key==="ArrowLeft"||w.key==="ArrowUp"?-1:0;if(!$)return;w.preventDefault();const Y=G[(j+$+G.length)%G.length];E(Y),w.currentTarget.parentElement?.querySelector(`[data-color="${Y}"]`)?.focus()},style:{background:$e(i)},className:ue("size-[26px] rounded-lg border-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",i===N?"border-ink shadow-[inset_0_0_0_2px_var(--color-app)]":"border-transparent")},i))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:"text-[13px] leading-[18px] text-ink-secondary",children:n("cloudBuy.setup.preview")}),e.jsxs("span",{"data-cloud-preview":!0,className:"inline-flex max-w-full items-center gap-2 self-start rounded-[12px] border-[0.5px] border-ink/10 bg-menu py-1.5 pe-3 ps-1.5",children:[e.jsx(ve,{color:N}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-[13px] font-medium leading-4 text-ink",children:p}),e.jsx("span",{className:"block truncate text-[12px] text-ink-tertiary",children:n(u?"cloudBuy.setup.previewLineSleeps":"cloudBuy.setup.previewLine",{plan:C})})]})]})]})]})]}),s&&k===null&&e.jsx("p",{className:"text-[13px] leading-[18px] text-ink-tertiary",children:n("cloudBuy.ready.hint",{name:p})}),e.jsxs("div",{className:se,children:[k!==null&&e.jsx("span",{role:"status",className:"me-1 text-[13px] text-ink-secondary",children:n("cloudBuy.setup.openingIn",{seconds:k})}),k!==null&&e.jsx("button",{type:"button",className:Q,onClick:M,children:n("notice.notNow")}),e.jsx("button",{type:"button",className:X,disabled:!s||I,onClick:A,children:n("cloudBuy.setup.open",{name:p})})]}),q&&e.jsx("p",{role:"alert",className:"-mt-2 text-end text-[13px] leading-[18px] text-danger",children:n("cloudBuy.openFailed",{name:p})})]})}function yt({team:t,step:a,slow:o}){const d=Math.max(0,R.findIndex(([u])=>u===a)),s=t??n("cloudBuy.team.unnamed");return e.jsxs("div",{"data-cloud-add":"team-starting","data-cloud-setup":a??"reserving",className:z,children:[e.jsx(U,{title:n("cloudBuy.team.setupTitle"),sub:n("cloudBuy.team.setupSub")}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ae,{value:d/R.length,label:n("cloudBuy.setup.progress")}),e.jsx(fe,{label:n("cloudBuy.setup.progress"),items:R.map(([u,p],v)=>({key:u,title:n(p,{name:s}),state:v<d?"done":v===d?"now":"next"}))}),o&&e.jsx("p",{role:"status",className:"px-3 text-[13px] leading-[18px] text-ink-secondary",children:n("cloudHome.slow")})]})]})}function gt({name:t,busy:a,openFailed:o,onOpen:d}){return e.jsxs("div",{"data-cloud-add":"team-ready",className:z,children:[e.jsx(U,{title:n("cloudBuy.team.readyTitle"),sub:n("cloudBuy.team.readySub",{name:t})}),e.jsx("p",{className:"text-[13px] leading-[18px] text-ink-tertiary",children:n("cloudBuy.ready.hint",{name:t})}),e.jsx("div",{className:se,children:e.jsx("button",{type:"button","data-autofocus":!0,className:X,disabled:a,onClick:d,children:n("cloudBuy.setup.open",{name:t})})}),o&&e.jsx("p",{role:"alert",className:"-mt-2 text-end text-[13px] leading-[18px] text-danger",children:n("cloudBuy.openFailed",{name:t})})]})}function ht({view:t,ui:a,actions:o}){switch(t.kind){case"checking":return e.jsx(ie,{kind:"checking",line:null,onClose:o.close});case"unreachable":return e.jsx(ie,{kind:"unreachable",line:n("cloudAdd.unreachable"),onRetry:o.retry,onClose:o.close});case"error":return e.jsx(ie,{kind:`error-${t.reason}`,line:n(t.reason==="rate-limited"?"cloudAdd.rateLimited":"cloudAdd.failed"),onRetry:o.retry,onClose:o.close});case"offer":return e.jsx(ct,{offer:t.offer,current:a.current,now:a.now,busy:a.busy,signedOut:t.signedOut,notice:t.notice?n(t.notice==="code-expired"?"cloudAdd.codeExpired":t.notice==="signin-ended"?"cloudAdd.signInEnded":t.notice==="terms"?"cloudBuy.termsChanged":"cloudAdd.preparing"):null,onStart:o.start,onSignIn:o.signIn});case"sign-in":return e.jsx(rt,{phase:t.phase,email:a.email,code:a.code,profileEmail:a.profileEmail,busy:a.busy,now:a.now,onBack:o.back,onEmail:o.email,onSend:o.sendCode,onChangeEmail:o.changeEmail,onCode:o.code,onResend:o.resend,onBrowser:o.browser});case"signing-in":return e.jsx(dt,{code:t.code,checkout:t.checkout,busy:a.busy,trial:a.offerShown?!!Le(a.offerShown,a.chosen).trialDays:!1,onReopen:o.reopenBrowser,onCancel:o.cancelSignIn});case"waiting":return e.jsx(ft,{plan:t.plan,offer:a.offerShown,browser:t.browser,late:t.late,link:t.link,email:t.email,busy:a.busy,copied:a.copied,failed:a.payFailed,onReopen:o.reopenCheckout,onCopy:o.copyLink,onChangePlan:o.changePlan});case"starting":case"ready":return e.jsx(xt,{started:t,received:t.kind==="starting"&&t.received,step:t.kind==="starting"?t.step:null,slow:t.kind==="starting"&&t.slow,ready:t.kind==="ready",sleeps:et(t,a.offerShown),name:a.look.name,typed:a.look.typed,color:a.look.color,counting:a.counting,busy:a.busy,openFailed:a.openFailed,onName:o.name,onColor:o.color,onOpen:o.openCloud,onNotNow:o.notNow});case"has-cloud":return e.jsx(pt,{name:a.look.name,color:a.look.color,busy:a.busy,interest:a.interest,openFailed:a.openFailed,onInterest:o.interest,onOpen:o.openCloud});case"team-starting":return e.jsx(yt,{team:t.team,step:t.step,slow:t.slow});case"team-ready":return e.jsx(gt,{name:t.team.name,busy:a.busy,openFailed:a.openFailed,onOpen:()=>o.openTeam(t.team.id)});case"settings":return null}}const bt={offer:"max-w-[920px]",starting:"max-w-[720px]",ready:"max-w-[720px]"};function Be({kind:t,staging:a,onClose:o,children:d}){return e.jsx("div",{className:"ui-scrim fixed inset-0 z-[60] flex items-center justify-center p-4 sm:p-6",onMouseDown:s=>s.stopPropagation(),children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"cloud-add-title","data-cloud-add-dialog":!0,tabIndex:-1,className:ue(Ze,"group/sheet animate-pop-in relative max-h-full w-full overflow-y-auto overscroll-contain outline-none",bt[t]??"max-w-[540px]"),children:[e.jsx("button",{type:"button",onClick:o,"aria-label":n("cloudAdd.close"),className:ue(Xe,Qe,"absolute end-4 top-4 z-10"),children:e.jsx(Je,{size:16})}),a&&e.jsx(Ye,{className:"absolute end-14 top-[22px] z-10 group-has-[[data-night-card]]/sheet:bg-app"}),d]})})}const kt=["offer","checking","unreachable","waiting","sign-in","signing-in"],jt="button:not([disabled]):not([tabindex='-1']), input:not([disabled]):not([tabindex='-1']), [href], [tabindex='0']",St=t=>t.status==="connected"&&t.entitlement?.plan==="free"&&!t.purchase&&!t.machine,Nt=t=>t?.status==="connected"&&t.entitlement?.plan==="pro"&&t.entitlement.status==="active"?t.entitlement.tier??"pro":null;function Lt({now:t=Date.now}){const{state:a,dispatch:o}=ut(),d=a.cloudAdd,s=window.ogb?.remoteClient?.active?void 0:window.ogb?.cloudAccount,[u,p]=r.useState(null),[v,N]=r.useState(void 0),[k,I]=r.useState(null),[q,y]=r.useState(null),[E,A]=r.useState(!1),[M,_]=r.useState(!1),[C,i]=r.useState(!1),[w,j]=r.useState(!1),[$,Y]=r.useState(0),[Z,me]=r.useState([]),[b,h]=r.useState(null),[T,O]=r.useState({email:"",code:""}),[B,ee]=r.useState(null),[F,P]=r.useState(null),[H,S]=r.useState(null),[,Ie]=r.useState(0),[xe,le]=r.useState(!1),[Te,ae]=r.useState(!1),[Oe,Fe]=r.useState(!1),L=!!(d&&s),oe=a.config?.profile?.email?.trim()||null,de=ot();r.useEffect(()=>{if(!L||!s)return;let l=!0,c=!1;const g=s.onState(x=>{c=!0,l&&p(x)});return s.state().then(x=>{l&&!c&&p(x)}).catch(()=>{}),()=>{l=!1,g()}},[L,s]);const m=L?We(u,v,{now:t(),error:q,choosing:M,conflict:E,signIn:b,arrived:xe,terms:Te}):null,ye=L&&m&&kt.includes(m.kind)&&u?`${u.status}:${JSON.stringify(u.offer??null)}:${$}`:null;r.useEffect(()=>{if(!ye||!s?.offer)return;let l=!0;return s.offer().then(c=>{l&&N(c)},()=>{l&&N(null)}),()=>{l=!1}},[ye,s]);const re=n("cloudSetup.myCloud"),K={typed:B?.typed??re,color:B?.color??we,name:Ve(B?.typed??re,re)},D=()=>{b&&s?.signInCancel?.().catch(()=>{}),o({type:"closeCloudAdd"}),y(null),A(!1),_(!1),j(!1),me([]),I(null),h(null),O({email:"",code:""}),ee(null),P(null),S(null),le(!1),ae(!1)};r.useEffect(()=>{if(!L)return;const l=document.activeElement,c=l&&l!==document.body&&typeof l.focus=="function"?l:null;d?.signIn&&(h({step:"email",intent:!1,problem:null}),O({email:oe??"",code:""}));const g=x=>{if(x.key==="Escape"){x.preventDefault(),D();return}if(x.key!=="Tab")return;const V=[...document.querySelector("[data-cloud-add-dialog]")?.querySelectorAll(jt)??[]];if(!V.length)return;x.preventDefault();const Ne=V.indexOf(document.activeElement);V[Ne===-1?0:(Ne+(x.shiftKey?-1:1)+V.length)%V.length].focus()};return window.addEventListener("keydown",g,!0),(document.querySelector("#cloud-add-title")??document.querySelector("[data-cloud-add-dialog]"))?.focus(),()=>{window.removeEventListener("keydown",g,!0),c?.isConnected&&c.focus()}},[L]),r.useEffect(()=>{if(!(!L||!s?.sheet||de))return s.sheet(!0).catch(()=>{}),()=>{s.sheet?.(!1).catch(()=>{})}},[L,s,de]);const f=m?.kind??null,te=m?.kind==="sign-in"?`sign-in-${m.phase.step}`:f;r.useEffect(()=>{!te||te==="checking"||te==="settings"||document.activeElement?.closest?.("[data-cloud-add-dialog]")||(document.querySelector("[data-cloud-add-dialog] [data-autofocus]")??document.querySelector("#cloud-add-title"))?.focus()},[te]),r.useEffect(()=>{(f==="waiting"||f==="starting"||f==="ready")&&!xe&&le(!0),(f==="ready"||f==="team-ready")&&s?.readySeen?.().catch(()=>{})},[f]),r.useEffect(()=>{if(!f||!d)return;if(f==="settings"){D(),o({type:"toggleAppSettings",open:!0,section:"cloudAccount"});return}if(f==="checking")return;const l=Z.length===0;l&&J("cloud_dialog_shown",{source:d.source}),["starting","ready"].includes(f)&&Z.includes(f),(l||!Z.includes(f))&&me([...Z,f])},[f]),r.useEffect(()=>{if(!f||!["starting","ready","has-cloud"].includes(f)||B||!s?.look)return;let l=!0;return s.look().then(c=>{l&&ee({typed:c.name,color:Ge(c.color)??we,dirty:f!=="has-cloud"})},()=>{}),()=>{l=!1}},[f]),r.useEffect(()=>{if(!B?.dirty||!s?.setLook)return;const l=setTimeout(()=>{s.setLook?.(K.name,B.color).catch(()=>{})},400);return()=>clearTimeout(l)},[B?.typed,B?.color]),r.useEffect(()=>{f!=="ready"||F!==null||P(!de&&typeof document.hasFocus=="function"&&document.hasFocus()?3:"off")},[f]);const ge=b?.step==="code"?b.resendAt:0;r.useEffect(()=>{if(!ge||ge<=t())return;const l=setTimeout(()=>Ie(t()),1e3);return()=>clearTimeout(l)}),r.useEffect(()=>{if(H!=="copied")return;const l=setTimeout(()=>S(null),2500);return()=>clearTimeout(l)},[H]);const ne=l=>{C||(i(!0),j(!1),l().catch(()=>y("failed")).finally(()=>i(!1)))},he=()=>{C||!s||(i(!0),j(!1),P("done"),(async()=>{B?.dirty&&s.setLook&&await s.setLook(K.name,B.color).catch(()=>{}),await s.connectHome()})().then(()=>D(),()=>j(!0)).finally(()=>i(!1)))},De=l=>{C||!s?.openTeam||(i(!0),j(!1),s.openTeam(l).then(()=>D(),()=>j(!0)).finally(()=>i(!1)))};r.useEffect(()=>{if(typeof F!="number")return;const l=setTimeout(()=>{F>1?P(F-1):he()},1e3);return()=>clearTimeout(l)},[F]);const be=typeof F=="number";if(r.useEffect(()=>{if(!be)return;const l=()=>P("off");return window.addEventListener("blur",l),()=>window.removeEventListener("blur",l)},[be]),!L||!m||!d||!s||m.kind==="settings")return null;if(m.kind==="has-cloud"&&u?.status==="connected"&&u.clouds&&window.ogb?.cloudAdd&&(u.addCloud?.canAdd!==!1||u.adding&&!u.adding.done))return e.jsx(Be,{kind:Oe?"offer":"has-cloud",staging:u.staging===!0,onClose:D,children:e.jsx(at,{onClose:D,onFirstCloud:()=>{},onWide:Fe,source:d.source})});const W=v??null,ke=()=>m.kind==="waiting"&&!k?m.plan:W?Le(W,k).tier:null,ce=async l=>{if(!l||!s.checkout){y("failed");return}W?.plans.find(x=>x.tier===l)?.trialDays;const c=await s.checkout(l,d.source),g=c.outcome;p(c.state),g==="opened"||g==="signing-in"?(_(!1),y(null),A(!1),S(null),ae(!1),J("cloud_checkout_opened",{source:d.source})):g==="rate-limited"?y("rate-limited"):g==="failed"?y("failed"):A(!0)},je=l=>{h({step:"email",intent:l,problem:null}),O({email:T.email||oe||"",code:""})},Se=()=>{if(C||!s.signInStart||!b||b.step==="done")return;const l=b;i(!0),s.signInStart(T.email).then(c=>{c.outcome==="sent"?(h({step:"code",intent:l.intent,email:c.email,resendAt:c.resendAt,problem:null,triesLeft:null,...c.signupOpen===!1?{signupOpen:!1}:{}}),O({email:c.email,code:""}),J("cloud_signin",{source:d.source})):h({...l,problem:c.outcome})},()=>h({...l,problem:"failed"})).finally(()=>i(!1))},_e=l=>{if(!s.signInVerify||b?.step!=="code")return;const c=b,g=c.intent?ke():null;i(!0),(async()=>{try{const x=await s.signInVerify(l);if(x.outcome!=="signed-in"){O({email:T.email,code:""}),h({...c,problem:x.outcome,triesLeft:x.outcome==="wrong-code"?x.triesLeft:null});return}p(x.state),le(!0),J("cloud_signin",{step:"signed_in",source:d.source}),g&&St(x.state)&&(tt(W,x.state.offer,g)?(h({step:"done",intent:!0}),await ce(g)):(ae(!0),I(g))),h(null),O({email:T.email,code:""})}catch{h({...c,problem:"failed",triesLeft:null})}finally{i(!1)}})()},Re={start:l=>{if(I(l),A(!1),m.kind==="offer"&&m.signedOut&&s.signInStart){je(!0);return}ne(()=>ce(l))},signIn:()=>je(!1),back:()=>{h(null),s.signInCancel?.().catch(()=>{})},email:l=>O({email:l,code:T.code}),sendCode:Se,changeEmail:()=>{b&&(h({step:"email",intent:b.intent,problem:null}),s.signInCancel?.().catch(()=>{}))},code:l=>{const c=it(l);O({email:T.email,code:c}),c.length===8&&!C&&_e(c)},resend:Se,browser:()=>ne(async()=>{const l=b?.intent?ke():null;h(null),await s.signInCancel?.().catch(()=>{}),J("cloud_signin",{source:d.source}),l?await ce(l):p(await s.begin())}),reopenBrowser:()=>ne(async()=>p(await s.reopen())),cancelSignIn:()=>ne(async()=>p(await s.cancel())),reopenCheckout:()=>{if(m.kind!=="waiting"||C)return;i(!0),S(null),(s.reopenCheckout?s.reopenCheckout(m.plan,d.source):s.checkout(m.plan,d.source)).then(c=>{p(c.state),c.outcome!=="opened"&&S("pay-failed")},()=>S("pay-failed")).finally(()=>i(!1))},copyLink:()=>{s.copyCheckoutLink?.().then(l=>S(l?"copied":"pay-failed"),()=>S("pay-failed"))},changePlan:()=>{I(m.kind==="waiting"?m.plan:k),_(!0),S(null)},retry:()=>{y(null),A(!1),N(void 0),Y($+1)},name:l=>ee({typed:l,color:K.color,dirty:!0}),color:l=>ee({typed:K.typed,color:l,dirty:!0}),openCloud:he,openTeam:De,notNow:()=>P("off"),interest:()=>{C||!s.interest||(i(!0),s.interest().then(()=>S("interest-sent"),()=>S("interest-failed")).finally(()=>i(!1)))},close:D},Pe={chosen:k,current:Nt(u),offerShown:W,now:t(),busy:C,openFailed:w,email:T.email,code:T.code,profileEmail:oe,look:K,counting:typeof F=="number"?F:null,copied:H==="copied",payFailed:H==="pay-failed",interest:H==="interest-sent"?"sent":H==="interest-failed"?"failed":null};return e.jsx(Be,{kind:m.kind,staging:u?.staging===!0,onClose:D,children:e.jsx(ht,{view:m,ui:Pe,actions:Re})})}export{Lt as CloudAddDialog,ht as CloudAddPanel,Be as CloudAddSheet};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,t as a,a as N,r as R}from"./styles-
|
|
1
|
+
import{j as e,t as a,a as N,r as R}from"./styles-DnwnyZpR.js";import{a6 as F,a7 as S,x as L,S as z,a8 as y,a9 as b,aa as A,ab as M,ac as w,ad as k,ae as P,af as E,ag as $,u as I,w as B,F as O,ah as v,ai as T,aj as D,ak as C,al as H,am as W,an as X}from"./App-CXIAAQw4.js";import{a as _,R as q}from"./RoutinesPage-0ilXXAQg.js";import{L as G,P as J,d as K}from"./PlacesRail-bn7tEIBM.js";import{C as Q}from"./MenuMotion-Dj4rtEj4.js";function U({routines:t,runs:r,bots:p,pausedBots:c,loading:o,error:d,onOpen:l,onLogs:n,onToggle:x}){const u=[...t].sort((s,i)=>Number(i.enabled)-Number(s.enabled)||(s.nextRunAt??1/0)-(i.nextRunAt??1/0)||s.name.localeCompare(i.name));return e.jsxs("div",{className:"space-y-3","aria-label":a("routines.list"),children:[d&&e.jsx("div",{role:"alert",className:"rounded-lg bg-danger/10 p-3 text-[12px] text-danger",children:a("routines.loadError")}),o&&e.jsxs("p",{role:"status",className:"flex items-center gap-2 p-3 text-[12px] text-ink-secondary",children:[e.jsx(G,{size:14,className:"animate-spin"}),a("routines.loading")]}),!o&&!d&&u.length===0&&e.jsxs("div",{className:"rounded-xl border border-dashed border-hairline/50 p-5 text-center text-[13px] text-ink-secondary",children:[e.jsx(_,{size:20,className:"mx-auto mb-2 opacity-60"}),a("routines.empty")]}),u.map(s=>{const i=F(s.id,r),m=i&&(i.attention?"attention":i.error?"error":i.output?"output":null),h=p?.find(g=>g.id===s.botId),f=x!==void 0&&!S(s);return e.jsxs("article",{className:"rounded-xl border border-hairline/40 bg-card p-3.5","aria-label":s.name,children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>l(s),className:"min-w-0 flex-1 text-left hover:text-accent",children:[e.jsx("span",{className:"block truncate text-[13px] font-semibold text-ink",children:s.name}),e.jsxs("span",{className:"mt-1 block text-[12px] leading-relaxed text-ink-secondary",children:[h&&`${h.name} · `,L(s.schedule)]})]}),f?e.jsx(z,{checked:s.enabled,"aria-label":a("routines.toggle",{name:s.name}),onClick:()=>x(s)}):e.jsx("span",{className:N("shrink-0 rounded-full bg-inset px-2 py-0.5 text-[10px]",s.enabled&&s.nextRunAt!=null?"text-accent":"text-ink-secondary"),children:y(s)})]}),(f||b(s)!==y(s))&&e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:b(s)}),e.jsxs("div",{className:"mt-1 flex items-start justify-between gap-2",children:[e.jsx("div",{className:"min-w-0 text-[12px]",children:i?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:M(i),children:a("routines.latestRun",{status:A(i)})}),e.jsx("span",{className:"block text-[11px] text-ink-secondary",children:w(i.finishedAt??i.startedAt??i.scheduledFor)})]}):e.jsx("span",{className:"text-ink-secondary",children:a("routines.neverRun")})}),e.jsxs("button",{type:"button",onClick:()=>n(s),"aria-label":a("routines.logsFor",{name:s.name}),className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[11px] text-ink-secondary hover:bg-raised hover:text-ink",children:[e.jsx(k,{size:12}),a("routines.logs")]})]}),i&&m&&e.jsx("p",{className:N("mt-2 line-clamp-2 whitespace-pre-wrap text-[12px] leading-relaxed",i.error?"text-danger":"text-ink-secondary"),children:P(i,m)}),!!s.failureStreak&&e.jsx("p",{className:"mt-2 text-[12px] text-danger",children:a("routines.failureStreak",{count:s.failureStreak})}),s.weekRuns&&e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:a(s.weekRuns.total===1?"routines.weekRunsOne":"routines.weekRuns",s.weekRuns)}),s.warning&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-warning",children:s.warning}),s.enabled&&c?.includes(s.botId)&&e.jsxs("p",{className:"mt-2 text-[12px] leading-relaxed text-warning","data-routine-bot-paused":"",children:[a("routines.botPaused")," ",e.jsx("button",{type:"button",className:"cursor-pointer text-accent hover:underline",onClick:()=>E("paused"),children:a("routines.botPausedSwap")})]}),s.heldFor&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:$(s)}),!!s.skippedRuns&&e.jsxs("p",{className:"mt-2 text-[12px] text-ink-secondary",children:[a("routines.skippedRuns",{count:s.skippedRuns}),s.lastSkippedAt!=null&&e.jsxs(e.Fragment,{children:[" · ",a("routines.lastSkipped",{date:w(s.lastSkippedAt)})]})]})]},s.id)})]})}function le({bot:t,routines:r,runs:p,defaultRunOn:c}){const{state:o,dispatch:d}=I(),[l,n]=R.useState(null);return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{size:16,className:"text-accent"}),e.jsx("h2",{className:"min-w-0 flex-1 text-[15px] font-medium text-ink",children:a("computer.tab.routines")}),e.jsx("span",{className:"text-[12px] text-ink-secondary",children:r.length})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>n("new"),className:"flex flex-1 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[12px] font-medium text-white hover:brightness-110",children:[e.jsx(J,{size:14}),a("computer.routines.create")]}),e.jsxs("button",{type:"button",onClick:()=>d({type:"showRoutines",section:"logs",botId:t.id}),className:"flex items-center gap-1.5 rounded-lg bg-control px-3 py-2 text-[12px] text-ink hover:bg-raised-hover",children:[e.jsx(k,{size:13}),a("routines.logs")]})]})]}),e.jsx(U,{routines:r,runs:p,pausedBots:o.config?.pausedBots,loading:o.routinesLoadState==="loading"&&r.length===0,error:o.routinesLoadState==="error",onOpen:n,onLogs:x=>d({type:"showRoutines",section:"logs",botId:t.id,routineId:x.id}),onToggle:x=>d({type:"updateRoutine",routineId:x.id,patch:{enabled:!x.enabled}})}),e.jsxs("button",{type:"button",onClick:()=>d({type:"showRoutines",section:"schedule",view:"list",botId:t.id}),className:"self-start text-[12px] text-accent hover:underline",children:[a("computer.routines.openTitle")," ",e.jsx(Q,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]}),l&&e.jsx(q,{routine:l==="new"?void 0:l,bots:[t],lockedBotId:t.id,defaultRunOn:c,onClose:()=>n(null)},t.id)]})}const V=20;function Y(t,r=V){const p=new Set,c=[],o=C(t);for(let d=o.length-1;d>=0&&c.length<r;d-=1){const l=o[d].digest?.files;if(l){for(const n of l.deleted)p.add(n);for(const n of[...l.added,...l.changed])if(!p.has(n)&&(p.add(n),c.push(n),c.length>=r))break}}return c}function Z(t){const r=new Map,p=t.tasks?.find(n=>n.threadId===t.threadId),c=p?.cwd===void 0?t.cwd:p.cwd,o=c&&(/^[a-z]:[\\/]/i.test(c)||c.startsWith("\\\\")),d=n=>o?n.replace(/\\/g,"/"):n,l=typeof c=="string"?`${d(c).replace(/\/+$/,"")}/`:void 0;for(const n of[...C(t)].reverse()){if(n.role!=="bot"||n.kind!=="text")continue;const x=H(n.attachments),u=[...x.files,...W(n.text??"",[...x.images,...x.files.map(s=>s.path)])];for(const s of u){const i=s.private?s.path:X(s.path),m={file:s,message:{threadId:t.threadId,messageId:n.id}},h=d(i),f=l&&(o?h.slice(0,l.length).toLowerCase()===l.toLowerCase():h.startsWith(l)),g=[i,...f?[h.slice(l.length)]:[]];i.startsWith("./")&&g.push(i.replace(/^(\.\/)+/,""));for(const j of g)r.has(j)||r.set(j,m)}}return r}function ee(t){const r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return r<0?{name:t,folder:""}:{name:t.slice(r+1),folder:t.slice(0,r)}}function re({bot:t}){const{dispatch:r}=I(),{capabilities:p}=K(),c=p.host.homeDir,d=t.tasks?.find(u=>u.threadId===t.threadId)?.cwd,l=d===void 0?t.cwd:d,n=Y(t),x=R.useMemo(()=>Z(t),[t.messages,t.activeLeafId,t.threadId,t.tasks,t.cwd]);return e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pb-5","data-testid":"computer-files",children:[e.jsxs("div",{className:"mt-2 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:a("computer.files.folder")}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(O,{size:15,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink",title:l??void 0,children:l?v(l,c):l===null?a("computer.files.homeFolder"):a("computer.files.privateFolder",{name:t.name})}),e.jsx("button",{type:"button",onClick:()=>{r({type:"toggleComputer",open:!1}),T(r,"access",{page:"folder"})},className:"shrink-0 rounded-lg bg-control px-2.5 py-1 text-[12px] text-ink hover:bg-raised-hover",children:a(d===void 0?"computer.files.changeFolder":"computer.files.changeDefaultFolder")})]}),d!==void 0&&e.jsx("p",{className:"mt-2 text-[12px] leading-5 text-ink-secondary",children:a("computer.files.pinnedFolderHint")})]}),e.jsxs("div",{className:"mt-3 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:a("computer.files.recent")}),n.length===0?e.jsx("p",{className:"mt-2 text-[12px] leading-5 text-ink-secondary",children:a("computer.files.empty",{name:t.name})}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:n.map(u=>{const{name:s,folder:i}=ee(u),m=x.get(u);return e.jsxs("li",{className:"min-w-0 rounded-lg py-1",title:u,children:[m?e.jsx(D,{file:{...m.file,name:s},message:m.message,linked:m.file.linked,className:"w-full max-w-none"},`${m.message.threadId}:${m.message.messageId}:${m.file.path}`):e.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",title:a("computer.files.notSharedHint"),children:[e.jsx(k,{size:14,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-ink",children:s}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:a("computer.files.notShared")})]}),i&&e.jsx("div",{className:"mt-1 truncate px-2.5 text-[11px] text-ink-tertiary",children:v(i,c)})]},u)})})]})]})}export{re as C,le as R,U as a,Y as r,Z as s};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DataPanel-B42JmnxF.js","assets/styles-DnwnyZpR.js","assets/styles-BxpHDI63.css","assets/App-CXIAAQw4.js","assets/PlacesRail-bn7tEIBM.js","assets/monitor-DUalxLhV.js","assets/index-CdcrwTp5.js","assets/MenuMotion-Dj4rtEj4.js","assets/calendar-days-DU-aFzFs.js","assets/LiveDesktop-B6kJJHn8.js","assets/desktop-connection-Dfaq6k5a.js","assets/desktop-viewer-CF-OpSo0.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as ht,r as a,t as n,j as e,a as K,ac as hr,X as gr,ad as vr,_ as Pn}from"./styles-DnwnyZpR.js";import{c as yr,a as wr,b as kr,i as jr,d as Nr}from"./remote-desktop-DDRRx8uY.js";import{v as Sr}from"./desktop-viewer-CF-OpSo0.js";import{dG as Je,S as zn,K as Cr,D as Ir,bH as Er,bt as Rr,W as pt,Y as Pr,Z as Ye,dH as zr,a0 as Ge,bs as Tr,F as Ar,dI as Dr,G as Ft,w as Tn,dJ as $t,dK as dt,u as Lr,dL as Mr,dM as Or,dN as Vr,dO as _r,a4 as Fr,dP as $r,dQ as Br,dR as Wr,dS as Kr,dT as Ur,o as Hr,bM as qr,bL as yn,n as F,dU as Xr,dV as Yr,l as Gr,$ as Jr,bO as wn,dW as Zr,dX as Qr,a5 as es,dY as kn,dZ as ts,d_ as ns,d$ as rs,p as jn,bB as ss,e0 as as,e1 as Vt,aa as os,ab as is,cp as ls,e2 as cs,e3 as ds,a1 as us,A as ps,e4 as ms,e5 as xs,e6 as bs,e7 as fs,q as hs,e8 as gs,e9 as vs,ea as ys}from"./App-CXIAAQw4.js";import{L as O,p as Nn,M as ws,w as ks}from"./MacLocalControl-D7ByxpUV.js";import{R as js,C as Ns}from"./ComputerFilesPane-y6L4ZrAL.js";import{L as A,Y as An,u as Dn,d as Ze,c as Ss,z as Sn,g as mt,X as Cn,o as Cs,e as In,f as Is,s as Es}from"./PlacesRail-bn7tEIBM.js";import{u as Bt,B as Rs}from"./BrowserPanel-BvycPh9Q.js";import{M as De}from"./monitor-DUalxLhV.js";import{C as Ln,w as Ps,a as zs,p as Ts,W as As}from"./WorksOnGrid-B5p2GXxB.js";import{C as Ds}from"./MenuMotion-Dj4rtEj4.js";import"./index-CdcrwTp5.js";import"./RoutinesPage-0ilXXAQg.js";import"./ProIntroduction--tZnt9fj.js";import"./BrowserProfilesManager-C-DSmpiF.js";import"./SignedInSites-BlnZihVe.js";import"./minimize-CQhJEKJt.js";import"./file-up-DA-MGVqh.js";const Ls=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Ms=ht("columns-2",Ls);const Os=[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m14.305 7.53.923-.382",key:"1mlnsw"}],["path",{d:"m15.228 4.852-.923-.383",key:"82mpwg"}],["path",{d:"m16.852 3.228-.383-.924",key:"ln4sir"}],["path",{d:"m16.852 8.772-.383.923",key:"1dejw0"}],["path",{d:"m19.148 3.228.383-.924",key:"192kgf"}],["path",{d:"m19.53 9.696-.382-.924",key:"fiavlr"}],["path",{d:"m20.772 4.852.924-.383",key:"1j8mgp"}],["path",{d:"m20.772 7.148.924.383",key:"zix9be"}],["path",{d:"M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"1tnzv8"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]],Vs=ht("monitor-cog",Os);const _s=[["path",{d:"m14.5 12.5-5-5",key:"1jahn5"}],["path",{d:"m9.5 12.5 5-5",key:"1k2t7b"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]],Fs=ht("monitor-x",_s);const $s=[["circle",{cx:"10",cy:"7",r:"1",key:"dypaad"}],["circle",{cx:"4",cy:"20",r:"1",key:"22iqad"}],["path",{d:"M4.7 19.3 19 5",key:"1enqfc"}],["path",{d:"m21 3-3 1 2 2Z",key:"d3ov82"}],["path",{d:"M9.26 7.68 5 12l2 5",key:"1esawj"}],["path",{d:"m10 14 5 2 3.5-3.5",key:"v8oal5"}],["path",{d:"m18 12 1-1 1 1-1 1Z",key:"1bh22v"}]],Bs=ht("usb",$s);function Ws({src:s,name:i,error:d,starting:S,opening:f,disabled:v,refreshing:k=!1,retry:j=0,onOpen:y,onRetry:P}){const[u,m]=a.useState(null),[h,g]=a.useState(null);a.useEffect(()=>{g(null)},[j]);const x=!!(s&&u===s&&h!==s),w=d??(s&&h===s?n("computer.preview.imageFailed"):null);return e.jsxs("div",{className:"relative h-full w-full","aria-busy":!w&&(!x||f||k),children:[s&&e.jsxs("button",{type:"button",onClick:y,disabled:v||S||f||!x,className:"group absolute inset-0 flex h-full w-full items-center justify-center disabled:cursor-wait","aria-label":n("computer.openLiveDesktopAria",{name:i}),title:n("computer.openLiveDesktop"),children:[e.jsx("img",{src:s,alt:n("computer.screenOf",{name:i}),onLoad:()=>{m(s),g(null)},onError:()=>g(s),className:`h-full w-full object-contain transition group-hover:brightness-75 ${x?"":"invisible"}`},j),x&&e.jsxs("span",{className:"absolute right-2 top-2 flex items-center gap-1 rounded-md bg-black/70 px-2 py-1 text-[11px] font-medium text-white",children:[f?e.jsx(A,{size:12,className:"animate-spin"}):e.jsx(Je,{size:12}),f?n("computer.preview.connecting"):n("computer.open")]})]}),!x&&!w&&e.jsxs("div",{role:"status",className:"absolute inset-0 flex flex-col items-center justify-center gap-2 px-6 text-center text-[12px] text-ink-secondary",children:[e.jsx(A,{size:18,className:"animate-spin"}),S?n("computer.phase.starting"):n("computer.preview.connectingScreen")]}),x&&k&&!w&&e.jsxs("div",{role:"status",className:"absolute bottom-2 left-2 flex items-center gap-1 rounded-md bg-black/70 px-2 py-1 text-[11px] text-white",children:[e.jsx(A,{size:12,className:"animate-spin"}),n("computer.preview.connectingScreen")]}),w&&e.jsxs("div",{role:"alert",className:`absolute inset-x-0 flex flex-col items-center justify-center gap-2 bg-card/95 p-4 text-center text-[12px] text-ink-secondary ${x?"bottom-0":"inset-y-0"}`,children:[!x&&e.jsx(De,{size:22}),e.jsxs("span",{children:[x?n("computer.preview.paused"):n("computer.preview.cantConnect")," ",w]}),e.jsx("button",{type:"button",onClick:()=>P(!x),className:"rounded-md bg-control px-3 py-1.5 text-ink hover:bg-raised-hover",children:n("computer.preview.retry")})]})]})}function Ks({bot:s,backend:i,onBackend:d,onAutoStart:S}){return e.jsxs("div",{"data-testid":"vps-choices",children:[e.jsx(Ln,{compact:!0,value:i,onChange:d}),!s.computer&&e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-4 rounded-lg bg-inset px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13px] text-ink",children:n("botAccess.cloud.startVps")}),e.jsx("div",{className:"mt-0.5 text-[12px] text-ink-secondary",children:n("botAccess.cloud.startVpsDescription")})]}),e.jsx(zn,{checked:!!s.autoStartVps,"aria-label":n("botAccess.cloud.startVps"),onClick:S})]})]})}const Us={available:!1,devices:[]};function Hs(){const s=window.ogb?.androidDevice,[i,d]=a.useState(Us),[S,f]=a.useState(!1),v=Bt();return a.useEffect(()=>{if(!s){f(!0);return}if(!v)return;let k=!0,j=0,y=0;const P=async()=>{const m=++j,h=()=>m<y;try{const g=await s.status();k&&!h()&&(y=m,d(g))}catch(g){k&&!h()&&(y=m,d({available:!1,devices:[],reasonCode:"adb-failed",message:g instanceof Error?g.message:String(g)}))}finally{k&&!h()&&f(!0)}};P();const u=window.setInterval(()=>{P()},2e3);return()=>{k=!1,window.clearInterval(u)}},[s,v]),{...i,scanned:S}}function ct(s){return s.model==="Android device"?s.serial:s.model}function qs({status:s}){const i=window.ogb?.androidDevice,d=Bt(),S=s.devices.filter(p=>p.state==="device"),[f,v]=a.useState(S[0]?.serial??s.devices[0]?.serial??""),[k,j]=a.useState(null),[y,P]=a.useState({width:0,height:0}),[u,m]=a.useState(null),h=a.useRef(null),g=a.useRef(null),x=a.useRef({x:0,y:0,timer:null}),w=s.devices.find(p=>p.serial===f)??s.devices[0],$=w?.serial,R=w?.state;a.useEffect(()=>{!w&&s.devices[0]&&v(s.devices[0].serial),w&&!s.devices.some(p=>p.serial===w.serial)&&v(s.devices[0]?.serial??"")},[w,s.devices]),a.useEffect(()=>{if(!i||!$||R!=="device"||!d){if(!d)return;j(null);return}let p=!0,C=null;const V=async()=>{try{const _=await i.frame($);p&&(j(_.dataUrl),m(null))}catch(_){p&&m(_ instanceof Error?_.message:String(_))}finally{p&&(C=window.setTimeout(()=>{V()},850))}};return V(),()=>{p=!1,C!==null&&window.clearTimeout(C)}},[i,$,R,d]),a.useEffect(()=>()=>{x.current.timer&&clearTimeout(x.current.timer)},[]);const D=p=>{!i||!w||w.state!=="device"||i.input(w.serial,p).catch(C=>{m(C instanceof Error?C.message:String(C))})},B=(p,C=!1)=>{if(!h.current||!y.width||!y.height)return null;const _=p.currentTarget.getBoundingClientRect(),L=Math.min(_.width/y.width,_.height/y.height),Y=y.width*L,Z=y.height*L,G=_.left+(_.width-Y)/2,Le=_.top+(_.height-Z)/2,Ce=(p.clientX-G)/Y,te=(p.clientY-Le)/Z;return C?{x:Math.max(0,Math.min(1,Ce)),y:Math.max(0,Math.min(1,te))}:Ce>=0&&Ce<=1&&te>=0&&te<=1?{x:Ce,y:te}:null},ye=p=>{if(p.metaKey||p.ctrlKey||p.altKey)return;const C={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",Backspace:"delete",Delete:"delete",Enter:"enter",Escape:"back",Tab:"tab"};C[p.key]?(p.preventDefault(),D({type:"key",key:C[p.key]})):/^[A-Za-z0-9 _.,@-]$/.test(p.key)&&(p.preventDefault(),D({type:"text",text:p.key}))},me=p=>{if(!y.width||!y.height)return;p.preventDefault();const C=x.current;C.x+=p.deltaX,C.y+=p.deltaY,C.timer&&clearTimeout(C.timer),C.timer=setTimeout(()=>{const V=Math.abs(C.x)>Math.abs(C.y),_=V?C.x:C.y;if(C.x=0,C.y=0,C.timer=null,Math.abs(_)<2)return;const L=Math.max(.18,Math.min(.45,Math.abs(_)/500)),Y=_>0?-1:1,Z=V?{x:.5,y:.5}:{x:.5,y:.65},G=V?{x:Z.x+Y*L,y:Z.y}:{x:Z.x,y:Z.y+Y*L};D({type:"swipe",fromX:Z.x,fromY:Z.y,toX:G.x,toY:G.y,durationMs:260,width:y.width,height:y.height})},80)};if(!w)return null;const r=w.state==="device";return e.jsxs("div",{className:"space-y-3 pb-5",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-[15px] font-medium text-ink",children:[e.jsx(An,{size:16,className:"text-success"})," ",ct(w)]}),e.jsx("div",{className:"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:n("computer.android.usbSubtitle")})]}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-[11px] text-success",children:[e.jsx(Cr,{size:12})," ",n("computer.android.usb")]})]}),s.devices.length>1&&e.jsx(Ir,{value:w.serial,onChange:p=>v(p.target.value),className:"mt-3 w-full",children:s.devices.map(p=>e.jsxs("option",{value:p.serial,children:[ct(p)," · ",p.state]},p.serial))})]}),r?e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"application","aria-label":n("computer.android.screenAria",{name:ct(w)}),tabIndex:0,onKeyDown:ye,onWheel:me,onPointerDown:p=>{const C=B(p);C&&(p.currentTarget.setPointerCapture(p.pointerId),g.current={point:C,at:performance.now()})},onPointerUp:p=>{const C=g.current,V=B(p,!0);if(g.current=null,!C||!V)return;Math.hypot(V.x-C.point.x,V.y-C.point.y)<.012?D({type:"tap",...V,...y}):D({type:"swipe",fromX:C.point.x,fromY:C.point.y,toX:V.x,toY:V.y,durationMs:performance.now()-C.at,...y}),p.currentTarget.focus()},onPointerCancel:()=>{g.current=null},className:"mx-auto flex h-[520px] w-full touch-none cursor-pointer items-center justify-center overflow-hidden overscroll-none rounded-[28px] bg-black outline-none ring-1 ring-white/10 focus:ring-2 focus:ring-accent",children:k?e.jsx("img",{ref:h,src:k,alt:n("computer.android.screenAlt",{name:ct(w)}),draggable:!1,onLoad:p=>{P({width:p.currentTarget.naturalWidth,height:p.currentTarget.naturalHeight})},className:"pointer-events-none h-full w-full select-none object-contain"}):e.jsx(A,{size:20,className:"animate-spin text-ink-secondary"})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{onClick:()=>D({type:"key",key:"back"}),className:"flex items-center justify-center gap-1.5 rounded-lg bg-raised py-2 text-[12px] text-ink hover:bg-raised-hover",children:[e.jsx(Er,{size:13})," ",n("computer.android.back")]}),e.jsxs("button",{onClick:()=>D({type:"key",key:"home"}),className:"flex items-center justify-center gap-1.5 rounded-lg bg-raised py-2 text-[12px] text-ink hover:bg-raised-hover",children:[e.jsx(Rr,{size:12})," ",n("computer.android.home")]}),e.jsxs("button",{onClick:()=>D({type:"key",key:"recent"}),className:"flex items-center justify-center gap-1.5 rounded-lg bg-raised py-2 text-[12px] text-ink hover:bg-raised-hover",children:[e.jsx(pt,{size:13})," ",n("computer.android.recent")]})]}),e.jsx("div",{className:"text-center text-[11px] leading-relaxed text-ink-secondary",children:n("computer.android.hint")})]}):e.jsx("div",{className:"rounded-xl border border-warning/25 bg-warning/10 p-4 text-[12px] leading-relaxed text-warning",children:w.state==="unauthorized"?n("computer.android.unauthorized"):n("computer.android.badState",{state:w.state})}),u&&e.jsx("div",{className:"rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:u}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[13px] font-medium text-ink",children:[e.jsx(Bs,{size:15,className:"text-accent"})," ",n("computer.android.setupTitle")]}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1.5 pl-4 text-[12px] leading-relaxed text-ink-secondary",children:[e.jsx("li",{children:n("computer.android.step1")}),e.jsx("li",{children:n("computer.android.step2").split(/(\{buildNumber\}|\{usbDebugging\})/).map((p,C)=>p==="{buildNumber}"||p==="{usbDebugging}"?e.jsx("span",{className:"text-ink",children:n(p==="{buildNumber}"?"computer.android.buildNumber":"computer.android.usbDebugging")},C):p)}),e.jsxs("li",{children:[n("computer.android.step3a")," ",e.jsx("span",{className:"text-ink",children:n("computer.android.allowUsbDebugging")})," ",n("computer.android.step3b")]})]}),e.jsx("div",{className:"mt-2 text-[11px] leading-relaxed text-ink-secondary",children:n("computer.android.agentNote")}),e.jsx("div",{className:"mt-2 rounded-lg bg-inset px-3 py-2 text-[11px] leading-relaxed text-ink-secondary",children:n("computer.android.harnessNote")})]})]})}const Xs=1500,Ys=2e5,Mn=()=>Array.from(crypto.getRandomValues(new Uint8Array(18)),s=>s.toString(16).padStart(2,"0")).join("");function Gs(s,i){const d=window.setInterval(()=>{s.closed&&(window.clearInterval(d),i())},1e3)}async function Js({botId:s,title:i,held:d,request:S,join:f,current:v}){let k=null,j=null;!window.ogb?.desktopViewer&&!window.ogb?.openExternal&&(j=window.open("","_blank"),j&&(j.opener=null));const y=()=>new DOMException("The selected conversation changed","AbortError");try{if(!d&&(k=Mn(),!(await S("take",k)).held))throw new O("computer.err.confirmControl");if(!v())throw y();const{joinUrl:P}=await f(AbortSignal.timeout(Ys)),u=typeof P=="string"&&P?P:null;if(!v())throw y();if(!u)throw new O("computer.err.noDesktopLink");if(window.ogb?.desktopViewer){if(!await window.ogb.desktopViewer.open(u,i,s))throw new O("computer.err.openDesktop")}else if(j){j.location.replace(u);const m=k;m&&Gs(j,()=>{S("release",m).catch(()=>{})})}else if(window.ogb?.openExternal){if(!await window.ogb.openExternal(u))throw new O("computer.err.openDesktopLink")}else if(!window.open(u,"_blank","noopener"))throw new O("computer.err.popupBlocked")}catch(P){throw j?.close(),k&&await S("release",k).catch(()=>{}),P}}function _t(s,i){fetch(s,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i),keepalive:!0}).catch(()=>{})}function Zs({botId:s,session:i,held:d,request:S,viewerClose:f}){const[v,k]=a.useState(!1),[j,y]=a.useState(!1),[P,u]=a.useState(!1),m=a.useRef(null),h=a.useRef(f);h.current=f;const g=a.useCallback(()=>{k(!1),y(!1)},[]),x=a.useCallback(()=>{const R=m.current;m.current=null,g(),R&&(_t(`/api/bots/${s}/computer/control`,{action:"release",controlLeaseId:R.id}),R.viewerClose&&_t(R.viewerClose,{}))},[s,g]),w=a.useCallback(async(R=!1)=>{const D=Mn(),B=await S("take",D);if(!B.held)throw new O("computer.err.confirmControl");m.current=B.owned?{id:D,viewerClose:h.current}:null,k(!0),y(R)},[S]),$=a.useCallback(async()=>{const R=m.current?.viewerClose??h.current;m.current=null,g(),u(!0);try{await S("release")}finally{u(!1),R&&_t(R,{})}},[g,S]);return a.useEffect(()=>x,[i,x]),a.useEffect(()=>(window.addEventListener("pagehide",x),()=>window.removeEventListener("pagehide",x)),[x]),a.useEffect(()=>{if(!v||d)return;const R=setTimeout(()=>{m.current=null,g()},Xs);return()=>clearTimeout(R)},[v,d,g]),{here:v,expanded:j,setExpanded:y,handingBack:P,take:w,handBack:$,leave:x}}function Qs({held:s,frame:i,name:d,disabled:S,takeDisabled:f,error:v,onTakeControl:k}){const[j,y]=a.useState(!1),P=a.useCallback(()=>y(!1),[]);return a.useEffect(()=>{s&&y(!1)},[s]),e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>s?k(!0):y(!0),disabled:S,className:"flex flex-auto items-center justify-center gap-2 whitespace-nowrap rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:n(s?"computer.openLiveDesktop":"computer.watchFullScreenTitle"),children:[e.jsx(Je,{size:14}),n("computer.fullScreen")]}),j&&!s&&e.jsx(ea,{frame:i,name:d,takeDisabled:f,error:v,onClose:P,onTakeControl:()=>k(!0)})]})}function ea({frame:s,name:i,takeDisabled:d,error:S,onClose:f,onTakeControl:v}){const k=a.useRef(null),j=a.useRef(null),{dragProps:y,noDragStyle:P}=Dn(),u=Ze().capabilities.windowChrome==="mac-inset",m=a.useRef(null),[h,g]=a.useState(!1);Ss(k,f),a.useEffect(()=>j.current?.focus(),[]),a.useEffect(()=>{const $=R=>{R.key!=="Escape"||R.defaultPrevented||!(R.target instanceof Node)||!k.current?.contains(R.target)||(R.preventDefault(),R.stopPropagation(),f())};return window.addEventListener("keydown",$,!0),()=>window.removeEventListener("keydown",$,!0)},[f]),a.useEffect(()=>{const $=document.activeElement;d&&($===m.current||$===document.body)&&k.current?.focus()},[d]);const x="flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] focus-visible:outline-2 focus-visible:outline-focus disabled:opacity-50",w=n("computer.screenOf",{name:i});return e.jsxs("div",{ref:k,tabIndex:-1,"data-watch-full-screen":!0,role:"dialog","aria-modal":"true","aria-label":w,className:"fixed inset-0 z-[65] flex flex-col bg-app outline-none",children:[e.jsxs("header",{...y,className:K("flex shrink-0 flex-wrap items-center gap-2 border-b border-hairline/40 bg-panel px-3 py-2",u&&"pl-[86px]"),children:[e.jsx("span",{className:"min-w-0 truncate text-[13px] font-medium text-ink",children:w}),e.jsx("span",{className:"pointer-events-none rounded-full bg-black/70 px-2.5 py-1 text-[11px] font-medium text-white shadow-sm",children:n("computer.watchingBotWorks")}),e.jsxs("button",{ref:j,type:"button",style:P,onClick:f,"aria-label":n("desktopViewer.exitFullscreen"),className:K(x,"ml-auto bg-control text-ink hover:bg-raised-hover"),children:[e.jsx(Pr,{size:14,"aria-hidden":"true"}),e.jsx("span",{className:"max-sm:hidden",children:n("desktopViewer.exitFullscreen")})]}),e.jsxs("button",{ref:m,type:"button",style:P,onClick:()=>{g(!0),v()},disabled:d,className:K(x,"bg-accent font-medium text-accent-ink hover:brightness-110"),title:n("computer.takeControlTitle"),children:[e.jsx(Ye,{size:14,"aria-hidden":"true"}),n("computer.takeControl")]})]}),h&&S&&e.jsx("div",{role:"alert",className:"shrink-0 border-b border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:S}),e.jsx("div",{className:"relative flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-inset",children:s?e.jsx("img",{src:s,alt:w,className:"h-full w-full object-contain"}):e.jsxs("span",{role:"status",className:"flex items-center gap-2 text-[12px] text-ink-secondary",children:[e.jsx(A,{size:16,className:"animate-spin","aria-hidden":"true"}),n("computer.waitingFrame")]})})]})}function ut(s){for(const i of s?.getTracks()??[])i.stop()}function ta(s){const i=s instanceof DOMException?s.name:"";return i==="NotAllowedError"||i==="AbortError"?{ok:!1,phase:"cancelled",messageKey:"computer.screen.cancelled"}:i==="NotFoundError"||i==="NotReadableError"||i==="NotSupportedError"||i==="SecurityError"?{ok:!1,phase:"unavailable",messageKey:"computer.screen.unavailableNow"}:{ok:!1,phase:"error",messageKey:"computer.screen.error"}}async function na({beginIntent:s,getDisplayMedia:i}){try{if(!s())return{ok:!1,phase:"unavailable",messageKey:"computer.screen.unavailableWindow"};const d=await i({video:!0,audio:!1});return d.getVideoTracks().length===0?(ut(d),{ok:!1,phase:"unavailable",messageKey:"computer.screen.noVideoTrack"}):{ok:!0,stream:d}}catch(d){return ta(d)}}const Xe={idle:"computer.screen.idle",ended:"computer.screen.ended",unavailable:"computer.screen.unavailable"};function ra(){const{capabilities:s,ready:i}=Ze(),d=s.screenPreview,S=s.host.platform==="linux",[f,v]=a.useState("idle"),[k,j]=a.useState(Xe.idle),[y,P]=a.useState(""),u=a.useRef(null),m=a.useRef(null),h=a.useRef(0),g=a.useCallback((R,D)=>{h.current+=1;const B=m.current;m.current=null,u.current&&(u.current.srcObject=null),ut(B),v(R),j(D)},[]);a.useEffect(()=>()=>{h.current+=1;const R=m.current;m.current=null,ut(R)},[]);const x=async()=>{if(!d.available||!window.ogb?.beginScreenPreviewIntent||!navigator.mediaDevices?.getDisplayMedia){v("unavailable"),j(Xe.unavailable);return}g("requesting","computer.screen.waiting");const R=h.current,D=await na({beginIntent:()=>window.ogb.beginScreenPreviewIntent(),getDisplayMedia:r=>navigator.mediaDevices.getDisplayMedia(r)});if(R!==h.current){D.ok&&ut(D.stream);return}if(!D.ok){v(D.phase),j(D.messageKey);return}const B=D.stream,ye=B.getVideoTracks()[0];m.current=B,P(ye.label),ye.addEventListener("ended",()=>{m.current===B&&g("ended",Xe.ended)},{once:!0});const me=u.current;if(!me){g("error","computer.screen.displayFailed");return}me.srcObject=B;try{await me.play()}catch{R===h.current&&m.current===B&&g("error","computer.screen.displayFailed");return}R!==h.current||m.current!==B||(v("streaming"),j("computer.screen.active"))};if(!S)return null;const w=y||n("computer.screen.selected"),$=f==="cancelled"||f==="ended"||f==="unavailable"||f==="error";return e.jsxs("section",{className:"mt-4 rounded-xl bg-card p-4","aria-labelledby":"local-preview-title",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{id:"local-preview-title",className:"text-[15px] font-medium text-ink",children:n("computer.screen.title")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:n("computer.screen.subtitle")})]}),e.jsx("span",{className:"shrink-0 rounded-full bg-raised px-2 py-1 text-[10px] font-medium text-ink-secondary",children:n("computer.screen.badge")})]}),e.jsxs("div",{className:"relative mt-3 flex aspect-[16/10] items-center justify-center overflow-hidden rounded-lg bg-panel",children:[e.jsx("video",{ref:u,autoPlay:!0,muted:!0,playsInline:!0,"aria-label":n("computer.screen.videoAria"),className:f==="streaming"?"h-full w-full object-contain":"hidden"}),f!=="streaming"&&e.jsxs("div",{className:"flex flex-col items-center gap-2 px-6 text-center text-ink-secondary",children:[f==="requesting"?e.jsx(A,{size:18,className:"animate-spin"}):e.jsx(De,{size:22}),e.jsx("span",{className:"text-[12px]","aria-live":"polite",children:i?n(d.available?k:Xe.unavailable):n("computer.screen.checking")})]})]}),f==="streaming"&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3 text-[11px] text-ink-secondary",children:[e.jsx("span",{className:"truncate",title:w,children:d.interaction==="portal-picker"?w:n("vm.dest.local")}),e.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success"})," ",n("computer.screen.sharing")]})]}),e.jsxs("button",{type:"button",disabled:f==="requesting"||!d.available&&f!=="streaming",onClick:f==="streaming"?()=>g("idle",Xe.idle):()=>{x()},className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg bg-raised py-2 text-[13px] text-ink hover:bg-raised-hover disabled:cursor-not-allowed disabled:opacity-50",children:[f==="requesting"?e.jsx(A,{size:14,className:"animate-spin"}):f==="streaming"?e.jsx(zr,{size:13}):$?e.jsx(pt,{size:14}):e.jsx(De,{size:14}),f==="requesting"?n("computer.screen.choosing"):f==="streaming"?n("computer.screen.stop"):$?n("computer.linux.tryAgain"):d.interaction==="portal-picker"?n("computer.screen.choose"):n("computer.screen.start")]})]})}const sa="https://github.com/leomieo/limix-bot/blob/main/docs/linux-desktop.md#enable-local-control",aa="https://github.com/leomieo/limix-bot/blob/main/docs/linux-desktop.md#omarchy-hyprland-experimental",oa="https://cua.ai/docs/cua-sdk/guides/omarchy";function ia(){const{capabilities:s}=Ze(),i=s.localComputer,[d,S]=a.useState(null),[f,v]=a.useState(null);if(s.host.platform!=="linux")return null;const k=d!==null||i.status==="checking"||i.status==="starting",j=i.available,y=i.reasonCode==="linux-wayland-seat-safety-blocked",P=i.reasonCode==="linux-hyprland-plugin-required",u=i.compositor==="hyprland",m=s.host.session==="wayland",h=i.driverSource==="bundled",g=async x=>{if(window.ogb?.localControl){S(x),v(null);try{if((x==="disable"||x==="retry")&&!(await fetch("/api/local-computer/interrupt",{method:"POST"})).ok){v({key:"computer.linux.stopFailed"});return}await window.ogb.localControl[x]()}catch(w){v(w instanceof Error?w.message:String(w))}finally{S(null)}}};return e.jsxs("section",{className:"mt-4 rounded-xl bg-card p-4","aria-labelledby":"linux-local-control-title",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{id:"linux-local-control-title",className:"flex items-center gap-2 text-[15px] font-medium text-ink",children:[e.jsx(Vs,{size:16,className:j?"text-success":"text-ink-secondary"}),n("computer.linux.title")]}),e.jsx("div",{className:"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:u?n("computer.linux.metaOmarchy"):n("computer.linux.meta",{session:m?"Wayland":"Xorg"})})]}),e.jsx("span",{className:K("shrink-0 rounded-full px-2 py-1 text-[10px] font-medium",j?"bg-success/10 text-success":y?"bg-danger/10 text-danger":P||i.enabled?"bg-warning/10 text-warning":"bg-raised text-ink-secondary"),children:j?n("computer.linux.ready"):y?n("computer.linux.waylandBadge"):P?n("computer.linux.pluginBadge"):i.enabled?n("vm.state.attention"):n("vm.dest.off")})]}),y?e.jsx("div",{className:"mt-3 rounded-lg border border-danger/20 bg-danger/5 p-3",children:e.jsxs("div",{className:"flex gap-2 text-[12px] leading-relaxed text-ink-secondary",children:[e.jsx(Ge,{size:15,className:"mt-0.5 shrink-0 text-danger"}),e.jsxs("span",{children:[n("computer.linux.waylandBefore")," ",e.jsx("strong",{className:"font-medium text-ink",children:n("computer.linux.waylandXorg")})," ",n("computer.linux.waylandAfter")]})]})}):P?e.jsxs("div",{className:"mt-3 rounded-lg border border-warning/20 bg-warning/5 p-3","data-linux-hyprland-plugin-required":!0,children:[e.jsxs("div",{className:"flex gap-2 text-[12px] leading-relaxed text-ink-secondary",children:[e.jsx(Ge,{size:15,className:"mt-0.5 shrink-0 text-warning"}),e.jsx("span",{children:n("computer.linux.hyprlandPlugin")})]}),e.jsxs("button",{type:"button",onClick:()=>window.open(oa,"_blank","noopener,noreferrer"),className:"mt-2 flex items-center gap-1.5 text-[12px] font-medium text-accent hover:underline",children:[n("computer.linux.omarchyGuide")," ",e.jsx(Sn,{size:11})]})]}):i.enabled?e.jsxs("div",{className:"mt-3 rounded-lg bg-panel p-3 text-[12px] text-ink-secondary",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[j?e.jsx(Tr,{size:15,className:"mt-0.5 shrink-0 text-success"}):k?e.jsx(A,{size:15,className:"mt-0.5 shrink-0 animate-spin"}):e.jsx(Ge,{size:15,className:"mt-0.5 shrink-0 text-warning"}),e.jsx("span",{"aria-live":"polite",children:j?n(u?"computer.linux.hyprlandReady":"computer.linux.readyMsg"):i.message??n("computer.linux.checking")})]}),i.driverPath&&e.jsxs("div",{className:"mt-2 break-all font-mono text-[10px] text-ink-tertiary",title:i.driverPath,children:[h?n("computer.linux.bundledDriver"):i.driverPath,i.driverVersion?` · ${i.driverVersion}`:""]})]}):e.jsx("div",{className:"mt-3 rounded-lg border border-warning/20 bg-warning/5 p-3",children:e.jsxs("div",{className:"flex gap-2 text-[12px] leading-relaxed text-ink-secondary",children:[e.jsx(Ge,{size:15,className:"mt-0.5 shrink-0 text-warning"}),e.jsxs("span",{children:[n("computer.linux.enableBefore")," ",e.jsx("strong",{className:"font-medium text-ink",children:n("vm.dest.local")})," ",n("computer.linux.enableAfter"),m&&!u&&` ${n("computer.linux.waylandInput")}`]})]})}),f&&e.jsx("div",{className:"mt-2 text-[12px] text-danger",children:typeof f=="string"?f:n(f.key)}),!y&&e.jsx("div",{className:"mt-3 flex gap-2",children:P?e.jsxs("button",{type:"button",disabled:k,onClick:()=>{g("enable")},className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-raised py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[d==="enable"?e.jsx(A,{size:14,className:"animate-spin"}):e.jsx(pt,{size:14}),n("computer.linux.tryAgain")]}):i.enabled?e.jsxs(e.Fragment,{children:[!j&&e.jsxs("button",{type:"button",disabled:k,onClick:()=>{g("retry")},className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-raised py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[d==="retry"?e.jsx(A,{size:14,className:"animate-spin"}):e.jsx(pt,{size:14}),n("computer.linux.tryAgain")]}),e.jsxs("button",{type:"button",disabled:d!==null,onClick:()=>{g("disable")},className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-raised py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[d==="disable"?e.jsx(A,{size:14,className:"animate-spin"}):e.jsx(mt,{size:14}),n("computer.linux.disable")]})]}):e.jsxs("button",{type:"button",disabled:k,onClick:()=>{g("enable")},className:"flex flex-1 items-center justify-center gap-2 rounded-lg bg-accent py-2 text-[13px] font-medium text-white hover:opacity-90 disabled:opacity-50",children:[d==="enable"?e.jsx(A,{size:14,className:"animate-spin"}):e.jsx(mt,{size:14}),n("computer.linux.enable")]})}),e.jsxs("button",{type:"button",onClick:()=>window.open(u?aa:sa,"_blank","noopener,noreferrer"),className:"mt-2 flex w-full items-center justify-center gap-1.5 rounded-lg py-1.5 text-[11px] text-ink-secondary hover:bg-raised hover:text-ink",children:[s.host.packaged?n("computer.linux.guide"):n("computer.linux.driverSetup")," ",e.jsx(Sn,{size:11})]})]})}function la(){const{capabilities:s}=Ze(),[i,d]=a.useState(!1),[S,f]=a.useState(null),v=s.localComputer;if(s.host.platform!=="win32"||v.reasonCode==="remote-server"||v.available)return null;const k=async()=>{d(!0),f(null);try{await window.ogb?.localControl?.retry()}catch(j){f(j instanceof Error?j.message:String(j))}finally{d(!1)}};return e.jsx("section",{"data-windows-local-control":v.reasonCode??"unavailable",className:"mt-4 rounded-xl border border-warning/25 bg-warning/10 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Fs,{size:16,className:"mt-0.5 shrink-0 text-warning","aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:n("computer.windows.title")}),e.jsxs("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:[n("computer.windows.body"),v.reasonCode==="cua-driver-blocked"&&e.jsxs(e.Fragment,{children:[" ",n("computer.windows.blocked")]})]}),v.message&&e.jsxs("details",{className:"mt-2 text-[12px] text-ink-secondary",children:[e.jsx("summary",{className:"cursor-pointer",children:n("computer.windows.detail")}),e.jsx("p",{className:"mt-1 break-words",children:v.message})]}),S&&e.jsxs("div",{role:"alert",className:"mt-2 flex gap-1.5 text-[12px] text-danger",children:[e.jsx(Ge,{size:13,className:"mt-0.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{children:S})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:e.jsxs("button",{type:"button",onClick:()=>{k()},disabled:i,className:"inline-flex items-center gap-1.5 rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[i&&e.jsx(A,{size:13,className:"animate-spin","aria-hidden":"true"}),n(i?"computer.windows.starting":"computer.windows.start")]})})]})]})})}const ca={computer:{Icon:De,label:"computer.tab.computer"},routines:{Icon:Tn,label:"computer.tab.routines"},android:{Icon:An,label:"computer.tab.android"},browser:{Icon:Ft,label:"computer.tab.browser",tour:"computer-browser"},data:{Icon:Dr,label:"computer.tab.data",tour:"computer-data"},files:{Icon:Ar,label:"computer.tab.files"}},Ne="outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent/60",xt=s=>`computer-panel-tabs-tab-${s}`,On=s=>`computer-panel-tabs-panel-${s}`,da=(s,i)=>({id:xt(s),role:"tab","aria-selected":i,"aria-controls":On(s),tabIndex:i?0:-1}),Se=s=>({role:"tabpanel",id:On(s),"aria-labelledby":xt(s),tabIndex:0});function ua(s){const i=s.currentTarget;Math.abs(s.deltaY)<=Math.abs(s.deltaX)||i.scrollWidth<=i.clientWidth||(i.scrollLeft+=s.deltaY)}function pa(s,i,d){if(s.ctrlKey||s.metaKey||s.altKey)return;const S=Math.max(0,i.findIndex(k=>xt(k)===s.target.id)),f=s.key==="ArrowRight"?1:s.key==="ArrowLeft"?-1:0,v=s.key==="Home"?i[0]:s.key==="End"?i[i.length-1]:f?i[(S+f+i.length)%i.length]:void 0;v&&(s.preventDefault(),d(v),document.getElementById(xt(v))?.focus())}function ma(s,i,d){const S=i.scanned&&i.devices.length===0&&i.reasonCode!=="adb-unavailable"&&i.reasonCode!=="adb-failed";a.useEffect(()=>{!S||$t(s)!=="android"||(d("computer"),dt(s,"computer"))},[s,S,d])}const Vn="omb-computer-panel-width",bt=360,ft=960,xa=400,En=40;function ba(){try{const s=Number(localStorage.getItem(Vn));if(Number.isFinite(s)&&s>=bt&&s<=ft)return s}catch{}return xa}function fa(){const[s,i]=a.useState(ba),d=a.useRef(null),S=h=>{try{localStorage.setItem(Vn,String(h))}catch{}},f=h=>{d.current={x:h.clientX,width:s},h.currentTarget.setPointerCapture(h.pointerId)},v=h=>{if(!d.current)return;const g=Math.min(ft,Math.max(bt,d.current.width+(d.current.x-h.clientX)));i(g)},k=h=>{d.current&&(d.current=null,h.currentTarget.releasePointerCapture(h.pointerId),S(s))},j=h=>{i(g=>{const x=Math.min(ft,Math.max(bt,g+h));return S(x),x})},y=a.useRef(null),[P,u]=a.useState(null);return a.useEffect(()=>{const h=y.current?.closest("aside");if(!h)return;const g=()=>u(h.offsetWidth);g();const x=new ResizeObserver(g);return x.observe(h),()=>x.disconnect()},[]),{panelWidth:s,separatorRef:y,separatorWidth:P,onSeparatorKeyDown:h=>{if(h.ctrlKey||h.metaKey||h.altKey)return;const g=h.key==="ArrowLeft"?En:h.key==="ArrowRight"?-En:null;g===null||P===null||(h.preventDefault(),j(g))},onResizeStart:f,onResizeMove:v,onResizeEnd:k}}const ha=a.lazy(()=>Pn(()=>import("./DataPanel-B42JmnxF.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(s=>({default:s.DataPanel}))),_n=()=>Pn(()=>import("./LiveDesktop-B6kJJHn8.js"),__vite__mapDeps([9,1,2,10,11,4,5,7,3,6])).then(s=>({default:s.LiveDesktop})),ga=a.lazy(_n),Rn=Cs({held:In().optional().default(!1),helpReason:Es().nullable().optional().default(null),help:Is().optional().transform(us),owned:In().optional()}).passthrough();function Oa({bot:s,onOpenVmWorkspace:i}){const{dragProps:d}=Dn(),{panelWidth:S,separatorRef:f,separatorWidth:v,onSeparatorKeyDown:k,onResizeStart:j,onResizeMove:y,onResizeEnd:P}=fa(),{state:u,dispatch:m,flushBotPatches:h}=Lr(),g=s.tasks?.find(t=>t.threadId===s.threadId),x=Mr(s,g),w=Or(g),$=Vr(s),R=`${s.id}:${s.threadId}:${x}:${s.cloudBackend??"box"}:${$.modelSelection.instanceId}`,[D,B]=a.useState(null),ye=D?.key===R,me=x!=="auto"||ye,r={...$,computer:x==="auto"?ye?D.surface:void 0:x},p=`${r.id}:${r.threadId}:${r.computer}:${r.cloudBackend??"box"}`,C=a.useRef(p);C.current=p;const V=a.useRef(null);a.useEffect(()=>()=>V.current?.abort(),[p]);const _=!!r.busy,L=a.useCallback(t=>`/api/bots/${s.id}/${t}?threadId=${encodeURIComponent(s.threadId)}`,[s.id,s.threadId]),Y=s.computer==="cloud"&&x==="cloud",Z=s.computer==="vm"&&x==="vm",{capabilities:G,ready:Le}=Ze(),Ce=G.localComputer.available,te=G.host.platform==="linux",Me=_r(u.instances,r),Wt=Fr("local",u.config)&&$r({capabilities:G,providerSupportsLocal:Me}),[Kt,gt]=a.useState(null),Ut=Br({capabilities:G,providerSupportsLocal:Me}),Fn=Wr(u.config,G),[c,N]=a.useState("checking"),[Oe,Ht]=a.useState(null),[xe,ne]=a.useState(null),[vt,yt]=a.useState(null),T=r.cloudBackend??"box",Qe=!!(Oe&&Oe.botId===r.id&&Oe.computer===s.computer&&Oe.cloudBackend===T&&Oe.section===(r.section?.trim()??"")),U=!!(xe&&xe.botId===r.id&&xe.threadId===r.threadId&&xe.computer===r.computer&&xe.cloudBackend===T),we=U&&x==="auto"&&T==="box"&&vt?.botId===r.id&&vt.section===(r.section?.trim()??"")?vt:null,W=U&&Kr({computer:r.computer,cloudBackend:T,phase:c,botId:r.id,resolvedBotId:xe?.botId??null,resolvedComputer:xe?.computer??null,resolvedCloudBackend:xe?.cloudBackend??null}),Ie=a.useCallback(t=>{ne(null),yt(null),N("checking"),m({type:"updateBot",botId:r.id,patch:t})},[r.id,m]);a.useEffect(()=>{let t=!0;return Ht(null),h(r.id).then(o=>{t&&(o&&!Ur({computer:s.computer,cloudBackend:T,persistedBot:o})||o&&(o.section?.trim()??"")!==(r.section?.trim()??"")||Ht({botId:r.id,computer:s.computer,cloudBackend:T,section:r.section?.trim()??""}))}),()=>{t=!1}},[r.id,s.computer,r.section,T,h]);const[Ve,ae]=a.useState(null),[wt,et]=a.useState(null),[$n,ce]=a.useState(null),[Bn,Ee]=a.useState(!1),[qt,Wn]=a.useState(0),[Kn,kt]=a.useState(null),[H,_e]=a.useState(null),[Xt,jt]=a.useState(null),[Un,Yt]=a.useState(null),[E,oe]=a.useState(null),[ie,Re]=a.useState(!1),[tt,Gt]=a.useState(!1),[nt,I]=a.useState(null),be=Nn(nt),Q=hr(),[Hn,Fe]=a.useState(()=>$t(r.id)),$e=u.dataResultFocus?.botId===r.id?u.dataResultFocus:void 0,[qn,Xn]=a.useState(),Nt=Hs(),St=Nt.devices.length>0,Jt=bs({advanced:Q,androidConnected:St}),M=cs(Hn,{advanced:Q,androidConnected:St}),Ct=Hr(s.id,M),Zt=qr(u.config),fe=yn(u.config)&&r.browser!==!1&&(Zt||u.config?.browserEngine?.installable===!0),[Qt,Pe]=a.useState(0),[Yn,Gn]=a.useState(!1);a.useEffect(()=>{if(x!=="auto"||!Qe)return;const t=new AbortController;return B(null),F(L("computer"),{signal:t.signal}).then(o=>{if(t.signal.aborted)return;const l=o.surface;B({key:R,surface:l==="cloud"||l==="vm"||l==="local"||l==="browser"||l==="off"?l:void 0})}).catch(o=>{t.signal.aborted||(I(o instanceof Error?o:String(o)),N("error"))}),()=>t.abort()},[R,x,Qe,L,Qt]);const It=c==="vm-unavailable"&&H?.resumable===!0,Be=a.useRef(0),ke=a.useRef(null);a.useEffect(()=>(ke.current?.signal.aborted&&(ke.current=null,oe(null)),()=>{ke.current?.abort()}),[r.id,r.threadId,r.computer,M]);const rt=u.instances.find(t=>t.instanceId===r.modelSelection.instanceId),We=a.useRef(!1),st=t=>{We.current=!0,Fe(t),dt(r.id,t)},en=a.useRef(null),at=`${s.id}:${s.threadId}:${x}:${s.cloudBackend??"box"}`;a.useEffect(()=>{const t=en.current;t===at&&(We.current||!(r.computer==="browser"&&fe))||(t!==at&&(We.current=!1),en.current=at,Fe(r.computer==="browser"&&fe?"browser":t===null?$t(r.id):"computer"))},[at,r.id,r.computer,fe]),a.useEffect(()=>{!$e||$e.consumed||(We.current=!0,Xn($e),Fe("data"),dt(r.id,"data"),m({type:"dataResultFocusConsumed",requestId:$e.requestId}))},[r.id,m,$e]);const he=u.signInFocus?.botId===r.id?u.signInFocus:void 0,[Jn,Zn]=a.useState(),[Qn,er]=a.useState();Xr(r.id,t=>{st("browser"),er(t)}),a.useEffect(()=>{if(!he||he.consumed)return;const t=he.place==="browser"?"browser":"computer";We.current=!0,Fe(t),dt(r.id,t),t==="browser"&&Zn({url:he.url,site:he.site,nonce:he.requestId}),m({type:"signInFocusConsumed",requestId:he.requestId})},[r.id,m,he]),a.useEffect(()=>{let t=!0;const o=window.ogb?.desktopViewer;o?.currentState&&o.currentState().then(b=>{t&&Gt(b.open&&b.contextId===r.id)}).catch(()=>{});const l=o?.onState(b=>{b.contextId===r.id&&Gt(b.open)});return()=>{t=!1,l?.()}},[r.id]),ma(r.id,Nt,Fe),a.useEffect(()=>{Be.current=0},[r.id,r.computer]);const tn=!!(rt?.snapshot.state==="available"&&rt.capabilities?.computerMcp),Et=yr(wr(rt)),nn=u.routines.filter(t=>t.botId===r.id).sort((t,o)=>Number(o.enabled)-Number(t.enabled)||(t.nextRunAt??1/0)-(o.nextRunAt??1/0)),tr=!!(u.config?.box.configured&&kr(u.instances,r.modelSelection.instanceId)?.snapshot.state==="available"),Ke=u.routineRuns.find(t=>t.botId===r.id&&["queued","running","waiting"].includes(t.status));a.useEffect(()=>{if(M!=="computer")return;let t=!0;if(ne(null),yt(null),N("checking"),et(null),ce(null),kt(null),_e(null),jt(null),Yt(null),I(null),!(!Qe||!me)){if(r.computer===void 0){N("auto-unavailable");return}if(r.computer==="off"){N("off");return}if(r.computer==="browser"){N("browser");return}if(r.computer==="local"){Me||I(new O("computer.err.localEngine")),N(Le&&Ce&&Me?"local":"local-unavailable"),ne({botId:r.id,threadId:r.threadId,computer:r.computer,cloudBackend:T});return}if(r.computer==="vm"){if(!tn){I(new O("computer.err.vmEngine")),N("vm-unavailable");return}let o;return F(L("local-computer")).then(l=>{if(!t)return;const b=l;if(ne({botId:r.id,threadId:r.threadId,computer:r.computer,cloudBackend:T}),_e(b),b.ready)Be.current=0,N("vm");else if(b.container==="running"&&b.imageMatches&&b.managed&&b.network==="loopback"&&b.security==="hardened"&&b.persistence==="durable"&&!b.desktopReady&&Be.current<15)Be.current+=1,I(null),N("checking"),o=window.setTimeout(()=>Pe(z=>z+1),2e3);else{const z=b.mode==="per-bot"&&b.container==="missing"&&b.image&&b.create_supported;I(z||b.resumable?null:new O("computer.err.vmOpenSettings",b.problem,"computer.err.vmNotReady")),N("vm-unavailable")}}).catch(l=>{t&&(I(l.message),N("vm-unavailable"))}),()=>{t=!1,o!==void 0&&window.clearTimeout(o)}}if(r.computer==="cloud"&&!Et){N("error");return}if(!(r.computer!=="cloud"&&!Le))return T==="vps"?(F(L("computer")).then(o=>{if(!t)return;const l=o;if(jt(l),ne({botId:r.id,threadId:r.threadId,computer:r.computer,cloudBackend:T}),!l.configured){I(new O("computer.err.vpsAlias")),N("vps-unconfigured");return}if(l.ready){ae(l.container??null),N("ready");return}if(l.managed&&l.container!=="missing"&&!l.imageMatches){I(l.problem),N("vps-incompatible");return}if(Y)return N("starting"),F(`/api/bots/${r.id}/computer/provision`,{method:"POST"}).then(b=>{t&&(ae(b.container??null),b.ready?(ne({botId:r.id,threadId:r.threadId,computer:r.computer,cloudBackend:T}),N("ready")):(I(b.problem??new O("computer.err.vpsNotReady")),N("error")))});ae(l.container??null),I(r.autoStartVps?new O("computer.err.vpsAuto",l.problem,"computer.err.vpsNoContainer"):new O("computer.err.vpsManual",l.problem,"computer.err.vpsNoContainer")),N(l.container==="stopped"?"vps-stopped":"vps-unconfigured")}).catch(o=>{t&&(I(o.message),N("error"))}),()=>{t=!1}):(F(L("computer")).then(o=>{if(!t)return;const l=Yr({computer:x==="cloud"?"cloud":void 0,configured:!!o.configured,boatState:typeof o.box?.state=="string"?o.box.state:null,canUseCloud:Et,autoLocal:!1,teamComputer:typeof o.teamComputer?.id=="string"&&typeof o.teamComputer?.name=="string",busy:s.busy});if(ne({botId:r.id,threadId:r.threadId,computer:r.computer,cloudBackend:T}),!o.configured&&r.computer==="cloud"&&!o.teamComputer){N("unconfigured");return}if(l==="team-boat"){yt({id:o.teamComputer.id,name:o.teamComputer.name,botId:r.id,section:r.section?.trim()??""}),ae(typeof o.box?.state=="string"?o.box.state:o.configured?"missing":"unavailable"),I(typeof o.problem=="string"?o.problem:null),N("team-boat");return}if(l==="attach-ready-boat"||r.computer==="cloud"&&l==="show-ready-boat"){ae(typeof o.box?.state=="string"?o.box.state:null),N("ready");return}ae(typeof o.box?.state=="string"?o.box.state:null),N(l)}).catch(o=>{t&&(I(o.message),N("error"))}),()=>{t=!1})}},[r.id,r.threadId,r.computer,r.section,r.autoStartVps,r.vpsAlias,T,Qt,Le,Wt,te,Me,rt?.driverKind,tn,Et,u.config?.vps?.sshAlias,M,Qe,me,Y,x,L]),a.useEffect(()=>{if(c!=="busy-boat")return;let t=!0;const o=()=>{if(!s.busy&&x==="cloud"){Pe(b=>b+1);return}F(L("computer"),{background:!0}).then(b=>{if(!t)return;const z=typeof b.box?.state=="string"?b.box.state:null;ae(z),ds(z)&&N("ready")}).catch(()=>{})},l=window.setInterval(o,5e3);return()=>{t=!1,window.clearInterval(l)}},[c,L,s.busy,x]);const q=u.computerControl[r.id]??{held:!1,helpReason:null},ot=a.useCallback(async(t,o)=>{const l=Rn.parse(await F(`/api/bots/${r.id}/computer/control`,{method:"POST",body:JSON.stringify({action:t,...o?{controlLeaseId:o}:{}})}));return m({type:"computerControl",botId:r.id,held:l.held===!0,helpReason:l.helpReason,help:l.help}),l},[r.id,m]),ee=U?c==="vm"&&H?.viewer_url&&H.target_key?Sr({key:H.target_key}):W&&T==="vps"?`vps/${r.id}`:null:null,le=Zs({botId:r.id,session:`${p}:${M}`,held:q.held,request:ot,viewerClose:ee?.startsWith("vps/")?L("computer/viewer-close"):null}),pe=le.here&&!!ee;a.useEffect(()=>{ee&&_n()},[ee]);const ze=Bt(),Te=a.useRef(0),Rt=a.useRef(r.busy);a.useEffect(()=>{Rt.current=r.busy},[r.busy]),a.useEffect(()=>{if(Te.current=0,!!W)return Gr({screens:!0,onFrame:t=>{t.kind!=="screen"||t.botId!==r.id||t.threadId!==r.threadId||(Te.current=Date.now(),et({png:t.png,mime:t.mime??"image/png"}),ce(null),Ee(!1))}})},[W,r.id,r.threadId]),a.useEffect(()=>{if(M!=="computer"||!W||tt||pe||!ze||E||ie)return;let t=!1,o=-1/0,l=null,b=null;const z=new AbortController;ce(null),Ee(!0);const se=async()=>{if(t||z.signal.aborted||Date.now()-o<(l??(Rt.current?4e3:3e4))||Rt.current&&Date.now()-Te.current<1e4)return;t=!0,l=null;const X=Date.now();try{const{png:J,format:Ae}=await F(L("computer/screenshot"),{method:"POST",signal:AbortSignal.any([z.signal,AbortSignal.timeout(9e4)])});if(!z.signal.aborted&&Te.current<=X){if(typeof J!="string"||!J.trim())throw new O("computer.err.emptyFrame");et({png:J,mime:Ae==="jpeg"?"image/jpeg":"image/png"}),ce(null),Ee(!1),b=null}}catch(J){if(!z.signal.aborted&&Te.current<=X)if(J instanceof ps&&jr(J)){l=1e3,b??=Date.now();const Ae=Date.now()-b>=1e4;ce(Ae?J:null),Ee(!Ae)}else b=null,Ee(!1),ce(J instanceof Error&&J.name==="TimeoutError"?new O("computer.err.frameTimeout"):J instanceof Error?J:new O("computer.err.screenUnavailable"))}finally{t=!1,o=Date.now()}};se();const ue=setInterval(se,1e3);return()=>{z.abort(),clearInterval(ue)}},[M,W,L,T,tt,pe,ze,E,ie,qt]),a.useEffect(()=>{if(M!=="computer"||c!=="vm"||!U||tt||pe||!ze)return;const t=new AbortController;let o=!1,l=-1/0,b=null,z=!0;const se=async()=>{if(!(o||t.signal.aborted)&&!(Date.now()-l<(b??(r.busy?3e3:3e4)))){o=!0,b=null;try{const{image:X}=await F(L("local-computer/screenshot"),{method:"POST",signal:t.signal});!t.signal.aborted&&typeof X=="string"&&(kt(X),ce(null))}catch(X){t.signal.aborted||(b=5e3,z?I(X instanceof Error?X.message:String(X)):ce(X instanceof Error?X:new O("computer.err.screenUnavailable")))}finally{o=!1,z=!1,l=Date.now()}}};se();const ue=window.setInterval(()=>{se()},r.busy?3e3:3e4);return()=>{t.abort(),window.clearInterval(ue)}},[M,c,U,L,tt,pe,ze,r.busy,I,ce,kt]);const[rn,Pt]=a.useState(0);a.useEffect(()=>{if(M!=="computer"||c!=="local"||!U||!window.ogb||te||!ze)return;let t=!0;Pt(0);const o=async()=>{try{const b=await window.ogb.screenFrame();t&&b?Yt(b):t&&Pt(z=>z+1)}catch{t&&Pt(b=>b+1)}};o();const l=setInterval(o,r.busy?3e3:3e4);return()=>{t=!1,clearInterval(l)}},[M,c,U,te,ze,r.busy,r.id,r.threadId]);const ge=U?c==="vm"?Kn:c==="local"&&!te?Un:W||r.computer==="cloud"&&c==="starting"?wt&&`data:${wt.mime};base64,${wt.png}`:null:null,nr=!!(ge&&(ee||W)),de=q.help??null,rr=de?u.bots.find(t=>t.id===de.botId)?.name??r.name:r.name;a.useEffect(()=>{let t=!0;return F(`/api/bots/${r.id}/computer/control`).then(o=>{if(!t)return;const l=Rn.parse(o);m({type:"computerControl",botId:r.id,held:l.held===!0,helpReason:l.helpReason,help:l.help})}).catch(()=>{}),()=>{t=!1}},[r.id]);const sn=a.useCallback(async()=>!0,[]),an=a.useCallback(async t=>Jr({action:t,syncNativeBrowser:M!=="browser",requestControl:ot,setNativeBrowserControl:sn}),[M,ot,sn]),sr=a.useCallback(async t=>{Re(!0),I(null);try{return await an(t),!0}catch(o){return I(o instanceof Error?o.message:String(o)),!1}finally{Re(!1)}},[an]),it=!!(de&&de.place!=="browser"&&de.place!=="local"&&(W||c==="vm"||we)),on=t=>de&&e.jsx(hs,{help:de,askerName:rr,takeControl:t&&{onClick:t,disabled:ie||E==="join",pending:E==="join"},onError:I}),ar=async()=>{const t=new AbortController;V.current=t;const o=()=>!t.signal.aborted&&C.current===p;oe("join"),Re(!0),I(null);try{await Js({botId:r.id,title:n("computer.viewerTitle",{name:r.name}),held:q.held,request:ot,join:l=>F(L("computer/join"),{method:"POST",signal:AbortSignal.any([t.signal,l])}),current:o})}catch(l){o()&&I(l instanceof Error?l:String(l))}finally{V.current===t&&(V.current=null,oe(null),Re(!1))}},zt=E==="join"||c==="vm"&&!ee,ve=async(t=!1)=>{if(!ee)return W?ar():void 0;if(le.here)return le.setExpanded(t||le.expanded);Re(!0),I(null);try{await le.take(t)}catch(o){I(o instanceof Error?o:String(o))}finally{Re(!1)}},ln=async()=>{I(null),window.ogb?.desktopViewer?.close(r.id),await le.handBack().catch(t=>I(t instanceof Error?t:String(t)))},Tt=t=>{oe(t),I(null),F(`/api/bots/${r.id}/computer/${t}`,{method:"POST"}).then(o=>{t==="provision"&&(ae(o.container??null),o.ready?(r.computer==="cloud"&&ne({botId:r.id,threadId:r.threadId,computer:r.computer,cloudBackend:T}),N("ready")):(I(o.problem??new O("computer.err.vpsNotReady")),N("error"))),t==="sleep"&&(ne(null),ae(T==="vps"?"stopped":"archived"),N(T==="vps"?"vps-stopped":Y?"cloud-asleep":"show-sleeping-boat"))}).catch(o=>{I(o.message)}).finally(()=>oe(null))},or=()=>{oe("provision"),I(null),N("starting"),F(`/api/bots/${r.id}/computer/provision`,{method:"POST"}).then(t=>{ae(t.state??null),ne({botId:r.id,threadId:r.threadId,computer:r.computer,cloudBackend:T}),N("ready")}).catch(t=>{if(Nr(t)){N("busy-boat");return}I(t.message),N("error")}).finally(()=>oe(null))},At=async t=>{if((t==="vm-recreate"||t==="vm-delete")&&!window.confirm(t==="vm-delete"?n("computer.confirm.deleteVm",{name:r.name}):n("computer.confirm.replaceVm",{name:r.name}))||ke.current)return;const o=new AbortController;ke.current=o,oe(t),I(null),Be.current=0;try{if((t==="vm-recreate"||t==="vm-delete")&&await F(`/api/bots/${r.id}/local-computer/remove`,{method:"POST",body:"{}",signal:o.signal}),t!=="vm-delete"){const l=t==="vm-start"&&H?.mode!=="per-bot"?"/api/local-computer/start":`/api/bots/${r.id}/local-computer/${t==="vm-start"?"start":"run"}`,b=await F(l,{method:"POST",body:"{}",signal:o.signal}),z=await ks(b,()=>F(L("local-computer"),{signal:o.signal}),o.signal);if(z.container==="stopped"&&z.capacity_limited){_e(z),N("vm-unavailable");return}if(!z.ready)throw new Error(z.problem??n("computer.err.vmNotReady"));_e(z),N("vm")}else _e(l=>l&&{...l,container:"missing",ready:!1}),N("vm-unavailable")}catch(l){if(o.signal.aborted)return;I(l instanceof Error?l.message:String(l)),N("vm-unavailable")}finally{ke.current===o&&!o.signal.aborted&&(ke.current=null,oe(null),Pe(l=>l+1))}},ir=async()=>{if(window.confirm(n("computer.confirm.replaceVps",{name:r.name}))){oe("vps-replace"),I(null);try{await F(`/api/bots/${r.id}/computer/remove`,{method:"POST",body:"{}"});const t=await F(`/api/bots/${r.id}/computer/provision`,{method:"POST",body:"{}"});jt(t),ae(t.container??null),t.ready&&r.computer==="cloud"&&ne({botId:r.id,threadId:r.threadId,computer:r.computer,cloudBackend:T}),N(t.ready?"ready":"error"),t.ready||I(t.problem??new O("computer.err.vpsReplaceNotReady"))}catch(t){I(t instanceof Error?t.message:String(t)),N("error")}finally{oe(null),Pe(t=>t+1)}}},cn=()=>{window.sessionStorage.setItem("openmausbot.settings.section","computer"),m({type:"toggleAppSettings",open:!0})},dn=()=>m(gs("vps")),un=U&&(c==="vps-unconfigured"||c==="vps-stopped"||c==="vps-incompatible"),pn=U&&Y&&(c==="vps-stopped"||c==="vps-unconfigured"&&!!Xt?.configured),mn=U&&Y&&c==="vps-incompatible"&&!!Xt?.managed,Dt=Zt||u.config?.browserEngine?.installable===!0,[xn,bn]=a.useState(!1),fn=async()=>{if(!xn){bn(!0),I(null);try{if(!yn(u.config)){const t=await F("/api/config",{method:"PATCH",body:JSON.stringify({features:{browser:!0}})});m({type:"configStatus",config:t})}s.browser===!1&&m({type:"updateBot",botId:s.id,patch:{browser:!0}})}catch(t){I(t instanceof Error?t.message:n("settings.experimental.error"))}finally{bn(!1)}}},lr=()=>{I(null),m({type:"updateBot",botId:s.id,patch:{browser:!1}})},hn=e.jsxs("div",{"data-testid":"browser-switch-row",className:"mb-3 flex items-center gap-3 rounded-xl bg-card px-3 py-2.5",children:[e.jsx(Ft,{size:15,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:n("computer.browserSwitch.title",{name:r.name})}),!Dt&&e.jsx("div",{className:"text-[12px] text-ink-secondary",children:wn(u.config)})]}),e.jsx(zn,{checked:fe,disabled:xn||!fe&&!Dt,"aria-label":n("computer.browserSwitch.title",{name:r.name}),onClick:()=>fe?lr():void fn()})]}),cr=u.config?.managedPolicy,Lt=Zr(Ve,s.busy===!0),dr=!U||x!=="cloud"||T!=="box"?void 0:c==="starting"?"starting":c==="busy-boat"?Lt.spinner?"starting":Lt.line==="computer.cloud.asleep"?"asleep":"none":c==="ready"?"on":Ve==="archived"||Ve==="stopped"?"asleep":void 0,Ue=(t,o)=>ms({...xs({bot:r,place:t,seat:Fn,config:u.config,instances:u.instances,local:{ready:Wt,reason:Ut??n("computer.unavailableLocal")},...t==="cloud"?{computer:dr}:{},...t==="auto"&&we?{teamComputer:we.name}:{}}),...o?{refusal:o}:{}}),Mt=r.computer==="cloud"&&T==="box"&&c==="error"&&nt&&!(nt instanceof O)?Qr({message:be??"",status:Number(nt.status??0)||void 0},u.config?.box?.included===!0):void 0,re=Ue("cloud",Mt),je=Ue("auto"),ur=es(G),He=Ps(u.config,G).map(([t,o,l,b])=>{const z=zs(t,s.computer,G),se=Ts(t,s.cloudBackend,cr),ue=t===null?je:t==="cloud"?re:Ue(t),X=!!se||kn(ue),J=!se&&ts(ue),Ae=se??(J?ue.line:t==="browser"?n("computer.browserOnlyTitle"):void 0);return{mode:t,labelKey:o,descriptionKey:l,Icon:b,simpleLabel:ns(t??void 0,G.host.platform),selected:z,managedBy:se,disabled:X,unavailableTitle:Ae,view:ue,issue:J}}),lt=He.find(({selected:t})=>t)?.view??je,pr=t=>{if(t==="start"||t==="wake")return or();if(t==="try-again")return Pe(o=>o+1);if(t==="turn-on-browser")return void fn();if(t==="open-vm-settings")return cn();ys(t,{botId:s.id,threadId:s.threadId},m)},mr=t=>!!t&&t!=="watch"&&t!=="open-computer-panel"&&(t!=="start"&&t!=="wake"||Y&&!s.busy),qe=(t,o="mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover")=>t.action&&mr(t.action.id)?e.jsx("button",{type:"button","data-testid":"place-action",onClick:()=>pr(t.action.id),className:o,children:t.action.label}):null,gn=t=>{t===null&&s.computer===void 0||t===s.computer||(t==="local"&&vs(s)==="auto"?gt(r.id):Ie(t==="browser"?{computer:t,browser:!0}:{computer:t}))},xr=()=>{s.computer==="local"&&ur&&Ie({computer:null}),m({type:"updateTask",botId:s.id,threadId:s.threadId,patch:{surface:null}})},Ot=w&&s.computer!=="off"&&w!==s.computer?w:void 0,br=t=>K("flex shrink-0 items-center gap-1.5 rounded-full px-3 py-1 text-[13px] transition-colors @max-[28rem]/paneltabs:[&>svg]:hidden @max-[22rem]/paneltabs:px-2",t?"bg-raised text-ink shadow-sm":"text-ink-secondary hover:text-ink"),vn=t=>{t==="browser"&&I(null),st(t)},fr={checking:n("computer.phase.checking"),starting:T==="vps"?n("computer.phase.starting"):re.line,"busy-boat":re.line,unconfigured:re.line,"auto-unavailable":je.line,"team-boat":je.line,"show-ready-boat":n("computer.phase.showReadyBoat"),"show-sleeping-boat":n("computer.phase.showSleepingBoat"),"show-pending-boat":n("computer.phase.showPendingBoat"),"cloud-new":re.line,"cloud-asleep":re.line,"vps-unconfigured":n("computer.phase.vpsUnconfigured"),"vps-incompatible":n("computer.phase.vpsIncompatible"),"vps-stopped":n("computer.phase.vpsStopped"),"local-unavailable":Ut??n("computer.phase.localUnavailable"),"vm-unavailable":n("computer.phase.vmUnavailable"),browser:Ue("browser").line,off:Ue("off").line,error:r.computer==="cloud"&&(Mt||kn(re))?re.line:n("computer.phase.error")};return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:K("animate-panel-in relative flex h-full shrink-0 flex-col border-l border-hairline/40 bg-panel","max-md:absolute max-md:inset-0 max-md:z-40 max-md:w-full!"),ref:Ct,"data-computer-panel":!0,style:{width:S},children:[e.jsx("div",{ref:f,role:"separator","aria-orientation":"vertical","aria-label":n("computer.resizeAria"),"aria-valuemin":bt,"aria-valuemax":ft,"aria-valuenow":v??void 0,tabIndex:0,onKeyDown:k,onPointerDown:j,onPointerMove:y,onPointerUp:P,onPointerCancel:P,className:"absolute inset-y-0 left-0 z-10 w-1.5 cursor-col-resize hover:bg-accent/40 focus-visible:bg-accent/60 max-md:hidden"}),e.jsx("div",{...d,className:"@container/paneltabs ml-1.5 py-3 pl-2.5 pr-4",children:e.jsxs("div",{className:"relative flex min-h-7 items-center justify-center",children:[Q&&e.jsx("button",{onClick:()=>{jn(Ct.current,r.id),m({type:"toggleComputer",open:!1}),m({type:"toggleSettings",open:!0,section:"access"})},className:"absolute left-0 top-1/2 -translate-y-1/2 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink",title:n("computer.botSettings"),children:e.jsx(rs,{size:18})}),e.jsx("div",{className:"mx-9 flex min-w-0 touch-pan-x gap-0.5 overflow-x-auto whitespace-nowrap rounded-full bg-inset p-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-tour":"computer-tabs","data-testid":"computer-tabs",role:"tablist","aria-label":n("computer.tabsAria"),onWheel:ua,onKeyDown:t=>pa(t,Jt,vn),children:Jt.map(t=>{const{Icon:o,label:l,tour:b}=ca[t],z=_?t==="computer"&&fs(x)?"computer-tab-live":t==="browser"&&x==="browser"?"browser-tab-live":void 0:void 0;return e.jsxs("button",{type:"button","data-tour":b,...da(t,t===M),title:n(l),onClick:()=>vn(t),className:br(t===M),children:[e.jsx(o,{size:13})," ",n(l),z&&e.jsx("span",{className:"size-1.5 animate-pulse rounded-full bg-success",role:"img","aria-label":n("place.live"),"data-testid":z})]},t)})}),e.jsx("button",{"data-computer-panel-close":!0,onClick:()=>{jn(Ct.current,r.id),m({type:"toggleComputer",open:!1})},className:"absolute right-0 top-1/2 -translate-y-1/2 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink","aria-label":n("computer.close"),title:n("computer.close"),children:e.jsx(gr,{size:18})})]})}),M==="routines"?e.jsx("div",{...Se("routines"),className:K("min-h-0 flex-1 overflow-y-auto px-4 pb-4",Ne),children:e.jsx(js,{bot:r,routines:nn,runs:u.routineRuns,defaultRunOn:tr?"cloud":"maus"},r.id)}):M==="browser"&&fe?e.jsxs("div",{...Se("browser"),className:K("flex min-h-0 flex-1 flex-col px-4 pb-4",Ne),children:[hn,de?.place==="browser"&&e.jsx("div",{className:"-mt-1 mb-3",children:on()}),e.jsx(Rs,{bot:r,signIn:Jn,page:Qn}),be&&e.jsx("div",{role:"alert",className:"mt-2 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:be})]}):M==="browser"?e.jsxs("div",{...Se("browser"),className:K("flex-1 overflow-y-auto px-5 pb-5",Ne),"data-testid":"browser-off",children:[hn,e.jsxs("div",{className:"mt-2 flex flex-col items-center gap-3 rounded-xl bg-card px-6 py-8 text-center",children:[e.jsx(Ft,{size:22,className:"text-ink-secondary","aria-hidden":"true"}),e.jsx("div",{className:"text-[14px] font-medium text-ink",children:n("computer.browserOff.title")}),e.jsx("p",{className:"text-[12px] leading-5 text-ink-secondary",children:Dt?n("computer.browserOff.body",{name:r.name}):wn(u.config)}),be&&e.jsx("div",{role:"alert",className:"w-full rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:be})]})]}):M==="data"?e.jsx("div",{...Se("data"),className:K("flex min-h-0 flex-1 flex-col overflow-hidden",Ne),children:e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"flex flex-1 items-center justify-center text-[13px] text-ink-secondary",role:"status",children:n("data.loading")}),children:e.jsx(ha,{bot:r,requestedCard:qn},r.id)})}):M==="files"?e.jsx("div",{...Se("files"),className:K("flex min-h-0 flex-1 flex-col",Ne),children:e.jsx(Ns,{bot:r})}):M==="android"&&St?e.jsx("div",{...Se("android"),className:K("flex-1 overflow-y-auto px-4 pt-2",Ne),children:e.jsx(qs,{status:Nt})}):e.jsxs("div",{...Se("computer"),className:K("flex-1 overflow-y-auto px-5 pb-5",Ne),children:[e.jsxs("div",{className:"mb-1.5 mt-2 flex items-center justify-between text-[13px] text-ink-secondary",children:[e.jsx("span",{children:n("computer.screenOf",{name:r.name})}),we&&e.jsx("span",{className:"text-[11px]",children:je.short}),c==="local"&&e.jsx("span",{className:"text-[11px]",children:n("computer.badge.local")}),pe&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] font-medium text-ink",children:[e.jsx("span",{className:"size-1.5 rounded-full bg-success"}),n("computer.inControl")]}),c==="vm"&&!pe&&e.jsx("span",{className:"text-[11px]",children:n("vm.dest.vm")}),(c==="show-ready-boat"||c==="show-sleeping-boat"||c==="show-pending-boat")&&e.jsx("span",{className:"text-[11px]",children:n("computer.badge.autoBoat")}),U&&r.computer==="cloud"&&T==="vps"&&(c==="ready"||c==="starting")&&!pe&&e.jsx("span",{className:"text-[11px]",children:n("computer.badge.vps")})]}),e.jsx("div",{className:K("relative flex aspect-[16/10] w-full items-center justify-center overflow-hidden rounded-xl bg-card",pe&&"ring-2 ring-accent"),children:pe&&ee?e.jsx(a.Suspense,{fallback:e.jsx(A,{size:18,className:"animate-spin text-ink-secondary"}),children:e.jsx(ga,{target:ee,threadId:r.threadId,name:r.name,poster:ge,expanded:le.expanded,onExpandedChange:le.setExpanded,onHandBack:()=>{ln()},handingBack:le.handingBack,onUnreachable:()=>{le.leave(),I(new O("computer.err.openDesktop"))}})}):W||r.computer==="cloud"&&c==="starting"?e.jsx(Ws,{src:ge,name:r.name,error:Nn($n),refreshing:Bn,retry:qt,starting:c==="starting",opening:E==="join",disabled:ie,onOpen:()=>{ve()},onRetry:t=>{Te.current=0,t&&et(null),ce(null),Ee(!0),Wn(o=>o+1)}},`${r.id}:${r.threadId}:${r.computer}:${T}`):ge&&nr?e.jsxs("button",{type:"button",onClick:()=>{ve()},disabled:ie||E==="join",className:"group relative flex h-full w-full cursor-pointer items-center justify-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-wait","aria-label":n("computer.openLiveDesktopAria",{name:r.name}),title:n("computer.openLiveDesktop"),children:[e.jsx("img",{src:ge,alt:n("computer.screenOf",{name:r.name}),className:"h-full w-full object-contain transition group-hover:brightness-75 group-focus-visible:brightness-75"}),e.jsxs("span",{className:"pointer-events-none absolute right-2 top-2 flex items-center gap-1 rounded-md bg-black/70 px-2 py-1 text-[11px] font-medium text-white opacity-80 shadow-sm transition group-hover:opacity-100 group-focus-visible:opacity-100",children:[E==="join"?e.jsx(A,{size:12,className:"animate-spin"}):e.jsx(Je,{size:12}),n("computer.open")]})]}):ge?e.jsx("img",{src:ge,alt:n("computer.screenOf",{name:r.name}),className:"h-full w-full object-contain",title:c==="vm"?n("computer.watchOnly"):void 0}):e.jsxs("div",{className:"flex flex-col items-center gap-2 px-6 text-center text-ink-secondary",children:[c==="checking"||c==="starting"||c==="busy-boat"&&Lt.spinner||c==="vm"||c==="local"&&!te?e.jsx(A,{size:18,className:"animate-spin"}):c==="off"?e.jsx(mt,{size:22}):e.jsx(De,{size:22}),e.jsx("span",{className:"text-[12px]",children:we?je.line:W?n("computer.waitingFrame"):c==="ready"?n("computer.autoChooseCloudOpen"):c==="vm"?n("computer.capturingVm"):c==="local"?te?n("computer.linuxReady"):rn>=3?n("computer.needsScreenPerm"):n("computer.capturingLocal"):It?n(E==="vm-start"?"vm.setup.starting":"computer.phase.vmStopped"):fr[c]}),we&&qe(je),r.computer==="cloud"&&(c==="unconfigured"||c==="error")&&re.action?.id!=="add-boat-key"&&qe(re),c==="local"&&!te&&rn>=3&&e.jsx("button",{onClick:()=>window.ogb?.permOpenSettings?.("screen"),className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:n("computer.openSettings")}),c==="browser"&&fe&&e.jsx("button",{onClick:()=>st("browser"),className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:n("computer.openBrowserTab")}),(c==="show-ready-boat"||c==="show-sleeping-boat"||c==="show-pending-boat")&&e.jsx("button",{type:"button",onClick:()=>Ie({computer:"cloud"}),className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:c==="show-sleeping-boat"?n("computer.chooseCloudWake"):c==="show-ready-boat"?n("computer.chooseCloudOpen"):n("computer.chooseCloudManage")}),E===null&&(c==="cloud-new"||c==="cloud-asleep")&&qe(re),It&&E!=="vm-start"&&e.jsx("p",{className:"text-[12px]",children:n(H?.stop_reason==="idle"?"vm.stopped.idle":"vm.stopped.detail")}),c==="vm-unavailable"&&(Z&&It&&H.mode!=="pool"?e.jsxs("button",{onClick:()=>{At("vm-start")},disabled:E!==null,"aria-busy":E==="vm-start",className:"mt-1 flex items-center gap-1.5 rounded-lg bg-accent px-3 py-1.5 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[E==="vm-start"&&e.jsx(A,{size:13,className:"animate-spin"}),n(E==="vm-start"?"vm.setup.starting":"vm.setup.start")]}):Z&&H?.mode==="per-bot"&&H.image&&H.create_supported?e.jsxs("button",{onClick:()=>{At(H.container==="missing"?"vm-create":"vm-recreate")},disabled:E!==null,className:"mt-1 rounded-lg bg-accent px-3 py-1.5 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[(E==="vm-create"||E==="vm-recreate")&&e.jsx(A,{size:13,className:"mr-1.5 inline animate-spin"}),H.container==="missing"?n("computer.createVm",{name:r.name}):n("computer.replaceVm",{name:r.name})]}):e.jsx("button",{onClick:cn,className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:n("computer.openVmSetup")})),c==="vm-unavailable"&&H?.capacity_limited&&e.jsx("p",{className:"text-[12px] text-ink-secondary",children:ss("Máy ảo đã được tạo và đang dừng vì đã đủ số máy chạy cùng lúc. Dừng một máy khác rồi bấm Bật.","This desktop has been created and is stopped because the running limit is full. Stop another desktop, then start this one.")}),!Q&&un&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[12px]",children:n("computer.simple.needsSetup",{name:r.name})}),!pn&&!mn&&e.jsx("button",{type:"button",onClick:()=>vr(!0),className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:n("computer.simple.showAdvanced")})]}),Q&&U&&(c==="vps-unconfigured"||c==="vps-stopped")&&e.jsx("button",{onClick:dn,className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover",children:n("computer.openVpsSettings")}),pn&&e.jsxs("button",{onClick:()=>Tt("provision"),disabled:E==="provision",className:"mt-1 rounded-lg bg-control px-3 py-1.5 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[E==="provision"&&e.jsx(A,{size:13,className:"mr-1.5 inline animate-spin"}),c==="vps-stopped"?n("computer.startVps"):n("computer.prepareVps")]}),mn&&e.jsxs("button",{onClick:()=>{ir()},disabled:E==="vps-replace",className:"mt-1 rounded-lg bg-accent px-3 py-1.5 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[E==="vps-replace"&&e.jsx(A,{size:13,className:"mr-1.5 inline animate-spin"}),n("computer.replaceVps")]})]})}),be&&!Mt&&e.jsx("div",{className:"mt-2 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:be}),(Yn||c==="unconfigured"&&re.action?.id==="add-boat-key")&&e.jsx("div",{"data-boat-key":!0,className:"mt-3 rounded-xl bg-card py-1.5",children:e.jsx(as,{id:"box",via:"computer_panel",onSaved:t=>{Gn(!0),t&&Pe(o=>o+1)}})}),Q&&c==="vps-unconfigured"&&e.jsxs("div",{className:"mt-3 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"mb-3 text-[13px] text-ink-secondary",children:n("computer.vpsAliasHint")}),e.jsx("button",{onClick:dn,className:"rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover",children:n("computer.openVpsSettings")})]}),Q&&c==="vm"&&H?.mode==="per-bot"&&window.ogb?.desktopWorkspace&&i&&e.jsxs("button",{type:"button",onClick:()=>i(r.id),disabled:E!==null,className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg border border-accent/30 bg-accent/10 py-2 text-[13px] font-medium text-ink hover:bg-accent/15 disabled:opacity-50",title:n("computer.twoDesktopsTitle"),children:[e.jsx(Ms,{size:14}),n("computer.twoDesktops")]}),de&&de.place!=="browser"&&on(it&&!q.held?()=>c==="vm"||W?void ve():void sr("take"):void 0),(W||c==="vm"||we)&&q.held&&e.jsxs("div",{className:"mt-3 rounded-xl border border-accent/25 bg-accent/10 p-4",children:[e.jsxs("div",{className:"text-[13px] leading-relaxed text-ink",children:[n("computer.youHaveWheel"),W&&!ee&&` ${n(Q?"computer.useOpenDesktop":"computer.simple.useFullScreen")}`]}),e.jsxs("button",{onClick:()=>{ln()},disabled:ie||le.handingBack,className:"mt-2 flex w-full items-center justify-center gap-2 rounded-lg bg-accent py-2 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[e.jsx(Ye,{size:14}),n("computer.handBack")]})]}),Q&&c==="vm"&&(q.held||!it)&&e.jsxs("button",{onClick:()=>{ve(q.held)},disabled:ie||!ee,className:"mt-3 flex w-full items-center justify-center gap-2 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:q.held?n("computer.openLiveDesktop"):n("computer.takeControlTitle"),children:[ie?e.jsx(A,{size:14,className:"animate-spin"}):q.held?e.jsx(Je,{size:14}):e.jsx(Ye,{size:14}),n(q.held?"computer.fullScreen":"computer.takeControl")]}),Q&&Z&&c==="vm"&&H?.mode==="per-bot"&&e.jsxs("button",{onClick:()=>{At("vm-delete")},disabled:E!==null||s.busy,className:"mt-2 flex w-full items-center justify-center gap-2 rounded-lg border border-danger/30 py-2 text-[13px] text-danger hover:bg-danger/10 disabled:opacity-50",title:s.busy?n("computer.deleteVmBlocked"):n("computer.deleteVmTitle",{name:r.name}),children:[E==="vm-delete"?e.jsx(A,{size:14,className:"animate-spin"}):e.jsx(mt,{size:14}),n("computer.deleteVm")]}),!Q&&(W||c==="vm")&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2","data-testid":"computer-actions",children:[!q.held&&!it&&e.jsxs("button",{type:"button",onClick:()=>{ve()},disabled:ie||zt,className:"flex flex-auto items-center justify-center gap-2 whitespace-nowrap rounded-lg bg-accent px-3 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110 disabled:opacity-50",title:n("computer.takeControlTitle"),children:[E==="join"?e.jsx(A,{size:14,className:"animate-spin"}):e.jsx(Ye,{size:14}),n("computer.takeControl")]}),e.jsx(Qs,{held:q.held,frame:ge,name:r.name,onTakeControl:t=>{ve(t)},disabled:q.held&&zt,takeDisabled:ie||zt,error:be}),W&&Y&&(T==="vps"||Ve!=="archived")&&e.jsxs("button",{type:"button",onClick:()=>Tt("sleep"),disabled:E==="sleep"||s.busy,className:"flex flex-auto items-center justify-center gap-2 whitespace-nowrap rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:n("computer.sleepTitle"),children:[E==="sleep"?e.jsx(A,{size:14,className:"animate-spin"}):e.jsx(Cn,{size:14}),n("vm.cloud.sleep")]})]}),Q&&W&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[!q.held&&!it&&e.jsxs("button",{onClick:()=>{ve()},disabled:ie||E==="join",className:"flex flex-auto items-center justify-center gap-2 whitespace-nowrap rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:n("computer.takeControlTitle"),children:[E==="join"?e.jsx(A,{size:14,className:"animate-spin"}):e.jsx(Ye,{size:14}),n("computer.takeControl")]}),q.held&&e.jsxs("button",{onClick:()=>{ve(!0)},disabled:E==="join",className:"flex flex-auto items-center justify-center gap-2 whitespace-nowrap rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[E==="join"?e.jsx(A,{size:14,className:"animate-spin"}):ee?e.jsx(Je,{size:14}):e.jsx(De,{size:14}),n(ee?"computer.fullScreen":"computer.openLiveDesktop")]}),Y&&(T==="vps"||Ve!=="archived")&&e.jsxs("button",{onClick:()=>Tt("sleep"),disabled:E==="sleep"||s.busy,className:"flex flex-auto items-center justify-center gap-2 whitespace-nowrap rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",title:n("computer.sleepTitle"),children:[E==="sleep"?e.jsx(A,{size:14,className:"animate-spin"}):e.jsx(Cn,{size:14}),n("vm.cloud.sleep")]})]}),c!=="team-boat"&&(r.computer!==void 0||U)&&e.jsxs(e.Fragment,{children:[e.jsx(ra,{}),e.jsx(ia,{}),e.jsx(ws,{}),e.jsx(la,{})]}),Q?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-4 rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:n("computer.worksOn")}),e.jsx("p",{className:"mt-1 text-[12px] leading-5 text-ink-secondary",children:n(u.config?.cloudHome?"computer.worksOnHintCloudHome":"computer.worksOnHint")}),e.jsx(As,{options:He,onSelect:gn}),w&&e.jsx("p",{className:"mt-2 text-[12px] leading-5 text-ink-secondary","data-testid":"place-pinned-note",children:n("place.pinnedNote",{place:n(Vt(w))})}),e.jsxs("div",{className:"mt-3 border-t border-hairline/40 pt-3 text-[12px] leading-5 text-ink-secondary","aria-live":"polite","data-testid":"place-line",children:[lt.line,qe(lt,"mt-1 block font-medium text-accent hover:underline")]}),s.computer==="cloud"&&e.jsx(Ln,{compact:!0,value:T,onChange:t=>Ie({cloudBackend:t})})]}),e.jsxs("button",{type:"button",onClick:()=>st("routines"),className:"mt-4 flex w-full items-start gap-3 rounded-xl bg-card p-4 text-left hover:bg-raised",children:[e.jsx(Tn,{size:17,className:"mt-0.5 shrink-0 text-accent"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"block text-[14px] font-medium text-ink",children:[n("computer.tab.routines")," ",e.jsx("span",{className:"ml-1 text-[11px] text-ink-secondary",children:nn.length})]}),e.jsx("span",{className:K("mt-1 block truncate text-[12px]",Ke?is(Ke):"text-ink-secondary"),children:Ke?`${Ke.routineName} · ${os(Ke)}`:n("computer.routines.openTitle")})]}),e.jsx(Ds,{size:14,className:"shrink-0 text-ink-secondary rtl:-scale-x-100","aria-hidden":"true"})]})]}):e.jsxs("div",{className:"mt-4 rounded-xl bg-card p-4","data-testid":"where-works",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:n("computer.simple.whereWorks",{name:r.name})}),e.jsx("div",{role:"group","aria-label":n("computer.destinationAria"),className:"mt-3 grid grid-cols-3 gap-2",children:He.map(({mode:t,Icon:o,selected:l,disabled:b,unavailableTitle:z,simpleLabel:se,issue:ue,view:X})=>e.jsxs("button",{type:"button",disabled:b,title:z,"aria-pressed":l,onClick:()=>gn(t),className:K("flex min-w-0 flex-col items-center gap-1.5 rounded-lg border px-1.5 py-2.5 text-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-card",l?"border-accent/60 bg-accent/10 text-ink":"border-hairline/50 bg-panel/30 text-ink-secondary",b?"cursor-not-allowed opacity-50":"hover:border-accent/40 hover:bg-control/60"),children:[e.jsx(o,{size:16,className:K("shrink-0",l?"text-accent":"text-ink-secondary"),"aria-hidden":"true"}),e.jsx("span",{className:"w-full truncate text-[12px] font-medium leading-4",children:se}),ue&&e.jsx("span",{className:"w-full truncate text-[11px] leading-3 text-ink-secondary",children:X.short})]},t??"auto"))}),e.jsxs("div",{className:"mt-3 text-[12px] leading-5 text-ink-secondary","data-testid":"place-line",children:[lt.line,qe(lt,"mt-1 block font-medium text-accent hover:underline")]}),Ot&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("p",{className:"min-w-0 flex-1 text-[12px] leading-5 text-ink-secondary","data-testid":"place-pinned-note",children:n("place.pinnedNoteSimple",{place:He.find(({mode:t})=>t===Ot)?.simpleLabel??n(Vt(Ot))})}),e.jsx("button",{type:"button",disabled:!!r.busy,title:r.busy?n("place.busy"):void 0,onClick:xr,className:"shrink-0 rounded-md px-2 py-0.5 text-[12px] font-medium leading-5 text-accent-text transition-colors hover:bg-control focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-45 disabled:hover:bg-transparent","data-testid":"place-unpin",children:n("place.unpinSimple",{place:He.find(({selected:t})=>t)?.simpleLabel??n(Vt(s.computer??"auto"))})})]}),un&&e.jsx(Ks,{bot:r,backend:T,onBackend:t=>Ie({cloudBackend:t}),onAutoStart:()=>m({type:"updateBot",botId:r.id,patch:{autoStartVps:!r.autoStartVps}})})]})]})]}),e.jsx(ls,{open:Kt!==null,onCancel:()=>gt(null),onConfirm:()=>{const t=Kt;gt(null),t&&(t===r.id&&(ne(null),N("checking")),m({type:"updateBot",botId:t,patch:{computer:"local",acknowledgeLocalAuto:!0}}))}})]})}export{Oa as ComputerPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Sl,j as F,t as J,r as C,at as E,S as iy,f as su,a as nc,a9 as Tp}from"./styles-
|
|
1
|
+
import{c as Sl,j as F,t as J,r as C,at as E,S as iy,f as su,a as nc,a9 as Tp}from"./styles-DnwnyZpR.js";import{eg as gs,eh as sy,ei as Pp,ej as ny,ek as oy,bH as ry,el as nu,em as ly,en as Ap,eo as ay,n as Tr,ep as Pr,eq as cy,X as hy,P as dy,er as uy,es as Fp,u as fy,et as gy,eu as py,dr as my,Y as Cy,dG as wy,dI as vy}from"./App-CXIAAQw4.js";import{$ as by,r as Mp,K as Ep,L as to}from"./PlacesRail-bn7tEIBM.js";import{C as yy}from"./calendar-days-DU-aFzFs.js";import"./index-CdcrwTp5.js";import"./monitor-DUalxLhV.js";import"./MenuMotion-Dj4rtEj4.js";const Sy=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],xy=Sl("columns-3",Sy);const Ry=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]],ky=Sl("list-filter",Ry);const Dy=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],Ty=Sl("toggle-left",Dy);const Py=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],Ay=Sl("type",Py);function Fy({sources:t}){return t.length===0?null:F.jsx("ul",{className:"m-0 mt-1 flex max-h-10 list-none flex-wrap gap-x-4 overflow-y-auto p-0 text-[12px] text-ink-tertiary","aria-label":J("data.sources.label"),"data-testid":"sources-strip",children:t.map(e=>F.jsxs("li",{className:"flex items-baseline gap-2 py-0.5",children:[F.jsx("span",{className:"min-w-0 truncate font-mono",children:e.sqlName??e.name}),F.jsx("span",{className:"shrink-0",children:J("data.sources.rows",{count:gs(e.rowCount)})})]},e.name))})}var V={BACKSPACE:"Backspace",TAB:"Tab",ENTER:"Enter",ESCAPE:"Escape",SPACE:" ",LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown",DELETE:"Delete",F2:"F2",PAGE_UP:"PageUp",PAGE_DOWN:"PageDown",PAGE_HOME:"Home",PAGE_END:"End",A:"KeyA",C:"KeyC",D:"KeyD",V:"KeyV",X:"KeyX",Y:"KeyY",Z:"KeyZ"},My=65,Ey=67,Ly=86,Iy=68,Oy=90,By=89;function Lp(t){const{keyCode:e}=t;let i;switch(e){case My:i=V.A;break;case Ey:i=V.C;break;case Ly:i=V.V;break;case Iy:i=V.D;break;case Oy:i=V.Z;break;case By:i=V.Y;break;default:i=t.code}return i}var oc="36.2.0",Hy=':where([class^=ag-]),:where([class^=ag-]):after,:where([class^=ag-]):before{box-sizing:border-box}:where([class^=ag-]):where(button){color:inherit}:where([class^=ag-]):where(input:not([type]),input[type=text],input[type=number],input[type=tel],input[type=date],input[type=datetime-local],textarea){font-family:inherit;font-size:inherit;line-height:inherit;padding:0}:where([class^=ag-]):where(div,span,label):focus-visible{box-shadow:inset var(--ag-focus-shadow);outline:none;&:where(.invalid){box-shadow:inset var(--ag-focus-error-shadow)}}:where([class^=ag-]) ::-ms-clear{display:none}.ag-hidden{display:none!important}.ag-invisible{visibility:hidden!important}.ag-tab-guard{display:block;height:0;position:absolute;width:0}.ag-tab-guard-top{top:1px}.ag-tab-guard-bottom{bottom:1px}.ag-measurement-container{height:0;overflow:hidden;visibility:hidden;width:0}.ag-measurement-element-border{display:inline-block}.ag-measurement-element-border:before{border-left:var(--ag-internal-measurement-border);content:"";display:block}.ag-aria-description-container{border:0;clip-path:inset(50%);height:1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px;z-index:9999}.ag-popup{background-color:var(--ag-wrapper-background-color)}.ag-popup-child{max-width:min(100%,calc(100vw - 30px));top:0;z-index:5}.ag-popup-child:where(:not(.ag-tooltip-custom)){box-shadow:var(--ag-popup-shadow)}.ag-input-wrapper,.ag-picker-field-wrapper{align-items:center;display:flex;flex:1 1 auto;line-height:normal;position:relative}.ag-input-field{align-items:center;display:flex;flex-direction:row}.ag-input-field-input:where(:not([type=checkbox],[type=radio])){flex:1 1 auto;min-width:0;width:100%}.ag-styled-root{cursor:default;display:contents;line-height:normal;white-space:normal;-webkit-font-smoothing:antialiased;color:var(--ag-text-color);color-scheme:var(--ag-browser-color-scheme);font-family:var(--ag-font-family);font-size:var(--ag-font-size);font-weight:var(--ag-font-weight);--ag-indentation-level:0}:where(.ag-toolbar) .ag-react-container:where(:not(.ag-react-wrapper-block)){display:contents}:where(.ag-icon):before{align-items:center;background-color:currentcolor;color:inherit;content:"";display:flex;font-family:inherit;font-size:var(--ag-icon-size);font-style:normal;font-variant:normal;height:var(--ag-icon-size);justify-content:center;line-height:var(--ag-icon-size);-webkit-mask-size:contain;mask-size:contain;text-transform:none;width:var(--ag-icon-size)}.ag-icon{background-position:50%;background-repeat:no-repeat;background-size:contain;color:var(--ag-icon-color);display:block;height:var(--ag-icon-size);position:relative;-webkit-print-color-adjust:exact;print-color-adjust:exact;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:var(--ag-icon-size)}.ag-disabled .ag-icon,[disabled] .ag-icon{opacity:.5}.ag-icon-grip.ag-disabled,.ag-icon-grip[disabled]{opacity:.35}.ag-icon-loading{animation-duration:1s;animation-iteration-count:infinite;animation-name:spin;animation-timing-function:linear}@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.ag-resizer{pointer-events:none;position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:1}:where(.ag-resizer){&.ag-resizer-topLeft{cursor:nwse-resize;height:5px;left:0;top:0;width:5px}&.ag-resizer-top{cursor:ns-resize;height:5px;left:5px;right:5px;top:0}&.ag-resizer-topRight{cursor:nesw-resize;height:5px;right:0;top:0;width:5px}&.ag-resizer-right{bottom:5px;cursor:ew-resize;right:0;top:5px;width:5px}&.ag-resizer-bottomRight{bottom:0;cursor:nwse-resize;height:5px;right:0;width:5px}&.ag-resizer-bottom{bottom:0;cursor:ns-resize;height:5px;left:5px;right:5px}&.ag-resizer-bottomLeft{bottom:0;cursor:nesw-resize;height:5px;left:0;width:5px}&.ag-resizer-left{bottom:5px;cursor:ew-resize;left:0;top:5px;width:5px}}.ag-menu{background-color:var(--ag-menu-background-color);border:var(--ag-menu-border);border-radius:var(--ag-border-radius);box-shadow:var(--ag-menu-shadow);color:var(--ag-menu-text-color);max-height:100%;overflow-y:auto;position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none}',Ny=typeof window!="object"||!window?.document?.fonts?.forEach,Gy=!1,Hh=()=>Ny&&!0||Gy,Ss=(t,e,i,s,n,o,r=!1)=>{if(Hh())return;let l=t;s&&(l=`@layer ${CSS.escape(s).replaceAll("\\.",".")} { ${t} }`);let a=li.map.get(e);if(a||(a=[],li.map.set(e,a)),a.some(u=>u.injectedCss===l))return;const c=document.createElement("style");o&&c.setAttribute("nonce",o),c.dataset.agCss=i,c.dataset.agCssVersion=oc,c.textContent=l;const h={rawCss:t,injectedCss:l,el:c,priority:n,isParams:r};let d;for(const u of a){if(u.priority>n)break;d=u}if(d){d.el.after(c);const u=a.indexOf(d);a.splice(u+1,0,h)}else e.nodeName==="STYLE"?e.after(c):e.insertBefore(c,e.querySelector(":not(title, meta)")),a.push(h)},Ip=(t,e,i,s)=>{Ss(Hy,t,"shared",e,0,i),s?.forEach((n,o)=>n.forEach(r=>Ss(r,t,o,e,0,i)))},Wy=(t,e,i,s,n,o)=>{if(Hh())return;const r=li.grids.get(t);r?r.paramsCss=e:li.grids.set(t,{styleContainer:s,paramsCss:e}),rc(s),e&&i&&Ss(e,s,i,n,2,o,!0)},Vy=t=>{const e=li.grids.get(t)?.styleContainer;if(!e)return;li.grids.delete(t),Array.from(li.grids.values()).some(s=>s.styleContainer===e)?rc(e):(rc(e,!0),li.map.delete(e))},rc=(t,e=!1)=>{const i=new Set;for(const n of li.grids.values())n.styleContainer===t&&i.add(n.paramsCss);const s=li.map.get(t)??[];for(let n=s.length-1;n>=0;n--)(e||s[n].isParams&&!i.has(s[n].rawCss))&&(s[n].el.remove(),s.splice(n,1))},Op=()=>{const t=globalThis.agStyleInjectionVersions??(globalThis.agStyleInjectionVersions=new Map);let e=t.get(oc);return e||(e={map:new WeakMap,grids:new Map,paramsId:0},t.set(oc,e)),e},li=Op(),gi=t=>new Bp(t),Oi="$default",_y=0,Bp=class{constructor({feature:t,params:e,modeParams:i={},css:s,cssImports:n}){this.feature=t,this.css=s,this.cssImports=n,this.modeParams={[Oi]:{...i[Oi]??{},...e??{}},...i}}use(t,e,i){let s=this._inject;if(s==null){let{css:n}=this;if(n){const o=`ag-theme-${this.feature??"part"}-${++_y}`;typeof n=="function"&&(n=n()),n=`:where(.${o}) {
|
|
2
2
|
${n}
|
|
3
3
|
}
|
|
4
4
|
`;for(const r of this.cssImports??[])n=`@import url(${JSON.stringify(r)});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as W,r as s,t,j as e,a as d,C as X,X as $}from"./styles-
|
|
1
|
+
import{c as W,r as s,t,j as e,a as d,C as X,X as $}from"./styles-DnwnyZpR.js";import{c as G,D as J,t as Q}from"./desktop-connection-Dfaq6k5a.js";import{u as Y,a as Z,K as ee,R as te,C as ne,S as se}from"./MenuMotion-Dj4rtEj4.js";import{M as oe}from"./monitor-DUalxLhV.js";import{M as ie,a as re}from"./minimize-CQhJEKJt.js";import"./desktop-viewer-CF-OpSo0.js";const ae=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],le=W("clipboard",ae);function ce(u){return window.addEventListener("hashchange",u),()=>window.removeEventListener("hashchange",u)}const de=()=>location.hash;function me(){const u=s.useRef(null),o=s.useRef(null),[v,m]=s.useState(0),[x,p]=s.useState("connecting"),i=x==="connected",L=t(`desktopViewer.${x}`),[a,w]=s.useState(null),[b,S]=s.useState(!0),[f,B]=s.useState(!1),[M,P]=s.useState(""),[H,k]=s.useState(""),g=Y(a),y=Z(!b),r=g.value==="keyboard",R=s.useRef(a);R.current=a;const[j,C]=s.useState(""),O=s.useSyncExternalStore(ce,de),D=new URLSearchParams(O.slice(1)),N=D.get("target"),V=D.get("threadId");s.useEffect(()=>{k(""),C(""),w(null)},[N,V]),s.useEffect(()=>{const n=new AbortController;let l;const q=document.title;document.title=t("desktopViewer.title"),p("connecting"),G(u.current,N??"",{threadId:V,signal:n.signal,events:{connected:()=>p("connected"),disconnected:()=>p("disconnected"),clipboard:k}}).then(c=>{if(n.signal.aborted)return c.disconnect();l=c,o.current=c,c.focusOnClick=R.current===null},c=>{n.signal.aborted||p(c instanceof J&&c.invalid?"invalid":"disconnected")});const z=()=>{n.abort(),l?.disconnect()},K=c=>{c.persisted&&m(U=>U+1)};return window.addEventListener("pagehide",z),window.addEventListener("pageshow",K),()=>{z(),o.current===l&&(o.current=null),window.removeEventListener("pagehide",z),window.removeEventListener("pageshow",K),document.title=q}},[N,V,v]),s.useEffect(()=>{o.current&&(o.current.focusOnClick=a===null)},[a]),s.useEffect(()=>{const n=()=>B(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",n),()=>document.removeEventListener("fullscreenchange",n)},[]);const _=async()=>{P("");try{document.fullscreenElement?await document.exitFullscreen():await document.documentElement.requestFullscreen()}catch{P(t("desktopViewer.fullscreenFailed"))}},F=()=>{w(null),a&&document.getElementById(a)?.focus()},I=n=>requestAnimationFrame(()=>document.getElementById(n)?.focus()),T=n=>w(l=>l===n?null:n),A="transition-[width,translate,opacity] duration-[240ms] ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",E="ui-button min-h-11 rounded-xl focus-visible:outline-2 focus-visible:outline-focus";return e.jsxs("div",{className:"relative flex h-dvh overflow-hidden bg-app text-sm text-ink",style:{paddingLeft:"env(safe-area-inset-left)",paddingRight:"env(safe-area-inset-right)"},children:[e.jsx("aside",{"aria-label":t("desktopViewer.controls"),"aria-hidden":!b,inert:!b,className:d("z-10 flex shrink-0 items-center justify-center py-3",A,b?"w-[72px]":"w-0"),children:e.jsxs("div",{className:d("flex max-h-full w-14 shrink-0 flex-col items-center gap-1 overflow-y-auto rounded-2xl border border-hairline bg-panel p-1 shadow-xl",A,b?"translate-x-0 opacity-100":"-translate-x-12 opacity-0"),children:[e.jsxs("div",{className:"relative flex h-11 w-11 shrink-0 items-center justify-center text-ink-secondary",title:L,children:[e.jsx(oe,{size:20,"aria-hidden":"true"}),e.jsx("span",{className:d("absolute right-2 bottom-2 size-2 rounded-full ring-2 ring-panel",i?"bg-success":"bg-warning")})]}),e.jsx("div",{className:"my-1 h-px w-7 shrink-0 bg-hairline"}),e.jsx(h,{id:"keyboard",label:t("desktopViewer.keyboard"),icon:ee,disabled:!i,active:a==="keyboard",expanded:a==="keyboard",onClick:()=>T("keyboard")}),e.jsx(h,{id:"clipboard",label:t("desktopViewer.clipboard"),icon:le,disabled:!i,active:a==="clipboard",expanded:a==="clipboard",onClick:()=>T("clipboard")}),document.fullscreenEnabled&&e.jsx(h,{id:"fullscreen",label:t(f?"desktopViewer.exitFullscreen":"desktopViewer.fullscreen"),icon:f?ie:re,onClick:()=>{_()}}),e.jsx("div",{className:"my-1 h-px w-7 shrink-0 bg-hairline"}),e.jsx(h,{id:"retry",label:t("desktopViewer.reconnect"),icon:te,onClick:()=>{k(""),m(n=>n+1)}}),e.jsx(h,{id:"hide-controls",label:t("desktopViewer.hideControls"),icon:X,onClick:()=>{S(!1),w(null),I("show-controls")}})]})}),y.shown&&e.jsx("div",{...y.exitProps,className:d("absolute left-0 top-1/2 z-10 -translate-y-1/2 rounded-r-2xl border border-l-0 border-hairline bg-panel p-1 shadow-xl",y.className),children:e.jsx(h,{id:"show-controls",label:t("desktopViewer.showControls"),icon:ne,onClick:()=>{S(!0),I("hide-controls")}})}),e.jsxs("main",{className:d("relative flex min-w-0 flex-1 items-center justify-center overflow-hidden bg-inset",!f&&"my-2 mr-2 rounded-2xl border border-hairline",!f&&!b&&"ml-2"),children:[e.jsx("div",{id:"screen",ref:u,role:"application","aria-label":t("desktopViewer.title"),className:d("overflow-hidden",f?"h-full w-full":"h-[95%] w-[95%]")}),e.jsx("div",{className:i?"sr-only":"pointer-events-none absolute inset-x-3 top-3 flex justify-center",children:e.jsx("span",{id:"status",role:"status",className:"max-w-full rounded-full border border-hairline bg-panel/95 px-3 py-1.5 text-center text-xs text-ink-secondary shadow-sm",children:L})}),M&&e.jsx("p",{role:"alert",className:"absolute inset-x-3 bottom-3 rounded-xl border border-hairline bg-panel p-3 text-ink",children:M})]}),e.jsx("a",{id:"viewer-notice",href:"/novnc-NOTICE.txt",target:"_blank",rel:"license noopener noreferrer",title:t("desktopViewer.notice"),"aria-label":t("desktopViewer.notice"),className:"absolute bottom-2 right-2 z-10 flex min-h-6 w-11 items-center justify-center rounded-lg bg-app/80 text-[10px] text-ink-secondary hover:text-ink hover:underline",style:{marginRight:"env(safe-area-inset-right)",marginBottom:"env(safe-area-inset-bottom)"},children:"noVNC"}),g.shown&&e.jsxs("section",{...g.exitProps,"aria-label":t(r?"desktopViewer.keyboard":"desktopViewer.clipboard"),onKeyDown:n=>{n.key==="Escape"&&(n.stopPropagation(),F())},className:d("absolute left-[72px] top-1/2 z-20 max-h-[calc(100dvh-24px)] w-[min(320px,calc(100%-84px))] -translate-y-1/2 overflow-y-auto rounded-2xl border border-hairline bg-panel p-4 shadow-2xl",g.className),style:{marginLeft:"env(safe-area-inset-left)"},children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[e.jsx("h1",{className:"font-medium",children:t(r?"desktopViewer.keyboard":"desktopViewer.clipboard")}),e.jsx("button",{type:"button",title:t("desktopViewer.closePanel"),"aria-label":t("desktopViewer.closePanel"),onClick:F,className:"ui-icon-button shrink-0",children:e.jsx($,{size:18,"aria-hidden":"true"})})]}),e.jsxs("form",{onSubmit:n=>{n.preventDefault(),!(!o.current||!i||!r)&&(Q(o.current,j),C(""))},children:[e.jsx("label",{className:"mb-2 block text-xs leading-relaxed text-ink-secondary",htmlFor:r?"text":"clipboard-text",children:t(r?"desktopViewer.text":"desktopViewer.clipboardHint")}),e.jsx("textarea",{id:r?"text":"clipboard-text",className:"w-full resize-y rounded-xl border border-hairline bg-inset p-3 text-base text-ink outline-none focus:border-focus",rows:4,maxLength:r?4096:65536,autoComplete:"off",autoCapitalize:"off",spellCheck:!1,value:r?j:H,disabled:!r&&!i,onChange:n=>{const l=n.target.value;r?C(l):(k(l),i&&o.current?.clipboardPasteFrom(l))}}),r&&e.jsxs("button",{id:"send",type:"submit",className:"mt-3 flex min-h-11 w-full items-center justify-center gap-2 rounded-xl bg-accent px-3 font-medium text-accent-ink transition-opacity hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus disabled:opacity-40",disabled:!i||!j,children:[e.jsx(se,{size:16,"aria-hidden":"true"}),t("desktopViewer.send")]})]}),r&&e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-2 border-t border-hairline pt-4",children:[e.jsx("button",{className:E,disabled:!i,onClick:()=>o.current?.sendKey(65289,"Tab"),children:t("desktopViewer.keyTab")}),e.jsx("button",{className:E,disabled:!i,onClick:()=>o.current?.sendKey(65307,"Escape"),children:t("desktopViewer.keyEscape")}),e.jsx("button",{id:"ctrl-alt-del",className:d(E,"col-span-2"),disabled:!i,onClick:()=>o.current?.sendCtrlAltDel(),children:t("desktopViewer.keyCtrlAltDel")})]})]})]})}function h({id:u,label:o,icon:v,disabled:m,active:x,expanded:p,onClick:i}){return e.jsx("button",{id:u,type:"button",title:o,"aria-label":o,"aria-pressed":x,"aria-expanded":p,disabled:m,onClick:i,className:d("ui-icon-button size-11 min-h-11 shrink-0 rounded-xl focus-visible:outline-2 focus-visible:outline-focus",x?"bg-accent/15 text-accent-text hover:bg-accent/25":"text-ink-secondary hover:bg-raised-hover hover:text-ink"),children:e.jsx(v,{size:19,strokeWidth:1.75,"aria-hidden":"true"})})}export{me as DesktopViewer};
|