@openchambery/web 1.17.1 → 1.18.0
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/bin/lib/DOCUMENTATION.md +1 -0
- package/dist/assets/{AgentAvatar-C6Hxu5_o.js → AgentAvatar-B2kZjgaf.js} +1 -1
- package/dist/assets/{AssistantView-CbnxMZU0.js → AssistantView-Dc9MhgcD.js} +1 -1
- package/dist/assets/{ChatContainer-DEDGosbz.js → ChatContainer-CA3RO1yP.js} +40 -40
- package/dist/assets/{DiagramView-Byxhaduz.js → DiagramView-CpT4q2Jg.js} +1 -1
- package/dist/assets/{FadeInOnReveal-CvNA_aGD.js → FadeInOnReveal-aeWlaqVB.js} +1 -1
- package/dist/assets/{Icon-BPJ_quEe.js → Icon-AXqa-fYB.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-Cv8V-Q5l.js → MarkdownRendererImpl-DLnXrjCS.js} +2 -2
- package/dist/assets/{MobileDetailNavigation-lVtCe-5P.js → MobileDetailNavigation-BYX8jFRg.js} +1 -1
- package/dist/assets/MobileShareBridge-BJzGsvUa.js +4 -0
- package/dist/assets/MobileSurface-Cfe17dw4.js +2 -0
- package/dist/assets/{MultiRunWindow-1kkKTh4h.js → MultiRunWindow-DEYIMkSg.js} +1 -1
- package/dist/assets/{OnboardingScreen-CdvaEBtt.js → OnboardingScreen-CCfdEtW6.js} +1 -1
- package/dist/assets/{OverlayScrollbar-Dqk1zGJB.js → OverlayScrollbar-CpQvV-qY.js} +1 -1
- package/dist/assets/SettingsView-PjA5aLCR.js +25 -0
- package/dist/assets/{SettingsWindow-DMQMRgc3.js → SettingsWindow-DOe4sCjl.js} +1 -1
- package/dist/assets/{TerminalView-jYq0JQPc.js → TerminalView-Bf-2wMV0.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DJefd2N6.js → ToolOutputDialog-DuT5ne12.js} +1 -1
- package/dist/assets/{appThemeRegistry-BXeIggYO.js → appThemeRegistry--wNZ5yxf.js} +2 -2
- package/dist/assets/{button-BmNJBT13.js → button-CDvMVaiO.js} +1 -1
- package/dist/assets/{clipboard-CXWbHCAk.js → clipboard-Jdqe05db.js} +1 -1
- package/dist/assets/{collapsible-68IqWBM1.js → collapsible-C2aamDvD.js} +1 -1
- package/dist/assets/{context-menu-BbRpMBQh.js → context-menu-CS_u7xxB.js} +1 -1
- package/dist/assets/desktopHosts-CBoBpJ1Z.js +1 -0
- package/dist/assets/desktopRelayRestore-l2R9muux.js +1 -0
- package/dist/assets/{diagram-YN0GZ1Q0.js → diagram-CEon0BQs.js} +1 -1
- package/dist/assets/{dialog-BV1ENlLf.js → dialog-BzZ3cKxG.js} +1 -1
- package/dist/assets/es-C25PRSjo.js +15 -0
- package/dist/assets/{fileQueries-i4oziMnC.js → fileQueries-CE_DaZWQ.js} +1 -1
- package/dist/assets/fr-Cv8ZWQdW.js +13 -0
- package/dist/assets/{gitApi-Bs_2iBAm.js → gitApi-DSLGdswL.js} +3 -3
- package/dist/assets/gitApiHttp-D8j1qRH4.js +2 -0
- package/dist/assets/{input-BLVhPvhN.js → input-k9DGGyZ6.js} +1 -1
- package/dist/assets/insertionBoundaries-BkoTIR-0.js +1 -0
- package/dist/assets/{ja-Dcb0VtDE.js → ja-Ue9m9eSe.js} +3 -3
- package/dist/assets/{ko-CX71xNDX.js → ko-DWBUCCV6.js} +3 -3
- package/dist/assets/main-CTnxV3y3.js +172 -0
- package/dist/assets/{main-CT0DuuLm.js → main-D1Xze0xA.js} +2 -2
- package/dist/assets/{markdown-worker-Cq3Twp1A.js → markdown-worker-DkeWiER6.js} +1 -1
- package/dist/assets/{markdownTheme-CCnvI6L0.js → markdownTheme-DNT93i5L.js} +1 -1
- package/dist/assets/miniChat-Dxajshg_.js +2 -0
- package/dist/assets/mobile-CisSv-ca.js +2 -0
- package/dist/assets/multirun-BOb2dW9T.js +4 -0
- package/dist/assets/persistence-DPNMIbF5.js +3 -0
- package/dist/assets/{pl-mR_3Sqr8.js → pl-DaBaPCyE.js} +3 -3
- package/dist/assets/projectMeta-WTDhB__y.js +3 -0
- package/dist/assets/pt-BR-C2cJZ43o.js +15 -0
- package/dist/assets/radio-DZwuHb7-.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-DpYFpBSy.js +2 -0
- package/dist/assets/renderMobileApp-DB1TXtLg.js +23 -0
- package/dist/assets/runtimeConfig-BtWi74Pm.js +1 -0
- package/dist/assets/runtimeEndpointReset-BnA1DoNG.js +145 -0
- package/dist/assets/{sortable-tabs-strip-oKJ700WG.js → sortable-tabs-strip-DADoz-JR.js} +1 -1
- package/dist/assets/src-oHrYIqHF.css +2 -0
- package/dist/assets/{store-oojlrF4d.js → store-SqV3zfE8.js} +4 -4
- package/dist/assets/{terminalApi-BYTA045F.js → terminalApi-tB3qLcfa.js} +1 -1
- package/dist/assets/{tooltip-BYGBBTc2.js → tooltip-DMNR5rN0.js} +1 -1
- package/dist/assets/uk-DJz_P8OZ.js +15 -0
- package/dist/assets/{url-CGHw6D-E.js → url-7MqoLs9X.js} +1 -1
- package/dist/assets/useAppFontEffects-CeS0e0FK.js +7 -0
- package/dist/assets/{useAssistantUIStore-ESTV1mEY.js → useAssistantUIStore-Bq3cPj2x.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-Cq5a2gcJ.js → useDesktopWindowControlsLayout-DwFMUFtC.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-DG6uPzBG.js → useEffectiveDirectory-Dp8McufI.js} +1 -1
- package/dist/assets/{useFontPreferences-Bu4ME5hk.js → useFontPreferences-CIurCeNv.js} +1 -1
- package/dist/assets/useMobileNavigationStore-kWPnKBP1.js +475 -0
- package/dist/assets/useSessionAutoCleanup-BLiIZW0x.js +1 -0
- package/dist/assets/useUIStore-5agS8bsW.js +1 -0
- package/dist/assets/{useWorkerHighlightedLines-ADgu9578.js → useWorkerHighlightedLines-Cnxz7HaG.js} +1 -1
- package/dist/assets/{utils-DyUyiLje.js → utils-Co19EJEL.js} +1 -1
- package/dist/assets/zh-CN-DLAKDOM9.js +15 -0
- package/dist/assets/zh-TW-s3Jjx1_n.js +15 -0
- package/dist/index.html +9 -9
- package/dist/mini-chat.html +9 -9
- package/dist/mobile.html +9 -9
- package/package.json +1 -1
- package/server/index.d.ts +4 -0
- package/server/index.js +29 -15
- package/server/lib/client-auth/pairing.js +7 -1
- package/server/lib/client-auth/pairing.test.js +45 -0
- package/server/lib/desktop-hosts/routes.js +157 -0
- package/server/lib/desktop-hosts/routes.test.js +227 -0
- package/server/lib/message-queue/DOCUMENTATION.md +1 -1
- package/server/lib/message-queue/routes.js +1 -1
- package/server/lib/message-queue/routes.test.js +1 -0
- package/server/lib/message-queue/service.js +12 -1
- package/server/lib/message-queue/service.test.js +30 -0
- package/server/lib/opencode/DOCUMENTATION.md +4 -4
- package/server/lib/opencode/bootstrap-runtime.js +7 -0
- package/server/lib/opencode/cli-entry-runtime.js +6 -0
- package/server/lib/opencode/cli-entry-runtime.test.js +43 -0
- package/server/lib/opencode/core-routes.js +4 -1
- package/server/lib/opencode/core-routes.test.js +29 -0
- package/server/lib/opencode/openchamber-routes.js +12 -0
- package/server/lib/opencode/settings-runtime.js +1 -1
- package/server/lib/package-manager.js +3 -1
- package/server/lib/relay/DOCUMENTATION.md +44 -1
- package/server/lib/relay/host-client.js +4 -1
- package/server/lib/relay/service.js +16 -8
- package/server/lib/relay/service.test.js +21 -6
- package/server/lib/relay/tunnel-host.js +57 -4
- package/server/lib/relay/tunnel-host.test.js +250 -2
- package/dist/assets/MobileShareBridge-DAlvgjo1.js +0 -4
- package/dist/assets/MobileSurface-Bde8yLWo.js +0 -2
- package/dist/assets/SettingsView-D0dhTIur.js +0 -25
- package/dist/assets/desktopHosts-BpjUSDz4.js +0 -1
- package/dist/assets/desktopRelayRestore-BzUEk1i7.js +0 -1
- package/dist/assets/es-EXZUX1sB.js +0 -15
- package/dist/assets/fr-jWNPO91J.js +0 -13
- package/dist/assets/gitApiHttp-C1DaEMKR.js +0 -2
- package/dist/assets/insertionBoundaries-BAFtAotq.js +0 -1
- package/dist/assets/main-G8tKFcTV.js +0 -172
- package/dist/assets/miniChat-BP3OHqNF.js +0 -2
- package/dist/assets/mobile-BtwuDs-C.js +0 -2
- package/dist/assets/multirun-B-L3JH60.js +0 -4
- package/dist/assets/persistence-C_KCiMcY.js +0 -3
- package/dist/assets/projectMeta-Cp74cItv.js +0 -3
- package/dist/assets/pt-BR-D1RpVOvC.js +0 -15
- package/dist/assets/radio-Bs4mdPv5.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-dgirEOtR.js +0 -2
- package/dist/assets/renderMobileApp-DK9qzy0P.js +0 -23
- package/dist/assets/runtimeConfig-JSaYFA5x.js +0 -1
- package/dist/assets/runtimeEndpointReset-C0eCWIE6.js +0 -145
- package/dist/assets/src-8zziWB78.css +0 -2
- package/dist/assets/uk-UvnVqWv-.js +0 -15
- package/dist/assets/useAppFontEffects-BhLcUfRB.js +0 -7
- package/dist/assets/useMobileNavigationStore-1xHjnAsg.js +0 -475
- package/dist/assets/useSessionAutoCleanup-BFletAeV.js +0 -1
- package/dist/assets/useUIStore-D6BTB4va.js +0 -1
- package/dist/assets/zh-CN-9v-RC966.js +0 -15
- package/dist/assets/zh-TW-BZ_wZdC-.js +0 -15
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{M as t,t as n}from"./useUIStore-5agS8bsW.js";import{Kt as r,kn as i,qt as a,u as o}from"./persistence-DPNMIbF5.js";import{h as s}from"./desktopHosts-CBoBpJ1Z.js";import{a as c,i as l,o as u,r as d}from"./desktopRelayRestore-l2R9muux.js";import{nt as f,rt as p}from"./vendor-base-ui-CnHfUmDN.js";import{kt as m}from"./gitApiHttp-D8j1qRH4.js";import{n as h}from"./vendor-react-DLPElpoQ.js";import{n as g}from"./vendor-tanstack-query-core-BWz0ose6.js";import{i as _,r as v}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as y,t as b}from"./clipboard-Jdqe05db.js";import{i as ee,t as x}from"./store-SqV3zfE8.js";import{Xi as S,hr as C,l as w,tr as te,wr as T,xr as ne}from"./useMobileNavigationStore-kWPnKBP1.js";import{t as E}from"./utils-Co19EJEL.js";import{n as D}from"./Icon-AXqa-fYB.js";import{t as O}from"./button-CDvMVaiO.js";import{i as re,n as ie,r as ae,t as oe}from"./vendor-simplewebauthn-browser-Dwhcdg_5.js";import{n as se,r as ce}from"./radio-DZwuHb7-.js";var k=h(),A=[`desktopHostSwitch`],j=class extends Error{result;host;constructor(e,t){super(e.reason),this.name=`DesktopHostSwitchError`,this.result=e,this.host=t}},le=(e,t)=>x(ee.getState().dictionary,e,t),ue=async e=>{let{host:n}=e;if(n.id===`local`){let r=(e.localApiOrigin||``).trim();if(!r)throw new j({ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`},n);return t({apiBaseUrl:r,clientToken:e.localClientToken||null,runtimeKey:l(n)}),{ok:!0,via:`direct`,status:{status:`ok`,latencyMs:0}}}if(n.viaSshRelay){let e=await u(n);if(!e.ok)throw new j(e,n);return e}let r=await c(n,{cachedProbe:e.cachedProbe});if(!r.ok)throw new j(r,n);return r},M=null,de=()=>M||(M=new g(o,{mutationKey:A,mutationFn:ue,onError:(e,t)=>{e instanceof j&&e.result.reason!==`unsupported`&&te.error(le(`desktopHostSwitcher.toast.instanceUnreachable`,{host:s(t.host.label)}))}}),M.subscribe(()=>void 0),M),fe=async e=>{if(d(e.host))return{ok:!0,via:`direct`,status:e.cachedProbe?.status===`ok`?e.cachedProbe:{status:`ok`,latencyMs:0}};if(o.isMutating({mutationKey:A})>0)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};try{return await de().mutate(e)}catch(e){if(e instanceof j)return e.result;throw e}},pe=()=>{let e=(0,k.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={mutationKey:A},e[0]=t):t=e[0],v(t)>0},me=()=>{let e=(0,k.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={filters:{mutationKey:A,status:`pending`},select:he},e[0]=t):t=e[0],_(t)[0]?.host.id??null};function he(e){return e.state.variables}var N=e=>typeof e==`object`&&!!e,P=(e,t)=>{let n=e[t];return typeof n==`string`?n:null},F=(e,t)=>{let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null},I=(e,t)=>{let n=e[t];return typeof n==`boolean`?n:null},L=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],R=()=>r()?(e,t)=>a(e,t):null,z=e=>{if(!N(e))return;let t=I(e,`enabled`)??!1,n=P(e,`store`)?.toLowerCase()===`settings`?`settings`:`never`,r=P(e,`value`);return{enabled:t,store:n,...r?{value:r}:{}}},ge=e=>e===`remote`||e===`dynamic`?e:`local`,_e=e=>{if(!N(e))return null;let t=P(e,`id`);if(!t)return null;let n=I(e,`enabled`)??!0,r=ge(P(e,`type`)),i=P(e,`localHost`)||P(e,`local_host`)||void 0,a=F(e,`localPort`)??F(e,`local_port`)??void 0,o=P(e,`remoteHost`)||P(e,`remote_host`)||void 0,s=F(e,`remotePort`)??F(e,`remote_port`)??void 0;return{id:t,enabled:n,type:r,...i?{localHost:i}:{},...typeof a==`number`?{localPort:a}:{},...o?{remoteHost:o}:{},...typeof s==`number`?{remotePort:s}:{}}},ve=e=>{if(!N(e))return null;let t=P(e,`id`),n=P(e,`sshCommand`)||P(e,`ssh_command`);if(!t||!n)return null;let r=P(e,`nickname`),i=e.sshParsed,a=N(i)?{destination:P(i,`destination`)||``,args:L(i.args)}:void 0,o=N(e.remoteOpenchamber)?e.remoteOpenchamber:N(e.remote_openchamber)?e.remote_openchamber:{},s=N(e.localForward)?e.localForward:N(e.local_forward)?e.local_forward:{},c=N(e.auth)?e.auth:{},l=P(o,`mode`)?.toLowerCase()===`external`?`external`:`managed`,u=P(o,`installMethod`)||P(o,`install_method`),d=u===`npm`||u===`download_release`||u===`upload_bundle`?u:`bun`,f=P(s,`bindHost`)||P(s,`bind_host`)||`127.0.0.1`,p=f===`localhost`||f===`0.0.0.0`?f:`127.0.0.1`,m=(Array.isArray(e.portForwards)?e.portForwards:Array.isArray(e.port_forwards)?e.port_forwards:[]).map(e=>_e(e)).filter(e=>!!e),h=F(o,`preferredPort`)??F(o,`preferred_port`),g=F(s,`preferredLocalPort`)??F(s,`preferred_local_port`),_=z(c.sshPassword||c.ssh_password),v=z(c.openchamberPassword||c.openchamber_password);return{id:t,...r?{nickname:r}:{},sshCommand:n,...a&&a.destination?{sshParsed:a}:{},connectionTimeoutSec:F(e,`connectionTimeoutSec`)??F(e,`connection_timeout_sec`)??60,remoteOpenchamber:{mode:l,keepRunning:I(o,`keepRunning`)??I(o,`keep_running`)??!0,...h?{preferredPort:h}:{},installMethod:d,uploadBundleOverSsh:I(o,`uploadBundleOverSsh`)??I(o,`upload_bundle_over_ssh`)??!1},localForward:{...g?{preferredLocalPort:g}:{},bindHost:p},auth:{..._?{sshPassword:_}:{},...v?{openchamberPassword:v}:{}},portForwards:m}},ye=e=>{switch(e){case`config_resolved`:case`auth_check`:case`master_connecting`:case`remote_probe`:case`installing`:case`updating`:case`server_detecting`:case`server_starting`:case`forwarding`:case`ready`:case`degraded`:case`error`:return e;default:return`idle`}},be=e=>{if(!N(e))return null;let t=P(e,`id`);return t?{id:t,phase:ye(P(e,`phase`)),...P(e,`detail`)?{detail:P(e,`detail`)||void 0}:{},...P(e,`localUrl`)||P(e,`local_url`)?{localUrl:P(e,`localUrl`)||P(e,`local_url`)||void 0}:{},...typeof(F(e,`localPort`)??F(e,`local_port`))==`number`?{localPort:F(e,`localPort`)??F(e,`local_port`)??void 0}:{},...typeof(F(e,`remotePort`)??F(e,`remote_port`))==`number`?{remotePort:F(e,`remotePort`)??F(e,`remote_port`)??void 0}:{},startedByUs:I(e,`startedByUs`)??I(e,`started_by_us`)??!1,retryAttempt:F(e,`retryAttempt`)??F(e,`retry_attempt`)??0,requiresUserAction:I(e,`requiresUserAction`)??I(e,`requires_user_action`)??!1,updatedAtMs:F(e,`updatedAtMs`)??F(e,`updated_at_ms`)??Date.now()}:null},xe=e=>{if(!N(e))return null;let t=P(e,`host`),n=P(e,`source`),r=P(e,`sshCommand`)||P(e,`ssh_command`);return!t||!n||!r?null:{host:t,source:n,sshCommand:r,pattern:I(e,`pattern`)??!1}},Se=(e,t)=>({id:e,sshCommand:t,connectionTimeoutSec:60,remoteOpenchamber:{mode:`managed`,keepRunning:!0,installMethod:`bun`,uploadBundleOverSsh:!1},localForward:{bindHost:`127.0.0.1`},auth:{},portForwards:[]}),Ce=async()=>{let e=R();if(!e)return{instances:[]};let t=await e(`desktop_ssh_instances_get`);return N(t)?{instances:(Array.isArray(t.instances)?t.instances:Array.isArray(t.desktopSshInstances)?t.desktopSshInstances:[]).map(e=>ve(e)).filter(e=>!!e)}:{instances:[]}},we=async e=>{let t=R();t&&await t(`desktop_ssh_instances_set`,{config:{instances:e.instances}})},Te=async()=>{let e=R();if(!e)return[];let t=await e(`desktop_ssh_import_hosts`);return Array.isArray(t)?t.map(e=>xe(e)).filter(e=>!!e):[]},Ee=async e=>{let t=R();t&&await t(`desktop_ssh_connect`,{id:e})},De=async e=>{let t=R();t&&await t(`desktop_ssh_disconnect`,{id:e})},Oe=async e=>{let t=R();if(!t)return[];let n=await t(`desktop_ssh_status`,{...e?{id:e}:{}});return Array.isArray(n)?n.map(e=>be(e)).filter(e=>!!e):[]},ke=async(e,t)=>{let n=R();if(!n)return[];let r=await n(`desktop_ssh_logs`,{id:e,...typeof t==`number`?{limit:t}:{}});return Array.isArray(r)?r.filter(e=>typeof e==`string`):[]},Ae=async e=>{let t=R();t&&await t(`desktop_ssh_logs_clear`,{id:e})},je=e=>{if(!N(e))return null;let t=P(e,`path`),n=F(e,`bytes`);return!t||n===null?null:{path:t,bytes:n}},Me=e=>{if(!N(e))return null;let t=P(e,`path`),n=F(e,`fileCount`)??F(e,`file_count`),r=F(e,`bytes`);return!t||n===null||r===null?null:{path:t,fileCount:n,bytes:r}},Ne=e=>{if(e==null||!N(e))return null;let t=F(e,`fileCount`)??F(e,`file_count`),n=F(e,`bytes`);return t===null||n===null?null:{fileCount:t,bytes:n}},Pe=e=>{if(e==null||!N(e))return null;let t=F(e,`bytes`);return t===null?null:{bytes:t}},B=e=>{if(!N(e))return null;let t=Array.isArray(e.files)?e.files:null,n=Array.isArray(e.directories)?e.directories:null,r=L(e.deletes),i=F(e,`totalBytes`)??F(e,`total_bytes`);if(!t||!n||i===null||!(`agentsRoot`in e)&&!(`agents_root`in e))return null;let a=t.map(e=>je(e)).filter(e=>!!e),o=n.map(e=>Me(e)).filter(e=>!!e);if(a.length!==t.length||o.length!==n.length)return null;let s=e.agentsRoot??e.agents_root,c=s==null?null:Ne(s);if(s!=null&&c===null)return null;let l=e.authFile??e.auth_file;return{files:a,directories:o,agentsRoot:c,authFile:l==null?null:Pe(l),deletes:r,totalBytes:i}},Fe=e=>{if(!N(e))return null;let t=B(e.plan);return t?{plan:t,remoteExisting:L(e.remoteExisting??e.remote_existing),remoteAgentsRootExists:I(e,`remoteAgentsRootExists`)??I(e,`remote_agents_root_exists`)??!1,remoteAuthFileExists:I(e,`remoteAuthFileExists`)??I(e,`remote_auth_file_exists`)??!1}:null},Ie=e=>{if(!N(e)||I(e,`ok`)!==!0)return null;let t=F(e,`files`),n=F(e,`directories`),r=F(e,`deletes`),i=F(e,`totalBytes`)??F(e,`total_bytes`);if(t===null||n===null||r===null||i===null||!(`agentsRoot`in e)&&!(`agents_root`in e))return null;let a=e.agentsRoot??e.agents_root,o=null;if(a!=null){if(!N(a))return null;let e=F(a,`fileCount`)??F(a,`file_count`);if(e===null)return null;o={fileCount:e}}let s=e.authFile??e.auth_file,c=s==null?null:Pe(s);return{ok:!0,files:t,directories:n,deletes:r,totalBytes:i,agentsRoot:o,authFile:c}},Le=async()=>{let e=R();if(!e)return null;let t=await e(`desktop_ssh_sync_opencode_config`,{stage:`local`});return N(t)?B(t.plan):null},Re=async e=>{let t=R();return t?Fe(await t(`desktop_ssh_sync_opencode_config`,{id:e})):null},ze=async e=>{let t=R();return t?Ie(await t(`desktop_ssh_sync_opencode_config`,{id:e,apply:!0})):null},Be=async e=>{if(!r())return async()=>{};let t=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof t!=`function`)return async()=>{};let n=await t(`openchamber:ssh-instance-status`,t=>{let n=be(t?.payload);n&&e(n)});return async()=>{await n()}},Ve=`/auth/passkey/authenticate/options`,He=`/auth/passkey/authenticate/verify`,Ue=`/auth/passkey/register/options`,We=`/auth/passkey/register/verify`,V=`/api/passkeys`,Ge=`/auth/passkey/status`,Ke=`/api/auth/reset`,H={enabled:!1,hasPasskeys:!1,passkeyCount:0,rpID:null},U=async(e,t)=>i(e,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),W=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim())return t.error}catch{}return t},qe=e=>e instanceof re&&e.code===`ERROR_CEREMONY_ABORTED`,Je=()=>{ae.cancelCeremony()},G=()=>typeof window>`u`?{supported:!1,reason:`Passkeys are unavailable outside the browser.`}:window.isSecureContext?{supported:!0,reason:``}:{supported:!1,reason:`Passkeys require HTTPS or localhost.`},Ye=async()=>{let e=G();if(!e.supported)throw Error(e.reason);let t=await U(Ue,{label:typeof navigator.userAgent==`string`&&navigator.userAgent.trim()?navigator.userAgent:`This device`});if(!t.ok)throw Error(await W(t,`Could not start passkey setup.`));let{requestId:n,optionsJSON:r}=await t.json(),i=await U(We,{requestId:n,response:await ie({optionsJSON:r})});if(!i.ok)throw Error(await W(i,`Could not finish passkey setup.`));return i.json().catch(()=>null)},Xe=async(e,t={})=>{let n=G();if(!n.supported)throw Error(n.reason);let r=await U(Ve);if(!r.ok)throw Error(await W(r,`Passkey sign-in is not available right now.`));let{requestId:i,optionsJSON:a}=await r.json(),o=await U(He,{requestId:i,response:await oe({optionsJSON:a}),trustDevice:e,issueClientToken:t.issueClientToken===!0,clientLabel:t.clientLabel,clientKind:t.clientKind,dedupeKey:t.dedupeKey});if(!o.ok)throw Error(await W(o,`Passkey sign-in failed.`));return o.json().catch(()=>null)},Ze=async()=>{let e=await i(Ge,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return H;let t=await e.json().catch(()=>null);return{enabled:t?.enabled===!0,hasPasskeys:t?.hasPasskeys===!0,passkeyCount:typeof t?.passkeyCount==`number`?t.passkeyCount:0,rpID:typeof t?.rpID==`string`&&t.rpID?t.rpID:null}},Qe=async()=>{let e=await i(V,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(await W(e,`Could not load passkeys.`));let t=await e.json().catch(()=>null);return Array.isArray(t?.passkeys)?t.passkeys:[]},$e=async e=>{let t=await i(`${V}/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(await W(t,`Could not remove passkey.`));return t.json().catch(()=>null)},et=async()=>{let e=await U(Ke);if(!e.ok)throw Error(await W(e,`Could not clear saved authentication.`));return e.json().catch(()=>null)},K=e(p(),1),q=f();function J(e){let t=(0,k.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=E(`bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,q.jsx)(`div`,{"data-slot":`card`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Y(e){let t=(0,k.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=E(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,q.jsx)(`div`,{"data-slot":`card-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function X(e){let t=(0,k.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=E(`leading-none font-semibold`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,q.jsx)(`div`,{"data-slot":`card-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Z(e){let t=(0,k.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=E(`px-6`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,q.jsx)(`div`,{"data-slot":`card-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var tt=class extends K.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t,copied:!1}),console.error(`Error caught by boundary:`,e,t)}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};handleCopy=async()=>{let{strings:e}=this.props,t=`${this.state.error?String(this.state.error):e.unknownError}${this.state.error?.stack?`\n\nStack:\n${this.state.error.stack}`:``}${this.state.errorInfo?.componentStack?`\n\n${e.componentStackLabel}${this.state.errorInfo.componentStack}`:``}`;(await b(t)).ok&&(this.setState({copied:!0}),window.setTimeout(()=>{this.setState(e=>e.copied?{copied:!1}:null)},1500))};render(){let{strings:e}=this.props;return this.state.hasError?this.props.fallback?this.props.fallback:(0,q.jsx)(`div`,{className:`p-4 flex items-center justify-center min-h-screen`,children:(0,q.jsxs)(J,{className:`w-full max-w-md`,children:[(0,q.jsx)(Y,{className:`text-center`,children:(0,q.jsxs)(X,{className:`flex items-center justify-center gap-2 text-destructive`,children:[(0,q.jsx)(D,{name:`error-warning`,className:`h-5 w-5`}),e.title]})}),(0,q.jsxs)(Z,{className:`space-y-4`,children:[(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground text-center`,children:e.description}),this.state.error&&(0,q.jsxs)(`details`,{className:`text-xs font-mono bg-muted p-3 rounded`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer hover:bg-interactive-hover/80`,children:e.detailsSummary}),(0,q.jsxs)(`pre`,{className:`mt-2 max-h-48 overflow-auto`,children:[this.state.error.toString(),this.state.errorInfo?.componentStack?`\n\n${e.componentStackLabel}${this.state.errorInfo.componentStack}`:``]})]}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsxs)(O,{onClick:this.handleReset,variant:`outline`,className:`flex-1`,children:[(0,q.jsx)(D,{name:`restart`,className:`h-4 w-4 mr-2`}),e.tryAgain]}),(0,q.jsx)(O,{onClick:this.handleCopy,variant:`outline`,className:`flex-1`,children:this.state.copied?e.copied:e.copy})]})]})]})}):this.props.children}},nt=e=>{let t=(0,k.c)(29),{children:n,fallback:r}=e,{t:i}=y(),a;t[0]===i?a=t[1]:(a=i(`errorBoundary.state.unknownError`),t[0]=i,t[1]=a);let o;t[2]===i?o=t[3]:(o=i(`errorBoundary.title`),t[2]=i,t[3]=o);let s;t[4]===i?s=t[5]:(s=i(`errorBoundary.description`),t[4]=i,t[5]=s);let c;t[6]===i?c=t[7]:(c=i(`errorBoundary.actions.errorDetails`),t[6]=i,t[7]=c);let l;t[8]===i?l=t[9]:(l=i(`errorBoundary.state.componentStackLabel`),t[8]=i,t[9]=l);let u;t[10]===i?u=t[11]:(u=i(`errorBoundary.actions.tryAgain`),t[10]=i,t[11]=u);let d;t[12]===i?d=t[13]:(d=i(`errorBoundary.actions.copied`),t[12]=i,t[13]=d);let f;t[14]===i?f=t[15]:(f=i(`errorBoundary.actions.copy`),t[14]=i,t[15]=f);let p;t[16]!==a||t[17]!==o||t[18]!==s||t[19]!==c||t[20]!==l||t[21]!==u||t[22]!==d||t[23]!==f?(p={unknownError:a,title:o,description:s,detailsSummary:c,componentStackLabel:l,tryAgain:u,copied:d,copy:f},t[16]=a,t[17]=o,t[18]=s,t[19]=c,t[20]=l,t[21]=u,t[22]=d,t[23]=f,t[24]=p):p=t[24];let m=p,h;return t[25]!==n||t[26]!==r||t[27]!==m?(h=(0,q.jsx)(tt,{fallback:r,strings:m,children:n}),t[25]=n,t[26]=r,t[27]=m,t[28]=h):h=t[28],h},Q=e=>x(ee.getState().dictionary,e),rt=e=>typeof e!=`number`||!Number.isFinite(e)?null:Math.max(0,Math.min(100,Math.round(e))),it=e=>typeof e!=`number`||!Number.isFinite(e)?`-`:`${Math.round(e)}%`,at=(e,t)=>e??it(t),ot=(e,t,n=`auto`)=>{if(!e)return t??``;try{let r=new Date(e);if(!Number.isFinite(r.getTime()))return t??``;let i=new Date;return r.toDateString()===i.toDateString()?ce(r,n,{fallback:t??``}):se(r,n,{month:`short`,day:`numeric`,weekday:`short`,hour:`numeric`,minute:`2-digit`})}catch{return t??``}},st=e=>e===null?`safe`:e>=80?`critical`:e>=50?`warn`:`safe`,ct=e=>e===`5h`?Q(`quota.window.5h`):e===`7d`?Q(`quota.window.7d`):e===`7d-sonnet`?Q(`quota.window.7dSonnet`):e===`7d-opus`?Q(`quota.window.7dOpus`):e===`weekly`?Q(`quota.window.weekly`):e===`daily`?Q(`quota.window.daily`):e===`monthly`?Q(`quota.window.monthly`):e===`credits`?Q(`quota.window.credits`):e===`credits_balance`?Q(`quota.window.creditsBalance`):e===`billing_cycle`?Q(`quota.window.billingCycle`):e===`auto`?Q(`quota.window.auto`):e===`api`?Q(`quota.window.api`):e===`plan_limit`?Q(`quota.window.planLimit`):e===`on_demand`?Q(`quota.window.onDemand`):e===`session`?Q(`quota.window.session`):e===`premium`?Q(`quota.window.premium`):e===`chat`?Q(`quota.window.chat`):e===`completions`?Q(`quota.window.completions`):e===`premium_interactions`?Q(`quota.window.premiumInteractions`):e,lt=e=>{let t=e.toLowerCase().trim();if(t===`5h`)return 18e3;if(t===`7d`||t===`weekly`||t===`7d-sonnet`||t===`7d-opus`)return 604800;if(t===`monthly`)return 2592e3;if(t===`24h`||t===`daily`)return 86400;if(t===`1h`)return 3600;let n=t.match(/^(\d+)h$/);if(n)return parseInt(n[1],10)*3600;let r=t.match(/^(\d+)d$/);return r?parseInt(r[1],10)*86400:null},ut=(e,t,n,r)=>{let i=n;if(i===null&&r&&(i=lt(r)),e===null||t===null||i===null||i<=0)return null;let a=Math.max(0,(t-Date.now())/1e3),o=Math.max(0,Math.min(i,i-a)),s=Math.max(0,Math.min(1,o/i)),c=e/100,l=e>=100&&a>0,u;u=s>.01?Math.min(999,c/s*100):e;let d;d=l?`exhausted`:c<=s?`on-track`:u<=130?`slightly-fast`:`too-fast`;let f=i>=432e3,p=f?86400:3600,m=f?`d`:`h`,h=i/p,g=e/Math.max(o/p,h*.01),_=Number.isFinite(g)?`${Math.min(999.9,Math.max(0,g)).toFixed(1)}%/${m}`:`-`,v=u>100?`+${Math.round(u)}%`:`${Math.round(u)}%`,y=null,b=i/86400;return b>=7&&(y=100/b),{elapsedRatio:s,usageRatio:c,predictedFinalPercent:u,remainingSeconds:a,isExhausted:l,elapsedSeconds:o,totalSeconds:i,status:d,paceRateText:_,predictText:v,dailyAllocationPercent:y}},dt=e=>{switch(e){case`exhausted`:case`too-fast`:return`var(--status-error)`;case`slightly-fast`:return`var(--status-warning)`;case`on-track`:return`var(--status-success)`}},ft=e=>{let t=Math.floor(Math.max(0,Math.floor(e))/60),n=Math.floor(t/60),r=Math.floor(n/24),i=n%24,a=t%60;return r>0?`${r}d ${i}h`:n>0?`${n}h`:t===0?`<1m`:`${a}m`},pt=e=>Math.min(100,Math.max(0,e*100)),mt=[`standalone`,`minimal-ui`,`fullscreen`,`window-controls-overlay`],ht=`openchamber.pwaRecentSessions`,gt=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(display-mode: ${e})`).matches,_t=()=>typeof window>`u`?`browser`:typeof document<`u`&&document.referrer.startsWith(`android-app://`)?`twa`:window.navigator.standalone?`standalone`:mt.find(e=>gt(e))??`browser`,vt=864e5,yt=5,bt=864e5,$=e=>e.time?.updated??e.time?.created??0,xt=({sessions:e,currentSessionId:t,cutoffDays:n,keepRecent:r=yt,now:i=Date.now()})=>{if(!Array.isArray(e)||n<=0)return[];let a=i-n*vt,o=[...e].sort((e,t)=>$(t)-$(e)),s=new Set(o.slice(0,r).map(e=>e.id));return o.filter(e=>{if(!e?.id||s.has(e.id)||e.id===t||e.share)return!1;let n=$(e);return n?n<a:!1}).map(e=>e.id)},St=e=>{let t=typeof e==`object`?e:void 0,r=t?.autoRun!==!1,i=typeof e==`boolean`?e:t?.enabled??!0,a=w(e=>e.currentSessionId),o=w(e=>e.isLoading),s=T(e=>e.activeSessions),c=T(e=>e.hasLoadedFullCatalog),l=n(e=>e.autoDeleteEnabled),u=n(e=>e.autoDeleteAfterDays),d=n(e=>e.sessionRetentionAction),f=n(e=>e.autoDeleteLastRunAt),p=n(e=>e.setAutoDeleteLastRunAt),[h,g]=K.useState(!1),_=K.useRef(!1);K.useEffect(()=>{if(!i||!r||!l||u<=0)return;let e=window.setTimeout(()=>{C(S())},8e3);return()=>window.clearTimeout(e)},[u,l,r,i]);let v=K.useMemo(()=>u<=0?[]:xt({sessions:s,currentSessionId:a,cutoffDays:u}),[u,a,s]),y=K.useCallback(async({force:e=!1}={})=>{if(_.current)return{completedIds:[],failedIds:[],action:d,skippedReason:`running`};if((!l||u<=0)&&!e)return{completedIds:[],failedIds:[],action:d,skippedReason:`disabled`};if(o)return{completedIds:[],failedIds:[],action:d,skippedReason:`loading`};let t=Date.now();if(!e&&f&&t-f<bt)return{completedIds:[],failedIds:[],action:d,skippedReason:`cooldown`};let{activeSessions:n}=await C(S());if(n.length===0)return{completedIds:[],failedIds:[],action:d,skippedReason:`no-candidates`};let r=xt({sessions:n,currentSessionId:a,cutoffDays:u,now:t});if(r.length===0)return p(t),{completedIds:[],failedIds:[],action:d,skippedReason:`no-candidates`};_.current=!0,g(!0);try{let e=new Map(n.map(e=>[e.id,e])),t=[],i=[];for(let n of r){let r=e.get(n),a=r?ne(r):null;if(!a){i.push(n);continue}try{d===`archive`?await m.updateSession(n,{time:{archived:Date.now()}},a):await m.deleteSession(n,a),t.push(n)}catch{i.push(n)}}return d===`archive`?T.getState().archiveSessions(t):T.getState().removeSessions(t),{completedIds:t,failedIds:i,action:d}}finally{_.current=!1,g(!1),p(Date.now())}},[u,l,f,a,o,d,p]);return K.useEffect(()=>{i&&r&&(!l||u<=0||o||!c||s.length===0||f&&Date.now()-f<bt||y())},[u,l,f,r,i,c,s.length,o,y]),{candidates:v,isRunning:h,runCleanup:y,keepRecentCount:yt,action:d}};export{De as A,Be as B,G as C,$e as D,et as E,Ae as F,pe as H,Oe as I,ze as L,Ce as M,we as N,Se as O,ke as P,Le as R,Qe as S,Ye as T,me as U,fe as V,X as _,ut as a,H as b,at as c,dt as d,st as f,Y as g,Z as h,pt as i,Te as j,Ee as k,ft as l,J as m,ht as n,rt as o,nt as p,_t as r,ot as s,St as t,ct as u,Xe as v,qe as w,Ze as x,Je as y,Re as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t,r as n}from"./vendor-zustand-B4dlGEM2.js";var r=`openchamber-relay-v1`,i=65526,a={HttpRequest:1,HttpBody:2,HttpResponse:3,StreamEnd:4,StreamAbort:5,WsOpen:6,WsOpened:7,WsText:8,WsBinary:9,WsClose:10,Ping:11,Pong:12},o=new Set(Object.values(a)),s=e=>o.has(e),c={ControlReplaced:4001,DuplicateClient:4002,StuckControlReset:4003,HostUnavailable:4008,AuthFailed:4010,LimitExceeded:4029,HostWentAway:1012,RekeyMismatch:1008,ChannelFailure:1011},l=globalThis.crypto.subtle,u={name:`ECDH`,namedCurve:`P-256`},d=16,f=32,p=16,m=4,h=8,g=class extends Error{constructor(e){super(e),this.name=`RelayCryptoError`}},ee=()=>l.generateKey(u,!0,[`deriveBits`]),_=async e=>{let t=await l.exportKey(`jwk`,e);return{kty:t.kty,crv:t.crv,x:t.x,y:t.y}},v=async e=>{if(e.kty!==`EC`||e.crv!==`P-256`||typeof e.x!=`string`||typeof e.y!=`string`)throw new g(`invalid ECDH public key JWK`);try{return await l.importKey(`jwk`,{kty:e.kty,crv:e.crv,x:e.x,y:e.y,ext:!0},u,!0,[])}catch{throw new g(`invalid ECDH public key JWK`)}},y=()=>{let e=new Uint8Array(d);return globalThis.crypto.getRandomValues(e),e},b=async(e,t,n)=>{if(n.length!==d)throw new g(`invalid handshake nonce length`);let i=await l.deriveBits({name:`ECDH`,public:t},e,256),a=await l.importKey(`raw`,i,`HKDF`,!1,[`deriveBits`]),o=new Uint8Array(await l.deriveBits({name:`HKDF`,hash:`SHA-256`,salt:n,info:new TextEncoder().encode(r)},a,512)),s=(e,t)=>l.importKey(`raw`,e,{name:`AES-GCM`},!1,t);return{clientToHost:await s(o.slice(0,f),[`encrypt`,`decrypt`]),hostToClient:await s(o.slice(f),[`encrypt`,`decrypt`])}},x=(e,t,n)=>{for(let r=7;r>=0;--r)e[t+r]=Number(n&255n),n>>=8n},S=(e,t)=>{let n=0n;for(let r=0;r<h;r+=1)n=n<<8n|BigInt(e[t+r]);return n},te=e=>{let t=new Uint8Array(m);globalThis.crypto.getRandomValues(t);let n=0n;return{async encrypt(r){if(r.length>65536)throw new g(`plaintext frame exceeds maximum size`);n+=1n;let i=new Uint8Array(12);i.set(t,0),x(i,m,n);let a=new Uint8Array(await l.encrypt({name:`AES-GCM`,iv:i},e,r)),o=new Uint8Array(13+a.length);return o[0]=1,o.set(i,1),o.set(a,13),o}}},ne=e=>{let t=0n;return{async decrypt(n){if(n.length<13+p)throw new g(`encrypted frame too short`);if(n[0]!==1)throw new g(`unsupported encrypted frame version`);let r=n.slice(1,13),i=S(r,m);if(i<=t)throw new g(`frame counter regression`);let a;try{a=await l.decrypt({name:`AES-GCM`,iv:r},e,n.slice(13))}catch{throw new g(`frame decryption failed`)}return t=i,new Uint8Array(a)}}},C=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`,re=e=>{let t=``;for(let n=0;n<e.length;n+=3){let r=e[n],i=n+1<e.length?e[n+1]:void 0,a=n+2<e.length?e[n+2]:void 0;t+=C[r>>2],t+=C[(r&3)<<4|(i??0)>>4],i!==void 0&&(t+=C[(i&15)<<2|(a??0)>>6]),a!==void 0&&(t+=C[a&63])}return t},w=e=>{let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let n=t;if(n.v!==1)return null;let r=n.batch===!0;return n.t===`ready`?{t:`ready`,v:1,batch:r}:n.t===`hello`&&typeof n.nonce==`string`&&typeof n.clientPubJwk==`object`&&n.clientPubJwk!==null?{t:`hello`,v:1,clientPubJwk:n.clientPubJwk,nonce:n.nonce,batch:r}:null},T=e=>({type:`fail`,closeCode:c.ChannelFailure,reason:e}),ie=async(e,t={})=>{let n=t.batch!==!1,r=await v(e),i=await ee(),a=y(),o={t:`hello`,v:1,clientPubJwk:await _(i.publicKey),nonce:re(a),...n?{batch:!0}:{}},s=!1;return{helloText:JSON.stringify(o),get established(){return s},async handleText(e){if(s)return w(e)?.t===`ready`?{type:`ignore`}:T(`plaintext frame on established channel`);let t=w(e);if(t?.t!==`ready`)return{type:`ignore`};let o=await b(i.privateKey,r,a);return s=!0,{type:`established`,batch:n&&t.batch===!0,channel:{encryptor:te(o.clientToHost),decryptor:ne(o.hostToClient)}}}}},E=4294967295,D=class extends Error{constructor(e){super(e),this.name=`TunnelCodecError`}},O=(e,t,n,r=!1)=>{if(!Number.isInteger(t)||t<0||t>E)throw new D(`invalid stream id`);if(n.length>65526)throw new D(`tunnel payload exceeds maximum size`);let i=new Uint8Array(5+n.length);return i[0]=r?e|128:e,i[1]=t>>>24&255,i[2]=t>>>16&255,i[3]=t>>>8&255,i[4]=t&255,i.set(n,5),i},ae=e=>{if(e.length<5)throw new D(`tunnel frame too short`);let t=e[0],n=!!(t&128),r=t&-129;if(!s(r))throw new D(`unknown tunnel frame type ${r}`);return{frameType:r,streamId:(e[1]<<24|e[2]<<16|e[3]<<8|e[4])>>>0,payload:e.slice(5),hasMoreFragments:n}},oe=new TextEncoder,se=new TextDecoder,k=e=>oe.encode(JSON.stringify(e)),A=(e,t)=>{let n;try{n=JSON.parse(se.decode(e))}catch{throw new D(`malformed JSON tunnel payload`)}if(!t(n))throw new D(`unexpected JSON tunnel payload shape`);return n},j=(e,t=i)=>{if(t<=0||t>65526)throw new D(`invalid chunk size`);if(e.length===0)return[new Uint8Array];let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n},ce=(e,t,n)=>{let r=j(n);return r.map((n,i)=>O(e,t,n,i<r.length-1))},le=(e=16777216)=>{let t=new Map;return{push(n){let r=`${n.streamId}:${n.frameType}`,i=t.get(r);if(!n.hasMoreFragments&&!i)return n.payload;let a=i?.chunks??[],o=(i?.totalBytes??0)+n.payload.length;if(o>e)throw t.delete(r),new D(`fragmented message exceeds maximum size`);if(a.push(n.payload),n.hasMoreFragments)return t.set(r,{chunks:a,totalBytes:o}),null;t.delete(r);let s=new Uint8Array(o),c=0;for(let e of a)s.set(e,c),c+=e.length;return s},dropStream(e){for(let n of t.keys())n.startsWith(`${e}:`)&&t.delete(n)}}},M=e=>{if(e.length===0)throw new D(`cannot encode an empty frame batch`);if(e.length===1){let t=e[0],n=new Uint8Array(1+t.length);if(n[0]=0,n.set(t,1),n.length>65536)throw new D(`frame batch exceeds maximum plaintext size`);return n}let t=1;for(let n of e)t+=4+n.length;if(t>65536)throw new D(`frame batch exceeds maximum plaintext size`);let n=new Uint8Array(t);n[0]=1;let r=1;for(let t of e)n[r]=t.length>>>24&255,n[r+1]=t.length>>>16&255,n[r+2]=t.length>>>8&255,n[r+3]=t.length&255,r+=4,n.set(t,r),r+=t.length;return n},ue=e=>{if(e.length<1)throw new D(`empty batch plaintext`);let t=e[0];if(t===0)return[e.slice(1)];if(t!==1)throw new D(`unknown batch container tag ${t}`);let n=[],r=1;for(;r<e.length;){if(r+4>e.length)throw new D(`truncated batch frame length`);let t=(e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3])>>>0;if(r+=4,r+t>e.length)throw new D(`truncated batch frame body`);n.push(e.slice(r,r+t)),r+=t}if(n.length===0)throw new D(`empty frame batch`);return n},N=new Set([a.HttpBody,a.WsText,a.WsBinary]),de=e=>{let t=e.windowMs??150,n=e.maxBatchBytes??24576,r=e.maxBatchFrames??32,i=e.now??(()=>Date.now()),a=e.setTimer??((e,t)=>setTimeout(e,t)),o=e.clearTimer??(e=>clearTimeout(e)),s=[],c=0,l=null,u=0,d=!1,f=()=>{l!==null&&(o(l),l=null)},p=()=>{if(f(),s.length===0)return;let t=s;s=[],c=0,u=i(),e.sendBatch(M(t))};return{enqueue:e=>{if(d)return;let o=e[0]&-129;if(!N.has(o)){s.push(e),p();return}let f=i();if(s.length===0&&f-u>=t){s.push(e),p();return}let m=4+e.length;if(s.length>0&&1+c+m>65536&&p(),s.push(e),c+=m,c>=n||s.length>=r){p();return}l===null&&(l=a(p,t))},flush:p,dispose(){d=!0,f(),s=[],c=0}}},fe=()=>{let e=1;return{next(){if(e>E)throw new D(`stream id space exhausted`);let t=e;return e+=2,t}}},P=e=>typeof e==`object`&&!!e&&!Array.isArray(e),pe=e=>P(e)&&Object.values(e).every(e=>typeof e==`string`),me=e=>P(e)&&typeof e.status==`number`&&pe(e.headers),he=e=>P(e)&&typeof e.reason==`string`,ge=e=>P(e)&&typeof e.code==`number`&&typeof e.reason==`string`,_e=/^[a-z][a-z\d+.-]*:\/\//i,ve=`http://tunnel.invalid`,ye=e=>{try{let t=_e.test(e)?new URL(e):new URL(e,ve);return`${t.pathname}${t.search}`}catch{return e}},be=e=>({async*[Symbol.asyncIterator](){yield e}}),xe=e=>({async*[Symbol.asyncIterator](){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;n&&(yield n)}}finally{t.releaseLock()}}}),Se=e=>{let t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),t},Ce=async e=>{if(e==null)return{body:null};if(e instanceof ReadableStream)return{body:xe(e)};if(typeof e==`string`)return{body:be(new TextEncoder().encode(e))};if(e instanceof ArrayBuffer)return{body:be(new Uint8Array(e.slice(0)))};if(ArrayBuffer.isView(e))return{body:be(Se(e))};let t=new Response(e),n=t.headers.get(`content-type`)??void 0;return{body:be(new Uint8Array(await t.arrayBuffer())),contentType:n}},we=async(e,t)=>{let n,r=new Headers,i=`GET`,a=null,o;e instanceof Request?(n=e.url,i=e.method,e.headers.forEach((e,t)=>r.set(t,e)),o=e.signal,a=e.body):n=e.toString(),t&&(t.method&&(i=t.method),t.headers&&new Headers(t.headers).forEach((e,t)=>r.set(t,e)),t.body!==void 0&&(a=t.body),t.signal&&(o=t.signal));let s=_e.test(n)?new URL(n):new URL(n,ve),{body:c,contentType:l}=await Ce(a);l&&!r.has(`content-type`)&&r.set(`content-type`,l);let u={};return r.forEach((e,t)=>{u[t]=e}),{method:i.toUpperCase(),path:s.pathname,query:s.search.startsWith(`?`)?s.search.slice(1):s.search,headers:u,body:c,signal:o}},Te=new Uint8Array,Ee=new TextEncoder,De=new TextDecoder,F=e=>e instanceof Error?e:Error(String(e)),Oe=()=>new DOMException(`The operation was aborted.`,`AbortError`),ke=e=>{e.binaryType=`arraybuffer`;let t={get readyState(){return e.readyState},send(t){e.send(t)},close(t,n){e.close(t,n)},onopen:null,onmessage:null,onclose:null,onerror:null};return e.onopen=()=>t.onopen?.(),e.onmessage=e=>t.onmessage?.({data:e.data}),e.onclose=e=>t.onclose?.({code:e.code,reason:e.reason}),e.onerror=()=>t.onerror?.(),t},Ae=e=>{let t={get readyState(){return e.readyState},get binaryType(){return e.binaryType},set binaryType(t){t&&(e.binaryType=t)},onopen:null,onmessage:null,onerror:null,onclose:null,send(t){e.send(t)},close(t,n){e.close(t,n)}};return e.onopen=()=>t.onopen?.(),e.onmessage=e=>{let n=e.data;(typeof n==`string`||n instanceof ArrayBuffer)&&t.onmessage?.({data:n})},e.onerror=()=>t.onerror?.(),e.onclose=e=>t.onclose?.({code:e.code,reason:e.reason}),t},je=0,Me=1,Ne=2,Pe=3,Fe=new Set([c.AuthFailed,c.DuplicateClient,c.LimitExceeded]),Ie={[c.AuthFailed]:`relay authentication failed`,[c.DuplicateClient]:`relay connection replaced by another client`,[c.LimitExceeded]:`relay connection limit reached`},Le=()=>{let e=typeof navigator<`u`&&navigator.onLine===!1,t=typeof document<`u`&&document.visibilityState===`hidden`;return e||t},Re=e=>{let t=e.helloRetryMs??1e3,n=e.helloTimeoutMs??3e4,r=e.pingIntervalMs??3e4,i=e.pingTimeoutMs??15e3,o=e.batchWindowMs??150,s=e.batch!==!1,c=e.reconnectBaseDelayMs??1e3,l=e.reconnectMaxDelayMs??3e4,u=e.hiddenOrOfflineMaxDelayMs??6e4,d=e.createWireSocket??(e=>ke(new WebSocket(e))),f=!1,p={state:`idle`},m=new Set,h=null,g=null,ee=null,_=0,v=0,y=null,b=[],x=!1,S=e=>{if(p.state!==e.state||p.lastError!==e.lastError){p=e;for(let e of m)try{e(p)}catch{}}},te=e=>{let t=b;b=[];for(let n of t)n.reject(e)},ne=e=>{let t=b;b=[];for(let n of t)n.resolve(e)},C=(e,t)=>{e.dead=!0;let n=Array.from(e.streams.values());e.streams.clear();for(let e of n)try{e.fail(t)}catch{}},re=()=>{y!==null&&(clearTimeout(y),y=null)},w=()=>{f||y===null||Le()||(re(),D(),M())},T=()=>{typeof document<`u`&&document.visibilityState===`visible`&&w()},E=()=>{x||typeof window>`u`||(x=!0,window.addEventListener(`online`,w),typeof document<`u`&&document.addEventListener(`visibilitychange`,T))},D=()=>{!x||typeof window>`u`||(x=!1,window.removeEventListener(`online`,w),typeof document<`u`&&document.removeEventListener(`visibilitychange`,T))},oe=()=>{if(f||y!==null)return;let e=Math.max(0,v-1),t=c*2**Math.min(e,10),n=Le()?u:l,r=Math.min(n,t);E(),y=setTimeout(()=>{y=null,D(),M()},r)},se=()=>{let t=new URL(e.relayUrl);return t.searchParams.set(`v`,`1`),t.searchParams.set(`role`,`client`),t.searchParams.set(`serverId`,e.serverId),e.grant&&t.searchParams.set(`grant`,e.grant),t.toString()},M=async()=>{if(f)return;re(),_+=1;let c=_;S({state:v>0?`reconnecting`:`connecting`,lastError:p.lastError});let l;try{l=await ie(e.hostEncPubJwk,{batch:s})}catch(e){if(c!==_||f)return;me(c,F(e),!0);return}if(c!==_||f)return;let u;try{u=d(se())}catch(e){me(c,F(e));return}g=u;let m=!1,y=null,b=null,x=null,w=null,T=Promise.resolve(),E=null,D=null,k=!1,A=null,j=Date.now(),ce=()=>{y!==null&&(clearInterval(y),y=null),b!==null&&(clearTimeout(b),b=null),x!==null&&(clearInterval(x),x=null),w!==null&&(clearTimeout(w),w=null),A!==null&&(A.dispose(),A=null)};ee=ce;function M(e,t=!1,n=!1){if(!(m||c!==_)){m=!0,ce(),E&&(h=null,C(E,Error(`relay tunnel reset: ${e.message}`))),te(e);try{u.close()}catch{}if(g===u&&(g=null),!f){if(v+=1,n){S({state:`error`,lastError:e.message});return}S({state:t?`error`:`reconnecting`,lastError:e.message}),oe()}}}let N=()=>{try{u.send(l.helloText)}catch{}},P=(e,t)=>{D=e,k=t,y!==null&&(clearInterval(y),y=null),b!==null&&(clearTimeout(b),b=null);let n=new Map,s=fe(),c=le(),l=Promise.resolve(),d=t=>{l=l.then(async()=>{if(p.dead)return;let n=await e.encryptor.encrypt(t);u.send(n)}).catch(()=>{})},f=t?de({windowMs:o,sendBatch:d}):null;A=f;let p={streams:n,assembler:c,nextStreamId:()=>s.next(),dead:!1,send(e){if(p.dead)return;let t=e[0]&-129;t!==a.Ping&&t!==a.Pong&&(j=Date.now()),f?f.enqueue(e):d(e)}};E=p,h=p,v=0,j=Date.now(),S({state:`connected`}),ne(p),x=setInterval(()=>{Date.now()-j<r||(p.send(O(a.Ping,0,Te)),w===null&&(w=setTimeout(()=>{w=null,M(Error(`relay keepalive timeout`))},i)))},r)},pe=(e,t)=>{let n;try{n=ae(t)}catch(e){M(F(e));return}if(w!==null&&(clearTimeout(w),w=null),n.frameType===a.Ping){e.send(O(a.Pong,n.streamId,Te));return}if(n.frameType===a.Pong)return;j=Date.now();let r=n.payload;if(n.frameType===a.WsText||n.frameType===a.WsBinary){let t;try{t=e.assembler.push(n)}catch(e){M(F(e));return}if(t===null)return;r=t}else if(n.hasMoreFragments){M(Error(`unexpected fragmented tunnel frame`));return}let i=e.streams.get(n.streamId);i&&i.handleFrame(n.frameType,r)};u.onopen=()=>{m||c!==_||(N(),y=setInterval(N,t))},u.onmessage=e=>{if(m||c!==_)return;let t=e.data;if(typeof t==`string`){T=T.then(async()=>{if(m||c!==_)return;let e=await l.handleText(t);if(e.type===`established`){if(D)return;P(e.channel,e.batch)}else e.type===`fail`&&M(Error(`relay handshake failed: ${e.reason}`))}).catch(e=>{M(F(e))});return}let n=t instanceof ArrayBuffer?new Uint8Array(t):t instanceof Uint8Array?t:null;n&&(T=T.then(async()=>{if(m||c!==_)return;let e=E,t=D;if(!e||!t){M(Error(`encrypted frame before handshake completed`));return}let r;try{r=await t.decryptor.decrypt(n)}catch(e){M(F(e));return}if(k){let t;try{t=ue(r)}catch(e){M(F(e));return}for(let n of t){if(m||c!==_||e.dead)return;pe(e,n)}return}pe(e,r)}).catch(e=>{M(F(e))}))},u.onclose=e=>{let t=Fe.has(e.code);M(Error(Ie[e.code]??`relay socket closed (code ${e.code})`),t,t)},u.onerror=()=>{},b=setTimeout(()=>{b=null,M(Error(`relay handshake timeout`),!0)},n);function me(e,t,n=!1){e!==_||f||(te(t),v+=1,S({state:n?`error`:`reconnecting`,lastError:t.message}),oe())}},N=e=>f?Promise.reject(Error(`relay tunnel closed`)):e?.aborted?Promise.reject(Oe()):h&&!h.dead?Promise.resolve(h):new Promise((t,n)=>{let r=null,i={resolve(n){r&&e&&e.removeEventListener(`abort`,r),t(n)},reject(t){r&&e&&e.removeEventListener(`abort`,r),n(t)}};e&&(r=()=>{b=b.filter(e=>e!==i),n(Oe())},e.addEventListener(`abort`,r,{once:!0})),b.push(i)}),P=async(e,t)=>{let n=await we(e,t),r=n.signal;if(r?.aborted)throw Oe();let i=await N(r),o=i.nextStreamId();return await new Promise((e,t)=>{let s=!1,c=!1,l=null,u=null,d=()=>{i.streams.delete(o),i.assembler.dropStream(o),u&&r&&r.removeEventListener(`abort`,u)},f=e=>{if(!c){if(c=!0,d(),!s){t(e);return}try{l?.error(e)}catch{}}},p=e=>{i.dead||i.send(O(a.StreamAbort,o,k({reason:e})))};u=()=>{p(`aborted`),f(Oe())},i.streams.set(o,{handleFrame(t,n){if(t===a.HttpResponse){if(s||c)return;let t;try{t=A(n,me)}catch(e){p(`malformed response head`),f(F(e));return}let r=t.status===204||t.status===205||t.status===304,i=null;r||(i=new ReadableStream({start(e){l=e},cancel(){c||(c=!0,d(),p(`response body cancelled`))}})),s=!0,e(new Response(i,{status:t.status,headers:t.headers})),r&&(c=!0,d());return}if(t===a.HttpBody){if(!s||c)return;try{l?.enqueue(n)}catch{}return}if(t===a.StreamEnd){if(c)return;if(!s){f(Error(`tunnel stream ended before response head`));return}c=!0,d();try{l?.close()}catch{}return}if(t===a.StreamAbort){let e=`stream aborted by host`;try{e=A(n,he).reason}catch{}f(Error(e))}},fail(e){f(e)}}),r&&r.addEventListener(`abort`,u,{once:!0});let m={method:n.method,path:n.path,query:n.query,headers:n.headers};i.send(O(a.HttpRequest,o,k(m))),(async()=>{try{if(n.body)for await(let e of n.body){if(c||i.dead)return;for(let t of j(e))i.send(O(a.HttpBody,o,t))}!c&&!i.dead&&i.send(O(a.StreamEnd,o,Te))}catch(e){p(`request body failed`),f(F(e))}})()})},pe=e=>{let t=e.indexOf(`?`);return t===-1?{path:e,query:``}:{path:e.slice(0,t),query:e.slice(t+1)}};return M(),{fetch:P,openWebSocket:(e,t,n)=>{let r=je,i=null,o=0,s=!1,c={get readyState(){return r},onopen:null,onmessage:null,onerror:null,onclose:null,send(e){if(r!==Me||!i||i.dead)throw Error(`relay tunnel socket is not open`);if(typeof e==`string`){for(let t of ce(a.WsText,o,Ee.encode(e)))i.send(t);return}let t=e instanceof ArrayBuffer?new Uint8Array(e.slice(0)):(()=>{let t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),t})();for(let e of ce(a.WsBinary,o,t))i.send(e)},close(e=1e3,t=``){r!==Pe&&r!==Ne&&(r===Me&&i&&!i.dead&&(r=Ne,i.send(O(a.WsClose,o,k({code:e,reason:t})))),l(e,t))}},l=(e,t,n=!1)=>{if(!s){if(s=!0,i&&(i.streams.delete(o),i.assembler.dropStream(o)),r=Pe,n)try{c.onerror?.()}catch{}try{c.onclose?.({code:e,reason:t})}catch{}}};return(async()=>{let u;try{u=await N()}catch(e){l(1006,F(e).message,!0);return}if(s)return;i=u,o=u.nextStreamId(),u.streams.set(o,{handleFrame(e,t){if(e===a.WsOpened){if(r===je){r=Me;try{c.onopen?.()}catch{}}return}if(e===a.WsText){try{c.onmessage?.({data:De.decode(t)})}catch{}return}if(e===a.WsBinary){let e=new ArrayBuffer(t.byteLength);new Uint8Array(e).set(t);try{c.onmessage?.({data:e})}catch{}return}if(e===a.WsClose){let e=1e3,n=``;try{let r=A(t,ge);e=r.code,n=r.reason}catch{}l(e,n);return}if(e===a.StreamAbort){let e=`stream aborted`;try{e=A(t,he).reason}catch{}l(1006,e,!0)}},fail(e){l(1012,e.message,!0)}});let{path:d,query:f}=pe(e),p={path:d,query:f,...t&&t.length>0?{protocols:t}:{},...n&&Object.keys(n).length>0?{headers:n}:{}};u.send(O(a.WsOpen,o,k(p)))})(),c},getStatus:()=>p,subscribeStatus(e){return m.add(e),()=>{m.delete(e)}},close:()=>{if(f)return;f=!0,_+=1,re(),D(),ee?.(),ee=null;let e=h;h=null;let t=Error(`relay tunnel closed`);e&&C(e,t),te(t);try{g?.close()}catch{}g=null,S({state:`idle`})}}},I=null,L=null,ze=(e,t)=>e.relayUrl===t.relayUrl&&e.serverId===t.serverId&&e.grant===t.grant&&JSON.stringify(e.hostEncPubJwk)===JSON.stringify(t.hostEncPubJwk),Be=()=>I,Ve=()=>L,He=()=>I!==null,Ue=()=>I?.getStatus().state===`connected`,We=e=>I&&L&&ze(L,e)?I:(I?.close(),L=e,I=Re(e),I),Ge=(e,t)=>{I!==t&&(I?.close(),L=e,I=t)},Ke=()=>{I?.close(),I=null,L=null},qe=()=>null,Je=``,Ye={},R=``,z=0,B=null,V=``,H=0,U=null,W=0,Xe=1e4,Ze=()=>W,Qe=e=>e.toLowerCase()===`authorization`,$e=e=>{let t={};for(let[n,r]of Object.entries(e||{})){let e=n.trim(),i=r.trim();e&&i&&!Qe(e)&&(t[e]=i)}return t},et=(e,t)=>{let n=Object.entries(e);return n.length===Object.keys(t).length&&n.every(([e,n])=>t[e]===n)},tt=e=>typeof e==`string`?e.trim():``,nt=()=>{if(typeof window>`u`)return``;let e=window.__OPENCHAMBER_CLIENT_TOKEN__;return tt(e)},rt=()=>{if(typeof window>`u`)return``;let e=window.__OPENCHAMBER_API_BASE_URL__;return typeof e==`string`?e.trim():``},it=(e,t)=>{let n=typeof e==`string`&&e.trim()?e.trim():rt();if(!n)return t;try{return new URL(t,`${n.replace(/\/+$/,``)}/`).toString()}catch{return t}},G=()=>{R=``,z=0,V=``,H=0},at=()=>{W+=1,B=null,G(),Et()},ot=e=>{let t=tt(e),n=t===lt();Je=t,qe=()=>t?{type:`bearer`,token:t}:null,!n&&at()},st=e=>{let t=$e(e);et(Ye,t)||(Ye=t,at())},ct=()=>{if(Object.keys(Ye).length>0)return Ye;if(typeof window>`u`)return{};let e=window.__OPENCHAMBER_RUNTIME_HEADERS__;return e&&typeof e==`object`?$e(e):{}},lt=()=>Je||nt(),ut=(e,t)=>{let n=tt(e);if(!n||typeof t!=`number`||!Number.isFinite(t)){G();return}let r=R;R=n,z=t,r&&r!==n&&wt()},dt=()=>!R||z<=Date.now()+Xe?(G(),``):R,ft=()=>!V||H<=Date.now()+Xe?(V=``,H=0,``):V,pt=()=>{let e=dt();return!e&&(lt()||typeof window<`u`)&&vt().catch(()=>{}),e},mt=e=>{let t=ft();return!t&&e&&typeof window<`u`&&yt(e).catch(()=>{}),t},ht=async()=>{let e=await qe(),t=e?.type===`bearer`?tt(e.token):lt();return t?{type:`bearer`,token:t}:null},gt=e=>{if(B)return B;let t=W,n=(async()=>{let n=await ht(),r=new Headers;for(let[e,t]of Object.entries(ct()))r.set(e,t);n?.type===`bearer`&&r.set(`Authorization`,`Bearer ${n.token}`);let i=Be(),a=i?await i.fetch(`/auth/url-token`,{method:`POST`,headers:r}):await fetch(it(e,`/auth/url-token`),{method:`POST`,headers:r,credentials:`include`});if(!a.ok)throw t===W&&G(),Error(`Failed to mint runtime URL auth token (${a.status})`);let o=await a.json().catch(()=>null),s=typeof o?.token==`string`?o.token.trim():``,c=typeof o?.expiresAt==`number`?o.expiresAt:0;if(t!==W)throw Error(`Runtime URL auth token response is stale`);if(ut(s,c),!R)throw Error(`Runtime URL auth token response was invalid`);return R})().finally(()=>{B===n&&(B=null)});return B=n,B},_t=e=>{if(U)return U;let t=(async()=>{let t=await fetch(it(e,`/auth/url-token`),{method:`POST`,credentials:`include`});if(!t.ok)throw V=``,H=0,Error(`Failed to mint local runtime URL auth token (${t.status})`);let n=await t.json().catch(()=>null),r=typeof n?.token==`string`?n.token.trim():``,i=typeof n?.expiresAt==`number`?n.expiresAt:0;if(!r||!Number.isFinite(i))throw Error(`Local runtime URL auth token response was invalid`);return V=r,H=i,r})().finally(()=>{U===t&&(U=null)});return U=t,U},vt=async e=>dt()||gt(e),yt=async e=>ft()||_t(e),K=0,bt=null,xt=null,St=new Set,Ct=5e3,wt=()=>{for(let e of St)try{e()}catch{}},Tt=()=>{bt!==null&&(clearTimeout(bt),bt=null)},Et=()=>{if(Tt(),K<=0||typeof window>`u`)return;let e=z-Xe-Ct,t=z>0?Math.max(0,e-Date.now()):0;bt=setTimeout(()=>{bt=null,!(K<=0)&>(xt).catch(()=>{}).finally(()=>{Et()})},t)},Dt=e=>{typeof e==`string`&&e.trim()&&(xt=e.trim()),K+=1,Et();let t=!1;return()=>{t||(t=!0,K=Math.max(0,K-1),K===0&&Tt())}},Ot=e=>(St.add(e),()=>{St.delete(e)}),kt=async e=>{let t=new Headers(e);for(let[e,n]of Object.entries(ct()))t.has(e)||t.set(e,n);if(t.has(`Authorization`))return t;let n=await ht();return n?.type===`bearer`&&t.set(`Authorization`,`Bearer ${n.token}`),t},At=/^[a-z][a-z\d+.-]*:\/\//i,jt=e=>{let t=e.trim();return t?t.startsWith(`/`)?t:`/${t}`:`/`},Mt=e=>typeof e==`string`?e.trim().replace(/\/+$/,``):``,Nt=()=>{if(typeof window>`u`)return``;let e=window.__OPENCHAMBER_API_BASE_URL__;return Mt(e)},Pt=()=>{if(typeof window>`u`)return``;let e=window.__OPENCHAMBER_LOCAL_ORIGIN__;return Mt(e)},Ft=()=>Object.keys(ct()).length>0,It=e=>e.currentHref?.()||(typeof window<`u`?window.location.href||window.location.origin:``),Lt=(e,t)=>{if(!t)return;let n=t instanceof URLSearchParams?Array.from(t.entries()):Object.entries(t);for(let[t,r]of n)r!=null&&e.searchParams.set(t,String(r))},Rt=(e,t)=>{if(!t)return e;let n=new URLSearchParams;Lt({searchParams:n},t);let r=n.toString();return r?e.includes(`?`)?`${e}&${r}`:`${e}?${r}`:e},zt=(e,t,n)=>{if(At.test(t)){let e=new URL(t);return Lt(e,n),e.toString()}let r=jt(t);if(!e)return Rt(r,n);let i=new URL(r,`${e}/`);return Lt(i,n),i.toString()},Bt=e=>{let t=pt();if(!t)return e;let n=At.test(e)?new URL(e):new URL(e,`http://openchamber.local`);return n.searchParams.set(`oc_url_token`,t),At.test(e)?n.toString():`${n.pathname}${n.search}${n.hash}`},Vt=(e,t)=>{let n=At.test(e)?new URL(e):new URL(e,It(t));return n.protocol===`ws:`||n.protocol===`wss:`||(n.protocol=n.protocol===`https:`?`wss:`:`ws:`),n.toString()},Ht=(e,t,n)=>{if(!Ft())return null;let r=Pt();if(!r)return null;try{let i=new URL(`/api/openchamber/realtime-proxy/${e===`sse`?`sse`:`ws`}`,`${r}/`);i.searchParams.set(`url`,t);let a=mt(r);return a&&i.searchParams.set(`oc_url_token`,a),e===`ws`?(i.protocol=i.protocol===`https:`?`wss:`:`ws:`,Vt(i.toString(),n)):i.toString()}catch{return null}},Ut=(e={})=>{let t=Mt(e.apiBaseUrl),n=Mt(e.realtimeBaseUrl),r=()=>t||Nt(),i=()=>n||r(),a=(e,t)=>zt(r(),e,t),o=(e,t)=>zt(i(),e,t);return{api:a,authenticatedAsset:(e,t)=>Bt(a(e,t)),auth:a,health:e=>a(`/health`,e),rawFile:(e,t)=>a(`/api/fs/raw`,{path:e,download:t?.download===!0||void 0,allowOutsideWorkspace:t?.allowOutsideWorkspace===!0||void 0,outsideFileGrant:t?.outsideFileGrant}),sse:(t,n)=>{let r=Bt(o(t,n));return Ht(`sse`,r,e)||r},websocket:(t,n)=>{let r=Vt(Bt(o(t,n)),e);return Ht(`ws`,r,e)||r}}},Wt=Ut(),Gt=()=>Wt,Kt=e=>{Wt=e},qt=e=>(Wt=Ut(e),Wt),Jt=`x-openchamber-target-port`,Yt=`openchamber:runtime-endpoint-changed`,Xt=``,Zt=``,Qt=``,$t=``,en=0,tn=e=>Array.isArray(e)?`[${e.map(tn).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${tn(t)}`).join(`,`)}}`:JSON.stringify(e)??`undefined`,nn=e=>e?Object.entries(e).map(([e,t])=>[e.trim().toLowerCase(),t]).filter(([e])=>e.length>0).sort(([e],[t])=>e.localeCompare(t)):[],rn=e=>tn({apiBaseUrl:e.apiBaseUrl.replace(/\/+$/,``),clientToken:e.clientToken||null,runtimeKey:e.runtimeKey,requestHeaders:nn(e.requestHeaders),relay:e.relay??null}),an=(e,t,n)=>{try{e[t]=n}catch{}},q=e=>{try{let t=new URL(e);return t.hash=``,t.search=``,t.pathname=t.pathname.replace(/\/+$/,``)||`/`,`url:${t.toString().replace(/\/+$/,``)}`}catch{return`url:${e.trim().replace(/\/+$/,``)||`default`}`}},on=e=>{if(!e)return null;for(let[t,n]of Object.entries(e))if(t.trim().toLowerCase()===`x-openchamber-target-port`)return n.trim()||null;return null},sn=(e,t,n)=>{let r=on(n);return t?`relay:${tn({relayUrl:t.relayUrl,serverId:t.serverId,hostEncPubJwk:t.hostEncPubJwk,...r?{targetPort:r}:{}})}`:r?`direct:${q(e)}:target-port:${r}`:`direct:${q(e)}`},cn=e=>e.transportIdentityChanged??q(e.apiBaseUrl)!==q(e.previousApiBaseUrl),ln=e=>e.runtimeKey!==e.previousRuntimeKey,un=()=>{if(typeof window>`u`)return``;let e=window.__OPENCHAMBER_API_BASE_URL__;return typeof e==`string`?e.trim():``},dn=()=>{if(typeof window>`u`)return``;let e=window.__OPENCHAMBER_LOCAL_ORIGIN__;return typeof e==`string`?e.trim():``},fn=(e,t)=>{if(!e||!t)return!1;try{return new URL(e).origin===new URL(t).origin}catch{return!1}},pn=()=>Xt||un(),mn=()=>$t||sn(pn()),hn=()=>en,gn=()=>{if(Zt)return Zt;let e=pn();return fn(e,dn())?`local`:q(e)},_n=(e={})=>{if(Xt||Zt)return;let t=e.apiBaseUrl?.trim()||un();t&&(Xt=t,Zt=e.runtimeKey?.trim()||(fn(t,dn())?`local`:q(t)),$t=sn(t,null,null))},vn=e=>{let t=e.apiBaseUrl.trim(),n=pn(),r=gn(),i=q(t)===q(n),a=e.runtimeKey?.trim()||(i?r:q(t)),o=rn({...e,apiBaseUrl:t,runtimeKey:a});if(o===Qt)return;let s=mn(),c=sn(t,e.relay,e.requestHeaders),l=c!==s;if(Qt=o,$t=c,l&&(en+=1),Xt=t,Zt=a,typeof window<`u`){let n=window;an(n,`__OPENCHAMBER_API_BASE_URL__`,t),an(n,`__OPENCHAMBER_CLIENT_TOKEN__`,e.clientToken||void 0),an(n,`__OPENCHAMBER_RUNTIME_HEADERS__`,e.requestHeaders||void 0)}qt({apiBaseUrl:t,realtimeBaseUrl:t}),st(e.requestHeaders||null),ot(e.clientToken||null),e.relay?We(e.relay):Ke(),vt(t).catch(()=>{}),typeof window<`u`&&window.dispatchEvent(new CustomEvent(Yt,{detail:{apiBaseUrl:t,previousApiBaseUrl:n,runtimeKey:a,previousRuntimeKey:r,transportIdentityChanged:l}}))},yn=e=>{if(typeof window>`u`)return()=>{};let t=t=>{e(t.detail)};return window.addEventListener(Yt,t),()=>window.removeEventListener(Yt,t)},bn=null,xn=null,Sn=null,Cn=new Set,wn=!1,Tn=e=>{if(Cn.add(e),wn||typeof window>`u`)return;wn=!0;let t=()=>{for(let e of Cn)e()};try{window.addEventListener(`pagehide`,t,{capture:!0}),window.addEventListener(`beforeunload`,t,{capture:!0}),window.addEventListener(`visibilitychange`,()=>{typeof document<`u`&&document.visibilityState===`hidden`&&t()}),window.addEventListener(`freeze`,t)}catch{}},En=(e,t)=>{let n;try{n=e()}catch{return}let r=new Map,i=new Set,a,o=()=>{if(a=void 0,r.size===0&&i.size===0)return!0;let e=Array.from(r.entries()),o=Array.from(i);r.clear(),i.clear();let c=!0;for(let[i,a]of e)try{n.setItem(i,JSON.stringify(a,t?.replacer))}catch(e){console.error(`Failed to persist deferred storage value`,e),r.set(i,a),c=!1}for(let e of o)try{n.removeItem(e)}catch(t){console.error(`Failed to remove deferred storage value`,t),i.add(e),c=!1}return c||s(),c},s=()=>{a===void 0&&(a=setTimeout(o,0))};return Tn(o),{getItem:e=>{if(r.has(e))return r.get(e)??null;if(i.has(e))return null;let a=e=>e===null?null:JSON.parse(e,t?.reviver),o=n.getItem(e);return o instanceof Promise?o.then(a):a(o)},setItem:(e,t)=>{r.set(e,t),i.delete(e),s()},removeItem:e=>{r.delete(e),i.add(e),s()},flush:o}},Dn=e=>En(()=>Mn(),e),On=e=>{let t=new Map,n=new Set,r,i=()=>{if(r=void 0,t.size===0&&n.size===0)return;let i=Array.from(t.entries()),a=Array.from(n);t.clear(),n.clear();for(let[t,n]of i)try{e.setItem(t,n)}catch(e){console.error(`Failed to persist deferred storage value`,e)}for(let t of a)try{e.removeItem(t)}catch(e){console.error(`Failed to remove deferred storage value`,e)}},a=()=>{r===void 0&&(r=setTimeout(i,0))};return Tn(i),{getItem:r=>t.has(r)?t.get(r)??null:n.has(r)?null:e.getItem(r),setItem:(e,r)=>{t.set(e,r),n.delete(e),a()},removeItem:e=>{t.delete(e),n.add(e),a()},clear:()=>{t.clear(),n.clear(),r!==void 0&&(clearTimeout(r),r=void 0),e.clear()},key:t=>e.key(t),get length(){return e.length}}},kn=e=>{if(typeof window>`u`)return null;try{return window[e]??null}catch{return null}},An=()=>{let e=new Map;return{getItem:t=>e.get(t)??null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)},clear:()=>{e.clear()},key:t=>Array.from(e.keys())[t]??null,get length(){return e.size}}},jn=()=>{let e=kn(`localStorage`);if(!e)return An();let t=An(),n=!0,r=()=>{n=!1};return{getItem:i=>{if(n)try{let t=e.getItem(i);if(t!==null)return t}catch{r()}return t.getItem(i)},setItem:(i,a)=>{if(n)try{e.setItem(i,a),t.removeItem(i);return}catch{r();try{e.removeItem(i)}catch{}}t.setItem(i,a)},removeItem:n=>{try{e.removeItem(n)}catch{r()}t.removeItem(n)},clear:()=>{try{e.clear()}catch{r()}t.clear()},key:i=>{if(n)try{return e.key(i)}catch{r()}return t.key(i)},get length(){if(n)try{return e.length+t.length}catch{r()}return t.length}}},Mn=()=>(bn||=jn(),bn),Nn=()=>(Sn||=On(Mn()),Sn),Pn=()=>{let e=kn(`sessionStorage`);if(!e)return An();let t=An(),n=!0,r=()=>{n=!1};return{getItem:i=>{if(n)try{let t=e.getItem(i);if(t!==null)return t}catch{r()}return t.getItem(i)},setItem:(i,a)=>{if(n)try{e.setItem(i,a),t.removeItem(i);return}catch{r();try{e.removeItem(i)}catch{}}t.setItem(i,a)},removeItem:n=>{try{e.removeItem(n)}catch{r()}t.removeItem(n)},clear:()=>{try{e.clear()}catch{r()}t.clear()},key:i=>{if(n)try{return e.key(i)}catch{r()}return t.key(i)},get length(){if(n)try{return e.length+t.length}catch{r()}return t.length}}},Fn=()=>(xn||=Pn(),xn);function In(e,t){return t>=12?e:(e.chatRenderMode===`live`&&(e.chatRenderMode=`sorted`),e.activityRenderMode===`summary`&&(e.activityRenderMode=`collapsed`),e.showTurnChangedFiles===!1&&(e.showTurnChangedFiles=!0),e)}var Ln={markdown:`0.875rem`,code:`0.75rem`,uiHeader:`0.9375rem`,uiLabel:`0.8750rem`,meta:`0.875rem`,micro:`0.875rem`},Rn={markdown:`0.9375rem`,code:`0.8125rem`,uiHeader:`0.875rem`,uiLabel:`0.8125rem`,meta:`0.8125rem`,micro:`0.75rem`},zn={markdown:`0.9063rem`,code:`0.8750rem`,uiHeader:`0.9063rem`,uiLabel:`0.8438rem`,meta:`0.8438rem`,micro:`0.7813rem`};function Bn(e){return`--text-${e.replace(/([A-Z])/g,`-$1`).toLowerCase()}`}function Vn(e=document.documentElement){return e.classList.contains(`mobile-pointer`)&&!e.classList.contains(`desktop-runtime`)}function Hn(e,t){return t?.mobile?Rn[e]:Ln[e]}var Un={semanticMarkdown:{fontSize:`var(--text-markdown)`},semanticCode:{fontSize:`var(--text-code)`},uiHeader:{fontSize:`var(--text-ui-header)`},uiLabel:{fontSize:`var(--text-ui-label)`},meta:{fontSize:`var(--text-meta)`},micro:{fontSize:`var(--text-micro)`},ui:{button:{fontSize:`var(--text-ui-label)`,lineHeight:`var(--ui-button-line-height)`,letterSpacing:`var(--ui-button-letter-spacing)`,fontWeight:`var(--ui-button-font-weight)`},buttonSmall:{fontSize:`var(--text-meta)`,lineHeight:`var(--ui-button-small-line-height)`,letterSpacing:`var(--ui-button-small-letter-spacing)`,fontWeight:`var(--ui-button-small-font-weight)`},buttonLarge:{fontSize:`var(--text-ui-label)`,lineHeight:`var(--ui-button-large-line-height)`,letterSpacing:`var(--ui-button-large-letter-spacing)`,fontWeight:`var(--ui-button-large-font-weight)`},label:{fontSize:`var(--text-meta)`,lineHeight:`var(--ui-label-line-height)`,letterSpacing:`var(--ui-label-letter-spacing)`,fontWeight:`var(--ui-label-font-weight)`},caption:{fontSize:`var(--text-micro)`,lineHeight:`var(--ui-caption-line-height)`,letterSpacing:`var(--ui-caption-letter-spacing)`,fontWeight:`var(--ui-caption-font-weight)`},badge:{fontSize:`var(--text-micro)`,lineHeight:`var(--ui-badge-line-height)`,letterSpacing:`var(--ui-badge-letter-spacing)`,fontWeight:`var(--ui-badge-font-weight)`},tooltip:{fontSize:`var(--text-micro)`,lineHeight:`var(--ui-tooltip-line-height)`,letterSpacing:`var(--ui-tooltip-letter-spacing)`,fontWeight:`var(--ui-tooltip-font-weight)`},input:{fontSize:`var(--text-ui-label)`,lineHeight:`var(--ui-input-line-height)`,letterSpacing:`var(--ui-input-letter-spacing)`,fontWeight:`var(--ui-input-font-weight)`},helperText:{fontSize:`var(--text-meta)`,lineHeight:`var(--ui-helper-text-line-height)`,letterSpacing:`var(--ui-helper-text-letter-spacing)`,fontWeight:`var(--ui-helper-text-font-weight)`}},code:{inline:{fontSize:`var(--text-code)`,lineHeight:`var(--code-inline-line-height)`,letterSpacing:`var(--code-inline-letter-spacing)`,fontWeight:`var(--code-inline-font-weight)`},block:{fontSize:`var(--text-code)`,lineHeight:`var(--code-block-line-height)`,letterSpacing:`var(--code-block-letter-spacing)`,fontWeight:`var(--code-block-font-weight)`},lineNumbers:{fontSize:`var(--text-micro)`,lineHeight:`var(--code-line-numbers-line-height)`,letterSpacing:`var(--code-line-numbers-letter-spacing)`,fontWeight:`var(--code-line-numbers-font-weight)`}},markdown:{body:{fontSize:`var(--text-markdown)`,lineHeight:`var(--markdown-body-line-height)`,letterSpacing:`var(--markdown-body-letter-spacing)`,fontWeight:`var(--markdown-body-font-weight)`},bodySmall:{fontSize:`var(--text-meta)`,lineHeight:`var(--markdown-body-small-line-height)`,letterSpacing:`var(--markdown-body-small-letter-spacing)`,fontWeight:`var(--markdown-body-small-font-weight)`},bodyLarge:{fontSize:`var(--text-markdown)`,lineHeight:`var(--markdown-body-large-line-height)`,letterSpacing:`var(--markdown-body-large-letter-spacing)`,fontWeight:`var(--markdown-body-large-font-weight)`},blockquote:{fontSize:`var(--text-markdown)`,lineHeight:`var(--markdown-blockquote-line-height)`,letterSpacing:`var(--markdown-blockquote-letter-spacing)`,fontWeight:`var(--markdown-blockquote-font-weight)`},list:{fontSize:`var(--text-markdown)`,lineHeight:`var(--markdown-list-line-height)`,letterSpacing:`var(--markdown-list-letter-spacing)`,fontWeight:`var(--markdown-list-font-weight)`},link:{fontSize:`var(--text-markdown)`,lineHeight:`var(--markdown-link-line-height)`,letterSpacing:`var(--markdown-link-letter-spacing)`,fontWeight:`var(--markdown-link-font-weight)`},code:{fontSize:`var(--text-code)`,lineHeight:`var(--markdown-code-line-height)`,letterSpacing:`var(--markdown-code-letter-spacing)`,fontWeight:`var(--markdown-code-font-weight)`},codeBlock:{fontSize:`var(--text-code)`,lineHeight:`var(--markdown-code-block-line-height)`,letterSpacing:`var(--markdown-code-block-letter-spacing)`,fontWeight:`var(--markdown-code-block-font-weight)`}},tool:{collapsed:{fontSize:`var(--text-code)`,lineHeight:`var(--code-block-line-height)`,letterSpacing:`var(--code-block-letter-spacing)`,fontWeight:`var(--code-block-font-weight)`},popup:{fontSize:`var(--text-code)`,lineHeight:`var(--code-block-line-height)`,letterSpacing:`var(--code-block-letter-spacing)`,fontWeight:`var(--code-block-font-weight)`},inline:{fontSize:`var(--text-code)`,lineHeight:`var(--code-inline-line-height)`,letterSpacing:`var(--code-inline-letter-spacing)`,fontWeight:`var(--code-inline-font-weight)`}}},Wn={padding:{collapsed:`0.375rem`,popup:`0.75rem`,popupContainer:`1rem`},backgroundOpacity:{muted:`30`,mutedAlt:`50`},getCollapsedStyles:()=>({...Un.tool.collapsed,background:`transparent`,backgroundColor:`transparent`,margin:0,padding:Wn.padding.collapsed,borderRadius:0}),getPopupStyles:()=>({...Un.tool.popup,background:`transparent`,backgroundColor:`transparent`,margin:0,padding:Wn.padding.popup,borderRadius:`0.75rem`}),getPopupContainerStyles:()=>({...Un.tool.popup,background:`transparent`,backgroundColor:`transparent`,margin:0,padding:Wn.padding.popupContainer,borderRadius:`0.5rem`,overflowX:`auto`}),getInlineStyles:()=>({...Un.tool.inline})},Gn=[{id:`inter`,label:`Inter`,description:`Modern UI sans with excellent readability at small sizes.`,stack:`"Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,source:{family:`Inter`,packageName:`@fontsource/inter`,filePrefix:`inter`,weights:[400,500,600]}},{id:`geist-sans`,label:`Geist Sans`,description:`Crisp sans-serif with a technical interface feel.`,stack:`"Geist Sans", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,source:{family:`Geist Sans`,packageName:`@fontsource/geist-sans`,filePrefix:`geist-sans`,weights:[400,500,600]}},{id:`atkinson-hyperlegible`,label:`Atkinson Hyperlegible`,description:`Accessibility-focused sans-serif optimized for character distinction.`,stack:`"Atkinson Hyperlegible", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,source:{family:`Atkinson Hyperlegible`,packageName:`@fontsource/atkinson-hyperlegible`,filePrefix:`atkinson-hyperlegible`,weights:[400,700]}},{id:`source-sans-3`,label:`Source Sans 3`,description:`Adobe sans-serif tuned for clean, readable interfaces.`,stack:`"Source Sans 3", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,source:{family:`Source Sans 3`,packageName:`@fontsource/source-sans-3`,filePrefix:`source-sans-3`,weights:[400,500,600]}},{id:`roboto`,label:`Roboto`,description:`Familiar Material-style sans-serif with broad UI usage.`,stack:`"Roboto", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,source:{family:`Roboto`,packageName:`@fontsource/roboto`,filePrefix:`roboto`,weights:[400,500,600]}},{id:`noto-sans`,label:`Noto Sans`,description:`Readable sans-serif with strong international coverage.`,stack:`"Noto Sans", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,source:{family:`Noto Sans`,packageName:`@fontsource/noto-sans`,filePrefix:`noto-sans`,weights:[400,500,600]}},{id:`dm-sans`,label:`DM Sans`,description:`Modern product UI sans-serif with friendly proportions.`,stack:`"DM Sans", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,source:{family:`DM Sans`,packageName:`@fontsource/dm-sans`,filePrefix:`dm-sans`,weights:[400,500,600]}},{id:`manrope`,label:`Manrope`,description:`Polished geometric sans-serif for modern app interfaces.`,stack:`"Manrope", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,source:{family:`Manrope`,packageName:`@fontsource/manrope`,filePrefix:`manrope`,weights:[400,500,600]}},{id:`system`,label:`System`,description:`Native operating system interface font.`,stack:`-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif`}],Kn=[{id:`jetbrains-mono`,label:`JetBrains Mono`,description:`Developer-focused monospace with strong punctuation clarity.`,stack:`"JetBrains Mono", "SFMono-Regular", "Menlo", monospace`,source:{family:`JetBrains Mono`,packageName:`@fontsource/jetbrains-mono`,filePrefix:`jetbrains-mono`,weights:[400,500,600]}},{id:`fira-code`,label:`Fira Code`,description:`Readable coding font with ligature support.`,stack:`"Fira Code", "SFMono-Regular", "Menlo", monospace`,source:{family:`Fira Code`,packageName:`@fontsource/fira-code`,filePrefix:`fira-code`,weights:[400,500,600]}},{id:`geist-mono`,label:`Geist Mono`,description:`Sharp monospace pair for Geist Sans.`,stack:`"Geist Mono", "SFMono-Regular", "Menlo", monospace`,source:{family:`Geist Mono`,packageName:`@fontsource/geist-mono`,filePrefix:`geist-mono`,weights:[400,500,600]}},{id:`commit-mono`,label:`Commit Mono`,description:`Code-oriented monospace with polished editor ergonomics.`,stack:`"Commit Mono", "SFMono-Regular", "Menlo", monospace`,source:{family:`Commit Mono`,packageName:`@fontsource/commit-mono`,filePrefix:`commit-mono`,weights:[400,500,600]}},{id:`source-code-pro`,label:`Source Code Pro`,description:`Adobe monospace designed for source code readability.`,stack:`"Source Code Pro", "SFMono-Regular", "Menlo", monospace`,source:{family:`Source Code Pro`,packageName:`@fontsource/source-code-pro`,filePrefix:`source-code-pro`,weights:[400,500,600]}},{id:`cascadia-code`,label:`Cascadia Code`,description:`Microsoft coding font popular in terminals and editors.`,stack:`"Cascadia Code", "SFMono-Regular", "Menlo", monospace`,source:{family:`Cascadia Code`,packageName:`@fontsource/cascadia-code`,filePrefix:`cascadia-code`,weights:[400,500,600]}},{id:`roboto-mono`,label:`Roboto Mono`,description:`Neutral monospace companion to Roboto.`,stack:`"Roboto Mono", "SFMono-Regular", "Menlo", monospace`,source:{family:`Roboto Mono`,packageName:`@fontsource/roboto-mono`,filePrefix:`roboto-mono`,weights:[400,500,600]}},{id:`iosevka`,label:`Iosevka`,description:`Compact monospace for dense code and terminal layouts.`,stack:`"Iosevka", "SFMono-Regular", "Menlo", monospace`,source:{family:`Iosevka`,packageName:`@fontsource/iosevka`,filePrefix:`iosevka`,weights:[400,500,600]}},{id:`system-mono`,label:`System Mono`,description:`Native operating system monospace font.`,stack:`ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace`}],qn=e=>Object.fromEntries(e.map(e=>[e.id,e])),Jn=qn(Gn),Yn=qn(Kn),Xn=`system`,Zn=`system-mono`,Qn=e=>typeof e==`string`&&e in Jn,$n=e=>typeof e==`string`&&e in Yn,er=`openchamber.mobileKeyboardMode`,tr=`meta[name="viewport"]`,nr=`width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover`,rr=()=>!0;function ir(e,t=`resize-content`){return e===`native`||e===`resize-content`?e:t}var ar=e=>ir(e)===`resize-content`?`${nr}, interactive-widget=resizes-content`:nr,or=()=>{if(typeof window>`u`)return`resize-content`;try{return ir(localStorage.getItem(er))}catch{return`resize-content`}},sr=e=>{let t=ir(e);if(typeof window<`u`)try{t===`resize-content`?localStorage.removeItem(er):localStorage.setItem(er,t)}catch{}return t},cr=e=>{let t=sr(e);if(typeof document>`u`)return t;document.documentElement.setAttribute(`data-oc-mobile-keyboard-mode`,t);let n=document.querySelector(tr);if(n instanceof HTMLMetaElement){let e=ar(t);n.getAttribute(`content`)!==e&&n.setAttribute(`content`,e)}return t};function lr(e){return e===`vim`?`vim`:`default`}var ur={completion:{title:`{agent_name} is ready`,message:`{last_message}`},error:{title:`Tool error`,message:`{last_message}`},question:{title:`{agent_name} needs input`,message:`{last_message}`},subtask:{title:`Subtask complete`,message:`{last_message}`}},J={completion:{title:``,message:``},error:{title:``,message:``},question:{title:``,message:``},subtask:{title:``,message:``}},dr=(e,t)=>e?e.title===t.title&&e.message===t.message:!1,fr=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return dr(t.completion,ur.completion)&&dr(t.error,ur.error)&&dr(t.question,ur.question)&&dr(t.subtask,ur.subtask)},pr=380,mr=380,hr=1400,gr=12,_r=40,vr=120,Y=260,yr=new Map,br=e=>(e??gn()).trim()||`default`,X=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+$/g,``);return r=r.replace(/\/+/g,`/`),n&&!r.startsWith(`//`)&&(r=`/${r}`),r===``?t.startsWith(`/`)?`/`:``:r},xr=e=>Number.isFinite(e)?Math.min(hr,Math.max(mr,Math.round(e))):pr,Sr=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t?t.replace(/\\/g,`/`):null},Cr=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t?t.length>vr?t.slice(0,vr):t:null},wr=e=>e===`working`||e===`staged`||e===`turn`?e:null,Tr=e=>typeof e==`string`&&e.trim()||null,Er=e=>typeof e==`string`&&e.trim()||null,Dr=(e,t)=>(e===`file`||e===`preview`)&&t||e,Or=(e,t,n)=>{if(e===`diff`||e===`file-diff`)return e;if(typeof n==`string`){let e=n.trim();if(e)return e}return Dr(e,t)},kr=(e,t)=>t===e?e:`${e}:${t}`,Ar=e=>e===`turn-diff-outside-workspace`?e:null,jr=e=>{let t=Sr(e.targetPath),n=Or(e.mode,t,e.dedupeKey);return{id:kr(e.mode,n),mode:e.mode,targetPath:t,dedupeKey:n,label:Cr(e.label),sessionTitleFallback:Cr(e.sessionTitleFallback),readOnly:e.readOnly===!0,stagedDiff:e.stagedDiff===!0,diffScope:wr(e.diffScope)??(e.stagedDiff===!0?`staged`:`working`),diffTargetLine:typeof e.diffTargetLine==`number`&&Number.isFinite(e.diffTargetLine)?Math.max(1,Math.trunc(e.diffTargetLine)):null,diffTurnMessageId:Tr(e.diffTurnMessageId),diffSessionId:Er(e.diffSessionId),fileNotice:e.mode===`file`?Ar(e.fileNotice):null,touchedAt:Date.now()}},Mr=(e,t,n)=>{if(e.length<=t)return e;let r=[...e].sort((e,t)=>e.touchedAt-t.touchedAt).filter(e=>e.id!==n),i=e.length-t;if(i<=0||r.length===0)return e.slice(-t);let a=new Set(r.slice(0,i).map(e=>e.id));return e.filter(e=>!a.has(e.id))},Nr=e=>{if(!Array.isArray(e))return[];let t=[],n=new Set;for(let r of e){if(!r||typeof r!=`object`)continue;let e=r;if(e.mode!==`diff`&&e.mode!==`file-diff`&&e.mode!==`file`&&e.mode!==`context`&&e.mode!==`plan`&&e.mode!==`chat`&&e.mode!==`preview`&&e.mode!==`browser`)continue;let i=Sr(typeof e.targetPath==`string`?e.targetPath:null),a=Or(e.mode,i,typeof e.dedupeKey==`string`?e.dedupeKey:null),o=kr(e.mode,a);!o||n.has(o)||(n.add(o),t.push({id:o,mode:e.mode,targetPath:i,dedupeKey:a,label:Cr(typeof e.label==`string`?e.label:null),sessionTitleFallback:Cr(typeof e.sessionTitleFallback==`string`?e.sessionTitleFallback:null),readOnly:e.readOnly===!0,stagedDiff:e.stagedDiff===!0,diffScope:wr(e.diffScope)??(e.stagedDiff===!0?`staged`:`working`),diffTargetLine:typeof e.diffTargetLine==`number`&&Number.isFinite(e.diffTargetLine)?Math.max(1,Math.trunc(e.diffTargetLine)):null,diffTurnMessageId:Tr(e.diffTurnMessageId),diffSessionId:Er(e.diffSessionId),fileNotice:e.mode===`file`?Ar(e.fileNotice):null,touchedAt:typeof e.touchedAt==`number`&&Number.isFinite(e.touchedAt)?e.touchedAt:Date.now()}))}return t},Z=(e,t)=>t&&e.some(e=>e.id===t)?t:e.length===0?null:e[e.length-1].id,Q=e=>{if(e){let t=Nr(e.tabs),n=Z(t,e.activeTabId);return{...e,tabs:t,activeTabId:n,touchedAt:Date.now()}}return{isOpen:!1,expanded:!1,tabs:[],activeTabId:null,width:pr,touchedAt:Date.now()}},Pr=(e,t)=>{let n=jr(t),r=e.tabs.findIndex(e=>e.id===n.id),i=r===-1?[...e.tabs,n]:e.tabs.map((e,t)=>t===r?{...e,diffTargetLine:n.diffTargetLine,diffTurnMessageId:n.diffTurnMessageId,diffSessionId:n.diffSessionId,mode:n.mode,targetPath:n.targetPath||e.targetPath,dedupeKey:n.dedupeKey,label:n.label,sessionTitleFallback:n.sessionTitleFallback||e.sessionTitleFallback,stagedDiff:n.stagedDiff,diffScope:n.diffScope,readOnly:n.readOnly,fileNotice:n.mode===`file`?n.fileNotice:null,touchedAt:Date.now()}:e),a=n.id,o=Mr(i,gr,a);return{...e,isOpen:!0,tabs:o,activeTabId:Z(o,a),touchedAt:Date.now()}},Fr=(e,t)=>{let n=e.tabs.filter(e=>e.id!==t),r=e.activeTabId===t?n[n.length-1]?.id??null:Z(n,e.activeTabId);return{...e,tabs:n,activeTabId:r,isOpen:n.length>0&&e.isOpen,touchedAt:Date.now()}},Ir=(e,t,n)=>{if(t===n)return e;let r=e.tabs.findIndex(e=>e.id===t),i=e.tabs.findIndex(e=>e.id===n);if(r===-1||i===-1)return e;let a=[...e.tabs],[o]=a.splice(r,1);return o?(a.splice(i,0,o),{...e,tabs:a,touchedAt:Date.now()}):e},Lr=(e,t,n)=>({...e,tabs:e.tabs.map(e=>e.id===t?{...e,targetPath:n}:e)}),Rr=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=X(e);if(!t||!r||typeof r!=`object`)continue;let i=r,a=Nr(i.tabs),o=typeof i.activeTabId==`string`?i.activeTabId:null;a.length===0&&(i.mode===`diff`||i.mode===`file-diff`||i.mode===`file`||i.mode===`context`||i.mode===`plan`||i.mode===`chat`)&&(a=[jr({mode:i.mode,targetPath:typeof i.targetPath==`string`?i.targetPath:null,dedupeKey:typeof i.dedupeKey==`string`?i.dedupeKey:null,label:typeof i.label==`string`?i.label:null})],o=a[0]?.id??null);let s=Z(a,o),c=Mr(a,gr,s);n[t]={isOpen:i.isOpen===!0,expanded:i.expanded===!0,tabs:c,activeTabId:Z(c,s),width:xr(typeof i.width==`number`?i.width:pr),touchedAt:typeof i.touchedAt==`number`&&Number.isFinite(i.touchedAt)?i.touchedAt:Date.now()}}return n},$=(e,t)=>{let n=Object.entries(e);if(n.length<=t)return e;n.sort((e,t)=>(t[1]?.touchedAt??0)-(e[1]?.touchedAt??0));let r={};for(let[e,i]of n.slice(0,t))r[e]=i;return r},zr=(e,t)=>{let n=Object.entries(e);if(n.length<=t)return e;n.sort((e,t)=>(t[1]?.touchedAt??0)-(e[1]?.touchedAt??0));let r={};for(let[e,i]of n.slice(0,t))r[e]=i;return r},Br=(e,t)=>{let n=X((t||``).trim())||null,r=n?e.contextPanelByDirectory[n]:void 0;return{isRightSidebarOpen:e.isRightSidebarOpen,rightSidebarTab:e.rightSidebarTab,contextPanelDirectory:n,contextPanelIsOpen:!!(r?.isOpen&&r.tabs.length>0),contextPanelActiveTabId:r?.activeTabId??null,contextPanelExpanded:!!r?.expanded,touchedAt:Date.now()}},Vr=(e,t,n)=>{let r=X((t||``).trim());if(!r)return e;let i=e[r];if(!i)return e;let a=!!(n?.contextPanelIsOpen&&n.contextPanelDirectory===r&&i.tabs.length>0),o=a?Z(i.tabs,n?.contextPanelActiveTabId??i.activeTabId):i.activeTabId,s=a?!!n?.contextPanelExpanded:i.expanded;return i.isOpen===a&&i.activeTabId===o&&i.expanded===s?e:{...e,[r]:{...i,isOpen:a,activeTabId:o,expanded:s,touchedAt:Date.now()}}},Hr=e()(n(t((e,t)=>({theme:`system`,isMultiRunLauncherOpen:!1,isSidebarOpen:!0,sidebarWidth:Y,hasManuallyResizedLeftSidebar:!1,isRightSidebarOpen:!1,rightSidebarWidth:360,hasManuallyResizedRightSidebar:!1,rightSidebarTab:`git`,contextPanelByDirectory:{},contextToolDiffByDirectory:{},sessionWorkspacePanelById:{},contextPanelsOpenBeforeRightSidebarCollapse:[],isBottomTerminalOpen:!1,isBottomTerminalExpanded:!1,bottomTerminalHeight:300,hasManuallyResizedBottomTerminal:!1,notesPanelHeight:112,todoPanelHeight:259,isSessionSwitcherOpen:!1,isSessionDropdownOpen:!1,activeMainTab:`chat`,mainTabGuard:null,sidebarOpenBeforeFullscreenTab:null,pendingDiffFile:null,pendingDiffStaged:!1,pendingDiffScope:null,pendingDiffLine:null,pendingDiagramFile:null,pendingFileNavigation:null,pendingFileFocusPath:null,isMobile:!1,isCommandPaletteOpen:!1,isHelpDialogOpen:!1,isAboutDialogOpen:!1,isOpenCodeStatusDialogOpen:!1,openCodeStatusText:``,isSessionCreateDialogOpen:!1,isScheduledTasksDialogOpen:!1,isArchivedSessionsDialogOpen:!1,isSettingsDialogOpen:!1,isNewWorktreeDialogOpen:!1,isModelSelectorOpen:!1,isAgentSelectorOpen:!1,isModelSelectorInstant:!1,isAgentSelectorInstant:!1,sidebarSection:`sessions`,settingsPage:`home`,settingsHasOpenedOnce:!1,settingsProjectsSelectedId:null,settingsRemoteInstancesSelectedId:null,eventStreamStatus:`idle`,eventStreamHint:null,showReasoningTraces:!0,sessionRecapEnabled:!0,sessionTitleRefreshEnabled:!0,sessionGoalEnabled:!0,sessionGoalDefaultBudgetEnabled:!1,sessionGoalDefaultBudget:2e5,collapsibleThinkingBlocks:!0,chatRenderMode:`sorted`,activityRenderMode:`collapsed`,showDeletionDialog:!0,autoDeleteEnabled:!1,autoDeleteAfterDays:30,sessionRetentionAction:`archive`,autoDeleteLastRunAt:null,messageLimit:200,fontSize:100,codeFontSize:100,globalDraftStarters:null,terminalFontSize:13,editorFontSize:13,uiFont:Xn,monoFont:Zn,padding:100,cornerRadius:18,inputBarOffset:0,mobileKeyboardMode:or(),favoriteModels:[],hiddenModels:[],providerOrder:[],collapsedModelProviders:[],recentModels:[],recentAgents:[],recentEfforts:{},diffLayoutPreference:`inline`,diffFileLayout:{},diffWrapLines:!1,gitChangesViewMode:`tree`,isTimelineDialogOpen:!1,isPromptNavigatorPanelOpen:!1,isImagePreviewOpen:!1,nativeNotificationsEnabled:!1,notificationMode:`hidden-only`,notifyOnSubtasks:!1,dockBadgeEnabled:!0,notifyOnCompletion:!0,notifyOnError:!0,notifyOnQuestion:!0,notificationTemplates:{completion:{...J.completion},error:{...J.error},question:{...J.question},subtask:{...J.subtask}},summarizeLastMessage:!1,summaryThreshold:200,summaryLength:100,maxLastMessageLength:250,showTerminalQuickKeysOnDesktop:!1,persistChatDraft:!0,showOpenCodeUpdateNotifications:!0,inputSpellcheckEnabled:!1,wideChatLayoutEnabled:!1,codeBlockLineWrap:!0,showToolFileIcons:!0,showTurnChangedFiles:!0,showExpandedBashTools:!1,showSubagentTaskDetails:!1,timeFormatPreference:`auto`,weekStartPreference:`auto`,desktopWindowControlsPosition:`auto`,mermaidRenderingMode:`svg`,userMessageRenderingMode:`markdown`,collapsibleUserMessages:!0,stickyUserHeader:!1,promptNavigatorEnabled:!1,expandedEditorToolbar:!1,showSplitAssistantMessageActions:!1,showAssistantTps:!0,allowPromptingSubagentSessions:!1,isMobileSessionStatusBarCollapsed:!1,mobileSessionPanelOpen:!1,mobileSessionFilterProjectId:null,isExpandedInput:!1,reportUsage:!1,shortcutOverrides:{},fileEditorKeymap:`default`,setTheme:n=>{e({theme:n}),t().applyTheme()},toggleSidebar:()=>{e(e=>{let t=!e.isSidebarOpen;return t&&!e.hasManuallyResizedLeftSidebar?{isSidebarOpen:t,sidebarWidth:Y}:{isSidebarOpen:t}})},setSidebarOpen:t=>{e(e=>e.isSidebarOpen===t?t&&!e.hasManuallyResizedLeftSidebar&&e.sidebarWidth!==Y?{isSidebarOpen:t,sidebarWidth:Y}:e:t&&!e.hasManuallyResizedLeftSidebar?{isSidebarOpen:t,sidebarWidth:Y}:{isSidebarOpen:t})},setSidebarWidth:t=>{e({sidebarWidth:t,hasManuallyResizedLeftSidebar:!0})},toggleRightSidebar:()=>{e(e=>{if(e.isRightSidebarOpen){let t=Object.entries(e.contextPanelByDirectory).filter(([,e])=>e.isOpen&&e.tabs.length>0).map(([e])=>e);return{isRightSidebarOpen:!1,contextPanelByDirectory:t.length===0?e.contextPanelByDirectory:Object.fromEntries(Object.entries(e.contextPanelByDirectory).map(([e,n])=>[e,t.includes(e)?{...n,isOpen:!1}:n])),contextPanelsOpenBeforeRightSidebarCollapse:t}}let t=e.contextPanelsOpenBeforeRightSidebarCollapse.length===0?e.contextPanelByDirectory:Object.fromEntries(Object.entries(e.contextPanelByDirectory).map(([t,n])=>[t,e.contextPanelsOpenBeforeRightSidebarCollapse.includes(t)&&n.tabs.length>0?{...n,isOpen:!0}:n]));return e.hasManuallyResizedRightSidebar?{isRightSidebarOpen:!0,contextPanelByDirectory:t,contextPanelsOpenBeforeRightSidebarCollapse:[]}:{isRightSidebarOpen:!0,rightSidebarWidth:360,contextPanelByDirectory:t,contextPanelsOpenBeforeRightSidebarCollapse:[]}})},setRightSidebarOpen:t=>{e(e=>e.isRightSidebarOpen===t?e:{isRightSidebarOpen:t,rightSidebarWidth:t&&!e.hasManuallyResizedRightSidebar&&e.rightSidebarWidth!==360?360:e.rightSidebarWidth})},setRightSidebarWidth:t=>{e({rightSidebarWidth:Math.min(860,Math.max(360,t)),hasManuallyResizedRightSidebar:!0})},setRightSidebarTab:t=>{e({rightSidebarTab:t})},syncWorkspacePanelsForSessionSwitch:({previousSessionId:t,previousDirectory:n,nextSessionId:r,nextDirectory:i})=>{let a=typeof t==`string`?t.trim():``,o=typeof r==`string`?r.trim():``;a!==o&&e(e=>{let t=e.sessionWorkspacePanelById;a&&(t={...t,[a]:Br(e,n)});let r=o?t[o]:void 0,s=Vr(e.contextPanelByDirectory,i,r),c=X((n||``).trim()),l=X((i||``).trim()),u=s;if(c&&c!==l){let e=u[c];e?.isOpen&&(u={...u,[c]:{...e,isOpen:!1,touchedAt:Date.now()}})}let d=r?r.isRightSidebarOpen:!1,f=r?.rightSidebarTab??e.rightSidebarTab;return{sessionWorkspacePanelById:zr(t,_r),contextPanelByDirectory:u,isRightSidebarOpen:d,rightSidebarTab:f,contextPanelsOpenBeforeRightSidebarCollapse:[]}})},openContextPanelTab:(t,n)=>{let r=X((t||``).trim());r&&e(e=>{let t=e.contextPanelByDirectory[r],i=Q(t),a={...e.contextPanelByDirectory,[r]:Pr(i,n)};if(n.mode===`diff`||n.mode===`file-diff`){let t={...e.contextToolDiffByDirectory};return delete t[r],{contextPanelByDirectory:$(a,20),contextToolDiffByDirectory:t}}return{contextPanelByDirectory:$(a,20)}})},openContextDiff:(e,n,r=!1,i=null,a,o,s)=>{let c=X((e||``).trim()),l=(n||``).trim();if(!c||!l)return;let u=wr(i)??(r?`staged`:`working`);t().openContextPanelTab(c,{mode:`diff`,targetPath:l,stagedDiff:u===`staged`,diffScope:u,diffTargetLine:a,diffTurnMessageId:o,diffSessionId:s})},openContextToolDiff:(t,n,r,i,a,o)=>{let s=X((t||``).trim()),c=(n||``).trim(),l=r.flatMap(e=>{let t=Sr(e.path),n=typeof e.patch==`string`?e.patch:``;return t&&n.trim()?[{path:t,patch:n}]:[]});if(!s||!c||l.length===0)return;let u={mode:`diff`,targetPath:c,stagedDiff:!1,diffScope:`turn`,diffTargetLine:i,diffTurnMessageId:a,diffSessionId:o};e(e=>{let t=e.contextPanelByDirectory[s],n=Q(t),r=$({...e.contextPanelByDirectory,[s]:Pr(n,u)},20),i=new Set(Object.keys(r)),o=Object.fromEntries(Object.entries(e.contextToolDiffByDirectory).filter(([e])=>i.has(e)));return o[s]={targetPath:c,patches:l,turnMessageId:Tr(a)},{contextPanelByDirectory:r,contextToolDiffByDirectory:o}})},openContextFileDiff:(e,n,r=!1,i=null)=>{let a=X((e||``).trim()),o=(n||``).trim();if(!a||!o)return;let s=wr(i)??(r?`staged`:`working`);t().openContextPanelTab(a,{mode:`file-diff`,targetPath:o,stagedDiff:s===`staged`,diffScope:s})},openContextFile:(e,n,r)=>{let i=X((e||``).trim()),a=Sr(n);!i||!a||(t().openContextPanelTab(i,{mode:`file`,targetPath:a,fileNotice:Ar(r?.fileNotice)}),t().setPendingFileFocusPath(a),t().setPendingFileNavigation(null))},openContextFileAtLine:(e,n,r,i)=>{let a=X((e||``).trim()),o=Sr(n),s=Number.isFinite(r)?Math.max(1,Math.trunc(r)):1,c=Number.isFinite(i)?Math.max(1,Math.trunc(i)):1;!a||!o||(t().openContextPanelTab(a,{mode:`file`,targetPath:o}),t().setPendingFileFocusPath(null),t().setPendingFileNavigation({path:o,line:s,column:c}))},openContextOverview:e=>{let n=X((e||``).trim());n&&t().openContextPanelTab(n,{mode:`context`})},openContextPlan:e=>{let n=X((e||``).trim());n&&t().openContextPanelTab(n,{mode:`plan`})},openContextPreview:(e,n)=>{let r=X((e||``).trim()),i=(n||``).trim();if(!r||!i)return;let a=null;try{let e=new URL(i);(e.protocol===`http:`||e.protocol===`https:`)&&(a=e.host||e.hostname||`Preview`)}catch{}t().openContextPanelTab(r,{mode:`preview`,targetPath:i,dedupeKey:i,label:a})},openContextBrowser:(e,n=``)=>{let r=X((e||``).trim());if(!r)return;let i=typeof n==`string`&&n.trim().length>0?n.trim():``;t().openContextPanelTab(r,{mode:`browser`,targetPath:i,dedupeKey:`desktop-browser`,label:`Browser`})},setContextPanelTabTargetPath:(t,n,r)=>{let i=X((t||``).trim()),a=(n||``).trim();!i||!a||e(e=>{let t=e.contextPanelByDirectory[i];return t?{contextPanelByDirectory:{...e.contextPanelByDirectory,[i]:Lr(t,a,r)}}:e})},setActiveContextPanelTab:(t,n)=>{let r=X((t||``).trim()),i=(n||``).trim();!r||!i||e(e=>{let t=e.contextPanelByDirectory[r],n=Q(t);return!n.tabs.some(e=>e.id===i)||n.activeTabId===i&&n.isOpen?e:{contextPanelByDirectory:$({...e.contextPanelByDirectory,[r]:{...n,isOpen:!0,activeTabId:i,touchedAt:Date.now(),tabs:n.tabs.map(e=>e.id===i?{...e,touchedAt:Date.now()}:e)}},20)}})},reorderContextPanelTabs:(t,n,r)=>{let i=X((t||``).trim()),a=(n||``).trim(),o=(r||``).trim();!i||!a||!o||e(e=>{let t=e.contextPanelByDirectory[i],n=Q(t);if(!n.tabs.some(e=>e.id===a)||!n.tabs.some(e=>e.id===o))return e;let r=Ir(n,a,o);return r.tabs===n.tabs?e:{contextPanelByDirectory:$({...e.contextPanelByDirectory,[i]:r},20)}})},closeContextPanelTab:(t,n)=>{let r=X((t||``).trim()),i=(n||``).trim();!r||!i||e(e=>{let t=e.contextPanelByDirectory[r],n=Q(t);if(!n.tabs.some(e=>e.id===i))return e;let a={...e.contextPanelByDirectory,[r]:Fr(n,i)};if(i===`diff`){let t={...e.contextToolDiffByDirectory};return delete t[r],{contextPanelByDirectory:$(a,20),contextToolDiffByDirectory:t}}return{contextPanelByDirectory:$(a,20)}})},closeActiveContextPanelTab:e=>{let n=X((e||``).trim());if(!n)return!1;let r=t().contextPanelByDirectory[n];if(!r?.isOpen||r.tabs.length===0)return!1;let i=Z(r.tabs,r.activeTabId);return i?(t().closeContextPanelTab(n,i),!0):!1},closeContextPanel:t=>{let n=X((t||``).trim());n&&e(e=>{let t=e.contextPanelByDirectory[n];return!t||!t.isOpen?e:{contextPanelByDirectory:$({...e.contextPanelByDirectory,[n]:{...Q(t),isOpen:!1}},20)}})},toggleContextPanelExpanded:t=>{let n=X((t||``).trim());n&&e(e=>{let t=e.contextPanelByDirectory[n],r=Q(t);return{contextPanelByDirectory:$({...e.contextPanelByDirectory,[n]:{...r,expanded:!r.expanded}},20)}})},setContextPanelWidth:(t,n)=>{let r=X((t||``).trim());r&&e(e=>{let t=e.contextPanelByDirectory[r],i=Q(t);return{contextPanelByDirectory:$({...e.contextPanelByDirectory,[r]:{...i,width:xr(n)}},20)}})},toggleBottomTerminal:()=>{e(e=>{let t=!e.isBottomTerminalOpen;return t&&typeof window<`u`?{isBottomTerminalOpen:t,bottomTerminalHeight:Math.floor(window.innerHeight*.32),hasManuallyResizedBottomTerminal:!1}:{isBottomTerminalOpen:t}})},setBottomTerminalOpen:t=>{e(e=>{if(e.isBottomTerminalOpen===t){if(!t)return e;if(!e.hasManuallyResizedBottomTerminal&&typeof window<`u`){let n=Math.floor(window.innerHeight*.32);return e.bottomTerminalHeight===n&&e.hasManuallyResizedBottomTerminal===!1?e:{isBottomTerminalOpen:t,bottomTerminalHeight:n,hasManuallyResizedBottomTerminal:!1}}return e}return t&&typeof window<`u`?{isBottomTerminalOpen:t,bottomTerminalHeight:Math.floor(window.innerHeight*.32),hasManuallyResizedBottomTerminal:!1}:{isBottomTerminalOpen:t}})},setBottomTerminalExpanded:t=>{e({isBottomTerminalExpanded:t})},setBottomTerminalHeight:t=>{e({bottomTerminalHeight:t,hasManuallyResizedBottomTerminal:!0})},setNotesPanelHeight:t=>{e({notesPanelHeight:t})},setTodoPanelHeight:t=>{e({todoPanelHeight:t})},setSessionSwitcherOpen:n=>{t().isSessionSwitcherOpen!==n&&e({isSessionSwitcherOpen:n})},setSessionDropdownOpen:n=>{t().isSessionDropdownOpen!==n&&e({isSessionDropdownOpen:n})},setMainTabGuard:n=>{t().mainTabGuard!==n&&e({mainTabGuard:n})},setActiveMainTab:n=>{let r=t().mainTabGuard;return r&&!r(n)?!1:(yr.set(br(),n),e({activeMainTab:n}),!0)},prepareForRuntimeSwitch:n=>{yr.set(br(n),t().activeMainTab),e({contextToolDiffByDirectory:{}})},restoreForRuntimeSwitch:t=>{e({activeMainTab:yr.get(br(t))??`chat`})},setPendingDiffFile:(t,n=!1,r=null,i)=>{e({pendingDiffFile:t,pendingDiffStaged:t?n:!1,pendingDiffScope:t?r:null,pendingDiffLine:t&&typeof i==`number`&&Number.isFinite(i)?Math.max(1,Math.trunc(i)):null})},setPendingDiagramFile:t=>{e({pendingDiagramFile:t})},setPendingFileNavigation:t=>{e({pendingFileNavigation:t})},setPendingFileFocusPath:t=>{e({pendingFileFocusPath:t})},navigateToDiff:(n,r=!1,i=null,a)=>{let o=t().mainTabGuard;o&&!o(`diff`)||e({pendingDiffFile:n,pendingDiffStaged:r,pendingDiffScope:i,pendingDiffLine:typeof a==`number`&&Number.isFinite(a)?Math.max(1,Math.trunc(a)):null,activeMainTab:`diff`})},consumePendingDiffFile:()=>{let{pendingDiffFile:n}=t();return n&&e({pendingDiffFile:null,pendingDiffStaged:!1,pendingDiffScope:null,pendingDiffLine:null}),n},navigateToDiagram:n=>{let r=t().mainTabGuard;r&&!r(`diagram`)||e({pendingDiagramFile:n,activeMainTab:`diagram`})},consumePendingDiagramFile:()=>{let{pendingDiagramFile:n}=t();return n&&e({pendingDiagramFile:null}),n},setIsMobile:t=>{e({isMobile:t})},toggleCommandPalette:()=>{e(e=>({isCommandPaletteOpen:!e.isCommandPaletteOpen}))},setCommandPaletteOpen:t=>{e({isCommandPaletteOpen:t})},toggleHelpDialog:()=>{e(e=>({isHelpDialogOpen:!e.isHelpDialogOpen}))},setHelpDialogOpen:t=>{e({isHelpDialogOpen:t})},setAboutDialogOpen:t=>{e({isAboutDialogOpen:t})},setOpenCodeStatusDialogOpen:t=>{e({isOpenCodeStatusDialogOpen:t})},setOpenCodeStatusText:t=>{e({openCodeStatusText:t})},setSessionCreateDialogOpen:t=>{e({isSessionCreateDialogOpen:t})},setScheduledTasksDialogOpen:t=>{e({isScheduledTasksDialogOpen:t})},setArchivedSessionsDialogOpen:t=>{e({isArchivedSessionsDialogOpen:t})},setSettingsDialogOpen:t=>{e(e=>t?e.settingsHasOpenedOnce?{isSettingsDialogOpen:!0}:{isSettingsDialogOpen:!0,settingsHasOpenedOnce:!0}:{isSettingsDialogOpen:!1})},setNewWorktreeDialogOpen:t=>{e({isNewWorktreeDialogOpen:t})},setModelSelectorOpen:(t,n)=>{e(e=>t?{isModelSelectorOpen:!0,isAgentSelectorOpen:!1,isModelSelectorInstant:n?.instant===!0}:{isModelSelectorOpen:!1,isModelSelectorInstant:n?.instant===!0||n?.instant!==!1&&e.isModelSelectorInstant})},setAgentSelectorOpen:(t,n)=>{e(e=>t?{isAgentSelectorOpen:!0,isModelSelectorOpen:!1,isAgentSelectorInstant:n?.instant===!0}:{isAgentSelectorOpen:!1,isAgentSelectorInstant:n?.instant!==!1&&e.isAgentSelectorInstant})},setSidebarSection:t=>{e({sidebarSection:t})},setSettingsPage:t=>{e({settingsPage:t})},setSettingsProjectsSelectedId:t=>{e({settingsProjectsSelectedId:t})},setSettingsRemoteInstancesSelectedId:t=>{e({settingsRemoteInstancesSelectedId:t})},setEventStreamStatus:(t,n)=>{e({eventStreamStatus:t,eventStreamHint:n??null})},setShowReasoningTraces:t=>{e({showReasoningTraces:t})},setSessionRecapEnabled:t=>{e({sessionRecapEnabled:t})},setSessionTitleRefreshEnabled:t=>{e({sessionTitleRefreshEnabled:t})},setSessionGoalEnabled:t=>{e({sessionGoalEnabled:t})},setSessionGoalDefaultBudgetEnabled:t=>{e({sessionGoalDefaultBudgetEnabled:t})},setSessionGoalDefaultBudget:t=>{e({sessionGoalDefaultBudget:t})},setCollapsibleThinkingBlocks:t=>{e({collapsibleThinkingBlocks:t})},setChatRenderMode:t=>{e({chatRenderMode:t})},setActivityRenderMode:t=>{e({activityRenderMode:t})},setShowDeletionDialog:t=>{e({showDeletionDialog:t})},setAutoDeleteEnabled:t=>{e({autoDeleteEnabled:t})},setAutoDeleteAfterDays:t=>{e({autoDeleteAfterDays:Math.max(1,Math.min(365,t))})},setSessionRetentionAction:t=>{e({sessionRetentionAction:t})},setAutoDeleteLastRunAt:t=>{e({autoDeleteLastRunAt:t})},setMessageLimit:t=>{e({messageLimit:Math.max(10,Math.min(500,Math.round(t)))})},setFontSize:n=>{e({fontSize:Math.max(50,Math.min(200,n))}),t().applyTypography()},setCodeFontSize:n=>{e({codeFontSize:Math.max(50,Math.min(200,n))}),t().applyTypography()},setGlobalDraftStarters:t=>{e({globalDraftStarters:t})},setTerminalFontSize:t=>{e({terminalFontSize:Math.max(9,Math.min(52,Math.round(t)))})},setEditorFontSize:t=>{e({editorFontSize:Math.max(9,Math.min(32,Math.round(t)))})},setUiFont:t=>{e({uiFont:t})},setMonoFont:t=>{e({monoFont:t})},setPadding:n=>{e({padding:Math.max(50,Math.min(200,n))}),t().applyPadding()},setCornerRadius:t=>{e({cornerRadius:t})},applyTypography:()=>{let{fontSize:e,codeFontSize:n}=t(),r=document.documentElement,i=e/100,a=n/100,o=typeof document<`u`&&Vn(r),s=Object.keys(Ln);if(i===1&&a===1){for(let e of s)r.style.removeProperty(Bn(e));return}for(let e of s){let t=Hn(e,{mobile:o}),n=parseFloat(t);if(!Number.isFinite(n))continue;let s=e===`code`?a:i;if(s===1){r.style.removeProperty(Bn(e));continue}r.style.setProperty(Bn(e),`${n*s}rem`)}},applyPadding:()=>{let{padding:e}=t(),n=document.documentElement,r=e/100;if(r===1){n.style.removeProperty(`--padding-scale`),n.style.removeProperty(`--line-height-tight`),n.style.removeProperty(`--line-height-normal`),n.style.removeProperty(`--line-height-relaxed`),n.style.removeProperty(`--line-height-loose`);return}let i=Math.sqrt(r);n.style.setProperty(`--padding-scale`,i.toString());let a=1+(r-1)*.15;n.style.setProperty(`--line-height-tight`,(1.25*a).toFixed(3)),n.style.setProperty(`--line-height-normal`,(1.5*a).toFixed(3)),n.style.setProperty(`--line-height-relaxed`,(1.625*a).toFixed(3)),n.style.setProperty(`--line-height-loose`,(2*a).toFixed(3))},setDiffLayoutPreference:t=>{e({diffLayoutPreference:t})},setDiffFileLayout:(t,n)=>{e(e=>({diffFileLayout:{...e.diffFileLayout,[t]:n}}))},setDiffWrapLines:t=>{e({diffWrapLines:t})},setGitChangesViewMode:t=>{e({gitChangesViewMode:t})},setInputBarOffset:t=>{e({inputBarOffset:t})},setMobileKeyboardMode:t=>{e(e=>e.mobileKeyboardMode===t?e:{mobileKeyboardMode:t})},toggleFavoriteModel:(t,n)=>{e(e=>e.favoriteModels.some(e=>e.providerID===t&&e.modelID===n)?{favoriteModels:e.favoriteModels.filter(e=>e.providerID!==t||e.modelID!==n)}:{favoriteModels:[{providerID:t,modelID:n},...e.favoriteModels]})},reorderFavoriteModel:(t,n,r,i)=>{e(e=>{let a=e.favoriteModels.findIndex(e=>e.providerID===t&&e.modelID===n),o=e.favoriteModels.findIndex(e=>e.providerID===r&&e.modelID===i);if(a===-1||o===-1||a===o)return e;let s=e.favoriteModels.slice(),[c]=s.splice(a,1);return c?(s.splice(o,0,c),{favoriteModels:s}):e})},setProviderOrder:t=>{e(e=>{let n=t.filter(e=>typeof e==`string`&&e.length>0),r=e.providerOrder;return r.length===n.length&&r.every((e,t)=>e===n[t])?e:{providerOrder:n}})},toggleHiddenModel:(t,n)=>{e(e=>e.hiddenModels.some(e=>e.providerID===t&&e.modelID===n)?{hiddenModels:e.hiddenModels.filter(e=>e.providerID!==t||e.modelID!==n)}:{hiddenModels:[{providerID:t,modelID:n},...e.hiddenModels]})},isHiddenModel:(e,n)=>{let{hiddenModels:r}=t();return r.some(t=>t.providerID===e&&t.modelID===n)},hideAllModels:(t,n)=>{e(e=>{let r=e.hiddenModels.filter(e=>e.providerID!==t);return{hiddenModels:[...n.filter(e=>typeof e==`string`&&e.length>0).map(e=>({providerID:t,modelID:e})),...r]}})},showAllModels:t=>{e(e=>({hiddenModels:e.hiddenModels.filter(e=>e.providerID!==t)}))},toggleModelProviderCollapsed:t=>{let n=typeof t==`string`?t.trim():``;n&&e(e=>e.collapsedModelProviders.includes(n)?{collapsedModelProviders:e.collapsedModelProviders.filter(e=>e!==n)}:{collapsedModelProviders:[...e.collapsedModelProviders,n]})},setModelProvidersCollapsed:(t,n)=>{let r=Array.from(new Set(t.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean)));r.length!==0&&e(e=>{let t=new Set(r),i=e.collapsedModelProviders.filter(e=>!t.has(e));return{collapsedModelProviders:n?[...i,...r]:i}})},isFavoriteModel:(e,n)=>{let{favoriteModels:r}=t();return r.some(t=>t.providerID===e&&t.modelID===n)},addRecentModel:(t,n)=>{e(e=>{let r=e.recentModels.filter(e=>e.providerID!==t||e.modelID!==n);return{recentModels:[{providerID:t,modelID:n},...r].slice(0,5)}})},addRecentAgent:t=>{let n=typeof t==`string`?t.trim():``;n&&e(e=>{if(e.recentAgents.includes(n))return e;let t=e.recentAgents;return{recentAgents:[n,...t].slice(0,5)}})},addRecentEffort:(t,n,r)=>{let i=typeof t==`string`?t.trim():``,a=typeof n==`string`?n.trim():``;if(!i||!a)return;let o=`${i}/${a}`,s=typeof r==`string`&&r.trim().length>0?r.trim():`default`;e(e=>{let t=e.recentEfforts[o]??[];if(t.includes(s))return e;let n=t;return{recentEfforts:{...e.recentEfforts,[o]:[s,...n].slice(0,5)}}})},updateProportionalSidebarWidths:()=>{typeof window>`u`||e(e=>{let t={};if(e.isBottomTerminalOpen&&!e.hasManuallyResizedBottomTerminal){let n=Math.floor(window.innerHeight*.32);e.bottomTerminalHeight!==n&&(t.bottomTerminalHeight=n)}return Object.keys(t).length>0?t:e})},applyTheme:()=>{let{theme:e}=t(),n=document.documentElement;if(n.classList.remove(`light`,`dark`),e===`system`){let e=window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`;n.classList.add(e)}else n.classList.add(e)},setMultiRunLauncherOpen:t=>{e({isMultiRunLauncherOpen:t})},openMultiRunLauncher:()=>{e({isMultiRunLauncherOpen:!0,isSessionSwitcherOpen:!1})},setTimelineDialogOpen:t=>{e({isTimelineDialogOpen:t})},setPromptNavigatorPanelOpen:t=>{e({isPromptNavigatorPanelOpen:t})},togglePromptNavigatorPanel:()=>{e(e=>({isPromptNavigatorPanelOpen:!e.isPromptNavigatorPanelOpen}))},setImagePreviewOpen:t=>{e({isImagePreviewOpen:t})},setNativeNotificationsEnabled:t=>{e({nativeNotificationsEnabled:t})},setNotificationMode:t=>{e({notificationMode:t})},setShowTerminalQuickKeysOnDesktop:t=>{e({showTerminalQuickKeysOnDesktop:t})},setNotifyOnSubtasks:t=>{e({notifyOnSubtasks:t})},setDockBadgeEnabled:t=>{e({dockBadgeEnabled:t})},setNotifyOnCompletion:t=>{e({notifyOnCompletion:t})},setNotifyOnError:t=>{e({notifyOnError:t})},setNotifyOnQuestion:t=>{e({notifyOnQuestion:t})},setNotificationTemplates:t=>{e({notificationTemplates:t})},setSummarizeLastMessage:t=>{e({summarizeLastMessage:t})},setSummaryThreshold:t=>{e({summaryThreshold:t})},setSummaryLength:t=>{e({summaryLength:t})},setMaxLastMessageLength:t=>{e({maxLastMessageLength:t})},setPersistChatDraft:t=>{e({persistChatDraft:t})},setShowOpenCodeUpdateNotifications:t=>{e({showOpenCodeUpdateNotifications:t})},setInputSpellcheckEnabled:t=>{e({inputSpellcheckEnabled:t})},setWideChatLayoutEnabled:t=>{e({wideChatLayoutEnabled:t})},setCodeBlockLineWrap:t=>{e({codeBlockLineWrap:t})},setShowToolFileIcons:t=>{e({showToolFileIcons:t})},setShowTurnChangedFiles:t=>{e({showTurnChangedFiles:t})},setShowExpandedBashTools:t=>{e({showExpandedBashTools:t})},setShowSubagentTaskDetails:t=>{e({showSubagentTaskDetails:t})},setTimeFormatPreference:t=>{e({timeFormatPreference:t})},setWeekStartPreference:t=>{e({weekStartPreference:t})},setDesktopWindowControlsPosition:t=>{e({desktopWindowControlsPosition:t})},setMermaidRenderingMode:t=>{e({mermaidRenderingMode:t})},setUserMessageRenderingMode:t=>{e({userMessageRenderingMode:t})},setCollapsibleUserMessages:t=>{e({collapsibleUserMessages:t})},setStickyUserHeader:t=>{e({stickyUserHeader:t})},setPromptNavigatorEnabled:t=>{e({promptNavigatorEnabled:t})},setExpandedEditorToolbar:t=>{e({expandedEditorToolbar:t})},setShowSplitAssistantMessageActions:t=>{e({showSplitAssistantMessageActions:t})},setShowAssistantTps:t=>{e({showAssistantTps:t})},setAllowPromptingSubagentSessions:t=>{e({allowPromptingSubagentSessions:t})},setIsMobileSessionStatusBarCollapsed:t=>{e({isMobileSessionStatusBarCollapsed:t})},setMobileSessionPanelOpen:t=>{e({mobileSessionPanelOpen:t})},setMobileSessionFilterProjectId:t=>{e({mobileSessionFilterProjectId:t})},setReportUsage:t=>{e({reportUsage:t})},viewPagerPage:`center`,setViewPagerPage:t=>{e({viewPagerPage:t}),e(t===`left`?{isSessionSwitcherOpen:!0,isRightSidebarOpen:!1}:t===`right`?{isRightSidebarOpen:!0,isSessionSwitcherOpen:!1}:{isSessionSwitcherOpen:!1,isRightSidebarOpen:!1})},setShortcutOverride:(t,n)=>{e(e=>({shortcutOverrides:{...e.shortcutOverrides,[t]:n}}))},clearShortcutOverride:t=>{e(e=>{let n={...e.shortcutOverrides};return delete n[t],{shortcutOverrides:n}})},resetAllShortcutOverrides:()=>{e({shortcutOverrides:{}})},setFileEditorKeymap:t=>{e({fileEditorKeymap:lr(t)})},toggleExpandedInput:()=>{e(e=>({isExpandedInput:!e.isExpandedInput}))},setExpandedInput:t=>{e({isExpandedInput:t})}}),{name:`ui-store`,storage:Dn(),version:12,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n=e;if(In(n,t),t<11&&n.sidebarWidth===280&&(n.sidebarWidth=Y),t<10&&delete n.diffViewMode,t<9&&((typeof n.notesPanelHeight!=`number`||!Number.isFinite(n.notesPanelHeight))&&(n.notesPanelHeight=112),(typeof n.todoPanelHeight!=`number`||!Number.isFinite(n.todoPanelHeight))&&(n.todoPanelHeight=259)),t<1&&fr(n.notificationTemplates)&&(n.notificationTemplates={completion:{...J.completion},error:{...J.error},question:{...J.question},subtask:{...J.subtask}}),t<3){let e=new Set([90,120,180,220]),t=n.memoryLimitHistorical,r=n.memoryLimitActiveSession;typeof t==`number`&&!e.has(t)?n.messageLimit=t:typeof r==`number`&&!e.has(r)&&(n.messageLimit=r),delete n.memoryLimitHistorical,delete n.memoryLimitViewport,delete n.memoryLimitActiveSession}if((typeof n.rightSidebarTab!=`string`||n.rightSidebarTab!==`git`&&n.rightSidebarTab!==`files`&&n.rightSidebarTab!==`context`)&&(n.rightSidebarTab=`git`),n.contextPanelByDirectory=Rr(n.contextPanelByDirectory),t<5)if(!n.shortcutOverrides||typeof n.shortcutOverrides!=`object`)n.shortcutOverrides={};else{let e=n.shortcutOverrides,t={};for(let[n,r]of Object.entries(e))typeof n==`string`&&typeof r==`string`&&(t[n]=r);n.shortcutOverrides=t}return t<6&&(n.contextPanelByDirectory=Rr(n.contextPanelByDirectory)),t<7&&(n.contextPanelByDirectory=Rr(n.contextPanelByDirectory)),t<8&&n.gitChangesViewMode!==`flat`&&n.gitChangesViewMode!==`tree`&&(n.gitChangesViewMode=`tree`),n.fileEditorKeymap=lr(n.fileEditorKeymap),n},partialize:e=>({theme:e.theme,isSidebarOpen:e.isSidebarOpen,sidebarWidth:e.sidebarWidth,isRightSidebarOpen:e.isRightSidebarOpen,rightSidebarWidth:e.rightSidebarWidth,rightSidebarTab:e.rightSidebarTab,contextPanelByDirectory:e.contextPanelByDirectory,isBottomTerminalOpen:e.isBottomTerminalOpen,isBottomTerminalExpanded:e.isBottomTerminalExpanded,bottomTerminalHeight:e.bottomTerminalHeight,notesPanelHeight:e.notesPanelHeight,todoPanelHeight:e.todoPanelHeight,isSessionSwitcherOpen:e.isSessionSwitcherOpen,activeMainTab:e.activeMainTab,sidebarSection:e.sidebarSection,settingsPage:e.settingsPage,settingsHasOpenedOnce:e.settingsHasOpenedOnce,settingsProjectsSelectedId:e.settingsProjectsSelectedId,settingsRemoteInstancesSelectedId:e.settingsRemoteInstancesSelectedId,isSessionCreateDialogOpen:e.isSessionCreateDialogOpen,showReasoningTraces:e.showReasoningTraces,sessionRecapEnabled:e.sessionRecapEnabled,sessionTitleRefreshEnabled:e.sessionTitleRefreshEnabled,sessionGoalEnabled:e.sessionGoalEnabled,sessionGoalDefaultBudgetEnabled:e.sessionGoalDefaultBudgetEnabled,sessionGoalDefaultBudget:e.sessionGoalDefaultBudget,collapsibleThinkingBlocks:e.collapsibleThinkingBlocks,chatRenderMode:e.chatRenderMode,activityRenderMode:e.activityRenderMode,showDeletionDialog:e.showDeletionDialog,autoDeleteEnabled:e.autoDeleteEnabled,autoDeleteAfterDays:e.autoDeleteAfterDays,sessionRetentionAction:e.sessionRetentionAction,autoDeleteLastRunAt:e.autoDeleteLastRunAt,messageLimit:e.messageLimit,fontSize:e.fontSize,codeFontSize:e.codeFontSize,globalDraftStarters:e.globalDraftStarters,terminalFontSize:e.terminalFontSize,editorFontSize:e.editorFontSize,uiFont:e.uiFont,monoFont:e.monoFont,padding:e.padding,cornerRadius:e.cornerRadius,favoriteModels:e.favoriteModels,hiddenModels:e.hiddenModels,providerOrder:e.providerOrder,collapsedModelProviders:e.collapsedModelProviders,recentModels:e.recentModels,recentAgents:e.recentAgents,recentEfforts:e.recentEfforts,diffLayoutPreference:e.diffLayoutPreference,diffWrapLines:e.diffWrapLines,gitChangesViewMode:e.gitChangesViewMode,nativeNotificationsEnabled:e.nativeNotificationsEnabled,notificationMode:e.notificationMode,showTerminalQuickKeysOnDesktop:e.showTerminalQuickKeysOnDesktop,notifyOnSubtasks:e.notifyOnSubtasks,dockBadgeEnabled:e.dockBadgeEnabled,notifyOnCompletion:e.notifyOnCompletion,notifyOnError:e.notifyOnError,notifyOnQuestion:e.notifyOnQuestion,notificationTemplates:e.notificationTemplates,summarizeLastMessage:e.summarizeLastMessage,summaryThreshold:e.summaryThreshold,summaryLength:e.summaryLength,maxLastMessageLength:e.maxLastMessageLength,persistChatDraft:e.persistChatDraft,showOpenCodeUpdateNotifications:e.showOpenCodeUpdateNotifications,inputSpellcheckEnabled:e.inputSpellcheckEnabled,wideChatLayoutEnabled:e.wideChatLayoutEnabled,codeBlockLineWrap:e.codeBlockLineWrap,showToolFileIcons:e.showToolFileIcons,showTurnChangedFiles:e.showTurnChangedFiles,showExpandedBashTools:e.showExpandedBashTools,showSubagentTaskDetails:e.showSubagentTaskDetails,timeFormatPreference:e.timeFormatPreference,weekStartPreference:e.weekStartPreference,desktopWindowControlsPosition:e.desktopWindowControlsPosition,mermaidRenderingMode:e.mermaidRenderingMode,userMessageRenderingMode:e.userMessageRenderingMode,collapsibleUserMessages:e.collapsibleUserMessages,stickyUserHeader:e.stickyUserHeader,promptNavigatorEnabled:e.promptNavigatorEnabled,expandedEditorToolbar:e.expandedEditorToolbar,showSplitAssistantMessageActions:e.showSplitAssistantMessageActions,showAssistantTps:e.showAssistantTps,allowPromptingSubagentSessions:e.allowPromptingSubagentSessions,isMobileSessionStatusBarCollapsed:e.isMobileSessionStatusBarCollapsed,mobileSessionFilterProjectId:e.mobileSessionFilterProjectId,shortcutOverrides:e.shortcutOverrides,fileEditorKeymap:e.fileEditorKeymap})}),{name:`ui-store`}));export{Re as $,ln as A,Ze as B,Jt as C,mn as D,gn as E,Gt as F,ot as G,ct as H,Kt as I,Ge as J,st as K,Dt as L,vn as M,qt as N,_n as O,Ut as P,Ue as Q,kt as R,Mn as S,hn as T,yt as U,lt as V,vt as W,Be as X,Ve as Y,He as Z,Un as _,rr as a,Nn as b,Zn as c,Jn as d,Ae as et,$n as f,Wn as g,zn as h,sr as i,yn as j,cn as k,Xn as l,Ln as m,cr as n,ye as nt,Kn as o,Qn as p,Ot as q,ir as r,Yn as s,Hr as t,ve as tt,Gn as u,Vn as v,pn as w,Fn as x,Dn as y,G as z};
|
package/dist/assets/{useWorkerHighlightedLines-ADgu9578.js → useWorkerHighlightedLines-Cnxz7HaG.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{_ as t}from"./useUIStore-D6BTB4va.js";import{$t as n,kn as r,xn as i}from"./persistence-C_KCiMcY.js";import{nt as a,rt as o}from"./vendor-base-ui-CnHfUmDN.js";import{a as s,n as c}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as l}from"./vendor-react-DLPElpoQ.js";import{n as u}from"./clipboard-CXWbHCAk.js";import{Co as d}from"./useMobileNavigationStore-1xHjnAsg.js";import{t as f}from"./utils-DyUyiLje.js";import{n as p}from"./Icon-BPJ_quEe.js";import{t as m}from"./button-BmNJBT13.js";import{i as h,n as g,t as _}from"./tooltip-BYGBBTc2.js";import{n as v}from"./useThemeSystem-DMzWVJaW.js";import{c as y,n as b,o as x,r as S,s as C}from"./markdownTheme-CCnvI6L0.js";import{i as w}from"./appThemeRegistry-BXeIggYO.js";import{d as T,n as E,t as D,u as ee}from"./markdown-worker-Cq3Twp1A.js";import{t as te}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";var O=e(o(),1),k=l(),A=a(),ne=`w-[min(30rem,calc(100cqw-1rem))] min-w-[280px] max-w-full overflow-hidden rounded-xl shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,j={maxWidth:`min(28rem, calc(100cqw - 4ch))`,backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`},M=`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] px-3 py-2.5`,N=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,re=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,P=`m-0 list-none divide-y divide-[var(--surface-subtle)] p-0`,F=`${P} max-h-[min(22rem,50vh)] overflow-y-auto`,ie=`${P} w-full`,ae={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},I=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,oe=`flex min-w-0 items-center gap-1 text-xs leading-4 text-muted-foreground md:gap-1.5 md:text-[0.8125rem] md:leading-5`,se=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,ce=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,le=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,ue={in_progress:`text-foreground`,pending:`text-foreground`,completed:`text-muted-foreground line-through`,cancelled:`text-muted-foreground line-through`},L={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},R=e=>{let t=(0,k.c)(26),{todo:n,isActive:r,activeRef:i}=e,{t:a}=u(),o=z.has(n.status)?n.status:`pending`,s=L[o],c;t[0]!==a||t[1]!==s?(c=a(s),t[0]=a,t[1]=s,t[2]=c):c=t[2];let l=c,d;t[3]===o?d=t[4]:(d=o===`in_progress`?(0,A.jsx)(p,{name:`record-circle`,className:`h-3.5 w-3.5 text-[var(--status-info)]`,"aria-hidden":`true`}):o===`completed`?(0,A.jsx)(p,{name:`checkbox-circle`,className:`h-3.5 w-3.5 text-[var(--status-success)]`,"aria-hidden":`true`}):(0,A.jsx)(p,{name:`time`,className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),t[3]=o,t[4]=d);let m=d,v=r?`step`:void 0,y=r&&`bg-[var(--surface-muted)] before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-[var(--status-info)]`,b;t[5]===y?b=t[6]:(b=f(`group relative grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5`,I,y),t[5]=y,t[6]=b);let x;t[7]!==m||t[8]!==l?(x=(0,A.jsx)(h,{asChild:!0,children:(0,A.jsx)(`span`,{className:`flex size-4 items-center justify-center`,"aria-label":l,children:m})}),t[7]=m,t[8]=l,t[9]=x):x=t[9];let S;t[10]===l?S=t[11]:(S=(0,A.jsx)(g,{side:`left`,sideOffset:6,children:l}),t[10]=l,t[11]=S);let C;t[12]!==x||t[13]!==S?(C=(0,A.jsxs)(_,{children:[x,S]}),t[12]=x,t[13]=S,t[14]=C):C=t[14];let w=ue[o],T;t[15]===w?T=t[16]:(T=f(`block whitespace-normal break-words`,w),t[15]=w,t[16]=T);let E;t[17]!==T||t[18]!==n.content?(E=(0,A.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,A.jsx)(`span`,{className:T,children:n.content})}),t[17]=T,t[18]=n.content,t[19]=E):E=t[19];let D;return t[20]!==i||t[21]!==E||t[22]!==v||t[23]!==b||t[24]!==C?(D=(0,A.jsxs)(`li`,{ref:i,"aria-current":v,className:b,children:[C,E]}),t[20]=i,t[21]=E,t[22]=v,t[23]=b,t[24]=C,t[25]=D):D=t[25],D},z=new Set([`in_progress`,`pending`,`completed`,`cancelled`]),B=`image/png`,V=s(`OpenChamberMedia`),H=e=>{let t=e.toLowerCase().split(`;`)[0]?.trim()||B;if(t===`image/jpeg`||t===`image/jpg`)return`jpg`;if(t===`image/webp`)return`webp`;if(t===`image/gif`)return`gif`;if(t===`image/svg+xml`)return`svg`;if(t===`image/png`)return`png`;let n=t.split(`/`)[1];return n&&/^[a-z0-9.+-]+$/i.test(n)?n:`png`},U=(e,t)=>{let n=`image.${H(t)}`,r=(((e||``).trim()||n).split(/[\\/]/).pop()||n).replace(/[^\w.\- ()[\]]+/g,`_`).replace(/^\.+/,``);return r?/\.[a-z0-9]{1,8}$/i.test(r)?r:`${r}.${H(t)}`:n},W=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{if(typeof r.result==`string`){t(r.result);return}n(Error(`Failed to encode image`))},r.onerror=()=>n(r.error??Error(`Failed to encode image`)),r.readAsDataURL(e)}),de=async e=>{let t=await W(e),n=t.indexOf(`,`);return n>=0?t.slice(n+1):t},fe=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.setTimeout(()=>URL.revokeObjectURL(n),1e3)},G=async(e,t)=>{let n=await fetch(e,{signal:t,cache:`no-store`});if(!n.ok)throw Error(`Image fetch failed (${n.status})`);return n.blob()},pe=async(e,t=B)=>{if(!e.naturalWidth||!e.naturalHeight)return null;let n=e.currentSrc||e.src;if(n&&(/^(?:blob:|data:|openchamber-asset:)/i.test(n)||/^https?:/i.test(n)||/^\/api(?=\/|[?#]|$)/.test(n)))try{let e=await G(n);if(e.size>0)return e}catch{}try{let n=document.createElement(`canvas`);n.width=e.naturalWidth,n.height=e.naturalHeight;let r=n.getContext(`2d`);if(!r)return null;r.drawImage(e,0,0);let i=t.startsWith(`image/`)?t:B,a=await new Promise(e=>{n.toBlob(t=>e(t),i===`image/jpg`?`image/jpeg`:i)});return a&&a.size>0?a:null}catch{return null}},me=async(e,t)=>{let n=``;try{return n=await S(e,t??new AbortController().signal),await G(n,t)}finally{n&&C(n)}},he=async(e,t)=>{let n=e.effectiveDirectory??``,i=null;e.prefetchedBlob&&e.prefetchedBlob.size>0&&(i=e.prefetchedBlob);let a=e.displayUrl?.trim();if(!i&&a)try{i=await G(a,t)}catch{i=null}if(!i){let a=e.sourceUrl.trim();if(!a)throw Error(`Image source is empty`);if(/^(?:data|blob):/i.test(a)||/^https?:/i.test(a)||/^\/api(?=\/|[?#]|$)/.test(a))i=await G(a,t);else{let e=y(a,n);if(x(e))try{i=await me(e.path,t)}catch{let n=await r(`/api/fs/raw`,{method:`GET`,cache:`no-store`,query:{path:e.path},signal:t});if(!n.ok)throw Error(`Image source request failed with status ${n.status}`);i=await n.blob()}else i=await G(e.source,t)}}if(!i||i.size<=0)throw Error(`Image is empty`);let o=(e.mimeType||(i.type&&i.type.startsWith(`image/`)?i.type:``)||B).split(`;`)[0].trim()||B;return{blob:i,filename:U(e.filename,o),mimeType:o}},ge=()=>!d()||c===void 0?!1:c.isPluginAvailable(`OpenChamberMedia`),_e=async(e,t)=>{let{blob:r,filename:a,mimeType:o}=await he(e,t);if(ge()){let e=await de(r);return await V.saveImage({dataBase64:e,mimeType:o,filename:a}),`saved`}if(n()){let e=i()?.vscode;if(e?.saveImage){let t=await W(r);return await e.saveImage({fileName:a,dataUrl:t}),`saved`}}return fe(r,a),`downloaded`},ve=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),ye=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,K=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=ye(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},be=e=>`<pre><code>${ve(e)}</code></pre>`,xe=e=>{let t=(0,k.c)(21),{code:n,language:r,className:i,style:a,codeStyle:o,wrap:s}=e,c=s!==void 0&&s,{currentTheme:l}=v(),u=O.useRef(null),d;t[0]===l?d=t[1]:(d=b(l),t[0]=l,t[1]=d);let p=d,m,h;t[2]!==n||t[3]!==o||t[4]!==c?(m=()=>{let e=u.current;e&&(e.innerHTML=be(n),K(e,c,o))},h=[n,c,o],t[2]=n,t[3]=o,t[4]=c,t[5]=m,t[6]=h):(m=t[5],h=t[6]),O.useLayoutEffect(m,h);let g,_;t[7]!==n||t[8]!==o||t[9]!==r||t[10]!==c?(g=()=>{let e=u.current;if(!e)return;let t=!0,i=new AbortController;return D(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,K(e,c,o))}),()=>{t=!1,i.abort()}},_=[n,r,c,o],t[7]=n,t[8]=o,t[9]=r,t[10]=c,t[11]=g,t[12]=_):(g=t[11],_=t[12]),O.useEffect(g,_);let y;t[13]===i?y=t[14]:(y=f(`typography-code`,i),t[13]=i,t[14]=y);let x=p,S;t[15]!==a||t[16]!==x?(S={...x,...a},t[15]=a,t[16]=x,t[17]=S):S=t[17];let C;return t[18]!==y||t[19]!==S?(C=(0,A.jsx)(`div`,{ref:u,className:y,style:S}),t[18]=y,t[19]=S,t[20]=C):C=t[20],C},Se=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},Ce=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},we=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,Te=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,Ee=(e,t)=>!e||typeof e!=`object`?String(e):T(e,t||``),q=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},De=e=>{if(!e||typeof e!=`object`)return;let t=q(e.patch)??q(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=q(e.patch)??q(e.diff);if(t)return t}},Oe=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},ke=(e,t,n)=>{let r=Se(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&we(r)&&(r=Te(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=De(n);if(e)return e}return r},Ae=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{_ as t}from"./useUIStore-5agS8bsW.js";import{$t as n,kn as r,xn as i}from"./persistence-DPNMIbF5.js";import{nt as a,rt as o}from"./vendor-base-ui-CnHfUmDN.js";import{a as s,n as c}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as l}from"./vendor-react-DLPElpoQ.js";import{n as u}from"./clipboard-Jdqe05db.js";import{ko as d}from"./useMobileNavigationStore-kWPnKBP1.js";import{t as f}from"./utils-Co19EJEL.js";import{n as p}from"./Icon-AXqa-fYB.js";import{t as m}from"./button-CDvMVaiO.js";import{i as h,n as g,t as _}from"./tooltip-DMNR5rN0.js";import{n as v}from"./useThemeSystem-DMzWVJaW.js";import{c as y,n as b,o as x,r as S,s as C}from"./markdownTheme-DNT93i5L.js";import{i as w}from"./appThemeRegistry--wNZ5yxf.js";import{d as T,n as E,t as D,u as ee}from"./markdown-worker-DkeWiER6.js";import{t as te}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";var O=e(o(),1),k=l(),A=a(),ne=`w-[min(30rem,calc(100cqw-1rem))] min-w-[280px] max-w-full overflow-hidden rounded-xl shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,j={maxWidth:`min(28rem, calc(100cqw - 4ch))`,backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`},M=`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] px-3 py-2.5`,N=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,re=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,P=`m-0 list-none divide-y divide-[var(--surface-subtle)] p-0`,F=`${P} max-h-[min(22rem,50vh)] overflow-y-auto`,ie=`${P} w-full`,ae={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},I=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,oe=`flex min-w-0 items-center gap-1 text-xs leading-4 text-muted-foreground md:gap-1.5 md:text-[0.8125rem] md:leading-5`,se=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,ce=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,le=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,ue={in_progress:`text-foreground`,pending:`text-foreground`,completed:`text-muted-foreground line-through`,cancelled:`text-muted-foreground line-through`},L={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},R=e=>{let t=(0,k.c)(26),{todo:n,isActive:r,activeRef:i}=e,{t:a}=u(),o=z.has(n.status)?n.status:`pending`,s=L[o],c;t[0]!==a||t[1]!==s?(c=a(s),t[0]=a,t[1]=s,t[2]=c):c=t[2];let l=c,d;t[3]===o?d=t[4]:(d=o===`in_progress`?(0,A.jsx)(p,{name:`record-circle`,className:`h-3.5 w-3.5 text-[var(--status-info)]`,"aria-hidden":`true`}):o===`completed`?(0,A.jsx)(p,{name:`checkbox-circle`,className:`h-3.5 w-3.5 text-[var(--status-success)]`,"aria-hidden":`true`}):(0,A.jsx)(p,{name:`time`,className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),t[3]=o,t[4]=d);let m=d,v=r?`step`:void 0,y=r&&`bg-[var(--surface-muted)] before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-[var(--status-info)]`,b;t[5]===y?b=t[6]:(b=f(`group relative grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5`,I,y),t[5]=y,t[6]=b);let x;t[7]!==m||t[8]!==l?(x=(0,A.jsx)(h,{asChild:!0,children:(0,A.jsx)(`span`,{className:`flex size-4 items-center justify-center`,"aria-label":l,children:m})}),t[7]=m,t[8]=l,t[9]=x):x=t[9];let S;t[10]===l?S=t[11]:(S=(0,A.jsx)(g,{side:`left`,sideOffset:6,children:l}),t[10]=l,t[11]=S);let C;t[12]!==x||t[13]!==S?(C=(0,A.jsxs)(_,{children:[x,S]}),t[12]=x,t[13]=S,t[14]=C):C=t[14];let w=ue[o],T;t[15]===w?T=t[16]:(T=f(`block whitespace-normal break-words`,w),t[15]=w,t[16]=T);let E;t[17]!==T||t[18]!==n.content?(E=(0,A.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,A.jsx)(`span`,{className:T,children:n.content})}),t[17]=T,t[18]=n.content,t[19]=E):E=t[19];let D;return t[20]!==i||t[21]!==E||t[22]!==v||t[23]!==b||t[24]!==C?(D=(0,A.jsxs)(`li`,{ref:i,"aria-current":v,className:b,children:[C,E]}),t[20]=i,t[21]=E,t[22]=v,t[23]=b,t[24]=C,t[25]=D):D=t[25],D},z=new Set([`in_progress`,`pending`,`completed`,`cancelled`]),B=`image/png`,V=s(`OpenChamberMedia`),H=e=>{let t=e.toLowerCase().split(`;`)[0]?.trim()||B;if(t===`image/jpeg`||t===`image/jpg`)return`jpg`;if(t===`image/webp`)return`webp`;if(t===`image/gif`)return`gif`;if(t===`image/svg+xml`)return`svg`;if(t===`image/png`)return`png`;let n=t.split(`/`)[1];return n&&/^[a-z0-9.+-]+$/i.test(n)?n:`png`},U=(e,t)=>{let n=`image.${H(t)}`,r=(((e||``).trim()||n).split(/[\\/]/).pop()||n).replace(/[^\w.\- ()[\]]+/g,`_`).replace(/^\.+/,``);return r?/\.[a-z0-9]{1,8}$/i.test(r)?r:`${r}.${H(t)}`:n},W=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{if(typeof r.result==`string`){t(r.result);return}n(Error(`Failed to encode image`))},r.onerror=()=>n(r.error??Error(`Failed to encode image`)),r.readAsDataURL(e)}),de=async e=>{let t=await W(e),n=t.indexOf(`,`);return n>=0?t.slice(n+1):t},fe=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.setTimeout(()=>URL.revokeObjectURL(n),1e3)},G=async(e,t)=>{let n=await fetch(e,{signal:t,cache:`no-store`});if(!n.ok)throw Error(`Image fetch failed (${n.status})`);return n.blob()},pe=async(e,t=B)=>{if(!e.naturalWidth||!e.naturalHeight)return null;let n=e.currentSrc||e.src;if(n&&(/^(?:blob:|data:|openchamber-asset:)/i.test(n)||/^https?:/i.test(n)||/^\/api(?=\/|[?#]|$)/.test(n)))try{let e=await G(n);if(e.size>0)return e}catch{}try{let n=document.createElement(`canvas`);n.width=e.naturalWidth,n.height=e.naturalHeight;let r=n.getContext(`2d`);if(!r)return null;r.drawImage(e,0,0);let i=t.startsWith(`image/`)?t:B,a=await new Promise(e=>{n.toBlob(t=>e(t),i===`image/jpg`?`image/jpeg`:i)});return a&&a.size>0?a:null}catch{return null}},me=async(e,t)=>{let n=``;try{return n=await S(e,t??new AbortController().signal),await G(n,t)}finally{n&&C(n)}},he=async(e,t)=>{let n=e.effectiveDirectory??``,i=null;e.prefetchedBlob&&e.prefetchedBlob.size>0&&(i=e.prefetchedBlob);let a=e.displayUrl?.trim();if(!i&&a)try{i=await G(a,t)}catch{i=null}if(!i){let a=e.sourceUrl.trim();if(!a)throw Error(`Image source is empty`);if(/^(?:data|blob):/i.test(a)||/^https?:/i.test(a)||/^\/api(?=\/|[?#]|$)/.test(a))i=await G(a,t);else{let e=y(a,n);if(x(e))try{i=await me(e.path,t)}catch{let n=await r(`/api/fs/raw`,{method:`GET`,cache:`no-store`,query:{path:e.path},signal:t});if(!n.ok)throw Error(`Image source request failed with status ${n.status}`);i=await n.blob()}else i=await G(e.source,t)}}if(!i||i.size<=0)throw Error(`Image is empty`);let o=(e.mimeType||(i.type&&i.type.startsWith(`image/`)?i.type:``)||B).split(`;`)[0].trim()||B;return{blob:i,filename:U(e.filename,o),mimeType:o}},ge=()=>!d()||c===void 0?!1:c.isPluginAvailable(`OpenChamberMedia`),_e=async(e,t)=>{let{blob:r,filename:a,mimeType:o}=await he(e,t);if(ge()){let e=await de(r);return await V.saveImage({dataBase64:e,mimeType:o,filename:a}),`saved`}if(n()){let e=i()?.vscode;if(e?.saveImage){let t=await W(r);return await e.saveImage({fileName:a,dataUrl:t}),`saved`}}return fe(r,a),`downloaded`},ve=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),ye=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,K=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=ye(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},be=e=>`<pre><code>${ve(e)}</code></pre>`,xe=e=>{let t=(0,k.c)(21),{code:n,language:r,className:i,style:a,codeStyle:o,wrap:s}=e,c=s!==void 0&&s,{currentTheme:l}=v(),u=O.useRef(null),d;t[0]===l?d=t[1]:(d=b(l),t[0]=l,t[1]=d);let p=d,m,h;t[2]!==n||t[3]!==o||t[4]!==c?(m=()=>{let e=u.current;e&&(e.innerHTML=be(n),K(e,c,o))},h=[n,c,o],t[2]=n,t[3]=o,t[4]=c,t[5]=m,t[6]=h):(m=t[5],h=t[6]),O.useLayoutEffect(m,h);let g,_;t[7]!==n||t[8]!==o||t[9]!==r||t[10]!==c?(g=()=>{let e=u.current;if(!e)return;let t=!0,i=new AbortController;return D(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,K(e,c,o))}),()=>{t=!1,i.abort()}},_=[n,r,c,o],t[7]=n,t[8]=o,t[9]=r,t[10]=c,t[11]=g,t[12]=_):(g=t[11],_=t[12]),O.useEffect(g,_);let y;t[13]===i?y=t[14]:(y=f(`typography-code`,i),t[13]=i,t[14]=y);let x=p,S;t[15]!==a||t[16]!==x?(S={...x,...a},t[15]=a,t[16]=x,t[17]=S):S=t[17];let C;return t[18]!==y||t[19]!==S?(C=(0,A.jsx)(`div`,{ref:u,className:y,style:S}),t[18]=y,t[19]=S,t[20]=C):C=t[20],C},Se=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},Ce=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},we=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,Te=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,Ee=(e,t)=>!e||typeof e!=`object`?String(e):T(e,t||``),q=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},De=e=>{if(!e||typeof e!=`object`)return;let t=q(e.patch)??q(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=q(e.patch)??q(e.diff);if(t)return t}},Oe=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},ke=(e,t,n)=>{let r=Se(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&we(r)&&(r=Te(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=De(n);if(e)return e}return r},Ae=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
|
|
2
2
|
`).split(`
|
|
3
3
|
`),r=e=>/\(\s*File has more lines\..*offset.*\)/i.test(e.trim());return{type:t,lines:n.map(e=>{let n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);if(t!==`directory`){let t=e.match(/^(\d+):\s?(.*)$/);if(t){let e=t[2],n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);return{lineNumber:i?null:Number(t[1]),text:e,isInfo:i}}}return{lineNumber:null,text:e,isInfo:i}}).filter((e,t,n)=>{if(e.text.trim().length>0)return!0;let r=n[t-1],i=n[t+1],a=!!(r?.isInfo||i?.isInfo),o=e.lineNumber!==null;return!(a&&o)})}},je=(e,n)=>{try{let r=e.trim().split(`
|
|
4
4
|
`).filter(Boolean);if(r.length===0)return null;let i=[];return r.forEach(e=>{let t=e.match(/^(\s*)(.+)$/);if(t){let[,e,n]=t,r=Math.floor(e.length/2),a=!n.endsWith(`/`);i.push({name:n.replace(/\/$/,``),depth:r,isFile:a})}}),(0,A.jsx)(`div`,{className:f(`w-full min-w-0 font-mono space-y-0.5`,n?.unstyled?null:`p-3 bg-muted/20 rounded-xl border border-border/30`),style:t.tool.popup,children:i.map((e,t)=>(0,A.jsx)(`div`,{className:`min-w-0`,style:{paddingLeft:`${e.depth*20}px`},children:e.isFile?(0,A.jsx)(`span`,{className:`text-foreground/90 block truncate`,children:e.name}):(0,A.jsxs)(`span`,{className:`font-semibold text-foreground block truncate`,children:[e.name,`/`]})},t))})}catch{return null}},Me={backgroundColor:`var(--status-info)`,opacity:.6},Ne=(e,n,r)=>{try{let i=e.trim().split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Xt as e}from"./persistence-
|
|
1
|
+
import{Xt as e}from"./persistence-DPNMIbF5.js";import{n as t}from"./vendor-class-variance-authority-BLUaYARZ.js";import{t as n}from"./vendor-tailwind-merge-BicNWLTg.js";function r(...e){return n(t(e))}var i=()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),a=()=>typeof navigator>`u`?!1:/Windows/.test(navigator.userAgent||``),o=()=>i()?`common.revealPath.finder`:a()?`common.revealPath.fileExplorer`:`common.revealPath.fileManager`,s=t=>i()&&e()?t.metaKey:t.ctrlKey,c=()=>i()&&e()?`⌘`:`Ctrl`,l=(e,t)=>{let n=e??``,r=Math.max(16,t?.maxLength??45);if(n.length<=r)return n;let i=n.split(`/`);if(i.length<=1)return n;let a=i.pop()??``;if(!a)return n;let o=Math.max(0,r-(a.length+2));if(o<=0)return`…/${a}`;let s=``;for(let e of i){if(!e)continue;let t=s?`${s}/${e}`:e;if(t.length>o)break;s=t}if(!s){let e=i[0]??``;s=e?e.slice(0,o):``}return s?`${s}…/${a}`:`…/${a}`},u=e=>e?e===`/`?`/`:e.replace(/\/+$/,``):``;function d(e,t){if(!e)return``;let n=u(e);if(n===`/`)return`/`;let r=t?u(t):void 0;if(r&&r!==`/`){if(n===r)return`~`;if(n.startsWith(`${r}/`)){let e=n.slice(r.length+1);return e?`~/${e}`:`~`}}return n}function f(e,t){if(!e)return`/`;let n=u(e);if(!n||n===`/`)return`/`;let r=t?u(t):void 0;return r&&r!==`/`&&n===r?`~`:n.split(`/`).pop()||n||`/`}export{o as a,l as c,c as i,f as n,s as o,d as r,i as s,r as t};
|