@xopcai/xopc 0.0.349 → 0.0.351
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CiOc0zWr.js → agent-avatar-dicebear-Dc0yBlKV.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BvL4FTKi.js → agent-defaults-settings-panel-BXFins6I.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-BOzZvojX.js → agent-plugin-dialog-B-w6bJuj.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-BrPqEJm5.js → agents-CuFzMN58.js} +3 -3
- package/dist/gateway/static/root/assets/{agents-admin-api-DZsBZ9R6.js → agents-admin-api-yUALtmym.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BY7yVNOc.js → app-management-settings-panel-C7QjGlMZ.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-Cqk9QUWY.js → appearance-settings-CgApGxhN.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DH1ZZh_x.js → apps-page-DWii4stP.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-CClKYiZH.js → archive-plugin--oP0UmoE.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-DqtZazSc.js → automations-page-DkV4w6xr.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-BN0s1ILZ.js → automations-workspace-DT95Uk9d.js} +2 -2
- package/dist/gateway/static/root/assets/{binary-plugins-C680MkH2.js → binary-plugins-DIpBiw_8.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-B4lDSWIv.js → block-editor-Di4X446B.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automation-inputs-BgK2Ma4E.js → browser-automation-inputs-B0TlAcoB.js} +1 -1
- package/dist/gateway/static/root/assets/browser-automations-page-pKPvkGW8.js +3 -0
- package/dist/gateway/static/root/assets/{browser-settings-page-CNVdAeRH.js → browser-settings-page-cJ200PlY.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-C2vyJC-B.js → capabilities-e-fO70DK.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-DqDP04o0.js → capabilities-page-CPKbJUDL.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-Dd1xjlpb.js → capabilities-settings-panel-D5xUFWBJ.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-header-actions-CHokFPVe.js → capability-header-actions-9qDm8ioP.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-aemisJsK.js → channels-CO_9_oIH.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-C9zgTx4N.js → chat-terminal-dock-DCFwzHu2.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-DzIVWHw5.js → computer-settings-page-bwWQ3axN.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-B_9tzNtD.js → connector-service-page-BIIP-gX4.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-D0qvb3mB.js → connectors-page-C0b5Xbca.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-B_hPKrIP.js → date-picker-DBio7OE6.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-BPAS7Ee7.js → dependency-picker-hyPm_1tB.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-XzkMTcLt.js → desktop-pet-BDPfot60.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CmhF1kse.js → desktop-pet-settings-C6IRO2iD.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-BcptV-hP.js → device-pairing-wizard-CUOh38IK.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-CHbRbJZj.js → directory-picker-path-field-ljXXfuLL.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-CNsneD82.js → extension-debug-page-DHw1dG1g.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DxiiQ_-P.js → extension-page-BjLN3E6q.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DIh4aO4j.js → extension-settings-page-BMp6v6zP.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-COCA8geG.js → gateway-config-swr-CmjHbMj7.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-Blcloycq.js → gateway-realtime-DzyR6LYb.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-KyhksZSM.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-settings-BNcafQJB.js → gateway-settings-D76thCuX.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CradGmBo.js → gateway-startup-retry-CbOUnKv5.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-BvZcBNhP.js → home-page-D1Tyeuul.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-CCe_-wBX.js → image-generation-api-BmLpVntI.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-DgUrv_Rh.js → imports-page-CabovqRQ.js} +1 -1
- package/dist/gateway/static/root/assets/index-Bb32g7Ll.js +106 -0
- package/dist/gateway/static/root/assets/index-CPi50n0l.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CuQZEmVh.js → keyboard-shortcuts-settings-DvN-2bcS.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-BLbLqWVm.js → local-app-workbench-page-CSEzRWxs.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-CErGXyIl.js → local-apps-page-C3Wy2zG2.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-CIcrQnQp.js → local-session-drafts-CxXjQ5Du.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-K7mHrs6W.js → locale-store-WMaCMm3_.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-flTbDuMT.js → logs-page-YojQFX9o.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-QQT6byMB.js → management-settings-CNMk0HRn.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-BNVvybMV.js → markdown-view-Oe4rXk1N.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Y1tnLGkI.js → media-plugins-Ds7HF3EM.js} +1 -1
- package/dist/gateway/static/root/assets/messages-sXePe3LQ.js +3 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-B7HS4oqs.js → note-detail-panel-D8vQ_INI.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-BYpUaCxU.js → notes-page-CIFcEPAd.js} +2 -2
- package/dist/gateway/static/root/assets/{page-context-capture-button-DOcROUXS.js → page-context-capture-button-YKiYT0q2.js} +1 -1
- package/dist/gateway/static/root/assets/{page-tabs-CU8zjRtM.js → page-tabs-ZUC486EH.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BoZWmgG_.js → preview-open-alternatives-Ca9tBmOg.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-C0pJaYJB.js → product-open-page-BuGb8QPn.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-xrlYOZ7-.js → project-detail-page-C6Awj1Ql.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page--OYwmNEy.js → projects-page-CmO8Gb9G.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-DKxVZeHC.js → registry-api-DEePN1Rc.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-6qkix2R1.js → remote-access-hub-BsqHroXR.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-C06BmltI.js → runtime-tools-settings-panel-Cva9t35o.js} +1 -1
- package/dist/gateway/static/root/assets/{scenes-page-BTRh_BNJ.js → scenes-page-3_61bQHN.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-Dl0j1Pjj.js → schema-form-DWHFyKEB.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-DoE_8MbN.js → session-api-Bv-hCMKS.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-B6_KNduD.js → session-manager-BcDptzCN.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-BDqe_-Sr.js → sessions-page-BaHue2bK.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-C4y4c2M7.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-DX9Q7-oB.js → settings-form-section-BwdrtX6k.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DyjpNUtv.js → settings-page-B6YZFEye.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-D7CPCTs-.js → setup-status-panel-nMWHz-ra.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-NXyrys7a.js → share-preview-page-DH0KHlev.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-C7APzUWD.js → shares-settings-KK-VNbMw.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-D2Zav1-k.js → skill-api-BbNk-3Ig.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DUOG2Ig1.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-C8XzNFai.js → skills-page-BQya9ygw.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-CjAKelf_.js → system-settings-panel-akm5mc8b.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-C2tCewyf.js → task-detail-page-wLGUc7Nu.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-RsRe1MVk.js → tunnel-api-vZ7P_KIQ.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-Cz8WM0U_.js → usage-page-BV1KJ0EY.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-Bs2Zw_LW.js → use-autosave-DQdLcZfO.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-DnLTTyOE.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-CCznhcKT.js → voice-api-key-field-CJ-FjNHr.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-C9HKTnnD.js → voice-config-api-DbjjZkIg.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-DzllwGa7.js → work-discovery-overlay-BA1AAqaW.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C8Q_04la.js → workflow-run-setup-panel-BhIOKmjW.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-3724WDyr.js → workflows-page-aYoObmuS.js} +2 -2
- package/dist/gateway/static/root/index.html +15 -15
- package/dist/package.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/gateway/hono/routes/connectors.js +1 -1
- package/dist/src/gateway/service.js +4 -4
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/voice/realtime/runtime.js +1 -1
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/browser-automations-page-B0FqXGpQ.js +0 -3
- package/dist/gateway/static/root/assets/gateway-realtime-store-B87bp5kF.js +0 -1
- package/dist/gateway/static/root/assets/index-Cfg6ma6d.css +0 -1
- package/dist/gateway/static/root/assets/index-oJE8g8BL.js +0 -106
- package/dist/gateway/static/root/assets/messages-CY3XVeek.js +0 -3
- package/dist/gateway/static/root/assets/settings-advanced-gate-aDIE1Okc.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-C7-ZWRB-.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-BQ4P1A_c.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as a,r as o}from"./popover-select-0p9PIHRy.js";import{t as s}from"./external-link-DjqjBmc3.js";import{t as c}from"./message-square-plus-XP0tGdlV.js";import{t as l}from"./messages-CY3XVeek.js";import{t as u}from"./cn-JdwAhgNB.js";import{n as d}from"./locale-store-K7mHrs6W.js";import{t as f}from"./skeleton-BwbyijEw.js";import{n as p}from"./electron-env-Dit0bHgy.js";import{Bu as m,Kc as h,Ns as g,lc as _,ol as v,wa as y}from"./index-oJE8g8BL.js";import{t as b}from"./desktop-pet-sprite-DTqXSpqf.js";import{n as x,r as S}from"./settings-page-layout-X1x-2Cp9.js";var C=n(),w=e(t(),1),T=r();function E(e){let t=(0,C.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r}),t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,T.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,T.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function D(){let e=l(d(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,w.useState)(null),[C,D]=(0,w.useState)(!1),[O,k]=(0,w.useState)(null),A=typeof window<`u`?window.electronAPI?.pet:void 0,j=(0,w.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),M=(0,w.useCallback)(async()=>{if(A){D(!0);try{r(await A.getState())}finally{D(!1)}}},[A]);if((0,w.useEffect)(()=>{if(A)return M(),A.onStateChanged(r)},[A,M]),!p()||!A)return null;if(!n)return(0,T.jsxs)(S,{gap:`gap-4`,children:[(0,T.jsx)(x,{title:e.title,subtitle:e.subtitle}),(0,T.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsx)(f,{className:`h-14 rounded-xl`}),(0,T.jsx)(f,{className:`h-14 rounded-xl`}),(0,T.jsx)(f,{className:`h-24 rounded-xl`}),(0,T.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,T.jsx)(f,{className:`h-16 rounded-xl`},t))})]})})]});let N=async e=>{D(!0);try{r(await A.setPrefs(e))}finally{D(!1)}},P=async e=>{e?(await A.show(),r(await A.getState())):r(await A.setPrefs({enabled:!1}))},F=e=>{N({selectedPetId:e})},I=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},L=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},R=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=I(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},z=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),B=()=>{L(e.createChatDraft)},V=t=>{L(z(e.optimizeChatDraft,{id:t.id,name:I(t).name,description:I(t).description,sourcePrompt:R(t)}))},H=t=>{L(z(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},U=O??n.prefs.sizePercent,W=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),G=async(e=U)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));k(null),t!==n.prefs.sizePercent&&await N({sizePercent:t})};return(0,T.jsxs)(S,{gap:`gap-4`,children:[(0,T.jsx)(x,{title:e.title,subtitle:e.subtitle,actions:(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,T.jsx)(y,{className:`size-9 shrink-0 p-0`,disabled:C,label:e.refresh,onClick:M}),(0,T.jsxs)(`button`,{type:`button`,className:u(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,g.press),onClick:()=>void A.openCustomPetsDir(),children:[(0,T.jsx)(s,{className:`size-3.5`,strokeWidth:1.75}),e.openFolder]})]})}),(0,T.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(E,{title:e.enable,desc:e.enableDesc,checked:n.prefs.enabled,disabled:C,onChange:e=>void P(e)}),(0,T.jsx)(E,{title:e.showOnStartup,desc:e.showOnStartupDesc,checked:n.prefs.showOnStartup,disabled:C,onChange:e=>void N({showOnStartup:e})})]}),(0,T.jsx)(`div`,{className:`mt-5 rounded-xl bg-surface-base/55 p-3`,children:(0,T.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,T.jsx)(_,{className:`mt-0.5 size-4 text-accent-fg`,strokeWidth:1.8}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.createTitle}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.createDesc})]})]}),(0,T.jsxs)(`button`,{type:`button`,className:u(`inline-flex h-9 shrink-0 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 text-xs font-semibold text-on-accent hover:bg-accent/90`,g.press),onClick:B,children:[(0,T.jsx)(c,{className:`size-3.5`,strokeWidth:1.75}),e.createInChat]})]})}),(0,T.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 rounded-xl bg-surface-base/55 p-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.bondTitle}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondDesc})]}),(0,T.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:e.bondSummary.replace(`{days}`,String(W)).replace(`{tasks}`,String(n.relationship.completedTaskCount))})]}),(0,T.jsxs)(`div`,{className:`mt-5`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.petList}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.petListDesc})]}),j?(0,T.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:I(j).name}):null]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl bg-surface-base/45 p-1 [&>*]:rounded-lg [&>*]:bg-surface-panel/55`,children:[n.pets.map(t=>{let r=t.id===n.prefs.selectedPetId,i=I(t);return(0,T.jsxs)(`div`,{className:`flex items-center gap-3 p-3`,children:[(0,T.jsx)(b,{pet:t,action:`idle`,size:`tiny`}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:i.name}),t.builtin?null:(0,T.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.customBadge})]}),(0,T.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:i.description})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t.builtin?null:(0,T.jsxs)(`button`,{type:`button`,className:u(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,g.press),onClick:()=>V(t),children:[(0,T.jsx)(v,{className:`size-3.5`,strokeWidth:1.75}),e.optimizeInChat]}),(0,T.jsx)(`button`,{type:`button`,className:u(`rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,r?`bg-surface-hover text-fg-muted`:`bg-surface-panel text-fg hover:bg-surface-hover`,g.press),disabled:r||C,onClick:()=>F(t.id),children:r?e.selected:e.select})]})]},t.id)}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:e.customPets}),(0,T.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,T.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,onClick:()=>void A.openCustomPetsDir(),children:[e.openFolder,(0,T.jsx)(s,{className:`size-3.5`,strokeWidth:1.75})]})]})]}),n.petIssues.length>0?(0,T.jsxs)(`div`,{className:`mt-2 rounded-xl bg-danger/10 p-3`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-danger`,children:[(0,T.jsx)(m,{className:`size-3.5`,strokeWidth:1.8}),e.invalidPets]}),(0,T.jsx)(`div`,{className:`mt-2 space-y-2`,children:n.petIssues.map(t=>(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base/70 p-2 text-xs text-fg-muted sm:flex-row sm:items-start sm:justify-between`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`p`,{className:`truncate font-mono text-[11px] text-fg`,children:t.dir}),(0,T.jsx)(`p`,{children:t.reason}),t.details?.length?(0,T.jsx)(`p`,{className:`line-clamp-2`,children:t.details.join(`; `)}):null]}),(0,T.jsxs)(`button`,{type:`button`,className:u(`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-danger/30 bg-surface-base px-2.5 text-xs font-medium text-danger hover:bg-danger/10`,g.press),onClick:()=>H(t),children:[(0,T.jsx)(c,{className:`size-3.5`,strokeWidth:1.75}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null]}),(0,T.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,T.jsxs)(`div`,{className:`rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.size}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.sizeDesc})]}),(0,T.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[U,`%`]})]}),(0,T.jsx)(`input`,{type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:U,onChange:e=>k(Number(e.target.value)),onBlur:()=>void G(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&G()},onPointerUp:()=>void G()})]}),(0,T.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,T.jsx)(E,{title:e.alwaysOnTop,desc:e.alwaysOnTopDesc,checked:n.prefs.alwaysOnTop,disabled:C,onChange:e=>void N({alwaysOnTop:e})}),(0,T.jsx)(E,{title:e.bubbles,desc:e.bubblesDesc,checked:n.prefs.bubbleEnabled,disabled:C,onChange:e=>void N({bubbleEnabled:e})}),(0,T.jsx)(E,{title:e.proactiveTips,desc:e.proactiveTipsDesc,checked:n.prefs.proactiveTipsEnabled,disabled:C,onChange:e=>void N({proactiveTipsEnabled:e})}),(0,T.jsx)(E,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:C,onChange:e=>void N({interactionEnabled:e})}),(0,T.jsx)(E,{title:e.reducedMotion,desc:e.reducedMotionDesc,checked:n.prefs.reducedMotion,disabled:C,onChange:e=>void N({reducedMotion:e})}),(0,T.jsx)(E,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:C,onChange:e=>void N({clickThroughWhenIdle:e})})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.behaviorModeDesc})]}),(0,T.jsxs)(a,{className:`w-full sm:w-40`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,onChange:e=>void N({behaviorMode:e.target.value}),children:[(0,T.jsx)(o,{value:`focus`,children:e.behaviorFocus}),(0,T.jsx)(o,{value:`companion`,children:e.behaviorCompanion}),(0,T.jsx)(o,{value:`playful`,children:e.behaviorPlayful})]})]}),(0,T.jsxs)(`button`,{type:`button`,className:u(`inline-flex w-fit items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,g.press),disabled:C,onClick:()=>void A.resetPosition().then(r),children:[(0,T.jsx)(h,{className:`size-3.5`,strokeWidth:1.75}),e.resetPosition]})]})]})]})}export{D as DesktopPetSettings};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as a,r as o}from"./popover-select-0p9PIHRy.js";import{t as s}from"./external-link-DjqjBmc3.js";import{t as c}from"./message-square-plus-XP0tGdlV.js";import{t as l}from"./messages-sXePe3LQ.js";import{t as u}from"./cn-JdwAhgNB.js";import{n as d}from"./locale-store-WMaCMm3_.js";import{t as f}from"./skeleton-BwbyijEw.js";import{n as p}from"./electron-env-Dit0bHgy.js";import{Bu as m,Kc as h,Ns as g,lc as _,ol as v,wa as y}from"./index-Bb32g7Ll.js";import{t as b}from"./desktop-pet-sprite-DTqXSpqf.js";import{n as x,r as S}from"./settings-page-layout-X1x-2Cp9.js";var C=n(),w=e(t(),1),T=r();function E(e){let t=(0,C.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r}),t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,T.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,T.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function D(){let e=l(d(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,w.useState)(null),[C,D]=(0,w.useState)(!1),[O,k]=(0,w.useState)(null),A=typeof window<`u`?window.electronAPI?.pet:void 0,j=(0,w.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),M=(0,w.useCallback)(async()=>{if(A){D(!0);try{r(await A.getState())}finally{D(!1)}}},[A]);if((0,w.useEffect)(()=>{if(A)return M(),A.onStateChanged(r)},[A,M]),!p()||!A)return null;if(!n)return(0,T.jsxs)(S,{gap:`gap-4`,children:[(0,T.jsx)(x,{title:e.title,subtitle:e.subtitle}),(0,T.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsx)(f,{className:`h-14 rounded-xl`}),(0,T.jsx)(f,{className:`h-14 rounded-xl`}),(0,T.jsx)(f,{className:`h-24 rounded-xl`}),(0,T.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,T.jsx)(f,{className:`h-16 rounded-xl`},t))})]})})]});let N=async e=>{D(!0);try{r(await A.setPrefs(e))}finally{D(!1)}},P=async e=>{e?(await A.show(),r(await A.getState())):r(await A.setPrefs({enabled:!1}))},F=e=>{N({selectedPetId:e})},I=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},L=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},R=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=I(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},z=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),B=()=>{L(e.createChatDraft)},V=t=>{L(z(e.optimizeChatDraft,{id:t.id,name:I(t).name,description:I(t).description,sourcePrompt:R(t)}))},H=t=>{L(z(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},U=O??n.prefs.sizePercent,W=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),G=async(e=U)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));k(null),t!==n.prefs.sizePercent&&await N({sizePercent:t})};return(0,T.jsxs)(S,{gap:`gap-4`,children:[(0,T.jsx)(x,{title:e.title,subtitle:e.subtitle,actions:(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,T.jsx)(y,{className:`size-9 shrink-0 p-0`,disabled:C,label:e.refresh,onClick:M}),(0,T.jsxs)(`button`,{type:`button`,className:u(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,g.press),onClick:()=>void A.openCustomPetsDir(),children:[(0,T.jsx)(s,{className:`size-3.5`,strokeWidth:1.75}),e.openFolder]})]})}),(0,T.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(E,{title:e.enable,desc:e.enableDesc,checked:n.prefs.enabled,disabled:C,onChange:e=>void P(e)}),(0,T.jsx)(E,{title:e.showOnStartup,desc:e.showOnStartupDesc,checked:n.prefs.showOnStartup,disabled:C,onChange:e=>void N({showOnStartup:e})})]}),(0,T.jsx)(`div`,{className:`mt-5 rounded-xl bg-surface-base/55 p-3`,children:(0,T.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,T.jsx)(_,{className:`mt-0.5 size-4 text-accent-fg`,strokeWidth:1.8}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.createTitle}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.createDesc})]})]}),(0,T.jsxs)(`button`,{type:`button`,className:u(`inline-flex h-9 shrink-0 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 text-xs font-semibold text-on-accent hover:bg-accent/90`,g.press),onClick:B,children:[(0,T.jsx)(c,{className:`size-3.5`,strokeWidth:1.75}),e.createInChat]})]})}),(0,T.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 rounded-xl bg-surface-base/55 p-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.bondTitle}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondDesc})]}),(0,T.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:e.bondSummary.replace(`{days}`,String(W)).replace(`{tasks}`,String(n.relationship.completedTaskCount))})]}),(0,T.jsxs)(`div`,{className:`mt-5`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.petList}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.petListDesc})]}),j?(0,T.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:I(j).name}):null]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl bg-surface-base/45 p-1 [&>*]:rounded-lg [&>*]:bg-surface-panel/55`,children:[n.pets.map(t=>{let r=t.id===n.prefs.selectedPetId,i=I(t);return(0,T.jsxs)(`div`,{className:`flex items-center gap-3 p-3`,children:[(0,T.jsx)(b,{pet:t,action:`idle`,size:`tiny`}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:i.name}),t.builtin?null:(0,T.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.customBadge})]}),(0,T.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:i.description})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t.builtin?null:(0,T.jsxs)(`button`,{type:`button`,className:u(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,g.press),onClick:()=>V(t),children:[(0,T.jsx)(v,{className:`size-3.5`,strokeWidth:1.75}),e.optimizeInChat]}),(0,T.jsx)(`button`,{type:`button`,className:u(`rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,r?`bg-surface-hover text-fg-muted`:`bg-surface-panel text-fg hover:bg-surface-hover`,g.press),disabled:r||C,onClick:()=>F(t.id),children:r?e.selected:e.select})]})]},t.id)}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:e.customPets}),(0,T.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,T.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,onClick:()=>void A.openCustomPetsDir(),children:[e.openFolder,(0,T.jsx)(s,{className:`size-3.5`,strokeWidth:1.75})]})]})]}),n.petIssues.length>0?(0,T.jsxs)(`div`,{className:`mt-2 rounded-xl bg-danger/10 p-3`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-danger`,children:[(0,T.jsx)(m,{className:`size-3.5`,strokeWidth:1.8}),e.invalidPets]}),(0,T.jsx)(`div`,{className:`mt-2 space-y-2`,children:n.petIssues.map(t=>(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base/70 p-2 text-xs text-fg-muted sm:flex-row sm:items-start sm:justify-between`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`p`,{className:`truncate font-mono text-[11px] text-fg`,children:t.dir}),(0,T.jsx)(`p`,{children:t.reason}),t.details?.length?(0,T.jsx)(`p`,{className:`line-clamp-2`,children:t.details.join(`; `)}):null]}),(0,T.jsxs)(`button`,{type:`button`,className:u(`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-danger/30 bg-surface-base px-2.5 text-xs font-medium text-danger hover:bg-danger/10`,g.press),onClick:()=>H(t),children:[(0,T.jsx)(c,{className:`size-3.5`,strokeWidth:1.75}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null]}),(0,T.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,T.jsxs)(`div`,{className:`rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.size}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.sizeDesc})]}),(0,T.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[U,`%`]})]}),(0,T.jsx)(`input`,{type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:U,onChange:e=>k(Number(e.target.value)),onBlur:()=>void G(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&G()},onPointerUp:()=>void G()})]}),(0,T.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,T.jsx)(E,{title:e.alwaysOnTop,desc:e.alwaysOnTopDesc,checked:n.prefs.alwaysOnTop,disabled:C,onChange:e=>void N({alwaysOnTop:e})}),(0,T.jsx)(E,{title:e.bubbles,desc:e.bubblesDesc,checked:n.prefs.bubbleEnabled,disabled:C,onChange:e=>void N({bubbleEnabled:e})}),(0,T.jsx)(E,{title:e.proactiveTips,desc:e.proactiveTipsDesc,checked:n.prefs.proactiveTipsEnabled,disabled:C,onChange:e=>void N({proactiveTipsEnabled:e})}),(0,T.jsx)(E,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:C,onChange:e=>void N({interactionEnabled:e})}),(0,T.jsx)(E,{title:e.reducedMotion,desc:e.reducedMotionDesc,checked:n.prefs.reducedMotion,disabled:C,onChange:e=>void N({reducedMotion:e})}),(0,T.jsx)(E,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:C,onChange:e=>void N({clickThroughWhenIdle:e})})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.behaviorModeDesc})]}),(0,T.jsxs)(a,{className:`w-full sm:w-40`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,onChange:e=>void N({behaviorMode:e.target.value}),children:[(0,T.jsx)(o,{value:`focus`,children:e.behaviorFocus}),(0,T.jsx)(o,{value:`companion`,children:e.behaviorCompanion}),(0,T.jsx)(o,{value:`playful`,children:e.behaviorPlayful})]})]}),(0,T.jsxs)(`button`,{type:`button`,className:u(`inline-flex w-fit items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,g.press),disabled:C,onClick:()=>void A.resetPosition().then(r),children:[(0,T.jsx)(h,{className:`size-3.5`,strokeWidth:1.75}),e.resetPosition]})]})]})]})}export{D as DesktopPetSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{f as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./x-B_N4OPjy.js";import{t as u}from"./messages-CY3XVeek.js";import{t as d}from"./cn-JdwAhgNB.js";import{n as f}from"./locale-store-K7mHrs6W.js";import{a as p,i as m,o as h,r as g,s as _,t as v}from"./dist-BGTk37IG.js";import{n as y}from"./app-link-DRL0YnPs.js";import{i as b}from"./vendor-swr-BIWyz7Rc.js";import{t as x}from"./button-CS04eWY9.js";import{t as S}from"./skeleton-BwbyijEw.js";import{i as C,o as w}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{Bl as T,Bt as E,Lt as D,Mt as O,Nt as k,Ou as A,Pc as j,Pt as M,Rt as N,Vu as P,ll as F,ua as I,xo as ee}from"./index-oJE8g8BL.js";import{_ as te,a as ne,d as re,f as ie,g as ae,h as oe,i as se,l as L,m as ce,n as R,p as le,r as z,s as B,t as V,u as ue,v as de}from"./tunnel-api-RsRe1MVk.js";import{t as H}from"./browser-BLJWD7WI.js";var U=e(n(),1),W=r(),G=e(H(),1),K={width:240,margin:4,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function fe(e){let t=await G.toString(e,{...K,type:`svg`});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}var q=i();function pe(){let e=u(f(e=>e.language)),t=e.endpointToolsSettings.deviceAccess.flow,n=e.tunnelSettings,{data:r,error:i,mutate:a}=b(`tunnel-status`,R,{refreshInterval:1500}),[o,s]=(0,U.useState)(!1),[l,d]=(0,U.useState)(!1),[p,m]=(0,U.useState)(!0),[h,g]=(0,U.useState)(`idle`),[_,v]=(0,U.useState)(null),[C,w]=(0,U.useState)(``),T=(0,U.useRef)(!0);(0,U.useEffect)(()=>(T.current=!0,()=>{T.current=!1}),[]);let A=async()=>{if(!r)return;if(r.consentRequired&&!o){d(!0);return}let e=r.registrationSecret?.configured?null:M(),t,n=!1;v(null);try{if(r.consentRequired&&await ne(),!r.registrationSecret?.configured){g(`provisioning`);let r=!1;try{await se()}catch(e){if(!ue(e))throw e;r=!0}if(r){g(`authorizing`);let r=sessionStorage.getItem(`device-pairing-oauth`),i=r?JSON.parse(r):null;t=i&&i.expiresAt>Date.now()?i.sessionId:(await E(`xopc-tunnel`)).sessionId,sessionStorage.setItem(`device-pairing-oauth`,JSON.stringify({sessionId:t,expiresAt:i&&i.expiresAt>Date.now()?i.expiresAt:Date.now()+5*6e4}));let a=``,o=Date.now()+5*6e4,s=!1;for(;T.current&&Date.now()<o;){let r=await N(t);if(r.authUrl&&r.authUrl!==a&&(a=r.authUrl,await k(a,e)||w(a)),r.status===`completed`){s=!0,n=!0;break}if(r.status===`failed`||r.status===`cancelled`)throw Error(`Authorization cancelled`);await new Promise(e=>setTimeout(e,1e3))}if(!T.current)return;if(!s)throw Error(`Authorization expired`);await se()}await a()}if(!T.current)return;g(`starting`),await B(),p&&await z({autoStart:!0}),await a(),n=!0}catch(e){n=!0,T.current&&v(L(e)===`tunnel_key_limit_reached`?`key-limit`:`failed`)}finally{O(e),n&&(sessionStorage.removeItem(`device-pairing-oauth`),t&&D(t).catch(()=>{})),T.current&&(g(`idle`),w(``))}};if(!r&&!i)return(0,q.jsxs)(`div`,{className:`space-y-5`,children:[(0,q.jsx)(S,{className:`h-5 w-4/5`}),(0,q.jsx)(S,{className:`h-24 w-full`})]});let j=h===`provisioning`||h===`starting`||r?.state===`connecting`||r?.state===`reconnecting`;return(0,q.jsxs)(`div`,{className:`flex min-h-full flex-col`,children:[(0,q.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:j?t.preparingHint:h===`authorizing`?t.authorizing:t.enableHint}),C&&h===`authorizing`?(0,q.jsx)(`a`,{href:C,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 inline-flex min-h-11 items-center text-sm text-accent`,children:t.openAuthorization}):null,j?(0,q.jsxs)(`div`,{className:`mt-8 space-y-3`,"aria-label":t.preparing,children:[(0,q.jsx)(S,{className:`h-2 w-full`}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.preparing})]}):null,(l||r?.consentRequired)&&h===`idle`?(0,q.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,q.jsxs)(`details`,{open:l,className:`text-sm text-fg-muted`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,q.jsx)(`p`,{className:`mt-2`,children:n.consentIntro}),(0,q.jsx)(`ul`,{className:`mt-3 list-disc space-y-2 pl-5`,children:[n.consentBullet1,n.consentBullet2,n.consentBullet3].map(e=>(0,q.jsx)(`li`,{children:e},e))})]}),(0,q.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),className:`mt-1 size-4 accent-accent`}),n.consentCheckbox]})]}):null,_===`key-limit`?(0,q.jsxs)(`div`,{role:`alert`,className:`mt-4 rounded-lg border border-warning/30 bg-warning/5 p-4`,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.routeKeyLimitTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.routeKeyLimitHint}),(0,q.jsxs)(x,{variant:`secondary`,className:`mt-3`,onClick:()=>void y(V),children:[t.manageTunnelKeys,(0,q.jsx)(c,{className:`size-3`})]})]}):_||i||r?.state===`error`?(0,q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:t.routeSetupFailed}):null,(0,q.jsx)(`div`,{className:`flex-1`}),(0,q.jsxs)(`label`,{className:`my-5 flex items-center gap-3 text-sm text-fg-muted`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:p,disabled:h!==`idle`,onChange:e=>m(e.target.checked),className:`size-4 accent-accent`}),t.autoStart]}),(0,q.jsx)(x,{className:`w-full`,variant:`primary`,disabled:!r||h!==`idle`||j||l&&!o,onClick:()=>void A(),children:h===`authorizing`?t.authorizing:j?t.preparing:_?t.retry:t.enable}),i&&!r?(0,q.jsx)(x,{variant:`ghost`,onClick:()=>void a(),children:t.retry}):null]})}var J=t({DevicePairingWizard:()=>Y});function Y(e){let t=(0,W.c)(16),{open:n,onOpenChange:r,onPaired:i,targetKind:o}=e,s=a(),[c,l]=(0,U.useState)(o),u,d;t[0]===o?(u=t[1],d=t[2]):(u=()=>{l(o)},d=[o],t[0]=o,t[1]=u,t[2]=d),(0,U.useEffect)(u,d);let f;t[3]!==r||t[4]!==o?(f=e=>{e||l(o),r(e)},t[3]=r,t[4]=o,t[5]=f):f=t[5];let p=f,m;t[6]!==p||t[7]!==s||t[8]!==i||t[9]!==n||t[10]!==c?(m=n?c?(0,q.jsx)(he,{targetKind:c,onClose:()=>p(!1),onPaired:i}):(0,q.jsx)(Z,{onChoose:l,onChooseLocalBrowser:()=>{p(!1),s(`/settings/agent-browser?driver=extension`)},onClose:()=>p(!1)}):null,t[6]=p,t[7]=s,t[8]=i,t[9]=n,t[10]=c,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==n||t[14]!==m?(h=(0,q.jsx)(v,{open:n,onOpenChange:p,children:m}),t[12]=p,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function X(e){let t=(0,W.c)(14),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,q.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,q.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,q.jsx)(P,{className:`size-4 shrink-0 text-fg-disabled transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":`true`}),t[9]=u):u=t[9];let d;return t[10]!==a||t[11]!==o||t[12]!==l?(d=(0,q.jsxs)(`button`,{type:`button`,className:`group flex min-h-18 w-full cursor-pointer items-center gap-4 rounded-xl border border-edge bg-surface-panel px-4 py-3.5 text-left shadow-surface transition-[background-color,border-color,box-shadow,transform] hover:border-edge-strong hover:bg-surface-active hover:shadow-elevated active:translate-y-px active:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel motion-reduce:active:translate-y-0`,onClick:a,children:[o,l,u]}),t[10]=a,t[11]=o,t[12]=l,t[13]=d):d=t[13],d}function Z(e){let t=(0,W.c)(40),{onChoose:n,onChooseLocalBrowser:r,onClose:i}=e,a=f(me),o;t[0]===a?o=t[1]:(o=u(a),t[0]=a,t[1]=o);let s=o.endpointToolsSettings.deviceAccess,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,q.jsx)(p,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),t[2]=c):c=t[2];let v;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(v=d(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(28rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,C),t[3]=v):v=t[3];let y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,q.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),t[4]=y):y=t[4];let b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,q.jsx)(l,{className:`size-4`}),t[5]=b):b=t[5];let x;t[6]!==s.cancel||t[7]!==i?(x=(0,q.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[y,(0,q.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":s.cancel,onClick:i,children:b})]}),t[6]=s.cancel,t[7]=i,t[8]=x):x=t[8];let S;t[9]===s.chooseTitle?S=t[10]:(S=(0,q.jsx)(_,{className:`text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:s.chooseTitle}),t[9]=s.chooseTitle,t[10]=S);let E;t[11]===s.chooseHint?E=t[12]:(E=(0,q.jsx)(m,{className:`mt-1.5 text-sm leading-6 text-fg-muted`,children:s.chooseHint}),t[11]=s.chooseHint,t[12]=E);let D;t[13]!==s.localBrowserHint||t[14]!==s.localBrowserTitle||t[15]!==r?(D=(0,q.jsx)(X,{icon:T,title:s.localBrowserTitle,hint:s.localBrowserHint,onClick:r}),t[13]=s.localBrowserHint,t[14]=s.localBrowserTitle,t[15]=r,t[16]=D):D=t[16];let O;t[17]===n?O=t[18]:(O=()=>n(`mobile`),t[17]=n,t[18]=O);let k;t[19]!==s.mobileHint||t[20]!==s.mobileTitle||t[21]!==O?(k=(0,q.jsx)(X,{icon:j,title:s.mobileTitle,hint:s.mobileHint,onClick:O}),t[19]=s.mobileHint,t[20]=s.mobileTitle,t[21]=O,t[22]=k):k=t[22];let A;t[23]===n?A=t[24]:(A=()=>n(`browser`),t[23]=n,t[24]=A);let M;t[25]!==s.remoteBrowserHint||t[26]!==s.remoteBrowserTitle||t[27]!==A?(M=(0,q.jsx)(X,{icon:F,title:s.remoteBrowserTitle,hint:s.remoteBrowserHint,onClick:A}),t[25]=s.remoteBrowserHint,t[26]=s.remoteBrowserTitle,t[27]=A,t[28]=M):M=t[28];let N;t[29]!==k||t[30]!==M||t[31]!==D?(N=(0,q.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2.5`,children:[D,k,M]}),t[29]=k,t[30]=M,t[31]=D,t[32]=N):N=t[32];let P;t[33]!==N||t[34]!==S||t[35]!==E?(P=(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-6 sm:px-8`,children:[S,E,N]}),t[33]=N,t[34]=S,t[35]=E,t[36]=P):P=t[36];let I;return t[37]!==P||t[38]!==x?(I=(0,q.jsxs)(h,{children:[c,(0,q.jsxs)(g,{className:v,children:[x,P]})]}),t[37]=P,t[38]=x,t[39]=I):I=t[39],I}function me(e){return e.language}function he({targetKind:e,onClose:t,onPaired:n}){let r=f(e=>e.language),i=u(r),a=i.endpointToolsSettings.deviceAccess,v=a.flow,[T,E]=(0,U.useState)(!1),D=b(T?`device-pairing-readiness`:null,oe,{refreshInterval:1500}),[O,k]=(0,U.useState)(),[j,M]=(0,U.useState)(null),[N,F]=(0,U.useState)(!1),[ne,se]=(0,U.useState)(Date.now()),[L,R]=(0,U.useState)(null),z=(0,U.useRef)(!0),B=(0,U.useRef)(null),V=(0,U.useRef)(!1),ue=(0,U.useRef)(!1),H=b(O?[`device-pairing-setup`,O.id]:null,()=>ae(O.id),{refreshInterval:1500}),W=H.data?.request,G=W?.status===`completed`,K=G&&W.connectedAt!==void 0,J=b(K&&window.electronAPI?.system?`system-behavior`:null,()=>window.electronAPI.system.getBehavior()),Y=O?.targetKind===`mobile`?O.universalLink:``,X=ee(()=>fe(Y),[Y],{enabled:!!Y,initial:null,errorData:null}),Z=r===`zh`?`https://xopc.ai/zh#download`:`https://xopc.ai/en#download`,me=r===`zh`?`https://xopcai.github.io/xopc/zh/browser-extension`:`https://xopcai.github.io/xopc/browser-extension`,he=ee(()=>fe(Z),[Z],{enabled:!T&&e===`mobile`,initial:null,errorData:null});(0,U.useEffect)(()=>{z.current=!0;let e=setInterval(()=>se(Date.now()),1e3);return()=>{z.current=!1,clearInterval(e),B.current&&re(B.current).catch(()=>{})}},[]);let ge=(0,U.useCallback)(async()=>{if(!V.current){V.current=!0,F(!0),M(null);try{B.current&&await re(B.current),B.current=null,k(void 0);let t=await ie(e);if(t.kind===`ready`){if(!z.current){await re(t.setup.id);return}B.current=t.setup.id,k(t.setup)}else await D.mutate()}catch{z.current&&M(`create`)}finally{V.current=!1,z.current&&F(!1)}}},[D,e]);(0,U.useEffect)(()=>{D.data?.ready&&!O&&j!==`create`&&!V.current&&ge()},[D.data,O,j,ge]),(0,U.useEffect)(()=>{K&&!ue.current&&(ue.current=!0,n?.())},[K,n]);let _e=async e=>{if(W){F(!0),M(null);try{await le(W,e),await H.mutate()}catch{M(`decision`),await H.mutate()}finally{z.current&&F(!1)}}},ve=(0,U.useRef)(0);(0,U.useEffect)(()=>{H.data&&(ve.current=H.data.serverTime-Date.now())},[H.data]);let Q=ne+ve.current,ye=O&&Q>=O.expiresAt&&!W,be=W&&[`expired`,`rejected`,`cancelled`].includes(W.status),xe=O?O.expiresAt-Q<6e4:!1,Se=O?xe?`${Math.max(0,Math.ceil((O.expiresAt-Q)/1e3))}s`:v.valid:``,$=e===`mobile`?{connect:a.mobileScan,connectHint:a.mobileScanHint,allowTitle:a.mobileAllowTitle,success:a.mobileSuccess,successHint:a.mobileSuccessHint}:{connect:a.browserConnect,connectHint:a.browserConnectHint,allowTitle:a.browserAllowTitle,success:a.browserSuccess,successHint:a.browserSuccessHint},Ce=e===`mobile`?a.mobilePrepareTitle:a.browserPrepareTitle,we=e===`mobile`?a.mobilePrepareHint:a.browserPrepareHint,Te=T?K?$.success:W?.status===`pending`?$.allowTitle:G||W?.status===`approved`?v.waiting:O?$.connect:v.title:Ce,Ee=j===`create`?v.createFailed:j===`decision`?v.decisionFailed:j===`background`?v.backgroundFailed:j===`download`?a.browserDownloadFailed:null,De=async()=>{F(!0),M(null);try{await ce()}catch{M(`download`)}finally{z.current&&F(!1)}};return(0,q.jsxs)(h,{children:[(0,q.jsx)(p,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),(0,q.jsxs)(g,{className:d(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(600px,calc(100dvh-48px))] w-[min(560px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,C),children:[(0,q.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[(0,q.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),(0,q.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":v.cancel,onClick:t,children:(0,q.jsx)(l,{className:`size-4`})})]}),(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-8 py-7`,children:[K?(0,q.jsx)(o,{className:`mb-5 size-7 text-success`}):null,(0,q.jsx)(_,{className:`text-xl font-semibold tracking-tight text-fg`,children:Te}),(0,q.jsx)(m,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:T?K?$.successHint:G?v.waitingForDevice:W?W.displayName:O?$.connectHint:v.intro:we}),Ee?(0,q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:Ee}):null,T&&D.error?(0,q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:v.readinessFailed}):null,T&&H.error?(0,q.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-warning`,children:v.statusUnavailable}):null,T?D.data?K?(0,q.jsxs)(q.Fragment,{children:[J.data?(0,q.jsxs)(`label`,{className:`mt-8 flex items-center justify-between gap-4 border-y border-edge-subtle py-5 text-sm text-fg`,children:[a.background,(0,q.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":J.data.runInBackground??!1,disabled:!J.data.backgroundSupported,checked:J.data.runInBackground??!1,className:`size-5 accent-accent`,onChange:e=>{window.electronAPI.system.setBehavior({runInBackground:e.target.checked}).then(e=>J.mutate(e.behavior)).catch(()=>M(`background`))}})]}):null,(0,q.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:a.sleep})]}):be||ye?(0,q.jsxs)(`div`,{className:`mt-10 space-y-5`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ye||W?.status===`expired`?v.expired:v.declined}),(0,q.jsx)(x,{variant:`primary`,onClick:()=>void ge(),disabled:N,children:v.refresh})]}):W?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:v.scope}),(0,q.jsxs)(`p`,{className:`mt-10 font-mono text-4xl tracking-[0.16em] text-fg`,"aria-live":`polite`,children:[W.confirmationCode.slice(0,3),` `,W.confirmationCode.slice(3)]}),(0,q.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:v.compare}),(0,q.jsxs)(`details`,{className:`mt-6 text-xs text-fg-muted`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer py-2`,children:v.access}),(0,q.jsx)(`p`,{children:v.accessHint})]})]}):O?.targetKind===`mobile`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`my-6 flex flex-col items-center`,children:[(0,q.jsx)(`div`,{className:`rounded-[1.75rem] border border-edge bg-surface-hover/55 p-2.5 shadow-surface`,children:(0,q.jsx)(`div`,{className:`rounded-[1.25rem] bg-white p-2 shadow-sm ring-1 ring-black/5`,children:X.data?(0,q.jsx)(`img`,{src:X.data,alt:a.qrAlt,width:240,height:240,className:`size-[240px] max-w-full rounded-xl bg-white`}):X.error?null:(0,q.jsx)(S,{className:`size-[240px] rounded-xl`})})}),X.error?null:(0,q.jsxs)(`p`,{className:d(`mt-4 inline-flex min-h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium`,xe?`bg-warning-soft text-warning`:`bg-surface-hover text-fg-muted`),"aria-live":`polite`,children:[(0,q.jsx)(A,{className:`size-3.5`,"aria-hidden":`true`}),Se]})]}),X.error?(0,q.jsx)(`p`,{role:`status`,className:`text-center text-sm text-warning`,children:v.qrFailed}):null,X.error?(0,q.jsx)(`div`,{className:`mt-5`,children:(0,q.jsx)(I,{text:O.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}):(0,q.jsxs)(`details`,{className:`group mx-auto mt-1 w-full max-w-sm rounded-xl border border-edge bg-surface-panel text-xs text-fg-muted`,children:[(0,q.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-3.5 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,children:[(0,q.jsx)(`span`,{children:v.fallback}),(0,q.jsx)(P,{className:`size-3.5 shrink-0 transition-transform group-open:rotate-90`,"aria-hidden":`true`})]}),(0,q.jsx)(`div`,{className:`border-t border-edge-subtle p-3`,children:(0,q.jsx)(I,{text:O.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})})]})]}):O?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`ol`,{className:`mt-7 space-y-2 text-sm leading-6 text-fg-muted`,children:[(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserConnectStep1]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserConnectStep2]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserConnectStep3]})]}),(0,q.jsx)(`div`,{className:`mt-6`,children:(0,q.jsx)(I,{text:O.browserInvitation,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}),(0,q.jsx)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,children:O.expiresAt-Q<6e4?`${Math.max(0,Math.ceil((O.expiresAt-Q)/1e3))}s`:v.valid})]}):D.data.ready?(0,q.jsx)(`div`,{className:`mt-8`,children:(0,q.jsx)(S,{className:`mx-auto size-[216px]`})}):(0,q.jsxs)(`div`,{className:`mt-6 flex flex-1 flex-col`,children:[L===`tailscale`?(0,q.jsx)(de,{embedded:!0}):L===`https`?(0,q.jsx)(te,{}):L===`choices`?(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(x,{variant:`secondary`,className:`w-full`,onClick:()=>R(`tailscale`),children:a.useTailscale}),(0,q.jsx)(x,{variant:`secondary`,className:`w-full`,onClick:()=>R(`https`),children:a.useOwnHttps})]}):(0,q.jsx)(pe,{}),(0,q.jsx)(x,{variant:`ghost`,className:`mt-3 w-full`,onClick:()=>R(L?null:`choices`),children:L?v.back:v.existing})]}):(0,q.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,q.jsx)(S,{className:`h-5 w-3/4`}),(0,q.jsx)(S,{className:`h-40 w-full`})]}):e===`mobile`?(0,q.jsxs)(`div`,{className:`mt-7 flex flex-col items-center`,children:[he.data?(0,q.jsx)(`img`,{src:he.data,alt:a.mobileDownloadQrAlt,width:144,height:144,className:`size-36 rounded-lg bg-white`}):(0,q.jsx)(S,{className:`size-36`}),(0,q.jsxs)(x,{variant:`secondary`,className:`mt-5 w-full`,onClick:()=>void y(Z),children:[(0,q.jsx)(c,{className:`size-4`}),a.mobileDownload]}),(0,q.jsx)(`p`,{className:`mt-3 text-center text-xs leading-5 text-fg-muted`,children:a.mobileDownloadHint})]}):(0,q.jsxs)(`div`,{className:`mt-7`,children:[(0,q.jsxs)(x,{variant:`secondary`,className:`w-full`,disabled:N,onClick:()=>void De(),children:[(0,q.jsx)(s,{className:`size-4`}),a.browserDownload]}),(0,q.jsxs)(`ol`,{className:`mt-5 space-y-3 text-sm leading-6 text-fg-muted`,children:[(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserInstallStep1]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserInstallStep2]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserInstallStep3]})]}),(0,q.jsxs)(`button`,{type:`button`,className:`mt-5 inline-flex items-center gap-1 text-xs text-accent hover:underline`,onClick:()=>void y(me),children:[a.browserInstallHelp,(0,q.jsx)(c,{className:`size-3`})]})]})]}),!T||D.error||K||W?.status===`pending`||j===`create`||j===`decision`?(0,q.jsx)(`footer`,{className:`shrink-0 px-8 pb-6`,children:T?K?(0,q.jsx)(x,{className:`w-full`,variant:`primary`,onClick:t,children:v.done}):W?.status===`pending`?(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsx)(x,{className:`w-full`,variant:`primary`,disabled:N,onClick:()=>void _e(`approve`),children:v.allow}),(0,q.jsx)(x,{className:`w-full`,variant:`ghost`,disabled:N,onClick:()=>void _e(`reject`),children:v.cancel})]}):D.error?(0,q.jsx)(x,{className:`w-full`,variant:`primary`,onClick:()=>void D.mutate(),children:v.retry}):(0,q.jsx)(x,{className:`w-full`,variant:`primary`,disabled:N,onClick:()=>void ge(),children:v.retry}):(0,q.jsx)(x,{className:`w-full`,variant:`primary`,onClick:()=>{M(null),E(!0)},children:e===`mobile`?a.mobileReady:a.browserReady})}):null]})]})}export{J as n,Y as t};
|
|
1
|
+
import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{f as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./x-B_N4OPjy.js";import{t as u}from"./messages-sXePe3LQ.js";import{t as d}from"./cn-JdwAhgNB.js";import{n as f}from"./locale-store-WMaCMm3_.js";import{a as p,i as m,o as h,r as g,s as _,t as v}from"./dist-BGTk37IG.js";import{n as y}from"./app-link-DRL0YnPs.js";import{i as b}from"./vendor-swr-BIWyz7Rc.js";import{t as x}from"./button-CS04eWY9.js";import{t as S}from"./skeleton-BwbyijEw.js";import{i as C,o as w}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{Bl as T,Bt as E,Lt as D,Mt as O,Nt as k,Ou as A,Pc as j,Pt as M,Rt as N,Vu as P,ll as F,ua as I,xo as ee}from"./index-Bb32g7Ll.js";import{_ as te,a as ne,d as re,f as ie,g as ae,h as oe,i as se,l as L,m as ce,n as R,p as le,r as z,s as B,t as V,u as ue,v as de}from"./tunnel-api-vZ7P_KIQ.js";import{t as H}from"./browser-BLJWD7WI.js";var U=e(n(),1),W=r(),G=e(H(),1),K={width:240,margin:4,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function fe(e){let t=await G.toString(e,{...K,type:`svg`});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}var q=i();function pe(){let e=u(f(e=>e.language)),t=e.endpointToolsSettings.deviceAccess.flow,n=e.tunnelSettings,{data:r,error:i,mutate:a}=b(`tunnel-status`,R,{refreshInterval:1500}),[o,s]=(0,U.useState)(!1),[l,d]=(0,U.useState)(!1),[p,m]=(0,U.useState)(!0),[h,g]=(0,U.useState)(`idle`),[_,v]=(0,U.useState)(null),[C,w]=(0,U.useState)(``),T=(0,U.useRef)(!0);(0,U.useEffect)(()=>(T.current=!0,()=>{T.current=!1}),[]);let A=async()=>{if(!r)return;if(r.consentRequired&&!o){d(!0);return}let e=r.registrationSecret?.configured?null:M(),t,n=!1;v(null);try{if(r.consentRequired&&await ne(),!r.registrationSecret?.configured){g(`provisioning`);let r=!1;try{await se()}catch(e){if(!ue(e))throw e;r=!0}if(r){g(`authorizing`);let r=sessionStorage.getItem(`device-pairing-oauth`),i=r?JSON.parse(r):null;t=i&&i.expiresAt>Date.now()?i.sessionId:(await E(`xopc-tunnel`)).sessionId,sessionStorage.setItem(`device-pairing-oauth`,JSON.stringify({sessionId:t,expiresAt:i&&i.expiresAt>Date.now()?i.expiresAt:Date.now()+5*6e4}));let a=``,o=Date.now()+5*6e4,s=!1;for(;T.current&&Date.now()<o;){let r=await N(t);if(r.authUrl&&r.authUrl!==a&&(a=r.authUrl,await k(a,e)||w(a)),r.status===`completed`){s=!0,n=!0;break}if(r.status===`failed`||r.status===`cancelled`)throw Error(`Authorization cancelled`);await new Promise(e=>setTimeout(e,1e3))}if(!T.current)return;if(!s)throw Error(`Authorization expired`);await se()}await a()}if(!T.current)return;g(`starting`),await B(),p&&await z({autoStart:!0}),await a(),n=!0}catch(e){n=!0,T.current&&v(L(e)===`tunnel_key_limit_reached`?`key-limit`:`failed`)}finally{O(e),n&&(sessionStorage.removeItem(`device-pairing-oauth`),t&&D(t).catch(()=>{})),T.current&&(g(`idle`),w(``))}};if(!r&&!i)return(0,q.jsxs)(`div`,{className:`space-y-5`,children:[(0,q.jsx)(S,{className:`h-5 w-4/5`}),(0,q.jsx)(S,{className:`h-24 w-full`})]});let j=h===`provisioning`||h===`starting`||r?.state===`connecting`||r?.state===`reconnecting`;return(0,q.jsxs)(`div`,{className:`flex min-h-full flex-col`,children:[(0,q.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:j?t.preparingHint:h===`authorizing`?t.authorizing:t.enableHint}),C&&h===`authorizing`?(0,q.jsx)(`a`,{href:C,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 inline-flex min-h-11 items-center text-sm text-accent`,children:t.openAuthorization}):null,j?(0,q.jsxs)(`div`,{className:`mt-8 space-y-3`,"aria-label":t.preparing,children:[(0,q.jsx)(S,{className:`h-2 w-full`}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.preparing})]}):null,(l||r?.consentRequired)&&h===`idle`?(0,q.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,q.jsxs)(`details`,{open:l,className:`text-sm text-fg-muted`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,q.jsx)(`p`,{className:`mt-2`,children:n.consentIntro}),(0,q.jsx)(`ul`,{className:`mt-3 list-disc space-y-2 pl-5`,children:[n.consentBullet1,n.consentBullet2,n.consentBullet3].map(e=>(0,q.jsx)(`li`,{children:e},e))})]}),(0,q.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),className:`mt-1 size-4 accent-accent`}),n.consentCheckbox]})]}):null,_===`key-limit`?(0,q.jsxs)(`div`,{role:`alert`,className:`mt-4 rounded-lg border border-warning/30 bg-warning/5 p-4`,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.routeKeyLimitTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.routeKeyLimitHint}),(0,q.jsxs)(x,{variant:`secondary`,className:`mt-3`,onClick:()=>void y(V),children:[t.manageTunnelKeys,(0,q.jsx)(c,{className:`size-3`})]})]}):_||i||r?.state===`error`?(0,q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:t.routeSetupFailed}):null,(0,q.jsx)(`div`,{className:`flex-1`}),(0,q.jsxs)(`label`,{className:`my-5 flex items-center gap-3 text-sm text-fg-muted`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:p,disabled:h!==`idle`,onChange:e=>m(e.target.checked),className:`size-4 accent-accent`}),t.autoStart]}),(0,q.jsx)(x,{className:`w-full`,variant:`primary`,disabled:!r||h!==`idle`||j||l&&!o,onClick:()=>void A(),children:h===`authorizing`?t.authorizing:j?t.preparing:_?t.retry:t.enable}),i&&!r?(0,q.jsx)(x,{variant:`ghost`,onClick:()=>void a(),children:t.retry}):null]})}var J=t({DevicePairingWizard:()=>Y});function Y(e){let t=(0,W.c)(16),{open:n,onOpenChange:r,onPaired:i,targetKind:o}=e,s=a(),[c,l]=(0,U.useState)(o),u,d;t[0]===o?(u=t[1],d=t[2]):(u=()=>{l(o)},d=[o],t[0]=o,t[1]=u,t[2]=d),(0,U.useEffect)(u,d);let f;t[3]!==r||t[4]!==o?(f=e=>{e||l(o),r(e)},t[3]=r,t[4]=o,t[5]=f):f=t[5];let p=f,m;t[6]!==p||t[7]!==s||t[8]!==i||t[9]!==n||t[10]!==c?(m=n?c?(0,q.jsx)(he,{targetKind:c,onClose:()=>p(!1),onPaired:i}):(0,q.jsx)(Z,{onChoose:l,onChooseLocalBrowser:()=>{p(!1),s(`/settings/agent-browser?driver=extension`)},onClose:()=>p(!1)}):null,t[6]=p,t[7]=s,t[8]=i,t[9]=n,t[10]=c,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==n||t[14]!==m?(h=(0,q.jsx)(v,{open:n,onOpenChange:p,children:m}),t[12]=p,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function X(e){let t=(0,W.c)(14),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,q.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,q.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,q.jsx)(P,{className:`size-4 shrink-0 text-fg-disabled transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":`true`}),t[9]=u):u=t[9];let d;return t[10]!==a||t[11]!==o||t[12]!==l?(d=(0,q.jsxs)(`button`,{type:`button`,className:`group flex min-h-18 w-full cursor-pointer items-center gap-4 rounded-xl border border-edge bg-surface-panel px-4 py-3.5 text-left shadow-surface transition-[background-color,border-color,box-shadow,transform] hover:border-edge-strong hover:bg-surface-active hover:shadow-elevated active:translate-y-px active:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel motion-reduce:active:translate-y-0`,onClick:a,children:[o,l,u]}),t[10]=a,t[11]=o,t[12]=l,t[13]=d):d=t[13],d}function Z(e){let t=(0,W.c)(40),{onChoose:n,onChooseLocalBrowser:r,onClose:i}=e,a=f(me),o;t[0]===a?o=t[1]:(o=u(a),t[0]=a,t[1]=o);let s=o.endpointToolsSettings.deviceAccess,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,q.jsx)(p,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),t[2]=c):c=t[2];let v;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(v=d(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(28rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,C),t[3]=v):v=t[3];let y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,q.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),t[4]=y):y=t[4];let b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,q.jsx)(l,{className:`size-4`}),t[5]=b):b=t[5];let x;t[6]!==s.cancel||t[7]!==i?(x=(0,q.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[y,(0,q.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":s.cancel,onClick:i,children:b})]}),t[6]=s.cancel,t[7]=i,t[8]=x):x=t[8];let S;t[9]===s.chooseTitle?S=t[10]:(S=(0,q.jsx)(_,{className:`text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:s.chooseTitle}),t[9]=s.chooseTitle,t[10]=S);let E;t[11]===s.chooseHint?E=t[12]:(E=(0,q.jsx)(m,{className:`mt-1.5 text-sm leading-6 text-fg-muted`,children:s.chooseHint}),t[11]=s.chooseHint,t[12]=E);let D;t[13]!==s.localBrowserHint||t[14]!==s.localBrowserTitle||t[15]!==r?(D=(0,q.jsx)(X,{icon:T,title:s.localBrowserTitle,hint:s.localBrowserHint,onClick:r}),t[13]=s.localBrowserHint,t[14]=s.localBrowserTitle,t[15]=r,t[16]=D):D=t[16];let O;t[17]===n?O=t[18]:(O=()=>n(`mobile`),t[17]=n,t[18]=O);let k;t[19]!==s.mobileHint||t[20]!==s.mobileTitle||t[21]!==O?(k=(0,q.jsx)(X,{icon:j,title:s.mobileTitle,hint:s.mobileHint,onClick:O}),t[19]=s.mobileHint,t[20]=s.mobileTitle,t[21]=O,t[22]=k):k=t[22];let A;t[23]===n?A=t[24]:(A=()=>n(`browser`),t[23]=n,t[24]=A);let M;t[25]!==s.remoteBrowserHint||t[26]!==s.remoteBrowserTitle||t[27]!==A?(M=(0,q.jsx)(X,{icon:F,title:s.remoteBrowserTitle,hint:s.remoteBrowserHint,onClick:A}),t[25]=s.remoteBrowserHint,t[26]=s.remoteBrowserTitle,t[27]=A,t[28]=M):M=t[28];let N;t[29]!==k||t[30]!==M||t[31]!==D?(N=(0,q.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2.5`,children:[D,k,M]}),t[29]=k,t[30]=M,t[31]=D,t[32]=N):N=t[32];let P;t[33]!==N||t[34]!==S||t[35]!==E?(P=(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-6 sm:px-8`,children:[S,E,N]}),t[33]=N,t[34]=S,t[35]=E,t[36]=P):P=t[36];let I;return t[37]!==P||t[38]!==x?(I=(0,q.jsxs)(h,{children:[c,(0,q.jsxs)(g,{className:v,children:[x,P]})]}),t[37]=P,t[38]=x,t[39]=I):I=t[39],I}function me(e){return e.language}function he({targetKind:e,onClose:t,onPaired:n}){let r=f(e=>e.language),i=u(r),a=i.endpointToolsSettings.deviceAccess,v=a.flow,[T,E]=(0,U.useState)(!1),D=b(T?`device-pairing-readiness`:null,oe,{refreshInterval:1500}),[O,k]=(0,U.useState)(),[j,M]=(0,U.useState)(null),[N,F]=(0,U.useState)(!1),[ne,se]=(0,U.useState)(Date.now()),[L,R]=(0,U.useState)(null),z=(0,U.useRef)(!0),B=(0,U.useRef)(null),V=(0,U.useRef)(!1),ue=(0,U.useRef)(!1),H=b(O?[`device-pairing-setup`,O.id]:null,()=>ae(O.id),{refreshInterval:1500}),W=H.data?.request,G=W?.status===`completed`,K=G&&W.connectedAt!==void 0,J=b(K&&window.electronAPI?.system?`system-behavior`:null,()=>window.electronAPI.system.getBehavior()),Y=O?.targetKind===`mobile`?O.universalLink:``,X=ee(()=>fe(Y),[Y],{enabled:!!Y,initial:null,errorData:null}),Z=r===`zh`?`https://xopc.ai/zh#download`:`https://xopc.ai/en#download`,me=r===`zh`?`https://xopcai.github.io/xopc/zh/browser-extension`:`https://xopcai.github.io/xopc/browser-extension`,he=ee(()=>fe(Z),[Z],{enabled:!T&&e===`mobile`,initial:null,errorData:null});(0,U.useEffect)(()=>{z.current=!0;let e=setInterval(()=>se(Date.now()),1e3);return()=>{z.current=!1,clearInterval(e),B.current&&re(B.current).catch(()=>{})}},[]);let ge=(0,U.useCallback)(async()=>{if(!V.current){V.current=!0,F(!0),M(null);try{B.current&&await re(B.current),B.current=null,k(void 0);let t=await ie(e);if(t.kind===`ready`){if(!z.current){await re(t.setup.id);return}B.current=t.setup.id,k(t.setup)}else await D.mutate()}catch{z.current&&M(`create`)}finally{V.current=!1,z.current&&F(!1)}}},[D,e]);(0,U.useEffect)(()=>{D.data?.ready&&!O&&j!==`create`&&!V.current&&ge()},[D.data,O,j,ge]),(0,U.useEffect)(()=>{K&&!ue.current&&(ue.current=!0,n?.())},[K,n]);let _e=async e=>{if(W){F(!0),M(null);try{await le(W,e),await H.mutate()}catch{M(`decision`),await H.mutate()}finally{z.current&&F(!1)}}},ve=(0,U.useRef)(0);(0,U.useEffect)(()=>{H.data&&(ve.current=H.data.serverTime-Date.now())},[H.data]);let Q=ne+ve.current,ye=O&&Q>=O.expiresAt&&!W,be=W&&[`expired`,`rejected`,`cancelled`].includes(W.status),xe=O?O.expiresAt-Q<6e4:!1,Se=O?xe?`${Math.max(0,Math.ceil((O.expiresAt-Q)/1e3))}s`:v.valid:``,$=e===`mobile`?{connect:a.mobileScan,connectHint:a.mobileScanHint,allowTitle:a.mobileAllowTitle,success:a.mobileSuccess,successHint:a.mobileSuccessHint}:{connect:a.browserConnect,connectHint:a.browserConnectHint,allowTitle:a.browserAllowTitle,success:a.browserSuccess,successHint:a.browserSuccessHint},Ce=e===`mobile`?a.mobilePrepareTitle:a.browserPrepareTitle,we=e===`mobile`?a.mobilePrepareHint:a.browserPrepareHint,Te=T?K?$.success:W?.status===`pending`?$.allowTitle:G||W?.status===`approved`?v.waiting:O?$.connect:v.title:Ce,Ee=j===`create`?v.createFailed:j===`decision`?v.decisionFailed:j===`background`?v.backgroundFailed:j===`download`?a.browserDownloadFailed:null,De=async()=>{F(!0),M(null);try{await ce()}catch{M(`download`)}finally{z.current&&F(!1)}};return(0,q.jsxs)(h,{children:[(0,q.jsx)(p,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),(0,q.jsxs)(g,{className:d(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(600px,calc(100dvh-48px))] w-[min(560px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,C),children:[(0,q.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[(0,q.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),(0,q.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":v.cancel,onClick:t,children:(0,q.jsx)(l,{className:`size-4`})})]}),(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-8 py-7`,children:[K?(0,q.jsx)(o,{className:`mb-5 size-7 text-success`}):null,(0,q.jsx)(_,{className:`text-xl font-semibold tracking-tight text-fg`,children:Te}),(0,q.jsx)(m,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:T?K?$.successHint:G?v.waitingForDevice:W?W.displayName:O?$.connectHint:v.intro:we}),Ee?(0,q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:Ee}):null,T&&D.error?(0,q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:v.readinessFailed}):null,T&&H.error?(0,q.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-warning`,children:v.statusUnavailable}):null,T?D.data?K?(0,q.jsxs)(q.Fragment,{children:[J.data?(0,q.jsxs)(`label`,{className:`mt-8 flex items-center justify-between gap-4 border-y border-edge-subtle py-5 text-sm text-fg`,children:[a.background,(0,q.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":J.data.runInBackground??!1,disabled:!J.data.backgroundSupported,checked:J.data.runInBackground??!1,className:`size-5 accent-accent`,onChange:e=>{window.electronAPI.system.setBehavior({runInBackground:e.target.checked}).then(e=>J.mutate(e.behavior)).catch(()=>M(`background`))}})]}):null,(0,q.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:a.sleep})]}):be||ye?(0,q.jsxs)(`div`,{className:`mt-10 space-y-5`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ye||W?.status===`expired`?v.expired:v.declined}),(0,q.jsx)(x,{variant:`primary`,onClick:()=>void ge(),disabled:N,children:v.refresh})]}):W?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:v.scope}),(0,q.jsxs)(`p`,{className:`mt-10 font-mono text-4xl tracking-[0.16em] text-fg`,"aria-live":`polite`,children:[W.confirmationCode.slice(0,3),` `,W.confirmationCode.slice(3)]}),(0,q.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:v.compare}),(0,q.jsxs)(`details`,{className:`mt-6 text-xs text-fg-muted`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer py-2`,children:v.access}),(0,q.jsx)(`p`,{children:v.accessHint})]})]}):O?.targetKind===`mobile`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`my-6 flex flex-col items-center`,children:[(0,q.jsx)(`div`,{className:`rounded-[1.75rem] border border-edge bg-surface-hover/55 p-2.5 shadow-surface`,children:(0,q.jsx)(`div`,{className:`rounded-[1.25rem] bg-white p-2 shadow-sm ring-1 ring-black/5`,children:X.data?(0,q.jsx)(`img`,{src:X.data,alt:a.qrAlt,width:240,height:240,className:`size-[240px] max-w-full rounded-xl bg-white`}):X.error?null:(0,q.jsx)(S,{className:`size-[240px] rounded-xl`})})}),X.error?null:(0,q.jsxs)(`p`,{className:d(`mt-4 inline-flex min-h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium`,xe?`bg-warning-soft text-warning`:`bg-surface-hover text-fg-muted`),"aria-live":`polite`,children:[(0,q.jsx)(A,{className:`size-3.5`,"aria-hidden":`true`}),Se]})]}),X.error?(0,q.jsx)(`p`,{role:`status`,className:`text-center text-sm text-warning`,children:v.qrFailed}):null,X.error?(0,q.jsx)(`div`,{className:`mt-5`,children:(0,q.jsx)(I,{text:O.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}):(0,q.jsxs)(`details`,{className:`group mx-auto mt-1 w-full max-w-sm rounded-xl border border-edge bg-surface-panel text-xs text-fg-muted`,children:[(0,q.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-3.5 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,children:[(0,q.jsx)(`span`,{children:v.fallback}),(0,q.jsx)(P,{className:`size-3.5 shrink-0 transition-transform group-open:rotate-90`,"aria-hidden":`true`})]}),(0,q.jsx)(`div`,{className:`border-t border-edge-subtle p-3`,children:(0,q.jsx)(I,{text:O.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})})]})]}):O?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`ol`,{className:`mt-7 space-y-2 text-sm leading-6 text-fg-muted`,children:[(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserConnectStep1]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserConnectStep2]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserConnectStep3]})]}),(0,q.jsx)(`div`,{className:`mt-6`,children:(0,q.jsx)(I,{text:O.browserInvitation,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}),(0,q.jsx)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,children:O.expiresAt-Q<6e4?`${Math.max(0,Math.ceil((O.expiresAt-Q)/1e3))}s`:v.valid})]}):D.data.ready?(0,q.jsx)(`div`,{className:`mt-8`,children:(0,q.jsx)(S,{className:`mx-auto size-[216px]`})}):(0,q.jsxs)(`div`,{className:`mt-6 flex flex-1 flex-col`,children:[L===`tailscale`?(0,q.jsx)(de,{embedded:!0}):L===`https`?(0,q.jsx)(te,{}):L===`choices`?(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(x,{variant:`secondary`,className:`w-full`,onClick:()=>R(`tailscale`),children:a.useTailscale}),(0,q.jsx)(x,{variant:`secondary`,className:`w-full`,onClick:()=>R(`https`),children:a.useOwnHttps})]}):(0,q.jsx)(pe,{}),(0,q.jsx)(x,{variant:`ghost`,className:`mt-3 w-full`,onClick:()=>R(L?null:`choices`),children:L?v.back:v.existing})]}):(0,q.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,q.jsx)(S,{className:`h-5 w-3/4`}),(0,q.jsx)(S,{className:`h-40 w-full`})]}):e===`mobile`?(0,q.jsxs)(`div`,{className:`mt-7 flex flex-col items-center`,children:[he.data?(0,q.jsx)(`img`,{src:he.data,alt:a.mobileDownloadQrAlt,width:144,height:144,className:`size-36 rounded-lg bg-white`}):(0,q.jsx)(S,{className:`size-36`}),(0,q.jsxs)(x,{variant:`secondary`,className:`mt-5 w-full`,onClick:()=>void y(Z),children:[(0,q.jsx)(c,{className:`size-4`}),a.mobileDownload]}),(0,q.jsx)(`p`,{className:`mt-3 text-center text-xs leading-5 text-fg-muted`,children:a.mobileDownloadHint})]}):(0,q.jsxs)(`div`,{className:`mt-7`,children:[(0,q.jsxs)(x,{variant:`secondary`,className:`w-full`,disabled:N,onClick:()=>void De(),children:[(0,q.jsx)(s,{className:`size-4`}),a.browserDownload]}),(0,q.jsxs)(`ol`,{className:`mt-5 space-y-3 text-sm leading-6 text-fg-muted`,children:[(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserInstallStep1]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserInstallStep2]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserInstallStep3]})]}),(0,q.jsxs)(`button`,{type:`button`,className:`mt-5 inline-flex items-center gap-1 text-xs text-accent hover:underline`,onClick:()=>void y(me),children:[a.browserInstallHelp,(0,q.jsx)(c,{className:`size-3`})]})]})]}),!T||D.error||K||W?.status===`pending`||j===`create`||j===`decision`?(0,q.jsx)(`footer`,{className:`shrink-0 px-8 pb-6`,children:T?K?(0,q.jsx)(x,{className:`w-full`,variant:`primary`,onClick:t,children:v.done}):W?.status===`pending`?(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsx)(x,{className:`w-full`,variant:`primary`,disabled:N,onClick:()=>void _e(`approve`),children:v.allow}),(0,q.jsx)(x,{className:`w-full`,variant:`ghost`,disabled:N,onClick:()=>void _e(`reject`),children:v.cancel})]}):D.error?(0,q.jsx)(x,{className:`w-full`,variant:`primary`,onClick:()=>void D.mutate(),children:v.retry}):(0,q.jsx)(x,{className:`w-full`,variant:`primary`,disabled:N,onClick:()=>void ge(),children:v.retry}):(0,q.jsx)(x,{className:`w-full`,variant:`primary`,onClick:()=>{M(null),E(!0)},children:e===`mobile`?a.mobileReady:a.browserReady})}):null]})]})}export{J as n,Y as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{Aa as r,Ea as i,Ns as a,ja as o,su as s}from"./index-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{Aa as r,Ea as i,Ns as a,ja as o,su as s}from"./index-Bb32g7Ll.js";var c=e(),l=t();function u(e){let t=(0,c.c)(27),{value:r,onPick:i,disabled:u,placeholder:d,title:f,className:p,maxWidthClass:m,compact:h,"aria-label":g}=e,_=m===void 0?`max-w-[min(12rem,40vw)]`:m,v=h===void 0?!1:h,y,b;t[0]!==d||t[1]!==r?(b=r.trim(),y=b?o(b):d??``,t[0]=d,t[1]=r,t[2]=y,t[3]=b):(y=t[2],b=t[3]);let x=y,S=f??(b||void 0),C=g??f??x,w=v?`inline-flex size-9 shrink-0 items-center justify-center rounded-lg p-0`:`inline-flex min-h-8 min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,T=!v&&_,E=u&&`cursor-not-allowed opacity-60`,D;t[4]!==p||t[5]!==w||t[6]!==T||t[7]!==E?(D=n(w,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,a.transition,a.focusRingPanel,`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,T,E,p),t[4]=p,t[5]=w,t[6]=T,t[7]=E,t[8]=D):D=t[8];let O;t[9]!==u||t[10]!==i?(O=e=>{e.stopPropagation(),u||i()},t[9]=u,t[10]=i,t[11]=O):O=t[11];let k=v?`size-4`:`size-3.5`,A;t[12]===k?A=t[13]:(A=n(`shrink-0 text-fg-muted`,k),t[12]=k,t[13]=A);let j;t[14]===A?j=t[15]:(j=(0,l.jsx)(s,{className:A,"aria-hidden":!0}),t[14]=A,t[15]=j);let M;t[16]!==v||t[17]!==x?(M=v?null:(0,l.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:x}),t[16]=v,t[17]=x,t[18]=M):M=t[18];let N;return t[19]!==u||t[20]!==O||t[21]!==j||t[22]!==M||t[23]!==S||t[24]!==C||t[25]!==D?(N=(0,l.jsxs)(`button`,{type:`button`,disabled:u,title:S,"aria-label":C,className:D,onClick:O,children:[j,M]}),t[19]=u,t[20]=O,t[21]=j,t[22]=M,t[23]=S,t[24]=C,t[25]=D,t[26]=N):N=t[26],N}function d(e){let t=(0,c.c)(39),{value:a,onChange:o,disabled:s,wd:d,placeholder:f,inputAriaLabel:p,inputClassName:m,autoFocus:h,trailing:g}=e,_;t[0]!==o||t[1]!==a?(_={initialPath:a,onPicked:o},t[0]=o,t[1]=a,t[2]=_):_=t[2];let v=r(_),y;t[3]===a?y=t[4]:(y=a.trim(),t[3]=a,t[4]=y);let b=y,x=b?`${b}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,S;t[5]===m?S=t[6]:(S=n(`min-w-0 flex-1`,m),t[5]=m,t[6]=S);let C=s||v.picking,w;t[7]===o?w=t[8]:(w=e=>void o(e.target.value),t[7]=o,t[8]=w);let T=f??d.pathInputPlaceholder,E;t[9]!==h||t[10]!==p||t[11]!==S||t[12]!==C||t[13]!==w||t[14]!==T||t[15]!==a?(E=(0,l.jsx)(`input`,{type:`text`,className:S,value:a,disabled:C,onChange:w,placeholder:T,"aria-label":p,autoFocus:h,autoComplete:`off`,spellCheck:!1}),t[9]=h,t[10]=p,t[11]=S,t[12]=C,t[13]=w,t[14]=T,t[15]=a,t[16]=E):E=t[16];let D=s||v.picking,O;t[17]!==x||t[18]!==v.pick||t[19]!==D||t[20]!==a||t[21]!==d.selectWorkingDirectory?(O=(0,l.jsx)(u,{compact:!0,value:a,onPick:v.pick,disabled:D,title:x,"aria-label":d.selectWorkingDirectory}),t[17]=x,t[18]=v.pick,t[19]=D,t[20]=a,t[21]=d.selectWorkingDirectory,t[22]=O):O=t[22];let k;t[23]!==O||t[24]!==g?(k=(0,l.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[O,g]}),t[23]=O,t[24]=g,t[25]=k):k=t[25];let A;t[26]!==k||t[27]!==E?(A=(0,l.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[E,k]}),t[26]=k,t[27]=E,t[28]=A):A=t[28];let j;t[29]!==v.confirmPick||t[30]!==v.hasNativePicker||t[31]!==v.modalOpen||t[32]!==v.setModalOpen||t[33]!==b||t[34]!==d?(j=v.hasNativePicker?null:(0,l.jsx)(i,{open:v.modalOpen,onOpenChange:v.setModalOpen,initialAbsolutePath:b||void 0,onConfirm:v.confirmPick,wd:d}),t[29]=v.confirmPick,t[30]=v.hasNativePicker,t[31]=v.modalOpen,t[32]=v.setModalOpen,t[33]=b,t[34]=d,t[35]=j):j=t[35];let M;return t[36]!==A||t[37]!==j?(M=(0,l.jsxs)(l.Fragment,{children:[A,j]}),t[36]=A,t[37]=j,t[38]=M):M=t[38],M}export{d as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./messages-
|
|
1
|
+
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./messages-sXePe3LQ.js";import{n as i}from"./locale-store-WMaCMm3_.js";import{go as a}from"./index-Bb32g7Ll.js";import{n as o,r as s}from"./settings-page-layout-X1x-2Cp9.js";var c=t();e();var l=n();function u(){let e=(0,c.c)(40),t=i(p),n;e[0]===t?n=e[1]:(n=r(t),e[0]=t,e[1]=n);let u=n.extensionDebug,m=a(),h;e[2]===m?h=e[3]:(h=m.toSorted(f),e[2]=m,e[3]=h);let g=h,_;e[4]!==u.subtitle||e[5]!==u.title?(_=(0,l.jsx)(o,{title:u.title,subtitle:u.subtitle}),e[4]=u.subtitle,e[5]=u.title,e[6]=_):_=e[6];let v;e[7]===u.listHeading?v=e[8]:(v=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:u.listHeading}),e[7]=u.listHeading,e[8]=v);let y;e[9]===u.colId?y=e[10]:(y=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colId}),e[9]=u.colId,e[10]=y);let b;e[11]===u.colName?b=e[12]:(b=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colName}),e[11]=u.colName,e[12]=b);let x;e[13]===u.colPermissions?x=e[14]:(x=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colPermissions}),e[13]=u.colPermissions,e[14]=x);let S;e[15]!==y||e[16]!==b||e[17]!==x?(S=(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`text-xs uppercase text-fg-muted`,children:[y,b,x]})}),e[15]=y,e[16]=b,e[17]=x,e[18]=S):S=e[18];let C;e[19]===g?C=e[20]:(C=g.map(d),e[19]=g,e[20]=C);let w;e[21]===C?w=e[22]:(w=(0,l.jsx)(`tbody`,{children:C}),e[21]=C,e[22]=w);let T;e[23]!==S||e[24]!==w?(T=(0,l.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full min-w-[32rem] border-separate border-spacing-y-1 text-left text-sm`,children:[S,w]})}),e[23]=S,e[24]=w,e[25]=T):T=e[25];let E;e[26]!==T||e[27]!==v?(E=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[v,T]}),e[26]=T,e[27]=v,e[28]=E):E=e[28];let D;e[29]===u.futureHeading?D=e[30]:(D=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:u.futureHeading}),e[29]=u.futureHeading,e[30]=D);let O;e[31]===u.futureBody?O=e[32]:(O=(0,l.jsx)(`p`,{className:`mt-2`,children:u.futureBody}),e[31]=u.futureBody,e[32]=O);let k;e[33]!==D||e[34]!==O?(k=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4 text-sm text-fg-muted`,children:[D,O]}),e[33]=D,e[34]=O,e[35]=k):k=e[35];let A;return e[36]!==E||e[37]!==k||e[38]!==_?(A=(0,l.jsxs)(s,{gap:`gap-5`,children:[_,E,k]}),e[36]=E,e[37]=k,e[38]=_,e[39]=A):A=e[39],A}function d(e){return(0,l.jsxs)(`tr`,{className:`bg-surface-base/55`,children:[(0,l.jsx)(`td`,{className:`rounded-l-lg px-3 py-2 font-mono text-xs text-fg`,children:e.id}),(0,l.jsx)(`td`,{className:`px-3 py-2 text-fg`,children:e.name}),(0,l.jsx)(`td`,{className:`rounded-r-lg px-3 py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function f(e,t){return e.id.localeCompare(t.id)}function p(e){return e.language}export{u as ExtensionDebugPage};
|
package/dist/gateway/static/root/assets/{extension-page-DxiiQ_-P.js → extension-page-BjLN3E6q.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{So as a,go as o,xi as s,yo as c}from"./index-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{So as a,go as o,xi as s,yo as c}from"./index-Bb32g7Ll.js";var l=n(),u=e(t(),1),d=r();function f(){let e=(0,l.c)(26),{extensionId:t,pageId:n}=i(),r=o(),f=a(m),g=a(p),_,v,y;e[0]!==t||e[1]!==r||e[2]!==n?(_=t?r.find(e=>e.id===t&&c(e)):void 0,v=_?.ui?.contributions?.pages,y=t&&v?.length?n?v.find(e=>e.id===n||e.id===`${t}.${n}`):v[0]:void 0,e[0]=t,e[1]=r,e[2]=n,e[3]=_,e[4]=v,e[5]=y):(_=e[3],v=e[4],y=e[5]);let b=y,x,S;if(e[6]!==g||e[7]!==_||e[8]!==t||e[9]!==b||e[10]!==f?(x=()=>{if(!t||!_||!b)return g(),()=>g();let e=b.title?.trim()||_.name||t;return f({startExtra:null,main:(0,d.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,d.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,title:e,children:e})}),end:null}),()=>g()},S=[g,_,t,b,f],e[6]=g,e[7]=_,e[8]=t,e[9]=b,e[10]=f,e[11]=x,e[12]=S):(x=e[11],S=e[12]),(0,u.useLayoutEffect)(x,S),!t){let t;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,d.jsx)(h,{message:`No extension ID provided.`}),e[13]=t):t=e[13],t}if(!_){let n=`Extension "${t}" not found or has no UI.`,r;return e[14]===n?r=e[15]:(r=(0,d.jsx)(h,{message:n}),e[14]=n,e[15]=r),r}if(!v?.length){let n=`Extension "${t}" has no page contributions.`,r;return e[16]===n?r=e[17]:(r=(0,d.jsx)(h,{message:n}),e[16]=n,e[17]=r),r}if(!b){let r=`Page "${n}" not found in extension "${t}".`,i;return e[18]===r?i=e[19]:(i=(0,d.jsx)(h,{message:r}),e[18]=r,e[19]=i),i}let C=_.ui?.permissions,w;return e[20]!==_.name||e[21]!==t||e[22]!==b.entrypoint||e[23]!==b.title||e[24]!==C?(w=(0,d.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,d.jsx)(s,{extensionId:t,extensionName:_.name,entrypoint:b.entrypoint,permissions:C,title:b.title,className:`min-h-0 flex-1`,fixedHeight:void 0,maxHeight:99999})}),e[20]=_.name,e[21]=t,e[22]=b.entrypoint,e[23]=b.title,e[24]=C,e[25]=w):w=e[25],w}function p(e){return e.clearPageHeader}function m(e){return e.setPageHeader}function h(e){let t=(0,l.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,d.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-1 items-center justify-center`,children:(0,d.jsx)(`div`,{className:`text-center`,children:(0,d.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})})}),t[0]=n,t[1]=r),r}export{f as ExtensionPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i,t as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as o,r as s}from"./popover-select-0p9PIHRy.js";import{t as c}from"./messages-CY3XVeek.js";import{t as l}from"./cn-JdwAhgNB.js";import{a as u,c as d,i as f,n as p,r as m}from"./locale-store-K7mHrs6W.js";import{i as h}from"./vendor-swr-BIWyz7Rc.js";import{t as g}from"./button-CS04eWY9.js";import{Fo as _,Io as v,Lo as y,go as b,xi as x}from"./index-oJE8g8BL.js";import{n as S,r as C}from"./settings-page-layout-X1x-2Cp9.js";import{t as w}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as T,t as E}from"./use-autosave-Bs2Zw_LW.js";import{a as D,c as O,o as k}from"./voice-config-api-C9HKTnnD.js";import{t as A}from"./voice-api-key-field-CCznhcKT.js";import{t as j}from"./schema-form-Dl0j1Pjj.js";var M=e(t(),1),N=n(),P=r();function F(e){let t=(0,N.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function I(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function L(){return l(v,_)}function R(){return l(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,y,`dark:border-edge`)}function z(e,t,n){if(!e||!t)return{apiKey:``,model:n};let r=e.stt.providers?.[t];return{apiKey:typeof r?.apiKey==`string`?r.apiKey:``,model:typeof r?.model==`string`?r.model:n}}function B({providerId:e,voiceSettings:t,mutateVoice:n}){let r=c(p(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,u={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:d}=h(m(`/api/voice/stt-providers`),k,{revalidateOnFocus:!1}),f=(0,M.useMemo)(()=>d?.providers.find(t=>t.id===e),[e,d]),g=f?.configured??!1,v=f?.models??[],y=v[0]?.id??f?.fields.find(e=>e.key===`model`)?.defaultValue??``,b=(0,M.useMemo)(()=>z(t,e,y),[y,e,t]),x=(0,M.useRef)(!1),[S,C]=(0,M.useState)(null),w=S??b,D=(0,M.useRef)(w);D.current=w;let j=b,N=E({value:w,dirty:w.apiKey!==j.apiKey||w.model!==j.model,onSave:(0,M.useCallback)(async r=>{let i=structuredClone(t);i.stt.enabled=!0,i.stt.provider=e,i.stt.providers={...i.stt.providers??{},[e]:{...i.stt.providers?.[e]??{},apiKey:r.apiKey,model:r.model}},await O(i),await n(i,!1),x.current=JSON.stringify(D.current)!==JSON.stringify(r),C(e=>e&&JSON.stringify(e)===JSON.stringify(r)?null:e)},[n,e,t])}),I=v.length>0?v:w.model?[{id:w.model,name:w.model}]:[];return(0,P.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,onBlurCapture:N.onBlurCapture,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(T,{status:N.status,error:N.error}),(0,P.jsx)(`span`,{className:l(`rounded-full px-2 py-0.5 text-xs font-medium`,g?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:g?a.configured:a.notConfigured})]})]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,_),children:[(0,P.jsx)(F,{children:i.stt.apiKey}),(0,P.jsx)(A,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:w.apiKey,onChange:e=>{x.current=!0,C(t=>({...t??b,apiKey:e}))},labels:u,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,P.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,P.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,_),children:[(0,P.jsx)(F,{children:i.stt.model}),I.length>0?(0,P.jsx)(o,{className:L(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value})),N.saveNow({...w,model:e.target.value})},children:I.map(e=>(0,P.jsx)(s,{value:e.id,children:e.name},e.id))}):(0,P.jsx)(`input`,{className:R(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value}))}})]})]})]})}function V(e){let t=(0,N.c)(13),{extensionId:n}=e,r=p(U),i=d(H),a;t[0]===n?a=t[1]:(a=()=>u(m(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:s}=h(i&&n?`ext-stt-detail-${n}`:null,a),c;t[2]===o?c=t[3]:(c=I(o),t[2]=o,t[3]=c);let l=c,f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f={revalidateOnFocus:!1},t[4]=f):f=t[4];let{data:g,mutate:_,isLoading:v}=h(i?`voice-settings-ext-stt`:null,D,f);if(!i)return null;if(s||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(w,{rows:2}),t[5]=e):e=t[5],e}if(!l){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let y=`${n}:${l}`,b;return t[8]!==_||t[9]!==l||t[10]!==y||t[11]!==g?(b=(0,P.jsx)(B,{providerId:l,voiceSettings:g,mutateVoice:_},y),t[8]=_,t[9]=l,t[10]=y,t[11]=g,t[12]=b):b=t[12],b}function H(e){return!!e.conversationId}function U(e){return e.language}function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function G(e){let t={};if(e.type!==`object`||!W(e.properties))return t;for(let[n,r]of Object.entries(e.properties))W(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function K(e,t){switch(t.type){case`sync`:return{localValues:t.value,isDirty:!1};case`change`:return{localValues:t.value,isDirty:!0};case`reset-defaults`:return{localValues:t.value,isDirty:!0};case`saved`:return JSON.stringify(e.localValues)===JSON.stringify(t.value)?{localValues:e.localValues,isDirty:!1}:e}}function q({extensionId:e}){let t=d(e=>!!e.conversationId),{data:n,error:r}=h(t&&e?`ext-detail-${e}`:null,()=>u(m(`/api/extensions/${encodeURIComponent(e)}`))),{data:i,mutate:a,error:o}=h(t&&e?`ext-cfg-${e}`:null,()=>u(m(`/api/extensions/${encodeURIComponent(e)}/config`))),s=n?.manifest?.configSchema,c=(0,M.useMemo)(()=>s&&s.type===`object`?G(s):{},[s]),l=(0,M.useMemo)(()=>({...c,...i??{}}),[c,i]),[p,_]=(0,M.useReducer)(K,{localValues:{},isDirty:!1}),v=(0,M.useRef)(!1),y=(0,M.useRef)(p.localValues);y.current=p.localValues;let b=(0,M.useRef)(l);!v.current&&b.current!==l&&(b.current=l,_({type:`sync`,value:l}));let x=(0,M.useCallback)(e=>{v.current=!0,_({type:`change`,value:e})},[]),S=(0,M.useCallback)(()=>{!s||s.type!==`object`||(v.current=!0,_({type:`reset-defaults`,value:{...G(s)}}))},[s]),C=(0,M.useCallback)(async t=>{if(!e)return;let n=await f(m(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await a(t,!1),_({type:`saved`,value:t}),v.current=JSON.stringify(y.current)!==JSON.stringify(t)},[e,a]),w=E({value:p.localValues,dirty:p.isDirty,onSave:C});if(!t)return null;if(r||o){let e=r??o;return(0,P.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!s||s.type!==`object`?null:(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-hover/20 p-4`,onBlurCapture:w.onBlurCapture,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(T,{status:w.status,error:w.error}),(0,P.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:S,children:`Reset to defaults`})]})]}),(0,P.jsx)(j,{schema:s,values:p.localValues,onChange:x})]})}function J(){let e=(0,N.c)(38),t=p(Y),n;e[0]===t?n=e[1]:(n=c(t),e[0]=t,e[1]=n);let r=n.extensionSttMedia,{extensionId:o,panelId:s}=i(),l=b();if(!o){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(X,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let u,d,f;if(e[3]!==o||e[4]!==l||e[5]!==s){f=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===o?t=e[10]:(t=e=>e.id===o,e[9]=o,e[10]=t),u=l.find(t),!u){let t=`Extension "${o}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,P.jsx)(X,{message:t}),e[11]=t,e[12]=n),f=n;break bb0}let n=u.ui?.contributions?.settingsPanels;d=s?n?.find(e=>e.id===s||e.id===`${o}.${s}`):n?.[0]}e[3]=o,e[4]=l,e[5]=s,e[6]=u,e[7]=d,e[8]=f}else u=e[6],d=e[7],f=e[8];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let m=d,h=!!(m&&u.ui),g=!!u.hasConfigSchema,_=u.kind===`media-provider`;if(!g&&!h&&!_){let t=`Extension "${o}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,P.jsx)(X,{message:t}),e[13]=t,e[14]=n),n}let v=m?.title??`${u.name} Settings`,y;e[15]===v?y=e[16]:(y=(0,P.jsx)(S,{title:v}),e[15]=v,e[16]=y);let w;e[17]!==_||e[18]!==r?(w=_?(0,P.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,P.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:r.banner}),(0,P.jsx)(a,{to:`/settings/capabilities/voice`,className:`w-fit font-medium text-accent hover:underline`,children:r.openVoice})]}):null,e[17]=_,e[18]=r,e[19]=w):w=e[19];let T;e[20]!==o||e[21]!==_?(T=_?(0,P.jsx)(V,{extensionId:o}):null,e[20]=o,e[21]=_,e[22]=T):T=e[22];let E;e[23]!==o||e[24]!==g?(E=g?(0,P.jsx)(q,{extensionId:o}):null,e[23]=o,e[24]=g,e[25]=E):E=e[25];let D;e[26]!==u.name||e[27]!==u.ui||e[28]!==o||e[29]!==h||e[30]!==m?(D=h&&m&&u.ui?(0,P.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,P.jsx)(x,{extensionId:o,extensionName:u.name,entrypoint:m.entrypoint,permissions:u.ui?.permissions,title:m.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[26]=u.name,e[27]=u.ui,e[28]=o,e[29]=h,e[30]=m,e[31]=D):D=e[31];let O;return e[32]!==y||e[33]!==w||e[34]!==T||e[35]!==E||e[36]!==D?(O=(0,P.jsxs)(C,{gap:`gap-5`,children:[y,w,T,E,D]}),e[32]=y,e[33]=w,e[34]=T,e[35]=E,e[36]=D,e[37]=O):O=e[37],O}function Y(e){return e.language}function X(e){let t=(0,N.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,P.jsx)(C,{gap:`gap-3`,children:(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{J as ExtensionSettingsPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i,t as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as o,r as s}from"./popover-select-0p9PIHRy.js";import{t as c}from"./messages-sXePe3LQ.js";import{t as l}from"./cn-JdwAhgNB.js";import{a as u,c as d,i as f,n as p,r as m}from"./locale-store-WMaCMm3_.js";import{i as h}from"./vendor-swr-BIWyz7Rc.js";import{t as g}from"./button-CS04eWY9.js";import{Fo as _,Io as v,Lo as y,go as b,xi as x}from"./index-Bb32g7Ll.js";import{n as S,r as C}from"./settings-page-layout-X1x-2Cp9.js";import{t as w}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as T,t as E}from"./use-autosave-DQdLcZfO.js";import{a as D,c as O,o as k}from"./voice-config-api-DbjjZkIg.js";import{t as A}from"./voice-api-key-field-CJ-FjNHr.js";import{t as j}from"./schema-form-DWHFyKEB.js";var M=e(t(),1),N=n(),P=r();function F(e){let t=(0,N.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function I(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function L(){return l(v,_)}function R(){return l(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,y,`dark:border-edge`)}function z(e,t,n){if(!e||!t)return{apiKey:``,model:n};let r=e.stt.providers?.[t];return{apiKey:typeof r?.apiKey==`string`?r.apiKey:``,model:typeof r?.model==`string`?r.model:n}}function B({providerId:e,voiceSettings:t,mutateVoice:n}){let r=c(p(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,u={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:d}=h(m(`/api/voice/stt-providers`),k,{revalidateOnFocus:!1}),f=(0,M.useMemo)(()=>d?.providers.find(t=>t.id===e),[e,d]),g=f?.configured??!1,v=f?.models??[],y=v[0]?.id??f?.fields.find(e=>e.key===`model`)?.defaultValue??``,b=(0,M.useMemo)(()=>z(t,e,y),[y,e,t]),x=(0,M.useRef)(!1),[S,C]=(0,M.useState)(null),w=S??b,D=(0,M.useRef)(w);D.current=w;let j=b,N=E({value:w,dirty:w.apiKey!==j.apiKey||w.model!==j.model,onSave:(0,M.useCallback)(async r=>{let i=structuredClone(t);i.stt.enabled=!0,i.stt.provider=e,i.stt.providers={...i.stt.providers??{},[e]:{...i.stt.providers?.[e]??{},apiKey:r.apiKey,model:r.model}},await O(i),await n(i,!1),x.current=JSON.stringify(D.current)!==JSON.stringify(r),C(e=>e&&JSON.stringify(e)===JSON.stringify(r)?null:e)},[n,e,t])}),I=v.length>0?v:w.model?[{id:w.model,name:w.model}]:[];return(0,P.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,onBlurCapture:N.onBlurCapture,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(T,{status:N.status,error:N.error}),(0,P.jsx)(`span`,{className:l(`rounded-full px-2 py-0.5 text-xs font-medium`,g?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:g?a.configured:a.notConfigured})]})]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,_),children:[(0,P.jsx)(F,{children:i.stt.apiKey}),(0,P.jsx)(A,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:w.apiKey,onChange:e=>{x.current=!0,C(t=>({...t??b,apiKey:e}))},labels:u,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,P.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,P.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,_),children:[(0,P.jsx)(F,{children:i.stt.model}),I.length>0?(0,P.jsx)(o,{className:L(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value})),N.saveNow({...w,model:e.target.value})},children:I.map(e=>(0,P.jsx)(s,{value:e.id,children:e.name},e.id))}):(0,P.jsx)(`input`,{className:R(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value}))}})]})]})]})}function V(e){let t=(0,N.c)(13),{extensionId:n}=e,r=p(U),i=d(H),a;t[0]===n?a=t[1]:(a=()=>u(m(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:s}=h(i&&n?`ext-stt-detail-${n}`:null,a),c;t[2]===o?c=t[3]:(c=I(o),t[2]=o,t[3]=c);let l=c,f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f={revalidateOnFocus:!1},t[4]=f):f=t[4];let{data:g,mutate:_,isLoading:v}=h(i?`voice-settings-ext-stt`:null,D,f);if(!i)return null;if(s||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(w,{rows:2}),t[5]=e):e=t[5],e}if(!l){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let y=`${n}:${l}`,b;return t[8]!==_||t[9]!==l||t[10]!==y||t[11]!==g?(b=(0,P.jsx)(B,{providerId:l,voiceSettings:g,mutateVoice:_},y),t[8]=_,t[9]=l,t[10]=y,t[11]=g,t[12]=b):b=t[12],b}function H(e){return!!e.conversationId}function U(e){return e.language}function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function G(e){let t={};if(e.type!==`object`||!W(e.properties))return t;for(let[n,r]of Object.entries(e.properties))W(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function K(e,t){switch(t.type){case`sync`:return{localValues:t.value,isDirty:!1};case`change`:return{localValues:t.value,isDirty:!0};case`reset-defaults`:return{localValues:t.value,isDirty:!0};case`saved`:return JSON.stringify(e.localValues)===JSON.stringify(t.value)?{localValues:e.localValues,isDirty:!1}:e}}function q({extensionId:e}){let t=d(e=>!!e.conversationId),{data:n,error:r}=h(t&&e?`ext-detail-${e}`:null,()=>u(m(`/api/extensions/${encodeURIComponent(e)}`))),{data:i,mutate:a,error:o}=h(t&&e?`ext-cfg-${e}`:null,()=>u(m(`/api/extensions/${encodeURIComponent(e)}/config`))),s=n?.manifest?.configSchema,c=(0,M.useMemo)(()=>s&&s.type===`object`?G(s):{},[s]),l=(0,M.useMemo)(()=>({...c,...i??{}}),[c,i]),[p,_]=(0,M.useReducer)(K,{localValues:{},isDirty:!1}),v=(0,M.useRef)(!1),y=(0,M.useRef)(p.localValues);y.current=p.localValues;let b=(0,M.useRef)(l);!v.current&&b.current!==l&&(b.current=l,_({type:`sync`,value:l}));let x=(0,M.useCallback)(e=>{v.current=!0,_({type:`change`,value:e})},[]),S=(0,M.useCallback)(()=>{!s||s.type!==`object`||(v.current=!0,_({type:`reset-defaults`,value:{...G(s)}}))},[s]),C=(0,M.useCallback)(async t=>{if(!e)return;let n=await f(m(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await a(t,!1),_({type:`saved`,value:t}),v.current=JSON.stringify(y.current)!==JSON.stringify(t)},[e,a]),w=E({value:p.localValues,dirty:p.isDirty,onSave:C});if(!t)return null;if(r||o){let e=r??o;return(0,P.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!s||s.type!==`object`?null:(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-hover/20 p-4`,onBlurCapture:w.onBlurCapture,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(T,{status:w.status,error:w.error}),(0,P.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:S,children:`Reset to defaults`})]})]}),(0,P.jsx)(j,{schema:s,values:p.localValues,onChange:x})]})}function J(){let e=(0,N.c)(38),t=p(Y),n;e[0]===t?n=e[1]:(n=c(t),e[0]=t,e[1]=n);let r=n.extensionSttMedia,{extensionId:o,panelId:s}=i(),l=b();if(!o){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(X,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let u,d,f;if(e[3]!==o||e[4]!==l||e[5]!==s){f=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===o?t=e[10]:(t=e=>e.id===o,e[9]=o,e[10]=t),u=l.find(t),!u){let t=`Extension "${o}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,P.jsx)(X,{message:t}),e[11]=t,e[12]=n),f=n;break bb0}let n=u.ui?.contributions?.settingsPanels;d=s?n?.find(e=>e.id===s||e.id===`${o}.${s}`):n?.[0]}e[3]=o,e[4]=l,e[5]=s,e[6]=u,e[7]=d,e[8]=f}else u=e[6],d=e[7],f=e[8];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let m=d,h=!!(m&&u.ui),g=!!u.hasConfigSchema,_=u.kind===`media-provider`;if(!g&&!h&&!_){let t=`Extension "${o}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,P.jsx)(X,{message:t}),e[13]=t,e[14]=n),n}let v=m?.title??`${u.name} Settings`,y;e[15]===v?y=e[16]:(y=(0,P.jsx)(S,{title:v}),e[15]=v,e[16]=y);let w;e[17]!==_||e[18]!==r?(w=_?(0,P.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,P.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:r.banner}),(0,P.jsx)(a,{to:`/settings/capabilities/voice`,className:`w-fit font-medium text-accent hover:underline`,children:r.openVoice})]}):null,e[17]=_,e[18]=r,e[19]=w):w=e[19];let T;e[20]!==o||e[21]!==_?(T=_?(0,P.jsx)(V,{extensionId:o}):null,e[20]=o,e[21]=_,e[22]=T):T=e[22];let E;e[23]!==o||e[24]!==g?(E=g?(0,P.jsx)(q,{extensionId:o}):null,e[23]=o,e[24]=g,e[25]=E):E=e[25];let D;e[26]!==u.name||e[27]!==u.ui||e[28]!==o||e[29]!==h||e[30]!==m?(D=h&&m&&u.ui?(0,P.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,P.jsx)(x,{extensionId:o,extensionName:u.name,entrypoint:m.entrypoint,permissions:u.ui?.permissions,title:m.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[26]=u.name,e[27]=u.ui,e[28]=o,e[29]=h,e[30]=m,e[31]=D):D=e[31];let O;return e[32]!==y||e[33]!==w||e[34]!==T||e[35]!==E||e[36]!==D?(O=(0,P.jsxs)(C,{gap:`gap-5`,children:[y,w,T,E,D]}),e[32]=y,e[33]=w,e[34]=T,e[35]=E,e[36]=D,e[37]=O):O=e[37],O}function Y(e){return e.language}function X(e){let t=(0,N.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,P.jsx)(C,{gap:`gap-3`,children:(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{J as ExtensionSettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{a as r,r as i}from"./locale-store-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{a as r,r as i}from"./locale-store-WMaCMm3_.js";import{i as a,o}from"./vendor-swr-BIWyz7Rc.js";var s=e(t(),1),c=n();function l(e){if(!(!e||typeof e!=`object`||!(`section`in e)))return e.section}function u(e){return l(e)===`skills`}function d(){return i(`/api/config`)}var f=null;async function p(){return f||(f=r(d()).finally(()=>{f=null}),f)}function m(e){let t=(0,c.c)(6),n;t[0]===e?n=t[1]:(n=e?d():null,t[0]=e,t[1]=n);let r=n,i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},t[2]=i):i=t[2];let l=a(r,p,i),f,m;return t[3]===e?(f=t[4],m=t[5]):(f=()=>{if(!e)return;let t=d(),n=e=>{u(e.detail)||o(t)};return window.addEventListener(`config-reload`,n),()=>window.removeEventListener(`config-reload`,n)},m=[e],t[3]=e,t[4]=f,t[5]=m),(0,s.useEffect)(f,m),l}function h(){return o(d())}export{u as a,l as i,h as n,m as r,p as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./locale-store-K7mHrs6W.js";import{a as t,d as n,f as r,g as i,i as a,l as o,p as s,r as c,s as l,t as u,u as d,v as f}from"./schemas-CObaziC7.js";import{t as p}from"./gateway-realtime-store-B87bp5kF.js";var m=25*1024*1024,h=u([`web`,`desktop`,`mobile`,`browser`]),g=u([`foreground`,`background`]),_=u([`read`,`write`,`destructive`]),ee=u([`never`,`always`]),te=u([`text`,`json`,`file`]),ne=u([`public`,`personal`]),v=s().min(1).max(160),re=s().min(32).max(160).regex(/^[A-Za-z0-9_-]+$/);t(`type`,[r({type:l(`endpoint`),endpointId:v}),r({type:l(`channel`),channel:s().min(1).max(64)}),r({type:l(`system`),source:u([`cli`,`automation`,`heartbeat`,`workflow`,`internal`,`task_update`])})]).options[0].extend({token:re});var ie=f(),y=o().int().nonnegative(),b=n(s(),i()),x=r({name:s().regex(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$/).max(120),title:s().min(1).max(120),description:s().min(1).max(2e3),inputSchema:b,outputSchema:b,policyId:s().regex(/^[a-z][a-z0-9_.-]+$/).max(120),sensitivity:ne,effect:_,confirmation:ee,requiresForeground:a(),requiredPermissions:c(s().min(1).max(120)).max(20),timeoutMs:o().int().min(1e3).max(3e5),maxConcurrency:o().int().min(1).max(4),supportsCancellation:a(),idempotent:a(),resultKinds:c(te).min(1).max(3)});r({principalId:v,displayName:s().min(1).max(120),kind:h,platform:s().min(1).max(80),publicKey:s().min(32).max(2048)}),r({endpointId:v});var S=s().regex(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$/).max(120);r({jobId:f(),endpointId:v,capability:S,input:b,idempotencyKey:v,consentGrantId:v,createdAt:y,expiresAt:y}),r({jobId:f(),status:u([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),updatedAt:y,output:b.optional(),error:r({code:v,message:s().min(1).max(2e3)}).optional()}),r({eventId:f(),endpointId:v,subscriptionId:v,eventType:S,data:b,occurredAt:y});var C=r({principalId:v,endpointId:v,connectionInstanceId:f(),displayName:s().min(1).max(120),kind:h,platform:s().min(1).max(80),appVersion:s().min(1).max(80),availability:g,nonce:v,signedAt:y,signature:s().min(16).max(1024),tools:c(x).max(100)}),w=r({invocationId:f(),toolCallId:v,toolName:x.shape.name,arguments:b,descriptorRevision:s().min(1).max(128),confirmationRequired:a(),deadlineAt:y,uploadGrant:r({path:s().startsWith(`/`).max(500),token:v,maxBytes:o().int().positive(),maxFiles:o().int().min(1).max(20),expiresAt:y}).optional()}),ae=r({invocationId:f(),reason:s().min(1).max(500)}),T=r({invocationId:f()}),E=t(`type`,[r({type:l(`text`),text:s().max(256*1024)}),r({type:l(`json`),value:i()}),r({type:l(`file`),fileId:v,name:s().min(1).max(255),mimeType:s().min(1).max(255),size:o().int().nonnegative(),sha256:s().regex(/^[a-f0-9]{64}$/)})]),D=u([`ENDPOINT_OFFLINE`,`ENDPOINT_NOT_FOREGROUND`,`ENDPOINT_DISCONNECTED`,`TOOL_NOT_FOUND`,`TOOL_REVISION_MISMATCH`,`INVALID_ARGUMENTS`,`PERMISSION_DENIED`,`USER_DENIED`,`TOOL_BUSY`,`TOOL_TIMEOUT`,`TOOL_CANCELLED`,`RESULT_TOO_LARGE`,`PROTOCOL_ERROR`]),O=(e,t)=>r({protocolVersion:l(2),messageId:ie,type:l(e),sentAt:y,payload:t}),oe=t(`type`,[O(`endpoint.availability_changed`,r({availability:g})),O(`tool.received`,T),O(`tool.progress`,r({invocationId:f(),message:s().max(500).optional(),percent:o().min(0).max(100).optional()})),O(`tool.result`,r({invocationId:f(),content:c(E).min(1).max(20),details:b.optional()})),O(`tool.error`,r({invocationId:f(),code:D,message:s().min(1).max(2e3)})),O(`tool.cancelled`,T)]),se=t(`type`,[O(`tool.invoke`,w),O(`tool.cancel`,ae)]),ce={type:`array`,minItems:1,maxItems:20,items:{type:`object`,additionalProperties:!1,required:[`type`,`text`],properties:{type:{const:`text`},text:{type:`string`,maxLength:256*1024}}}},le={type:`array`,minItems:1,maxItems:20,items:{type:`object`,additionalProperties:!1,required:[`type`,`fileId`,`name`,`mimeType`,`size`,`sha256`],properties:{type:{const:`file`},fileId:{type:`string`,minLength:1,maxLength:160},name:{type:`string`,minLength:1,maxLength:255},mimeType:{type:`string`,minLength:1,maxLength:255},size:{type:`integer`,minimum:0},sha256:{type:`string`,pattern:`^[a-f0-9]{64}$`}}}};function k(e){if(e===null)return`null`;if(typeof e==`string`||typeof e==`boolean`)return JSON.stringify(e);if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`Canonical JSON only supports finite numbers`);return JSON.stringify(e)}if(typeof e!=`object`)throw Error(`Canonical JSON does not support ${typeof e}`);if(Array.isArray(e))return`[${e.map(k).join(`,`)}]`;let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw Error(`Canonical JSON only supports plain objects`);let n=e;return`{${Object.keys(n).sort().map(e=>`${JSON.stringify(e)}:${k(n[e])}`).join(`,`)}}`}function A(e){let{signature:t,...n}=e;return k(n)}var j=256*1024,M=15e3,N=45e3,P=[`realtime.capability-negotiation.v1`],F=u([`web`,`desktop`,`mobile`,`browser_extension`,`tui`,`mcp`]),I=s().min(1).max(512),L=s().regex(/^[a-z][a-z0-9_.-]*$/).max(160),R=f(),z=o().int().nonnegative(),B=o().int().positive(),V=s().min(1).max(160),H=(e,t)=>d({protocolVersion:l(2),messageId:R,kind:l(e),sentAt:z,payload:t}),U=d({topic:I,afterSeq:o().int().nonnegative().optional(),view:l(`compact`).optional()});t(`kind`,[H(`realtime.hello`,d({ticket:s().min(32).max(512),clientId:s().min(1).max(160),clientKind:F,subscriptions:c(U).max(100).default([]),capabilities:c(V).max(64).optional(),endpoint:C.optional()})),H(`realtime.subscribe`,d({subscriptions:c(U).min(1).max(100)})),H(`realtime.unsubscribe`,d({topics:c(I).min(1).max(100)})),H(`realtime.ping`,d({})),H(`endpoint.message`,oe)]);var W=d({topic:I,seq:B,event:L,data:i()}),ue=t(`kind`,[H(`realtime.ready`,d({connectionId:f(),heartbeatIntervalMs:l(M),heartbeatTimeoutMs:l(N),negotiatedCapabilities:c(V).max(64).optional(),endpoint:d({endpointId:s().min(1).max(160),turnToken:s().min(32).max(160)}).optional()})),H(`realtime.event`,W),H(`realtime.subscribed`,d({topic:I,cursor:o().int().nonnegative()})),H(`realtime.gap`,d({topic:I,requestedSeq:o().int().nonnegative(),earliestSeq:B,recoverable:a()})),H(`realtime.pong`,d({})),H(`realtime.error`,d({code:s().min(1).max(80),message:s().min(1).max(500)})),H(`endpoint.message`,se)]);function de(e){return ue.parse(e)}var G=class extends Error{retryable;constructor(e,t){super(e),this.retryable=t,this.name=`RealtimeConnectionError`}},fe=class extends Error{bytes;maxBytes;constructor(e,t){super(`Realtime client frame is ${e} bytes; maximum is ${t} bytes`),this.bytes=e,this.maxBytes=t,this.name=`RealtimeFrameTooLargeError`}};function pe(e){if(typeof e==`string`)return e;if(e instanceof ArrayBuffer)return new TextDecoder().decode(e);if(ArrayBuffer.isView(e)){let t=Uint8Array.from(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));return new TextDecoder().decode(t)}throw Error(`Realtime server sent a non-text frame`)}function me(e){return e===1009||e===4400||e===4401||e===4409||e===4413}var he=class{options;desiredSubscriptions=new Map;cursors=new Map;socket;reconnectTimer;heartbeatTimer;connectionTimer;ticketAbort;generation=0;reconnectAttempts=0;shouldReconnect=!1;ready=!1;lastServerMessageAt=0;endpointBinding;reconnectWhenSocketOpens=!1;offeredCapabilities=new Set;constructor(e){this.options=e}connect(){this.shouldReconnect||(this.shouldReconnect=!0,this.open(!1))}disconnect(){this.shouldReconnect=!1,this.reconnectWhenSocketOpens=!1,this.generation+=1,this.clearTimers(),this.ready=!1,this.offeredCapabilities.clear(),this.endpointBinding?.onDisconnected?.(),this.socket?.close(1e3,`Client disconnected`),this.socket=void 0,this.options.onStateChange?.(`disconnected`)}reconnect(){this.reconnectWhenSocketOpens=!1,this.generation+=1,this.clearTimers(),this.ready=!1,this.endpointBinding?.onDisconnected?.(),this.socket?.close(1e3,`Client reconnecting`),this.socket=void 0,this.reconnectAttempts=0,this.shouldReconnect=!0,this.open(!0)}subscribe(e,t){this.desiredSubscriptions.set(e,t),t!==void 0&&this.cursors.set(e,t),this.ready&&this.sendSubscriptions([{topic:e,afterSeq:this.cursors.get(e)??t}])}unsubscribe(e){this.desiredSubscriptions.delete(e),this.ready&&this.send(this.clientMessage(`realtime.unsubscribe`,{topics:[e]}))}sendEndpointMessage(e){if(!this.ready)throw Error(`Realtime connection is not ready`);this.send(this.clientMessage(`endpoint.message`,e))}setEndpoint(e){this.endpointBinding=e,this.refreshEndpointConnection()}clearEndpoint(e){if(e&&this.endpointBinding!==e)return;let t=this.endpointBinding;this.endpointBinding=void 0,t?.onDisconnected?.(),this.refreshEndpointConnection()}refreshEndpointConnection(){if(this.shouldReconnect){if(this.socket?.readyState===0){this.reconnectWhenSocketOpens=!0;return}this.reconnect()}}async open(e){let t=++this.generation,n=this.options.connectionTimeoutMs??15e3,r=new AbortController;this.ticketAbort?.abort(),this.ticketAbort=r;let i,a=!1,o,s=(e,n=!0)=>{a||t!==this.generation||(a=!0,this.clearConnectionTimer(),r.abort(),this.ticketAbort===r&&(this.ticketAbort=void 0),this.ready=!1,this.offeredCapabilities.clear(),this.endpointBinding?.onDisconnected?.(),this.clearHeartbeat(),this.socket===i&&(this.socket=void 0),i&&(i.onopen=null,i.onmessage=null,i.onerror=null,i.onclose=null,i.close(4e3,e.slice(0,120))),this.shouldReconnect&&n?this.scheduleReconnect(e):this.shouldReconnect?(this.shouldReconnect=!1,this.options.onStateChange?.(`error`,e)):this.options.onStateChange?.(`disconnected`))};this.connectionTimer=setTimeout(()=>s(`Realtime connection timed out`),n),this.options.onStateChange?.(e?`reconnecting`:`connecting`);try{let[e,n]=await Promise.all([this.options.issueTicket(r.signal),this.endpointBinding?.createHello()]),c=e.ticket;if(2<e.realtime.minVersion)throw new G(`CLIENT_UPDATE_REQUIRED`,!1);if(2>e.realtime.maxVersion)throw new G(`GATEWAY_UPDATE_REQUIRED`,!1);let l=P.filter(t=>e.realtime.capabilities.includes(t));if(a||!this.shouldReconnect||t!==this.generation)return;this.offeredCapabilities=new Set(l??[]),i=this.options.createWebSocket(this.options.getWebSocketUrl()),this.socket=i,i.onopen=()=>{if(t!==this.generation)return;if(this.reconnectWhenSocketOpens){this.reconnect();return}let e=[...this.desiredSubscriptions].map(([e,t])=>({topic:e,afterSeq:this.cursors.get(e)??t}));this.send(this.clientMessage(`realtime.hello`,{ticket:c,clientId:this.options.clientId,clientKind:this.options.clientKind,subscriptions:e,...l?.length?{capabilities:l}:{},...n?{endpoint:n}:{}}))},i.onmessage=e=>{if(t!==this.generation)return;let n=()=>{if(!(a||t!==this.generation))return this.handleServerMessage(pe(e.data))};if(!o){try{let e=n();if(!e)return;let t=e.catch(e=>s(e instanceof Error?e.message:`Invalid realtime server message`)).then(()=>void 0);o=t,t.finally(()=>{o===t&&(o=void 0)})}catch(e){s(e instanceof Error?e.message:`Invalid realtime server message`)}return}let r=o.then(n).catch(e=>s(e instanceof Error?e.message:`Invalid realtime server message`)).then(()=>void 0);o=r,r.finally(()=>{o===r&&(o=void 0)})},i.onerror=()=>{},i.onclose=e=>{s(e.reason||`WebSocket closed (${e.code??0})`,!me(e.code))}}catch(e){s(e instanceof Error?e.message:`Realtime connection failed`,!(e instanceof G)||e.retryable)}}handleServerMessage(e){let t=de(JSON.parse(e));if(this.lastServerMessageAt=Date.now(),t.kind===`realtime.ready`){let e=t.payload.negotiatedCapabilities??[];if(e.some(e=>!this.offeredCapabilities.has(e)))throw Error(`Realtime server negotiated a capability the client did not offer`);this.ready=!0,this.reconnectAttempts=0,this.clearConnectionTimer(),this.ticketAbort=void 0,this.options.onStateChange?.(`connected`),this.options.onCapabilities?.(e),t.payload.endpoint&&this.endpointBinding?.onReady(t.payload.endpoint),this.clearHeartbeat(),this.heartbeatTimer=setInterval(()=>{if(this.ready){if(Date.now()-this.lastServerMessageAt>=t.payload.heartbeatTimeoutMs){this.reconnect();return}this.send(this.clientMessage(`realtime.ping`,{}))}},t.payload.heartbeatIntervalMs)}else if(t.kind===`realtime.event`){let e=this.cursors.get(t.payload.topic);if(e!==void 0&&t.payload.seq<=e)return;this.options.onEvent?.(t.payload),this.cursors.set(t.payload.topic,t.payload.seq)}else if(t.kind===`realtime.subscribed`)this.cursors.set(t.payload.topic,t.payload.cursor),this.options.onSubscribed?.(t.payload);else if(t.kind===`realtime.gap`)return this.cursors.set(t.payload.topic,t.payload.earliestSeq-1),this.options.onGap?.(t.payload);else t.kind===`realtime.error`?this.options.onStateChange?.(`error`,t.payload.message):t.kind===`endpoint.message`&&(this.endpointBinding?.onMessage(t.payload),this.options.onEndpointMessage?.(t.payload))}sendSubscriptions(e){this.send(this.clientMessage(`realtime.subscribe`,{subscriptions:e}))}clientMessage(e,t){let n=this.options.createMessageId?.()??globalThis.crypto?.randomUUID?.();if(!n)throw Error(`RealtimeClient requires createMessageId when crypto.randomUUID is unavailable`);return{protocolVersion:2,messageId:n,kind:e,sentAt:Date.now(),payload:t}}send(e){if(!this.socket||this.socket.readyState!==1)return;let t=JSON.stringify(e),n=new TextEncoder().encode(t).byteLength;if(n>262144)throw new fe(n,j);this.socket.send(t)}scheduleReconnect(e){if(!this.shouldReconnect)return;this.reconnectAttempts+=1;let t=this.options.maxReconnectAttempts;if(t!==void 0&&this.reconnectAttempts>t){this.shouldReconnect=!1,this.options.onStateChange?.(`error`,e);return}this.options.onStateChange?.(`reconnecting`,e);let n=Math.min(3e4,1e3*2**Math.min(this.reconnectAttempts-1,5)),r=Math.round(n*(.5+Math.random()*.5));this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=void 0,this.open(!0)},r)}clearHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0}clearTimers(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0,this.clearConnectionTimer(),this.ticketAbort?.abort(),this.ticketAbort=void 0,this.clearHeartbeat()}clearConnectionTimer(){this.connectionTimer&&clearTimeout(this.connectionTimer),this.connectionTimer=void 0}},ge=500,K=null,q;function J(e){q=e,K!==null&&clearTimeout(K),K=setTimeout(()=>{K=null;let e=q;q=void 0,window.dispatchEvent(new CustomEvent(`config-reload`,{detail:e}))},ge)}function _e(e,t){if(e===`config.reload`){J(t);return}window.dispatchEvent(new CustomEvent(e.replace(/[._]/g,`-`),{detail:t}))}var Y=new Map,X=new Map,Z,Q;function $(){let e=`xopc:realtime-client-id`,t=sessionStorage.getItem(e);if(t)return t;let n=crypto.randomUUID();return sessionStorage.setItem(e,n),n}function ve(){let t=new URL(e(`/api/realtime/v1/ws`));return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString()}function ye(){let t=$(),n=window.electronAPI?`desktop`:`web`,r=new he({clientId:t,clientKind:n,getWebSocketUrl:ve,issueTicket:async r=>{let i=await fetch(e(`/api/realtime/tickets`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientId:t,clientKind:n,protocolVersion:2}),signal:r}),a=await i.json().catch(()=>null);if(!i.ok||!a?.payload?.ticket||!a.payload.realtime)throw Error(a?.error?.message??`Realtime ticket failed (${i.status})`);return{ticket:a.payload.ticket,realtime:a.payload.realtime}},createWebSocket:e=>new WebSocket(e),onStateChange:(e,t)=>{p({connectionState:e,error:t??null}),e===`connected`&&window.dispatchEvent(new CustomEvent(`gateway-realtime-connected`))},onEvent:e=>{(e.topic===`gateway`||e.topic===`sessions`)&&_e(e.event,e.data);let t=X.get(e.topic);(t===void 0||e.seq>t)&&X.set(e.topic,e.seq);for(let t of Y.get(e.topic)??[])if(!(t.cursor!==void 0&&e.seq<=t.cursor))try{t.listener.onEvent(e)}catch(e){console.error(`[realtime] topic listener failed:`,e)}finally{t.cursor=Math.max(t.cursor??0,e.seq)}},onGap:async e=>{window.dispatchEvent(new CustomEvent(`realtime-gap`,{detail:e}));let t=[...Y.get(e.topic)??[]].filter(t=>!e.recoverable||t.cursor===void 0||t.cursor<e.earliestSeq-1),n=await Promise.allSettled(t.map(t=>t.listener.onGap?.(e)));for(let e of n)e.status===`rejected`&&console.error(`[realtime] topic gap handler failed:`,e.reason)}});Z?.disconnect(),Z=r,Q&&r.setEndpoint(Q),r.subscribe(`gateway`,X.get(`gateway`)),r.subscribe(`sessions`,X.get(`sessions`));for(let e of Y.keys())r.subscribe(e,X.get(e));return p({connectionState:`connecting`,error:null}),r.connect(),()=>{Z===r&&(r.disconnect(),Z=void 0)}}function be(e){return Q=e,Z?.setEndpoint(e),()=>{Q===e&&(Q=void 0,Z?.clearEndpoint(e))}}function xe(e){Z?.sendEndpointMessage(e)}function Se(){Z?.reconnect()}function Ce(e,t,n){let r=Y.get(e)??new Set,i=r.size===0,a=X.get(e),o={listener:t,cursor:n??a};if(r.add(o),Y.set(e,r),i){let t=n??a;X.set(e,t),Z?.subscribe(e,t)}else n!==void 0&&(a===void 0||n<a)&&Z?.subscribe(e,n);return()=>{let t=Y.get(e);t?.delete(o),(!t||t.size===0)&&(Y.delete(e),X.delete(e),Z?.unsubscribe(e))}}export{Ce as a,m as c,A as d,E as f,ye as i,ce as l,Se as n,J as o,xe as r,le as s,be as t,k as u};
|
|
1
|
+
import{r as e}from"./locale-store-WMaCMm3_.js";import{a as t,d as n,f as r,g as i,i as a,l as o,p as s,r as c,s as l,t as u,u as d,v as f}from"./schemas-CObaziC7.js";import{t as p}from"./gateway-realtime-store-KyhksZSM.js";var m=25*1024*1024,h=u([`web`,`desktop`,`mobile`,`browser`]),g=u([`foreground`,`background`]),_=u([`read`,`write`,`destructive`]),ee=u([`never`,`always`]),te=u([`text`,`json`,`file`]),ne=u([`public`,`personal`]),v=s().min(1).max(160),re=s().min(32).max(160).regex(/^[A-Za-z0-9_-]+$/);t(`type`,[r({type:l(`endpoint`),endpointId:v}),r({type:l(`channel`),channel:s().min(1).max(64)}),r({type:l(`system`),source:u([`cli`,`automation`,`heartbeat`,`workflow`,`internal`,`task_update`])})]).options[0].extend({token:re});var ie=f(),y=o().int().nonnegative(),b=n(s(),i()),x=r({name:s().regex(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$/).max(120),title:s().min(1).max(120),description:s().min(1).max(2e3),inputSchema:b,outputSchema:b,policyId:s().regex(/^[a-z][a-z0-9_.-]+$/).max(120),sensitivity:ne,effect:_,confirmation:ee,requiresForeground:a(),requiredPermissions:c(s().min(1).max(120)).max(20),timeoutMs:o().int().min(1e3).max(3e5),maxConcurrency:o().int().min(1).max(4),supportsCancellation:a(),idempotent:a(),resultKinds:c(te).min(1).max(3)});r({principalId:v,displayName:s().min(1).max(120),kind:h,platform:s().min(1).max(80),publicKey:s().min(32).max(2048)}),r({endpointId:v});var S=s().regex(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$/).max(120);r({jobId:f(),endpointId:v,capability:S,input:b,idempotencyKey:v,consentGrantId:v,createdAt:y,expiresAt:y}),r({jobId:f(),status:u([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),updatedAt:y,output:b.optional(),error:r({code:v,message:s().min(1).max(2e3)}).optional()}),r({eventId:f(),endpointId:v,subscriptionId:v,eventType:S,data:b,occurredAt:y});var C=r({principalId:v,endpointId:v,connectionInstanceId:f(),displayName:s().min(1).max(120),kind:h,platform:s().min(1).max(80),appVersion:s().min(1).max(80),availability:g,nonce:v,signedAt:y,signature:s().min(16).max(1024),tools:c(x).max(100)}),w=r({invocationId:f(),toolCallId:v,toolName:x.shape.name,arguments:b,descriptorRevision:s().min(1).max(128),confirmationRequired:a(),deadlineAt:y,uploadGrant:r({path:s().startsWith(`/`).max(500),token:v,maxBytes:o().int().positive(),maxFiles:o().int().min(1).max(20),expiresAt:y}).optional()}),ae=r({invocationId:f(),reason:s().min(1).max(500)}),T=r({invocationId:f()}),E=t(`type`,[r({type:l(`text`),text:s().max(256*1024)}),r({type:l(`json`),value:i()}),r({type:l(`file`),fileId:v,name:s().min(1).max(255),mimeType:s().min(1).max(255),size:o().int().nonnegative(),sha256:s().regex(/^[a-f0-9]{64}$/)})]),D=u([`ENDPOINT_OFFLINE`,`ENDPOINT_NOT_FOREGROUND`,`ENDPOINT_DISCONNECTED`,`TOOL_NOT_FOUND`,`TOOL_REVISION_MISMATCH`,`INVALID_ARGUMENTS`,`PERMISSION_DENIED`,`USER_DENIED`,`TOOL_BUSY`,`TOOL_TIMEOUT`,`TOOL_CANCELLED`,`RESULT_TOO_LARGE`,`PROTOCOL_ERROR`]),O=(e,t)=>r({protocolVersion:l(2),messageId:ie,type:l(e),sentAt:y,payload:t}),oe=t(`type`,[O(`endpoint.availability_changed`,r({availability:g})),O(`tool.received`,T),O(`tool.progress`,r({invocationId:f(),message:s().max(500).optional(),percent:o().min(0).max(100).optional()})),O(`tool.result`,r({invocationId:f(),content:c(E).min(1).max(20),details:b.optional()})),O(`tool.error`,r({invocationId:f(),code:D,message:s().min(1).max(2e3)})),O(`tool.cancelled`,T)]),se=t(`type`,[O(`tool.invoke`,w),O(`tool.cancel`,ae)]),ce={type:`array`,minItems:1,maxItems:20,items:{type:`object`,additionalProperties:!1,required:[`type`,`text`],properties:{type:{const:`text`},text:{type:`string`,maxLength:256*1024}}}},le={type:`array`,minItems:1,maxItems:20,items:{type:`object`,additionalProperties:!1,required:[`type`,`fileId`,`name`,`mimeType`,`size`,`sha256`],properties:{type:{const:`file`},fileId:{type:`string`,minLength:1,maxLength:160},name:{type:`string`,minLength:1,maxLength:255},mimeType:{type:`string`,minLength:1,maxLength:255},size:{type:`integer`,minimum:0},sha256:{type:`string`,pattern:`^[a-f0-9]{64}$`}}}};function k(e){if(e===null)return`null`;if(typeof e==`string`||typeof e==`boolean`)return JSON.stringify(e);if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`Canonical JSON only supports finite numbers`);return JSON.stringify(e)}if(typeof e!=`object`)throw Error(`Canonical JSON does not support ${typeof e}`);if(Array.isArray(e))return`[${e.map(k).join(`,`)}]`;let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw Error(`Canonical JSON only supports plain objects`);let n=e;return`{${Object.keys(n).sort().map(e=>`${JSON.stringify(e)}:${k(n[e])}`).join(`,`)}}`}function A(e){let{signature:t,...n}=e;return k(n)}var j=256*1024,M=15e3,N=45e3,P=[`realtime.capability-negotiation.v1`],F=u([`web`,`desktop`,`mobile`,`browser_extension`,`tui`,`mcp`]),I=s().min(1).max(512),L=s().regex(/^[a-z][a-z0-9_.-]*$/).max(160),R=f(),z=o().int().nonnegative(),B=o().int().positive(),V=s().min(1).max(160),H=(e,t)=>d({protocolVersion:l(2),messageId:R,kind:l(e),sentAt:z,payload:t}),U=d({topic:I,afterSeq:o().int().nonnegative().optional(),view:l(`compact`).optional()});t(`kind`,[H(`realtime.hello`,d({ticket:s().min(32).max(512),clientId:s().min(1).max(160),clientKind:F,subscriptions:c(U).max(100).default([]),capabilities:c(V).max(64).optional(),endpoint:C.optional()})),H(`realtime.subscribe`,d({subscriptions:c(U).min(1).max(100)})),H(`realtime.unsubscribe`,d({topics:c(I).min(1).max(100)})),H(`realtime.ping`,d({})),H(`endpoint.message`,oe)]);var W=d({topic:I,seq:B,event:L,data:i()}),ue=t(`kind`,[H(`realtime.ready`,d({connectionId:f(),heartbeatIntervalMs:l(M),heartbeatTimeoutMs:l(N),negotiatedCapabilities:c(V).max(64).optional(),endpoint:d({endpointId:s().min(1).max(160),turnToken:s().min(32).max(160)}).optional()})),H(`realtime.event`,W),H(`realtime.subscribed`,d({topic:I,cursor:o().int().nonnegative()})),H(`realtime.gap`,d({topic:I,requestedSeq:o().int().nonnegative(),earliestSeq:B,recoverable:a()})),H(`realtime.pong`,d({})),H(`realtime.error`,d({code:s().min(1).max(80),message:s().min(1).max(500)})),H(`endpoint.message`,se)]);function de(e){return ue.parse(e)}var G=class extends Error{retryable;constructor(e,t){super(e),this.retryable=t,this.name=`RealtimeConnectionError`}},fe=class extends Error{bytes;maxBytes;constructor(e,t){super(`Realtime client frame is ${e} bytes; maximum is ${t} bytes`),this.bytes=e,this.maxBytes=t,this.name=`RealtimeFrameTooLargeError`}};function pe(e){if(typeof e==`string`)return e;if(e instanceof ArrayBuffer)return new TextDecoder().decode(e);if(ArrayBuffer.isView(e)){let t=Uint8Array.from(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));return new TextDecoder().decode(t)}throw Error(`Realtime server sent a non-text frame`)}function me(e){return e===1009||e===4400||e===4401||e===4409||e===4413}var he=class{options;desiredSubscriptions=new Map;cursors=new Map;socket;reconnectTimer;heartbeatTimer;connectionTimer;ticketAbort;generation=0;reconnectAttempts=0;shouldReconnect=!1;ready=!1;lastServerMessageAt=0;endpointBinding;reconnectWhenSocketOpens=!1;offeredCapabilities=new Set;constructor(e){this.options=e}connect(){this.shouldReconnect||(this.shouldReconnect=!0,this.open(!1))}disconnect(){this.shouldReconnect=!1,this.reconnectWhenSocketOpens=!1,this.generation+=1,this.clearTimers(),this.ready=!1,this.offeredCapabilities.clear(),this.endpointBinding?.onDisconnected?.(),this.socket?.close(1e3,`Client disconnected`),this.socket=void 0,this.options.onStateChange?.(`disconnected`)}reconnect(){this.reconnectWhenSocketOpens=!1,this.generation+=1,this.clearTimers(),this.ready=!1,this.endpointBinding?.onDisconnected?.(),this.socket?.close(1e3,`Client reconnecting`),this.socket=void 0,this.reconnectAttempts=0,this.shouldReconnect=!0,this.open(!0)}subscribe(e,t){this.desiredSubscriptions.set(e,t),t!==void 0&&this.cursors.set(e,t),this.ready&&this.sendSubscriptions([{topic:e,afterSeq:this.cursors.get(e)??t}])}unsubscribe(e){this.desiredSubscriptions.delete(e),this.ready&&this.send(this.clientMessage(`realtime.unsubscribe`,{topics:[e]}))}sendEndpointMessage(e){if(!this.ready)throw Error(`Realtime connection is not ready`);this.send(this.clientMessage(`endpoint.message`,e))}setEndpoint(e){this.endpointBinding=e,this.refreshEndpointConnection()}clearEndpoint(e){if(e&&this.endpointBinding!==e)return;let t=this.endpointBinding;this.endpointBinding=void 0,t?.onDisconnected?.(),this.refreshEndpointConnection()}refreshEndpointConnection(){if(this.shouldReconnect){if(this.socket?.readyState===0){this.reconnectWhenSocketOpens=!0;return}this.reconnect()}}async open(e){let t=++this.generation,n=this.options.connectionTimeoutMs??15e3,r=new AbortController;this.ticketAbort?.abort(),this.ticketAbort=r;let i,a=!1,o,s=(e,n=!0)=>{a||t!==this.generation||(a=!0,this.clearConnectionTimer(),r.abort(),this.ticketAbort===r&&(this.ticketAbort=void 0),this.ready=!1,this.offeredCapabilities.clear(),this.endpointBinding?.onDisconnected?.(),this.clearHeartbeat(),this.socket===i&&(this.socket=void 0),i&&(i.onopen=null,i.onmessage=null,i.onerror=null,i.onclose=null,i.close(4e3,e.slice(0,120))),this.shouldReconnect&&n?this.scheduleReconnect(e):this.shouldReconnect?(this.shouldReconnect=!1,this.options.onStateChange?.(`error`,e)):this.options.onStateChange?.(`disconnected`))};this.connectionTimer=setTimeout(()=>s(`Realtime connection timed out`),n),this.options.onStateChange?.(e?`reconnecting`:`connecting`);try{let[e,n]=await Promise.all([this.options.issueTicket(r.signal),this.endpointBinding?.createHello()]),c=e.ticket;if(2<e.realtime.minVersion)throw new G(`CLIENT_UPDATE_REQUIRED`,!1);if(2>e.realtime.maxVersion)throw new G(`GATEWAY_UPDATE_REQUIRED`,!1);let l=P.filter(t=>e.realtime.capabilities.includes(t));if(a||!this.shouldReconnect||t!==this.generation)return;this.offeredCapabilities=new Set(l??[]),i=this.options.createWebSocket(this.options.getWebSocketUrl()),this.socket=i,i.onopen=()=>{if(t!==this.generation)return;if(this.reconnectWhenSocketOpens){this.reconnect();return}let e=[...this.desiredSubscriptions].map(([e,t])=>({topic:e,afterSeq:this.cursors.get(e)??t}));this.send(this.clientMessage(`realtime.hello`,{ticket:c,clientId:this.options.clientId,clientKind:this.options.clientKind,subscriptions:e,...l?.length?{capabilities:l}:{},...n?{endpoint:n}:{}}))},i.onmessage=e=>{if(t!==this.generation)return;let n=()=>{if(!(a||t!==this.generation))return this.handleServerMessage(pe(e.data))};if(!o){try{let e=n();if(!e)return;let t=e.catch(e=>s(e instanceof Error?e.message:`Invalid realtime server message`)).then(()=>void 0);o=t,t.finally(()=>{o===t&&(o=void 0)})}catch(e){s(e instanceof Error?e.message:`Invalid realtime server message`)}return}let r=o.then(n).catch(e=>s(e instanceof Error?e.message:`Invalid realtime server message`)).then(()=>void 0);o=r,r.finally(()=>{o===r&&(o=void 0)})},i.onerror=()=>{},i.onclose=e=>{s(e.reason||`WebSocket closed (${e.code??0})`,!me(e.code))}}catch(e){s(e instanceof Error?e.message:`Realtime connection failed`,!(e instanceof G)||e.retryable)}}handleServerMessage(e){let t=de(JSON.parse(e));if(this.lastServerMessageAt=Date.now(),t.kind===`realtime.ready`){let e=t.payload.negotiatedCapabilities??[];if(e.some(e=>!this.offeredCapabilities.has(e)))throw Error(`Realtime server negotiated a capability the client did not offer`);this.ready=!0,this.reconnectAttempts=0,this.clearConnectionTimer(),this.ticketAbort=void 0,this.options.onStateChange?.(`connected`),this.options.onCapabilities?.(e),t.payload.endpoint&&this.endpointBinding?.onReady(t.payload.endpoint),this.clearHeartbeat(),this.heartbeatTimer=setInterval(()=>{if(this.ready){if(Date.now()-this.lastServerMessageAt>=t.payload.heartbeatTimeoutMs){this.reconnect();return}this.send(this.clientMessage(`realtime.ping`,{}))}},t.payload.heartbeatIntervalMs)}else if(t.kind===`realtime.event`){let e=this.cursors.get(t.payload.topic);if(e!==void 0&&t.payload.seq<=e)return;this.options.onEvent?.(t.payload),this.cursors.set(t.payload.topic,t.payload.seq)}else if(t.kind===`realtime.subscribed`)this.cursors.set(t.payload.topic,t.payload.cursor),this.options.onSubscribed?.(t.payload);else if(t.kind===`realtime.gap`)return this.cursors.set(t.payload.topic,t.payload.earliestSeq-1),this.options.onGap?.(t.payload);else t.kind===`realtime.error`?this.options.onStateChange?.(`error`,t.payload.message):t.kind===`endpoint.message`&&(this.endpointBinding?.onMessage(t.payload),this.options.onEndpointMessage?.(t.payload))}sendSubscriptions(e){this.send(this.clientMessage(`realtime.subscribe`,{subscriptions:e}))}clientMessage(e,t){let n=this.options.createMessageId?.()??globalThis.crypto?.randomUUID?.();if(!n)throw Error(`RealtimeClient requires createMessageId when crypto.randomUUID is unavailable`);return{protocolVersion:2,messageId:n,kind:e,sentAt:Date.now(),payload:t}}send(e){if(!this.socket||this.socket.readyState!==1)return;let t=JSON.stringify(e),n=new TextEncoder().encode(t).byteLength;if(n>262144)throw new fe(n,j);this.socket.send(t)}scheduleReconnect(e){if(!this.shouldReconnect)return;this.reconnectAttempts+=1;let t=this.options.maxReconnectAttempts;if(t!==void 0&&this.reconnectAttempts>t){this.shouldReconnect=!1,this.options.onStateChange?.(`error`,e);return}this.options.onStateChange?.(`reconnecting`,e);let n=Math.min(3e4,1e3*2**Math.min(this.reconnectAttempts-1,5)),r=Math.round(n*(.5+Math.random()*.5));this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=void 0,this.open(!0)},r)}clearHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0}clearTimers(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0,this.clearConnectionTimer(),this.ticketAbort?.abort(),this.ticketAbort=void 0,this.clearHeartbeat()}clearConnectionTimer(){this.connectionTimer&&clearTimeout(this.connectionTimer),this.connectionTimer=void 0}},ge=500,K=null,q;function J(e){q=e,K!==null&&clearTimeout(K),K=setTimeout(()=>{K=null;let e=q;q=void 0,window.dispatchEvent(new CustomEvent(`config-reload`,{detail:e}))},ge)}function _e(e,t){if(e===`config.reload`){J(t);return}window.dispatchEvent(new CustomEvent(e.replace(/[._]/g,`-`),{detail:t}))}var Y=new Map,X=new Map,Z,Q;function $(){let e=`xopc:realtime-client-id`,t=sessionStorage.getItem(e);if(t)return t;let n=crypto.randomUUID();return sessionStorage.setItem(e,n),n}function ve(){let t=new URL(e(`/api/realtime/v1/ws`));return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString()}function ye(){let t=$(),n=window.electronAPI?`desktop`:`web`,r=new he({clientId:t,clientKind:n,getWebSocketUrl:ve,issueTicket:async r=>{let i=await fetch(e(`/api/realtime/tickets`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientId:t,clientKind:n,protocolVersion:2}),signal:r}),a=await i.json().catch(()=>null);if(!i.ok||!a?.payload?.ticket||!a.payload.realtime)throw Error(a?.error?.message??`Realtime ticket failed (${i.status})`);return{ticket:a.payload.ticket,realtime:a.payload.realtime}},createWebSocket:e=>new WebSocket(e),onStateChange:(e,t)=>{p({connectionState:e,error:t??null}),e===`connected`&&window.dispatchEvent(new CustomEvent(`gateway-realtime-connected`))},onEvent:e=>{(e.topic===`gateway`||e.topic===`sessions`)&&_e(e.event,e.data);let t=X.get(e.topic);(t===void 0||e.seq>t)&&X.set(e.topic,e.seq);for(let t of Y.get(e.topic)??[])if(!(t.cursor!==void 0&&e.seq<=t.cursor))try{t.listener.onEvent(e)}catch(e){console.error(`[realtime] topic listener failed:`,e)}finally{t.cursor=Math.max(t.cursor??0,e.seq)}},onGap:async e=>{window.dispatchEvent(new CustomEvent(`realtime-gap`,{detail:e}));let t=[...Y.get(e.topic)??[]].filter(t=>!e.recoverable||t.cursor===void 0||t.cursor<e.earliestSeq-1),n=await Promise.allSettled(t.map(t=>t.listener.onGap?.(e)));for(let e of n)e.status===`rejected`&&console.error(`[realtime] topic gap handler failed:`,e.reason)}});Z?.disconnect(),Z=r,Q&&r.setEndpoint(Q),r.subscribe(`gateway`,X.get(`gateway`)),r.subscribe(`sessions`,X.get(`sessions`));for(let e of Y.keys())r.subscribe(e,X.get(e));return p({connectionState:`connecting`,error:null}),r.connect(),()=>{Z===r&&(r.disconnect(),Z=void 0)}}function be(e){return Q=e,Z?.setEndpoint(e),()=>{Q===e&&(Q=void 0,Z?.clearEndpoint(e))}}function xe(e){Z?.sendEndpointMessage(e)}function Se(){Z?.reconnect()}function Ce(e,t,n){let r=Y.get(e)??new Set,i=r.size===0,a=X.get(e),o={listener:t,cursor:n??a};if(r.add(o),Y.set(e,r),i){let t=n??a;X.set(e,t),Z?.subscribe(e,t)}else n!==void 0&&(a===void 0||n<a)&&Z?.subscribe(e,n);return()=>{let t=Y.get(e);t?.delete(o),(!t||t.size===0)&&(Y.delete(e),X.delete(e),Z?.unsubscribe(e))}}export{Ce as a,m as c,A as d,E as f,ye as i,ce as l,Se as n,J as o,xe as r,le as s,be as t,k as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as e}from"./locale-store-WMaCMm3_.js";var t=e(()=>({connectionState:`idle`,error:null}));function n(e){t.setState(e)}export{t as n,n as t};
|