@cmmd-center/forge 0.13.95 → 0.13.97

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.
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/transport-CgH8pQK3.js","assets/rolldown-runtime-hePW80VL.js","assets/workspaceReadinessAtom-D6bgTvKb.js","assets/atomRegistry-C1yW8tyM.js","assets/Stream-mUTFnSY9.js","assets/angular-html-B8mrqUL5.js","assets/html-XwrE-1r6.js","assets/javascript-obGGvMPs.js","assets/css-CNuuLpMC.js","assets/angular-ts-Bzix210W.js","assets/scss-YesllqfO.js","assets/apl-Dhin1L29.js","assets/xml-BlnrEAEy.js","assets/java-DdHNQ9hk.js","assets/json-DAgxKhMr.js","assets/astro-B-4NNgOP.js","assets/typescript-BydbNFcO.js","assets/postcss-BXeXVLqQ.js","assets/tsx-CUOciP0b.js","assets/blade-Wr94ul2N.js","assets/html-derivative-i4STDFnl.js","assets/sql-ClgswhA6.js","assets/bsl-BkkzgIyY.js","assets/sdbl-bTVj8UrX.js","assets/c-iCihek07.js","assets/cairo-DLTphjLi.js","assets/python-gzcpVVnB.js","assets/cobol-Cw2-KvLW.js","assets/coffee-CiiSLhB6.js","assets/cpp-DjoE5qBx.js","assets/regexp-DR20uMnK.js","assets/glsl-D5MA2a_X.js","assets/crystal-wCJpIkgB.js","assets/shellscript-Da78Ox-3.js","assets/edge-DCY0a-ow.js","assets/elixir-DP304Xio.js","assets/elm-o4NJxfws.js","assets/erb-BcNYoZVd.js","assets/ruby-2bd251b9.js","assets/haml-CwEpbK1d.js","assets/graphql-Ctjuxyvl.js","assets/jsx-gTgmArGx.js","assets/lua-FONpmTUP.js","assets/yaml-Du_6cdrH.js","assets/erlang-Cphh6RMH.js","assets/markdown-BYOwaDjH.js","assets/fortran-fixed-form-DEKoE2YW.js","assets/fortran-free-form-CYNrtFtB.js","assets/fsharp-D13ZGOAj.js","assets/gdresource-C0sCabJj.js","assets/gdshader-CBce3t8t.js","assets/gdscript-Cp2uCuqX.js","assets/git-commit-BSykSTBG.js","assets/diff-woXpYk--.js","assets/git-rebase-BDPpS8w6.js","assets/glimmer-js-BONyzAsu.js","assets/glimmer-ts-f9c0GCOe.js","assets/hack-7ztQ7Up-.js","assets/handlebars-ryMP1rBR.js","assets/http-kmH8AyfE.js","assets/hurl-DCZHXKU4.js","assets/csv-Dx-8-gkx.js","assets/hxml-B0Qn7Nwc.js","assets/haxe-OTjmBuCE.js","assets/jinja-B-tLrNsM.js","assets/jison-CBjhYtSs.js","assets/julia-CjHxn3vf.js","assets/r-D6UWEOL2.js","assets/just-CZ9bduw9.js","assets/perl-BAov3eih.js","assets/latex-D9bvcAJr.js","assets/tex-0w6-Dtgt.js","assets/liquid-G0MH4h_m.js","assets/marko-DV5GrDmo.js","assets/less-DVTAwKKz.js","assets/mdc-cg1lnqpW.js","assets/nextflow-BJtWHP5T.js","assets/nextflow-groovy-DJMQeKeT.js","assets/nginx-BTMw9COX.js","assets/nim-B6yJ_yaC.js","assets/php-Cg76ANFt.js","assets/pug-DkgDHZci.js","assets/qml-_a-QhfPD.js","assets/razor-D3EoCAik.js","assets/csharp-Ct8U2NOr.js","assets/rst-YTmaoyaq.js","assets/cmake-Bj61d0ZC.js","assets/sas-B6p8-ynO.js","assets/shaderlab-TOUzSsQk.js","assets/hlsl-Cvrh5tZx.js","assets/shellsession-CVsQGYfZ.js","assets/soy-DEd-qcad.js","assets/sparql-D_iOobhT.js","assets/turtle-ByJddavk.js","assets/stata-RoaAgbqU.js","assets/surrealql-DIn4NJsS.js","assets/svelte-Bj3Hmc9F.js","assets/templ-TjxbArHn.js","assets/go-rLFTqkRN.js","assets/ts-tags-DFwAVxhO.js","assets/twig-BbcH-NR0.js","assets/vue-BNi0qJZP.js","assets/vue-html-DkKkQnZL.js","assets/vue-vine-DFaKYU4X.js","assets/stylus-B6D30XZt.js","assets/xsl-BOPS8gLt.js"])))=>i.map(i=>d[i]);
2
- import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{$ as r,$t as i,Aa as a,An as o,Ar as s,At as c,B as l,Br as u,Bt as d,Ci as f,Dn as p,Ei as m,En as h,Er as g,Fa as _,Fi as v,Fn as y,Gn as b,Gt as x,Ha as S,Hn as C,Hr as w,Ht as T,Ia as E,It as ee,J as te,Jt as ne,Kt as re,L as ie,La as ae,Ln as oe,Lt as D,M as se,Ma as ce,Mr as le,Ni as ue,Nn as de,Nt as fe,Oa as pe,Pi as me,Pn as he,Pt as ge,Qi as _e,Rn as ve,Rr as ye,Rt as be,Si as xe,Ta as Se,Tn as Ce,Tr as we,Tt as Te,Ua as Ee,Un as De,Ur as Oe,Ut as eee,V as tee,Va as ke,Vn as Ae,Vr as je,Vt as Me,W as nee,Wa as ree,Wn as iee,Wr as aee,Wt as oee,X as see,Yi as Ne,Yt as cee,Z as lee,Zi as uee,_ as dee,_t as fee,an as pee,at as Pe,bn as mee,br as hee,bt as Fe,ca as Ie,ci as Le,ct as gee,dn as _ee,ea as Re,en as ze,et as Be,fi as Ve,gi as vee,gn as He,hn as yee,hr as bee,ht as xee,in as Ue,it as See,ja as Cee,jn as We,jr as wee,jt as Ge,ki as Tee,kr as Eee,kt as Dee,li as Ke,ln as Oee,m as kee,mn as Aee,mr as qe,na as jee,ni as Mee,nt as Je,oa as Nee,or as Ye,pn as Xe,pt as Pee,q as Fee,qt as Iee,r as Lee,rn as Ze,rr as Ree,rt as zee,sn as Bee,un as Vee,ut as Qe,vn as $e,vr as et,wn as Hee,wr as Uee,wt as tt,xi as Wee,xn as nt,y as Gee,yi as Kee,yn as qee,z as Jee,zn as Yee,zt as Xee}from"./Stream-mUTFnSY9.js";import{i as Zee,l as rt,n as it,o as at,s as ot}from"./atomRegistry-C1yW8tyM.js";import{En as Qee,Fn as st,J as ct,On as $ee,Rn as ete,Tn as lt,an as ut,cn as tte,dn as dt,fn as ft,gn as nte,hn as pt,i as rte,ln as ite,on as ate,sn as mt,un as ote}from"./CompositeItem-DNkNENOR.js";import{$n as ht,$t as ste,A as gt,An as cte,At as _t,Bn as lte,Bt as ute,C as dte,Ct as fte,D as vt,Dn as pte,Dt as yt,E as mte,Et as bt,Fn as xt,Gn as hte,Gt as St,H as Ct,Hn as gte,Ht as wt,It as Tt,Jn as _te,Jt as vte,Kt as Et,L as yte,Lt as bte,Mn as xte,Mt as Dt,O as Ot,On as kt,Pn as At,Qt as Ste,Rn as Cte,Rt as wte,St as jt,T as Tte,Tn as Mt,Tt as Nt,U as Ete,Un as Dte,Ut as Pt,V as Ft,Vn as Ote,Vt as kte,W as Ate,Wn as jte,Wt as It,Xt as Lt,Yt as Mte,Z as Nte,Zt as Pte,_n as O,_t as Rt,a as Fte,an as zt,b as Bt,bn as Vt,c as Ite,dt as Ht,en as Lte,et as Rte,fn as Ut,gn as Wt,gt as zte,hn as Gt,ht as Kt,i as Bte,in as Vte,j as qt,jn as Jt,jt as Yt,k as Hte,kt as Xt,l as Zt,lt as Qt,mn as $t,nt as en,on as tn,pt as Ute,q as Wte,qt as nn,rn as Gte,s as k,sn as rn,tn as an,tt as on,ut as sn,v as cn,vn as ln,w as Kte,wn as qte,x as Jte,xn as Yte,yt as Xte,zt as un}from"./src-DFTFXdyK.js";import{$ as Zte,A as dn,B as Qte,C as $te,D as ene,E as tne,F as fn,G as nne,H as rne,I as pn,J as ine,K as ane,L as mn,M as hn,N as gn,O as one,P as _n,Q as sne,R as cne,T as lne,U as une,W as dne,X as fne,Y as pne,Z as mne,_ as hne,a as vn,c as gne,d as _ne,et as vne,it as yn,l as yne,n as bn,nt as bne,q as xne,rt as Sne,s as Cne,tt as wne,u as Tne,w as Ene}from"./cmmdAuthRedirect-DCgS12fq.js";import{t as A}from"./preload-helper-Czpn1I53.js";import{n as j,t as xn}from"./transport-CgH8pQK3.js";import{n as Dne,t as One}from"./workspaceReadinessAtom-D6bgTvKb.js";function kne(e){return e[e.length-1]}function Ane(e,t){return typeof e==`function`?e(t):e}var Sn=Object.prototype.hasOwnProperty,jne=Object.prototype.propertyIsEnumerable;function Mne(e){for(let t in e)if(Sn.call(e,t))return!0;return!1}var Nne=()=>Object.create(null),Pne=(e,t)=>Cn(e,t,Nne);function Cn(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=Dn(e)&&Dn(i);if(!a&&!(Tn(e)&&Tn(i)))return i;let o=a?e:wn(e);if(!o)return i;let s=a?i:wn(i);if(!s)return i;let c=o.length,l=s.length,u=a?Array(l):n(),d=0;for(let t=0;t<l;t++){let o=a?t:s[t],l=e[o],f=i[o];if(l===f){u[o]=l,(a?t<c:Sn.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=Cn(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function wn(e){let t=Object.keys(e);if(t.length!==Object.getOwnPropertyNames(e).length)return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;for(let r of n){if(!jne.call(e,r))return!1;t.push(r)}return t}function Tn(e){if(!En(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!En(n)||!n.hasOwnProperty(`isPrototypeOf`))}function En(e){return Object.prototype.toString.call(e)===`[object Object]`}function Dn(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function On(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!On(e[r],t[r],n))return!1;return!0}if(Tn(e)&&Tn(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!On(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!On(e[o],t[o],n)))return!1;return i===a}return!1}var Fne=/[\x00-\x1f\x7f"<>`{}]/g;function Ine(e){return e.replace(Fne,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function kn(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return Ine(t)}var Lne=[`http:`,`https:`,`mailto:`,`tel:`];function Rne(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function zne(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=kn(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=kn(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function Bne(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function Vne(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function An(){throw Error(`Invariant failed`)}var M=t(ree(),1),jn=M.createContext(null);function Mn(e){return M.useContext(jn)}var Nn=M.createContext(void 0),Hne=M.createContext(void 0),Une=ete();function Wne(e,t){return e===t}function Pn(e,t,n=Wne){let r=(0,M.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,M.useCallback)(()=>e?.get(),[e]);return(0,Une.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var Fn={};function In(e,t){let n=M.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=Cn(n.current,i):i}}function Ln(e){let t=Mn(),n=M.useContext(e.from?Hne:Nn),r=e.from??n,i=t.stores.getMatchStore(r),a=In(e,t),o=Pn(i,e=>e?a(e):Fn);if(o!==Fn)return o;(e.shouldThrow??!0)&&An()}function Gne(e){return Ln({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}var N=Ee(),Rn=typeof window<`u`&&(window.desktopBridge!==void 0||window.nativeApi!==void 0),zn=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Bn=new class extends zn{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Kne={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Vn=new class{#e=Kne;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function qne(e){setTimeout(e,0)}var Jne=typeof window>`u`||`Deno`in globalThis;function Hn(){}function Yne(e,t){return typeof e==`function`?e(t):e}function Un(e){return typeof e==`number`&&e>=0&&e!==1/0}function Wn(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Gn(e,t){return typeof e==`function`?e(t):e}function Kn(e,t){return typeof e==`function`?e(t):e}function Xne(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==qn(o,t.options))return!1}else if(!Yn(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Zne(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Jn(t.options.mutationKey)!==Jn(a))return!1}else if(!Yn(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function qn(e,t){return(t?.queryKeyHashFn||Jn)(e)}function Jn(e){return JSON.stringify(e,(e,t)=>$n(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Yn(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!Yn(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Yn(e[r],t[r]))return!1;return!0}return!1}var Qne=Object.prototype.hasOwnProperty;function Xn(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Qn(e)&&Qn(t);if(!r&&!($n(e)&&$n(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Qne.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Xn(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Zn(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Qn(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function $n(e){if(!er(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!er(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function er(e){return Object.prototype.toString.call(e)===`[object Object]`}function $ne(e){return new Promise(t=>{Vn.setTimeout(t,e)})}function tr(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Xn(e,t)}function ere(e){return e}function tre(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function nre(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var nr=Symbol();function rr(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===nr?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ir(e,t){return typeof e==`function`?e(...t):!!e}function rre(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var ar=(()=>{let e=()=>Jne;return{isServer(){return e()},setIsServer(t){e=t}}})();function or(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var ire=qne;function are(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=ire,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var sr=are(),cr=new class extends zn{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function ore(e){return Math.min(1e3*2**e,3e4)}function lr(e){return(e??`online`)!==`online`||cr.isOnline()}var ur=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function dr(e){let t=!1,n=0,r,i=or(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new ur(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>Bn.isFocused()&&(e.networkMode===`always`||cr.isOnline())&&e.canRun(),u=()=>lr(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(ar.isServer()?0:3),o=e.retryDelay??ore,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),$ne(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var fr=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Un(this.gcTime)&&(this.#e=Vn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ar.isServer()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(Vn.clearTimeout(this.#e),this.#e=void 0)}};function sre(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{rre(e,()=>t.signal,()=>n=!0)},u=rr(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?nre:tre;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?mr:pr,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:pr(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function pr(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function mr(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function cre(e,t){return t?pr(e,t)!=null:!1}function lre(e,t){return!t||!e.getPreviousPageParam?!1:mr(e,t)!=null}var ure=class extends fr{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=_r(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=_r(this.options);e.data!==void 0&&(this.setState(gr(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=tr(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(Hn).catch(Hn):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Kn(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===nr||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Gn(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Wn(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=rr(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?sre(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=dr({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof ur&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof ur){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...hr(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...gr(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),sr.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function hr(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:lr(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function gr(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function _r(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var vr=class extends zn{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=or(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),yr(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return br(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return br(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Kn(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Zn(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&xr(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Kn(this.options.enabled,this.#t)!==Kn(t.enabled,this.#t)||Gn(this.options.staleTime,this.#t)!==Gn(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Kn(this.options.enabled,this.#t)!==Kn(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return fre(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Hn)),t}#g(){this.#b();let e=Gn(this.options.staleTime,this.#t);if(ar.isServer()||this.#r.isStale||!Un(e))return;let t=Wn(this.#r.dataUpdatedAt,e)+1;this.#d=Vn.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(ar.isServer()||Kn(this.options.enabled,this.#t)===!1||!Un(this.#p)||this.#p===0)&&(this.#f=Vn.setInterval(()=>{(this.options.refetchIntervalInBackground||Bn.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(Vn.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(Vn.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&yr(e,t),o=i&&xr(e,n,t,r);(a||o)&&(l={...l,...hr(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=tr(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=tr(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Sr(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Kn(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{let e=this.#o=x.promise=or();i(e)},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a()}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Zn(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){sr.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function dre(e,t){return Kn(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||Kn(t.retryOnMount,e)!==!1)}function yr(e,t){return dre(e,t)||e.state.data!==void 0&&br(e,t,t.refetchOnMount)}function br(e,t,n){if(Kn(t.enabled,e)!==!1&&Gn(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Sr(e,t)}return!1}function xr(e,t,n,r){return(e!==t||Kn(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Sr(e,n)}function Sr(e,t){return Kn(t.enabled,e)!==!1&&e.isStaleByTime(Gn(t.staleTime,e))}function fre(e,t){return!Zn(e.getCurrentResult(),t)}var Cr=M.createContext(void 0),wr=e=>{let t=M.useContext(Cr);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},pre=({client:e,children:t})=>(M.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,N.jsx)(Cr.Provider,{value:e,children:t})),Tr=M.createContext(!1),Er=()=>M.useContext(Tr);Tr.Provider;function mre(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var hre=M.createContext(mre()),Dr=()=>M.useContext(hre),Or=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?ir(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},kr=e=>{M.useEffect(()=>{e.clearReset()},[e])},Ar=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||ir(n,[e.error,r])),jr=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},gre=(e,t)=>e.isLoading&&e.isFetching&&!t,Mr=(e,t)=>e?.suspense&&t.isPending,Nr=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Pr(e,t,n){let r=Er(),i=Dr(),a=wr(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,jr(o),Or(o,i,s),kr(i);let l=!a.getQueryCache().get(o.queryHash),[u]=M.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(M.useSyncExternalStore(M.useCallback(e=>{let t=f?u.subscribe(sr.batchCalls(e)):Hn;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),M.useEffect(()=>{u.setOptions(o)},[o,u]),Mr(o,d))throw Nr(o,u,i);if(Ar({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!ar.isServer()&&gre(d,r)&&(l?Nr(o,u,i):s?.promise)?.catch(Hn).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function Fr(e,t){return Pr(e,vr,t)}function _re(e){return e}var vre=g,Ir=globalThis.Number,yre=e=>{if(e===`NaN`)return v(NaN);if(e===`Infinity`)return v(1/0);if(e===`-Infinity`)return v(-1/0);if(e.trim()===``)return me();let t=Ir(e);return Ir.isNaN(t)?me():v(t)},bre=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`]],Lr=`~effect/http/HttpClientRequest`,xre={[Lr]:Lr,..._e,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Nee(this.headers),body:this.body.toJSON()}},pipe(){return ke(this,arguments)}};function Rr(e,t,n,r,i,a){let o=Object.create(xre);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var Sre=Rr(`GET`,``,Pte,me(),kte,Mte),zr=e=>(t,n)=>wre(Sre,{method:e,url:t,...n??void 0}),Cre=zr(`POST`),wre=_(2,(e,t)=>{let n=e;return t.method&&(n=Tre(n,t.method)),t.url&&(n=Ore(n,t.url)),t.headers&&(n=Br(n,t.headers)),t.urlParams&&(n=kre(n,t.urlParams)),t.hash&&(n=Are(n,t.hash)),t.body&&(n=Hr(n,t.body)),t.accept&&(n=Vr(n,t.accept)),t.acceptJson&&(n=Dre(n)),n}),Tre=_(2,(e,t)=>Rr(t,e.url,e.urlParams,e.hash,e.headers,e.body)),Ere=_(3,(e,t,n)=>Rr(e.method,e.url,e.urlParams,e.hash,nn(e.headers,t,n),e.body)),Br=_(2,(e,t)=>Rr(e.method,e.url,e.urlParams,e.hash,vte(e.headers,t),e.body)),Vr=_(2,(e,t)=>Ere(e,`Accept`,t)),Dre=Vr(`application/json`),Ore=_(2,(e,t)=>{if(typeof t==`string`)return Rr(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Ste(n.searchParams),i=Wee(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,Rr(e.method,n.toString(),r,i,e.headers,e.body)}),kre=_(2,(e,t)=>Rr(e.method,e.url,Lte(e.urlParams,t),e.hash,e.headers,e.body)),Are=_(2,(e,t)=>Rr(e.method,e.url,e.urlParams,v(t),e.headers,e.body)),Hr=_(2,(e,t)=>{let n=e.headers;return t._tag===`Empty`||t._tag===`FormData`?n=Et(Et(n,`Content-Type`),`Content-length`):(t.contentType&&(n=nn(n,`content-type`,t.contentType)),t.contentLength!==void 0&&(n=nn(n,`content-length`,t.contentLength.toString()))),Rr(e.method,e.url,e.urlParams,e.hash,n,t)}),jre=e=>Pt({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${ue(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),Ur=`~effect/http/HttpClient`,Wr=Ke(`effect/HttpClient`),Gr=_(2,(e,t)=>Kr(n=>t(e.postprocess(n)),e.preprocess)),Mre=Gr(Je(bte)),Kr=(e,t)=>{let n=Object.create(Nre);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},Nre={[Ur]:Ur,pipe(){return ke(this,arguments)},..._e,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(bre.map(([e,t])=>[t,function(t,n){return this.execute(zr(e)(t,n))}]))},Pre=e=>Kr(t=>Je(t,t=>$e(n=>{let i=Rre.get(t),a=i??new AbortController,o=ste(t.url,t.urlParams,m(t.hash));if(Mee(o))return r(new an({reason:new Gte({request:t,cause:o.failure})}));let s=o.success;if(n.getRef(Eee)||n.getRef(qr)(t)){let r=e(t,s,a.signal,n);return i?r:Xe(e=>Te(e(r),{onSuccess(e){return Yr.register(e,a),ze(new Xr(e,a))},onFailure(e){return qe(e)&&a.abort(),Be(e)}}))}return yee(n.getRef(Ire)(t),{kind:`client`},r=>{r.attribute(`http.request.method`,t.method),r.attribute(`server.address`,s.origin),s.port!==``&&r.attribute(`server.port`,+s.port),r.attribute(`url.full`,s.toString()),r.attribute(`url.path`,s.pathname),r.attribute(`url.scheme`,s.protocol.slice(0,-1));let o=s.search.slice(1);o!==``&&r.attribute(`url.query`,o);let c=n.getRef(ute),l=St(t.headers,c);for(let e in l)r.attribute(`http.request.header.${e}`,String(l[e]));return t=n.getRef(Jr)?Br(t,jre(r)):t,Xe(o=>o(e(t,s,a.signal,n)).pipe(qee(r,{captureStackTrace:!1}),Te({onSuccess:e=>{r.attribute(`http.response.status_code`,e.status);let t=St(e.headers,c);for(let e in t)r.attribute(`http.response.header.${e}`,String(t[e]));return i?ze(e):(Yr.register(e,a),ze(new Xr(e,a)))},onFailure(e){return!i&&qe(e)&&a.abort(),Be(e)}})))})})),ze),Fre=_(2,(e,t)=>{let n=Ce(t),r=n?`errors-and-responses`:t.retryOn??`errors-and-responses`,i=n?t:t.schedule,o=i&&h(i),s=n?void 0:t.times;return Gr(e,E(r===`errors-only`?ae:ee({schedule:o,times:s,while:Qr}),r===`response-only`?ae:D({while:n||t.while===void 0?Zr:a(Zr,t.while),schedule:i,times:s})))}),qr=Le(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>Cee}),Jr=Le(`effect/HttpClient/TracerPropagationEnabled`,{defaultValue:ce}),Ire=Le(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),Lre=e=>We(Wr)(te(t=>Fe(e,e=>Gr(e,Aee(e=>vee(t,e)))))),Yr=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),Rre=new WeakMap,Xr=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[Tt]=Tt;[un]=un;applyInterrupt(e){return Ze(()=>(Yr.unregister(this.original),Dee(e,()=>Ue(()=>{this.controller.abort()}))))}get request(){return this.original.request}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return dee(()=>(Yr.unregister(this.original),Lee(this.original.stream,Ue(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Re](){return this.original[Re]()}pipe(){return ke(this,arguments)}},Zr=e=>hee(e)||zre(e),zre=e=>zt(e)&&(e.reason._tag===`TransportError`||e.reason._tag===`StatusCodeError`&&Qr(e.reason.response)),Qr=e=>e.status===408||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504;function $r(e){return{id:e.id??`ws:${e.label}`,label:e.label,source:e.source??`manual`,target:e.target}}function Bre(e){return e?.target.wsBaseUrl??null}function Vre(e){return e?.target.httpBaseUrl??null}function Hre(e,t){return{...e,environmentId:t.environmentId,label:t.label}}function Ure(e){return e.cloudMode?`cmmd-cloud-runtime`:`local-web`}function Wre(e){let t=Ure(e);return{topology:t,controlPlane:t!==`cmmd-cloud-runtime`,executionPlane:!0,workspaceProxy:!1}}function Gre(e){let t=e.topology===`cmmd-cloud-runtime`;return{cmmd:!0,ownerBootstrapPromotion:e.topology!==`cloud-shell`&&!t,bearerBootstrap:!0,desktopBootstrap:e.topology===`desktop-local`,providerCredentialBroker:e.topology===`cmmd-control-plane`}}function Kre(e){let t=e.executionPlane;return{agents:t,browser:t,github:t,terminal:t,providerEgress:e.topology===`cmmd-control-plane`}}function qre(e,t){return{localProjects:t.executionPlane,cloudProjects:e.cloudMode}}function ei(e){let t=e.capabilities,n=t.runtime??Wre(t);return{repositoryIdentity:t.repositoryIdentity,pullRequests:t.pullRequests??!1,cloudMode:t.cloudMode,posthogPublicKey:t.posthogPublicKey,posthogHost:t.posthogHost,runtime:n,auth:t.auth??Gre(n),tools:t.tools??Kre(n),projects:t.projects??qre(t,n)}}function Jre(e){return e?ei(e).projects.cloudProjects:!1}function Yre(e){return e?ei(e).runtime.workspaceProxy??!1:!1}function ti(e,t){return{environmentId:e,projectId:t}}function ni(e,t){return{environmentId:e,threadId:t}}var ri=`scoped:v1:`;function ii(e){let t=`projectId`in e?e.projectId:e.threadId;return t.includes(`:`)||e.environmentId.startsWith(ri)?`${ri}${encodeURIComponent(e.environmentId)}:${encodeURIComponent(t)}`:`${e.environmentId}:${t}`}function ai(e){return ii(e)}function oi(e){return ii(e)}function Xre(e){let t=e.slice(10),n=t.indexOf(`:`);if(n<=0||n>=t.length-1||t.indexOf(`:`,n+1)!==-1)return null;try{let e=decodeURIComponent(t.slice(0,n)),r=decodeURIComponent(t.slice(n+1));return e.length>0&&r.length>0?{environmentId:e,localId:r}:null}catch{return null}}function si(e){if(e.startsWith(ri))return Xre(e);let t=e.lastIndexOf(`:`);return t<=0||t>=e.length-1?null:{environmentId:e.slice(0,t),localId:e.slice(t+1)}}function ci(e){let t=si(e);return t?{environmentId:t.environmentId,projectId:t.localId}:null}function li(e){let t=si(e);return t?{environmentId:t.environmentId,threadId:t.localId}:null}var ui=`~effect/ManagedRuntime`,di=(e,t)=>{let n=t?.memoMap??de(),r=iee(`parallel`),i=C(r,`sequential`),a={onFiberStart:ie(r)},s=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,c,l=$e(t=>(c||=d(pee(o(e,n,i),e=>Ue(()=>{u.cachedContext=e})),{...a,scheduler:t.currentScheduler}),See(se(c)))),u={[ui]:ui,memoMap:n,scope:r,contextEffect:l,cachedContext:void 0,context(){return u.cachedContext===void 0?T(u.contextEffect):Promise.resolve(u.cachedContext)},dispose(){return T(u.disposeEffect)},disposeEffect:Ze(()=>(u.contextEffect=see(`ManagedRuntime disposed`),u.cachedContext=void 0,Ae(u.scope,Ye))),runFork(e,t){return u.cachedContext===void 0?d(fi(u,e),s(t)):Me(u.cachedContext)(e,s(t))},runCallback(e,t){return u.cachedContext===void 0?be(fi(u,e),s(t)):Xee(u.cachedContext)(e,s(t))},runSyncExit(e){return u.cachedContext===void 0?Iee(fi(u,e)):ne(u.cachedContext)(e)},runSync(e){return u.cachedContext===void 0?re(fi(u,e)):cee(u.cachedContext)(e)},runPromiseExit(e,t){return u.cachedContext===void 0?eee(fi(u,e),s(t)):oee(u.cachedContext)(e,s(t))},runPromise(e,t){return u.cachedContext===void 0?T(fi(u,e),s(t)):x(u.cachedContext)(e,s(t))}};return u};function fi(e,t){return Je(e.contextEffect,e=>fe(t,e))}var pi={accept:!1,observe:!1,missingFrameCount:0,startsNewStream:!1};function mi(e){let t=e===!0;return{accept:t,observe:t,missingFrameCount:0,startsNewStream:t}}function Zre(e,t){let n=e.streamGeneration===void 0&&e.streamId===void 0,r=t.streamGeneration!==void 0||t.streamId!==void 0;return n&&r?mi(t.keyframe):null}function Qre(e,t){return e.streamGeneration===void 0||t.streamGeneration===void 0?null:t.streamGeneration<e.streamGeneration?pi:t.streamGeneration>e.streamGeneration?mi(t.keyframe):null}function $re(e,t){if(!e.streamId||!t.streamId)return null;if(e.streamId!==t.streamId)return mi(t.keyframe);if(t.sequence<=e.observedSequence)return pi;let n=Math.max(0,t.sequence-e.observedSequence-1);return{accept:n===0||t.keyframe===!0,observe:!0,missingFrameCount:n,startsNewStream:!1}}function eie(e,t){if(t.sequence>e.acceptedSequence)return{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1};if(!e.acceptedCapturedAt)return pi;let n=Date.parse(e.acceptedCapturedAt),r=Date.parse(t.capturedAt);return Number.isNaN(n)||Number.isNaN(r)||r<=n?pi:{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1}}function tie(e,t){return Zre(e,t)??Qre(e,t)??$re(e,t)??eie(e,t)}function nie(e,t){let n=tie(e,t);if(!n.observe)return{accept:n.accept,observe:n.observe,missingFrameCount:n.missingFrameCount,state:e};let r=n.startsNewStream?t.sequence:Math.max(e.observedSequence,t.sequence),i={...e,observedSequence:r,gapCount:e.gapCount+n.missingFrameCount},a=n.accept?{...i,acceptedSequence:t.sequence,acceptedCapturedAt:t.capturedAt,...t.streamId?{streamId:t.streamId}:{},...t.streamGeneration===void 0?{}:{streamGeneration:t.streamGeneration}}:i;return{accept:n.accept,observe:n.observe,missingFrameCount:n.missingFrameCount,state:a}}var hi=S();function rie(e){return e.stageLabel.trim().toLowerCase()===`latest`?e.baseName:`${e.baseName} (${e.stageLabel})`}var gi=`Forge`,_i=``,vi=_i===`latest`||_i===`nightly`?_i:null,yi=vi===`nightly`?`Nightly`:vi===`latest`?`Latest`:null,bi=yi??`Alpha`,xi=yi?rie({baseName:gi,stageLabel:bi}):gi,Si=`0.13.4`,Ci=pt(`forge-app-top-bar drag-region @container/header-actions relative z-20 w-full min-w-0 shrink-0 bg-background`,`grid grid-cols-[minmax(0,1fr)_minmax(0,auto)] items-center`),wi=`flex h-full min-w-0 items-center gap-1 md:gap-1.5`,Ti=`flex h-touch min-w-0 max-w-full touch-manipulation items-center justify-center rounded-lg px-3 text-foreground transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring md:h-7 md:px-2`,iie={width:`calc(100% - var(--forge-right-panel-reserved-width, 0px))`},aie=`forge-app-shell flex w-full min-w-0 flex-row`,Ei=`forge-app-shell flex w-full min-w-0 flex-col`,oie=`flex min-h-0 min-w-0 flex-1 flex-col`,sie=`relative flex h-[var(--forge-content-height)] min-h-0 min-w-0 flex-1 overflow-hidden`;function Di(e){let t=(0,hi.c)(19),{showStageBadge:n,tone:r,variant:i}=e,a=n!==void 0&&n,o=r===void 0?`default`:r,s=(i===void 0?`default`:i)===`auth`,c=s?20:16,l=s?`h-5 w-5 shrink-0`:`h-4 w-4 shrink-0`,u;t[0]!==c||t[1]!==l?(u=(0,N.jsx)(`img`,{className:l,src:`/forge-mark.svg`,width:c,height:c,alt:``,"aria-hidden":`true`}),t[0]=c,t[1]=l,t[2]=u):u=t[2];let d=u,f=s?`text-[15px] sm:text-base`:`text-sm`,p=o===`on-dark`?`text-primary-foreground`:`text-foreground`,m;t[3]!==f||t[4]!==p?(m=pt(`truncate font-semibold tracking-tight`,f,p),t[3]=f,t[4]=p,t[5]=m):m=t[5];let h;t[6]===m?h=t[7]:(h=(0,N.jsx)(`span`,{className:m,children:gi}),t[6]=m,t[7]=h);let g=h,_=s?`rounded-full bg-muted/50 px-2 py-0.5 text-[9px] leading-none font-medium tracking-[0.14em] text-muted-foreground/70 uppercase [text-indent:0.14em]`:`rounded-full bg-muted/50 px-1.5 py-0.5 text-[8px] leading-none font-medium tracking-[0.18em] text-muted-foreground/60 uppercase [text-indent:0.18em]`,v;t[8]===_?v=t[9]:(v=(0,N.jsx)(`span`,{className:_,children:bi}),t[8]=_,t[9]=v);let y=v;if(a){let e;t[10]!==d||t[11]!==g?(e=(0,N.jsxs)(`span`,{className:`flex items-center gap-2`,children:[d,g]}),t[10]=d,t[11]=g,t[12]=e):e=t[12];let n;return t[13]!==y||t[14]!==e?(n=(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md`,"aria-label":xi,children:[e,y]}),t[13]=y,t[14]=e,t[15]=n):n=t[15],n}let b;return t[16]!==d||t[17]!==g?(b=(0,N.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,"aria-label":xi,children:[d,g]}),t[16]=d,t[17]=g,t[18]=b):b=t[18],b}function Oi(e){let t=(0,hi.c)(5),{className:n}=e,r;t[0]===n?r=t[1]:(r=pt(`pointer-events-none flex select-none items-center`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,N.jsx)(Di,{}),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,N.jsx)(`div`,{className:r,children:i}),t[3]=r,t[4]=a),a}function cie(){let e=new Map;return{clear:()=>e.clear(),getItem:t=>e.get(t)??null,key:t=>Array.from(e.keys()).at(t)??null,get length(){return e.size},removeItem:t=>e.delete(t),setItem:(t,n)=>e.set(t,n)}}var ki=typeof window<`u`?window.localStorage:cie(),lie=(e,t)=>qte(Jt(e))(t),uie=(e,t)=>cte(Jt(e))(t),Ai=(e,t)=>{let n=ki.getItem(e);return n?lie(t,n):null},ji=(e,t,n)=>{let r=uie(n,t);ki.setItem(e,r)},Mi=e=>{ki.removeItem(e)},Ni=`forge:local_storage_change`;function die(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(Ni,{detail:{key:e}}))}function Pi(e,t,n){let[r,i]=(0,M.useState)(()=>{try{return Ai(e,n)??t}catch(e){return console.error(`[LOCALSTORAGE] Error:`,e),t}}),a=(0,M.useCallback)(t=>{i(r=>{try{let i=typeof t==`function`?t(r):t;return i===null?Mi(e):ji(e,i,n),queueMicrotask(()=>die(e)),i}catch(e){return console.error(`[LOCALSTORAGE] Error:`,e),r}})},[e,n]),o=(0,M.useRef)(e);return(0,M.useEffect)(()=>{if(o.current!==e){o.current=e;try{let r=Ai(e,n);i(r??t)}catch(e){console.error(`[LOCALSTORAGE] Error:`,e)}}},[e,t,n]),(0,M.useEffect)(()=>{let r=()=>{try{let r=Ai(e,n);i(r??t)}catch(e){console.error(`[LOCALSTORAGE] Error:`,e)}},a=t=>{t.key===e&&r()},o=t=>{t.detail.key===e&&r()};return window.addEventListener(`storage`,a),window.addEventListener(Ni,o),()=>{window.removeEventListener(`storage`,a),window.removeEventListener(Ni,o)}},[e,t,n]),[r,a]}var Fi=`cmmd-runtime:`;function Ii(e){return`${Fi}${e}`}var fie=/^env_[0-9a-f]{32}$/,pie=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,Li={shape:`local`,isCloud:!1,legacyRuntimeId:null},mie={shape:`cloud-project-placeholder`,isCloud:!0,legacyRuntimeId:null},hie={shape:`durable-environment`,isCloud:!0,legacyRuntimeId:null};function Ri(e){if(typeof e!=`string`)return Li;if(e.startsWith(`cmmd-runtime:`)){let t=e.slice(Fi.length);return pie.test(t)?{shape:`legacy-runtime`,isCloud:!0,legacyRuntimeId:t}:Li}return e.startsWith(`cmmd-cloud-project:`)?mie:fie.test(e)?hie:Li}var zi=`forge:client-settings:v1`,gie=`forge:saved-environment-registry:v1`,_ie=ln({environmentId:yt,label:O,httpBaseUrl:O,wsBaseUrl:O,createdAt:O,lastConnectedAt:$t(O),cmmdOrganizationId:xt(O),cmmdProjectId:xt(O),runtimeId:xt(O),runtimeTicketExpiresAt:xt(O),lastAuthenticatedPullRequestCapability:xt(rn),bearerToken:xt(O)}),Bi=ln({version:xt(Gt),records:xt(tn(_ie))});function Vi(){return typeof window<`u`}var vie={uiFontSize:14,codeFontSize:15},yie=[[`uiFontSize`,11,20],[`codeFontSize`,11,20]];function bie(e){return e.defaultThreadRuntime===`desktop-cloud-bridge`?{...e,defaultThreadRuntime:`cloud`}:null}function xie(e){if(typeof e.fontDefaultsVersion==`number`)return null;let t=Object.entries(vie).filter(([t,n])=>e[t]===n);if(t.length===0)return null;let n={...e};for(let[e]of t)delete n[e];return n}function Sie(e){let t=yie.flatMap(([t,n,r])=>{let i=e[t];if(typeof i!=`number`||!Number.isFinite(i))return[];let a=Math.min(r,Math.max(n,Math.round(i)));return a===i?[]:[[t,a]]});if(t.length===0)return null;let n={...e};for(let[e,r]of t)n[e]=r;return n}function Hi(e){if(!e||typeof e!=`object`)return e;let t=e,n=!1;for(let e of[bie,xie,Sie]){let r=e(t);r!==null&&(t=r,n=!0)}return n?t:e}function Cie(){if(!Vi())return null;try{let e=window.localStorage.getItem(zi);return e?kt(cn)(Hi(JSON.parse(e))):null}catch{return null}}function wie(e){Vi()&&ji(zi,e,cn)}function Ui(){if(!Vi())return{};try{return Ai(`forge:saved-environment-registry:v1`,Bi)??{}}catch{return{}}}function Wi(e){Vi()&&ji(gie,e,Bi)}function Gi(){return Ui().records??[]}function Tie(e){Wi({version:1,records:e})}function Eie(){return Gi().map(e=>Ft(e))}function Die(e){let t=new Map(Gi().map(e=>[e.environmentId,e]));Tie(e.map(e=>{let n=Ri(e.environmentId).legacyRuntimeId===null?t.get(e.environmentId)?.bearerToken:void 0;return n?{...Ft(e),bearerToken:n}:Ft(e)}))}function Oie(e){return Gi().find(t=>t.environmentId===e)?.bearerToken??null}function kie(e,t){let n=Ui(),r=n.records??[],i=!1;return Wi({version:n.version??1,records:r.map(n=>n.environmentId===e?(i=!0,Object.assign(Ft(n),{bearerToken:t})):n)}),i}function Aie(e){let t=Ui();Wi({version:t.version??1,records:(t.records??[]).map(t=>t.environmentId===e?Ft(t):t)})}var jie=kt(cn);function Mie(){return typeof window>`u`?void 0:window.desktopBridge}function Ki(e){let t=Mie(),n=t?.[e];return typeof n==`function`?n.bind(t):null}async function qi(){let e=Ki(`getClientSettings`);if(e){let t=await e();return t?jie(t):null}return Cie()}async function Ji(e){let t=Ki(`setClientSettings`);if(t)return t(e);wie(e)}async function Yi(){let e=Ki(`getSavedEnvironmentRegistry`);return e?e():Eie()}async function Xi(e){let t=Ki(`setSavedEnvironmentRegistry`);if(t)return t(e);Die(e)}async function Zi(e){let t=Ki(`getSavedEnvironmentSecret`);return t?t(e):Oie(e)}async function Qi(e,t){let n=Ki(`setSavedEnvironmentSecret`);return n?n(e,t):kie(e,t)}async function $i(e){let t=Ki(`removeSavedEnvironmentSecret`);if(t)return t(e);Aie(e)}var ea=`token`;function ta(e){return new URLSearchParams(e.hash.startsWith(`#`)?e.hash.slice(1):e.hash)}function na(e){let t=ta(e).get(ea)?.trim()??``;if(t.length>0)return t;let n=e.searchParams.get(ea)?.trim()??``;return n.length>0?n:null}function Nie(e){let t=new URL(e.toString()),n=ta(t);return n.has(ea)&&(n.delete(ea),t.hash=n.toString()),t.searchParams.delete(ea),t}function ra(e,t){let n=new URL(e.toString());return n.searchParams.delete(ea),n.hash=new URLSearchParams([[ea,t]]).toString(),n}function Pie(e,t){let n=new URL(e);return n.pathname=`/login`,ra(n,t).toString()}function Fie(e){return ra(new URL(`/login`,window.location.href),e).toString()}var Iie=`host`;function Lie(e){let t=new URL(e),n=na(t),r=new URL(`forge:///pair`);return r.searchParams.set(Iie,t.origin),n&&r.searchParams.set(ea,n),r.toString()}function Rie(e){return{_tag:`Value`,value:e}}function zie(e,t){return{_tag:`Record`,keys:e,value:t}}function Bie(e,t){return{_tag:`Array`,length:e,value:t}}ht(`SourceError`);var Vie=Le(`effect/ConfigProvider`,{defaultValue:()=>Wie()}),Hie={...Ne,toJSON(){return{_id:`ConfigProvider`}}};function Uie(e,t,n){let r=Object.create(Hie);return r.get=e,r.mapInput=t,r.prefix=n,r.load=r=>(t&&(r=t(r)),n&&(r=[...n,...r]),e(r)),r}function Wie(e){let t=e?.env??{APP_VERSION:`0.13.4`,BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`,VITE_COMMIT_SHA:``,VITE_HOSTED_APP_CHANNEL:``,VITE_HTTP_URL:``,VITE_SENTRY_COMMIT_SHA:`88bc45ce168df8c9acf36ad6734d8a66bcb353ec`,VITE_SENTRY_DEBUG:``,VITE_SENTRY_DSN:``,VITE_SENTRY_ENABLED:``,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_PROFILES_SAMPLE_RATE:``,VITE_SENTRY_RELEASE:`forge-web@0.13.4+88bc45ce168df8c9acf36ad6734d8a66bcb353ec`,VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE:``,VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE:``,VITE_SENTRY_TRACES_SAMPLE_RATE:``,VITE_WS_URL:``},n=Gie(t);return Uie(e=>ze(qie(n,t,e)))}function Gie(e){let t={};for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let e=n.split(`_`),i=t;for(let t of e)i.children??={},i=i.children[t]??={};i.value=r}return t}var Kie=/^(0|[1-9][0-9]*)$/;function qie(e,t,n){let r=t[n.map(String).join(`_`)],i=Jie(e,n),a=i?.children?Object.keys(i.children):[];return a.length===0?r===void 0?void 0:Rie(r):a.every(e=>Kie.test(e))?Bie(Math.max(...a.map(e=>parseInt(e,10)))+1,r):zie(new Set(a),r)}function Jie(e,t){if(t.length===0)return e;let n=e;for(let e of t)if(n=n?.children?.[String(e)],!n)return;return n}var ia=`~effect/Config`,Yie=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},Xie={...Ne,...uee,[ia]:ia,asEffect(){return Je(Vie.asEffect(),e=>this.parse(e))},toJSON(){return{_id:`Config`}}};function Zie(e){let t=Object.create(Xie);return t.parse=e,t}var aa=Pe(function*(e,t){let n=yield*e.load(t);if(n!==void 0)switch(n._tag){case`Value`:return n.value;case`Record`:{if(n.value!==void 0)return n.value;let r={};for(let i of n.keys){let n=yield*aa(e,[...t,i]);n!==void 0&&(r[i]=n)}return r}case`Array`:{if(n.value!==void 0)return n.value;let r=[];for(let i=0;i<n.length;i++)r.push(yield*aa(e,[...t,i]));return r}}}),oa=Pe(function*(e,t,n){switch(e._tag){case`Objects`:{let r={};for(let i of e.propertySignatures){let e=i.name;if(typeof e==`string`){let a=yield*oa(i.type,t,[...n,e]);a!==void 0&&(r[e]=a)}}if(e.indexSignatures.length>0){let i=yield*t.load(n);if(i&&i._tag===`Record`)for(let a of e.indexSignatures){let e=Ote(a.parameter);for(let o of i.keys)if(!Object.hasOwn(r,o)&&e(o)){let e=yield*oa(a.type,t,[...n,o]);e!==void 0&&(r[o]=e)}}}return r}case`Arrays`:{let r=yield*t.load(n);if(r&&r._tag===`Value`)return r.value;let i=[];for(let r=0;r<e.elements.length;r++)i.push(yield*oa(e.elements[r],t,[...n,r]));return i}case`Union`:return yield*aa(t,n);case`Suspend`:return yield*oa(e.thunk(),t,n);default:{let e=yield*t.load(n);return e===void 0?void 0:e._tag===`Value`||e._tag===`Record`&&e.value!==void 0||e._tag===`Array`&&e.value!==void 0?e.value:void 0}}});function sa(e,t){let n=Cte(e),r=gte(n),i=jte(n.ast),a=typeof t==`string`?[t]:t??[];return Zie(e=>{let t=e.prefix?[...e.prefix,...a]:a;return oa(i,e,a).pipe(zee(e=>r(e).pipe(tt(e=>new lte(t.length>0?new _te(t,e):e)))),tt(e=>new Yie(e)))})}var Qie=(e,t,n)=>{let r=Wt(e,t),i=O.pipe(Mt(Wt(O,O),hte(n)),Mt(r));return Yte([r,i])},P=typeof __SENTRY_DEBUG__>`u`||__SENTRY_DEBUG__,F=globalThis,ca=`10.74.0`;function la(){return ua(F),F}function ua(e){let t=e.__SENTRY__=e.__SENTRY__||{};return t.version=t.version||`10.74.0`,t[ca]=t[`10.74.0`]||{}}function da(e,t,n=F){let r=n.__SENTRY__=n.__SENTRY__||{},i=r[ca]=r[`10.74.0`]||{};return i[e]||(i[e]=t())}var fa=[`debug`,`info`,`warn`,`error`,`log`,`assert`,`trace`],pa=`Sentry Logger `,ma={};function ha(e){if(!(`console`in F))return e();let t=F.console,n={},r=Object.keys(ma);r.forEach(e=>{let r=ma[e];n[e]=t[e],t[e]=r});try{return e()}finally{r.forEach(e=>{t[e]=n[e]})}}function $ie(){va().enabled=!0}function eae(){va().enabled=!1}function ga(){return va().enabled}function tae(...e){_a(`log`,...e)}function nae(...e){_a(`warn`,...e)}function rae(...e){_a(`error`,...e)}function _a(e,...t){P&&ga()&&ha(()=>{F.console[e](`${pa}[${e}]:`,...t)})}function va(){return P?da(`loggerSettings`,()=>({enabled:!1})):{enabled:!1}}var I={enable:$ie,disable:eae,isEnabled:ga,log:tae,warn:nae,error:rae},ya=50,ba=/\(error: (.*)\)/,xa=/captureMessage|captureException/;function Sa(...e){let t=e.sort((e,t)=>e[0]-t[0]).map(e=>e[1]);return(e,n=0,r=0)=>{let i=[],a=e.split(`
2
+ import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{$ as r,$t as i,Aa as a,An as o,Ar as s,At as c,B as l,Br as u,Bt as d,Ci as f,Dn as p,Ei as m,En as h,Er as g,Fa as _,Fi as v,Fn as y,Gn as b,Gt as x,Ha as S,Hn as C,Hr as w,Ht as T,Ia as E,It as ee,J as te,Jt as ne,Kt as re,L as ie,La as ae,Ln as oe,Lt as D,M as se,Ma as ce,Mr as le,Ni as ue,Nn as de,Nt as fe,Oa as pe,Pi as me,Pn as he,Pt as ge,Qi as _e,Rn as ve,Rr as ye,Rt as be,Si as xe,Ta as Se,Tn as Ce,Tr as we,Tt as Te,Ua as Ee,Un as De,Ur as Oe,Ut as eee,V as tee,Va as ke,Vn as Ae,Vr as je,Vt as Me,W as nee,Wa as ree,Wn as iee,Wr as aee,Wt as oee,X as see,Yi as Ne,Yt as cee,Z as lee,Zi as uee,_ as dee,_t as fee,an as pee,at as Pe,bn as mee,br as hee,bt as Fe,ca as Ie,ci as Le,ct as gee,dn as _ee,ea as Re,en as ze,et as Be,fi as Ve,gi as vee,gn as He,hn as yee,hr as bee,ht as xee,in as Ue,it as See,ja as Cee,jn as We,jr as wee,jt as Ge,ki as Tee,kr as Eee,kt as Dee,li as Ke,ln as Oee,m as kee,mn as Aee,mr as qe,na as jee,ni as Mee,nt as Je,oa as Nee,or as Ye,pn as Xe,pt as Pee,q as Fee,qt as Iee,r as Lee,rn as Ze,rr as Ree,rt as zee,sn as Bee,un as Vee,ut as Qe,vn as $e,vr as et,wn as Hee,wr as Uee,wt as tt,xi as Wee,xn as nt,y as Gee,yi as Kee,yn as qee,z as Jee,zn as Yee,zt as Xee}from"./Stream-mUTFnSY9.js";import{i as Zee,l as rt,n as it,o as at,s as ot}from"./atomRegistry-C1yW8tyM.js";import{En as Qee,Fn as st,J as ct,On as $ee,Rn as ete,Tn as lt,an as ut,cn as tte,dn as dt,fn as ft,gn as nte,hn as pt,i as rte,ln as ite,on as ate,sn as mt,un as ote}from"./CompositeItem-DNkNENOR.js";import{$n as ht,$t as ste,A as gt,An as cte,At as _t,Bn as lte,Bt as ute,C as dte,Ct as fte,D as vt,Dn as pte,Dt as yt,E as mte,Et as bt,Fn as xt,Gn as hte,Gt as St,H as Ct,Hn as gte,Ht as wt,It as Tt,Jn as _te,Jt as vte,Kt as Et,L as yte,Lt as bte,Mn as xte,Mt as Dt,O as Ot,On as kt,Pn as At,Qt as Ste,Rn as Cte,Rt as wte,St as jt,T as Tte,Tn as Mt,Tt as Nt,U as Ete,Un as Dte,Ut as Pt,V as Ft,Vn as Ote,Vt as kte,W as Ate,Wn as jte,Wt as It,Xt as Lt,Yt as Mte,Z as Nte,Zt as Pte,_n as O,_t as Rt,a as Fte,an as zt,b as Bt,bn as Vt,c as Ite,dt as Ht,en as Lte,et as Rte,fn as Ut,gn as Wt,gt as zte,hn as Gt,ht as Kt,i as Bte,in as Vte,j as qt,jn as Jt,jt as Yt,k as Hte,kt as Xt,l as Zt,lt as Qt,mn as $t,nt as en,on as tn,pt as Ute,q as Wte,qt as nn,rn as Gte,s as k,sn as rn,tn as an,tt as on,ut as sn,v as cn,vn as ln,w as Kte,wn as qte,x as Jte,xn as Yte,yt as Xte,zt as un}from"./src-DFTFXdyK.js";import{$ as Zte,A as dn,B as Qte,C as $te,D as ene,E as tne,F as fn,G as nne,H as rne,I as pn,J as ine,K as ane,L as mn,M as hn,N as gn,O as one,P as _n,Q as sne,R as cne,T as lne,U as une,W as dne,X as fne,Y as pne,Z as mne,_ as hne,a as vn,c as gne,d as _ne,et as vne,it as yn,l as yne,n as bn,nt as bne,q as xne,rt as Sne,s as Cne,tt as wne,u as Tne,w as Ene}from"./cmmdAuthRedirect-DCgS12fq.js";import{t as A}from"./preload-helper-Czpn1I53.js";import{n as j,t as xn}from"./transport-CgH8pQK3.js";import{n as Dne,t as One}from"./workspaceReadinessAtom-D6bgTvKb.js";function kne(e){return e[e.length-1]}function Ane(e,t){return typeof e==`function`?e(t):e}var Sn=Object.prototype.hasOwnProperty,jne=Object.prototype.propertyIsEnumerable;function Mne(e){for(let t in e)if(Sn.call(e,t))return!0;return!1}var Nne=()=>Object.create(null),Pne=(e,t)=>Cn(e,t,Nne);function Cn(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=Dn(e)&&Dn(i);if(!a&&!(Tn(e)&&Tn(i)))return i;let o=a?e:wn(e);if(!o)return i;let s=a?i:wn(i);if(!s)return i;let c=o.length,l=s.length,u=a?Array(l):n(),d=0;for(let t=0;t<l;t++){let o=a?t:s[t],l=e[o],f=i[o];if(l===f){u[o]=l,(a?t<c:Sn.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=Cn(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function wn(e){let t=Object.keys(e);if(t.length!==Object.getOwnPropertyNames(e).length)return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;for(let r of n){if(!jne.call(e,r))return!1;t.push(r)}return t}function Tn(e){if(!En(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!En(n)||!n.hasOwnProperty(`isPrototypeOf`))}function En(e){return Object.prototype.toString.call(e)===`[object Object]`}function Dn(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function On(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!On(e[r],t[r],n))return!1;return!0}if(Tn(e)&&Tn(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!On(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!On(e[o],t[o],n)))return!1;return i===a}return!1}var Fne=/[\x00-\x1f\x7f"<>`{}]/g;function Ine(e){return e.replace(Fne,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function kn(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return Ine(t)}var Lne=[`http:`,`https:`,`mailto:`,`tel:`];function Rne(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function zne(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=kn(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=kn(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function Bne(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function Vne(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function An(){throw Error(`Invariant failed`)}var M=t(ree(),1),jn=M.createContext(null);function Mn(e){return M.useContext(jn)}var Nn=M.createContext(void 0),Hne=M.createContext(void 0),Une=ete();function Wne(e,t){return e===t}function Pn(e,t,n=Wne){let r=(0,M.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,M.useCallback)(()=>e?.get(),[e]);return(0,Une.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var Fn={};function In(e,t){let n=M.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=Cn(n.current,i):i}}function Ln(e){let t=Mn(),n=M.useContext(e.from?Hne:Nn),r=e.from??n,i=t.stores.getMatchStore(r),a=In(e,t),o=Pn(i,e=>e?a(e):Fn);if(o!==Fn)return o;(e.shouldThrow??!0)&&An()}function Gne(e){return Ln({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}var N=Ee(),Rn=typeof window<`u`&&(window.desktopBridge!==void 0||window.nativeApi!==void 0),zn=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Bn=new class extends zn{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Kne={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Vn=new class{#e=Kne;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function qne(e){setTimeout(e,0)}var Jne=typeof window>`u`||`Deno`in globalThis;function Hn(){}function Yne(e,t){return typeof e==`function`?e(t):e}function Un(e){return typeof e==`number`&&e>=0&&e!==1/0}function Wn(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Gn(e,t){return typeof e==`function`?e(t):e}function Kn(e,t){return typeof e==`function`?e(t):e}function Xne(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==qn(o,t.options))return!1}else if(!Yn(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Zne(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Jn(t.options.mutationKey)!==Jn(a))return!1}else if(!Yn(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function qn(e,t){return(t?.queryKeyHashFn||Jn)(e)}function Jn(e){return JSON.stringify(e,(e,t)=>$n(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Yn(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!Yn(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Yn(e[r],t[r]))return!1;return!0}return!1}var Qne=Object.prototype.hasOwnProperty;function Xn(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Qn(e)&&Qn(t);if(!r&&!($n(e)&&$n(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Qne.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Xn(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Zn(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Qn(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function $n(e){if(!er(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!er(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function er(e){return Object.prototype.toString.call(e)===`[object Object]`}function $ne(e){return new Promise(t=>{Vn.setTimeout(t,e)})}function tr(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Xn(e,t)}function ere(e){return e}function tre(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function nre(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var nr=Symbol();function rr(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===nr?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ir(e,t){return typeof e==`function`?e(...t):!!e}function rre(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var ar=(()=>{let e=()=>Jne;return{isServer(){return e()},setIsServer(t){e=t}}})();function or(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var ire=qne;function are(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=ire,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var sr=are(),cr=new class extends zn{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function ore(e){return Math.min(1e3*2**e,3e4)}function lr(e){return(e??`online`)!==`online`||cr.isOnline()}var ur=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function dr(e){let t=!1,n=0,r,i=or(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new ur(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>Bn.isFocused()&&(e.networkMode===`always`||cr.isOnline())&&e.canRun(),u=()=>lr(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(ar.isServer()?0:3),o=e.retryDelay??ore,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),$ne(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var fr=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Un(this.gcTime)&&(this.#e=Vn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ar.isServer()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(Vn.clearTimeout(this.#e),this.#e=void 0)}};function sre(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{rre(e,()=>t.signal,()=>n=!0)},u=rr(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?nre:tre;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?mr:pr,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:pr(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function pr(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function mr(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function cre(e,t){return t?pr(e,t)!=null:!1}function lre(e,t){return!t||!e.getPreviousPageParam?!1:mr(e,t)!=null}var ure=class extends fr{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=_r(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=_r(this.options);e.data!==void 0&&(this.setState(gr(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=tr(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(Hn).catch(Hn):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Kn(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===nr||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Gn(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Wn(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=rr(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?sre(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=dr({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof ur&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof ur){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...hr(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...gr(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),sr.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function hr(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:lr(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function gr(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function _r(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var vr=class extends zn{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=or(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),yr(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return br(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return br(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Kn(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Zn(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&xr(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Kn(this.options.enabled,this.#t)!==Kn(t.enabled,this.#t)||Gn(this.options.staleTime,this.#t)!==Gn(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Kn(this.options.enabled,this.#t)!==Kn(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return fre(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Hn)),t}#g(){this.#b();let e=Gn(this.options.staleTime,this.#t);if(ar.isServer()||this.#r.isStale||!Un(e))return;let t=Wn(this.#r.dataUpdatedAt,e)+1;this.#d=Vn.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(ar.isServer()||Kn(this.options.enabled,this.#t)===!1||!Un(this.#p)||this.#p===0)&&(this.#f=Vn.setInterval(()=>{(this.options.refetchIntervalInBackground||Bn.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(Vn.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(Vn.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&yr(e,t),o=i&&xr(e,n,t,r);(a||o)&&(l={...l,...hr(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=tr(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=tr(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Sr(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Kn(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{let e=this.#o=x.promise=or();i(e)},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a()}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Zn(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){sr.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function dre(e,t){return Kn(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||Kn(t.retryOnMount,e)!==!1)}function yr(e,t){return dre(e,t)||e.state.data!==void 0&&br(e,t,t.refetchOnMount)}function br(e,t,n){if(Kn(t.enabled,e)!==!1&&Gn(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Sr(e,t)}return!1}function xr(e,t,n,r){return(e!==t||Kn(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Sr(e,n)}function Sr(e,t){return Kn(t.enabled,e)!==!1&&e.isStaleByTime(Gn(t.staleTime,e))}function fre(e,t){return!Zn(e.getCurrentResult(),t)}var Cr=M.createContext(void 0),wr=e=>{let t=M.useContext(Cr);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},pre=({client:e,children:t})=>(M.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,N.jsx)(Cr.Provider,{value:e,children:t})),Tr=M.createContext(!1),Er=()=>M.useContext(Tr);Tr.Provider;function mre(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var hre=M.createContext(mre()),Dr=()=>M.useContext(hre),Or=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?ir(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},kr=e=>{M.useEffect(()=>{e.clearReset()},[e])},Ar=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||ir(n,[e.error,r])),jr=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},gre=(e,t)=>e.isLoading&&e.isFetching&&!t,Mr=(e,t)=>e?.suspense&&t.isPending,Nr=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Pr(e,t,n){let r=Er(),i=Dr(),a=wr(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,jr(o),Or(o,i,s),kr(i);let l=!a.getQueryCache().get(o.queryHash),[u]=M.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(M.useSyncExternalStore(M.useCallback(e=>{let t=f?u.subscribe(sr.batchCalls(e)):Hn;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),M.useEffect(()=>{u.setOptions(o)},[o,u]),Mr(o,d))throw Nr(o,u,i);if(Ar({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!ar.isServer()&&gre(d,r)&&(l?Nr(o,u,i):s?.promise)?.catch(Hn).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function Fr(e,t){return Pr(e,vr,t)}function _re(e){return e}var vre=g,Ir=globalThis.Number,yre=e=>{if(e===`NaN`)return v(NaN);if(e===`Infinity`)return v(1/0);if(e===`-Infinity`)return v(-1/0);if(e.trim()===``)return me();let t=Ir(e);return Ir.isNaN(t)?me():v(t)},bre=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`]],Lr=`~effect/http/HttpClientRequest`,xre={[Lr]:Lr,..._e,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Nee(this.headers),body:this.body.toJSON()}},pipe(){return ke(this,arguments)}};function Rr(e,t,n,r,i,a){let o=Object.create(xre);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var Sre=Rr(`GET`,``,Pte,me(),kte,Mte),zr=e=>(t,n)=>wre(Sre,{method:e,url:t,...n??void 0}),Cre=zr(`POST`),wre=_(2,(e,t)=>{let n=e;return t.method&&(n=Tre(n,t.method)),t.url&&(n=Ore(n,t.url)),t.headers&&(n=Br(n,t.headers)),t.urlParams&&(n=kre(n,t.urlParams)),t.hash&&(n=Are(n,t.hash)),t.body&&(n=Hr(n,t.body)),t.accept&&(n=Vr(n,t.accept)),t.acceptJson&&(n=Dre(n)),n}),Tre=_(2,(e,t)=>Rr(t,e.url,e.urlParams,e.hash,e.headers,e.body)),Ere=_(3,(e,t,n)=>Rr(e.method,e.url,e.urlParams,e.hash,nn(e.headers,t,n),e.body)),Br=_(2,(e,t)=>Rr(e.method,e.url,e.urlParams,e.hash,vte(e.headers,t),e.body)),Vr=_(2,(e,t)=>Ere(e,`Accept`,t)),Dre=Vr(`application/json`),Ore=_(2,(e,t)=>{if(typeof t==`string`)return Rr(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Ste(n.searchParams),i=Wee(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,Rr(e.method,n.toString(),r,i,e.headers,e.body)}),kre=_(2,(e,t)=>Rr(e.method,e.url,Lte(e.urlParams,t),e.hash,e.headers,e.body)),Are=_(2,(e,t)=>Rr(e.method,e.url,e.urlParams,v(t),e.headers,e.body)),Hr=_(2,(e,t)=>{let n=e.headers;return t._tag===`Empty`||t._tag===`FormData`?n=Et(Et(n,`Content-Type`),`Content-length`):(t.contentType&&(n=nn(n,`content-type`,t.contentType)),t.contentLength!==void 0&&(n=nn(n,`content-length`,t.contentLength.toString()))),Rr(e.method,e.url,e.urlParams,e.hash,n,t)}),jre=e=>Pt({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${ue(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),Ur=`~effect/http/HttpClient`,Wr=Ke(`effect/HttpClient`),Gr=_(2,(e,t)=>Kr(n=>t(e.postprocess(n)),e.preprocess)),Mre=Gr(Je(bte)),Kr=(e,t)=>{let n=Object.create(Nre);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},Nre={[Ur]:Ur,pipe(){return ke(this,arguments)},..._e,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(bre.map(([e,t])=>[t,function(t,n){return this.execute(zr(e)(t,n))}]))},Pre=e=>Kr(t=>Je(t,t=>$e(n=>{let i=Rre.get(t),a=i??new AbortController,o=ste(t.url,t.urlParams,m(t.hash));if(Mee(o))return r(new an({reason:new Gte({request:t,cause:o.failure})}));let s=o.success;if(n.getRef(Eee)||n.getRef(qr)(t)){let r=e(t,s,a.signal,n);return i?r:Xe(e=>Te(e(r),{onSuccess(e){return Yr.register(e,a),ze(new Xr(e,a))},onFailure(e){return qe(e)&&a.abort(),Be(e)}}))}return yee(n.getRef(Ire)(t),{kind:`client`},r=>{r.attribute(`http.request.method`,t.method),r.attribute(`server.address`,s.origin),s.port!==``&&r.attribute(`server.port`,+s.port),r.attribute(`url.full`,s.toString()),r.attribute(`url.path`,s.pathname),r.attribute(`url.scheme`,s.protocol.slice(0,-1));let o=s.search.slice(1);o!==``&&r.attribute(`url.query`,o);let c=n.getRef(ute),l=St(t.headers,c);for(let e in l)r.attribute(`http.request.header.${e}`,String(l[e]));return t=n.getRef(Jr)?Br(t,jre(r)):t,Xe(o=>o(e(t,s,a.signal,n)).pipe(qee(r,{captureStackTrace:!1}),Te({onSuccess:e=>{r.attribute(`http.response.status_code`,e.status);let t=St(e.headers,c);for(let e in t)r.attribute(`http.response.header.${e}`,String(t[e]));return i?ze(e):(Yr.register(e,a),ze(new Xr(e,a)))},onFailure(e){return!i&&qe(e)&&a.abort(),Be(e)}})))})})),ze),Fre=_(2,(e,t)=>{let n=Ce(t),r=n?`errors-and-responses`:t.retryOn??`errors-and-responses`,i=n?t:t.schedule,o=i&&h(i),s=n?void 0:t.times;return Gr(e,E(r===`errors-only`?ae:ee({schedule:o,times:s,while:Qr}),r===`response-only`?ae:D({while:n||t.while===void 0?Zr:a(Zr,t.while),schedule:i,times:s})))}),qr=Le(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>Cee}),Jr=Le(`effect/HttpClient/TracerPropagationEnabled`,{defaultValue:ce}),Ire=Le(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),Lre=e=>We(Wr)(te(t=>Fe(e,e=>Gr(e,Aee(e=>vee(t,e)))))),Yr=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),Rre=new WeakMap,Xr=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[Tt]=Tt;[un]=un;applyInterrupt(e){return Ze(()=>(Yr.unregister(this.original),Dee(e,()=>Ue(()=>{this.controller.abort()}))))}get request(){return this.original.request}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return dee(()=>(Yr.unregister(this.original),Lee(this.original.stream,Ue(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Re](){return this.original[Re]()}pipe(){return ke(this,arguments)}},Zr=e=>hee(e)||zre(e),zre=e=>zt(e)&&(e.reason._tag===`TransportError`||e.reason._tag===`StatusCodeError`&&Qr(e.reason.response)),Qr=e=>e.status===408||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504;function $r(e){return{id:e.id??`ws:${e.label}`,label:e.label,source:e.source??`manual`,target:e.target}}function Bre(e){return e?.target.wsBaseUrl??null}function Vre(e){return e?.target.httpBaseUrl??null}function Hre(e,t){return{...e,environmentId:t.environmentId,label:t.label}}function Ure(e){return e.cloudMode?`cmmd-cloud-runtime`:`local-web`}function Wre(e){let t=Ure(e);return{topology:t,controlPlane:t!==`cmmd-cloud-runtime`,executionPlane:!0,workspaceProxy:!1}}function Gre(e){let t=e.topology===`cmmd-cloud-runtime`;return{cmmd:!0,ownerBootstrapPromotion:e.topology!==`cloud-shell`&&!t,bearerBootstrap:!0,desktopBootstrap:e.topology===`desktop-local`,providerCredentialBroker:e.topology===`cmmd-control-plane`}}function Kre(e){let t=e.executionPlane;return{agents:t,browser:t,github:t,terminal:t,providerEgress:e.topology===`cmmd-control-plane`}}function qre(e,t){return{localProjects:t.executionPlane,cloudProjects:e.cloudMode}}function ei(e){let t=e.capabilities,n=t.runtime??Wre(t);return{repositoryIdentity:t.repositoryIdentity,pullRequests:t.pullRequests??!1,cloudMode:t.cloudMode,posthogPublicKey:t.posthogPublicKey,posthogHost:t.posthogHost,runtime:n,auth:t.auth??Gre(n),tools:t.tools??Kre(n),projects:t.projects??qre(t,n)}}function Jre(e){return e?ei(e).projects.cloudProjects:!1}function Yre(e){return e?ei(e).runtime.workspaceProxy??!1:!1}function ti(e,t){return{environmentId:e,projectId:t}}function ni(e,t){return{environmentId:e,threadId:t}}var ri=`scoped:v1:`;function ii(e){let t=`projectId`in e?e.projectId:e.threadId;return t.includes(`:`)||e.environmentId.startsWith(ri)?`${ri}${encodeURIComponent(e.environmentId)}:${encodeURIComponent(t)}`:`${e.environmentId}:${t}`}function ai(e){return ii(e)}function oi(e){return ii(e)}function Xre(e){let t=e.slice(10),n=t.indexOf(`:`);if(n<=0||n>=t.length-1||t.indexOf(`:`,n+1)!==-1)return null;try{let e=decodeURIComponent(t.slice(0,n)),r=decodeURIComponent(t.slice(n+1));return e.length>0&&r.length>0?{environmentId:e,localId:r}:null}catch{return null}}function si(e){if(e.startsWith(ri))return Xre(e);let t=e.lastIndexOf(`:`);return t<=0||t>=e.length-1?null:{environmentId:e.slice(0,t),localId:e.slice(t+1)}}function ci(e){let t=si(e);return t?{environmentId:t.environmentId,projectId:t.localId}:null}function li(e){let t=si(e);return t?{environmentId:t.environmentId,threadId:t.localId}:null}var ui=`~effect/ManagedRuntime`,di=(e,t)=>{let n=t?.memoMap??de(),r=iee(`parallel`),i=C(r,`sequential`),a={onFiberStart:ie(r)},s=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,c,l=$e(t=>(c||=d(pee(o(e,n,i),e=>Ue(()=>{u.cachedContext=e})),{...a,scheduler:t.currentScheduler}),See(se(c)))),u={[ui]:ui,memoMap:n,scope:r,contextEffect:l,cachedContext:void 0,context(){return u.cachedContext===void 0?T(u.contextEffect):Promise.resolve(u.cachedContext)},dispose(){return T(u.disposeEffect)},disposeEffect:Ze(()=>(u.contextEffect=see(`ManagedRuntime disposed`),u.cachedContext=void 0,Ae(u.scope,Ye))),runFork(e,t){return u.cachedContext===void 0?d(fi(u,e),s(t)):Me(u.cachedContext)(e,s(t))},runCallback(e,t){return u.cachedContext===void 0?be(fi(u,e),s(t)):Xee(u.cachedContext)(e,s(t))},runSyncExit(e){return u.cachedContext===void 0?Iee(fi(u,e)):ne(u.cachedContext)(e)},runSync(e){return u.cachedContext===void 0?re(fi(u,e)):cee(u.cachedContext)(e)},runPromiseExit(e,t){return u.cachedContext===void 0?eee(fi(u,e),s(t)):oee(u.cachedContext)(e,s(t))},runPromise(e,t){return u.cachedContext===void 0?T(fi(u,e),s(t)):x(u.cachedContext)(e,s(t))}};return u};function fi(e,t){return Je(e.contextEffect,e=>fe(t,e))}var pi={accept:!1,observe:!1,missingFrameCount:0,startsNewStream:!1};function mi(e){let t=e===!0;return{accept:t,observe:t,missingFrameCount:0,startsNewStream:t}}function Zre(e,t){let n=e.streamGeneration===void 0&&e.streamId===void 0,r=t.streamGeneration!==void 0||t.streamId!==void 0;return n&&r?mi(t.keyframe):null}function Qre(e,t){return e.streamGeneration===void 0||t.streamGeneration===void 0?null:t.streamGeneration<e.streamGeneration?pi:t.streamGeneration>e.streamGeneration?mi(t.keyframe):null}function $re(e,t){if(!e.streamId||!t.streamId)return null;if(e.streamId!==t.streamId)return mi(t.keyframe);if(t.sequence<=e.observedSequence)return pi;let n=Math.max(0,t.sequence-e.observedSequence-1);return{accept:n===0||t.keyframe===!0,observe:!0,missingFrameCount:n,startsNewStream:!1}}function eie(e,t){if(t.sequence>e.acceptedSequence)return{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1};if(!e.acceptedCapturedAt)return pi;let n=Date.parse(e.acceptedCapturedAt),r=Date.parse(t.capturedAt);return Number.isNaN(n)||Number.isNaN(r)||r<=n?pi:{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1}}function tie(e,t){return Zre(e,t)??Qre(e,t)??$re(e,t)??eie(e,t)}function nie(e,t){let n=tie(e,t);if(!n.observe)return{accept:n.accept,observe:n.observe,missingFrameCount:n.missingFrameCount,state:e};let r=n.startsNewStream?t.sequence:Math.max(e.observedSequence,t.sequence),i={...e,observedSequence:r,gapCount:e.gapCount+n.missingFrameCount},a=n.accept?{...i,acceptedSequence:t.sequence,acceptedCapturedAt:t.capturedAt,...t.streamId?{streamId:t.streamId}:{},...t.streamGeneration===void 0?{}:{streamGeneration:t.streamGeneration}}:i;return{accept:n.accept,observe:n.observe,missingFrameCount:n.missingFrameCount,state:a}}var hi=S();function rie(e){return e.stageLabel.trim().toLowerCase()===`latest`?e.baseName:`${e.baseName} (${e.stageLabel})`}var gi=`Forge`,_i=``,vi=_i===`latest`||_i===`nightly`?_i:null,yi=vi===`nightly`?`Nightly`:vi===`latest`?`Latest`:null,bi=yi??`Alpha`,xi=yi?rie({baseName:gi,stageLabel:bi}):gi,Si=`0.13.4`,Ci=pt(`forge-app-top-bar drag-region @container/header-actions relative z-20 w-full min-w-0 shrink-0 bg-background`,`grid grid-cols-[minmax(0,1fr)_minmax(0,auto)] items-center`),wi=`flex h-full min-w-0 items-center gap-1 md:gap-1.5`,Ti=`flex h-touch min-w-0 max-w-full touch-manipulation items-center justify-center rounded-lg px-3 text-foreground transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring md:h-7 md:px-2`,iie={width:`calc(100% - var(--forge-right-panel-reserved-width, 0px))`},aie=`forge-app-shell flex w-full min-w-0 flex-row`,Ei=`forge-app-shell flex w-full min-w-0 flex-col`,oie=`flex min-h-0 min-w-0 flex-1 flex-col`,sie=`relative flex h-[var(--forge-content-height)] min-h-0 min-w-0 flex-1 overflow-hidden`;function Di(e){let t=(0,hi.c)(19),{showStageBadge:n,tone:r,variant:i}=e,a=n!==void 0&&n,o=r===void 0?`default`:r,s=(i===void 0?`default`:i)===`auth`,c=s?20:16,l=s?`h-5 w-5 shrink-0`:`h-4 w-4 shrink-0`,u;t[0]!==c||t[1]!==l?(u=(0,N.jsx)(`img`,{className:l,src:`/forge-mark.svg`,width:c,height:c,alt:``,"aria-hidden":`true`}),t[0]=c,t[1]=l,t[2]=u):u=t[2];let d=u,f=s?`text-[15px] sm:text-base`:`text-sm`,p=o===`on-dark`?`text-primary-foreground`:`text-foreground`,m;t[3]!==f||t[4]!==p?(m=pt(`truncate font-semibold tracking-tight`,f,p),t[3]=f,t[4]=p,t[5]=m):m=t[5];let h;t[6]===m?h=t[7]:(h=(0,N.jsx)(`span`,{className:m,children:gi}),t[6]=m,t[7]=h);let g=h,_=s?`rounded-full bg-muted/50 px-2 py-0.5 text-[9px] leading-none font-medium tracking-[0.14em] text-muted-foreground/70 uppercase [text-indent:0.14em]`:`rounded-full bg-muted/50 px-1.5 py-0.5 text-[8px] leading-none font-medium tracking-[0.18em] text-muted-foreground/60 uppercase [text-indent:0.18em]`,v;t[8]===_?v=t[9]:(v=(0,N.jsx)(`span`,{className:_,children:bi}),t[8]=_,t[9]=v);let y=v;if(a){let e;t[10]!==d||t[11]!==g?(e=(0,N.jsxs)(`span`,{className:`flex items-center gap-2`,children:[d,g]}),t[10]=d,t[11]=g,t[12]=e):e=t[12];let n;return t[13]!==y||t[14]!==e?(n=(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md`,"aria-label":xi,children:[e,y]}),t[13]=y,t[14]=e,t[15]=n):n=t[15],n}let b;return t[16]!==d||t[17]!==g?(b=(0,N.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,"aria-label":xi,children:[d,g]}),t[16]=d,t[17]=g,t[18]=b):b=t[18],b}function Oi(e){let t=(0,hi.c)(5),{className:n}=e,r;t[0]===n?r=t[1]:(r=pt(`pointer-events-none flex select-none items-center`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,N.jsx)(Di,{}),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,N.jsx)(`div`,{className:r,children:i}),t[3]=r,t[4]=a),a}function cie(){let e=new Map;return{clear:()=>e.clear(),getItem:t=>e.get(t)??null,key:t=>Array.from(e.keys()).at(t)??null,get length(){return e.size},removeItem:t=>e.delete(t),setItem:(t,n)=>e.set(t,n)}}var ki=typeof window<`u`?window.localStorage:cie(),lie=(e,t)=>qte(Jt(e))(t),uie=(e,t)=>cte(Jt(e))(t),Ai=(e,t)=>{let n=ki.getItem(e);return n?lie(t,n):null},ji=(e,t,n)=>{let r=uie(n,t);ki.setItem(e,r)},Mi=e=>{ki.removeItem(e)},Ni=`forge:local_storage_change`;function die(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(Ni,{detail:{key:e}}))}function Pi(e,t,n){let[r,i]=(0,M.useState)(()=>{try{return Ai(e,n)??t}catch(e){return console.error(`[LOCALSTORAGE] Error:`,e),t}}),a=(0,M.useCallback)(t=>{i(r=>{try{let i=typeof t==`function`?t(r):t;return i===null?Mi(e):ji(e,i,n),queueMicrotask(()=>die(e)),i}catch(e){return console.error(`[LOCALSTORAGE] Error:`,e),r}})},[e,n]),o=(0,M.useRef)(e);return(0,M.useEffect)(()=>{if(o.current!==e){o.current=e;try{let r=Ai(e,n);i(r??t)}catch(e){console.error(`[LOCALSTORAGE] Error:`,e)}}},[e,t,n]),(0,M.useEffect)(()=>{let r=()=>{try{let r=Ai(e,n);i(r??t)}catch(e){console.error(`[LOCALSTORAGE] Error:`,e)}},a=t=>{t.key===e&&r()},o=t=>{t.detail.key===e&&r()};return window.addEventListener(`storage`,a),window.addEventListener(Ni,o),()=>{window.removeEventListener(`storage`,a),window.removeEventListener(Ni,o)}},[e,t,n]),[r,a]}var Fi=`cmmd-runtime:`;function Ii(e){return`${Fi}${e}`}var fie=/^env_[0-9a-f]{32}$/,pie=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,Li={shape:`local`,isCloud:!1,legacyRuntimeId:null},mie={shape:`cloud-project-placeholder`,isCloud:!0,legacyRuntimeId:null},hie={shape:`durable-environment`,isCloud:!0,legacyRuntimeId:null};function Ri(e){if(typeof e!=`string`)return Li;if(e.startsWith(`cmmd-runtime:`)){let t=e.slice(Fi.length);return pie.test(t)?{shape:`legacy-runtime`,isCloud:!0,legacyRuntimeId:t}:Li}return e.startsWith(`cmmd-cloud-project:`)?mie:fie.test(e)?hie:Li}var zi=`forge:client-settings:v1`,gie=`forge:saved-environment-registry:v1`,_ie=ln({environmentId:yt,label:O,httpBaseUrl:O,wsBaseUrl:O,createdAt:O,lastConnectedAt:$t(O),cmmdOrganizationId:xt(O),cmmdProjectId:xt(O),runtimeId:xt(O),runtimeTicketExpiresAt:xt(O),lastAuthenticatedPullRequestCapability:xt(rn),bearerToken:xt(O)}),Bi=ln({version:xt(Gt),records:xt(tn(_ie))});function Vi(){return typeof window<`u`}var vie={uiFontSize:14,codeFontSize:15},yie=[[`uiFontSize`,11,20],[`codeFontSize`,11,20]];function bie(e){return e.defaultThreadRuntime===`desktop-cloud-bridge`?{...e,defaultThreadRuntime:`cloud`}:null}function xie(e){if(typeof e.fontDefaultsVersion==`number`)return null;let t=Object.entries(vie).filter(([t,n])=>e[t]===n);if(t.length===0)return null;let n={...e};for(let[e]of t)delete n[e];return n}function Sie(e){let t=yie.flatMap(([t,n,r])=>{let i=e[t];if(typeof i!=`number`||!Number.isFinite(i))return[];let a=Math.min(r,Math.max(n,Math.round(i)));return a===i?[]:[[t,a]]});if(t.length===0)return null;let n={...e};for(let[e,r]of t)n[e]=r;return n}function Hi(e){if(!e||typeof e!=`object`)return e;let t=e,n=!1;for(let e of[bie,xie,Sie]){let r=e(t);r!==null&&(t=r,n=!0)}return n?t:e}function Cie(){if(!Vi())return null;try{let e=window.localStorage.getItem(zi);return e?kt(cn)(Hi(JSON.parse(e))):null}catch{return null}}function wie(e){Vi()&&ji(zi,e,cn)}function Ui(){if(!Vi())return{};try{return Ai(`forge:saved-environment-registry:v1`,Bi)??{}}catch{return{}}}function Wi(e){Vi()&&ji(gie,e,Bi)}function Gi(){return Ui().records??[]}function Tie(e){Wi({version:1,records:e})}function Eie(){return Gi().map(e=>Ft(e))}function Die(e){let t=new Map(Gi().map(e=>[e.environmentId,e]));Tie(e.map(e=>{let n=Ri(e.environmentId).legacyRuntimeId===null?t.get(e.environmentId)?.bearerToken:void 0;return n?{...Ft(e),bearerToken:n}:Ft(e)}))}function Oie(e){return Gi().find(t=>t.environmentId===e)?.bearerToken??null}function kie(e,t){let n=Ui(),r=n.records??[],i=!1;return Wi({version:n.version??1,records:r.map(n=>n.environmentId===e?(i=!0,Object.assign(Ft(n),{bearerToken:t})):n)}),i}function Aie(e){let t=Ui();Wi({version:t.version??1,records:(t.records??[]).map(t=>t.environmentId===e?Ft(t):t)})}var jie=kt(cn);function Mie(){return typeof window>`u`?void 0:window.desktopBridge}function Ki(e){let t=Mie(),n=t?.[e];return typeof n==`function`?n.bind(t):null}async function qi(){let e=Ki(`getClientSettings`);if(e){let t=await e();return t?jie(t):null}return Cie()}async function Ji(e){let t=Ki(`setClientSettings`);if(t)return t(e);wie(e)}async function Yi(){let e=Ki(`getSavedEnvironmentRegistry`);return e?e():Eie()}async function Xi(e){let t=Ki(`setSavedEnvironmentRegistry`);if(t)return t(e);Die(e)}async function Zi(e){let t=Ki(`getSavedEnvironmentSecret`);return t?t(e):Oie(e)}async function Qi(e,t){let n=Ki(`setSavedEnvironmentSecret`);return n?n(e,t):kie(e,t)}async function $i(e){let t=Ki(`removeSavedEnvironmentSecret`);if(t)return t(e);Aie(e)}var ea=`token`;function ta(e){return new URLSearchParams(e.hash.startsWith(`#`)?e.hash.slice(1):e.hash)}function na(e){let t=ta(e).get(ea)?.trim()??``;if(t.length>0)return t;let n=e.searchParams.get(ea)?.trim()??``;return n.length>0?n:null}function Nie(e){let t=new URL(e.toString()),n=ta(t);return n.has(ea)&&(n.delete(ea),t.hash=n.toString()),t.searchParams.delete(ea),t}function ra(e,t){let n=new URL(e.toString());return n.searchParams.delete(ea),n.hash=new URLSearchParams([[ea,t]]).toString(),n}function Pie(e,t){let n=new URL(e);return n.pathname=`/login`,ra(n,t).toString()}function Fie(e){return ra(new URL(`/login`,window.location.href),e).toString()}var Iie=`host`;function Lie(e){let t=new URL(e),n=na(t),r=new URL(`forge:///pair`);return r.searchParams.set(Iie,t.origin),n&&r.searchParams.set(ea,n),r.toString()}function Rie(e){return{_tag:`Value`,value:e}}function zie(e,t){return{_tag:`Record`,keys:e,value:t}}function Bie(e,t){return{_tag:`Array`,length:e,value:t}}ht(`SourceError`);var Vie=Le(`effect/ConfigProvider`,{defaultValue:()=>Wie()}),Hie={...Ne,toJSON(){return{_id:`ConfigProvider`}}};function Uie(e,t,n){let r=Object.create(Hie);return r.get=e,r.mapInput=t,r.prefix=n,r.load=r=>(t&&(r=t(r)),n&&(r=[...n,...r]),e(r)),r}function Wie(e){let t=e?.env??{APP_VERSION:`0.13.4`,BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`,VITE_COMMIT_SHA:``,VITE_HOSTED_APP_CHANNEL:``,VITE_HTTP_URL:``,VITE_SENTRY_COMMIT_SHA:`c825d8a74e28836b97016dbd8c2abc730841a622`,VITE_SENTRY_DEBUG:``,VITE_SENTRY_DSN:``,VITE_SENTRY_ENABLED:``,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_PROFILES_SAMPLE_RATE:``,VITE_SENTRY_RELEASE:`forge-web@0.13.4+c825d8a74e28836b97016dbd8c2abc730841a622`,VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE:``,VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE:``,VITE_SENTRY_TRACES_SAMPLE_RATE:``,VITE_WS_URL:``},n=Gie(t);return Uie(e=>ze(qie(n,t,e)))}function Gie(e){let t={};for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let e=n.split(`_`),i=t;for(let t of e)i.children??={},i=i.children[t]??={};i.value=r}return t}var Kie=/^(0|[1-9][0-9]*)$/;function qie(e,t,n){let r=t[n.map(String).join(`_`)],i=Jie(e,n),a=i?.children?Object.keys(i.children):[];return a.length===0?r===void 0?void 0:Rie(r):a.every(e=>Kie.test(e))?Bie(Math.max(...a.map(e=>parseInt(e,10)))+1,r):zie(new Set(a),r)}function Jie(e,t){if(t.length===0)return e;let n=e;for(let e of t)if(n=n?.children?.[String(e)],!n)return;return n}var ia=`~effect/Config`,Yie=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},Xie={...Ne,...uee,[ia]:ia,asEffect(){return Je(Vie.asEffect(),e=>this.parse(e))},toJSON(){return{_id:`Config`}}};function Zie(e){let t=Object.create(Xie);return t.parse=e,t}var aa=Pe(function*(e,t){let n=yield*e.load(t);if(n!==void 0)switch(n._tag){case`Value`:return n.value;case`Record`:{if(n.value!==void 0)return n.value;let r={};for(let i of n.keys){let n=yield*aa(e,[...t,i]);n!==void 0&&(r[i]=n)}return r}case`Array`:{if(n.value!==void 0)return n.value;let r=[];for(let i=0;i<n.length;i++)r.push(yield*aa(e,[...t,i]));return r}}}),oa=Pe(function*(e,t,n){switch(e._tag){case`Objects`:{let r={};for(let i of e.propertySignatures){let e=i.name;if(typeof e==`string`){let a=yield*oa(i.type,t,[...n,e]);a!==void 0&&(r[e]=a)}}if(e.indexSignatures.length>0){let i=yield*t.load(n);if(i&&i._tag===`Record`)for(let a of e.indexSignatures){let e=Ote(a.parameter);for(let o of i.keys)if(!Object.hasOwn(r,o)&&e(o)){let e=yield*oa(a.type,t,[...n,o]);e!==void 0&&(r[o]=e)}}}return r}case`Arrays`:{let r=yield*t.load(n);if(r&&r._tag===`Value`)return r.value;let i=[];for(let r=0;r<e.elements.length;r++)i.push(yield*oa(e.elements[r],t,[...n,r]));return i}case`Union`:return yield*aa(t,n);case`Suspend`:return yield*oa(e.thunk(),t,n);default:{let e=yield*t.load(n);return e===void 0?void 0:e._tag===`Value`||e._tag===`Record`&&e.value!==void 0||e._tag===`Array`&&e.value!==void 0?e.value:void 0}}});function sa(e,t){let n=Cte(e),r=gte(n),i=jte(n.ast),a=typeof t==`string`?[t]:t??[];return Zie(e=>{let t=e.prefix?[...e.prefix,...a]:a;return oa(i,e,a).pipe(zee(e=>r(e).pipe(tt(e=>new lte(t.length>0?new _te(t,e):e)))),tt(e=>new Yie(e)))})}var Qie=(e,t,n)=>{let r=Wt(e,t),i=O.pipe(Mt(Wt(O,O),hte(n)),Mt(r));return Yte([r,i])},P=typeof __SENTRY_DEBUG__>`u`||__SENTRY_DEBUG__,F=globalThis,ca=`10.74.0`;function la(){return ua(F),F}function ua(e){let t=e.__SENTRY__=e.__SENTRY__||{};return t.version=t.version||`10.74.0`,t[ca]=t[`10.74.0`]||{}}function da(e,t,n=F){let r=n.__SENTRY__=n.__SENTRY__||{},i=r[ca]=r[`10.74.0`]||{};return i[e]||(i[e]=t())}var fa=[`debug`,`info`,`warn`,`error`,`log`,`assert`,`trace`],pa=`Sentry Logger `,ma={};function ha(e){if(!(`console`in F))return e();let t=F.console,n={},r=Object.keys(ma);r.forEach(e=>{let r=ma[e];n[e]=t[e],t[e]=r});try{return e()}finally{r.forEach(e=>{t[e]=n[e]})}}function $ie(){va().enabled=!0}function eae(){va().enabled=!1}function ga(){return va().enabled}function tae(...e){_a(`log`,...e)}function nae(...e){_a(`warn`,...e)}function rae(...e){_a(`error`,...e)}function _a(e,...t){P&&ga()&&ha(()=>{F.console[e](`${pa}[${e}]:`,...t)})}function va(){return P?da(`loggerSettings`,()=>({enabled:!1})):{enabled:!1}}var I={enable:$ie,disable:eae,isEnabled:ga,log:tae,warn:nae,error:rae},ya=50,ba=/\(error: (.*)\)/,xa=/captureMessage|captureException/;function Sa(...e){let t=e.sort((e,t)=>e[0]-t[0]).map(e=>e[1]);return(e,n=0,r=0)=>{let i=[],a=e.split(`
3
3
  `);for(let e=n;e<a.length;e++){let n=a[e];n.length>1024&&(n=n.slice(0,1024));let o=ba.test(n)?n.replace(ba,`$1`):n;if(!o.includes(`Error: `)){for(let e of t){let t=e(o);if(t){i.push(t);break}}if(i.length>=ya+r)break}}return aae(i.slice(r))}}function iae(e){return Array.isArray(e)?Sa(...e):e}function aae(e){if(!e.length)return[];let t=Array.from(e);return/sentryWrapped/.test(Ca(t).function||``)&&t.pop(),t.reverse(),xa.test(Ca(t).function||``)&&(t.pop(),xa.test(Ca(t).function||``)&&t.pop()),t.slice(0,ya).map(e=>({...e,filename:e.filename||Ca(t).filename,function:e.function||`?`}))}function Ca(e){return e[e.length-1]||{}}var wa=`<anonymous>`;function Ta(e){try{return!e||typeof e!=`function`?wa:e.name||wa}catch{return wa}}function Ea(e){let t=e.exception;if(t){let e=[];try{return t.values.forEach(t=>{t.stacktrace.frames&&e.push(...t.stacktrace.frames)}),e}catch{return}}}function oae(e){let t=e?.startsWith(`file://`)?e.slice(7):e;return t?.match(/\/[A-Z]:/)&&(t=t.slice(1)),t}var Da={},Oa={};function ka(e,t){return Da[e]=Da[e]||[],Da[e].push(t),()=>{let n=Da[e];if(n){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}function Aa(e,t){if(!Oa[e]){Oa[e]=!0;try{t()}catch(t){P&&I.error(`Error while instrumenting ${e}`,t)}}}function ja(e,t){let n=e&&Da[e];if(n)for(let r of n)try{r(t)}catch(t){P&&I.error(`Error while triggering instrumentation handler.
4
4
  Type: ${e}
5
5
  Name: ${Ta(r)}
@@ -1002,7 +1002,7 @@ or you can use record.mirror to access the mirror instance during recording.`,BR
1002
1002
  now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
1003
1003
  or you can use record.mirror to access the mirror instance during recording.`,QB={map:{},getId(){return console.error(ZB),-1},getNode(){return console.error(ZB),null},removeNodeFromMap(){console.error(ZB)},has(){return console.error(ZB),!1},reset(){console.error(ZB)}};typeof window<`u`&&window.Proxy&&window.Reflect&&(QB=new Proxy(QB,{get(e,t,n){return t===`map`&&console.error(ZB),Reflect.get(e,t,n)}}));function $B(e,t,n,r,i=window){let a=i.Object.getOwnPropertyDescriptor(e,t);return i.Object.defineProperty(e,t,r?n:{set(e){aV(()=>{n.set.call(this,e)},0),a&&a.set&&a.set.call(this,e)}}),()=>$B(e,t,a||{},!0)}function eV(e,t,n){try{if(!(t in e))return()=>{};let r=e[t],i=n(r);return typeof i==`function`&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}Date.now().toString();function oRe(e){if(!e)return null;try{return e.nodeType===e.ELEMENT_NODE?e:e.parentElement}catch{return null}}function tV(e,t,n,r,i){if(!e)return!1;let a=oRe(e);if(!a)return!1;let o=XB(t,n);if(!i){let e=r&&a.matches(r);return o(a)&&!e}let s=YB(a,o),c=-1;return s<0?!1:(r&&(c=YB(a,XB(null,r))),s>-1&&c<0||s<c)}var nV={};function rV(e){let t=nV[e];if(t)return t;let n=window.document,r=window[e];if(n&&typeof n.createElement==`function`)try{let t=n.createElement(`iframe`);t.hidden=!0,n.head.appendChild(t);let i=t.contentWindow;i&&i[e]&&(r=i[e]),n.head.removeChild(t)}catch{}return nV[e]=r.bind(window)}function iV(...e){return rV(`requestAnimationFrame`)(...e)}function aV(...e){return rV(`setTimeout`)(...e)}var oV=(e=>(e[e[`2D`]=0]=`2D`,e[e.WebGL=1]=`WebGL`,e[e.WebGL2=2]=`WebGL2`,e))(oV||{}),sV;function sRe(e){sV=e}for(var cV=e=>sV?((...t)=>{try{return e(...t)}catch(e){if(sV&&sV(e)===!0)return()=>{};throw e}}):e,lV=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,cRe=typeof Uint8Array>`u`?[]:new Uint8Array(256),uV=0;uV<lV.length;uV++)cRe[lV.charCodeAt(uV)]=uV;var lRe=function(e){var t=new Uint8Array(e),n,r=t.length,i=``;for(n=0;n<r;n+=3)i+=lV[t[n]>>2],i+=lV[(t[n]&3)<<4|t[n+1]>>4],i+=lV[(t[n+1]&15)<<2|t[n+2]>>6],i+=lV[t[n+2]&63];return r%3==2?i=i.substring(0,i.length-1)+`=`:r%3==1&&(i=i.substring(0,i.length-2)+`==`),i},dV=new Map;function uRe(e,t){let n=dV.get(e);return n||(n=new Map,dV.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}var fV=(e,t,n)=>{if(!e||!(hV(e,t)||typeof e==`object`))return;let r=e.constructor.name,i=uRe(n,r),a=i.indexOf(e);return a===-1&&(a=i.length,i.push(e)),a};function pV(e,t,n){if(e instanceof Array)return e.map(e=>pV(e,t,n));if(e===null)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer)return{rr_type:e.constructor.name,base64:lRe(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[pV(e.buffer,t,n),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){let t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}return e instanceof HTMLCanvasElement?{rr_type:`HTMLImageElement`,src:e.toDataURL()}:e instanceof ImageData?{rr_type:e.constructor.name,args:[pV(e.data,t,n),e.width,e.height]}:hV(e,t)||typeof e==`object`?{rr_type:e.constructor.name,index:fV(e,t,n)}:e}var mV=(e,t,n)=>e.map(e=>pV(e,t,n)),hV=(e,t)=>!![`WebGLActiveInfo`,`WebGLBuffer`,`WebGLFramebuffer`,`WebGLProgram`,`WebGLRenderbuffer`,`WebGLShader`,`WebGLShaderPrecisionFormat`,`WebGLTexture`,`WebGLUniformLocation`,`WebGLVertexArrayObject`,`WebGLVertexArrayObjectOES`].filter(e=>typeof t[e]==`function`).find(n=>e instanceof t[n]);function dRe(e,t,n,r,i){let a=[],o=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(let s of o)try{if(typeof t.CanvasRenderingContext2D.prototype[s]!=`function`)continue;let o=eV(t.CanvasRenderingContext2D.prototype,s,function(a){return function(...o){return tV(this.canvas,n,r,i,!0)||aV(()=>{let n=mV(o,t,this);e(this.canvas,{type:oV[`2D`],property:s,args:n})},0),a.apply(this,o)}});a.push(o)}catch{let n=$B(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:oV[`2D`],property:s,args:[t],setter:!0})}});a.push(n)}return()=>{a.forEach(e=>e())}}function fRe(e){return e===`experimental-webgl`?`webgl`:e}function gV(e,t,n,r,i){let a=[];try{let o=eV(e.HTMLCanvasElement.prototype,`getContext`,function(e){return function(a,...o){if(!tV(this,t,n,r,!0)){let e=fRe(a);if(`__context`in this||(this.__context=e),i&&[`webgl`,`webgl2`].includes(e))if(o[0]&&typeof o[0]==`object`){let e=o[0];e.preserveDrawingBuffer||=!0}else o.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[a,...o])}});a.push(o)}catch{console.error(`failed to patch HTMLCanvasElement.prototype.getContext`)}return()=>{a.forEach(e=>e())}}function _V(e,t,n,r,i,a,o,s){let c=[],l=Object.getOwnPropertyNames(e);for(let o of l)if(![`isContextLost`,`canvas`,`drawingBufferWidth`,`drawingBufferHeight`].includes(o))try{if(typeof e[o]!=`function`)continue;let l=eV(e,o,function(e){return function(...c){let l=e.apply(this,c);if(fV(l,s,this),`tagName`in this.canvas&&!tV(this.canvas,r,i,a,!0)){let e=mV(c,s,this),r={type:t,property:o,args:e};n(this.canvas,r)}return l}});c.push(l)}catch{let r=$B(e,o,{set(e){n(this.canvas,{type:t,property:o,args:[e],setter:!0})}});c.push(r)}return c}function pRe(e,t,n,r,i,a){let o=[];return o.push(..._V(t.WebGLRenderingContext.prototype,oV.WebGL,e,n,r,i,a,t)),t.WebGL2RenderingContext!==void 0&&o.push(..._V(t.WebGL2RenderingContext.prototype,oV.WebGL2,e,n,r,i,a,t)),()=>{o.forEach(e=>e())}}var mRe=`for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t="undefined"==typeof Uint8Array?[]:new Uint8Array(256),a=0;a<64;a++)t[e.charCodeAt(a)]=a;var n=function(t){var a,n=new Uint8Array(t),r=n.length,s="";for(a=0;a<r;a+=3)s+=e[n[a]>>2],s+=e[(3&n[a])<<4|n[a+1]>>4],s+=e[(15&n[a+1])<<2|n[a+2]>>6],s+=e[63&n[a+2]];return r%3==2?s=s.substring(0,s.length-1)+"=":r%3==1&&(s=s.substring(0,s.length-2)+"=="),s};const r=new Map,s=new Map;const i=self;i.onmessage=async function(e){if(!("OffscreenCanvas"in globalThis))return i.postMessage({id:e.data.id});{const{id:t,bitmap:a,width:o,height:f,maxCanvasSize:c,dataURLOptions:g}=e.data,u=async function(e,t,a){const r=e+"-"+t;if("OffscreenCanvas"in globalThis){if(s.has(r))return s.get(r);const i=new OffscreenCanvas(e,t);i.getContext("2d");const o=await i.convertToBlob(a),f=await o.arrayBuffer(),c=n(f);return s.set(r,c),c}return""}(o,f,g),[h,d]=function(e,t,a){if(!a)return[e,t];const[n,r]=a;if(e<=n&&t<=r)return[e,t];let s=e,i=t;return s>n&&(i=Math.floor(n*t/e),s=n),i>r&&(s=Math.floor(r*e/t),i=r),[s,i]}(o,f,c),l=new OffscreenCanvas(h,d),w=l.getContext("bitmaprenderer"),p=h===o&&d===f?a:await createImageBitmap(a,{resizeWidth:h,resizeHeight:d,resizeQuality:"low"});w?.transferFromImageBitmap(p),a.close();const y=await l.convertToBlob(g),v=y.type,b=await y.arrayBuffer(),m=n(b);if(p.close(),!r.has(t)&&await u===m)return r.set(t,m),i.postMessage({id:t});if(r.get(t)===m)return i.postMessage({id:t});i.postMessage({id:t,type:v,base64:m,width:o,height:f}),r.set(t,m)}};`;function hRe(){let e=new Blob([mRe]);return URL.createObjectURL(e)}var gRe=class{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.shadowDoms=new Set,this.windowsSet=new WeakSet,this.windows=[],this.restoreHandlers=[],this.frozen=!1,this.locked=!1,this.snapshotInProgressMap=new Map,this.worker=null,this.lastSnapshotTime=0,this.processMutation=(e,t)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};let{enableManualSnapshot:t,sampling:n=`all`,win:r,recordCanvas:i,errorHandler:a}=e;e.sampling=n,this.mutationCb=e.mutationCb,this.mirror=e.mirror,this.options=e,a&&sRe(a),(i&&typeof n==`number`||t)&&(this.worker=this.initFPSWorker()),this.addWindow(r),!t&&cV(()=>{i&&n===`all`&&(this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher()),i&&typeof n==`number`&&this.initCanvasFPSObserver()})()}reset(){this.pendingCanvasMutations.clear(),this.restoreHandlers.forEach(e=>{try{e()}catch{}}),this.restoreHandlers=[],this.windowsSet=new WeakSet,this.windows=[],this.shadowDoms=new Set,this.worker?.terminate(),this.worker=null,this.snapshotInProgressMap=new Map}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}addWindow(e){let{sampling:t=`all`,blockClass:n,blockSelector:r,unblockSelector:i,recordCanvas:a,enableManualSnapshot:o}=this.options;if(!this.windowsSet.has(e)){if(o){this.windowsSet.add(e),this.windows.push(new WeakRef(e));return}cV(()=>{if(a&&t===`all`&&this.initCanvasMutationObserver(e,n,r,i),a&&typeof t==`number`){let t=gV(e,n,r,i,!0);this.restoreHandlers.push(()=>{t()})}})(),this.windowsSet.add(e),this.windows.push(new WeakRef(e))}}addShadowRoot(e){this.shadowDoms.add(new WeakRef(e))}resetShadowRoots(){this.shadowDoms=new Set}snapshot(e,t){if(t?.skipRequestAnimationFrame){this.takeSnapshot(performance.now(),!0,e);return}iV(t=>this.takeSnapshot(t,!0,e))}initFPSWorker(){let e=new Worker(hRe());return e.onmessage=e=>{let t=e.data,{id:n}=t;if(this.snapshotInProgressMap.set(n,!1),!(`base64`in t))return;let{base64:r,type:i,width:a,height:o}=t;this.mutationCb({id:n,type:oV[`2D`],commands:[{property:`clearRect`,args:[0,0,a,o]},{property:`drawImage`,args:[{rr_type:`ImageBitmap`,args:[{rr_type:`Blob`,data:[{rr_type:`ArrayBuffer`,base64:r}],type:i}]},0,0,a,o]}]})},e}initCanvasFPSObserver(){let e;if(!this.windows.length&&!this.shadowDoms.size)return;let t=n=>{this.takeSnapshot(n,!1),e=iV(t)};e=iV(t),this.restoreHandlers.push(()=>{e&&cancelAnimationFrame(e)})}initCanvasMutationObserver(e,t,n,r){let i=gV(e,t,n,r,!1),a=dRe(this.processMutation.bind(this),e,t,n,r),o=pRe(this.processMutation.bind(this),e,t,n,r,this.mirror);this.restoreHandlers.push(()=>{i(),a(),o()})}getCanvasElements(e,t,n){let r=[],i=i=>{i.querySelectorAll(`canvas`).forEach(i=>{tV(i,e,t,n,!0)||r.push(i)})};for(let e of this.windows){let t=e.deref(),n;try{n=t&&t.document}catch{}n&&i(n)}for(let e of this.shadowDoms){let t=e.deref();t&&i(t)}return r}takeSnapshot(e,t,n){let{sampling:r,blockClass:i,blockSelector:a,unblockSelector:o,dataURLOptions:s,maxCanvasSize:c}=this.options,l=1e3/(r===`all`?2:r||2);return this.lastSnapshotTime&&e-this.lastSnapshotTime<l?!1:(this.lastSnapshotTime=e,(n?[n]:this.getCanvasElements(i,a,o)).forEach(e=>{let n=this.mirror.getId(e);if(!(!this.mirror.hasNode(e)||!e.width||!e.height||this.snapshotInProgressMap.get(n))){if(this.snapshotInProgressMap.set(n,!0),!t&&[`webgl`,`webgl2`].includes(e.__context)){let t=e.getContext(e.__context);t?.getContextAttributes()?.preserveDrawingBuffer===!1&&t.clear(t.COLOR_BUFFER_BIT)}createImageBitmap(e).then(t=>{this.worker?.postMessage({id:n,bitmap:t,width:e.width,height:e.height,dataURLOptions:s,maxCanvasSize:c},[t])}).catch(e=>{cV(()=>{throw this.snapshotInProgressMap.delete(n),e})()})}}),!0)}startPendingCanvasMutationFlusher(){iV(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){let e=t=>{this.rafStamps.latestId=t,iV(e)};iV(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{let n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),iV(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;let n=this.pendingCanvasMutations.get(e);if(!n||t===-1)return;let r=n.map(e=>{let{type:t,...n}=e;return n}),{type:i}=n[0];this.mutationCb({id:t,type:i,commands:r}),this.pendingCanvasMutations.delete(e)}};try{if(Array.from([1],e=>e*2)[0]!==2){let e=document.createElement(`iframe`);document.body.appendChild(e),Array.from=e.contentWindow?.Array.from||Array.from,document.body.removeChild(e)}}catch(e){console.debug(`Unable to override Array.from`,e)}iRe();var _Re;(function(e){e[e.NotStarted=0]=`NotStarted`,e[e.Running=1]=`Running`,e[e.Stopped=2]=`Stopped`})(_Re||={});var vV={low:{sampling:{canvas:1},dataURLOptions:{type:`image/webp`,quality:.25}},medium:{sampling:{canvas:2},dataURLOptions:{type:`image/webp`,quality:.4}},high:{sampling:{canvas:4},dataURLOptions:{type:`image/webp`,quality:.5}}},vRe=`ReplayCanvas`,yV=1280,yRe=qO(((e={})=>{let[t,n]=e.maxCanvasSize||[],r={quality:e.quality||`medium`,enableManualSnapshot:e.enableManualSnapshot,maxCanvasSize:[t?Math.min(t,yV):yV,n?Math.min(n,yV):yV]},i,a,o=new Promise(e=>a=e);return{name:vRe,getOptions(){let{quality:e,enableManualSnapshot:t,maxCanvasSize:n}=r;return{enableManualSnapshot:t,recordCanvas:!0,getCanvasManager:e=>{let r=new gRe({...e,enableManualSnapshot:t,maxCanvasSize:n,errorHandler:e=>{try{typeof e==`object`&&(e.__rrweb__=!0)}catch{}}});return i=r,a(r),r},...vV[e]||vV.medium}},async snapshot(e,t){(i||await o).snapshot(e,t)}}}));function bRe(e){return e.split(`,`).some(e=>e.trim().startsWith(`sentry-`))}function bV(e){try{return new URL(e,J.location.origin).href}catch{return}}function xRe(e){return e.entryType===`resource`&&`initiatorType`in e&&typeof e.nextHopProtocol==`string`&&(e.initiatorType===`fetch`||e.initiatorType===`xmlhttprequest`)}function xV(e){try{return new Headers(e)}catch{return}}var SV={traceFetch:!0,traceXHR:!0,enableHTTPTimings:!0,trackFetchStreamPerformance:!1};function CV(e,t){let{traceFetch:n,traceXHR:r,shouldCreateSpanForRequest:i,enableHTTPTimings:a,tracePropagationTargets:o,onRequestSpanStart:s,onRequestSpanEnd:c}={...SV,...t},l=typeof i==`function`?i:e=>!0,u=e=>CRe(e,o),d={},f=e.getOptions().propagateTraceparent;n&&lN(t=>{let n=xOe(t,l,u,d,{propagateTraceparent:f,onRequestSpanEnd:c});if(n){let r=bV(t.fetchData.url),i=r?Bk(r).host:void 0,o=r?Hk(r):void 0;n.setAttributes({"http.url":o,"url.full":o,"server.address":i}),a&&wV(n,e),s?.(n,{headers:t.headers})}}),r&&hL(t=>{let n=wRe(t,l,u,d,f,c);n&&(a&&wV(n,e),s?.(n,{headers:xV(t.xhr.__sentry_xhr_v3__?.request_headers)}))})}var SRe=300;function wV(e,t){let{url:n}=JE(e).data;if(!n||typeof n!=`string`)return;let r=()=>void setTimeout(i);if(RD(t)){let t=e.end.bind(e);e.end=e=>{let n=e??RT(),a=!1,o=()=>{a||(a=!0,setTimeout(i),t(n),clearTimeout(s))};r=o;let s=setTimeout(o,SRe)}}let i=kI(`resource`,({entries:t})=>{t.forEach(t=>{xRe(t)&&t.name.endsWith(n)&&(e.setAttributes(KI(t)),r())})})}function CRe(e,t){let n=wN();if(n){let r,i;try{r=new URL(e,n),i=new URL(n).origin}catch{return!1}let a=r.origin===i;return t?OT(r.toString(),t)||a&&OT(r.pathname,t):a}{let n=!!e.match(/^\/(?!\/)/);return t?OT(e,t):n}}function wRe(e,t,n,r,i,a){let o=e.xhr,s=o?.[mL];if(!o||o.__sentry_own_request__||!s)return;let{url:c,method:l}=s,u=mD()&&t(c);if(e.endTimestamp){let t=o.__sentry_xhr_span_id__;if(!t)return;let n=r[t];n&&(u&&s.status_code!==void 0&&(SE(n,s.status_code),n.end(),a?.(n,{headers:xV(yL(o)),error:e.error})),delete r[t]);return}let d=bV(c),f=Bk(d||c),p=d?Hk(d):void 0,m=Hk(Vk(c)),h=q(),g=!!uD(),_=g||!!h&&RD(h),v=u&&_?qD({name:`${l} ${m}`,attributes:{url:Hk(c),type:`xhr`,"http.method":l,"http.url":p,"url.full":p,"server.address":f?.host,[mE]:`auto.http.browser`,[pE]:`http.client`,...f?.search&&{"http.query":f?.search},...f?.hash&&{"http.fragment":f?.hash}}}):new vD,y=iO(v)&&g?void 0:v;return u&&!_&&h?.recordDroppedEvent(`no_parent_span`,`span`),o.__sentry_xhr_span_id__=v.spanContext().spanId,r[o.__sentry_xhr_span_id__]=v,n(c)&&TRe(o,mD()&&_?y:void 0,i),h&&h.emit(`beforeOutgoingRequestSpan`,v,e),v}function TRe(e,t,n){let{"sentry-trace":r,baggage:i,traceparent:a}=Kk({span:t,propagateTraceparent:n});r&&ERe(e,r,i,a)}function ERe(e,t,n,r){let i=e.__sentry_xhr_v3__?.request_headers;if(!(i?.[`sentry-trace`]||!e.setRequestHeader))try{if(e.setRequestHeader(`sentry-trace`,t),r&&!i?.traceparent&&e.setRequestHeader(`traceparent`,r),n){let t=i?.baggage;(!t||!bRe(t))&&e.setRequestHeader(`baggage`,n)}}catch{}}var TV=new WeakMap,EV=new WeakMap,DRe=9e4,ORe=[`text/event-stream`,`application/x-ndjson`,`application/stream+json`],DV=qO(()=>({name:`FetchStreamPerformance`,setup(){uN(e=>{if(e.response){let t=TV.get(e.response);if(t&&e.endTimestamp){t.end(e.endTimestamp);let n=EV.get(e.response);n&&clearTimeout(n)}}}),lN(e=>{if(e.endTimestamp&&e.response){let t=e.response.headers?.get(`content-type`)||``;if(e.response.headers?.get(`content-length`)||!ORe.some(e=>t.startsWith(e)))return;let n=e.fetchData?.url||``,r=e.fetchData?.method||`GET`,i=Rk(n),a=qD({name:`${r} ${n.startsWith(`data:`)?Hk(n):i?zk(i):n}`,startTime:e.endTimestamp,attributes:{url:Hk(n),"http.method":r,type:`fetch`,[pE]:`http.client.stream`,[mE]:`auto.http.browser.stream`}});TV.set(e.response,a);let o=setTimeout(()=>{a.isRecording()&&a.end()},DRe);EV.set(e.response,o)}})}})),kRe=`WebVitals`,OV=qO((e={})=>{let t=new Set(e.ignore??[]);return{name:kRe,setup(n){let r=RD(n),{enableStandaloneClsSpans:i,enableStandaloneLcpSpans:a}=e._experiments??{},o=r||t.has(`cls`)?void 0:i||!1,s=r||t.has(`lcp`)?void 0:a||!1,c=tMe({recordClsStandaloneSpans:o,recordLcpStandaloneSpans:s,client:n}),l=new WeakSet;n.on(`afterStartPageLoadSpan`,e=>{l.add(e)}),n.on(`spanEnd`,e=>{l.delete(e)&&(c(),uMe(e,{recordClsOnPageloadSpan:o===!1,recordLcpOnPageloadSpan:s===!1,spanStreamingEnabled:r}))}),r?(t.has(`lcp`)||kMe(n),t.has(`cls`)||jMe(n),t.has(`inp`)||NMe()):t.has(`inp`)||wMe()},afterAllSetup(){t.has(`inp`)||OMe()}}});function ARe(){J.document?J.document.addEventListener(`visibilitychange`,()=>{let e=uD();if(!e)return;let t=cD(e);if(J.document.hidden&&t){let e=`cancelled`,{op:n,status:r}=JE(t);Y&&G.log(`[Tracing] Transaction: ${e} -> since tab moved to the background, op: ${n}`),r||t.setStatus({code:2,message:e}),t.setAttribute(`sentry.cancellation_reason`,`document.hidden`),t.end()}}):Y&&G.warn(`[Tracing] Could not set up background tab detection due to lack of global document`)}var kV=`sentry_previous_trace`,jRe=`sentry.previous_trace`;function MRe(e,{linkPreviousTrace:t,consistentTraceSampling:n}){let r=t===`session-storage`,i=r?FRe():void 0;e.on(`spanStart`,e=>{if(cD(e)!==e)return;let t=K().getPropagationContext();i=NRe(i,e,t),r&&PRe(i)});let a=!0;n&&e.on(`beforeSampling`,e=>{if(!i)return;let t=K(),n=t.getPropagationContext();if(a&&n.parentSpanId){a=!1;return}t.setPropagationContext({...n,dsc:{...n.dsc,sample_rate:String(i.sampleRate),sampled:String(AV(i.spanContext))},sampleRand:i.sampleRand}),e.parentSampled=AV(i.spanContext),e.parentSampleRate=i.sampleRate,e.spanAttributes={...e.spanAttributes,[pwe]:i.sampleRate}})}function NRe(e,t,n){let r=JE(t);function i(){try{let e=Number(r.data?.[`sentry.sample_rate`]??n.dsc?.sample_rate);return Number.isNaN(e)?0:e}catch{return 0}}let a={spanContext:t.spanContext(),startTimestamp:r.start_timestamp,sampleRate:i(),sampleRand:n.sampleRand};if(!e)return a;let o=e.spanContext;return o.traceId===r.trace_id?e:(Date.now()/1e3-e.startTimestamp<=3600&&(Y&&G.log(`Adding previous_trace \`${JSON.stringify(o)}\` link to span \`${JSON.stringify({op:r.op,...t.spanContext()})}\``),t.addLink({context:o,attributes:{[Swe]:`previous_trace`}}),t.setAttribute(jRe,`${o.traceId}-${o.spanId}-${+!!AV(o)}`)),a)}function PRe(e){try{J.sessionStorage.setItem(kV,JSON.stringify(e))}catch(e){Y&&G.warn(`Could not store previous trace in sessionStorage`,e)}}function FRe(){try{let e=J.sessionStorage?.getItem(kV);return JSON.parse(e)}catch{return}}function AV(e){return e.traceFlags===1}var IRe=`BrowserTracing`,LRe=/Googlebot|Google-InspectionTool|Storebot-Google|Bingbot|Slurp|DuckDuckBot|Baiduspider|YandexBot|Facebot|facebookexternalhit|LinkedInBot|Twitterbot|Applebot/i;function jV(){let e=J.navigator;return e?.userAgent?LRe.test(e.userAgent):!1}var RRe={...aO,instrumentNavigation:!0,instrumentPageLoad:!0,markBackgroundSpan:!0,enableLongTask:!0,enableLongAnimationFrame:!0,enableInp:!0,ignoreResourceSpans:[],ignorePerformanceApiSpans:[],detectRedirects:!0,linkPreviousTrace:`in-memory`,consistentTraceSampling:!1,enableReportPageLoaded:!1,_experiments:{},...SV},MV=((e={})=>{`enableElementTiming`in e&&ww(()=>{console.warn("[Sentry] `enableElementTiming` is deprecated and no longer has any effect. Use the standalone `elementTimingIntegration` instead.")});let t={name:void 0,source:void 0},n=J.document,{enableInp:r,enableLongTask:i,enableLongAnimationFrame:a,_experiments:{enableInteractions:o,enableStandaloneClsSpans:s,enableStandaloneLcpSpans:c},beforeStartSpan:l,idleTimeout:u,finalTimeout:d,childSpanTimeout:f,markBackgroundSpan:p,traceFetch:m,traceXHR:h,trackFetchStreamPerformance:g,shouldCreateSpanForRequest:_,enableHTTPTimings:v,ignoreResourceSpans:y,ignorePerformanceApiSpans:b,instrumentPageLoad:x,instrumentNavigation:S,detectRedirects:C,linkPreviousTrace:w,consistentTraceSampling:T,enableReportPageLoaded:E,onRequestSpanStart:ee,onRequestSpanEnd:te}={...RRe,...e},ne=jV(),re,ie;function ae(e,r,i=!0,a){let o=r.op===`pageload`,s=r.name,c=l?l(r):r,p=Rk(a||wN()),m={...p?.pathname&&{"url.path":p.pathname},...p&&!Lk(p)&&{"url.full":p.href},...c.attributes};if(s!==c.name&&(m[dE]=`custom`),c.attributes=m,!i){let e=LT();qD({...c,startTime:e}).end(e);return}t.name=c.name,t.source=m[dE];let h=oO(c,{idleTimeout:u,finalTimeout:d,childSpanTimeout:f,disableAutoFinish:o,beforeSpanEnd:t=>{lMe(t,{ignoreResourceSpans:y,ignorePerformanceApiSpans:b,spanStreamingEnabled:RD(e)}),zV(e,void 0);let n=K(),r=n.getPropagationContext();n.setPropagationContext({...r,traceId:h.spanContext().traceId,sampled:eD(h),dsc:wD(t)}),o&&(ie=void 0)},trimIdleSpanEndTimestamp:!E});o&&E&&(ie=h),zV(e,h);function g(){n&&[`interactive`,`complete`].includes(n.readyState)&&(e.emit(`idleSpanEnableAutoFinish`,h),n.removeEventListener(`readystatechange`,g))}o&&!E&&n&&(n.addEventListener(`readystatechange`,g),g())}return{name:IRe,setup(e){if(ne){Y&&G.log(`[Tracing] Skipping browserTracingIntegration setup for bot user agent.`);return}if(pD(),a&&W.PerformanceObserver&&PerformanceObserver.supportedEntryTypes?.includes(`long-animation-frame`)?rMe():i&&nMe(),o&&iMe(),C&&n){let e=()=>{re=RT()};addEventListener(`click`,e,{capture:!0}),addEventListener(`keydown`,e,{capture:!0,passive:!0})}function t(){let t=RV(e);t&&!JE(t).timestamp&&(Y&&G.log(`[Tracing] Finishing current active span with op: ${JE(t).op}`),t.setAttribute(hE,`cancelled`),t.end())}e.on(`startNavigationSpan`,(n,r)=>{if(q()!==e)return;if(r?.isRedirect){Y&&G.warn(`[Tracing] Detected redirect, navigation span will not be the root span, but a child span.`),ae(e,{op:`navigation.redirect`,...n},!1,r.url);return}re=void 0,t(),sE().setPropagationContext({traceId:UT(),sampleRand:Math.random(),propagationSpanId:mD()?void 0:WT()});let i=K();i.setPropagationContext({traceId:UT(),sampleRand:Math.random(),propagationSpanId:mD()?void 0:WT()}),i.setSDKProcessingMetadata({normalizedRequest:void 0}),ae(e,{op:`navigation`,...n,parentSpan:null,forceTransaction:!0},!0,r?.url)}),e.on(`startPageLoadSpan`,(n,r={})=>{if(q()!==e)return;t();let i=zE(r.sentryTrace||FV(`sentry-trace`)||IV(`sentry-trace`),r.baggage||FV(`baggage`)||IV(`baggage`)),a=K();a.setPropagationContext(i),mD()||(a.getPropagationContext().propagationSpanId=WT()),a.setSDKProcessingMetadata({normalizedRequest:IF()}),ae(e,{op:`pageload`,...n})}),e.on(`endPageloadSpan`,()=>{E&&ie&&(ie.setAttribute(hE,`reportPageLoaded`),ie.end())})},afterAllSetup(e){if(ne)return;e.addIntegration&&!e.getIntegrationByName?.(`WebVitals`)&&e.addIntegration(OV({ignore:r?[]:[`inp`],_experiments:{enableStandaloneClsSpans:s,enableStandaloneLcpSpans:c}}));let n=wN();if(w!==`off`&&MRe(e,{linkPreviousTrace:w,consistentTraceSampling:T}),J.location){if(x){let t=BT();NV(e,{name:J.location.pathname,startTime:t?t/1e3:void 0,attributes:{[dE]:`url`,[mE]:`auto.pageload.browser`}})}S&&uL(({to:t,from:r})=>{if(r===void 0&&n?.indexOf(t)!==-1){n=void 0;return}n=void 0;let i=Rk(t),a=RV(e),o=a&&C&&BRe(a,re);PV(e,{name:i?.pathname||J.location.pathname,attributes:{[dE]:`url`,[mE]:`auto.navigation.browser`}},{url:t,isRedirect:o})})}p&&ARe(),o&&zRe(e,u,d,f,t),CV(e,{traceFetch:m,traceXHR:h,tracePropagationTargets:e.getOptions().tracePropagationTargets,shouldCreateSpanForRequest:_,enableHTTPTimings:v,onRequestSpanStart:ee,onRequestSpanEnd:te}),g&&e.addIntegration(DV())}}});function NV(e,t,n){e.emit(`startPageLoadSpan`,t,n),K().setTransactionName(t.name);let r=RV(e);return r&&e.emit(`afterStartPageLoadSpan`,r),r}function PV(e,t,n){let{url:r,isRedirect:i}=n||{};e.emit(`beforeStartNavigationSpan`,t,{isRedirect:i,url:r}),e.emit(`startNavigationSpan`,t,{isRedirect:i,url:r});let a=K();return a.setTransactionName(t.name),r&&!i&&a.setSDKProcessingMetadata({normalizedRequest:{...IF(),url:r}}),RV(e)}function FV(e){return(J.document?.querySelector(`meta[name=${e}]`))?.getAttribute(`content`)||void 0}function IV(e){return(J.performance?.getEntriesByType?.(`navigation`)[0])?.serverTiming?.find(t=>t.name===e)?.description}function zRe(e,t,n,r,i){let a=J.document,o;a&&addEventListener(`click`,()=>{let a=`ui.action.click`,s=RV(e);if(s){let e=JE(s).op;if([`navigation`,`pageload`].includes(e)){Y&&G.warn(`[Tracing] Did not create ${a} span because a pageload or navigation span is in progress.`);return}}if(o&&=(o.setAttribute(hE,`interactionInterrupted`),o.end(),void 0),!i.name){Y&&G.warn(`[Tracing] Did not create ${a} transaction because _latestRouteName is missing.`);return}o=oO({name:i.name,op:a,attributes:{[dE]:i.source||`url`}},{idleTimeout:t,finalTimeout:n,childSpanTimeout:r})},{capture:!0})}var LV=`_sentry_idleSpan`;function RV(e){return e[LV]}function zV(e,t){cT(e,LV,t)}var BV=1.5;function BRe(e,t){let n=JE(e),r=LT();return!(r-n.start_timestamp>BV||t&&r-t<=BV)}function VRe(e=q()){e?.emit(`endPageloadSpan`)}function HRe(e){let t=uD();if(t===e)return;let n=K();e.end=new Proxy(e.end,{apply(e,r,i){return JT(n,t),Reflect.apply(e,r,i)}}),JT(n,e)}var URe=qO(()=>({name:`SpanStreaming`,beforeSetup(e){let t=e.getOptions();t.traceLifecycle||=(Y&&G.log('[SpanStreaming] setting `traceLifecycle` to "stream"'),`stream`)},setup(e){let t=`SpanStreaming integration requires`,n=`Falling back to static trace lifecycle.`,r=e.getOptions();if(!RD(e)){r.traceLifecycle=`static`,Y&&G.warn(`${t} \`traceLifecycle\` to be set to "stream"! ${n}`);return}let i=r.beforeSendSpan;if(i&&!TD(i)){r.traceLifecycle=`static`,Y&&G.warn(`${t} a beforeSendSpan callback using \`withStreamedSpan\`! ${n}`);return}let a=new tN(e);e.on(`afterSpanEnd`,t=>{eD(t)&&a.add(LTe(t,e))}),e.on(`afterSegmentSpanEnd`,e=>{let t=e.spanContext().traceId;setTimeout(()=>{a.flush(t)},500)})}})),VV=1e6,WRe=`window`in W&&W.window===W&&typeof importScripts>`u`,HV=`0`,UV=WRe?`main`:`worker`,WV=J.navigator,GV=``,KV=``,qV=``,JV=WV?.userAgent||``,YV=``,GRe=WV?.language||WV?.languages?.[0]||``;function KRe(e){return typeof e==`object`&&!!e&&`getHighEntropyValues`in e}var XV=WV?.userAgentData;KRe(XV)&&XV.getHighEntropyValues([`architecture`,`model`,`platform`,`platformVersion`,`fullVersionList`]).then(e=>{if(GV=e.platform||``,qV=e.architecture||``,YV=e.model||``,KV=e.platformVersion||``,e.fullVersionList?.length){let t=e.fullVersionList[e.fullVersionList.length-1];JV=`${t.brand} ${t.version}`}}).catch(e=>void 0);function qRe(e){return!(`thread_metadata`in e)}function JRe(e){return qRe(e)?eze(e):e}function YRe(e){let t=e.contexts?.trace?.trace_id;return typeof t==`string`&&t.length!==32&&Y&&G.log(`[Profiling] Invalid traceId: ${t} on profiled event`),typeof t==`string`?t:``}function XRe(e,t,n,r){if(r.type!==`transaction`)throw TypeError(`Profiling events may only be attached to transactions, this should never occur.`);if(n==null)throw TypeError(`Cannot construct profiling event envelope without a valid profile. Got ${n} instead.`);let i=YRe(r),a=JRe(n),o=t||(typeof r.start_timestamp==`number`?r.start_timestamp*1e3:RT()*1e3),s=typeof r.timestamp==`number`?r.timestamp*1e3:RT()*1e3;return{event_id:e,timestamp:new Date(o).toISOString(),platform:`javascript`,version:`1`,release:r.release||``,environment:r.environment||`production`,runtime:{name:`javascript`,version:J.navigator.userAgent},os:{name:GV,version:KV,build_number:JV},device:{locale:GRe,model:YV,manufacturer:JV,architecture:qV,is_emulator:!1},debug_meta:{images:QV(n.resources)},profile:a,transactions:[{name:r.transaction||``,id:r.event_id||AT(),trace_id:i,active_thread_id:HV,relative_start_ns:`0`,relative_end_ns:((s-o)*1e6).toFixed(0)}]}}function ZRe(e,t,n){if(e==null)throw TypeError(`Cannot construct profiling event envelope without a valid profile. Got ${e} instead.`);let r=$Re(e),i=t.getOptions(),a=t.getSdkMetadata?.()?.sdk;return{chunk_id:AT(),client_sdk:{name:a?.name??`sentry.javascript.browser`,version:a?.version??`0.0.0`},profiler_id:n||AT(),platform:`javascript`,version:`2`,release:i.release??``,environment:i.environment??`production`,debug_meta:{images:QV(e.resources)},profile:r}}function QRe(e){try{if(!e||typeof e!=`object`)return{reason:`chunk is not an object`};let t=e=>typeof e==`string`&&/^[a-f0-9]{32}$/.test(e);if(!t(e.profiler_id))return{reason:`missing or invalid profiler_id`};if(!t(e.chunk_id))return{reason:`missing or invalid chunk_id`};if(!e.client_sdk)return{reason:`missing client_sdk metadata`};let n=e.profile;return n?!Array.isArray(n.frames)||!n.frames.length?{reason:`profile has no frames`}:!Array.isArray(n.stacks)||!n.stacks.length?{reason:`profile has no stacks`}:!Array.isArray(n.samples)||!n.samples.length?{reason:`profile has no samples`}:{valid:!0}:{reason:`missing profile data`}}catch(e){return{reason:`unknown validation error: ${e}`}}}function $Re(e){let t=[];for(let n=0;n<e.frames.length;n++){let r=e.frames[n];r&&(t[n]={function:r.name,abs_path:typeof r.resourceId==`number`?e.resources[r.resourceId]:void 0,lineno:r.line,colno:r.column})}let n=[];for(let t=0;t<e.stacks.length;t++){let r=e.stacks[t];if(!r)continue;let i=[],a=r;for(;a;)i.push(a.frameId),a=a.parentId===void 0?void 0:e.stacks[a.parentId];n[t]=i}let r=BT(),i=typeof performance.timeOrigin==`number`?performance.timeOrigin:r||0,a=i-(r||i),o=[];for(let t=0;t<e.samples.length;t++){let n=e.samples[t];if(!n)continue;let r=(i+(n.timestamp-a))/1e3;o[t]={stack_id:n.stackId??0,thread_id:HV,timestamp:r}}return{frames:t,stacks:n,samples:o,thread_metadata:{[HV]:{name:UV}}}}function ZV(e){return JE(e).op===`pageload`}function eze(e){let t,n=0,r={samples:[],stacks:[],frames:[],thread_metadata:{[HV]:{name:UV}}},i=e.samples[0];if(!i)return r;let a=i.timestamp,o=BT(),s=typeof performance.timeOrigin==`number`?performance.timeOrigin:o||0,c=s-(o||s);return e.samples.forEach((i,o)=>{if(i.stackId===void 0){t===void 0&&(t=n,r.stacks[t]=[],n++),r.samples[o]={elapsed_since_start_ns:((i.timestamp+c-a)*VV).toFixed(0),stack_id:t,thread_id:HV};return}let s=e.stacks[i.stackId],l=[];for(;s;){l.push(s.frameId);let t=e.frames[s.frameId];t&&r.frames[s.frameId]===void 0&&(r.frames[s.frameId]={function:t.name,abs_path:typeof t.resourceId==`number`?e.resources[t.resourceId]:void 0,lineno:t.line,colno:t.column}),s=s.parentId===void 0?void 0:e.stacks[s.parentId]}let u={elapsed_since_start_ns:((i.timestamp+c-a)*VV).toFixed(0),stack_id:n,thread_id:HV};r.stacks[n]=l,r.samples[o]=u,n++}),r}function tze(e,t){if(!t.length)return e;for(let n of t)e[1].push([{type:`profile`},n]);return e}function nze(e){let t=[];return OD(e,(e,n)=>{if(n===`transaction`)for(let n=1;n<e.length;n++)e[n]?.contexts?.profile?.profile_id&&t.push(e[n])}),t}function QV(e){let t=q()?.getOptions()?.stackParser;return t?UTe(t,e):[]}function $V(e){return typeof e!=`number`&&typeof e!=`boolean`||typeof e==`number`&&isNaN(e)?(Y&&G.warn(`[Profiling] Invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(e)} of type ${JSON.stringify(typeof e)}.`),!1):e===!0||e===!1?!0:e<0||e>1?(Y&&G.warn(`[Profiling] Invalid sample rate. Sample rate must be between 0 and 1. Got ${e}.`),!1):!0}function rze(e){return e.samples.length<2?(Y&&G.log(`[Profiling] Discarding profile because it contains less than 2 samples`),!1):e.frames.length?!0:(Y&&G.log(`[Profiling] Discarding profile because it contains no frames`),!1)}var eH=!1,tH=3e4;function ize(e){return typeof e==`function`}function nH(){let e=J.Profiler;if(!ize(e)){Y&&G.log(`[Profiling] Profiling is not supported by this browser, Profiler interface missing on window object.`);return}let t=Math.floor(tH/10);try{return new e({sampleInterval:10,maxBufferSize:t})}catch{Y&&(G.log(`[Profiling] Failed to initialize the Profiling constructor, this is likely due to a missing 'Document-Policy': 'js-profiling' header.`),G.log(`[Profiling] Disabling profiling for current user session.`)),eH=!0}}function rH(e){if(eH)return Y&&G.log(`[Profiling] Profiling has been disabled for the duration of the current user session.`),!1;if(!e.isRecording())return Y&&G.log(`[Profiling] Discarding profile because root span was not sampled.`),!1;let t=q()?.getOptions();if(!t)return Y&&G.log(`[Profiling] Profiling disabled, no options found.`),!1;let n=t.profilesSampleRate;return $V(n)?n?n===!0||Math.random()<n||(Y&&G.log(`[Profiling] Discarding profile because it's not included in the random sample (sampling rate = ${Number(n)})`),!1):(Y&&G.log(`[Profiling] Discarding profile because a negative sampling decision was inherited or profileSampleRate is set to 0`),!1):(Y&&G.warn(`[Profiling] Discarding profile because of invalid sample rate.`),!1)}function aze(e){if(eH)return Y&&G.log(`[Profiling] Profiling has been disabled for the duration of the current user session as the JS Profiler could not be started.`),!1;if(e.profileLifecycle!==`trace`&&e.profileLifecycle!==`manual`)return Y&&G.warn("[Profiling] Session not sampled. Invalid `profileLifecycle` option."),!1;let t=e.profileSessionSampleRate;return $V(t)?t?Math.random()<=t:(Y&&G.log(`[Profiling] Discarding profile because profileSessionSampleRate is not defined or set to 0`),!1):(Y&&G.warn(`[Profiling] Discarding profile because of invalid profileSessionSampleRate.`),!1)}function iH(e){return e.profilesSampleRate!==void 0}function oze(e,t,n,r){return rze(n)?XRe(e,t,n,r):null}var aH=new Map;function sze(){return aH.size}function cze(e){let t=aH.get(e);return t&&aH.delete(e),t}function lze(e,t){if(aH.set(e,t),aH.size>30){let e=aH.keys().next().value;e!==void 0&&aH.delete(e)}}var oH=new WeakSet;function sH(e){e.setAttribute(`thread.id`,HV),e.setAttribute(`thread.name`,UV)}function cH(e){let t;ZV(e)&&(t=RT()*1e3);let n=nH();if(!n)return;Y&&G.log(`[Profiling] started profiling span: ${JE(e).description}`);let r=AT(),i=null;K().setContext(`profile`,{profile_id:r,start_timestamp:t}),oH.add(e),sH(e);async function a(){if(e&&n){if(i){Y&&G.log(`[Profiling] profile for:`,JE(e).description,`already exists, returning early`);return}return n.stop().then(t=>{if(o&&=(J.clearTimeout(o),void 0),Y&&G.log(`[Profiling] stopped profiling of span: ${JE(e).description}`),!t){Y&&G.log(`[Profiling] profiler returned null profile for: ${JE(e).description}`,`this may indicate an overlapping span or a call to stopProfiling with a profile title that was never started`);return}i=t,lze(r,t)}).catch(e=>{Y&&G.log(`[Profiling] error while stopping profiler:`,e)})}}let o=J.setTimeout(()=>{Y&&G.log(`[Profiling] max profile duration elapsed, stopping profiling for:`,JE(e).description),a()},tH),s=e.end.bind(e);function c(){return e?(a().then(()=>{s()},()=>{s()}),e):s()}e.end=c}var uze=6e4,dze=3e5,fze=class{constructor(){this._client=void 0,this._profiler=void 0,this._chunkTimer=void 0,this._profilerId=void 0,this._isRunning=!1,this._sessionSampled=!1,this._lifecycleMode=void 0,this._activeRootSpanIds=new Set,this._rootSpanTimeouts=new Map}initialize(e){let t=e.getOptions().profileLifecycle,n=aze(e.getOptions());Y&&G.log(`[Profiling] Initializing profiler (lifecycle='${t}').`),n||Y&&G.log(`[Profiling] Session not sampled. Skipping lifecycle profiler initialization.`),this._profilerId=AT(),this._client=e,this._sessionSampled=n,this._lifecycleMode=t,t===`trace`&&this._setupTraceLifecycleListeners(e),e.on(`spanStart`,e=>{this._isRunning&&sH(e)})}start(){if(this._lifecycleMode===`trace`){Y&&G.warn('[Profiling] `profileLifecycle` is set to "trace". Calls to `uiProfiler.start()` are ignored in trace mode.');return}if(this._isRunning){Y&&G.warn("[Profiling] Profile session is already running, `uiProfiler.start()` is a no-op.");return}if(!this._sessionSampled){Y&&G.warn("[Profiling] Session is not sampled, `uiProfiler.start()` is a no-op.");return}this._beginProfiling()}stop(){if(this._lifecycleMode===`trace`){Y&&G.warn('[Profiling] `profileLifecycle` is set to "trace". Calls to `uiProfiler.stop()` are ignored in trace mode.');return}if(!this._isRunning){Y&&G.warn("[Profiling] Profiler is not running, `uiProfiler.stop()` is a no-op.");return}this._endProfiling()}notifyRootSpanActive(e){if(this._lifecycleMode!==`trace`||!this._sessionSampled)return;let t=e.spanContext().spanId;if(!t||this._activeRootSpanIds.has(t))return;this._registerTraceRootSpan(t);let n=this._activeRootSpanIds.size;n===1&&(Y&&G.log(`[Profiling] Detected already active root span during setup. Active root spans now:`,n),this._beginProfiling()),this._isRunning&&sH(e)}_beginProfiling(){if(!this._isRunning){if(this._isRunning=!0,Y&&G.log(`[Profiling] Started profiling with profiler ID:`,this._profilerId),cE().setContext(`profile`,{profiler_id:this._profilerId}),this._startProfilerInstance(),!this._profiler){Y&&G.log(`[Profiling] Failed to start JS Profiler; stopping.`),this._resetProfilerInfo();return}this._startPeriodicChunking()}}_endProfiling(){this._isRunning&&(this._isRunning=!1,this._chunkTimer&&=(clearTimeout(this._chunkTimer),void 0),this._clearAllRootSpanTimeouts(),this._collectCurrentChunk().catch(e=>{Y&&G.error("[Profiling] Failed to collect current profile chunk on `stop()`:",e)}),this._lifecycleMode===`manual`&&cE().setContext(`profile`,{}))}_setupTraceLifecycleListeners(e){e.on(`spanStart`,e=>{if(!this._sessionSampled){Y&&G.log(`[Profiling] Span not profiled because of negative sampling decision for user session.`);return}if(e!==cD(e))return;if(!e.isRecording()){Y&&G.log(`[Profiling] Discarding profile because root span was not sampled.`);return}let t=e.spanContext().spanId;if(!t||this._activeRootSpanIds.has(t))return;this._registerTraceRootSpan(t);let n=this._activeRootSpanIds.size;n===1&&(Y&&G.log(`[Profiling] Root span ${t} started. Profiling active while there are active root spans (count=${n}).`),this._beginProfiling())}),e.on(`spanEnd`,e=>{if(!this._sessionSampled)return;let t=e.spanContext().spanId;if(!t||!this._activeRootSpanIds.has(t))return;this._activeRootSpanIds.delete(t);let n=this._activeRootSpanIds.size;Y&&G.log(`[Profiling] Root span with ID ${t} ended. Will continue profiling for as long as there are active root spans (currently: ${n}).`),n===0&&(this._collectCurrentChunk().catch(e=>{Y&&G.error("[Profiling] Failed to collect current profile chunk on last `spanEnd`:",e)}),this._endProfiling())})}_resetProfilerInfo(){this._isRunning=!1,cE().setContext(`profile`,{})}_clearAllRootSpanTimeouts(){this._rootSpanTimeouts.forEach(e=>clearTimeout(e)),this._rootSpanTimeouts.clear()}_registerTraceRootSpan(e){this._activeRootSpanIds.add(e);let t=setTimeout(()=>this._onRootSpanTimeout(e),dze);this._rootSpanTimeouts.set(e,t)}_startProfilerInstance(){if(this._profiler?.stopped===!1)return;let e=nH();if(!e){Y&&G.log(`[Profiling] Failed to start JS Profiler.`);return}this._profiler=e}_startPeriodicChunking(){this._isRunning&&(this._chunkTimer=setTimeout(()=>{if(this._collectCurrentChunk().catch(e=>{Y&&G.error(`[Profiling] Failed to collect current profile chunk during periodic chunking:`,e)}),this._isRunning){if(this._startProfilerInstance(),!this._profiler){this._resetProfilerInfo();return}this._startPeriodicChunking()}},uze))}_onRootSpanTimeout(e){this._rootSpanTimeouts.has(e)&&(this._rootSpanTimeouts.delete(e),this._activeRootSpanIds.has(e)&&(Y&&G.log(`[Profiling] Reached 5-minute timeout for root span ${e}. You likely started a manual root span that never called \`.end()\`.`),this._activeRootSpanIds.delete(e),this._activeRootSpanIds.size===0&&this._endProfiling()))}async _collectCurrentChunk(){let e=this._profiler;if(this._profiler=void 0,e)try{let t=ZRe(await e.stop(),this._client,this._profilerId),n=QRe(t);if(`reason`in n){Y&&G.log(`[Profiling] Discarding invalid profile chunk (this is probably a bug in the SDK):`,n.reason);return}this._sendProfileChunk(t),Y&&G.log(`[Profiling] Collected browser profile chunk.`)}catch(e){Y&&G.log(`[Profiling] Error while stopping JS Profiler for chunk:`,e)}}_sendProfileChunk(e){let t=this._client,n=ND(t.getSdkMetadata?.()),r=t.getDsn(),i=t.getOptions().tunnel,a=ED({event_id:AT(),sent_at:new Date().toISOString(),...n&&{sdk:n},...!!i&&r&&{dsn:NE(r)}},[[{type:`profile_chunk`,platform:`javascript`},e]]);t.sendEnvelope(a).then(null,e=>{Y&&G.error(`Error while sending profile chunk envelope:`,e)})}},pze=`BrowserProfiling`,mze=qO((()=>({name:pze,setup(e){let t=e.getOptions(),n=new fze;if(!iH(t)&&!t.profileLifecycle&&(t.profileLifecycle=`manual`),iH(t)&&!t.profilesSampleRate){Y&&G.log(`[Profiling] Profiling disabled, no profiling options found.`);return}let r=uD(),i=r&&cD(r);if(iH(t)&&t.profileSessionSampleRate!==void 0&&Y&&G.warn("[Profiling] Both legacy profiling (`profilesSampleRate`) and UI profiling settings are defined. `profileSessionSampleRate` has no effect when legacy profiling is enabled."),iH(t))i&&ZV(i)&&rH(i)&&cH(i),e.on(`spanStart`,e=>{let t=cD(e);e===t?rH(e)&&cH(e):oH.has(t)&&sH(e)}),e.on(`beforeEnvelope`,e=>{if(!sze())return;let t=nze(e);if(!t.length)return;let n=[];for(let e of t){let t=e?.contexts,r=t?.profile?.profile_id,i=t?.profile?.start_timestamp;if(typeof r!=`string`){Y&&G.log(`[Profiling] cannot find profile for a span without a profile context`);continue}if(!r){Y&&G.log(`[Profiling] cannot find profile for a span without a profile context`);continue}t?.profile&&delete t.profile;let a=cze(r);if(!a){Y&&G.log(`[Profiling] Could not retrieve profile for span: ${r}`);continue}let o=oze(r,i,a,e);o&&n.push(o)}tze(e,n)});else{let r=t.profileLifecycle;if(e.on(`startUIProfiler`,()=>n.start()),e.on(`stopUIProfiler`,()=>n.stop()),r===`manual`)n.initialize(e);else if(r===`trace`){if(!mD(t)){Y&&G.warn("[Profiling] `profileLifecycle` is 'trace' but tracing is disabled. Set a `tracesSampleRate` or `tracesSampler` to enable span tracing.");return}n.initialize(e),i&&n.notifyRootSpanActive(i),J.setTimeout(()=>{let e=uD(),t=e&&cD(e);t&&n.notifyRootSpanActive(t)},0)}}}}))),hze=`SpotlightBrowser`,gze=[{op:`ui.interaction.click`,name:`#sentry-spotlight`}],_ze=((e={})=>{let t=e.sidecarUrl||`http://localhost:8969/stream`;return{name:hze,setup:()=>{Y&&G.log(`Using Sidecar URL`,t)},beforeSetup(e){let t=e.getOptions();t.ignoreSpans=[...t.ignoreSpans||[],...gze]},afterAllSetup:e=>{vze(e,t)}}});function vze(e,t){let n=fL(`fetch`),r=0;e.on(`beforeEnvelope`,e=>{if(r>3){G.warn(`[Spotlight] Disabled Sentry -> Spotlight integration due to too many failed requests:`,r);return}n(t,{method:`POST`,body:AD(e),headers:{"Content-Type":`application/x-sentry-envelope`},mode:`cors`}).then(e=>{e.status>=200&&e.status<400&&(r=0)},e=>{r++,G.error(`Sentry SDK can't connect to Sidecar is it running? See: https://spotlightjs.com/sidecar/npx/`,e)})})}var yze=qO(_ze),bze=qO(()=>({name:`LaunchDarkly`,processEvent(e,t,n){return OA(e)}}));function xze(){return{name:`sentry-flag-auditor`,type:`flag-used`,synchronous:!0,method:(e,t,n)=>{kA(e,t.value),AA(e,t.value)}}}var Sze=qO(()=>({name:`OpenFeature`,processEvent(e,t,n){return OA(e)}})),Cze=class{after(e,t){kA(t.flagKey,t.value),AA(t.flagKey,t.value)}error(e,t,n){kA(e.flagKey,e.defaultValue),AA(e.flagKey,e.defaultValue)}},wze=qO(({featureFlagClientClass:e})=>({name:`Unleash`,setupOnce(){let t=e.prototype;sT(t,`isEnabled`,Tze)},processEvent(e,t,n){return OA(e)}}));function Tze(e){return function(...t){let n=t[0],r=e.apply(this,t);return typeof n==`string`&&typeof r==`boolean`?(kA(n,r),AA(n,r)):Y&&G.error(`[Feature Flags] UnleashClient.isEnabled does not match expected signature. arg0: ${n} (${typeof n}), result: ${r} (${typeof r})`),r}}var Eze=(({growthbookClass:e})=>vOe({growthbookClass:e})),Dze=qO(({featureFlagClient:e})=>({name:`Statsig`,setup(t){e.on(`gate_evaluation`,e=>{kA(e.gate.name,e.gate.value),AA(e.gate.name,e.gate.value)})},processEvent(e,t,n){return OA(e)}})),Oze=`WebWorker`,kze=qO(({worker:e})=>({name:Oze,setupOnce:()=>{(Array.isArray(e)?e:[e]).forEach(e=>lH(e))},addWorker:e=>lH(e)}));function lH(e){e.addEventListener(`message`,e=>{if(Mze(e.data)){if(e.stopImmediatePropagation(),e.data._sentryDebugIds&&(Y&&G.log(`Sentry debugId web worker message received`,e.data),J._sentryDebugIds={...e.data._sentryDebugIds,...J._sentryDebugIds}),e.data._sentryModuleMetadata&&(Y&&G.log(`Sentry module metadata web worker message received`,e.data),J._sentryModuleMetadata={...e.data._sentryModuleMetadata,...J._sentryModuleMetadata}),e.data._sentryWasmImages){Y&&G.log(`Sentry WASM images web worker message received`,e.data);let t=J._sentryWasmImages||[],n=e.data._sentryWasmImages.filter(e=>tT(e)&&typeof e.code_file==`string`&&!t.some(t=>t.code_file===e.code_file));J._sentryWasmImages=[...t,...n]}e.data._sentryWorkerError&&(Y&&G.log(`Sentry worker rejection message received`,e.data._sentryWorkerError),Aze(e.data._sentryWorkerError))}})}function Aze(e){let t=q();if(!t)return;let n=t.getOptions().stackParser,r=t.getOptions().attachStacktrace,i=e.reason,a=eT(i)?jL(i):GF(n,i,void 0,r,!0);a.level=`error`,e.filename&&(a.contexts={...a.contexts,worker:{filename:e.filename}}),jO(a,{originalException:i,mechanism:{handled:!1,type:`auto.browser.web_worker.onunhandledrejection`}}),Y&&G.log(`Captured worker unhandled rejection`,i)}function jze({self:e}){e.postMessage({_sentryMessage:!0,_sentryDebugIds:e._sentryDebugIds??void 0,_sentryModuleMetadata:e._sentryModuleMetadata??void 0}),e.addEventListener(`unhandledrejection`,t=>{let n={reason:AL(t),filename:e.location?.href};e.postMessage({_sentryMessage:!0,_sentryWorkerError:n}),Y&&G.log(`[Sentry Worker] Forwarding unhandled rejection to parent`,n)}),Y&&G.log(`[Sentry Worker] Registered worker with unhandled rejection handling`)}function Mze(e){if(!tT(e)||e._sentryMessage!==!0)return!1;let t=`_sentryDebugIds`in e,n=`_sentryModuleMetadata`in e,r=`_sentryWorkerError`in e,i=`_sentryWasmImages`in e;return!(!t&&!n&&!r&&!i||t&&!(tT(e._sentryDebugIds)||e._sentryDebugIds===void 0)||n&&!(tT(e._sentryModuleMetadata)||e._sentryModuleMetadata===void 0)||r&&!tT(e._sentryWorkerError)||i&&(!Array.isArray(e._sentryWasmImages)||!e._sentryWasmImages.every(e=>tT(e)&&typeof e.code_file==`string`)))}var Nze=50,[,Pze]=xL,[,Fze]=bN(),uH=(e,t=0)=>{let n=[];for(let r of e.split(`
1004
1004
  `).slice(t)){let e=Pze(r),t=Fze(r);if(e&&t?.in_app!==!1?n.push(e):t&&(t.module===void 0&&delete t.module,n.push(t)),n.length>=Nze)break}return Mw(n)},Ize=qO(e=>{let t=e?.threshold??1e3,n=e?.pollInterval||t/2;return{name:`EventLoopBlockRenderer`,setup(r){let i={pollInterval:n,anrThreshold:t,captureStackTrace:!0,...e},a=jN(r);a.sendStatus({status:document.visibilityState,config:i}),setInterval(()=>{a.sendStatus({status:`alive`,config:i})},i.pollInterval)}}});function dH(){let e=cE().getScopeData(),t=sE().getScopeData(),n=K().getScopeData();return fO(e,t),fO(e,n),e.eventProcessors=[],e}function Lze(e){sE().addScopeListener(t=>{e(dH(),t)}),K().addScopeListener(t=>{e(dH(),t)}),cE().addScopeListener(t=>{e(dH(),t)})}var fH=qO(()=>({name:`ScopeToMain`,setup(e){let t=jN(e);Lze((e,n)=>{t.sendScope(JSON.stringify(yT(e,20,2e3))),n.clearBreadcrumbs(),n.clearAttachments()})}}));function pH(e){let t;return mk(e,async e=>(t||=jN(),t.sendEnvelope(e.body),{statusCode:200}))}function mH(e){return[...LL(e).filter(e=>e.name!==`BrowserSession`&&e.name!==`CultureContext`),fH()]}function hH(e={},t=zNe){if(window?.__SENTRY__RENDERER_INIT__){G.warn(`The browser SDK has already been initialized.
1005
- If init has been called in the preload and contextIsolation is disabled, is not required to call init in the renderer`);return}window.__SENTRY__RENDERER_INIT__=!0,e.sendClientReports=!1,e.defaultIntegrations===void 0&&(e.defaultIntegrations=mH(e)),e.stackParser===void 0&&(e.stackParser=uH),e.ipcNamespace===void 0&&(e.ipcNamespace=`sentry-ipc`),e.dsn===void 0&&(e.dsn=`https://12345@dummy.dsn/12345`),e.transport===void 0&&(e.transport=pH),delete e.initialScope,t(e)}var gH=e({BrowserClient:()=>qF,MULTIPLEXED_TRANSPORT_EXTRA_KEY:()=>ZEe,OpenFeatureIntegrationHook:()=>Cze,SEMANTIC_ATTRIBUTE_SENTRY_OP:()=>pE,SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN:()=>mE,SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE:()=>fE,SEMANTIC_ATTRIBUTE_SENTRY_SOURCE:()=>dE,Scope:()=>XT,addBreadcrumb:()=>qk,addEventProcessor:()=>IO,addIntegration:()=>KO,bindScopeToEmitter:()=>TTe,breadcrumbsIntegration:()=>wL,browserApiErrorsIntegration:()=>TL,browserProfilingIntegration:()=>mze,browserSessionIntegration:()=>DL,browserTracingIntegration:()=>MV,buildLaunchDarklyFlagUsedHandler:()=>xze,captureConsoleIntegration:()=>EDe,captureEvent:()=>jO,captureException:()=>kO,captureFeedback:()=>PA,captureMessage:()=>AO,captureSession:()=>BO,chromeStackLineParser:()=>xL,consoleLoggingIntegration:()=>AOe,contextLinesIntegration:()=>iPe,continueTrace:()=>fTe,createConsolaReporter:()=>NOe,createLangChainCallbackHandler:()=>OM,createTransport:()=>mk,createUserFeedbackEnvelope:()=>cNe,dedupeIntegration:()=>pA,defaultRequestInstrumentationOptions:()=>SV,defaultStackParser:()=>uH,elementTimingIntegration:()=>CMe,endSession:()=>RO,eventFiltersIntegration:()=>Xk,eventFromException:()=>UF,eventFromMessage:()=>WF,eventLoopBlockIntegration:()=>Ize,exceptionFromError:()=>zF,extraErrorDataIntegration:()=>NDe,featureFlagsIntegration:()=>_Oe,feedbackAsyncIntegration:()=>oje,feedbackIntegration:()=>RF,feedbackSyncIntegration:()=>RF,fetchStreamPerformanceIntegration:()=>DV,forceLoad:()=>BNe,functionToStringIntegration:()=>Yk,getAbsoluteUrl:()=>qMe,getActiveSpan:()=>uD,getClient:()=>q,getCurrentScope:()=>K,getDefaultIntegrations:()=>mH,getFeedback:()=>pAe,getGlobalScope:()=>cE,getIsolationScope:()=>sE,getReplay:()=>eRe,getRootSpan:()=>cD,getSpanDescendants:()=>sD,getSpanStatusFromHttpCode:()=>xE,getTraceData:()=>Kk,globalHandlersIntegration:()=>kL,graphqlClientIntegration:()=>fPe,growthbookIntegration:()=>Eze,httpClientIntegration:()=>KNe,httpContextIntegration:()=>PL,inboundFiltersIntegration:()=>Zk,init:()=>hH,instrumentAnthropicAiClient:()=>Yke,instrumentCreateReactAgent:()=>JM,instrumentGoogleGenAIClient:()=>aM,instrumentLangChainEmbeddings:()=>NM,instrumentLangGraph:()=>YM,instrumentOpenAiClient:()=>Ake,instrumentOutgoingRequests:()=>CV,instrumentSupabaseClient:()=>TA,isBotUserAgent:()=>jV,isEnabled:()=>FO,isInitialized:()=>sEe,lastEventId:()=>PO,launchDarklyIntegration:()=>bze,linkedErrorsIntegration:()=>FL,logger:()=>MN,makeRendererTransport:()=>pH,metrics:()=>BN,moduleMetadataIntegration:()=>CDe,normalizeStringifyValue:()=>IL,onLoad:()=>VNe,openFeatureIntegration:()=>Sze,parameterize:()=>Gk,registerSpanErrorInstrumentation:()=>pD,registerWebWorker:()=>jze,replayCanvasIntegration:()=>yRe,replayIntegration:()=>KB,reportPageLoaded:()=>VRe,reportingObserverIntegration:()=>WNe,rewriteFramesIntegration:()=>VDe,scopeToMainIntegration:()=>fH,sendFeedback:()=>hP,setActiveSpanInBrowser:()=>HRe,setAttribute:()=>aEe,setAttributes:()=>iEe,setContext:()=>MO,setConversationId:()=>oEe,setCurrentClient:()=>Nk,setExtra:()=>tEe,setExtras:()=>eEe,setHttpStatus:()=>SE,setMeasurement:()=>FD,setTag:()=>rEe,setTags:()=>nEe,setUser:()=>NO,showReportDialog:()=>RL,spanStreamingIntegration:()=>URe,spanToBaggageHeader:()=>Jwe,spanToJSON:()=>JE,spanToTraceHeader:()=>UE,spotlightBrowserIntegration:()=>yze,startBrowserTracingNavigationSpan:()=>PV,startBrowserTracingPageLoadSpan:()=>NV,startInactiveSpan:()=>qD,startNewTrace:()=>XD,startSession:()=>LO,startSpan:()=>GD,startSpanManual:()=>KD,statsigIntegration:()=>Dze,supabaseIntegration:()=>tOe,suppressTracing:()=>pTe,thirdPartyErrorFilterIntegration:()=>uOe,uiProfiler:()=>QMe,unleashIntegration:()=>wze,updateSpanName:()=>Uwe,viewHierarchyIntegration:()=>pPe,webVitalsIntegration:()=>OV,webWorkerIntegration:()=>kze,withActiveSpan:()=>JD,withIsolationScope:()=>fwe,withScope:()=>lE,withStreamedSpan:()=>Ywe,zodErrorsIntegration:()=>lOe}),Rze=100,zze=5,Bze=[`ResizeObserver loop completed with undelivered notifications.`,`ResizeObserver loop limit exceeded`,`AbortError`,`The user aborted a request.`,`Network request failed`,`NetworkError when attempting to fetch resource.`,`Failed to fetch`,`ChunkLoadError`,`Loading chunk`,`Loading CSS chunk`,`Non-Error promise rejection captured with value: Object Not Found Matching Id`];function _H(e){if(e)for(let t of Object.keys(e))/token|secret|password|api[_-]?key/i.test(t)&&(e[t]=`[redacted]`)}function Vze(e){e.request?.url&&(e.request.url=e.request.url.replace(/([?&](?:code|token|access_token|state)=)[^&]+/gi,`$1[redacted]`)),_H(e.extra),_H(e.tags)}function Hze(e){let t=yH(e.version)??`0.0.0`,n=yH(e.commitHash);return n?`${e.appName}@${t}+${n}`:`${e.appName}@${t}`}function vH(e,t){for(let n of t){let t=yH(e[n]);if(t)return t}}function Uze(e){return bH(e.enabled)??e.defaultEnabled??!1}function Wze(e){let t=yH(e.dsn);return!t||Uze(e)===!1?null:{dsn:t,environment:yH(e.environment)??yH(e.defaultEnvironment)??`production`,release:yH(e.release)??yH(e.defaultRelease)??void 0,debug:bH(e.debug)??e.defaultDebug??!1,tracesSampleRate:SH(e.tracesSampleRate,e.defaultTracesSampleRate??.1),profilesSampleRate:xH(e.profilesSampleRate,e.defaultProfilesSampleRate),replaysSessionSampleRate:xH(e.replaysSessionSampleRate,e.defaultReplaysSessionSampleRate),replaysOnErrorSampleRate:xH(e.replaysOnErrorSampleRate,e.defaultReplaysOnErrorSampleRate),attachStacktrace:!0,maxBreadcrumbs:Rze,normalizeDepth:zze,tags:Gze(e)}}function Gze(e){let t={app:e.appName,runtime:e.runtime};for(let[n,r]of Object.entries(e.tags??{})){let e=yH(r);e&&(t[n]=e)}return t}function yH(e){if(e==null)return null;let t=e.trim();return t.length>0?t:null}function bH(e){if(typeof e==`boolean`)return e;let t=yH(e);if(t){if(t===`1`||t.toLowerCase()===`true`)return!0;if(t===`0`||t.toLowerCase()===`false`)return!1}}function xH(e,t){if(t!==void 0||e!==void 0)return SH(e,t??0)}function SH(e,t){let n=Kze(e);return n===null||n<0||n>1?t:n}function Kze(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;let t=yH(e);if(!t)return null;let n=Number.parseFloat(t);return Number.isFinite(n)?n:null}function qze(e){let t=(0,hi.c)(11),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=pt(Ei,`bg-background text-foreground`),t[0]=n):n=t[0];let r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=pt(wi,`pl-1 md:pl-2.5`),t[1]=r):r=t[1];let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,N.jsx)(Oi,{}),t[2]=i):i=t[2];let a;t[3]===e.onGoToNewChat?a=t[4]:(a=(0,N.jsx)(`div`,{className:r,children:(0,N.jsx)(`button`,{type:`button`,"aria-label":`Go to new chat`,onClick:e.onGoToNewChat,className:`${Ti} hover:bg-accent/70`,children:i})}),t[3]=e.onGoToNewChat,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,N.jsx)(`div`,{}),t[5]=o):o=t[5];let s;t[6]===a?s=t[7]:(s=(0,N.jsxs)(`header`,{className:Ci,children:[a,o]}),t[6]=a,t[7]=s);let c;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,N.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-4`,children:(0,N.jsxs)(`div`,{className:`max-w-md rounded-xl border border-border bg-card p-6 text-center shadow-lg`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Something went wrong.`}),(0,N.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Forge hit an unexpected error and reported it.`}),(0,N.jsx)(`button`,{className:`mt-4 inline-flex rounded-md border border-border px-3 py-2 text-sm font-medium hover:bg-accent`,onClick:Jze,type:`button`,children:`Reload app`})]})}),t[8]=c):c=t[8];let l;return t[9]===s?l=t[10]:(l=(0,N.jsxs)(`div`,{className:n,children:[s,c]}),t[9]=s,t[10]=l),l}function Jze(){return window.location.reload()}var Yze=[/\bDeepSeek\b/i,/\bKimi\b/i,/\bMoonshot\b/i,/\bdeepseek[-._a-z0-9]*\b/i,/\bkimi[-._a-z0-9]*\b/i,/\bmoonshot[-._a-z0-9]*\b/i,/\bAPEX_API_KEY\b/,/\bDEEPSEEK_API_KEY\b/,/\bKIMI_API_KEY\b/,/\bOPENAI_API_KEY\b/,/\bANTHROPIC_API_KEY\b/,/\bCURSOR_API_KEY\b/,/\bOPENCODE_API_KEY\b/,/\bforge_proxy_[A-Za-z0-9._-]+\b/,/\bProviderValidationError\b/,/\/forge-server\/node_modules\//,/https?:\/\/[^\s'"<>)]*\/api\/provider-egress\/[^\s'"<>)]*/i,/https?:\/\/[^\s'"<>)]*(?:apex|deepseek|moonshot|kimi)[^\s'"<>)]*/i],Xze=`CMMD is temporarily unavailable. Check the workspace AI connection and retry.`;function CH(e){if(!e)return!1;let t=e.toLowerCase();return/\b(rate[\s-]?limit|too\s+many\s+requests|usage[ _-]limit|usage_limit_reached|quota|insufficient_quota)\b/.test(t)||/\b429\b/.test(t)}function Zze(e){return/\bbound to provider account\b/.test(e)&&/\bcannot use provider account\b/.test(e)?`Forge could not switch this conversation to the selected AI account. Retry the account switch.`:/\bforge_runtime_repairing\b/.test(e)||/\bthis turn was interrupted because the environment is being repaired\b/.test(e)?`This turn was interrupted because the environment is being repaired. Retry after the repair finishes.`:/\bforge_runtime_stopped\b/.test(e)||/\bthis turn was interrupted because the environment was stopped\b/.test(e)?`This turn was interrupted because the environment was stopped. Start the environment and retry.`:null}function Qze(e){if(!e)return null;let t=e.toLowerCase(),n=Zze(t);return n===null?/\bforge_provider_model_not_allowed\b/.test(t)||/\bnot\s+scoped\s+to\s+the\s+requested\s+model\b/.test(t)?`The workspace AI credential does not cover the model this turn asked for. Retry, or pick that model for the thread.`:/\bmodel\b[\s\S]*\b(not\s+(found|available|supported)|does\s+not\s+exist|unsupported|invalid|unknown)\b/.test(t)||/\b(unsupported|unknown|invalid)\b[\s\S]*\bmodel\b/.test(t)||/\b(model_not_found|invalid_model|model_not_supported)\b/.test(t)?`The selected model isn't available right now. Pick a different model and retry.`:CH(t)?`The AI service is rate-limited or out of quota. Wait a moment and retry.`:/_credential_reconnect_required\b/.test(t)?`The workspace AI credential needs to be reconnected. Reconnect it in Settings > Providers, then retry.`:/\b(unauthorized|forbidden|authentication\s+(failed|error|required)|invalid\s+api\s+key|expired\s+(token|credential))\b/.test(t)||/\b40[13]\b/.test(t)?`Workspace AI authentication failed. Reconnect the workspace and retry.`:/\b(timed?\s*out|timeout|overloaded|service\s+unavailable)\b/.test(t)||/\b50[234]\b/.test(t)?`The AI service is temporarily overloaded. Retry in a moment.`:null:n}function $ze(e){return e?Yze.some(t=>t.test(e)):!1}function wH(e,t={}){if(e==null)return null;let n=e.trim();return n.length===0?null:$ze(n)?Qze(n)??t.fallback??`CMMD is temporarily unavailable. Check the workspace AI connection and retry.`:n}var eBe=[/\bSocketCloseError\b/i,/\bSocketOpenError\b/i,/\bSocketReadError\b/i,/\bRpcClientDefect:\s*Unknown socket error\b/i,/Unable to connect to the Forge server WebSocket\./i,/\bping timeout\b/i];function TH(e){if(typeof e!=`string`)return!1;let t=e.trim();return t.length!==0&&eBe.some(e=>e.test(t))}function EH(e){return TH(e)?null:wH(e,{fallback:Xze})}var tBe=[/^Transport disposed$/,/WebSocket RPC request timed out after \d+ms\./],nBe=`Lost the connection to this Environment. Your message was not sent.`;function rBe(e){return e instanceof Error?TH(e.message)||tBe.some(t=>t.test(e.message.trim()))?nBe:e.message:`Failed to send message.`}var DH=`forge-web`,OH=[`VITE_SENTRY_ENVIRONMENT`,`MODE`],kH=[`VITE_SENTRY_RELEASE`],iBe=[`VITE_SENTRY_DSN`],aBe=[`VITE_SENTRY_DEBUG`],oBe=[`VITE_SENTRY_ENABLED`],sBe=[`VITE_SENTRY_TRACES_SAMPLE_RATE`],cBe=[`VITE_SENTRY_PROFILES_SAMPLE_RATE`],lBe=[`VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE`],uBe=[`VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE`],dBe=[`VITE_SENTRY_COMMIT_SHA`,`VITE_COMMIT_SHA`],AH=!1,jH={autoInject:!1,colorScheme:`system`,formTitle:`Report a Bug`,themeLight:{accentBackground:`oklch(0.52 0.19 48)`,accentForeground:`#ffffff`,background:`#ffffff`,boxShadow:`0 24px 80px rgba(0, 0, 0, 0.18)`,foreground:`#262626`,outline:`1px solid oklch(0.52 0.19 48)`},themeDark:{accentBackground:`oklch(0.62 0.2 47)`,accentForeground:`#ffffff`,background:`#171717`,boxShadow:`0 24px 80px rgba(0, 0, 0, 0.45)`,foreground:`#f5f5f5`,outline:`1px solid oklch(0.62 0.2 47)`}};function fBe(e){let t=e.exception&&typeof e.exception==`object`&&`values`in e.exception&&Array.isArray(e.exception.values)?e.exception.values:[];return[typeof e.title==`string`?e.title:void 0,...t.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e;return[typeof t.type==`string`?t.type:void 0,typeof t.value==`string`?t.value:void 0]})]}function pBe(e){return(e.exception&&typeof e.exception==`object`&&`values`in e.exception&&Array.isArray(e.exception.values)?e.exception.values:[]).some(e=>{if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.value!=`string`||!/All fibers interrupted without error/i.test(t.value)?!1:t.stacktrace?.frames?.some(e=>{let t=typeof e.filename==`string`?e.filename:``,n=typeof e.function==`string`?e.function:``;return t.includes(`src/rpc/wsTransport.ts`)&&n===`WsTransport.request`})})}function mBe(e){return fBe(e).some(TH)||pBe(e)}function hBe(){let e=new URL(window.location.href);Rn?e.hash=`/new`:(e.pathname=`/new`,e.search=``,e.hash=``),window.location.assign(e.toString())}function gBe(){let e=Rn?`electron-renderer`:`browser`,t={APP_VERSION:`0.13.4`,BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`,VITE_COMMIT_SHA:``,VITE_HOSTED_APP_CHANNEL:``,VITE_HTTP_URL:``,VITE_SENTRY_COMMIT_SHA:`88bc45ce168df8c9acf36ad6734d8a66bcb353ec`,VITE_SENTRY_DEBUG:``,VITE_SENTRY_DSN:``,VITE_SENTRY_ENABLED:``,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_PROFILES_SAMPLE_RATE:``,VITE_SENTRY_RELEASE:`forge-web@0.13.4+88bc45ce168df8c9acf36ad6734d8a66bcb353ec`,VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE:``,VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE:``,VITE_SENTRY_TRACES_SAMPLE_RATE:``,VITE_WS_URL:``},n=vH(t,[...kH])??Hze({appName:DH,version:`0.13.4`,commitHash:vH(t,[...dBe])});return Wze({appName:DH,runtime:e,defaultEnvironment:vH(t,[...OH])??`development`,defaultRelease:n,defaultEnabled:!0,defaultTracesSampleRate:0,defaultReplaysSessionSampleRate:0,defaultReplaysOnErrorSampleRate:0,enabled:vH(t,[...oBe]),dsn:vH(t,[...iBe]),environment:vH(t,[...OH]),release:vH(t,[...kH]),debug:vH(t,[...aBe]),tracesSampleRate:vH(t,[...sBe]),profilesSampleRate:vH(t,[...cBe]),replaysSessionSampleRate:vH(t,[...lBe]),replaysOnErrorSampleRate:vH(t,[...uBe]),tags:{platform:Rn?`desktop`:`web`}})}function MH(e){return Vze(e),mBe(e)?null:e}function _Be(e){return{...e.replaysOnErrorSampleRate===void 0?{}:{replaysOnErrorSampleRate:e.replaysOnErrorSampleRate},...e.replaysSessionSampleRate===void 0?{}:{replaysSessionSampleRate:e.replaysSessionSampleRate}}}function NH(e){return{attachStacktrace:e.attachStacktrace,debug:e.debug,dsn:e.dsn,environment:e.environment,ignoreErrors:[...Bze],initialScope:{tags:e.tags},maxBreadcrumbs:e.maxBreadcrumbs,normalizeDepth:e.normalizeDepth,sendDefaultPii:!1,tracesSampleRate:e.tracesSampleRate,...e.release===void 0?{}:{release:e.release},..._Be(e)}}function vBe(e){let t=[];e.tracesSampleRate>0&&t.push(MV()),((e.replaysSessionSampleRate??0)>0||(e.replaysOnErrorSampleRate??0)>0)&&t.push(KB());let n=RF(jH);t.push(n);try{hH({...NH(e),beforeSend:e=>MH(e),integrations:t})}catch{return null}return AH=!0,gH}function yBe(e){let t=[];e.tracesSampleRate>0&&t.push(lS()),((e.replaysSessionSampleRate??0)>0||(e.replaysOnErrorSampleRate??0)>0)&&t.push(dx());let n=Bh(jH);t.push(n);try{US({...NH(e),beforeSend:e=>MH(e),integrations:t})}catch{return null}return AH=!0,_w}function PH(){if(AH)return Rn?gH:_w;let e=gBe();return e?Rn?vBe(e):yBe(e):null}function FH(e){if(PH()){if(Rn){NO(e);return}Zl(e)}}function IH(e,t,n){if(!PH())return;let r=bBe(e);if(Rn){lE(e=>{t&&e.setTags(t);let i=kO(r);n?.showReportDialog&&RL({eventId:i})});return}ts(e=>{t&&e.setTags(t);let i=Vl(r);n?.showReportDialog&&q_({eventId:i})})}function bBe(e){if(e instanceof Error)return e;if(typeof e==`string`&&e.trim().length>0)return Error(e);try{return Error(JSON.stringify(e))}catch{return Error(`Unknown non-Error exception`)}}var xBe=class extends M.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){IH(e,{origin:`react-boundary`},{showReportDialog:!0})}render(){return this.state.hasError?(0,N.jsx)(qze,{onGoToNewChat:hBe}):this.props.children}},LH=!1,RH=!1,zH=null,BH=null,VH=null,HH=!1,UH=new Set;function SBe(e){if(LH||RH)return;if(!e.publicKey||!e.host){RH=!0;return}if(zH)return;if(typeof window>`u`||typeof location>`u`){RH=!0;return}let t=e.publicKey,n=e.host;zH=A(async()=>{let{default:e}=await import(`./module-CPO4cjSm.js`);return{default:e}},[]).then(({default:e})=>{BH=e,e.init(t,{api_host:n,person_profiles:`identified_only`,capture_pageview:!1,capture_pageleave:!1,autocapture:!1,disable_session_recording:!0,loaded:()=>{LH=!0,VH&&WH(VH),GH(),UH.forEach(e=>e())}})}).catch(()=>{RH=!0,BH=null})}function WH(e){if(VH=e,!LH||!BH)return;let t={};e.email!==void 0&&(t.email=e.email),e.displayName!==void 0&&(t.name=e.displayName),BH.identify(e.cmmdUserId,t)}function CBe(e){return!LH||!BH?!1:BH.isFeatureEnabled(e)===!0}function GH(){!BH||HH||(HH=!0,BH.onFeatureFlags(()=>{UH.forEach(e=>e())}))}function wBe(e){return UH.add(e),LH&&BH&&(GH(),e()),()=>{UH.delete(e)}}var KH=`/api/cmmd/auth-runtime`;function TBe(e){return j({method:`POST`,path:KH},e)}function EBe(e){return j({method:`GET`,path:KH},e)}function DBe(e){return j({method:`DELETE`,path:KH},e)}function OBe(e){return j({method:`POST`,path:`${KH}/connect`},e)}function kBe(e,t){return j({method:`GET`,path:`/api/cmmd/billing`,...t?.organizationId===void 0?{}:{query:{orgId:t.organizationId}}},e)}function ABe(e,t){return j({method:`GET`,path:`/api/cmmd/billing/series`,query:{timeZone:t.timeZone}},e)}var qH=`/api/cmmd/providers/codex/credential`,JH=`/api/cmmd/providers/claude/credential`;function jBe(e){return j({method:`GET`,path:qH},e)}function MBe(e){return j({method:`DELETE`,path:qH},e)}function NBe(e){return j({method:`GET`,path:JH},e)}function PBe(e){return j({method:`DELETE`,path:JH},e)}function FBe(e,t){return j({method:`DELETE`,path:`/api/cmmd/providers/accounts/${encodeURIComponent(String(t))}`},e)}function IBe(e,t,n){return`/api/cmmd/threads/${encodeURIComponent(e)}/${encodeURIComponent(t)}/${encodeURIComponent(n)}/disposition`}function LBe(e,t,n,r,i){return j({method:`PUT`,path:IBe(t,n,r),body:i},e)}function RBe(e){return(t,n,r,i)=>LBe(e,t,n,r,i)}function zBe(e,t,n){return`/api/cmmd/threads/${encodeURIComponent(e)}/${encodeURIComponent(t)}/${encodeURIComponent(n)}/archive`}function BBe(e,t,n,r,i){return j({method:`POST`,path:zBe(t,n,r),body:i},e)}function VBe(e){return(t,n,r,i)=>BBe(e,t,n,r,i)}function HBe(e){return typeof e==`object`&&!!e&&`status`in e&&e.status===409}async function UBe(e){let t={action:e.action,...e.operationId===void 0?{}:{operationId:e.operationId},expectedRevision:e.expectedRevision,force:e.force};try{return await e.submit(t)}catch(n){if(!HBe(n))throw n;let r=await e.refresh();return e.submit({...t,expectedRevision:r.revision})}}function WBe(e,t,n){return j({method:`POST`,path:`/api/cmmd/forge-runtimes/${encodeURIComponent(t)}/rename`,body:{displayName:n}},e)}function GBe(e,t,n){return j({method:`POST`,path:`/api/cmmd/devices/${encodeURIComponent(String(t))}/rename`,body:{displayName:n}},e)}function KBe(e,t){return j({method:`POST`,path:`/api/cmmd/devices/${encodeURIComponent(String(t))}/revoke`},e)}function qBe(e){return{...e?.projectId===void 0?{}:{projectId:String(e.projectId)},...e?.allWorkspaces===!0?{allWorkspaces:`true`}:{},...e?.organizationId===void 0?{}:{orgId:String(e.organizationId)}}}var YH=`rt-demo`,XH=`th-demo`,ZH=`example-project`,JBe=`example-conversation`,QH=`2026-09-26T20:00:00.000Z`;function YBe(e,t){return e===YH&&t===XH}function XBe(){return{runtime:{id:YH,source:`forge-cloud`,runtimeKind:`cloud-vm`,displayName:`Example Forge Server`,status:`online`,endpointUrl:null,hostId:null,deviceId:null,workspaceRoot:null,githubRepoFullName:null,lastSeenAt:QH,reachability:{status:`online`,lastReachableAt:QH,source:`cloud-runtime`},metadata:null},inventoryStatus:`synced`,inventoryPublishedAt:QH,projectCount:1,threadCount:1,projects:[{projectId:ZH,title:`Example project`,workspaceRoot:null,githubRepoFullName:null,branch:null,status:`active`,threadCount:1,lastActivityAt:QH,metadata:null,publishedAt:QH,updatedAt:QH,threads:[{threadId:XH,title:`Example thread (viewer check)`,status:`active`,model:null,provider:null,providerAccountId:null,branch:null,lastMessagePreview:null,lastActivityAt:QH,kind:`master`,parentThreadId:null,workerRole:null,anchorKind:`scratch`,anchorCmmdId:null,archive:null,disposition:{manualDisposition:null,automaticDisposition:null,effectiveDisposition:null,revision:null,source:null},metadata:null,publishedAt:QH,updatedAt:QH}]}]}}function ZBe(){return{conversationId:JBe,runtime:{id:YH,source:`forge-cloud`,runtimeKind:`cloud-vm`,displayName:`Example Forge Server`,status:`online`,endpointUrl:null,deviceId:null,workspaceRoot:null,githubRepoFullName:null,lastSeenAt:QH,metadata:null},project:{projectId:ZH,title:`Example project`,githubRepoFullName:null,branch:null},thread:{threadId:XH,title:`Example thread (viewer check)`,status:`active`,model:null,provider:null,providerAccountId:null,branch:null,lastActivityAt:QH,metadata:null},reachability:`online`,execution:{available:!0,reason:null},replication:null,events:[{sequence:1,eventId:`example-user-1`,kind:`user_message`,turnId:null,text:`This is an example chat thread for verifying the Forge embed viewer. It is not a live Work Session.`,status:null,occurredAt:`2026-09-26T19:58:00.000Z`},{sequence:2,eventId:`example-assistant-1`,kind:`assistant_message`,turnId:null,text:`Understood. You should see this reply in the iframe under CMMD /forge, with the composer still available below.`,status:null,occurredAt:`2026-09-26T19:59:00.000Z`},{sequence:3,eventId:`example-user-2`,kind:`user_message`,turnId:null,text:`Thanks. If these three turns render, the thread wire is working.`,status:null,occurredAt:QH}]}}function QBe(e){return e.runtimes.some(e=>e.runtime.id===YH)?{...e,runtimes:[...e.runtimes]}:{...e,runtimes:[...e.runtimes,XBe()]}}function $H(e,t){if(!e||typeof e!=`object`)return null;let n=e[t];return typeof n==`string`&&n.trim().length>0?n.trim():null}function $Be(e,t){if(!e||typeof e!=`object`)return null;let n=e[t];return typeof n==`boolean`?n:null}function eU(e,t){if(!e||typeof e!=`object`)return null;let n=e[t];return typeof n==`string`&&n.trim().length>0?n.trim():typeof n==`number`&&Number.isFinite(n)?String(n):null}function tU(e){return{...e.limit===void 0?{}:{limit:e.limit},...e.cursor?{cursor:e.cursor}:{}}}var eVe=class extends Error{constructor(e){super(e),this.name=`CmmdApiAuthError`}},tVe=class extends Error{status;constructor(e,t){super(e),this.name=`CmmdApiServerError`,this.status=t}},nU=class extends Error{constructor(e){super(`CmmdApiClient.${e} is not implemented yet`),this.name=`CmmdApiNotImplementedError`}};function rU(e,t){if(Array.isArray(e))return e;if(e&&typeof e==`object`){let n=e[t];if(Array.isArray(n))return n}return[]}function iU(e,t){if(Array.isArray(e))return e;if(e&&typeof e==`object`){let n=e[t];if(Array.isArray(n))return n}return[]}function aU(e,t){let n={};return e?.organizationId&&(n.orgId=e.organizationId),t!==void 0&&(n.taskId=String(t)),Object.keys(n).length>0?n:void 0}function oU(e){let t=`${$H(e,`firstName`)??``} ${$H(e,`lastName`)??``}`.trim()||$H(e,`username`)||$H(e,`email`)||`Unknown`;return{id:eU(e,`userId`)??eU(e,`id`)??t,name:t,email:$H(e,`email`),role:$H(e,`role`),avatarUrl:$H(e,`profileImage`)??$H(e,`avatar`)}}function nVe(e){let t=cU(e,`user`)??e;return oU({...typeof t==`object`&&t?t:{},userId:eU(e,`userId`)??eU(t,`id`),role:$H(e,`role`)})}function sU(e){let t=$H(e,`authorFirstName`)??``,n=$H(e,`authorLastName`)??``,r=$H(e,`status`),i=r===`at_risk`||r===`off_track`||r===`complete`?r:`on_track`;return{id:eU(e,`id`)??``,status:i,body:$H(e,`body`)??``,authorName:`${t} ${n}`.trim()||null,authorAvatarUrl:$H(e,`authorProfileImage`)??null,createdAt:$H(e,`createdAt`)??``,updatedAt:$H(e,`updatedAt`)??$H(e,`createdAt`)??``,canEdit:$Be(e,`canEdit`)??!1}}function rVe(e,t,n){let r=Array.isArray(e.data)?e.data.map(sU):[];return{updates:r,pagination:e.pagination??{page:t,limit:n,total:r.length,hasMore:!1}}}function cU(e,t){if(!e||typeof e!=`object`)return null;let n=e[t];return n&&typeof n==`object`?n:null}var iVe=[`avatarUrl`,`avatar_url`,`profileImage`,`profile_image`,`profileImageUrl`,`profile_image_url`,`image`,`imageUrl`,`image_url`,`picture`];function lU(e,t){let n=cU(e,t);if(!n)return null;for(let e of iVe){let t=$H(n,e);if(t)return t}return null}function uU(e,t){let n=cU(e,t);return n?eU(n,`id`):null}function dU(e,t){return!!(e&&typeof e==`object`&&Object.hasOwn(e,t))}function aVe(e){let t={...e,id:eU(e,`id`)??e.id,title:e.title??$H(e,`name`)??``},n=eU(e,`workspaceId`)??eU(e,`workspace_id`)??uU(e,`workspace`)??e.workspaceId??null;return n!==null||dU(e,`workspaceId`)?{...t,workspaceId:n,startDate:e.startDate??$H(e,`start_date`)??null,endDate:e.endDate??$H(e,`end_date`)??null}:t}function fU(e){let t=e.ownerAvatarUrl??$H(e,`owner_avatar_url`)??$H(e,`ownerProfileImage`)??$H(e,`owner_profile_image`)??$H(e,`ownerImage`)??$H(e,`owner_image`)??$H(e,`ownerImageUrl`)??$H(e,`owner_image_url`)??$H(e,`createdByAvatarUrl`)??$H(e,`created_by_avatar_url`)??$H(e,`createdByProfileImage`)??$H(e,`created_by_profile_image`)??lU(e,`owner`)??lU(e,`createdBy`)??lU(e,`created_by`)??null,n={...e,id:eU(e,`id`)??e.id},r=eU(e,`campaignId`)??eU(e,`campaign_id`)??uU(e,`campaign`)??e.campaignId??null;(r!==null||dU(e,`campaignId`))&&(n.campaignId=r);let i=e.campaignTitle??$H(e,`campaignTitle`)??$H(e,`campaign_title`)??$H(cU(e,`campaign`),`title`)??$H(cU(e,`campaign`),`name`)??null;(i!==null||dU(e,`campaignTitle`))&&(n.campaignTitle=i);let a=eU(e,`workspaceId`)??eU(e,`workspace_id`)??uU(e,`workspace`)??e.workspaceId??null;(a!==null||dU(e,`workspaceId`))&&(n.workspaceId=a);let o=e.workspaceName??$H(e,`workspace_name`)??$H(cU(e,`workspace`),`name`)??null;(o!==null||dU(e,`workspaceName`))&&(n.workspaceName=o);let s=$H(e,`workspaceIconUrl`)??$H(e,`workspace_icon_url`)??$H(cU(e,`workspace`),`iconUrl`)??null;(s!==null||dU(e,`workspaceIconUrl`))&&(n.workspaceIconUrl=s);let c=eU(e,`ownerId`)??eU(e,`owner_id`)??uU(e,`owner`)??e.ownerId??null;(c!==null||dU(e,`ownerId`))&&(n.ownerId=c);let l=e.ownerName??$H(e,`owner_name`)??$H(cU(e,`owner`),`name`)??null;(l!==null||dU(e,`ownerName`))&&(n.ownerName=l),(t!==null||dU(e,`ownerAvatarUrl`))&&(n.ownerAvatarUrl=t);let u=eU(e,`teamId`)??eU(e,`team_id`)??uU(e,`team`)??e.teamId??null;(u!==null||dU(e,`teamId`))&&(n.teamId=u);let d=e.teamName??$H(e,`team_name`)??$H(cU(e,`team`),`name`)??null;(d!==null||dU(e,`teamName`))&&(n.teamName=d);let f=e.startDate??$H(e,`start_date`)??null;(f!==null||dU(e,`startDate`))&&(n.startDate=f);let p=e.targetEndDate??$H(e,`target_end_date`)??null;return(p!==null||dU(e,`targetEndDate`))&&(n.targetEndDate=p),n}function pU(e){if(Array.isArray(e))return e;if(e&&typeof e==`object`){let t=e;if(Array.isArray(t.items))return t.items;if(Array.isArray(t.results))return t.results}return[]}function oVe(e){return pU(e).flatMap(e=>{let t=e,n=typeof t.id==`number`?t.id:null,r=typeof t.name==`string`?t.name:null;if(n===null||r===null)return[];let i=e=>typeof t[e]==`string`?t[e]:null;return[{id:n,name:r,startDate:i(`startDate`),endDate:i(`endDate`),status:i(`status`)}]})}function sVe(e){if(e&&typeof e==`object`){let t=e;if(t.project&&typeof t.project==`object`)return t.project}return e}function mU(e){if(e===null||e.trim()===``)return null;let t=Number(e);return Number.isSafeInteger(t)?t:e}async function hU(e){try{return await e}catch(e){throw e instanceof xn?e.kind===`auth`?new eVe(e.message):new tVe(e.message,e.status??502):e}}var gU=class e{cfg;putThreadDisposition;postThreadArchive;commentEditIdempotencyKeys=new Map;commentDeleteIdempotencyKeys=new Map;constructor(e={}){let t=e.forgeOrigin===void 0,n=e.forgeOrigin??`http://localhost:13773`;this.cfg={resolveUrl:t?fn:e=>`${n}${e}`,maxRetries:e.maxRetries??3,onAuthExpired:e.onAuthExpired??bn,...t?{resolveBearerToken:()=>_n()?.bearerToken??null}:{}},this.putThreadDisposition=RBe(this.cfg),this.postThreadArchive=VBe(this.cfg)}async getTask(e){return hU(j({method:`GET`,path:`/api/cmmd/tasks/${e}`},this.cfg))}async getForgeTaskDetail(e){return j({method:`GET`,path:`/api/cmmd/tasks/${e}`},this.cfg)}async searchTasks(e){let t={q:e.q};return e.status&&(t.status=e.status),e.limit!==void 0&&(t.limit=e.limit),e.projectId&&(t.projectId=e.projectId),(await hU(j({method:`GET`,path:`/api/cmmd/tasks/search`,query:t},this.cfg))).tasks??[]}async getTaskComments(e){return(await hU(j({method:`GET`,path:`/api/cmmd/tasks/${e}/comments`},this.cfg))).comments??[]}async listProjectTaskComments(e){return(await hU(j({method:`GET`,path:`/api/cmmd/tasks/${e}/comments`},this.cfg))).comments??[]}async createProjectTaskComment(e,t){return(await hU(j({method:`POST`,path:`/api/cmmd/tasks/comment`,body:{taskId:e,content:t.content}},this.cfg))).details}async updateProjectTaskComment(e,t,n){return(await hU(j({method:`PATCH`,path:`/api/cmmd/tasks/${e}/comments/${encodeURIComponent(t)}`,body:n},this.cfg))).comment}async deleteProjectTaskComment(e,t,n){return hU(j({method:`DELETE`,path:`/api/cmmd/tasks/${e}/comments/${encodeURIComponent(t)}`,body:n},this.cfg))}async getTaskAttachments(e){return hU(j({method:`GET`,path:`/api/cmmd/tasks/${e}/attachments`},this.cfg))}async getProjectRepository(e){return hU(j({method:`GET`,path:`/api/cmmd/projects/${e}/repository`},this.cfg))}async listProjectRepositories(e){return(await hU(j({method:`GET`,path:`/api/cmmd/projects/${e}/repositories`},this.cfg))).repositories}async getWorkspaceMembers(e){return hU(j({method:`GET`,path:`/api/cmmd/organizations/${e}/members`},this.cfg))}async getWebSocketToken(e){return j({method:`GET`,path:`/api/cmmd/ws-token`,...e?.signal===void 0?{}:{signal:e.signal}},this.cfg)}async getProjectComments(e,t){let n={};return t?.organizationId&&(n.organizationId=t.organizationId),(await j({method:`GET`,path:`/api/cmmd/projects/${e}/comments`,query:n},this.cfg))?.comments??[]}async getProjectLink(e){return j({method:`GET`,path:`/.well-known/forge/project-link`,query:{environmentId:e.environmentId,projectId:e.projectId,cwd:e.cwd}},this.cfg)}async listProjectLinks(){return j({method:`GET`,path:`/.well-known/forge/project-links`,suppressBearerToken:!0},this.cfg)}async listProjectContextLinks(e){let t={};e.environmentId&&(t.forgeEnvironmentId=e.environmentId),e.projectId&&(t.forgeProjectId=e.projectId),e.githubRepoFullName&&(t.githubRepoFullName=e.githubRepoFullName),e.cmmdOrganizationId&&(t.cmmdOrganizationId=e.cmmdOrganizationId);let n=await j({method:`GET`,path:`/.well-known/forge/cmmd/project-links`,query:t},this.cfg),r=pte(Wte)(n);return r._tag===`Some`?r.value.links:[]}async listCmmdWorkspaces(){return pU(await j({method:`GET`,path:`/.well-known/forge/cmmd/workspaces`},this.cfg))}async listCmmdCampaigns(e){return oVe(await j({method:`GET`,path:`/.well-known/forge/cmmd/campaigns`,query:{workspaceId:e.workspaceId}},this.cfg))}async listCmmdProjects(e){return pU(await j({method:`GET`,path:`/.well-known/forge/cmmd/projects`,query:{campaignId:e.campaignId}},this.cfg))}async updateTask(e,t){let n={taskId:e};return t.title!==void 0&&(n.title=t.title),t.description!==void 0&&(n.description=t.description),t.status!==void 0&&(n.status=t.status),t.priority!==void 0&&(n.priority=t.priority),t.dueDate!==void 0&&(n.dueDate=t.dueDate),t.assigneeId!==void 0&&(n.assigneeId=t.assigneeId),t.labels!==void 0&&(n.labels=t.labels),hU(j({method:`POST`,path:`/api/cmmd/tasks/update`,body:n},this.cfg))}async createComment(e){return hU(j({method:`POST`,path:`/api/cmmd/tasks/comment`,body:{taskId:e.entityId,content:e.content}},this.cfg))}async updateComment(e,t,n){let r=`${e}:${t}:${n}`,i=this.commentEditIdempotencyKeys.get(r)??crypto.randomUUID();this.commentEditIdempotencyKeys.set(r,i);let a=await hU(j({method:`PATCH`,path:`/api/cmmd/tasks/${e}/comments/${t}`,body:{content:n,idempotencyKey:i}},this.cfg));return this.commentEditIdempotencyKeys.delete(r),a}async deleteComment(e,t){let n=`${e}:${t}`,r=this.commentDeleteIdempotencyKeys.get(n)??crypto.randomUUID();this.commentDeleteIdempotencyKeys.set(n,r),await hU(j({method:`DELETE`,path:`/api/cmmd/tasks/${e}/comments/${t}`,body:{idempotencyKey:r}},this.cfg)),this.commentDeleteIdempotencyKeys.delete(n)}async createProjectComment(e,t){let n=(await j({method:`POST`,path:`/api/cmmd/projects/${e}/comments`,body:{content:t.content,organizationId:t.organizationId??null}},this.cfg))?.comment;if(!n)throw new xn({kind:`server`,message:`CMMD did not return the created project comment.`});return n}async updateProject(e,t){let n={};for(let e of Fte){let r=t[e];r!==void 0&&(n[e]=Bte[e]===`nullableId`?mU(r):r)}await j({method:`PATCH`,path:`/api/cmmd/projects/${e}`,body:n},this.cfg)}async setProjectLink(e){await j({method:`POST`,path:`/.well-known/forge/project-link`,body:e},this.cfg)}async deleteProjectLink(e){await j({method:`DELETE`,path:`/.well-known/forge/project-link`,query:{environmentId:e.environmentId,projectId:e.projectId,cwd:e.cwd,...e.cmmdProjectId?{cmmdProjectId:e.cmmdProjectId}:{}}},this.cfg)}async createCmmdProject(e){return j({method:`POST`,path:`/.well-known/forge/cmmd/projects`,body:e},this.cfg)}async ensureGitHubProjectContext(e){return j({method:`POST`,path:`/.well-known/forge/cmmd/github-project-contexts/ensure`,body:e},this.cfg)}async createBrainDoc(e){return j({method:`POST`,path:`/api/cmmd/brain-docs`,body:e},this.cfg)}async uploadTaskAttachment(e,t){let n=new FormData;return n.append(`file`,t),hU(j({method:`POST`,path:`/api/cmmd/tasks/${e}/attachments`,form:n},this.cfg))}async archiveTask(e){await j({method:`POST`,path:`/api/cmmd/tasks/${e}/archive`},this.cfg)}async unarchiveTask(e){await j({method:`POST`,path:`/api/cmmd/tasks/${e}/unarchive`},this.cfg)}async getProfile(){return j({method:`GET`,path:`/api/cmmd/profile`},this.cfg)}async getUsageSummary(e){return j({method:`GET`,path:`/api/cmmd/usage/summary`,query:{sinceDay:e.sinceDay,untilDay:e.untilDay,timeZone:e.timeZone,...e.resolution===`hour`?{resolution:e.resolution,sinceTime:e.sinceTime,untilTime:e.untilTime}:{}}},this.cfg)}getBilling(e){return kBe(this.cfg,e)}getBillingSeries(e){return ABe(this.cfg,e)}async getBootstrap(){return j({method:`GET`,path:`/api/cmmd/bootstrap`},this.cfg)}async getForgeAccountPreferences(){return j({method:`GET`,path:`/api/cmmd/account/preferences`},this.cfg)}async updateForgeAccountPreferences(e){return j({method:`PATCH`,path:`/api/cmmd/account/preferences`,body:e},this.cfg)}async getOrgProviderPolicy(){return j({method:`GET`,path:`/api/cmmd/org/provider-policy`},this.cfg)}async listSavedDataViews(e){return j({method:`GET`,path:`/api/cmmd/saved-views`,query:{surface:e.surface,projectId:e.projectId}},this.cfg)}async createSavedDataView(e){return j({method:`POST`,path:`/api/cmmd/saved-views`,body:e},this.cfg)}async importSavedDataView(e){return j({method:`POST`,path:`/api/cmmd/saved-views/import`,body:e},this.cfg)}async updateSavedDataView(e,t){return j({method:`PATCH`,path:`/api/cmmd/saved-views/${encodeURIComponent(e)}`,body:t},this.cfg)}async deleteSavedDataView(e,t){return j({method:`DELETE`,path:`/api/cmmd/saved-views/${encodeURIComponent(e)}`,query:t},this.cfg)}async getDeviceRegistry(e){return j({method:`GET`,path:`/api/cmmd/devices`,...e?.projectId===void 0?{}:{query:{projectId:String(e.projectId)}},...e?.signal===void 0?{}:{signal:e.signal}},this.cfg)}async registerDevice(e){return j({method:`POST`,path:`/api/cmmd/devices/register`,body:e},this.cfg)}async grantRuntimeAccess(e,t){return j({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/access-grants`,body:t},this.cfg)}async revokeRuntimeAccess(e,t){return j({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/access-grants/${encodeURIComponent(String(t))}/revoke`},this.cfg)}async issueRelayControlRoute(e,t){return j({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/relay-routes`,body:t},this.cfg)}async issueRelayActionGrant(e,t){return j({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/relay-action-grants`,body:t},this.cfg)}async getRuntimeInventory(e){let t=qBe(e);return QBe(await j({method:`GET`,path:`/api/cmmd/runtime-inventory`,...Object.keys(t).length>0?{query:t}:{}},this.cfg))}async getRuntimeDiagnostics(e){return j({method:`GET`,path:`/api/cmmd/runtime-diagnostics/v2/runtimes/${encodeURIComponent(e)}`},this.cfg)}async getCloudProjectLifecyclePreflight(e){return(await j({method:`GET`,path:`/api/cmmd/forge-cloud-projects/${encodeURIComponent(String(e))}/lifecycle-preflight`},this.cfg)).preflight}async replaceRuntimeInventory(e,t){return j({method:`PUT`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/inventory`,body:t},this.cfg)}static PROVIDER_ACCOUNTS_PATH=`/api/cmmd/providers/accounts`;static PROVIDER_USAGE_PATH=`/api/cmmd/providers/usage`;static PROVIDER_USAGE_REFRESH_PATH=`/api/cmmd/providers/usage/refresh`;provisionAuthRuntime(){return TBe(this.cfg)}getAuthRuntimeState(){return EBe(this.cfg)}destroyAuthRuntime(){return DBe(this.cfg)}connectAuthRuntime(){return OBe(this.cfg)}getUserCodexCredential(){return jBe(this.cfg)}disconnectUserCodexCredential(){return MBe(this.cfg)}getUserClaudeCredential(){return NBe(this.cfg)}async getProviderAccounts(){return j({method:`GET`,path:e.PROVIDER_ACCOUNTS_PATH},this.cfg)}async removeLinkedProviderAccount(e){return FBe(this.cfg,e)}async setProviderAccountDefault(t){return j({method:`PUT`,path:`${e.PROVIDER_ACCOUNTS_PATH}/default`,body:{provider:t.provider,provider_account_id:t.providerAccountId}},this.cfg)}async getProviderUsage(){return j({method:`GET`,path:e.PROVIDER_USAGE_PATH},this.cfg)}async refreshProviderUsage(t,n){return j({method:`POST`,path:e.PROVIDER_USAGE_REFRESH_PATH,body:{provider:t,providerAccountId:n}},this.cfg)}disconnectUserClaudeCredential(){return PBe(this.cfg)}async getClaudeRuntimeReadiness(e){return j({method:`GET`,path:`/api/cmmd/providers/claude/runtime-readiness/${encodeURIComponent(e)}`},this.cfg)}async appendRuntimeThreadEvents(e,t,n){return j({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/threads/${encodeURIComponent(t)}/events`,body:n},this.cfg)}async getRuntimeThreadReplica(e,t){return YBe(e,t)?ZBe():j({method:`GET`,path:`/api/cmmd/threads/${encodeURIComponent(e)}/${encodeURIComponent(t)}`},this.cfg)}renameCloudEnvironment(e,t){return WBe(this.cfg,e,t)}renameDevice(e,t){return GBe(this.cfg,e,t)}revokeDevice(e){return KBe(this.cfg,e)}static SIM_PATH=`/api/cmmd/sim-host`;static simScope(e){return e?.orgId===void 0?``:`?orgId=${encodeURIComponent(String(e.orgId))}`}async listSimHosts(t){return j({method:`GET`,path:`${e.SIM_PATH}/hosts${e.simScope(t)}`},this.cfg)}async getSimLease(t){let n=new URLSearchParams({forgeEnvironmentId:t.forgeEnvironmentId,threadId:t.threadId,...t.orgId===void 0?{}:{orgId:String(t.orgId)}});return j({method:`GET`,path:`${e.SIM_PATH}/leases?${n.toString()}`},this.cfg)}async claimSimLease(t){return j({method:`POST`,path:`${e.SIM_PATH}/leases${e.simScope(t)}`,body:{hostId:t.hostId,forgeEnvironmentId:t.forgeEnvironmentId,threadId:t.threadId,ttlMs:t.ttlMs}},this.cfg)}async renewSimLease(t){return j({method:`POST`,path:`${e.SIM_PATH}/leases/${encodeURIComponent(String(t.leaseId))}/renew${e.simScope(t)}`,body:{generation:t.generation,rowVersion:t.rowVersion,ttlMs:t.ttlMs}},this.cfg)}async releaseSimLease(t){await j({method:`POST`,path:`${e.SIM_PATH}/leases/${encodeURIComponent(String(t.leaseId))}/release${e.simScope(t)}`,body:{generation:t.generation,rowVersion:t.rowVersion}},this.cfg)}async listCampaigns(e){let t={};return e?.orgId&&(t.orgId=e.orgId),e?.allWorkspaces&&(t.allWorkspaces=`true`),rU(await j({method:`GET`,path:`/api/cmmd/campaigns`,query:t,...e?.signal?{signal:e.signal}:{}},this.cfg),`campaigns`).map(aVe)}async getCampaign(e){return j({method:`GET`,path:`/api/cmmd/campaigns/${e}`},this.cfg)}async createCampaign(e){return j({method:`POST`,path:`/api/cmmd/campaigns`,body:e},this.cfg)}async updateCampaign(e,t){return j({method:`PUT`,path:`/api/cmmd/campaigns/${e}`,body:t},this.cfg)}async deleteCampaign(e){await j({method:`DELETE`,path:`/api/cmmd/campaigns/${e}`},this.cfg)}async listProjects(e){let t={};return e?.campaignId&&(t.campaignId=e.campaignId),e?.orgId&&(t.orgId=e.orgId),e?.allWorkspaces&&(t.allWorkspaces=`true`),rU(await j({method:`GET`,path:`/api/cmmd/projects`,query:t,...e?.signal?{signal:e.signal}:{}},this.cfg),`projects`).map(fU)}async listTasks(e){let t={};return e?.projectId&&(t.projectId=e.projectId),e?.status&&(t.status=e.status),j({method:`GET`,path:`/api/cmmd/tasks`,query:t},this.cfg)}async getProject(e){return fU(await j({method:`GET`,path:`/api/cmmd/projects/${e}`},this.cfg))}async getProjectMembers(e){let t=await j({method:`GET`,path:`/api/cmmd/projects/${e}/members`},this.cfg);return Array.isArray(t)?t.map(oU):[]}async listWorkspaceMembers(){let e=await j({method:`GET`,path:`/api/cmmd/members`},this.cfg);return Array.isArray(e)?e.map(nVe):[]}async addProjectMember(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/members`,body:t},this.cfg)}async listProjectAgentMembers(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/agent-members`},this.cfg)}async createProjectAgentMember(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/agent-members`,body:t},this.cfg)}async renameProjectAgentMember(e,t,n){return j({method:`PATCH`,path:`/api/cmmd/projects/${e}/agent-members/${t}`,body:n},this.cfg)}async retireProjectAgentMember(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/agent-members/${t}/retire`,body:n},this.cfg)}async updateProjectAgentMemberAvatar(e,t,n){return j({method:`PUT`,path:`/api/cmmd/projects/${e}/agent-members/${t}/avatar`,body:n},this.cfg)}async listProjectAgentMemberInstances(e,t){return j({method:`GET`,path:`/api/cmmd/projects/${e}/agent-members/${t}/instances`},this.cfg)}async previewProjectAgentMemberConsolidation(e){return j({method:`POST`,path:`/api/cmmd/projects/${e}/agent-members/consolidation/preview`},this.cfg)}async applyProjectAgentMemberConsolidation(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/agent-members/consolidation/apply`,body:t},this.cfg)}async setProjectTaskAssignment(e,t,n){return j({method:`PUT`,path:`/api/cmmd/projects/${e}/tasks/${t}/assignment`,body:n},this.cfg)}async getProjectUpdates(e,t){let n=t?.page??1,r=t?.limit??10;return rVe(await j({method:`GET`,path:`/api/cmmd/projects/${e}/updates`,query:{page:n,limit:r},unwrapEnvelope:!1},this.cfg),n,r)}async createProjectUpdate(e,t){return sU(await j({method:`POST`,path:`/api/cmmd/projects/${e}/updates`,body:t},this.cfg))}async updateProjectUpdate(e,t,n){return sU(await j({method:`PATCH`,path:`/api/cmmd/projects/${e}/updates/${t}`,body:n},this.cfg))}async deleteProjectUpdate(e,t){await j({method:`DELETE`,path:`/api/cmmd/projects/${e}/updates/${t}`},this.cfg)}async listProjectMilestones(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/milestones`},this.cfg)}async createProjectMilestone(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/milestones`,body:t},this.cfg)}async updateProjectMilestone(e,t,n){return j({method:`PATCH`,path:`/api/cmmd/projects/${e}/milestones/${t}`,body:n},this.cfg)}async deleteProjectMilestone(e,t){await j({method:`DELETE`,path:`/api/cmmd/projects/${e}/milestones/${t}`},this.cfg)}async improveProjectContent(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/content/readability`,body:t},this.cfg)}async listProjectBoard(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/board`},this.cfg)}async createProjectTaskDraft(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/task-drafts`,body:t},this.cfg)}async getProjectTaskDraft(e,t){return j({method:`GET`,path:`/api/cmmd/projects/${e}/task-drafts/${t}`},this.cfg)}async updateProjectTaskDraft(e,t,n){return j({method:`PATCH`,path:`/api/cmmd/projects/${e}/task-drafts/${t}`,body:n},this.cfg)}async previewProjectTaskDraft(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/task-drafts/${t}/preview`,body:n},this.cfg)}async commitProjectTaskDraft(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/task-drafts/${t}/commit`,body:n},this.cfg)}async discardProjectTaskDraft(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/task-drafts/${t}/discard`,body:n},this.cfg)}async getProjectTaskWorkflow(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/task-workflow`},this.cfg)}async updateProjectTaskWorkflow(e,t){return j({method:`PUT`,path:`/api/cmmd/projects/${e}/task-workflow`,body:t},this.cfg)}async getProjectLeadPlan(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/plan`},this.cfg)}async activateProjectLeadAutomaticStaffing(e){return j({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/authority/activate`,body:{}},this.cfg)}async getProjectLeadReadiness(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/readiness`},this.cfg)}async getProjectLeadCapabilities(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/capabilities`},this.cfg)}async getProjectLeadSummary(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/summary`},this.cfg)}async getProjectLeadDetail(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/detail`},this.cfg)}async getProjectLeadBriefing(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/briefing`},this.cfg)}async decideProjectLeadApproval(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/approvals/${t}/decision`,body:n},this.cfg)}async listProjectLeadEvents(e,t){return j({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/events`,...t?{query:{...t.afterEventId===void 0?{}:{afterEventId:String(t.afterEventId)},...t.latest===void 0?{}:{latest:String(t.latest)},...t.limit===void 0?{}:{limit:String(t.limit)}}}:{}},this.cfg)}async explainProjectLead(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/explain`},this.cfg)}async pauseProjectLead(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/pause`,body:t},this.cfg)}async resumeProjectLead(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/resume`,body:t},this.cfg)}async reserveProjectLeadTask(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/tasks/${t}/reservations`,body:n},this.cfg)}async releaseProjectLeadReservation(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/reservations/${t}/release`,body:n},this.cfg)}async reconcileProjectLead(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/reconcile`,body:t},this.cfg)}async resolveProjectLeadAttention(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/attention/${t}/resolve`,body:n},this.cfg)}async listCenterBoard(e){let t={};return e?.status&&(t.status=e.status),e?.workspaceId&&(t.workspaceId=String(e.workspaceId)),e?.campaignId&&(t.campaignId=String(e.campaignId)),e?.ownerId&&(t.ownerId=String(e.ownerId)),e?.includeArchived!==void 0&&(t.includeArchived=e.includeArchived),e?.q&&(t.q=e.q),j({method:`GET`,path:`/api/cmmd/work-items/board`,query:t},this.cfg)}async listForgeAutomationPresets(){return iU(await j({method:`GET`,path:`/api/cmmd/automations/presets`},this.cfg),`presets`)}async listUserForgeAutomationRules(){return iU(await j({method:`GET`,path:`/api/cmmd/automations/user/rules`},this.cfg),`rules`)}async createUserForgeAutomationRule(e){return j({method:`POST`,path:`/api/cmmd/automations/user/rules`,body:e},this.cfg)}async updateUserForgeAutomationRule(e,t){return j({method:`PATCH`,path:`/api/cmmd/automations/user/rules/${e}`,body:t},this.cfg)}async listUserForgeAutomationRuns(e){return iU(await j({method:`GET`,path:`/api/cmmd/automations/user/rules/${e}/runs`},this.cfg),`runs`)}async startUserForgeAutomationRun(e,t){return j({method:`POST`,path:`/api/cmmd/automations/user/rules/${e}/runs`,body:t},this.cfg)}async listForgeAutomationRules(e,t){let n=aU(t);return iU(await j({method:`GET`,path:`/api/cmmd/automations/projects/${e}/rules`,...n?{query:n}:{}},this.cfg),`rules`)}async createForgeAutomationRule(e,t,n){let r=aU(n);return j({method:`POST`,path:`/api/cmmd/automations/projects/${e}/rules`,body:t,...r?{query:r}:{}},this.cfg)}async updateForgeAutomationRule(e,t,n,r){let i=aU(r);return j({method:`PATCH`,path:`/api/cmmd/automations/projects/${e}/rules/${t}`,body:n,...i?{query:i}:{}},this.cfg)}async listForgeAutomationRuns(e,t){let n=aU(t,t?.taskId);return iU(await j({method:`GET`,path:`/api/cmmd/automations/projects/${e}/runs`,...n?{query:n}:{}},this.cfg),`runs`)}async getForgeAutomationRun(e,t){let n=aU(t);return j({method:`GET`,path:`/api/cmmd/automations/runs/${e}`,...n?{query:n}:{}},this.cfg)}async startForgeAutomationRun(e,t,n,r){let i=aU(r);return j({method:`POST`,path:`/api/cmmd/automations/projects/${e}/tasks/${t}/runs`,body:n,...i?{query:i}:{}},this.cfg)}async retryForgeAutomationRun(e,t,n){let r=aU(n);return j({method:`POST`,path:`/api/cmmd/automations/runs/${e}/retry`,body:t,...r?{query:r}:{}},this.cfg)}async cancelForgeAutomationRun(e,t,n){let r=aU(n);return j({method:`POST`,path:`/api/cmmd/automations/runs/${e}/cancel`,body:t,...r?{query:r}:{}},this.cfg)}async approveForgeAutomationEscalation(e,t,n){let r=aU(n);return j({method:`POST`,path:`/api/cmmd/automations/runs/${e}/escalations/approve`,body:t,...r?{query:r}:{}},this.cfg)}async rejectForgeAutomationEscalation(e,t,n){let r=aU(n);return j({method:`POST`,path:`/api/cmmd/automations/runs/${e}/escalations/reject`,body:t,...r?{query:r}:{}},this.cfg)}async createProjectBoardTask(e,t){let n={title:t.title};return t.description!==void 0&&(n.description=t.description),t.priority!==void 0&&(n.priority=t.priority),t.status!==void 0&&(n.status=t.status),t.workflowStageId!==void 0&&(n.workflowStageId=t.workflowStageId),t.assignee!==void 0&&(n.assignee=t.assignee),t.dueDate!==void 0&&(n.dueDate=t.dueDate),t.workItemType!==void 0&&(n.workItemType=t.workItemType),t.parentTaskId!==void 0&&(n.parentTaskId=t.parentTaskId),t.milestoneId!==void 0&&(n.milestoneId=t.milestoneId),t.dependsOn!==void 0&&(n.dependsOn=t.dependsOn),j({method:`POST`,path:`/api/cmmd/projects/${e}/board`,body:n},this.cfg)}async createCenterBoardTask(e){let t={title:e.title,projectId:e.projectId};return e.description!==void 0&&(t.description=e.description),e.priority!==void 0&&(t.priority=e.priority),e.status!==void 0&&(t.status=e.status),e.assignee!==void 0&&(t.assignee=e.assignee),e.dueDate!==void 0&&(t.dueDate=e.dueDate),e.workItemType!==void 0&&(t.workItemType=e.workItemType),e.parentTaskId!==void 0&&(t.parentTaskId=e.parentTaskId),e.milestoneId!==void 0&&(t.milestoneId=e.milestoneId),e.dependsOn!==void 0&&(t.dependsOn=e.dependsOn),j({method:`POST`,path:`/api/cmmd/work-items/board`,body:t},this.cfg)}async submitFeedback(e){let t={type:e.type,title:e.title,source:e.source};return e.description!==void 0&&(t.description=e.description),e.priority!==void 0&&(t.priority=e.priority),e.senderName!==void 0&&(t.senderName=e.senderName),j({method:`POST`,path:`/api/cmmd/feedback`,body:t},this.cfg)}async updateProjectBoardTask(e,t,n){return j({method:`PATCH`,path:`/api/cmmd/projects/${e}/board/${t}`,body:n},this.cfg)}async updateCenterBoardTask(e,t){return j({method:`PATCH`,path:`/api/cmmd/work-items/board/${e}`,body:t},this.cfg)}async moveCenterBoardTask(e,t){let n={toStatus:t.toStatus};return t.beforeTaskId!==void 0&&(n.beforeTaskId=t.beforeTaskId),t.afterTaskId!==void 0&&(n.afterTaskId=t.afterTaskId),j({method:`PATCH`,path:`/api/cmmd/work-items/board/${e}/move`,body:n},this.cfg)}async moveProjectBoardTask(e,t,n){let r={toStatus:n.toStatus};return n.toStageId!==void 0&&(r.toStageId=n.toStageId),n.beforeTaskId!==void 0&&(r.beforeTaskId=n.beforeTaskId),n.afterTaskId!==void 0&&(r.afterTaskId=n.afterTaskId),j({method:`PATCH`,path:`/api/cmmd/projects/${e}/board/${t}/move`,body:r},this.cfg)}async archiveProjectBoardTask(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/board/${t}/archive`},this.cfg)}async unarchiveProjectBoardTask(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/board/${t}/unarchive`},this.cfg)}async updateProjectBoardTaskStatus(e,t,n,r){return j({method:`PATCH`,path:`/api/cmmd/projects/${e}/board/${t}/status`,body:{status:n,...r?{workflowStageId:r}:{}}},this.cfg)}async listTaskExecutionOptions(e,t){return j({method:`GET`,path:`/api/cmmd/projects/${e}/board/${t}/execution-options`},this.cfg)}async createTaskWorkSession(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/board/${t}/work-sessions`,body:n},this.cfg)}async listProjectWorkSessions(e,t={}){return j({method:`GET`,path:`/api/cmmd/projects/${e}/work-sessions`,query:t},this.cfg)}async getWorkSession(e){return j({method:`GET`,path:`/api/cmmd/work-sessions/${e}`},this.cfg)}async updateWorkSessionStatus(e,t){return j({method:`PATCH`,path:`/api/cmmd/work-sessions/${e}`,body:{status:t}},this.cfg)}async attachWorkSessionThread(e,t){return j({method:`POST`,path:`/api/cmmd/work-sessions/${e}/threads`,body:t},this.cfg)}async listTaskConversations(e,t={}){return j({method:`GET`,path:`/api/cmmd/tasks/${e}/conversations`,query:tU(t)},this.cfg)}async linkTaskConversation(e,t){return j({method:`POST`,path:`/api/cmmd/tasks/${e}/conversations`,body:t},this.cfg)}async getTaskHistory(e){return j({method:`GET`,path:`/api/cmmd/tasks/${e}/history`},this.cfg)}async upsertTaskPullRequest(e,t){return j({method:`PUT`,path:`/api/cmmd/tasks/${e}/pull-requests`,body:t},this.cfg)}postPullRequest(e,t){return j({method:`POST`,path:`/api/cmmd/pull-requests/${e}`,body:t},this.cfg)}async listPullRequests(e){return this.postPullRequest(`list`,e)}async getPullRequestListStats(e){return this.postPullRequest(`list-stats`,e)}async getPullRequestDetail(e){return this.postPullRequest(`detail`,e)}async getPullRequestActivity(e){return this.postPullRequest(`activity`,e)}async getPullRequestDiff(e){return this.postPullRequest(`diff`,e)}async getPullRequestDiffFileContents(e){return this.postPullRequest(`diff-file-contents`,e)}async getPullRequestThreadComments(e){return this.postPullRequest(`thread/comments`,e)}async getPullRequestReviewerCandidates(e){return this.postPullRequest(`reviewer-candidates`,e)}async runPullRequestAction(e){return this.postPullRequest(`action`,e)}async createPullRequestComment(e){return this.postPullRequest(`comment`,e)}async updatePullRequest(e){return this.postPullRequest(`update`,e)}async updatePullRequestComment(e){return this.postPullRequest(`comment/update`,e)}async submitPullRequestReview(e){return this.postPullRequest(`review`,e)}async replyToPullRequestThread(e){return this.postPullRequest(`thread/reply`,e)}async setPullRequestThreadResolution(e){return this.postPullRequest(`thread/resolution`,e)}async requestPullRequestReviewers(e){return this.postPullRequest(`reviewers`,e)}async setPullRequestReaction(e){return this.postPullRequest(`reaction`,e)}async getTaskConversation(e,t,n={}){return j({method:`GET`,path:`/api/cmmd/tasks/${e}/conversations/${encodeURIComponent(t)}`,query:tU(n)},this.cfg)}async createTask(e){return j({method:`POST`,path:`/api/cmmd/tasks`,body:e},this.cfg)}async createSubtask(e){throw new nU(`createSubtask`)}async createBoardTask(e){throw new nU(`createBoardTask`)}async createProject(e){let t={};for(let[n,r]of Object.entries(e))r!=null&&(t[n]=r);return e.campaignId!==void 0&&e.campaignId!==null&&(t.campaignId=mU(e.campaignId)),e.organizationId!==void 0&&e.organizationId!==null&&(t.organizationId=mU(e.organizationId)),sVe(await j({method:`POST`,path:`/api/cmmd/projects`,body:t},this.cfg))}async moveProject(e,t){let n={targetOrgId:mU(t.targetOrgId)};return t.campaignStrategy!==void 0&&(n.campaignStrategy=t.campaignStrategy),t.targetCampaignId!==void 0&&(n.targetCampaignId=mU(t.targetCampaignId)),t.dryRun!==void 0&&(n.dryRun=t.dryRun),j({method:`POST`,path:`/api/cmmd/projects/${e}/move`,body:n},this.cfg)}async uploadBrainDoc(e,t){throw new nU(`uploadBrainDoc`)}};function _U(e){return new gU(e)}var vU=new gU({onAuthExpired:bn}),yU=class extends ht(`BootstrapHttpError`){},bU=e=>pe(e,`BootstrapHttpError`);function xU(e){return typeof e!=`object`||!e?!1:!!(bU(e)&&e.status===401||e instanceof Error&&e.name===`RemoteEnvironmentAuthHttpError`&&`status`in e&&e.status===401||e instanceof xn&&e.kind===`auth`)}function cVe(e){let t=e.replace(/\s+/g,` `).trim();return t.length===0?`<empty response>`:t.slice(0,120)}async function SU(e,t){let n=await e.text();try{return JSON.parse(n)}catch{throw new yU({message:`${t} returned a non-JSON response (${cVe(n)}). Ensure the Forge server is running and this route is proxied correctly.`,status:e.status})}}function CU(e={resolveUrl:fn}){let t=_n()?.bearerToken;return t?{...e,bearerToken:t}:e}var wU=null,TU=null,EU=null,DU=new Set,OU=`cmmd-forge.loggedOutLocalBootstrapCredentials.v1`;function lVe(e){let t=`${e.firstName??``} ${e.lastName??``}`.trim();FH({id:e.id,email:e.email,...t.length>0?{username:t}:{}}),WH({cmmdUserId:e.id,...e.email?{email:e.email}:{},...t.length>0?{displayName:t}:{}})}function kU(){if(typeof window>`u`||EU)return;let e=window.desktopBridge?.desktopAuth?.onStateChange;e&&(EU=e(e=>{wU=null,TU=null,e.sessionLifecycle.status!==`ready`&&FH(null),(e.sessionLifecycle.status===`expired`||e.sessionLifecycle.status===`signed-out`&&e.sessionLifecycle.reason===`refresh-revoked`)&&gne().catch(e=>{IH(e,{route:`desktop-auth-session-expired`})})}))}function uVe(){return na(new URL(window.location.href))}function AU(){let e=new URL(window.location.href),t=Nie(e);t.toString()!==e.toString()&&window.history.replaceState({},document.title,t.toString())}async function dVe(){return zU(async()=>{let e=fn(`/api/auth/session`),t=async()=>{let t=await fetch(e,gn({credentials:`include`}));if(!t.ok)throw new yU({message:`Failed to load server auth session state (${t.status}).`,status:t.status});return SU(t,e)},n=await t();return!n.authenticated&&n.auth.sessionMethods.length===1&&n.auth.sessionMethods[0]===`proxy-asserted`&&typeof window<`u`&&!window.desktopBridge&&e.startsWith(`https://`)&&await yne()?t():n})}var jU=new Set([`CMMD_AUTH_REQUIRED`,`CMMD_AUTH_EXPIRED`]);async function fVe(e){return zU(async()=>{let t={credential:e},n=fn(`/api/auth/bootstrap`),r=await fetch(n,gn({body:JSON.stringify(t),credentials:`include`,headers:{"content-type":`application/json`},method:`POST`}));if(!r.ok)throw new yU({message:await r.text()||`Failed to bootstrap auth session (${r.status}).`,status:r.status});return SU(r,n)})}function MU(e){return new URL(e,window.location.origin).toString()}function NU(e){let t=(e?.primaryMode===`cloud`?null:e)?.bootstrapToken?.trim();return t&&t.length>0?t:null}function PU(){return typeof window>`u`?null:NU(window.desktopBridge?.getLocalEnvironmentBootstrap?.()??null)}function pVe(){return typeof window>`u`?!1:Cne()===`session-expired`}function FU(){if(typeof window>`u`)return new Set;try{let e=window.sessionStorage.getItem(OU),t=e?JSON.parse(e):[];return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function IU(e){if(!(typeof window>`u`))try{if(e.size===0){window.sessionStorage.removeItem(OU);return}window.sessionStorage.setItem(OU,JSON.stringify([...e]))}catch{}}function mVe(){let e=PU();if(!e)return;let t=new Set(FU());t.add(e),IU(t)}function hVe(e){return FU().has(e)}function LU(){let e=PU();if(!e){IU(new Set);return}let t=new Set(FU());t.delete(e),IU(t)}async function RU(){let e=MU(`/api/auth/session`),t=await fetch(e,{credentials:`include`});return t.ok?SU(t,e):null}async function gVe(e){if(typeof window>`u`)return;let t=NU(e);if(!t||pVe()||DU.has(t)||hVe(t))return;if((await RU().catch(()=>null))?.authenticated){DU.add(t);return}let n=MU(`/api/auth/bootstrap`),r=await fetch(n,{body:JSON.stringify({credential:t}),credentials:`include`,headers:{"content-type":`application/json`},method:`POST`});if(!r.ok){if(r.status===401)return;throw new yU({message:await r.text()||`Failed to bootstrap local web owner session (${r.status}).`,status:r.status})}await SU(r,n),DU.add(t)}async function _Ve(){let e=await dVe();if(e.authenticated)return e;let t=_n();if(t?.source!==`desktop-managed`||!t.bearerToken)return e;let n=await RU().catch(()=>null);return n?.authenticated?n:e}var vVe=new Set([404,502,503,504]),yVe=15e3,bVe=500;function xVe(e){_n()?.source===`paired-bearer`&&xU(e)&&dn(`http`)}async function zU(e){let t=Date.now();for(;;)try{return await e()}catch(e){if(xVe(e),!CVe(e))throw e;if(Date.now()-t>=yVe)throw IH(e,{route:`bootstrap-retry-exhausted`}),e;await SVe(bVe)}}function SVe(e){return new Promise(t=>{setTimeout(t,e)})}function CVe(e){return bU(e)?vVe.has(e.status):e instanceof TypeError||e instanceof DOMException&&e.name===`AbortError`}function wVe(e,t){return e.sessionLifecycle.status===`ready`?e.sessionLifecycle.principalId!==t.id||e.cmmd.identity?.id!==t.id?`desktop-principal-mismatch`:null:`desktop-session-required`}async function TVe(e){if(typeof window>`u`||!window.desktopBridge)return null;let t=window.desktopBridge.desktopAuth?.getState;if(!t)return`desktop-state-unavailable`;try{return wVe(await t(),e)}catch(e){return IH(e,{route:`desktop-auth-gate-state`}),`desktop-state-unavailable`}}async function EVe(e,t){return FH(null),_ne(t),await hn().catch(e=>{IH(e,{route:`desktop-auth-gate-logout`})}),{status:`requires-auth`,auth:e.auth,errorMessage:Tne(t)??`Forge Desktop requires CMMD authentication.`}}async function DVe(){let e=await _Ve();if(e.authenticated){if(e.cmmdIdentity){let t=await TVe(e.cmmdIdentity);return t?(vn(),EVe(e,t)):(vn(),lVe(e.cmmdIdentity),{status:`authenticated`})}return{status:`requires-auth`,auth:e.auth}}return{status:`requires-auth`,auth:e.auth}}async function OVe(e){let t=e.trim();if(!t)throw Error(`Enter a pairing token to continue.`);TU=null,LU(),await fVe(t),wU=null,AU()}function BU(){LU(),TU=null,wU=null}async function VU(e,t,n){let r=e.trim();if(!r)throw Error(`CMMD (Command) OAuth did not return an access token.`);let i=n?.refreshToken?.trim(),a=n?.mcpToken?.trim(),o=fn(`/api/auth/bootstrap/command`),s=await fetch(o,gn({body:JSON.stringify({accessToken:r,...i?{refreshToken:i}:{},...a?{mcpToken:a}:{},...t===void 0?{}:{user:t}}),credentials:`include`,headers:{"content-type":`application/json`},method:`POST`}));if(!s.ok)throw new yU({message:await s.text()||`Failed to bootstrap with CMMD OAuth token (${s.status}).`,status:s.status});await SU(s,o),BU()}async function kVe(){let e=fn(`/api/auth/ws-token`),t=await fetch(e,gn({credentials:`include`,method:`POST`}));if(!t.ok)throw new yU({message:await t.text()||`Failed to issue websocket token (${t.status}).`,status:t.status});return SU(t,e)}async function AVe(e){let t=await kVe(),n=new URL(e,window.location.origin);return n.searchParams.set(`wsToken`,t.token),n.toString()}async function jVe(){let e=new URL(`/api/auth/session`,window.location.origin).toString(),t=await fetch(e,{credentials:`include`});if(!t.ok)throw new yU({message:`Failed to load current app auth session state (${t.status}).`,status:t.status});return MVe(await SU(t,e))}function MVe(e){if(!e.authenticated||!e.role)throw Error(`Authenticated session is required.`);let t=NVe(e.cmmdIdentity??null);return t?{displayName:t,email:e.cmmdIdentity?.email??null,avatarUrl:e.cmmdIdentity?.avatarUrl??null,role:e.role,verified:!0,source:`cmmd-identity`}:{displayName:`CMMD identity unavailable`,email:null,avatarUrl:null,role:e.role,verified:!1,source:`fallback`}}function NVe(e){return e&&([e.firstName,e.lastName].map(e=>e?.trim()??``).filter(e=>e.length>0).join(` `)||e.username.trim()||e.email.trim())||null}async function PVe(e){let t=`/api/cmmd/work-intake`,n;try{n=await j({method:`GET`,path:t,allowRetry:!1,...e?{query:{fresh:1}}:{}},CU())}catch(e){throw e instanceof xn&&e.kind!==`auth`&&e.code!==null&&jU.has(e.code)?new xn({kind:`auth`,message:e.message,status:e.status??401,code:e.code}):e}if(!n)throw Error(`Invalid response from ${t}`);return n}async function FVe(e={}){return PVe(e.forceFresh===!0)}async function HU(e,t){try{return await j({method:`POST`,path:e,body:t,allowRetry:!1},CU())}catch(e){throw e instanceof xn&&e.kind!==`auth`&&e.code!==null&&jU.has(e.code)?new xn({kind:`auth`,message:e.message,status:e.status??401,code:e.code}):e}}async function IVe(e){try{return await HU(`/api/cmmd/tasks/update`,e)}catch(t){if(t instanceof xn&&(t.kind===`auth`||t.kind===`permission`))throw t;if(t instanceof xn||t instanceof Error)return HU(`/api/command/tasks/update`,e);throw t}}async function LVe(){typeof window>`u`||await window.desktopBridge?.desktopAuth?.logoutCloud?.()}async function RVe(){let e=await Promise.allSettled([hn(),LVe()]);FH(null),mVe(),wU=null,TU=null;let t=e.find(e=>e.status===`rejected`);if(t)throw t.reason}async function zVe(){if(kU(),TU?.status===`authenticated`)return vn(),TU;if(wU)return wU;let e=UU();return wU=e,e.then(e=>(e.status===`authenticated`&&(TU=e),e)).finally(()=>{wU===e&&(wU=null)})}async function UU(){return mn().then(e=>gVe(e)).then(()=>DVe())}async function BVe(){kU(),wU=null,TU=null;let e=await UU();return e.status===`authenticated`&&(TU=e,vn()),e}function VVe(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/u,``)}function HVe(e){let t=VVe(e).replace(/-/g,`+`).replace(/_/g,`/`);return`-----BEGIN PUBLIC KEY-----\n${((t+`=`.repeat((4-t.length%4)%4)).match(/.{1,64}/gu)??[]).join(`
1005
+ If init has been called in the preload and contextIsolation is disabled, is not required to call init in the renderer`);return}window.__SENTRY__RENDERER_INIT__=!0,e.sendClientReports=!1,e.defaultIntegrations===void 0&&(e.defaultIntegrations=mH(e)),e.stackParser===void 0&&(e.stackParser=uH),e.ipcNamespace===void 0&&(e.ipcNamespace=`sentry-ipc`),e.dsn===void 0&&(e.dsn=`https://12345@dummy.dsn/12345`),e.transport===void 0&&(e.transport=pH),delete e.initialScope,t(e)}var gH=e({BrowserClient:()=>qF,MULTIPLEXED_TRANSPORT_EXTRA_KEY:()=>ZEe,OpenFeatureIntegrationHook:()=>Cze,SEMANTIC_ATTRIBUTE_SENTRY_OP:()=>pE,SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN:()=>mE,SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE:()=>fE,SEMANTIC_ATTRIBUTE_SENTRY_SOURCE:()=>dE,Scope:()=>XT,addBreadcrumb:()=>qk,addEventProcessor:()=>IO,addIntegration:()=>KO,bindScopeToEmitter:()=>TTe,breadcrumbsIntegration:()=>wL,browserApiErrorsIntegration:()=>TL,browserProfilingIntegration:()=>mze,browserSessionIntegration:()=>DL,browserTracingIntegration:()=>MV,buildLaunchDarklyFlagUsedHandler:()=>xze,captureConsoleIntegration:()=>EDe,captureEvent:()=>jO,captureException:()=>kO,captureFeedback:()=>PA,captureMessage:()=>AO,captureSession:()=>BO,chromeStackLineParser:()=>xL,consoleLoggingIntegration:()=>AOe,contextLinesIntegration:()=>iPe,continueTrace:()=>fTe,createConsolaReporter:()=>NOe,createLangChainCallbackHandler:()=>OM,createTransport:()=>mk,createUserFeedbackEnvelope:()=>cNe,dedupeIntegration:()=>pA,defaultRequestInstrumentationOptions:()=>SV,defaultStackParser:()=>uH,elementTimingIntegration:()=>CMe,endSession:()=>RO,eventFiltersIntegration:()=>Xk,eventFromException:()=>UF,eventFromMessage:()=>WF,eventLoopBlockIntegration:()=>Ize,exceptionFromError:()=>zF,extraErrorDataIntegration:()=>NDe,featureFlagsIntegration:()=>_Oe,feedbackAsyncIntegration:()=>oje,feedbackIntegration:()=>RF,feedbackSyncIntegration:()=>RF,fetchStreamPerformanceIntegration:()=>DV,forceLoad:()=>BNe,functionToStringIntegration:()=>Yk,getAbsoluteUrl:()=>qMe,getActiveSpan:()=>uD,getClient:()=>q,getCurrentScope:()=>K,getDefaultIntegrations:()=>mH,getFeedback:()=>pAe,getGlobalScope:()=>cE,getIsolationScope:()=>sE,getReplay:()=>eRe,getRootSpan:()=>cD,getSpanDescendants:()=>sD,getSpanStatusFromHttpCode:()=>xE,getTraceData:()=>Kk,globalHandlersIntegration:()=>kL,graphqlClientIntegration:()=>fPe,growthbookIntegration:()=>Eze,httpClientIntegration:()=>KNe,httpContextIntegration:()=>PL,inboundFiltersIntegration:()=>Zk,init:()=>hH,instrumentAnthropicAiClient:()=>Yke,instrumentCreateReactAgent:()=>JM,instrumentGoogleGenAIClient:()=>aM,instrumentLangChainEmbeddings:()=>NM,instrumentLangGraph:()=>YM,instrumentOpenAiClient:()=>Ake,instrumentOutgoingRequests:()=>CV,instrumentSupabaseClient:()=>TA,isBotUserAgent:()=>jV,isEnabled:()=>FO,isInitialized:()=>sEe,lastEventId:()=>PO,launchDarklyIntegration:()=>bze,linkedErrorsIntegration:()=>FL,logger:()=>MN,makeRendererTransport:()=>pH,metrics:()=>BN,moduleMetadataIntegration:()=>CDe,normalizeStringifyValue:()=>IL,onLoad:()=>VNe,openFeatureIntegration:()=>Sze,parameterize:()=>Gk,registerSpanErrorInstrumentation:()=>pD,registerWebWorker:()=>jze,replayCanvasIntegration:()=>yRe,replayIntegration:()=>KB,reportPageLoaded:()=>VRe,reportingObserverIntegration:()=>WNe,rewriteFramesIntegration:()=>VDe,scopeToMainIntegration:()=>fH,sendFeedback:()=>hP,setActiveSpanInBrowser:()=>HRe,setAttribute:()=>aEe,setAttributes:()=>iEe,setContext:()=>MO,setConversationId:()=>oEe,setCurrentClient:()=>Nk,setExtra:()=>tEe,setExtras:()=>eEe,setHttpStatus:()=>SE,setMeasurement:()=>FD,setTag:()=>rEe,setTags:()=>nEe,setUser:()=>NO,showReportDialog:()=>RL,spanStreamingIntegration:()=>URe,spanToBaggageHeader:()=>Jwe,spanToJSON:()=>JE,spanToTraceHeader:()=>UE,spotlightBrowserIntegration:()=>yze,startBrowserTracingNavigationSpan:()=>PV,startBrowserTracingPageLoadSpan:()=>NV,startInactiveSpan:()=>qD,startNewTrace:()=>XD,startSession:()=>LO,startSpan:()=>GD,startSpanManual:()=>KD,statsigIntegration:()=>Dze,supabaseIntegration:()=>tOe,suppressTracing:()=>pTe,thirdPartyErrorFilterIntegration:()=>uOe,uiProfiler:()=>QMe,unleashIntegration:()=>wze,updateSpanName:()=>Uwe,viewHierarchyIntegration:()=>pPe,webVitalsIntegration:()=>OV,webWorkerIntegration:()=>kze,withActiveSpan:()=>JD,withIsolationScope:()=>fwe,withScope:()=>lE,withStreamedSpan:()=>Ywe,zodErrorsIntegration:()=>lOe}),Rze=100,zze=5,Bze=[`ResizeObserver loop completed with undelivered notifications.`,`ResizeObserver loop limit exceeded`,`AbortError`,`The user aborted a request.`,`Network request failed`,`NetworkError when attempting to fetch resource.`,`Failed to fetch`,`ChunkLoadError`,`Loading chunk`,`Loading CSS chunk`,`Non-Error promise rejection captured with value: Object Not Found Matching Id`];function _H(e){if(e)for(let t of Object.keys(e))/token|secret|password|api[_-]?key/i.test(t)&&(e[t]=`[redacted]`)}function Vze(e){e.request?.url&&(e.request.url=e.request.url.replace(/([?&](?:code|token|access_token|state)=)[^&]+/gi,`$1[redacted]`)),_H(e.extra),_H(e.tags)}function Hze(e){let t=yH(e.version)??`0.0.0`,n=yH(e.commitHash);return n?`${e.appName}@${t}+${n}`:`${e.appName}@${t}`}function vH(e,t){for(let n of t){let t=yH(e[n]);if(t)return t}}function Uze(e){return bH(e.enabled)??e.defaultEnabled??!1}function Wze(e){let t=yH(e.dsn);return!t||Uze(e)===!1?null:{dsn:t,environment:yH(e.environment)??yH(e.defaultEnvironment)??`production`,release:yH(e.release)??yH(e.defaultRelease)??void 0,debug:bH(e.debug)??e.defaultDebug??!1,tracesSampleRate:SH(e.tracesSampleRate,e.defaultTracesSampleRate??.1),profilesSampleRate:xH(e.profilesSampleRate,e.defaultProfilesSampleRate),replaysSessionSampleRate:xH(e.replaysSessionSampleRate,e.defaultReplaysSessionSampleRate),replaysOnErrorSampleRate:xH(e.replaysOnErrorSampleRate,e.defaultReplaysOnErrorSampleRate),attachStacktrace:!0,maxBreadcrumbs:Rze,normalizeDepth:zze,tags:Gze(e)}}function Gze(e){let t={app:e.appName,runtime:e.runtime};for(let[n,r]of Object.entries(e.tags??{})){let e=yH(r);e&&(t[n]=e)}return t}function yH(e){if(e==null)return null;let t=e.trim();return t.length>0?t:null}function bH(e){if(typeof e==`boolean`)return e;let t=yH(e);if(t){if(t===`1`||t.toLowerCase()===`true`)return!0;if(t===`0`||t.toLowerCase()===`false`)return!1}}function xH(e,t){if(t!==void 0||e!==void 0)return SH(e,t??0)}function SH(e,t){let n=Kze(e);return n===null||n<0||n>1?t:n}function Kze(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;let t=yH(e);if(!t)return null;let n=Number.parseFloat(t);return Number.isFinite(n)?n:null}function qze(e){let t=(0,hi.c)(11),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=pt(Ei,`bg-background text-foreground`),t[0]=n):n=t[0];let r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=pt(wi,`pl-1 md:pl-2.5`),t[1]=r):r=t[1];let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,N.jsx)(Oi,{}),t[2]=i):i=t[2];let a;t[3]===e.onGoToNewChat?a=t[4]:(a=(0,N.jsx)(`div`,{className:r,children:(0,N.jsx)(`button`,{type:`button`,"aria-label":`Go to new chat`,onClick:e.onGoToNewChat,className:`${Ti} hover:bg-accent/70`,children:i})}),t[3]=e.onGoToNewChat,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,N.jsx)(`div`,{}),t[5]=o):o=t[5];let s;t[6]===a?s=t[7]:(s=(0,N.jsxs)(`header`,{className:Ci,children:[a,o]}),t[6]=a,t[7]=s);let c;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,N.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-4`,children:(0,N.jsxs)(`div`,{className:`max-w-md rounded-xl border border-border bg-card p-6 text-center shadow-lg`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Something went wrong.`}),(0,N.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Forge hit an unexpected error and reported it.`}),(0,N.jsx)(`button`,{className:`mt-4 inline-flex rounded-md border border-border px-3 py-2 text-sm font-medium hover:bg-accent`,onClick:Jze,type:`button`,children:`Reload app`})]})}),t[8]=c):c=t[8];let l;return t[9]===s?l=t[10]:(l=(0,N.jsxs)(`div`,{className:n,children:[s,c]}),t[9]=s,t[10]=l),l}function Jze(){return window.location.reload()}var Yze=[/\bDeepSeek\b/i,/\bKimi\b/i,/\bMoonshot\b/i,/\bdeepseek[-._a-z0-9]*\b/i,/\bkimi[-._a-z0-9]*\b/i,/\bmoonshot[-._a-z0-9]*\b/i,/\bAPEX_API_KEY\b/,/\bDEEPSEEK_API_KEY\b/,/\bKIMI_API_KEY\b/,/\bOPENAI_API_KEY\b/,/\bANTHROPIC_API_KEY\b/,/\bCURSOR_API_KEY\b/,/\bOPENCODE_API_KEY\b/,/\bforge_proxy_[A-Za-z0-9._-]+\b/,/\bProviderValidationError\b/,/\/forge-server\/node_modules\//,/https?:\/\/[^\s'"<>)]*\/api\/provider-egress\/[^\s'"<>)]*/i,/https?:\/\/[^\s'"<>)]*(?:apex|deepseek|moonshot|kimi)[^\s'"<>)]*/i],Xze=`CMMD is temporarily unavailable. Check the workspace AI connection and retry.`;function CH(e){if(!e)return!1;let t=e.toLowerCase();return/\b(rate[\s-]?limit|too\s+many\s+requests|usage[ _-]limit|usage_limit_reached|quota|insufficient_quota)\b/.test(t)||/\b429\b/.test(t)}function Zze(e){return/\bbound to provider account\b/.test(e)&&/\bcannot use provider account\b/.test(e)?`Forge could not switch this conversation to the selected AI account. Retry the account switch.`:/\bforge_runtime_repairing\b/.test(e)||/\bthis turn was interrupted because the environment is being repaired\b/.test(e)?`This turn was interrupted because the environment is being repaired. Retry after the repair finishes.`:/\bforge_runtime_stopped\b/.test(e)||/\bthis turn was interrupted because the environment was stopped\b/.test(e)?`This turn was interrupted because the environment was stopped. Start the environment and retry.`:null}function Qze(e){if(!e)return null;let t=e.toLowerCase(),n=Zze(t);return n===null?/\bforge_provider_model_not_allowed\b/.test(t)||/\bnot\s+scoped\s+to\s+the\s+requested\s+model\b/.test(t)?`The workspace AI credential does not cover the model this turn asked for. Retry, or pick that model for the thread.`:/\bmodel\b[\s\S]*\b(not\s+(found|available|supported)|does\s+not\s+exist|unsupported|invalid|unknown)\b/.test(t)||/\b(unsupported|unknown|invalid)\b[\s\S]*\bmodel\b/.test(t)||/\b(model_not_found|invalid_model|model_not_supported)\b/.test(t)?`The selected model isn't available right now. Pick a different model and retry.`:CH(t)?`The AI service is rate-limited or out of quota. Wait a moment and retry.`:/_credential_reconnect_required\b/.test(t)?`The workspace AI credential needs to be reconnected. Reconnect it in Settings > Providers, then retry.`:/\b(unauthorized|forbidden|authentication\s+(failed|error|required)|invalid\s+api\s+key|expired\s+(token|credential))\b/.test(t)||/\b40[13]\b/.test(t)?`Workspace AI authentication failed. Reconnect the workspace and retry.`:/\b(timed?\s*out|timeout|overloaded|service\s+unavailable)\b/.test(t)||/\b50[234]\b/.test(t)?`The AI service is temporarily overloaded. Retry in a moment.`:null:n}function $ze(e){return e?Yze.some(t=>t.test(e)):!1}function wH(e,t={}){if(e==null)return null;let n=e.trim();return n.length===0?null:$ze(n)?Qze(n)??t.fallback??`CMMD is temporarily unavailable. Check the workspace AI connection and retry.`:n}var eBe=[/\bSocketCloseError\b/i,/\bSocketOpenError\b/i,/\bSocketReadError\b/i,/\bRpcClientDefect:\s*Unknown socket error\b/i,/Unable to connect to the Forge server WebSocket\./i,/\bping timeout\b/i];function TH(e){if(typeof e!=`string`)return!1;let t=e.trim();return t.length!==0&&eBe.some(e=>e.test(t))}function EH(e){return TH(e)?null:wH(e,{fallback:Xze})}var tBe=[/^Transport disposed$/,/WebSocket RPC request timed out after \d+ms\./],nBe=`Lost the connection to this Environment. Your message was not sent.`;function rBe(e){return e instanceof Error?TH(e.message)||tBe.some(t=>t.test(e.message.trim()))?nBe:e.message:`Failed to send message.`}var DH=`forge-web`,OH=[`VITE_SENTRY_ENVIRONMENT`,`MODE`],kH=[`VITE_SENTRY_RELEASE`],iBe=[`VITE_SENTRY_DSN`],aBe=[`VITE_SENTRY_DEBUG`],oBe=[`VITE_SENTRY_ENABLED`],sBe=[`VITE_SENTRY_TRACES_SAMPLE_RATE`],cBe=[`VITE_SENTRY_PROFILES_SAMPLE_RATE`],lBe=[`VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE`],uBe=[`VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE`],dBe=[`VITE_SENTRY_COMMIT_SHA`,`VITE_COMMIT_SHA`],AH=!1,jH={autoInject:!1,colorScheme:`system`,formTitle:`Report a Bug`,themeLight:{accentBackground:`oklch(0.52 0.19 48)`,accentForeground:`#ffffff`,background:`#ffffff`,boxShadow:`0 24px 80px rgba(0, 0, 0, 0.18)`,foreground:`#262626`,outline:`1px solid oklch(0.52 0.19 48)`},themeDark:{accentBackground:`oklch(0.62 0.2 47)`,accentForeground:`#ffffff`,background:`#171717`,boxShadow:`0 24px 80px rgba(0, 0, 0, 0.45)`,foreground:`#f5f5f5`,outline:`1px solid oklch(0.62 0.2 47)`}};function fBe(e){let t=e.exception&&typeof e.exception==`object`&&`values`in e.exception&&Array.isArray(e.exception.values)?e.exception.values:[];return[typeof e.title==`string`?e.title:void 0,...t.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e;return[typeof t.type==`string`?t.type:void 0,typeof t.value==`string`?t.value:void 0]})]}function pBe(e){return(e.exception&&typeof e.exception==`object`&&`values`in e.exception&&Array.isArray(e.exception.values)?e.exception.values:[]).some(e=>{if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.value!=`string`||!/All fibers interrupted without error/i.test(t.value)?!1:t.stacktrace?.frames?.some(e=>{let t=typeof e.filename==`string`?e.filename:``,n=typeof e.function==`string`?e.function:``;return t.includes(`src/rpc/wsTransport.ts`)&&n===`WsTransport.request`})})}function mBe(e){return fBe(e).some(TH)||pBe(e)}function hBe(){let e=new URL(window.location.href);Rn?e.hash=`/new`:(e.pathname=`/new`,e.search=``,e.hash=``),window.location.assign(e.toString())}function gBe(){let e=Rn?`electron-renderer`:`browser`,t={APP_VERSION:`0.13.4`,BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`,VITE_COMMIT_SHA:``,VITE_HOSTED_APP_CHANNEL:``,VITE_HTTP_URL:``,VITE_SENTRY_COMMIT_SHA:`c825d8a74e28836b97016dbd8c2abc730841a622`,VITE_SENTRY_DEBUG:``,VITE_SENTRY_DSN:``,VITE_SENTRY_ENABLED:``,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_PROFILES_SAMPLE_RATE:``,VITE_SENTRY_RELEASE:`forge-web@0.13.4+c825d8a74e28836b97016dbd8c2abc730841a622`,VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE:``,VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE:``,VITE_SENTRY_TRACES_SAMPLE_RATE:``,VITE_WS_URL:``},n=vH(t,[...kH])??Hze({appName:DH,version:`0.13.4`,commitHash:vH(t,[...dBe])});return Wze({appName:DH,runtime:e,defaultEnvironment:vH(t,[...OH])??`development`,defaultRelease:n,defaultEnabled:!0,defaultTracesSampleRate:0,defaultReplaysSessionSampleRate:0,defaultReplaysOnErrorSampleRate:0,enabled:vH(t,[...oBe]),dsn:vH(t,[...iBe]),environment:vH(t,[...OH]),release:vH(t,[...kH]),debug:vH(t,[...aBe]),tracesSampleRate:vH(t,[...sBe]),profilesSampleRate:vH(t,[...cBe]),replaysSessionSampleRate:vH(t,[...lBe]),replaysOnErrorSampleRate:vH(t,[...uBe]),tags:{platform:Rn?`desktop`:`web`}})}function MH(e){return Vze(e),mBe(e)?null:e}function _Be(e){return{...e.replaysOnErrorSampleRate===void 0?{}:{replaysOnErrorSampleRate:e.replaysOnErrorSampleRate},...e.replaysSessionSampleRate===void 0?{}:{replaysSessionSampleRate:e.replaysSessionSampleRate}}}function NH(e){return{attachStacktrace:e.attachStacktrace,debug:e.debug,dsn:e.dsn,environment:e.environment,ignoreErrors:[...Bze],initialScope:{tags:e.tags},maxBreadcrumbs:e.maxBreadcrumbs,normalizeDepth:e.normalizeDepth,sendDefaultPii:!1,tracesSampleRate:e.tracesSampleRate,...e.release===void 0?{}:{release:e.release},..._Be(e)}}function vBe(e){let t=[];e.tracesSampleRate>0&&t.push(MV()),((e.replaysSessionSampleRate??0)>0||(e.replaysOnErrorSampleRate??0)>0)&&t.push(KB());let n=RF(jH);t.push(n);try{hH({...NH(e),beforeSend:e=>MH(e),integrations:t})}catch{return null}return AH=!0,gH}function yBe(e){let t=[];e.tracesSampleRate>0&&t.push(lS()),((e.replaysSessionSampleRate??0)>0||(e.replaysOnErrorSampleRate??0)>0)&&t.push(dx());let n=Bh(jH);t.push(n);try{US({...NH(e),beforeSend:e=>MH(e),integrations:t})}catch{return null}return AH=!0,_w}function PH(){if(AH)return Rn?gH:_w;let e=gBe();return e?Rn?vBe(e):yBe(e):null}function FH(e){if(PH()){if(Rn){NO(e);return}Zl(e)}}function IH(e,t,n){if(!PH())return;let r=bBe(e);if(Rn){lE(e=>{t&&e.setTags(t);let i=kO(r);n?.showReportDialog&&RL({eventId:i})});return}ts(e=>{t&&e.setTags(t);let i=Vl(r);n?.showReportDialog&&q_({eventId:i})})}function bBe(e){if(e instanceof Error)return e;if(typeof e==`string`&&e.trim().length>0)return Error(e);try{return Error(JSON.stringify(e))}catch{return Error(`Unknown non-Error exception`)}}var xBe=class extends M.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){IH(e,{origin:`react-boundary`},{showReportDialog:!0})}render(){return this.state.hasError?(0,N.jsx)(qze,{onGoToNewChat:hBe}):this.props.children}},LH=!1,RH=!1,zH=null,BH=null,VH=null,HH=!1,UH=new Set;function SBe(e){if(LH||RH)return;if(!e.publicKey||!e.host){RH=!0;return}if(zH)return;if(typeof window>`u`||typeof location>`u`){RH=!0;return}let t=e.publicKey,n=e.host;zH=A(async()=>{let{default:e}=await import(`./module-CPO4cjSm.js`);return{default:e}},[]).then(({default:e})=>{BH=e,e.init(t,{api_host:n,person_profiles:`identified_only`,capture_pageview:!1,capture_pageleave:!1,autocapture:!1,disable_session_recording:!0,loaded:()=>{LH=!0,VH&&WH(VH),GH(),UH.forEach(e=>e())}})}).catch(()=>{RH=!0,BH=null})}function WH(e){if(VH=e,!LH||!BH)return;let t={};e.email!==void 0&&(t.email=e.email),e.displayName!==void 0&&(t.name=e.displayName),BH.identify(e.cmmdUserId,t)}function CBe(e){return!LH||!BH?!1:BH.isFeatureEnabled(e)===!0}function GH(){!BH||HH||(HH=!0,BH.onFeatureFlags(()=>{UH.forEach(e=>e())}))}function wBe(e){return UH.add(e),LH&&BH&&(GH(),e()),()=>{UH.delete(e)}}var KH=`/api/cmmd/auth-runtime`;function TBe(e){return j({method:`POST`,path:KH},e)}function EBe(e){return j({method:`GET`,path:KH},e)}function DBe(e){return j({method:`DELETE`,path:KH},e)}function OBe(e){return j({method:`POST`,path:`${KH}/connect`},e)}function kBe(e,t){return j({method:`GET`,path:`/api/cmmd/billing`,...t?.organizationId===void 0?{}:{query:{orgId:t.organizationId}}},e)}function ABe(e,t){return j({method:`GET`,path:`/api/cmmd/billing/series`,query:{timeZone:t.timeZone}},e)}var qH=`/api/cmmd/providers/codex/credential`,JH=`/api/cmmd/providers/claude/credential`;function jBe(e){return j({method:`GET`,path:qH},e)}function MBe(e){return j({method:`DELETE`,path:qH},e)}function NBe(e){return j({method:`GET`,path:JH},e)}function PBe(e){return j({method:`DELETE`,path:JH},e)}function FBe(e,t){return j({method:`DELETE`,path:`/api/cmmd/providers/accounts/${encodeURIComponent(String(t))}`},e)}function IBe(e,t,n){return`/api/cmmd/threads/${encodeURIComponent(e)}/${encodeURIComponent(t)}/${encodeURIComponent(n)}/disposition`}function LBe(e,t,n,r,i){return j({method:`PUT`,path:IBe(t,n,r),body:i},e)}function RBe(e){return(t,n,r,i)=>LBe(e,t,n,r,i)}function zBe(e,t,n){return`/api/cmmd/threads/${encodeURIComponent(e)}/${encodeURIComponent(t)}/${encodeURIComponent(n)}/archive`}function BBe(e,t,n,r,i){return j({method:`POST`,path:zBe(t,n,r),body:i},e)}function VBe(e){return(t,n,r,i)=>BBe(e,t,n,r,i)}function HBe(e){return typeof e==`object`&&!!e&&`status`in e&&e.status===409}async function UBe(e){let t={action:e.action,...e.operationId===void 0?{}:{operationId:e.operationId},expectedRevision:e.expectedRevision,force:e.force};try{return await e.submit(t)}catch(n){if(!HBe(n))throw n;let r=await e.refresh();return e.submit({...t,expectedRevision:r.revision})}}function WBe(e,t,n){return j({method:`POST`,path:`/api/cmmd/forge-runtimes/${encodeURIComponent(t)}/rename`,body:{displayName:n}},e)}function GBe(e,t,n){return j({method:`POST`,path:`/api/cmmd/devices/${encodeURIComponent(String(t))}/rename`,body:{displayName:n}},e)}function KBe(e,t){return j({method:`POST`,path:`/api/cmmd/devices/${encodeURIComponent(String(t))}/revoke`},e)}function qBe(e){return{...e?.projectId===void 0?{}:{projectId:String(e.projectId)},...e?.allWorkspaces===!0?{allWorkspaces:`true`}:{},...e?.organizationId===void 0?{}:{orgId:String(e.organizationId)}}}var YH=`rt-demo`,XH=`th-demo`,ZH=`example-project`,JBe=`example-conversation`,QH=`2026-09-26T20:00:00.000Z`;function YBe(e,t){return e===YH&&t===XH}function XBe(){return{runtime:{id:YH,source:`forge-cloud`,runtimeKind:`cloud-vm`,displayName:`Example Forge Server`,status:`online`,endpointUrl:null,hostId:null,deviceId:null,workspaceRoot:null,githubRepoFullName:null,lastSeenAt:QH,reachability:{status:`online`,lastReachableAt:QH,source:`cloud-runtime`},metadata:null},inventoryStatus:`synced`,inventoryPublishedAt:QH,projectCount:1,threadCount:1,projects:[{projectId:ZH,title:`Example project`,workspaceRoot:null,githubRepoFullName:null,branch:null,status:`active`,threadCount:1,lastActivityAt:QH,metadata:null,publishedAt:QH,updatedAt:QH,threads:[{threadId:XH,title:`Example thread (viewer check)`,status:`active`,model:null,provider:null,providerAccountId:null,branch:null,lastMessagePreview:null,lastActivityAt:QH,kind:`master`,parentThreadId:null,workerRole:null,anchorKind:`scratch`,anchorCmmdId:null,archive:null,disposition:{manualDisposition:null,automaticDisposition:null,effectiveDisposition:null,revision:null,source:null},metadata:null,publishedAt:QH,updatedAt:QH}]}]}}function ZBe(){return{conversationId:JBe,runtime:{id:YH,source:`forge-cloud`,runtimeKind:`cloud-vm`,displayName:`Example Forge Server`,status:`online`,endpointUrl:null,deviceId:null,workspaceRoot:null,githubRepoFullName:null,lastSeenAt:QH,metadata:null},project:{projectId:ZH,title:`Example project`,githubRepoFullName:null,branch:null},thread:{threadId:XH,title:`Example thread (viewer check)`,status:`active`,model:null,provider:null,providerAccountId:null,branch:null,lastActivityAt:QH,metadata:null},reachability:`online`,execution:{available:!0,reason:null},replication:null,events:[{sequence:1,eventId:`example-user-1`,kind:`user_message`,turnId:null,text:`This is an example chat thread for verifying the Forge embed viewer. It is not a live Work Session.`,status:null,occurredAt:`2026-09-26T19:58:00.000Z`},{sequence:2,eventId:`example-assistant-1`,kind:`assistant_message`,turnId:null,text:`Understood. You should see this reply in the iframe under CMMD /forge, with the composer still available below.`,status:null,occurredAt:`2026-09-26T19:59:00.000Z`},{sequence:3,eventId:`example-user-2`,kind:`user_message`,turnId:null,text:`Thanks. If these three turns render, the thread wire is working.`,status:null,occurredAt:QH}]}}function QBe(e){return e.runtimes.some(e=>e.runtime.id===YH)?{...e,runtimes:[...e.runtimes]}:{...e,runtimes:[...e.runtimes,XBe()]}}function $H(e,t){if(!e||typeof e!=`object`)return null;let n=e[t];return typeof n==`string`&&n.trim().length>0?n.trim():null}function $Be(e,t){if(!e||typeof e!=`object`)return null;let n=e[t];return typeof n==`boolean`?n:null}function eU(e,t){if(!e||typeof e!=`object`)return null;let n=e[t];return typeof n==`string`&&n.trim().length>0?n.trim():typeof n==`number`&&Number.isFinite(n)?String(n):null}function tU(e){return{...e.limit===void 0?{}:{limit:e.limit},...e.cursor?{cursor:e.cursor}:{}}}var eVe=class extends Error{constructor(e){super(e),this.name=`CmmdApiAuthError`}},tVe=class extends Error{status;constructor(e,t){super(e),this.name=`CmmdApiServerError`,this.status=t}},nU=class extends Error{constructor(e){super(`CmmdApiClient.${e} is not implemented yet`),this.name=`CmmdApiNotImplementedError`}};function rU(e,t){if(Array.isArray(e))return e;if(e&&typeof e==`object`){let n=e[t];if(Array.isArray(n))return n}return[]}function iU(e,t){if(Array.isArray(e))return e;if(e&&typeof e==`object`){let n=e[t];if(Array.isArray(n))return n}return[]}function aU(e,t){let n={};return e?.organizationId&&(n.orgId=e.organizationId),t!==void 0&&(n.taskId=String(t)),Object.keys(n).length>0?n:void 0}function oU(e){let t=`${$H(e,`firstName`)??``} ${$H(e,`lastName`)??``}`.trim()||$H(e,`username`)||$H(e,`email`)||`Unknown`;return{id:eU(e,`userId`)??eU(e,`id`)??t,name:t,email:$H(e,`email`),role:$H(e,`role`),avatarUrl:$H(e,`profileImage`)??$H(e,`avatar`)}}function nVe(e){let t=cU(e,`user`)??e;return oU({...typeof t==`object`&&t?t:{},userId:eU(e,`userId`)??eU(t,`id`),role:$H(e,`role`)})}function sU(e){let t=$H(e,`authorFirstName`)??``,n=$H(e,`authorLastName`)??``,r=$H(e,`status`),i=r===`at_risk`||r===`off_track`||r===`complete`?r:`on_track`;return{id:eU(e,`id`)??``,status:i,body:$H(e,`body`)??``,authorName:`${t} ${n}`.trim()||null,authorAvatarUrl:$H(e,`authorProfileImage`)??null,createdAt:$H(e,`createdAt`)??``,updatedAt:$H(e,`updatedAt`)??$H(e,`createdAt`)??``,canEdit:$Be(e,`canEdit`)??!1}}function rVe(e,t,n){let r=Array.isArray(e.data)?e.data.map(sU):[];return{updates:r,pagination:e.pagination??{page:t,limit:n,total:r.length,hasMore:!1}}}function cU(e,t){if(!e||typeof e!=`object`)return null;let n=e[t];return n&&typeof n==`object`?n:null}var iVe=[`avatarUrl`,`avatar_url`,`profileImage`,`profile_image`,`profileImageUrl`,`profile_image_url`,`image`,`imageUrl`,`image_url`,`picture`];function lU(e,t){let n=cU(e,t);if(!n)return null;for(let e of iVe){let t=$H(n,e);if(t)return t}return null}function uU(e,t){let n=cU(e,t);return n?eU(n,`id`):null}function dU(e,t){return!!(e&&typeof e==`object`&&Object.hasOwn(e,t))}function aVe(e){let t={...e,id:eU(e,`id`)??e.id,title:e.title??$H(e,`name`)??``},n=eU(e,`workspaceId`)??eU(e,`workspace_id`)??uU(e,`workspace`)??e.workspaceId??null;return n!==null||dU(e,`workspaceId`)?{...t,workspaceId:n,startDate:e.startDate??$H(e,`start_date`)??null,endDate:e.endDate??$H(e,`end_date`)??null}:t}function fU(e){let t=e.ownerAvatarUrl??$H(e,`owner_avatar_url`)??$H(e,`ownerProfileImage`)??$H(e,`owner_profile_image`)??$H(e,`ownerImage`)??$H(e,`owner_image`)??$H(e,`ownerImageUrl`)??$H(e,`owner_image_url`)??$H(e,`createdByAvatarUrl`)??$H(e,`created_by_avatar_url`)??$H(e,`createdByProfileImage`)??$H(e,`created_by_profile_image`)??lU(e,`owner`)??lU(e,`createdBy`)??lU(e,`created_by`)??null,n={...e,id:eU(e,`id`)??e.id},r=eU(e,`campaignId`)??eU(e,`campaign_id`)??uU(e,`campaign`)??e.campaignId??null;(r!==null||dU(e,`campaignId`))&&(n.campaignId=r);let i=e.campaignTitle??$H(e,`campaignTitle`)??$H(e,`campaign_title`)??$H(cU(e,`campaign`),`title`)??$H(cU(e,`campaign`),`name`)??null;(i!==null||dU(e,`campaignTitle`))&&(n.campaignTitle=i);let a=eU(e,`workspaceId`)??eU(e,`workspace_id`)??uU(e,`workspace`)??e.workspaceId??null;(a!==null||dU(e,`workspaceId`))&&(n.workspaceId=a);let o=e.workspaceName??$H(e,`workspace_name`)??$H(cU(e,`workspace`),`name`)??null;(o!==null||dU(e,`workspaceName`))&&(n.workspaceName=o);let s=$H(e,`workspaceIconUrl`)??$H(e,`workspace_icon_url`)??$H(cU(e,`workspace`),`iconUrl`)??null;(s!==null||dU(e,`workspaceIconUrl`))&&(n.workspaceIconUrl=s);let c=eU(e,`ownerId`)??eU(e,`owner_id`)??uU(e,`owner`)??e.ownerId??null;(c!==null||dU(e,`ownerId`))&&(n.ownerId=c);let l=e.ownerName??$H(e,`owner_name`)??$H(cU(e,`owner`),`name`)??null;(l!==null||dU(e,`ownerName`))&&(n.ownerName=l),(t!==null||dU(e,`ownerAvatarUrl`))&&(n.ownerAvatarUrl=t);let u=eU(e,`teamId`)??eU(e,`team_id`)??uU(e,`team`)??e.teamId??null;(u!==null||dU(e,`teamId`))&&(n.teamId=u);let d=e.teamName??$H(e,`team_name`)??$H(cU(e,`team`),`name`)??null;(d!==null||dU(e,`teamName`))&&(n.teamName=d);let f=e.startDate??$H(e,`start_date`)??null;(f!==null||dU(e,`startDate`))&&(n.startDate=f);let p=e.targetEndDate??$H(e,`target_end_date`)??null;return(p!==null||dU(e,`targetEndDate`))&&(n.targetEndDate=p),n}function pU(e){if(Array.isArray(e))return e;if(e&&typeof e==`object`){let t=e;if(Array.isArray(t.items))return t.items;if(Array.isArray(t.results))return t.results}return[]}function oVe(e){return pU(e).flatMap(e=>{let t=e,n=typeof t.id==`number`?t.id:null,r=typeof t.name==`string`?t.name:null;if(n===null||r===null)return[];let i=e=>typeof t[e]==`string`?t[e]:null;return[{id:n,name:r,startDate:i(`startDate`),endDate:i(`endDate`),status:i(`status`)}]})}function sVe(e){if(e&&typeof e==`object`){let t=e;if(t.project&&typeof t.project==`object`)return t.project}return e}function mU(e){if(e===null||e.trim()===``)return null;let t=Number(e);return Number.isSafeInteger(t)?t:e}async function hU(e){try{return await e}catch(e){throw e instanceof xn?e.kind===`auth`?new eVe(e.message):new tVe(e.message,e.status??502):e}}var gU=class e{cfg;putThreadDisposition;postThreadArchive;commentEditIdempotencyKeys=new Map;commentDeleteIdempotencyKeys=new Map;constructor(e={}){let t=e.forgeOrigin===void 0,n=e.forgeOrigin??`http://localhost:13773`;this.cfg={resolveUrl:t?fn:e=>`${n}${e}`,maxRetries:e.maxRetries??3,onAuthExpired:e.onAuthExpired??bn,...t?{resolveBearerToken:()=>_n()?.bearerToken??null}:{}},this.putThreadDisposition=RBe(this.cfg),this.postThreadArchive=VBe(this.cfg)}async getTask(e){return hU(j({method:`GET`,path:`/api/cmmd/tasks/${e}`},this.cfg))}async getForgeTaskDetail(e){return j({method:`GET`,path:`/api/cmmd/tasks/${e}`},this.cfg)}async searchTasks(e){let t={q:e.q};return e.status&&(t.status=e.status),e.limit!==void 0&&(t.limit=e.limit),e.projectId&&(t.projectId=e.projectId),(await hU(j({method:`GET`,path:`/api/cmmd/tasks/search`,query:t},this.cfg))).tasks??[]}async getTaskComments(e){return(await hU(j({method:`GET`,path:`/api/cmmd/tasks/${e}/comments`},this.cfg))).comments??[]}async listProjectTaskComments(e){return(await hU(j({method:`GET`,path:`/api/cmmd/tasks/${e}/comments`},this.cfg))).comments??[]}async createProjectTaskComment(e,t){return(await hU(j({method:`POST`,path:`/api/cmmd/tasks/comment`,body:{taskId:e,content:t.content}},this.cfg))).details}async updateProjectTaskComment(e,t,n){return(await hU(j({method:`PATCH`,path:`/api/cmmd/tasks/${e}/comments/${encodeURIComponent(t)}`,body:n},this.cfg))).comment}async deleteProjectTaskComment(e,t,n){return hU(j({method:`DELETE`,path:`/api/cmmd/tasks/${e}/comments/${encodeURIComponent(t)}`,body:n},this.cfg))}async getTaskAttachments(e){return hU(j({method:`GET`,path:`/api/cmmd/tasks/${e}/attachments`},this.cfg))}async getProjectRepository(e){return hU(j({method:`GET`,path:`/api/cmmd/projects/${e}/repository`},this.cfg))}async listProjectRepositories(e){return(await hU(j({method:`GET`,path:`/api/cmmd/projects/${e}/repositories`},this.cfg))).repositories}async getWorkspaceMembers(e){return hU(j({method:`GET`,path:`/api/cmmd/organizations/${e}/members`},this.cfg))}async getWebSocketToken(e){return j({method:`GET`,path:`/api/cmmd/ws-token`,...e?.signal===void 0?{}:{signal:e.signal}},this.cfg)}async getProjectComments(e,t){let n={};return t?.organizationId&&(n.organizationId=t.organizationId),(await j({method:`GET`,path:`/api/cmmd/projects/${e}/comments`,query:n},this.cfg))?.comments??[]}async getProjectLink(e){return j({method:`GET`,path:`/.well-known/forge/project-link`,query:{environmentId:e.environmentId,projectId:e.projectId,cwd:e.cwd}},this.cfg)}async listProjectLinks(){return j({method:`GET`,path:`/.well-known/forge/project-links`,suppressBearerToken:!0},this.cfg)}async listProjectContextLinks(e){let t={};e.environmentId&&(t.forgeEnvironmentId=e.environmentId),e.projectId&&(t.forgeProjectId=e.projectId),e.githubRepoFullName&&(t.githubRepoFullName=e.githubRepoFullName),e.cmmdOrganizationId&&(t.cmmdOrganizationId=e.cmmdOrganizationId);let n=await j({method:`GET`,path:`/.well-known/forge/cmmd/project-links`,query:t},this.cfg),r=pte(Wte)(n);return r._tag===`Some`?r.value.links:[]}async listCmmdWorkspaces(){return pU(await j({method:`GET`,path:`/.well-known/forge/cmmd/workspaces`},this.cfg))}async listCmmdCampaigns(e){return oVe(await j({method:`GET`,path:`/.well-known/forge/cmmd/campaigns`,query:{workspaceId:e.workspaceId}},this.cfg))}async listCmmdProjects(e){return pU(await j({method:`GET`,path:`/.well-known/forge/cmmd/projects`,query:{campaignId:e.campaignId}},this.cfg))}async updateTask(e,t){let n={taskId:e};return t.title!==void 0&&(n.title=t.title),t.description!==void 0&&(n.description=t.description),t.status!==void 0&&(n.status=t.status),t.priority!==void 0&&(n.priority=t.priority),t.dueDate!==void 0&&(n.dueDate=t.dueDate),t.assigneeId!==void 0&&(n.assigneeId=t.assigneeId),t.labels!==void 0&&(n.labels=t.labels),hU(j({method:`POST`,path:`/api/cmmd/tasks/update`,body:n},this.cfg))}async createComment(e){return hU(j({method:`POST`,path:`/api/cmmd/tasks/comment`,body:{taskId:e.entityId,content:e.content}},this.cfg))}async updateComment(e,t,n){let r=`${e}:${t}:${n}`,i=this.commentEditIdempotencyKeys.get(r)??crypto.randomUUID();this.commentEditIdempotencyKeys.set(r,i);let a=await hU(j({method:`PATCH`,path:`/api/cmmd/tasks/${e}/comments/${t}`,body:{content:n,idempotencyKey:i}},this.cfg));return this.commentEditIdempotencyKeys.delete(r),a}async deleteComment(e,t){let n=`${e}:${t}`,r=this.commentDeleteIdempotencyKeys.get(n)??crypto.randomUUID();this.commentDeleteIdempotencyKeys.set(n,r),await hU(j({method:`DELETE`,path:`/api/cmmd/tasks/${e}/comments/${t}`,body:{idempotencyKey:r}},this.cfg)),this.commentDeleteIdempotencyKeys.delete(n)}async createProjectComment(e,t){let n=(await j({method:`POST`,path:`/api/cmmd/projects/${e}/comments`,body:{content:t.content,organizationId:t.organizationId??null}},this.cfg))?.comment;if(!n)throw new xn({kind:`server`,message:`CMMD did not return the created project comment.`});return n}async updateProject(e,t){let n={};for(let e of Fte){let r=t[e];r!==void 0&&(n[e]=Bte[e]===`nullableId`?mU(r):r)}await j({method:`PATCH`,path:`/api/cmmd/projects/${e}`,body:n},this.cfg)}async setProjectLink(e){await j({method:`POST`,path:`/.well-known/forge/project-link`,body:e},this.cfg)}async deleteProjectLink(e){await j({method:`DELETE`,path:`/.well-known/forge/project-link`,query:{environmentId:e.environmentId,projectId:e.projectId,cwd:e.cwd,...e.cmmdProjectId?{cmmdProjectId:e.cmmdProjectId}:{}}},this.cfg)}async createCmmdProject(e){return j({method:`POST`,path:`/.well-known/forge/cmmd/projects`,body:e},this.cfg)}async ensureGitHubProjectContext(e){return j({method:`POST`,path:`/.well-known/forge/cmmd/github-project-contexts/ensure`,body:e},this.cfg)}async createBrainDoc(e){return j({method:`POST`,path:`/api/cmmd/brain-docs`,body:e},this.cfg)}async uploadTaskAttachment(e,t){let n=new FormData;return n.append(`file`,t),hU(j({method:`POST`,path:`/api/cmmd/tasks/${e}/attachments`,form:n},this.cfg))}async archiveTask(e){await j({method:`POST`,path:`/api/cmmd/tasks/${e}/archive`},this.cfg)}async unarchiveTask(e){await j({method:`POST`,path:`/api/cmmd/tasks/${e}/unarchive`},this.cfg)}async getProfile(){return j({method:`GET`,path:`/api/cmmd/profile`},this.cfg)}async getUsageSummary(e){return j({method:`GET`,path:`/api/cmmd/usage/summary`,query:{sinceDay:e.sinceDay,untilDay:e.untilDay,timeZone:e.timeZone,...e.resolution===`hour`?{resolution:e.resolution,sinceTime:e.sinceTime,untilTime:e.untilTime}:{}}},this.cfg)}getBilling(e){return kBe(this.cfg,e)}getBillingSeries(e){return ABe(this.cfg,e)}async getBootstrap(){return j({method:`GET`,path:`/api/cmmd/bootstrap`},this.cfg)}async getForgeAccountPreferences(){return j({method:`GET`,path:`/api/cmmd/account/preferences`},this.cfg)}async updateForgeAccountPreferences(e){return j({method:`PATCH`,path:`/api/cmmd/account/preferences`,body:e},this.cfg)}async getOrgProviderPolicy(){return j({method:`GET`,path:`/api/cmmd/org/provider-policy`},this.cfg)}async listSavedDataViews(e){return j({method:`GET`,path:`/api/cmmd/saved-views`,query:{surface:e.surface,projectId:e.projectId}},this.cfg)}async createSavedDataView(e){return j({method:`POST`,path:`/api/cmmd/saved-views`,body:e},this.cfg)}async importSavedDataView(e){return j({method:`POST`,path:`/api/cmmd/saved-views/import`,body:e},this.cfg)}async updateSavedDataView(e,t){return j({method:`PATCH`,path:`/api/cmmd/saved-views/${encodeURIComponent(e)}`,body:t},this.cfg)}async deleteSavedDataView(e,t){return j({method:`DELETE`,path:`/api/cmmd/saved-views/${encodeURIComponent(e)}`,query:t},this.cfg)}async getDeviceRegistry(e){return j({method:`GET`,path:`/api/cmmd/devices`,...e?.projectId===void 0?{}:{query:{projectId:String(e.projectId)}},...e?.signal===void 0?{}:{signal:e.signal}},this.cfg)}async registerDevice(e){return j({method:`POST`,path:`/api/cmmd/devices/register`,body:e},this.cfg)}async grantRuntimeAccess(e,t){return j({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/access-grants`,body:t},this.cfg)}async revokeRuntimeAccess(e,t){return j({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/access-grants/${encodeURIComponent(String(t))}/revoke`},this.cfg)}async issueRelayControlRoute(e,t){return j({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/relay-routes`,body:t},this.cfg)}async issueRelayActionGrant(e,t){return j({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/relay-action-grants`,body:t},this.cfg)}async getRuntimeInventory(e){let t=qBe(e);return QBe(await j({method:`GET`,path:`/api/cmmd/runtime-inventory`,...Object.keys(t).length>0?{query:t}:{}},this.cfg))}async getRuntimeDiagnostics(e){return j({method:`GET`,path:`/api/cmmd/runtime-diagnostics/v2/runtimes/${encodeURIComponent(e)}`},this.cfg)}async getCloudProjectLifecyclePreflight(e){return(await j({method:`GET`,path:`/api/cmmd/forge-cloud-projects/${encodeURIComponent(String(e))}/lifecycle-preflight`},this.cfg)).preflight}async replaceRuntimeInventory(e,t){return j({method:`PUT`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/inventory`,body:t},this.cfg)}static PROVIDER_ACCOUNTS_PATH=`/api/cmmd/providers/accounts`;static PROVIDER_USAGE_PATH=`/api/cmmd/providers/usage`;static PROVIDER_USAGE_REFRESH_PATH=`/api/cmmd/providers/usage/refresh`;provisionAuthRuntime(){return TBe(this.cfg)}getAuthRuntimeState(){return EBe(this.cfg)}destroyAuthRuntime(){return DBe(this.cfg)}connectAuthRuntime(){return OBe(this.cfg)}getUserCodexCredential(){return jBe(this.cfg)}disconnectUserCodexCredential(){return MBe(this.cfg)}getUserClaudeCredential(){return NBe(this.cfg)}async getProviderAccounts(){return j({method:`GET`,path:e.PROVIDER_ACCOUNTS_PATH},this.cfg)}async removeLinkedProviderAccount(e){return FBe(this.cfg,e)}async setProviderAccountDefault(t){return j({method:`PUT`,path:`${e.PROVIDER_ACCOUNTS_PATH}/default`,body:{provider:t.provider,provider_account_id:t.providerAccountId}},this.cfg)}async getProviderUsage(){return j({method:`GET`,path:e.PROVIDER_USAGE_PATH},this.cfg)}async refreshProviderUsage(t,n){return j({method:`POST`,path:e.PROVIDER_USAGE_REFRESH_PATH,body:{provider:t,providerAccountId:n}},this.cfg)}disconnectUserClaudeCredential(){return PBe(this.cfg)}async getClaudeRuntimeReadiness(e){return j({method:`GET`,path:`/api/cmmd/providers/claude/runtime-readiness/${encodeURIComponent(e)}`},this.cfg)}async appendRuntimeThreadEvents(e,t,n){return j({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/threads/${encodeURIComponent(t)}/events`,body:n},this.cfg)}async getRuntimeThreadReplica(e,t){return YBe(e,t)?ZBe():j({method:`GET`,path:`/api/cmmd/threads/${encodeURIComponent(e)}/${encodeURIComponent(t)}`},this.cfg)}renameCloudEnvironment(e,t){return WBe(this.cfg,e,t)}renameDevice(e,t){return GBe(this.cfg,e,t)}revokeDevice(e){return KBe(this.cfg,e)}static SIM_PATH=`/api/cmmd/sim-host`;static simScope(e){return e?.orgId===void 0?``:`?orgId=${encodeURIComponent(String(e.orgId))}`}async listSimHosts(t){return j({method:`GET`,path:`${e.SIM_PATH}/hosts${e.simScope(t)}`},this.cfg)}async getSimLease(t){let n=new URLSearchParams({forgeEnvironmentId:t.forgeEnvironmentId,threadId:t.threadId,...t.orgId===void 0?{}:{orgId:String(t.orgId)}});return j({method:`GET`,path:`${e.SIM_PATH}/leases?${n.toString()}`},this.cfg)}async claimSimLease(t){return j({method:`POST`,path:`${e.SIM_PATH}/leases${e.simScope(t)}`,body:{hostId:t.hostId,forgeEnvironmentId:t.forgeEnvironmentId,threadId:t.threadId,ttlMs:t.ttlMs}},this.cfg)}async renewSimLease(t){return j({method:`POST`,path:`${e.SIM_PATH}/leases/${encodeURIComponent(String(t.leaseId))}/renew${e.simScope(t)}`,body:{generation:t.generation,rowVersion:t.rowVersion,ttlMs:t.ttlMs}},this.cfg)}async releaseSimLease(t){await j({method:`POST`,path:`${e.SIM_PATH}/leases/${encodeURIComponent(String(t.leaseId))}/release${e.simScope(t)}`,body:{generation:t.generation,rowVersion:t.rowVersion}},this.cfg)}async listCampaigns(e){let t={};return e?.orgId&&(t.orgId=e.orgId),e?.allWorkspaces&&(t.allWorkspaces=`true`),rU(await j({method:`GET`,path:`/api/cmmd/campaigns`,query:t,...e?.signal?{signal:e.signal}:{}},this.cfg),`campaigns`).map(aVe)}async getCampaign(e){return j({method:`GET`,path:`/api/cmmd/campaigns/${e}`},this.cfg)}async createCampaign(e){return j({method:`POST`,path:`/api/cmmd/campaigns`,body:e},this.cfg)}async updateCampaign(e,t){return j({method:`PUT`,path:`/api/cmmd/campaigns/${e}`,body:t},this.cfg)}async deleteCampaign(e){await j({method:`DELETE`,path:`/api/cmmd/campaigns/${e}`},this.cfg)}async listProjects(e){let t={};return e?.campaignId&&(t.campaignId=e.campaignId),e?.orgId&&(t.orgId=e.orgId),e?.allWorkspaces&&(t.allWorkspaces=`true`),rU(await j({method:`GET`,path:`/api/cmmd/projects`,query:t,...e?.signal?{signal:e.signal}:{}},this.cfg),`projects`).map(fU)}async listTasks(e){let t={};return e?.projectId&&(t.projectId=e.projectId),e?.status&&(t.status=e.status),j({method:`GET`,path:`/api/cmmd/tasks`,query:t},this.cfg)}async getProject(e){return fU(await j({method:`GET`,path:`/api/cmmd/projects/${e}`},this.cfg))}async getProjectMembers(e){let t=await j({method:`GET`,path:`/api/cmmd/projects/${e}/members`},this.cfg);return Array.isArray(t)?t.map(oU):[]}async listWorkspaceMembers(){let e=await j({method:`GET`,path:`/api/cmmd/members`},this.cfg);return Array.isArray(e)?e.map(nVe):[]}async addProjectMember(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/members`,body:t},this.cfg)}async listProjectAgentMembers(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/agent-members`},this.cfg)}async createProjectAgentMember(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/agent-members`,body:t},this.cfg)}async renameProjectAgentMember(e,t,n){return j({method:`PATCH`,path:`/api/cmmd/projects/${e}/agent-members/${t}`,body:n},this.cfg)}async retireProjectAgentMember(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/agent-members/${t}/retire`,body:n},this.cfg)}async updateProjectAgentMemberAvatar(e,t,n){return j({method:`PUT`,path:`/api/cmmd/projects/${e}/agent-members/${t}/avatar`,body:n},this.cfg)}async listProjectAgentMemberInstances(e,t){return j({method:`GET`,path:`/api/cmmd/projects/${e}/agent-members/${t}/instances`},this.cfg)}async previewProjectAgentMemberConsolidation(e){return j({method:`POST`,path:`/api/cmmd/projects/${e}/agent-members/consolidation/preview`},this.cfg)}async applyProjectAgentMemberConsolidation(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/agent-members/consolidation/apply`,body:t},this.cfg)}async setProjectTaskAssignment(e,t,n){return j({method:`PUT`,path:`/api/cmmd/projects/${e}/tasks/${t}/assignment`,body:n},this.cfg)}async getProjectUpdates(e,t){let n=t?.page??1,r=t?.limit??10;return rVe(await j({method:`GET`,path:`/api/cmmd/projects/${e}/updates`,query:{page:n,limit:r},unwrapEnvelope:!1},this.cfg),n,r)}async createProjectUpdate(e,t){return sU(await j({method:`POST`,path:`/api/cmmd/projects/${e}/updates`,body:t},this.cfg))}async updateProjectUpdate(e,t,n){return sU(await j({method:`PATCH`,path:`/api/cmmd/projects/${e}/updates/${t}`,body:n},this.cfg))}async deleteProjectUpdate(e,t){await j({method:`DELETE`,path:`/api/cmmd/projects/${e}/updates/${t}`},this.cfg)}async listProjectMilestones(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/milestones`},this.cfg)}async createProjectMilestone(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/milestones`,body:t},this.cfg)}async updateProjectMilestone(e,t,n){return j({method:`PATCH`,path:`/api/cmmd/projects/${e}/milestones/${t}`,body:n},this.cfg)}async deleteProjectMilestone(e,t){await j({method:`DELETE`,path:`/api/cmmd/projects/${e}/milestones/${t}`},this.cfg)}async improveProjectContent(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/content/readability`,body:t},this.cfg)}async listProjectBoard(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/board`},this.cfg)}async createProjectTaskDraft(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/task-drafts`,body:t},this.cfg)}async getProjectTaskDraft(e,t){return j({method:`GET`,path:`/api/cmmd/projects/${e}/task-drafts/${t}`},this.cfg)}async updateProjectTaskDraft(e,t,n){return j({method:`PATCH`,path:`/api/cmmd/projects/${e}/task-drafts/${t}`,body:n},this.cfg)}async previewProjectTaskDraft(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/task-drafts/${t}/preview`,body:n},this.cfg)}async commitProjectTaskDraft(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/task-drafts/${t}/commit`,body:n},this.cfg)}async discardProjectTaskDraft(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/task-drafts/${t}/discard`,body:n},this.cfg)}async getProjectTaskWorkflow(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/task-workflow`},this.cfg)}async updateProjectTaskWorkflow(e,t){return j({method:`PUT`,path:`/api/cmmd/projects/${e}/task-workflow`,body:t},this.cfg)}async getProjectLeadPlan(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/plan`},this.cfg)}async activateProjectLeadAutomaticStaffing(e){return j({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/authority/activate`,body:{}},this.cfg)}async getProjectLeadReadiness(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/readiness`},this.cfg)}async getProjectLeadCapabilities(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/capabilities`},this.cfg)}async getProjectLeadSummary(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/summary`},this.cfg)}async getProjectLeadDetail(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/detail`},this.cfg)}async getProjectLeadBriefing(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/briefing`},this.cfg)}async decideProjectLeadApproval(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/approvals/${t}/decision`,body:n},this.cfg)}async listProjectLeadEvents(e,t){return j({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/events`,...t?{query:{...t.afterEventId===void 0?{}:{afterEventId:String(t.afterEventId)},...t.latest===void 0?{}:{latest:String(t.latest)},...t.limit===void 0?{}:{limit:String(t.limit)}}}:{}},this.cfg)}async explainProjectLead(e){return j({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/explain`},this.cfg)}async pauseProjectLead(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/pause`,body:t},this.cfg)}async resumeProjectLead(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/resume`,body:t},this.cfg)}async reserveProjectLeadTask(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/tasks/${t}/reservations`,body:n},this.cfg)}async releaseProjectLeadReservation(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/reservations/${t}/release`,body:n},this.cfg)}async reconcileProjectLead(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/reconcile`,body:t},this.cfg)}async resolveProjectLeadAttention(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/attention/${t}/resolve`,body:n},this.cfg)}async listCenterBoard(e){let t={};return e?.status&&(t.status=e.status),e?.workspaceId&&(t.workspaceId=String(e.workspaceId)),e?.campaignId&&(t.campaignId=String(e.campaignId)),e?.ownerId&&(t.ownerId=String(e.ownerId)),e?.includeArchived!==void 0&&(t.includeArchived=e.includeArchived),e?.q&&(t.q=e.q),j({method:`GET`,path:`/api/cmmd/work-items/board`,query:t},this.cfg)}async listForgeAutomationPresets(){return iU(await j({method:`GET`,path:`/api/cmmd/automations/presets`},this.cfg),`presets`)}async listUserForgeAutomationRules(){return iU(await j({method:`GET`,path:`/api/cmmd/automations/user/rules`},this.cfg),`rules`)}async createUserForgeAutomationRule(e){return j({method:`POST`,path:`/api/cmmd/automations/user/rules`,body:e},this.cfg)}async updateUserForgeAutomationRule(e,t){return j({method:`PATCH`,path:`/api/cmmd/automations/user/rules/${e}`,body:t},this.cfg)}async listUserForgeAutomationRuns(e){return iU(await j({method:`GET`,path:`/api/cmmd/automations/user/rules/${e}/runs`},this.cfg),`runs`)}async startUserForgeAutomationRun(e,t){return j({method:`POST`,path:`/api/cmmd/automations/user/rules/${e}/runs`,body:t},this.cfg)}async listForgeAutomationRules(e,t){let n=aU(t);return iU(await j({method:`GET`,path:`/api/cmmd/automations/projects/${e}/rules`,...n?{query:n}:{}},this.cfg),`rules`)}async createForgeAutomationRule(e,t,n){let r=aU(n);return j({method:`POST`,path:`/api/cmmd/automations/projects/${e}/rules`,body:t,...r?{query:r}:{}},this.cfg)}async updateForgeAutomationRule(e,t,n,r){let i=aU(r);return j({method:`PATCH`,path:`/api/cmmd/automations/projects/${e}/rules/${t}`,body:n,...i?{query:i}:{}},this.cfg)}async listForgeAutomationRuns(e,t){let n=aU(t,t?.taskId);return iU(await j({method:`GET`,path:`/api/cmmd/automations/projects/${e}/runs`,...n?{query:n}:{}},this.cfg),`runs`)}async getForgeAutomationRun(e,t){let n=aU(t);return j({method:`GET`,path:`/api/cmmd/automations/runs/${e}`,...n?{query:n}:{}},this.cfg)}async startForgeAutomationRun(e,t,n,r){let i=aU(r);return j({method:`POST`,path:`/api/cmmd/automations/projects/${e}/tasks/${t}/runs`,body:n,...i?{query:i}:{}},this.cfg)}async retryForgeAutomationRun(e,t,n){let r=aU(n);return j({method:`POST`,path:`/api/cmmd/automations/runs/${e}/retry`,body:t,...r?{query:r}:{}},this.cfg)}async cancelForgeAutomationRun(e,t,n){let r=aU(n);return j({method:`POST`,path:`/api/cmmd/automations/runs/${e}/cancel`,body:t,...r?{query:r}:{}},this.cfg)}async approveForgeAutomationEscalation(e,t,n){let r=aU(n);return j({method:`POST`,path:`/api/cmmd/automations/runs/${e}/escalations/approve`,body:t,...r?{query:r}:{}},this.cfg)}async rejectForgeAutomationEscalation(e,t,n){let r=aU(n);return j({method:`POST`,path:`/api/cmmd/automations/runs/${e}/escalations/reject`,body:t,...r?{query:r}:{}},this.cfg)}async createProjectBoardTask(e,t){let n={title:t.title};return t.description!==void 0&&(n.description=t.description),t.priority!==void 0&&(n.priority=t.priority),t.status!==void 0&&(n.status=t.status),t.workflowStageId!==void 0&&(n.workflowStageId=t.workflowStageId),t.assignee!==void 0&&(n.assignee=t.assignee),t.dueDate!==void 0&&(n.dueDate=t.dueDate),t.workItemType!==void 0&&(n.workItemType=t.workItemType),t.parentTaskId!==void 0&&(n.parentTaskId=t.parentTaskId),t.milestoneId!==void 0&&(n.milestoneId=t.milestoneId),t.dependsOn!==void 0&&(n.dependsOn=t.dependsOn),j({method:`POST`,path:`/api/cmmd/projects/${e}/board`,body:n},this.cfg)}async createCenterBoardTask(e){let t={title:e.title,projectId:e.projectId};return e.description!==void 0&&(t.description=e.description),e.priority!==void 0&&(t.priority=e.priority),e.status!==void 0&&(t.status=e.status),e.assignee!==void 0&&(t.assignee=e.assignee),e.dueDate!==void 0&&(t.dueDate=e.dueDate),e.workItemType!==void 0&&(t.workItemType=e.workItemType),e.parentTaskId!==void 0&&(t.parentTaskId=e.parentTaskId),e.milestoneId!==void 0&&(t.milestoneId=e.milestoneId),e.dependsOn!==void 0&&(t.dependsOn=e.dependsOn),j({method:`POST`,path:`/api/cmmd/work-items/board`,body:t},this.cfg)}async submitFeedback(e){let t={type:e.type,title:e.title,source:e.source};return e.description!==void 0&&(t.description=e.description),e.priority!==void 0&&(t.priority=e.priority),e.senderName!==void 0&&(t.senderName=e.senderName),j({method:`POST`,path:`/api/cmmd/feedback`,body:t},this.cfg)}async updateProjectBoardTask(e,t,n){return j({method:`PATCH`,path:`/api/cmmd/projects/${e}/board/${t}`,body:n},this.cfg)}async updateCenterBoardTask(e,t){return j({method:`PATCH`,path:`/api/cmmd/work-items/board/${e}`,body:t},this.cfg)}async moveCenterBoardTask(e,t){let n={toStatus:t.toStatus};return t.beforeTaskId!==void 0&&(n.beforeTaskId=t.beforeTaskId),t.afterTaskId!==void 0&&(n.afterTaskId=t.afterTaskId),j({method:`PATCH`,path:`/api/cmmd/work-items/board/${e}/move`,body:n},this.cfg)}async moveProjectBoardTask(e,t,n){let r={toStatus:n.toStatus};return n.toStageId!==void 0&&(r.toStageId=n.toStageId),n.beforeTaskId!==void 0&&(r.beforeTaskId=n.beforeTaskId),n.afterTaskId!==void 0&&(r.afterTaskId=n.afterTaskId),j({method:`PATCH`,path:`/api/cmmd/projects/${e}/board/${t}/move`,body:r},this.cfg)}async archiveProjectBoardTask(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/board/${t}/archive`},this.cfg)}async unarchiveProjectBoardTask(e,t){return j({method:`POST`,path:`/api/cmmd/projects/${e}/board/${t}/unarchive`},this.cfg)}async updateProjectBoardTaskStatus(e,t,n,r){return j({method:`PATCH`,path:`/api/cmmd/projects/${e}/board/${t}/status`,body:{status:n,...r?{workflowStageId:r}:{}}},this.cfg)}async listTaskExecutionOptions(e,t){return j({method:`GET`,path:`/api/cmmd/projects/${e}/board/${t}/execution-options`},this.cfg)}async createTaskWorkSession(e,t,n){return j({method:`POST`,path:`/api/cmmd/projects/${e}/board/${t}/work-sessions`,body:n},this.cfg)}async listProjectWorkSessions(e,t={}){return j({method:`GET`,path:`/api/cmmd/projects/${e}/work-sessions`,query:t},this.cfg)}async getWorkSession(e){return j({method:`GET`,path:`/api/cmmd/work-sessions/${e}`},this.cfg)}async updateWorkSessionStatus(e,t){return j({method:`PATCH`,path:`/api/cmmd/work-sessions/${e}`,body:{status:t}},this.cfg)}async attachWorkSessionThread(e,t){return j({method:`POST`,path:`/api/cmmd/work-sessions/${e}/threads`,body:t},this.cfg)}async listTaskConversations(e,t={}){return j({method:`GET`,path:`/api/cmmd/tasks/${e}/conversations`,query:tU(t)},this.cfg)}async linkTaskConversation(e,t){return j({method:`POST`,path:`/api/cmmd/tasks/${e}/conversations`,body:t},this.cfg)}async getTaskHistory(e){return j({method:`GET`,path:`/api/cmmd/tasks/${e}/history`},this.cfg)}async upsertTaskPullRequest(e,t){return j({method:`PUT`,path:`/api/cmmd/tasks/${e}/pull-requests`,body:t},this.cfg)}postPullRequest(e,t){return j({method:`POST`,path:`/api/cmmd/pull-requests/${e}`,body:t},this.cfg)}async listPullRequests(e){return this.postPullRequest(`list`,e)}async getPullRequestListStats(e){return this.postPullRequest(`list-stats`,e)}async getPullRequestDetail(e){return this.postPullRequest(`detail`,e)}async getPullRequestActivity(e){return this.postPullRequest(`activity`,e)}async getPullRequestDiff(e){return this.postPullRequest(`diff`,e)}async getPullRequestDiffFileContents(e){return this.postPullRequest(`diff-file-contents`,e)}async getPullRequestThreadComments(e){return this.postPullRequest(`thread/comments`,e)}async getPullRequestReviewerCandidates(e){return this.postPullRequest(`reviewer-candidates`,e)}async runPullRequestAction(e){return this.postPullRequest(`action`,e)}async createPullRequestComment(e){return this.postPullRequest(`comment`,e)}async updatePullRequest(e){return this.postPullRequest(`update`,e)}async updatePullRequestComment(e){return this.postPullRequest(`comment/update`,e)}async submitPullRequestReview(e){return this.postPullRequest(`review`,e)}async replyToPullRequestThread(e){return this.postPullRequest(`thread/reply`,e)}async setPullRequestThreadResolution(e){return this.postPullRequest(`thread/resolution`,e)}async requestPullRequestReviewers(e){return this.postPullRequest(`reviewers`,e)}async setPullRequestReaction(e){return this.postPullRequest(`reaction`,e)}async getTaskConversation(e,t,n={}){return j({method:`GET`,path:`/api/cmmd/tasks/${e}/conversations/${encodeURIComponent(t)}`,query:tU(n)},this.cfg)}async createTask(e){return j({method:`POST`,path:`/api/cmmd/tasks`,body:e},this.cfg)}async createSubtask(e){throw new nU(`createSubtask`)}async createBoardTask(e){throw new nU(`createBoardTask`)}async createProject(e){let t={};for(let[n,r]of Object.entries(e))r!=null&&(t[n]=r);return e.campaignId!==void 0&&e.campaignId!==null&&(t.campaignId=mU(e.campaignId)),e.organizationId!==void 0&&e.organizationId!==null&&(t.organizationId=mU(e.organizationId)),sVe(await j({method:`POST`,path:`/api/cmmd/projects`,body:t},this.cfg))}async moveProject(e,t){let n={targetOrgId:mU(t.targetOrgId)};return t.campaignStrategy!==void 0&&(n.campaignStrategy=t.campaignStrategy),t.targetCampaignId!==void 0&&(n.targetCampaignId=mU(t.targetCampaignId)),t.dryRun!==void 0&&(n.dryRun=t.dryRun),j({method:`POST`,path:`/api/cmmd/projects/${e}/move`,body:n},this.cfg)}async uploadBrainDoc(e,t){throw new nU(`uploadBrainDoc`)}};function _U(e){return new gU(e)}var vU=new gU({onAuthExpired:bn}),yU=class extends ht(`BootstrapHttpError`){},bU=e=>pe(e,`BootstrapHttpError`);function xU(e){return typeof e!=`object`||!e?!1:!!(bU(e)&&e.status===401||e instanceof Error&&e.name===`RemoteEnvironmentAuthHttpError`&&`status`in e&&e.status===401||e instanceof xn&&e.kind===`auth`)}function cVe(e){let t=e.replace(/\s+/g,` `).trim();return t.length===0?`<empty response>`:t.slice(0,120)}async function SU(e,t){let n=await e.text();try{return JSON.parse(n)}catch{throw new yU({message:`${t} returned a non-JSON response (${cVe(n)}). Ensure the Forge server is running and this route is proxied correctly.`,status:e.status})}}function CU(e={resolveUrl:fn}){let t=_n()?.bearerToken;return t?{...e,bearerToken:t}:e}var wU=null,TU=null,EU=null,DU=new Set,OU=`cmmd-forge.loggedOutLocalBootstrapCredentials.v1`;function lVe(e){let t=`${e.firstName??``} ${e.lastName??``}`.trim();FH({id:e.id,email:e.email,...t.length>0?{username:t}:{}}),WH({cmmdUserId:e.id,...e.email?{email:e.email}:{},...t.length>0?{displayName:t}:{}})}function kU(){if(typeof window>`u`||EU)return;let e=window.desktopBridge?.desktopAuth?.onStateChange;e&&(EU=e(e=>{wU=null,TU=null,e.sessionLifecycle.status!==`ready`&&FH(null),(e.sessionLifecycle.status===`expired`||e.sessionLifecycle.status===`signed-out`&&e.sessionLifecycle.reason===`refresh-revoked`)&&gne().catch(e=>{IH(e,{route:`desktop-auth-session-expired`})})}))}function uVe(){return na(new URL(window.location.href))}function AU(){let e=new URL(window.location.href),t=Nie(e);t.toString()!==e.toString()&&window.history.replaceState({},document.title,t.toString())}async function dVe(){return zU(async()=>{let e=fn(`/api/auth/session`),t=async()=>{let t=await fetch(e,gn({credentials:`include`}));if(!t.ok)throw new yU({message:`Failed to load server auth session state (${t.status}).`,status:t.status});return SU(t,e)},n=await t();return!n.authenticated&&n.auth.sessionMethods.length===1&&n.auth.sessionMethods[0]===`proxy-asserted`&&typeof window<`u`&&!window.desktopBridge&&e.startsWith(`https://`)&&await yne()?t():n})}var jU=new Set([`CMMD_AUTH_REQUIRED`,`CMMD_AUTH_EXPIRED`]);async function fVe(e){return zU(async()=>{let t={credential:e},n=fn(`/api/auth/bootstrap`),r=await fetch(n,gn({body:JSON.stringify(t),credentials:`include`,headers:{"content-type":`application/json`},method:`POST`}));if(!r.ok)throw new yU({message:await r.text()||`Failed to bootstrap auth session (${r.status}).`,status:r.status});return SU(r,n)})}function MU(e){return new URL(e,window.location.origin).toString()}function NU(e){let t=(e?.primaryMode===`cloud`?null:e)?.bootstrapToken?.trim();return t&&t.length>0?t:null}function PU(){return typeof window>`u`?null:NU(window.desktopBridge?.getLocalEnvironmentBootstrap?.()??null)}function pVe(){return typeof window>`u`?!1:Cne()===`session-expired`}function FU(){if(typeof window>`u`)return new Set;try{let e=window.sessionStorage.getItem(OU),t=e?JSON.parse(e):[];return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function IU(e){if(!(typeof window>`u`))try{if(e.size===0){window.sessionStorage.removeItem(OU);return}window.sessionStorage.setItem(OU,JSON.stringify([...e]))}catch{}}function mVe(){let e=PU();if(!e)return;let t=new Set(FU());t.add(e),IU(t)}function hVe(e){return FU().has(e)}function LU(){let e=PU();if(!e){IU(new Set);return}let t=new Set(FU());t.delete(e),IU(t)}async function RU(){let e=MU(`/api/auth/session`),t=await fetch(e,{credentials:`include`});return t.ok?SU(t,e):null}async function gVe(e){if(typeof window>`u`)return;let t=NU(e);if(!t||pVe()||DU.has(t)||hVe(t))return;if((await RU().catch(()=>null))?.authenticated){DU.add(t);return}let n=MU(`/api/auth/bootstrap`),r=await fetch(n,{body:JSON.stringify({credential:t}),credentials:`include`,headers:{"content-type":`application/json`},method:`POST`});if(!r.ok){if(r.status===401)return;throw new yU({message:await r.text()||`Failed to bootstrap local web owner session (${r.status}).`,status:r.status})}await SU(r,n),DU.add(t)}async function _Ve(){let e=await dVe();if(e.authenticated)return e;let t=_n();if(t?.source!==`desktop-managed`||!t.bearerToken)return e;let n=await RU().catch(()=>null);return n?.authenticated?n:e}var vVe=new Set([404,502,503,504]),yVe=15e3,bVe=500;function xVe(e){_n()?.source===`paired-bearer`&&xU(e)&&dn(`http`)}async function zU(e){let t=Date.now();for(;;)try{return await e()}catch(e){if(xVe(e),!CVe(e))throw e;if(Date.now()-t>=yVe)throw IH(e,{route:`bootstrap-retry-exhausted`}),e;await SVe(bVe)}}function SVe(e){return new Promise(t=>{setTimeout(t,e)})}function CVe(e){return bU(e)?vVe.has(e.status):e instanceof TypeError||e instanceof DOMException&&e.name===`AbortError`}function wVe(e,t){return e.sessionLifecycle.status===`ready`?e.sessionLifecycle.principalId!==t.id||e.cmmd.identity?.id!==t.id?`desktop-principal-mismatch`:null:`desktop-session-required`}async function TVe(e){if(typeof window>`u`||!window.desktopBridge)return null;let t=window.desktopBridge.desktopAuth?.getState;if(!t)return`desktop-state-unavailable`;try{return wVe(await t(),e)}catch(e){return IH(e,{route:`desktop-auth-gate-state`}),`desktop-state-unavailable`}}async function EVe(e,t){return FH(null),_ne(t),await hn().catch(e=>{IH(e,{route:`desktop-auth-gate-logout`})}),{status:`requires-auth`,auth:e.auth,errorMessage:Tne(t)??`Forge Desktop requires CMMD authentication.`}}async function DVe(){let e=await _Ve();if(e.authenticated){if(e.cmmdIdentity){let t=await TVe(e.cmmdIdentity);return t?(vn(),EVe(e,t)):(vn(),lVe(e.cmmdIdentity),{status:`authenticated`})}return{status:`requires-auth`,auth:e.auth}}return{status:`requires-auth`,auth:e.auth}}async function OVe(e){let t=e.trim();if(!t)throw Error(`Enter a pairing token to continue.`);TU=null,LU(),await fVe(t),wU=null,AU()}function BU(){LU(),TU=null,wU=null}async function VU(e,t,n){let r=e.trim();if(!r)throw Error(`CMMD (Command) OAuth did not return an access token.`);let i=n?.refreshToken?.trim(),a=n?.mcpToken?.trim(),o=fn(`/api/auth/bootstrap/command`),s=await fetch(o,gn({body:JSON.stringify({accessToken:r,...i?{refreshToken:i}:{},...a?{mcpToken:a}:{},...t===void 0?{}:{user:t}}),credentials:`include`,headers:{"content-type":`application/json`},method:`POST`}));if(!s.ok)throw new yU({message:await s.text()||`Failed to bootstrap with CMMD OAuth token (${s.status}).`,status:s.status});await SU(s,o),BU()}async function kVe(){let e=fn(`/api/auth/ws-token`),t=await fetch(e,gn({credentials:`include`,method:`POST`}));if(!t.ok)throw new yU({message:await t.text()||`Failed to issue websocket token (${t.status}).`,status:t.status});return SU(t,e)}async function AVe(e){let t=await kVe(),n=new URL(e,window.location.origin);return n.searchParams.set(`wsToken`,t.token),n.toString()}async function jVe(){let e=new URL(`/api/auth/session`,window.location.origin).toString(),t=await fetch(e,{credentials:`include`});if(!t.ok)throw new yU({message:`Failed to load current app auth session state (${t.status}).`,status:t.status});return MVe(await SU(t,e))}function MVe(e){if(!e.authenticated||!e.role)throw Error(`Authenticated session is required.`);let t=NVe(e.cmmdIdentity??null);return t?{displayName:t,email:e.cmmdIdentity?.email??null,avatarUrl:e.cmmdIdentity?.avatarUrl??null,role:e.role,verified:!0,source:`cmmd-identity`}:{displayName:`CMMD identity unavailable`,email:null,avatarUrl:null,role:e.role,verified:!1,source:`fallback`}}function NVe(e){return e&&([e.firstName,e.lastName].map(e=>e?.trim()??``).filter(e=>e.length>0).join(` `)||e.username.trim()||e.email.trim())||null}async function PVe(e){let t=`/api/cmmd/work-intake`,n;try{n=await j({method:`GET`,path:t,allowRetry:!1,...e?{query:{fresh:1}}:{}},CU())}catch(e){throw e instanceof xn&&e.kind!==`auth`&&e.code!==null&&jU.has(e.code)?new xn({kind:`auth`,message:e.message,status:e.status??401,code:e.code}):e}if(!n)throw Error(`Invalid response from ${t}`);return n}async function FVe(e={}){return PVe(e.forceFresh===!0)}async function HU(e,t){try{return await j({method:`POST`,path:e,body:t,allowRetry:!1},CU())}catch(e){throw e instanceof xn&&e.kind!==`auth`&&e.code!==null&&jU.has(e.code)?new xn({kind:`auth`,message:e.message,status:e.status??401,code:e.code}):e}}async function IVe(e){try{return await HU(`/api/cmmd/tasks/update`,e)}catch(t){if(t instanceof xn&&(t.kind===`auth`||t.kind===`permission`))throw t;if(t instanceof xn||t instanceof Error)return HU(`/api/command/tasks/update`,e);throw t}}async function LVe(){typeof window>`u`||await window.desktopBridge?.desktopAuth?.logoutCloud?.()}async function RVe(){let e=await Promise.allSettled([hn(),LVe()]);FH(null),mVe(),wU=null,TU=null;let t=e.find(e=>e.status===`rejected`);if(t)throw t.reason}async function zVe(){if(kU(),TU?.status===`authenticated`)return vn(),TU;if(wU)return wU;let e=UU();return wU=e,e.then(e=>(e.status===`authenticated`&&(TU=e),e)).finally(()=>{wU===e&&(wU=null)})}async function UU(){return mn().then(e=>gVe(e)).then(()=>DVe())}async function BVe(){kU(),wU=null,TU=null;let e=await UU();return e.status===`authenticated`&&(TU=e,vn()),e}function VVe(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/u,``)}function HVe(e){let t=VVe(e).replace(/-/g,`+`).replace(/_/g,`/`);return`-----BEGIN PUBLIC KEY-----\n${((t+`=`.repeat((4-t.length%4)%4)).match(/.{1,64}/gu)??[]).join(`
1006
1006
  `)}\n-----END PUBLIC KEY-----\n`}function WU(e){return{publicKeyPem:HVe(e.publicKeySpkiDer),async sign(t){let n=await crypto.subtle.sign(`Ed25519`,e.privateKey,new TextEncoder().encode(t));return new Uint8Array(n)}}}var UVe=`cmmd-session-pop`,GU=`keys`,KU=`device-key`;function WVe(){return!1}var qU=class extends Error{constructor(e){super(`CMMD session key storage is unavailable (${e}). Session binding is enabled, so login cannot continue without a bound key: allow site data and IndexedDB for this origin, then retry.`),this.name=`CmmdSessionPopKeyStorageError`}};function GVe(e){return e===void 0?typeof indexedDB>`u`?null:indexedDB:e}function JU(e){return new Promise((t,n)=>{e.addEventListener(`success`,()=>t(e.result),{once:!0}),e.addEventListener(`error`,()=>n(e.error),{once:!0})})}function KVe(e){return new Promise((t,n)=>{e.addEventListener(`complete`,()=>t(),{once:!0}),e.addEventListener(`abort`,()=>n(e.error??new DOMException(`The transaction aborted.`,`AbortError`)),{once:!0}),e.addEventListener(`error`,()=>n(e.error??new DOMException(`The transaction failed.`,`UnknownError`)),{once:!0})})}function qVe(e){return new Promise((t,n)=>{let r=e.open(UVe,1);r.addEventListener(`upgradeneeded`,()=>{r.result.objectStoreNames.contains(GU)||r.result.createObjectStore(GU)}),r.addEventListener(`success`,()=>t(r.result),{once:!0}),r.addEventListener(`error`,()=>n(r.error),{once:!0})})}function YU(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.privateKey instanceof CryptoKey&&t.publicKeySpkiDer instanceof Uint8Array}async function JVe(e){let t=await JU(e.transaction(GU,`readonly`).objectStore(GU).get(KU));return YU(t)?{privateKey:t.privateKey,publicKeySpkiDer:t.publicKeySpkiDer}:null}async function YVe(e,t){let n=e.transaction(GU,`readwrite`),r=n.objectStore(GU),i=KVe(n);i.catch(()=>void 0);let a=await JU(r.get(KU));return YU(a)?{privateKey:a.privateKey,publicKeySpkiDer:a.publicKeySpkiDer}:(await JU(r.add(t,KU)),await i,t)}var XU=null;async function XVe(e={}){return WVe()?(XU??=ZVe(e).finally(()=>{XU=null}),XU):null}async function ZVe(e){let t=GVe(e.indexedDB),n=e.subtle??crypto.subtle;if(!t)throw new qU(`IndexedDB is not available in this context`);let r;try{r=await qVe(t)}catch{throw new qU(`the key database could not be opened`)}try{let e=await JVe(r);if(e)return WU({privateKey:e.privateKey,publicKeySpkiDer:e.publicKeySpkiDer});let t=await n.generateKey({name:`Ed25519`},!1,[`sign`]),i={privateKey:t.privateKey,publicKeySpkiDer:new Uint8Array(await n.exportKey(`spki`,t.publicKey))};return WU(await YVe(r,i))}catch(e){throw e instanceof qU?e:new qU(`the session key could not be generated or persisted`)}}function ZU(e={}){return XVe(e).then(e=>e?.publicKeyPem??null)}async function QVe(e,t={}){let n=e.email.trim();if(!n||!e.password)throw Error(`Enter your CMMD email and password.`);let r=await(t.resolvePopPublicKey??ZU)(),i=fn(`/api/auth/cmmd-password/token`),a=await fetch(i,gn({body:JSON.stringify({email:n,password:e.password,...r?{pop_public_key:r}:{}}),credentials:`include`,headers:{"content-type":`application/json`},method:`POST`}));if(!a.ok)throw new yU({message:await a.text()||`CMMD login failed (${a.status}).`,status:a.status});let o=await SU(a,i);if(o.authenticated===!0)return BU(),{serverEstablishedSession:!0};if(typeof o.access_token!=`string`||o.access_token.trim().length===0)throw Error(`CMMD login did not return an access token.`);return await VU(o.access_token,o.user,{refreshToken:typeof o.refresh_token==`string`?o.refresh_token:void 0,mcpToken:typeof o.mcp_token==`string`?o.mcp_token:void 0}),{serverEstablishedSession:!1}}async function QU(e,t){return await e.text()||t}async function $Ve(e,t){let n=e?.trim(),r={...n?{label:n}:{},...t?{role:t}:{}},i=fn(`/api/auth/pairing-token`),a=await fetch(i,gn({body:JSON.stringify(r),credentials:`include`,headers:{"content-type":`application/json`},method:`POST`}));if(!a.ok)throw Error(await QU(a,`Failed to create pairing credential (${a.status}).`));return SU(a,i)}async function eHe(){let e=fn(`/api/auth/clients`),t=await fetch(e,gn({credentials:`include`}));if(!t.ok)throw Error(await QU(t,`Failed to load paired clients (${t.status}).`));return SU(t,e)}async function tHe(e){let t=fn(`/api/auth/pairing-links/revoke`),n=await fetch(t,gn({body:JSON.stringify({id:e}),credentials:`include`,headers:{"content-type":`application/json`},method:`POST`}));if(!n.ok)throw Error(await QU(n,`Failed to revoke the pairing link (${n.status}).`));return(await SU(n,t)).revoked}var nHe=`/.well-known/forge/environment`,$U=ft()(e=>({descriptor:null,setDescriptor:t=>e({descriptor:t}),reset:()=>e({descriptor:null})})),eW=null;function rHe(e){let t=tW();return t?Hre($r({id:t.environmentId,label:t.label,source:e.source,target:e.target}),t):null}async function iHe(){return zU(async()=>{await mn();let e=_n()?.bearerToken,t=fn(nHe),n=e?await fetch(t,{headers:{Authorization:`Bearer ${e}`}}):await fetch(t);if(!n.ok)throw new yU({message:`Failed to load server environment descriptor (${n.status}).`,status:n.status});let r=await SU(n,t);return nW(r),r})}function tW(){return $U.getState().descriptor}function aHe(){return $U(oHe)}function oHe(e){return e.descriptor?.environmentId??null}function sHe(){return $U(cHe)}function cHe(e){return e.descriptor}function lHe(){return $U(uHe)}function uHe(e){return e.descriptor?.deviceRuntimeId??null}function dHe(){return tW()?.deviceRuntimeId??null}function fHe(){return $U(pHe)}function pHe(e){return Jre(e.descriptor)}function mHe(){return $U(hHe)}function hHe(e){return Yre(e.descriptor)}function nW(e){$U.getState().setDescriptor(e)}function gHe(e,t){return t?.primaryMode!==`cloud`||e.environmentId===t.environmentId}function rW(){let e=_n();return e?rHe({source:e.source,target:e.target}):null}function _He(){return vHe()}async function vHe(){let e=await mn(),t=tW();if(t&&gHe(t,e))return Promise.resolve(t);if(t&&nW(null),eW)return eW;let n=iHe();return eW=n,n.finally(()=>{eW===n&&(eW=null)})}var iW=class e{#e;constructor(e){this.#e=e}static namedByCatalog(t){return new e(t.projectId)}get registrationProjectId(){return this.#e}asConfirmationIdentity(){return{registrationProjectId:this.#e}}};function aW(e){return{match:t=>t.present({target:e})}}function oW(){return{match:e=>e.provablyAbsent()}}function yHe(e){return{match:t=>t.unprovable(e)}}var bHe=class e{#e;#t;capacity;constructor(e,t,n){this.#e=e,this.#t=t,this.capacity=n}static fromValidatedBody(t,n,r){return new e(t,n,r)}listRowsForDisplay(){return this.#e}listEnvironmentsForDisplay(){return this.#t}locate(e){if(e.registrationProjectId!==void 0){let t=this.#e.find(t=>t.projectId===e.registrationProjectId);return t===void 0?oW():aW(iW.namedByCatalog(t))}if(e.runtimeId!==void 0||e.cmmdEnvironmentId!==void 0){let t=this.#e.find(t=>t.runtime!=null&&(e.runtimeId!==void 0&&t.runtime.runtimeId===e.runtimeId||e.cmmdEnvironmentId!==void 0&&t.runtime.environmentId===e.cmmdEnvironmentId));if(t)return aW(iW.namedByCatalog(t))}if(this.#e.length===0)return oW();let t=e.runtimeId??e.cmmdEnvironmentId;return yHe(t===void 0?`no identity this catalog can be matched on`:`the catalog holds ${String(this.#e.length)} row(s) that ${t} cannot be ruled out against`)}};function sW(e){let t=e,n=t&&typeof t==`object`&&`data`in t&&t.data?t.data:t,r=n?.projects;if(!Array.isArray(r))throw Error("Forge Cloud returned a project catalog this version cannot read (no `projects` list).");let i=n?.environments;if(!Array.isArray(i))throw Error("Forge Cloud returned an Environment catalog this version cannot read (invalid `environments` list).");if(!r.every(xHe))throw Error(`Forge Cloud returned a project catalog this version cannot read (invalid project entry).`);if(!i.every(SHe))throw Error(`Forge Cloud returned an Environment catalog this version cannot read (invalid Environment entry).`);return bHe.fromValidatedBody(r,i,n?.capacity??null)}function xHe(e){return!lW(e)||typeof e.organizationId!=`number`||typeof e.projectId!=`number`?!1:e.runtime===void 0||e.runtime===null||cW(e.runtime)}function SHe(e){return lW(e)&&typeof e.organizationId==`number`&&typeof e.userId==`number`&&cW(e.runtime)}function cW(e){return lW(e)&&typeof e.runtimeId==`string`&&typeof e.status==`string`}function lW(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function CHe(e,t){let n=new URL(e);return n.pathname=t,n.search=``,n.hash=``,n.toString()}function uW(e){return e.accessToken??e.resolveAccessToken?.()}function dW(e,t,n=t=>CHe(e.cmmdHttpBaseUrl,t)){return j({method:t.method,path:t.path,...t.body===void 0?{}:{body:t.body},...t.signal===void 0?{}:{signal:t.signal}},{resolveUrl:n,resolveBearerToken:()=>uW(e)})}function wHe(e,t){return dW(e,{method:`GET`,path:`/api/forge/context/cloud-projects/${encodeURIComponent(String(t.projectId))}/removal-preview`,...t.signal===void 0?{}:{signal:t.signal}},e.cloudProjectRemovalPreviewUrl?()=>e.cloudProjectRemovalPreviewUrl(t.projectId):void 0).then(e=>e.preview)}function THe(e,t){return dW(e,{method:`POST`,path:`/api/forge/context/cloud-projects/${encodeURIComponent(String(t.projectId))}/removal`,body:{idempotencyKey:t.idempotencyKey,deletePlanningProject:t.deletePlanningProject,...t.deleteCheckoutFiles===void 0?{}:{deleteCheckoutFiles:t.deleteCheckoutFiles},...t.previewToken===void 0?{}:{previewToken:t.previewToken},...t.forceDirty===void 0?{}:{forceDirty:t.forceDirty}},...t.signal===void 0?{}:{signal:t.signal}},e.cloudProjectRemovalUrl?()=>e.cloudProjectRemovalUrl(t.projectId):void 0).then(e=>e.operation)}function fW(e,t=``){return`/api/forge/context/runtimes/${encodeURIComponent(e)}${t}`}async function EHe(e){if(e.ok)return;let{CmmdApiError:t}=await A(async()=>{let{CmmdApiError:e}=await import(`./transport-CgH8pQK3.js`).then(e=>e.r);return{CmmdApiError:e}},__vite__mapDeps([0,1]));if(e.status===401||e.status===403){let n=null;try{let t=await e.json();n=typeof t?.code==`string`?t.code:null}catch{}throw new t({kind:`auth`,message:`CMMD authentication required. Sign in again to continue.`,status:e.status,code:n})}throw new t({kind:e.status>=500?`server`:`client`,message:`forge-cloud-projects proxy error (${e.status})`,status:e.status})}var pW=class{config;constructor(e){this.config=e}async ensureRuntime(e){return(await dW(this.config,{method:`POST`,path:`/api/forge/context/runtimes/ensure`,body:{...e.projectId===void 0?{}:{projectId:e.projectId},...e.organizationId===void 0?{}:{organizationId:e.organizationId},...e.githubRepoFullName===void 0?{}:{githubRepoFullName:e.githubRepoFullName},...e.workspaceRoot===void 0?{}:{workspaceRoot:e.workspaceRoot}},...e.signal===void 0?{}:{signal:e.signal}},this.config.ensureUrl?()=>this.config.ensureUrl:void 0)).runtime}async connectRuntime(e){return dW(this.config,{method:`POST`,path:fW(e.runtimeId,`/connect`),...e.organizationId===void 0?{}:{body:{organizationId:e.organizationId}},...e.signal===void 0?{}:{signal:e.signal}})}async getRuntime(e){return(await dW(this.config,{method:`GET`,path:fW(e.runtimeId),...e.signal===void 0?{}:{signal:e.signal}})).runtime}async destroyRuntime(e){return(await dW(this.config,{method:`POST`,path:fW(e.runtimeId,`/destroy`),body:{purgeVolume:e.purgeVolume??!1,...e.force===!0?{force:!0}:{},...e.reason===void 0?{}:{reason:e.reason},...e.organizationId===void 0?{}:{organizationId:e.organizationId}},...e.signal===void 0?{}:{signal:e.signal}},this.config.destroyUrl?()=>this.config.destroyUrl(e.runtimeId):void 0)).runtime}async runRuntimeLifecycleAction(e){return(await dW(this.config,{method:`POST`,path:fW(e.runtimeId,`/${e.action}`),body:e.organizationId===void 0?{}:{organizationId:e.organizationId},...e.signal===void 0?{}:{signal:e.signal}},this.config.lifecycleUrl?()=>this.config.lifecycleUrl(e.runtimeId,e.action):void 0)).runtime}async updateRuntimeCommit(e){return(await dW(this.config,{method:`POST`,path:fW(e.runtimeId,`/update-commit`),body:e.organizationId===void 0?{}:{organizationId:e.organizationId},...e.signal===void 0?{}:{signal:e.signal}},this.config.updateCommitUrl?()=>this.config.updateCommitUrl(e.runtimeId):void 0)).operation}async getRuntimeCommitUpdateOperation(e){return(await dW(this.config,{method:`GET`,path:fW(e.runtimeId,`/update-commit/${encodeURIComponent(String(e.operationId))}`),...e.signal===void 0?{}:{signal:e.signal}},this.config.updateCommitOperationUrl?()=>this.config.updateCommitOperationUrl(e.runtimeId,e.operationId):void 0)).operation}async listCloudProjects(e){if(this.config.listUrl){let t=uW(this.config),n=await fetch(this.config.listUrl,{method:`GET`,headers:{Accept:`application/json`,...t?{Authorization:`Bearer ${t}`}:{}},credentials:t?`omit`:`include`,cache:`no-store`,...e?.signal===void 0?{}:{signal:e.signal}});return await EHe(n),sW(await n.json())}return sW(await dW(this.config,{method:`GET`,path:`/api/forge/context/cloud-projects`,...e?.signal===void 0?{}:{signal:e.signal}}))}async previewCloudProjectRemoval(e){return wHe(this.config,e)}async requestCloudProjectRemoval(e){return THe(this.config,e)}async getCloudProjectRemoval(e){return(await dW(this.config,{method:`GET`,path:`/api/forge/context/cloud-projects/removals/${encodeURIComponent(e.operationId)}`,...e.signal===void 0?{}:{signal:e.signal}},this.config.cloudProjectRemovalReceiptUrl?()=>this.config.cloudProjectRemovalReceiptUrl(e.operationId):void 0)).operation}},mW=`/api/attachments/upload/`;function DHe(e){if(!e.relativeUrl.startsWith(mW))throw Error(`Attachment upload URL did not use the expected upload route.`);let t=e.relativeUrl.slice(24);if(!/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(t))throw Error(`Attachment upload URL did not contain a valid signed token.`);if(e.relativeUrl.includes(`?`)||e.relativeUrl.includes(`#`))throw Error(`Attachment upload URL must not include a query or fragment.`);let n=new URL(e.httpBaseUrl),r=n.pathname.endsWith(`/`)?n.pathname.slice(0,-1):n.pathname,i=`${r}${mW}`,a=new URL(`${r}${e.relativeUrl}`,n);if(a.origin!==n.origin||!a.pathname.startsWith(i))throw Error(`Attachment upload URL resolved outside the selected environment.`);return a.toString()}var hW=!1,gW=null;function _W(e){return Object.values(e)}function vW(e){return e.map(e=>Ft(e))}function yW(e){try{Xi(vW(_W(e))).catch(e=>{console.error(`[SAVED_ENVIRONMENTS] persist failed`,e)})}catch(e){console.error(`[SAVED_ENVIRONMENTS] persist failed`,e)}}function OHe(e){let t=bW.getState().byId,n=Object.fromEntries(e.map(e=>[e.environmentId,e]));bW.setState({byId:{...n,...t}})}async function kHe(){if(hW)return;if(gW)return gW;let e=(async()=>{try{OHe(await Yi())}catch(e){console.error(`[SAVED_ENVIRONMENTS] hydrate failed`,e)}finally{hW=!0,bW.setState({hydrated:!0})}})().finally(()=>{gW===e&&(gW=null)});return gW=e,gW}var bW=ft()(e=>({byId:{},hydrated:hW,upsert:t=>e(e=>{let n={...e.byId,[t.environmentId]:t};return yW(n),{byId:n}}),remove:t=>e(e=>{let{[t]:n,...r}=e.byId;return yW(r),{byId:r}}),markConnected:(t,n)=>e(e=>{let r=e.byId[t];if(!r)return e;let i={...e.byId,[t]:{...r,lastConnectedAt:n}};return yW(i),{byId:i}}),reset:()=>{yW({}),e({byId:{}})}}));function xW(){return hW}function SW(){return xW()?Promise.resolve():kHe()}function CW(){return Object.values(bW.getState().byId).toSorted((e,t)=>e.label.localeCompare(t.label))}function AHe(){return CW().filter(e=>e.lastAuthenticatedPullRequestCapability===!0)}function wW(e){return bW.getState().byId[e]??null}function TW(e){let t=rW();return t?.environmentId===e?Vre(t):wW(e)?.httpBaseUrl??null}function EW(e){let t=TW(e.environmentId)??(typeof window<`u`?window.location.origin:null);if(!t)throw Error(`Unable to resolve HTTP base URL for environment ${e.environmentId}.`);let n=new URL(t);return n.pathname=`${n.pathname.endsWith(`/`)?n.pathname.slice(0,-1):n.pathname}${e.pathname.startsWith(`/`)?e.pathname:`/${e.pathname}`}`,e.searchParams&&(n.search=new URLSearchParams(e.searchParams).toString()),n.toString()}function DW(e){if(!TW(e))throw Error(`Unable to resolve HTTP base URL for environment ${e}.`)}function jHe(e){return DW(e.environmentId),DHe({httpBaseUrl:TW(e.environmentId),relativeUrl:e.relativeUrl})}async function OW(e){await Xi(vW(_W({...bW.getState().byId,[e.environmentId]:e})))}async function MHe(e,t){let{[e]:n,...r}=bW.getState().byId,i={...r,[t.environmentId]:t};await Xi(vW(_W(i))),bW.setState({byId:i})}async function kW(e){return Zi(e)}async function NHe(e,t){return Qi(e,t)}async function AW(e){await $i(e)}function PHe(e){return new Promise(t=>globalThis.setTimeout(t,e))}function jW(){let e=Error(`The environment connection attempt was cancelled.`);return e.name=`AbortError`,e}function MW(e){if(e?.aborted)throw jW()}function NW(e,t){return t?t.aborted?Promise.reject(jW()):new Promise((n,r)=>{let i=()=>r(jW());t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>{t.removeEventListener(`abort`,i)})}):e}function PW(e,t){return t?t.aborted?Promise.reject(jW()):new Promise((n,r)=>{let i=globalThis.setTimeout(()=>{t.removeEventListener(`abort`,a),n()},e),a=()=>{globalThis.clearTimeout(i),r(jW())};t.addEventListener(`abort`,a,{once:!0})}):PHe(e)}var FHe=Object.freeze({connectionState:`disconnected`,authState:`unknown`,lastError:null,lastErrorAt:null,role:null,descriptor:null,serverConfig:null,connectedAt:null,disconnectedAt:null,providerAuthority:null}),FW=()=>({...FHe}),IW=ft()(e=>({byId:{},ensure:t=>e(e=>e.byId[t]?e:{byId:{...e.byId,[t]:FW()}}),patch:(t,n)=>e(e=>({byId:{...e.byId,[t]:{...e.byId[t]??FW(),...n}}})),clear:t=>e(e=>{let{[t]:n,...r}=e.byId;return{byId:r}}),reset:()=>e({byId:{}})}));function LW(e){let t=wW(e.environmentId);if(t?.lastAuthenticatedPullRequestCapability!==void 0)return{...e,lastAuthenticatedPullRequestCapability:t.lastAuthenticatedPullRequestCapability};let n=IW.getState().byId?.[e.environmentId];return n?.authState===`authenticated`&&n.descriptor?{...e,lastAuthenticatedPullRequestCapability:n.descriptor.capabilities.pullRequests===!0}:e}function RW(e){return!!e.runtimeId?.trim()||Ri(e.environmentId).isCloud}function zW(e,t){return e.environmentId===t.environmentId&&e.httpBaseUrl===t.httpBaseUrl&&e.wsBaseUrl===t.wsBaseUrl&&e.runtimeId===t.runtimeId&&e.cmmdOrganizationId===t.cmmdOrganizationId}function IHe(e){return e.replacedRecord===null&&e.existing!==null&&zW(e.existing,e.record)}function LHe(e){let t=e.replacesEnvironmentId?yt.make(e.replacesEnvironmentId):null,n=t&&t!==e.environmentId?wW(t):null;return{existing:wW(e.environmentId)??n,replacedRecord:n}}async function RHe(e){return{records:CW(),bearerToken:e?await kW(e.environmentId):null}}async function BW(e){let t=e.replacedRecord?.environmentId??e.record.environmentId;await Xi(e.rollback.records),await AW(e.record.environmentId).catch(()=>void 0),e.rollback.bearerToken&&await NHe(t,e.rollback.bearerToken)}async function zHe(e){try{e.replacedRecord?await MHe(e.replacedRecord.environmentId,e.record):await OW(e.record),MW(e.signal),await AW(e.record.environmentId),e.replacedRecord&&await AW(e.replacedRecord.environmentId),MW(e.signal)}catch(t){try{await BW(e)}catch(e){let n=AggregateError([t,e],`Cloud Environment rollback failed.`);throw n.cause=t,n}throw t}}function BHe(e){return{lastError:e instanceof Error?e.message:String(e),lastErrorAt:new Date().toISOString()}}var VW=new Map;function HW(e,t){return e.acquire(t?{signal:t}:{})}function VHe(e,t){VW.set(e,t)}function HHe(e){return VW.has(e)}function UW(e,t){let n=VW.get(e);if(t&&n!==t){t.dispose();return}n?.dispose(),VW.delete(e)}async function UHe(e){let t=VW.get(e);if(t)return(await t.acquire()).bearerToken;let n=wW(e);return n&&RW(n)?null:kW(e)}function WW(){return{executionCount:0,isPending:!1,lastArgs:void 0,lastExecutionTime:0,nextExecutionTime:0,status:`idle`,maybeExecuteCount:0}}var WHe={enabled:!0,leading:!0,trailing:!0,wait:0},GHe=class{#e;constructor(e,t){this.fn=e,this.store=new ote(WW()),this.setOptions=e=>{this.options={...this.options,...e},this.#n()||this.cancel()},this.#t=e=>{this.store.setState(t=>{let n={...t,...e},{isPending:r}=n;return{...n,status:this.#n()?r?`pending`:`idle`:`disabled`}}),tte(`Throttler`,this)},this.#n=()=>!!dt(this.options.enabled,this),this.#r=()=>dt(this.options.wait,this),this.maybeExecute=(...e)=>{this.#t({maybeExecuteCount:this.store.state.maybeExecuteCount+1});let t=Date.now(),n=t-this.store.state.lastExecutionTime,r=this.#r();if(this.options.leading&&n>=r)this.#i(...e);else if(this.#t({lastArgs:e}),!this.#e&&this.options.trailing){let e=r-(this.store.state.lastExecutionTime?t-this.store.state.lastExecutionTime:0);this.#t({isPending:!0}),this.#e=setTimeout(()=>{let{lastArgs:e}=this.store.state;e!==void 0&&this.#i(...e)},e)}},this.#i=(...e)=>{if(!this.#n())return;this.fn(...e);let t=Date.now(),n=t+this.#r();this.#a(),this.#t({executionCount:this.store.state.executionCount+1,lastExecutionTime:t,nextExecutionTime:n,isPending:!1,lastArgs:void 0}),this.options.onExecute?.(e,this),setTimeout(()=>{this.store.state.isPending||this.#t({nextExecutionTime:void 0})},this.#r())},this.flush=()=>{this.store.state.isPending&&this.store.state.lastArgs&&this.#i(...this.store.state.lastArgs)},this.#a=()=>{this.#e&&=(clearTimeout(this.#e),void 0)},this.cancel=()=>{this.#a(),this.#t({lastArgs:void 0,isPending:!1})},this.reset=()=>{this.#t(WW())},this.key=t.key,this.options={...WHe,...t},this.#t(this.options.initialState??{}),this.key&&ite.on(`d-Throttler`,e=>{e.payload.key===this.key&&(this.#t(e.payload.store.state),this.setOptions(e.payload.options))})}#t;#n;#r;#i;#a},GW={all:[`projects`],searchContents:(e,t,n,r,i,a,o)=>[`projects`,`search-contents`,e??null,t,n,r,i,a,o],searchEntries:(e,t,n,r)=>[`projects`,`search-entries`,e??null,t,n,r]},KW={all:[`providers`],checkpointDiff:e=>[`providers`,`checkpointDiff`,e.environmentId??null,e.threadId,e.fromTurnCount,e.toTurnCount,e.cacheScope??null]};function KHe(e){let t=null,n=!1;function r(){return t}function i(){n=!0,t?.queryInvalidationThrottler.maybeExecute()}function a(){t?.stop(),t=null}function o(r){if(t?.queryClient===r)return t.refCount+=1,()=>{!t||t.queryClient!==r||(--t.refCount,t.refCount===0&&a())};a(),n=!1;let i=new GHe(()=>{n&&(n=!1,r.invalidateQueries({queryKey:KW.all}),r.invalidateQueries({queryKey:GW.all}))},{wait:100,leading:!1,trailing:!0});e.createPrimaryEnvironmentConnection(),mn().catch(()=>void 0);let o=bW.subscribe(()=>{xW()&&e.syncSavedEnvironmentConnections(CW())});return SW().then(()=>e.syncSavedEnvironmentConnections(CW())).catch(()=>void 0),t={queryClient:r,queryInvalidationThrottler:i,refCount:1,stop:()=>{o(),i.cancel()}},()=>{!t||t.queryClient!==r||(--t.refCount,t.refCount===0&&a())}}return{readActiveService:r,notifyProviderInvalidation:i,stopActiveService:a,start:o}}var qHe=class extends Error{status;constructor(e,t){super(e),this.name=`RemoteEnvironmentAuthHttpError`,this.status=t}};function JHe(e,t){let n=new URL(e);return n.pathname=`${n.pathname.endsWith(`/`)?n.pathname.slice(0,-1):n.pathname}${t.startsWith(`/`)?t:`/${t}`}`,n.search=``,n.hash=``,n.toString()}async function YHe(e,t){let n=await e.text();if(!n)return t;try{let e=JSON.parse(n);if(typeof e.error==`string`&&e.error.length>0)return e.error}catch{}return n}async function qW(e){let t=JHe(e.httpBaseUrl,e.pathname),n;try{n=await fetch(t,{method:e.method??`GET`,headers:{...e.body===void 0?{}:{"content-type":`application/json`},...e.bearerToken?{authorization:`Bearer ${e.bearerToken}`}:{}},...e.body===void 0?{}:{body:JSON.stringify(e.body)},...e.signal?{signal:e.signal}:{}})}catch(e){throw Error(`Failed to fetch remote auth endpoint ${t} (${e.message}).`,{cause:e})}if(!n.ok)throw new qHe(await YHe(n,`Remote auth request failed (${n.status}).`),n.status);return await n.json()}async function JW(e){return qW({httpBaseUrl:e.httpBaseUrl,pathname:`/api/auth/session`,bearerToken:e.bearerToken,...e.signal?{signal:e.signal}:{}})}async function XHe(e){return qW({httpBaseUrl:e.httpBaseUrl,pathname:`/.well-known/forge/environment`,...e.bearerToken?{bearerToken:e.bearerToken}:{}})}async function ZHe(e){return qW({httpBaseUrl:e.httpBaseUrl,pathname:`/api/auth/ws-token`,method:`POST`,bearerToken:e.bearerToken})}async function YW(e){let t=new URL(e.wsBaseUrl,window.location.origin);if(e.runtimeTicket)return t.searchParams.set(`runtimeTicket`,e.runtimeTicket),t.searchParams.delete(`wsToken`),t.toString();let n=await ZHe({httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken});return t.searchParams.set(`wsToken`,n.token),t.toString()}function QHe(e,t){if(t){Dne(t,e);return}One(e)}function $He(e){let t=null,n=[];for(let r of e.split(/\r?\n/)){if(r.startsWith(`event:`)){t=r.slice(6).trim();continue}r.startsWith(`data:`)&&n.push(r.slice(5).trimStart())}return{eventName:t,data:n.join(`
1007
1007
  `)}}function eUe(e,t){let n=$He(e);if(n.eventName!==`phase`||!n.data)return!1;try{let e=JSON.parse(n.data);return QHe(e,t),e.phase===`app-ready`||e.phase===`error`}catch{return!1}}async function tUe(e,t,n){if(!e.body)return;let r=e.body.getReader(),i=new TextDecoder,a=``;for(;!n.aborted;){let{done:e,value:n}=await r.read();if(e)break;a+=i.decode(n,{stream:!0});let o=a.indexOf(`
1008
1008
 
@@ -1021,7 +1021,7 @@ If init has been called in the preload and contextIsolation is disabled, is not
1021
1021
  `))r.startsWith(`event: `)&&(t=r.slice(7).trim()),r.startsWith(`data: `)&&(n=r.slice(6).trim());return{name:t,data:n}}var NQe=`/api/cmmd/forge-cloud-projects`,PQe=`/api/cmmd/forge-cloud-projects/events`,FQe=15e3,IQe=3e4,LQe=2e3,RQe=3e4,zQe=200;function FZ(e){return e!==null&&clearTimeout(e),null}function BQe({config:e,onEvent:t}){let n=!1,r=!1,i=!1,a=!1,o=!1,s=0,c=null,l=0,u=null,d=null,f=0,p=null,m=null,h=null,g=null;function _(){p=FZ(p),g=FZ(g)}function v(){f+=1,d?.controller.abort(),d=null}function y(e,t){return d?.controller===e&&d.generation===t&&f===t}function b(e){return u===e}function x(){v(),u?.abort(),u=null,_(),h=FZ(h)}function S(){return!r&&!a}function C(e){t({kind:`catalog`,catalog:e,fetchedAt:new Date().toISOString()})}function w(e){a||r||(a=!0,c=null,x(),t({kind:`auth-required`,message:e}))}function T(e,n){if(r||a)return;s+=1,c=n;let i=NZ({failedAttempt:s,retryDelayMs:MZ});if(i.kind===`terminal`){w(e);return}u?.abort(),u=null,g=FZ(g),t({kind:`auth-refreshing`}),o=!0,h=FZ(h),h=setTimeout(()=>{h=null,o=!1,he()},i.delayMs)}async function E(){if(!S())return!1;let n=new AbortController,r=++f;d={controller:n,generation:r},t({kind:`loading`});try{return ee(await wQe(e,n,FQe),n,r)}finally{y(n,r)&&(d=null)}}function ee(e,t,n){return!S()||!y(t,n)?!1:e.kind===`catalog`?te(e.catalog):e.kind===`timed-out`?ne():re(e.error)}function te(e){return c!==`sse`&&(s=0,c=null),o=!1,C(e),!0}function ne(){return t({kind:`failed`,message:`Cloud connection refresh timed out. Showing last known connections.`}),!a}function re(e){let n=e instanceof Error?e.message:`Failed to load cloud projects`;return xU(e)||VQe(e)||/authentication required/i.test(n)?T(n,`list`):t({kind:`failed`,message:n}),!a}function ie(){S()&&(p=FZ(p),p=setTimeout(async()=>{await E(),S()&&ie()},IQe))}function ae(){!S()||o||(i?ie():se(l))}function oe(e){l=e+1;let t=Math.min(LQe*2**e,RQe);g=FZ(g),g=setTimeout(()=>{g=null,se(l)},t)}function D(e){s=0,c=null,l=0,C(e)}async function se(t){if(!S()||u!==null)return;u=new AbortController;let n=u,r=e.eventsUrl??EQe(e.cmmdHttpBaseUrl,`/api/forge/context/runtimes/events`),i=e.eventsUrl?{Accept:`text/event-stream`}:TQe(e);try{await ce(await fetch(r,{headers:i,signal:n.signal,credentials:`include`}),n,t)}catch{pe(n)}}async function ce(e,t,n){if(!le(t))return;let r=await PZ(e);if(le(t)){if(typeof r==`string`){fe(r);return}await DQe({reader:r,signal:t.signal,onAuthRequired:()=>ue(t),onCatalog:e=>de(t,e)}),me(t,n)}}function le(e){return S()&&b(e)}function ue(e){le(e)&&T(`CMMD authentication required. Sign in again to continue.`,`sse`)}function de(e,t){le(e)&&D(t)}function fe(e){if(u=null,e===`auth-required`){T(`CMMD authentication required. Sign in again to continue.`,`sse`);return}i=!0,ie()}function pe(e){e.signal.aborted||!le(e)||(u=null,i=!0,ie())}function me(e,t){e.signal.aborted||!le(e)||(u=null,oe(t))}function he(){return E().then(e=>{e&&S()&&ae()})}return{initialize(){n||r||(n=!0,he())},refresh(){r||(v(),m=FZ(m),m=setTimeout(()=>{m=null,a=!1,o=!1,s=0,c=null,x(),he()},zQe))},teardown(){r=!0,m=FZ(m),x()}}}function VQe(e){return typeof e==`object`&&!!e&&`kind`in e&&e.kind===`auth`}var IZ={connected:!1,isLoading:!1,error:null,rows:[],environments:[],fetchedAt:null,stale:!1,startupPhase:`idle`,capacity:null};function HQe({config:e}){let t=yQe(),n=t?{...IZ,isLoading:!0,rows:t.rows,environments:t.environments,fetchedAt:t.fetchedAt,stale:!0}:IZ,r=new Set;function i(e){n=e;for(let e of r)e()}function a(e){switch(e.kind){case`loading`:i({...n,isLoading:!0,error:null});return;case`catalog`:{let t=hQe(e.catalog.listRowsForDisplay()),n=gQe(e.catalog.listEnvironmentsForDisplay());bQe(t,n,e.fetchedAt),i({connected:!0,isLoading:!1,error:null,rows:t,environments:n,fetchedAt:e.fetchedAt,stale:!1,startupPhase:`idle`,capacity:e.catalog.capacity});return}case`failed`:i({...n,connected:!1,isLoading:!1,error:e.message,stale:n.rows.length>0,startupPhase:`idle`});return;case`auth-refreshing`:i({...n,connected:!1,isLoading:!0,error:null,stale:n.rows.length>0,startupPhase:`auth-refreshing`});return;case`auth-required`:i({...n,connected:!1,isLoading:!1,error:e.message,stale:n.rows.length>0,startupPhase:`idle`}),dn(`cmmd-runtimes`);return}}let o=BQe({config:e,onEvent:a});return{subscribe(e){return r.add(e),()=>r.delete(e)},read(){return n},initialize(){o.initialize()},refresh(){o.refresh()},_teardown(){o.teardown()},_setState(e){i(e)}}}var LZ=null;function RZ(e){return typeof window<`u`&&window.location?.href?new URL(e,window.location.href).toString():new URL(e,`http://localhost`).toString()}function zZ(){return{cmmdHttpBaseUrl:`https://cmmd.ai`,resolveAccessToken:()=>null,listUrl:NQe,eventsUrl:PQe,destroyUrl:e=>RZ(`/api/cmmd/forge-runtimes/${encodeURIComponent(e)}/destroy`),lifecycleUrl:(e,t)=>RZ(`/api/cmmd/forge-runtimes/${encodeURIComponent(e)}/${t}`),updateCommitUrl:e=>RZ(`/api/cmmd/forge-runtimes/${encodeURIComponent(e)}/update-commit`),updateCommitOperationUrl:(e,t)=>RZ(`/api/cmmd/forge-runtimes/${encodeURIComponent(e)}/update-commit/${encodeURIComponent(String(t))}`),ensureUrl:RZ(`/api/cmmd/forge-runtimes/ensure`)}}function BZ(){return LZ===null&&(LZ=HQe({config:zZ()})),LZ}function UQe(){BZ().refresh()}function WQe(e){return BZ().subscribe(e)}function VZ(){return BZ().read()}function GQe(e){let t=(0,hi.c)(9),n=e?.enabled??!0,r,i;t[0]===n?(r=t[1],i=t[2]):(r=()=>{n&&BZ().initialize()},i=[n],t[0]=n,t[1]=r,t[2]=i),(0,M.useEffect)(r,i);let a=(0,M.useSyncExternalStore)(WQe,VZ,VZ),o=KK(KQe),s,c;t[3]!==o||t[4]!==a.rows?(c=rQe(a.rows,o),t[3]=o,t[4]=a.rows,t[5]=c):c=t[5],s=c;let l=s,u;return t[6]!==l||t[7]!==a?(u=l===a.rows?a:{...a,rows:l},t[6]=l,t[7]=a,t[8]=u):u=t[8],u}function KQe(e){return e.environmentStateById}var qQe=`forge:cloud-runtime-handoffs:v2`,JQe=3e5,HZ=new Map,YQe={clear:()=>HZ.clear(),getItem:e=>HZ.get(e)??null,key:e=>Array.from(HZ.keys())[e]??null,get length(){return HZ.size},removeItem:e=>HZ.delete(e),setItem:(e,t)=>HZ.set(e,t)};function XQe(){return typeof window<`u`?window.localStorage:globalThis.localStorage??YQe}var UZ=ft()(YK(e=>({byRuntimeId:{},record:t=>e(e=>({byRuntimeId:{...e.byRuntimeId,[t.runtimeId]:t}})),clearRuntime:t=>e(e=>t in e.byRuntimeId?{byRuntimeId:Object.fromEntries(Object.entries(e.byRuntimeId).filter(([e])=>e!==t))}:e),reconcileCatalog:(t,n=Date.now())=>e(e=>{let r=Object.entries(e.byRuntimeId).filter(([,e])=>{if(n-e.recordedAt>JQe)return!1;let r=t.find(t=>t.cmmdOrganizationId===e.cmmdOrganizationId&&t.cmmdProjectId===e.cmmdProjectId);return r?.runtimeId===e.previousCatalogRuntimeId&&r.registeredAt===e.catalogRegisteredAt});return r.length===Object.keys(e.byRuntimeId).length?e:{byRuntimeId:Object.fromEntries(r)}}),reset:()=>e({byRuntimeId:{}})}),{name:qQe,storage:qK(XQe),partialize:e=>({byRuntimeId:e.byRuntimeId}),version:2}));function ZQe(e){UZ.getState().record({...e,recordedAt:Date.now()})}function QQe(e){UZ.getState().clearRuntime(e)}var $Qe=new Set([`filesystem`,`terminal`,`git`,`project-write`]);function e$e(e){return e===`desktop-local`}function t$e(e){return e===`cloud`||e===`cloud-vm`||e===`cmmd`||e===`github`}function WZ(e){return e.actionKind===`cloud-api`?{available:!0,route:`cloud`,requiresPermissionGate:!1,title:`Cloud API route`,description:`Cloud and Command work routes through authenticated Forge Cloud APIs.`}:$Qe.has(e.actionKind)?t$e(e.workSource)?e.workSource===`cloud-vm`&&e.executionRuntime===`cloud`?{available:!0,route:`cloud-vm`,requiresPermissionGate:!1,title:`Cloud VM route`,description:`Filesystem, terminal, git, and project writes run inside the user's Forge Cloud VM.`}:e.executionRuntime===`cloud`?{available:!0,route:`cloud`,requiresPermissionGate:!1,title:`Cloud work route`,description:`Cloud-scoped filesystem, terminal, git, and project writes run in the Forge Cloud runtime.`}:{available:!1,route:`blocked`,requiresPermissionGate:!1,title:`Open in Forge Cloud`,description:`Cloud projects must execute inside the Forge Cloud runtime. Local Desktop cannot run cloud project filesystem, terminal, git, or project-write actions.`}:e$e(e.workSource)?e.surface===`desktop-local`||e.executionRuntime===`desktop-local`?{available:!0,route:`desktop-local`,requiresPermissionGate:!1,title:`Desktop local route`,description:`Local filesystem, terminal, git, and project writes run through the Desktop local backend.`}:e.executionRuntime===`dev-local-web`?{available:!0,route:`dev-local-web`,requiresPermissionGate:!1,title:`Dev local route`,description:`Local Web is a development-only projection and routes local actions through the dev server.`}:{available:!1,route:`blocked`,requiresPermissionGate:!1,title:`Switch to Desktop Local`,description:`Local projects must execute in the Desktop Local runtime. Forge Cloud cannot run local filesystem, terminal, git, or project-write actions.`}:{available:!1,route:`blocked`,requiresPermissionGate:!1,title:`Unknown work source`,description:`Forge cannot safely route local actions for this work source yet.`}:{available:!1,route:`blocked`,requiresPermissionGate:!1,title:`Unsupported route`,description:`Forge does not have a runtime route for this action yet.`}}var n$e=`Ready to use. Your cloud project starts when you open the first thread.`;function r$e(e){let t=WZ({actionKind:`project-write`,surface:`cloud-official`,workSource:`cloud-vm`,executionRuntime:`cloud`});return{actionAuthority:`runtime`,surface:`cloud-official`,hostKind:`user-cloud-vm`,workSource:`cloud-vm`,executionRuntime:`cloud`,modelRuntime:`cloud`,linkState:`cloud-only`,workspaceIdentity:null,hideLocalPath:!0,label:`Cloud project`,description:e?`This project runs in your Forge Cloud VM.`:n$e,actionRouteLabel:t.title,actionRouteDescription:t.description,actionRouteAvailable:t.available,requiresPermissionGate:t.requiresPermissionGate}}var i$e=3e5;function GZ(e,t,n=Date.now()){let r=new Map,i=new Map;for(let t of e){let e={cmmdOrganizationId:t.cmmdOrganizationId,cmmdProjectId:t.cmmdProjectId};r.set(qZ(e),e),t.runtimeId!==null&&i.set(t.runtimeId,e)}for(let a of t){if(n-a.recordedAt>i$e)continue;let t=r.get(qZ({cmmdOrganizationId:a.cmmdOrganizationId,cmmdProjectId:a.cmmdProjectId})),o=e.find(e=>e.cmmdOrganizationId===a.cmmdOrganizationId&&e.cmmdProjectId===a.cmmdProjectId);t&&o?.runtimeId===a.previousCatalogRuntimeId&&o.registeredAt===a.catalogRegisteredAt&&!i.has(a.runtimeId)&&i.set(a.runtimeId,t)}return i}function KZ(e){return e.environmentId??`cmmd-cloud-project:${e.cmmdOrganizationId}:${e.cmmdProjectId}`}function a$e(e){return{environmentId:KZ(e),workspaceRoot:e.workspaceRoot,resolvedRef:e.resolvedRef}}function qZ(e){return`cloud:${e.cmmdOrganizationId}:${e.cmmdProjectId}`}function o$e(e){let t=/^cloud:(\d+):(\d+)$/.exec(e??``);return t?{cmmdOrganizationId:Number(t[1]),cmmdProjectId:Number(t[2])}:null}function s$e(e){return`cloud-runtime:${e}`}var c$e=`cloud-unconnected:`;function l$e(e,t,n=[]){let r=qZ(e);return JZ({id:_t.make(`${c$e}${r}`),environmentId:yt.make(KZ(e)),name:e.projectName,cwd:``,repositoryIdentity:null,availability:void 0,defaultModelSelection:null,createdAt:void 0,updatedAt:void 0,scripts:[],projectKey:r,environmentPresence:`remote-only`,source:r$e(e.runtimeId!==null),memberProjectRefs:t?[t]:[],remoteEnvironmentLabels:[],worktreeMembers:[],activeWorktreeKey:null,preConnectCloud:{runtimeId:e.runtimeId,cmmdOrganizationId:e.cmmdOrganizationId,cmmdProjectId:e.cmmdProjectId,cmmdEnvironmentId:e.cmmdEnvironmentId,registeredAt:e.registeredAt,projectName:e.projectName,githubRepoFullName:e.githubRepoFullName,workspaceRoot:e.workspaceRoot,iconUrl:e.iconUrl,icon:e.icon,status:e.status,removal:e.removal},cloudRemoval:e.removal},n)}function JZ(e,t){if(t.length===0)return e;let n=[...e.memberProjectRefs],r=new Set(n.map(e=>`${e.environmentId}:${e.projectId}`));for(let e of t){let t=`${e.environmentId}:${e.projectId}`;r.has(t)||(r.add(t),n.push(e))}return n.length===e.memberProjectRefs.length?e:{...e,memberProjectRefs:n}}function YZ(e,t,n,r){if(!e)return null;let i=t.find(t=>t.cmmdEnvironmentId===String(e));if(i)return{row:i,runtimeId:i.runtimeId,matchedByHandoff:!1};let a=Ri(e).legacyRuntimeId;if(a){let e=t.find(e=>e.runtimeId===a);if(e)return{row:e,runtimeId:a,matchedByHandoff:!1};let i=GZ(t,n,r).get(a);if(!i)return null;let o=t.find(e=>e.cmmdOrganizationId===i.cmmdOrganizationId&&e.cmmdProjectId===i.cmmdProjectId);return o?{row:o,runtimeId:a,matchedByHandoff:!0}:null}let o=t.find(t=>t.runtimeId===null&&KZ(t)===String(e));return o?{row:o,runtimeId:null,matchedByHandoff:!1}:null}function u$e(e,t=e.runtimeId){return{runtimeId:t,cmmdOrganizationId:e.cmmdOrganizationId,cmmdProjectId:e.cmmdProjectId,cmmdEnvironmentId:e.cmmdEnvironmentId,registeredAt:e.registeredAt,projectName:e.projectName,githubRepoFullName:e.githubRepoFullName,workspaceRoot:e.workspaceRoot,iconUrl:e.iconUrl,icon:e.icon,status:e.status,desiredState:e.desiredState}}function d$e(e){return e.desiredState===`stopped`}var f$e=15e3;function p$e(e){return e===401||e===403}function m$e(e){return typeof e!=`object`||!e?!1:e.retryable===!0}function XZ(e){return p$e(e.status)||e.attempt>=e.maxAttempts||e.status>=200&&e.status<300?!1:e.status>=500||e.status===409&&m$e(e.body)}function h$e(e,t){let n=e?.trim();if(!n)return null;if(/^-?\d+$/.test(n))return Number(n)*1e3;let r=Date.parse(n);return Number.isNaN(r)?null:r-t}function ZZ(e){let t=e=>Math.min(f$e,Math.max(0,e)),n=h$e(e.retryAfter,e.nowMs??Date.now());return t(n===null?300*2**Math.max(0,e.attempt-1):n)}var g$e=6e4;function _$e(e,t){if(!e||typeof e!=`object`)return t;let n=e.error;return typeof n==`string`&&n.trim().length>0?n:t}var QZ=`CMMD returned an invalid Cloud runtime connection descriptor.`;function $Z(e,t){let n=e[t];if(typeof n!=`string`||n.length===0)throw Error(QZ);return n}function v$e(e){if(!e||typeof e!=`object`)throw Error(QZ);let t=e;return{httpBaseUrl:$Z(t,`httpBaseUrl`),wsBaseUrl:$Z(t,`wsBaseUrl`),bearerToken:$Z(t,`bearerToken`),expiresAt:$Z(t,`expiresAt`)}}async function y$e(e){let t=fn(`/api/cmmd/forge-runtimes/${encodeURIComponent(e.runtimeId)}/connect`),n=gn({method:`POST`,...e.signal?{signal:e.signal}:{},headers:{"Content-Type":`application/json`},body:JSON.stringify(e.organizationId===void 0?{}:{organizationId:e.organizationId})});for(let r=1;r<=8;r+=1){let i=await fetch(t,n),a=await i.json().catch(()=>null);if(i.ok)return v$e(a);if(!XZ({status:i.status,body:a,attempt:r,maxAttempts:8})){let e=mZ(i.status,a)?`CMMD authentication expired while renewing the Cloud runtime connection. Sign in again.`:`CMMD could not renew the Cloud runtime connection (${i.status}).`;throw Object.assign(Error(_$e(a,e)),{status:i.status,...pZ(a)?{code:pZ(a)}:{}})}await PW(ZZ({attempt:r,retryAfter:i.headers.get(`retry-after`)}),e.signal)}throw Error(`Cloud runtime connection retry budget was exhausted.`)}function b$e(e,t){if(!e?.expiresAt)return!0;let n=Date.parse(e.expiresAt);return!Number.isFinite(n)||n<=t+g$e}function eQ(e){let t=e.requestDescriptor??y$e,n=e.now??Date.now,r=e.initialDescriptor??null,i=null,a=!1,o=new AbortController,s=e=>NW(e,o.signal),c=()=>i||(i=s(t({runtimeId:e.runtimeId,...e.organizationId===void 0?{}:{organizationId:e.organizationId},signal:o.signal})).then(async t=>(await s(Promise.resolve(e.validateDescriptor?.(t))),await s(Promise.resolve(e.persistDescriptor?.(t))),await s(Promise.resolve()),r=t,a=!1,t)).then(e=>(i=null,e),e=>{throw i=null,e}),i);return{acquire:e=>{if(o.signal.aborted)return s(Promise.resolve(r));let t=e?.forceRefresh||a||b$e(r,n())?c():Promise.resolve(r);return NW(s(t),e?.signal)},invalidate:()=>{a=!0},dispose:()=>{o.abort()}}}function x$e(e){let t=e.runtimeId?.trim();if(t)return t;let n=Ri(e.environmentId).legacyRuntimeId;if(n)return n;let r=VZ().rows,i=Object.values(UZ.getState().byRuntimeId);return YZ(e.environmentId,r,i)?.runtimeId??null}function S$e(e,t,n,r){let i=e,a=eQ({runtimeId:t,...e.cmmdOrganizationId===void 0?{}:{organizationId:e.cmmdOrganizationId},...n===void 0?{}:{initialDescriptor:{httpBaseUrl:e.httpBaseUrl,wsBaseUrl:e.wsBaseUrl,bearerToken:n,expiresAt:e.runtimeTicketExpiresAt??null}},validateDescriptor:async e=>{await JW({httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken})},persistDescriptor:async e=>{if(r&&!r())throw Error(`Saved environment changed while its connection was being acquired.`);let t={...LW(i),httpBaseUrl:e.httpBaseUrl,wsBaseUrl:Ct(e.wsBaseUrl),...e.expiresAt===null?{}:{runtimeTicketExpiresAt:e.expiresAt},lastConnectedAt:new Date().toISOString()};await OW(t),await AW(t.environmentId),bW.getState().upsert(t),i=t}});return VHe(e.environmentId,a),a}function C$e(e){let t={wsBaseUrl:e.record.wsBaseUrl,httpBaseUrl:e.record.httpBaseUrl,bearerToken:e.bearerToken,expiresAt:e.record.runtimeTicketExpiresAt??null};return{acquire:()=>Promise.resolve(t)}}var w$e=12e4,T$e=3e4,tQ=3e4;function nQ(e){let t=e.expiresAt?Date.parse(e.expiresAt):NaN;if(!Number.isFinite(t))throw Error(`Cloud runtime authority descriptor has no valid expiry.`);return t}function E$e(e){if(!e||typeof e!=`object`)return!1;let t=e.status;return t===401||t===403}function D$e(e){let t=e.now??Date.now,n=e.renewalSkewMs??w$e,r=!1,i=null,a=null,o=nQ(e.initialDescriptor),s=()=>{i!==null&&(globalThis.clearTimeout(i),i=null)},c=a=>{if(r)return;s();let c=nQ(a);o=c;let l=Math.max(t(),c-n);e.onState?.({kind:`scheduled`,expiresAt:new Date(c).toISOString(),renewAt:new Date(l).toISOString()}),i=globalThis.setTimeout(()=>{i=null,u().catch(()=>void 0)},Math.max(0,l-t()))},l=()=>{if(r)return null;let e=t()+tQ;return e>=o?null:(i=globalThis.setTimeout(()=>{i=null,u().catch(()=>void 0)},tQ),new Date(e).toISOString())},u=()=>{if(r)return Promise.resolve();if(a)return a;s(),e.onState?.({kind:`renewing`,expiresAt:new Date(o).toISOString()});let n=e.renew().then(async n=>{let i=nQ(n);if(i<=t())throw Error(`Cloud runtime authority descriptor is already expired.`);r||(e.onState?.({kind:`ready`,expiresAt:new Date(i).toISOString(),renewedAt:new Date(t()).toISOString()}),c(n))}).catch(t=>{if(r)return;let n=E$e(t);throw e.onState?.({kind:`error`,code:n?`authority_auth_rejected`:`authority_renewal_failed`,retryAt:n?null:l()}),t}).finally(()=>{a=null});return a=n,n};return c(e.initialDescriptor),{ensureLive:()=>o>t()+T$e?Promise.resolve():u(),renewNow:u,dispose:()=>{r=!0,s()}}}function rQ(){return new Date().toISOString()}function O$e(e,t,n,r,i){return n()&&IW.getState().ensure(e.environmentId),jG(new SG(async()=>{let e=e=>YW({wsBaseUrl:e.wsBaseUrl,httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken,...r?{runtimeTicket:e.bearerToken}:{}}),n=await t.acquire();try{return await e(n)}catch(n){if(!r||!xU(n))throw n;return e(await t.acquire({forceRefresh:!0}))}},{trackGlobalConnection:!1,onAttempt:()=>{n()&&i.setConnecting(e.environmentId)},onOpen:()=>{n()&&i.setConnected(e.environmentId)},onError:i=>{r&&gZ(i)&&t.invalidate?.(),n()&&IW.getState().patch(e.environmentId,{connectionState:`error`,lastError:i,lastErrorAt:rQ()})},onClose:a=>{r&&(a.code===1008||gZ(a.reason))&&t.invalidate?.(),n()&&i.setDisconnected(e.environmentId,a.reason)}}))}async function iQ(e,t,n,r,i,a,o){let s=await HW(t,o),[c,l]=await Promise.all([a?Promise.resolve(a):n.server.getConfig(),JW({httpBaseUrl:s.httpBaseUrl,bearerToken:s.bearerToken,...o?{signal:o}:{}})]);return r()?(IW.getState().patch(e.environmentId,{authState:l.authenticated?`authenticated`:`requires-auth`,descriptor:c.environment,serverConfig:c,role:l.authenticated?l.role??i??null:null}),k$e(e,c,l.authenticated,r),!0):!1}function k$e(e,t,n,r){if(!n||!r())return;let i=wW(e.environmentId);i&&bW.getState().upsert({...i,lastAuthenticatedPullRequestCapability:t.environment.capabilities?.pullRequests===!0})}async function A$e(e,t,n,r){let i=n.findConnection(e.environmentId);if(i)return i;let a=r?.registryExpectation??{kind:`existing-record`,record:e},o=()=>n.canCommit({record:e,generation:t,registryExpectation:a}),{isCmmdRuntime:s,targetProvider:c,initialTarget:l}=await j$e(e,r,o);if(!o())throw aQ(e.environmentId,c,s),Error(`Saved environment changed while its connection was being acquired.`);let u=r?.client??O$e(e,c,o,s,n),d=N$e({record:e,initialTarget:l,targetProvider:c,isCmmdRuntime:s,client:u,canCommit:o,dependencies:n});try{if(!await n.withMetadataTimeout(e,iQ(e,c,u,o,r?.role??null,r?.serverConfig??null,r?.signal))||!o())throw Error(`Saved environment changed while its connection was being acquired.`);return n.registerConnection(d)}catch(t){throw s&&UW(e.environmentId,c),o()&&n.setError(e.environmentId,t),await d.dispose().catch(()=>void 0),t}}async function j$e(e,t,n){let r=RW(e)?x$e(e):null,i=r!==null,a=await M$e(e,t,i,n),o=i?S$e(e,r,a??void 0,n):C$e({record:e,bearerToken:a});try{return{isCmmdRuntime:i,targetProvider:o,initialTarget:await HW(o,t?.signal)}}catch(t){throw aQ(e.environmentId,o,i),t}}function aQ(e,t,n){n&&UW(e,t)}async function M$e(e,t,n,r){if(n)return t?.bearerToken;let i=t?.bearerToken??await kW(e.environmentId);if(i)return i;throw r()&&IW.getState().patch(e.environmentId,{authState:`requires-auth`,role:null,connectionState:`disconnected`,lastError:`Saved environment is missing its saved credential. Pair it again.`,lastErrorAt:rQ()}),Error(`Saved environment is missing its saved credential.`)}function N$e(e){let{record:t,initialTarget:n,targetProvider:r,isCmmdRuntime:i,client:a,canCommit:o,dependencies:s}=e,c=$r({id:t.environmentId,label:t.label,source:`manual`,target:{httpBaseUrl:n.httpBaseUrl,wsBaseUrl:n.wsBaseUrl}}),l=i&&n.expiresAt?D$e({initialDescriptor:{...n,expiresAt:n.expiresAt},renew:async()=>{let e=await r.acquire({forceRefresh:!0});return{...e,expiresAt:e.expiresAt??null}},onState:e=>{o()&&IW.getState().patch(t.environmentId,{providerAuthority:e})}}):null;return XW({kind:`saved`,knownEnvironment:{...c,environmentId:t.environmentId},client:a,readiness:{bearerToken:n.bearerToken},tolerateReportedEnvironmentIdentity:i,refreshMetadata:async()=>{await iQ(t,r,a,o)},...l?{ensureProviderAuthority:l.ensureLive,onDispose:l.dispose}:{},onConfigSnapshot:e=>{o()&&IW.getState().patch(t.environmentId,{descriptor:e.environment,serverConfig:e})},...s.createHandlers(e=>{o()&&IW.getState().patch(t.environmentId,{descriptor:e.environment})})})}var P$e=class{readRecord;hasSameTarget;generations=new Map;acquisitions=new Map;constructor(e,t){this.readRecord=e,this.hasSameTarget=t}invalidate(e){this.generations.set(e,this.readGeneration(e)+1)}generationFor(e){return this.readGeneration(e)}isCurrent(e){if(this.readGeneration(e.record.environmentId)!==e.generation)return!1;let t=this.readRecord(e.record.environmentId);return e.registryExpectation.kind===`initial-add`?t===null||this.hasSameTarget(t,e.record):t!==null&&this.hasSameTarget(t,e.registryExpectation.record)}ensure(e,t){let n=this.readGeneration(e.environmentId),r=this.acquisitions.get(e.environmentId);if(r&&r.generation===n&&this.hasSameTarget(r.record,e))return r.promise;let i=t(e,n).finally(()=>{this.acquisitions.get(e.environmentId)?.promise===i&&this.acquisitions.delete(e.environmentId)});return this.acquisitions.set(e.environmentId,{generation:n,record:e,promise:i}),i}async sync(e){await Xi(e.records);let t=new Map(e.records.map(e=>[e.environmentId,e]));for(let[e,n]of this.acquisitions){let r=t.get(e);(!r||!this.hasSameTarget(r,n.record))&&this.invalidate(e)}let n=new Set(t.keys());await Promise.all(e.connectedSavedEnvironmentIds.filter(e=>!n.has(e)).map(async t=>{this.invalidate(t),await e.disconnect(t)}))}clear(){this.generations.clear(),this.acquisitions.clear()}readGeneration(e){return this.generations.get(e)??0}};async function F$e(e,t,n){if(!RW(e))return n.ensureSavedEnvironmentConnection(e,t);let r=n.getGeneration(e.environmentId),i=()=>n.registry.isCurrent({record:e,generation:r,registryExpectation:t?.registryExpectation??{kind:`existing-record`,record:e}}),a=null;for(let r=0;r<8;r+=1){MW(t?.signal);try{let r=await n.ensureSavedEnvironmentConnection(e,t);return await NW(r.ensureBootstrapped(),t?.signal),r}catch(o){a=o,await I$e({error:o,attemptIndex:r,record:e,options:t,dependencies:n,canCommit:i})}}let o=a instanceof Error?a:Error(String(a));throw i()&&n.setRuntimeError(e.environmentId,o),o}async function I$e(e){let{error:t,attemptIndex:n,record:r,options:i,dependencies:a,canCommit:o}=e;if(!o())throw t;if(await a.removeConnection(r.environmentId).catch(()=>!1),MW(i?.signal),n>=7||!WZe(t))throw o()&&a.setRuntimeError(r.environmentId,t),t;let s=GZe(n);i?.onBootstrapRetry?.({attempt:n+2,maxAttempts:8,retryDelayMs:s,error:t}),o()&&IW.getState().patch(r.environmentId,{connectionState:`connecting`,lastError:null,lastErrorAt:null}),await PW(s,i?.signal)}var oQ=new Map,sQ=new P$e(e=>wW(e),zW),cQ=new Set,lQ=KHe({createPrimaryEnvironmentConnection:pQ,syncSavedEnvironmentConnections:R$e});function L$e(){lQ.notifyProviderInvalidation()}function uQ(){for(let e of cQ)e()}function dQ(e){let t=oQ.get(e.environmentId);if(t&&t!==e)throw Error(`Environment ${e.environmentId} already has an active connection.`);return oQ.set(e.environmentId,e),uQ(),e}async function fQ(e){let t=oQ.get(e);return t?(oQ.delete(e),UW(e),PX(e),uQ(),await t.dispose(),!0):!1}function pQ(){return uZe({readConnection:gQ,registerConnection:dQ})}async function mQ(e,t){return oQ.get(e.environmentId)||sQ.ensure(e,(e,n)=>A$e(e,n,{findConnection:e=>oQ.get(e),registerConnection:dQ,canCommit:sQ.isCurrent.bind(sQ),createHandlers:HX,withMetadataTimeout:qZe,setConnecting:WX,setConnected:GX,setDisconnected:qX,setError:JX},t))}async function R$e(e){await sQ.sync({records:e,connectedSavedEnvironmentIds:[...oQ.values()].filter(e=>e.kind===`saved`).map(e=>e.environmentId),disconnect:H$e})}function hQ(e){return cQ.add(e),()=>{cQ.delete(e)}}function gQ(e){return oQ.get(e)??null}function z$e(e){return LZe(e,{readConnection:gQ,registerConnection:dQ})}function B$e(e){let t=gQ(e);if(!t)throw Error(`No websocket client registered for environment ${e}.`);return t}function _Q(){return pQ()}async function V$e(){return dZe({readConnection:gQ,registerConnection:dQ})}function vQ(){return{readConnection:gQ,removeConnection:fQ,ensureSavedEnvironmentConnection:mQ,ensureCmmdRuntimeSavedEnvironmentConnection:yQ,invalidate:e=>sQ.invalidate(e),retireEnvironmentId:GXe}}async function H$e(e){await QX(e,vQ())}async function U$e(e){await mZe(e,vQ())}async function W$e(){return pZe({readConnection:gQ,ensureCmmdRuntimeSavedEnvironmentConnection:yQ})}async function G$e(e){await hZe(e,vQ())}async function K$e(e){return gZe(e,vQ())}async function yQ(e,t){return F$e(e,t,{ensureSavedEnvironmentConnection:mQ,getGeneration:e=>sQ.generationFor(e),registry:sQ,removeConnection:fQ,setRuntimeError:JX})}async function q$e(e){await oQ.get(e)?.ensureBootstrapped()}async function J$e(e){let t=oQ.get(e);if(t?.ensureProviderAuthority){await t.ensureProviderAuthority();return}if(HHe(e))throw Error(`Cloud runtime provider authority is not available.`)}function Y$e(e){return lQ.start(e)}FXe({applyEvent:oZe,readConnection:gQ,subscribeConnections:hQ}),JYe({notifyProviderInvalidation:L$e,readQueryClient:()=>lQ.readActiveService()?.queryClient??null,setRuntimeError:JX});var X$e=ate(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);function Z$e(e){return{environmentId:e.environmentId,threadId:e.threadId}}function Q$e(e){return{draftId:e}}function $$e(e){return!e.environmentId||!e.threadId?null:ni(e.environmentId,e.threadId)}function e1e(e){return e.environmentId&&e.threadId?{kind:`server`,threadRef:ni(e.environmentId,e.threadId)}:e.draftId?{kind:`draft`,draftId:e.draftId}:null}var t1e=M.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return $ee(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function bQ(e){let t=(0,hi.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=pt(`relative overflow-hidden rounded-sm bg-muted [--skeleton-highlight:--alpha(var(--color-white)/64%)] after:absolute after:inset-0 after:animate-skeleton after:bg-[linear-gradient(120deg,transparent_40%,var(--skeleton-highlight),transparent_60%)] motion-reduce:after:content-none dark:[--skeleton-highlight:--alpha(var(--color-white)/4%)]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,N.jsx)(`div`,{className:i,"data-slot":`skeleton`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function n1e(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=ct(i),[,o]=M.useState(!1),s=st(i1e).current,c=st(r1e).current,l=M.useRef(0),u=M.useRef(!0),d=M.useRef([]),f=M.useRef(null),p=ct(()=>{u.current||(u.current=!0,o(e=>!e))}),m=ct((e,t)=>{c.set(e,t),p()}),h=ct(e=>{c.delete(e),p()}),g=ct(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!s1e(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&xQ(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=o1e(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=ct(()=>{let[e,t]=a1e(c),n=g(e);_(t),d.current=e,u.current=!1,s.forEach(e=>e(n)),a(n)});ut(()=>(u.current||g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),ut(()=>{u.current&&v()}),ut(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=ct(e=>(s.add(e),()=>{s.delete(e)})),b=M.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,N.jsx)(rte.Provider,{value:b,children:t})}function r1e(){return new Map}function i1e(){return new Set}function a1e(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>xQ(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function o1e(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function s1e(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function xQ(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function SQ(e){let t=e.browser,n=t?{openSession:t.openSession,listSessions:t.listSessions,closeSession:t.closeSession,getSession:t.getSession,command:t.command,clearBrowsingData:t.clearBrowsingData,attachDisplay:t.attachDisplay,addDisplayIceCandidate:async e=>{await t.addDisplayIceCandidate(e)},onEvent:(e,n)=>t.onEvent(e,n)}:void 0;return{...n?{browser:n}:{},attachments:{createUploadUrl:t=>e.attachments.createUploadUrl(t),delete:t=>e.attachments.delete(t)},computer:{input:t=>e.computer.input(t)},threadDevRuntime:{get:t=>e.threadDevRuntime.get(t),allocatePort:t=>e.threadDevRuntime.allocatePort(t),release:t=>e.threadDevRuntime.release(t)},devTunnel:{register:t=>e.devTunnel.register(t),unregister:t=>e.devTunnel.unregister(t),list:t=>e.devTunnel.list(t)},terminal:{open:t=>e.terminal.open(t),write:t=>e.terminal.write(t),resize:t=>e.terminal.resize(t),signal:t=>e.terminal.signal(t),clear:t=>e.terminal.clear(t),restart:t=>e.terminal.restart(t),close:t=>e.terminal.close(t),onEvent:t=>e.terminal.onEvent(t)},projects:{searchContents:e.projects.searchContents,searchEntries:e.projects.searchEntries,readFile:e.projects.readFile,writeFile:e.projects.writeFile},workspace:{environmentPreflight:e.workspace.environmentPreflight,ensureScratch:e.workspace.ensureScratch},shell:{openInEditor:t=>e.shell.openInEditor(t)},git:{pull:e.git.pull,refreshStatus:e.git.refreshStatus,onStatus:(t,n,r)=>e.git.onStatus(t,n,r),listBranches:e.git.listBranches,createWorktree:e.git.createWorktree,removeWorktree:e.git.removeWorktree,createBranch:e.git.createBranch,checkout:e.git.checkout,init:e.git.init,resolvePullRequest:e.git.resolvePullRequest,preparePullRequestThread:e.git.preparePullRequestThread},pullRequests:{list:t=>e.pullRequests.list(t),listStats:t=>e.pullRequests.listStats(t),detail:t=>e.pullRequests.detail(t),activity:t=>e.pullRequests.activity(t),threadComments:t=>e.pullRequests.threadComments(t),diffFileContents:t=>e.pullRequests.diffFileContents(t),runAction:t=>e.pullRequests.runAction(t),update:t=>e.pullRequests.update(t),comment:t=>e.pullRequests.comment(t),updateComment:t=>e.pullRequests.updateComment(t),submitReview:t=>e.pullRequests.submitReview(t),replyToThread:t=>e.pullRequests.replyToThread(t),setThreadResolution:t=>e.pullRequests.setThreadResolution(t),setReaction:t=>e.pullRequests.setReaction(t),invalidate:t=>e.pullRequests.invalidate(t),reviewerCandidates:t=>e.pullRequests.reviewerCandidates(t),requestReviewers:t=>e.pullRequests.requestReviewers(t)},orchestration:{dispatchCommand:e.orchestration.dispatchCommand,getTurnDiff:e.orchestration.getTurnDiff,getFullThreadDiff:e.orchestration.getFullThreadDiff,subscribeShell:(t,n)=>e.orchestration.subscribeShell(t,n),subscribeThread:(t,n,r)=>e.orchestration.subscribeThread(t,n,r)}}}function CQ(e){if(typeof window>`u`||!e)return;let t=gQ(e);return t?SQ(t.client):void 0}function c1e(e){let t=(0,hi.c)(4),n;t[0]===e?n=t[1]:(n=()=>gQ(e),t[0]=e,t[1]=n);let r=(0,M.useSyncExternalStore)(hQ,n,l1e),i,a;return t[2]===r?a=t[3]:(a=r?SQ(r.client):void 0,t[2]=r,t[3]=a),i=a,i}function l1e(){return null}function u1e(e){let t=CQ(e);if(!t)throw Error(`Environment API not found for environment ${e}`);return t}var wQ=`forge:last-editor`;function d1e(e){let t=(0,hi.c)(5),[n,r]=Pi(wQ,null,qt),i;bb0:{if(n&&e.includes(n)){i=n;break bb0}let r;t[0]===e?r=t[1]:(r=gt.find(t=>e.includes(t.id))?.id??null,t[0]=e,t[1]=r),i=r}let a=i,o;return t[2]!==a||t[3]!==r?(o=[a,r],t[2]=a,t[3]=r,t[4]=o):o=t[4],o}function TQ(e){let t=new Set(e),n=Ai(wQ,qt);if(n&&t.has(n))return n;let r=gt.find(e=>t.has(e.id))?.id??null;return r&&ji(wQ,r,qt),r??null}async function f1e(e,t){let{availableEditors:n}=await e.server.getConfig(),r=TQ(n);if(!r)throw Error(`No available editors found.`);return await e.shell.openInEditor(t,r),r}function EQ(e){if(e===null)return null;let t=e.trim();return t.length>0?t:null}var DQ=Object.freeze({data:null,error:null,cause:null,isPending:!1}),OQ=Object.freeze({...DQ,isPending:!0}),p1e=ot(DQ).pipe(at,rt(`git-status:null`)),kQ=()=>void 0,AQ=new Map,m1e=new Set,jQ=new Map,MQ=new Map,h1e=1e3,NQ=Zee(e=>(m1e.add(e),ot(OQ).pipe(at,rt(`git-status:${e}`))));function PQ(e){return e.environmentId===null||EQ(e.cwd)===null?null:`${e.environmentId}:${e.cwd}`}function FQ(e){if(e.environmentId===null)return null;let t=gQ(e.environmentId);return t?{clientIdentity:t.environmentId,client:t.client.git}:null}function IQ(e){let t=PQ(e);return t===null?DQ:it.get(NQ(t))}function g1e(e,t){let n=PQ(e);if(n===null)return kQ;let r=AQ.get(n);return r?(r.refCount+=1,()=>LQ(n)):(AQ.set(n,{refCount:1,unsubscribe:y1e(n,e,t)}),()=>LQ(n))}function _1e(e,t){let n=PQ(e),r=EQ(e.cwd);if(n===null||r===null)return Promise.resolve(null);let i=t??FQ(e)?.client;if(!i)return Promise.resolve(IQ(e).data);let a=jQ.get(n);if(a)return a;let o=MQ.get(n)??0;if(Date.now()-o<h1e)return Promise.resolve(IQ(e).data);MQ.set(n,Date.now());let s=i.refreshStatus({cwd:r}).finally(()=>{jQ.delete(n)});return jQ.set(n,s),s}function v1e(e){let t=(0,hi.c)(4),n=PQ(e),r,i;t[0]!==e.cwd||t[1]!==e.environmentId?(r=()=>g1e({environmentId:e.environmentId,cwd:e.cwd}),i=[e.environmentId,e.cwd],t[0]=e.cwd,t[1]=e.environmentId,t[2]=r,t[3]=i):(r=t[2],i=t[3]),(0,M.useEffect)(r,i);let a=yn(n===null?p1e:NQ(n));return n===null?DQ:a}function LQ(e){let t=AQ.get(e);t&&(--t.refCount,!(t.refCount>0)&&(t.unsubscribe(),AQ.delete(e)))}function y1e(e,t,n){let r=EQ(t.cwd);if(r===null)return kQ;let i=null,a=kQ,o=()=>{let o=n?{clientIdentity:`provided:${e}`,client:n}:FQ(t);if(!o){i!==null&&(a(),a=kQ,i=null),RQ(e);return}i!==o.clientIdentity&&(a(),i=o.clientIdentity,a=b1e(e,r,o.client))},s=n?kQ:hQ(o);return o(),()=>{s(),a()}}function b1e(e,t,n){return RQ(e),n.onStatus({cwd:t},t=>{it.set(NQ(e),{data:t,error:null,cause:null,isPending:!1})},{onResubscribe:()=>{RQ(e)}})}function RQ(e){let t=NQ(e),n=it.get(t),r=n.data===null?OQ:{...n,error:null,cause:null,isPending:!0};(n.data!==r.data||n.error!==r.error||n.cause!==r.cause||n.isPending!==r.isPending)&&it.set(t,r)}function zQ(e,t){return ot(t).pipe(at,rt(e))}function BQ(e){return{issues:e.issues,providers:e.providers,settings:e.settings}}var x1e=[],S1e=[],C1e=[],w1e=e=>e?.availableEditors??x1e,T1e=e=>e?.keybindings??S1e,E1e=e=>e?.keybindingsConfigPath??null,D1e=e=>e?.observability??null,O1e=e=>e?.providers??C1e,k1e=e=>e?.settings??Jte,VQ=zQ(`server-welcome`,null),HQ=zQ(`server-config`,null),UQ=zQ(`server-config-updated`,null),A1e=zQ(`server-providers-updated`,null);function WQ(){return it.get(HQ)}function j1e(){return it.get(UQ)}function GQ(e){YQ(e),XQ({providers:e.providers}),ZQ(BQ(e),`snapshot`)}function M1e(e){switch(e.type){case`snapshot`:GQ(e.config);return;case`keybindingsUpdated`:{let t=WQ();if(!t)return;let n={...t,issues:e.payload.issues,keybindings:e.payload.keybindings};YQ(n),ZQ(BQ(n),e.type);return}case`providerStatuses`:KQ(e.payload);return;case`settingsUpdated`:qQ(e.payload.settings);return;case`environmentUpdated`:JQ(e.payload.environment);return}}function KQ(e){let t=WQ();if(XQ(e),!t)return;let n={...t,providers:e.providers};YQ(n),ZQ(BQ(n),`providerStatuses`)}function qQ(e){let t=WQ();if(!t)return;let n={...t,settings:e};YQ(n),ZQ(BQ(n),`settingsUpdated`)}function JQ(e){let t=WQ();if(tW()?.environmentId===e.environmentId&&nW(e),!t)return;let n={...t,environment:e};YQ(n),ZQ(BQ(n),`environmentUpdated`)}function N1e(e){it.set(VQ,e)}function P1e(e){let t=!1,n=[e.subscribeLifecycle(e=>{e.type===`welcome`&&N1e(e.payload)}),e.subscribeConfig(e=>{M1e(e)})];return WQ()===null&&e.getConfig().then(e=>{t||WQ()!==null||GQ(e)}).catch(()=>void 0),()=>{t=!0;for(let e of n)e()}}var F1e=1;function YQ(e){it.set(HQ,e)}function XQ(e){it.set(A1e,e)}function ZQ(e,t){it.set(UQ,{id:F1e++,payload:e,source:t})}function QQ(e,t){let n=(0,M.useRef)(t);n.current=t;let r=(0,M.useCallback)(e=>{e!==null&&n.current(e)},[]);Sne(e,r,{immediate:!0})}function I1e(){return yn(HQ)}function $Q(){return yn(HQ,k1e)}function L1e(){return yn(HQ,O1e)}function R1e(){return yn(HQ,T1e)}function z1e(){return yn(HQ,w1e)}function B1e(){return yn(HQ,E1e)}function V1e(){return yn(HQ,D1e)}function H1e(e){QQ(VQ,e)}function U1e(e){QQ(UQ,e)}function W1e(e){let t=[];for(let n of e){let e=n.children??[];if(e.length>0){t.push({item:n,isGroupLabel:!0});for(let n of e)t.push({item:n,isGroupLabel:!1});continue}Array.isArray(n.children)||t.push({item:n,isGroupLabel:!1})}return t}function G1e(e){let t=document.createElement(`div`);return t.textContent=e,t.className=`px-2 pt-1.5 pb-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground/70`,t}function K1e(e){let t=document.createElement(`button`);return t.type=`button`,t.textContent=e.label,t.disabled=e.disabled,t.className=e.disabled?`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[11px] text-muted-foreground/50 cursor-not-allowed`:e.destructive?`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[11px] text-destructive transition-colors hover:bg-accent`:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[11px] text-popover-foreground transition-colors hover:bg-accent`,t}function q1e(e,t){return new Promise(n=>{let r=document.createElement(`div`);r.style.cssText=`position:fixed;inset:0;z-index:9999`;let i=document.createElement(`div`);i.className=`fixed z-[10000] min-w-[160px] rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg/5 outline-none before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:before:shadow-[0_-1px_--theme(--color-white/6%)]`;let a=t?.x??0,o=t?.y??0;i.style.top=`${o}px`,i.style.left=`${a}px`;function s(e){document.removeEventListener(`keydown`,c),r.remove(),i.remove(),n(e)}function c(e){e.key===`Escape`&&(e.preventDefault(),s(null))}r.addEventListener(`mousedown`,()=>s(null)),document.addEventListener(`keydown`,c);let l=!1;for(let{item:t,isGroupLabel:n}of W1e(e)){if(n){i.appendChild(G1e(t.label));continue}let e=t.destructive===!0||t.id===`delete`,r=t.disabled===!0;if(e&&!l){let e=document.createElement(`div`);e.className=`-mx-1 my-1 h-px bg-border`,i.appendChild(e),l=!0}let a=K1e({label:t.label,disabled:r,destructive:e});r||a.addEventListener(`click`,()=>s(t.id)),i.appendChild(a)}document.body.appendChild(r),document.body.appendChild(i),requestAnimationFrame(()=>{let e=i.getBoundingClientRect();e.right>window.innerWidth&&(i.style.left=`${window.innerWidth-e.width-4}px`),e.bottom>window.innerHeight&&(i.style.top=`${window.innerHeight-e.height-4}px`)})})}var e$;function J1e(){return t$(_Q().client)}function t$(e){return{getConfig:e.server.getConfig,refreshProviders:e.server.refreshProviders,startProviderAuth:e.server.startProviderAuth,repairProviderAuthRuntime:e.server.repairProviderAuthRuntime,disconnectProviderAuth:e.server.disconnectProviderAuth,getProviderAuthSession:e.server.getProviderAuthSession,cancelProviderAuth:e.server.cancelProviderAuth,submitProviderAuthCode:e.server.submitProviderAuthCode,syncPersonalCodexToCloud:e.server.syncPersonalCodexToCloud,syncPersonalClaudeToCloud:e.server.syncPersonalClaudeToCloud,upsertKeybinding:e.server.upsertKeybinding,removeKeybinding:e.server.removeKeybinding,getSettings:e.server.getSettings,updateSettings:e.server.updateSettings,updateEnvironmentDisplayName:async t=>{let n=await e.server.updateEnvironmentDisplayName({displayName:t});return JQ(n.environment),n}}}function Y1e(e,t){return{...e,...t,dialogs:{...e.dialogs,...t.dialogs},shell:{...e.shell,...t.shell},contextMenu:{...e.contextMenu,...t.contextMenu},persistence:{...e.persistence,...t.persistence},server:{...e.server,...t.server}}}function X1e(e){return{dialogs:{pickFolder:async()=>window.desktopBridge?window.desktopBridge.pickFolder():null,confirm:async e=>window.desktopBridge?window.desktopBridge.confirm(e):window.confirm(e)},shell:{openInEditor:(t,n)=>e.shell.openInEditor({cwd:t,editor:n}),openExternal:async e=>{if(window.desktopBridge){if(!await window.desktopBridge.openExternal(e))throw Error(`Unable to open link.`);return}window.open(e,`_blank`,`noopener,noreferrer`)}},contextMenu:{show:async(e,t)=>window.desktopBridge?window.desktopBridge.showContextMenu(e,t):q1e(e,t)},persistence:{getClientSettings:qi,setClientSettings:Ji,getSavedEnvironmentRegistry:Yi,setSavedEnvironmentRegistry:Xi,getSavedEnvironmentSecret:Zi,setSavedEnvironmentSecret:Qi,removeSavedEnvironmentSecret:$i},server:t$(e)}}function n$(){if(typeof window>`u`)return;if(e$)return e$;let e=X1e(_Q().client);return window.nativeApi?(e$=Y1e(e,window.nativeApi),e$):(e$=e,e$)}function Z1e(){let e=n$();if(!e)throw Error(`Local API not found`);return e}function Q1e(e,t){e.style.setProperty(`--appearance-contrast-base`,`${Math.min(t,100)}%`),e.style.setProperty(`--appearance-contrast-boost`,`${Math.max(t-100,0)}%`),e.style.setProperty(`--appearance-contrast-border-boost`,`${Math.max(t-100,0)/4}%`)}var $1e=`-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif`,e0e=`ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace`;function t0e(e){let t=e.trim();return t.length===0?``:/^(['"]).*\1$/u.test(t)||/^[a-zA-Z][a-zA-Z0-9-]*$/u.test(t)?t:`"${t.replaceAll(`"`,``)}"`}function n0e(e){let t=e.split(`,`).map(t0e).filter(e=>e.length>0);return t.length>0?t.join(`, `):null}var r$={appearanceContrastBase:`--appearance-contrast-base`,appearanceContrastBoost:`--appearance-contrast-boost`,appearanceContrastBorderBoost:`--appearance-contrast-border-boost`,fontSans:`--font-sans`,fontMono:`--font-mono`,fontComposer:`--font-composer`,fontTerminal:`--font-terminal`,promptFontSize:`--forge-prompt-font-size`,terminalFontSize:`--forge-terminal-font-size`,glassOpacity:`--glass-opacity`};function r0e(e,t){let n=[[r$.fontSans,t.fontFamilySans,$1e],[r$.fontMono,t.fontFamilyCode,e0e],[r$.fontComposer,t.fontFamilyComposer,`var(--font-sans)`],[r$.fontTerminal,t.fontFamilyTerminal,`var(--font-mono)`]];for(let[t,r,i]of n){let n=n0e(r);if(n===null){e.style.removeProperty(t);continue}e.style.setProperty(t,`${n}, ${i}`)}e.style.setProperty(r$.promptFontSize,`${String(t.promptFontSize)}px`),e.style.setProperty(r$.terminalFontSize,`${String(t.terminalFontSize)}px`),e.style.setProperty(r$.glassOpacity,`${String(t.glassOpacity)}%`),Q1e(e,t.appearanceContrast),t.fontSmoothing?e.style.setProperty(`-webkit-font-smoothing`,`antialiased`):e.style.removeProperty(`-webkit-font-smoothing`)}var i$=(e,t)=>{if(typeof e==`number`){if(t===3)return{mode:`rgb`,r:(e>>8&15|e>>4&240)/255,g:(e>>4&15|e&240)/255,b:(e&15|e<<4&240)/255};if(t===4)return{mode:`rgb`,r:(e>>12&15|e>>8&240)/255,g:(e>>8&15|e>>4&240)/255,b:(e>>4&15|e&240)/255,alpha:(e&15|e<<4&240)/255};if(t===6)return{mode:`rgb`,r:(e>>16&255)/255,g:(e>>8&255)/255,b:(e&255)/255};if(t===8)return{mode:`rgb`,r:(e>>24&255)/255,g:(e>>16&255)/255,b:(e>>8&255)/255,alpha:(e&255)/255}}},i0e={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},a0e=e=>i$(i0e[e.toLowerCase()],6),o0e=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,s0e=e=>{let t;return(t=e.match(o0e))?i$(parseInt(t[1],16),t[1].length):void 0},a$=`([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)`;`${a$}`;var o$=`${a$}%`;`${a$}`;var s$=`(?:${a$}%|${a$})`,c0e=`(?:${a$}%|${a$}|none)`,l0e=`(?:${a$}(deg|grad|rad|turn)|${a$})`;`${a$}${a$}`;var c$=`\\s*,\\s*`;RegExp(`^`+c0e+`$`);var u0e=RegExp(`^rgba?\\(\\s*${a$}${c$}${a$}${c$}${a$}\\s*(?:,\\s*${s$}\\s*)?\\)$`),d0e=RegExp(`^rgba?\\(\\s*${o$}${c$}${o$}${c$}${o$}\\s*(?:,\\s*${s$}\\s*)?\\)$`),f0e=e=>{let t={mode:`rgb`},n;if(n=e.match(u0e))n[1]!==void 0&&(t.r=n[1]/255),n[2]!==void 0&&(t.g=n[2]/255),n[3]!==void 0&&(t.b=n[3]/255);else if(n=e.match(d0e))n[1]!==void 0&&(t.r=n[1]/100),n[2]!==void 0&&(t.g=n[2]/100),n[3]!==void 0&&(t.b=n[3]/100);else return;return n[4]===void 0?n[5]!==void 0&&(t.alpha=Math.max(0,Math.min(1,+n[5]))):t.alpha=Math.max(0,Math.min(1,n[4]/100)),t},p0e=(e,t)=>e===void 0?void 0:typeof e==`object`?e.mode===void 0?t?{...e,mode:t}:void 0:e:C$(e),l$=(e=`rgb`)=>t=>(t=p0e(t,e))===void 0?void 0:t.mode===e?t:u$[t.mode][e]?u$[t.mode][e](t):e===`rgb`?u$[t.mode].rgb(t):u$.rgb[e](u$[t.mode].rgb(t)),u$={},d$={},f$=[],p$={},m0e=e=>e,m$=e=>(u$[e.mode]={...u$[e.mode],...e.toMode},Object.keys(e.fromMode||{}).forEach(t=>{u$[t]||(u$[t]={}),u$[t][e.mode]=e.fromMode[t]}),e.ranges||={},e.difference||={},e.channels.forEach(t=>{if(e.ranges[t]===void 0&&(e.ranges[t]=[0,1]),!e.interpolate[t])throw Error(`Missing interpolator for: ${t}`);typeof e.interpolate[t]==`function`&&(e.interpolate[t]={use:e.interpolate[t]}),e.interpolate[t].fixup||(e.interpolate[t].fixup=m0e)}),d$[e.mode]=e,(e.parse||[]).forEach(t=>{g0e(t,e.mode)}),l$(e.mode)),h0e=e=>d$[e],g0e=(e,t)=>{if(typeof e==`string`){if(!t)throw Error(`'mode' required when 'parser' is a string`);p$[e]=t}else typeof e==`function`&&f$.indexOf(e)<0&&f$.push(e)},h$=/[^\x00-\x7F]|[a-zA-Z_]/,_0e=/[^\x00-\x7F]|[-\w]/,Q={Function:`function`,Ident:`ident`,Number:`number`,Percentage:`percentage`,ParenClose:`)`,None:`none`,Hue:`hue`,Alpha:`alpha`},g$=0;function _$(e){let t=e[g$],n=e[g$+1];return t===`-`||t===`+`?/\d/.test(n)||n===`.`&&/\d/.test(e[g$+2]):t===`.`?/\d/.test(n):/\d/.test(t)}function v$(e){if(g$>=e.length)return!1;let t=e[g$];if(h$.test(t))return!0;if(t===`-`){if(e.length-g$<2)return!1;let t=e[g$+1];return!!(t===`-`||h$.test(t))}return!1}var v0e={deg:1,rad:180/Math.PI,grad:9/10,turn:360};function y$(e){let t=``;if((e[g$]===`-`||e[g$]===`+`)&&(t+=e[g$++]),t+=b$(e),e[g$]===`.`&&/\d/.test(e[g$+1])&&(t+=e[g$++]+b$(e)),(e[g$]===`e`||e[g$]===`E`)&&((e[g$+1]===`-`||e[g$+1]===`+`)&&/\d/.test(e[g$+2])?t+=e[g$++]+e[g$++]+b$(e):/\d/.test(e[g$+1])&&(t+=e[g$++]+b$(e))),v$(e)){let n=x$(e);return n===`deg`||n===`rad`||n===`turn`||n===`grad`?{type:Q.Hue,value:t*v0e[n]}:void 0}return e[g$]===`%`?(g$++,{type:Q.Percentage,value:+t}):{type:Q.Number,value:+t}}function b$(e){let t=``;for(;/\d/.test(e[g$]);)t+=e[g$++];return t}function x$(e){let t=``;for(;g$<e.length&&_0e.test(e[g$]);)t+=e[g$++];return t}function y0e(e){let t=x$(e);return e[g$]===`(`?(g$++,{type:Q.Function,value:t}):t===`none`?{type:Q.None,value:void 0}:{type:Q.Ident,value:t}}function b0e(e=``){let t=e.trim(),n=[],r;for(g$=0;g$<t.length;){if(r=t[g$++],r===`
1022
1022
  `||r===` `||r===` `){for(;g$<t.length&&(t[g$]===`
1023
1023
  `||t[g$]===` `||t[g$]===` `);)g$++;continue}if(r===`,`)return;if(r===`)`){n.push({type:Q.ParenClose});continue}if(r===`+`){if(g$--,_$(t)){n.push(y$(t));continue}return}if(r===`-`){if(g$--,_$(t)){n.push(y$(t));continue}if(v$(t)){n.push({type:Q.Ident,value:x$(t)});continue}return}if(r===`.`){if(g$--,_$(t)){n.push(y$(t));continue}return}if(r===`/`){for(;g$<t.length&&(t[g$]===`
1024
- `||t[g$]===` `||t[g$]===` `);)g$++;let e;if(_$(t)&&(e=y$(t),e.type!==Q.Hue)){n.push({type:Q.Alpha,value:e});continue}if(v$(t)&&x$(t)===`none`){n.push({type:Q.Alpha,value:{type:Q.None,value:void 0}});continue}return}if(/\d/.test(r)){g$--,n.push(y$(t));continue}if(h$.test(r)){g$--,n.push(y0e(t));continue}return}return n}function x0e(e){e._i=0;let t=e[e._i++];if(!t||t.type!==Q.Function||t.value!==`color`||(t=e[e._i++],t.type!==Q.Ident))return;let n=p$[t.value];if(!n)return;let r={mode:n},i=S$(e,!1);if(!i)return;let a=h0e(n).channels;for(let e=0,t,n;e<a.length;e++)t=i[e],n=a[e],t.type!==Q.None&&(r[n]=t.type===Q.Number?t.value:t.value/100,n===`alpha`&&(r[n]=Math.max(0,Math.min(1,r[n]))));return r}function S$(e,t){let n=[],r;for(;e._i<e.length;){if(r=e[e._i++],r.type===Q.None||r.type===Q.Number||r.type===Q.Alpha||r.type===Q.Percentage||t&&r.type===Q.Hue){n.push(r);continue}if(r.type===Q.ParenClose){if(e._i<e.length)return;continue}return}if(!(n.length<3||n.length>4)){if(n.length===4){if(n[3].type!==Q.Alpha)return;n[3]=n[3].value}return n.length===3&&n.push({type:Q.None,value:void 0}),n.every(e=>e.type!==Q.Alpha)?n:void 0}}function S0e(e,t){e._i=0;let n=e[e._i++];if(!n||n.type!==Q.Function)return;let r=S$(e,t);if(r)return r.unshift(n.value),r}var C$=e=>{if(typeof e!=`string`)return;let t=b0e(e),n=t?S0e(t,!0):void 0,r,i=0,a=f$.length;for(;i<a;)if((r=f$[i++](e,n))!==void 0)return r;return t?x0e(t):void 0};function C0e(e,t){if(!t||t[0]!==`rgb`&&t[0]!==`rgba`)return;let n={mode:`rgb`},[,r,i,a,o]=t;if(r.type!==Q.Hue&&i.type!==Q.Hue&&a.type!==Q.Hue)return r.type!==Q.None&&(n.r=r.type===Q.Number?r.value/255:r.value/100),i.type!==Q.None&&(n.g=i.type===Q.Number?i.value/255:i.value/100),a.type!==Q.None&&(n.b=a.type===Q.Number?a.value/255:a.value/100),o.type!==Q.None&&(n.alpha=Math.min(1,Math.max(0,o.type===Q.Number?o.value:o.value/100))),n}var w0e=e=>e===`transparent`?{mode:`rgb`,r:0,g:0,b:0,alpha:0}:void 0,T0e=(e,t,n)=>e+n*(t-e),E0e=e=>{let t=[];for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];r===void 0&&i===void 0?t.push(void 0):r!==void 0&&i!==void 0?t.push([r,i]):t.push(r===void 0?[i,i]:[r,r])}return t},w$=(e=>t=>{let n=E0e(t);return t=>{let r=t*n.length,i=t>=1?n.length-1:Math.max(Math.floor(r),0),a=n[i];return a===void 0?void 0:e(a[0],a[1],r-i)}})(T0e),T$=e=>{let t=!1,n=e.map(e=>e===void 0?1:(t=!0,e));return t?n:e},E$={mode:`rgb`,channels:[`r`,`g`,`b`,`alpha`],parse:[C0e,s0e,f0e,a0e,w0e,`srgb`],serialize:`srgb`,interpolate:{r:w$,g:w$,b:w$,alpha:{use:w$,fixup:T$}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},D$=(e=0)=>Math.abs(e)**(563/256)*Math.sign(e),O$=e=>{let t=D$(e.r),n=D$(e.g),r=D$(e.b),i={mode:`xyz65`,x:.5766690429101305*t+.1855582379065463*n+.1882286462349947*r,y:.297344975250536*t+.6273635662554661*n+.0752914584939979*r,z:.0270313613864123*t+.0706888525358272*n+.9913375368376386*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},k$=e=>Math.abs(e)**(256/563)*Math.sign(e),A$=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`a98`,r:k$(e*2.0415879038107465-t*.5650069742788597-.3447313507783297*n),g:k$(e*-.9692436362808798+t*1.8759675015077206+.0415550574071756*n),b:k$(e*.0134442806320312-t*.1183623922310184+1.0151749943912058*n)};return r!==void 0&&(i.alpha=r),i},j$=(e=0)=>{let t=Math.abs(e);return t<=.04045?e/12.92:(Math.sign(e)||1)*((t+.055)/1.055)**2.4},M$=({r:e,g:t,b:n,alpha:r})=>{let i={mode:`lrgb`,r:j$(e),g:j$(t),b:j$(n)};return r!==void 0&&(i.alpha=r),i},N$=e=>{let{r:t,g:n,b:r,alpha:i}=M$(e),a={mode:`xyz65`,x:.4123907992659593*t+.357584339383878*n+.1804807884018343*r,y:.2126390058715102*t+.715168678767756*n+.0721923153607337*r,z:.0193308187155918*t+.119194779794626*n+.9505321522496607*r};return i!==void 0&&(a.alpha=i),a},P$=(e=0)=>{let t=Math.abs(e);return t>.0031308?(Math.sign(e)||1)*(1.055*t**(1/2.4)-.055):e*12.92},F$=({r:e,g:t,b:n,alpha:r},i=`rgb`)=>{let a={mode:i,r:P$(e),g:P$(t),b:P$(n)};return r!==void 0&&(a.alpha=r),a},I$=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=F$({r:e*3.2409699419045226-t*1.537383177570094-.4986107602930034*n,g:e*-.9692436362808796+t*1.8759675015077204+.0415550574071756*n,b:e*.0556300796969936-t*.2039769588889765+1.0569715142428784*n});return r!==void 0&&(i.alpha=r),i},D0e={...E$,mode:`a98`,parse:[`a98-rgb`],serialize:`a98-rgb`,fromMode:{rgb:e=>A$(N$(e)),xyz65:A$},toMode:{rgb:e=>I$(O$(e)),xyz65:O$}},L$=e=>(e%=360)<0?e+360:e;function O0e({h:e,s:t,l:n,alpha:r}){e=L$(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=n+t*(n<.5?n:1-n),a=i-(i-n)*2*Math.abs(e/60%2-1),o;switch(Math.floor(e/60)){case 0:o={r:i,g:a,b:2*n-i};break;case 1:o={r:a,g:i,b:2*n-i};break;case 2:o={r:2*n-i,g:i,b:a};break;case 3:o={r:2*n-i,g:a,b:i};break;case 4:o={r:a,g:2*n-i,b:i};break;case 5:o={r:i,g:2*n-i,b:a};break;default:o={r:2*n-i,g:2*n-i,b:2*n-i}}return o.mode=`rgb`,r!==void 0&&(o.alpha=r),o}function k0e({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsl`,s:i===a?0:(i-a)/(1-Math.abs(i+a-1)),l:.5*(i+a)};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}var A0e=(e,t)=>{switch(t){case`deg`:return+e;case`rad`:return e/Math.PI*180;case`grad`:return e/10*9;case`turn`:return e*360}},j0e=RegExp(`^hsla?\\(\\s*${l0e}${c$}${o$}${c$}${o$}\\s*(?:,\\s*${s$}\\s*)?\\)$`),M0e=e=>{let t=e.match(j0e);if(!t)return;let n={mode:`hsl`};return t[3]===void 0?t[1]!==void 0&&t[2]!==void 0&&(n.h=A0e(t[1],t[2])):n.h=+t[3],t[4]!==void 0&&(n.s=Math.min(Math.max(0,t[4]/100),1)),t[5]!==void 0&&(n.l=Math.min(Math.max(0,t[5]/100),1)),t[6]===void 0?t[7]!==void 0&&(n.alpha=Math.max(0,Math.min(1,+t[7]))):n.alpha=Math.max(0,Math.min(1,t[6]/100)),n};function N0e(e,t){if(!t||t[0]!==`hsl`&&t[0]!==`hsla`)return;let n={mode:`hsl`},[,r,i,a,o]=t;if(r.type!==Q.None){if(r.type===Q.Percentage)return;n.h=r.value}if(i.type!==Q.None){if(i.type===Q.Hue)return;n.s=i.value/100}if(a.type!==Q.None){if(a.type===Q.Hue)return;n.l=a.value/100}return o.type!==Q.None&&(n.alpha=Math.min(1,Math.max(0,o.type===Q.Number?o.value:o.value/100))),n}var P0e=(e,t)=>e.map((n,r,i)=>{if(n===void 0)return n;let a=L$(n);return r===0||e[r-1]===void 0?a:t(a-L$(i[r-1]))}).reduce((e,t)=>!e.length||t===void 0||e[e.length-1]===void 0?(e.push(t),e):(e.push(t+e[e.length-1]),e),[]),R$=e=>P0e(e,e=>Math.abs(e)<=180?e:e-360*Math.sign(e)),z$=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.s||!t.s)return 0;let n=L$(e.h),r=L$(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*t.s)*i},F0e=(e,t)=>{if(e.h===void 0||t.h===void 0)return 0;let n=L$(e.h),r=L$(t.h);return Math.abs(r-n)>180?n-(r-360*Math.sign(r-n)):r-n},I0e=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.c||!t.c)return 0;let n=L$(e.h),r=L$(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*t.c)*i},B$=e=>{let t=e.reduce((e,t)=>{if(t!==void 0){let n=t*Math.PI/180;e.sin+=Math.sin(n),e.cos+=Math.cos(n)}return e},{sin:0,cos:0}),n=Math.atan2(t.sin,t.cos)*180/Math.PI;return n<0?360+n:n},L0e={mode:`hsl`,toMode:{rgb:O0e},fromMode:{rgb:k0e},channels:[`h`,`s`,`l`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[N0e,M0e],serialize:e=>`hsl(${e.h===void 0?`none`:e.h} ${e.s===void 0?`none`:e.s*100+`%`} ${e.l===void 0?`none`:e.l*100+`%`}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:w$,fixup:R$},s:w$,l:w$,alpha:{use:w$,fixup:T$}},difference:{h:z$},average:{h:B$}};function V$({h:e,s:t,v:n,alpha:r}){e=L$(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.abs(e/60%2-1),a;switch(Math.floor(e/60)){case 0:a={r:n,g:n*(1-t*i),b:n*(1-t)};break;case 1:a={r:n*(1-t*i),g:n,b:n*(1-t)};break;case 2:a={r:n*(1-t),g:n,b:n*(1-t*i)};break;case 3:a={r:n*(1-t),g:n*(1-t*i),b:n};break;case 4:a={r:n*(1-t*i),g:n*(1-t),b:n};break;case 5:a={r:n,g:n*(1-t),b:n*(1-t*i)};break;default:a={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return a.mode=`rgb`,r!==void 0&&(a.alpha=r),a}function H$({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsv`,s:i===0?0:1-a/i,v:i};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}var R0e={mode:`hsv`,toMode:{rgb:V$},parse:[`--hsv`],serialize:`--hsv`,fromMode:{rgb:H$},channels:[`h`,`s`,`v`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,interpolate:{h:{use:w$,fixup:R$},s:w$,v:w$,alpha:{use:w$,fixup:T$}},difference:{h:z$},average:{h:B$}};function z0e({h:e,w:t,b:n,alpha:r}){if(t===void 0&&(t=0),n===void 0&&(n=0),t+n>1){let e=t+n;t/=e,n/=e}return V$({h:e,s:n===1?1:1-t/(1-n),v:1-n,alpha:r})}function B0e(e){let t=H$(e);if(t===void 0)return;let n=t.s===void 0?0:t.s,r=t.v===void 0?0:t.v,i={mode:`hwb`,w:(1-n)*r,b:1-r};return t.h!==void 0&&(i.h=t.h),t.alpha!==void 0&&(i.alpha=t.alpha),i}function V0e(e,t){if(!t||t[0]!==`hwb`)return;let n={mode:`hwb`},[,r,i,a,o]=t;if(r.type!==Q.None){if(r.type===Q.Percentage)return;n.h=r.value}if(i.type!==Q.None){if(i.type===Q.Hue)return;n.w=i.value/100}if(a.type!==Q.None){if(a.type===Q.Hue)return;n.b=a.value/100}return o.type!==Q.None&&(n.alpha=Math.min(1,Math.max(0,o.type===Q.Number?o.value:o.value/100))),n}var H0e={mode:`hwb`,toMode:{rgb:z0e},fromMode:{rgb:B0e},channels:[`h`,`w`,`b`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[V0e],serialize:e=>`hwb(${e.h===void 0?`none`:e.h} ${e.w===void 0?`none`:e.w*100+`%`} ${e.b===void 0?`none`:e.b*100+`%`}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:w$,fixup:R$},w:w$,b:w$,alpha:{use:w$,fixup:T$}},difference:{h:F0e},average:{h:B$}},U$=29**3/3**3,W$=6**3/29**3,G$={X:.3457/.3585,Y:1,Z:.2958/.3585},K$={X:.3127/.329,Y:1,Z:.3583/.329},q$=e=>e**3>W$?e**3:(116*e-16)/U$,J$=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+16)/116,a=t/500+i,o=i-n/200,s={mode:`xyz50`,x:q$(a)*G$.X,y:q$(i)*G$.Y,z:q$(o)*G$.Z};return r!==void 0&&(s.alpha=r),s},Y$=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=F$({r:e*3.1341359569958707-t*1.6173863321612538-.4906619460083532*n,g:e*-.978795502912089+t*1.916254567259524+.03344273116131949*n,b:e*.07195537988411677-t*.2289768264158322+1.405386058324125*n});return r!==void 0&&(i.alpha=r),i},X$=e=>Y$(J$(e)),Z$=e=>{let{r:t,g:n,b:r,alpha:i}=M$(e),a={mode:`xyz50`,x:.436065742824811*t+.3851514688337912*n+.14307845442264197*r,y:.22249319175623702*t+.7168870538238823*n+.06061979053616537*r,z:.013923904500943465*t+.09708128566574634*n+.7140993584005155*r};return i!==void 0&&(a.alpha=i),a},Q$=e=>e>W$?Math.cbrt(e):(U$*e+16)/116,$$=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Q$(e/G$.X),a=Q$(t/G$.Y),o=Q$(n/G$.Z),s={mode:`lab`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},e1=e=>{let t=$$(Z$(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t};function U0e(e,t){if(!t||t[0]!==`lab`)return;let n={mode:`lab`},[,r,i,a,o]=t;if(r.type!==Q.Hue&&i.type!==Q.Hue&&a.type!==Q.Hue)return r.type!==Q.None&&(n.l=Math.min(Math.max(0,r.value),100)),i.type!==Q.None&&(n.a=i.type===Q.Number?i.value:i.value*125/100),a.type!==Q.None&&(n.b=a.type===Q.Number?a.value:a.value*125/100),o.type!==Q.None&&(n.alpha=Math.min(1,Math.max(0,o.type===Q.Number?o.value:o.value/100))),n}var t1={mode:`lab`,toMode:{xyz50:J$,rgb:X$},fromMode:{xyz50:$$,rgb:e1},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[U0e],serialize:e=>`lab(${e.l===void 0?`none`:e.l} ${e.a===void 0?`none`:e.a} ${e.b===void 0?`none`:e.b}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{l:w$,a:w$,b:w$,alpha:{use:w$,fixup:T$}}},n1=29**3/3**3,r1=6**3/29**3,i1=e=>e**3>r1?e**3:(116*e-16)/n1,a1=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+16)/116,a=t/500+i,o=i-n/200,s={mode:`xyz65`,x:i1(a)*K$.X,y:i1(i)*K$.Y,z:i1(o)*K$.Z};return r!==void 0&&(s.alpha=r),s},o1=e=>I$(a1(e)),s1=e=>e>r1?Math.cbrt(e):(n1*e+16)/116,c1=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=s1(e/K$.X),a=s1(t/K$.Y),o=s1(n/K$.Z),s={mode:`lab65`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},l1=e=>{let t=c1(N$(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},W0e={...t1,mode:`lab65`,parse:[`--lab-d65`],serialize:`--lab-d65`,toMode:{xyz65:a1,rgb:o1},fromMode:{xyz65:c1,rgb:l1},ranges:{l:[0,100],a:[-125,125],b:[-125,125]}},u1=({l:e,a:t,b:n,alpha:r},i=`lch`)=>{t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.sqrt(t*t+n*n),o={mode:i,l:e,c:a};return a&&(o.h=L$(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(o.alpha=r),o},d1=({l:e,c:t,h:n,alpha:r},i=`lab`)=>{n===void 0&&(n=0);let a={mode:i,l:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return r!==void 0&&(a.alpha=r),a};function G0e(e,t){if(!t||t[0]!==`lch`)return;let n={mode:`lch`},[,r,i,a,o]=t;if(r.type!==Q.None){if(r.type===Q.Hue)return;n.l=Math.min(Math.max(0,r.value),100)}if(i.type!==Q.None&&(n.c=Math.max(0,i.type===Q.Number?i.value:i.value*150/100)),a.type!==Q.None){if(a.type===Q.Percentage)return;n.h=a.value}return o.type!==Q.None&&(n.alpha=Math.min(1,Math.max(0,o.type===Q.Number?o.value:o.value/100))),n}var f1={mode:`lch`,toMode:{lab:d1,rgb:e=>X$(d1(e))},fromMode:{rgb:e=>u1(e1(e)),lab:u1},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[G0e],serialize:e=>`lch(${e.l===void 0?`none`:e.l} ${e.c===void 0?`none`:e.c} ${e.h===void 0?`none`:e.h}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:w$,fixup:R$},c:w$,l:w$,alpha:{use:w$,fixup:T$}},difference:{h:I0e},average:{h:B$}},K0e={...f1,mode:`lch65`,parse:[`--lch-d65`],serialize:`--lch-d65`,toMode:{lab65:e=>d1(e,`lab65`),rgb:e=>o1(d1(e,`lab65`))},fromMode:{rgb:e=>u1(l1(e),`lch65`),lab65:e=>u1(e,`lch65`)},ranges:{l:[0,100],c:[0,150],h:[0,360]}},q0e={...E$,mode:`lrgb`,toMode:{rgb:F$},fromMode:{rgb:M$},parse:[`srgb-linear`],serialize:`srgb-linear`},p1=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+.3963377773761749*t+.2158037573099136*n)**3,a=(e-.1055613458156586*t-.0638541728258133*n)**3,o=(e-.0894841775298119*t-1.2914855480194092*n)**3,s={mode:`lrgb`,r:4.076741636075957*i-3.3077115392580616*a+.2309699031821044*o,g:-1.2684379732850317*i+2.6097573492876887*a-.3413193760026573*o,b:-.0041960761386756*i-.7034186179359362*a+1.7076146940746117*o};return r!==void 0&&(s.alpha=r),s},m1=({r:e,g:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.cbrt(.412221469470763*e+.5363325372617348*t+.0514459932675022*n),a=Math.cbrt(.2119034958178252*e+.6806995506452344*t+.1073969535369406*n),o=Math.cbrt(.0883024591900564*e+.2817188391361215*t+.6299787016738222*n),s={mode:`oklab`,l:.210454268309314*i+.7936177747023054*a-.0040720430116193*o,a:1.9779985324311684*i-2.42859224204858*a+.450593709617411*o,b:.0259040424655478*i+.7827717124575296*a-.8086757549230774*o};return r!==void 0&&(s.alpha=r),s},h1=e=>{let t=m1(M$(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},g1=e=>F$(p1(e));function J0e(e,t){if(!t||t[0]!==`oklab`)return;let n={mode:`oklab`},[,r,i,a,o]=t;if(r.type!==Q.Hue&&i.type!==Q.Hue&&a.type!==Q.Hue)return r.type!==Q.None&&(n.l=Math.min(Math.max(0,r.type===Q.Number?r.value:r.value/100),1)),i.type!==Q.None&&(n.a=i.type===Q.Number?i.value:i.value*.4/100),a.type!==Q.None&&(n.b=a.type===Q.Number?a.value:a.value*.4/100),o.type!==Q.None&&(n.alpha=Math.min(1,Math.max(0,o.type===Q.Number?o.value:o.value/100))),n}var Y0e={...t1,mode:`oklab`,toMode:{lrgb:p1,rgb:g1},fromMode:{lrgb:m1,rgb:h1},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[J0e],serialize:e=>`oklab(${e.l===void 0?`none`:e.l} ${e.a===void 0?`none`:e.a} ${e.b===void 0?`none`:e.b}${e.alpha<1?` / ${e.alpha}`:``})`};function X0e(e,t){if(!t||t[0]!==`oklch`)return;let n={mode:`oklch`},[,r,i,a,o]=t;if(r.type!==Q.None){if(r.type===Q.Hue)return;n.l=Math.min(Math.max(0,r.type===Q.Number?r.value:r.value/100),1)}if(i.type!==Q.None&&(n.c=Math.max(0,i.type===Q.Number?i.value:i.value*.4/100)),a.type!==Q.None){if(a.type===Q.Percentage)return;n.h=a.value}return o.type!==Q.None&&(n.alpha=Math.min(1,Math.max(0,o.type===Q.Number?o.value:o.value/100))),n}var Z0e={...f1,mode:`oklch`,toMode:{oklab:e=>d1(e,`oklab`),rgb:e=>g1(d1(e,`oklab`))},fromMode:{rgb:e=>u1(h1(e),`oklch`),oklab:e=>u1(e,`oklch`)},parse:[X0e],serialize:e=>`oklch(${e.l===void 0?`none`:e.l} ${e.c===void 0?`none`:e.c} ${e.h===void 0?`none`:e.h}${e.alpha<1?` / ${e.alpha}`:``})`,ranges:{l:[0,1],c:[0,.4],h:[0,360]}},_1=e=>{let{r:t,g:n,b:r,alpha:i}=M$(e),a={mode:`xyz65`,x:.486570948648216*t+.265667693169093*n+.1982172852343625*r,y:.2289745640697487*t+.6917385218365062*n+.079286914093745*r,z:0*t+.0451133818589026*n+1.043944368900976*r};return i!==void 0&&(a.alpha=i),a},v1=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=F$({r:e*2.4934969119414263-t*.9313836179191242-.402710784450717*n,g:e*-.8294889695615749+t*1.7626640603183465+.0236246858419436*n,b:e*.0358458302437845-t*.0761723892680418+.9568845240076871*n},`p3`);return r!==void 0&&(i.alpha=r),i},Q0e={...E$,mode:`p3`,parse:[`display-p3`],serialize:`display-p3`,fromMode:{rgb:e=>v1(N$(e)),xyz65:v1},toMode:{rgb:e=>I$(_1(e)),xyz65:_1}},y1=e=>{let t=Math.abs(e);return t>=1/512?Math.sign(e)*t**(1/1.8):16*e},b1=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`prophoto`,r:y1(e*1.3457868816471585-t*.2555720873797946-.0511018649755453*n),g:y1(e*-.5446307051249019+t*1.5082477428451466+.0205274474364214*n),b:y1(e*0+t*0+1.2119675456389452*n)};return r!==void 0&&(i.alpha=r),i},x1=(e=0)=>{let t=Math.abs(e);return t>=16/512?Math.sign(e)*t**1.8:e/16},S1=e=>{let t=x1(e.r),n=x1(e.g),r=x1(e.b),i={mode:`xyz50`,x:.7977666449006423*t+.1351812974005331*n+.0313477341283922*r,y:.2880748288194013*t+.7118352342418731*n+899369387256e-16*r,z:0*t+0*n+.8251046025104602*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},$0e={...E$,mode:`prophoto`,parse:[`prophoto-rgb`],serialize:`prophoto-rgb`,fromMode:{xyz50:b1,rgb:e=>b1(Z$(e))},toMode:{xyz50:S1,rgb:e=>Y$(S1(e))}},e2e=1.09929682680944,t2e=.018053968510807,C1=e=>{let t=Math.abs(e);return t>t2e?(Math.sign(e)||1)*(e2e*t**.45-.09929682680944008):4.5*e},w1=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`rec2020`,r:C1(e*1.7166511879712683-t*.3556707837763925-.2533662813736599*n),g:C1(e*-.6666843518324893+t*1.6164812366349395+.0157685458139111*n),b:C1(e*.0176398574453108-t*.0427706132578085+.9421031212354739*n)};return r!==void 0&&(i.alpha=r),i},T1=1.09929682680944,n2e=.018053968510807,E1=(e=0)=>{let t=Math.abs(e);return t<n2e*4.5?e/4.5:(Math.sign(e)||1)*((t+T1-1)/T1)**(1/.45)},D1=e=>{let t=E1(e.r),n=E1(e.g),r=E1(e.b),i={mode:`xyz65`,x:.6369580483012911*t+.1446169035862083*n+.1688809751641721*r,y:.262700212011267*t+.6779980715188708*n+.059301716469862*r,z:0*t+.0280726930490874*n+1.0609850577107909*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},r2e={...E$,mode:`rec2020`,fromMode:{xyz65:w1,rgb:e=>w1(N$(e))},toMode:{xyz65:D1,rgb:e=>I$(D1(e))},parse:[`rec2020`],serialize:`rec2020`},i2e={mode:`xyz50`,parse:[`xyz-d50`],serialize:`xyz-d50`,toMode:{rgb:Y$,lab:$$},fromMode:{rgb:Z$,lab:J$},channels:[`x`,`y`,`z`,`alpha`],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:w$,y:w$,z:w$,alpha:{use:w$,fixup:T$}}},a2e={mode:`xyz65`,toMode:{rgb:I$,xyz50:e=>{let{x:t,y:n,z:r,alpha:i}=e;t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0);let a={mode:`xyz50`,x:1.0479298208405488*t+.0229467933410191*n-.0501922295431356*r,y:.0296278156881593*t+.990434484573249*n-.0170738250293851*r,z:-.0092430581525912*t+.0150551448965779*n+.7518742899580008*r};return i!==void 0&&(a.alpha=i),a}},fromMode:{rgb:N$,xyz50:e=>{let{x:t,y:n,z:r,alpha:i}=e;t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0);let a={mode:`xyz65`,x:.9554734527042182*t-.0230985368742614*n+.0632593086610217*r,y:-.0283697069632081*t+1.0099954580058226*n+.021041398966943*r,z:.0123140016883199*t-.0205076964334779*n+1.3303659366080753*r};return i!==void 0&&(a.alpha=i),a}},ranges:{x:[0,.95],y:[0,1],z:[0,1.088]},channels:[`x`,`y`,`z`,`alpha`],parse:[`xyz`,`xyz-d65`],serialize:`xyz-d65`,interpolate:{x:w$,y:w$,z:w$,alpha:{use:w$,fixup:T$}}};m$(D0e),m$(L0e),m$(R0e),m$(H0e),m$(t1),m$(W0e),m$(f1),m$(K0e),m$(q0e),m$(Y0e),m$(Z0e),m$(Q0e),m$($0e),m$(r2e),m$(E$),m$(i2e),m$(a2e);var o2e=l$(`oklch`);function s2e(e){if(typeof e!=`string`)return null;let t=e.trim(),n=C$(t);if(!n)return null;let r=o2e(n),i=r.l??0,a=r.c??0,o=r.h??0,s=/\/\s*none\s*\)$/i.test(t)?0:r.alpha??1;return[i,a,o,s].every(Number.isFinite)?{color:{L:Math.min(1,Math.max(0,i)),C:Math.max(0,a),h:o},alpha:Math.min(1,Math.max(0,s))}:null}function O1(e,t){return(Math.abs(e)<10**-t/2?0:e).toFixed(t).replace(/(?:\.0+|(?:(\.[0-9]*?)0+))$/,`$1`)}function c2e(e,t=1){let n=e.C<5e-7?0:(e.h%360+360)%360,r=`${O1(e.L,6)} ${O1(e.C,6)} ${O1(n,3)}`;return t<1?`oklch(${r} / ${O1(t,4)})`:`oklch(${r})`}function k1(e){let t=s2e(e);return t?c2e(t.color,t.alpha):null}var A1=new Set(vt),j1=new Set(mte.map(e=>e.id)),M1=new Set([Tte,...j1,`light`,`dark`,`system`]),N1=`forge:theme-halves:v1`,P1=1;function F1(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function I1(e){return e===`light`||e===`dark`}function L1(e){return typeof e==`string`&&/^[a-z0-9](?:[a-z0-9-]{0,47})$/.test(e)}function R1(e){return typeof e==`string`&&e.trim().length>0&&e.trim().length<=48}function z1(e){return F1(e)&&typeof e.id==`string`&&/^[a-z0-9][a-z0-9.:-]{0,127}$/i.test(e.id)&&R1(e.label)?{id:e.id,label:e.label.trim()}:void 0}function l2e(e){let t={};for(let[n,r]of Object.entries(e)){let e=k1(r);A1.has(n)&&e&&(t[n]=e)}return t}function B1(e){if(!F1(e))throw Error(`Theme colors must be objects.`);let t={};for(let[n,r]of Object.entries(e)){if(!A1.has(n))throw Error(`"${n}" is not a supported theme color role.`);let e=k1(r);if(!e)throw Error(`The color for "${n}" must be a literal CSS color such as oklch(0.62 0.2 280).`);t[n]=e}if(Object.keys(t).length===0)throw Error(`Add at least one color role to the theme file.`);return t}function u2e(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)||`custom-theme`}function V1(e){return F1(e)?l2e(e):null}function d2e(e,t){let n=e.variants,r;if(n===void 0)r={};else{if(!F1(n))return null;let t=V1((e.appearance===`light`?n.dark:n.light)??{});if(t===null)return null;r=t}return{light:e.appearance===`light`?t:r,dark:e.appearance===`dark`?t:r}}function f2e(e){return F1(e)&&L1(e.id)&&!M1.has(e.id)&&R1(e.label)&&I1(e.appearance)}function p2e(e){if(!f2e(e))return null;let t=V1(e.colors);if(t===null)return null;let n=d2e(e,t);if(n===null)return null;let{light:r,dark:i}=n,a=z1(e.collection);return{id:e.id,name:e.label.trim(),description:typeof e.description==`string`?e.description:``,appearance:e.appearance,light:r,dark:i,...a?{collection:a}:{}}}function m2e(e){let t=[];for(let n of e){let e=p2e(n);e&&!t.some(t=>t.id===e.id)&&t.push(e)}return t}function H1(e){let t={};for(let[n,r]of Object.entries(e)){let e=k1(r);e&&(t[n]=e)}return t}function U1(e){return{...e,light:H1(e.light),dark:H1(e.dark)}}function W1(e){let t=e.appearance===`light`?e.light:e.dark,n=e.appearance===`light`?e.dark:e.light,r={version:P1,id:e.id,label:e.name,appearance:e.appearance,colors:t};return Object.keys(n).length>0&&(r.variants=e.appearance===`light`?{dark:n}:{light:n}),e.collection&&(r.collection=e.collection),r}function h2e(e){if(e.version!==P1)throw Error(`This theme file uses an unsupported version. Expected ${P1}.`);let t=e.name,n=e.appearance;if(!R1(t))throw Error(`Theme files need a name (48 characters or fewer).`);if(!I1(n))throw Error(`Theme files need an appearance of "light" or "dark".`);let r=e.id===void 0?u2e(t):e.id;if(!L1(r))throw Error(`Theme ids may only contain lowercase letters, numbers, and hyphens.`);if(M1.has(r))throw Error(`The theme id "${r}" is reserved.`);let i=z1(e.collection);if(e.collection!==void 0&&!i)throw Error(`Theme collections need a valid id and label.`);return{id:r,name:t.trim(),appearance:n,collection:i}}function g2e(e,t){if(e.variants===void 0)return{};if(!F1(e.variants))throw Error(`Theme variants must be an object.`);for(let[n,r]of Object.entries(e.variants)){if(!I1(n))throw Error(`Theme variants may only be named "light" or "dark".`);if(n===t)throw Error(`Theme variants must not repeat the base appearance "${t}".`);if(!F1(r))throw Error(`Theme variants must be objects.`);return B1(r)}return{}}function _2e(e){if(!F1(e))throw Error(`Theme files must contain a JSON object.`);let{id:t,name:n,appearance:r,collection:i}=h2e(e);if(!F1(e.colors))throw Error(`Theme files need a colors object.`);let a=B1(e.colors),o=g2e(e,r);return{id:t,name:n,description:typeof e.description==`string`?e.description:``,appearance:r,light:r===`light`?a:o,dark:r===`dark`?a:o,...i?{collection:i}:{}}}function v2e(e){let t=U1(e),n=t.appearance===`light`?t.light:t.dark,r=t.appearance===`light`?t.dark:t.light,i={version:P1,id:t.id,name:t.name,appearance:t.appearance,colors:n,...Object.keys(r).length>0?{variants:t.appearance===`light`?{dark:r}:{light:r}}:{},...t.collection?{collection:t.collection}:{}};return`${JSON.stringify(i,null,2)}\n`}var G1=`forge:custom-themes:v1`,K1=null,q1=new Set;function y2e(){if(typeof window>`u`)return{status:`ready`,storedThemes:[],themes:[]};let e;try{e=window.localStorage.getItem(G1)}catch(e){return{status:`unavailable`,reason:`storage-unavailable`,cause:e}}if(!e)return{status:`ready`,storedThemes:[],themes:[]};let t;try{t=JSON.parse(e)}catch{return{status:`unavailable`,reason:`malformed`}}return Array.isArray(t)?{status:`ready`,storedThemes:t,themes:m2e(t)}:{status:`unavailable`,reason:`malformed`}}function J1(){return K1===null&&(K1=y2e()),K1}function Y1(){for(let e of q1)e()}function b2e(){K1=null,Y1()}var x2e=[];function X1(){let e=J1();return e.status===`ready`?e.themes:x2e}function Z1(e){return X1().find(t=>t.id===e)}function S2e(e){if(q1.add(e),typeof window>`u`)return()=>q1.delete(e);let t=e=>{(e.key===`forge:custom-themes:v1`||e.key===null)&&b2e()};return window.addEventListener(`storage`,t),()=>{q1.delete(e),window.removeEventListener(`storage`,t)}}var Q1=class extends Error{storageKey;operation;reason;constructor(e){let t=e.operation===`read`?`from`:`to`;super(`Failed to ${e.operation} the theme library ${t} ${e.storageKey}.`),this.name=`ThemeLibraryStorageError`,this.storageKey=e.storageKey,this.operation=e.operation,this.reason=e.reason,e.cause!==void 0&&(this.cause=e.cause)}};function $1(){let e=J1();if(e.status===`unavailable`)throw new Q1({storageKey:G1,operation:`read`,reason:e.reason,cause:`cause`in e?e.cause:void 0});return e}function e0(e,t){if(!(typeof window>`u`)){try{window.localStorage.setItem(G1,JSON.stringify(e)),K1={status:`ready`,storedThemes:e,themes:t}}catch(e){throw new Q1({storageKey:G1,operation:`write`,reason:`storage-unavailable`,cause:e})}Y1()}}function t0(e,t){return F1(e)&&e.id===t}function C2e(e){if(M1.has(e.id))throw Error(`The theme id "${e.id}" is reserved.`);let t=$1();if(j1.has(e.id)||t.storedThemes.some(t=>t0(t,e.id)))throw Error(`A theme named "${e.name}" is already installed.`);let n=U1(e),r=[...t.themes,n];return e0([...t.storedThemes,W1(n)],r),n}function w2e(e){if(M1.has(e.id))throw Error(`The theme id "${e.id}" is reserved.`);let t=$1(),n=t.themes.findIndex(t=>t.id===e.id);if(n===-1)throw Error(`The theme "${e.name}" is not installed.`);let r=U1(e),i=[...t.themes];i[n]=r;let a=[],o=!1;for(let n of t.storedThemes)t0(n,e.id)?o||=(a.push(W1(r)),!0):a.push(n);return e0(a,i),r}function T2e(e){E2e([e])}function E2e(e){let t=new Set(e);if(t.size===0)return;let n=$1(),r=n.themes.filter(e=>!t.has(e.id));r.length!==n.themes.length&&e0(n.storedThemes.filter(e=>!F1(e)||typeof e.id!=`string`||!t.has(e.id)),r)}function D2e(e){return j1.has(e)?!0:Z1(e)!==void 0}function O2e(e){if(!e)return null;try{let t=JSON.parse(e);if(!F1(t))return null;let n={};for(let e of[`light`,`dark`]){let r=t[e];typeof r==`string`&&D2e(r)&&(n[e]=r)}return n.light!==void 0||n.dark!==void 0?n:null}catch{return null}}function k2e(e,t,n){return t?.[n]??e}var n0=`themeId`,r0=`forge:theme-boot:v1`;function A2e(e,t){try{window.localStorage.setItem(r0,JSON.stringify({appearance:t,background:e}))}catch{}}function j2e(){try{window.localStorage.removeItem(r0)}catch{}}function i0(){return typeof document>`u`?null:document.documentElement}function a0(){let e=i0();if(e!==null){for(let t of vt)e.style.removeProperty(Ot[t]);delete e.dataset[n0],j2e()}}function M2e(e,t){let n=i0();if(n===null)return;let r=t===`dark`?e.dark:e.light;for(let e of vt){let t=r[e];if(t===void 0){n.style.removeProperty(Ot[e]);continue}n.style.setProperty(Ot[e],t)}n.dataset[n0]=e.id,r.background!==void 0&&A2e(r.background,t)}function N2e(e,t){if(e===`forge`){a0();return}let n=Hte(e)??Z1(e);if(n===void 0){a0();return}M2e(n,t)}function o0(){let e=(0,hi.c)(2),[t,n]=(0,M.useState)(P2e),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>(n(X1()),S2e(()=>{n(X1())})),i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,M.useEffect)(r,i),t}function P2e(){return X1()}function s0(){return typeof window<`u`&&typeof localStorage<`u`}function F2e(){if(!s0())return{};try{let e=JSON.parse(window.localStorage.getItem(`forge:theme-halves:v1`)??`null`);if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={};for(let n of[`light`,`dark`]){let r=e[n];typeof r==`string`&&(t[n]=r)}return t}catch{return{}}}function I2e(){if(!s0())return null;try{return O2e(window.localStorage.getItem(N1))}catch{return null}}function c0(e){if(s0())try{e===null||e.light===void 0&&e.dark===void 0?window.localStorage.removeItem(N1):window.localStorage.setItem(N1,JSON.stringify(e))}catch{}}function L2e(e,t,n){let r={...e};return n===null?delete r[t]:r[t]=n,r}function R2e(e){return e!==null&&(e.light!==void 0||e.dark!==void 0)?e:null}function z2e(e,t){let n=(0,hi.c)(13),[r,i]=(0,M.useState)(B2e),a=o0(),o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(e,t)=>{let n=L2e(F2e(),e,t);return c0(n),i(R2e(n)),!0},n[0]=o):o=n[0];let s=o,c;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>(c0(null),i(null),!0),n[1]=c):c=n[1];let l=c,u;n[2]!==t||n[3]!==r||n[4]!==e?(u=()=>{let n=t===`dark`?`dark`:`light`;N2e(k2e(e,r,n),n)},n[2]=t,n[3]=r,n[4]=e,n[5]=u):u=n[5];let d;n[6]!==a||n[7]!==t||n[8]!==r||n[9]!==e?(d=[e,t,r,a],n[6]=a,n[7]=t,n[8]=r,n[9]=e,n[10]=d):d=n[10],(0,M.useEffect)(u,d);let f;return n[11]===r?f=n[12]:(f={themeHalves:r,setThemeHalf:s,clearThemeHalves:l},n[11]=r,n[12]=f),f}function B2e(){return I2e()}var l0=`theme-color`,V2e=`meta[name="${l0}"][data-dynamic-theme-color="true"]`,H2e={dark:`#0a0a0a`,light:`#ffffff`};function U2e(){let e=document.querySelector(V2e);return e||(e=document.createElement(`meta`),e.name=l0,e.setAttribute(`data-dynamic-theme-color`,`true`),document.head.append(e),e)}function u0(e){let t=e?.trim().toLowerCase();return!t||t===`transparent`||t===`rgba(0, 0, 0, 0)`||t===`rgba(0 0 0 / 0)`?null:e?.trim()??null}function W2e(){return document.querySelector(`main[data-slot='sidebar-inset']`)??document.querySelector(`[data-slot='sidebar-inner']`)??document.body}function G2e(){return document.documentElement.classList.contains(`dark`)?`dark`:`light`}function d0(e=G2e()){if(typeof document>`u`||typeof getComputedStyle>`u`)return;document.documentElement.style.backgroundColor=``,document.body.style.backgroundColor=``;let t=u0(getComputedStyle(W2e()).backgroundColor),n=u0(getComputedStyle(document.body).backgroundColor),r=t??n??H2e[e];document.documentElement.style.backgroundColor=r,document.body.style.backgroundColor=r,U2e().setAttribute(`content`,r)}function f0(e,t){if(!Se(e)||!Se(t))return t;let n={...e};for(let[e,r]of Object.entries(t)){if(r===void 0)continue;let t=n[e];n[e]=Se(t)&&Se(r)?f0(t,r):r}return n}var p0=`[CLIENT_SETTINGS]`,m0=new Set,h0=Bt,g0=!1,_0=null;function K2e(){for(let e of m0)e()}function v0(){return h0}function y0(e){h0=e,K2e()}function q2e(e){return m0.add(e),J2e(),()=>{m0.delete(e)}}async function J2e(){if(g0)return;if(_0)return _0;let e=(async()=>{try{let e=await qi();e&&y0(e)}catch(e){console.error(`${p0} hydrate failed`,e)}finally{g0=!0}})().finally(()=>{_0===e&&(_0=null)});return _0=e,_0}function Y2e(e){y0(e),Ji(e).catch(e=>{console.error(`${p0} persist failed`,e)})}var X2e=new Set(Dte(Kte.fields));function Z2e(e){let t={},n={};for(let[r,i]of Object.entries(e))X2e.has(r)?t[r]=i:n[r]=i;return{serverPatch:t,clientPatch:n}}function b0(e){let t=$Q(),n=(0,M.useSyncExternalStore)(q2e,v0,()=>Bt),r=(0,M.useMemo)(()=>({...t,...n}),[n,t]);return(0,M.useMemo)(()=>e?e(r):r,[r,e])}function x0(){let e=(0,hi.c)(2),t=Q2e,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{t(dte)},e[0]=n):n=e[0];let r=n,i;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={updateSettings:t,resetSettings:r},e[1]=i):i=e[1],i}function Q2e(e){let{serverPatch:t,clientPatch:n}=Z2e(e);if(Object.keys(t).length>0){let e=WQ();e&&qQ(f0(e.settings,t)),_Q().client.server.updateSettings(t)}Object.keys(n).length>0&&Y2e({...v0(),...n})}var $2e=`forge:theme`,S0=`(prefers-color-scheme: dark)`;function C0(e){return e===`system`||e===`light`||e===`dark`}function w0(e,t){return typeof e!=`number`||!Number.isFinite(e)?t:Math.min(20,Math.max(11,Math.round(e)))}function e4e(){if(!s0())return{theme:`system`,uiFontSize:16,codeFontSize:13};try{let e=window.localStorage.getItem(zi);if(e){let t=Hi(JSON.parse(e));return{theme:C0(t.theme)?t.theme:`system`,uiFontSize:w0(t.uiFontSize,16),codeFontSize:w0(t.codeFontSize,13)}}let t=window.localStorage.getItem($2e);return{theme:C0(t)?t:`system`,uiFontSize:16,codeFontSize:13}}catch{return{theme:`system`,uiFontSize:16,codeFontSize:13}}}function t4e(){return typeof window>`u`||typeof window.matchMedia!=`function`||window.matchMedia(S0).matches?`dark`:`light`}function T0(e){return e===`system`?t4e():e}function n4e(e){if(typeof window>`u`)return;let t=window.desktopBridge;t&&t.setTheme(e).catch(()=>{})}function E0(e,t=!1){let n=T0(e);return typeof document>`u`||typeof window>`u`?n:(t&&document.documentElement.classList.add(`no-transitions`),document.documentElement.classList.toggle(`dark`,n===`dark`),document.documentElement.dataset.theme=e,document.documentElement.style.colorScheme=n,d0(n),n4e(e),t&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove(`no-transitions`)})),n)}function D0(e){typeof document>`u`||document.documentElement.style.setProperty(`--forge-ui-font-size`,`${w0(e,16)}px`)}function O0(e){typeof document>`u`||document.documentElement.style.setProperty(`--forge-code-font-size`,`${w0(e,13)}px`)}function k0(e){D0(e.uiFontSize),O0(e.codeFontSize)}if(typeof document<`u`){let e=e4e();E0(e.theme),k0(e)}function r4e(){let e=(0,hi.c)(33),t=b0(s4e),n=b0(o4e),r=b0(a4e),i=b0(i4e),{updateSettings:a}=x0(),o;e[0]===t?o=e[1]:(o=()=>T0(t),e[0]=t,e[1]=o);let[s,c]=(0,M.useState)(o),{themeHalves:l,setThemeHalf:u,clearThemeHalves:d}=z2e(n,s),f;e[2]===a?f=e[3]:(f=e=>{a({theme:e}),c(E0(e,!0))},e[2]=a,e[3]=f);let p=f,m;e[4]===a?m=e[5]:(m=e=>{a({themeId:e})},e[4]=a,e[5]=m);let h=m,g;e[6]===a?g=e[7]:(g=e=>{let t=w0(e,16);a({uiFontSize:t}),D0(t)},e[6]=a,e[7]=g);let _=g,v;e[8]===a?v=e[9]:(v=e=>{let t=w0(e,13);a({codeFontSize:t}),O0(t)},e[8]=a,e[9]=v);let y=v,b,x;e[10]===t?(b=e[11],x=e[12]):(b=()=>{c(E0(t))},x=[t],e[10]=t,e[11]=b,e[12]=x),(0,M.useEffect)(b,x);let S,C;e[13]!==i||e[14]!==r?(S=()=>{k0({uiFontSize:r,codeFontSize:i})},C=[r,i],e[13]=i,e[14]=r,e[15]=S,e[16]=C):(S=e[15],C=e[16]),(0,M.useEffect)(S,C);let w,T;e[17]===t?(w=e[18],T=e[19]):(T=()=>{if(t!==`system`||typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(S0),n=()=>{c(E0(`system`,!0))};return e.addEventListener(`change`,n),()=>{e.removeEventListener(`change`,n)}},w=[t],e[17]=t,e[18]=w,e[19]=T),(0,M.useEffect)(T,w);let E;return e[20]!==d||e[21]!==i||e[22]!==s||e[23]!==y||e[24]!==p||e[25]!==u||e[26]!==h||e[27]!==_||e[28]!==t||e[29]!==l||e[30]!==n||e[31]!==r?(E={theme:t,setTheme:p,themeId:n,setThemeId:h,resolvedTheme:s,themeHalves:l,setThemeHalf:u,clearThemeHalves:d,uiFontSize:r,codeFontSize:i,setUiFontSize:_,setCodeFontSize:y},e[20]=d,e[21]=i,e[22]=s,e[23]=y,e[24]=p,e[25]=u,e[26]=h,e[27]=_,e[28]=t,e[29]=l,e[30]=n,e[31]=r,e[32]=E):E=e[32],E}function i4e(e){return e.codeFontSize}function a4e(e){return e.uiFontSize}function o4e(e){return e.themeId}function s4e(e){return e.theme}function c4e(){let e=(0,hi.c)(11),t=b0(_4e),n=b0(g4e),r=b0(h4e),i=b0(m4e),a=b0(p4e),o=b0(f4e),s=b0(d4e),c=b0(u4e),l=b0(l4e),u,d;e[0]!==t||e[1]!==r||e[2]!==i||e[3]!==n||e[4]!==a||e[5]!==c||e[6]!==l||e[7]!==o||e[8]!==s?(u=()=>{typeof document>`u`||r0e(document.documentElement,{appearanceContrast:t,fontFamilyCode:r,fontFamilyComposer:i,fontFamilySans:n,fontFamilyTerminal:a,fontSmoothing:c,glassOpacity:l,promptFontSize:o,terminalFontSize:s})},d=[t,r,i,n,a,c,l,o,s],e[0]=t,e[1]=r,e[2]=i,e[3]=n,e[4]=a,e[5]=c,e[6]=l,e[7]=o,e[8]=s,e[9]=u,e[10]=d):(u=e[9],d=e[10]),(0,M.useEffect)(u,d)}function l4e(e){return e.glassOpacity}function u4e(e){return e.fontSmoothing}function d4e(e){return e.terminalFontSize}function f4e(e){return e.promptFontSize}function p4e(e){return e.fontFamilyTerminal}function m4e(e){return e.fontFamilyComposer}function h4e(e){return e.fontFamilyCode}function g4e(e){return e.fontFamilySans}function _4e(e){return e.appearanceContrast}function v4e(e,t){let n={hour:`numeric`,minute:`2-digit`,...t?{second:`2-digit`}:{}};return e===`locale`?n:{...n,hour12:e===`12-hour`}}var A0=new Map;function j0(e,t){let n=`${e}:${t?`seconds`:`minutes`}`,r=A0.get(n);if(r)return r;let i=new Intl.DateTimeFormat(void 0,v4e(e,t));return A0.set(n,i),i}function y4e(e,t){return j0(t,!0).format(new Date(e))}function b4e(e,t){return j0(t,!1).format(new Date(e))}function M0(e){let t=Date.now()-new Date(e).getTime();if(t<0)return{value:`just now`,suffix:null};let n=Math.floor(t/1e3);if(n<60)return{value:`just now`,suffix:null};let r=Math.floor(n/60);if(r<60)return{value:`${r}m`,suffix:`ago`};let i=Math.floor(r/60);return i<24?{value:`${i}h`,suffix:`ago`}:{value:`${Math.floor(i/24)}d`,suffix:`ago`}}function x4e(e){let t=M0(e);return t.suffix?`${t.value} ${t.suffix}`:t.value}var S4e=new Set([`tool.started`,`task.started`,`context-window.updated`,`text-generation.usage`,`worktree.stage`,`launch.agent-starting`]);function N0(e){return S4e.has(e.kind)||e.summary===`Checkpoint captured`}function P0(e){let t=I0(e?.data),n=I0(t?.item),r=I0(n?.result),i=I0(n?.input),a=L0(e?.itemType),o=L0(e?.detail),s=[e?.command,n?.command,i?.command,r?.command,t?.command,a===`command_execution`&&o?F0(o).output:null];for(let e of s){let t=A4e(e);if(t)return{command:t,rawCommand:j4e(e,t)}}return{command:null,rawCommand:null}}function F0(e){let t=e.trim(),n=/^(?<output>[\s\S]*?)(?:\s*<exited with exit code (?<code>\d+)>)\s*$/i.exec(t);if(!n?.groups)return{output:t.length>0?t:null};let r=Number.parseInt(n.groups.code??``,10),i=n.groups.output?.trim()??``;return{output:i.length>0?i:null,...Number.isInteger(r)?{exitCode:r}:{}}}function I0(e){return e&&typeof e==`object`?e:null}function L0(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function R0(e){let t=e.trim();if(t.startsWith(`'`)&&t.endsWith(`'`)||t.startsWith(`"`)&&t.endsWith(`"`)){let e=t.slice(1,-1).trim();return e.length>0?e:t}return t}function C4e(e){let t=R0(e);if(t.length===0)return null;let n=t.replace(/\\/g,`/`).split(`/`).at(-1)?.trim()??``;return n.length>0?n.toLowerCase():null}function w4e(e){let t=e.trim();if(t.length===0)return null;if(t.startsWith(`"`)||t.startsWith(`'`)){let e=t.charAt(0),n=t.indexOf(e,1);return n<=0?null:{executable:t.slice(0,n+1),rest:t.slice(n+1).trim()}}let n=t.search(/\s/);return n<0?{executable:t,rest:``}:{executable:t.slice(0,n),rest:t.slice(n).trim()}}var T4e=[{executables:[`pwsh`,`pwsh.exe`,`powershell`,`powershell.exe`],wrapperFlagPattern:/(?:^|\s)-command\s+/i},{executables:[`cmd`,`cmd.exe`],wrapperFlagPattern:/(?:^|\s)\/c\s+/i},{executables:[`bash`,`sh`,`zsh`],wrapperFlagPattern:/(?:^|\s)-(?:l)?c\s+/i}];function E4e(e){return T4e.find(t=>t.executables.includes(e))}function D4e(e,t){let n=t.exec(e);if(!n)return null;let r=e.slice(n.index+n[0].length).trim();if(r.length===0)return null;let i=r[0];if((i===`'`||i===`"`)&&!r.endsWith(i))return null;let a=R0(r);return a.length>0?a:null}function O4e(e){let t=w4e(e);if(!t||t.rest.length===0)return e;let n=C4e(t.executable);if(!n)return e;let r=E4e(n);return r?D4e(t.rest,r.wrapperFlagPattern)??e:e}function k4e(e){return/[\s"'`]/.test(e)?`"${e.replace(/"/g,`\\"`)}"`:e}function z0(e){let t=L0(e);if(t)return t;if(!Array.isArray(e))return null;let n=[];for(let t of e){let e=L0(t);e!==null&&n.push(e)}return n.length===0?null:n.map(e=>k4e(e)).join(` `)}function A4e(e){let t=z0(e);return t?O4e(t):null}function j4e(e,t){let n=z0(e);return!n||t===null||n===t?null:n}function B0(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function V0(e){return typeof e==`string`&&e.trim().length>0?e:null}function M4e(e){let t=V0(e);if(t)return t;let n=Array.isArray(e)?e:null,r=B0(e)?.content,i=V0(r);if(i)return i;let a=n??(Array.isArray(r)?r:null);if(!a)return null;let o=a.flatMap(e=>{let t=V0(e)??V0(B0(e)?.text);return t?[t]:[]});return o.length>0?o.join(`
1024
+ `||t[g$]===` `||t[g$]===` `);)g$++;let e;if(_$(t)&&(e=y$(t),e.type!==Q.Hue)){n.push({type:Q.Alpha,value:e});continue}if(v$(t)&&x$(t)===`none`){n.push({type:Q.Alpha,value:{type:Q.None,value:void 0}});continue}return}if(/\d/.test(r)){g$--,n.push(y$(t));continue}if(h$.test(r)){g$--,n.push(y0e(t));continue}return}return n}function x0e(e){e._i=0;let t=e[e._i++];if(!t||t.type!==Q.Function||t.value!==`color`||(t=e[e._i++],t.type!==Q.Ident))return;let n=p$[t.value];if(!n)return;let r={mode:n},i=S$(e,!1);if(!i)return;let a=h0e(n).channels;for(let e=0,t,n;e<a.length;e++)t=i[e],n=a[e],t.type!==Q.None&&(r[n]=t.type===Q.Number?t.value:t.value/100,n===`alpha`&&(r[n]=Math.max(0,Math.min(1,r[n]))));return r}function S$(e,t){let n=[],r;for(;e._i<e.length;){if(r=e[e._i++],r.type===Q.None||r.type===Q.Number||r.type===Q.Alpha||r.type===Q.Percentage||t&&r.type===Q.Hue){n.push(r);continue}if(r.type===Q.ParenClose){if(e._i<e.length)return;continue}return}if(!(n.length<3||n.length>4)){if(n.length===4){if(n[3].type!==Q.Alpha)return;n[3]=n[3].value}return n.length===3&&n.push({type:Q.None,value:void 0}),n.every(e=>e.type!==Q.Alpha)?n:void 0}}function S0e(e,t){e._i=0;let n=e[e._i++];if(!n||n.type!==Q.Function)return;let r=S$(e,t);if(r)return r.unshift(n.value),r}var C$=e=>{if(typeof e!=`string`)return;let t=b0e(e),n=t?S0e(t,!0):void 0,r,i=0,a=f$.length;for(;i<a;)if((r=f$[i++](e,n))!==void 0)return r;return t?x0e(t):void 0};function C0e(e,t){if(!t||t[0]!==`rgb`&&t[0]!==`rgba`)return;let n={mode:`rgb`},[,r,i,a,o]=t;if(r.type!==Q.Hue&&i.type!==Q.Hue&&a.type!==Q.Hue)return r.type!==Q.None&&(n.r=r.type===Q.Number?r.value/255:r.value/100),i.type!==Q.None&&(n.g=i.type===Q.Number?i.value/255:i.value/100),a.type!==Q.None&&(n.b=a.type===Q.Number?a.value/255:a.value/100),o.type!==Q.None&&(n.alpha=Math.min(1,Math.max(0,o.type===Q.Number?o.value:o.value/100))),n}var w0e=e=>e===`transparent`?{mode:`rgb`,r:0,g:0,b:0,alpha:0}:void 0,T0e=(e,t,n)=>e+n*(t-e),E0e=e=>{let t=[];for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];r===void 0&&i===void 0?t.push(void 0):r!==void 0&&i!==void 0?t.push([r,i]):t.push(r===void 0?[i,i]:[r,r])}return t},w$=(e=>t=>{let n=E0e(t);return t=>{let r=t*n.length,i=t>=1?n.length-1:Math.max(Math.floor(r),0),a=n[i];return a===void 0?void 0:e(a[0],a[1],r-i)}})(T0e),T$=e=>{let t=!1,n=e.map(e=>e===void 0?1:(t=!0,e));return t?n:e},E$={mode:`rgb`,channels:[`r`,`g`,`b`,`alpha`],parse:[C0e,s0e,f0e,a0e,w0e,`srgb`],serialize:`srgb`,interpolate:{r:w$,g:w$,b:w$,alpha:{use:w$,fixup:T$}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},D$=(e=0)=>Math.abs(e)**(563/256)*Math.sign(e),O$=e=>{let t=D$(e.r),n=D$(e.g),r=D$(e.b),i={mode:`xyz65`,x:.5766690429101305*t+.1855582379065463*n+.1882286462349947*r,y:.297344975250536*t+.6273635662554661*n+.0752914584939979*r,z:.0270313613864123*t+.0706888525358272*n+.9913375368376386*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},k$=e=>Math.abs(e)**(256/563)*Math.sign(e),A$=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`a98`,r:k$(e*2.0415879038107465-t*.5650069742788597-.3447313507783297*n),g:k$(e*-.9692436362808798+t*1.8759675015077206+.0415550574071756*n),b:k$(e*.0134442806320312-t*.1183623922310184+1.0151749943912058*n)};return r!==void 0&&(i.alpha=r),i},j$=(e=0)=>{let t=Math.abs(e);return t<=.04045?e/12.92:(Math.sign(e)||1)*((t+.055)/1.055)**2.4},M$=({r:e,g:t,b:n,alpha:r})=>{let i={mode:`lrgb`,r:j$(e),g:j$(t),b:j$(n)};return r!==void 0&&(i.alpha=r),i},N$=e=>{let{r:t,g:n,b:r,alpha:i}=M$(e),a={mode:`xyz65`,x:.4123907992659593*t+.357584339383878*n+.1804807884018343*r,y:.2126390058715102*t+.715168678767756*n+.0721923153607337*r,z:.0193308187155918*t+.119194779794626*n+.9505321522496607*r};return i!==void 0&&(a.alpha=i),a},P$=(e=0)=>{let t=Math.abs(e);return t>.0031308?(Math.sign(e)||1)*(1.055*t**(1/2.4)-.055):e*12.92},F$=({r:e,g:t,b:n,alpha:r},i=`rgb`)=>{let a={mode:i,r:P$(e),g:P$(t),b:P$(n)};return r!==void 0&&(a.alpha=r),a},I$=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=F$({r:e*3.2409699419045226-t*1.537383177570094-.4986107602930034*n,g:e*-.9692436362808796+t*1.8759675015077204+.0415550574071756*n,b:e*.0556300796969936-t*.2039769588889765+1.0569715142428784*n});return r!==void 0&&(i.alpha=r),i},D0e={...E$,mode:`a98`,parse:[`a98-rgb`],serialize:`a98-rgb`,fromMode:{rgb:e=>A$(N$(e)),xyz65:A$},toMode:{rgb:e=>I$(O$(e)),xyz65:O$}},L$=e=>(e%=360)<0?e+360:e;function O0e({h:e,s:t,l:n,alpha:r}){e=L$(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=n+t*(n<.5?n:1-n),a=i-(i-n)*2*Math.abs(e/60%2-1),o;switch(Math.floor(e/60)){case 0:o={r:i,g:a,b:2*n-i};break;case 1:o={r:a,g:i,b:2*n-i};break;case 2:o={r:2*n-i,g:i,b:a};break;case 3:o={r:2*n-i,g:a,b:i};break;case 4:o={r:a,g:2*n-i,b:i};break;case 5:o={r:i,g:2*n-i,b:a};break;default:o={r:2*n-i,g:2*n-i,b:2*n-i}}return o.mode=`rgb`,r!==void 0&&(o.alpha=r),o}function k0e({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsl`,s:i===a?0:(i-a)/(1-Math.abs(i+a-1)),l:.5*(i+a)};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}var A0e=(e,t)=>{switch(t){case`deg`:return+e;case`rad`:return e/Math.PI*180;case`grad`:return e/10*9;case`turn`:return e*360}},j0e=RegExp(`^hsla?\\(\\s*${l0e}${c$}${o$}${c$}${o$}\\s*(?:,\\s*${s$}\\s*)?\\)$`),M0e=e=>{let t=e.match(j0e);if(!t)return;let n={mode:`hsl`};return t[3]===void 0?t[1]!==void 0&&t[2]!==void 0&&(n.h=A0e(t[1],t[2])):n.h=+t[3],t[4]!==void 0&&(n.s=Math.min(Math.max(0,t[4]/100),1)),t[5]!==void 0&&(n.l=Math.min(Math.max(0,t[5]/100),1)),t[6]===void 0?t[7]!==void 0&&(n.alpha=Math.max(0,Math.min(1,+t[7]))):n.alpha=Math.max(0,Math.min(1,t[6]/100)),n};function N0e(e,t){if(!t||t[0]!==`hsl`&&t[0]!==`hsla`)return;let n={mode:`hsl`},[,r,i,a,o]=t;if(r.type!==Q.None){if(r.type===Q.Percentage)return;n.h=r.value}if(i.type!==Q.None){if(i.type===Q.Hue)return;n.s=i.value/100}if(a.type!==Q.None){if(a.type===Q.Hue)return;n.l=a.value/100}return o.type!==Q.None&&(n.alpha=Math.min(1,Math.max(0,o.type===Q.Number?o.value:o.value/100))),n}var P0e=(e,t)=>e.map((n,r,i)=>{if(n===void 0)return n;let a=L$(n);return r===0||e[r-1]===void 0?a:t(a-L$(i[r-1]))}).reduce((e,t)=>!e.length||t===void 0||e[e.length-1]===void 0?(e.push(t),e):(e.push(t+e[e.length-1]),e),[]),R$=e=>P0e(e,e=>Math.abs(e)<=180?e:e-360*Math.sign(e)),z$=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.s||!t.s)return 0;let n=L$(e.h),r=L$(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*t.s)*i},F0e=(e,t)=>{if(e.h===void 0||t.h===void 0)return 0;let n=L$(e.h),r=L$(t.h);return Math.abs(r-n)>180?n-(r-360*Math.sign(r-n)):r-n},I0e=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.c||!t.c)return 0;let n=L$(e.h),r=L$(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*t.c)*i},B$=e=>{let t=e.reduce((e,t)=>{if(t!==void 0){let n=t*Math.PI/180;e.sin+=Math.sin(n),e.cos+=Math.cos(n)}return e},{sin:0,cos:0}),n=Math.atan2(t.sin,t.cos)*180/Math.PI;return n<0?360+n:n},L0e={mode:`hsl`,toMode:{rgb:O0e},fromMode:{rgb:k0e},channels:[`h`,`s`,`l`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[N0e,M0e],serialize:e=>`hsl(${e.h===void 0?`none`:e.h} ${e.s===void 0?`none`:e.s*100+`%`} ${e.l===void 0?`none`:e.l*100+`%`}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:w$,fixup:R$},s:w$,l:w$,alpha:{use:w$,fixup:T$}},difference:{h:z$},average:{h:B$}};function V$({h:e,s:t,v:n,alpha:r}){e=L$(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.abs(e/60%2-1),a;switch(Math.floor(e/60)){case 0:a={r:n,g:n*(1-t*i),b:n*(1-t)};break;case 1:a={r:n*(1-t*i),g:n,b:n*(1-t)};break;case 2:a={r:n*(1-t),g:n,b:n*(1-t*i)};break;case 3:a={r:n*(1-t),g:n*(1-t*i),b:n};break;case 4:a={r:n*(1-t*i),g:n*(1-t),b:n};break;case 5:a={r:n,g:n*(1-t),b:n*(1-t*i)};break;default:a={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return a.mode=`rgb`,r!==void 0&&(a.alpha=r),a}function H$({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsv`,s:i===0?0:1-a/i,v:i};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}var R0e={mode:`hsv`,toMode:{rgb:V$},parse:[`--hsv`],serialize:`--hsv`,fromMode:{rgb:H$},channels:[`h`,`s`,`v`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,interpolate:{h:{use:w$,fixup:R$},s:w$,v:w$,alpha:{use:w$,fixup:T$}},difference:{h:z$},average:{h:B$}};function z0e({h:e,w:t,b:n,alpha:r}){if(t===void 0&&(t=0),n===void 0&&(n=0),t+n>1){let e=t+n;t/=e,n/=e}return V$({h:e,s:n===1?1:1-t/(1-n),v:1-n,alpha:r})}function B0e(e){let t=H$(e);if(t===void 0)return;let n=t.s===void 0?0:t.s,r=t.v===void 0?0:t.v,i={mode:`hwb`,w:(1-n)*r,b:1-r};return t.h!==void 0&&(i.h=t.h),t.alpha!==void 0&&(i.alpha=t.alpha),i}function V0e(e,t){if(!t||t[0]!==`hwb`)return;let n={mode:`hwb`},[,r,i,a,o]=t;if(r.type!==Q.None){if(r.type===Q.Percentage)return;n.h=r.value}if(i.type!==Q.None){if(i.type===Q.Hue)return;n.w=i.value/100}if(a.type!==Q.None){if(a.type===Q.Hue)return;n.b=a.value/100}return o.type!==Q.None&&(n.alpha=Math.min(1,Math.max(0,o.type===Q.Number?o.value:o.value/100))),n}var H0e={mode:`hwb`,toMode:{rgb:z0e},fromMode:{rgb:B0e},channels:[`h`,`w`,`b`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[V0e],serialize:e=>`hwb(${e.h===void 0?`none`:e.h} ${e.w===void 0?`none`:e.w*100+`%`} ${e.b===void 0?`none`:e.b*100+`%`}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:w$,fixup:R$},w:w$,b:w$,alpha:{use:w$,fixup:T$}},difference:{h:F0e},average:{h:B$}},U$=29**3/3**3,W$=6**3/29**3,G$={X:.3457/.3585,Y:1,Z:.2958/.3585},K$={X:.3127/.329,Y:1,Z:.3583/.329},q$=e=>e**3>W$?e**3:(116*e-16)/U$,J$=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+16)/116,a=t/500+i,o=i-n/200,s={mode:`xyz50`,x:q$(a)*G$.X,y:q$(i)*G$.Y,z:q$(o)*G$.Z};return r!==void 0&&(s.alpha=r),s},Y$=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=F$({r:e*3.1341359569958707-t*1.6173863321612538-.4906619460083532*n,g:e*-.978795502912089+t*1.916254567259524+.03344273116131949*n,b:e*.07195537988411677-t*.2289768264158322+1.405386058324125*n});return r!==void 0&&(i.alpha=r),i},X$=e=>Y$(J$(e)),Z$=e=>{let{r:t,g:n,b:r,alpha:i}=M$(e),a={mode:`xyz50`,x:.436065742824811*t+.3851514688337912*n+.14307845442264197*r,y:.22249319175623702*t+.7168870538238823*n+.06061979053616537*r,z:.013923904500943465*t+.09708128566574634*n+.7140993584005155*r};return i!==void 0&&(a.alpha=i),a},Q$=e=>e>W$?Math.cbrt(e):(U$*e+16)/116,$$=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Q$(e/G$.X),a=Q$(t/G$.Y),o=Q$(n/G$.Z),s={mode:`lab`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},e1=e=>{let t=$$(Z$(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t};function U0e(e,t){if(!t||t[0]!==`lab`)return;let n={mode:`lab`},[,r,i,a,o]=t;if(r.type!==Q.Hue&&i.type!==Q.Hue&&a.type!==Q.Hue)return r.type!==Q.None&&(n.l=Math.min(Math.max(0,r.value),100)),i.type!==Q.None&&(n.a=i.type===Q.Number?i.value:i.value*125/100),a.type!==Q.None&&(n.b=a.type===Q.Number?a.value:a.value*125/100),o.type!==Q.None&&(n.alpha=Math.min(1,Math.max(0,o.type===Q.Number?o.value:o.value/100))),n}var t1={mode:`lab`,toMode:{xyz50:J$,rgb:X$},fromMode:{xyz50:$$,rgb:e1},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[U0e],serialize:e=>`lab(${e.l===void 0?`none`:e.l} ${e.a===void 0?`none`:e.a} ${e.b===void 0?`none`:e.b}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{l:w$,a:w$,b:w$,alpha:{use:w$,fixup:T$}}},n1=29**3/3**3,r1=6**3/29**3,i1=e=>e**3>r1?e**3:(116*e-16)/n1,a1=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+16)/116,a=t/500+i,o=i-n/200,s={mode:`xyz65`,x:i1(a)*K$.X,y:i1(i)*K$.Y,z:i1(o)*K$.Z};return r!==void 0&&(s.alpha=r),s},o1=e=>I$(a1(e)),s1=e=>e>r1?Math.cbrt(e):(n1*e+16)/116,c1=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=s1(e/K$.X),a=s1(t/K$.Y),o=s1(n/K$.Z),s={mode:`lab65`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},l1=e=>{let t=c1(N$(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},W0e={...t1,mode:`lab65`,parse:[`--lab-d65`],serialize:`--lab-d65`,toMode:{xyz65:a1,rgb:o1},fromMode:{xyz65:c1,rgb:l1},ranges:{l:[0,100],a:[-125,125],b:[-125,125]}},u1=({l:e,a:t,b:n,alpha:r},i=`lch`)=>{t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.sqrt(t*t+n*n),o={mode:i,l:e,c:a};return a&&(o.h=L$(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(o.alpha=r),o},d1=({l:e,c:t,h:n,alpha:r},i=`lab`)=>{n===void 0&&(n=0);let a={mode:i,l:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return r!==void 0&&(a.alpha=r),a};function G0e(e,t){if(!t||t[0]!==`lch`)return;let n={mode:`lch`},[,r,i,a,o]=t;if(r.type!==Q.None){if(r.type===Q.Hue)return;n.l=Math.min(Math.max(0,r.value),100)}if(i.type!==Q.None&&(n.c=Math.max(0,i.type===Q.Number?i.value:i.value*150/100)),a.type!==Q.None){if(a.type===Q.Percentage)return;n.h=a.value}return o.type!==Q.None&&(n.alpha=Math.min(1,Math.max(0,o.type===Q.Number?o.value:o.value/100))),n}var f1={mode:`lch`,toMode:{lab:d1,rgb:e=>X$(d1(e))},fromMode:{rgb:e=>u1(e1(e)),lab:u1},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[G0e],serialize:e=>`lch(${e.l===void 0?`none`:e.l} ${e.c===void 0?`none`:e.c} ${e.h===void 0?`none`:e.h}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:w$,fixup:R$},c:w$,l:w$,alpha:{use:w$,fixup:T$}},difference:{h:I0e},average:{h:B$}},K0e={...f1,mode:`lch65`,parse:[`--lch-d65`],serialize:`--lch-d65`,toMode:{lab65:e=>d1(e,`lab65`),rgb:e=>o1(d1(e,`lab65`))},fromMode:{rgb:e=>u1(l1(e),`lch65`),lab65:e=>u1(e,`lch65`)},ranges:{l:[0,100],c:[0,150],h:[0,360]}},q0e={...E$,mode:`lrgb`,toMode:{rgb:F$},fromMode:{rgb:M$},parse:[`srgb-linear`],serialize:`srgb-linear`},p1=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+.3963377773761749*t+.2158037573099136*n)**3,a=(e-.1055613458156586*t-.0638541728258133*n)**3,o=(e-.0894841775298119*t-1.2914855480194092*n)**3,s={mode:`lrgb`,r:4.076741636075957*i-3.3077115392580616*a+.2309699031821044*o,g:-1.2684379732850317*i+2.6097573492876887*a-.3413193760026573*o,b:-.0041960761386756*i-.7034186179359362*a+1.7076146940746117*o};return r!==void 0&&(s.alpha=r),s},m1=({r:e,g:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.cbrt(.412221469470763*e+.5363325372617348*t+.0514459932675022*n),a=Math.cbrt(.2119034958178252*e+.6806995506452344*t+.1073969535369406*n),o=Math.cbrt(.0883024591900564*e+.2817188391361215*t+.6299787016738222*n),s={mode:`oklab`,l:.210454268309314*i+.7936177747023054*a-.0040720430116193*o,a:1.9779985324311684*i-2.42859224204858*a+.450593709617411*o,b:.0259040424655478*i+.7827717124575296*a-.8086757549230774*o};return r!==void 0&&(s.alpha=r),s},h1=e=>{let t=m1(M$(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},g1=e=>F$(p1(e));function J0e(e,t){if(!t||t[0]!==`oklab`)return;let n={mode:`oklab`},[,r,i,a,o]=t;if(r.type!==Q.Hue&&i.type!==Q.Hue&&a.type!==Q.Hue)return r.type!==Q.None&&(n.l=Math.min(Math.max(0,r.type===Q.Number?r.value:r.value/100),1)),i.type!==Q.None&&(n.a=i.type===Q.Number?i.value:i.value*.4/100),a.type!==Q.None&&(n.b=a.type===Q.Number?a.value:a.value*.4/100),o.type!==Q.None&&(n.alpha=Math.min(1,Math.max(0,o.type===Q.Number?o.value:o.value/100))),n}var Y0e={...t1,mode:`oklab`,toMode:{lrgb:p1,rgb:g1},fromMode:{lrgb:m1,rgb:h1},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[J0e],serialize:e=>`oklab(${e.l===void 0?`none`:e.l} ${e.a===void 0?`none`:e.a} ${e.b===void 0?`none`:e.b}${e.alpha<1?` / ${e.alpha}`:``})`};function X0e(e,t){if(!t||t[0]!==`oklch`)return;let n={mode:`oklch`},[,r,i,a,o]=t;if(r.type!==Q.None){if(r.type===Q.Hue)return;n.l=Math.min(Math.max(0,r.type===Q.Number?r.value:r.value/100),1)}if(i.type!==Q.None&&(n.c=Math.max(0,i.type===Q.Number?i.value:i.value*.4/100)),a.type!==Q.None){if(a.type===Q.Percentage)return;n.h=a.value}return o.type!==Q.None&&(n.alpha=Math.min(1,Math.max(0,o.type===Q.Number?o.value:o.value/100))),n}var Z0e={...f1,mode:`oklch`,toMode:{oklab:e=>d1(e,`oklab`),rgb:e=>g1(d1(e,`oklab`))},fromMode:{rgb:e=>u1(h1(e),`oklch`),oklab:e=>u1(e,`oklch`)},parse:[X0e],serialize:e=>`oklch(${e.l===void 0?`none`:e.l} ${e.c===void 0?`none`:e.c} ${e.h===void 0?`none`:e.h}${e.alpha<1?` / ${e.alpha}`:``})`,ranges:{l:[0,1],c:[0,.4],h:[0,360]}},_1=e=>{let{r:t,g:n,b:r,alpha:i}=M$(e),a={mode:`xyz65`,x:.486570948648216*t+.265667693169093*n+.1982172852343625*r,y:.2289745640697487*t+.6917385218365062*n+.079286914093745*r,z:0*t+.0451133818589026*n+1.043944368900976*r};return i!==void 0&&(a.alpha=i),a},v1=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=F$({r:e*2.4934969119414263-t*.9313836179191242-.402710784450717*n,g:e*-.8294889695615749+t*1.7626640603183465+.0236246858419436*n,b:e*.0358458302437845-t*.0761723892680418+.9568845240076871*n},`p3`);return r!==void 0&&(i.alpha=r),i},Q0e={...E$,mode:`p3`,parse:[`display-p3`],serialize:`display-p3`,fromMode:{rgb:e=>v1(N$(e)),xyz65:v1},toMode:{rgb:e=>I$(_1(e)),xyz65:_1}},y1=e=>{let t=Math.abs(e);return t>=1/512?Math.sign(e)*t**(1/1.8):16*e},b1=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`prophoto`,r:y1(e*1.3457868816471585-t*.2555720873797946-.0511018649755453*n),g:y1(e*-.5446307051249019+t*1.5082477428451466+.0205274474364214*n),b:y1(e*0+t*0+1.2119675456389452*n)};return r!==void 0&&(i.alpha=r),i},x1=(e=0)=>{let t=Math.abs(e);return t>=16/512?Math.sign(e)*t**1.8:e/16},S1=e=>{let t=x1(e.r),n=x1(e.g),r=x1(e.b),i={mode:`xyz50`,x:.7977666449006423*t+.1351812974005331*n+.0313477341283922*r,y:.2880748288194013*t+.7118352342418731*n+899369387256e-16*r,z:0*t+0*n+.8251046025104602*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},$0e={...E$,mode:`prophoto`,parse:[`prophoto-rgb`],serialize:`prophoto-rgb`,fromMode:{xyz50:b1,rgb:e=>b1(Z$(e))},toMode:{xyz50:S1,rgb:e=>Y$(S1(e))}},e2e=1.09929682680944,t2e=.018053968510807,C1=e=>{let t=Math.abs(e);return t>t2e?(Math.sign(e)||1)*(e2e*t**.45-.09929682680944008):4.5*e},w1=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`rec2020`,r:C1(e*1.7166511879712683-t*.3556707837763925-.2533662813736599*n),g:C1(e*-.6666843518324893+t*1.6164812366349395+.0157685458139111*n),b:C1(e*.0176398574453108-t*.0427706132578085+.9421031212354739*n)};return r!==void 0&&(i.alpha=r),i},T1=1.09929682680944,n2e=.018053968510807,E1=(e=0)=>{let t=Math.abs(e);return t<n2e*4.5?e/4.5:(Math.sign(e)||1)*((t+T1-1)/T1)**(1/.45)},D1=e=>{let t=E1(e.r),n=E1(e.g),r=E1(e.b),i={mode:`xyz65`,x:.6369580483012911*t+.1446169035862083*n+.1688809751641721*r,y:.262700212011267*t+.6779980715188708*n+.059301716469862*r,z:0*t+.0280726930490874*n+1.0609850577107909*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},r2e={...E$,mode:`rec2020`,fromMode:{xyz65:w1,rgb:e=>w1(N$(e))},toMode:{xyz65:D1,rgb:e=>I$(D1(e))},parse:[`rec2020`],serialize:`rec2020`},i2e={mode:`xyz50`,parse:[`xyz-d50`],serialize:`xyz-d50`,toMode:{rgb:Y$,lab:$$},fromMode:{rgb:Z$,lab:J$},channels:[`x`,`y`,`z`,`alpha`],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:w$,y:w$,z:w$,alpha:{use:w$,fixup:T$}}},a2e={mode:`xyz65`,toMode:{rgb:I$,xyz50:e=>{let{x:t,y:n,z:r,alpha:i}=e;t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0);let a={mode:`xyz50`,x:1.0479298208405488*t+.0229467933410191*n-.0501922295431356*r,y:.0296278156881593*t+.990434484573249*n-.0170738250293851*r,z:-.0092430581525912*t+.0150551448965779*n+.7518742899580008*r};return i!==void 0&&(a.alpha=i),a}},fromMode:{rgb:N$,xyz50:e=>{let{x:t,y:n,z:r,alpha:i}=e;t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0);let a={mode:`xyz65`,x:.9554734527042182*t-.0230985368742614*n+.0632593086610217*r,y:-.0283697069632081*t+1.0099954580058226*n+.021041398966943*r,z:.0123140016883199*t-.0205076964334779*n+1.3303659366080753*r};return i!==void 0&&(a.alpha=i),a}},ranges:{x:[0,.95],y:[0,1],z:[0,1.088]},channels:[`x`,`y`,`z`,`alpha`],parse:[`xyz`,`xyz-d65`],serialize:`xyz-d65`,interpolate:{x:w$,y:w$,z:w$,alpha:{use:w$,fixup:T$}}};m$(D0e),m$(L0e),m$(R0e),m$(H0e),m$(t1),m$(W0e),m$(f1),m$(K0e),m$(q0e),m$(Y0e),m$(Z0e),m$(Q0e),m$($0e),m$(r2e),m$(E$),m$(i2e),m$(a2e);var o2e=l$(`oklch`);function s2e(e){if(typeof e!=`string`)return null;let t=e.trim(),n=C$(t);if(!n)return null;let r=o2e(n),i=r.l??0,a=r.c??0,o=r.h??0,s=/\/\s*none\s*\)$/i.test(t)?0:r.alpha??1;return[i,a,o,s].every(Number.isFinite)?{color:{L:Math.min(1,Math.max(0,i)),C:Math.max(0,a),h:o},alpha:Math.min(1,Math.max(0,s))}:null}function O1(e,t){return(Math.abs(e)<10**-t/2?0:e).toFixed(t).replace(/(?:\.0+|(?:(\.[0-9]*?)0+))$/,`$1`)}function c2e(e,t=1){let n=e.C<5e-7?0:(e.h%360+360)%360,r=`${O1(e.L,6)} ${O1(e.C,6)} ${O1(n,3)}`;return t<1?`oklch(${r} / ${O1(t,4)})`:`oklch(${r})`}function k1(e){let t=s2e(e);return t?c2e(t.color,t.alpha):null}var A1=new Set(vt),j1=new Set(mte.map(e=>e.id)),M1=new Set([Tte,...j1,`light`,`dark`,`system`]),N1=`forge:theme-halves:v1`,P1=1;function F1(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function I1(e){return e===`light`||e===`dark`}function L1(e){return typeof e==`string`&&/^[a-z0-9](?:[a-z0-9-]{0,47})$/.test(e)}function R1(e){return typeof e==`string`&&e.trim().length>0&&e.trim().length<=48}function z1(e){return F1(e)&&typeof e.id==`string`&&/^[a-z0-9][a-z0-9.:-]{0,127}$/i.test(e.id)&&R1(e.label)?{id:e.id,label:e.label.trim()}:void 0}function l2e(e){let t={};for(let[n,r]of Object.entries(e)){let e=k1(r);A1.has(n)&&e&&(t[n]=e)}return t}function B1(e){if(!F1(e))throw Error(`Theme colors must be objects.`);let t={};for(let[n,r]of Object.entries(e)){if(!A1.has(n))throw Error(`"${n}" is not a supported theme color role.`);let e=k1(r);if(!e)throw Error(`The color for "${n}" must be a literal CSS color such as oklch(0.62 0.2 280).`);t[n]=e}if(Object.keys(t).length===0)throw Error(`Add at least one color role to the theme file.`);return t}function u2e(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)||`custom-theme`}function V1(e){return F1(e)?l2e(e):null}function d2e(e,t){let n=e.variants,r;if(n===void 0)r={};else{if(!F1(n))return null;let t=V1((e.appearance===`light`?n.dark:n.light)??{});if(t===null)return null;r=t}return{light:e.appearance===`light`?t:r,dark:e.appearance===`dark`?t:r}}function f2e(e){return F1(e)&&L1(e.id)&&!M1.has(e.id)&&R1(e.label)&&I1(e.appearance)}function p2e(e){if(!f2e(e))return null;let t=V1(e.colors);if(t===null)return null;let n=d2e(e,t);if(n===null)return null;let{light:r,dark:i}=n,a=z1(e.collection);return{id:e.id,name:e.label.trim(),description:typeof e.description==`string`?e.description:``,appearance:e.appearance,light:r,dark:i,...a?{collection:a}:{}}}function m2e(e){let t=[];for(let n of e){let e=p2e(n);e&&!t.some(t=>t.id===e.id)&&t.push(e)}return t}function H1(e){let t={};for(let[n,r]of Object.entries(e)){let e=k1(r);e&&(t[n]=e)}return t}function U1(e){return{...e,light:H1(e.light),dark:H1(e.dark)}}function W1(e){let t=e.appearance===`light`?e.light:e.dark,n=e.appearance===`light`?e.dark:e.light,r={version:P1,id:e.id,label:e.name,appearance:e.appearance,colors:t};return Object.keys(n).length>0&&(r.variants=e.appearance===`light`?{dark:n}:{light:n}),e.collection&&(r.collection=e.collection),r}function h2e(e){if(e.version!==P1)throw Error(`This theme file uses an unsupported version. Expected ${P1}.`);let t=e.name,n=e.appearance;if(!R1(t))throw Error(`Theme files need a name (48 characters or fewer).`);if(!I1(n))throw Error(`Theme files need an appearance of "light" or "dark".`);let r=e.id===void 0?u2e(t):e.id;if(!L1(r))throw Error(`Theme ids may only contain lowercase letters, numbers, and hyphens.`);if(M1.has(r))throw Error(`The theme id "${r}" is reserved.`);let i=z1(e.collection);if(e.collection!==void 0&&!i)throw Error(`Theme collections need a valid id and label.`);return{id:r,name:t.trim(),appearance:n,collection:i}}function g2e(e,t){if(e.variants===void 0)return{};if(!F1(e.variants))throw Error(`Theme variants must be an object.`);for(let[n,r]of Object.entries(e.variants)){if(!I1(n))throw Error(`Theme variants may only be named "light" or "dark".`);if(n===t)throw Error(`Theme variants must not repeat the base appearance "${t}".`);if(!F1(r))throw Error(`Theme variants must be objects.`);return B1(r)}return{}}function _2e(e){if(!F1(e))throw Error(`Theme files must contain a JSON object.`);let{id:t,name:n,appearance:r,collection:i}=h2e(e);if(!F1(e.colors))throw Error(`Theme files need a colors object.`);let a=B1(e.colors),o=g2e(e,r);return{id:t,name:n,description:typeof e.description==`string`?e.description:``,appearance:r,light:r===`light`?a:o,dark:r===`dark`?a:o,...i?{collection:i}:{}}}function v2e(e){let t=U1(e),n=t.appearance===`light`?t.light:t.dark,r=t.appearance===`light`?t.dark:t.light,i={version:P1,id:t.id,name:t.name,appearance:t.appearance,colors:n,...Object.keys(r).length>0?{variants:t.appearance===`light`?{dark:r}:{light:r}}:{},...t.collection?{collection:t.collection}:{}};return`${JSON.stringify(i,null,2)}\n`}var G1=`forge:custom-themes:v1`,K1=null,q1=new Set;function y2e(){if(typeof window>`u`)return{status:`ready`,storedThemes:[],themes:[]};let e;try{e=window.localStorage.getItem(G1)}catch(e){return{status:`unavailable`,reason:`storage-unavailable`,cause:e}}if(!e)return{status:`ready`,storedThemes:[],themes:[]};let t;try{t=JSON.parse(e)}catch{return{status:`unavailable`,reason:`malformed`}}return Array.isArray(t)?{status:`ready`,storedThemes:t,themes:m2e(t)}:{status:`unavailable`,reason:`malformed`}}function J1(){return K1===null&&(K1=y2e()),K1}function Y1(){for(let e of q1)e()}function b2e(){K1=null,Y1()}var x2e=[];function X1(){let e=J1();return e.status===`ready`?e.themes:x2e}function Z1(e){return X1().find(t=>t.id===e)}function S2e(e){if(q1.add(e),typeof window>`u`)return()=>q1.delete(e);let t=e=>{(e.key===`forge:custom-themes:v1`||e.key===null)&&b2e()};return window.addEventListener(`storage`,t),()=>{q1.delete(e),window.removeEventListener(`storage`,t)}}var Q1=class extends Error{storageKey;operation;reason;constructor(e){let t=e.operation===`read`?`from`:`to`;super(`Failed to ${e.operation} the theme library ${t} ${e.storageKey}.`),this.name=`ThemeLibraryStorageError`,this.storageKey=e.storageKey,this.operation=e.operation,this.reason=e.reason,e.cause!==void 0&&(this.cause=e.cause)}};function $1(){let e=J1();if(e.status===`unavailable`)throw new Q1({storageKey:G1,operation:`read`,reason:e.reason,cause:`cause`in e?e.cause:void 0});return e}function e0(e,t){if(!(typeof window>`u`)){try{window.localStorage.setItem(G1,JSON.stringify(e)),K1={status:`ready`,storedThemes:e,themes:t}}catch(e){throw new Q1({storageKey:G1,operation:`write`,reason:`storage-unavailable`,cause:e})}Y1()}}function t0(e,t){return F1(e)&&e.id===t}function C2e(e){if(M1.has(e.id))throw Error(`The theme id "${e.id}" is reserved.`);let t=$1();if(j1.has(e.id)||t.storedThemes.some(t=>t0(t,e.id)))throw Error(`A theme named "${e.name}" is already installed.`);let n=U1(e),r=[...t.themes,n];return e0([...t.storedThemes,W1(n)],r),n}function w2e(e){if(M1.has(e.id))throw Error(`The theme id "${e.id}" is reserved.`);let t=$1(),n=t.themes.findIndex(t=>t.id===e.id);if(n===-1)throw Error(`The theme "${e.name}" is not installed.`);let r=U1(e),i=[...t.themes];i[n]=r;let a=[],o=!1;for(let n of t.storedThemes)t0(n,e.id)?o||=(a.push(W1(r)),!0):a.push(n);return e0(a,i),r}function T2e(e){E2e([e])}function E2e(e){let t=new Set(e);if(t.size===0)return;let n=$1(),r=n.themes.filter(e=>!t.has(e.id));r.length!==n.themes.length&&e0(n.storedThemes.filter(e=>!F1(e)||typeof e.id!=`string`||!t.has(e.id)),r)}function D2e(e){return j1.has(e)?!0:Z1(e)!==void 0}function O2e(e){if(!e)return null;try{let t=JSON.parse(e);if(!F1(t))return null;let n={};for(let e of[`light`,`dark`]){let r=t[e];typeof r==`string`&&D2e(r)&&(n[e]=r)}return n.light!==void 0||n.dark!==void 0?n:null}catch{return null}}function k2e(e,t,n){return t?.[n]??e}var n0=`themeId`,r0=`forge:theme-boot:v1`;function A2e(e,t){try{window.localStorage.setItem(r0,JSON.stringify({appearance:t,background:e}))}catch{}}function j2e(){try{window.localStorage.removeItem(r0)}catch{}}function i0(){return typeof document>`u`?null:document.documentElement}function a0(){let e=i0();if(e!==null){for(let t of vt)e.style.removeProperty(Ot[t]);delete e.dataset[n0],j2e()}}function M2e(e,t){let n=i0();if(n===null)return;let r=t===`dark`?e.dark:e.light;for(let e of vt){let t=r[e];if(t===void 0){n.style.removeProperty(Ot[e]);continue}n.style.setProperty(Ot[e],t)}n.dataset[n0]=e.id,r.background!==void 0&&A2e(r.background,t)}function N2e(e,t){if(e===`forge`){a0();return}let n=Hte(e)??Z1(e);if(n===void 0){a0();return}M2e(n,t)}function o0(){let e=(0,hi.c)(2),[t,n]=(0,M.useState)(P2e),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>(n(X1()),S2e(()=>{n(X1())})),i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,M.useEffect)(r,i),t}function P2e(){return X1()}function s0(){return typeof window<`u`&&typeof localStorage<`u`}function F2e(){if(!s0())return{};try{let e=JSON.parse(window.localStorage.getItem(`forge:theme-halves:v1`)??`null`);if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={};for(let n of[`light`,`dark`]){let r=e[n];typeof r==`string`&&(t[n]=r)}return t}catch{return{}}}function I2e(){if(!s0())return null;try{return O2e(window.localStorage.getItem(N1))}catch{return null}}function c0(e){if(s0())try{e===null||e.light===void 0&&e.dark===void 0?window.localStorage.removeItem(N1):window.localStorage.setItem(N1,JSON.stringify(e))}catch{}}function L2e(e,t,n){let r={...e};return n===null?delete r[t]:r[t]=n,r}function R2e(e){return e!==null&&(e.light!==void 0||e.dark!==void 0)?e:null}function z2e(e,t){let n=(0,hi.c)(13),[r,i]=(0,M.useState)(B2e),a=o0(),o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(e,t)=>{let n=L2e(F2e(),e,t);return c0(n),i(R2e(n)),!0},n[0]=o):o=n[0];let s=o,c;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>(c0(null),i(null),!0),n[1]=c):c=n[1];let l=c,u;n[2]!==t||n[3]!==r||n[4]!==e?(u=()=>{let n=t===`dark`?`dark`:`light`;N2e(k2e(e,r,n),n)},n[2]=t,n[3]=r,n[4]=e,n[5]=u):u=n[5];let d;n[6]!==a||n[7]!==t||n[8]!==r||n[9]!==e?(d=[e,t,r,a],n[6]=a,n[7]=t,n[8]=r,n[9]=e,n[10]=d):d=n[10],(0,M.useEffect)(u,d);let f;return n[11]===r?f=n[12]:(f={themeHalves:r,setThemeHalf:s,clearThemeHalves:l},n[11]=r,n[12]=f),f}function B2e(){return I2e()}var l0=`theme-color`,V2e=`meta[name="${l0}"][data-dynamic-theme-color="true"]`,H2e={dark:`#0a0a0a`,light:`#ffffff`};function U2e(){let e=document.querySelector(V2e);return e||(e=document.createElement(`meta`),e.name=l0,e.setAttribute(`data-dynamic-theme-color`,`true`),document.head.append(e),e)}function u0(e){let t=e?.trim().toLowerCase();return!t||t===`transparent`||t===`rgba(0, 0, 0, 0)`||t===`rgba(0 0 0 / 0)`?null:e?.trim()??null}function W2e(){return document.querySelector(`main[data-slot='sidebar-inset']`)??document.querySelector(`[data-slot='sidebar-inner']`)??document.body}function G2e(){return document.documentElement.classList.contains(`dark`)?`dark`:`light`}function d0(e=G2e()){if(typeof document>`u`||typeof getComputedStyle>`u`)return;document.documentElement.style.backgroundColor=``,document.body.style.backgroundColor=``;let t=u0(getComputedStyle(W2e()).backgroundColor),n=u0(getComputedStyle(document.body).backgroundColor),r=t??n??H2e[e];document.documentElement.style.backgroundColor=r,document.body.style.backgroundColor=r,U2e().setAttribute(`content`,r)}function f0(e,t){if(!Se(e)||!Se(t))return t;let n={...e};for(let[e,r]of Object.entries(t)){if(r===void 0)continue;let t=n[e];n[e]=Se(t)&&Se(r)?f0(t,r):r}return n}var p0=`[CLIENT_SETTINGS]`,m0=new Set,h0=Bt,g0=!1,_0=null;function K2e(){for(let e of m0)e()}function v0(){return h0}function y0(e){h0=e,K2e()}function q2e(e){return m0.add(e),J2e(),()=>{m0.delete(e)}}async function J2e(){if(g0)return;if(_0)return _0;let e=(async()=>{try{let e=await qi();e&&y0(e)}catch(e){console.error(`${p0} hydrate failed`,e)}finally{g0=!0}})().finally(()=>{_0===e&&(_0=null)});return _0=e,_0}function Y2e(e){y0(e),Ji(e).catch(e=>{console.error(`${p0} persist failed`,e)})}var X2e=new Set(Dte(Kte.fields));function Z2e(e){let t={},n={};for(let[r,i]of Object.entries(e))X2e.has(r)?t[r]=i:n[r]=i;return{serverPatch:t,clientPatch:n}}function b0(e){let t=$Q(),n=(0,M.useSyncExternalStore)(q2e,v0,()=>Bt),r=(0,M.useMemo)(()=>({...t,...n}),[n,t]);return(0,M.useMemo)(()=>e?e(r):r,[r,e])}function x0(){let e=(0,hi.c)(2),t=Q2e,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{t(dte)},e[0]=n):n=e[0];let r=n,i;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={updateSettings:t,resetSettings:r},e[1]=i):i=e[1],i}function Q2e(e){let{serverPatch:t,clientPatch:n}=Z2e(e);if(Object.keys(t).length>0){let e=WQ();e&&qQ(f0(e.settings,t)),_Q().client.server.updateSettings(t)}Object.keys(n).length>0&&Y2e({...v0(),...n})}var $2e=`forge:theme`,S0=`(prefers-color-scheme: dark)`;function C0(e){return e===`system`||e===`light`||e===`dark`}function w0(e,t){return typeof e!=`number`||!Number.isFinite(e)?t:Math.min(20,Math.max(11,Math.round(e)))}function e4e(){if(!s0())return{theme:`system`,uiFontSize:16,codeFontSize:13};try{let e=window.localStorage.getItem(zi);if(e){let t=Hi(JSON.parse(e));return{theme:C0(t.theme)?t.theme:`system`,uiFontSize:w0(t.uiFontSize,16),codeFontSize:w0(t.codeFontSize,13)}}let t=window.localStorage.getItem($2e);return{theme:C0(t)?t:`system`,uiFontSize:16,codeFontSize:13}}catch{return{theme:`system`,uiFontSize:16,codeFontSize:13}}}function t4e(){return typeof window>`u`||typeof window.matchMedia!=`function`||window.matchMedia(S0).matches?`dark`:`light`}function T0(e){return e===`system`?t4e():e}function n4e(e){if(typeof window>`u`)return;let t=window.desktopBridge;t&&t.setTheme(e).catch(()=>{})}function E0(e,t=!1){let n=T0(e);return typeof document>`u`||typeof window>`u`?n:(t&&document.documentElement.classList.add(`no-transitions`),document.documentElement.classList.toggle(`dark`,n===`dark`),document.documentElement.dataset.theme=e,document.documentElement.style.colorScheme=n,d0(n),n4e(e),t&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove(`no-transitions`)})),n)}function D0(e){typeof document>`u`||document.documentElement.style.setProperty(`--forge-ui-font-size`,`${w0(e,16)}px`)}function O0(e){typeof document>`u`||document.documentElement.style.setProperty(`--forge-code-font-size`,`${w0(e,13)}px`)}function k0(e){D0(e.uiFontSize),O0(e.codeFontSize)}if(typeof document<`u`){let e=e4e();E0(e.theme),k0(e)}function r4e(){let e=(0,hi.c)(33),t=b0(s4e),n=b0(o4e),r=b0(a4e),i=b0(i4e),{updateSettings:a}=x0(),o;e[0]===t?o=e[1]:(o=()=>T0(t),e[0]=t,e[1]=o);let[s,c]=(0,M.useState)(o),{themeHalves:l,setThemeHalf:u,clearThemeHalves:d}=z2e(n,s),f;e[2]===a?f=e[3]:(f=e=>{a({theme:e}),c(E0(e,!0))},e[2]=a,e[3]=f);let p=f,m;e[4]===a?m=e[5]:(m=e=>{a({themeId:e})},e[4]=a,e[5]=m);let h=m,g;e[6]===a?g=e[7]:(g=e=>{let t=w0(e,16);a({uiFontSize:t}),D0(t)},e[6]=a,e[7]=g);let _=g,v;e[8]===a?v=e[9]:(v=e=>{let t=w0(e,13);a({codeFontSize:t}),O0(t)},e[8]=a,e[9]=v);let y=v,b,x;e[10]===t?(b=e[11],x=e[12]):(b=()=>{c(E0(t))},x=[t],e[10]=t,e[11]=b,e[12]=x),(0,M.useEffect)(b,x);let S,C;e[13]!==i||e[14]!==r?(S=()=>{k0({uiFontSize:r,codeFontSize:i})},C=[r,i],e[13]=i,e[14]=r,e[15]=S,e[16]=C):(S=e[15],C=e[16]),(0,M.useEffect)(S,C);let w,T;e[17]===t?(w=e[18],T=e[19]):(T=()=>{if(t!==`system`||typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(S0),n=()=>{c(E0(`system`,!0))};return e.addEventListener(`change`,n),()=>{e.removeEventListener(`change`,n)}},w=[t],e[17]=t,e[18]=w,e[19]=T),(0,M.useEffect)(T,w);let E;return e[20]!==d||e[21]!==i||e[22]!==s||e[23]!==y||e[24]!==p||e[25]!==u||e[26]!==h||e[27]!==_||e[28]!==t||e[29]!==l||e[30]!==n||e[31]!==r?(E={theme:t,setTheme:p,themeId:n,setThemeId:h,resolvedTheme:s,themeHalves:l,setThemeHalf:u,clearThemeHalves:d,uiFontSize:r,codeFontSize:i,setUiFontSize:_,setCodeFontSize:y},e[20]=d,e[21]=i,e[22]=s,e[23]=y,e[24]=p,e[25]=u,e[26]=h,e[27]=_,e[28]=t,e[29]=l,e[30]=n,e[31]=r,e[32]=E):E=e[32],E}function i4e(e){return e.codeFontSize}function a4e(e){return e.uiFontSize}function o4e(e){return e.themeId}function s4e(e){return e.theme}function c4e(){let e=(0,hi.c)(11),t=b0(_4e),n=b0(g4e),r=b0(h4e),i=b0(m4e),a=b0(p4e),o=b0(f4e),s=b0(d4e),c=b0(u4e),l=b0(l4e),u,d;e[0]!==t||e[1]!==r||e[2]!==i||e[3]!==n||e[4]!==a||e[5]!==c||e[6]!==l||e[7]!==o||e[8]!==s?(u=()=>{typeof document>`u`||r0e(document.documentElement,{appearanceContrast:t,fontFamilyCode:r,fontFamilyComposer:i,fontFamilySans:n,fontFamilyTerminal:a,fontSmoothing:c,glassOpacity:l,promptFontSize:o,terminalFontSize:s})},d=[t,r,i,n,a,c,l,o,s],e[0]=t,e[1]=r,e[2]=i,e[3]=n,e[4]=a,e[5]=c,e[6]=l,e[7]=o,e[8]=s,e[9]=u,e[10]=d):(u=e[9],d=e[10]),(0,M.useEffect)(u,d)}function l4e(e){return e.glassOpacity}function u4e(e){return e.fontSmoothing}function d4e(e){return e.terminalFontSize}function f4e(e){return e.promptFontSize}function p4e(e){return e.fontFamilyTerminal}function m4e(e){return e.fontFamilyComposer}function h4e(e){return e.fontFamilyCode}function g4e(e){return e.fontFamilySans}function _4e(e){return e.appearanceContrast}function v4e(e,t){let n={hour:`numeric`,minute:`2-digit`,...t?{second:`2-digit`}:{}};return e===`locale`?n:{...n,hour12:e===`12-hour`}}var A0=new Map;function j0(e,t){let n=`${e}:${t?`seconds`:`minutes`}`,r=A0.get(n);if(r)return r;let i=new Intl.DateTimeFormat(void 0,v4e(e,t));return A0.set(n,i),i}function y4e(e,t){return j0(t,!0).format(new Date(e))}function b4e(e,t){return j0(t,!1).format(new Date(e))}function M0(e){let t=Date.now()-new Date(e).getTime();if(t<0)return{value:`just now`,suffix:null};let n=Math.floor(t/1e3);if(n<60)return{value:`just now`,suffix:null};let r=Math.floor(n/60);if(r<60)return{value:`${r}m`,suffix:`ago`};let i=Math.floor(r/60);return i<24?{value:`${i}h`,suffix:`ago`}:{value:`${Math.floor(i/24)}d`,suffix:`ago`}}function x4e(e){let t=M0(e);return t.suffix?`${t.value} ${t.suffix}`:t.value}var S4e=new Set([`tool.started`,`task.started`,`context-window.updated`,`text-generation.usage`,`worktree.stage`,`launch.agent-starting`,`turn.terminal-status`]);function N0(e){return S4e.has(e.kind)||e.summary===`Checkpoint captured`}function P0(e){let t=I0(e?.data),n=I0(t?.item),r=I0(n?.result),i=I0(n?.input),a=L0(e?.itemType),o=L0(e?.detail),s=[e?.command,n?.command,i?.command,r?.command,t?.command,a===`command_execution`&&o?F0(o).output:null];for(let e of s){let t=A4e(e);if(t)return{command:t,rawCommand:j4e(e,t)}}return{command:null,rawCommand:null}}function F0(e){let t=e.trim(),n=/^(?<output>[\s\S]*?)(?:\s*<exited with exit code (?<code>\d+)>)\s*$/i.exec(t);if(!n?.groups)return{output:t.length>0?t:null};let r=Number.parseInt(n.groups.code??``,10),i=n.groups.output?.trim()??``;return{output:i.length>0?i:null,...Number.isInteger(r)?{exitCode:r}:{}}}function I0(e){return e&&typeof e==`object`?e:null}function L0(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function R0(e){let t=e.trim();if(t.startsWith(`'`)&&t.endsWith(`'`)||t.startsWith(`"`)&&t.endsWith(`"`)){let e=t.slice(1,-1).trim();return e.length>0?e:t}return t}function C4e(e){let t=R0(e);if(t.length===0)return null;let n=t.replace(/\\/g,`/`).split(`/`).at(-1)?.trim()??``;return n.length>0?n.toLowerCase():null}function w4e(e){let t=e.trim();if(t.length===0)return null;if(t.startsWith(`"`)||t.startsWith(`'`)){let e=t.charAt(0),n=t.indexOf(e,1);return n<=0?null:{executable:t.slice(0,n+1),rest:t.slice(n+1).trim()}}let n=t.search(/\s/);return n<0?{executable:t,rest:``}:{executable:t.slice(0,n),rest:t.slice(n).trim()}}var T4e=[{executables:[`pwsh`,`pwsh.exe`,`powershell`,`powershell.exe`],wrapperFlagPattern:/(?:^|\s)-command\s+/i},{executables:[`cmd`,`cmd.exe`],wrapperFlagPattern:/(?:^|\s)\/c\s+/i},{executables:[`bash`,`sh`,`zsh`],wrapperFlagPattern:/(?:^|\s)-(?:l)?c\s+/i}];function E4e(e){return T4e.find(t=>t.executables.includes(e))}function D4e(e,t){let n=t.exec(e);if(!n)return null;let r=e.slice(n.index+n[0].length).trim();if(r.length===0)return null;let i=r[0];if((i===`'`||i===`"`)&&!r.endsWith(i))return null;let a=R0(r);return a.length>0?a:null}function O4e(e){let t=w4e(e);if(!t||t.rest.length===0)return e;let n=C4e(t.executable);if(!n)return e;let r=E4e(n);return r?D4e(t.rest,r.wrapperFlagPattern)??e:e}function k4e(e){return/[\s"'`]/.test(e)?`"${e.replace(/"/g,`\\"`)}"`:e}function z0(e){let t=L0(e);if(t)return t;if(!Array.isArray(e))return null;let n=[];for(let t of e){let e=L0(t);e!==null&&n.push(e)}return n.length===0?null:n.map(e=>k4e(e)).join(` `)}function A4e(e){let t=z0(e);return t?O4e(t):null}function j4e(e,t){let n=z0(e);return!n||t===null||n===t?null:n}function B0(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function V0(e){return typeof e==`string`&&e.trim().length>0?e:null}function M4e(e){let t=V0(e);if(t)return t;let n=Array.isArray(e)?e:null,r=B0(e)?.content,i=V0(r);if(i)return i;let a=n??(Array.isArray(r)?r:null);if(!a)return null;let o=a.flatMap(e=>{let t=V0(e)??V0(B0(e)?.text);return t?[t]:[]});return o.length>0?o.join(`
1025
1025
  `):null}function N4e(e){let t=B0(e),n=B0(t?.item),r=B0(n?.result),i=B0(t?.rawOutput),a=[V0(i?.stdout),V0(i?.stderr)].filter(e=>e!==null),o=Array.isArray(t?.content)?t.content.flatMap(e=>{let t=B0(e),n=B0(t?.content),r=t?.type===`content`?V0(n?.text):null;return r?[r]:[]}).join(`
1026
1026
  `):null,s=[n?.aggregatedOutput,r?.content,t?.rawOutput,i?.content,a.length>0?a.join(`
1027
1027
  `):null,i?.output,o,t?.result];for(let e of s){let t=M4e(e);if(t)return t}return null}function H0(e,t){let n=e.endsWith(`...`)?e.slice(0,-3):e.endsWith(`…`)?e.slice(0,-1):null;return t.some(t=>{let r=t?.trim();return r?r===e||n!==null&&n.length>0&&r.length>n.length&&r.startsWith(n):!1})}function P4e(e){let t=V0(e.toolName)?.trim(),n=e.detail.trim(),r=[e.command,e.rawCommand];if(t){let e=`${t}:`;if(n.toLowerCase().startsWith(e.toLowerCase())&&H0(n.slice(e.length).trim(),r))return!0}if(!H0(n,r))return!1;let i=B0(e.data),a=B0(i?.item),o=B0(a?.input),s=B0(a?.result);return![a?.command,o?.command,s?.command,i?.command].some(e=>Array.isArray(e)?e.some(e=>V0(e)!==null):V0(e)!==null)||a!==null||i?.toolCallId!==void 0||V0(i?.kind)?.toLowerCase()===`execute`}function F4e(e){return e.kind===`runtime.warning`&&e.summary.endsWith(`(no displayable text content)`)}function I4e(e,t){let n=Y0(e?.message);return n&&G0(n)!==G0(t)?n:null}function U0(e){if(typeof e?.itemType==`string`&&yte(e.itemType))return e.itemType}function W0(e){return e.replace(/\s+/g,` `).trim()}function L4e(e,t=84){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`}function G0(e){let t=Y0(e);return t?q0(W0(t)).toLowerCase():null}function K0(e){let t=[];for(let n of e.split(/\r?\n/u)){let e=W0(n);e.length>0&&t.push(e)}let n=t.find(e=>e!=="```");return n?L4e(n):t.length>1?`${t.length.toLocaleString()} lines`:null}function R4e(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function z4e(e){let t=J0(J0(e?.data)?.rawOutput);if(!t)return null;let n=R4e(t.totalFiles);if(n!==null){let e=t.truncated===!0?`+`:``;return`${n.toLocaleString()} file${n===1?``:`s`}${e}`}let r=Y0(t.content);if(r)return K0(r);let i=Y0(t.stdout);return i?K0(i):null}function B4e(e){let t=N4e(e?.data);return t?F0(t).output:null}function V4e(e,t){let n=Y0(J0(e?.data)?.kind)?.toLowerCase(),r=Y0(e?.title??t)?.toLowerCase();return U0(e)===`command_execution`||n===`execute`||r===`terminal`||r===`ran command`}function H4e(e,t){let n=Y0(e?.detail),r=n?F0(n).output:null,i=G0(t),a=G0(r),o=V4e(e,t),s=o?P0(e):{command:null,rawCommand:null},c=s.command;if(o&&c){let t=B4e(e);if(t)return t}let l=J0(e?.data),u=r!==null&&P4e({detail:r,command:c,rawCommand:s.rawCommand,toolName:l?.toolName,data:l});if(r&&i!==a&&(!o||!u))return r;if(o)return null;let d=z4e(e);return d&&G0(d)!==i?d:null}function q0(e){return e.replace(/\s+(?:complete|completed)\s*$/i,``).trim()}function J0(e){return e&&typeof e==`object`?e:null}function Y0(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function U4e(e,t){return!t.latestTurnId||e.turnId===t.latestTurnId||W4e(e)?!0:G4e(e,t.latestTurnStartedAt)}function W4e(e){return e.kind.startsWith(`worktree.`)||e.kind.startsWith(`setup-script.`)}function G4e(e,t){return e.turnId!==null||e.tone!==`error`||t===null?!1:e.createdAt>=t}function X0(e){let t=e.payload&&typeof e.payload==`object`?e.payload:null,n=t?.plan;if(!Array.isArray(n))return null;let r=[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=e;if(typeof t.step!=`string`)continue;let n=t.status===`completed`||t.status===`inProgress`?t.status:`pending`;r.push({step:t.step,status:n})}return r.length===0?null:{createdAt:e.createdAt,turnId:e.turnId,...t&&`explanation`in t?{explanation:t.explanation}:{},steps:r}}function Z0(e){let t=new Map;return e.map(e=>{let n=t.get(e.step)??0;return t.set(e.step,n+1),{key:`${e.step}:${n}`,step:e}})}function K4e(e,t){let n=new Map,r;for(let e of t){let t=X0(e),i=Date.parse(e.createdAt);if(!(!t||Number.isNaN(i))){r??=i;for(let{key:e,step:r}of Z0(t.steps)){let t=n.get(e)??{};r.status===`inProgress`&&t.startedAt===void 0&&(t.startedAt=i),r.status===`completed`&&t.completedAt===void 0&&(t.completedAt=i),n.set(e,t)}}}let i=new Map,a=r;for(let[e,t]of[...n.entries()].toSorted((e,t)=>(e[1].completedAt??1/0)-(t[1].completedAt??1/0))){let n=t.completedAt,r=t.startedAt??a;n!==void 0&&(r!==void 0&&n>r&&i.set(e,n-r),a=n)}return{...e,steps:Z0(e.steps).map(({key:e,step:t})=>{if(t.status!==`completed`)return t;let n=i.get(e);return n===void 0?t:Object.assign({},t,{durationMs:n})})}}var q4e=[{value:`codex`,label:`Codex`,available:!0},{value:`claudeAgent`,label:`Claude`,available:!0},{value:`cmmd`,label:`CMMD`,available:!0},{value:`ollama`,label:`Ollama`,available:!1},{value:`cursor`,label:`Cursor`,available:!1}];function J4e(e){if(!Number.isFinite(e)||e<0)return`0ms`;if(e<1e3)return`${Math.max(1,Math.round(e))}ms`;if(e<1e4)return`${(e/1e3).toFixed(1)}s`;if(e<6e4)return`${Math.round(e/1e3)}s`;let t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return n===0?`${t}m`:n===60?`${t+1}m`:`${t}m ${n}s`}function Y4e(e,t){if(!t)return null;let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)||r<n?null:J4e(r-n)}function Q0(e,t){return!e?.startedAt||!e.completedAt?!1:!t||t.orchestrationStatus!==`running`}function X4e(e,t,n){let r=t?.orchestrationStatus===`running`?t.activeTurnId??null:null;return r===null?Q0(e,t)?n:e?.startedAt??n:e?.turnId===r?e.startedAt??n:n}function $0(e){switch(e){case`command_execution_approval`:case`exec_command_approval`:return`command`;case`file_read_approval`:return`file-read`;case`file_change_approval`:case`apply_patch_approval`:return`file-change`;default:return null}}function e2(e){let t=e?.toLowerCase();return t?t.includes(`stale pending approval request`)||t.includes(`stale pending user-input request`)||t.includes(`unknown pending approval request`)||t.includes(`unknown pending permission request`)||t.includes(`unknown pending user-input request`):!1}function Z4e(e){let t=new Map,n=[...e].toSorted(h2);for(let e of n){let n=e.payload&&typeof e.payload==`object`?e.payload:null,r=n&&typeof n.requestId==`string`?Nt.make(n.requestId):null,i=n&&(n.requestKind===`command`||n.requestKind===`file-read`||n.requestKind===`file-change`)?n.requestKind:n?$0(n.requestType):null,a=n&&typeof n.detail==`string`?n.detail:void 0;if(e.kind===`approval.requested`&&r&&i){t.set(r,{requestId:r,requestKind:i,createdAt:e.createdAt,...a?{detail:a}:{}});continue}if(e.kind===`approval.resolved`&&r){t.delete(r);continue}if(e.kind===`provider.approval.respond.failed`&&r&&e2(a)){t.delete(r);continue}}return[...t.values()].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}function Q4e(e){let t=e?.questions;if(!Array.isArray(t))return null;let n=t.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.id!=`string`||typeof t.header!=`string`||typeof t.question!=`string`||!Array.isArray(t.options))return null;let n=t.options.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;return typeof t.label!=`string`||typeof t.description!=`string`?null:{label:t.label,description:t.description}}).filter(e=>e!==null);return n.length===0?null:{id:t.id,header:t.header,question:t.question,options:n,multiSelect:t.multiSelect===!0}}).filter(e=>e!==null);return n.length>0?n:null}function $4e(e){let t=new Map,n=[...e].toSorted(h2);for(let e of n){let n=e.payload&&typeof e.payload==`object`?e.payload:null,r=n&&typeof n.requestId==`string`?Nt.make(n.requestId):null,i=n&&typeof n.detail==`string`?n.detail:void 0;if(e.kind===`user-input.requested`&&r){let i=Q4e(n);if(!i)continue;t.set(r,{requestId:r,createdAt:e.createdAt,questions:i});continue}if(e.kind===`user-input.resolved`&&r){t.delete(r);continue}e.kind===`provider.user-input.respond.failed`&&r&&e2(i)&&t.delete(r)}return[...t.values()].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}function e3e(e,t){if(!t)return null;let n=[...e].toSorted(h2),r=null;for(let e of n){let t=n2(e.payload&&typeof e.payload==`object`?e.payload:null);t&&(r={request:t,turnId:e.turnId})}return!r||r.turnId!==t?null:r.request}function t3e(e,t){let n=[...e].toSorted(h2),r=n.filter(e=>e.kind===`turn.plan.updated`),i=(t?r.findLast(e=>e.turnId===t):void 0)??r.at(-1)??null;if(!i)return null;let a=X0(i);if(!a)return null;let o=r.filter(e=>e.turnId===i.turnId),s=o.findLastIndex(e=>X0(e)===null),c=K4e(a,o.slice(s+1)),l=i.turnId!==null&&n.some(e=>e.kind===`turn.completed`&&e.turnId===i.turnId&&h2(i,e)<0);return{...c,steps:l?c.steps.map(e=>e.status===`inProgress`?{...e,status:`completed`}:e):c.steps}}function t2(e,t){if(t){let n=[...e].filter(e=>e.turnId===t).toSorted((e,t)=>e.updatedAt.localeCompare(t.updatedAt)||e.id.localeCompare(t.id)).at(-1);if(n)return l2(n)}let n=[...e].toSorted((e,t)=>e.updatedAt.localeCompare(t.updatedAt)||e.id.localeCompare(t.id)).at(-1);return n?l2(n):null}function n3e(e){let t=e.threads.find(t=>t.id===e.threadId)?.proposedPlans??[];if(!e.latestTurnSettled){let t=e.latestTurn?.sourceProposedPlan;if(t){let n=e.threads.find(e=>e.id===t.threadId)?.proposedPlans.find(e=>e.id===t.planId);if(n)return l2(n)}}return t2(t,e.latestTurn?.turnId??null)}function r3e(e){return e!==null&&e.implementedAt===null}function i3e(e,t,n){let r=a3e(),i={latestTurnId:t,latestTurnStartedAt:n??null};return p3e([...e].toSorted(h2).filter(e=>U4e(e,i)).filter(e=>!N0(e)).filter(e=>r||!F4e(e)).filter(e=>!o3e(e)).map(s3e)).map(({activityKind:e,collapseKey:t,...n})=>n)}function a3e(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`forge:debug-mode`)===`true`}catch{return!1}}function o3e(e){if(e.kind!==`tool.updated`&&e.kind!==`tool.completed`)return!1;let t=e.payload&&typeof e.payload==`object`?e.payload:null;return typeof t?.detail==`string`&&t.detail.startsWith(`ExitPlanMode:`)}function s3e(e){let t=e.payload&&typeof e.payload==`object`?e.payload:null,n=P0(t),r=S3e(t),i=v3e(t),a=e.kind===`task.progress`||e.kind===`task.completed`,o=a&&typeof t?.summary==`string`&&t.summary.length>0?t.summary:null,s=a&&!o&&typeof t?.detail==`string`&&t.detail.length>0?t.detail:null,c=o||s,l={id:e.id,createdAt:e.createdAt,label:c||e.summary,tone:e.kind===`task.progress`?`thinking`:e.tone,activityKind:e.kind},u=U0(t),d=x3e(t),f=a?!s&&t&&typeof t.detail==`string`&&t.detail.length>0?F0(t.detail).output:null:H4e(t,i??e.summary);if(f)l.detail=f;else if(e.kind===`runtime.error`||e.kind===`runtime.warning`){let n=I4e(t,e.summary);n&&(l.detail=n)}n.command&&(l.command=n.command),n.rawCommand&&(l.rawCommand=n.rawCommand),r.length>0&&(l.changedFiles=r),i&&(l.toolTitle=i),u&&(l.itemType=u),d&&(l.requestKind=d);let p=c3e(t);if(p)l.githubConfirmation=p,l.tone=`approval`,l.label=`GitHub action needs approval`,l.toolTitle=i2(p.operation),l.detail=a2(p);else{let e=n2(t);e&&(l.githubActionRequired=e,l.tone=`approval`,l.label=o2(e.action),l.toolTitle=`GitHub setup required`,l.detail=c2(e))}let m=_3e(l);return m&&(l.collapseKey=m),l}function c3e(e){for(let t of r2(e)){if(t.userActionRequired!==`confirm_github_tool`)continue;let e=u2(t.confirmation),n=u2(e?.request),r=d2(e?.confirmationId),i=d2(e?.toolName),a=d2(e?.operation);if(!(!r||!i||!a||!n))return{confirmationId:r,toolName:i,operation:a,request:n}}return null}function n2(e){let t=r2(e)[0];if(!t)return null;let n=d2(t.userActionRequired);return!n||n===`confirm_github_tool`?null:{action:n,toolName:d2(t.toolName),message:d2(t.error)??d2(t.message)}}function r2(e){if(!e)return[];let t=[],n=new Set,r=(e,i)=>{if(i>8||e==null)return;if(typeof e==`string`){let n=d2(e);if(!n)return;let r=l3e(n);r&&d2(r.userActionRequired)&&t.push(r);return}if(typeof e!=`object`||n.has(e))return;if(n.add(e),Array.isArray(e)){for(let t of e)r(t,i+1);return}let a=e;if(d2(a.userActionRequired)){t.push(a);return}for(let e of Object.values(a))r(e,i+1)};return r(e,0),t}function l3e(e){try{return u2(JSON.parse(e))}catch{return null}}function i2(e){switch(e){case`create_repository`:return`Create GitHub repository`;case`link_project_repository`:return`Link project repository`;case`push_branch`:return`Push Git branch`;case`create_pull_request`:return`Create pull request`;case`rerun_workflow`:return`Rerun GitHub Actions workflow`;default:return e.split(`_`).filter(Boolean).map(e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`).join(` `)}}function a2(e){return[d2(e.request.repoFullName)??(d2(e.request.owner)&&d2(e.request.name)?`${d2(e.request.owner)}/${d2(e.request.name)}`:null),d2(e.request.cwd),d2(e.request.branch),d2(e.request.title)].filter(Boolean).join(` - `)}function o2(e){switch(e){case`connect_github`:return`Connect GitHub to continue`;case`connect_cmmd`:return`Forge couldn't authorize this action`;case`start_from_authenticated_forge_session`:return`Open this thread in Forge`;case`link_project_repository`:return`Link this project to GitHub`;case`create_branch`:return`Create a branch before pushing`;case`retry_in_user_vm`:return`Retry in the project VM`;default:return e.split(`_`).filter(Boolean).map(e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`).join(` `)}}function s2(e){switch(e){case`connect_github`:return`Connect GitHub so agents can create repos, push branches, and open PRs.`;case`connect_cmmd`:return`Reconnect Forge, then retry. Your conversation is preserved.`;case`start_from_authenticated_forge_session`:return`Open it in Forge so this action uses your signed-in account.`;case`link_project_repository`:return`Link a GitHub repo to this project before pushing or opening PRs.`;case`create_branch`:return`Forge needs a branch before it can push to GitHub.`;case`retry_in_user_vm`:return`This has to run from the project's cloud VM.`;default:return`Finish the required setup, then retry.`}}function c2(e){return e.action===`connect_cmmd`?s2(e.action):e.message??s2(e.action)}function u3e(e,t){return e.action===t.action&&e.toolName===t.toolName&&e.message===t.message}function d3e(e){switch(e){case`connect_cmmd`:return`Reconnect Forge`;case`connect_github`:return`Connect GitHub`;default:return`Open Git settings`}}function f3e(e){return[`The required Forge GitHub setup has been completed by the user.`,e.toolName?`Retry the previous GitHub tool request for \`${e.toolName}\`.`:`Retry the previous GitHub tool request.`,`Continue the previous GitHub lifecycle request using Forge brokered GitHub tools only.`,"Do not use shell `gh` or direct GitHub CLI commands."].join(`
@@ -2537,4 +2537,4 @@ XID_Start XIDS`.split(/\s/).map(e=>[b5(e),e])),Zet=new Map([[`s`,U5(383)],[U5(38
2537
2537
  ${e}
2538
2538
  }
2539
2539
  }`}function Xnt(e,t){let n=_9(t);return e.replace(qnt,n)}function Znt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Qnt({code:e,pre:t,columnType:n,rowSpan:r,containerSize:i=!1}={}){return e??(e=document.createElement(`code`),e.setAttribute(`data-code`,``),n!=null&&e.setAttribute(`data-${n}`,``),t?.appendChild(e)),r==null?e.style.removeProperty(`grid-row`):e.style.setProperty(`grid-row`,`span ${r}`),i?e.setAttribute(`data-container-size`,``):e.removeAttribute(`data-container-size`),e}function $nt(e,t){if(t==null)return;let n=e.shadowRoot??e.attachShadow({mode:`open`});n.innerHTML===``&&(n.innerHTML=t)}function ert(e,{type:t,diffIndicators:n,disableBackground:r,disableLineNumbers:i,overflow:a,split:o,totalLines:s,customProperties:c}){if(c!=null)for(let t in c){let n=c[t];n!=null&&e.setAttribute(t,`${n}`)}switch(t===`diff`?(e.setAttribute(`data-diff`,``),e.removeAttribute(`data-file`)):(e.setAttribute(`data-file`,``),e.removeAttribute(`data-diff`)),n){case`bars`:case`classic`:e.setAttribute(`data-indicators`,n);break;case`none`:e.removeAttribute(`data-indicators`)}return i?e.setAttribute(`data-disable-line-numbers`,``):e.removeAttribute(`data-disable-line-numbers`),r?e.removeAttribute(`data-background`):e.setAttribute(`data-background`,``),t===`diff`?e.setAttribute(`data-diff-type`,o?`split`:`single`):e.removeAttribute(`data-diff-type`),e.setAttribute(`data-overflow`,a),e.style.setProperty(`--diffs-min-number-column-width-default`,`${`${s}`.length}ch`),e}function trt(e){if(typeof HTMLStyleElement<`u`&&e instanceof HTMLStyleElement)return!0;let t=e.tagName??e.nodeName;return typeof t==`string`&&t.toLowerCase()===`style`}function nrt(e){return e?.useTokenTransformer===!0||e?.onTokenClick!=null||e?.onTokenEnter!=null||e?.onTokenLeave!=null}function rrt(e,t){let n=e?.offsetHeight??0;if(e==null||n===0){t();return}e.style.minHeight=`${n}px`;try{t(),e.offsetHeight}finally{e.style.minHeight=``}}function irt({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===``){t?.remove();return}return t??=art(),t.textContent=n,t.parentNode!==e&&e.appendChild(t),t}function art(){let e=document.createElement(`style`);return e.setAttribute(A6e,``),e}var ort=void 0;function srt(){return ort??=`safari`in window&&`pushNotification`in window.safari||/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}if(typeof HTMLElement<`u`&&customElements.get(`diffs-container`)==null){let e;class t extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;let t=this.attachShadow({mode:`open`});e??(e=new CSSStyleSheet,e.replaceSync(Knt)),t.adoptedStyleSheets=[e]}connectedCallback(){g9(this.shadowRoot??this.attachShadow({mode:`open`}))}}customElements.define(F2,t)}function crt(e){return{...H2,...e}}function lrt(e,t){let n=urt(e,t);return t?n:e.diffHeaderHeight+n}function urt(e,t){return e.paddingTop??(t?e.spacing:0)}function drt(e){return e.paddingBottom??e.spacing}function frt(e){switch(e){case`simple`:return 4;case`metadata`:case`line-info`:case`line-info-basic`:case`custom`:return 32}}function y9(e,t){return e===t||e?.cacheKey!=null&&e.cacheKey===t?.cacheKey}function b9(e,t){return Y2(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function x9({line:e,spanStart:t,spanLength:n}){return{start:{line:e,character:t},end:{line:e,character:t+n},properties:{"data-diff-span":``},alwaysWrap:!0}}function S9({item:e,arr:t,enableJoin:n,isNeutral:r=!1,isLastItem:i=!1}){let a=t[t.length-1];if(a==null||i||!n){t.push([+!r,e.value]);return}let o=a[0]===0;if(r===o||r&&e.value.length===1&&!o){a[1]+=e.value;return}t.push([+!r,e.value])}function C9(e){return[$2(e.additionStart,e.additionCount)+1,e4(e.additionStart,e.additionCount)+1]}function w9({isPartial:e,rangeSize:t,expandedHunks:n,hunkIndex:r,collapsedContextThreshold:i}){let a=Math.max(t,0);if(a===0||e)return{fromStart:0,fromEnd:0,rangeSize:a,collapsedLines:a,renderAll:!1};if(n===!0||a<=i)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(r),s=Math.min(Math.max(o?.fromStart??0,0),a),c=Math.min(Math.max(o?.fromEnd??0,0),a),l=s+c,u=l>=a;return{fromStart:u?a:s,fromEnd:u?0:c,rangeSize:a,collapsedLines:Math.max(a-l,0),renderAll:u}}function prt(e){let t=e.hunks[e.hunks.length-1];if(t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return!1;let n=e.additionLines.length-e4(t.additionStart,t.additionCount),r=e.deletionLines.length-e4(t.deletionStart,t.deletionCount);return n<=0&&r<=0?!1:n!==r}function T9({fileDiff:e,errorPrefix:t}){let n=e.hunks[e.hunks.length-1];if(n==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return 0;let r=e.additionLines.length-e4(n.additionStart,n.additionCount),i=e.deletionLines.length-e4(n.deletionStart,n.deletionCount);if(r<=0&&i<=0)return 0;if(r!==i)throw Error(`${t}: trailing context mismatch (additions=${r}, deletions=${i}) for ${e.name}`);return Math.min(r,i)}function E9({fileDiff:e,hunkIndex:t,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:i}){if(t!==e.hunks.length-1)return;let a=T9({fileDiff:e,errorPrefix:i});if(a<=0)return;if(n===!0||a<=r)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(e.hunks.length),s=Math.min(Math.max(o?.fromStart??0,0),a);return{fromStart:s,fromEnd:0,rangeSize:a,collapsedLines:a-s,renderAll:s>=a}}function mrt({fileDiff:e,lineNumber:t,expandedHunks:n,collapsedContextThreshold:r}){if(n===!0||e.isPartial)return!0;for(let[i,a]of e.hunks.entries()){let[o,s]=C9(a);if(t<o){let s=w9({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:n,hunkIndex:i,collapsedContextThreshold:r}),c=o-s.rangeSize;return s.renderAll||t<c+s.fromStart||t>=o-s.fromEnd}if(t<s)return!0}let i=E9({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:`isAdditionLineRenderable`});if(i==null||i.renderAll)return!0;let a=e.hunks[e.hunks.length-1],[,o]=C9(a);return t<o+i.fromStart||t>=o+i.rangeSize}function hrt({fileDiff:e,lineNumber:t,direction:n,expandedHunks:r,collapsedContextThreshold:i}){if(r===!0||e.isPartial)return t;let a=[],o=1;for(let[t,n]of e.hunks.entries()){let[s,c]=C9(n),l=w9({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:r,hunkIndex:t,collapsedContextThreshold:i}),u=s-l.rangeSize;l.renderAll?a.push([u,s]):(l.fromStart>0&&a.push([u,u+l.fromStart]),l.fromEnd>0&&a.push([s-l.fromEnd,s])),a.push([s,c]),o=c}let s=E9({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:r,collapsedContextThreshold:i,errorPrefix:`getNearestRenderableAdditionLine`});if(s!=null){let e=o;o=e+s.rangeSize,s.renderAll?a.push([e,o]):s.fromStart>0&&a.push([e,e+s.fromStart])}if(t>=o)return t;if(n===`down`){for(let[e,n]of a)if(n>t)return Math.max(e,t);return}for(let e=a.length-1;e>=0;e--){let[n,r]=a[e];if(n<=t)return Math.min(r-1,t)}}function D9({type:e,metrics:t}){return t.hunkSeparatorHeight??frt(e)}function O9({type:e,metrics:t}){return e===`simple`||e===`metadata`||e===`line-info-basic`?0:t.spacing}function grt({type:e,hunkIndex:t,hunkSpecs:n}){switch(e){case`simple`:return t>0;case`metadata`:return n!=null;case`line-info`:case`line-info-basic`:case`custom`:return!0}}function _rt(e){return e!==`simple`&&e!==`metadata`}function vrt({type:e,metrics:t,hunkIndex:n,hunkSpecs:r}){if(!grt({type:e,hunkIndex:n,hunkSpecs:r}))return;let i=D9({type:e,metrics:t}),a=O9({type:e,metrics:t}),o=n>0?a:0,s=a;return{height:i,gapBefore:o,gapAfter:s,totalHeight:o+i+s}}function yrt({type:e,metrics:t}){if(!_rt(e))return;let n=D9({type:e,metrics:t}),r=O9({type:e,metrics:t});return{height:n,gapBefore:r,gapAfter:0,totalHeight:r+n}}function k9({diff:e,diffStyle:t,startingLine:n=0,totalLines:r=1/0,expandedHunks:i,collapsedContextThreshold:a=1,callback:o}){let s=brt({diff:e,diffStyle:t,startingLine:n,expandedHunks:i,collapsedContextThreshold:a}),c={viewportStart:n,viewportEnd:n+r,isWindowedHighlight:n>0||r<1/0,splitCount:s.splitCount,unifiedCount:s.unifiedCount,finalHunkIndex:e.hunks.length-1,shouldBreak(){if(!c.isWindowedHighlight)return!1;let e=c.unifiedCount>=n+r,i=c.splitCount>=n+r;return t===`unified`?e:(t===`split`||e)&&i},shouldSkip(e,r){if(!c.isWindowedHighlight)return!1;let i=e>0&&c.unifiedCount+e<=n,a=r>0&&c.splitCount+r<=n;return t===`unified`?i:(t===`split`||i)&&a},incrementCounts(e,n){(t===`unified`||t===`both`)&&(c.unifiedCount+=e),(t===`split`||t===`both`)&&(c.splitCount+=n)},isInWindow(e,n){if(!c.isWindowedHighlight)return!0;let r=c.isInUnifiedWindow(e),i=c.isInSplitWindow(n);return t===`unified`?r:t===`split`?i:r||i},isInUnifiedWindow(e){return!c.isWindowedHighlight||c.unifiedCount>=n-e&&c.unifiedCount<n+r},isInSplitWindow(e){return!c.isWindowedHighlight||c.splitCount>=n-e&&c.splitCount<n+r},emit(e,n=!1){return n||(t===`unified`?c.incrementCounts(1,0):t===`split`?c.incrementCounts(0,1):c.incrementCounts(1,1)),o(e)??!1}};hunkIterator:for(let n=s.hunkIndex;n<e.hunks.length;n++){let r=e.hunks[n];if(r==null)throw Error(`iterateOverDiff: invalid hunk index`);if(c.shouldBreak())break;let o=$2(r.deletionStart,r.deletionCount),s=$2(r.additionStart,r.additionCount),l=!e.isPartial&&r.deletionCount===0?o:r.deletionLineIndex,u=!e.isPartial&&r.additionCount===0?s:r.additionLineIndex,d=w9({isPartial:e.isPartial,rangeSize:r.collapsedBefore,expandedHunks:i,hunkIndex:n,collapsedContextThreshold:a}),f=n===c.finalHunkIndex?E9({fileDiff:e,hunkIndex:n,expandedHunks:i,collapsedContextThreshold:a,errorPrefix:`iterateOverDiff`}):void 0,p=d.fromStart+d.fromEnd;function m(e,n){return f==null||f.collapsedLines<=0||f.fromStart+f.fromEnd>0?0:t===`unified`?e===r.unifiedLineStart+r.unifiedLineCount-1?f.collapsedLines:0:n===r.splitLineStart+r.splitLineCount-1?f.collapsedLines:0}let h=d.collapsedLines===0;function g(){return h?0:(h=!0,d.collapsedLines)}if(c.shouldSkip(p,p))c.incrementCounts(p,p),g();else{let e=r.unifiedLineStart-d.rangeSize,i=r.splitLineStart-d.rangeSize,a=l-d.rangeSize,f=u-d.rangeSize,p=o+1-d.rangeSize,m=s+1-d.rangeSize;if(A9(c,d.fromStart,t,t=>c.emit({hunkIndex:n,hunk:r,collapsedBefore:0,collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:p+t,lineIndex:a+t,noEOFCR:!1,unifiedLineIndex:e+t,splitLineIndex:i+t},additionLine:{unifiedLineIndex:e+t,splitLineIndex:i+t,lineIndex:f+t,lineNumber:m+t,noEOFCR:!1}}))||(e=r.unifiedLineStart-d.fromEnd,i=r.splitLineStart-d.fromEnd,a=l-d.fromEnd,f=u-d.fromEnd,p=o+1-d.fromEnd,m=s+1-d.fromEnd,A9(c,d.fromEnd,t,t=>c.emit({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:p+t,lineIndex:a+t,noEOFCR:!1,unifiedLineIndex:e+t,splitLineIndex:i+t},additionLine:{unifiedLineIndex:e+t,splitLineIndex:i+t,lineIndex:f+t,lineNumber:m+t,noEOFCR:!1}}),()=>{g()})))break hunkIterator}let _=r.unifiedLineStart,v=r.splitLineStart,y=l,b=u,x=o+1,S=s+1,C=r.hunkContent.at(-1);for(let e of r.hunkContent){if(c.shouldBreak())break hunkIterator;let i=e===C;if(e.type===`context`){if(c.shouldSkip(e.lines,e.lines))c.incrementCounts(e.lines,e.lines),g();else if(A9(c,e.lines,t,t=>{let a=i&&t===e.lines-1,o=_+t,s=v+t;return c.emit({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:m(o,s),type:`context`,deletionLine:{lineNumber:x+t,lineIndex:y+t,noEOFCR:a&&r.noEOFCRDeletions,unifiedLineIndex:o,splitLineIndex:s},additionLine:{unifiedLineIndex:o,splitLineIndex:s,lineIndex:b+t,lineNumber:S+t,noEOFCR:a&&r.noEOFCRAdditions}})},()=>{g()}))break hunkIterator;_+=e.lines,v+=e.lines,y+=e.lines,b+=e.lines,x+=e.lines,S+=e.lines}else{let a=Math.max(e.deletions,e.additions),o=e.deletions+e.additions;if(!c.shouldSkip(o,a)){let s=Crt(c,e,t);(s[0]?.[0]??0)>0&&g();for(let[l,u]of s)for(let s=l;s<u;s++){let l=m(_+s,t===`unified`?v+(s<e.deletions?s:s-e.deletions):v+s);if(c.emit(wrt({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:l,diffStyle:t,index:s,unifiedLineIndex:_,splitLineIndex:v,additionLineIndex:b,deletionLineIndex:y,additionLineNumber:S,deletionLineNumber:x,content:e,isLastContent:i,unifiedCount:o,splitCount:a}),!0))break hunkIterator}}g(),c.incrementCounts(o,a),_+=o,v+=a,y+=e.deletions,b+=e.additions,x+=e.deletions,S+=e.additions}}if(f!=null){let{collapsedLines:n,fromStart:r,fromEnd:i}=f,a=r+i;if(A9(c,a,t,t=>{let r=t===a-1;return c.emit({hunkIndex:e.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:r?n:0,type:`context-expanded`,deletionLine:{lineNumber:x+t,lineIndex:y+t,noEOFCR:!1,unifiedLineIndex:_+t,splitLineIndex:v+t},additionLine:{unifiedLineIndex:_+t,splitLineIndex:v+t,lineIndex:b+t,lineNumber:S+t,noEOFCR:!1}})},void 0,()=>c.shouldBreak()))break hunkIterator}}}function brt({diff:e,diffStyle:t,startingLine:n,expandedHunks:r,collapsedContextThreshold:i}){if(n<=0||t===`both`)return{hunkIndex:0,splitCount:0,unifiedCount:0};let a=xrt({diff:e,expandedHunks:r,collapsedContextThreshold:i}),o=0,s=e.hunks.length-1,c=e.hunks.length;for(;o<=s;){let e=o+s>>1,r=a[e+1];if(r==null)throw Error(`iterateOverDiff: invalid hunk prefix index`);(t===`unified`?r.unifiedCount:r.splitCount)>n?(c=e,s=e-1):o=e+1}if(c>=e.hunks.length){let t=a[e.hunks.length];if(t==null)throw Error(`iterateOverDiff: invalid terminal hunk prefix index`);return{hunkIndex:e.hunks.length,splitCount:t.splitCount,unifiedCount:t.unifiedCount}}let l=a[c];if(l==null)throw Error(`iterateOverDiff: invalid selected hunk prefix index`);return{hunkIndex:c,splitCount:l.splitCount,unifiedCount:l.unifiedCount}}function xrt({diff:e,expandedHunks:t,collapsedContextThreshold:n}){let r=0,i=0,a=e.hunks.length-1,o=[{splitCount:0,unifiedCount:0}];for(let s=0;s<e.hunks.length;s++){let c=e.hunks[s];if(c==null)throw Error(`iterateOverDiff: invalid hunk summary index`);let l=w9({isPartial:e.isPartial,rangeSize:c.collapsedBefore,expandedHunks:t,hunkIndex:s,collapsedContextThreshold:n}),u=l.fromStart+l.fromEnd;r+=u+c.splitLineCount,i+=u+c.unifiedLineCount;let d=s===a?E9({fileDiff:e,hunkIndex:s,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`iterateOverDiff`}):void 0;if(d!=null){let e=d.fromStart+d.fromEnd;r+=e,i+=e}o.push({splitCount:r,unifiedCount:i})}return o}function Srt(e,t,n){if(!e.isWindowedHighlight||t<=0)return[0,t];let r=[];function i(n){let i=Math.max(0,e.viewportStart-n),a=Math.min(t,e.viewportEnd-n);a>i&&r.push([i,a])}if(n!==`split`&&i(e.unifiedCount),n!==`unified`&&i(e.splitCount),r.length===0)return[0,0];let a=r[0][0],o=r[0][1];for(let e=1;e<r.length;e++){let t=r[e];a=Math.min(a,t[0]),o=Math.max(o,t[1])}return[a,o]}function A9(e,t,n,r,i,a){let[o,s]=Srt(e,t,n);o>0&&(e.incrementCounts(o,o),i?.());let c=o;for(;c<t;){if(a?.()===!0)return!0;if(c>=s){e.incrementCounts(t-c,t-c);break}if(e.isInWindow(0,0)){if(r(c)===!0)return!0}else e.incrementCounts(1,1);c++}return!1}function Crt(e,t,n){if(!e.isWindowedHighlight)return[[0,n===`unified`?t.deletions+t.additions:Math.max(t.deletions,t.additions)]];let r=n!==`split`,i=n!==`unified`,a=n===`unified`?`unified`:`split`,o=[];function s(t,n){if(t+n<=e.viewportStart||t>=e.viewportEnd)return;let r=Math.max(0,e.viewportStart-t),i=Math.min(n,e.viewportEnd-t);return i>r?[r,i]:void 0}function c(e,n){return a===`split`?e:n===`additions`?[e[0]+t.deletions,e[1]+t.deletions]:e}function l(e,t){if(e==null)return;let[n,r]=c(e,t);r>n&&o.push([n,r])}if(r&&(l(s(e.unifiedCount,t.deletions),`deletions`),l(s(e.unifiedCount+t.deletions,t.additions),`additions`)),i&&(l(s(e.splitCount,t.deletions),`deletions`),l(s(e.splitCount,t.additions),`additions`)),o.length===0)return o;o.sort((e,t)=>e[0]-t[0]);let u=[o[0]];for(let[e,t]of o.slice(1)){let n=u[u.length-1];e<=n[1]?n[1]=Math.max(n[1],t):u.push([e,t])}return u}function wrt({hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,diffStyle:i,index:a,unifiedLineIndex:o,splitLineIndex:s,additionLineIndex:c,deletionLineIndex:l,additionLineNumber:u,deletionLineNumber:d,content:f,isLastContent:p,unifiedCount:m,splitCount:h}){let g=a<f.deletions?o+a:void 0,_=i===`unified`?a>=f.deletions?o+a:void 0:a<f.additions?o+f.deletions+a:void 0,v=i===`unified`?s+(a<f.deletions?a:a-f.deletions):s+a,y=a<f.deletions?l+a:void 0,b=a<f.deletions?d+a:void 0,x=i===`unified`?a>=f.deletions?c+(a-f.deletions):void 0:a<f.additions?c+a:void 0,S=i===`unified`?a>=f.deletions?u+(a-f.deletions):void 0:a<f.additions?u+a:void 0,C=i===`unified`?p&&a===f.deletions-1&&t.noEOFCRDeletions:p&&a===h-1&&t.noEOFCRDeletions,w=i===`unified`?p&&a===m-1&&t.noEOFCRAdditions:p&&a===h-1&&t.noEOFCRAdditions,T=y!=null&&b!=null&&g!=null?{lineNumber:b,lineIndex:y,noEOFCR:C,unifiedLineIndex:g,splitLineIndex:v}:void 0,E=x!=null&&S!=null&&_!=null?{unifiedLineIndex:_,splitLineIndex:v,lineIndex:x,lineNumber:S,noEOFCR:w}:void 0;if(T==null&&E!=null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:void 0,additionLine:E};if(T!=null&&E==null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:T,additionLine:void 0};if(T==null||E==null)throw Error(`iterateOverDiff: missing change line data`);return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:T,additionLine:E}}var Trt={forcePlainText:!1};function j9(e,t,n,{forcePlainText:r,startingLine:i,totalLines:a,expandedHunks:o,collapsedContextThreshold:s=1}=Trt){r?(i??=0,a??=1/0):(i=0,a=1/0);let c=i>0||a<1/0,l=typeof n.theme==`string`?t.getTheme(n.theme).type:void 0,u=o9({theme:n.theme,highlighter:t}),d=r&&!c&&(e.unifiedLineCount>1e3||e.splitLineCount>1e3)?`none`:n.lineDiffType,f={deletionLines:[],additionLines:[]},{maxLineDiffLength:p}=n,m=!r&&!e.isPartial,h=r?o:void 0,g=new Map;function _(e){let t=m?0:e,n=g.get(t)??Drt();return g.set(t,n),n}function v(e,t,n,r){if(c){let e=n.at(-1);(e==null||e.targetIndex+e.count!==t)&&(e={targetIndex:t,originalOffset:r.length,count:0},n.push(e)),e.count++}r.push(e)}k9({diff:e,diffStyle:`both`,startingLine:i,totalLines:a,expandedHunks:!c||h,collapsedContextThreshold:s,callback:({hunkIndex:t,additionLine:n,deletionLine:r,type:i})=>{let a=_(t),o=n==null?r.splitLineIndex:n.splitLineIndex;i===`change`&&n!=null&&r!=null&&Ert({additionLine:e.additionLines[n.lineIndex],deletionLine:e.deletionLines[r.lineIndex],deletionLineIndex:a.deletionContent.length,additionLineIndex:a.additionContent.length,deletionDecorations:a.deletionDecorations,additionDecorations:a.additionDecorations,lineDiffType:d,maxLineDiffLength:p}),r!=null&&(v(e.deletionLines[r.lineIndex],r.lineIndex,a.deletionSegments,a.deletionContent),a.deletionInfo.push({type:i===`change`?`change-deletion`:i,lineNumber:r.lineNumber,altLineNumber:i===`change`?void 0:n.lineNumber??void 0,lineIndex:`${r.unifiedLineIndex},${o}`})),n!=null&&(v(e.additionLines[n.lineIndex],n.lineIndex,a.additionSegments,a.additionContent),a.additionInfo.push({type:i===`change`?`change-addition`:i,lineNumber:n.lineNumber,altLineNumber:i===`change`?void 0:r.lineNumber??void 0,lineIndex:`${n.unifiedLineIndex},${o}`}))}});for(let i of g.values()){if(i.deletionContent.length===0&&i.additionContent.length===0)continue;let a={name:e.prevName??e.name,contents:i.deletionContent.value},o={name:e.name,contents:i.additionContent.value},{deletionLines:s,additionLines:c}=Ort({deletionFile:a,deletionInfo:i.deletionInfo,deletionDecorations:i.deletionDecorations,additionFile:o,additionInfo:i.additionInfo,additionDecorations:i.additionDecorations,highlighter:t,options:n,languageOverride:r?`text`:e.lang});if(m){f.deletionLines=s,f.additionLines=c;continue}if(i.deletionSegments.length>0)for(let e of i.deletionSegments)for(let t=0;t<e.count;t++)f.deletionLines[e.targetIndex+t]=s[e.originalOffset+t];else f.deletionLines.push(...s);if(i.additionSegments.length>0)for(let e of i.additionSegments)for(let t=0;t<e.count;t++)f.additionLines[e.targetIndex+t]=c[e.originalOffset+t];else f.additionLines.push(...c)}return{code:f,themeStyles:u,baseThemeType:l}}function Ert({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:a,lineDiffType:o,maxLineDiffLength:s}){if(e==null||t==null||o===`none`||(e=Q2(e),t=Q2(t),e.length>s||t.length>s))return;let c=o===`char`?G6e(e,t):Y6e(e,t),l=[],u=[],d=o===`word-alt`,f=c.at(-1);for(let e of c){let t=e===f;!e.added&&!e.removed?(S9({item:e,arr:l,enableJoin:d,isNeutral:!0,isLastItem:t}),S9({item:e,arr:u,enableJoin:d,isNeutral:!0,isLastItem:t})):e.removed?S9({item:e,arr:l,enableJoin:d,isLastItem:t}):S9({item:e,arr:u,enableJoin:d,isLastItem:t})}let p=0;for(let e of l)e[0]===1&&i.push(x9({line:n,spanStart:p,spanLength:e[1].length})),p+=e[1].length;p=0;for(let e of u)e[0]===1&&a.push(x9({line:r,spanStart:p,spanLength:e[1].length})),p+=e[1].length}function Drt(){return{deletionContent:{push(e){this.value+=e,this.length++},value:``,length:0},additionContent:{push(e){this.value+=e,this.length++},value:``,length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function Ort({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:r,highlighter:i,deletionDecorations:a,additionDecorations:o,languageOverride:s,options:{theme:c=B2,...l}}){let u=s??W7(e.name),d=s??W7(t.name),{state:f,transformers:p}=Z7(l.useTokenTransformer),m=typeof c==`string`?{...l,lang:`text`,theme:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:$7(`token`),tokenizeTimeLimit:0}:{...l,lang:`text`,themes:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:$7(`token`),tokenizeTimeLimit:0};return{deletionLines:e.contents===``?[]:(m.lang=u,f.lineInfo=n,m.decorations=a,c9(i.codeToHast(Q2(e.contents),m))),additionLines:t.contents===``?[]:(m.lang=d,m.decorations=o,f.lineInfo=r,c9(i.codeToHast(Q2(t.contents),m)))}}function M9(e){let t=e.lang??W7(e.name),n=e.lang??(e.prevName==null?`text`:W7(e.prevName));return t===`text`&&n===`text`}function N9(e){let t=[];for(let n of e){let e=I3.get(n);if(e==null)throw Error(`getResolvedLanguages: ${n} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(e)}return t}function P9(e){for(let t of Array.isArray(e)?e:[e])if(!I3.has(t))return!1;return!0}async function F9(e){let t=[],n=[];for(let r of e){if(r===`text`||r===`ansi`)continue;let e=w7(r)??C7(r);`then`in e?n.push(e):t.push(e)}return n.length>0&&await Promise.all(n).then(e=>{for(let n of e){if(n==null)throw Error(`resolvedLanguages: unable to resolve language`);t.push(n)}}),t}function I9(e){return k7.getResolvedThemes(e)}async function L9(e){for(let t of e)F7(t);let t=await k7.resolveThemes(e);for(let n=0;n<e.length;n++)I7(e[n],t[n]);return t}var R9={light:`pierre-light`,dark:`pierre-dark`};function krt(e){return e===`dark`?R9.dark:R9.light}var z9=2166136261,B9=16777619,Art=2654435769,jrt=2246822507;function V9(e,t=z9,n=B9){let r=t>>>0;for(let t=0;t<e.length;t+=1)r^=e.charCodeAt(t),r=Math.imul(r,n)>>>0;return r>>>0}function Mrt(e,t=`diff-panel`){let n=e.trim(),r=V9(n,z9,B9).toString(36),i=V9(n,Art,jrt).toString(36);return`${t}:${n.length}:${r}:${i}`}function H9(e){return pt(`flex items-center justify-between gap-2 px-4 wco:pr-[calc(100vw-env(titlebar-area-width)-env(titlebar-area-x)+1em)]`,Rn&&e!==`sheet`?`h-[52px] border-b border-border wco:h-[env(titlebar-area-height)]`:`h-12 wco:max-h-[env(titlebar-area-height)]`)}function Nrt(e){let t=(0,hi.c)(10),n=Rn&&e.mode!==`sheet`,r=e.mode===`inline`?`w-[42vw] min-w-[360px] max-w-[560px] shrink-0 border-l border-border`:`w-full`,i;t[0]===r?i=t[1]:(i=pt(`flex h-full min-w-0 flex-col bg-background`,r),t[0]=r,t[1]=i);let a;t[2]!==e.header||t[3]!==e.mode||t[4]!==n?(a=n?(0,N.jsx)(`div`,{className:H9(e.mode),children:e.header}):(0,N.jsx)(`div`,{className:`border-b border-border`,children:(0,N.jsx)(`div`,{className:H9(e.mode),children:e.header})}),t[2]=e.header,t[3]=e.mode,t[4]=n,t[5]=a):a=t[5];let o;return t[6]!==e.children||t[7]!==i||t[8]!==a?(o=(0,N.jsxs)(`div`,{className:i,children:[a,e.children]}),t[6]=e.children,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function Prt(){let e=(0,hi.c)(4),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,N.jsx)(bQ,{className:`absolute left-0 top-1/2 size-6 -translate-y-1/2 rounded-md border border-border/50`}),n=(0,N.jsx)(bQ,{className:`absolute right-0 top-1/2 size-6 -translate-y-1/2 rounded-md border border-border/50`}),e[0]=t,e[1]=n):(t=e[0],n=e[1]);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,N.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[t,n,(0,N.jsxs)(`div`,{className:`flex gap-1 overflow-hidden px-8 py-0.5`,children:[(0,N.jsx)(bQ,{className:`h-6 w-16 shrink-0 rounded-md`}),(0,N.jsx)(bQ,{className:`h-6 w-24 shrink-0 rounded-md`}),(0,N.jsx)(bQ,{className:`h-6 w-24 shrink-0 rounded-md max-sm:hidden`})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,N.jsxs)(N.Fragment,{children:[r,(0,N.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,N.jsx)(bQ,{className:`size-7 rounded-md`}),(0,N.jsx)(bQ,{className:`size-7 rounded-md`})]})]}),e[3]=i):i=e[3],i}function Frt(e){let t=(0,hi.c)(7),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,N.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,N.jsx)(bQ,{className:`h-4 w-32 rounded-full`}),(0,N.jsx)(bQ,{className:`ml-auto h-4 w-20 rounded-full`})]}),t[0]=n):n=t[0];let r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(bQ,{className:`h-3 w-full rounded-full`}),(0,N.jsx)(bQ,{className:`h-3 w-full rounded-full`}),(0,N.jsx)(bQ,{className:`h-3 w-10/12 rounded-full`}),(0,N.jsx)(bQ,{className:`h-3 w-11/12 rounded-full`}),(0,N.jsx)(bQ,{className:`h-3 w-9/12 rounded-full`})]}),t[1]=r):r=t[1];let i;t[2]===e.label?i=t[3]:(i=(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 px-3 py-4`,children:[r,(0,N.jsx)(`span`,{className:`sr-only`,children:e.label})]}),t[2]=e.label,t[3]=i);let a;return t[4]!==e.label||t[5]!==i?(a=(0,N.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col p-2`,children:(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border border-border/60 bg-card/25`,role:`status`,"aria-live":`polite`,"aria-label":e.label,children:[n,i]})}),t[4]=e.label,t[5]=i,t[6]=a):a=t[6],a}function Irt(e){let t=(0,M.useRef)(e);return(0,M.useInsertionEffect)(()=>void(t.current=e)),(0,M.useCallback)((...e)=>t.current(...e),[])}var Lrt=(0,M.createContext)(void 0);function Rrt(){return(0,M.useContext)(Lrt)}var zrt={position:`absolute`,top:0,bottom:0,textAlign:`center`,whiteSpace:`normal`,touchAction:`none`},Brt={display:`contents`};function Vrt(){return null}var U9=t(n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):r((n||=self).lru_map=n.lru_map||{})})(e,function(e){let t=Symbol(`newer`),n=Symbol(`older`);class r{constructor(e,t){typeof e!=`number`&&(t=e,e=0),this.size=0,this.limit=e,this.oldest=this.newest=void 0,this._keymap=new Map,t&&(this.assign(t),e<1&&(this.limit=this.size))}_markEntryAsUsed(e){e!==this.newest&&(e[t]&&(e===this.oldest&&(this.oldest=e[t]),e[t][n]=e[n]),e[n]&&(e[n][t]=e[t]),e[t]=void 0,e[n]=this.newest,this.newest&&(this.newest[t]=e),this.newest=e)}assign(e){let r,a=this.limit||Number.MAX_VALUE;this._keymap.clear();let o=e[Symbol.iterator]();for(let e=o.next();!e.done;e=o.next()){let o=new i(e.value[0],e.value[1]);if(this._keymap.set(o.key,o),r?(r[t]=o,o[n]=r):this.oldest=o,r=o,a--==0)throw Error(`overflow`)}this.newest=r,this.size=this._keymap.size}get(e){var t=this._keymap.get(e);return t?(this._markEntryAsUsed(t),t.value):void 0}set(e,r){var a=this._keymap.get(e);return a?(a.value=r,this._markEntryAsUsed(a),this):(this._keymap.set(e,a=new i(e,r)),this.newest?(this.newest[t]=a,a[n]=this.newest):this.oldest=a,this.newest=a,++this.size,this.size>this.limit&&this.shift(),this)}shift(){var e=this.oldest;if(e)return this.oldest[t]?(this.oldest=this.oldest[t],this.oldest[n]=void 0):(this.oldest=void 0,this.newest=void 0),e[t]=e[n]=void 0,this._keymap.delete(e.key),--this.size,[e.key,e.value]}find(e){let t=this._keymap.get(e);return t?t.value:void 0}has(e){return this._keymap.has(e)}delete(e){var r=this._keymap.get(e);return r?(this._keymap.delete(r.key),r[t]&&r[n]?(r[n][t]=r[t],r[t][n]=r[n]):r[t]?(r[t][n]=void 0,this.oldest=r[t]):r[n]?(r[n][t]=void 0,this.newest=r[n]):this.oldest=this.newest=void 0,this.size--,r.value):void 0}clear(){this.oldest=this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new o(this.oldest)}values(){return new s(this.oldest)}entries(){return this}[Symbol.iterator](){return new a(this.oldest)}forEach(e,n){typeof n!=`object`&&(n=this);let r=this.oldest;for(;r;)e.call(n,r.value,r.key,this),r=r[t]}toJSON(){for(var e=Array(this.size),n=0,r=this.oldest;r;)e[n++]={key:r.key,value:r.value},r=r[t];return e}toString(){for(var e=``,n=this.oldest;n;)e+=String(n.key)+`:`+n.value,n=n[t],n&&(e+=` < `);return e}}e.LRUMap=r;function i(e,r){this.key=e,this.value=r,this[t]=void 0,this[n]=void 0}function a(e){this.entry=e}a.prototype[Symbol.iterator]=function(){return this},a.prototype.next=function(){let e=this.entry;return e?(this.entry=e[t],{done:!1,value:[e.key,e.value]}):{done:!0,value:void 0}};function o(e){this.entry=e}o.prototype[Symbol.iterator]=function(){return this},o.prototype.next=function(){let e=this.entry;return e?(this.entry=e[t],{done:!1,value:e.key}):{done:!0,value:void 0}};function s(e){this.entry=e}s.prototype[Symbol.iterator]=function(){return this},s.prototype.next=function(){let e=this.entry;return e?(this.entry=e[t],{done:!1,value:e.value}):{done:!0,value:void 0}}})}))(),1),W9=Symbol(`IGNORE_RESPONSE`),G9=class extends Error{constructor(){super(`WorkerPoolManager: operation canceled because the pool terminated`)}},K9=class extends Error{constructor(){super(`WorkerPoolManager: operation canceled before the task completed`)}},Hrt=class{options;highlighter;preferredHighlighter;renderOptions;renderOptionsRequestVersion=0;renderOptionsVersion=0;initialized=!1;workers=[];queuedTasks=[];queuedTaskByInstance=new Map;taskByHighlightKey=new Map;activeTaskById=new Map;activeRequestByInstance=new Map;nextRequestId=0;themeSubscribers=new Set;workersFailed=!1;statSubscribers=new Set;fileCache;diffCache;_queuedBroadcast;lifecycleGeneration=0;constructor(e,{langs:t,theme:n=B2,useTokenTransformer:r=!1,lineDiffType:i=`word-alt`,maxLineDiffLength:a=1e3,tokenizeMaxLineLength:o=1e3,preferredHighlighter:s=`shiki-js`}){this.options=e,this.preferredHighlighter=s,this.renderOptions={theme:n,useTokenTransformer:r,lineDiffType:i,maxLineDiffLength:a,tokenizeMaxLineLength:o},this.fileCache=new U9.default.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new U9.default.LRUMap(e.totalASTLRUCacheSize??100),this.queueInitialization(t)}isWorkingPool(){return!this.workersFailed}getFileResultCache(e){return e.cacheKey==null?void 0:this.fileCache.get(e.cacheKey)}getDiffResultCache(e){return e.cacheKey==null?void 0:this.diffCache.get(e.cacheKey)}inspectCaches(){let{fileCache:e,diffCache:t}=this;return{fileCache:e,diffCache:t}}evictFileFromCache(e){try{return this.fileCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}evictDiffFromCache(e){try{return this.diffCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}async setRenderOptions({theme:e=this.renderOptions.theme??B2,useTokenTransformer:t=this.renderOptions.useTokenTransformer??!1,lineDiffType:n=this.renderOptions.lineDiffType??`word-alt`,maxLineDiffLength:r=this.renderOptions.maxLineDiffLength??1e3,tokenizeMaxLineLength:i=this.renderOptions.tokenizeMaxLineLength??1e3}){let{lifecycleGeneration:a}=this,o=++this.renderOptionsRequestVersion,s=()=>this.isCurrentLifecycle(a)&&this.renderOptionsRequestVersion===o;try{let a={theme:e,useTokenTransformer:t,lineDiffType:n,maxLineDiffLength:r,tokenizeMaxLineLength:i};if(this.isInitialized()||await this.initialize(),!s()||b9(a,this.renderOptions))return;let o=z7(e),c=[];if(Y2(a.theme,this.renderOptions.theme)||(c=B7(o)?I9(o):await L9(o)),!s())return;if(this.highlighter!=null)A7(c,this.highlighter);else{let e=await R7({themes:o,langs:[`text`],preferredHighlighter:this.preferredHighlighter});if(!s())return;this.highlighter=e}let l=this.setRenderOptionsOnWorkers(a,c);this.renderOptions=a,this.renderOptionsVersion++,this.diffCache.clear(),this.fileCache.clear(),this.invalidateRenderTasks();for(let e of this.themeSubscribers)e.onThemeChange();await l}catch(e){if(e instanceof G9||!s())return;throw e}}getPreferredHighlighter(){return this.preferredHighlighter}getFileRenderOptions(){let{tokenizeMaxLineLength:e,theme:t,useTokenTransformer:n}=this.renderOptions;return{theme:t,useTokenTransformer:n,tokenizeMaxLineLength:e}}getDiffRenderOptions(){return{...this.renderOptions}}async setRenderOptionsOnWorkers(e,t){if(this.workersFailed)return;this.isInitialized()||await this.initialize();let n=[];for(let r of this.workers){if(!r.initialized)throw console.log({managedWorker:r}),Error(`setRenderOptionsOnWorkers: Somehow we have an uninitialized worker`);n.push(new Promise((n,i)=>{let a=this.generateRequestId(),o={type:`set-render-options`,id:a,request:{type:`set-render-options`,id:a,renderOptions:e,resolvedThemes:t},resolve:n,reject:i,requestStart:Date.now()};this.activeTaskById.set(a,o),r.pendingSetupRequestId=a,r.worker.postMessage(o.request)}))}await Promise.all(n)}subscribeToThemeChanges(e){return this.themeSubscribers.add(e),this.queueBroadcastStateChanges(),()=>{this.unsubscribeToThemeChanges(e),this.queueBroadcastStateChanges()}}unsubscribeToThemeChanges(e){this.themeSubscribers.delete(e),this.queueBroadcastStateChanges()}subscribeToStatChanges(e){return this.statSubscribers.add(e),e(this.getStats()),()=>{this.statSubscribers.delete(e)}}queueBroadcastStateChanges(){this._queuedBroadcast??=requestAnimationFrame(this._broadcastStateChanges)}_broadcastStateChanges=()=>{this._queuedBroadcast!=null&&(cancelAnimationFrame(this._queuedBroadcast),this._queuedBroadcast=void 0);let e=this.getStats();for(let t of this.statSubscribers)t(e)};cleanUpTasks(e){this.detachInstanceFromQueuedTasks(e);let t=this.activeRequestByInstance.get(e);if(t!=null){let n=this.activeTaskById.get(t);J9(n)?(this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0&&this.removeActiveTask(n)):this.activeTaskById.delete(t)}this.activeRequestByInstance.delete(e),this.queueBroadcastStateChanges()}isInitialized(){return this.initialized===!0}async initialize(e=[]){if(this.initialized!==!0)if(this.initialized===!1){let{lifecycleGeneration:t}=this;this.initialized=new Promise((n,r)=>{(async()=>{try{let r=z7(this.renderOptions.theme),i=[];if(i=B7(r)?I9(r):await L9(r),!this.isCurrentLifecycle(t)){n();return}let a=[];if(a=P9(e)?N9(e):await F9(e),!this.isCurrentLifecycle(t)){n();return}let[o]=await Promise.all([R7({themes:r,langs:[`text`,...e],preferredHighlighter:this.preferredHighlighter}),this.initializeWorkers(i,a)]);if(!this.isCurrentLifecycle(t)){this.terminateWorkers(),n();return}this.highlighter=o,this.initialized=!0,this.diffCache.clear(),this.fileCache.clear(),this.drainQueue(),this.queueBroadcastStateChanges(),n()}catch(e){if(e instanceof G9||!this.isCurrentLifecycle(t)){n();return}this.initialized=!1,this.workersFailed=!0;for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,X9(e));this.queueBroadcastStateChanges(),r(e)}})()}),this.queueBroadcastStateChanges()}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;let n=[],r=G7(),i=r>0?K7():void 0;this.workers.length>0&&this.terminateWorkers();for(let a=0;a<(this.options.poolSize??8);a++){let a=this.options.workerFactory(),o={worker:a,requestId:void 0,pendingSetupRequestId:void 0,initialized:!1,langs:new Set([`text`,...t.map(({name:e})=>e)]),customExtensionsVersion:0};a.addEventListener(`message`,e=>{this.handleWorkerMessage(o,e.data)}),a.addEventListener(`error`,e=>console.error(`Worker error:`,e,o)),this.workers.push(o),n.push(new Promise((n,a)=>{let s=this.generateRequestId(),c={type:`initialize`,id:s,request:{type:`initialize`,id:s,renderOptions:this.renderOptions,preferredHighlighter:this.preferredHighlighter,resolvedThemes:e,resolvedLanguages:t,customExtensionsVersion:i==null?void 0:r,customExtensionMap:i},resolve(){o.initialized=!0,n()},reject:a,requestStart:Date.now()};this.activeTaskById.set(s,c),this.executeTask(o,c)}))}await Promise.all(n)}drainQueue=()=>{if(this._queuedDrain=void 0,this.initialized===!0&&this.queuedTasks.length!==0){for(let e=0;e<this.queuedTasks.length;){let t=this.queuedTasks[e];if(this.hasActiveRequest(t)){e++;continue}let n=q9(t),r=this.getAvailableWorker(n);if(r==null)break;this.queuedTasks.splice(e,1),this.assignWorkerToTask(t,r),this.resolveLanguagesAndExecuteTask(r,t,n)}this.queueBroadcastStateChanges()}};highlightFileAST(e,t){let n=this.getFileResultCache(t);p9(t)||n!=null&&V7(n.options,this.getFileRenderOptions())||this.hasMatchingFileInstanceTask(e,t)||this.submitTask(e,{type:`file`,file:t})}primeFileHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error(`WorkerPoolManager.primeFileHighlightCache: worker pool is not working`));let t=this.getOrCreateFileHighlightCacheTask(e);return t==null?Promise.resolve():this.createRenderTaskCallbacks(t)}getOrCreateFileHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeFileHighlightCache: priming highlight cache requires file.cacheKey; skipping "${e.name}".`);return}let t=this.getFileResultCache(e),n=this.getFileHighlightKey(e);if(n==null||p9(e)||t!=null&&V7(t.options,this.getFileRenderOptions()))return;let r=this.getTaskByHighlightKey(n);if(r!=null)return r.primeCache=!0,r.type===`file`?r:void 0;{let t=this.submitCacheTask({type:`file`,file:e},n);return t.type===`file`?t:void 0}}getPlainFileAST(e,t,n,r){if(this.highlighter==null){this.queueInitialization();return}return f9(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,lines:r})}highlightDiffAST(e,t){let n=this.getDiffResultCache(t);M9(t)||n!=null&&b9(n.options,this.getDiffRenderOptions())||this.hasMatchingDiffInstanceTask(e,t)||this.submitTask(e,{type:`diff`,diff:t})}primeDiffHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error(`WorkerPoolManager.primeDiffHighlightCache: worker pool is not working`));let t=this.getOrCreateDiffHighlightCacheTask(e);return t==null?Promise.resolve():this.createRenderTaskCallbacks(t)}getOrCreateDiffHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeDiffHighlightCache: priming highlight cache requires diff.cacheKey; skipping "${e.prevName??e.name}" -> "${e.name}".`);return}let t=this.getDiffResultCache(e),n=this.getDiffHighlightKey(e);if(n==null||M9(e)||t!=null&&b9(t.options,this.getDiffRenderOptions()))return;let r=this.getTaskByHighlightKey(n);if(r!=null)return r.primeCache=!0,r.type===`diff`?r:void 0;{let t=this.submitCacheTask({type:`diff`,diff:e},n);return t.type===`diff`?t:void 0}}getPlainDiffAST(e,t,n,r,i){return this.highlighter==null?void 0:j9(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,expandedHunks:r,collapsedContextThreshold:i})}terminate(){this.lifecycleGeneration++,this.cancelActiveWorkerTasks(),this.terminateWorkers();let e=new G9;for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,e);this.fileCache.clear(),this.diffCache.clear(),this.activeRequestByInstance.clear(),this.queuedTasks.length=0,this.queuedTaskByInstance.clear(),this.taskByHighlightKey.clear(),this.activeTaskById.clear(),this.highlighter=void 0,this.initialized=!1,this.workersFailed=!1,this.queueBroadcastStateChanges()}isCurrentLifecycle(e){return this.lifecycleGeneration===e}queueInitialization(e){this.initialize(e).catch(e=>{console.error(e)})}cancelActiveWorkerTasks(){let e=new G9;for(let t of this.activeTaskById.values())`reject`in t?t.reject(e):J9(t)&&this.rejectRenderTaskCallbacks(t,e)}terminateWorkers(){for(let e of this.workers)e.worker.terminate();this.workers.length=0}getStats(){return{managerState:this.initialized===!1?`waiting`:this.initialized===!0?`initialized`:`initializing`,totalWorkers:this.workers.length,workersFailed:this.workersFailed,busyWorkers:this.workers.filter(e=>e.requestId!=null||e.pendingSetupRequestId!=null).length,queuedTasks:this.queuedTasks.length,activeTasks:this.activeTaskById.size,themeSubscribers:this.themeSubscribers.size,fileCacheSize:this.fileCache.size,diffCacheSize:this.diffCache.size}}submitTask(e,t){this.initialized===!1&&this.queueInitialization();let n=this.getHighlightKeyForRequest(t),r=n==null?void 0:this.getTaskByHighlightKey(n);if(r!=null){this.detachInstanceFromQueuedTasks(e,r),this.addInstanceToTask(r,e),this.queueBroadcastStateChanges();return}this.detachInstanceFromQueuedTasks(e);let i=this.generateRequestId(),a=Date.now(),{renderOptionsVersion:o}=this,s=(()=>{switch(t.type){case`file`:return{type:`file`,id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:o,requestStart:a};case`diff`:return{type:`diff`,id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:o,requestStart:a}}})();this.enqueueRenderTask(s,e)}submitCacheTask(e,t){this.initialized===!1&&this.queueInitialization();let n=this.generateRequestId(),r=Date.now(),{renderOptionsVersion:i}=this,a=(()=>{switch(e.type){case`file`:return{type:`file`,id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r};case`diff`:return{type:`diff`,id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r}}})();return this.enqueueRenderTask(a),a}enqueueRenderTask(e,t){this.queuedTasks.push(e),t!=null&&this.queuedTaskByInstance.set(t,e),e.highlightKey!=null&&this.taskByHighlightKey.set(e.highlightKey,e),this.queueDrain()}async resolveLanguagesAndExecuteTask(e,t,n){try{let r=n.filter(t=>!e.langs.has(t));if(r.length>0&&(P9(r)?t.request.resolvedLanguages=N9(r):t.request.resolvedLanguages=await F9(r)),!this.activeTaskById.has(t.id)){e.requestId===t.id&&(this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain());return}this.executeTask(e,t)}catch(n){this.rejectRenderTaskCallbacks(t,X9(n)),this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}}handleWorkerMessage(e,t){let n=this.activeTaskById.get(t.id);try{if(n==null)throw W9;if(t.type===`error`){let e=Error(t.error);if(t.stack&&(e.stack=t.stack),`reject`in n)n.reject(e);else if(J9(n))this.notifyHighlightError(n,e),this.rejectRenderTaskCallbacks(n,e);else throw Error(`handleWorkerMessage: unknown task type`);throw e}switch(t.requestType){case`initialize`:if(n.type!==`initialize`)throw Error(`handleWorkerMessage: task/response dont match`);this.syncCustomExtensionVersion(e,n.request),n.resolve();break;case`set-render-options`:if(n.type!==`set-render-options`)throw Error(`handleWorkerMessage: task/response dont match`);n.resolve();break;case`file`:{if(n.type!==`file`)throw Error(`handleWorkerMessage: task/response dont match`);let{result:r,options:i}=t;if(!this.isCurrentRenderTask(n)||!V7(i,this.getFileRenderOptions()))throw W9;let{request:a}=n;this.syncCustomExtensionVersion(e,a),n.cacheKeyAtDispatch!=null&&this.fileCache.set(n.cacheKeyAtDispatch,{result:r,options:i}),this.resolveRenderTaskCallbacks(n),this.notifyFileInstances(n,r,i);break}case`diff`:{if(n.type!==`diff`)throw Error(`handleWorkerMessage: task/response dont match`);let{result:r,options:i}=t;if(!this.isCurrentRenderTask(n)||!b9(i,this.getDiffRenderOptions()))throw W9;let{request:a}=n;this.syncCustomExtensionVersion(e,a),n.cacheKeyAtDispatch!=null&&this.diffCache.set(n.cacheKeyAtDispatch,{result:r,options:i}),this.resolveRenderTaskCallbacks(n),this.notifyDiffInstances(n,r,i);break}}}catch(e){e!==W9&&console.error(e,n,t)}this.cleanWorkerAndTask(e,n,t.id),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}_queuedDrain;queueDrain(){this._queuedDrain??(this._queuedDrain=Promise.resolve().then(this.drainQueue),this.queueBroadcastStateChanges())}assignWorkerToTask(e,t){t.requestId=e.id,J9(e)&&(this.clearQueuedInstanceRequests(e),this.trackInstanceRequests(e)),this.activeTaskById.set(e.id,e)}cleanWorkerAndTask(e,t,n=t?.id){e.requestId===n&&(e.requestId=void 0),e.pendingSetupRequestId===n&&(e.pendingSetupRequestId=void 0),t!=null&&(J9(t)&&(this.rejectRenderTaskCallbacks(t,new K9),this.clearInstanceRequests(t),this.clearHighlightKey(t)),this.activeTaskById.delete(t.id))}executeTask(e,t){Urt(t.request)&&this.maybeAttachCustomExtensions(e,t.request),this.activeTaskById.has(t.id)||this.assignWorkerToTask(t,e);for(let n of q9(t))e.langs.add(n);try{t.type===`file`?t.cacheKeyAtDispatch=t.request.file.cacheKey:t.type===`diff`&&(t.cacheKeyAtDispatch=t.request.diff.cacheKey),e.worker.postMessage(t.request)}catch(n){console.error(`Failed to post message to worker:`,n),J9(t)?(this.notifyHighlightError(t,n),this.rejectRenderTaskCallbacks(t,X9(n))):`reject`in t&&t.reject(n),this.cleanWorkerAndTask(e,t),this.queuedTasks.length>0&&this.queueDrain()}this.queueBroadcastStateChanges()}maybeAttachCustomExtensions(e,t){if(t.customExtensionsVersion!=null)return;let n=G7();e.customExtensionsVersion>=n||(t.customExtensionsVersion=n,t.customExtensionMap=K7())}syncCustomExtensionVersion(e,t){t.customExtensionsVersion!=null&&(e.customExtensionsVersion=t.customExtensionsVersion)}getAvailableWorker(e){let t;for(let n of this.workers){if(n.requestId!=null||n.pendingSetupRequestId!=null||!n.initialized)continue;if(t=n,e.length===0)break;let r=!0;for(let t of e)if(!n.langs.has(t)){r=!1;break}if(r)break}return t}getFileHighlightKey(e){if(e.cacheKey!=null)return`file:${e.cacheKey}:${this.renderOptionsVersion}`}getDiffHighlightKey(e){if(e.cacheKey!=null)return`diff:${e.cacheKey}:${this.renderOptionsVersion}`}getHighlightKeyForRequest(e){switch(e.type){case`file`:return this.getFileHighlightKey(e.file);case`diff`:return this.getDiffHighlightKey(e.diff)}}hasActiveRequest(e){for(let t of Y9(e))if(this.activeRequestByInstance.has(t))return!0;return!1}addInstanceToTask(e,t){e.type,e.instances.add(t),this.activeTaskById.has(e.id)?this.activeRequestByInstance.set(t,e.id):this.queuedTaskByInstance.set(t,e)}detachInstanceFromQueuedTasks(e,t){let n=this.queuedTaskByInstance.get(e);n!=null&&n!==t&&(this.queuedTaskByInstance.delete(e),this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0&&this.removeQueuedTask(n))}detachInstanceFromRenderTask(e,t){e.type,e.instances.delete(t)}removeQueuedTask(e){let t=this.queuedTasks.indexOf(e);t!==-1&&this.queuedTasks.splice(t,1),this.rejectRenderTaskCallbacks(e,new K9),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new K9),this.clearInstanceRequests(e),this.clearHighlightKey(e),this.activeTaskById.delete(e.id)}createRenderTaskCallbacks(e){return new Promise((t,n)=>{e.callbacks.add({resolve:t,reject:n})})}resolveRenderTaskCallbacks(e){for(let t of e.callbacks)t.resolve();e.callbacks.clear()}rejectRenderTaskCallbacks(e,t){for(let n of e.callbacks)n.reject(t);e.callbacks.clear()}invalidateRenderTasks(){for(let e=this.queuedTasks.length-1;e>=0;e--){let t=this.queuedTasks[e];t.renderOptionsVersion!==this.renderOptionsVersion&&this.removeQueuedTask(t)}for(let e of Array.from(this.activeTaskById.values()))J9(e)&&e.renderOptionsVersion!==this.renderOptionsVersion&&this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(let t of Y9(e))this.queuedTaskByInstance.get(t)===e&&this.queuedTaskByInstance.delete(t)}clearHighlightKey(e){e.highlightKey!=null&&this.taskByHighlightKey.get(e.highlightKey)===e&&this.taskByHighlightKey.delete(e.highlightKey)}trackInstanceRequests(e){for(let t of Y9(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(let t of Y9(e))this.activeRequestByInstance.get(t)===e.id&&this.activeRequestByInstance.delete(t)}notifyFileInstances(e,t,n){for(let r of e.instances)this.activeRequestByInstance.get(r)===e.id&&r.onHighlightSuccess(e.request.file,t,n)}notifyDiffInstances(e,t,n){for(let r of e.instances)this.activeRequestByInstance.get(r)===e.id&&r.onHighlightSuccess(e.request.diff,t,n)}notifyHighlightError(e,t){for(let n of Y9(e))this.activeRequestByInstance.get(n)===e.id&&n.onHighlightError(t)}hasMatchingFileInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type===`file`&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&S4(t,n.request.file))return!0;return!1}hasMatchingDiffInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type===`diff`&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&y9(n.request.diff,t))return!0;return!1}getTaskByHighlightKey(e){let t=this.taskByHighlightKey.get(e);return t!=null&&this.isCurrentRenderTask(t)?t:void 0}isCurrentRenderTask(e){return e.renderOptionsVersion===this.renderOptionsVersion}*iterateRenderTasks(){for(let e of this.queuedTasks)yield e;for(let e of this.activeTaskById.values())J9(e)&&(yield e)}generateRequestId(){return`req_${++this.nextRequestId}`}};function Urt(e){return e.type===`initialize`||e.type===`file`||e.type===`diff`}function q9(e){let t=new Set;if(e.type===`initialize`||e.type===`set-render-options`)return[];switch(e.type){case`file`:t.add(e.request.file.lang??W7(e.request.file.name));break;case`diff`:t.add(e.request.diff.lang??W7(e.request.diff.name)),t.add(e.request.diff.lang??W7(e.request.diff.prevName??`-`))}return t.delete(`text`),Array.from(t)}function J9(e){return e?.type===`file`||e?.type===`diff`}function Y9(e){return e.instances}function X9(e){return e instanceof Error?e:Error(String(e))}var Z9;function Wrt({poolOptions:e,highlighterOptions:t}){return Z9??=new Hrt(e,t),Z9}function Grt(){Z9!=null&&(Z9.terminate(),Z9=void 0)}var Q9=(0,M.createContext)(void 0),$9=0;function Krt({children:e,poolOptions:t,highlighterOptions:n}){let[r]=(0,M.useState)(()=>{if(!(typeof window>`u`))return Wrt({poolOptions:t,highlighterOptions:n})});return(0,M.useInsertionEffect)(()=>{if(r!=null)return $9++,()=>{$9--}},[r]),(0,M.useEffect)(()=>()=>{$9===0&&Grt()},[]),(0,N.jsx)(Q9.Provider,{value:r,children:e})}function qrt(){return(0,M.useContext)(Q9)}export{Int as $,NJe as $a,li as $c,yZ as $i,On as $l,t2 as $n,WK as $o,t1e as $r,nW as $s,P6e as $t,lrt as A,rY as Aa,Fie as Ac,l$e as Ai,Zne as Al,c6e as An,uq as Ao,qQ as Ar,YW as As,$4 as At,Xnt as B,WJ as Ba,Oi as Bc,PZ as Bi,zn as Bl,q4e as Bn,bKe as Bo,L1e as Br,kW as Bs,S4 as Bt,E9 as C,eX as Ca,xBe as Cc,d$e as Ci,dr as Cl,g6e as Cn,bqe as Co,_2e as Cr,aWe as Cs,I8e as Ct,b9 as D,mY as Da,EH as Dc,JZ as Di,Jn as Dl,N2 as Dn,GKe as Do,J1e as Dr,jUe as Ds,c3 as Dt,mrt as E,cYe as Ea,rBe as Ec,s$e as Ei,Yne as El,v6e as En,KKe as Eo,Z1e as Er,SG as Es,l3 as Et,nrt as F,UJe as Fa,Ii as Fc,UZ as Fi,Gn as Fl,n6e as Fn,SKe as Fo,I1e as Fr,IW as Fs,r8e as Ft,Wnt as G,zJ as Ga,aie as Gc,DZ as Gi,Pn as Gl,t3e as Gn,aKe as Go,f1e as Gr,tW as Gs,U6e as Gt,Jnt as H,YJ as Ha,Ei as Hc,NZ as Hi,Gne as Hl,f3e as Hn,ZK as Ho,H1e as Hr,EW as Hs,e4 as Ht,trt as I,QJ as Ia,Ai as Ic,VZ as Ii,Zn as Il,v2 as In,cq as Io,U1e as Ir,NW as Is,n8e as It,Bnt as J,BJ as Ja,Ti as Jc,aQe as Ji,jn as Jl,Z4e as Jn,zK as Jo,u1e as Jr,fHe as Js,Y2 as Jt,Unt as K,LJe as Ka,Ci as Kc,uQe as Ki,Nn as Kl,X4e as Kn,RK as Ko,TQ as Kr,dHe as Ks,Z2 as Kt,ert as L,ZJ as La,Mi as Lc,UQe as Li,ir as Ll,_2 as Ln,tq as Lo,R1e as Lr,DW as Ls,w4 as Lt,srt as M,KJe as Ma,Lie as Mc,WZ as Mi,Hn as Ml,a6e as Mn,dq as Mo,j1e as Mr,GW as Ms,A4 as Mt,irt as N,HJe as Na,Ri as Nc,QQe as Ni,Yn as Nl,o6e as Nn,nq as No,P1e as Nr,UHe as Ns,D4 as Nt,y9 as O,pY as Oa,CH as Oc,o$e as Oi,qn as Ol,y6e as On,Hq as Oo,n$ as Or,PUe as Os,t3 as Ot,rrt as P,eY as Pa,Fi as Pc,ZQe as Pi,Xn as Pl,Q3e as Pn,sq as Po,z1e as Pr,RW as Ps,i8e as Pt,Pnt as Q,OJ as Qa,vi as Qc,xZ as Qi,zne as Ql,i3e as Qn,iKe as Qo,bQ as Qr,mHe as Qs,O6e as Qt,$nt as R,XJ as Ra,ji as Rc,zZ as Ri,nr as Rl,y2 as Rn,gKe as Ro,B1e as Rr,wW as Rs,T4 as Rt,T9 as S,GYe as Sa,wBe as Sc,YZ as Si,fr as Sl,_6e as Sn,xqe as So,w2e as Sr,pWe as Ss,d3 as St,prt as T,mYe as Ta,PH as Tc,qZ as Ti,sr as Tl,x6e as Tn,WKe as To,t$ as Tr,xG as Ts,F8e as Tt,g9 as U,JJ as Ua,oie as Uc,xQe as Ui,Ln as Ul,e3e as Un,qK as Uo,_1e as Ur,bW as Us,$2 as Ut,Ynt as V,VJe as Va,Di as Vc,MZ as Vi,Rn as Vl,d3e as Vn,eq as Vo,$Q as Vr,jHe as Vs,$6e as Vt,Gnt as W,qJ as Wa,sie as Wc,vQe as Wi,In as Wl,N3e as Wn,YK as Wo,v1e as Wr,pW as Ws,Q2 as Wt,znt as X,IJ as Xa,xi as Xc,SZ as Xi,Lne as Xl,M3e as Xn,rKe as Xo,c1e as Xr,lHe as Xs,K2 as Xt,p9 as Y,MJ as Ya,iie as Yc,wZ as Yi,An as Yl,$4e as Yn,GK as Yo,CQ as Yr,sHe as Ys,J2 as Yt,Rnt as Z,LJ as Za,Si as Zc,_Z as Zi,Vne as Zl,w3e as Zn,UK as Zo,n1e as Zr,aHe as Zs,G2 as Zt,k9 as _,eXe as _a,vU as _c,hQ as _i,wr as _l,L2 as _n,sqe as _o,x0 as _r,zG as _s,F5e as _t,Brt as a,MZe as aa,LU as ac,W$e as ai,_re as al,z6e as an,TJ as ao,j3e as ar,JG as as,hnt as at,kne as au,vrt as b,wYe as ba,SBe as bc,XZ as bi,cre as bl,k6e as bn,yqe as bo,C2e as br,jG as bs,y5e as bt,Irt as c,iZ as ca,RVe as cc,q$e as ci,jr as cl,B2 as cn,Lqe as co,u3e as cr,UG as cs,lnt as ct,Nrt as d,jXe as da,zVe as dc,_Q as di,Or as dl,S6e as dn,mJ as do,x4e as dr,HG as ds,V7 as dt,vZ as ea,$Ve as ec,Q$e as ei,ti as el,N6e as en,wJe as eo,n3e as er,sKe as es,Fnt as et,Bne as eu,Mrt as f,MXe as fa,AU as fc,gQ as fi,Ar as fl,F2 as fn,dJ as fo,b4e as fr,YG as fs,B7 as ft,j9 as g,QYe as ga,xU as gc,Y$e as gi,pre as gl,w6e as gn,gqe as go,b0 as gr,rGe as gs,R7 as gt,M9 as h,vX as ha,IVe as hc,B$e as hi,Er as hl,D6e as hn,pqe as ho,r4e as hr,BG as hs,rnt as ht,zrt as i,pZ as ia,ZU as ic,X$e as ii,ei as il,L6e as in,wJ as io,C3e as ir,pGe as is,gnt as it,Rne as iu,drt as j,aY as ja,Pie as jc,a$e as ji,Xne as jl,i6e as jn,lq as jo,WQ as jr,KW as js,Z4 as jt,crt as k,iY as ka,wH as kc,KZ as ki,ere as kl,r6e as kn,Wq as ko,KQ as kr,TUe as ks,Q4 as kt,Prt as l,bZe as la,uVe as lc,J$e as li,Nr as ll,F6e as ln,Rqe as lo,N0 as lr,GG as ls,snt as lt,krt as m,EXe as ma,VU as mc,G$e as mi,Dr as ml,E6e as mn,iJ as mo,c4e as mr,fGe as ms,z7 as mt,Krt as n,JZe as na,tHe as nc,$$e as ni,ai as nl,z2 as nn,DJe as no,o2 as nr,tKe as ns,f9 as nt,Mne as nu,Vrt as o,kZe as oa,jVe as oc,K$e as oi,Fr as ol,B6e as on,Nqe as oo,Q0 as or,WG as os,W7 as ot,Pne as ou,V9 as p,xX as pa,OVe as pc,U$e as pi,kr as pl,V6e as pn,lJ as po,y4e as pr,qG as ps,ant as pt,Vnt as q,RJ as qa,wi as qc,oQe as qi,Mn as ql,A3e as qn,oKe as qo,d1e as qr,_He as qs,H6e as qt,qrt as r,mZ as ra,QVe as rc,e1e as ri,oi as rl,I6e as rn,gJe as ro,r3e as rr,KK as rs,d9 as rt,Sn as ru,Rrt as s,tZ as sa,FVe as sc,V$e as si,Pr as sl,R6e as sn,Fqe as so,c2 as sr,VG as ss,fnt as st,Cn as su,Q9 as t,XZe as ta,eHe as tc,Z$e as ti,ni as tl,C6e as tn,xJe as to,Y4e as tr,nKe as ts,Lnt as tt,Ane as tu,Frt as u,tZe as ua,BVe as uc,z$e as ui,Mr as ul,H2 as un,hJ as uo,M0 as ur,KG as us,ont as ut,w9 as v,TY as va,_U as vc,eQ as vi,vr as vl,R2 as vn,Qq as vo,d0 as vr,BWe as vs,O5e as vt,yrt as w,WYe as wa,IH as wc,GZ as wi,cr as wl,b6e as wn,UKe as wo,v2e as wr,sWe as ws,u3 as wt,hrt as x,CYe as xa,CBe as xc,u$e as xi,lre as xl,T6e as xn,oqe as xo,T2e as xr,iWe as xs,C3 as xt,C9 as y,qYe as ya,UBe as yc,ZZ as yi,ure as yl,I2 as yn,Zq as yo,o0 as yr,NG as ys,v5e as yt,Qnt as z,GJ as za,Pi as zc,GQe as zi,Bn as zl,x2 as zn,QK as zo,V1e as zr,CW as zs,C4 as zt};
2540
- //# sourceMappingURL=WorkerPoolContext-Q7KzTxot.js.map
2540
+ //# sourceMappingURL=WorkerPoolContext-DkMo0hso.js.map