@seira-bot/seira 0.1.180 → 0.1.181
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-DpipGqnm.js → ActivityPanel-tZLxRHYi.js} +1 -1
- package/dist/assets/{AnnouncementsPage-GCXia4xK.js → AnnouncementsPage-BrGYAaS0.js} +1 -1
- package/dist/assets/{App-BIllYA_e.js → App-h8WTNY4l.js} +136 -136
- package/dist/assets/{AppEventEditor-DYdUkpiM.js → AppEventEditor-CLpZ2lyb.js} +1 -1
- package/dist/assets/{BotSettingsDialog-DxRMUwAP.js → BotSettingsDialog-COjDhP9V.js} +1 -1
- package/dist/assets/{BrowserPanel-Cu_GqDA1.js → BrowserPanel-D_kPeSZ3.js} +1 -1
- package/dist/assets/{BrowserProfilesManager-CL3TIl73.js → BrowserProfilesManager-haN8RgPf.js} +1 -1
- package/dist/assets/{CloudAddDialog-DUk6i4df.js → CloudAddDialog-vwGwJIYN.js} +1 -1
- package/dist/assets/{ComputerFilesPane-HvpeAXhL.js → ComputerFilesPane-DJu1k1Ap.js} +1 -1
- package/dist/assets/{ComputerPanel-CozzFQeF.js → ComputerPanel-D9bTedHq.js} +2 -2
- package/dist/assets/{DataPanel-DGqcWB1O.js → DataPanel-CsuS_ybT.js} +1 -1
- package/dist/assets/{DesktopViewer-BoBSIDfB.js → DesktopViewer-YvIV04Lf.js} +1 -1
- package/dist/assets/{EnginesSettings-D643-yZk.js → EnginesSettings-C27xDaBN.js} +1 -1
- package/dist/assets/{FilesView-b5DFlMDt.js → FilesView-Dsxj73nW.js} +1 -1
- package/dist/assets/{GrokMoveDialog-gGTLfrGg.js → GrokMoveDialog-DEgRQW9G.js} +1 -1
- package/dist/assets/{ImportDialog-Bu5X6qOF.js → ImportDialog-DLVTgN-h.js} +1 -1
- package/dist/assets/{InspectorPanel-DU7_iwQR.js → InspectorPanel-gvFj5wfe.js} +1 -1
- package/dist/assets/{KeyboardShortcutsModal-Wxnn1d66.js → KeyboardShortcutsModal-aF0vhD29.js} +1 -1
- package/dist/assets/{LiveDesktop-D9PC-iAT.js → LiveDesktop-Bca91cEb.js} +1 -1
- package/dist/assets/{LocalVmWorkspace-0YxB-I-X.js → LocalVmWorkspace-CVLDY3ws.js} +1 -1
- package/dist/assets/{MacLocalControl-DoEGcs3V.js → MacLocalControl-BeNWQ9oY.js} +1 -1
- package/dist/assets/{MarkdownFilePreview-CAlARwd0.js → MarkdownFilePreview-CYw3CQ3T.js} +1 -1
- package/dist/assets/{MenuMotion-DfjnHTCi.js → MenuMotion-CHp-hB40.js} +1 -1
- package/dist/assets/{NewBotDialog-D3i7j_KP.js → NewBotDialog-BxeQktoI.js} +1 -1
- package/dist/assets/{PhoneAppDialog-OeXLO0Wb.js → PhoneAppDialog-CIlw_m5U.js} +1 -1
- package/dist/assets/{PlacesRail-3RaNlpug.js → PlacesRail-Df-jNTHn.js} +1 -1
- package/dist/assets/PluginsPanel-CMqZcDkC.js +8 -0
- package/dist/assets/{ProIntroduction-B3phUWnc.js → ProIntroduction-D8hWm9R5.js} +1 -1
- package/dist/assets/{PublishedAppsPage-BXWDYkhG.js → PublishedAppsPage-BMn3C64O.js} +1 -1
- package/dist/assets/{RemoteAgentSettingsPanel-vgrEf5B7.js → RemoteAgentSettingsPanel-B7QJizjx.js} +1 -1
- package/dist/assets/{RoomPanel-BmXypXPv.js → RoomPanel-CyWZ4kkq.js} +1 -1
- package/dist/assets/RoutinesPage-B9kKyfFp.js +2 -0
- package/dist/assets/{ServerPairingCard-c2fKq1gh.js → ServerPairingCard-D21dP5Bc.js} +1 -1
- package/dist/assets/SettingsModal-afRPXeYI.js +2 -0
- package/dist/assets/{ShareDepartmentDialog-CJITsmAd.js → ShareDepartmentDialog-CwErWDth.js} +1 -1
- package/dist/assets/{SignedInSites-B2pCMdic.js → SignedInSites-CFyvOLSc.js} +1 -1
- package/dist/assets/{TeamFilesPage-B10cdbwa.js → TeamFilesPage-BvhXs2O5.js} +1 -1
- package/dist/assets/{TeamLibraryPanel-CRmTfBOI.js → TeamLibraryPanel-Dm8wjNB4.js} +1 -1
- package/dist/assets/{TeamMapPage-BoTNppEy.js → TeamMapPage-jCSzFPvB.js} +1 -1
- package/dist/assets/{ToolPageShell-BPd_nyJ8.js → ToolPageShell-DKZUregg.js} +1 -1
- package/dist/assets/{TriggersPage-DDxtJMT4.js → TriggersPage-wSB6z1cp.js} +1 -1
- package/dist/assets/{VisibilitySection-Cd3TZvS_.js → VisibilitySection-CFr6fOzq.js} +1 -1
- package/dist/assets/{WebhookTrigger-AJduidiC.js → WebhookTrigger-BJN-V-bx.js} +1 -1
- package/dist/assets/{WorksOnGrid-DHo10o0j.js → WorksOnGrid-B3wYro9M.js} +1 -1
- package/dist/assets/{abnfDiagram-YUKMZFIV-DnIZyeSK.js → abnfDiagram-YUKMZFIV-DRhWKTiz.js} +1 -1
- package/dist/assets/{activity-DrX2_Hm9.js → activity-l0oTqbd6.js} +1 -1
- package/dist/assets/{architectureDiagram-47P4ROYG-DHdulT2e.js → architectureDiagram-47P4ROYG-C_qnTvJF.js} +1 -1
- package/dist/assets/{blockDiagram-E7TT5TSB-BGReDH4k.js → blockDiagram-E7TT5TSB-DzLSloVY.js} +1 -1
- package/dist/assets/{c4Diagram-CRA5TL53-BV9zDZsL.js → c4Diagram-CRA5TL53-BzVViHCA.js} +1 -1
- package/dist/assets/{calendar-days-Ddhxf1PV.js → calendar-days-DFd3GKf_.js} +1 -1
- package/dist/assets/channel-B2D6cAE5.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-DAj16syq.js → chunk-2Q5K7J3B-hR-bQJHo.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-CMyoXW_3.js → chunk-5VM5RSS4-BWmBW1XC.js} +1 -1
- package/dist/assets/{chunk-7TKQ45FW--z54G8Jv.js → chunk-7TKQ45FW-DuUk7RXl.js} +1 -1
- package/dist/assets/{chunk-AW2ZBBNX-CPPbUHIj.js → chunk-AW2ZBBNX-Madgl1uv.js} +1 -1
- package/dist/assets/{chunk-FVRAUYC3-pKEz9wbK.js → chunk-FVRAUYC3-WSgsvIGA.js} +2 -2
- package/dist/assets/{chunk-HTAEGDNF-DIOqwx2X.js → chunk-HTAEGDNF-CfoPR2yG.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-BW474-Li.js → chunk-JWPE2WC7-tLRHdBom.js} +1 -1
- package/dist/assets/{chunk-KQW6MTUR-DjAEB-Df.js → chunk-KQW6MTUR-BqwuNuVY.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-CMZz2xNV.js → chunk-XXDRQBXY-BOeb8xE4.js} +1 -1
- package/dist/assets/{classDiagram-v2-K4WV4PDN-7GYDWs2n.js → classDiagram-v2-K4WV4PDN-CFeH5trZ.js} +1 -1
- package/dist/assets/{core-Dq4LUz6X.js → core-CnInZb-o.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-Dy2zOVu3.js → cose-bilkent-JH36ORCC-BEg68hhI.js} +1 -1
- package/dist/assets/{cynefin-EF2NZ3EQ-C7I3qmqf.js → cynefin-EF2NZ3EQ-B_Xq3hQ3.js} +1 -1
- package/dist/assets/{cynefinDiagram-3GCD6N5R-CsPcUXHD.js → cynefinDiagram-3GCD6N5R-DN1o2ihW.js} +1 -1
- package/dist/assets/{dagre-W4DXFKR2-DxvGlifm.js → dagre-W4DXFKR2-BFf83-nP.js} +1 -1
- package/dist/assets/{de-CrlnmnfQ.js → de-BpsYkrLY.js} +1 -1
- package/dist/assets/{desktop-connection-Df-k5QBM.js → desktop-connection-CU6jsy2e.js} +1 -1
- package/dist/assets/{diagram-2UJZ2QOL-Qz2-e2_u.js → diagram-2UJZ2QOL-_qwbS5JH.js} +1 -1
- package/dist/assets/{diagram-OVF4WLC6-D1u4ioUX.js → diagram-OVF4WLC6-9sq9EfiF.js} +1 -1
- package/dist/assets/{diagram-PFPMY2P6-DZiCtcMI.js → diagram-PFPMY2P6-Ow1v5ZhK.js} +1 -1
- package/dist/assets/{diagram-UMYRVEAY-DmVn9h1H.js → diagram-UMYRVEAY-DDTBFPls.js} +1 -1
- package/dist/assets/{diagram-YEKJPTXX-CJK2ajcB.js → diagram-YEKJPTXX-D1zZ8KqI.js} +1 -1
- package/dist/assets/{diagram-ZIFT7M5P-NoYT_JX9.js → diagram-ZIFT7M5P-C_vZWUw8.js} +1 -1
- package/dist/assets/{ebnfDiagram-VR2GEFS7-BooF3Pem.js → ebnfDiagram-VR2GEFS7-D_1GvBDx.js} +1 -1
- package/dist/assets/{elk-IJKZMXRS-4Ai0igvq.js → elk-IJKZMXRS-CV-PzspH.js} +1 -1
- package/dist/assets/{erDiagram-O2IAPWRE-CdhhzqVX.js → erDiagram-O2IAPWRE-CnKVd0av.js} +1 -1
- package/dist/assets/{es-BIPy8tP9.js → es-COLCGADa.js} +1 -1
- package/dist/assets/{file-up-Bs5NWcjw.js → file-up-Bjx5Vcmk.js} +1 -1
- package/dist/assets/{flowDiagram-OXPTDLAJ-SeyZJAiT.js → flowDiagram-OXPTDLAJ-CGJh171P.js} +1 -1
- package/dist/assets/{fr-CCbXz1Dc.js → fr-CJ1x1iRl.js} +1 -1
- package/dist/assets/{ganttDiagram-R7TSEDQI-rmA_SJlC.js → ganttDiagram-R7TSEDQI-CygoACFs.js} +1 -1
- package/dist/assets/{gitGraphDiagram-XJZIOB7I-Coc2oeHo.js → gitGraphDiagram-XJZIOB7I-ByxErzHV.js} +1 -1
- package/dist/assets/{hi-DmCL9a_Y.js → hi-BC0iO7jD.js} +1 -1
- package/dist/assets/{index-uiyAwyX1.js → index-BRfvYRb5.js} +1 -1
- package/dist/assets/{index-D69O3YiA.js → index-DQZxP2c4.js} +2 -2
- package/dist/assets/{index-C1PEx1tc.js → index-DtDQrExn.js} +3 -3
- package/dist/assets/{infoDiagram-5W2HQ5XZ-DScYPtht.js → infoDiagram-5W2HQ5XZ-BlzjfTwq.js} +1 -1
- package/dist/assets/{ishikawaDiagram-K3B6WC7H-Cf7mJB_l.js → ishikawaDiagram-K3B6WC7H-2rf_4lR_.js} +1 -1
- package/dist/assets/{it-BWkdcVfm.js → it-BIwsqdpz.js} +2 -2
- package/dist/assets/{ja-BaOL6cSA.js → ja-BJYXkO5E.js} +2 -2
- package/dist/assets/{journeyDiagram-COXZFDF6-Dtmolw3A.js → journeyDiagram-COXZFDF6-mGgPoETt.js} +1 -1
- package/dist/assets/{kanban-definition-P3RFRI5V-CSL1-s5L.js → kanban-definition-P3RFRI5V-j2hU8Bw4.js} +1 -1
- package/dist/assets/{kit-Cjq8TV0N.js → kit-qjammJR4.js} +1 -1
- package/dist/assets/{ko-ebMBLBXv.js → ko-7QtaPFvf.js} +2 -2
- package/dist/assets/{livekit-KT4NEVZO-B3DA1PsD.js → livekit-KT4NEVZO-DbFoU2r9.js} +1 -1
- package/dist/assets/{mcp-servers-DoMFsds6.js → mcp-servers-Tb2cnkiM.js} +1 -1
- package/dist/assets/{memory-BR-ujoQY.js → memory-BNaMRI5v.js} +1 -1
- package/dist/assets/{mermaid.core-BK1qxlD4.js → mermaid.core-B1mlFiOp.js} +4 -4
- package/dist/assets/{mindmap-definition-LZFPQGKD-Cb7ESZ0y.js → mindmap-definition-LZFPQGKD-C7XLkIzZ.js} +1 -1
- package/dist/assets/{minimize-msM7mbil.js → minimize-Dga3UCb8.js} +1 -1
- package/dist/assets/{monitor-DpsqT1_R.js → monitor-DMPjQDZP.js} +1 -1
- package/dist/assets/{org-library-alRyzCTE.js → org-library-IKFXm7D6.js} +1 -1
- package/dist/assets/{package-format-BFXbXHk8.js → package-format-COujx3jP.js} +1 -1
- package/dist/assets/{pegDiagram-BGZESJAR-CqmJQKhe.js → pegDiagram-BGZESJAR-BS2zKH6g.js} +1 -1
- package/dist/assets/{phones-J7mYR-fY.js → phones-CINpTjZv.js} +1 -1
- package/dist/assets/{pieDiagram-CAPJLFHJ-w_QuumOv.js → pieDiagram-CAPJLFHJ-DVAuLXem.js} +1 -1
- package/dist/assets/{pl-CSbinyb5.js → pl-CLa2ta1_.js} +2 -2
- package/dist/assets/{pt-br-BkWykL5e.js → pt-br-8RQzCbpg.js} +3 -3
- package/dist/assets/{quadrantDiagram-GDMTTRAM-248q9C3h.js → quadrantDiagram-GDMTTRAM-H7QRxmHt.js} +1 -1
- package/dist/assets/{rail-DRr_33Fe.js → rail-DNpLzOxa.js} +1 -1
- package/dist/assets/{railroadDiagram-SM67HX2B-BLzQ_5t7.js → railroadDiagram-SM67HX2B-dq6Rokc9.js} +1 -1
- package/dist/assets/{remote-desktop-panel-BPK6Q0O6.js → remote-desktop-panel-Cxv6Qt3x.js} +1 -1
- package/dist/assets/{requirementDiagram-X7JNWC4A-Bgi1TLdN.js → requirementDiagram-X7JNWC4A-BeWeL_-r.js} +1 -1
- package/dist/assets/{ru-DD01Hb1S.js → ru-CIdzvRVZ.js} +2 -2
- package/dist/assets/{sankeyDiagram-UM26HJRW-CrZgn-Cf.js → sankeyDiagram-UM26HJRW-BmJ-9lt-.js} +1 -1
- package/dist/assets/{sequenceDiagram-ZO4K6R2Y-gAwq1ZfG.js → sequenceDiagram-ZO4K6R2Y-Uuh1hEOh.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-BlXmG_DJ.js → sizeCapture-INFHLROL-mKDf6lys.js} +1 -1
- package/dist/assets/{stateDiagram-v2-TBUQTH76-CEFB1Iaq.js → stateDiagram-v2-TBUQTH76-BaEihzov.js} +1 -1
- package/dist/assets/{styles-DOJOOIp4.js → styles-3g-ZPS7M.js} +5 -5
- package/dist/assets/styles-CsrDURJH.css +1 -0
- package/dist/assets/{swimlanes-N4OXWK64-BtJmWAOz.js → swimlanes-N4OXWK64-CpP-NKGz.js} +1 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-C50Dm6LQ.js +8 -0
- package/dist/assets/{template-add-BcTS64TG.js → template-add-CHwGLPet.js} +1 -1
- package/dist/assets/{timeline-definition-YOQAKGHF-BZ270zxf.js → timeline-definition-YOQAKGHF-Ca3rjetv.js} +1 -1
- package/dist/assets/{tr-Bw35A32w.js → tr-BhclavHM.js} +1 -1
- package/dist/assets/{uk-DsPsCgp4.js → uk-Or5wmf6s.js} +1 -1
- package/dist/assets/{usecaseDiagram-VIAY4XPW-D5yZb3KQ.js → usecaseDiagram-VIAY4XPW-BuuYl689.js} +1 -1
- package/dist/assets/{vennDiagram-BLWOH2XV-OFx2qTzp.js → vennDiagram-BLWOH2XV-C__pWnnE.js} +1 -1
- package/dist/assets/{vi-DhPdzwW-.js → vi-CYbGVqh-.js} +1 -1
- package/dist/assets/{wardleyDiagram-YMQ3BMBF-DzSmrVKa.js → wardleyDiagram-YMQ3BMBF-yWcEHD-N.js} +1 -1
- package/dist/assets/{xychartDiagram-TAQBALBS-UP1H1u5V.js → xychartDiagram-TAQBALBS-CvcdOA7A.js} +1 -1
- package/dist/assets/{zh-CzC3CUQA.js → zh-iptM1e_T.js} +2 -2
- package/dist/assets/{zh-tw-DeXHnAvy.js → zh-tw-BaO1c--E.js} +2 -2
- package/dist/index.html +3 -3
- package/dist/rail.html +5 -5
- package/dist-server/container-mcp.js +18 -17
- package/dist-server/index.js +1136 -1114
- package/dist-server/openmausbot.js +182 -180
- package/dist-server/package.json +1 -1
- package/dist-server/pair-cli.js +182 -180
- package/dist-server/server/ai-pool.js +72 -0
- package/dist-server/server/cloud-connected-apps.js +33 -16
- package/dist-server/server/composio-broker-access.js +1 -1
- package/dist-server/server/composio.js +3 -2
- package/dist-server/server/config.js +5 -7
- package/dist-server/server/connector-auth-config-hint.js +5 -0
- package/dist-server/server/drivers/claude.js +14 -11
- package/dist-server/server/flatpak-host.js +5 -2
- package/dist-server/server/host/ai-pool.js +109 -0
- package/dist-server/server/host/app-suggestions.js +2 -1
- package/dist-server/server/host/limit-takeover.js +11 -4
- package/dist-server/server/index.js +33 -26
- package/dist-server/server/limit-failover.js +3 -0
- package/dist-server/server/model-selection-schema.js +9 -0
- package/dist-server/server/routes/ai-pool-patch.js +24 -0
- package/dist-server/server/routes/config.js +8 -1
- package/dist-server/server/routine-dispatch.js +21 -0
- package/dist-server/server/routines.js +4 -18
- package/dist-server/server/tailscale.js +16 -6
- package/dist-server/server/workspace-backup-http.js +2 -2
- package/dist-server/shared/limit-backup.js +1 -1
- package/dist-server/shared/settings-places.js +1 -0
- package/dist-server/shared/toolkit-card.js +1 -0
- package/dist-server/vps-container-mcp.js +18 -17
- package/dist-server/workspace-backup.worker.js +18 -17
- package/package.json +1 -1
- package/dist/assets/PluginsPanel-B5Q70eO8.js +0 -8
- package/dist/assets/RoutinesPage-CLXohizn.js +0 -2
- package/dist/assets/SettingsModal-BlX9XoBu.js +0 -2
- package/dist/assets/channel-DZM5KU--.js +0 -1
- package/dist/assets/styles-9UFSdSaJ.css +0 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-pBTtzroP.js +0 -8
package/dist/assets/{BrowserProfilesManager-CL3TIl73.js → BrowserProfilesManager-haN8RgPf.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t,r as h,j as s}from"./styles-DOJOOIp4.js";import{aj as te,u as ne,b0 as ie,b3 as ae,b4 as re,b5 as le,b6 as oe,b7 as V,aI as de,y as O,b8 as ce,b9 as me,G as ue,T as xe,g as A,A as W}from"./App-BIllYA_e.js";import{r as fe,i as ge}from"./index-C1PEx1tc.js";import{S as R}from"./SignedInSites-B2pCMdic.js";import{P as pe}from"./PlacesRail-3RaNlpug.js";function X(l){return l.map(({id:d,name:g,browser:c})=>({id:d,name:g,...c?{browser:c}:{}}))}function he(l,d){return{browserProfiles:X(d),expectedBrowserProfiles:X(l)}}function be(){return`profile-${te().replaceAll("-","")}`}function U(l,d){const g=l.filter(b=>b.browserProfile===d&&b.busy);if(!g.length)return null;const c=g.map(b=>b.name).join(", ");return g.length===1?t("settings.profiles.busyOne",{names:c}):t("settings.profiles.busyMany",{names:c})}function ye(l,d){return l&&d?{threadId:d}:{}}function Se(l,d){const g=new URLSearchParams(d).toString();return g?`${l}${l.includes("?")?"&":"?"}${g}`:l}function Ce({bot:l,onProfileChanged:d,disabled:g=!1}){const{state:c,dispatch:b,flushBotPatches:Z}=ne(),ee=h.useContext(ie),a=c.config?.browserProfiles??[],k=c.config?.browserEngine?.myChrome===!0,S=c.config?.browserEngine?.myChromeOn,q=c.config?.browserEngine?.myChromeLendable===!0,w=c.bots??[],o=l?w.find(e=>e.id===l.id)??l:void 0,[D,M]=h.useState(null),[C,p]=h.useState(!1),[v,$]=h.useState(""),[x,y]=h.useState(null),[z,B]=h.useState(!1),[N,m]=h.useState(""),j=h.useId(),i=C||g||D!==!0;h.useEffect(()=>{let e=!0;return fe().then(n=>{e&&M(ge(n))}),()=>{e=!1}},[]);const H=async e=>{if(m(e instanceof Error?e.message:t("settings.profiles.saveError")),e instanceof W&&e.status===409)try{const n=await A("/api/config");b({type:"configStatus",config:n})}catch{m(t("settings.profiles.refreshError"))}e instanceof W&&(e.status===401||e.status===403)&&M(!1)},E=async e=>{try{const n=await A("/api/config",{method:"PATCH",body:JSON.stringify(he(a,e))});return b({type:"configStatus",config:n}),!0}catch(n){return await H(n),!1}},G=async()=>{if(!(i||!v.trim()||a.length>=20)){p(!0),m("");try{await E([...a,{id:be(),name:v.trim()}])&&$("")}finally{p(!1)}}},J=async()=>{if(!(i||!x?.name.trim())){if(!a.some(e=>e.id===x.id)){m(t("settings.profiles.removed"));return}p(!0),m("");try{await E(a.map(e=>e.id===x.id?{...e,name:x.name.trim()}:e))&&y(null)}finally{p(!1)}}},Y=async e=>{if(i)return;const n=U(w,e.id);if(n)return m(n);const u=w.filter(r=>r.browserProfile===e.id),P=u.length?` ${t("settings.profiles.deleteUsers",{names:u.map(r=>r.name).join(", ")})}`:"";if(window.confirm(t("settings.profiles.confirm",{name:e.name,bots:P}))){p(!0),m("");try{await E(a.filter(r=>r.id!==e.id))&&(x?.id===e.id&&y(null),o?.browserProfile===e.id&&d?.())}finally{p(!1)}}},_=async(e,n)=>{if(!(i||(e.browser??"")===n)){p(!0),m("");try{await E(a.map(u=>u.id===e.id?{...u,browser:n==="chrome"?"chrome":void 0}:u))}finally{p(!1)}}},se=async e=>{if(!(i||!o||o.busy||e===(o.browserProfile??""))){p(!0),m("");try{await Z(o.id);const n=await A(`/api/bots/${encodeURIComponent(o.id)}`,{method:"PATCH",body:JSON.stringify({browserProfile:e||null})});b({type:"botPatched",bot:n.bot}),d?.()}catch(n){await H(n)}finally{p(!1)}}};if(D===!1)return s.jsx("p",{className:"text-[12px] text-ink-secondary",children:t("settings.profiles.ownerOnly")});const K="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",L="shrink-0 rounded-md bg-control px-2.5 py-2 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-50",f=o?.browserProfile??"",Q=a.find(e=>e.id===f),T=e=>w.filter(n=>n.browserProfile===e).map(n=>n.name),I=e=>e?.browser==="chrome"&&(k||q),F=s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeHint")}),S&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeLent",{name:S.name,device:ae(S.device)})}),S?.online===!1&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeLentOffline",{name:S.name})})]});return ee&&!o?s.jsxs(re,{label:t("settings.profiles.title"),block:"profiles",actions:s.jsx("button",{type:"button",disabled:i||a.length>=20,className:"ui-button ui-button-md rounded-full","data-profile-add":"",onClick:()=>{B(!0),$(""),m("")},children:t("settings.profiles.add")}),children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-2","aria-busy":C,children:[s.jsxs(le,{children:[!a.length&&s.jsx(oe,{children:t("settings.profiles.noneYet")}),a.map(e=>{const n=T(e.id),u=U(w,e.id),P=I(e);return x?.id===e.id?s.jsxs("form",{className:"flex items-center gap-2 px-4 py-3",onSubmit:r=>{r.preventDefault(),J()},children:[s.jsx("input",{autoFocus:!0,value:x.name,onChange:r=>y({id:e.id,name:r.target.value}),maxLength:40,required:!0,disabled:i,className:V,"aria-label":t("settings.profiles.nameAria")}),s.jsx("button",{type:"button",disabled:C,onClick:()=>y(null),className:"ui-button shrink-0",children:t("common.cancel")}),s.jsx("button",{type:"submit",disabled:i||!x.name.trim(),className:"ui-button shrink-0",children:t("common.save")})]},e.id):s.jsxs(de,{title:e.name,subtitle:n.length?t("settings.profiles.usedBy",{names:n.join(", ")}):t("settings.profiles.notInUse"),message:s.jsxs("span",{className:"flex flex-col gap-2 pt-1",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[t("settings.profiles.browserLabel"),s.jsxs(O,{size:"sm",value:e.browser??"",disabled:i,onChange:r=>{_(e,r.target.value)},"aria-label":t("settings.profiles.browserLabel"),children:[s.jsx("option",{value:"",children:t("settings.profiles.builtIn")}),s.jsx("option",{value:"chrome",disabled:!k,children:t("settings.profiles.myChrome")})]})]}),P?F:s.jsx(R,{target:{profile:e.id},sharedBy:n,disabled:i})]}),children:[s.jsx("button",{type:"button",disabled:i,onClick:()=>{y({id:e.id,name:e.name}),m("")},className:"settings-quiet cursor-pointer",children:t("settings.profiles.rename")}),s.jsx("button",{type:"button",onClick:()=>{Y(e)},disabled:i||!!u,title:u??t("settings.profiles.deleteTitle"),"aria-label":`${t("common.delete")} ${e.name}`,"data-danger":"",className:"settings-quiet cursor-pointer",children:t("common.delete")})]},e.id)})]}),a.length>=20&&s.jsx("p",{className:"px-4 text-[12px] leading-4 text-ink-secondary",children:t("settings.profiles.limit")}),N&&!z&&s.jsx("p",{role:"alert",className:"px-4 text-[12px] leading-4 text-danger",children:N})]}),z&&s.jsx(ce,{title:t("settings.profiles.addTitle"),onClose:()=>B(!1),footer:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"ui-button ui-button-md rounded-full",onClick:()=>B(!1),children:t("common.cancel")}),s.jsx("button",{type:"submit",form:`${j}-new-form`,disabled:i||!v.trim(),className:"ui-button ui-button-md ui-button-primary rounded-full",children:t("settings.profiles.add")})]}),children:s.jsxs("form",{id:`${j}-new-form`,className:"flex flex-col gap-2",onSubmit:e=>{e.preventDefault(),G().then(()=>B(!1))},children:[s.jsx(me,{label:t("settings.profiles.newName"),children:s.jsx("input",{id:`${j}-new`,value:v,onChange:e=>$(e.target.value),maxLength:40,required:!0,disabled:i,className:V})}),N&&s.jsx("p",{role:"alert",className:"text-[12px] leading-4 text-danger",children:N})]})})]}):s.jsxs("div",{className:"flex min-w-0 flex-col gap-3","aria-busy":C,children:[o&&s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:`${j}-profile`,className:"text-[12px] font-medium text-ink",children:t("settings.profiles.browserSession")}),s.jsxs(O,{className:"w-full",id:`${j}-profile`,value:f,disabled:i||o.busy,onChange:e=>{se(e.target.value)},children:[s.jsx("option",{value:"",children:t("settings.profiles.own")}),a.map(e=>s.jsx("option",{value:e.id,children:e.name},e.id)),s.jsx("option",{value:"guest",children:t("settings.profiles.temporary")}),f&&f!=="guest"&&!a.some(e=>e.id===f)?s.jsx("option",{value:f,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"):f==="guest"?t("settings.profiles.temporaryHint"):t("settings.profiles.sharedHint")}),I(Q)?s.jsxs(s.Fragment,{children:[F,!k&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeShare")})]}):(f===""||Q)&&s.jsx(R,{target:{bot:o.id},scope:ye(c.config?.team,l?.threadId),sharedBy:f?T(f):[o.name],disabled:i},`${o.id}:${f}`)]}),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(),G()},children:[s.jsx("label",{htmlFor:`${j}-new`,className:"sr-only",children:t("settings.profiles.newName")}),s.jsx("input",{id:`${j}-new`,value:v,onChange:e=>$(e.target.value),maxLength:40,required:!0,disabled:i||a.length>=20,placeholder:t("settings.profiles.newName"),className:K}),s.jsxs("button",{type:"submit",disabled:i||!v.trim()||a.length>=20,className:`${L} flex items-center gap-1`,children:[s.jsx(pe,{size:13}),t("settings.profiles.create")]})]}),a.length>=20&&s.jsx("p",{className:"text-[11px] text-ink-secondary",children:t("settings.profiles.limit")}),!k&&a.length>0&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t(q?"settings.profiles.myChromeShare":"settings.profiles.myChromeUnavailable")}),!a.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:a.map(e=>{const n=T(e.id),u=U(w,e.id),P=I(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(ue,{size:14,className:"shrink-0 text-ink-secondary"}),x?.id===e.id?s.jsxs("form",{className:"flex min-w-0 flex-1 flex-wrap gap-2",onSubmit:r=>{r.preventDefault(),J()},children:[s.jsx("input",{autoFocus:!0,value:x.name,onChange:r=>y({id:e.id,name:r.target.value}),maxLength:40,required:!0,disabled:i,className:K,"aria-label":t("settings.profiles.nameAria")}),s.jsx("button",{type:"submit",disabled:i||!x.name.trim(),className:L,children:t("common.save")}),s.jsx("button",{type:"button",disabled:C,onClick:()=>y(null),className:L,children:t("common.cancel")})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",disabled:i,onClick:()=>{y({id:e.id,name:e.name}),m("")},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:()=>{Y(e)},disabled:i||!!u,title:u??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(xe,{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(O,{size:"sm",value:e.browser??"",disabled:i,onChange:r=>{_(e,r.target.value)},children:[s.jsx("option",{value:"",children:t("settings.profiles.builtIn")}),s.jsx("option",{value:"chrome",disabled:!k,children:t("settings.profiles.myChrome")})]})]}),P?F:s.jsx(R,{target:{profile:e.id},sharedBy:n,disabled:i})]})]},e.id)})})]})]}),N&&s.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:N})]})}export{Ce as B,ye as b,Se as w};
|
|
1
|
+
import{t,r as h,j as s}from"./styles-3g-ZPS7M.js";import{aj as te,u as ne,b0 as ie,b3 as ae,b4 as re,b5 as le,b6 as oe,b7 as V,aI as de,y as O,b8 as ce,b9 as me,G as ue,T as xe,g as A,A as W}from"./App-h8WTNY4l.js";import{r as fe,i as ge}from"./index-DtDQrExn.js";import{S as R}from"./SignedInSites-CFyvOLSc.js";import{P as pe}from"./PlacesRail-Df-jNTHn.js";function X(l){return l.map(({id:d,name:g,browser:c})=>({id:d,name:g,...c?{browser:c}:{}}))}function he(l,d){return{browserProfiles:X(d),expectedBrowserProfiles:X(l)}}function be(){return`profile-${te().replaceAll("-","")}`}function U(l,d){const g=l.filter(b=>b.browserProfile===d&&b.busy);if(!g.length)return null;const c=g.map(b=>b.name).join(", ");return g.length===1?t("settings.profiles.busyOne",{names:c}):t("settings.profiles.busyMany",{names:c})}function ye(l,d){return l&&d?{threadId:d}:{}}function Se(l,d){const g=new URLSearchParams(d).toString();return g?`${l}${l.includes("?")?"&":"?"}${g}`:l}function Ce({bot:l,onProfileChanged:d,disabled:g=!1}){const{state:c,dispatch:b,flushBotPatches:Z}=ne(),ee=h.useContext(ie),a=c.config?.browserProfiles??[],k=c.config?.browserEngine?.myChrome===!0,S=c.config?.browserEngine?.myChromeOn,q=c.config?.browserEngine?.myChromeLendable===!0,w=c.bots??[],o=l?w.find(e=>e.id===l.id)??l:void 0,[D,M]=h.useState(null),[C,p]=h.useState(!1),[v,$]=h.useState(""),[x,y]=h.useState(null),[z,B]=h.useState(!1),[N,m]=h.useState(""),j=h.useId(),i=C||g||D!==!0;h.useEffect(()=>{let e=!0;return fe().then(n=>{e&&M(ge(n))}),()=>{e=!1}},[]);const H=async e=>{if(m(e instanceof Error?e.message:t("settings.profiles.saveError")),e instanceof W&&e.status===409)try{const n=await A("/api/config");b({type:"configStatus",config:n})}catch{m(t("settings.profiles.refreshError"))}e instanceof W&&(e.status===401||e.status===403)&&M(!1)},E=async e=>{try{const n=await A("/api/config",{method:"PATCH",body:JSON.stringify(he(a,e))});return b({type:"configStatus",config:n}),!0}catch(n){return await H(n),!1}},G=async()=>{if(!(i||!v.trim()||a.length>=20)){p(!0),m("");try{await E([...a,{id:be(),name:v.trim()}])&&$("")}finally{p(!1)}}},J=async()=>{if(!(i||!x?.name.trim())){if(!a.some(e=>e.id===x.id)){m(t("settings.profiles.removed"));return}p(!0),m("");try{await E(a.map(e=>e.id===x.id?{...e,name:x.name.trim()}:e))&&y(null)}finally{p(!1)}}},Y=async e=>{if(i)return;const n=U(w,e.id);if(n)return m(n);const u=w.filter(r=>r.browserProfile===e.id),P=u.length?` ${t("settings.profiles.deleteUsers",{names:u.map(r=>r.name).join(", ")})}`:"";if(window.confirm(t("settings.profiles.confirm",{name:e.name,bots:P}))){p(!0),m("");try{await E(a.filter(r=>r.id!==e.id))&&(x?.id===e.id&&y(null),o?.browserProfile===e.id&&d?.())}finally{p(!1)}}},_=async(e,n)=>{if(!(i||(e.browser??"")===n)){p(!0),m("");try{await E(a.map(u=>u.id===e.id?{...u,browser:n==="chrome"?"chrome":void 0}:u))}finally{p(!1)}}},se=async e=>{if(!(i||!o||o.busy||e===(o.browserProfile??""))){p(!0),m("");try{await Z(o.id);const n=await A(`/api/bots/${encodeURIComponent(o.id)}`,{method:"PATCH",body:JSON.stringify({browserProfile:e||null})});b({type:"botPatched",bot:n.bot}),d?.()}catch(n){await H(n)}finally{p(!1)}}};if(D===!1)return s.jsx("p",{className:"text-[12px] text-ink-secondary",children:t("settings.profiles.ownerOnly")});const K="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",L="shrink-0 rounded-md bg-control px-2.5 py-2 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-50",f=o?.browserProfile??"",Q=a.find(e=>e.id===f),T=e=>w.filter(n=>n.browserProfile===e).map(n=>n.name),I=e=>e?.browser==="chrome"&&(k||q),F=s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeHint")}),S&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeLent",{name:S.name,device:ae(S.device)})}),S?.online===!1&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeLentOffline",{name:S.name})})]});return ee&&!o?s.jsxs(re,{label:t("settings.profiles.title"),block:"profiles",actions:s.jsx("button",{type:"button",disabled:i||a.length>=20,className:"ui-button ui-button-md rounded-full","data-profile-add":"",onClick:()=>{B(!0),$(""),m("")},children:t("settings.profiles.add")}),children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-2","aria-busy":C,children:[s.jsxs(le,{children:[!a.length&&s.jsx(oe,{children:t("settings.profiles.noneYet")}),a.map(e=>{const n=T(e.id),u=U(w,e.id),P=I(e);return x?.id===e.id?s.jsxs("form",{className:"flex items-center gap-2 px-4 py-3",onSubmit:r=>{r.preventDefault(),J()},children:[s.jsx("input",{autoFocus:!0,value:x.name,onChange:r=>y({id:e.id,name:r.target.value}),maxLength:40,required:!0,disabled:i,className:V,"aria-label":t("settings.profiles.nameAria")}),s.jsx("button",{type:"button",disabled:C,onClick:()=>y(null),className:"ui-button shrink-0",children:t("common.cancel")}),s.jsx("button",{type:"submit",disabled:i||!x.name.trim(),className:"ui-button shrink-0",children:t("common.save")})]},e.id):s.jsxs(de,{title:e.name,subtitle:n.length?t("settings.profiles.usedBy",{names:n.join(", ")}):t("settings.profiles.notInUse"),message:s.jsxs("span",{className:"flex flex-col gap-2 pt-1",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[t("settings.profiles.browserLabel"),s.jsxs(O,{size:"sm",value:e.browser??"",disabled:i,onChange:r=>{_(e,r.target.value)},"aria-label":t("settings.profiles.browserLabel"),children:[s.jsx("option",{value:"",children:t("settings.profiles.builtIn")}),s.jsx("option",{value:"chrome",disabled:!k,children:t("settings.profiles.myChrome")})]})]}),P?F:s.jsx(R,{target:{profile:e.id},sharedBy:n,disabled:i})]}),children:[s.jsx("button",{type:"button",disabled:i,onClick:()=>{y({id:e.id,name:e.name}),m("")},className:"settings-quiet cursor-pointer",children:t("settings.profiles.rename")}),s.jsx("button",{type:"button",onClick:()=>{Y(e)},disabled:i||!!u,title:u??t("settings.profiles.deleteTitle"),"aria-label":`${t("common.delete")} ${e.name}`,"data-danger":"",className:"settings-quiet cursor-pointer",children:t("common.delete")})]},e.id)})]}),a.length>=20&&s.jsx("p",{className:"px-4 text-[12px] leading-4 text-ink-secondary",children:t("settings.profiles.limit")}),N&&!z&&s.jsx("p",{role:"alert",className:"px-4 text-[12px] leading-4 text-danger",children:N})]}),z&&s.jsx(ce,{title:t("settings.profiles.addTitle"),onClose:()=>B(!1),footer:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"ui-button ui-button-md rounded-full",onClick:()=>B(!1),children:t("common.cancel")}),s.jsx("button",{type:"submit",form:`${j}-new-form`,disabled:i||!v.trim(),className:"ui-button ui-button-md ui-button-primary rounded-full",children:t("settings.profiles.add")})]}),children:s.jsxs("form",{id:`${j}-new-form`,className:"flex flex-col gap-2",onSubmit:e=>{e.preventDefault(),G().then(()=>B(!1))},children:[s.jsx(me,{label:t("settings.profiles.newName"),children:s.jsx("input",{id:`${j}-new`,value:v,onChange:e=>$(e.target.value),maxLength:40,required:!0,disabled:i,className:V})}),N&&s.jsx("p",{role:"alert",className:"text-[12px] leading-4 text-danger",children:N})]})})]}):s.jsxs("div",{className:"flex min-w-0 flex-col gap-3","aria-busy":C,children:[o&&s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:`${j}-profile`,className:"text-[12px] font-medium text-ink",children:t("settings.profiles.browserSession")}),s.jsxs(O,{className:"w-full",id:`${j}-profile`,value:f,disabled:i||o.busy,onChange:e=>{se(e.target.value)},children:[s.jsx("option",{value:"",children:t("settings.profiles.own")}),a.map(e=>s.jsx("option",{value:e.id,children:e.name},e.id)),s.jsx("option",{value:"guest",children:t("settings.profiles.temporary")}),f&&f!=="guest"&&!a.some(e=>e.id===f)?s.jsx("option",{value:f,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"):f==="guest"?t("settings.profiles.temporaryHint"):t("settings.profiles.sharedHint")}),I(Q)?s.jsxs(s.Fragment,{children:[F,!k&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t("settings.profiles.myChromeShare")})]}):(f===""||Q)&&s.jsx(R,{target:{bot:o.id},scope:ye(c.config?.team,l?.threadId),sharedBy:f?T(f):[o.name],disabled:i},`${o.id}:${f}`)]}),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(),G()},children:[s.jsx("label",{htmlFor:`${j}-new`,className:"sr-only",children:t("settings.profiles.newName")}),s.jsx("input",{id:`${j}-new`,value:v,onChange:e=>$(e.target.value),maxLength:40,required:!0,disabled:i||a.length>=20,placeholder:t("settings.profiles.newName"),className:K}),s.jsxs("button",{type:"submit",disabled:i||!v.trim()||a.length>=20,className:`${L} flex items-center gap-1`,children:[s.jsx(pe,{size:13}),t("settings.profiles.create")]})]}),a.length>=20&&s.jsx("p",{className:"text-[11px] text-ink-secondary",children:t("settings.profiles.limit")}),!k&&a.length>0&&s.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:t(q?"settings.profiles.myChromeShare":"settings.profiles.myChromeUnavailable")}),!a.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:a.map(e=>{const n=T(e.id),u=U(w,e.id),P=I(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(ue,{size:14,className:"shrink-0 text-ink-secondary"}),x?.id===e.id?s.jsxs("form",{className:"flex min-w-0 flex-1 flex-wrap gap-2",onSubmit:r=>{r.preventDefault(),J()},children:[s.jsx("input",{autoFocus:!0,value:x.name,onChange:r=>y({id:e.id,name:r.target.value}),maxLength:40,required:!0,disabled:i,className:K,"aria-label":t("settings.profiles.nameAria")}),s.jsx("button",{type:"submit",disabled:i||!x.name.trim(),className:L,children:t("common.save")}),s.jsx("button",{type:"button",disabled:C,onClick:()=>y(null),className:L,children:t("common.cancel")})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",disabled:i,onClick:()=>{y({id:e.id,name:e.name}),m("")},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:()=>{Y(e)},disabled:i||!!u,title:u??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(xe,{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(O,{size:"sm",value:e.browser??"",disabled:i,onChange:r=>{_(e,r.target.value)},children:[s.jsx("option",{value:"",children:t("settings.profiles.builtIn")}),s.jsx("option",{value:"chrome",disabled:!k,children:t("settings.profiles.myChrome")})]})]}),P?F:s.jsx(R,{target:{profile:e.id},sharedBy:n,disabled:i})]})]},e.id)})})]})]}),N&&s.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:N})]})}export{Ce as B,ye as b,Se as w};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,O as q,Q as ve,R as $,t as n,T as se,U as Y,V as G,W as Pe,Y as pe,Z as Ce,$ as He,a0 as fe,a1 as Ue,a2 as Ee,a3 as ze,a4 as qe,a5 as $e,a6 as X,a as ue,a7 as Me,a8 as We,a9 as Ke,r as i,aa as Ve,ab as Qe,ac as we,ad as z,ae as Xe,X as Ye,af as Ge,ag as Je,ah as Ze,ai as et,aj as tt,ak as Ae,al as nt}from"./styles-DOJOOIp4.js";import{L as st,k as at,C as lt,l as ot,m as rt,n as it,S as dt,o as ct,p as ut}from"./PlacesRail-3RaNlpug.js";import{u as pt}from"./App-BIllYA_e.js";import"./placement-BKtVnQht.js";import"./monitor-DpsqT1_R.js";import"./index-C1PEx1tc.js";import"./MenuMotion-DfjnHTCi.js";function ft({name:t,color:l,busy:o,interest:r,openFailed:s,onInterest:p,onOpen:f}){return e.jsxs("div",{"data-cloud-add":"has-cloud",className:q,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(ve,{color:l,size:32}),e.jsx($,{title:n("cloudBuy.one.title"),sub:n("cloudBuy.one.sub",{name:t})})]}),e.jsxs("div",{className:se,children:[r!=="sent"&&e.jsx("button",{type:"button",className:Y,disabled:o,onClick:p,children:n("cloudBuy.one.email")}),e.jsx("button",{type:"button",className:G,disabled:o,onClick:f,children:n("cloudBuy.setup.open",{name:t})})]}),e.jsxs("div",{"aria-live":"polite",className:"text-[13px] leading-[18px] empty:-mt-5",children:[r==="sent"&&e.jsx("p",{className:"text-ink-secondary",children:n("cloudBuy.one.thanks")}),r==="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 ce({kind:t,line:l,onRetry:o,onClose:r}){return e.jsxs("div",{"data-cloud-add":t,className:q,children:[e.jsx($,{title:n("cloudAdd.title")}),l?e.jsx("p",{role:"alert",className:"text-[14px] leading-5 text-ink",children:l}):e.jsxs("p",{role:"status",className:"flex items-center gap-2 text-[13px] leading-[18px] text-ink-secondary",children:[e.jsx(st,{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:Y,onClick:r,children:n("cloudAdd.close")}),o&&e.jsx("button",{type:"button",className:G,onClick:o,children:n("cloudAdd.tryAgain")})]})]})}function mt({plan:t,offer:l,browser:o,late:r,link:s,email:p,busy:f,copied:v,failed:N,onReopen:k,onCopy:T,onChangePlan:M}){const y=l?.plans.find(W=>W.tier===t)??null,E=y?Pe(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?He(y,E):E;return e.jsxs("div",{"data-cloud-add":r?"waiting-late":o==="signin"?"waiting-signin":"waiting",className:q,children:[e.jsx($,{title:r?n("cloudBuy.pay.lateTitle"):n("cloudAdd.browserTitle"),sub:r?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:p},{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:r?G:Y,disabled:f,onClick:k,children:[e.jsx(at,{size:14,"aria-hidden":"true"}),n("cloudAdd.reopenCheckout")]}),s&&e.jsxs("button",{type:"button",className:Y,disabled:f,onClick:T,children:[e.jsx(lt,{size:14,"aria-hidden":"true"}),n("cloudBuy.pay.copy")]}),e.jsx("button",{type:"button",className:`${Ue} ms-1 px-1 py-1`,onClick:M,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 P=[["reserving","cloudHome.step.reserving"],["storage","cloudHome.step.storage"],["starting","cloudBuy.step.starting"],["checking","cloudHome.step.checking"]];function xt({tier:t,trial:l,credit:o},r){if(r)return n("cloudAdd.receivedTitle");const s=pe(t??l?.tier??void 0);return l?o?n("cloudBuy.setup.badgeCredit",{plan:s,credit:Ke(o.grantedUsd)}):n("cloudBuy.setup.badgeTrial",{plan:s}):n("cloudBuy.setup.badgePaid",{plan:s})}function yt({started:t,received:l,step:o,slow:r,ready:s,sleeps:p=!1,name:f,typed:v,color:N,counting:k,busy:T,openFailed:M,onName:y,onColor:E,onOpen:A,onNotNow:W}){const D=s?P.length:Math.max(0,P.findIndex(([d])=>d===o)),C=pe(t.tier??t.trial?.tier??void 0);return e.jsxs("div",{"data-cloud-add":s?"ready":l?"received":"starting","data-cloud-setup":s?"ready":o??"reserving",className:q,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(ze,{children:xt(t,l)}),e.jsx($,{title:s?n("cloudBuy.ready.title",{name:f}):n("cloudBuy.setup.title"),sub:s?n("cloudBuy.ready.sub"):l?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(Ee,{value:D/P.length,label:n("cloudBuy.setup.progress")}),e.jsx(fe,{label:n("cloudBuy.setup.progress"),items:P.map(([d,w],j)=>({key:d,title:n(w,{name:f}),state:j<D?"done":j===D?"now":"next"}))}),r&&!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:$e,placeholder:n("cloudSetup.myCloud"),autoComplete:"off",spellCheck:!1,onChange:d=>y(d.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:X.map(d=>e.jsx("button",{type:"button",role:"radio","aria-checked":d===N,"aria-label":n(We[d]),tabIndex:d===N?0:-1,"data-color":d,onClick:()=>E(d),onKeyDown:w=>{const j=X.indexOf(d),K=w.key==="ArrowRight"||w.key==="ArrowDown"?1:w.key==="ArrowLeft"||w.key==="ArrowUp"?-1:0;if(!K)return;w.preventDefault();const J=X[(j+K+X.length)%X.length];E(J),w.currentTarget.parentElement?.querySelector(`[data-color="${J}"]`)?.focus()},style:{background:Me(d)},className:ue("size-[26px] rounded-lg border-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",d===N?"border-ink shadow-[inset_0_0_0_2px_var(--color-app)]":"border-transparent")},d))})]}),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:f}),e.jsx("span",{className:"block truncate text-[12px] text-ink-tertiary",children:n(p?"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:f})}),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:Y,onClick:W,children:n("notice.notNow")}),e.jsx("button",{type:"button",className:G,disabled:!s||T,onClick:A,children:n("cloudBuy.setup.open",{name:f})})]}),M&&e.jsx("p",{role:"alert",className:"-mt-2 text-end text-[13px] leading-[18px] text-danger",children:n("cloudBuy.openFailed",{name:f})})]})}function gt({team:t,step:l,slow:o}){const r=Math.max(0,P.findIndex(([p])=>p===l)),s=t??n("cloudBuy.team.unnamed");return e.jsxs("div",{"data-cloud-add":"team-starting","data-cloud-setup":l??"reserving",className:q,children:[e.jsx($,{title:n("cloudBuy.team.setupTitle"),sub:n("cloudBuy.team.setupSub")}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ee,{value:r/P.length,label:n("cloudBuy.setup.progress")}),e.jsx(fe,{label:n("cloudBuy.setup.progress"),items:P.map(([p,f],v)=>({key:p,title:n(f,{name:s}),state:v<r?"done":v===r?"now":"next"}))}),o&&e.jsx("p",{role:"status",className:"px-3 text-[13px] leading-[18px] text-ink-secondary",children:n("cloudHome.slow")})]})]})}function ht({name:t,busy:l,openFailed:o,onOpen:r}){return e.jsxs("div",{"data-cloud-add":"team-ready",className:q,children:[e.jsx($,{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:G,disabled:l,onClick:r,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 bt({view:t,ui:l,actions:o}){switch(t.kind){case"checking":return e.jsx(ce,{kind:"checking",line:null,onClose:o.close});case"unreachable":return e.jsx(ce,{kind:"unreachable",line:n("cloudAdd.unreachable"),onRetry:o.retry,onClose:o.close});case"error":return e.jsx(ce,{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:l.current,now:l.now,busy:l.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(dt,{phase:t.phase,email:l.email,code:l.code,profileEmail:l.profileEmail,busy:l.busy,now:l.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(it,{code:t.code,checkout:t.checkout,busy:l.busy,trial:l.offerShown?!!Ae(l.offerShown,l.chosen).trialDays:!1,onReopen:o.reopenBrowser,onCancel:o.cancelSignIn});case"waiting":return e.jsx(mt,{plan:t.plan,offer:l.offerShown,browser:t.browser,late:t.late,link:t.link,email:t.email,busy:l.busy,copied:l.copied,failed:l.payFailed,onReopen:o.reopenCheckout,onCopy:o.copyLink,onChangePlan:o.changePlan});case"starting":case"ready":return e.jsx(yt,{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:tt(t,l.offerShown),name:l.look.name,typed:l.look.typed,color:l.look.color,counting:l.counting,busy:l.busy,openFailed:l.openFailed,onName:o.name,onColor:o.color,onOpen:o.openCloud,onNotNow:o.notNow});case"has-cloud":return e.jsx(ft,{name:l.look.name,color:l.look.color,busy:l.busy,interest:l.interest,openFailed:l.openFailed,onInterest:o.interest,onOpen:o.openCloud});case"team-starting":return e.jsx(gt,{team:t.team,step:t.step,slow:t.slow});case"team-ready":return e.jsx(ht,{name:t.team.name,busy:l.busy,openFailed:l.openFailed,onOpen:()=>o.openTeam(t.team.id)});case"settings":return null}}const kt={offer:"max-w-[920px]",starting:"max-w-[720px]",ready:"max-w-[720px]"},jt=new Set(["sign-in","signing-in","waiting","starting","team-starting"]);function Be({kind:t,staging:l,onClose:o,children:r}){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.target===s.currentTarget&&!jt.has(t)&&o(),children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"cloud-add-title","data-cloud-add-dialog":!0,tabIndex:-1,className:ue(et,"group/sheet animate-pop-in relative max-h-full w-full overflow-y-auto overscroll-contain outline-none",kt[t]??"max-w-[540px]"),children:[e.jsx("button",{type:"button",onClick:o,"aria-label":n("cloudAdd.close"),className:ue(Je,Ge,"absolute end-4 top-4 z-10"),children:e.jsx(Ye,{size:16})}),l&&e.jsx(Ze,{className:"absolute end-14 top-[22px] z-10 group-has-[[data-night-card]]/sheet:bg-app"}),r]})})}const St=["offer","checking","unreachable","waiting","sign-in","signing-in"],Nt="button:not([disabled]):not([tabindex='-1']), input:not([disabled]):not([tabindex='-1']), [href], [tabindex='0']",Ct=t=>t.status==="connected"&&t.entitlement?.plan==="free"&&!t.purchase&&!t.machine,wt=t=>t?.status==="connected"&&t.entitlement?.plan==="pro"&&t.entitlement.status==="active"?t.entitlement.tier??"pro":null;function Ot({now:t=Date.now}){const{state:l,dispatch:o}=pt(),r=l.cloudAdd,s=window.ogb?.remoteClient?.active?void 0:window.ogb?.cloudAccount,[p,f]=i.useState(null),[v,N]=i.useState(void 0),[k,T]=i.useState(null),[M,y]=i.useState(null),[E,A]=i.useState(!1),[W,D]=i.useState(!1),[C,d]=i.useState(!1),[w,j]=i.useState(!1),[K,J]=i.useState(0),[Z,me]=i.useState([]),[h,g]=i.useState(null),[I,O]=i.useState({email:"",code:""}),[B,ee]=i.useState(null),[F,H]=i.useState(null),[U,S]=i.useState(null),[,Le]=i.useState(0),[xe,ae]=i.useState(!1),[Te,le]=i.useState(!1),[Ie,Oe]=i.useState(!1),L=!!(r&&s),oe=l.config?.profile?.email?.trim()||null,re=rt();i.useEffect(()=>{if(!L||!s)return;let a=!0,c=!1;const b=s.onState(m=>{c=!0,a&&f(m)});return s.state().then(m=>{a&&!c&&f(m)}).catch(()=>{}),()=>{a=!1,b()}},[L,s]);const x=L?Ve(p,v,{now:t(),error:M,choosing:W,conflict:E,signIn:h,arrived:xe,terms:Te}):null,ye=L&&x&&St.includes(x.kind)&&p?`${p.status}:${JSON.stringify(p.offer??null)}:${K}`:null;i.useEffect(()=>{if(!ye||!s?.offer)return;let a=!0;return s.offer().then(c=>{a&&N(c)},()=>{a&&N(null)}),()=>{a=!1}},[ye,s]);const ie=n("cloudSetup.myCloud"),V={typed:B?.typed??ie,color:B?.color??we,name:Qe(B?.typed??ie,ie)},_=()=>{h&&s?.signInCancel?.().catch(()=>{}),o({type:"closeCloudAdd"}),y(null),A(!1),D(!1),j(!1),me([]),T(null),g(null),O({email:"",code:""}),ee(null),H(null),S(null),ae(!1),le(!1)};i.useEffect(()=>{if(!L)return;const a=document.activeElement,c=a&&a!==document.body&&typeof a.focus=="function"?a:null;r?.signIn&&(g({step:"email",intent:!1,problem:null}),O({email:oe??"",code:""}));const b=m=>{if(m.key==="Escape"){m.preventDefault(),_();return}if(m.key!=="Tab")return;const R=[...document.querySelector("[data-cloud-add-dialog]")?.querySelectorAll(Nt)??[]];if(!R.length)return;m.preventDefault();const Ne=R.indexOf(document.activeElement);R[Ne===-1?0:(Ne+(m.shiftKey?-1:1)+R.length)%R.length].focus()};return window.addEventListener("keydown",b,!0),(document.querySelector("#cloud-add-title")??document.querySelector("[data-cloud-add-dialog]"))?.focus(),()=>{window.removeEventListener("keydown",b,!0),c?.isConnected&&c.focus()}},[L]),i.useEffect(()=>{if(!(!L||!s?.sheet||re))return s.sheet(!0).catch(()=>{}),()=>{s.sheet?.(!1).catch(()=>{})}},[L,s,re]);const u=x?.kind??null,te=x?.kind==="sign-in"?`sign-in-${x.phase.step}`:u;i.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]),i.useEffect(()=>{(u==="waiting"||u==="starting"||u==="ready")&&!xe&&ae(!0),(u==="ready"||u==="team-ready")&&s?.readySeen?.().catch(()=>{})},[u]),i.useEffect(()=>{if(!u||!r)return;if(u==="settings"){_(),o({type:"toggleAppSettings",open:!0,section:"cloudAccount"});return}if(u==="checking")return;const a=Z.length===0;a&&z("cloud_dialog_shown",{source:r.source,view:u}),["starting","ready"].includes(u)&&!Z.includes(u)&&z("cloud_dialog_view",{view:u}),(a||!Z.includes(u))&&me([...Z,u])},[u]),i.useEffect(()=>{if(!u||!["starting","ready","has-cloud"].includes(u)||B||!s?.look)return;let a=!0;return s.look().then(c=>{a&&ee({typed:c.name,color:Xe(c.color)??we,dirty:u!=="has-cloud"})},()=>{}),()=>{a=!1}},[u]),i.useEffect(()=>{if(!B?.dirty||!s?.setLook)return;const a=setTimeout(()=>{s.setLook?.(V.name,B.color).catch(()=>{})},400);return()=>clearTimeout(a)},[B?.typed,B?.color]),i.useEffect(()=>{u!=="ready"||F!==null||H(!re&&typeof document.hasFocus=="function"&&document.hasFocus()?3:"off")},[u]);const ge=h?.step==="code"?h.resendAt:0;i.useEffect(()=>{if(!ge||ge<=t())return;const a=setTimeout(()=>Le(t()),1e3);return()=>clearTimeout(a)}),i.useEffect(()=>{if(U!=="copied")return;const a=setTimeout(()=>S(null),2500);return()=>clearTimeout(a)},[U]);const ne=a=>{C||(d(!0),j(!1),a().catch(()=>y("failed")).finally(()=>d(!1)))},he=()=>{C||!s||(d(!0),j(!1),H("done"),(async()=>{B?.dirty&&s.setLook&&await s.setLook(V.name,B.color).catch(()=>{}),await s.connectHome()})().then(()=>_(),()=>j(!0)).finally(()=>d(!1)))},Fe=a=>{C||!s?.openTeam||(d(!0),j(!1),s.openTeam(a).then(()=>_(),()=>j(!0)).finally(()=>d(!1)))};i.useEffect(()=>{if(typeof F!="number")return;const a=setTimeout(()=>{F>1?H(F-1):he()},1e3);return()=>clearTimeout(a)},[F]);const be=typeof F=="number";if(i.useEffect(()=>{if(!be)return;const a=()=>H("off");return window.addEventListener("blur",a),()=>window.removeEventListener("blur",a)},[be]),!L||!x||!r||!s||x.kind==="settings")return null;if(x.kind==="has-cloud"&&p?.status==="connected"&&p.clouds&&window.ogb?.cloudAdd&&(p.addCloud?.canAdd!==!1||p.adding&&!p.adding.done))return e.jsx(Be,{kind:Ie?"offer":"has-cloud",staging:p.staging===!0,onClose:_,children:e.jsx(ot,{onClose:_,onFirstCloud:()=>{},onWide:Oe,source:r.source})});const Q=v??null,ke=()=>x.kind==="waiting"&&!k?x.plan:Q?Ae(Q,k).tier:null,de=async a=>{if(!a||!s.checkout){y("failed");return}const c=!!Q?.plans.find(R=>R.tier===a)?.trialDays,b=await s.checkout(a,r.source),m=b.outcome;f(b.state),m==="opened"||m==="signing-in"?(D(!1),y(null),A(!1),S(null),le(!1),z("cloud_checkout_opened",{plan:a,trial:c,source:r.source})):m==="rate-limited"?y("rate-limited"):m==="failed"?y("failed"):A(!0)},je=a=>{g({step:"email",intent:a,problem:null}),O({email:I.email||oe||"",code:""})},Se=()=>{if(C||!s.signInStart||!h||h.step==="done")return;const a=h;d(!0),s.signInStart(I.email).then(c=>{c.outcome==="sent"?(g({step:"code",intent:a.intent,email:c.email,resendAt:c.resendAt,problem:null,triesLeft:null,...c.signupOpen===!1?{signupOpen:!1}:{}}),O({email:c.email,code:""}),z("cloud_signin",{step:"code_sent",source:r.source})):g({...a,problem:c.outcome})},()=>g({...a,problem:"failed"})).finally(()=>d(!1))},_e=a=>{if(!s.signInVerify||h?.step!=="code")return;const c=h,b=c.intent?ke():null;d(!0),(async()=>{try{const m=await s.signInVerify(a);if(m.outcome!=="signed-in"){O({email:I.email,code:""}),g({...c,problem:m.outcome,triesLeft:m.outcome==="wrong-code"?m.triesLeft:null});return}f(m.state),ae(!0),z("cloud_signin",{step:"signed_in",source:r.source}),b&&Ct(m.state)&&(nt(Q,m.state.offer,b)?(g({step:"done",intent:!0}),await de(b)):(le(!0),T(b))),g(null),O({email:I.email,code:""})}catch{g({...c,problem:"failed",triesLeft:null})}finally{d(!1)}})()},De={start:a=>{if(T(a),A(!1),x.kind==="offer"&&x.signedOut&&s.signInStart){je(!0);return}ne(()=>de(a))},signIn:()=>je(!1),back:()=>{g(null),s.signInCancel?.().catch(()=>{})},email:a=>O({email:a,code:I.code}),sendCode:Se,changeEmail:()=>{h&&(g({step:"email",intent:h.intent,problem:null}),s.signInCancel?.().catch(()=>{}))},code:a=>{const c=ut(a);O({email:I.email,code:c}),c.length===8&&!C&&_e(c)},resend:Se,browser:()=>ne(async()=>{const a=h?.intent?ke():null;g(null),await s.signInCancel?.().catch(()=>{}),z("cloud_signin",{step:"browser",source:r.source}),a?await de(a):f(await s.begin())}),reopenBrowser:()=>ne(async()=>f(await s.reopen())),cancelSignIn:()=>ne(async()=>f(await s.cancel())),reopenCheckout:()=>{if(x.kind!=="waiting"||C)return;d(!0),S(null),(s.reopenCheckout?s.reopenCheckout(x.plan,r.source):s.checkout(x.plan,r.source)).then(c=>{f(c.state),c.outcome!=="opened"&&S("pay-failed")},()=>S("pay-failed")).finally(()=>d(!1))},copyLink:()=>{s.copyCheckoutLink?.().then(a=>S(a?"copied":"pay-failed"),()=>S("pay-failed"))},changePlan:()=>{T(x.kind==="waiting"?x.plan:k),D(!0),S(null)},retry:()=>{y(null),A(!1),N(void 0),J(K+1)},name:a=>ee({typed:a,color:V.color,dirty:!0}),color:a=>ee({typed:V.typed,color:a,dirty:!0}),openCloud:he,openTeam:Fe,notNow:()=>H("off"),interest:()=>{C||!s.interest||(d(!0),s.interest().then(()=>S("interest-sent"),()=>S("interest-failed")).finally(()=>d(!1)))},close:_},Re={chosen:k,current:wt(p),offerShown:Q,now:t(),busy:C,openFailed:w,email:I.email,code:I.code,profileEmail:oe,look:V,counting:typeof F=="number"?F:null,copied:U==="copied",payFailed:U==="pay-failed",interest:U==="interest-sent"?"sent":U==="interest-failed"?"failed":null};return e.jsx(Be,{kind:x.kind,staging:p?.staging===!0,onClose:_,children:e.jsx(bt,{view:x,ui:Re,actions:De})})}export{Ot as CloudAddDialog,bt as CloudAddPanel,Be as CloudAddSheet};
|
|
1
|
+
import{j as e,O as q,Q as ve,R as $,t as n,T as se,U as Y,V as G,W as Pe,Y as pe,Z as Ce,$ as He,a0 as fe,a1 as Ue,a2 as Ee,a3 as ze,a4 as qe,a5 as $e,a6 as X,a as ue,a7 as Me,a8 as We,a9 as Ke,r as i,aa as Ve,ab as Qe,ac as we,ad as z,ae as Xe,X as Ye,af as Ge,ag as Je,ah as Ze,ai as et,aj as tt,ak as Ae,al as nt}from"./styles-3g-ZPS7M.js";import{L as st,k as at,C as lt,l as ot,m as rt,n as it,S as dt,o as ct,p as ut}from"./PlacesRail-Df-jNTHn.js";import{u as pt}from"./App-h8WTNY4l.js";import"./placement-BKtVnQht.js";import"./monitor-DMPjQDZP.js";import"./index-DtDQrExn.js";import"./MenuMotion-CHp-hB40.js";function ft({name:t,color:l,busy:o,interest:r,openFailed:s,onInterest:p,onOpen:f}){return e.jsxs("div",{"data-cloud-add":"has-cloud",className:q,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(ve,{color:l,size:32}),e.jsx($,{title:n("cloudBuy.one.title"),sub:n("cloudBuy.one.sub",{name:t})})]}),e.jsxs("div",{className:se,children:[r!=="sent"&&e.jsx("button",{type:"button",className:Y,disabled:o,onClick:p,children:n("cloudBuy.one.email")}),e.jsx("button",{type:"button",className:G,disabled:o,onClick:f,children:n("cloudBuy.setup.open",{name:t})})]}),e.jsxs("div",{"aria-live":"polite",className:"text-[13px] leading-[18px] empty:-mt-5",children:[r==="sent"&&e.jsx("p",{className:"text-ink-secondary",children:n("cloudBuy.one.thanks")}),r==="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 ce({kind:t,line:l,onRetry:o,onClose:r}){return e.jsxs("div",{"data-cloud-add":t,className:q,children:[e.jsx($,{title:n("cloudAdd.title")}),l?e.jsx("p",{role:"alert",className:"text-[14px] leading-5 text-ink",children:l}):e.jsxs("p",{role:"status",className:"flex items-center gap-2 text-[13px] leading-[18px] text-ink-secondary",children:[e.jsx(st,{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:Y,onClick:r,children:n("cloudAdd.close")}),o&&e.jsx("button",{type:"button",className:G,onClick:o,children:n("cloudAdd.tryAgain")})]})]})}function mt({plan:t,offer:l,browser:o,late:r,link:s,email:p,busy:f,copied:v,failed:N,onReopen:k,onCopy:T,onChangePlan:M}){const y=l?.plans.find(W=>W.tier===t)??null,E=y?Pe(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?He(y,E):E;return e.jsxs("div",{"data-cloud-add":r?"waiting-late":o==="signin"?"waiting-signin":"waiting",className:q,children:[e.jsx($,{title:r?n("cloudBuy.pay.lateTitle"):n("cloudAdd.browserTitle"),sub:r?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:p},{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:r?G:Y,disabled:f,onClick:k,children:[e.jsx(at,{size:14,"aria-hidden":"true"}),n("cloudAdd.reopenCheckout")]}),s&&e.jsxs("button",{type:"button",className:Y,disabled:f,onClick:T,children:[e.jsx(lt,{size:14,"aria-hidden":"true"}),n("cloudBuy.pay.copy")]}),e.jsx("button",{type:"button",className:`${Ue} ms-1 px-1 py-1`,onClick:M,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 P=[["reserving","cloudHome.step.reserving"],["storage","cloudHome.step.storage"],["starting","cloudBuy.step.starting"],["checking","cloudHome.step.checking"]];function xt({tier:t,trial:l,credit:o},r){if(r)return n("cloudAdd.receivedTitle");const s=pe(t??l?.tier??void 0);return l?o?n("cloudBuy.setup.badgeCredit",{plan:s,credit:Ke(o.grantedUsd)}):n("cloudBuy.setup.badgeTrial",{plan:s}):n("cloudBuy.setup.badgePaid",{plan:s})}function yt({started:t,received:l,step:o,slow:r,ready:s,sleeps:p=!1,name:f,typed:v,color:N,counting:k,busy:T,openFailed:M,onName:y,onColor:E,onOpen:A,onNotNow:W}){const D=s?P.length:Math.max(0,P.findIndex(([d])=>d===o)),C=pe(t.tier??t.trial?.tier??void 0);return e.jsxs("div",{"data-cloud-add":s?"ready":l?"received":"starting","data-cloud-setup":s?"ready":o??"reserving",className:q,children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(ze,{children:xt(t,l)}),e.jsx($,{title:s?n("cloudBuy.ready.title",{name:f}):n("cloudBuy.setup.title"),sub:s?n("cloudBuy.ready.sub"):l?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(Ee,{value:D/P.length,label:n("cloudBuy.setup.progress")}),e.jsx(fe,{label:n("cloudBuy.setup.progress"),items:P.map(([d,w],j)=>({key:d,title:n(w,{name:f}),state:j<D?"done":j===D?"now":"next"}))}),r&&!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:$e,placeholder:n("cloudSetup.myCloud"),autoComplete:"off",spellCheck:!1,onChange:d=>y(d.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:X.map(d=>e.jsx("button",{type:"button",role:"radio","aria-checked":d===N,"aria-label":n(We[d]),tabIndex:d===N?0:-1,"data-color":d,onClick:()=>E(d),onKeyDown:w=>{const j=X.indexOf(d),K=w.key==="ArrowRight"||w.key==="ArrowDown"?1:w.key==="ArrowLeft"||w.key==="ArrowUp"?-1:0;if(!K)return;w.preventDefault();const J=X[(j+K+X.length)%X.length];E(J),w.currentTarget.parentElement?.querySelector(`[data-color="${J}"]`)?.focus()},style:{background:Me(d)},className:ue("size-[26px] rounded-lg border-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",d===N?"border-ink shadow-[inset_0_0_0_2px_var(--color-app)]":"border-transparent")},d))})]}),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:f}),e.jsx("span",{className:"block truncate text-[12px] text-ink-tertiary",children:n(p?"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:f})}),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:Y,onClick:W,children:n("notice.notNow")}),e.jsx("button",{type:"button",className:G,disabled:!s||T,onClick:A,children:n("cloudBuy.setup.open",{name:f})})]}),M&&e.jsx("p",{role:"alert",className:"-mt-2 text-end text-[13px] leading-[18px] text-danger",children:n("cloudBuy.openFailed",{name:f})})]})}function gt({team:t,step:l,slow:o}){const r=Math.max(0,P.findIndex(([p])=>p===l)),s=t??n("cloudBuy.team.unnamed");return e.jsxs("div",{"data-cloud-add":"team-starting","data-cloud-setup":l??"reserving",className:q,children:[e.jsx($,{title:n("cloudBuy.team.setupTitle"),sub:n("cloudBuy.team.setupSub")}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ee,{value:r/P.length,label:n("cloudBuy.setup.progress")}),e.jsx(fe,{label:n("cloudBuy.setup.progress"),items:P.map(([p,f],v)=>({key:p,title:n(f,{name:s}),state:v<r?"done":v===r?"now":"next"}))}),o&&e.jsx("p",{role:"status",className:"px-3 text-[13px] leading-[18px] text-ink-secondary",children:n("cloudHome.slow")})]})]})}function ht({name:t,busy:l,openFailed:o,onOpen:r}){return e.jsxs("div",{"data-cloud-add":"team-ready",className:q,children:[e.jsx($,{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:G,disabled:l,onClick:r,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 bt({view:t,ui:l,actions:o}){switch(t.kind){case"checking":return e.jsx(ce,{kind:"checking",line:null,onClose:o.close});case"unreachable":return e.jsx(ce,{kind:"unreachable",line:n("cloudAdd.unreachable"),onRetry:o.retry,onClose:o.close});case"error":return e.jsx(ce,{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:l.current,now:l.now,busy:l.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(dt,{phase:t.phase,email:l.email,code:l.code,profileEmail:l.profileEmail,busy:l.busy,now:l.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(it,{code:t.code,checkout:t.checkout,busy:l.busy,trial:l.offerShown?!!Ae(l.offerShown,l.chosen).trialDays:!1,onReopen:o.reopenBrowser,onCancel:o.cancelSignIn});case"waiting":return e.jsx(mt,{plan:t.plan,offer:l.offerShown,browser:t.browser,late:t.late,link:t.link,email:t.email,busy:l.busy,copied:l.copied,failed:l.payFailed,onReopen:o.reopenCheckout,onCopy:o.copyLink,onChangePlan:o.changePlan});case"starting":case"ready":return e.jsx(yt,{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:tt(t,l.offerShown),name:l.look.name,typed:l.look.typed,color:l.look.color,counting:l.counting,busy:l.busy,openFailed:l.openFailed,onName:o.name,onColor:o.color,onOpen:o.openCloud,onNotNow:o.notNow});case"has-cloud":return e.jsx(ft,{name:l.look.name,color:l.look.color,busy:l.busy,interest:l.interest,openFailed:l.openFailed,onInterest:o.interest,onOpen:o.openCloud});case"team-starting":return e.jsx(gt,{team:t.team,step:t.step,slow:t.slow});case"team-ready":return e.jsx(ht,{name:t.team.name,busy:l.busy,openFailed:l.openFailed,onOpen:()=>o.openTeam(t.team.id)});case"settings":return null}}const kt={offer:"max-w-[920px]",starting:"max-w-[720px]",ready:"max-w-[720px]"},jt=new Set(["sign-in","signing-in","waiting","starting","team-starting"]);function Be({kind:t,staging:l,onClose:o,children:r}){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.target===s.currentTarget&&!jt.has(t)&&o(),children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"cloud-add-title","data-cloud-add-dialog":!0,tabIndex:-1,className:ue(et,"group/sheet animate-pop-in relative max-h-full w-full overflow-y-auto overscroll-contain outline-none",kt[t]??"max-w-[540px]"),children:[e.jsx("button",{type:"button",onClick:o,"aria-label":n("cloudAdd.close"),className:ue(Je,Ge,"absolute end-4 top-4 z-10"),children:e.jsx(Ye,{size:16})}),l&&e.jsx(Ze,{className:"absolute end-14 top-[22px] z-10 group-has-[[data-night-card]]/sheet:bg-app"}),r]})})}const St=["offer","checking","unreachable","waiting","sign-in","signing-in"],Nt="button:not([disabled]):not([tabindex='-1']), input:not([disabled]):not([tabindex='-1']), [href], [tabindex='0']",Ct=t=>t.status==="connected"&&t.entitlement?.plan==="free"&&!t.purchase&&!t.machine,wt=t=>t?.status==="connected"&&t.entitlement?.plan==="pro"&&t.entitlement.status==="active"?t.entitlement.tier??"pro":null;function Ot({now:t=Date.now}){const{state:l,dispatch:o}=pt(),r=l.cloudAdd,s=window.ogb?.remoteClient?.active?void 0:window.ogb?.cloudAccount,[p,f]=i.useState(null),[v,N]=i.useState(void 0),[k,T]=i.useState(null),[M,y]=i.useState(null),[E,A]=i.useState(!1),[W,D]=i.useState(!1),[C,d]=i.useState(!1),[w,j]=i.useState(!1),[K,J]=i.useState(0),[Z,me]=i.useState([]),[h,g]=i.useState(null),[I,O]=i.useState({email:"",code:""}),[B,ee]=i.useState(null),[F,H]=i.useState(null),[U,S]=i.useState(null),[,Le]=i.useState(0),[xe,ae]=i.useState(!1),[Te,le]=i.useState(!1),[Ie,Oe]=i.useState(!1),L=!!(r&&s),oe=l.config?.profile?.email?.trim()||null,re=rt();i.useEffect(()=>{if(!L||!s)return;let a=!0,c=!1;const b=s.onState(m=>{c=!0,a&&f(m)});return s.state().then(m=>{a&&!c&&f(m)}).catch(()=>{}),()=>{a=!1,b()}},[L,s]);const x=L?Ve(p,v,{now:t(),error:M,choosing:W,conflict:E,signIn:h,arrived:xe,terms:Te}):null,ye=L&&x&&St.includes(x.kind)&&p?`${p.status}:${JSON.stringify(p.offer??null)}:${K}`:null;i.useEffect(()=>{if(!ye||!s?.offer)return;let a=!0;return s.offer().then(c=>{a&&N(c)},()=>{a&&N(null)}),()=>{a=!1}},[ye,s]);const ie=n("cloudSetup.myCloud"),V={typed:B?.typed??ie,color:B?.color??we,name:Qe(B?.typed??ie,ie)},_=()=>{h&&s?.signInCancel?.().catch(()=>{}),o({type:"closeCloudAdd"}),y(null),A(!1),D(!1),j(!1),me([]),T(null),g(null),O({email:"",code:""}),ee(null),H(null),S(null),ae(!1),le(!1)};i.useEffect(()=>{if(!L)return;const a=document.activeElement,c=a&&a!==document.body&&typeof a.focus=="function"?a:null;r?.signIn&&(g({step:"email",intent:!1,problem:null}),O({email:oe??"",code:""}));const b=m=>{if(m.key==="Escape"){m.preventDefault(),_();return}if(m.key!=="Tab")return;const R=[...document.querySelector("[data-cloud-add-dialog]")?.querySelectorAll(Nt)??[]];if(!R.length)return;m.preventDefault();const Ne=R.indexOf(document.activeElement);R[Ne===-1?0:(Ne+(m.shiftKey?-1:1)+R.length)%R.length].focus()};return window.addEventListener("keydown",b,!0),(document.querySelector("#cloud-add-title")??document.querySelector("[data-cloud-add-dialog]"))?.focus(),()=>{window.removeEventListener("keydown",b,!0),c?.isConnected&&c.focus()}},[L]),i.useEffect(()=>{if(!(!L||!s?.sheet||re))return s.sheet(!0).catch(()=>{}),()=>{s.sheet?.(!1).catch(()=>{})}},[L,s,re]);const u=x?.kind??null,te=x?.kind==="sign-in"?`sign-in-${x.phase.step}`:u;i.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]),i.useEffect(()=>{(u==="waiting"||u==="starting"||u==="ready")&&!xe&&ae(!0),(u==="ready"||u==="team-ready")&&s?.readySeen?.().catch(()=>{})},[u]),i.useEffect(()=>{if(!u||!r)return;if(u==="settings"){_(),o({type:"toggleAppSettings",open:!0,section:"cloudAccount"});return}if(u==="checking")return;const a=Z.length===0;a&&z("cloud_dialog_shown",{source:r.source,view:u}),["starting","ready"].includes(u)&&!Z.includes(u)&&z("cloud_dialog_view",{view:u}),(a||!Z.includes(u))&&me([...Z,u])},[u]),i.useEffect(()=>{if(!u||!["starting","ready","has-cloud"].includes(u)||B||!s?.look)return;let a=!0;return s.look().then(c=>{a&&ee({typed:c.name,color:Xe(c.color)??we,dirty:u!=="has-cloud"})},()=>{}),()=>{a=!1}},[u]),i.useEffect(()=>{if(!B?.dirty||!s?.setLook)return;const a=setTimeout(()=>{s.setLook?.(V.name,B.color).catch(()=>{})},400);return()=>clearTimeout(a)},[B?.typed,B?.color]),i.useEffect(()=>{u!=="ready"||F!==null||H(!re&&typeof document.hasFocus=="function"&&document.hasFocus()?3:"off")},[u]);const ge=h?.step==="code"?h.resendAt:0;i.useEffect(()=>{if(!ge||ge<=t())return;const a=setTimeout(()=>Le(t()),1e3);return()=>clearTimeout(a)}),i.useEffect(()=>{if(U!=="copied")return;const a=setTimeout(()=>S(null),2500);return()=>clearTimeout(a)},[U]);const ne=a=>{C||(d(!0),j(!1),a().catch(()=>y("failed")).finally(()=>d(!1)))},he=()=>{C||!s||(d(!0),j(!1),H("done"),(async()=>{B?.dirty&&s.setLook&&await s.setLook(V.name,B.color).catch(()=>{}),await s.connectHome()})().then(()=>_(),()=>j(!0)).finally(()=>d(!1)))},Fe=a=>{C||!s?.openTeam||(d(!0),j(!1),s.openTeam(a).then(()=>_(),()=>j(!0)).finally(()=>d(!1)))};i.useEffect(()=>{if(typeof F!="number")return;const a=setTimeout(()=>{F>1?H(F-1):he()},1e3);return()=>clearTimeout(a)},[F]);const be=typeof F=="number";if(i.useEffect(()=>{if(!be)return;const a=()=>H("off");return window.addEventListener("blur",a),()=>window.removeEventListener("blur",a)},[be]),!L||!x||!r||!s||x.kind==="settings")return null;if(x.kind==="has-cloud"&&p?.status==="connected"&&p.clouds&&window.ogb?.cloudAdd&&(p.addCloud?.canAdd!==!1||p.adding&&!p.adding.done))return e.jsx(Be,{kind:Ie?"offer":"has-cloud",staging:p.staging===!0,onClose:_,children:e.jsx(ot,{onClose:_,onFirstCloud:()=>{},onWide:Oe,source:r.source})});const Q=v??null,ke=()=>x.kind==="waiting"&&!k?x.plan:Q?Ae(Q,k).tier:null,de=async a=>{if(!a||!s.checkout){y("failed");return}const c=!!Q?.plans.find(R=>R.tier===a)?.trialDays,b=await s.checkout(a,r.source),m=b.outcome;f(b.state),m==="opened"||m==="signing-in"?(D(!1),y(null),A(!1),S(null),le(!1),z("cloud_checkout_opened",{plan:a,trial:c,source:r.source})):m==="rate-limited"?y("rate-limited"):m==="failed"?y("failed"):A(!0)},je=a=>{g({step:"email",intent:a,problem:null}),O({email:I.email||oe||"",code:""})},Se=()=>{if(C||!s.signInStart||!h||h.step==="done")return;const a=h;d(!0),s.signInStart(I.email).then(c=>{c.outcome==="sent"?(g({step:"code",intent:a.intent,email:c.email,resendAt:c.resendAt,problem:null,triesLeft:null,...c.signupOpen===!1?{signupOpen:!1}:{}}),O({email:c.email,code:""}),z("cloud_signin",{step:"code_sent",source:r.source})):g({...a,problem:c.outcome})},()=>g({...a,problem:"failed"})).finally(()=>d(!1))},_e=a=>{if(!s.signInVerify||h?.step!=="code")return;const c=h,b=c.intent?ke():null;d(!0),(async()=>{try{const m=await s.signInVerify(a);if(m.outcome!=="signed-in"){O({email:I.email,code:""}),g({...c,problem:m.outcome,triesLeft:m.outcome==="wrong-code"?m.triesLeft:null});return}f(m.state),ae(!0),z("cloud_signin",{step:"signed_in",source:r.source}),b&&Ct(m.state)&&(nt(Q,m.state.offer,b)?(g({step:"done",intent:!0}),await de(b)):(le(!0),T(b))),g(null),O({email:I.email,code:""})}catch{g({...c,problem:"failed",triesLeft:null})}finally{d(!1)}})()},De={start:a=>{if(T(a),A(!1),x.kind==="offer"&&x.signedOut&&s.signInStart){je(!0);return}ne(()=>de(a))},signIn:()=>je(!1),back:()=>{g(null),s.signInCancel?.().catch(()=>{})},email:a=>O({email:a,code:I.code}),sendCode:Se,changeEmail:()=>{h&&(g({step:"email",intent:h.intent,problem:null}),s.signInCancel?.().catch(()=>{}))},code:a=>{const c=ut(a);O({email:I.email,code:c}),c.length===8&&!C&&_e(c)},resend:Se,browser:()=>ne(async()=>{const a=h?.intent?ke():null;g(null),await s.signInCancel?.().catch(()=>{}),z("cloud_signin",{step:"browser",source:r.source}),a?await de(a):f(await s.begin())}),reopenBrowser:()=>ne(async()=>f(await s.reopen())),cancelSignIn:()=>ne(async()=>f(await s.cancel())),reopenCheckout:()=>{if(x.kind!=="waiting"||C)return;d(!0),S(null),(s.reopenCheckout?s.reopenCheckout(x.plan,r.source):s.checkout(x.plan,r.source)).then(c=>{f(c.state),c.outcome!=="opened"&&S("pay-failed")},()=>S("pay-failed")).finally(()=>d(!1))},copyLink:()=>{s.copyCheckoutLink?.().then(a=>S(a?"copied":"pay-failed"),()=>S("pay-failed"))},changePlan:()=>{T(x.kind==="waiting"?x.plan:k),D(!0),S(null)},retry:()=>{y(null),A(!1),N(void 0),J(K+1)},name:a=>ee({typed:a,color:V.color,dirty:!0}),color:a=>ee({typed:V.typed,color:a,dirty:!0}),openCloud:he,openTeam:Fe,notNow:()=>H("off"),interest:()=>{C||!s.interest||(d(!0),s.interest().then(()=>S("interest-sent"),()=>S("interest-failed")).finally(()=>d(!1)))},close:_},Re={chosen:k,current:wt(p),offerShown:Q,now:t(),busy:C,openFailed:w,email:I.email,code:I.code,profileEmail:oe,look:V,counting:typeof F=="number"?F:null,copied:U==="copied",payFailed:U==="pay-failed",interest:U==="interest-sent"?"sent":U==="interest-failed"?"failed":null};return e.jsx(Be,{kind:x.kind,staging:p?.staging===!0,onClose:_,children:e.jsx(bt,{view:x,ui:Re,actions:De})})}export{Ot as CloudAddDialog,bt as CloudAddPanel,Be as CloudAddSheet};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,t as a,a as N,r as R}from"./styles-DOJOOIp4.js";import{aJ as F,aK as L,v as z,S as A,aL as b,aM as y,aN as M,aO as P,aP as w,a7 as j,aQ as B,aR as E,aS as O,u as S,o as T,F as $,aT as v,aU as D,aV as H,aW as I,aX as W,aY as U,aZ as X}from"./App-BIllYA_e.js";import{a as J,R as K}from"./RoutinesPage-CLXohizn.js";import{L as Q,P as V,c as Y}from"./PlacesRail-3RaNlpug.js";import{C as Z}from"./MenuMotion-DfjnHTCi.js";function _({routines:s,runs:r,bots:x,pausedBots:c,heldBots:o,loading:d,error:i,unreadable:n,onOpen:p,onLogs:u,onToggle:m}){const h=[...s].sort((t,l)=>Number(l.enabled)-Number(t.enabled)||(t.nextRunAt??1/0)-(l.nextRunAt??1/0)||t.name.localeCompare(l.name));return e.jsxs("div",{className:"space-y-3","aria-label":a("routines.list"),children:[i&&e.jsx("div",{role:"alert",className:"rounded-lg bg-danger/10 p-3 text-[12px] text-danger",children:a("routines.loadError")}),n&&e.jsx("div",{role:"alert",className:"rounded-lg bg-danger/10 p-3 text-[12px] leading-relaxed text-danger","data-routines-unreadable":"",children:a("routines.unreadable")}),d&&e.jsxs("p",{role:"status",className:"flex items-center gap-2 p-3 text-[12px] text-ink-secondary",children:[e.jsx(Q,{size:14,className:"animate-spin"}),a("routines.loading")]}),!d&&!i&&!n&&h.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(J,{size:20,className:"mx-auto mb-2 opacity-60"}),a("routines.empty")]}),h.map(t=>{const l=F(t.id,r),k=l&&(l.attention?"attention":l.error?"error":l.output?"output":null),f=x?.find(C=>C.id===t.botId),g=m!==void 0&&!L(t);return e.jsxs("article",{className:"rounded-xl border border-hairline/40 bg-card p-3.5","aria-label":t.name,children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>p(t),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:t.name}),e.jsxs("span",{className:"mt-1 block text-[12px] leading-relaxed text-ink-secondary",children:[f&&`${f.name} · `,z(t.schedule)]})]}),g?e.jsx(A,{checked:t.enabled,"aria-label":a("routines.toggle",{name:t.name}),onClick:()=>m(t)}):e.jsx("span",{className:N("shrink-0 rounded-full bg-inset px-2 py-0.5 text-[10px]",t.enabled&&t.nextRunAt!=null?"text-accent":"text-ink-secondary"),children:b(t)})]}),(g||y(t)!==b(t))&&e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:y(t)}),e.jsxs("div",{className:"mt-1 flex items-start justify-between gap-2",children:[e.jsx("div",{className:"min-w-0 text-[12px]",children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:P(l),children:a("routines.latestRun",{status:M(l)})}),e.jsx("span",{className:"block text-[11px] text-ink-secondary",children:w(l.finishedAt??l.startedAt??l.scheduledFor)})]}):e.jsx("span",{className:"text-ink-secondary",children:a("routines.neverRun")})}),e.jsxs("button",{type:"button",onClick:()=>u(t),"aria-label":a("routines.logsFor",{name:t.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(j,{size:12}),a("routines.logs")]})]}),l&&k&&e.jsx("p",{className:N("mt-2 line-clamp-2 whitespace-pre-wrap text-[12px] leading-relaxed",l.error?"text-danger":"text-ink-secondary"),children:B(l,k)}),!!t.failureStreak&&e.jsx("p",{className:"mt-2 text-[12px] text-danger",children:a("routines.failureStreak",{count:t.failureStreak})}),!!t.noStartStreak&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-warning","data-routine-no-start":"",children:a("routines.noStartStreak",{count:t.noStartStreak})}),t.weekRuns&&e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:a(t.weekRuns.total===1?"routines.weekRunsOne":"routines.weekRuns",t.weekRuns)}),t.warning&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-warning",children:t.warning}),t.enabled&&c?.includes(t.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")})]}),t.enabled&&o?.includes(t.botId)&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-warning","data-routine-bot-held":"",children:a("routines.botHeld")}),t.heldFor&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:O(t)}),!!t.skippedRuns&&e.jsxs("p",{className:"mt-2 text-[12px] text-ink-secondary",children:[a("routines.skippedRuns",{count:t.skippedRuns}),t.lastSkippedAt!=null&&e.jsxs(e.Fragment,{children:[" · ",a("routines.lastSkipped",{date:w(t.lastSkippedAt)})]})]})]},t.id)})]})}function re({bot:s,routines:r,runs:x,defaultRunOn:c}){const{state:o,dispatch:d}=S(),[i,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(T,{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(V,{size:14}),a("computer.routines.create")]}),e.jsxs("button",{type:"button",onClick:()=>d({type:"showRoutines",section:"logs",botId:s.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(j,{size:13}),a("routines.logs")]})]})]}),e.jsx(_,{routines:r,runs:x,pausedBots:o.config?.pausedBots,heldBots:o.config?.heldBots,loading:o.routinesLoadState==="loading"&&r.length===0,error:o.routinesLoadState==="error",unreadable:o.config?.routinesUnreadable,onOpen:n,onLogs:p=>d({type:"showRoutines",section:"logs",botId:s.id,routineId:p.id}),onToggle:p=>d({type:"updateRoutine",routineId:p.id,patch:{enabled:!p.enabled}})}),e.jsxs("button",{type:"button",onClick:()=>d({type:"showRoutines",section:"schedule",view:"list",botId:s.id}),className:"self-start text-[12px] text-accent hover:underline",children:[a("computer.routines.openTitle")," ",e.jsx(Z,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]}),i&&e.jsx(K,{routine:i==="new"?void 0:i,bots:[s],lockedBotId:s.id,defaultRunOn:c,onClose:()=>n(null)},s.id)]})}const q=20;function G(s,r=q){const x=new Set,c=[],o=I(s);for(let d=o.length-1;d>=0&&c.length<r;d-=1){const i=o[d].digest?.files;if(i){for(const n of i.deleted)x.add(n);for(const n of[...i.added,...i.changed])if(!x.has(n)&&(x.add(n),c.push(n),c.length>=r))break}}return c}function ee(s){const r=new Map,x=s.tasks?.find(n=>n.threadId===s.threadId),c=x?.cwd===void 0?s.cwd:x.cwd,o=c&&(/^[a-z]:[\\/]/i.test(c)||c.startsWith("\\\\")),d=n=>o?n.replace(/\\/g,"/"):n,i=typeof c=="string"?`${d(c).replace(/\/+$/,"")}/`:void 0;for(const n of[...I(s)].reverse()){if(n.role!=="bot"||n.kind!=="text")continue;const p=W(n.attachments),u=[...p.files,...U(n.text??"",[...p.images,...p.files.map(m=>m.path)])];for(const m of u){const h=m.private?m.path:X(m.path),t={file:m,message:{threadId:s.threadId,messageId:n.id}},l=d(h),k=i&&(o?l.slice(0,i.length).toLowerCase()===i.toLowerCase():l.startsWith(i)),f=[h,...k?[l.slice(i.length)]:[]];h.startsWith("./")&&f.push(h.replace(/^(\.\/)+/,""));for(const g of f)r.has(g)||r.set(g,t)}}return r}function te(s){const r=Math.max(s.lastIndexOf("/"),s.lastIndexOf("\\"));return r<0?{name:s,folder:""}:{name:s.slice(r+1),folder:s.slice(0,r)}}function de({bot:s}){const{dispatch:r}=S(),{capabilities:x}=Y(),c=x.host.homeDir,d=s.tasks?.find(u=>u.threadId===s.threadId)?.cwd,i=d===void 0?s.cwd:d,n=G(s),p=R.useMemo(()=>ee(s),[s.messages,s.activeLeafId,s.threadId,s.tasks,s.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($,{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:i??void 0,children:i?v(i,c):i===null?a("computer.files.homeFolder"):a("computer.files.privateFolder",{name:s.name})}),e.jsx("button",{type:"button",onClick:()=>{r({type:"toggleComputer",open:!1}),D(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:s.name})}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:n.map(u=>{const{name:m,folder:h}=te(u),t=p.get(u);return e.jsxs("li",{className:"min-w-0 rounded-lg py-1",title:u,children:[t?e.jsx(H,{file:{...t.file,name:m},message:t.message,linked:t.file.linked,className:"w-full max-w-none"},`${t.message.threadId}:${t.message.messageId}:${t.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(j,{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:m}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:a("computer.files.notShared")})]}),h&&e.jsx("div",{className:"mt-1 truncate px-2.5 text-[11px] text-ink-tertiary",children:v(h,c)})]},u)})})]})]})}export{de as C,re as R,_ as a,G as r,ee as s};
|
|
1
|
+
import{j as e,t as a,a as N,r as R}from"./styles-3g-ZPS7M.js";import{aJ as F,aK as L,v as z,S as A,aL as b,aM as y,aN as M,aO as P,aP as w,a7 as j,aQ as B,aR as E,aS as O,u as S,o as T,F as $,aT as v,aU as D,aV as H,aW as I,aX as W,aY as U,aZ as X}from"./App-h8WTNY4l.js";import{a as J,R as K}from"./RoutinesPage-B9kKyfFp.js";import{L as Q,P as V,c as Y}from"./PlacesRail-Df-jNTHn.js";import{C as Z}from"./MenuMotion-CHp-hB40.js";function _({routines:s,runs:r,bots:x,pausedBots:c,heldBots:o,loading:d,error:i,unreadable:n,onOpen:p,onLogs:u,onToggle:m}){const h=[...s].sort((t,l)=>Number(l.enabled)-Number(t.enabled)||(t.nextRunAt??1/0)-(l.nextRunAt??1/0)||t.name.localeCompare(l.name));return e.jsxs("div",{className:"space-y-3","aria-label":a("routines.list"),children:[i&&e.jsx("div",{role:"alert",className:"rounded-lg bg-danger/10 p-3 text-[12px] text-danger",children:a("routines.loadError")}),n&&e.jsx("div",{role:"alert",className:"rounded-lg bg-danger/10 p-3 text-[12px] leading-relaxed text-danger","data-routines-unreadable":"",children:a("routines.unreadable")}),d&&e.jsxs("p",{role:"status",className:"flex items-center gap-2 p-3 text-[12px] text-ink-secondary",children:[e.jsx(Q,{size:14,className:"animate-spin"}),a("routines.loading")]}),!d&&!i&&!n&&h.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(J,{size:20,className:"mx-auto mb-2 opacity-60"}),a("routines.empty")]}),h.map(t=>{const l=F(t.id,r),k=l&&(l.attention?"attention":l.error?"error":l.output?"output":null),f=x?.find(C=>C.id===t.botId),g=m!==void 0&&!L(t);return e.jsxs("article",{className:"rounded-xl border border-hairline/40 bg-card p-3.5","aria-label":t.name,children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>p(t),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:t.name}),e.jsxs("span",{className:"mt-1 block text-[12px] leading-relaxed text-ink-secondary",children:[f&&`${f.name} · `,z(t.schedule)]})]}),g?e.jsx(A,{checked:t.enabled,"aria-label":a("routines.toggle",{name:t.name}),onClick:()=>m(t)}):e.jsx("span",{className:N("shrink-0 rounded-full bg-inset px-2 py-0.5 text-[10px]",t.enabled&&t.nextRunAt!=null?"text-accent":"text-ink-secondary"),children:b(t)})]}),(g||y(t)!==b(t))&&e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:y(t)}),e.jsxs("div",{className:"mt-1 flex items-start justify-between gap-2",children:[e.jsx("div",{className:"min-w-0 text-[12px]",children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:P(l),children:a("routines.latestRun",{status:M(l)})}),e.jsx("span",{className:"block text-[11px] text-ink-secondary",children:w(l.finishedAt??l.startedAt??l.scheduledFor)})]}):e.jsx("span",{className:"text-ink-secondary",children:a("routines.neverRun")})}),e.jsxs("button",{type:"button",onClick:()=>u(t),"aria-label":a("routines.logsFor",{name:t.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(j,{size:12}),a("routines.logs")]})]}),l&&k&&e.jsx("p",{className:N("mt-2 line-clamp-2 whitespace-pre-wrap text-[12px] leading-relaxed",l.error?"text-danger":"text-ink-secondary"),children:B(l,k)}),!!t.failureStreak&&e.jsx("p",{className:"mt-2 text-[12px] text-danger",children:a("routines.failureStreak",{count:t.failureStreak})}),!!t.noStartStreak&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-warning","data-routine-no-start":"",children:a("routines.noStartStreak",{count:t.noStartStreak})}),t.weekRuns&&e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:a(t.weekRuns.total===1?"routines.weekRunsOne":"routines.weekRuns",t.weekRuns)}),t.warning&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-warning",children:t.warning}),t.enabled&&c?.includes(t.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")})]}),t.enabled&&o?.includes(t.botId)&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-warning","data-routine-bot-held":"",children:a("routines.botHeld")}),t.heldFor&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:O(t)}),!!t.skippedRuns&&e.jsxs("p",{className:"mt-2 text-[12px] text-ink-secondary",children:[a("routines.skippedRuns",{count:t.skippedRuns}),t.lastSkippedAt!=null&&e.jsxs(e.Fragment,{children:[" · ",a("routines.lastSkipped",{date:w(t.lastSkippedAt)})]})]})]},t.id)})]})}function re({bot:s,routines:r,runs:x,defaultRunOn:c}){const{state:o,dispatch:d}=S(),[i,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(T,{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(V,{size:14}),a("computer.routines.create")]}),e.jsxs("button",{type:"button",onClick:()=>d({type:"showRoutines",section:"logs",botId:s.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(j,{size:13}),a("routines.logs")]})]})]}),e.jsx(_,{routines:r,runs:x,pausedBots:o.config?.pausedBots,heldBots:o.config?.heldBots,loading:o.routinesLoadState==="loading"&&r.length===0,error:o.routinesLoadState==="error",unreadable:o.config?.routinesUnreadable,onOpen:n,onLogs:p=>d({type:"showRoutines",section:"logs",botId:s.id,routineId:p.id}),onToggle:p=>d({type:"updateRoutine",routineId:p.id,patch:{enabled:!p.enabled}})}),e.jsxs("button",{type:"button",onClick:()=>d({type:"showRoutines",section:"schedule",view:"list",botId:s.id}),className:"self-start text-[12px] text-accent hover:underline",children:[a("computer.routines.openTitle")," ",e.jsx(Z,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]}),i&&e.jsx(K,{routine:i==="new"?void 0:i,bots:[s],lockedBotId:s.id,defaultRunOn:c,onClose:()=>n(null)},s.id)]})}const q=20;function G(s,r=q){const x=new Set,c=[],o=I(s);for(let d=o.length-1;d>=0&&c.length<r;d-=1){const i=o[d].digest?.files;if(i){for(const n of i.deleted)x.add(n);for(const n of[...i.added,...i.changed])if(!x.has(n)&&(x.add(n),c.push(n),c.length>=r))break}}return c}function ee(s){const r=new Map,x=s.tasks?.find(n=>n.threadId===s.threadId),c=x?.cwd===void 0?s.cwd:x.cwd,o=c&&(/^[a-z]:[\\/]/i.test(c)||c.startsWith("\\\\")),d=n=>o?n.replace(/\\/g,"/"):n,i=typeof c=="string"?`${d(c).replace(/\/+$/,"")}/`:void 0;for(const n of[...I(s)].reverse()){if(n.role!=="bot"||n.kind!=="text")continue;const p=W(n.attachments),u=[...p.files,...U(n.text??"",[...p.images,...p.files.map(m=>m.path)])];for(const m of u){const h=m.private?m.path:X(m.path),t={file:m,message:{threadId:s.threadId,messageId:n.id}},l=d(h),k=i&&(o?l.slice(0,i.length).toLowerCase()===i.toLowerCase():l.startsWith(i)),f=[h,...k?[l.slice(i.length)]:[]];h.startsWith("./")&&f.push(h.replace(/^(\.\/)+/,""));for(const g of f)r.has(g)||r.set(g,t)}}return r}function te(s){const r=Math.max(s.lastIndexOf("/"),s.lastIndexOf("\\"));return r<0?{name:s,folder:""}:{name:s.slice(r+1),folder:s.slice(0,r)}}function de({bot:s}){const{dispatch:r}=S(),{capabilities:x}=Y(),c=x.host.homeDir,d=s.tasks?.find(u=>u.threadId===s.threadId)?.cwd,i=d===void 0?s.cwd:d,n=G(s),p=R.useMemo(()=>ee(s),[s.messages,s.activeLeafId,s.threadId,s.tasks,s.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($,{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:i??void 0,children:i?v(i,c):i===null?a("computer.files.homeFolder"):a("computer.files.privateFolder",{name:s.name})}),e.jsx("button",{type:"button",onClick:()=>{r({type:"toggleComputer",open:!1}),D(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:s.name})}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:n.map(u=>{const{name:m,folder:h}=te(u),t=p.get(u);return e.jsxs("li",{className:"min-w-0 rounded-lg py-1",title:u,children:[t?e.jsx(H,{file:{...t.file,name:m},message:t.message,linked:t.file.linked,className:"w-full max-w-none"},`${t.message.threadId}:${t.message.messageId}:${t.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(j,{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:m}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:a("computer.files.notShared")})]}),h&&e.jsx("div",{className:"mt-1 truncate px-2.5 text-[11px] text-ink-tertiary",children:v(h,c)})]},u)})})]})]})}export{de as C,re as R,_ as a,G as r,ee as s};
|