@openchambery/web 1.19.11 → 1.19.13-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-CX0a1rKE.js → AgentAvatar-CiQIIM0d.js} +1 -1
- package/dist/assets/AssistantView-YmeyxehG.js +2 -0
- package/dist/assets/{DiagramView-BQO1cBLs.js → DiagramView-BpZb-G9P.js} +1 -1
- package/dist/assets/{FadeInOnReveal-CTlNE4Hg.js → FadeInOnReveal-nf6-ZCrs.js} +1 -1
- package/dist/assets/{Icon-BYM02QyU.js → Icon-CeKHYyKZ.js} +1 -1
- package/dist/assets/MarkdownRenderer-wpeGdciL.js +2 -0
- package/dist/assets/{MarkdownRendererImpl--takeMXN.js → MarkdownRendererImpl-Peu0GVSQ.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-DGSqWcPN.js → MarkstreamRendererImpl-B-odd2Gz.js} +1 -1
- package/dist/assets/MobileDetailNavigation-CtYke_1C.js +1 -0
- package/dist/assets/{MobileShareBridge-D-BUjACe.js → MobileShareBridge-DIfOl8EZ.js} +3 -3
- package/dist/assets/MobileSurface-_KoX75Ff.js +2 -0
- package/dist/assets/{MultiRunWindow-BNR9ZWmD.js → MultiRunWindow-BT5Dwgzu.js} +1 -1
- package/dist/assets/{OnboardingScreen-DS2nugLX.js → OnboardingScreen-BPusUgFG.js} +1 -1
- package/dist/assets/{OverlayScrollbar-KUpvYHdv.js → OverlayScrollbar-DUghqFGg.js} +1 -1
- package/dist/assets/{SettingsView-DGerg-C2.js → SettingsView-BwQpbIZl.js} +11 -11
- package/dist/assets/{SettingsWindow-CSpd5JbJ.js → SettingsWindow-DfEGfyr8.js} +1 -1
- package/dist/assets/{TerminalView-DS-oUxJr.js → TerminalView-8402vpcO.js} +1 -1
- package/dist/assets/{ToolOutputDialog-Q1k9-IaY.js → ToolOutputDialog-B5RdkhsG.js} +1 -1
- package/dist/assets/{appThemeRegistry-CG7D-3-q.js → appThemeRegistry-CIZ-shMD.js} +1 -1
- package/dist/assets/{button-C0cth9tl.js → button-DFPOdZ0g.js} +1 -1
- package/dist/assets/{clipboard-DJ4nQEuY.js → clipboard-C05anBwU.js} +1 -1
- package/dist/assets/{collapsible-DFT9cE80.js → collapsible-oGbEvbe1.js} +1 -1
- package/dist/assets/{context-menu-CAp74NfV.js → context-menu-DGz4_2hs.js} +1 -1
- package/dist/assets/{desktopHosts-Dc2PS66M.js → desktopHosts-BVJXQq1S.js} +1 -1
- package/dist/assets/{desktopRelayRestore-T9y0orqa.js → desktopRelayRestore-RDfuj1M7.js} +1 -1
- package/dist/assets/{diagram-BryzMuta.js → diagram-Csk5GpDC.js} +1 -1
- package/dist/assets/{dialog-CgbV5ljg.js → dialog-rrqB-H6q.js} +1 -1
- package/dist/assets/{es-BHqnSjoZ.js → es-FE0sJ9EC.js} +1 -1
- package/dist/assets/{fileQueries-BY-9OWzp.js → fileQueries-BcdWOPlD.js} +1 -1
- package/dist/assets/{fr-BfrlJY9i.js → fr-DNDCSfGt.js} +1 -1
- package/dist/assets/{gitApi-Cr-joUEw.js → gitApi-_P0FsoXe.js} +1 -1
- package/dist/assets/{input-DFLpqjGR.js → input-BO3r20op.js} +1 -1
- package/dist/assets/{insertionBoundaries-X0xbikAA.js → insertionBoundaries-CWoioTdE.js} +1 -1
- package/dist/assets/{ja-DP-7qt-x.js → ja-BDwrk0cM.js} +1 -1
- package/dist/assets/{ko-E2B5vGQP.js → ko-BeeU2o4I.js} +1 -1
- package/dist/assets/{main-D0L7fIg3.js → main-CLj_WS1o.js} +2 -2
- package/dist/assets/{main-BI7fNQoi.js → main-CnSZ89pD.js} +4 -4
- package/dist/assets/{markdown-worker-CTsrtpPh.js → markdown-worker-CZWE1F1M.js} +1 -1
- package/dist/assets/{markdownHeightCache-CYDlisxr.js → markdownHeightCache-Cdd3hkMl.js} +1 -1
- package/dist/assets/{markdownTheme-DyJ4Gfcj.js → markdownTheme-DIB8WVmz.js} +1 -1
- package/dist/assets/miniChat-B9c3y2pD.js +2 -0
- package/dist/assets/{mobile-OcCu_0mG.js → mobile-DvbXUfNS.js} +2 -2
- package/dist/assets/{multirun-B0G_BEIN.js → multirun-CxhTsmRq.js} +1 -1
- package/dist/assets/{persistence-DdUac14I.js → persistence-CVTWFaqe.js} +2 -2
- package/dist/assets/{pl-r8X5gRM5.js → pl-BYuzpcI5.js} +1 -1
- package/dist/assets/{platform-B4KKLnZ5.js → platform-BY_Gtsqr.js} +1 -1
- package/dist/assets/{projectMeta-BNOzn1QS.js → projectMeta-Dl5iPCB6.js} +1 -1
- package/dist/assets/{pt-BR-DcpdXCf5.js → pt-BR-Bn7cwEzv.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-BREc3uhX.js → renderElectronMiniChatApp-CkJ51qCh.js} +2 -2
- package/dist/assets/renderMobileApp-DcjQPhWw.js +28 -0
- package/dist/assets/{runtimeConfig-P8nVMYzE.js → runtimeConfig-Bsk2kWsW.js} +1 -1
- package/dist/assets/runtimeEndpointReset-BBLFgl85.js +147 -0
- package/dist/assets/{sessionChangeSummary-hVby3sJk.js → sessionChangeSummary-DDVT7O5J.js} +1 -1
- package/dist/assets/{sessionLookup-C_9-9ggp.js → sessionLookup-C8VZn0gJ.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-C8_9kHqu.js → sortable-tabs-strip-s7UUxsa6.js} +1 -1
- package/dist/assets/src-BpHDMgud.css +2 -0
- package/dist/assets/{store-BDFdnk6l.js → store-n94dSb3M.js} +2 -2
- package/dist/assets/{terminalApi-947l7Ra3.js → terminalApi-C54_rKEK.js} +1 -1
- package/dist/assets/{textarea-Cgo_nWUU.js → textarea-BjX-KhMN.js} +1 -1
- package/dist/assets/{tooltip-BifLJ8o0.js → tooltip-CQGqGAG_.js} +1 -1
- package/dist/assets/{uk-Di0vl9V-.js → uk-CwpbHEa3.js} +1 -1
- package/dist/assets/{url-Pk6tQ1EZ.js → url-BMjqccCo.js} +1 -1
- package/dist/assets/{useAppFontEffects-CEmOsrr6.js → useAppFontEffects-BIFw36SA.js} +5 -5
- package/dist/assets/{useAssistantUIStore-me6s63b2.js → useAssistantUIStore-Cg9bsT4b.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-CxaK-zXh.js → useDesktopWindowControlsLayout-DoygEcN4.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-BIwv5r5l.js → useEffectiveDirectory-DJSYYkVp.js} +1 -1
- package/dist/assets/{useFontPreferences-BCOBlaAd.js → useFontPreferences-B5_apbBC.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-DHm5kZPx.js → useMobileNavigationStore-DuTu0Mzh.js} +5 -5
- package/dist/assets/{useSessionAutoCleanup-CPLP9KWH.js → useSessionAutoCleanup-C-L9teva.js} +1 -1
- package/dist/assets/{useUIStore-CuaA8-Hp.js → useUIStore-DwpQTjLO.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-CZ4ZTWEH.js → useWorkerHighlightedLines-DxTfgdEi.js} +1 -1
- package/dist/assets/{utils-BiK3tBGM.js → utils-81nUI_xp.js} +1 -1
- package/dist/assets/{zh-CN-coFCfeQE.js → zh-CN-BpzFZ-LU.js} +1 -1
- package/dist/assets/{zh-TW-oDRZ1-yb.js → zh-TW-Bopgc5Eo.js} +1 -1
- 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.js +19 -0
- package/server/lib/assistants/DOCUMENTATION.md +21 -6
- package/server/lib/assistants/assign.js +455 -30
- package/server/lib/assistants/assign.test.js +351 -0
- package/server/lib/assistants/contact-active-turn.http.test.js +134 -0
- package/server/lib/assistants/contact-store.js +64 -0
- package/server/lib/assistants/contact-store.test.js +12 -0
- package/server/lib/assistants/contact-tools.js +216 -25
- package/server/lib/assistants/contact-tools.test.js +167 -0
- package/server/lib/assistants/contracts.js +2 -2
- package/server/lib/assistants/harness.js +20 -3
- package/server/lib/assistants/harness.test.js +120 -1
- package/server/lib/assistants/pi-tools.js +50 -3
- package/server/lib/assistants/pi-tools.test.js +25 -0
- package/server/lib/assistants/service.js +320 -27
- package/server/lib/assistants/service.test.js +581 -9
- package/server/lib/llm/DOCUMENTATION.md +31 -18
- package/server/lib/llm/catalog.js +91 -16
- package/server/lib/llm/catalog.test.js +152 -11
- package/server/lib/llm/generate.js +43 -7
- package/server/lib/llm/generate.test.js +98 -1
- package/server/lib/llm/temp-directory.js +34 -13
- package/server/lib/llm/temp-directory.test.js +57 -0
- package/server/lib/notifications/APNS.md +20 -4
- package/server/lib/notifications/DOCUMENTATION.md +5 -0
- package/server/lib/notifications/apns-runtime.js +136 -18
- package/server/lib/notifications/apns-runtime.test.js +128 -0
- package/server/lib/notifications/apns-titles.js +21 -1
- package/server/lib/notifications/live-activity-refresh-runtime.js +185 -0
- package/server/lib/notifications/live-activity-refresh-runtime.test.js +242 -0
- package/server/lib/notifications/runtime.js +93 -2
- package/server/lib/notifications/runtime.test.js +167 -4
- package/server/lib/opencode/settings-helpers.js +12 -0
- package/server/lib/opencode/settings-runtime.js +16 -0
- package/server/lib/opencode/settings-runtime.test.js +21 -0
- package/server/lib/scheduled-tasks/runtime.js +21 -0
- package/server/lib/scheduled-tasks/runtime.test.js +24 -0
- package/dist/assets/AssistantView-BwrcqJzu.js +0 -2
- package/dist/assets/MarkdownRenderer-C49bfcHx.js +0 -2
- package/dist/assets/MobileDetailNavigation-LZU2vFAs.js +0 -1
- package/dist/assets/MobileSurface-OAJjAQCZ.js +0 -2
- package/dist/assets/miniChat-BJ9AclZX.js +0 -2
- package/dist/assets/renderMobileApp-C4igZ42L.js +0 -28
- package/dist/assets/runtimeEndpointReset-6lVRspis.js +0 -147
- package/dist/assets/src-B-P5qIBc.css +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,B as n,C as r,E as i,H as a,I as o,O as s,P as c,Q as l,S as u,T as d,b as f,f as p,i as m,p as h,r as g,rt as _,t as v,w as y,y as ee}from"./useUIStore-CuaA8-Hp.js";import{a as te,i as ne,r as re}from"./vendor-zustand-B4dlGEM2.js";import{rt as ie}from"./vendor-base-ui-CnHfUmDN.js";import{i as ae}from"./vendor-pathe-vBmvQE8f.js";import{n as oe}from"./vendor-react-DLPElpoQ.js";import{t as se}from"./vendor-tanstack-query-core-BWz0ose6.js";var b=e=>e.startsWith(`/api/`)||e===`/api`||e.startsWith(`/auth/`)||e===`/auth`||e===`/health`,ce=()=>typeof window>`u`?``:window.location.origin||``,le=e=>{if(typeof window>`u`)return!1;let t=ce();if(t&&e.origin===t)return!0;try{let n=new URL(window.location.href||t);return e.protocol===n.protocol&&e.host===n.host}catch{return!1}},ue=e=>/^[a-z][a-z\d+.-]*:\/\//i.test(e),de=(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))},x=e=>{try{let t=c().api(`/api`);if(!/^[a-z][a-z\d+.-]*:\/\//i.test(t))return!1;let n=new URL(t);return e.origin===n.origin&&b(e.pathname)}catch{return!1}},fe=e=>{if(b(e))return!0;if(!/^[a-z][a-z\d+.-]*:\/\//i.test(e))return!1;try{let t=new URL(e);return le(t)&&b(t.pathname)}catch{return!1}},pe=(e,t)=>{try{let n=new URL(e);if(!le(n))return t&&x(n)?(de(n,t),n.toString()):e;let r=S(`${n.pathname}${n.search}`,t);return!ue(r)&&(n.protocol===`http:`||n.protocol===`https:`)?(de(n,t),n.toString()):n.hash?`${r}${n.hash}`:r}catch{return e}},S=(e,t)=>e===`/health`?c().health(t):e.startsWith(`/auth/`)||e===`/auth`?c().auth(e,t):b(e)?c().api(e,t):/^[a-z][a-z\d+.-]*:\/\//i.test(e)?pe(e,t):e,me=e=>{let t=e instanceof Request?e.url:e.toString();if(!ue(t))return b(t);try{return x(new URL(t))}catch{return!1}},he=/^\/api\/session\/(?!status$)([^/]+)(?:\/(?:message|children|todo|diff))?$/,ge=/^\/api\/openchamber\/sessions\/([^/]+)\/messages\/?$/,_e=null,ve=e=>{_e=e},ye=e=>{try{return decodeURIComponent(e)}catch{return e}},be=e=>_e?e===_e||ye(e)===_e:!1,xe=new Set([`/health`,`/api/opencode/health`,`/api/opencode/upgrade-status`,`/api/global/config`,`/api/project`,`/api/project/current`,`/api/config`,`/api/config/providers`,`/api/config/settings`,`/api/config/themes`,`/api/experimental/session`,`/api/session/status`,`/api/session-folders`,`/api/github/pr/status`,`/api/openchamber/session-index`]),Se=[`/api/agent`,`/api/command`,`/api/mcp`,`/api/lsp`,`/api/vcs`,`/api/question`,`/api/permission`,`/api/git/check`,`/api/git/primary-root`,`/api/git/discover`,`/api/git/status`,`/api/git/worktrees`,`/api/quota`],Ce=e=>xe.has(e)||Se.some(t=>e===t||e.startsWith(`${t}/`)),we=e=>{if(!ue(e))return b(e);try{return x(new URL(e))}catch{return!1}},Te=e=>{try{return new URL(e,`http://openchamber.local`).pathname}catch{return null}},Ee=[/^\/api\/session\/(?!status$)[^/]+\/message\/?$/,/^\/api\/session\/(?!status$)[^/]+\/message\/[^/]+\/?$/,/^\/api\/openchamber\/sessions\/[^/]+\/messages\/?$/,/^\/api\/openchamber\/sessions\/[^/]+\/messages\/reconcile\/?$/,/^\/api\/openchamber\/transcript-cache\/session\/?$/,/^\/api\/openchamber\/transcript-cache\/message\/?$/,/^\/api\/global\/event\/?$/,/^\/api\/event\/?$/],De=(e,t)=>o()||!t||e.toUpperCase()!==`GET`?!1:Ee.some(e=>e.test(t)),Oe=(e,t)=>{if(!e)return t;if(e instanceof URLSearchParams){let n=new URLSearchParams(e);for(let[e,r]of Object.entries(t))n.set(e,r);return n}return{...e,...t}},ke=(e,t)=>String(t.method??(e instanceof Request?e.method:`GET`)).toUpperCase(),Ae=e=>Te(e instanceof Request?e.url:e.toString()),je=(e,t,n)=>De(t,Ae(e))?Oe(n,{includeReasoning:`false`}):n,Me=(e,t)=>{if(e.toUpperCase()!==`GET`||!we(t))return;let n=Te(t);if(!n)return;let r=n.match(he);if(r?.[1]&&be(r[1]))return`high`;let i=n.match(ge);if(i?.[1]&&be(i[1]))return`high`;if(Ce(n))return`low`},Ne=e=>{for(let t=0;t<e.length;t+=1)if(e.charCodeAt(t)>255)return!1;return!0},Pe=(e,t)=>!Ne(t),Fe=e=>{if(!e)return;let t=e instanceof Headers?Array.from(e.entries()):Array.isArray(e)?e:Object.entries(e);if(t.length===0)return;let n=[],r=!1,i=!1;for(let[e,a]of t)Pe(e,a)?(n.push([e,encodeURIComponent(a)]),r=!0,e.toLowerCase()===`x-opencode-directory`&&(i=!0)):n.push([e,a]);return i&&n.push([`x-opencode-directory-encoding`,`uri`]),r?n:void 0},C=async(e,t,r=!0)=>{let i=new Headers(Fe(e)??e);return t&&new Headers(Fe(t)??t).forEach((e,t)=>i.set(t,e)),r?n(i):i},Ie=(e,t)=>{if(!t)return e;let n=new URL(e,_);return de(n,t),`${n.pathname}${n.search}`},Le=(e,t)=>{let n=e instanceof Request?e.url:e.toString();if(!ue(n))return b(n)?Ie(n,t):null;try{let e=new URL(n);return!le(e)||!b(e.pathname)?null:(de(e,t),`${e.pathname}${e.search}`)}catch{return null}},Re=async(e,t,n)=>{let r=l();if(!r)return null;let i=ke(e,t),a=Le(e,je(e,i,n));if(a===null)return null;let o=await C(e instanceof Request?e.headers:void 0,t.headers,!0);return e instanceof Request?i===`GET`&&De(i,Ae(e))?r.fetch(a,{...t,method:`GET`,headers:o,signal:t.signal??e.signal}):r.fetch(e,{...t,headers:o}):r.fetch(a,{...t,headers:o})},ze=(e,t)=>{if(typeof e==`string`)return S(e,t);if(e instanceof URL)return S(e.toString(),t);let n=S(e.url,t);return n===e.url?e:new Request(n,e)},Be=/\/api\/(config|path|app\/agents|agent|project|command|opencode\/upgrade-status)(\b|\/|\?|$)/,Ve=new Map,He=new WeakMap,Ue=1,We=e=>{let t=He.get(e);if(t)return t;let n=Ue;return Ue+=1,He.set(e,n),n},Ge=(e,t,n,r,i,a)=>n||!i||e!==`GET`||t.includes(`/event`)||!Be.test(t)?null:`GET ${a?`relay:${We(a)}`:`url:${t}`} ${t} auth:${r}`,Ke=async(e,t={})=>{let{query:n,...r}=t,i=ke(e,r),o=je(e,i,n),s=l(),c=s?Le(e,o):null,u=a(),d,f,p;if(s&&c!==null){let t=await C(e instanceof Request?e.headers:void 0,r.headers,!0);p=i,d=e instanceof Request&&p===`GET`&&De(p,Ae(e))?()=>s.fetch(c,{...r,method:`GET`,headers:t,signal:r.signal??e.signal}):e instanceof Request?()=>s.fetch(e,{...r,headers:t}):()=>s.fetch(c,{...r,headers:t}),f=c}else{let t=ze(e,o),n=await C(t instanceof Request?t.headers:void 0,r.headers,me(t));f=t instanceof Request?t.url:t instanceof URL?t.toString():String(t),p=String(r.method??(t instanceof Request?t.method:`GET`)).toUpperCase();let i=r.priority??Me(p,f),a=i?{...r,priority:i}:r;d=t instanceof Request?()=>fetch(new Request(t,{...a,headers:n})):()=>fetch(t,{...a,headers:n})}let m=r.signal!=null||e instanceof Request,h=Ge(p,f,m,u,u===a(),s&&c!==null?s:null);if(!h)return d();let g=Ve.get(h);if(g)return g.then(e=>e.clone());let _=d();return Ve.set(h,_),_.then(()=>Ve.delete(h),()=>Ve.delete(h)),_.then(e=>e.clone())},qe=!1,Je=()=>{if(qe||typeof window>`u`)return;qe=!0;let e=window.fetch.bind(window);window.fetch=async(t,n)=>{let r=await Re(t,n??{});if(r)return r;if(typeof t==`string`){if(!fe(t)){try{if(x(new URL(t))){let r=await C(void 0,n?.headers);return e(t,{...n,headers:r})}}catch{}return e(t,n)}let r=await C(void 0,n?.headers);return e(S(t),{...n,headers:r})}if(t instanceof URL){let r=t.toString();if(!fe(r)){if(x(t)){let r=await C(void 0,n?.headers);return e(t,{...n,headers:r})}return e(t,n)}let i=await C(void 0,n?.headers);return e(S(r),{...n,headers:i})}if(t instanceof Request){if(!fe(t.url)){try{if(x(new URL(t.url))){let r=await C(t.headers,n?.headers);return e(new Request(t,{...n,headers:r}))}}catch{}return e(t,n)}let r=await C(t.headers,n?.headers),i=S(t.url),a=i===t.url?t:new Request(i,t),o=await e(new Request(a,{...n,headers:r}));if(o.status>=500){let e=i;try{e=new URL(i).pathname}catch{}console.error(`[runtime-fetch] server request failed`,{method:a.method,path:e,status:o.status,statusText:o.statusText},Error(`runtime fetch received HTTP ${o.status}`))}return o}return e(t,n)}},Ye=[`local`,`remote`,null],Xe=[`ok`,`not-configured`,`unreachable`,`incompatible`,`wrong-service`,`missing`];function Ze(e){if(!e||typeof e!=`object`)return{valid:!1};let t=e,n=t.target,r=t.status;if(n!==null&&(typeof n!=`string`||!Ye.includes(n))||typeof r!=`string`||!Xe.includes(r))return{valid:!1};if(n===`remote`||n===`local`){if(r===`ok`&&n===`local`)return{valid:!0,outcome:{target:`local`,status:`ok`}};if(r===`ok`&&n===`remote`)return typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`ok`,hostId:t.hostId,url:t.url}};if(r===`unreachable`)return n===`local`?{valid:!0,outcome:{target:`local`,status:`unreachable`}}:typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`unreachable`,hostId:t.hostId,url:t.url}};if(r===`incompatible`||r===`wrong-service`)return n!==`remote`||typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:r,hostId:t.hostId,url:t.url}};if(r===`missing`)return n!==`remote`||typeof t.hostId!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`missing`,hostId:t.hostId}}}if(n===null){if(r===`not-configured`)return{valid:!0,outcome:{target:null,status:`not-configured`}};if(r===`missing`)return{valid:!1}}return{valid:!1}}function Qe(e){if(!e.isDesktopShell)return null;let t=e.bootOutcome;if(!t)return null;if(t.status===`ok`){if(t.target===`local`)return{screen:`main`};if(t.target===`remote`)return{screen:`main`,hostId:t.hostId,url:t.url}}if(t.target===null&&t.status===`not-configured`)return{screen:`chooser`};if(t.target===`local`&&t.status===`unreachable`)return{screen:`recovery`,variant:`local-unavailable`};if(t.target===`remote`){if(t.status===`unreachable`)return{screen:`recovery`,variant:`remote-unreachable`,hostId:t.hostId,url:t.url};if(t.status===`incompatible`)return{screen:`recovery`,variant:`remote-incompatible`,hostId:t.hostId,url:t.url};if(t.status===`wrong-service`)return{screen:`recovery`,variant:`remote-wrong-service`,hostId:t.hostId,url:t.url};if(t.status===`missing`)return{screen:`recovery`,variant:`remote-missing`,hostId:t.hostId}}return null}function $e(e){return e.isDesktopShell?e.bootOutcomeKnown?e.bootViewIsMain===!1||e.isInitialized:!1:e.isInitialized}function et(e){return e.isDesktopShell&&!e.isDesktopLocalOriginActive}function tt(){if(rt()!==`valid`)return null;let e=Ze(nt());return e.valid?e.outcome:null}var nt=()=>{if(typeof window>`u`)return;let e=window.__OPENCHAMBER_DESKTOP_BOOT_OUTCOME__;if(e!=null)return e;let t=window.__OPENCHAMBER_DESKTOP_BOOT__;if(t&&typeof t.getOutcome==`function`)try{return t.getOutcome()}catch{return}return e};function rt(){if(typeof window>`u`)return`not-injected`;let e=nt();return e==null?`not-injected`:Ze(e).valid?`valid`:`malformed`}var it=null,at=e=>{it=e},ot=()=>it||(typeof window>`u`?null:window.__OPENCHAMBER_RUNTIME_APIS__??null),st=()=>typeof window>`u`?null:window.__OPENCHAMBER_ELECTRON__??null,w=()=>typeof window>`u`?null:window.__OPENCHAMBER_DESKTOP__??null,ct=()=>st()?.runtime===`electron`,lt=()=>ct()&&st()?.packaged===!0,ut=e=>{if(!ct())return null;let t=w()?.getPathForFile?.(e);return typeof t==`string`&&t.trim()?t:null},dt=()=>{if(typeof window>`u`)return null;let e=window.__OPENCHAMBER_PLATFORM__;return typeof e==`string`?e:null},ft=()=>{if(!ct())return!1;let e=dt();return e===`win32`||e===`linux`},pt=(e=dt())=>e===`linux`?`left`:`right`,mt=(e,t=dt())=>e===`left`||e===`right`?e:pt(t),T=()=>typeof w()?.invoke==`function`,E=()=>ct()&&T(),D=async(e,t)=>{let n=w();return typeof n?.invoke==`function`?n.invoke(e,t??{}):null},ht=async()=>{if(!E()||!O())return null;try{let e=await D(`desktop_get_launch_at_login`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`?null:e}catch(e){return console.warn(`Failed to get launch at login status`,e),null}},gt=async e=>{if(!E()||!O())return null;try{let t=await D(`desktop_set_launch_at_login`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`?null:t}catch(e){return console.warn(`Failed to set launch at login status`,e),null}},_t=async()=>{if(!E()||!O())return null;try{let e=await D(`desktop_get_minimize_to_tray`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`?null:e}catch(e){return console.warn(`Failed to get minimize to tray status`,e),null}},vt=async e=>{if(!E()||!O())return null;try{let t=await D(`desktop_set_minimize_to_tray`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`?null:t}catch(e){return console.warn(`Failed to set minimize to tray status`,e),null}},yt=async()=>{if(!E()||!O())return null;try{let e=await D(`desktop_get_keep_awake`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`||typeof e.active!=`boolean`?null:e}catch(e){return console.warn(`Failed to get keep awake status`,e),null}},bt=async e=>{if(!E()||!O())return null;try{let t=await D(`desktop_set_keep_awake`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`||typeof t.active!=`boolean`?null:t}catch(e){return console.warn(`Failed to set keep awake status`,e),null}},xt=e=>{let t=e.trim();if(!t)return null;try{return new URL(t).origin}catch{try{return new URL(t.endsWith(`/`)?t:`${t}/`).origin}catch{return null}}},St=e=>{let t=e.trim();if(!t)return null;try{return new URL(t)}catch{try{return new URL(t.endsWith(`/`)?t:`${t}/`)}catch{return null}}},Ct=e=>e.replace(/^\[|\]$/g,``).toLowerCase(),wt=e=>{let t=Ct(e);return t===`localhost`||t===`127.0.0.1`||t===`::1`},O=()=>{if(typeof window>`u`||!Tt())return!1;if(d()===`local`)return!0;let e=typeof window.__OPENCHAMBER_LOCAL_ORIGIN__==`string`?window.__OPENCHAMBER_LOCAL_ORIGIN__:``,t=St(e),n=St(r());if(!n&&t&&tt()?.target===`local`)return!0;if(t&&n){if(t.origin===n.origin)return!0;let e=t.port||(t.protocol===`https:`?`443`:`80`),r=n.port||(n.protocol===`https:`?`443`:`80`);return t.protocol===n.protocol&&e===r&&wt(t.hostname)&&wt(n.hostname)}let i=St(window.location.origin);if(t&&i){if(t.origin===i.origin)return!0;let e=t.port||(t.protocol===`https:`?`443`:`80`),n=i.port||(i.protocol===`https:`?`443`:`80`);return t.protocol===i.protocol&&e===n&&wt(t.hostname)&&wt(i.hostname)}let a=xt(e),o=xt(window.location.origin)||window.location.origin;return a&&o&&a===o?!0:!!(i&&wt(i.hostname))},Tt=()=>typeof window>`u`?!1:ct(),Et=async()=>{if(!Tt())return!1;try{return await D(`desktop_start_window_drag`),!0}catch{return!1}},Dt=()=>ot()?.runtime?.isVSCode===!0,Ot=()=>{let e=ot()?.runtime?.platform;return e===`web`?!0:e===`desktop`||e===`vscode`?!1:!Dt()},kt=async()=>{if(typeof window<`u`){let e=window.__OPENCHAMBER_HOME__;if(e&&e.length>0)return e}return null},At=async e=>{if(T()&&O())try{let e=await w()?.openDialog?.({directory:!0,multiple:!1,title:`Select Working Directory`});return!e||typeof e!=`string`?{success:!1,error:`Directory selection cancelled`}:{success:!0,path:e}}catch(e){return console.warn(`Failed to request directory access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}return{success:!0,path:e}},jt=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Mt=async e=>{if(T()&&O())try{let t=await w()?.openDialog?.({directory:!1,multiple:!1,title:`Select File`,returnGrant:!0,...e?.filters?{filters:e.filters}:{},...e?.defaultPath?{defaultPath:e.defaultPath}:{}});if(!t)return{success:!1,error:`File selection cancelled`};if(typeof t==`string`)return{success:!0,path:t};if(!jt(t))return{success:!1,error:`File selection cancelled`};let n=typeof t.path==`string`?t.path:``;return n?{success:!0,path:n,outsideFileGrant:typeof t.outsideFileGrant==`string`?t.outsideFileGrant:void 0}:{success:!1,error:`File selection cancelled`}}catch(e){return console.warn(`Failed to request file access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}return{success:!1,error:`Native file picker not available`}},Nt=async e=>{let t=typeof e==`string`?e.trim():``;if(!t)return{success:!1,error:`Path is required`};if(!T()||!O())return{success:!1,error:`Native file access not available`};try{let e=await w()?.grantFileAccess?.(t);if(!jt(e))return{success:!1,error:`File access was not granted`};let n=typeof e.path==`string`?e.path:``,r=typeof e.outsideFileGrant==`string`?e.outsideFileGrant:``;return!n||!r?{success:!1,error:`File access was not granted`}:{success:!0,path:n,outsideFileGrant:r}}catch(e){return console.warn(`Failed to request existing file access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}},Pt=async e=>({success:!0}),Ft=async e=>({success:!0}),It=async()=>{if(!T())throw Error(`Desktop update checker is unavailable`);let e=await D(`desktop_check_for_updates`);if(!e)throw Error(`Desktop update checker returned no result`);return e},Lt=async e=>{let t=w();return typeof t?.listen==`function`?t.listen(`openchamber:update-progress`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let r=n;e({event:typeof r.event==`string`?r.event:void 0,data:r.data&&typeof r.data==`object`?r.data:void 0})}):null},Rt=async e=>{let t=w();return typeof t?.listen==`function`?t.listen(`openchamber:update-ready`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let r=n;e({version:typeof r.version==`string`?r.version:null,downloaded:r.downloaded===!0})}):null},zt=async e=>{if(!T())return!1;let t=w(),n=null,r=0,i;try{return typeof e==`function`&&t?.listen&&(n=await t.listen(`openchamber:update-progress`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let a=n,o=typeof a.event==`string`?a.event:null,s=a.data&&typeof a.data==`object`?a.data:null;if(o===`Started`){r=0,i=typeof s?.contentLength==`number`?s.contentLength:void 0,e({downloaded:r,total:i});return}if(o===`Progress`){let t=s?.downloaded,n=s?.total;typeof t==`number`&&(r=t),typeof n==`number`&&(i=n),e({downloaded:r,total:i});return}o===`Finished`&&e({downloaded:r,total:i})})),await D(`desktop_download_and_install_update`),!0}catch(e){throw e instanceof Error?e:Error(String(e))}finally{if(n)try{let e=n();e instanceof Promise&&await e}catch{}}},Bt=async()=>T()?Vt({applyUpdate:!0}):!1,Vt=async({applyUpdate:e=!1}={})=>{if(!T())return!1;try{return await D(`desktop_restart`,e?{applyUpdate:!0}:void 0),!0}catch(e){return console.warn(`Failed to restart desktop app`,e),!1}},Ht=async()=>{if(!T()||!O())return null;try{let e=await D(`desktop_get_lan_address`);return typeof e==`string`&&e.trim().length>0?e.trim():null}catch(e){return console.warn(`Failed to get desktop LAN address`,e),null}},Ut=async(e,t)=>{if(!T()||!O())return!1;let n=e?.trim();if(!n)return!1;try{return await D(`desktop_open_path`,{path:n,app:typeof t==`string`&&t.trim().length>0?t.trim():void 0}),!0}catch(e){return console.warn(`Failed to open path`,e),!1}},Wt=async e=>{if(!T()||!O())return null;let t=e?.trim();if(!t)return null;try{let e=await D(`desktop_is_binary_path`,{path:t});return typeof e==`boolean`?e:null}catch{return null}},Gt=async e=>{if(!T()||!O())return!1;let t=e?.trim();if(!t)return!1;try{return await D(`desktop_reveal_path`,{path:t}),!0}catch{return Ut(t)}},Kt=async(e,t)=>{if(!T()||!O())return null;let n=e?.trim();if(!n)return null;try{let e=await D(`desktop_save_markdown_file`,{defaultFileName:n,content:t});return typeof e==`string`&&e.trim().length>0?e:null}catch(e){return console.warn(`Failed to save markdown file`,e),null}},qt=async(e,t,n)=>{if(!T()||!O())return!1;let r=e?.trim(),i=t?.trim(),a=n?.trim();if(!r||!i||!a)return!1;try{return await D(`desktop_open_in_app`,{projectPath:r,appId:i,appName:a}),!0}catch(e){return console.warn(`Failed to open project in app`,e),!1}},Jt=async(e,t,n)=>{if(!T()||!O())return!1;let r=e?.trim(),i=t?.trim(),a=n?.trim();if(!r||!i||!a)return!1;try{return await D(`desktop_open_file_in_app`,{filePath:r,appId:i,appName:a}),!0}catch(e){return console.warn(`Failed to open file in app`,e),!1}},Yt=async(e,t)=>{if(!T()||!O())return{apps:[],success:!1,hasCache:!1,isCacheStale:!1};if(dt()===`linux`)return{apps:[],success:!0,hasCache:!1,isCacheStale:!1};let n=Array.isArray(e)?e.filter(e=>typeof e==`string`):[];if(n.length===0)return{apps:[],success:!0,hasCache:!1,isCacheStale:!1};try{let e=await D(`desktop_get_installed_apps`,{apps:n,force:t===!0||void 0});if(!e||typeof e!=`object`)return{apps:[],success:!1,hasCache:!1,isCacheStale:!1};let r=e;return r.supported===!1?{apps:[],success:!0,hasCache:!1,isCacheStale:!1}:Array.isArray(r.apps)?{apps:r.apps.filter(e=>e&&typeof e==`object`).map(e=>{let t=e;return{name:typeof t.name==`string`?t.name:``,iconDataUrl:typeof t.iconDataUrl==`string`?t.iconDataUrl:null}}).filter(e=>e.name.length>0),success:!0,hasCache:r.hasCache===!0,isCacheStale:r.isCacheStale===!0}:{apps:[],success:!1,hasCache:!1,isCacheStale:!1}}catch(e){return console.warn(`Failed to fetch installed apps`,e),{apps:[],success:!1,hasCache:!1,isCacheStale:!1}}},Xt=`oc.inst.`,Zt=e=>{try{return btoa(unescape(encodeURIComponent(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}catch{return encodeURIComponent(e)}},Qt=e=>{let t=(e??d()).trim();return t.length>0?t:`default`},$t=()=>{if(typeof window>`u`)return``;let e=window.__OPENCHAMBER_LOCAL_ORIGIN__;return typeof e==`string`?e.trim().replace(/\/+$/,``):``},k=(e,t=d())=>`${Xt}${Zt(Qt(t))}.${e}`,en=(e=d())=>Qt(e).startsWith(`relay:`),tn=(e=d())=>{let t=Qt(e);if(t==="default"||t===`local`)return!0;if(en(t)||!t.startsWith(`url:`))return!1;let n=$t();if(!n)return!1;try{return new URL(t.slice(4)).origin===new URL(n).origin}catch{return!1}},nn=(e=d())=>!en(e),rn=(e,t=r())=>{let n=t.trim().replace(/\/+$/,``);return n?`${e}:${encodeURIComponent(n)}`:null},an=(e,t)=>{let n=t?.storage??(typeof localStorage<`u`?localStorage:{getItem:()=>null}),r=t?.runtimeKey??d(),i=n.getItem(k(e,r));if(i!==null)return i;if(nn(r)){let t=rn(e),r=t?n.getItem(t):null;if(r!==null)return r}return tn(r)?n.getItem(e):null},A=(e,t,n)=>{let r=n?.storage??(typeof localStorage<`u`?localStorage:{setItem:()=>void 0}),i=n?.runtimeKey??d();r.setItem(k(e,i),t)},on=e=>({getItem:t=>an(t,{storage:e}),setItem:(t,n)=>{A(t,n,{storage:e})},removeItem:t=>{j(t,{storage:e})}}),j=(e,t)=>{let n=t?.storage??(typeof localStorage<`u`?localStorage:{removeItem:()=>void 0}),r=t?.runtimeKey??d();n.removeItem(k(e,r))},sn=e=>{let t;try{t=u()}catch{return}let n=t=>t===null?null:JSON.parse(t,e?.reviver),r=e=>t.getItem(e);return{getItem:e=>{let t=d(),i=k(e,t),a=r(i);if(a instanceof Promise)return a.then(i=>{if(i!==null)return n(i);if(!tn(t))return null;let a=r(e);return a instanceof Promise?a.then(n):n(a)});if(a!==null)return n(a);if(!tn(t))return null;let o=r(e);return o instanceof Promise?o.then(n):n(o)},setItem:(n,r)=>{let i=k(n,d());t.setItem(i,JSON.stringify(r,e?.replacer))},removeItem:e=>{let n=k(e,d());t.removeItem(n)}}},cn=(e=ln)=>{let t=new Map,n=0;return{countUnicodeCodePoints:r=>{let i=t.get(r);if(i!==void 0)return t.delete(r),t.set(r,i),i;let a=e(r);if(r.length>4e5)return a;for(;n+r.length>4e5&&t.size>0;){let e=t.keys().next().value;n-=e.length,t.delete(e)}return t.set(r,a),n+=r.length,a}}},ln=e=>{let t=0;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);if(r>=55296&&r<=56319&&n+1<e.length){let t=e.charCodeAt(n+1);t>=56320&&t<=57343&&(n+=1)}t+=1}return t},un=cn(),dn=e=>un.countUnicodeCodePoints(e),M=(e,t)=>{if(!e)throw Error(`${t} must be non-empty`);return e},fn=({transportIdentity:e},t)=>({transportIdentity:M(e,`transportIdentity`),owner:{kind:`session`,ownerID:M(t,`sessionID`)}}),pn=({transportIdentity:e},t)=>({transportIdentity:M(e,`transportIdentity`),owner:{kind:`draft`,ownerID:M(t,`draftID`)}}),mn=e=>{let t=typeof e.projectId==`string`?e.projectId.trim():``;if(t)return`new-session:project:${t}`;let n=typeof e.directory==`string`?e.directory.trim():``;return n?`new-session:directory:${n}`:`new-session:default`},hn=({transportIdentity:e},t)=>({transportIdentity:M(e,`transportIdentity`),owner:{kind:`surface`,ownerID:M(t,`surfaceID`)}}),gn=8192,_n=e=>{if(typeof e!=`string`||e.length===0||e.length>gn)return!1;try{let t=new URL(e).protocol;return t===`http:`||t===`https:`||t===`file:`}catch{return!1}},vn=e=>JSON.stringify([e.transportIdentity,e.owner.kind,e.owner.ownerID]),yn=e=>JSON.stringify([e.transportIdentity,e.owner.kind,e.owner.ownerID,e.attachmentOccurrenceRefID]),bn=e=>JSON.stringify([`root`,e]),xn=(e,t)=>JSON.stringify([`part`,e,t]),Sn={mentionCount:1e3,valueLength:8192,pathLength:8192,labelLength:512},N={referenceCount:1e3,idLength:512,displayLength:514,sessionIDLength:128,skillNameLength:511,commandNameLength:511,commandReferenceLength:8192,pastePayloadLength:1e5,totalPastePayloadLength:2e5},P=e=>{if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},F=(e,t)=>Object.keys(e).every(e=>t.includes(e)),I=e=>typeof e==`string`&&e.length>0,Cn=e=>typeof e==`string`,L=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,R=(e,t)=>typeof e==`string`&&e.length>0&&e.length<=t,wn=(e,t)=>{if(t<=0||t>=e.length)return!0;let n=e.charCodeAt(t-1),r=e.charCodeAt(t);return!(n>=55296&&n<=56319&&r>=56320&&r<=57343)},Tn=(e,t)=>{if(!Array.isArray(t)||t.length>Sn.mentionCount)return;let n=[],r=new Set,i=0;for(let a of t){if(!P(a)||!F(a,[`kind`,`value`,`path`,`label`,`range`])||a.kind!==`file`&&a.kind!==`directory`&&a.kind!==`agent`||!R(a.value,Sn.valueLength)||!R(a.path,Sn.pathLength)||!R(a.label,Sn.labelLength)||!P(a.range)||!F(a.range,[`start`,`end`])||!L(a.range.start)||!L(a.range.end)||a.range.end<=a.range.start||a.range.end>e.length||a.range.start<i||!wn(e,a.range.start)||!wn(e,a.range.end)||e.slice(a.range.start,a.range.end)!==`@${a.value}`)return;let t=JSON.stringify([a.kind,a.value,a.path,a.label,a.range.start,a.range.end]);if(r.has(t))return;r.add(t),i=a.range.end,n.push({kind:a.kind,value:a.value,path:a.path,label:a.label,range:{start:a.range.start,end:a.range.end}})}return n},En=e=>R(e,N.sessionIDLength)&&/^[A-Za-z0-9_-]+$/.test(e),Dn=e=>R(e,N.skillNameLength)&&/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(e),On=e=>R(e,N.commandNameLength)&&/^[\p{L}\p{N}._/-]+$/u.test(e),kn=e=>R(e,N.commandReferenceLength)&&!/[\]\r\n]/u.test(e),An=e=>{if(!(!P(e)||!R(e.id,N.idLength)||!R(e.display,N.displayLength)||!L(e.start)||!L(e.end)||e.end<=e.start)){if(e.kind===`session`&&F(e,[`id`,`kind`,`start`,`end`,`display`,`sessionId`])&&En(e.sessionId))return{id:e.id,kind:`session`,start:e.start,end:e.end,display:e.display,sessionId:e.sessionId};if(e.kind===`paste`&&F(e,[`id`,`kind`,`start`,`end`,`display`,`text`,`characterCount`,`index`])&&typeof e.text==`string`&&e.text.length<=N.pastePayloadLength&&L(e.characterCount)&&e.characterCount===dn(e.text)&&L(e.index)&&e.index>=1)return{id:e.id,kind:`paste`,start:e.start,end:e.end,display:e.display,text:e.text,characterCount:e.characterCount,index:e.index};if(e.kind===`skill`&&F(e,[`id`,`kind`,`start`,`end`,`display`,`skillName`])&&Dn(e.skillName)&&(e.display===`/${e.skillName}`||e.display===`/ ${e.skillName}`))return{id:e.id,kind:`skill`,start:e.start,end:e.end,display:e.display,skillName:e.skillName};if(e.kind===`command`&&F(e,[`id`,`kind`,`start`,`end`,`display`,`commandName`,`reference`])&&On(e.commandName)&&kn(e.reference)&&(e.display===`/${e.commandName}`||e.display===`/ ${e.commandName}`))return{id:e.id,kind:`command`,start:e.start,end:e.end,display:e.display,commandName:e.commandName,reference:e.reference}}},jn=(e,t)=>{if(!Array.isArray(t)||t.length>N.referenceCount)return;let n=t.map(An);if(!n.every(Boolean))return;let r=n,i=new Set,a=0,o=0;for(let t of r)if(i.has(t.id)||t.start<a||t.end>e.length||e.slice(t.start,t.end)!==t.display||(i.add(t.id),a=t.end,t.kind===`paste`&&(o+=t.text.length,o>N.totalPastePayloadLength)))return;return{text:e,references:r}},Mn=(e,t)=>{if(e===null||[`string`,`number`,`boolean`,`undefined`].includes(typeof e))return!0;if(typeof e!=`object`||e instanceof Blob||typeof File<`u`&&e instanceof File||!Array.isArray(e)&&!P(e)||t.has(e))return!1;t.add(e);let n=Object.values(e).every(e=>Mn(e,t));return t.delete(e),n},Nn=e=>{if(!(!P(e)||!F(e,[`kind`,`ownerID`])||!I(e.ownerID))&&(e.kind===`session`||e.kind===`draft`||e.kind===`surface`))return{kind:e.kind,ownerID:e.ownerID}},Pn=e=>{if(!P(e)||!F(e,[`transportIdentity`,`owner`])||!I(e.transportIdentity))return;let t=Nn(e.owner);return t?{transportIdentity:e.transportIdentity,owner:t}:void 0},Fn=e=>{if(!(!P(e)||!I(e.kind))){if(e.kind===`blob`&&F(e,[`kind`,`blobID`])&&I(e.blobID))return{kind:`blob`,blobID:e.blobID};if(!(e.kind!==`url`||!F(e,[`kind`,`url`])||!_n(e.url)))return{kind:`url`,url:e.url}}},In=(e,t,n)=>{try{let r=JSON.parse(e);return Array.isArray(r)?n===void 0?r.length===2&&r[0]===`root`&&r[1]===t:r.length===3&&r[0]===`part`&&r[1]===n&&r[2]===t:!1}catch{return!1}},Ln=(e,t)=>{if(!P(e)||!F(e,[`attachmentID`,`attachmentRefID`,`filename`,`mimeType`,`size`,`locator`,`source`,`serverPath`,`vscodePath`,`vscodeSource`])||!I(e.attachmentID)||!I(e.attachmentRefID)||!In(e.attachmentRefID,e.attachmentID,t)||!I(e.filename)||!Cn(e.mimeType)||!L(e.size)||e.source!==`local`&&e.source!==`vscode`&&e.source!==`server`||e.serverPath!==void 0&&!I(e.serverPath)||e.vscodePath!==void 0&&!I(e.vscodePath)||e.vscodeSource!==void 0&&e.vscodeSource!==`file`&&e.vscodeSource!==`selection`||e.source===`server`&&!I(e.serverPath)||e.source===`vscode`&&(!I(e.vscodePath)||e.vscodeSource!==`file`&&e.vscodeSource!==`selection`))return;let n=Fn(e.locator);if(n)return{attachmentID:e.attachmentID,attachmentRefID:e.attachmentRefID,filename:e.filename,mimeType:e.mimeType,size:e.size,locator:n,source:e.source,...e.serverPath===void 0?{}:{serverPath:e.serverPath},...e.vscodePath===void 0?{}:{vscodePath:e.vscodePath},...e.vscodeSource===void 0?{}:{vscodeSource:e.vscodeSource}}},Rn=e=>{if(!Mn(e,new Set)||!P(e)||!F(e,[`version`,`key`,`revision`,`text`,`attachments`,`syntheticParts`,`mentions`,`composerReferences`])||e.version!==1||!L(e.revision)||e.revision<1||typeof e.text!=`string`||!Array.isArray(e.attachments)||!Array.isArray(e.syntheticParts)||!Array.isArray(e.mentions))return;let t=e.text,n=Pn(e.key),r=e.attachments.map(e=>Ln(e)),i=e.syntheticParts.map(e=>{if(!P(e)||!F(e,[`partID`,`text`,`attachments`,`synthetic`])||!I(e.partID)||typeof e.text!=`string`||!Array.isArray(e.attachments)||e.synthetic!==void 0&&typeof e.synthetic!=`boolean`)return;let t=e.partID,n=e.text,r=e.attachments.map(e=>Ln(e,t));return r.every(Boolean)?{partID:t,text:n,attachments:r,...e.synthetic===void 0?{}:{synthetic:e.synthetic}}:void 0}),a=Tn(t,e.mentions),o=e.composerReferences===void 0?{text:t,references:[]}:jn(t,e.composerReferences);if(!n||!r.every(Boolean)||!i.every(Boolean)||!a||!o)return;let s=r,c=i,l=new Set;for(let e of[...s,...c.flatMap(e=>e.attachments)]){if(l.has(e.attachmentRefID))return;l.add(e.attachmentRefID)}if(new Set(c.map(e=>e.partID)).size===c.length)return{version:1,key:n,revision:e.revision,text:t,attachments:s,syntheticParts:c,mentions:a,...e.composerReferences===void 0?{}:{composerReferences:o.references}}},zn=e=>Rn(e),z=` `,Bn=`0.2em`,Vn=`size-[1em]`,Hn=e=>e.startsWith(z)?e.slice(z.length):e,Un=e=>e.replaceAll(`/${z}`,`/`).replaceAll(`@${z}`,`@`).replaceAll(`[${z}`,`[`),Wn=e=>{let t=e.match(/^\s*/)?.[0].length??0,n=e.slice(t);if(!n.startsWith(`/`))return null;let r=1;n.startsWith(z,r)&&(r+=z.length);let i=n.slice(r);if(!i)return null;let a=i.search(/\s/u),o=a===-1?i:i.slice(0,a);return o?{commandName:o,argumentsText:a===-1?``:i.slice(a).trim()}:null},Gn=e=>B({trigger:`[`,icon:`file-image`,label:e,suffix:`]`}),Kn=({trigger:e,label:t,suffix:n=``})=>`${e}${t}${n}`,B=e=>`${e.trigger}${z}${e.label}${e.suffix??``}`,qn=e=>Kn(e),Jn=(e,t)=>e===qn(t)||e===B(t),Yn=(e,t)=>{let n=t===B(e);return{trigger:n?`${e.trigger}${z}`:e.trigger,icon:e.icon,align:e.align??`end`,label:e.label,suffix:e.suffix,slot:n?`reserved`:`compact`}},Xn=(e,t,n=``)=>{let r=e.startsWith(t)?e.slice(t.length):e,i=r.startsWith(z)?r.slice(z.length):r;return n&&i.endsWith(n)?i.slice(0,-n.length):i},Zn=(e,t)=>e===t||!!e&&!!t&&e.trigger===t.trigger&&e.icon===t.icon&&e.align===t.align&&e.label===t.label&&e.suffix===t.suffix&&e.slot===t.slot,Qn=0n,$n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,er=14;function tr(e){let t=``;for(let n=0;n<e;n++)t+=$n[Math.floor(Math.random()*62)];return t}var nr=/^[0-9a-f]{12}$/,rr=/^[0-9A-Za-z]{14}$/,ir=(1n<<48n)-1n,ar=(e,t)=>{if(typeof t!=`string`||!t.startsWith(`${e}_`))return;let n=t.slice(e.length+1),r=n.slice(0,12);if(!(!nr.test(r)||!rr.test(n.slice(12))))return BigInt(`0x${r}`)},or=(e,t)=>{let n=BigInt(Date.now())*4096n&ir,r=ar(e,t)??0n,i=[n,Qn,r].reduce((e,t)=>e>t?e:t);if(i>=ir)throw Error(`Ascending ID space exhausted`);let a=i+1n;Qn=a;let o=new Uint8Array(6);for(let e=0;e<6;e++)o[e]=Number(a>>BigInt(40-8*e)&BigInt(255));let s=``;for(let e=0;e<o.length;e++)s+=o[e].toString(16).padStart(2,`0`);return`${e}_${s}${tr(er)}`},sr=e=>or(e),cr=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/g,``).trim();if(!t)return``;let n=new TextEncoder().encode(t),r=``;for(let e of n)r+=String.fromCharCode(e);return`path_${typeof btoa==`function`?btoa(r).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``):t.replace(/[^A-Za-z0-9._-]+/g,`_`)}`},lr=()=>globalThis.crypto===void 0?null:{randomUUID:typeof globalThis.crypto.randomUUID==`function`?()=>globalThis.crypto.randomUUID():void 0,getRandomValues:typeof globalThis.crypto.getRandomValues==`function`?e=>globalThis.crypto.getRandomValues(e):void 0},ur=(e=lr())=>{try{let t=e?.randomUUID?.();if(t)return t}catch{}let t=new Uint8Array(16),n=!1;try{e?.getRandomValues&&(e.getRandomValues(t),n=!0)}catch{}if(!n)for(let e=0;e<t.length;e+=1)t[e]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let r=Array.from(t,e=>e.toString(16).padStart(2,`0`));return`${r.slice(0,4).join(``)}-${r.slice(4,6).join(``)}-${r.slice(6,8).join(``)}-${r.slice(8,10).join(``)}-${r.slice(10).join(``)}`},dr=e=>/^[\\/]+$/.test(e),fr=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;if(dr(t))return t.length===1?`/`:null;let n=ae(t);return n===`/`?`/`:(n.length>1?n.replace(/\/+$/,``):n)||null},pr=e=>{if(typeof e!=`string`)return``;let t=e.trim();return t?fr(t)??t:``},V={...N,sessionIdLength:N.sessionIDLength,visibleTextLength:1e5,canonicalOutputLength:2e5},mr=e=>typeof e==`string`&&En(e),hr=e=>e.replaceAll(`\\`,`/`).split(`/`).at(-1)?.replace(/\.md$/,``)??``,gr=e=>({trigger:`@`,icon:`chat-thread`,label:e}),_r=(e,t)=>({trigger:`/`,icon:t,label:e}),vr={session:{kind:`session`,validatePayload:e=>mr(e.sessionId),contributeCanonical:e=>({text:`@session:${e.sessionId}`,semantic:{type:`session`,sessionId:e.sessionId}}),contributeDirectSend:e=>({text:qn(gr(Xn(e.display,`@`))),semantic:{type:`session`,sessionId:e.sessionId}}),decorate:e=>({style:`mentionSession`,visual:Yn(gr(Xn(e.display,`@`)),e.display)}),payloadBudget:()=>void 0,canonical:{matcher:/@session:([A-Za-z0-9_-]+)/g,resolveDisplay:(e,t)=>{let n=e.index===0?``:t.text[e.index-1],r=t.text[e.index+e[0].length]??``;return(n===``||/[\s([{]/.test(n))&&(r===``||/[\s)\]},.!?;:]/.test(r))?B(gr(t.sessionTitles.get(e[1])||e[1])):null},materialize:(e,t,n)=>({id:`session:${e[1]}:${e.index}`,kind:`session`,sessionId:e[1],display:t,start:n,end:n+t.length})}},paste:{kind:`paste`,validatePayload:e=>typeof e.text==`string`&&e.text.length<=V.pastePayloadLength&&typeof e.characterCount==`number`&&Number.isSafeInteger(e.characterCount)&&e.characterCount===dn(e.text)&&typeof e.index==`number`&&Number.isSafeInteger(e.index)&&e.index>=1,contributeCanonical:e=>({text:e.text}),contributeDirectSend:e=>({text:e.text}),decorate:()=>({style:`mentionPaste`}),payloadBudget:e=>({category:`opaque-text`,length:e.text.length})},skill:{kind:`skill`,validatePayload:e=>Dn(e.skillName)&&typeof e.display==`string`&&Jn(e.display,_r(e.skillName,`book-open`)),contributeCanonical:e=>({text:`[skill:${e.skillName}]`}),contributeDirectSend:e=>({text:`[skill:${e.skillName}]`}),decorate:e=>({style:`mentionCommand`,skillName:e.skillName,visual:Yn(_r(e.skillName,`book-open`),e.display)}),payloadBudget:()=>void 0,canonical:{matcher:/\[skill:([A-Za-z0-9][A-Za-z0-9_-]*)\]/g,resolveDisplay:e=>B(_r(e[1],`book-open`)),materialize:(e,t,n)=>({id:`skill:${n}`,kind:`skill`,skillName:e[1],display:t,start:n,end:n+t.length})}},command:{kind:`command`,validatePayload:e=>On(e.commandName)&&kn(e.reference)&&typeof e.display==`string`&&Jn(e.display,_r(e.commandName,`command`)),contributeCanonical:e=>({text:`[command:${e.reference}]`}),contributeDirectSend:e=>({text:`[command:${e.reference}]`}),decorate:e=>({style:`mentionCommand`,visual:Yn(_r(e.commandName,`command`),e.display)}),payloadBudget:()=>void 0,canonical:{matcher:/\[command:([^\]\r\n]+)\]/g,resolveDisplay:e=>{let t=hr(e[1]);return kn(e[1])&&On(t)?B(_r(t,`command`)):null},materialize:(e,t,n)=>({id:`command:${n}`,kind:`command`,commandName:hr(e[1]),reference:e[1],display:t,start:n,end:n+t.length})}}},H=e=>vr[e],yr=(e,t)=>H(e).validatePayload(t),br=e=>H(e.kind).contributeCanonical(e),xr=e=>H(e.kind).contributeDirectSend(e),Sr=e=>H(e.kind).decorate(e),Cr=e=>H(e.kind).payloadBudget(e),wr=e=>H(e.kind).describeResourceIdentity?.(e),Tr=Object.keys(vr),Er=e=>typeof e==`string`&&Tr.includes(e),Dr=()=>Tr.flatMap(e=>{let t=H(e).canonical;return t?[t]:[]}),Or=e=>{if(e.type===`attachment`)return`attachment:${e.attachmentRefID}`},kr=e=>{let t=new Map;for(let n of e.references){let e=wr(n);e&&t.set(Or(e),e)}return[...t.values()]},Ar=(e,t)=>{let n=new Map(e.map(e=>[Or(e),e])),r=new Map(t.map(e=>[Or(e),e]));return{previous:[...n.values()],next:[...r.values()],added:[...r].flatMap(([e,t])=>n.has(e)?[]:[t]),removed:[...n].flatMap(([e,t])=>r.has(e)?[]:[t])}},jr=(e,t)=>Ar(kr(e),kr(t)),Mr=(e,t=`queue-canonical`)=>{if(e.references.length>V.referenceCount)return{ok:!1,reason:`reference-budget-exceeded`};let n=[...e.references].sort((e,t)=>e.start-t.start),r=0,i=0;for(let t of n){if(t.start<r||t.start<0||t.end<=t.start||t.end>e.text.length||e.text.slice(t.start,t.end)!==t.display)return{ok:!1,reason:`invalid-references`};r=t.end;let n=Cr(t);i+=n?.category===`opaque-text`?n.length:0}if(i>V.totalPastePayloadLength)return{ok:!1,reason:`reference-payload-budget-exceeded`};let a=[],o=[],s=0;for(let r of n){s<r.start&&a.push({provenance:`authored`,text:e.text.slice(s,r.start),start:s,end:r.start});let n=t===`direct-send-display`?xr(r):br(r);n.semantic?(a.push({provenance:`generated-reference`,text:n.text,start:r.start,end:r.end,referenceId:r.id,semantic:n.semantic}),o.push(n.semantic)):a.push({provenance:`reference-payload`,text:n.text,start:r.start,end:r.end,referenceId:r.id}),s=r.end}s<e.text.length&&a.push({provenance:`authored`,text:e.text.slice(s),start:s,end:e.text.length});let c=a.map(e=>e.text).join(``);return c.length>V.canonicalOutputLength?{ok:!1,reason:`canonical-output-too-large`}:{ok:!0,plan:{chunks:a,semantics:o},text:c}},U=(e,t)=>Math.max(0,Math.min(e,t)),Nr=(e,t)=>typeof e==`string`&&e.length>0&&e.length<=t,Pr=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return!Nr(t.id,V.displayLength)||!Nr(t.display,V.displayLength)||!Number.isSafeInteger(t.start)||!Number.isSafeInteger(t.end)||typeof t.kind!=`string`?!1:Er(t.kind)&&yr(t.kind,t)},W=(e,t)=>{let n=[],r=0,i=[],a=Math.min(t.length,V.referenceCount);for(let e=0;e<a;e+=1){let a=t[e];if(!Pr(a)){typeof a==`object`&&a&&typeof a.id==`string`&&n.push(a.id),r+=1;continue}i.push({reference:a,index:e})}i.sort((e,t)=>e.reference.start-t.reference.start||e.index-t.index);let o=[],s=new Set,c=0,l=0,u=!1;for(let{reference:t}of i){if(s.has(t.id)||t.start<c||t.start<0||t.end<=t.start||t.end>e.length||e.slice(t.start,t.end)!==t.display){n.push(t.id),r+=1;continue}s.add(t.id),c=t.end;let i=Cr(t);if(l+=i?.category===`opaque-text`?i.length:0,l>N.totalPastePayloadLength){n.push(t.id),r+=1,s.delete(t.id),c=o.at(-1)?.end??0,u=!0,l-=i?.category===`opaque-text`?i.length:0;continue}o.push(t)}return r+=t.length-a,{document:{text:e,references:o},rejectedIds:n,rejectedCount:r,budgetExceeded:t.length>V.referenceCount,payloadBudgetExceeded:u}},G=e=>{let t=[...e.references].sort((e,t)=>e.start-t.start||e.end-t.end),n=[],r=new Set,i=0,a=0;for(let o of t){if(!Nr(o.id,V.idLength)||!Nr(o.display,V.displayLength)||!Er(o.kind)||!Number.isSafeInteger(o.start)||!Number.isSafeInteger(o.end)||r.has(o.id)||o.start<i||o.start<0||o.end<=o.start||o.end>e.text.length||e.text.slice(o.start,o.end)!==o.display)continue;let t=Cr(o),s=t?.category===`opaque-text`?t.length:0;a+s>N.totalPastePayloadLength||(r.add(o.id),i=o.end,a+=s,n.push(o))}return{text:e.text,references:n}},Fr=(e,t)=>{if(t.length>N.pastePayloadLength)return!1;let n=W(e.text,e.references);return n.budgetExceeded||n.payloadBudgetExceeded?!1:n.document.references.reduce((e,t)=>{let n=Cr(t);return e+(n?.category===`opaque-text`?n.length:0)},0)+t.length<=N.totalPastePayloadLength},Ir=(e,t,n)=>{let r=e.filter(e=>t===n?t>e.start&&t<e.end:e.start<n&&e.end>t);return r.length===0?{start:t,end:n}:{start:Math.min(t,...r.map(e=>e.start)),end:Math.max(n,...r.map(e=>e.end))}};function Lr(e,t,n,r,i={}){let a=G(e);if(!yr(r.kind,r))return{document:a,caret:U(n,a.text.length),edit:{oldStart:t,oldEnd:n,newEnd:n}};let o=U(t,a.text.length),s=Math.max(o,U(n,a.text.length)),c=Ir(a.references,o,s),l=a.text.slice(0,c.start),u=a.text.slice(c.end),d=!!i.padDocumentEdges&&i.padLeadingDocumentEdge!==!1,f=!!i.padDocumentEdges,p=i.inlineBoundaries&&(l.length>0||d)&&!/\s$/.test(l)?` `:``,m=i.inlineBoundaries&&(u.length>0||f)&&!/^\s/.test(u)?` `:``,h=`${l}${p}${r.display}${m}${u}`,g={...r,start:c.start+p.length,end:c.start+p.length+r.display.length},_=p.length+r.display.length+m.length-(c.end-c.start);return{document:G({text:h,references:[...a.references.filter(e=>e.end<=c.start||e.start>=c.end).map(e=>e.start>=c.end?{...e,start:e.start+_,end:e.end+_}:e),g]}),caret:g.end,edit:{oldStart:c.start,oldEnd:c.end,newEnd:c.start+p.length+r.display.length+m.length}}}var Rr=(e,t)=>e<=t.oldStart?e:e>=t.oldEnd?e+t.newEnd-t.oldEnd:t.newEnd,zr=(e,t,n=t.length,r=n)=>{let i=G(e),a=0,o=Math.min(i.text.length,t.length);for(;a<o&&i.text[a]===t[a];)a+=1;let s=0;for(;s<i.text.length-a&&s<t.length-a&&i.text[i.text.length-s-1]===t[t.length-s-1];)s+=1;let c={oldStart:a,oldEnd:i.text.length-s,newEnd:t.length-s},l=Ir(i.references,c.oldStart,c.oldEnd),u=l.start!==c.oldStart||l.end!==c.oldEnd,d=i.references.filter(e=>e.start<l.end&&e.end>l.start),f=t.slice(c.oldStart,c.newEnd),p=`${i.text.slice(0,l.start)}${f}${i.text.slice(l.end)}`,m={oldStart:l.start,oldEnd:l.end,newEnd:l.start+f.length},h=m.newEnd-m.oldEnd,g=i.references.filter(e=>e.end<=l.start||e.start>=l.end).map(e=>e.start>=l.end?{...e,start:e.start+h,end:e.end+h}:e),_=(e,n)=>{let r=U(e,t.length),i=c.newEnd+l.end-c.oldEnd;return U(r<=l.start?r:r<c.oldStart||r===c.oldStart&&n===`start`?l.start:r<c.newEnd||r===c.newEnd&&n===`start`?l.start+r-c.oldStart:r<=i?m.newEnd:m.newEnd+r-i,p.length)},v=_(n,`start`),y=Math.max(v,_(r,`end`)),ee=G({text:p,references:g});return{document:ee,edit:m,requiresTextCorrection:u,selectionStart:v,selectionEnd:y,caret:y,mapCaret:e=>U(Rr(e,m),ee.text.length),removedReferences:d}},Br=(e,t,n)=>{let r=Ir(n,e,t);return r.start===e&&r.end===t?null:r},Vr=(e,t,n)=>{let r=n,i=n;if(t===`Backspace`){for(;r>0&&/\s/.test(e[r-1]);)--r;for(;r>0&&!/\s/.test(e[r-1]);)--r}else{for(;i<e.length&&/\s/.test(e[i]);)i+=1;for(;i<e.length&&!/\s/.test(e[i]);)i+=1}return{start:r,end:i}},Hr=(e,t)=>{let n=G(e),r=U(t.selectionStart,n.text.length),i=Math.max(r,U(t.selectionEnd,n.text.length)),a=r===i?t.altKey?Vr(n.text,t.key,r):t.key===`Backspace`?{start:Math.max(0,r-1),end:r}:{start:r,end:Math.min(n.text.length,r+1)}:{start:r,end:i},o=Br(a.start,a.end,n.references);if(!o)return null;let s=n.references.filter(e=>e.start<o.end&&e.end>o.start);return{document:G({text:`${n.text.slice(0,o.start)}${n.text.slice(o.end)}`,references:n.references.filter(e=>!s.includes(e)).map(e=>e.start>=o.end?{...e,start:e.start-(o.end-o.start),end:e.end-(o.end-o.start)}:e)}),caret:o.start,edit:{oldStart:o.start,oldEnd:o.end,newEnd:o.start},removedIds:s.map(e=>e.id),removedReferences:s}},Ur=(e,t)=>{let n=t,r=t;for(;n>0&&/\s/.test(e[n-1]);)--n;for(;r<e.length&&/\s/.test(e[r]);)r+=1;let i=n>0&&r<e.length?` `:``;return{text:`${e.slice(0,n)}${i}${e.slice(r)}`,caret:n+i.length}},Wr=(e,t=`queue-canonical`)=>{let n=W(e.text,e.references);if(n.budgetExceeded)return{ok:!1,reason:`reference-budget-exceeded`};if(n.payloadBudgetExceeded)return{ok:!1,reason:`reference-payload-budget-exceeded`};if(n.rejectedCount>0)return{ok:!1,reason:`invalid-references`};let r=Mr(n.document,t);return r.ok?{ok:!0,text:r.text,chunks:r.plan.chunks,semantics:r.plan.semantics}:r},Gr=(e,t)=>e.match.index-t.match.index||e.adapterOrder-t.adapterOrder||e.matchOrder-t.matchOrder,Kr=e=>{if(e.length>V.canonicalOutputLength||e.length>V.visibleTextLength)return null;let t=[],n=0;for(let[r,i]of Dr().entries()){i.matcher.lastIndex=0;let a,o=0;for(;(a=i.matcher.exec(e))!==null;){if(n+=1,n>V.referenceCount)return null;let e={codec:i,match:a,adapterOrder:r,matchOrder:o};o+=1;let s=t.findIndex(t=>Gr(e,t)<0);s===-1?t.push(e):t.splice(s,0,e)}}return t},qr=(e,t)=>{let n=W(e.text,e.references).document,r=Kr(n.text);if(r===null)return n;let i={text:n.text,sessionTitles:t},a=[],o=``,s=0,c=0,l=new Set(n.references.map(e=>e.id)),u=[];for(let e of r){let{match:t,codec:r}=e,a=t.index,o=a+t[0].length;if(a<c||n.references.some(e=>e.start<o&&e.end>a))continue;let s=r.resolveDisplay(t,i);if(s===null||s.length>V.displayLength)continue;let d=r.materialize(t,s,a),f=d.id;for(;l.has(f);)f=`materialized:${f}`;l.add(f),u.push({start:a,end:o,display:s,reference:{...d,id:f}}),c=o}s=0;let d=0;for(let e of u){o+=`${n.text.slice(s,e.start)}${e.display}`;let t=e.start+d;a.push({...e.reference,start:t,end:t+e.display.length}),d+=e.display.length-(e.end-e.start),s=e.end}if(o+=n.text.slice(s),o.length>V.visibleTextLength)return n;let f=n.references.map(e=>{let t=u.filter(t=>t.end<=e.start).reduce((e,t)=>e+t.display.length-(t.end-t.start),0);return{...e,start:e.start+t,end:e.end+t}});return W(o,[...f,...a]).document},Jr=(e,t)=>qr({text:e,references:[]},t),Yr=(e,t,n=`
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,B as n,C as r,E as i,H as a,I as o,O as s,P as c,Q as l,S as u,T as d,b as f,f as p,i as m,p as h,r as g,rt as _,t as v,w as y,y as ee}from"./useUIStore-DwpQTjLO.js";import{a as te,i as ne,r as re}from"./vendor-zustand-B4dlGEM2.js";import{rt as ie}from"./vendor-base-ui-CnHfUmDN.js";import{i as ae}from"./vendor-pathe-vBmvQE8f.js";import{n as oe}from"./vendor-react-DLPElpoQ.js";import{t as se}from"./vendor-tanstack-query-core-BWz0ose6.js";var b=e=>e.startsWith(`/api/`)||e===`/api`||e.startsWith(`/auth/`)||e===`/auth`||e===`/health`,ce=()=>typeof window>`u`?``:window.location.origin||``,le=e=>{if(typeof window>`u`)return!1;let t=ce();if(t&&e.origin===t)return!0;try{let n=new URL(window.location.href||t);return e.protocol===n.protocol&&e.host===n.host}catch{return!1}},ue=e=>/^[a-z][a-z\d+.-]*:\/\//i.test(e),de=(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))},x=e=>{try{let t=c().api(`/api`);if(!/^[a-z][a-z\d+.-]*:\/\//i.test(t))return!1;let n=new URL(t);return e.origin===n.origin&&b(e.pathname)}catch{return!1}},fe=e=>{if(b(e))return!0;if(!/^[a-z][a-z\d+.-]*:\/\//i.test(e))return!1;try{let t=new URL(e);return le(t)&&b(t.pathname)}catch{return!1}},pe=(e,t)=>{try{let n=new URL(e);if(!le(n))return t&&x(n)?(de(n,t),n.toString()):e;let r=S(`${n.pathname}${n.search}`,t);return!ue(r)&&(n.protocol===`http:`||n.protocol===`https:`)?(de(n,t),n.toString()):n.hash?`${r}${n.hash}`:r}catch{return e}},S=(e,t)=>e===`/health`?c().health(t):e.startsWith(`/auth/`)||e===`/auth`?c().auth(e,t):b(e)?c().api(e,t):/^[a-z][a-z\d+.-]*:\/\//i.test(e)?pe(e,t):e,me=e=>{let t=e instanceof Request?e.url:e.toString();if(!ue(t))return b(t);try{return x(new URL(t))}catch{return!1}},he=/^\/api\/session\/(?!status$)([^/]+)(?:\/(?:message|children|todo|diff))?$/,ge=/^\/api\/openchamber\/sessions\/([^/]+)\/messages\/?$/,_e=null,ve=e=>{_e=e},ye=e=>{try{return decodeURIComponent(e)}catch{return e}},be=e=>_e?e===_e||ye(e)===_e:!1,xe=new Set([`/health`,`/api/opencode/health`,`/api/opencode/upgrade-status`,`/api/global/config`,`/api/project`,`/api/project/current`,`/api/config`,`/api/config/providers`,`/api/config/settings`,`/api/config/themes`,`/api/experimental/session`,`/api/session/status`,`/api/session-folders`,`/api/github/pr/status`,`/api/openchamber/session-index`]),Se=[`/api/agent`,`/api/command`,`/api/mcp`,`/api/lsp`,`/api/vcs`,`/api/question`,`/api/permission`,`/api/git/check`,`/api/git/primary-root`,`/api/git/discover`,`/api/git/status`,`/api/git/worktrees`,`/api/quota`],Ce=e=>xe.has(e)||Se.some(t=>e===t||e.startsWith(`${t}/`)),we=e=>{if(!ue(e))return b(e);try{return x(new URL(e))}catch{return!1}},Te=e=>{try{return new URL(e,`http://openchamber.local`).pathname}catch{return null}},Ee=[/^\/api\/session\/(?!status$)[^/]+\/message\/?$/,/^\/api\/session\/(?!status$)[^/]+\/message\/[^/]+\/?$/,/^\/api\/openchamber\/sessions\/[^/]+\/messages\/?$/,/^\/api\/openchamber\/sessions\/[^/]+\/messages\/reconcile\/?$/,/^\/api\/openchamber\/transcript-cache\/session\/?$/,/^\/api\/openchamber\/transcript-cache\/message\/?$/,/^\/api\/global\/event\/?$/,/^\/api\/event\/?$/],De=(e,t)=>o()||!t||e.toUpperCase()!==`GET`?!1:Ee.some(e=>e.test(t)),Oe=(e,t)=>{if(!e)return t;if(e instanceof URLSearchParams){let n=new URLSearchParams(e);for(let[e,r]of Object.entries(t))n.set(e,r);return n}return{...e,...t}},ke=(e,t)=>String(t.method??(e instanceof Request?e.method:`GET`)).toUpperCase(),Ae=e=>Te(e instanceof Request?e.url:e.toString()),je=(e,t,n)=>De(t,Ae(e))?Oe(n,{includeReasoning:`false`}):n,Me=(e,t)=>{if(e.toUpperCase()!==`GET`||!we(t))return;let n=Te(t);if(!n)return;let r=n.match(he);if(r?.[1]&&be(r[1]))return`high`;let i=n.match(ge);if(i?.[1]&&be(i[1]))return`high`;if(Ce(n))return`low`},Ne=e=>{for(let t=0;t<e.length;t+=1)if(e.charCodeAt(t)>255)return!1;return!0},Pe=(e,t)=>!Ne(t),Fe=e=>{if(!e)return;let t=e instanceof Headers?Array.from(e.entries()):Array.isArray(e)?e:Object.entries(e);if(t.length===0)return;let n=[],r=!1,i=!1;for(let[e,a]of t)Pe(e,a)?(n.push([e,encodeURIComponent(a)]),r=!0,e.toLowerCase()===`x-opencode-directory`&&(i=!0)):n.push([e,a]);return i&&n.push([`x-opencode-directory-encoding`,`uri`]),r?n:void 0},C=async(e,t,r=!0)=>{let i=new Headers(Fe(e)??e);return t&&new Headers(Fe(t)??t).forEach((e,t)=>i.set(t,e)),r?n(i):i},Ie=(e,t)=>{if(!t)return e;let n=new URL(e,_);return de(n,t),`${n.pathname}${n.search}`},Le=(e,t)=>{let n=e instanceof Request?e.url:e.toString();if(!ue(n))return b(n)?Ie(n,t):null;try{let e=new URL(n);return!le(e)||!b(e.pathname)?null:(de(e,t),`${e.pathname}${e.search}`)}catch{return null}},Re=async(e,t,n)=>{let r=l();if(!r)return null;let i=ke(e,t),a=Le(e,je(e,i,n));if(a===null)return null;let o=await C(e instanceof Request?e.headers:void 0,t.headers,!0);return e instanceof Request?i===`GET`&&De(i,Ae(e))?r.fetch(a,{...t,method:`GET`,headers:o,signal:t.signal??e.signal}):r.fetch(e,{...t,headers:o}):r.fetch(a,{...t,headers:o})},ze=(e,t)=>{if(typeof e==`string`)return S(e,t);if(e instanceof URL)return S(e.toString(),t);let n=S(e.url,t);return n===e.url?e:new Request(n,e)},Be=/\/api\/(config|path|app\/agents|agent|project|command|opencode\/upgrade-status)(\b|\/|\?|$)/,Ve=new Map,He=new WeakMap,Ue=1,We=e=>{let t=He.get(e);if(t)return t;let n=Ue;return Ue+=1,He.set(e,n),n},Ge=(e,t,n,r,i,a)=>n||!i||e!==`GET`||t.includes(`/event`)||!Be.test(t)?null:`GET ${a?`relay:${We(a)}`:`url:${t}`} ${t} auth:${r}`,Ke=async(e,t={})=>{let{query:n,...r}=t,i=ke(e,r),o=je(e,i,n),s=l(),c=s?Le(e,o):null,u=a(),d,f,p;if(s&&c!==null){let t=await C(e instanceof Request?e.headers:void 0,r.headers,!0);p=i,d=e instanceof Request&&p===`GET`&&De(p,Ae(e))?()=>s.fetch(c,{...r,method:`GET`,headers:t,signal:r.signal??e.signal}):e instanceof Request?()=>s.fetch(e,{...r,headers:t}):()=>s.fetch(c,{...r,headers:t}),f=c}else{let t=ze(e,o),n=await C(t instanceof Request?t.headers:void 0,r.headers,me(t));f=t instanceof Request?t.url:t instanceof URL?t.toString():String(t),p=String(r.method??(t instanceof Request?t.method:`GET`)).toUpperCase();let i=r.priority??Me(p,f),a=i?{...r,priority:i}:r;d=t instanceof Request?()=>fetch(new Request(t,{...a,headers:n})):()=>fetch(t,{...a,headers:n})}let m=r.signal!=null||e instanceof Request,h=Ge(p,f,m,u,u===a(),s&&c!==null?s:null);if(!h)return d();let g=Ve.get(h);if(g)return g.then(e=>e.clone());let _=d();return Ve.set(h,_),_.then(()=>Ve.delete(h),()=>Ve.delete(h)),_.then(e=>e.clone())},qe=!1,Je=()=>{if(qe||typeof window>`u`)return;qe=!0;let e=window.fetch.bind(window);window.fetch=async(t,n)=>{let r=await Re(t,n??{});if(r)return r;if(typeof t==`string`){if(!fe(t)){try{if(x(new URL(t))){let r=await C(void 0,n?.headers);return e(t,{...n,headers:r})}}catch{}return e(t,n)}let r=await C(void 0,n?.headers);return e(S(t),{...n,headers:r})}if(t instanceof URL){let r=t.toString();if(!fe(r)){if(x(t)){let r=await C(void 0,n?.headers);return e(t,{...n,headers:r})}return e(t,n)}let i=await C(void 0,n?.headers);return e(S(r),{...n,headers:i})}if(t instanceof Request){if(!fe(t.url)){try{if(x(new URL(t.url))){let r=await C(t.headers,n?.headers);return e(new Request(t,{...n,headers:r}))}}catch{}return e(t,n)}let r=await C(t.headers,n?.headers),i=S(t.url),a=i===t.url?t:new Request(i,t),o=await e(new Request(a,{...n,headers:r}));if(o.status>=500){let e=i;try{e=new URL(i).pathname}catch{}console.error(`[runtime-fetch] server request failed`,{method:a.method,path:e,status:o.status,statusText:o.statusText},Error(`runtime fetch received HTTP ${o.status}`))}return o}return e(t,n)}},Ye=[`local`,`remote`,null],Xe=[`ok`,`not-configured`,`unreachable`,`incompatible`,`wrong-service`,`missing`];function Ze(e){if(!e||typeof e!=`object`)return{valid:!1};let t=e,n=t.target,r=t.status;if(n!==null&&(typeof n!=`string`||!Ye.includes(n))||typeof r!=`string`||!Xe.includes(r))return{valid:!1};if(n===`remote`||n===`local`){if(r===`ok`&&n===`local`)return{valid:!0,outcome:{target:`local`,status:`ok`}};if(r===`ok`&&n===`remote`)return typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`ok`,hostId:t.hostId,url:t.url}};if(r===`unreachable`)return n===`local`?{valid:!0,outcome:{target:`local`,status:`unreachable`}}:typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`unreachable`,hostId:t.hostId,url:t.url}};if(r===`incompatible`||r===`wrong-service`)return n!==`remote`||typeof t.hostId!=`string`||typeof t.url!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:r,hostId:t.hostId,url:t.url}};if(r===`missing`)return n!==`remote`||typeof t.hostId!=`string`?{valid:!1}:{valid:!0,outcome:{target:`remote`,status:`missing`,hostId:t.hostId}}}if(n===null){if(r===`not-configured`)return{valid:!0,outcome:{target:null,status:`not-configured`}};if(r===`missing`)return{valid:!1}}return{valid:!1}}function Qe(e){if(!e.isDesktopShell)return null;let t=e.bootOutcome;if(!t)return null;if(t.status===`ok`){if(t.target===`local`)return{screen:`main`};if(t.target===`remote`)return{screen:`main`,hostId:t.hostId,url:t.url}}if(t.target===null&&t.status===`not-configured`)return{screen:`chooser`};if(t.target===`local`&&t.status===`unreachable`)return{screen:`recovery`,variant:`local-unavailable`};if(t.target===`remote`){if(t.status===`unreachable`)return{screen:`recovery`,variant:`remote-unreachable`,hostId:t.hostId,url:t.url};if(t.status===`incompatible`)return{screen:`recovery`,variant:`remote-incompatible`,hostId:t.hostId,url:t.url};if(t.status===`wrong-service`)return{screen:`recovery`,variant:`remote-wrong-service`,hostId:t.hostId,url:t.url};if(t.status===`missing`)return{screen:`recovery`,variant:`remote-missing`,hostId:t.hostId}}return null}function $e(e){return e.isDesktopShell?e.bootOutcomeKnown?e.bootViewIsMain===!1||e.isInitialized:!1:e.isInitialized}function et(e){return e.isDesktopShell&&!e.isDesktopLocalOriginActive}function tt(){if(rt()!==`valid`)return null;let e=Ze(nt());return e.valid?e.outcome:null}var nt=()=>{if(typeof window>`u`)return;let e=window.__OPENCHAMBER_DESKTOP_BOOT_OUTCOME__;if(e!=null)return e;let t=window.__OPENCHAMBER_DESKTOP_BOOT__;if(t&&typeof t.getOutcome==`function`)try{return t.getOutcome()}catch{return}return e};function rt(){if(typeof window>`u`)return`not-injected`;let e=nt();return e==null?`not-injected`:Ze(e).valid?`valid`:`malformed`}var it=null,at=e=>{it=e},ot=()=>it||(typeof window>`u`?null:window.__OPENCHAMBER_RUNTIME_APIS__??null),st=()=>typeof window>`u`?null:window.__OPENCHAMBER_ELECTRON__??null,w=()=>typeof window>`u`?null:window.__OPENCHAMBER_DESKTOP__??null,ct=()=>st()?.runtime===`electron`,lt=()=>ct()&&st()?.packaged===!0,ut=e=>{if(!ct())return null;let t=w()?.getPathForFile?.(e);return typeof t==`string`&&t.trim()?t:null},dt=()=>{if(typeof window>`u`)return null;let e=window.__OPENCHAMBER_PLATFORM__;return typeof e==`string`?e:null},ft=()=>{if(!ct())return!1;let e=dt();return e===`win32`||e===`linux`},pt=(e=dt())=>e===`linux`?`left`:`right`,mt=(e,t=dt())=>e===`left`||e===`right`?e:pt(t),T=()=>typeof w()?.invoke==`function`,E=()=>ct()&&T(),D=async(e,t)=>{let n=w();return typeof n?.invoke==`function`?n.invoke(e,t??{}):null},ht=async()=>{if(!E()||!O())return null;try{let e=await D(`desktop_get_launch_at_login`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`?null:e}catch(e){return console.warn(`Failed to get launch at login status`,e),null}},gt=async e=>{if(!E()||!O())return null;try{let t=await D(`desktop_set_launch_at_login`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`?null:t}catch(e){return console.warn(`Failed to set launch at login status`,e),null}},_t=async()=>{if(!E()||!O())return null;try{let e=await D(`desktop_get_minimize_to_tray`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`?null:e}catch(e){return console.warn(`Failed to get minimize to tray status`,e),null}},vt=async e=>{if(!E()||!O())return null;try{let t=await D(`desktop_set_minimize_to_tray`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`?null:t}catch(e){return console.warn(`Failed to set minimize to tray status`,e),null}},yt=async()=>{if(!E()||!O())return null;try{let e=await D(`desktop_get_keep_awake`);return!e||typeof e.supported!=`boolean`||typeof e.enabled!=`boolean`||typeof e.active!=`boolean`?null:e}catch(e){return console.warn(`Failed to get keep awake status`,e),null}},bt=async e=>{if(!E()||!O())return null;try{let t=await D(`desktop_set_keep_awake`,{enabled:e});return!t||typeof t.supported!=`boolean`||typeof t.enabled!=`boolean`||typeof t.active!=`boolean`?null:t}catch(e){return console.warn(`Failed to set keep awake status`,e),null}},xt=e=>{let t=e.trim();if(!t)return null;try{return new URL(t).origin}catch{try{return new URL(t.endsWith(`/`)?t:`${t}/`).origin}catch{return null}}},St=e=>{let t=e.trim();if(!t)return null;try{return new URL(t)}catch{try{return new URL(t.endsWith(`/`)?t:`${t}/`)}catch{return null}}},Ct=e=>e.replace(/^\[|\]$/g,``).toLowerCase(),wt=e=>{let t=Ct(e);return t===`localhost`||t===`127.0.0.1`||t===`::1`},O=()=>{if(typeof window>`u`||!Tt())return!1;if(d()===`local`)return!0;let e=typeof window.__OPENCHAMBER_LOCAL_ORIGIN__==`string`?window.__OPENCHAMBER_LOCAL_ORIGIN__:``,t=St(e),n=St(r());if(!n&&t&&tt()?.target===`local`)return!0;if(t&&n){if(t.origin===n.origin)return!0;let e=t.port||(t.protocol===`https:`?`443`:`80`),r=n.port||(n.protocol===`https:`?`443`:`80`);return t.protocol===n.protocol&&e===r&&wt(t.hostname)&&wt(n.hostname)}let i=St(window.location.origin);if(t&&i){if(t.origin===i.origin)return!0;let e=t.port||(t.protocol===`https:`?`443`:`80`),n=i.port||(i.protocol===`https:`?`443`:`80`);return t.protocol===i.protocol&&e===n&&wt(t.hostname)&&wt(i.hostname)}let a=xt(e),o=xt(window.location.origin)||window.location.origin;return a&&o&&a===o?!0:!!(i&&wt(i.hostname))},Tt=()=>typeof window>`u`?!1:ct(),Et=async()=>{if(!Tt())return!1;try{return await D(`desktop_start_window_drag`),!0}catch{return!1}},Dt=()=>ot()?.runtime?.isVSCode===!0,Ot=()=>{let e=ot()?.runtime?.platform;return e===`web`?!0:e===`desktop`||e===`vscode`?!1:!Dt()},kt=async()=>{if(typeof window<`u`){let e=window.__OPENCHAMBER_HOME__;if(e&&e.length>0)return e}return null},At=async e=>{if(T()&&O())try{let e=await w()?.openDialog?.({directory:!0,multiple:!1,title:`Select Working Directory`});return!e||typeof e!=`string`?{success:!1,error:`Directory selection cancelled`}:{success:!0,path:e}}catch(e){return console.warn(`Failed to request directory access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}return{success:!0,path:e}},jt=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Mt=async e=>{if(T()&&O())try{let t=await w()?.openDialog?.({directory:!1,multiple:!1,title:`Select File`,returnGrant:!0,...e?.filters?{filters:e.filters}:{},...e?.defaultPath?{defaultPath:e.defaultPath}:{}});if(!t)return{success:!1,error:`File selection cancelled`};if(typeof t==`string`)return{success:!0,path:t};if(!jt(t))return{success:!1,error:`File selection cancelled`};let n=typeof t.path==`string`?t.path:``;return n?{success:!0,path:n,outsideFileGrant:typeof t.outsideFileGrant==`string`?t.outsideFileGrant:void 0}:{success:!1,error:`File selection cancelled`}}catch(e){return console.warn(`Failed to request file access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}return{success:!1,error:`Native file picker not available`}},Nt=async e=>{let t=typeof e==`string`?e.trim():``;if(!t)return{success:!1,error:`Path is required`};if(!T()||!O())return{success:!1,error:`Native file access not available`};try{let e=await w()?.grantFileAccess?.(t);if(!jt(e))return{success:!1,error:`File access was not granted`};let n=typeof e.path==`string`?e.path:``,r=typeof e.outsideFileGrant==`string`?e.outsideFileGrant:``;return!n||!r?{success:!1,error:`File access was not granted`}:{success:!0,path:n,outsideFileGrant:r}}catch(e){return console.warn(`Failed to request existing file access`,e),{success:!1,error:e instanceof Error?e.message:String(e)}}},Pt=async e=>({success:!0}),Ft=async e=>({success:!0}),It=async()=>{if(!T())throw Error(`Desktop update checker is unavailable`);let e=await D(`desktop_check_for_updates`);if(!e)throw Error(`Desktop update checker returned no result`);return e},Lt=async e=>{let t=w();return typeof t?.listen==`function`?t.listen(`openchamber:update-progress`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let r=n;e({event:typeof r.event==`string`?r.event:void 0,data:r.data&&typeof r.data==`object`?r.data:void 0})}):null},Rt=async e=>{let t=w();return typeof t?.listen==`function`?t.listen(`openchamber:update-ready`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let r=n;e({version:typeof r.version==`string`?r.version:null,downloaded:r.downloaded===!0})}):null},zt=async e=>{if(!T())return!1;let t=w(),n=null,r=0,i;try{return typeof e==`function`&&t?.listen&&(n=await t.listen(`openchamber:update-progress`,t=>{let n=t?.payload;if(!n||typeof n!=`object`)return;let a=n,o=typeof a.event==`string`?a.event:null,s=a.data&&typeof a.data==`object`?a.data:null;if(o===`Started`){r=0,i=typeof s?.contentLength==`number`?s.contentLength:void 0,e({downloaded:r,total:i});return}if(o===`Progress`){let t=s?.downloaded,n=s?.total;typeof t==`number`&&(r=t),typeof n==`number`&&(i=n),e({downloaded:r,total:i});return}o===`Finished`&&e({downloaded:r,total:i})})),await D(`desktop_download_and_install_update`),!0}catch(e){throw e instanceof Error?e:Error(String(e))}finally{if(n)try{let e=n();e instanceof Promise&&await e}catch{}}},Bt=async()=>T()?Vt({applyUpdate:!0}):!1,Vt=async({applyUpdate:e=!1}={})=>{if(!T())return!1;try{return await D(`desktop_restart`,e?{applyUpdate:!0}:void 0),!0}catch(e){return console.warn(`Failed to restart desktop app`,e),!1}},Ht=async()=>{if(!T()||!O())return null;try{let e=await D(`desktop_get_lan_address`);return typeof e==`string`&&e.trim().length>0?e.trim():null}catch(e){return console.warn(`Failed to get desktop LAN address`,e),null}},Ut=async(e,t)=>{if(!T()||!O())return!1;let n=e?.trim();if(!n)return!1;try{return await D(`desktop_open_path`,{path:n,app:typeof t==`string`&&t.trim().length>0?t.trim():void 0}),!0}catch(e){return console.warn(`Failed to open path`,e),!1}},Wt=async e=>{if(!T()||!O())return null;let t=e?.trim();if(!t)return null;try{let e=await D(`desktop_is_binary_path`,{path:t});return typeof e==`boolean`?e:null}catch{return null}},Gt=async e=>{if(!T()||!O())return!1;let t=e?.trim();if(!t)return!1;try{return await D(`desktop_reveal_path`,{path:t}),!0}catch{return Ut(t)}},Kt=async(e,t)=>{if(!T()||!O())return null;let n=e?.trim();if(!n)return null;try{let e=await D(`desktop_save_markdown_file`,{defaultFileName:n,content:t});return typeof e==`string`&&e.trim().length>0?e:null}catch(e){return console.warn(`Failed to save markdown file`,e),null}},qt=async(e,t,n)=>{if(!T()||!O())return!1;let r=e?.trim(),i=t?.trim(),a=n?.trim();if(!r||!i||!a)return!1;try{return await D(`desktop_open_in_app`,{projectPath:r,appId:i,appName:a}),!0}catch(e){return console.warn(`Failed to open project in app`,e),!1}},Jt=async(e,t,n)=>{if(!T()||!O())return!1;let r=e?.trim(),i=t?.trim(),a=n?.trim();if(!r||!i||!a)return!1;try{return await D(`desktop_open_file_in_app`,{filePath:r,appId:i,appName:a}),!0}catch(e){return console.warn(`Failed to open file in app`,e),!1}},Yt=async(e,t)=>{if(!T()||!O())return{apps:[],success:!1,hasCache:!1,isCacheStale:!1};if(dt()===`linux`)return{apps:[],success:!0,hasCache:!1,isCacheStale:!1};let n=Array.isArray(e)?e.filter(e=>typeof e==`string`):[];if(n.length===0)return{apps:[],success:!0,hasCache:!1,isCacheStale:!1};try{let e=await D(`desktop_get_installed_apps`,{apps:n,force:t===!0||void 0});if(!e||typeof e!=`object`)return{apps:[],success:!1,hasCache:!1,isCacheStale:!1};let r=e;return r.supported===!1?{apps:[],success:!0,hasCache:!1,isCacheStale:!1}:Array.isArray(r.apps)?{apps:r.apps.filter(e=>e&&typeof e==`object`).map(e=>{let t=e;return{name:typeof t.name==`string`?t.name:``,iconDataUrl:typeof t.iconDataUrl==`string`?t.iconDataUrl:null}}).filter(e=>e.name.length>0),success:!0,hasCache:r.hasCache===!0,isCacheStale:r.isCacheStale===!0}:{apps:[],success:!1,hasCache:!1,isCacheStale:!1}}catch(e){return console.warn(`Failed to fetch installed apps`,e),{apps:[],success:!1,hasCache:!1,isCacheStale:!1}}},Xt=`oc.inst.`,Zt=e=>{try{return btoa(unescape(encodeURIComponent(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}catch{return encodeURIComponent(e)}},Qt=e=>{let t=(e??d()).trim();return t.length>0?t:`default`},$t=()=>{if(typeof window>`u`)return``;let e=window.__OPENCHAMBER_LOCAL_ORIGIN__;return typeof e==`string`?e.trim().replace(/\/+$/,``):``},k=(e,t=d())=>`${Xt}${Zt(Qt(t))}.${e}`,en=(e=d())=>Qt(e).startsWith(`relay:`),tn=(e=d())=>{let t=Qt(e);if(t==="default"||t===`local`)return!0;if(en(t)||!t.startsWith(`url:`))return!1;let n=$t();if(!n)return!1;try{return new URL(t.slice(4)).origin===new URL(n).origin}catch{return!1}},nn=(e=d())=>!en(e),rn=(e,t=r())=>{let n=t.trim().replace(/\/+$/,``);return n?`${e}:${encodeURIComponent(n)}`:null},an=(e,t)=>{let n=t?.storage??(typeof localStorage<`u`?localStorage:{getItem:()=>null}),r=t?.runtimeKey??d(),i=n.getItem(k(e,r));if(i!==null)return i;if(nn(r)){let t=rn(e),r=t?n.getItem(t):null;if(r!==null)return r}return tn(r)?n.getItem(e):null},A=(e,t,n)=>{let r=n?.storage??(typeof localStorage<`u`?localStorage:{setItem:()=>void 0}),i=n?.runtimeKey??d();r.setItem(k(e,i),t)},on=e=>({getItem:t=>an(t,{storage:e}),setItem:(t,n)=>{A(t,n,{storage:e})},removeItem:t=>{j(t,{storage:e})}}),j=(e,t)=>{let n=t?.storage??(typeof localStorage<`u`?localStorage:{removeItem:()=>void 0}),r=t?.runtimeKey??d();n.removeItem(k(e,r))},sn=e=>{let t;try{t=u()}catch{return}let n=t=>t===null?null:JSON.parse(t,e?.reviver),r=e=>t.getItem(e);return{getItem:e=>{let t=d(),i=k(e,t),a=r(i);if(a instanceof Promise)return a.then(i=>{if(i!==null)return n(i);if(!tn(t))return null;let a=r(e);return a instanceof Promise?a.then(n):n(a)});if(a!==null)return n(a);if(!tn(t))return null;let o=r(e);return o instanceof Promise?o.then(n):n(o)},setItem:(n,r)=>{let i=k(n,d());t.setItem(i,JSON.stringify(r,e?.replacer))},removeItem:e=>{let n=k(e,d());t.removeItem(n)}}},cn=(e=ln)=>{let t=new Map,n=0;return{countUnicodeCodePoints:r=>{let i=t.get(r);if(i!==void 0)return t.delete(r),t.set(r,i),i;let a=e(r);if(r.length>4e5)return a;for(;n+r.length>4e5&&t.size>0;){let e=t.keys().next().value;n-=e.length,t.delete(e)}return t.set(r,a),n+=r.length,a}}},ln=e=>{let t=0;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);if(r>=55296&&r<=56319&&n+1<e.length){let t=e.charCodeAt(n+1);t>=56320&&t<=57343&&(n+=1)}t+=1}return t},un=cn(),dn=e=>un.countUnicodeCodePoints(e),M=(e,t)=>{if(!e)throw Error(`${t} must be non-empty`);return e},fn=({transportIdentity:e},t)=>({transportIdentity:M(e,`transportIdentity`),owner:{kind:`session`,ownerID:M(t,`sessionID`)}}),pn=({transportIdentity:e},t)=>({transportIdentity:M(e,`transportIdentity`),owner:{kind:`draft`,ownerID:M(t,`draftID`)}}),mn=e=>{let t=typeof e.projectId==`string`?e.projectId.trim():``;if(t)return`new-session:project:${t}`;let n=typeof e.directory==`string`?e.directory.trim():``;return n?`new-session:directory:${n}`:`new-session:default`},hn=({transportIdentity:e},t)=>({transportIdentity:M(e,`transportIdentity`),owner:{kind:`surface`,ownerID:M(t,`surfaceID`)}}),gn=8192,_n=e=>{if(typeof e!=`string`||e.length===0||e.length>gn)return!1;try{let t=new URL(e).protocol;return t===`http:`||t===`https:`||t===`file:`}catch{return!1}},vn=e=>JSON.stringify([e.transportIdentity,e.owner.kind,e.owner.ownerID]),yn=e=>JSON.stringify([e.transportIdentity,e.owner.kind,e.owner.ownerID,e.attachmentOccurrenceRefID]),bn=e=>JSON.stringify([`root`,e]),xn=(e,t)=>JSON.stringify([`part`,e,t]),Sn={mentionCount:1e3,valueLength:8192,pathLength:8192,labelLength:512},N={referenceCount:1e3,idLength:512,displayLength:514,sessionIDLength:128,skillNameLength:511,commandNameLength:511,commandReferenceLength:8192,pastePayloadLength:1e5,totalPastePayloadLength:2e5},P=e=>{if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},F=(e,t)=>Object.keys(e).every(e=>t.includes(e)),I=e=>typeof e==`string`&&e.length>0,Cn=e=>typeof e==`string`,L=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,R=(e,t)=>typeof e==`string`&&e.length>0&&e.length<=t,wn=(e,t)=>{if(t<=0||t>=e.length)return!0;let n=e.charCodeAt(t-1),r=e.charCodeAt(t);return!(n>=55296&&n<=56319&&r>=56320&&r<=57343)},Tn=(e,t)=>{if(!Array.isArray(t)||t.length>Sn.mentionCount)return;let n=[],r=new Set,i=0;for(let a of t){if(!P(a)||!F(a,[`kind`,`value`,`path`,`label`,`range`])||a.kind!==`file`&&a.kind!==`directory`&&a.kind!==`agent`||!R(a.value,Sn.valueLength)||!R(a.path,Sn.pathLength)||!R(a.label,Sn.labelLength)||!P(a.range)||!F(a.range,[`start`,`end`])||!L(a.range.start)||!L(a.range.end)||a.range.end<=a.range.start||a.range.end>e.length||a.range.start<i||!wn(e,a.range.start)||!wn(e,a.range.end)||e.slice(a.range.start,a.range.end)!==`@${a.value}`)return;let t=JSON.stringify([a.kind,a.value,a.path,a.label,a.range.start,a.range.end]);if(r.has(t))return;r.add(t),i=a.range.end,n.push({kind:a.kind,value:a.value,path:a.path,label:a.label,range:{start:a.range.start,end:a.range.end}})}return n},En=e=>R(e,N.sessionIDLength)&&/^[A-Za-z0-9_-]+$/.test(e),Dn=e=>R(e,N.skillNameLength)&&/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(e),On=e=>R(e,N.commandNameLength)&&/^[\p{L}\p{N}._/-]+$/u.test(e),kn=e=>R(e,N.commandReferenceLength)&&!/[\]\r\n]/u.test(e),An=e=>{if(!(!P(e)||!R(e.id,N.idLength)||!R(e.display,N.displayLength)||!L(e.start)||!L(e.end)||e.end<=e.start)){if(e.kind===`session`&&F(e,[`id`,`kind`,`start`,`end`,`display`,`sessionId`])&&En(e.sessionId))return{id:e.id,kind:`session`,start:e.start,end:e.end,display:e.display,sessionId:e.sessionId};if(e.kind===`paste`&&F(e,[`id`,`kind`,`start`,`end`,`display`,`text`,`characterCount`,`index`])&&typeof e.text==`string`&&e.text.length<=N.pastePayloadLength&&L(e.characterCount)&&e.characterCount===dn(e.text)&&L(e.index)&&e.index>=1)return{id:e.id,kind:`paste`,start:e.start,end:e.end,display:e.display,text:e.text,characterCount:e.characterCount,index:e.index};if(e.kind===`skill`&&F(e,[`id`,`kind`,`start`,`end`,`display`,`skillName`])&&Dn(e.skillName)&&(e.display===`/${e.skillName}`||e.display===`/ ${e.skillName}`))return{id:e.id,kind:`skill`,start:e.start,end:e.end,display:e.display,skillName:e.skillName};if(e.kind===`command`&&F(e,[`id`,`kind`,`start`,`end`,`display`,`commandName`,`reference`])&&On(e.commandName)&&kn(e.reference)&&(e.display===`/${e.commandName}`||e.display===`/ ${e.commandName}`))return{id:e.id,kind:`command`,start:e.start,end:e.end,display:e.display,commandName:e.commandName,reference:e.reference}}},jn=(e,t)=>{if(!Array.isArray(t)||t.length>N.referenceCount)return;let n=t.map(An);if(!n.every(Boolean))return;let r=n,i=new Set,a=0,o=0;for(let t of r)if(i.has(t.id)||t.start<a||t.end>e.length||e.slice(t.start,t.end)!==t.display||(i.add(t.id),a=t.end,t.kind===`paste`&&(o+=t.text.length,o>N.totalPastePayloadLength)))return;return{text:e,references:r}},Mn=(e,t)=>{if(e===null||[`string`,`number`,`boolean`,`undefined`].includes(typeof e))return!0;if(typeof e!=`object`||e instanceof Blob||typeof File<`u`&&e instanceof File||!Array.isArray(e)&&!P(e)||t.has(e))return!1;t.add(e);let n=Object.values(e).every(e=>Mn(e,t));return t.delete(e),n},Nn=e=>{if(!(!P(e)||!F(e,[`kind`,`ownerID`])||!I(e.ownerID))&&(e.kind===`session`||e.kind===`draft`||e.kind===`surface`))return{kind:e.kind,ownerID:e.ownerID}},Pn=e=>{if(!P(e)||!F(e,[`transportIdentity`,`owner`])||!I(e.transportIdentity))return;let t=Nn(e.owner);return t?{transportIdentity:e.transportIdentity,owner:t}:void 0},Fn=e=>{if(!(!P(e)||!I(e.kind))){if(e.kind===`blob`&&F(e,[`kind`,`blobID`])&&I(e.blobID))return{kind:`blob`,blobID:e.blobID};if(!(e.kind!==`url`||!F(e,[`kind`,`url`])||!_n(e.url)))return{kind:`url`,url:e.url}}},In=(e,t,n)=>{try{let r=JSON.parse(e);return Array.isArray(r)?n===void 0?r.length===2&&r[0]===`root`&&r[1]===t:r.length===3&&r[0]===`part`&&r[1]===n&&r[2]===t:!1}catch{return!1}},Ln=(e,t)=>{if(!P(e)||!F(e,[`attachmentID`,`attachmentRefID`,`filename`,`mimeType`,`size`,`locator`,`source`,`serverPath`,`vscodePath`,`vscodeSource`])||!I(e.attachmentID)||!I(e.attachmentRefID)||!In(e.attachmentRefID,e.attachmentID,t)||!I(e.filename)||!Cn(e.mimeType)||!L(e.size)||e.source!==`local`&&e.source!==`vscode`&&e.source!==`server`||e.serverPath!==void 0&&!I(e.serverPath)||e.vscodePath!==void 0&&!I(e.vscodePath)||e.vscodeSource!==void 0&&e.vscodeSource!==`file`&&e.vscodeSource!==`selection`||e.source===`server`&&!I(e.serverPath)||e.source===`vscode`&&(!I(e.vscodePath)||e.vscodeSource!==`file`&&e.vscodeSource!==`selection`))return;let n=Fn(e.locator);if(n)return{attachmentID:e.attachmentID,attachmentRefID:e.attachmentRefID,filename:e.filename,mimeType:e.mimeType,size:e.size,locator:n,source:e.source,...e.serverPath===void 0?{}:{serverPath:e.serverPath},...e.vscodePath===void 0?{}:{vscodePath:e.vscodePath},...e.vscodeSource===void 0?{}:{vscodeSource:e.vscodeSource}}},Rn=e=>{if(!Mn(e,new Set)||!P(e)||!F(e,[`version`,`key`,`revision`,`text`,`attachments`,`syntheticParts`,`mentions`,`composerReferences`])||e.version!==1||!L(e.revision)||e.revision<1||typeof e.text!=`string`||!Array.isArray(e.attachments)||!Array.isArray(e.syntheticParts)||!Array.isArray(e.mentions))return;let t=e.text,n=Pn(e.key),r=e.attachments.map(e=>Ln(e)),i=e.syntheticParts.map(e=>{if(!P(e)||!F(e,[`partID`,`text`,`attachments`,`synthetic`])||!I(e.partID)||typeof e.text!=`string`||!Array.isArray(e.attachments)||e.synthetic!==void 0&&typeof e.synthetic!=`boolean`)return;let t=e.partID,n=e.text,r=e.attachments.map(e=>Ln(e,t));return r.every(Boolean)?{partID:t,text:n,attachments:r,...e.synthetic===void 0?{}:{synthetic:e.synthetic}}:void 0}),a=Tn(t,e.mentions),o=e.composerReferences===void 0?{text:t,references:[]}:jn(t,e.composerReferences);if(!n||!r.every(Boolean)||!i.every(Boolean)||!a||!o)return;let s=r,c=i,l=new Set;for(let e of[...s,...c.flatMap(e=>e.attachments)]){if(l.has(e.attachmentRefID))return;l.add(e.attachmentRefID)}if(new Set(c.map(e=>e.partID)).size===c.length)return{version:1,key:n,revision:e.revision,text:t,attachments:s,syntheticParts:c,mentions:a,...e.composerReferences===void 0?{}:{composerReferences:o.references}}},zn=e=>Rn(e),z=` `,Bn=`0.2em`,Vn=`size-[1em]`,Hn=e=>e.startsWith(z)?e.slice(z.length):e,Un=e=>e.replaceAll(`/${z}`,`/`).replaceAll(`@${z}`,`@`).replaceAll(`[${z}`,`[`),Wn=e=>{let t=e.match(/^\s*/)?.[0].length??0,n=e.slice(t);if(!n.startsWith(`/`))return null;let r=1;n.startsWith(z,r)&&(r+=z.length);let i=n.slice(r);if(!i)return null;let a=i.search(/\s/u),o=a===-1?i:i.slice(0,a);return o?{commandName:o,argumentsText:a===-1?``:i.slice(a).trim()}:null},Gn=e=>B({trigger:`[`,icon:`file-image`,label:e,suffix:`]`}),Kn=({trigger:e,label:t,suffix:n=``})=>`${e}${t}${n}`,B=e=>`${e.trigger}${z}${e.label}${e.suffix??``}`,qn=e=>Kn(e),Jn=(e,t)=>e===qn(t)||e===B(t),Yn=(e,t)=>{let n=t===B(e);return{trigger:n?`${e.trigger}${z}`:e.trigger,icon:e.icon,align:e.align??`end`,label:e.label,suffix:e.suffix,slot:n?`reserved`:`compact`}},Xn=(e,t,n=``)=>{let r=e.startsWith(t)?e.slice(t.length):e,i=r.startsWith(z)?r.slice(z.length):r;return n&&i.endsWith(n)?i.slice(0,-n.length):i},Zn=(e,t)=>e===t||!!e&&!!t&&e.trigger===t.trigger&&e.icon===t.icon&&e.align===t.align&&e.label===t.label&&e.suffix===t.suffix&&e.slot===t.slot,Qn=0n,$n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,er=14;function tr(e){let t=``;for(let n=0;n<e;n++)t+=$n[Math.floor(Math.random()*62)];return t}var nr=/^[0-9a-f]{12}$/,rr=/^[0-9A-Za-z]{14}$/,ir=(1n<<48n)-1n,ar=(e,t)=>{if(typeof t!=`string`||!t.startsWith(`${e}_`))return;let n=t.slice(e.length+1),r=n.slice(0,12);if(!(!nr.test(r)||!rr.test(n.slice(12))))return BigInt(`0x${r}`)},or=(e,t)=>{let n=BigInt(Date.now())*4096n&ir,r=ar(e,t)??0n,i=[n,Qn,r].reduce((e,t)=>e>t?e:t);if(i>=ir)throw Error(`Ascending ID space exhausted`);let a=i+1n;Qn=a;let o=new Uint8Array(6);for(let e=0;e<6;e++)o[e]=Number(a>>BigInt(40-8*e)&BigInt(255));let s=``;for(let e=0;e<o.length;e++)s+=o[e].toString(16).padStart(2,`0`);return`${e}_${s}${tr(er)}`},sr=e=>or(e),cr=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/g,``).trim();if(!t)return``;let n=new TextEncoder().encode(t),r=``;for(let e of n)r+=String.fromCharCode(e);return`path_${typeof btoa==`function`?btoa(r).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``):t.replace(/[^A-Za-z0-9._-]+/g,`_`)}`},lr=()=>globalThis.crypto===void 0?null:{randomUUID:typeof globalThis.crypto.randomUUID==`function`?()=>globalThis.crypto.randomUUID():void 0,getRandomValues:typeof globalThis.crypto.getRandomValues==`function`?e=>globalThis.crypto.getRandomValues(e):void 0},ur=(e=lr())=>{try{let t=e?.randomUUID?.();if(t)return t}catch{}let t=new Uint8Array(16),n=!1;try{e?.getRandomValues&&(e.getRandomValues(t),n=!0)}catch{}if(!n)for(let e=0;e<t.length;e+=1)t[e]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let r=Array.from(t,e=>e.toString(16).padStart(2,`0`));return`${r.slice(0,4).join(``)}-${r.slice(4,6).join(``)}-${r.slice(6,8).join(``)}-${r.slice(8,10).join(``)}-${r.slice(10).join(``)}`},dr=e=>/^[\\/]+$/.test(e),fr=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;if(dr(t))return t.length===1?`/`:null;let n=ae(t);return n===`/`?`/`:(n.length>1?n.replace(/\/+$/,``):n)||null},pr=e=>{if(typeof e!=`string`)return``;let t=e.trim();return t?fr(t)??t:``},V={...N,sessionIdLength:N.sessionIDLength,visibleTextLength:1e5,canonicalOutputLength:2e5},mr=e=>typeof e==`string`&&En(e),hr=e=>e.replaceAll(`\\`,`/`).split(`/`).at(-1)?.replace(/\.md$/,``)??``,gr=e=>({trigger:`@`,icon:`chat-thread`,label:e}),_r=(e,t)=>({trigger:`/`,icon:t,label:e}),vr={session:{kind:`session`,validatePayload:e=>mr(e.sessionId),contributeCanonical:e=>({text:`@session:${e.sessionId}`,semantic:{type:`session`,sessionId:e.sessionId}}),contributeDirectSend:e=>({text:qn(gr(Xn(e.display,`@`))),semantic:{type:`session`,sessionId:e.sessionId}}),decorate:e=>({style:`mentionSession`,visual:Yn(gr(Xn(e.display,`@`)),e.display)}),payloadBudget:()=>void 0,canonical:{matcher:/@session:([A-Za-z0-9_-]+)/g,resolveDisplay:(e,t)=>{let n=e.index===0?``:t.text[e.index-1],r=t.text[e.index+e[0].length]??``;return(n===``||/[\s([{]/.test(n))&&(r===``||/[\s)\]},.!?;:]/.test(r))?B(gr(t.sessionTitles.get(e[1])||e[1])):null},materialize:(e,t,n)=>({id:`session:${e[1]}:${e.index}`,kind:`session`,sessionId:e[1],display:t,start:n,end:n+t.length})}},paste:{kind:`paste`,validatePayload:e=>typeof e.text==`string`&&e.text.length<=V.pastePayloadLength&&typeof e.characterCount==`number`&&Number.isSafeInteger(e.characterCount)&&e.characterCount===dn(e.text)&&typeof e.index==`number`&&Number.isSafeInteger(e.index)&&e.index>=1,contributeCanonical:e=>({text:e.text}),contributeDirectSend:e=>({text:e.text}),decorate:()=>({style:`mentionPaste`}),payloadBudget:e=>({category:`opaque-text`,length:e.text.length})},skill:{kind:`skill`,validatePayload:e=>Dn(e.skillName)&&typeof e.display==`string`&&Jn(e.display,_r(e.skillName,`book-open`)),contributeCanonical:e=>({text:`[skill:${e.skillName}]`}),contributeDirectSend:e=>({text:`[skill:${e.skillName}]`}),decorate:e=>({style:`mentionCommand`,skillName:e.skillName,visual:Yn(_r(e.skillName,`book-open`),e.display)}),payloadBudget:()=>void 0,canonical:{matcher:/\[skill:([A-Za-z0-9][A-Za-z0-9_-]*)\]/g,resolveDisplay:e=>B(_r(e[1],`book-open`)),materialize:(e,t,n)=>({id:`skill:${n}`,kind:`skill`,skillName:e[1],display:t,start:n,end:n+t.length})}},command:{kind:`command`,validatePayload:e=>On(e.commandName)&&kn(e.reference)&&typeof e.display==`string`&&Jn(e.display,_r(e.commandName,`command`)),contributeCanonical:e=>({text:`[command:${e.reference}]`}),contributeDirectSend:e=>({text:`[command:${e.reference}]`}),decorate:e=>({style:`mentionCommand`,visual:Yn(_r(e.commandName,`command`),e.display)}),payloadBudget:()=>void 0,canonical:{matcher:/\[command:([^\]\r\n]+)\]/g,resolveDisplay:e=>{let t=hr(e[1]);return kn(e[1])&&On(t)?B(_r(t,`command`)):null},materialize:(e,t,n)=>({id:`command:${n}`,kind:`command`,commandName:hr(e[1]),reference:e[1],display:t,start:n,end:n+t.length})}}},H=e=>vr[e],yr=(e,t)=>H(e).validatePayload(t),br=e=>H(e.kind).contributeCanonical(e),xr=e=>H(e.kind).contributeDirectSend(e),Sr=e=>H(e.kind).decorate(e),Cr=e=>H(e.kind).payloadBudget(e),wr=e=>H(e.kind).describeResourceIdentity?.(e),Tr=Object.keys(vr),Er=e=>typeof e==`string`&&Tr.includes(e),Dr=()=>Tr.flatMap(e=>{let t=H(e).canonical;return t?[t]:[]}),Or=e=>{if(e.type===`attachment`)return`attachment:${e.attachmentRefID}`},kr=e=>{let t=new Map;for(let n of e.references){let e=wr(n);e&&t.set(Or(e),e)}return[...t.values()]},Ar=(e,t)=>{let n=new Map(e.map(e=>[Or(e),e])),r=new Map(t.map(e=>[Or(e),e]));return{previous:[...n.values()],next:[...r.values()],added:[...r].flatMap(([e,t])=>n.has(e)?[]:[t]),removed:[...n].flatMap(([e,t])=>r.has(e)?[]:[t])}},jr=(e,t)=>Ar(kr(e),kr(t)),Mr=(e,t=`queue-canonical`)=>{if(e.references.length>V.referenceCount)return{ok:!1,reason:`reference-budget-exceeded`};let n=[...e.references].sort((e,t)=>e.start-t.start),r=0,i=0;for(let t of n){if(t.start<r||t.start<0||t.end<=t.start||t.end>e.text.length||e.text.slice(t.start,t.end)!==t.display)return{ok:!1,reason:`invalid-references`};r=t.end;let n=Cr(t);i+=n?.category===`opaque-text`?n.length:0}if(i>V.totalPastePayloadLength)return{ok:!1,reason:`reference-payload-budget-exceeded`};let a=[],o=[],s=0;for(let r of n){s<r.start&&a.push({provenance:`authored`,text:e.text.slice(s,r.start),start:s,end:r.start});let n=t===`direct-send-display`?xr(r):br(r);n.semantic?(a.push({provenance:`generated-reference`,text:n.text,start:r.start,end:r.end,referenceId:r.id,semantic:n.semantic}),o.push(n.semantic)):a.push({provenance:`reference-payload`,text:n.text,start:r.start,end:r.end,referenceId:r.id}),s=r.end}s<e.text.length&&a.push({provenance:`authored`,text:e.text.slice(s),start:s,end:e.text.length});let c=a.map(e=>e.text).join(``);return c.length>V.canonicalOutputLength?{ok:!1,reason:`canonical-output-too-large`}:{ok:!0,plan:{chunks:a,semantics:o},text:c}},U=(e,t)=>Math.max(0,Math.min(e,t)),Nr=(e,t)=>typeof e==`string`&&e.length>0&&e.length<=t,Pr=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return!Nr(t.id,V.displayLength)||!Nr(t.display,V.displayLength)||!Number.isSafeInteger(t.start)||!Number.isSafeInteger(t.end)||typeof t.kind!=`string`?!1:Er(t.kind)&&yr(t.kind,t)},W=(e,t)=>{let n=[],r=0,i=[],a=Math.min(t.length,V.referenceCount);for(let e=0;e<a;e+=1){let a=t[e];if(!Pr(a)){typeof a==`object`&&a&&typeof a.id==`string`&&n.push(a.id),r+=1;continue}i.push({reference:a,index:e})}i.sort((e,t)=>e.reference.start-t.reference.start||e.index-t.index);let o=[],s=new Set,c=0,l=0,u=!1;for(let{reference:t}of i){if(s.has(t.id)||t.start<c||t.start<0||t.end<=t.start||t.end>e.length||e.slice(t.start,t.end)!==t.display){n.push(t.id),r+=1;continue}s.add(t.id),c=t.end;let i=Cr(t);if(l+=i?.category===`opaque-text`?i.length:0,l>N.totalPastePayloadLength){n.push(t.id),r+=1,s.delete(t.id),c=o.at(-1)?.end??0,u=!0,l-=i?.category===`opaque-text`?i.length:0;continue}o.push(t)}return r+=t.length-a,{document:{text:e,references:o},rejectedIds:n,rejectedCount:r,budgetExceeded:t.length>V.referenceCount,payloadBudgetExceeded:u}},G=e=>{let t=[...e.references].sort((e,t)=>e.start-t.start||e.end-t.end),n=[],r=new Set,i=0,a=0;for(let o of t){if(!Nr(o.id,V.idLength)||!Nr(o.display,V.displayLength)||!Er(o.kind)||!Number.isSafeInteger(o.start)||!Number.isSafeInteger(o.end)||r.has(o.id)||o.start<i||o.start<0||o.end<=o.start||o.end>e.text.length||e.text.slice(o.start,o.end)!==o.display)continue;let t=Cr(o),s=t?.category===`opaque-text`?t.length:0;a+s>N.totalPastePayloadLength||(r.add(o.id),i=o.end,a+=s,n.push(o))}return{text:e.text,references:n}},Fr=(e,t)=>{if(t.length>N.pastePayloadLength)return!1;let n=W(e.text,e.references);return n.budgetExceeded||n.payloadBudgetExceeded?!1:n.document.references.reduce((e,t)=>{let n=Cr(t);return e+(n?.category===`opaque-text`?n.length:0)},0)+t.length<=N.totalPastePayloadLength},Ir=(e,t,n)=>{let r=e.filter(e=>t===n?t>e.start&&t<e.end:e.start<n&&e.end>t);return r.length===0?{start:t,end:n}:{start:Math.min(t,...r.map(e=>e.start)),end:Math.max(n,...r.map(e=>e.end))}};function Lr(e,t,n,r,i={}){let a=G(e);if(!yr(r.kind,r))return{document:a,caret:U(n,a.text.length),edit:{oldStart:t,oldEnd:n,newEnd:n}};let o=U(t,a.text.length),s=Math.max(o,U(n,a.text.length)),c=Ir(a.references,o,s),l=a.text.slice(0,c.start),u=a.text.slice(c.end),d=!!i.padDocumentEdges&&i.padLeadingDocumentEdge!==!1,f=!!i.padDocumentEdges,p=i.inlineBoundaries&&(l.length>0||d)&&!/\s$/.test(l)?` `:``,m=i.inlineBoundaries&&(u.length>0||f)&&!/^\s/.test(u)?` `:``,h=`${l}${p}${r.display}${m}${u}`,g={...r,start:c.start+p.length,end:c.start+p.length+r.display.length},_=p.length+r.display.length+m.length-(c.end-c.start);return{document:G({text:h,references:[...a.references.filter(e=>e.end<=c.start||e.start>=c.end).map(e=>e.start>=c.end?{...e,start:e.start+_,end:e.end+_}:e),g]}),caret:g.end,edit:{oldStart:c.start,oldEnd:c.end,newEnd:c.start+p.length+r.display.length+m.length}}}var Rr=(e,t)=>e<=t.oldStart?e:e>=t.oldEnd?e+t.newEnd-t.oldEnd:t.newEnd,zr=(e,t,n=t.length,r=n)=>{let i=G(e),a=0,o=Math.min(i.text.length,t.length);for(;a<o&&i.text[a]===t[a];)a+=1;let s=0;for(;s<i.text.length-a&&s<t.length-a&&i.text[i.text.length-s-1]===t[t.length-s-1];)s+=1;let c={oldStart:a,oldEnd:i.text.length-s,newEnd:t.length-s},l=Ir(i.references,c.oldStart,c.oldEnd),u=l.start!==c.oldStart||l.end!==c.oldEnd,d=i.references.filter(e=>e.start<l.end&&e.end>l.start),f=t.slice(c.oldStart,c.newEnd),p=`${i.text.slice(0,l.start)}${f}${i.text.slice(l.end)}`,m={oldStart:l.start,oldEnd:l.end,newEnd:l.start+f.length},h=m.newEnd-m.oldEnd,g=i.references.filter(e=>e.end<=l.start||e.start>=l.end).map(e=>e.start>=l.end?{...e,start:e.start+h,end:e.end+h}:e),_=(e,n)=>{let r=U(e,t.length),i=c.newEnd+l.end-c.oldEnd;return U(r<=l.start?r:r<c.oldStart||r===c.oldStart&&n===`start`?l.start:r<c.newEnd||r===c.newEnd&&n===`start`?l.start+r-c.oldStart:r<=i?m.newEnd:m.newEnd+r-i,p.length)},v=_(n,`start`),y=Math.max(v,_(r,`end`)),ee=G({text:p,references:g});return{document:ee,edit:m,requiresTextCorrection:u,selectionStart:v,selectionEnd:y,caret:y,mapCaret:e=>U(Rr(e,m),ee.text.length),removedReferences:d}},Br=(e,t,n)=>{let r=Ir(n,e,t);return r.start===e&&r.end===t?null:r},Vr=(e,t,n)=>{let r=n,i=n;if(t===`Backspace`){for(;r>0&&/\s/.test(e[r-1]);)--r;for(;r>0&&!/\s/.test(e[r-1]);)--r}else{for(;i<e.length&&/\s/.test(e[i]);)i+=1;for(;i<e.length&&!/\s/.test(e[i]);)i+=1}return{start:r,end:i}},Hr=(e,t)=>{let n=G(e),r=U(t.selectionStart,n.text.length),i=Math.max(r,U(t.selectionEnd,n.text.length)),a=r===i?t.altKey?Vr(n.text,t.key,r):t.key===`Backspace`?{start:Math.max(0,r-1),end:r}:{start:r,end:Math.min(n.text.length,r+1)}:{start:r,end:i},o=Br(a.start,a.end,n.references);if(!o)return null;let s=n.references.filter(e=>e.start<o.end&&e.end>o.start);return{document:G({text:`${n.text.slice(0,o.start)}${n.text.slice(o.end)}`,references:n.references.filter(e=>!s.includes(e)).map(e=>e.start>=o.end?{...e,start:e.start-(o.end-o.start),end:e.end-(o.end-o.start)}:e)}),caret:o.start,edit:{oldStart:o.start,oldEnd:o.end,newEnd:o.start},removedIds:s.map(e=>e.id),removedReferences:s}},Ur=(e,t)=>{let n=t,r=t;for(;n>0&&/\s/.test(e[n-1]);)--n;for(;r<e.length&&/\s/.test(e[r]);)r+=1;let i=n>0&&r<e.length?` `:``;return{text:`${e.slice(0,n)}${i}${e.slice(r)}`,caret:n+i.length}},Wr=(e,t=`queue-canonical`)=>{let n=W(e.text,e.references);if(n.budgetExceeded)return{ok:!1,reason:`reference-budget-exceeded`};if(n.payloadBudgetExceeded)return{ok:!1,reason:`reference-payload-budget-exceeded`};if(n.rejectedCount>0)return{ok:!1,reason:`invalid-references`};let r=Mr(n.document,t);return r.ok?{ok:!0,text:r.text,chunks:r.plan.chunks,semantics:r.plan.semantics}:r},Gr=(e,t)=>e.match.index-t.match.index||e.adapterOrder-t.adapterOrder||e.matchOrder-t.matchOrder,Kr=e=>{if(e.length>V.canonicalOutputLength||e.length>V.visibleTextLength)return null;let t=[],n=0;for(let[r,i]of Dr().entries()){i.matcher.lastIndex=0;let a,o=0;for(;(a=i.matcher.exec(e))!==null;){if(n+=1,n>V.referenceCount)return null;let e={codec:i,match:a,adapterOrder:r,matchOrder:o};o+=1;let s=t.findIndex(t=>Gr(e,t)<0);s===-1?t.push(e):t.splice(s,0,e)}}return t},qr=(e,t)=>{let n=W(e.text,e.references).document,r=Kr(n.text);if(r===null)return n;let i={text:n.text,sessionTitles:t},a=[],o=``,s=0,c=0,l=new Set(n.references.map(e=>e.id)),u=[];for(let e of r){let{match:t,codec:r}=e,a=t.index,o=a+t[0].length;if(a<c||n.references.some(e=>e.start<o&&e.end>a))continue;let s=r.resolveDisplay(t,i);if(s===null||s.length>V.displayLength)continue;let d=r.materialize(t,s,a),f=d.id;for(;l.has(f);)f=`materialized:${f}`;l.add(f),u.push({start:a,end:o,display:s,reference:{...d,id:f}}),c=o}s=0;let d=0;for(let e of u){o+=`${n.text.slice(s,e.start)}${e.display}`;let t=e.start+d;a.push({...e.reference,start:t,end:t+e.display.length}),d+=e.display.length-(e.end-e.start),s=e.end}if(o+=n.text.slice(s),o.length>V.visibleTextLength)return n;let f=n.references.map(e=>{let t=u.filter(t=>t.end<=e.start).reduce((e,t)=>e+t.display.length-(t.end-t.start),0);return{...e,start:e.start+t,end:e.end+t}});return W(o,[...f,...a]).document},Jr=(e,t)=>qr({text:e,references:[]},t),Yr=(e,t,n=`
|
|
2
2
|
|
|
3
|
-
`)=>{let r=W(e.text,e.references).document,i=W(t.text,t.references).document;if(r.text===i.text&&JSON.stringify(r.references)===JSON.stringify(i.references))return i;let a=new Set(r.references.map(e=>e.id)),o=e=>{let t=e;for(;a.has(t);)t=`recovered:${t}`;return a.add(t),t},s=r.text.length+n.length;return W(`${r.text}${n}${i.text}`,[...r.references,...i.references.map(e=>({...e,id:o(e.id),start:e.start+s,end:e.end+s}))]).document},Xr=e=>({state:`unbound-legacy`,sessionID:e}),K=e=>e.state===`bound`?`bound:${JSON.stringify([e.transportIdentity,pr(e.directory),e.sessionID,e.deliveryTarget??{kind:`primary`}])}`:`unbound-legacy:${JSON.stringify([e.sessionID])}`,Zr=(e,t)=>e.queuedMessages[K(t)]??Qr,Qr=[],$r=3e4,ei=`queue`,ti=e=>e===`steer`||e===`queue`,ni=(e,t)=>e===`immediate`?`steer`:ti(e)?e:t===!1?`steer`:`queue`,ri=[],ii=(e,t)=>e.pendingAdmissions[K(t)]??ri,ai=e=>`${e}-${ur()}`,oi=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype,si=(e,t,n=[])=>{if(!oi(e)||!Object.keys(e).every(e=>e===`text`||e===`references`))return;let r=e;if(typeof r.text!=`string`)return;let i=jn(r.text,r.references),a=i&&Wr(i,`queue-canonical`);if(!a||!a.ok||a.text!==t)return;let o=new Set(n.map(e=>e.id));return kr(i).every(e=>o.has(e.attachmentRefID))?i:void 0},ci=(e,t)=>{if(e===void 0)return[];if(!t)return;let n=Tn(t.text,e);if(n)return n.some(e=>t.references.some(t=>e.range.start<t.end&&t.start<e.range.end))?void 0:n},li=(e,t)=>{let n=oi(e)&&typeof e.content==`string`?e:t,r=si(n.composerDocument,n.content,Array.isArray(n.attachments)?n.attachments:[]),i=ci(n.composerMentions,r);return{content:n.content,...r?{composerDocument:r}:{},...r&&i?.length?{composerMentions:i}:{},...Array.isArray(n.attachments)?{attachments:n.attachments}:{},...oi(n.sendConfig)?{sendConfig:n.sendConfig}:{}}},ui=e=>li(void 0,e),di=(e,t)=>e.queueItemID===t.queueItemID&&e.operationID===t.operationID&&(!t.messageID||e.messageID===t.messageID),q=e=>e.status===`sending`||e.status===`reconciling`,fi=ee(),pi=()=>fi?.flush()??!0,mi=`quiescing`,hi=new Set,gi=new Set,_i=e=>{if(mi!==e){mi=e;for(let e of gi)e()}},vi=e=>{if(!(!e||hi.has(e))){hi.add(e);for(let e of gi)e()}},yi=e=>e.state===`bound`&&hi.has(e.transportIdentity),J=e=>mi===`open`&&(!e||!yi(e)),bi=(e,t=Date.now())=>({reconciliationStartedAt:e.reconciliationStartedAt??t,reconciliationDeadlineAt:e.reconciliationDeadlineAt??(e.reconciliationStartedAt??t)+$r,reconciliationChecks:Math.max(0,Math.floor(e.reconciliationChecks??0))}),xi=(e,t,n)=>{let r=t.queueItemID??(t.id||ai(`queued`)),i=!t.owner&&(t.status===`sending`||t.status===`reconciling`),a=i?`unresolved`:t.status===`sending`?`reconciling`:t.status===`retrying`||t.status===`reconciling`||t.status===`unresolved`||t.status===`failed`?t.status:`queued`,o=typeof t.messageID==`string`&&t.messageID.startsWith(`msg_`)?t.messageID:sr(`msg`),s=si(t.composerDocument,t.content,t.attachments),c=ci(t.composerMentions,s);return{...t,...s?{composerDocument:s}:{composerDocument:void 0},...s&&c?.length?{composerMentions:c}:{composerMentions:void 0},id:r,queueItemID:r,operationID:t.operationID??ai(`operation`),messageID:o,owner:n,status:a,attemptCount:Math.max(0,Math.floor(t.attemptCount??0)),...t.status===`sending`||t.status===`reconciling`?bi(t):{},...i||a===`reconciling`&&t.status===`sending`?{failure:{kind:`ambiguous-dispatch`,recovery:li(t.failure?.recovery,t)}}:{}}},Si=e=>{let t=e??{},n={};for(let[e,r]of Object.entries(t.queuedMessages??{})){if(!Array.isArray(r))continue;let t;if(e.startsWith(`bound:`)||e.startsWith(`unbound-legacy:`)){let n=r[0],i=e.startsWith(`unbound-legacy:`)?(()=>{try{let t=JSON.parse(e.slice(15));return Array.isArray(t)&&typeof t[0]==`string`?t[0]:e}catch{return e}})():e;t=n?.owner?.state===`bound`?n.owner:Xr(n?.owner?.sessionID??i)}else t=Xr(e);for(let e of r){let r=e.owner?.state===`bound`?e.owner:t,i=K(r);(n[i]??=[]).push(xi(r.sessionID,e,r))}}return{queuedMessages:n,followUpBehavior:ni(t.followUpBehavior,t.queueModeEnabled??null)}},Y=(e,t,n,r)=>{if(yi(t))return;let i=K(t);e(e=>{let t=e.queuedMessages[i],a=t?.findIndex(e=>K(e.owner)===i&&di(e,n))??-1;if(a<0||!t)return e;let o=r(t[a]);if(o===t[a])return e;let s=t.slice();return s[a]=o,{queuedMessages:{...e.queuedMessages,[i]:s}}})},Ci=te()(re(ne((e,t)=>({queuedMessages:{},followUpBehavior:ei,pendingAdmissions:{},addToQueue:(t,n)=>{if(!J(t))return{ok:!1,reason:`invalid-composer-document`};let r=si(n.composerDocument,n.content,n.attachments);if(n.composerDocument!==void 0&&!r)return{ok:!1,reason:`invalid-composer-document`};let i=ci(n.composerMentions,r);if(n.composerMentions!==void 0&&!i)return{ok:!1,reason:`invalid-composer-mentions`};n={...n,...r?{composerDocument:r}:{},...i?.length?{composerMentions:i}:{}};let a={...n,id:ai(`queued`),queueItemID:``,operationID:ai(`operation`),messageID:sr(`msg`),createdAt:Date.now(),owner:t,status:`queued`,attemptCount:0};a.queueItemID=a.id;let o=K(t);return e(e=>({queuedMessages:{...e.queuedMessages,[o]:[...e.queuedMessages[o]??[],a]}})),{ok:!0,item:a}},removeFromQueue:(n,r,i)=>{if(!J(n)||!i)return!1;let a=K(n),o=t().queuedMessages[a];if(!o||o.length===0)return!0;let s=o.find(e=>(e.queueItemID===r||e.id===r)&&K(e.owner)===a);if(s&&s.operationID!==i)return!1;let c=o.find(e=>(e.queueItemID===r||e.id===r)&&e.operationID===i&&K(e.owner)===a);return!c||!q(c)&&(e(e=>{let t=e.queuedMessages[a];if(!t)return e;let n=t.filter(e=>e!==c);if(n.length===t.length)return e;if(n.length)return{queuedMessages:{...e.queuedMessages,[a]:n}};let{[a]:r,...i}=e.queuedMessages;return{queuedMessages:i}}),!Zr(t(),n).some(e=>e===c||(e.queueItemID===r||e.id===r)&&e.operationID===i))},reorderQueue:(t,n,r,i)=>{if(!J(t)||!i)return;let a=K(t);e(e=>{let t=e.queuedMessages[a],o=t?.findIndex(e=>(e.id===n||e.queueItemID===n)&&e.operationID===i&&K(e.owner)===a)??-1,s=t?.findIndex(e=>(e.id===r||e.queueItemID===r)&&K(e.owner)===a)??-1;if(!t||o<0||s<0||o===s||q(t[o])||q(t[s]))return e;let c=t.slice(),[l]=c.splice(o,1);return c.splice(s,0,l),{queuedMessages:{...e.queuedMessages,[a]:c}}})},popToInput:(e,n,r)=>{if(!J(e)||!r)return null;let i=Zr(t(),e).find(t=>(t.id===n||t.queueItemID===n)&&t.operationID===r&&K(t.owner)===K(e));return!i||q(i)||!t().removeFromQueue(e,i.queueItemID,i.operationID)?null:i},clearQueue:n=>{if(!J(n))return!1;let r=K(n),i=t().queuedMessages[r],a=(t().pendingAdmissions[r]??[]).length>0;return(!i||i.length===0)&&!a||!i?.some(q)&&(e(e=>{if(e.queuedMessages[r]?.some(q))return e;let t={...e.queuedMessages},n={...e.pendingAdmissions};return delete t[r],delete n[r],{queuedMessages:t,pendingAdmissions:n}}),(t().queuedMessages[r]??[]).length===0)},clearAllQueues:()=>{J()&&e(e=>{let t={},n=!1;for(let[r,i]of Object.entries(e.queuedMessages)){if(i[0]&&yi(i[0].owner)){t[r]=i;continue}let e=i.filter(q);e.length&&(t[r]=e),e.length!==i.length&&(n=!0)}let r=Object.keys(e.pendingAdmissions).length>0;return n||r?{queuedMessages:t,pendingAdmissions:{}}:e})},setFollowUpBehavior:t=>{J()&&(e({followUpBehavior:t}),fo({followUpBehavior:t}))},getQueueForScope:e=>Zr(t(),e),getPendingAdmissionsForScope:e=>ii(t(),e),stageAdmission:(t,n)=>{if(!J(t)||!n.requestID||!n.queueItemID||!n.operationID||!n.messageID||typeof n.content!=`string`)return;let r=si(n.composerDocument,n.content);if(n.composerDocument!==void 0&&!r)return;let i=ci(n.composerMentions,r);if(n.composerMentions!==void 0&&!i)return;let a=K(t),o={kind:`pending-admission`,requestID:n.requestID,queueItemID:n.queueItemID,operationID:n.operationID,messageID:n.messageID,content:n.content,createdAt:n.createdAt,phase:`admitting`,attachmentCount:Math.max(0,Math.floor(n.attachmentCount??0)),...r?{composerDocument:r}:{},...r&&i?.length?{composerMentions:i}:{}};e(e=>{let t=[...(e.pendingAdmissions[a]??[]).filter(e=>e.requestID!==o.requestID&&e.queueItemID!==o.queueItemID),o];return{pendingAdmissions:{...e.pendingAdmissions,[a]:t}}})},unstageAdmission:(t,n)=>{if(!n)return;let r=K(t);e(e=>{let t=e.pendingAdmissions[r];if(!t?.length)return e;let i=t.filter(e=>e.requestID!==n);if(i.length===t.length)return e;if(i.length)return{pendingAdmissions:{...e.pendingAdmissions,[r]:i}};let{[r]:a,...o}=e.pendingAdmissions;return{pendingAdmissions:o}})},confirmAdmission:(n,r)=>{if(!J(n)||!r.requestID||!r.sendConfig?.providerID||!r.sendConfig?.modelID)return{ok:!1,reason:`invalid-composer-document`};let i=K(n),a=(t().pendingAdmissions[i]??[]).find(e=>e.requestID===r.requestID);if(!a)return{ok:!1,reason:`invalid-composer-document`};let o=si(a.composerDocument,a.content,r.attachments);if(a.composerDocument!==void 0&&!o)return{ok:!1,reason:`invalid-composer-document`};let s=ci(a.composerMentions,o);if(a.composerMentions!==void 0&&!s)return{ok:!1,reason:`invalid-composer-mentions`};let c={id:a.queueItemID,queueItemID:a.queueItemID,operationID:a.operationID,messageID:a.messageID,content:a.content,createdAt:a.createdAt,owner:n,status:`queued`,attemptCount:0,sendConfig:r.sendConfig,...o?{composerDocument:o}:{},...o&&s?.length?{composerMentions:s}:{},...r.attachments?.length?{attachments:r.attachments}:{}};return e(e=>{let t=(e.pendingAdmissions[i]??[]).filter(e=>e.requestID!==r.requestID);return{pendingAdmissions:t.length?{...e.pendingAdmissions,[i]:t}:(()=>{let{[i]:t,...n}=e.pendingAdmissions;return n})(),queuedMessages:{...e.queuedMessages,[i]:[...e.queuedMessages[i]??[],c]}}}),{ok:!0,item:c}},bindLegacyQueue:(t,n)=>{if(!J(t)||!J(n)||t.state!==`unbound-legacy`||n.state!==`bound`||t.sessionID!==n.sessionID)return[];let r=K(t),i=K(n),a=[];return e(e=>{let t=e.queuedMessages[r];if(!t||(a=t.filter(e=>!q(e)),a.length===0))return e;let o=t.filter(q),s={...e.queuedMessages,[i]:[...a.map(e=>({...e,owner:n})),...e.queuedMessages[i]??[]]};return o.length?s[r]=o:delete s[r],{queuedMessages:s}}),a.map(e=>({...e,owner:n}))},markQueueItemSendAttempt:(t,n)=>{J(t)&&Y(e,t,n,e=>e.status===`queued`||e.status===`retrying`&&(e.nextAttemptAt??0)<=Date.now()?{...e,status:`sending`,attemptCount:e.attemptCount+1,nextAttemptAt:void 0,failure:void 0}:e)},markQueueItemPreDispatchRetry:(t,n,r,i)=>Y(e,t,n,e=>e.status===`sending`?{...e,status:`retrying`,nextAttemptAt:r,failure:{kind:`pre-dispatch`,recovery:i?.recovery??ui(e)}}:e),markQueueItemReconciling:(t,n,r)=>Y(e,t,n,e=>e.status===`sending`?{...e,status:`reconciling`,nextAttemptAt:void 0,...bi(e),reconciliationNextCheckAt:void 0,failure:{kind:`ambiguous-dispatch`,recovery:r?.recovery??ui(e)}}:e),recordQueueItemReconciliationCheck:(t,n)=>Y(e,t,n,e=>e.status===`reconciling`&&di(e,n)?{...e,reconciliationChecks:(e.reconciliationChecks??0)+1,reconciliationNextCheckAt:Date.now()+2e3}:e),resolveQueueItemReconciliation:(t,n)=>Y(e,t,n,e=>e.status===`reconciling`&&di(e,n)?{...e,status:`unresolved`,nextAttemptAt:void 0}:e),markQueueItemDefinitiveFailure:(t,n,r)=>Y(e,t,n,e=>e.status===`sending`?{...e,status:`failed`,nextAttemptAt:void 0,failure:{kind:`definitive`,recovery:r?.recovery??ui(e)}}:e),resetQueueItemForDispatch:(t,n)=>{J(t)&&Y(e,t,n,e=>e.status!==`failed`&&e.status!==`unresolved`&&e.status!==`retrying`?e:{...e,status:`queued`,nextAttemptAt:void 0,failure:void 0,reconciliationStartedAt:void 0,reconciliationDeadlineAt:void 0,reconciliationChecks:void 0,reconciliationNextCheckAt:void 0})},beginQueueItemDispatch:(t,n,r,i,a=Date.now())=>{if(!J(t)||!r.startsWith(`msg_`))return null;let o=K(t),s=null;return e(e=>{let t=e.queuedMessages[o],c=i?t?.findIndex(e=>K(e.owner)===o&&di(e,n))??-1:0,l=c>=0?t?.[c]:void 0,u=l?.status===`queued`||l?.status===`retrying`&&(i||(l.nextAttemptAt??0)<=a)||i&&(l?.status===`failed`||l?.status===`unresolved`);if(!l||K(l.owner)!==o||!di(l,n)||!u||t?.some(q))return e;s={...l,messageID:r,status:`sending`,attemptCount:l.attemptCount+1,nextAttemptAt:void 0,failure:void 0,reconciliationStartedAt:void 0,reconciliationDeadlineAt:void 0,reconciliationChecks:void 0,reconciliationNextCheckAt:void 0};let d=t.slice();return d.splice(c,1),d.unshift(s),{queuedMessages:{...e.queuedMessages,[o]:d}}}),s},confirmQueueItem:(t,n)=>{if(yi(t))return;let r=K(t);e(e=>{let t=e.queuedMessages[r],i=t?.find(e=>{let t=!n.operationID||e.operationID===n.operationID,r=!n.messageID||e.messageID===n.messageID,i=!n.queueItemID||e.queueItemID===n.queueItemID;return t&&r&&i});if(!i||!n.operationID&&!n.messageID)return e;let a=t.filter(e=>e!==i);if(a.length)return{queuedMessages:{...e.queuedMessages,[r]:a}};let{[r]:o,...s}=e.queuedMessages;return{queuedMessages:s}})}}),{name:`message-queue-store`,version:4,storage:fi,partialize:e=>({queuedMessages:e.queuedMessages,followUpBehavior:e.followUpBehavior}),migrate:Si,merge:(e,t)=>({...t,...Si(e),pendingAdmissions:t.pendingAdmissions})}),{name:`message-queue-store`})),wi=(e,t)=>{let n=Ci.getState().queuedMessages,r=[],i=[];for(let[a,o]of Object.entries(n)){let n=o[0]?.owner;if(!n||n.state!==`unbound-legacy`)continue;let s=t(n.sessionID);if(!s){i.push(n.sessionID);continue}r.push({sourceKey:a,target:{state:`bound`,transportIdentity:e,directory:s,sessionID:n.sessionID},items:o})}return!e||i.length?{ok:!1,unresolvedSessionIDs:i}:r.length?(Ci.setState(e=>{let t={...e.queuedMessages};for(let e of r){let n=K(e.target);t[n]=[...e.items.map(t=>({...t,owner:e.target})),...t[n]??[]],delete t[e.sourceKey]}return{queuedMessages:t}}),{ok:!0,moved:r.reduce((e,t)=>e+t.items.length,0)}):{ok:!0,moved:0}},Ti=oe(),Ei=e(ie(),1),Di=`directoryTreeShowHidden`,Oi=`directory-show-hidden-change`,ki=()=>{if(typeof window>`u`)return!0;try{let e=f().getItem(Di);return e===null||e===`true`}catch{return!0}},Ai=()=>{typeof window>`u`||window.dispatchEvent(new Event(Oi))},ji=(e,t={})=>{if(!(typeof window>`u`)){try{f().setItem(Di,e?`true`:`false`),Ai()}catch{}t.persist!==!1&&fo({directoryShowHidden:e})}},Mi=()=>{let e=(0,Ti.c)(2),[t,n]=Ei.useState(ki),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>{n(ki())};return window.addEventListener(`storage`,e),window.addEventListener(Oi,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(Oi,e)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Ei.useEffect(r,i),t},Ni=`filesViewShowGitignored`,Pi=`files-view-show-gitignored-change`,Fi=()=>{if(typeof window>`u`)return!1;try{return f().getItem(Ni)===`true`}catch{return!1}},Ii=()=>{typeof window>`u`||window.dispatchEvent(new Event(Pi))},Li=(e,t={})=>{if(!(typeof window>`u`)){try{f().setItem(Ni,e?`true`:`false`),Ii()}catch{}t.persist!==!1&&fo({filesViewShowGitignored:e})}},Ri=()=>{let e=(0,Ti.c)(2),[t,n]=Ei.useState(Fi),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>{n(Fi())};return window.addEventListener(`storage`,e),window.addEventListener(Pi,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(Pi,e)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Ei.useEffect(r,i),t},zi=e=>{if(!e||typeof e!=`object`)return null;let t={};return typeof e.showReasoningTraces==`boolean`&&(t.showReasoningTraces=e.showReasoningTraces),typeof e.collapsibleThinkingBlocks==`boolean`&&(t.collapsibleThinkingBlocks=e.collapsibleThinkingBlocks),Object.keys(t).length>0?t:null},Bi=e=>{if(!e||typeof e!=`object`)return null;let t=e;return{showReasoningTraces:t.showReasoningTraces,collapsibleThinkingBlocks:t.collapsibleThinkingBlocks}},Vi=e=>{let t=v.getState();typeof e.showReasoningTraces==`boolean`&&t.setShowReasoningTraces(e.showReasoningTraces),typeof e.collapsibleThinkingBlocks==`boolean`&&t.setCollapsibleThinkingBlocks(e.collapsibleThinkingBlocks)},Hi=async()=>{if(typeof window>`u`)return null;let e=localStorage.getItem(`appearance-preferences`);if(!e)return null;try{return zi(Bi(JSON.parse(e)))}catch(e){return console.warn(`Failed to parse stored appearance preferences:`,e),null}},Ui=[{name:`explore`,icon:`compass-3`,labelKey:`chat.draftPresets.explore.label`,command:`/explore`},{name:`catch-up`,icon:`history`,labelKey:`chat.draftPresets.catchup.label`,command:`/catch-up`},{name:`weigh`,icon:`scales-3`,labelKey:`chat.draftPresets.weigh.label`,command:`/weigh`},{name:`craft-goal`,icon:`target`,labelKey:`chat.draftPresets.craftGoal.label`,command:`/craft-goal`},{name:`debug`,icon:`bug`,labelKey:`chat.draftPresets.debug.label`,command:`/debug`},{name:`review`,icon:`search-eye`,labelKey:`chat.draftPresets.review.label`,command:`/workspace-review`}],Wi=new Map(Ui.map(e=>[e.name,e])),Gi=e=>Wi.get(e),Ki=[{type:`command`,name:`explore`},{type:`command`,name:`catch-up`},{type:`command`,name:`weigh`},{type:`command`,name:`debug`},{type:`command`,name:`review`}],qi=`terminal-box`,Ji=`book-open`,Yi=e=>`${e.type}:${e.name}`,Xi=(e,t)=>e.type===t.type&&e.name===t.name,Zi=e=>{let t=e.replace(/^\//,``).replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();return t?t.charAt(0).toUpperCase()+t.slice(1):e},Qi=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,i=e.type===`command`||e.type===`skill`?e.type:null,a=typeof e.name==`string`?e.name.trim():``;if(!i||!a)continue;let o=`${i}:${a}`;n.has(o)||(n.add(o),t.push({type:i,name:a}))}return t},$i=`oc.rt.`,ea=e=>{try{return btoa(unescape(encodeURIComponent(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}catch{return encodeURIComponent(e)}},ta=(e,t=i())=>`${$i}${ea(t.trim().length>0?t.trim():`default`)}.${e}`,na=(e,t,n=i())=>e?e===ta(t,n):!1,ra=()=>{if(typeof window>`u`)return!0;let e=window.__OPENCHAMBER_API_BASE_URL__,t=window.__OPENCHAMBER_LOCAL_ORIGIN__;if(typeof e==`string`&&e.trim()&&typeof t==`string`&&t.trim())try{return new URL(e).origin===new URL(t).origin}catch{return!1}try{if(O())return!0}catch{}if(typeof e==`string`&&e.trim())try{let t=new URL(e).hostname;if(t!==`localhost`&&t!==`127.0.0.1`&&t!==`::1`)return!1}catch{return!1}return!0},ia=(e,t)=>{let n=t?.storage??(typeof localStorage<`u`?localStorage:{getItem:()=>null}),r=t?.transport??i(),a=n.getItem(ta(e,r));return a===null?ra()?n.getItem(e):null:a},X=(e,t,n)=>{let r=n?.storage??(typeof localStorage<`u`?localStorage:{setItem:()=>void 0}),a=n?.transport??i();r.setItem(ta(e,a),t)},aa=e=>{let t;try{t=u()}catch{return}let n=t=>t===null?null:JSON.parse(t,e?.reviver),r=e=>t.getItem(e);return{getItem:e=>{let t=ta(e,i()),a=r(t);if(a instanceof Promise)return a.then(t=>{if(t!==null)return n(t);if(!ra())return null;let i=r(e);return i instanceof Promise?i.then(n):n(i)});if(a!==null)return n(a);if(!ra())return null;let o=r(e);return o instanceof Promise?o.then(n):n(o)},setItem:(n,r)=>{let a=ta(n,i());t.setItem(a,JSON.stringify(r,e?.replacer))},removeItem:e=>{let n=ta(e,i());t.removeItem(n)}}},oa=512,sa=4096,ca=64,la=2e5,ua=[`concise`,`detailed`,`mentor`,`pushback`,`noFiller`,`matchEnergy`,`warmPeer`,`custom`],da=[`defaultModel`,`defaultVariant`,`defaultAgent`,`autoCreateWorktree`,`gitmojiEnabled`,`defaultFileViewerPreview`,`zenModel`,`messageStreamTransport`,`sttProvider`,`sttServerUrl`,`sttModel`,`sttLocalModel`,`sttLanguage`,`responseStyleEnabled`,`responseStylePreset`,`responseStyleCustomInstructions`],fa=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype,pa=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ma=(e,t)=>{if(typeof e!=`string`)return;let n=e.trim();return n.length<=t?n:void 0},ha=e=>{let t=ma(e,sa);if(t!==void 0)try{let e=new URL(t);return(e.protocol===`http:`||e.protocol===`https:`)&&!e.username&&!e.password?t:void 0}catch{return}},ga=(e,t)=>typeof e==`string`&&t.includes(e)?e:void 0,_a=e=>typeof e==`boolean`?e:void 0,va=(e,t)=>{let n=e[t];switch(t){case`autoCreateWorktree`:case`gitmojiEnabled`:case`defaultFileViewerPreview`:case`responseStyleEnabled`:return _a(n);case`messageStreamTransport`:return ga(n,[`auto`,`ws`,`sse`]);case`sttProvider`:return ga(n,[`local`,`openai-compatible`]);case`sttServerUrl`:return ha(n);case`sttLanguage`:return ma(n,ca);case`responseStyleCustomInstructions`:return ma(n,la);case`responseStylePreset`:return ga(n,ua);default:return ma(n,oa)}},ya=e=>{if(!fa(e))throw Error(`Invalid settings bootstrap response`);if(!pa(e,`schemaVersion`)||e.schemaVersion!==1)throw Error(`Unsupported settings bootstrap schema version`);let t={schemaVersion:1};for(let n of da){if(!pa(e,n))continue;let r=va(e,n);r!==void 0&&Object.assign(t,{[n]:r})}return t},ba=e=>{if(!fa(e))throw Error(`Invalid settings bootstrap patch`);for(let t of Object.keys(e))if(!da.includes(t))throw Error(`Invalid settings bootstrap patch`);let t=ya({schemaVersion:1,...e}),n={};for(let r of da)if(pa(e,r)){if(!pa(t,r))throw Error(`Invalid settings bootstrap patch`);Object.assign(n,{[r]:t[r]})}return n},xa=e=>{if(!fa(e))return{};let t={};for(let n of da){if(!pa(e,n))continue;let r=va(e,n);r!==void 0&&Object.assign(t,{[n]:r})}return t},Sa=new se({defaultOptions:{queries:{staleTime:3e4,gcTime:3e5,retry:1,refetchOnWindowFocus:!1}}}),Ca={runtime:()=>[i()],scoped:(...e)=>[i(),...e],quota:e=>[i(),e],commands:{list:(e,t=i())=>[t,`commands`,e]},agents:{list:(e,t=i())=>[t,`agents`,e],raw:(e,t=i())=>[t,`agents`,`raw`]},configCatalog:{providers:(e,t=i())=>[t,`configCatalog`,`providers`,e]},providers:{list:(e,t=i())=>[t,`providers`,e]},skills:{list:(e,t=i())=>[t,`skills`,e]},skillsCatalog:{sources:(e,t=i())=>[t,`skillsCatalog`,`sources`,Z(e)],source:(e,t,n=i())=>[n,`skillsCatalog`,`source`,Z(e),t]},messageQueue:{status:(e=i())=>[e,`messageQueue`,`status`],snapshot:(e=i())=>[e,`messageQueue`,`snapshot`],scope:(e,t,n=i())=>[n,`messageQueue`,`scope`,e,t]},mcp:{configs:(e,t=i())=>[t,`mcp`,`configs`,Z(e)],status:(e,t=i())=>[t,`mcp`,`status`,Z(e)]},github:{auth:(e=i())=>[e,`github`,`auth`]},git:{branches:(e,t=i())=>[t,`git`,`branches`,Z(e)],remotes:(e,t=i())=>[t,`git`,`remotes`,Z(e)]},sessionIndex:{snapshot:(e=i())=>[e,`sessionIndex`,`snapshot`]},sessionStatus:{snapshot:(e,t=i())=>[t,`sessionStatus`,`snapshot`,Z(e)]},sessionTurnChanges:{file:(e,t,n,r,a,o=i())=>[o,`sessionTurnChanges`,`file`,Z(e),t,n,r,typeof a==`number`&&Number.isFinite(a)?Math.max(0,Math.trunc(a)):null]},sessionActive:{snapshot:(e,t)=>[e,`sessionActive`,`snapshot`,t]},sessionTranscript:{infinite:(e,t,n=i(),r=y())=>[n,r,`session-transcript`,Z(e)??``,t],page:(e,t,n,r,a=i(),o=y())=>[a,o,`sessionMessages`,`page`,Z(e)??``,t,n,r?.trim()?r.trim():`tail`],tailTask:(e,t,n,r=i(),a=y())=>[r,a,`session-transcript-task`,`tail`,Z(e)??``,t,n],reconcileTask:(e,t,n,r=i(),a=y())=>[r,a,`session-transcript-task`,`reconcile`,Z(e)??``,t,n],checkpoint:(e,t,n=i(),r=y())=>[n,r,`session-transcript-checkpoint`,Z(e)??``,t]},plugins:{list:(e,t=i())=>[t,`plugins`,`list`,e],registry:(e,t,n=!1,r=i())=>[r,`plugins`,`registry`,e,wa(t),n],file:(e,t,n=i())=>[n,`plugins`,`file`,e,t]},files:{directory:(e,t,n,r=i())=>[r,`files`,`directory`,Ta(e),Ta(t),!!n],search:(e,t,n,r,a,o=i())=>[o,`files`,`search`,Ta(e),t.trim(),n??null,!!r,!!a],content:(e,t,n,r=i())=>Ea(`content`,e,t,n,r),stat:(e,t,n,r=i())=>Ea(`stat`,e,t,n,r)}},wa=e=>Array.from(new Set(e.map(e=>e.trim()).filter(Boolean))).sort(),Z=e=>e?.trim()||null,Ta=e=>{if(typeof e!=`string`)return null;let t=e.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},Ea=(e,t,n,r,i)=>[i,`files`,e,Ta(t),Ta(n),!!r?.allowOutsideWorkspace,r?.outsideFileGrant??null,!!r?.optional,Ta(r?.directory)],Da=async(e,t)=>{let n=await Ke(`/api/quota/${encodeURIComponent(e)}`,{signal:t}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Failed to fetch quota`);return r},Oa=e=>t(t=>{s(t)&&e.clear()}),ka=class extends Error{status;constructor(e){super(`Settings bootstrap request failed (${e})`),this.status=e,this.name=`SettingsBootstrapRequestError`}},Aa=(e=i())=>[e,`settings`,`bootstrap`],ja=(e=i())=>({queryKey:Aa(e),queryFn:async({signal:e})=>{let t=await Ke(`/api/config/settings/bootstrap`,{method:`GET`,headers:{Accept:`application/json`},signal:e});if(!t.ok)throw new ka(t.status);return ya(await t.json())},retry:(e,t)=>!(t instanceof ka&&(t.status===404||t.status===501))&&e<1,staleTime:1/0,gcTime:1/0}),Ma=(e=i())=>Sa.fetchQuery(ja(e)),Na=(e=i())=>Sa.getQueryData(Aa(e)),Pa=(e,t=i())=>{let n=ba(e),r=Aa(t),a=ya({schemaVersion:1,...Sa.getQueryData(r),...n});return Sa.setQueryData(r,a),a},Fa=e=>{if(!(typeof window>`u`)&&!(typeof window.__OPENCHAMBER_HOME__==`string`&&window.__OPENCHAMBER_HOME__.length>0))try{window.__OPENCHAMBER_HOME__=e}catch{}},Ia=e=>{if(!(typeof window>`u`)){if(e.themeId&&X(`selectedThemeId`,e.themeId),e.themeVariant&&X(`selectedThemeVariant`,e.themeVariant),e.lightThemeId&&X(`lightThemeId`,e.lightThemeId),e.darkThemeId&&X(`darkThemeId`,e.darkThemeId),typeof e.useSystemTheme==`boolean`&&(X(`useSystemTheme`,String(e.useSystemTheme)),X(`themeMode`,e.useSystemTheme?`system`:e.themeVariant===`dark`||e.themeVariant===`light`?e.themeVariant:`system`)),e.lastDirectory&&A(`lastDirectory`,e.lastDirectory),e.homeDirectory&&(A(`homeDirectory`,e.homeDirectory),Fa(e.homeDirectory)),Array.isArray(e.projects)&&e.projects.length>0?A(`projects`,JSON.stringify(e.projects)):j(`projects`),e.activeProjectId?A(`activeProjectId`,e.activeProjectId):j(`activeProjectId`),Array.isArray(e.pinnedDirectories)&&e.pinnedDirectories.length>0?A(`pinnedDirectories`,JSON.stringify(e.pinnedDirectories)):j(`pinnedDirectories`),Array.isArray(e.projects)&&e.projects.length>0){let t=e.projects.filter(e=>e.sidebarCollapsed===!0).map(e=>e.id).filter(e=>typeof e==`string`&&e.length>0);t.length>0?A(`oc.sessions.projectCollapse`,JSON.stringify(t)):j(`oc.sessions.projectCollapse`)}if(typeof e.gitmojiEnabled==`boolean`?localStorage.setItem(`gitmojiEnabled`,String(e.gitmojiEnabled)):localStorage.removeItem(`gitmojiEnabled`),typeof e.directoryShowHidden==`boolean`&&localStorage.setItem(`directoryTreeShowHidden`,e.directoryShowHidden?`true`:`false`),typeof e.filesViewShowGitignored==`boolean`&&localStorage.setItem(`filesViewShowGitignored`,e.filesViewShowGitignored?`true`:`false`),typeof e.openInAppId==`string`&&e.openInAppId.length>0&&localStorage.setItem(`openInAppId`,e.openInAppId),typeof e.pwaAppName==`string`){let t=e.pwaAppName.trim().replace(/\s+/g,` `).slice(0,64);t.length>0?localStorage.setItem(`openchamber.pwaName`,t):localStorage.removeItem(`openchamber.pwaName`)}if(typeof e.mobileKeyboardMode==`string`&&m(e.mobileKeyboardMode),typeof e.openCodeUpdateToastDismissedVersion==`string`){let t=e.openCodeUpdateToastDismissedVersion.trim();t?localStorage.setItem(`opencode-update-toast-dismissed-version`,t):localStorage.removeItem(`opencode-update-toast-dismissed-version`)}typeof e.dictationEnabled==`boolean`&&localStorage.setItem(`dictationEnabled`,String(e.dictationEnabled)),(e.sttProvider===`local`||e.sttProvider===`openai-compatible`)&&localStorage.setItem(`sttProvider`,e.sttProvider),typeof e.sttServerUrl==`string`&&localStorage.setItem(`sttServerUrl`,e.sttServerUrl),typeof e.sttModel==`string`&&localStorage.setItem(`sttModel`,e.sttModel),typeof e.sttLocalModel==`string`&&localStorage.setItem(`sttLocalModel`,e.sttLocalModel),typeof e.sttLanguage==`string`&&localStorage.setItem(`sttLanguage`,e.sttLanguage)}},La=e=>{typeof window>`u`||window.dispatchEvent(new CustomEvent(`openchamber:settings-synced`,{detail:e}))},Ra=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,i=typeof e.id==`string`?e.id.trim():``,a=typeof e.label==`string`?e.label.trim():``,o=typeof e.source==`string`?e.source.trim():``,s=typeof e.subpath==`string`?e.subpath.trim():``,c=typeof e.gitIdentityId==`string`?e.gitIdentityId.trim():``;!i||!a||!o||n.has(i)||(n.add(i),t.push({id:i,label:a,source:o,...s?{subpath:s}:{},...c?{gitIdentityId:c}:{}}))}return t},za=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e)){let e=typeof n==`string`?n.trim():``,i=typeof r==`string`?r.trim():``;!e||!i||(t[e]=i)}return t},Ba=(e,t)=>{let n=Object.entries(e),r=Object.entries(t);return n.length===r.length&&n.every(([e,n])=>t[e]===n)},Va=(e,t)=>e.length===t.length&&e.every((e,n)=>e.providerID===t[n]?.providerID&&e.modelID===t[n]?.modelID&&e.variant===t[n]?.variant),Ha=(e,t)=>{if(t.length===0)return t;let n=new Map;for(let t of e)typeof t.variant==`string`&&t.variant.length>0&&n.set(`${t.providerID}/${t.modelID}`,t.variant);return t.map(e=>{if(typeof e.variant==`string`&&e.variant.length>0)return e;let t=n.get(`${e.providerID}/${e.modelID}`);return t?{providerID:e.providerID,modelID:e.modelID,variant:t}:e})},Ua=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),Wa=e=>{if(Array.isArray(e))return Array.from(new Set(e.filter(e=>typeof e==`string`&&e.length>0)))},Ga=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e)){if(!n||!Array.isArray(r))continue;let e=Wa(r);e&&e.length>0&&(t[n]=e.slice(0,5))}return Object.keys(t).length>0?t:void 0},Ka=(e,t)=>{let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Array.isArray(t[n])&&Ua(e[n],t[n]))},qa=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,Ja=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t&&qa.test(t)?t.toLowerCase():null},Ya=e=>{if(!Array.isArray(e))return;let t=[],n=new Set,r=new Set;for(let i of e){if(!i||typeof i!=`object`)continue;let e=i,a=typeof e.path==`string`?e.path.trim():``;if(!a)continue;let o=a===`/`?a:a.replace(/\\/g,`/`).replace(/\/+$/,``);if(!o)continue;let s=cr(o);if(!s||n.has(s)||r.has(o))continue;n.add(s),r.add(o);let c={id:s,path:o};if(typeof e.label==`string`&&e.label.trim().length>0&&(c.label=e.label.trim()),typeof e.icon==`string`&&e.icon.trim().length>0&&(c.icon=e.icon.trim()),e.iconImage===null)c.iconImage=null;else if(e.iconImage&&typeof e.iconImage==`object`){let t=e.iconImage,n=typeof t.mime==`string`?t.mime.trim():``,r=typeof t.updatedAt==`number`&&Number.isFinite(t.updatedAt)?Math.max(0,Math.round(t.updatedAt)):0,i=t.source===`custom`||t.source===`auto`?t.source:null;n&&r>0&&i&&(c.iconImage={mime:n,updatedAt:r,source:i})}if(typeof e.color==`string`&&e.color.trim().length>0&&(c.color=e.color.trim()),e.iconBackground===null)c.iconBackground=null;else{let t=Ja(e.iconBackground);t&&(c.iconBackground=t)}typeof e.addedAt==`number`&&Number.isFinite(e.addedAt)&&e.addedAt>=0&&(c.addedAt=e.addedAt),typeof e.lastOpenedAt==`number`&&Number.isFinite(e.lastOpenedAt)&&e.lastOpenedAt>=0&&(c.lastOpenedAt=e.lastOpenedAt),typeof e.sidebarCollapsed==`boolean`&&(c.sidebarCollapsed=e.sidebarCollapsed),t.push(c)}return t.length>0?t:void 0},Xa=(e,t,n)=>{if(!Array.isArray(e))return;let r=[],i=new Set,a=n?.preserveVariant===!0;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n,o=typeof e.providerID==`string`?e.providerID.trim():``,s=typeof e.modelID==`string`?e.modelID.trim():``;if(!o||!s)continue;let c=`${o}/${s}`;if(!i.has(c)&&(i.add(c),a&&typeof e.variant==`string`&&e.variant.trim().length>0?r.push({providerID:o,modelID:s,variant:e.variant.trim()}):r.push({providerID:o,modelID:s}),r.length>=t))break}return r},Za=()=>{let e=v.persist;if(e&&typeof e==`object`)return e},Qa=()=>ot()?.settings??null,$a=(e,t,n)=>{let r={...xa(t),...xa(e)};if(Object.keys(r).length!==0)try{Pa(r,n)}catch(e){console.warn(`Failed to patch settings bootstrap cache:`,e)}},eo=e=>{let t=v.getState(),n=typeof window<`u`?window.__zustand_config_store__?.getState?.()??null:null,r=typeof window<`u`?window.__zustand_config_store__??null:null,i=Ci.getState();if(typeof e.showReasoningTraces==`boolean`&&e.showReasoningTraces!==t.showReasoningTraces&&t.setShowReasoningTraces(e.showReasoningTraces),typeof e.sessionTitleRefreshEnabled==`boolean`&&e.sessionTitleRefreshEnabled!==t.sessionTitleRefreshEnabled&&t.setSessionTitleRefreshEnabled(e.sessionTitleRefreshEnabled),typeof e.sessionGoalEnabled==`boolean`&&e.sessionGoalEnabled!==t.sessionGoalEnabled&&t.setSessionGoalEnabled(e.sessionGoalEnabled),typeof e.sessionGoalDefaultBudgetEnabled==`boolean`&&e.sessionGoalDefaultBudgetEnabled!==t.sessionGoalDefaultBudgetEnabled&&t.setSessionGoalDefaultBudgetEnabled(e.sessionGoalDefaultBudgetEnabled),typeof e.sessionGoalDefaultBudget==`number`&&Number.isFinite(e.sessionGoalDefaultBudget)&&e.sessionGoalDefaultBudget!==t.sessionGoalDefaultBudget&&t.setSessionGoalDefaultBudget(e.sessionGoalDefaultBudget),typeof e.collapsibleThinkingBlocks==`boolean`&&e.collapsibleThinkingBlocks!==t.collapsibleThinkingBlocks&&t.setCollapsibleThinkingBlocks(e.collapsibleThinkingBlocks),typeof e.autoDeleteEnabled==`boolean`&&e.autoDeleteEnabled!==t.autoDeleteEnabled&&t.setAutoDeleteEnabled(e.autoDeleteEnabled),typeof e.autoDeleteAfterDays==`number`&&Number.isFinite(e.autoDeleteAfterDays)){let n=Math.max(1,Math.min(365,e.autoDeleteAfterDays));n!==t.autoDeleteAfterDays&&t.setAutoDeleteAfterDays(n)}(e.sessionRetentionAction===`archive`||e.sessionRetentionAction===`delete`)&&e.sessionRetentionAction!==t.sessionRetentionAction&&t.setSessionRetentionAction(e.sessionRetentionAction);let a=null;if(ti(e.followUpBehavior)?a=e.followUpBehavior:typeof e.queueModeEnabled==`boolean`&&(a=ni(void 0,e.queueModeEnabled)),a&&a!==i.followUpBehavior&&i.setFollowUpBehavior(a),typeof e.showDeletionDialog==`boolean`&&e.showDeletionDialog!==t.showDeletionDialog&&t.setShowDeletionDialog(e.showDeletionDialog),typeof e.nativeNotificationsEnabled==`boolean`&&e.nativeNotificationsEnabled!==t.nativeNotificationsEnabled&&t.setNativeNotificationsEnabled(e.nativeNotificationsEnabled),typeof e.notificationMode==`string`&&(e.notificationMode===`always`||e.notificationMode===`hidden-only`)&&e.notificationMode!==t.notificationMode&&t.setNotificationMode(e.notificationMode),typeof e.notifyOnSubtasks==`boolean`&&e.notifyOnSubtasks!==t.notifyOnSubtasks&&t.setNotifyOnSubtasks(e.notifyOnSubtasks),typeof e.notifyOnCompletion==`boolean`&&e.notifyOnCompletion!==t.notifyOnCompletion&&t.setNotifyOnCompletion(e.notifyOnCompletion),typeof e.notifyOnError==`boolean`&&e.notifyOnError!==t.notifyOnError&&t.setNotifyOnError(e.notifyOnError),typeof e.notifyOnQuestion==`boolean`&&e.notifyOnQuestion!==t.notifyOnQuestion&&t.setNotifyOnQuestion(e.notifyOnQuestion),e.notificationTemplates&&typeof e.notificationTemplates==`object`&&t.setNotificationTemplates(e.notificationTemplates),typeof e.summarizeLastMessage==`boolean`&&e.summarizeLastMessage!==t.summarizeLastMessage&&t.setSummarizeLastMessage(e.summarizeLastMessage),typeof e.summaryThreshold==`number`&&Number.isFinite(e.summaryThreshold)&&t.setSummaryThreshold(e.summaryThreshold),typeof e.summaryLength==`number`&&Number.isFinite(e.summaryLength)&&t.setSummaryLength(e.summaryLength),typeof e.maxLastMessageLength==`number`&&Number.isFinite(e.maxLastMessageLength)&&t.setMaxLastMessageLength(e.maxLastMessageLength),typeof e.inputSpellcheckEnabled==`boolean`&&e.inputSpellcheckEnabled!==t.inputSpellcheckEnabled&&t.setInputSpellcheckEnabled(e.inputSpellcheckEnabled),typeof e.showOpenCodeUpdateNotifications==`boolean`&&e.showOpenCodeUpdateNotifications!==t.showOpenCodeUpdateNotifications&&t.setShowOpenCodeUpdateNotifications(e.showOpenCodeUpdateNotifications),typeof e.showToolFileIcons==`boolean`&&e.showToolFileIcons!==t.showToolFileIcons&&t.setShowToolFileIcons(e.showToolFileIcons),typeof e.codeBlockLineWrap==`boolean`&&e.codeBlockLineWrap!==t.codeBlockLineWrap&&t.setCodeBlockLineWrap(e.codeBlockLineWrap),typeof e.showTurnChangedFiles==`boolean`&&e.showTurnChangedFiles!==t.showTurnChangedFiles&&t.setShowTurnChangedFiles(e.showTurnChangedFiles),typeof e.showExpandedBashTools==`boolean`&&e.showExpandedBashTools!==t.showExpandedBashTools&&t.setShowExpandedBashTools(e.showExpandedBashTools),typeof e.showSubagentTaskDetails==`boolean`&&e.showSubagentTaskDetails!==t.showSubagentTaskDetails&&t.setShowSubagentTaskDetails(e.showSubagentTaskDetails),typeof e.timeFormatPreference==`string`&&(e.timeFormatPreference===`auto`||e.timeFormatPreference===`12h`||e.timeFormatPreference===`24h`)&&e.timeFormatPreference!==t.timeFormatPreference&&t.setTimeFormatPreference(e.timeFormatPreference),typeof e.weekStartPreference==`string`&&(e.weekStartPreference===`auto`||e.weekStartPreference===`sunday`||e.weekStartPreference===`monday`)&&e.weekStartPreference!==t.weekStartPreference&&t.setWeekStartPreference(e.weekStartPreference),typeof e.desktopWindowControlsPosition==`string`&&(e.desktopWindowControlsPosition===`auto`||e.desktopWindowControlsPosition===`left`||e.desktopWindowControlsPosition===`right`)&&e.desktopWindowControlsPosition!==t.desktopWindowControlsPosition&&t.setDesktopWindowControlsPosition(e.desktopWindowControlsPosition),typeof e.chatRenderMode==`string`&&(e.chatRenderMode===`sorted`||e.chatRenderMode===`live`)&&e.chatRenderMode!==t.chatRenderMode&&t.setChatRenderMode(e.chatRenderMode),typeof e.activityRenderMode==`string`&&(e.activityRenderMode===`collapsed`||e.activityRenderMode===`summary`)&&e.activityRenderMode!==t.activityRenderMode&&t.setActivityRenderMode(e.activityRenderMode),typeof e.mermaidRenderingMode==`string`&&(e.mermaidRenderingMode===`svg`||e.mermaidRenderingMode===`ascii`)&&e.mermaidRenderingMode!==t.mermaidRenderingMode&&t.setMermaidRenderingMode(e.mermaidRenderingMode),typeof e.userMessageRenderingMode==`string`&&(e.userMessageRenderingMode===`markdown`||e.userMessageRenderingMode===`plain`)&&e.userMessageRenderingMode!==t.userMessageRenderingMode&&t.setUserMessageRenderingMode(e.userMessageRenderingMode),typeof e.collapsibleUserMessages==`boolean`&&e.collapsibleUserMessages!==t.collapsibleUserMessages&&t.setCollapsibleUserMessages(e.collapsibleUserMessages),typeof e.messageStreamTransport==`string`&&(e.messageStreamTransport===`auto`||e.messageStreamTransport===`ws`||e.messageStreamTransport===`sse`)&&n&&e.messageStreamTransport!==n.settingsMessageStreamTransport&&n.setSettingsMessageStreamTransport(e.messageStreamTransport),typeof e.stickyUserHeader==`boolean`&&e.stickyUserHeader!==t.stickyUserHeader&&t.setStickyUserHeader(e.stickyUserHeader),typeof e.promptNavigatorEnabled==`boolean`&&e.promptNavigatorEnabled!==t.promptNavigatorEnabled&&t.setPromptNavigatorEnabled(e.promptNavigatorEnabled),typeof e.expandedEditorToolbar==`boolean`&&e.expandedEditorToolbar!==t.expandedEditorToolbar&&t.setExpandedEditorToolbar(e.expandedEditorToolbar),typeof e.wideChatLayoutEnabled==`boolean`&&e.wideChatLayoutEnabled!==t.wideChatLayoutEnabled&&t.setWideChatLayoutEnabled(e.wideChatLayoutEnabled),typeof e.showSplitAssistantMessageActions==`boolean`&&e.showSplitAssistantMessageActions!==t.showSplitAssistantMessageActions&&t.setShowSplitAssistantMessageActions(e.showSplitAssistantMessageActions),typeof e.showAssistantTps==`boolean`&&e.showAssistantTps!==t.showAssistantTps&&t.setShowAssistantTps(e.showAssistantTps),typeof e.reportUsage==`boolean`&&e.reportUsage!==t.reportUsage&&t.setReportUsage(e.reportUsage),typeof e.fontSize==`number`&&Number.isFinite(e.fontSize)&&e.fontSize!==t.fontSize&&t.setFontSize(e.fontSize),Array.isArray(e.draftStarters)){let n=Qi(e.draftStarters);JSON.stringify(t.globalDraftStarters)!==JSON.stringify(n)&&t.setGlobalDraftStarters(n)}if(typeof e.terminalFontSize==`number`&&Number.isFinite(e.terminalFontSize)&&e.terminalFontSize!==t.terminalFontSize&&t.setTerminalFontSize(e.terminalFontSize),typeof e.editorFontSize==`number`&&Number.isFinite(e.editorFontSize)&&e.editorFontSize!==t.editorFontSize&&t.setEditorFontSize(e.editorFontSize),h(e.uiFont)&&e.uiFont!==t.uiFont&&t.setUiFont(e.uiFont),p(e.monoFont)&&e.monoFont!==t.monoFont&&t.setMonoFont(e.monoFont),typeof e.padding==`number`&&Number.isFinite(e.padding)&&e.padding!==t.padding&&t.setPadding(e.padding),typeof e.cornerRadius==`number`&&Number.isFinite(e.cornerRadius)&&e.cornerRadius!==t.cornerRadius&&t.setCornerRadius(e.cornerRadius),typeof e.inputBarOffset==`number`&&Number.isFinite(e.inputBarOffset)&&e.inputBarOffset!==t.inputBarOffset&&t.setInputBarOffset(e.inputBarOffset),e.shortcutOverrides&&!Ba(e.shortcutOverrides,t.shortcutOverrides)&&v.setState({shortcutOverrides:e.shortcutOverrides}),typeof e.mobileKeyboardMode==`string`){let n=g(e.mobileKeyboardMode,t.mobileKeyboardMode);n!==t.mobileKeyboardMode&&t.setMobileKeyboardMode(n)}if(r&&n){let t={};typeof e.dictationEnabled==`boolean`&&e.dictationEnabled!==n.dictationEnabled&&(t.dictationEnabled=e.dictationEnabled),(e.sttProvider===`local`||e.sttProvider===`openai-compatible`)&&e.sttProvider!==n.sttProvider&&(t.sttProvider=e.sttProvider),typeof e.sttServerUrl==`string`&&e.sttServerUrl!==n.sttServerUrl&&(t.sttServerUrl=e.sttServerUrl),typeof e.sttModel==`string`&&e.sttModel!==n.sttModel&&(t.sttModel=e.sttModel),typeof e.sttLocalModel==`string`&&e.sttLocalModel!==n.sttLocalModel&&(t.sttLocalModel=e.sttLocalModel),typeof e.sttLanguage==`string`&&e.sttLanguage!==n.sttLanguage&&(t.sttLanguage=e.sttLanguage),Object.keys(t).length>0&&r.setState(t)}if(Array.isArray(e.favoriteModels)){let n=t.favoriteModels,r=Ha(n,e.favoriteModels);Va(n,r)||v.setState({favoriteModels:r})}if(Array.isArray(e.hiddenModels)){let n=t.hiddenModels,r=e.hiddenModels;Va(n,r)||v.setState({hiddenModels:r})}if(Array.isArray(e.collapsedModelProviders)){let n=t.collapsedModelProviders,r=e.collapsedModelProviders;Ua(n,r)||v.setState({collapsedModelProviders:r})}if(Array.isArray(e.recentModels)){let n=t.recentModels,r=Ha(n,e.recentModels);Va(n,r)||v.setState({recentModels:r})}if(Array.isArray(e.recentAgents)){let n=t.recentAgents,r=e.recentAgents;Ua(n,r)||v.setState({recentAgents:r})}if(e.recentEfforts&&typeof e.recentEfforts==`object`){let n=t.recentEfforts,r=e.recentEfforts;Ka(n,r)||v.setState({recentEfforts:r})}typeof e.diffLayoutPreference==`string`&&(e.diffLayoutPreference===`dynamic`||e.diffLayoutPreference===`inline`||e.diffLayoutPreference===`side-by-side`)&&e.diffLayoutPreference!==t.diffLayoutPreference&&t.setDiffLayoutPreference(e.diffLayoutPreference),typeof e.gitChangesViewMode==`string`&&(e.gitChangesViewMode===`flat`||e.gitChangesViewMode===`tree`)&&e.gitChangesViewMode!==t.gitChangesViewMode&&t.setGitChangesViewMode(e.gitChangesViewMode),typeof e.directoryShowHidden==`boolean`&&ji(e.directoryShowHidden,{persist:!1}),typeof e.filesViewShowGitignored==`boolean`&&Li(e.filesViewShowGitignored,{persist:!1})},to=e=>{if(!e||typeof e!=`object`)return null;let t=e,n={};if(typeof t.themeId==`string`&&t.themeId.length>0&&(n.themeId=t.themeId),(t.useSystemTheme===!0||t.useSystemTheme===!1)&&(n.useSystemTheme=t.useSystemTheme),typeof t.themeVariant==`string`&&(t.themeVariant===`light`||t.themeVariant===`dark`)&&(n.themeVariant=t.themeVariant),typeof t.lightThemeId==`string`&&t.lightThemeId.length>0&&(n.lightThemeId=t.lightThemeId),typeof t.darkThemeId==`string`&&t.darkThemeId.length>0&&(n.darkThemeId=t.darkThemeId),typeof t.lastDirectory==`string`&&t.lastDirectory.length>0&&(n.lastDirectory=t.lastDirectory),typeof t.homeDirectory==`string`&&t.homeDirectory.length>0&&(n.homeDirectory=t.homeDirectory),typeof t.opencodeBinary==`string`){let e=t.opencodeBinary.trim();n.opencodeBinary=e.length>0?e:void 0}typeof t.desktopLanAccessEnabled==`boolean`&&(n.desktopLanAccessEnabled=t.desktopLanAccessEnabled),typeof t.desktopKeepAwakeEnabled==`boolean`&&(n.desktopKeepAwakeEnabled=t.desktopKeepAwakeEnabled),typeof t.desktopMinimizeToTrayEnabled==`boolean`&&(n.desktopMinimizeToTrayEnabled=t.desktopMinimizeToTrayEnabled);let r=Ya(t.projects);if(r&&(n.projects=r),typeof t.activeProjectId==`string`&&t.activeProjectId.length>0&&(n.activeProjectId=t.activeProjectId),Array.isArray(t.securityScopedBookmarks)&&(n.securityScopedBookmarks=t.securityScopedBookmarks.filter(e=>typeof e==`string`&&e.length>0)),Array.isArray(t.pinnedDirectories)&&(n.pinnedDirectories=Array.from(new Set(t.pinnedDirectories.filter(e=>typeof e==`string`&&e.length>0)))),Array.isArray(t.draftStarters)&&(n.draftStarters=Qi(t.draftStarters)),typeof t.draftStartersCraftGoalAdded==`boolean`&&(n.draftStartersCraftGoalAdded=t.draftStartersCraftGoalAdded),typeof t.showReasoningTraces==`boolean`&&(n.showReasoningTraces=t.showReasoningTraces),typeof t.sessionTitleRefreshEnabled==`boolean`&&(n.sessionTitleRefreshEnabled=t.sessionTitleRefreshEnabled),typeof t.sessionGoalEnabled==`boolean`&&(n.sessionGoalEnabled=t.sessionGoalEnabled),typeof t.sessionGoalDefaultBudgetEnabled==`boolean`&&(n.sessionGoalDefaultBudgetEnabled=t.sessionGoalDefaultBudgetEnabled),typeof t.sessionGoalDefaultBudget==`number`&&Number.isFinite(t.sessionGoalDefaultBudget)&&t.sessionGoalDefaultBudget>0&&(n.sessionGoalDefaultBudget=Math.floor(t.sessionGoalDefaultBudget)),typeof t.collapsibleThinkingBlocks==`boolean`&&(n.collapsibleThinkingBlocks=t.collapsibleThinkingBlocks),typeof t.autoDeleteEnabled==`boolean`&&(n.autoDeleteEnabled=t.autoDeleteEnabled),typeof t.autoDeleteAfterDays==`number`&&Number.isFinite(t.autoDeleteAfterDays)&&(n.autoDeleteAfterDays=t.autoDeleteAfterDays),(t.sessionRetentionAction===`archive`||t.sessionRetentionAction===`delete`)&&(n.sessionRetentionAction=t.sessionRetentionAction),typeof t.defaultModel==`string`&&t.defaultModel.length>0&&(n.defaultModel=t.defaultModel),typeof t.defaultVariant==`string`&&t.defaultVariant.length>0&&(n.defaultVariant=t.defaultVariant),typeof t.defaultAgent==`string`&&t.defaultAgent.length>0&&(n.defaultAgent=t.defaultAgent),typeof t.smallModelUseDefault==`boolean`&&(n.smallModelUseDefault=t.smallModelUseDefault),typeof t.smallModelOverride==`string`&&t.smallModelOverride.length>0&&(n.smallModelOverride=t.smallModelOverride),(t.summaryModelMode===`provider`||t.summaryModelMode===`custom`)&&(n.summaryModelMode=t.summaryModelMode),typeof t.summaryProviderID==`string`&&t.summaryProviderID.length>0&&(n.summaryProviderID=t.summaryProviderID),typeof t.summaryModelID==`string`&&t.summaryModelID.length>0&&(n.summaryModelID=t.summaryModelID),typeof t.summaryCustomBaseURL==`string`&&(n.summaryCustomBaseURL=t.summaryCustomBaseURL),typeof t.hasSummaryCustomAPIToken==`boolean`&&(n.hasSummaryCustomAPIToken=t.hasSummaryCustomAPIToken),typeof t.summaryCommitPrompt==`string`&&(n.summaryCommitPrompt=t.summaryCommitPrompt),typeof t.summarySessionTitlePrompt==`string`&&(n.summarySessionTitlePrompt=t.summarySessionTitlePrompt),typeof t.autoCreateWorktree==`boolean`&&(n.autoCreateWorktree=t.autoCreateWorktree),typeof t.gitmojiEnabled==`boolean`&&(n.gitmojiEnabled=t.gitmojiEnabled),ti(t.followUpBehavior)?n.followUpBehavior=t.followUpBehavior:typeof t.queueModeEnabled==`boolean`&&(n.followUpBehavior=ni(void 0,t.queueModeEnabled)),typeof t.showDeletionDialog==`boolean`&&(n.showDeletionDialog=t.showDeletionDialog),typeof t.nativeNotificationsEnabled==`boolean`&&(n.nativeNotificationsEnabled=t.nativeNotificationsEnabled),typeof t.notificationMode==`string`&&(t.notificationMode===`always`||t.notificationMode===`hidden-only`)&&(n.notificationMode=t.notificationMode),typeof t.notifyOnSubtasks==`boolean`&&(n.notifyOnSubtasks=t.notifyOnSubtasks),typeof t.notifyOnCompletion==`boolean`&&(n.notifyOnCompletion=t.notifyOnCompletion),typeof t.notifyOnError==`boolean`&&(n.notifyOnError=t.notifyOnError),typeof t.notifyOnQuestion==`boolean`&&(n.notifyOnQuestion=t.notifyOnQuestion),t.notificationTemplates&&typeof t.notificationTemplates==`object`){let e=t.notificationTemplates,r=t=>{let n=e[t];if(!n||typeof n!=`object`)return;let r=n;return{title:typeof r.title==`string`?r.title:``,message:typeof r.message==`string`?r.message:``}},i=r(`completion`),a=r(`error`),o=r(`question`),s=r(`subtask`);(i||a||o||s)&&(n.notificationTemplates={completion:i??{title:`Task Complete`,message:`Your task has finished.`},error:a??{title:`Error Occurred`,message:`An error occurred while processing your task.`},question:o??{title:`Input Needed`,message:`Please provide input to continue.`},subtask:s??{title:`Subtask Complete`,message:`A subtask has finished.`}})}if(typeof t.summarizeLastMessage==`boolean`&&(n.summarizeLastMessage=t.summarizeLastMessage),typeof t.summaryThreshold==`number`&&Number.isFinite(t.summaryThreshold)&&(n.summaryThreshold=Math.max(0,Math.round(t.summaryThreshold))),typeof t.summaryLength==`number`&&Number.isFinite(t.summaryLength)&&(n.summaryLength=Math.max(10,Math.round(t.summaryLength))),typeof t.maxLastMessageLength==`number`&&Number.isFinite(t.maxLastMessageLength)&&(n.maxLastMessageLength=Math.max(10,Math.round(t.maxLastMessageLength))),typeof t.usageAutoRefresh==`boolean`&&(n.usageAutoRefresh=t.usageAutoRefresh),typeof t.usageRefreshIntervalMs==`number`&&Number.isFinite(t.usageRefreshIntervalMs)&&(n.usageRefreshIntervalMs=t.usageRefreshIntervalMs),(t.usageDisplayMode===`usage`||t.usageDisplayMode===`remaining`)&&(n.usageDisplayMode=t.usageDisplayMode),typeof t.usageShowPredValues==`boolean`&&(n.usageShowPredValues=t.usageShowPredValues),Array.isArray(t.usageDropdownProviders)&&(n.usageDropdownProviders=t.usageDropdownProviders.filter(e=>typeof e==`string`&&e.length>0)),t.usageSelectedModels&&typeof t.usageSelectedModels==`object`){let e={};for(let[n,r]of Object.entries(t.usageSelectedModels))Array.isArray(r)&&(e[n]=r.filter(e=>typeof e==`string`));Object.keys(e).length>0&&(n.usageSelectedModels=e)}if(t.usageCollapsedFamilies&&typeof t.usageCollapsedFamilies==`object`){let e={};for(let[n,r]of Object.entries(t.usageCollapsedFamilies))Array.isArray(r)&&(e[n]=r.filter(e=>typeof e==`string`));Object.keys(e).length>0&&(n.usageCollapsedFamilies=e)}if(t.usageExpandedFamilies&&typeof t.usageExpandedFamilies==`object`){let e={};for(let[n,r]of Object.entries(t.usageExpandedFamilies))Array.isArray(r)&&(e[n]=r.filter(e=>typeof e==`string`));Object.keys(e).length>0&&(n.usageExpandedFamilies=e)}if(t.usageModelGroups&&typeof t.usageModelGroups==`object`){let e={};for(let[n,r]of Object.entries(t.usageModelGroups))if(r&&typeof r==`object`){let t=r,i={};Array.isArray(t.customGroups)&&(i.customGroups=t.customGroups.filter(e=>e&&typeof e==`object`).map(e=>({id:String(e.id??``),label:String(e.label??``),models:Array.isArray(e.models)?e.models.filter(e=>typeof e==`string`):[],order:typeof e.order==`number`?e.order:0}))),t.modelAssignments&&typeof t.modelAssignments==`object`&&(i.modelAssignments=Object.fromEntries(Object.entries(t.modelAssignments).filter(([,e])=>typeof e==`string`).map(([e,t])=>[e,String(t)]))),t.renamedGroups&&typeof t.renamedGroups==`object`&&(i.renamedGroups=Object.fromEntries(Object.entries(t.renamedGroups).filter(([,e])=>typeof e==`string`).map(([e,t])=>[e,String(t)]))),Object.keys(i).length>0&&(e[n]=i)}Object.keys(e).length>0&&(n.usageModelGroups=e)}typeof t.inputSpellcheckEnabled==`boolean`&&(n.inputSpellcheckEnabled=t.inputSpellcheckEnabled),typeof t.showOpenCodeUpdateNotifications==`boolean`&&(n.showOpenCodeUpdateNotifications=t.showOpenCodeUpdateNotifications),typeof t.openCodeUpdateToastDismissedVersion==`string`&&(n.openCodeUpdateToastDismissedVersion=t.openCodeUpdateToastDismissedVersion.trim().slice(0,128)),typeof t.showToolFileIcons==`boolean`&&(n.showToolFileIcons=t.showToolFileIcons),typeof t.codeBlockLineWrap==`boolean`&&(n.codeBlockLineWrap=t.codeBlockLineWrap),typeof t.showTurnChangedFiles==`boolean`&&(n.showTurnChangedFiles=t.showTurnChangedFiles),typeof t.showExpandedBashTools==`boolean`&&(n.showExpandedBashTools=t.showExpandedBashTools),typeof t.showSubagentTaskDetails==`boolean`&&(n.showSubagentTaskDetails=t.showSubagentTaskDetails),typeof t.timeFormatPreference==`string`&&(t.timeFormatPreference===`auto`||t.timeFormatPreference===`12h`||t.timeFormatPreference===`24h`)&&(n.timeFormatPreference=t.timeFormatPreference),typeof t.weekStartPreference==`string`&&(t.weekStartPreference===`auto`||t.weekStartPreference===`sunday`||t.weekStartPreference===`monday`)&&(n.weekStartPreference=t.weekStartPreference),typeof t.desktopWindowControlsPosition==`string`&&(t.desktopWindowControlsPosition===`auto`||t.desktopWindowControlsPosition===`left`||t.desktopWindowControlsPosition===`right`)&&(n.desktopWindowControlsPosition=t.desktopWindowControlsPosition),typeof t.chatRenderMode==`string`&&(t.chatRenderMode===`sorted`||t.chatRenderMode===`live`)&&(n.chatRenderMode=t.chatRenderMode),typeof t.messageStreamTransport==`string`&&(t.messageStreamTransport===`auto`||t.messageStreamTransport===`ws`||t.messageStreamTransport===`sse`)&&(n.messageStreamTransport=t.messageStreamTransport),typeof t.activityRenderMode==`string`&&(t.activityRenderMode===`collapsed`||t.activityRenderMode===`summary`)&&(n.activityRenderMode=t.activityRenderMode),typeof t.mermaidRenderingMode==`string`&&(t.mermaidRenderingMode===`svg`||t.mermaidRenderingMode===`ascii`)&&(n.mermaidRenderingMode=t.mermaidRenderingMode),typeof t.userMessageRenderingMode==`string`&&(t.userMessageRenderingMode===`markdown`||t.userMessageRenderingMode===`plain`)&&(n.userMessageRenderingMode=t.userMessageRenderingMode),typeof t.collapsibleUserMessages==`boolean`&&(n.collapsibleUserMessages=t.collapsibleUserMessages),typeof t.stickyUserHeader==`boolean`&&(n.stickyUserHeader=t.stickyUserHeader),typeof t.promptNavigatorEnabled==`boolean`&&(n.promptNavigatorEnabled=t.promptNavigatorEnabled),typeof t.wideChatLayoutEnabled==`boolean`&&(n.wideChatLayoutEnabled=t.wideChatLayoutEnabled),typeof t.showSplitAssistantMessageActions==`boolean`&&(n.showSplitAssistantMessageActions=t.showSplitAssistantMessageActions),typeof t.showAssistantTps==`boolean`&&(n.showAssistantTps=t.showAssistantTps),typeof t.fontSize==`number`&&Number.isFinite(t.fontSize)&&(n.fontSize=t.fontSize),typeof t.terminalFontSize==`number`&&Number.isFinite(t.terminalFontSize)&&(n.terminalFontSize=t.terminalFontSize),typeof t.editorFontSize==`number`&&Number.isFinite(t.editorFontSize)&&(n.editorFontSize=t.editorFontSize),h(t.uiFont)&&(n.uiFont=t.uiFont),p(t.monoFont)&&(n.monoFont=t.monoFont),typeof t.padding==`number`&&Number.isFinite(t.padding)&&(n.padding=t.padding),typeof t.cornerRadius==`number`&&Number.isFinite(t.cornerRadius)&&(n.cornerRadius=t.cornerRadius),typeof t.inputBarOffset==`number`&&Number.isFinite(t.inputBarOffset)&&(n.inputBarOffset=t.inputBarOffset);let i=za(t.shortcutOverrides);i&&(n.shortcutOverrides=i),typeof t.mobileKeyboardMode==`string`&&(t.mobileKeyboardMode===`native`||t.mobileKeyboardMode===`resize-content`)&&(n.mobileKeyboardMode=t.mobileKeyboardMode);let a=Xa(t.favoriteModels,64,{preserveVariant:!0});a&&(n.favoriteModels=a);let o=Xa(t.hiddenModels,1024);o&&(n.hiddenModels=o);let s=Wa(t.collapsedModelProviders);s&&(n.collapsedModelProviders=s);let c=Xa(t.recentModels,16,{preserveVariant:!0});c&&(n.recentModels=c);let l=Wa(t.recentAgents);l&&(n.recentAgents=l);let u=Ga(t.recentEfforts);if(u&&(n.recentEfforts=u),typeof t.diffLayoutPreference==`string`&&(t.diffLayoutPreference===`dynamic`||t.diffLayoutPreference===`inline`||t.diffLayoutPreference===`side-by-side`)&&(n.diffLayoutPreference=t.diffLayoutPreference),typeof t.gitChangesViewMode==`string`&&(t.gitChangesViewMode===`flat`||t.gitChangesViewMode===`tree`)&&(n.gitChangesViewMode=t.gitChangesViewMode),typeof t.directoryShowHidden==`boolean`&&(n.directoryShowHidden=t.directoryShowHidden),typeof t.filesViewShowGitignored==`boolean`&&(n.filesViewShowGitignored=t.filesViewShowGitignored),typeof t.openInAppId==`string`&&t.openInAppId.length>0&&(n.openInAppId=t.openInAppId),typeof t.pwaAppName==`string`){let e=t.pwaAppName.trim().replace(/\s+/g,` `).slice(0,64);n.pwaAppName=e.length>0?e:``}let d=Ra(t.skillCatalogs);return d&&(n.skillCatalogs=d),typeof t.reportUsage==`boolean`&&(n.reportUsage=t.reportUsage),typeof t.globalBehaviorPrompt==`string`&&(n.globalBehaviorPrompt=t.globalBehaviorPrompt),typeof t.responseStyleEnabled==`boolean`&&(n.responseStyleEnabled=t.responseStyleEnabled),typeof t.responseStylePreset==`string`&&(t.responseStylePreset===`concise`||t.responseStylePreset===`detailed`||t.responseStylePreset===`mentor`||t.responseStylePreset===`pushback`||t.responseStylePreset===`noFiller`||t.responseStylePreset===`matchEnergy`||t.responseStylePreset===`warmPeer`||t.responseStylePreset===`custom`)&&(n.responseStylePreset=t.responseStylePreset),typeof t.responseStyleCustomInstructions==`string`&&(n.responseStyleCustomInstructions=t.responseStyleCustomInstructions),typeof t.dictationEnabled==`boolean`&&(n.dictationEnabled=t.dictationEnabled),t.sttProvider===`local`||t.sttProvider===`openai-compatible`?n.sttProvider=t.sttProvider:t.sttProvider===`server`?n.sttProvider=`openai-compatible`:(t.sttProvider===`browser`||t.sttProvider===`wasm`)&&(n.sttProvider=`local`),typeof t.sttServerUrl==`string`&&(n.sttServerUrl=t.sttServerUrl.trim()),typeof t.sttModel==`string`&&(n.sttModel=t.sttModel.trim()),typeof t.sttLocalModel==`string`&&(n.sttLocalModel=t.sttLocalModel.trim()),typeof t.sttLanguage==`string`&&(n.sttLanguage=t.sttLanguage.trim()),n},no=new Map,ro=new Map,io=2e3,ao=async e=>{let t=no.get(e);if(t&&Date.now()-t.at<io)return t.value;let n=ro.get(e);if(n)return n;let r=(async()=>{if(i()!==e)return null;let t=Qa();if(t)try{let n=to((await t.load()).settings);return no.set(e,{value:n,at:Date.now()}),n}catch(e){console.warn(`Failed to load shared settings from runtime settings API:`,e)}if(i()!==e)return null;try{let t=await Ke(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return null;let n=to(await t.json().catch(()=>null));return no.set(e,{value:n,at:Date.now()}),n}catch(e){return console.warn(`Failed to load shared settings from server:`,e),null}})();ro.set(e,r);try{return await r}finally{ro.get(e)===r&&ro.delete(e)}},oo=async()=>{if(typeof window>`u`)return;let e=i(),t=Za(),n=()=>!t?.hasHydrated||t.hasHydrated()||!t.onFinishHydration?Promise.resolve():new Promise(e=>{let n=!1,r=()=>{n||(n=!0,e())},i=t.onFinishHydration(()=>{i?.(),r()});t.hasHydrated?.()&&r()}),r=async t=>{if(await n(),i()===e){try{Ia(t)}catch(e){console.warn(`persistToLocalStorage failed:`,e)}try{eo(t)}catch(e){console.warn(`applyDesktopUiPreferences failed:`,e)}La(t)}};try{let t=await ao(e);t&&i()===e&&await r(t)}catch(e){console.warn(`Failed to synchronise settings:`,e)}},so=null,Q=null,$=null,co=[],lo=200,uo=async()=>{let e=so,t=Q,n=co;if(so=null,Q=null,$=null,co=[],!e||!t||Object.keys(e).length===0){n.forEach(e=>e());return}if(i()!==t){n.forEach(e=>e());return}let r=()=>i()===t,a=Qa();if(a){try{let i=await a.save(e);$a(i,e,t),i&&r()&&(Ia(i),eo(i),La(i),no.set(t,{value:to(i),at:Date.now()})),n.forEach(e=>e());return}catch(e){console.warn(`Failed to update settings via runtime settings API:`,e)}if(!r()){n.forEach(e=>e());return}}try{let n=await Ke(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!n.ok){console.warn(`Failed to update shared settings via API:`,n.status,n.statusText);return}let i=await n.json().catch(()=>null);$a(i,e,t),i&&r()&&(Ia(i),eo(i),La(i),no.set(t,{value:to(i),at:Date.now()}))}catch(e){console.warn(`Failed to update shared settings via API:`,e)}finally{n.forEach(e=>e())}},fo=async e=>{if(typeof window>`u`)return;let t=i();if(Q&&Q!==t){$&&=(clearTimeout($),null),so=null,Q=null;let e=co;co=[],e.forEach(e=>e())}let n={...so??{}},r=no.get(t)?.value;for(let[t,i]of Object.entries(e)){let e=r?.[t];Object.is(i,e)||i!==void 0&&e!==void 0&&JSON.stringify(i)===JSON.stringify(e)?delete n[t]:n[t]=i}if(so=n,Q=t,Object.keys(n).length===0&&!$){so=null,Q=null;return}$&&clearTimeout($);let a=new Promise(e=>{co.push(e)});return $=setTimeout(()=>void uo(),lo),a},po=async()=>{if(typeof window>`u`)return;let e=Za();try{let t=await Hi();if(!t)return;let n=()=>Vi(t);if(e?.hasHydrated?.()){n();return}if(n(),e?.onFinishHydration){let t=e.onFinishHydration(()=>{t?.(),n()})}}catch(e){console.warn(`Failed to load appearance preferences:`,e)}};export{fr as $,Dt as $t,pi as A,ve as An,on as At,Lr as B,yt as Bt,Xi as C,$e as Cn,pn as Ct,Ri as D,et as Dn,fn as Dt,Li as E,Qe as En,Rn as Et,wi as F,E as Ft,zr as G,dt as Gt,Jr as H,ht as Ht,K as I,It,W as J,Wt as Jt,Hr as K,T as Kt,_i as L,zt as Lt,Zr as M,an as Mt,Xr as N,j as Nt,ji as O,Je as On,hn as Ot,vi as P,A as Pt,pr as Q,lt as Qt,Ci as R,Yt as Rt,Zi as S,at as Sn,_n as St,Yi as T,tt as Tn,Tn as Tt,Yr as U,_t as Ut,qr as V,Ht as Vt,Ur as W,ut as Wt,kr as X,Tt as Xt,Sr as Y,O as Yt,jr as Z,ct as Zt,Ui as _,Pt as _n,mn as _t,Pa as a,qt as an,Vn as at,Ji as b,ft as bn,bn as bt,Oa as c,Mt as cn,B as ct,Ca as d,Bt as dn,Wn as dt,Ot as en,ur as et,xa as f,Gt as fn,Zn as ft,X as g,vt as gn,zn as gt,ia as h,gt as hn,N as ht,Ma as i,Ut as in,Bn as it,ii as j,nn as jt,Mi as k,Ke as kn,sn as kt,wa as l,mt as ln,qn as lt,na as m,bt as mn,Un as mt,oo as n,Rt as nn,sr as nt,Na as o,At as on,z as ot,aa as p,Kt as pn,Hn as pt,Wr as q,D as qt,fo as r,Jt as rn,or as rt,Da as s,Nt as sn,Gn as st,po as t,Lt as tn,cr as tt,Sa as u,Vt as un,Yn as ut,qi as v,Et as vn,yn as vt,Qi as w,rt as wn,jn as wt,Gi as x,ot as xn,xn as xt,Ki as y,Ft as yn,vn as yt,Fr as z,kt as zt};
|
|
3
|
+
`)=>{let r=W(e.text,e.references).document,i=W(t.text,t.references).document;if(r.text===i.text&&JSON.stringify(r.references)===JSON.stringify(i.references))return i;let a=new Set(r.references.map(e=>e.id)),o=e=>{let t=e;for(;a.has(t);)t=`recovered:${t}`;return a.add(t),t},s=r.text.length+n.length;return W(`${r.text}${n}${i.text}`,[...r.references,...i.references.map(e=>({...e,id:o(e.id),start:e.start+s,end:e.end+s}))]).document},Xr=e=>({state:`unbound-legacy`,sessionID:e}),K=e=>e.state===`bound`?`bound:${JSON.stringify([e.transportIdentity,pr(e.directory),e.sessionID,e.deliveryTarget??{kind:`primary`}])}`:`unbound-legacy:${JSON.stringify([e.sessionID])}`,Zr=(e,t)=>e.queuedMessages[K(t)]??Qr,Qr=[],$r=3e4,ei=`queue`,ti=e=>e===`steer`||e===`queue`,ni=(e,t)=>e===`immediate`?`steer`:ti(e)?e:t===!1?`steer`:`queue`,ri=[],ii=(e,t)=>e.pendingAdmissions[K(t)]??ri,ai=e=>`${e}-${ur()}`,oi=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype,si=(e,t,n=[])=>{if(!oi(e)||!Object.keys(e).every(e=>e===`text`||e===`references`))return;let r=e;if(typeof r.text!=`string`)return;let i=jn(r.text,r.references),a=i&&Wr(i,`queue-canonical`);if(!a||!a.ok||a.text!==t)return;let o=new Set(n.map(e=>e.id));return kr(i).every(e=>o.has(e.attachmentRefID))?i:void 0},ci=(e,t)=>{if(e===void 0)return[];if(!t)return;let n=Tn(t.text,e);if(n)return n.some(e=>t.references.some(t=>e.range.start<t.end&&t.start<e.range.end))?void 0:n},li=(e,t)=>{let n=oi(e)&&typeof e.content==`string`?e:t,r=si(n.composerDocument,n.content,Array.isArray(n.attachments)?n.attachments:[]),i=ci(n.composerMentions,r);return{content:n.content,...r?{composerDocument:r}:{},...r&&i?.length?{composerMentions:i}:{},...Array.isArray(n.attachments)?{attachments:n.attachments}:{},...oi(n.sendConfig)?{sendConfig:n.sendConfig}:{}}},ui=e=>li(void 0,e),di=(e,t)=>e.queueItemID===t.queueItemID&&e.operationID===t.operationID&&(!t.messageID||e.messageID===t.messageID),q=e=>e.status===`sending`||e.status===`reconciling`,fi=ee(),pi=()=>fi?.flush()??!0,mi=`quiescing`,hi=new Set,gi=new Set,_i=e=>{if(mi!==e){mi=e;for(let e of gi)e()}},vi=e=>{if(!(!e||hi.has(e))){hi.add(e);for(let e of gi)e()}},yi=e=>e.state===`bound`&&hi.has(e.transportIdentity),J=e=>mi===`open`&&(!e||!yi(e)),bi=(e,t=Date.now())=>({reconciliationStartedAt:e.reconciliationStartedAt??t,reconciliationDeadlineAt:e.reconciliationDeadlineAt??(e.reconciliationStartedAt??t)+$r,reconciliationChecks:Math.max(0,Math.floor(e.reconciliationChecks??0))}),xi=(e,t,n)=>{let r=t.queueItemID??(t.id||ai(`queued`)),i=!t.owner&&(t.status===`sending`||t.status===`reconciling`),a=i?`unresolved`:t.status===`sending`?`reconciling`:t.status===`retrying`||t.status===`reconciling`||t.status===`unresolved`||t.status===`failed`?t.status:`queued`,o=typeof t.messageID==`string`&&t.messageID.startsWith(`msg_`)?t.messageID:sr(`msg`),s=si(t.composerDocument,t.content,t.attachments),c=ci(t.composerMentions,s);return{...t,...s?{composerDocument:s}:{composerDocument:void 0},...s&&c?.length?{composerMentions:c}:{composerMentions:void 0},id:r,queueItemID:r,operationID:t.operationID??ai(`operation`),messageID:o,owner:n,status:a,attemptCount:Math.max(0,Math.floor(t.attemptCount??0)),...t.status===`sending`||t.status===`reconciling`?bi(t):{},...i||a===`reconciling`&&t.status===`sending`?{failure:{kind:`ambiguous-dispatch`,recovery:li(t.failure?.recovery,t)}}:{}}},Si=e=>{let t=e??{},n={};for(let[e,r]of Object.entries(t.queuedMessages??{})){if(!Array.isArray(r))continue;let t;if(e.startsWith(`bound:`)||e.startsWith(`unbound-legacy:`)){let n=r[0],i=e.startsWith(`unbound-legacy:`)?(()=>{try{let t=JSON.parse(e.slice(15));return Array.isArray(t)&&typeof t[0]==`string`?t[0]:e}catch{return e}})():e;t=n?.owner?.state===`bound`?n.owner:Xr(n?.owner?.sessionID??i)}else t=Xr(e);for(let e of r){let r=e.owner?.state===`bound`?e.owner:t,i=K(r);(n[i]??=[]).push(xi(r.sessionID,e,r))}}return{queuedMessages:n,followUpBehavior:ni(t.followUpBehavior,t.queueModeEnabled??null)}},Y=(e,t,n,r)=>{if(yi(t))return;let i=K(t);e(e=>{let t=e.queuedMessages[i],a=t?.findIndex(e=>K(e.owner)===i&&di(e,n))??-1;if(a<0||!t)return e;let o=r(t[a]);if(o===t[a])return e;let s=t.slice();return s[a]=o,{queuedMessages:{...e.queuedMessages,[i]:s}}})},Ci=te()(re(ne((e,t)=>({queuedMessages:{},followUpBehavior:ei,pendingAdmissions:{},addToQueue:(t,n)=>{if(!J(t))return{ok:!1,reason:`invalid-composer-document`};let r=si(n.composerDocument,n.content,n.attachments);if(n.composerDocument!==void 0&&!r)return{ok:!1,reason:`invalid-composer-document`};let i=ci(n.composerMentions,r);if(n.composerMentions!==void 0&&!i)return{ok:!1,reason:`invalid-composer-mentions`};n={...n,...r?{composerDocument:r}:{},...i?.length?{composerMentions:i}:{}};let a={...n,id:ai(`queued`),queueItemID:``,operationID:ai(`operation`),messageID:sr(`msg`),createdAt:Date.now(),owner:t,status:`queued`,attemptCount:0};a.queueItemID=a.id;let o=K(t);return e(e=>({queuedMessages:{...e.queuedMessages,[o]:[...e.queuedMessages[o]??[],a]}})),{ok:!0,item:a}},removeFromQueue:(n,r,i)=>{if(!J(n)||!i)return!1;let a=K(n),o=t().queuedMessages[a];if(!o||o.length===0)return!0;let s=o.find(e=>(e.queueItemID===r||e.id===r)&&K(e.owner)===a);if(s&&s.operationID!==i)return!1;let c=o.find(e=>(e.queueItemID===r||e.id===r)&&e.operationID===i&&K(e.owner)===a);return!c||!q(c)&&(e(e=>{let t=e.queuedMessages[a];if(!t)return e;let n=t.filter(e=>e!==c);if(n.length===t.length)return e;if(n.length)return{queuedMessages:{...e.queuedMessages,[a]:n}};let{[a]:r,...i}=e.queuedMessages;return{queuedMessages:i}}),!Zr(t(),n).some(e=>e===c||(e.queueItemID===r||e.id===r)&&e.operationID===i))},reorderQueue:(t,n,r,i)=>{if(!J(t)||!i)return;let a=K(t);e(e=>{let t=e.queuedMessages[a],o=t?.findIndex(e=>(e.id===n||e.queueItemID===n)&&e.operationID===i&&K(e.owner)===a)??-1,s=t?.findIndex(e=>(e.id===r||e.queueItemID===r)&&K(e.owner)===a)??-1;if(!t||o<0||s<0||o===s||q(t[o])||q(t[s]))return e;let c=t.slice(),[l]=c.splice(o,1);return c.splice(s,0,l),{queuedMessages:{...e.queuedMessages,[a]:c}}})},popToInput:(e,n,r)=>{if(!J(e)||!r)return null;let i=Zr(t(),e).find(t=>(t.id===n||t.queueItemID===n)&&t.operationID===r&&K(t.owner)===K(e));return!i||q(i)||!t().removeFromQueue(e,i.queueItemID,i.operationID)?null:i},clearQueue:n=>{if(!J(n))return!1;let r=K(n),i=t().queuedMessages[r],a=(t().pendingAdmissions[r]??[]).length>0;return(!i||i.length===0)&&!a||!i?.some(q)&&(e(e=>{if(e.queuedMessages[r]?.some(q))return e;let t={...e.queuedMessages},n={...e.pendingAdmissions};return delete t[r],delete n[r],{queuedMessages:t,pendingAdmissions:n}}),(t().queuedMessages[r]??[]).length===0)},clearAllQueues:()=>{J()&&e(e=>{let t={},n=!1;for(let[r,i]of Object.entries(e.queuedMessages)){if(i[0]&&yi(i[0].owner)){t[r]=i;continue}let e=i.filter(q);e.length&&(t[r]=e),e.length!==i.length&&(n=!0)}let r=Object.keys(e.pendingAdmissions).length>0;return n||r?{queuedMessages:t,pendingAdmissions:{}}:e})},setFollowUpBehavior:t=>{J()&&(e({followUpBehavior:t}),fo({followUpBehavior:t}))},getQueueForScope:e=>Zr(t(),e),getPendingAdmissionsForScope:e=>ii(t(),e),stageAdmission:(t,n)=>{if(!J(t)||!n.requestID||!n.queueItemID||!n.operationID||!n.messageID||typeof n.content!=`string`)return;let r=si(n.composerDocument,n.content);if(n.composerDocument!==void 0&&!r)return;let i=ci(n.composerMentions,r);if(n.composerMentions!==void 0&&!i)return;let a=K(t),o={kind:`pending-admission`,requestID:n.requestID,queueItemID:n.queueItemID,operationID:n.operationID,messageID:n.messageID,content:n.content,createdAt:n.createdAt,phase:`admitting`,attachmentCount:Math.max(0,Math.floor(n.attachmentCount??0)),...r?{composerDocument:r}:{},...r&&i?.length?{composerMentions:i}:{}};e(e=>{let t=[...(e.pendingAdmissions[a]??[]).filter(e=>e.requestID!==o.requestID&&e.queueItemID!==o.queueItemID),o];return{pendingAdmissions:{...e.pendingAdmissions,[a]:t}}})},unstageAdmission:(t,n)=>{if(!n)return;let r=K(t);e(e=>{let t=e.pendingAdmissions[r];if(!t?.length)return e;let i=t.filter(e=>e.requestID!==n);if(i.length===t.length)return e;if(i.length)return{pendingAdmissions:{...e.pendingAdmissions,[r]:i}};let{[r]:a,...o}=e.pendingAdmissions;return{pendingAdmissions:o}})},confirmAdmission:(n,r)=>{if(!J(n)||!r.requestID||!r.sendConfig?.providerID||!r.sendConfig?.modelID)return{ok:!1,reason:`invalid-composer-document`};let i=K(n),a=(t().pendingAdmissions[i]??[]).find(e=>e.requestID===r.requestID);if(!a)return{ok:!1,reason:`invalid-composer-document`};let o=si(a.composerDocument,a.content,r.attachments);if(a.composerDocument!==void 0&&!o)return{ok:!1,reason:`invalid-composer-document`};let s=ci(a.composerMentions,o);if(a.composerMentions!==void 0&&!s)return{ok:!1,reason:`invalid-composer-mentions`};let c={id:a.queueItemID,queueItemID:a.queueItemID,operationID:a.operationID,messageID:a.messageID,content:a.content,createdAt:a.createdAt,owner:n,status:`queued`,attemptCount:0,sendConfig:r.sendConfig,...o?{composerDocument:o}:{},...o&&s?.length?{composerMentions:s}:{},...r.attachments?.length?{attachments:r.attachments}:{}};return e(e=>{let t=(e.pendingAdmissions[i]??[]).filter(e=>e.requestID!==r.requestID);return{pendingAdmissions:t.length?{...e.pendingAdmissions,[i]:t}:(()=>{let{[i]:t,...n}=e.pendingAdmissions;return n})(),queuedMessages:{...e.queuedMessages,[i]:[...e.queuedMessages[i]??[],c]}}}),{ok:!0,item:c}},bindLegacyQueue:(t,n)=>{if(!J(t)||!J(n)||t.state!==`unbound-legacy`||n.state!==`bound`||t.sessionID!==n.sessionID)return[];let r=K(t),i=K(n),a=[];return e(e=>{let t=e.queuedMessages[r];if(!t||(a=t.filter(e=>!q(e)),a.length===0))return e;let o=t.filter(q),s={...e.queuedMessages,[i]:[...a.map(e=>({...e,owner:n})),...e.queuedMessages[i]??[]]};return o.length?s[r]=o:delete s[r],{queuedMessages:s}}),a.map(e=>({...e,owner:n}))},markQueueItemSendAttempt:(t,n)=>{J(t)&&Y(e,t,n,e=>e.status===`queued`||e.status===`retrying`&&(e.nextAttemptAt??0)<=Date.now()?{...e,status:`sending`,attemptCount:e.attemptCount+1,nextAttemptAt:void 0,failure:void 0}:e)},markQueueItemPreDispatchRetry:(t,n,r,i)=>Y(e,t,n,e=>e.status===`sending`?{...e,status:`retrying`,nextAttemptAt:r,failure:{kind:`pre-dispatch`,recovery:i?.recovery??ui(e)}}:e),markQueueItemReconciling:(t,n,r)=>Y(e,t,n,e=>e.status===`sending`?{...e,status:`reconciling`,nextAttemptAt:void 0,...bi(e),reconciliationNextCheckAt:void 0,failure:{kind:`ambiguous-dispatch`,recovery:r?.recovery??ui(e)}}:e),recordQueueItemReconciliationCheck:(t,n)=>Y(e,t,n,e=>e.status===`reconciling`&&di(e,n)?{...e,reconciliationChecks:(e.reconciliationChecks??0)+1,reconciliationNextCheckAt:Date.now()+2e3}:e),resolveQueueItemReconciliation:(t,n)=>Y(e,t,n,e=>e.status===`reconciling`&&di(e,n)?{...e,status:`unresolved`,nextAttemptAt:void 0}:e),markQueueItemDefinitiveFailure:(t,n,r)=>Y(e,t,n,e=>e.status===`sending`?{...e,status:`failed`,nextAttemptAt:void 0,failure:{kind:`definitive`,recovery:r?.recovery??ui(e)}}:e),resetQueueItemForDispatch:(t,n)=>{J(t)&&Y(e,t,n,e=>e.status!==`failed`&&e.status!==`unresolved`&&e.status!==`retrying`?e:{...e,status:`queued`,nextAttemptAt:void 0,failure:void 0,reconciliationStartedAt:void 0,reconciliationDeadlineAt:void 0,reconciliationChecks:void 0,reconciliationNextCheckAt:void 0})},beginQueueItemDispatch:(t,n,r,i,a=Date.now())=>{if(!J(t)||!r.startsWith(`msg_`))return null;let o=K(t),s=null;return e(e=>{let t=e.queuedMessages[o],c=i?t?.findIndex(e=>K(e.owner)===o&&di(e,n))??-1:0,l=c>=0?t?.[c]:void 0,u=l?.status===`queued`||l?.status===`retrying`&&(i||(l.nextAttemptAt??0)<=a)||i&&(l?.status===`failed`||l?.status===`unresolved`);if(!l||K(l.owner)!==o||!di(l,n)||!u||t?.some(q))return e;s={...l,messageID:r,status:`sending`,attemptCount:l.attemptCount+1,nextAttemptAt:void 0,failure:void 0,reconciliationStartedAt:void 0,reconciliationDeadlineAt:void 0,reconciliationChecks:void 0,reconciliationNextCheckAt:void 0};let d=t.slice();return d.splice(c,1),d.unshift(s),{queuedMessages:{...e.queuedMessages,[o]:d}}}),s},confirmQueueItem:(t,n)=>{if(yi(t))return;let r=K(t);e(e=>{let t=e.queuedMessages[r],i=t?.find(e=>{let t=!n.operationID||e.operationID===n.operationID,r=!n.messageID||e.messageID===n.messageID,i=!n.queueItemID||e.queueItemID===n.queueItemID;return t&&r&&i});if(!i||!n.operationID&&!n.messageID)return e;let a=t.filter(e=>e!==i);if(a.length)return{queuedMessages:{...e.queuedMessages,[r]:a}};let{[r]:o,...s}=e.queuedMessages;return{queuedMessages:s}})}}),{name:`message-queue-store`,version:4,storage:fi,partialize:e=>({queuedMessages:e.queuedMessages,followUpBehavior:e.followUpBehavior}),migrate:Si,merge:(e,t)=>({...t,...Si(e),pendingAdmissions:t.pendingAdmissions})}),{name:`message-queue-store`})),wi=(e,t)=>{let n=Ci.getState().queuedMessages,r=[],i=[];for(let[a,o]of Object.entries(n)){let n=o[0]?.owner;if(!n||n.state!==`unbound-legacy`)continue;let s=t(n.sessionID);if(!s){i.push(n.sessionID);continue}r.push({sourceKey:a,target:{state:`bound`,transportIdentity:e,directory:s,sessionID:n.sessionID},items:o})}return!e||i.length?{ok:!1,unresolvedSessionIDs:i}:r.length?(Ci.setState(e=>{let t={...e.queuedMessages};for(let e of r){let n=K(e.target);t[n]=[...e.items.map(t=>({...t,owner:e.target})),...t[n]??[]],delete t[e.sourceKey]}return{queuedMessages:t}}),{ok:!0,moved:r.reduce((e,t)=>e+t.items.length,0)}):{ok:!0,moved:0}},Ti=oe(),Ei=e(ie(),1),Di=`directoryTreeShowHidden`,Oi=`directory-show-hidden-change`,ki=()=>{if(typeof window>`u`)return!0;try{let e=f().getItem(Di);return e===null||e===`true`}catch{return!0}},Ai=()=>{typeof window>`u`||window.dispatchEvent(new Event(Oi))},ji=(e,t={})=>{if(!(typeof window>`u`)){try{f().setItem(Di,e?`true`:`false`),Ai()}catch{}t.persist!==!1&&fo({directoryShowHidden:e})}},Mi=()=>{let e=(0,Ti.c)(2),[t,n]=Ei.useState(ki),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>{n(ki())};return window.addEventListener(`storage`,e),window.addEventListener(Oi,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(Oi,e)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Ei.useEffect(r,i),t},Ni=`filesViewShowGitignored`,Pi=`files-view-show-gitignored-change`,Fi=()=>{if(typeof window>`u`)return!1;try{return f().getItem(Ni)===`true`}catch{return!1}},Ii=()=>{typeof window>`u`||window.dispatchEvent(new Event(Pi))},Li=(e,t={})=>{if(!(typeof window>`u`)){try{f().setItem(Ni,e?`true`:`false`),Ii()}catch{}t.persist!==!1&&fo({filesViewShowGitignored:e})}},Ri=()=>{let e=(0,Ti.c)(2),[t,n]=Ei.useState(Fi),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>{n(Fi())};return window.addEventListener(`storage`,e),window.addEventListener(Pi,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(Pi,e)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Ei.useEffect(r,i),t},zi=e=>{if(!e||typeof e!=`object`)return null;let t={};return typeof e.showReasoningTraces==`boolean`&&(t.showReasoningTraces=e.showReasoningTraces),typeof e.collapsibleThinkingBlocks==`boolean`&&(t.collapsibleThinkingBlocks=e.collapsibleThinkingBlocks),Object.keys(t).length>0?t:null},Bi=e=>{if(!e||typeof e!=`object`)return null;let t=e;return{showReasoningTraces:t.showReasoningTraces,collapsibleThinkingBlocks:t.collapsibleThinkingBlocks}},Vi=e=>{let t=v.getState();typeof e.showReasoningTraces==`boolean`&&t.setShowReasoningTraces(e.showReasoningTraces),typeof e.collapsibleThinkingBlocks==`boolean`&&t.setCollapsibleThinkingBlocks(e.collapsibleThinkingBlocks)},Hi=async()=>{if(typeof window>`u`)return null;let e=localStorage.getItem(`appearance-preferences`);if(!e)return null;try{return zi(Bi(JSON.parse(e)))}catch(e){return console.warn(`Failed to parse stored appearance preferences:`,e),null}},Ui=[{name:`explore`,icon:`compass-3`,labelKey:`chat.draftPresets.explore.label`,command:`/explore`},{name:`catch-up`,icon:`history`,labelKey:`chat.draftPresets.catchup.label`,command:`/catch-up`},{name:`weigh`,icon:`scales-3`,labelKey:`chat.draftPresets.weigh.label`,command:`/weigh`},{name:`craft-goal`,icon:`target`,labelKey:`chat.draftPresets.craftGoal.label`,command:`/craft-goal`},{name:`debug`,icon:`bug`,labelKey:`chat.draftPresets.debug.label`,command:`/debug`},{name:`review`,icon:`search-eye`,labelKey:`chat.draftPresets.review.label`,command:`/workspace-review`}],Wi=new Map(Ui.map(e=>[e.name,e])),Gi=e=>Wi.get(e),Ki=[{type:`command`,name:`explore`},{type:`command`,name:`catch-up`},{type:`command`,name:`weigh`},{type:`command`,name:`debug`},{type:`command`,name:`review`}],qi=`terminal-box`,Ji=`book-open`,Yi=e=>`${e.type}:${e.name}`,Xi=(e,t)=>e.type===t.type&&e.name===t.name,Zi=e=>{let t=e.replace(/^\//,``).replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();return t?t.charAt(0).toUpperCase()+t.slice(1):e},Qi=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,i=e.type===`command`||e.type===`skill`?e.type:null,a=typeof e.name==`string`?e.name.trim():``;if(!i||!a)continue;let o=`${i}:${a}`;n.has(o)||(n.add(o),t.push({type:i,name:a}))}return t},$i=`oc.rt.`,ea=e=>{try{return btoa(unescape(encodeURIComponent(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}catch{return encodeURIComponent(e)}},ta=(e,t=i())=>`${$i}${ea(t.trim().length>0?t.trim():`default`)}.${e}`,na=(e,t,n=i())=>e?e===ta(t,n):!1,ra=()=>{if(typeof window>`u`)return!0;let e=window.__OPENCHAMBER_API_BASE_URL__,t=window.__OPENCHAMBER_LOCAL_ORIGIN__;if(typeof e==`string`&&e.trim()&&typeof t==`string`&&t.trim())try{return new URL(e).origin===new URL(t).origin}catch{return!1}try{if(O())return!0}catch{}if(typeof e==`string`&&e.trim())try{let t=new URL(e).hostname;if(t!==`localhost`&&t!==`127.0.0.1`&&t!==`::1`)return!1}catch{return!1}return!0},ia=(e,t)=>{let n=t?.storage??(typeof localStorage<`u`?localStorage:{getItem:()=>null}),r=t?.transport??i(),a=n.getItem(ta(e,r));return a===null?ra()?n.getItem(e):null:a},X=(e,t,n)=>{let r=n?.storage??(typeof localStorage<`u`?localStorage:{setItem:()=>void 0}),a=n?.transport??i();r.setItem(ta(e,a),t)},aa=e=>{let t;try{t=u()}catch{return}let n=t=>t===null?null:JSON.parse(t,e?.reviver),r=e=>t.getItem(e);return{getItem:e=>{let t=ta(e,i()),a=r(t);if(a instanceof Promise)return a.then(t=>{if(t!==null)return n(t);if(!ra())return null;let i=r(e);return i instanceof Promise?i.then(n):n(i)});if(a!==null)return n(a);if(!ra())return null;let o=r(e);return o instanceof Promise?o.then(n):n(o)},setItem:(n,r)=>{let a=ta(n,i());t.setItem(a,JSON.stringify(r,e?.replacer))},removeItem:e=>{let n=ta(e,i());t.removeItem(n)}}},oa=512,sa=4096,ca=64,la=2e5,ua=[`concise`,`detailed`,`mentor`,`pushback`,`noFiller`,`matchEnergy`,`warmPeer`,`custom`],da=[`defaultModel`,`defaultVariant`,`defaultAgent`,`autoCreateWorktree`,`gitmojiEnabled`,`defaultFileViewerPreview`,`zenModel`,`messageStreamTransport`,`sttProvider`,`sttServerUrl`,`sttModel`,`sttLocalModel`,`sttLanguage`,`responseStyleEnabled`,`responseStylePreset`,`responseStyleCustomInstructions`],fa=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype,pa=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ma=(e,t)=>{if(typeof e!=`string`)return;let n=e.trim();return n.length<=t?n:void 0},ha=e=>{let t=ma(e,sa);if(t!==void 0)try{let e=new URL(t);return(e.protocol===`http:`||e.protocol===`https:`)&&!e.username&&!e.password?t:void 0}catch{return}},ga=(e,t)=>typeof e==`string`&&t.includes(e)?e:void 0,_a=e=>typeof e==`boolean`?e:void 0,va=(e,t)=>{let n=e[t];switch(t){case`autoCreateWorktree`:case`gitmojiEnabled`:case`defaultFileViewerPreview`:case`responseStyleEnabled`:return _a(n);case`messageStreamTransport`:return ga(n,[`auto`,`ws`,`sse`]);case`sttProvider`:return ga(n,[`local`,`openai-compatible`]);case`sttServerUrl`:return ha(n);case`sttLanguage`:return ma(n,ca);case`responseStyleCustomInstructions`:return ma(n,la);case`responseStylePreset`:return ga(n,ua);default:return ma(n,oa)}},ya=e=>{if(!fa(e))throw Error(`Invalid settings bootstrap response`);if(!pa(e,`schemaVersion`)||e.schemaVersion!==1)throw Error(`Unsupported settings bootstrap schema version`);let t={schemaVersion:1};for(let n of da){if(!pa(e,n))continue;let r=va(e,n);r!==void 0&&Object.assign(t,{[n]:r})}return t},ba=e=>{if(!fa(e))throw Error(`Invalid settings bootstrap patch`);for(let t of Object.keys(e))if(!da.includes(t))throw Error(`Invalid settings bootstrap patch`);let t=ya({schemaVersion:1,...e}),n={};for(let r of da)if(pa(e,r)){if(!pa(t,r))throw Error(`Invalid settings bootstrap patch`);Object.assign(n,{[r]:t[r]})}return n},xa=e=>{if(!fa(e))return{};let t={};for(let n of da){if(!pa(e,n))continue;let r=va(e,n);r!==void 0&&Object.assign(t,{[n]:r})}return t},Sa=new se({defaultOptions:{queries:{staleTime:3e4,gcTime:3e5,retry:1,refetchOnWindowFocus:!1}}}),Ca={runtime:()=>[i()],scoped:(...e)=>[i(),...e],quota:e=>[i(),e],commands:{list:(e,t=i())=>[t,`commands`,e]},agents:{list:(e,t=i())=>[t,`agents`,e],raw:(e,t=i())=>[t,`agents`,`raw`]},configCatalog:{providers:(e,t=i())=>[t,`configCatalog`,`providers`,e]},providers:{list:(e,t=i())=>[t,`providers`,e]},skills:{list:(e,t=i())=>[t,`skills`,e]},skillsCatalog:{sources:(e,t=i())=>[t,`skillsCatalog`,`sources`,Z(e)],source:(e,t,n=i())=>[n,`skillsCatalog`,`source`,Z(e),t]},messageQueue:{status:(e=i())=>[e,`messageQueue`,`status`],snapshot:(e=i())=>[e,`messageQueue`,`snapshot`],scope:(e,t,n=i())=>[n,`messageQueue`,`scope`,e,t]},mcp:{configs:(e,t=i())=>[t,`mcp`,`configs`,Z(e)],status:(e,t=i())=>[t,`mcp`,`status`,Z(e)]},github:{auth:(e=i())=>[e,`github`,`auth`]},git:{branches:(e,t=i())=>[t,`git`,`branches`,Z(e)],remotes:(e,t=i())=>[t,`git`,`remotes`,Z(e)]},sessionIndex:{snapshot:(e=i())=>[e,`sessionIndex`,`snapshot`]},sessionStatus:{snapshot:(e,t=i())=>[t,`sessionStatus`,`snapshot`,Z(e)]},sessionTurnChanges:{file:(e,t,n,r,a,o=i())=>[o,`sessionTurnChanges`,`file`,Z(e),t,n,r,typeof a==`number`&&Number.isFinite(a)?Math.max(0,Math.trunc(a)):null]},sessionActive:{snapshot:(e,t)=>[e,`sessionActive`,`snapshot`,t]},sessionTranscript:{infinite:(e,t,n=i(),r=y())=>[n,r,`session-transcript`,Z(e)??``,t],page:(e,t,n,r,a=i(),o=y())=>[a,o,`sessionMessages`,`page`,Z(e)??``,t,n,r?.trim()?r.trim():`tail`],tailTask:(e,t,n,r=i(),a=y())=>[r,a,`session-transcript-task`,`tail`,Z(e)??``,t,n],reconcileTask:(e,t,n,r=i(),a=y())=>[r,a,`session-transcript-task`,`reconcile`,Z(e)??``,t,n],checkpoint:(e,t,n=i(),r=y())=>[n,r,`session-transcript-checkpoint`,Z(e)??``,t]},plugins:{list:(e,t=i())=>[t,`plugins`,`list`,e],registry:(e,t,n=!1,r=i())=>[r,`plugins`,`registry`,e,wa(t),n],file:(e,t,n=i())=>[n,`plugins`,`file`,e,t]},files:{directory:(e,t,n,r=i())=>[r,`files`,`directory`,Ta(e),Ta(t),!!n],search:(e,t,n,r,a,o=i())=>[o,`files`,`search`,Ta(e),t.trim(),n??null,!!r,!!a],content:(e,t,n,r=i())=>Ea(`content`,e,t,n,r),stat:(e,t,n,r=i())=>Ea(`stat`,e,t,n,r)}},wa=e=>Array.from(new Set(e.map(e=>e.trim()).filter(Boolean))).sort(),Z=e=>e?.trim()||null,Ta=e=>{if(typeof e!=`string`)return null;let t=e.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},Ea=(e,t,n,r,i)=>[i,`files`,e,Ta(t),Ta(n),!!r?.allowOutsideWorkspace,r?.outsideFileGrant??null,!!r?.optional,Ta(r?.directory)],Da=async(e,t)=>{let n=await Ke(`/api/quota/${encodeURIComponent(e)}`,{signal:t}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Failed to fetch quota`);return r},Oa=e=>t(t=>{s(t)&&e.clear()}),ka=class extends Error{status;constructor(e){super(`Settings bootstrap request failed (${e})`),this.status=e,this.name=`SettingsBootstrapRequestError`}},Aa=(e=i())=>[e,`settings`,`bootstrap`],ja=(e=i())=>({queryKey:Aa(e),queryFn:async({signal:e})=>{let t=await Ke(`/api/config/settings/bootstrap`,{method:`GET`,headers:{Accept:`application/json`},signal:e});if(!t.ok)throw new ka(t.status);return ya(await t.json())},retry:(e,t)=>!(t instanceof ka&&(t.status===404||t.status===501))&&e<1,staleTime:1/0,gcTime:1/0}),Ma=(e=i())=>Sa.fetchQuery(ja(e)),Na=(e=i())=>Sa.getQueryData(Aa(e)),Pa=(e,t=i())=>{let n=ba(e),r=Aa(t),a=ya({schemaVersion:1,...Sa.getQueryData(r),...n});return Sa.setQueryData(r,a),a},Fa=e=>{if(!(typeof window>`u`)&&!(typeof window.__OPENCHAMBER_HOME__==`string`&&window.__OPENCHAMBER_HOME__.length>0))try{window.__OPENCHAMBER_HOME__=e}catch{}},Ia=e=>{if(!(typeof window>`u`)){if(e.themeId&&X(`selectedThemeId`,e.themeId),e.themeVariant&&X(`selectedThemeVariant`,e.themeVariant),e.lightThemeId&&X(`lightThemeId`,e.lightThemeId),e.darkThemeId&&X(`darkThemeId`,e.darkThemeId),typeof e.useSystemTheme==`boolean`&&(X(`useSystemTheme`,String(e.useSystemTheme)),X(`themeMode`,e.useSystemTheme?`system`:e.themeVariant===`dark`||e.themeVariant===`light`?e.themeVariant:`system`)),e.lastDirectory&&A(`lastDirectory`,e.lastDirectory),e.homeDirectory&&(A(`homeDirectory`,e.homeDirectory),Fa(e.homeDirectory)),Array.isArray(e.projects)&&e.projects.length>0?A(`projects`,JSON.stringify(e.projects)):j(`projects`),e.activeProjectId?A(`activeProjectId`,e.activeProjectId):j(`activeProjectId`),Array.isArray(e.pinnedDirectories)&&e.pinnedDirectories.length>0?A(`pinnedDirectories`,JSON.stringify(e.pinnedDirectories)):j(`pinnedDirectories`),Array.isArray(e.projects)&&e.projects.length>0){let t=e.projects.filter(e=>e.sidebarCollapsed===!0).map(e=>e.id).filter(e=>typeof e==`string`&&e.length>0);t.length>0?A(`oc.sessions.projectCollapse`,JSON.stringify(t)):j(`oc.sessions.projectCollapse`)}if(typeof e.gitmojiEnabled==`boolean`?localStorage.setItem(`gitmojiEnabled`,String(e.gitmojiEnabled)):localStorage.removeItem(`gitmojiEnabled`),typeof e.directoryShowHidden==`boolean`&&localStorage.setItem(`directoryTreeShowHidden`,e.directoryShowHidden?`true`:`false`),typeof e.filesViewShowGitignored==`boolean`&&localStorage.setItem(`filesViewShowGitignored`,e.filesViewShowGitignored?`true`:`false`),typeof e.openInAppId==`string`&&e.openInAppId.length>0&&localStorage.setItem(`openInAppId`,e.openInAppId),typeof e.pwaAppName==`string`){let t=e.pwaAppName.trim().replace(/\s+/g,` `).slice(0,64);t.length>0?localStorage.setItem(`openchamber.pwaName`,t):localStorage.removeItem(`openchamber.pwaName`)}if(typeof e.mobileKeyboardMode==`string`&&m(e.mobileKeyboardMode),typeof e.openCodeUpdateToastDismissedVersion==`string`){let t=e.openCodeUpdateToastDismissedVersion.trim();t?localStorage.setItem(`opencode-update-toast-dismissed-version`,t):localStorage.removeItem(`opencode-update-toast-dismissed-version`)}typeof e.dictationEnabled==`boolean`&&localStorage.setItem(`dictationEnabled`,String(e.dictationEnabled)),(e.sttProvider===`local`||e.sttProvider===`openai-compatible`)&&localStorage.setItem(`sttProvider`,e.sttProvider),typeof e.sttServerUrl==`string`&&localStorage.setItem(`sttServerUrl`,e.sttServerUrl),typeof e.sttModel==`string`&&localStorage.setItem(`sttModel`,e.sttModel),typeof e.sttLocalModel==`string`&&localStorage.setItem(`sttLocalModel`,e.sttLocalModel),typeof e.sttLanguage==`string`&&localStorage.setItem(`sttLanguage`,e.sttLanguage)}},La=e=>{typeof window>`u`||window.dispatchEvent(new CustomEvent(`openchamber:settings-synced`,{detail:e}))},Ra=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,i=typeof e.id==`string`?e.id.trim():``,a=typeof e.label==`string`?e.label.trim():``,o=typeof e.source==`string`?e.source.trim():``,s=typeof e.subpath==`string`?e.subpath.trim():``,c=typeof e.gitIdentityId==`string`?e.gitIdentityId.trim():``;!i||!a||!o||n.has(i)||(n.add(i),t.push({id:i,label:a,source:o,...s?{subpath:s}:{},...c?{gitIdentityId:c}:{}}))}return t},za=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e)){let e=typeof n==`string`?n.trim():``,i=typeof r==`string`?r.trim():``;!e||!i||(t[e]=i)}return t},Ba=(e,t)=>{let n=Object.entries(e),r=Object.entries(t);return n.length===r.length&&n.every(([e,n])=>t[e]===n)},Va=(e,t)=>e.length===t.length&&e.every((e,n)=>e.providerID===t[n]?.providerID&&e.modelID===t[n]?.modelID&&e.variant===t[n]?.variant),Ha=(e,t)=>{if(t.length===0)return t;let n=new Map;for(let t of e)typeof t.variant==`string`&&t.variant.length>0&&n.set(`${t.providerID}/${t.modelID}`,t.variant);return t.map(e=>{if(typeof e.variant==`string`&&e.variant.length>0)return e;let t=n.get(`${e.providerID}/${e.modelID}`);return t?{providerID:e.providerID,modelID:e.modelID,variant:t}:e})},Ua=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),Wa=e=>{if(Array.isArray(e))return Array.from(new Set(e.filter(e=>typeof e==`string`&&e.length>0)))},Ga=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e)){if(!n||!Array.isArray(r))continue;let e=Wa(r);e&&e.length>0&&(t[n]=e.slice(0,5))}return Object.keys(t).length>0?t:void 0},Ka=(e,t)=>{let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Array.isArray(t[n])&&Ua(e[n],t[n]))},qa=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,Ja=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t&&qa.test(t)?t.toLowerCase():null},Ya=e=>{if(!Array.isArray(e))return;let t=[],n=new Set,r=new Set;for(let i of e){if(!i||typeof i!=`object`)continue;let e=i,a=typeof e.path==`string`?e.path.trim():``;if(!a)continue;let o=a===`/`?a:a.replace(/\\/g,`/`).replace(/\/+$/,``);if(!o)continue;let s=cr(o);if(!s||n.has(s)||r.has(o))continue;n.add(s),r.add(o);let c={id:s,path:o};if(typeof e.label==`string`&&e.label.trim().length>0&&(c.label=e.label.trim()),typeof e.icon==`string`&&e.icon.trim().length>0&&(c.icon=e.icon.trim()),e.iconImage===null)c.iconImage=null;else if(e.iconImage&&typeof e.iconImage==`object`){let t=e.iconImage,n=typeof t.mime==`string`?t.mime.trim():``,r=typeof t.updatedAt==`number`&&Number.isFinite(t.updatedAt)?Math.max(0,Math.round(t.updatedAt)):0,i=t.source===`custom`||t.source===`auto`?t.source:null;n&&r>0&&i&&(c.iconImage={mime:n,updatedAt:r,source:i})}if(typeof e.color==`string`&&e.color.trim().length>0&&(c.color=e.color.trim()),e.iconBackground===null)c.iconBackground=null;else{let t=Ja(e.iconBackground);t&&(c.iconBackground=t)}typeof e.addedAt==`number`&&Number.isFinite(e.addedAt)&&e.addedAt>=0&&(c.addedAt=e.addedAt),typeof e.lastOpenedAt==`number`&&Number.isFinite(e.lastOpenedAt)&&e.lastOpenedAt>=0&&(c.lastOpenedAt=e.lastOpenedAt),typeof e.sidebarCollapsed==`boolean`&&(c.sidebarCollapsed=e.sidebarCollapsed),t.push(c)}return t.length>0?t:void 0},Xa=(e,t,n)=>{if(!Array.isArray(e))return;let r=[],i=new Set,a=n?.preserveVariant===!0;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n,o=typeof e.providerID==`string`?e.providerID.trim():``,s=typeof e.modelID==`string`?e.modelID.trim():``;if(!o||!s)continue;let c=`${o}/${s}`;if(!i.has(c)&&(i.add(c),a&&typeof e.variant==`string`&&e.variant.trim().length>0?r.push({providerID:o,modelID:s,variant:e.variant.trim()}):r.push({providerID:o,modelID:s}),r.length>=t))break}return r},Za=()=>{let e=v.persist;if(e&&typeof e==`object`)return e},Qa=()=>ot()?.settings??null,$a=(e,t,n)=>{let r={...xa(t),...xa(e)};if(Object.keys(r).length!==0)try{Pa(r,n)}catch(e){console.warn(`Failed to patch settings bootstrap cache:`,e)}},eo=e=>{let t=v.getState(),n=typeof window<`u`?window.__zustand_config_store__?.getState?.()??null:null,r=typeof window<`u`?window.__zustand_config_store__??null:null,i=Ci.getState();if(typeof e.showReasoningTraces==`boolean`&&e.showReasoningTraces!==t.showReasoningTraces&&t.setShowReasoningTraces(e.showReasoningTraces),typeof e.sessionTitleRefreshEnabled==`boolean`&&e.sessionTitleRefreshEnabled!==t.sessionTitleRefreshEnabled&&t.setSessionTitleRefreshEnabled(e.sessionTitleRefreshEnabled),typeof e.sessionGoalEnabled==`boolean`&&e.sessionGoalEnabled!==t.sessionGoalEnabled&&t.setSessionGoalEnabled(e.sessionGoalEnabled),typeof e.sessionGoalDefaultBudgetEnabled==`boolean`&&e.sessionGoalDefaultBudgetEnabled!==t.sessionGoalDefaultBudgetEnabled&&t.setSessionGoalDefaultBudgetEnabled(e.sessionGoalDefaultBudgetEnabled),typeof e.sessionGoalDefaultBudget==`number`&&Number.isFinite(e.sessionGoalDefaultBudget)&&e.sessionGoalDefaultBudget!==t.sessionGoalDefaultBudget&&t.setSessionGoalDefaultBudget(e.sessionGoalDefaultBudget),typeof e.collapsibleThinkingBlocks==`boolean`&&e.collapsibleThinkingBlocks!==t.collapsibleThinkingBlocks&&t.setCollapsibleThinkingBlocks(e.collapsibleThinkingBlocks),typeof e.autoDeleteEnabled==`boolean`&&e.autoDeleteEnabled!==t.autoDeleteEnabled&&t.setAutoDeleteEnabled(e.autoDeleteEnabled),typeof e.autoDeleteAfterDays==`number`&&Number.isFinite(e.autoDeleteAfterDays)){let n=Math.max(1,Math.min(365,e.autoDeleteAfterDays));n!==t.autoDeleteAfterDays&&t.setAutoDeleteAfterDays(n)}(e.sessionRetentionAction===`archive`||e.sessionRetentionAction===`delete`)&&e.sessionRetentionAction!==t.sessionRetentionAction&&t.setSessionRetentionAction(e.sessionRetentionAction);let a=null;if(ti(e.followUpBehavior)?a=e.followUpBehavior:typeof e.queueModeEnabled==`boolean`&&(a=ni(void 0,e.queueModeEnabled)),a&&a!==i.followUpBehavior&&i.setFollowUpBehavior(a),typeof e.showDeletionDialog==`boolean`&&e.showDeletionDialog!==t.showDeletionDialog&&t.setShowDeletionDialog(e.showDeletionDialog),typeof e.nativeNotificationsEnabled==`boolean`&&e.nativeNotificationsEnabled!==t.nativeNotificationsEnabled&&t.setNativeNotificationsEnabled(e.nativeNotificationsEnabled),typeof e.notificationMode==`string`&&(e.notificationMode===`always`||e.notificationMode===`hidden-only`)&&e.notificationMode!==t.notificationMode&&t.setNotificationMode(e.notificationMode),typeof e.notifyOnSubtasks==`boolean`&&e.notifyOnSubtasks!==t.notifyOnSubtasks&&t.setNotifyOnSubtasks(e.notifyOnSubtasks),typeof e.notifyOnCompletion==`boolean`&&e.notifyOnCompletion!==t.notifyOnCompletion&&t.setNotifyOnCompletion(e.notifyOnCompletion),typeof e.notifyOnError==`boolean`&&e.notifyOnError!==t.notifyOnError&&t.setNotifyOnError(e.notifyOnError),typeof e.notifyOnQuestion==`boolean`&&e.notifyOnQuestion!==t.notifyOnQuestion&&t.setNotifyOnQuestion(e.notifyOnQuestion),typeof e.notifyOnPermission==`boolean`&&e.notifyOnPermission!==t.notifyOnPermission&&t.setNotifyOnPermission(e.notifyOnPermission),typeof e.notifyOnScheduledTasks==`boolean`&&e.notifyOnScheduledTasks!==t.notifyOnScheduledTasks&&t.setNotifyOnScheduledTasks(e.notifyOnScheduledTasks),typeof e.notifyOnAssistants==`boolean`&&e.notifyOnAssistants!==t.notifyOnAssistants&&t.setNotifyOnAssistants(e.notifyOnAssistants),typeof e.notifyOnGoals==`boolean`&&e.notifyOnGoals!==t.notifyOnGoals&&t.setNotifyOnGoals(e.notifyOnGoals),e.notificationTemplates&&typeof e.notificationTemplates==`object`&&t.setNotificationTemplates(e.notificationTemplates),typeof e.summarizeLastMessage==`boolean`&&e.summarizeLastMessage!==t.summarizeLastMessage&&t.setSummarizeLastMessage(e.summarizeLastMessage),typeof e.summaryThreshold==`number`&&Number.isFinite(e.summaryThreshold)&&t.setSummaryThreshold(e.summaryThreshold),typeof e.summaryLength==`number`&&Number.isFinite(e.summaryLength)&&t.setSummaryLength(e.summaryLength),typeof e.maxLastMessageLength==`number`&&Number.isFinite(e.maxLastMessageLength)&&t.setMaxLastMessageLength(e.maxLastMessageLength),typeof e.inputSpellcheckEnabled==`boolean`&&e.inputSpellcheckEnabled!==t.inputSpellcheckEnabled&&t.setInputSpellcheckEnabled(e.inputSpellcheckEnabled),typeof e.showOpenCodeUpdateNotifications==`boolean`&&e.showOpenCodeUpdateNotifications!==t.showOpenCodeUpdateNotifications&&t.setShowOpenCodeUpdateNotifications(e.showOpenCodeUpdateNotifications),typeof e.showToolFileIcons==`boolean`&&e.showToolFileIcons!==t.showToolFileIcons&&t.setShowToolFileIcons(e.showToolFileIcons),typeof e.codeBlockLineWrap==`boolean`&&e.codeBlockLineWrap!==t.codeBlockLineWrap&&t.setCodeBlockLineWrap(e.codeBlockLineWrap),typeof e.showTurnChangedFiles==`boolean`&&e.showTurnChangedFiles!==t.showTurnChangedFiles&&t.setShowTurnChangedFiles(e.showTurnChangedFiles),typeof e.showExpandedBashTools==`boolean`&&e.showExpandedBashTools!==t.showExpandedBashTools&&t.setShowExpandedBashTools(e.showExpandedBashTools),typeof e.showSubagentTaskDetails==`boolean`&&e.showSubagentTaskDetails!==t.showSubagentTaskDetails&&t.setShowSubagentTaskDetails(e.showSubagentTaskDetails),typeof e.timeFormatPreference==`string`&&(e.timeFormatPreference===`auto`||e.timeFormatPreference===`12h`||e.timeFormatPreference===`24h`)&&e.timeFormatPreference!==t.timeFormatPreference&&t.setTimeFormatPreference(e.timeFormatPreference),typeof e.weekStartPreference==`string`&&(e.weekStartPreference===`auto`||e.weekStartPreference===`sunday`||e.weekStartPreference===`monday`)&&e.weekStartPreference!==t.weekStartPreference&&t.setWeekStartPreference(e.weekStartPreference),typeof e.desktopWindowControlsPosition==`string`&&(e.desktopWindowControlsPosition===`auto`||e.desktopWindowControlsPosition===`left`||e.desktopWindowControlsPosition===`right`)&&e.desktopWindowControlsPosition!==t.desktopWindowControlsPosition&&t.setDesktopWindowControlsPosition(e.desktopWindowControlsPosition),typeof e.chatRenderMode==`string`&&(e.chatRenderMode===`sorted`||e.chatRenderMode===`live`)&&e.chatRenderMode!==t.chatRenderMode&&t.setChatRenderMode(e.chatRenderMode),typeof e.activityRenderMode==`string`&&(e.activityRenderMode===`collapsed`||e.activityRenderMode===`summary`)&&e.activityRenderMode!==t.activityRenderMode&&t.setActivityRenderMode(e.activityRenderMode),typeof e.mermaidRenderingMode==`string`&&(e.mermaidRenderingMode===`svg`||e.mermaidRenderingMode===`ascii`)&&e.mermaidRenderingMode!==t.mermaidRenderingMode&&t.setMermaidRenderingMode(e.mermaidRenderingMode),typeof e.userMessageRenderingMode==`string`&&(e.userMessageRenderingMode===`markdown`||e.userMessageRenderingMode===`plain`)&&e.userMessageRenderingMode!==t.userMessageRenderingMode&&t.setUserMessageRenderingMode(e.userMessageRenderingMode),typeof e.collapsibleUserMessages==`boolean`&&e.collapsibleUserMessages!==t.collapsibleUserMessages&&t.setCollapsibleUserMessages(e.collapsibleUserMessages),typeof e.messageStreamTransport==`string`&&(e.messageStreamTransport===`auto`||e.messageStreamTransport===`ws`||e.messageStreamTransport===`sse`)&&n&&e.messageStreamTransport!==n.settingsMessageStreamTransport&&n.setSettingsMessageStreamTransport(e.messageStreamTransport),typeof e.stickyUserHeader==`boolean`&&e.stickyUserHeader!==t.stickyUserHeader&&t.setStickyUserHeader(e.stickyUserHeader),typeof e.promptNavigatorEnabled==`boolean`&&e.promptNavigatorEnabled!==t.promptNavigatorEnabled&&t.setPromptNavigatorEnabled(e.promptNavigatorEnabled),typeof e.expandedEditorToolbar==`boolean`&&e.expandedEditorToolbar!==t.expandedEditorToolbar&&t.setExpandedEditorToolbar(e.expandedEditorToolbar),typeof e.wideChatLayoutEnabled==`boolean`&&e.wideChatLayoutEnabled!==t.wideChatLayoutEnabled&&t.setWideChatLayoutEnabled(e.wideChatLayoutEnabled),typeof e.showSplitAssistantMessageActions==`boolean`&&e.showSplitAssistantMessageActions!==t.showSplitAssistantMessageActions&&t.setShowSplitAssistantMessageActions(e.showSplitAssistantMessageActions),typeof e.showAssistantTps==`boolean`&&e.showAssistantTps!==t.showAssistantTps&&t.setShowAssistantTps(e.showAssistantTps),typeof e.reportUsage==`boolean`&&e.reportUsage!==t.reportUsage&&t.setReportUsage(e.reportUsage),typeof e.fontSize==`number`&&Number.isFinite(e.fontSize)&&e.fontSize!==t.fontSize&&t.setFontSize(e.fontSize),Array.isArray(e.draftStarters)){let n=Qi(e.draftStarters);JSON.stringify(t.globalDraftStarters)!==JSON.stringify(n)&&t.setGlobalDraftStarters(n)}if(typeof e.terminalFontSize==`number`&&Number.isFinite(e.terminalFontSize)&&e.terminalFontSize!==t.terminalFontSize&&t.setTerminalFontSize(e.terminalFontSize),typeof e.editorFontSize==`number`&&Number.isFinite(e.editorFontSize)&&e.editorFontSize!==t.editorFontSize&&t.setEditorFontSize(e.editorFontSize),h(e.uiFont)&&e.uiFont!==t.uiFont&&t.setUiFont(e.uiFont),p(e.monoFont)&&e.monoFont!==t.monoFont&&t.setMonoFont(e.monoFont),typeof e.padding==`number`&&Number.isFinite(e.padding)&&e.padding!==t.padding&&t.setPadding(e.padding),typeof e.cornerRadius==`number`&&Number.isFinite(e.cornerRadius)&&e.cornerRadius!==t.cornerRadius&&t.setCornerRadius(e.cornerRadius),typeof e.inputBarOffset==`number`&&Number.isFinite(e.inputBarOffset)&&e.inputBarOffset!==t.inputBarOffset&&t.setInputBarOffset(e.inputBarOffset),e.shortcutOverrides&&!Ba(e.shortcutOverrides,t.shortcutOverrides)&&v.setState({shortcutOverrides:e.shortcutOverrides}),typeof e.mobileKeyboardMode==`string`){let n=g(e.mobileKeyboardMode,t.mobileKeyboardMode);n!==t.mobileKeyboardMode&&t.setMobileKeyboardMode(n)}if(r&&n){let t={};typeof e.dictationEnabled==`boolean`&&e.dictationEnabled!==n.dictationEnabled&&(t.dictationEnabled=e.dictationEnabled),(e.sttProvider===`local`||e.sttProvider===`openai-compatible`)&&e.sttProvider!==n.sttProvider&&(t.sttProvider=e.sttProvider),typeof e.sttServerUrl==`string`&&e.sttServerUrl!==n.sttServerUrl&&(t.sttServerUrl=e.sttServerUrl),typeof e.sttModel==`string`&&e.sttModel!==n.sttModel&&(t.sttModel=e.sttModel),typeof e.sttLocalModel==`string`&&e.sttLocalModel!==n.sttLocalModel&&(t.sttLocalModel=e.sttLocalModel),typeof e.sttLanguage==`string`&&e.sttLanguage!==n.sttLanguage&&(t.sttLanguage=e.sttLanguage),Object.keys(t).length>0&&r.setState(t)}if(Array.isArray(e.favoriteModels)){let n=t.favoriteModels,r=Ha(n,e.favoriteModels);Va(n,r)||v.setState({favoriteModels:r})}if(Array.isArray(e.hiddenModels)){let n=t.hiddenModels,r=e.hiddenModels;Va(n,r)||v.setState({hiddenModels:r})}if(Array.isArray(e.collapsedModelProviders)){let n=t.collapsedModelProviders,r=e.collapsedModelProviders;Ua(n,r)||v.setState({collapsedModelProviders:r})}if(Array.isArray(e.recentModels)){let n=t.recentModels,r=Ha(n,e.recentModels);Va(n,r)||v.setState({recentModels:r})}if(Array.isArray(e.recentAgents)){let n=t.recentAgents,r=e.recentAgents;Ua(n,r)||v.setState({recentAgents:r})}if(e.recentEfforts&&typeof e.recentEfforts==`object`){let n=t.recentEfforts,r=e.recentEfforts;Ka(n,r)||v.setState({recentEfforts:r})}typeof e.diffLayoutPreference==`string`&&(e.diffLayoutPreference===`dynamic`||e.diffLayoutPreference===`inline`||e.diffLayoutPreference===`side-by-side`)&&e.diffLayoutPreference!==t.diffLayoutPreference&&t.setDiffLayoutPreference(e.diffLayoutPreference),typeof e.gitChangesViewMode==`string`&&(e.gitChangesViewMode===`flat`||e.gitChangesViewMode===`tree`)&&e.gitChangesViewMode!==t.gitChangesViewMode&&t.setGitChangesViewMode(e.gitChangesViewMode),typeof e.directoryShowHidden==`boolean`&&ji(e.directoryShowHidden,{persist:!1}),typeof e.filesViewShowGitignored==`boolean`&&Li(e.filesViewShowGitignored,{persist:!1})},to=e=>{if(!e||typeof e!=`object`)return null;let t=e,n={};if(typeof t.themeId==`string`&&t.themeId.length>0&&(n.themeId=t.themeId),(t.useSystemTheme===!0||t.useSystemTheme===!1)&&(n.useSystemTheme=t.useSystemTheme),typeof t.themeVariant==`string`&&(t.themeVariant===`light`||t.themeVariant===`dark`)&&(n.themeVariant=t.themeVariant),typeof t.lightThemeId==`string`&&t.lightThemeId.length>0&&(n.lightThemeId=t.lightThemeId),typeof t.darkThemeId==`string`&&t.darkThemeId.length>0&&(n.darkThemeId=t.darkThemeId),typeof t.lastDirectory==`string`&&t.lastDirectory.length>0&&(n.lastDirectory=t.lastDirectory),typeof t.homeDirectory==`string`&&t.homeDirectory.length>0&&(n.homeDirectory=t.homeDirectory),typeof t.opencodeBinary==`string`){let e=t.opencodeBinary.trim();n.opencodeBinary=e.length>0?e:void 0}typeof t.desktopLanAccessEnabled==`boolean`&&(n.desktopLanAccessEnabled=t.desktopLanAccessEnabled),typeof t.desktopKeepAwakeEnabled==`boolean`&&(n.desktopKeepAwakeEnabled=t.desktopKeepAwakeEnabled),typeof t.desktopMinimizeToTrayEnabled==`boolean`&&(n.desktopMinimizeToTrayEnabled=t.desktopMinimizeToTrayEnabled);let r=Ya(t.projects);if(r&&(n.projects=r),typeof t.activeProjectId==`string`&&t.activeProjectId.length>0&&(n.activeProjectId=t.activeProjectId),Array.isArray(t.securityScopedBookmarks)&&(n.securityScopedBookmarks=t.securityScopedBookmarks.filter(e=>typeof e==`string`&&e.length>0)),Array.isArray(t.pinnedDirectories)&&(n.pinnedDirectories=Array.from(new Set(t.pinnedDirectories.filter(e=>typeof e==`string`&&e.length>0)))),Array.isArray(t.draftStarters)&&(n.draftStarters=Qi(t.draftStarters)),typeof t.draftStartersCraftGoalAdded==`boolean`&&(n.draftStartersCraftGoalAdded=t.draftStartersCraftGoalAdded),typeof t.showReasoningTraces==`boolean`&&(n.showReasoningTraces=t.showReasoningTraces),typeof t.sessionTitleRefreshEnabled==`boolean`&&(n.sessionTitleRefreshEnabled=t.sessionTitleRefreshEnabled),typeof t.sessionGoalEnabled==`boolean`&&(n.sessionGoalEnabled=t.sessionGoalEnabled),typeof t.sessionGoalDefaultBudgetEnabled==`boolean`&&(n.sessionGoalDefaultBudgetEnabled=t.sessionGoalDefaultBudgetEnabled),typeof t.sessionGoalDefaultBudget==`number`&&Number.isFinite(t.sessionGoalDefaultBudget)&&t.sessionGoalDefaultBudget>0&&(n.sessionGoalDefaultBudget=Math.floor(t.sessionGoalDefaultBudget)),typeof t.collapsibleThinkingBlocks==`boolean`&&(n.collapsibleThinkingBlocks=t.collapsibleThinkingBlocks),typeof t.autoDeleteEnabled==`boolean`&&(n.autoDeleteEnabled=t.autoDeleteEnabled),typeof t.autoDeleteAfterDays==`number`&&Number.isFinite(t.autoDeleteAfterDays)&&(n.autoDeleteAfterDays=t.autoDeleteAfterDays),(t.sessionRetentionAction===`archive`||t.sessionRetentionAction===`delete`)&&(n.sessionRetentionAction=t.sessionRetentionAction),typeof t.defaultModel==`string`&&t.defaultModel.length>0&&(n.defaultModel=t.defaultModel),typeof t.defaultVariant==`string`&&t.defaultVariant.length>0&&(n.defaultVariant=t.defaultVariant),typeof t.defaultAgent==`string`&&t.defaultAgent.length>0&&(n.defaultAgent=t.defaultAgent),typeof t.smallModelUseDefault==`boolean`&&(n.smallModelUseDefault=t.smallModelUseDefault),typeof t.smallModelOverride==`string`&&t.smallModelOverride.length>0&&(n.smallModelOverride=t.smallModelOverride),(t.summaryModelMode===`provider`||t.summaryModelMode===`custom`)&&(n.summaryModelMode=t.summaryModelMode),typeof t.summaryProviderID==`string`&&t.summaryProviderID.length>0&&(n.summaryProviderID=t.summaryProviderID),typeof t.summaryModelID==`string`&&t.summaryModelID.length>0&&(n.summaryModelID=t.summaryModelID),typeof t.summaryCustomBaseURL==`string`&&(n.summaryCustomBaseURL=t.summaryCustomBaseURL),typeof t.hasSummaryCustomAPIToken==`boolean`&&(n.hasSummaryCustomAPIToken=t.hasSummaryCustomAPIToken),typeof t.summaryCommitPrompt==`string`&&(n.summaryCommitPrompt=t.summaryCommitPrompt),typeof t.summarySessionTitlePrompt==`string`&&(n.summarySessionTitlePrompt=t.summarySessionTitlePrompt),typeof t.autoCreateWorktree==`boolean`&&(n.autoCreateWorktree=t.autoCreateWorktree),typeof t.gitmojiEnabled==`boolean`&&(n.gitmojiEnabled=t.gitmojiEnabled),ti(t.followUpBehavior)?n.followUpBehavior=t.followUpBehavior:typeof t.queueModeEnabled==`boolean`&&(n.followUpBehavior=ni(void 0,t.queueModeEnabled)),typeof t.showDeletionDialog==`boolean`&&(n.showDeletionDialog=t.showDeletionDialog),typeof t.nativeNotificationsEnabled==`boolean`&&(n.nativeNotificationsEnabled=t.nativeNotificationsEnabled),typeof t.notificationMode==`string`&&(t.notificationMode===`always`||t.notificationMode===`hidden-only`)&&(n.notificationMode=t.notificationMode),typeof t.notifyOnSubtasks==`boolean`&&(n.notifyOnSubtasks=t.notifyOnSubtasks),typeof t.notifyOnCompletion==`boolean`&&(n.notifyOnCompletion=t.notifyOnCompletion),typeof t.notifyOnError==`boolean`&&(n.notifyOnError=t.notifyOnError),typeof t.notifyOnQuestion==`boolean`&&(n.notifyOnQuestion=t.notifyOnQuestion),typeof t.notifyOnPermission==`boolean`&&(n.notifyOnPermission=t.notifyOnPermission),typeof t.notifyOnScheduledTasks==`boolean`&&(n.notifyOnScheduledTasks=t.notifyOnScheduledTasks),typeof t.notifyOnAssistants==`boolean`&&(n.notifyOnAssistants=t.notifyOnAssistants),typeof t.notifyOnGoals==`boolean`&&(n.notifyOnGoals=t.notifyOnGoals),t.notificationTemplates&&typeof t.notificationTemplates==`object`){let e=t.notificationTemplates,r=t=>{let n=e[t];if(!n||typeof n!=`object`)return;let r=n;return{title:typeof r.title==`string`?r.title:``,message:typeof r.message==`string`?r.message:``}},i=r(`completion`),a=r(`error`),o=r(`question`),s=r(`subtask`);(i||a||o||s)&&(n.notificationTemplates={completion:i??{title:`Task Complete`,message:`Your task has finished.`},error:a??{title:`Error Occurred`,message:`An error occurred while processing your task.`},question:o??{title:`Input Needed`,message:`Please provide input to continue.`},subtask:s??{title:`Subtask Complete`,message:`A subtask has finished.`}})}if(typeof t.summarizeLastMessage==`boolean`&&(n.summarizeLastMessage=t.summarizeLastMessage),typeof t.summaryThreshold==`number`&&Number.isFinite(t.summaryThreshold)&&(n.summaryThreshold=Math.max(0,Math.round(t.summaryThreshold))),typeof t.summaryLength==`number`&&Number.isFinite(t.summaryLength)&&(n.summaryLength=Math.max(10,Math.round(t.summaryLength))),typeof t.maxLastMessageLength==`number`&&Number.isFinite(t.maxLastMessageLength)&&(n.maxLastMessageLength=Math.max(10,Math.round(t.maxLastMessageLength))),typeof t.usageAutoRefresh==`boolean`&&(n.usageAutoRefresh=t.usageAutoRefresh),typeof t.usageRefreshIntervalMs==`number`&&Number.isFinite(t.usageRefreshIntervalMs)&&(n.usageRefreshIntervalMs=t.usageRefreshIntervalMs),(t.usageDisplayMode===`usage`||t.usageDisplayMode===`remaining`)&&(n.usageDisplayMode=t.usageDisplayMode),typeof t.usageShowPredValues==`boolean`&&(n.usageShowPredValues=t.usageShowPredValues),Array.isArray(t.usageDropdownProviders)&&(n.usageDropdownProviders=t.usageDropdownProviders.filter(e=>typeof e==`string`&&e.length>0)),t.usageSelectedModels&&typeof t.usageSelectedModels==`object`){let e={};for(let[n,r]of Object.entries(t.usageSelectedModels))Array.isArray(r)&&(e[n]=r.filter(e=>typeof e==`string`));Object.keys(e).length>0&&(n.usageSelectedModels=e)}if(t.usageCollapsedFamilies&&typeof t.usageCollapsedFamilies==`object`){let e={};for(let[n,r]of Object.entries(t.usageCollapsedFamilies))Array.isArray(r)&&(e[n]=r.filter(e=>typeof e==`string`));Object.keys(e).length>0&&(n.usageCollapsedFamilies=e)}if(t.usageExpandedFamilies&&typeof t.usageExpandedFamilies==`object`){let e={};for(let[n,r]of Object.entries(t.usageExpandedFamilies))Array.isArray(r)&&(e[n]=r.filter(e=>typeof e==`string`));Object.keys(e).length>0&&(n.usageExpandedFamilies=e)}if(t.usageModelGroups&&typeof t.usageModelGroups==`object`){let e={};for(let[n,r]of Object.entries(t.usageModelGroups))if(r&&typeof r==`object`){let t=r,i={};Array.isArray(t.customGroups)&&(i.customGroups=t.customGroups.filter(e=>e&&typeof e==`object`).map(e=>({id:String(e.id??``),label:String(e.label??``),models:Array.isArray(e.models)?e.models.filter(e=>typeof e==`string`):[],order:typeof e.order==`number`?e.order:0}))),t.modelAssignments&&typeof t.modelAssignments==`object`&&(i.modelAssignments=Object.fromEntries(Object.entries(t.modelAssignments).filter(([,e])=>typeof e==`string`).map(([e,t])=>[e,String(t)]))),t.renamedGroups&&typeof t.renamedGroups==`object`&&(i.renamedGroups=Object.fromEntries(Object.entries(t.renamedGroups).filter(([,e])=>typeof e==`string`).map(([e,t])=>[e,String(t)]))),Object.keys(i).length>0&&(e[n]=i)}Object.keys(e).length>0&&(n.usageModelGroups=e)}typeof t.inputSpellcheckEnabled==`boolean`&&(n.inputSpellcheckEnabled=t.inputSpellcheckEnabled),typeof t.showOpenCodeUpdateNotifications==`boolean`&&(n.showOpenCodeUpdateNotifications=t.showOpenCodeUpdateNotifications),typeof t.openCodeUpdateToastDismissedVersion==`string`&&(n.openCodeUpdateToastDismissedVersion=t.openCodeUpdateToastDismissedVersion.trim().slice(0,128)),typeof t.showToolFileIcons==`boolean`&&(n.showToolFileIcons=t.showToolFileIcons),typeof t.codeBlockLineWrap==`boolean`&&(n.codeBlockLineWrap=t.codeBlockLineWrap),typeof t.showTurnChangedFiles==`boolean`&&(n.showTurnChangedFiles=t.showTurnChangedFiles),typeof t.showExpandedBashTools==`boolean`&&(n.showExpandedBashTools=t.showExpandedBashTools),typeof t.showSubagentTaskDetails==`boolean`&&(n.showSubagentTaskDetails=t.showSubagentTaskDetails),typeof t.timeFormatPreference==`string`&&(t.timeFormatPreference===`auto`||t.timeFormatPreference===`12h`||t.timeFormatPreference===`24h`)&&(n.timeFormatPreference=t.timeFormatPreference),typeof t.weekStartPreference==`string`&&(t.weekStartPreference===`auto`||t.weekStartPreference===`sunday`||t.weekStartPreference===`monday`)&&(n.weekStartPreference=t.weekStartPreference),typeof t.desktopWindowControlsPosition==`string`&&(t.desktopWindowControlsPosition===`auto`||t.desktopWindowControlsPosition===`left`||t.desktopWindowControlsPosition===`right`)&&(n.desktopWindowControlsPosition=t.desktopWindowControlsPosition),typeof t.chatRenderMode==`string`&&(t.chatRenderMode===`sorted`||t.chatRenderMode===`live`)&&(n.chatRenderMode=t.chatRenderMode),typeof t.messageStreamTransport==`string`&&(t.messageStreamTransport===`auto`||t.messageStreamTransport===`ws`||t.messageStreamTransport===`sse`)&&(n.messageStreamTransport=t.messageStreamTransport),typeof t.activityRenderMode==`string`&&(t.activityRenderMode===`collapsed`||t.activityRenderMode===`summary`)&&(n.activityRenderMode=t.activityRenderMode),typeof t.mermaidRenderingMode==`string`&&(t.mermaidRenderingMode===`svg`||t.mermaidRenderingMode===`ascii`)&&(n.mermaidRenderingMode=t.mermaidRenderingMode),typeof t.userMessageRenderingMode==`string`&&(t.userMessageRenderingMode===`markdown`||t.userMessageRenderingMode===`plain`)&&(n.userMessageRenderingMode=t.userMessageRenderingMode),typeof t.collapsibleUserMessages==`boolean`&&(n.collapsibleUserMessages=t.collapsibleUserMessages),typeof t.stickyUserHeader==`boolean`&&(n.stickyUserHeader=t.stickyUserHeader),typeof t.promptNavigatorEnabled==`boolean`&&(n.promptNavigatorEnabled=t.promptNavigatorEnabled),typeof t.wideChatLayoutEnabled==`boolean`&&(n.wideChatLayoutEnabled=t.wideChatLayoutEnabled),typeof t.showSplitAssistantMessageActions==`boolean`&&(n.showSplitAssistantMessageActions=t.showSplitAssistantMessageActions),typeof t.showAssistantTps==`boolean`&&(n.showAssistantTps=t.showAssistantTps),typeof t.fontSize==`number`&&Number.isFinite(t.fontSize)&&(n.fontSize=t.fontSize),typeof t.terminalFontSize==`number`&&Number.isFinite(t.terminalFontSize)&&(n.terminalFontSize=t.terminalFontSize),typeof t.editorFontSize==`number`&&Number.isFinite(t.editorFontSize)&&(n.editorFontSize=t.editorFontSize),h(t.uiFont)&&(n.uiFont=t.uiFont),p(t.monoFont)&&(n.monoFont=t.monoFont),typeof t.padding==`number`&&Number.isFinite(t.padding)&&(n.padding=t.padding),typeof t.cornerRadius==`number`&&Number.isFinite(t.cornerRadius)&&(n.cornerRadius=t.cornerRadius),typeof t.inputBarOffset==`number`&&Number.isFinite(t.inputBarOffset)&&(n.inputBarOffset=t.inputBarOffset);let i=za(t.shortcutOverrides);i&&(n.shortcutOverrides=i),typeof t.mobileKeyboardMode==`string`&&(t.mobileKeyboardMode===`native`||t.mobileKeyboardMode===`resize-content`)&&(n.mobileKeyboardMode=t.mobileKeyboardMode);let a=Xa(t.favoriteModels,64,{preserveVariant:!0});a&&(n.favoriteModels=a);let o=Xa(t.hiddenModels,1024);o&&(n.hiddenModels=o);let s=Wa(t.collapsedModelProviders);s&&(n.collapsedModelProviders=s);let c=Xa(t.recentModels,16,{preserveVariant:!0});c&&(n.recentModels=c);let l=Wa(t.recentAgents);l&&(n.recentAgents=l);let u=Ga(t.recentEfforts);if(u&&(n.recentEfforts=u),typeof t.diffLayoutPreference==`string`&&(t.diffLayoutPreference===`dynamic`||t.diffLayoutPreference===`inline`||t.diffLayoutPreference===`side-by-side`)&&(n.diffLayoutPreference=t.diffLayoutPreference),typeof t.gitChangesViewMode==`string`&&(t.gitChangesViewMode===`flat`||t.gitChangesViewMode===`tree`)&&(n.gitChangesViewMode=t.gitChangesViewMode),typeof t.directoryShowHidden==`boolean`&&(n.directoryShowHidden=t.directoryShowHidden),typeof t.filesViewShowGitignored==`boolean`&&(n.filesViewShowGitignored=t.filesViewShowGitignored),typeof t.openInAppId==`string`&&t.openInAppId.length>0&&(n.openInAppId=t.openInAppId),typeof t.pwaAppName==`string`){let e=t.pwaAppName.trim().replace(/\s+/g,` `).slice(0,64);n.pwaAppName=e.length>0?e:``}let d=Ra(t.skillCatalogs);return d&&(n.skillCatalogs=d),typeof t.reportUsage==`boolean`&&(n.reportUsage=t.reportUsage),typeof t.globalBehaviorPrompt==`string`&&(n.globalBehaviorPrompt=t.globalBehaviorPrompt),typeof t.responseStyleEnabled==`boolean`&&(n.responseStyleEnabled=t.responseStyleEnabled),typeof t.responseStylePreset==`string`&&(t.responseStylePreset===`concise`||t.responseStylePreset===`detailed`||t.responseStylePreset===`mentor`||t.responseStylePreset===`pushback`||t.responseStylePreset===`noFiller`||t.responseStylePreset===`matchEnergy`||t.responseStylePreset===`warmPeer`||t.responseStylePreset===`custom`)&&(n.responseStylePreset=t.responseStylePreset),typeof t.responseStyleCustomInstructions==`string`&&(n.responseStyleCustomInstructions=t.responseStyleCustomInstructions),typeof t.dictationEnabled==`boolean`&&(n.dictationEnabled=t.dictationEnabled),t.sttProvider===`local`||t.sttProvider===`openai-compatible`?n.sttProvider=t.sttProvider:t.sttProvider===`server`?n.sttProvider=`openai-compatible`:(t.sttProvider===`browser`||t.sttProvider===`wasm`)&&(n.sttProvider=`local`),typeof t.sttServerUrl==`string`&&(n.sttServerUrl=t.sttServerUrl.trim()),typeof t.sttModel==`string`&&(n.sttModel=t.sttModel.trim()),typeof t.sttLocalModel==`string`&&(n.sttLocalModel=t.sttLocalModel.trim()),typeof t.sttLanguage==`string`&&(n.sttLanguage=t.sttLanguage.trim()),n},no=new Map,ro=new Map,io=2e3,ao=async e=>{let t=no.get(e);if(t&&Date.now()-t.at<io)return t.value;let n=ro.get(e);if(n)return n;let r=(async()=>{if(i()!==e)return null;let t=Qa();if(t)try{let n=to((await t.load()).settings);return no.set(e,{value:n,at:Date.now()}),n}catch(e){console.warn(`Failed to load shared settings from runtime settings API:`,e)}if(i()!==e)return null;try{let t=await Ke(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return null;let n=to(await t.json().catch(()=>null));return no.set(e,{value:n,at:Date.now()}),n}catch(e){return console.warn(`Failed to load shared settings from server:`,e),null}})();ro.set(e,r);try{return await r}finally{ro.get(e)===r&&ro.delete(e)}},oo=async()=>{if(typeof window>`u`)return;let e=i(),t=Za(),n=()=>!t?.hasHydrated||t.hasHydrated()||!t.onFinishHydration?Promise.resolve():new Promise(e=>{let n=!1,r=()=>{n||(n=!0,e())},i=t.onFinishHydration(()=>{i?.(),r()});t.hasHydrated?.()&&r()}),r=async t=>{if(await n(),i()===e){try{Ia(t)}catch(e){console.warn(`persistToLocalStorage failed:`,e)}try{eo(t)}catch(e){console.warn(`applyDesktopUiPreferences failed:`,e)}La(t)}};try{let t=await ao(e);t&&i()===e&&await r(t)}catch(e){console.warn(`Failed to synchronise settings:`,e)}},so=null,Q=null,$=null,co=[],lo=200,uo=async()=>{let e=so,t=Q,n=co;if(so=null,Q=null,$=null,co=[],!e||!t||Object.keys(e).length===0){n.forEach(e=>e());return}if(i()!==t){n.forEach(e=>e());return}let r=()=>i()===t,a=Qa();if(a){try{let i=await a.save(e);$a(i,e,t),i&&r()&&(Ia(i),eo(i),La(i),no.set(t,{value:to(i),at:Date.now()})),n.forEach(e=>e());return}catch(e){console.warn(`Failed to update settings via runtime settings API:`,e)}if(!r()){n.forEach(e=>e());return}}try{let n=await Ke(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!n.ok){console.warn(`Failed to update shared settings via API:`,n.status,n.statusText);return}let i=await n.json().catch(()=>null);$a(i,e,t),i&&r()&&(Ia(i),eo(i),La(i),no.set(t,{value:to(i),at:Date.now()}))}catch(e){console.warn(`Failed to update shared settings via API:`,e)}finally{n.forEach(e=>e())}},fo=async e=>{if(typeof window>`u`)return;let t=i();if(Q&&Q!==t){$&&=(clearTimeout($),null),so=null,Q=null;let e=co;co=[],e.forEach(e=>e())}let n={...so??{}},r=no.get(t)?.value;for(let[t,i]of Object.entries(e)){let e=r?.[t];Object.is(i,e)||i!==void 0&&e!==void 0&&JSON.stringify(i)===JSON.stringify(e)?delete n[t]:n[t]=i}if(so=n,Q=t,Object.keys(n).length===0&&!$){so=null,Q=null;return}$&&clearTimeout($);let a=new Promise(e=>{co.push(e)});return $=setTimeout(()=>void uo(),lo),a},po=async()=>{if(typeof window>`u`)return;let e=Za();try{let t=await Hi();if(!t)return;let n=()=>Vi(t);if(e?.hasHydrated?.()){n();return}if(n(),e?.onFinishHydration){let t=e.onFinishHydration(()=>{t?.(),n()})}}catch(e){console.warn(`Failed to load appearance preferences:`,e)}};export{fr as $,Dt as $t,pi as A,ve as An,on as At,Lr as B,yt as Bt,Xi as C,$e as Cn,pn as Ct,Ri as D,et as Dn,fn as Dt,Li as E,Qe as En,Rn as Et,wi as F,E as Ft,zr as G,dt as Gt,Jr as H,ht as Ht,K as I,It,W as J,Wt as Jt,Hr as K,T as Kt,_i as L,zt as Lt,Zr as M,an as Mt,Xr as N,j as Nt,ji as O,Je as On,hn as Ot,vi as P,A as Pt,pr as Q,lt as Qt,Ci as R,Yt as Rt,Zi as S,at as Sn,_n as St,Yi as T,tt as Tn,Tn as Tt,Yr as U,_t as Ut,qr as V,Ht as Vt,Ur as W,ut as Wt,kr as X,Tt as Xt,Sr as Y,O as Yt,jr as Z,ct as Zt,Ui as _,Pt as _n,mn as _t,Pa as a,qt as an,Vn as at,Ji as b,ft as bn,bn as bt,Oa as c,Mt as cn,B as ct,Ca as d,Bt as dn,Wn as dt,Ot as en,ur as et,xa as f,Gt as fn,Zn as ft,X as g,vt as gn,zn as gt,ia as h,gt as hn,N as ht,Ma as i,Ut as in,Bn as it,ii as j,nn as jt,Mi as k,Ke as kn,sn as kt,wa as l,mt as ln,qn as lt,na as m,bt as mn,Un as mt,oo as n,Rt as nn,sr as nt,Na as o,At as on,z as ot,aa as p,Kt as pn,Hn as pt,Wr as q,D as qt,fo as r,Jt as rn,or as rt,Da as s,Nt as sn,Gn as st,po as t,Lt as tn,cr as tt,Sa as u,Vt as un,Yn as ut,qi as v,Et as vn,yn as vt,Qi as w,rt as wn,jn as wt,Gi as x,ot as xn,xn as xt,Ki as y,Ft as yn,vn as yt,Fr as z,kt as zt};
|