@cmmd-center/forge 0.10.4 → 0.10.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.cjs +106 -37
- package/dist/bin.mjs +129 -60
- package/dist/client/assets/{CanvasPanel-BYsK8tAq.js → CanvasPanel-Dr4I7MnM.js} +2 -2
- package/dist/client/assets/{CompositeItem-khilqBJh.js → CompositeItem-Cj6_oAlz.js} +2 -2
- package/dist/client/assets/{DiffPanel-CrG7-Qe5.js → DiffPanel-njtnlFro.js} +3 -3
- package/dist/client/assets/{DiffPanel.logic--xX71t7M.js → DiffPanel.logic-BiWRNb4k.js} +2 -2
- package/dist/client/assets/{DiffPanelShell-CSeG4SSQ.js → DiffPanelShell-AKUK0L-g.js} +33 -33
- package/dist/client/assets/{DiffWorkerPoolProvider-C1s-wxqS.js → DiffWorkerPoolProvider-DWrja16U.js} +51 -51
- package/dist/client/assets/PullRequestCodePanel-CAaq9dk8.js +5 -0
- package/dist/client/assets/{Virtualizer-BaEpKPBi.js → Virtualizer-BXpiamky.js} +2 -2
- package/dist/client/assets/{canvasStateStore-CVTcDwc2.js → canvasStateStore-DncdOQ4J.js} +2 -2
- package/dist/client/assets/{cmmdAuthRedirect-B6WFFIw6.js → cmmdAuthRedirect-DWiMDVzN.js} +2 -2
- package/dist/client/assets/index-DBIIL0ML.js +151 -0
- package/dist/client/assets/index-T36rURmx.css +1 -0
- package/dist/client/assets/src-CtyKlVph.js +3 -0
- package/dist/client/assets/{toggle-DnYrc2U3.js → toggle-pTm2fPLg.js} +2 -2
- package/dist/client/assets/{useTriggerFocusGuards-CVcUEajo.js → useTriggerFocusGuards-B4Ejoaox.js} +2 -2
- package/dist/client/index.html +11 -11
- package/dist/forge-build.json +1 -1
- package/dist/{open-FIgTDosf.mjs → open-D8mGyWmt.mjs} +3 -3
- package/package.json +1 -1
- package/dist/client/assets/PullRequestCodePanel-CDmYMNEt.js +0 -5
- package/dist/client/assets/index-DB-C-45R.css +0 -1
- package/dist/client/assets/index-zQmFiQS7.js +0 -151
- package/dist/client/assets/src-BSCF6BY3.js +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-2W3EstLn.js","assets/rolldown-runtime-hePW80VL.js","assets/workspaceReadinessAtom-DZAbFDrM.js","assets/atomRegistry-C-gODSji.js","assets/Stream-C4tOsbfQ.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,$i as i,$t as a,Ai as o,An as s,Ar as c,At as l,B as u,Ba as d,Bn as f,Br as p,Bt as m,C as h,Ci as g,Cn as _,Da as v,Dn as y,Dt as b,Ei as x,En as S,Er as C,Et as w,F as T,Fn as E,Fr as D,Ft as O,Gn as ee,Gt as te,Hn as k,Hr as A,Ht as ne,Ir as j,It as re,J as ie,Ji as ae,Jn as oe,Jt as se,K as ce,Ki as le,Kn as ue,Kt as de,L as fe,Ln as pe,Lr as me,Lt as he,M as ge,Ma as _e,Mi as ve,Mr as ye,Mt as be,N as xe,Na as Se,Nn as eee,Nt as Ce,O as tee,Oa as nee,On as ree,Ot as iee,P as aee,Pa as we,Pn as Te,Pt as Ee,Qn as De,Qt as oee,R as Oe,Ra as ke,Rn as Ae,Rr as je,Rt as see,Sa as Me,Sn as cee,T as Ne,Ta as lee,Tn as uee,Tr as Pe,Tt as Fe,U as Ie,Un as Le,Ur as Re,Ut as dee,V as fee,Va as pee,Vn as ze,Vr as Be,Vt as Ve,W as He,Wn as mee,Wr as hee,Wt as gee,X as _ee,Xn as vee,Y as yee,Yi as Ue,Yn as We,Yt as bee,Z as Ge,Zi as Ke,Zn as xee,Zt as See,_ as Cee,_i as wee,_n as Tee,_r as Eee,_t as Dee,aa as qe,ai as Oee,an as kee,at as Je,bi as Aee,bn as jee,br as Mee,bt as Ye,ci as Nee,cn as Xe,ct as Ze,di as Pee,dn as Fee,dr as Iee,dt as Qe,ei as Lee,en as $e,er as Ree,et,fr as zee,ft as tt,gn as nt,gt as rt,hn as it,hr as at,ht as ot,in as st,it as Bee,j as ct,ja as Vee,ji as lt,jn as ut,jr as Hee,jt as dt,ka as Uee,ki as Wee,kr as Gee,kt as ft,li as Kee,ln as qee,m as Jee,ma as pt,mi as mt,mn as ht,mr as gt,mt as _t,ni as Yee,nr as vt,nt as yt,oi as bt,on as Xee,or as xt,pn as St,pt as Ct,q as wt,qn as Tt,qt as Zee,r as Qee,ra as $ee,rn as Et,rr as ete,rt as tte,s as nte,si as Dt,sn as rte,st as Ot,ti as ite,ui as kt,un as At,ut as jt,vn as Mt,vr as ate,vt as ote,w as Nt,wi as ste,wn as cte,wr as lte,wt as Pt,x as ute,xi as dte,xn as Ft,y as fte,yi as pte,yn as It,yt as mte,z as Lt,za as hte,zn as Rt,zt as gte}from"./Stream-C4tOsbfQ.js";import{i as _te,l as zt,n as Bt,o as Vt,s as Ht}from"./atomRegistry-C-gODSji.js";import{An as Ut,Fn as vte,Mn as Wt,Nn as yte,Pn as bte,Sn as xte,Z as Ste,_ as Cte,_n as Gt,b as Kt,g as qt,gn as Jt,i as wte,pn as Yt,v as Tte,xn as Xt,y as Ete}from"./CompositeItem-khilqBJh.js";import{$t as Dte,An as Zt,At as Ote,B as kte,Bn as Ate,Bt as Qt,Cn as $t,Ct as en,D as jte,Dn as tn,Dt as nn,E as rn,En as Mte,Et as an,F as Nte,Ft as on,Gt as Pte,H as sn,Ht as cn,In as Fte,It as Ite,J as ln,Jt as Lte,Kt as un,L as Rte,Ln as zte,Lt as dn,Mn as fn,Mt as pn,Nn as mn,Nt as Bte,O as Vte,On as Hte,Ot as hn,Pn as Ute,Pt as Wte,Q as Gte,Qt as Kte,Rn as qte,Rt as gn,S as Jte,Sn as _n,T as vn,Tn as Yte,Ut as yn,V as bn,Vn as Xte,Vt as xn,Wn as Zte,Wt as Qte,X as Sn,Xt as $te,Y as Cn,Yt as ene,Zt as wn,_n as Tn,a as M,an as En,bn as Dn,bt as tne,c as On,cn as kn,ct as nne,d as rne,dn as An,en as ine,et as jn,f as ane,fn as Mn,ft as Nn,g as Pn,gn as Fn,hn as one,ht as sne,i as cne,in as In,it as lne,jn as Ln,jt as une,k as Rn,kt as dne,l as fne,ln as pne,m as mne,mn as zn,mt as hne,n as gne,nn as Bn,nt as Vn,o as Hn,pn as Un,pt as Wn,qn as Gn,qt as _ne,rn as Kn,s as qn,st as Jn,t as vne,tn as Yn,tt as yne,u as bne,un as Xn,ut as xne,v as Zn,vt as Sne,wn as Qn,x as Cne,xn as $n,xt as er,y as wne,zn as Tne,zt as tr}from"./src-BSCF6BY3.js";import{A as nr,D as rr,E as ir,F as Ene,I as ar,M as Dne,O as or,P as One,S as kne,_ as Ane,a as sr,b as jne,c as Mne,j as cr,k as lr,l as Nne,n as ur,s as Pne,u as Fne,v as Ine,w as dr,x as Lne,y as Rne}from"./cmmdAuthRedirect-B6WFFIw6.js";import{t as N}from"./preload-helper-Czpn1I53.js";import{n as P,t as fr}from"./transport-CgH8pQK3.js";import{n as zne,t as Bne}from"./workspaceReadinessAtom-DZAbFDrM.js";function Vne(e){return e[e.length-1]}function Hne(e,t){return typeof e==`function`?e(t):e}var pr=Object.prototype.hasOwnProperty,Une=Object.prototype.propertyIsEnumerable;function Wne(e){for(let t in e)if(pr.call(e,t))return!0;return!1}var Gne=()=>Object.create(null),Kne=(e,t)=>mr(e,t,Gne);function mr(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=vr(e)&&vr(i);if(!a&&!(gr(e)&&gr(i)))return i;let o=a?e:hr(e);if(!o)return i;let s=a?i:hr(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:pr.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=mr(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function hr(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(!Une.call(e,r))return!1;t.push(r)}return t}function gr(e){if(!_r(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!_r(n)||!n.hasOwnProperty(`isPrototypeOf`))}function _r(e){return Object.prototype.toString.call(e)===`[object Object]`}function vr(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function yr(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(!yr(e[r],t[r],n))return!1;return!0}if(gr(e)&&gr(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!yr(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||!yr(e[o],t[o],n)))return!1;return i===a}return!1}var qne=/[\x00-\x1f\x7f"<>`{}]/g;function Jne(e){return e.replace(qne,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function br(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 Jne(t)}var Yne=[`http:`,`https:`,`mailto:`,`tel:`];function Xne(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+=br(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=br(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function Qne(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function $ne(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 xr(){throw Error(`Invariant failed`)}var F=t(pee(),1),Sr=F.createContext(null);function Cr(e){return F.useContext(Sr)}var wr=F.createContext(void 0),ere=F.createContext(void 0),tre=vte();function nre(e,t){return e===t}function Tr(e,t,n=nre){let r=(0,F.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,F.useCallback)(()=>e?.get(),[e]);return(0,tre.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var Er={};function Dr(e,t){let n=F.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=mr(n.current,i):i}}function Or(e){let t=Cr(),n=F.useContext(e.from?ere:wr),r=e.from??n,i=t.stores.getMatchStore(r),a=Dr(e,t),o=Tr(i,e=>e?a(e):Er);if(o!==Er)return o;(e.shouldThrow??!0)&&xr()}function rre(e){return Or({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 kr=d(),Ar=typeof window<`u`&&(window.desktopBridge!==void 0||window.nativeApi!==void 0),jr=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(){}},Mr=new class extends jr{#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`}},ire={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Nr=new class{#e=ire;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 are(e){setTimeout(e,0)}var ore=typeof window>`u`||`Deno`in globalThis;function Pr(){}function sre(e,t){return typeof e==`function`?e(t):e}function Fr(e){return typeof e==`number`&&e>=0&&e!==1/0}function Ir(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Lr(e,t){return typeof e==`function`?e(t):e}function Rr(e,t){return typeof e==`function`?e(t):e}function cre(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==zr(o,t.options))return!1}else if(!Vr(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 lre(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Br(t.options.mutationKey)!==Br(a))return!1}else if(!Vr(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function zr(e,t){return(t?.queryKeyHashFn||Br)(e)}function Br(e){return JSON.stringify(e,(e,t)=>Gr(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Vr(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(!Vr(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Vr(e[r],t[r]))return!1;return!0}return!1}var ure=Object.prototype.hasOwnProperty;function Hr(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Wr(e)&&Wr(t);if(!r&&!(Gr(e)&&Gr(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:ure.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Hr(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Ur(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 Wr(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Gr(e){if(!Kr(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Kr(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Kr(e){return Object.prototype.toString.call(e)===`[object Object]`}function dre(e){return new Promise(t=>{Nr.setTimeout(t,e)})}function qr(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Hr(e,t)}function fre(e){return e}function pre(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function mre(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Jr=Symbol();function Yr(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Jr?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Xr(e,t){return typeof e==`function`?e(...t):!!e}function hre(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 Zr=(()=>{let e=()=>ore;return{isServer(){return e()},setIsServer(t){e=t}}})();function Qr(){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 gre=are;function _re(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=gre,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 $r=_re(),ei=new class extends jr{#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 vre(e){return Math.min(1e3*2**e,3e4)}function ti(e){return(e??`online`)!==`online`||ei.isOnline()}var ni=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function ri(e){let t=!1,n=0,r,i=Qr(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new ni(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>Mr.isFocused()&&(e.networkMode===`always`||ei.isOnline())&&e.canRun(),u=()=>ti(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??(Zr.isServer()?0:3),o=e.retryDelay??vre,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),dre(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 ii=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Fr(this.gcTime)&&(this.#e=Nr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Zr.isServer()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(Nr.clearTimeout(this.#e),this.#e=void 0)}};function yre(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=>{hre(e,()=>t.signal,()=>n=!0)},u=Yr(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?mre:pre;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?oi:ai,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:ai(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 ai(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 oi(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function bre(e,t){return t?ai(e,t)!=null:!1}function xre(e,t){return!t||!e.getPreviousPageParam?!1:oi(e,t)!=null}var Sre=class extends ii{#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=li(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=li(this.options);e.data!==void 0&&(this.setState(ci(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=qr(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(Pr).catch(Pr):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=>Rr(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Jr||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Lr(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:!Ir(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=Yr(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`?yre(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=ri({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof ni&&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 ni){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,...si(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...ci(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),$r.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function si(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ti(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function ci(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function li(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 ui=class extends jr{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=Qr(),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),di(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return fi(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return fi(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 Rr(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&&!Ur(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&pi(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Rr(this.options.enabled,this.#t)!==Rr(t.enabled,this.#t)||Lr(this.options.staleTime,this.#t)!==Lr(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Rr(this.options.enabled,this.#t)!==Rr(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 wre(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(Pr)),t}#g(){this.#b();let e=Lr(this.options.staleTime,this.#t);if(Zr.isServer()||this.#r.isStale||!Fr(e))return;let t=Ir(this.#r.dataUpdatedAt,e)+1;this.#d=Nr.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,!(Zr.isServer()||Rr(this.options.enabled,this.#t)===!1||!Fr(this.#p)||this.#p===0)&&(this.#f=Nr.setInterval(()=>{(this.options.refetchIntervalInBackground||Mr.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(Nr.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(Nr.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&&di(e,t),o=i&&pi(e,n,t,r);(a||o)&&(l={...l,...si(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=qr(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=qr(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:mi(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Rr(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=Qr();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),!Ur(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){$r.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function Cre(e,t){return Rr(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||Rr(t.retryOnMount,e)!==!1)}function di(e,t){return Cre(e,t)||e.state.data!==void 0&&fi(e,t,t.refetchOnMount)}function fi(e,t,n){if(Rr(t.enabled,e)!==!1&&Lr(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&mi(e,t)}return!1}function pi(e,t,n,r){return(e!==t||Rr(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&mi(e,n)}function mi(e,t){return Rr(t.enabled,e)!==!1&&e.isStaleByTime(Lr(t.staleTime,e))}function wre(e,t){return!Ur(e.getCurrentResult(),t)}var hi=F.createContext(void 0),gi=e=>{let t=F.useContext(hi);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Tre=({client:e,children:t})=>(F.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,kr.jsx)(hi.Provider,{value:e,children:t})),_i=F.createContext(!1),vi=()=>F.useContext(_i);_i.Provider;function Ere(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Dre=F.createContext(Ere()),yi=()=>F.useContext(Dre),bi=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Xr(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},xi=e=>{F.useEffect(()=>{e.clearReset()},[e])},Si=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Xr(n,[e.error,r])),Ci=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))}},Ore=(e,t)=>e.isLoading&&e.isFetching&&!t,wi=(e,t)=>e?.suspense&&t.isPending,Ti=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ei(e,t,n){let r=vi(),i=yi(),a=gi(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,Ci(o),bi(o,i,s),xi(i);let l=!a.getQueryCache().get(o.queryHash),[u]=F.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(F.useSyncExternalStore(F.useCallback(e=>{let t=f?u.subscribe($r.batchCalls(e)):Pr;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),F.useEffect(()=>{u.setOptions(o)},[o,u]),wi(o,d))throw Ti(o,u,i);if(Si({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&&!Zr.isServer()&&Ore(d,r)&&(l?Ti(o,u,i):s?.promise)?.catch(Pr).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function Di(e,t){return Ei(e,ui,t)}function kre(e){return e}var Are={[Symbol.iterator](){return jre}},jre={next(){return{done:!0,value:void 0}}},Mre=()=>Are,Nre=C,Oi=globalThis.Number,Pre=e=>{if(e===`NaN`)return ve(NaN);if(e===`Infinity`)return ve(1/0);if(e===`-Infinity`)return ve(-1/0);if(e.trim()===``)return lt();let t=Oi(e);return Oi.isNaN(t)?lt():ve(t)},Fre=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`]],ki=`~effect/http/HttpClientRequest`,Ire={[ki]:ki,...Ue,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:$ee(this.headers),body:this.body.toJSON()}},pipe(){return ke(this,arguments)}};function Ai(e,t,n,r,i,a){let o=Object.create(Ire);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var Lre=Ai(`GET`,``,_ne,lt(),dn,Pte),ji=e=>(t,n)=>zre(Lre,{method:e,url:t,...n??void 0}),Rre=ji(`POST`),zre=_e(2,(e,t)=>{let n=e;return t.method&&(n=Bre(n,t.method)),t.url&&(n=Ure(n,t.url)),t.headers&&(n=Mi(n,t.headers)),t.urlParams&&(n=Wre(n,t.urlParams)),t.hash&&(n=Gre(n,t.hash)),t.body&&(n=Pi(n,t.body)),t.accept&&(n=Ni(n,t.accept)),t.acceptJson&&(n=Hre(n)),n}),Bre=_e(2,(e,t)=>Ai(t,e.url,e.urlParams,e.hash,e.headers,e.body)),Vre=_e(3,(e,t,n)=>Ai(e.method,e.url,e.urlParams,e.hash,yn(e.headers,t,n),e.body)),Mi=_e(2,(e,t)=>Ai(e.method,e.url,e.urlParams,e.hash,Qte(e.headers,t),e.body)),Ni=_e(2,(e,t)=>Vre(e,`Accept`,t)),Hre=Ni(`application/json`),Ure=_e(2,(e,t)=>{if(typeof t==`string`)return Ai(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Lte(n.searchParams),i=pte(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,Ai(e.method,n.toString(),r,i,e.headers,e.body)}),Wre=_e(2,(e,t)=>Ai(e.method,e.url,$te(e.urlParams,t),e.hash,e.headers,e.body)),Gre=_e(2,(e,t)=>Ai(e.method,e.url,e.urlParams,ve(t),e.headers,e.body)),Pi=_e(2,(e,t)=>{let n=e.headers;return t._tag===`Empty`||t._tag===`FormData`?n=cn(cn(n,`Content-Type`),`Content-length`):(t.contentType&&(n=yn(n,`content-type`,t.contentType)),t.contentLength!==void 0&&(n=yn(n,`content-length`,t.contentLength.toString()))),Ai(e.method,e.url,e.urlParams,e.hash,n,t)}),Kre=e=>tr({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${o(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),Fi=`~effect/http/HttpClient`,Ii=Dt(`effect/HttpClient`),Li=_e(2,(e,t)=>Ri(n=>t(e.postprocess(n)),e.preprocess)),qre=Li(yt(Bte)),Ri=(e,t)=>{let n=Object.create(Jre);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},Jre={[Fi]:Fi,pipe(){return ke(this,arguments)},...Ue,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(Fre.map(([e,t])=>[t,function(t,n){return this.execute(ji(e)(t,n))}]))},Yre=e=>Ri(t=>yt(t,t=>Mt(n=>{let i=$re.get(t),a=i??new AbortController,o=ene(t.url,t.urlParams,g(t.hash));if(ite(o))return r(new wn({reason:new Dte({request:t,cause:o.failure})}));let s=o.success;if(n.getRef(Gee)||n.getRef(zi)(t)){let r=e(t,s,a.signal,n);return i?r:St(e=>Fe(e(r),{onSuccess(e){return Vi.register(e,a),$e(new Hi(e,a))},onFailure(e){return gt(e)&&a.abort(),et(e)}}))}return it(n.getRef(Zre)(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(Ite),l=xn(t.headers,c);for(let e in l)r.attribute(`http.request.header.${e}`,String(l[e]));return t=n.getRef(Bi)?Mi(t,Kre(r)):t,St(o=>o(e(t,s,a.signal,n)).pipe(It(r,{captureStackTrace:!1}),Fe({onSuccess:e=>{r.attribute(`http.response.status_code`,e.status);let t=xn(e.headers,c);for(let e in t)r.attribute(`http.response.header.${e}`,String(t[e]));return i?$e(e):(Vi.register(e,a),$e(new Hi(e,a)))},onFailure(e){return!i&>(e)&&a.abort(),et(e)}})))})})),$e),Xre=_e(2,(e,t)=>{let n=uee(t),r=n?`errors-and-responses`:t.retryOn??`errors-and-responses`,i=n?t:t.schedule,a=i&&S(i),o=n?void 0:t.times;return Li(e,Se(r===`errors-only`?we:re({schedule:a,times:o,while:Wi}),r===`response-only`?we:he({while:n||t.while===void 0?Ui:v(Ui,t.while),schedule:i,times:o})))}),zi=bt(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>nee}),Bi=bt(`effect/HttpClient/TracerPropagationEnabled`,{defaultValue:Uee}),Zre=bt(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),Qre=e=>ut(Ii)(ie(t=>Ye(e,e=>Li(e,ht(e=>mt(t,e)))))),Vi=(()=>{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))}}})(),$re=new WeakMap,Hi=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[pn]=pn;[on]=on;applyInterrupt(e){return Et(()=>(Vi.unregister(this.original),ft(e,()=>st(()=>{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 Cee(()=>(Vi.unregister(this.original),Qee(this.original.stream,st(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Ke](){return this.original[Ke]()}pipe(){return ke(this,arguments)}},Ui=e=>Mee(e)||eie(e),eie=e=>Yn(e)&&(e.reason._tag===`TransportError`||e.reason._tag===`StatusCodeError`&&Wi(e.reason.response)),Wi=e=>e.status===408||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504,Gi=`~effect/FiberSet`,Ki=e=>pt(e,Gi),qi={[Gi]:Gi,[Symbol.iterator](){return this.state._tag===`Closed`?Mre():this.state.backing[Symbol.iterator]()},...le,toJSON(){return{_id:`FiberMap`,state:this.state}}},Ji=(e,t)=>{let n=Object.create(qi);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},Yi=()=>Oe(st(()=>Ji(new Set,We())),e=>Et(()=>{let t=e.state;if(t._tag===`Closed`)return nt;e.state={_tag:`Closed`};let n=t.backing;return T(n).pipe(oe(e.deferred))})),Xi=-1,tie=me(D(Iee,j(Xi))),nie=_e(e=>Ki(e[0]),(e,t,n)=>{if(e.state._tag===`Closed`){t.interruptUnsafe(Xi);return}e.state.backing.has(t)||(e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),vt(r)&&(n?.propagateInterruption===!0?!tie(r.cause):!at(r.cause))&&Tt(e.deferred,r))}))}),rie=function(){let e;return()=>(e===void 0&&(e=m(_t)),e)}(),iie=e=>()=>Ye(wt(),t=>{let n=Ve(t);return(t,r)=>{if(e.state._tag===`Closed`)return rie();let i=n(t,r);return nie(e,i),i}}),Zi=e=>ue(e.deferred),Qi=`~effect/socket/Socket`,$i=Dt(`effect/socket/Socket`),aie=`~effect/socket/Socket/CloseEvent`,oie=e=>pt(e,aie),ea=`~effect/socket/Socket/SocketError`,sie=e=>pt(e,ea),ta=class extends En(`effect/socket/Socket/SocketReadError`)({_tag:fn(`SocketReadError`),cause:In}){message=`An error occurred during Read`},cie=class extends En(`effect/socket/Socket/SocketWriteError`)({_tag:fn(`SocketWriteError`),cause:In}){message=`An error occurred during Write`},na=class extends En(`effect/socket/Socket/SocketOpenError`)({_tag:fn(`SocketOpenError`),kind:kn([`Unknown`,`Timeout`]),cause:In}){get message(){return this.kind===`Timeout`?`timeout waiting for "open"`:`An error occurred during Open`}},ra=class extends En(`effect/socket/Socket/SocketCloseError`)({_tag:fn(`SocketCloseError`),code:An,closeReason:Zt(Un)}){static filterClean(e){return function(t){return aa.is(t)&&t.reason._tag===`SocketCloseError`&&e(t.reason.code)?Oee(t.reason):Lee(t)}}get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},ia=Tn([ta,cie,na,ra]),aa=class extends one(ea)(`SocketError`,{_tag:fn(`SocketError`),reason:ia}){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[ea]=ea;static is(e){return sie(e)}message=this.reason.message},lie=e=>!0,uie=class extends Dt()(`~effect/socket/Socket/WebSocket`){},oa=class extends Dt()(`@effect/platform/Socket/WebSocketConstructor`){},die=(e,t)=>oa.use(n=>fie(Oe((typeof e==`string`?$e(e):e).pipe(Ye(e=>n(e,t?.protocols))),e=>st(()=>e.close(1e3))),t)),fie=(e,t)=>Mt(n=>{let i,a=ct(!1),o=n.context,s=t?.closeCodeIsError??lie,c=(n,c)=>See(Je(function*(o){let l=yield*Yi().pipe(ee(o)),u=yield*ee(e,o),d=yield*Ee(iie(l)(),uie,u),f=!1;function p(e){if(e.data instanceof Blob){let t=yt(dt(()=>e.data.arrayBuffer()),e=>{let t=n(new Uint8Array(e));return rt(t)?t:nt});return d(t)}let t=n(e.data);rt(t)&&d(t)}function m(e){u.removeEventListener(`message`,p),u.removeEventListener(`close`,h),Tt(l.deferred,r(new aa({reason:f?new ta({cause:e}):new na({kind:`Unknown`,cause:e})})))}function h(e){let t=typeof e.code==`number`?e.code:1001;u.removeEventListener(`message`,p),u.removeEventListener(`error`,m),Tt(l.deferred,r(new aa({reason:new ra({code:t,closeReason:e.reason})})))}if(u.addEventListener(`close`,h,{once:!0}),u.addEventListener(`error`,m,{once:!0}),u.addEventListener(`message`,p),u.readyState!==1){let e=We();u.addEventListener(`open`,()=>{f=!0,Tt(e,nt)},{once:!0}),yield*ue(e).pipe(At({duration:t?.openTimeout??1e4,orElse:()=>r(new aa({reason:new na({kind:`Timeout`,cause:Error(`timeout waiting for "open"`)})}))}),O(Zi(l)))}return f=!0,i=u,a.openUnsafe(),c?.onOpen&&(yield*c.onOpen),yield*ce(Zi(l),ra.filterClean(e=>!s(e)),()=>nt)})).pipe(ht(e=>mt(o,e)),Ge(st(()=>{a.closeUnsafe(),i=void 0}))),l=new TextEncoder,u=(e,t)=>c(t=>typeof t==`string`?e(l.encode(t)):t instanceof Uint8Array?e(t):e(new Uint8Array(t)),t),d=$e(e=>a.whenOpen(st(()=>{let t=i;oie(e)?t.close(e.code,e.reason):t.send(e)})));return $e($i.of({[Qi]:Qi,run:u,runRaw:c,writer:d}))}),sa=Se(die,ut($i)),ca=class extends Dt()(`effect/workers/Transferable/Collector`){},pie=()=>{let e=[],t=t=>{e.push(...t)},n=()=>e,r=()=>{let t=e;return e=[],t};return ca.of({addAllUnsafe:t,addAll:e=>st(()=>t(e)),readUnsafe:n,read:st(n),clearUnsafe:r,clear:st(r)})},mie=`~effect/workers/WorkerError`,hie=class extends En(`effect/workers/WorkerError/WorkerSpawnError`)({_tag:fn(`WorkerSpawnError`),message:Un,cause:Zt(In)}){},gie=class extends En(`effect/workers/WorkerError/WorkerSendError`)({_tag:fn(`WorkerSendError`),message:Un,cause:Zt(In)}){},_ie=class extends En(`effect/workers/WorkerError/WorkerReceiveError`)({_tag:fn(`WorkerReceiveError`),message:Un,cause:Zt(In)}){},vie=class extends En(`effect/workers/WorkerError/WorkerUnknownError`)({_tag:fn(`WorkerUnknownError`),message:Un,cause:Zt(In)}){},la=Tn([hie,gie,_ie,vie]);En(mie)({_tag:fn(`WorkerError`),reason:la});var ua=`~effect/rpc/RpcClientError`,da=class extends En(`effect/rpc/RpcClientError/RpcClientDefect`)({_tag:fn(`RpcClientDefect`),message:Un,cause:In}){},fa=class extends En(ua)({_tag:fn(`RpcClientError`),reason:Tn([la,ia,Kte,da])}){[ua]=ua;get message(){return`${this.reason._tag}: ${this.reason.message}`}},pa=e=>typeof e==`bigint`?e:BigInt(e),yie={_tag:`Ping`},ma;try{ma=new TextDecoder}catch{}var I,ha,L=0,ga=[],_a=ga,va=0,ya={},ba,xa,Sa=0,Ca=0,wa,Ta,Ea=[],Da,Oa={useRecords:!1,mapsAsObjects:!0},ka=class{},Aa=new ka;Aa.name=`MessagePack 0xC1`;var ja=!1,Ma=2,Na,Pa,Fa;try{Function(``)}catch{Ma=1/0}var Ia=class e{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=0&&(e.structures=[],e.maxSharedStructures||=0)),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType=`number`)),Object.assign(this,e)}unpack(t,n){if(I)return ao(()=>(oo(),this?this.unpack(t,n):e.prototype.unpack.call(Oa,t,n)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<`u`?Buffer.from(t):new Uint8Array(t)),typeof n==`object`?(ha=n.end||t.length,L=n.start||0):(L=0,ha=n>-1?n:t.length),va=0,Ca=0,xa=null,_a=ga,wa=null,I=t;try{Da=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(e){throw I=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(ya=this,this.structures)return ba=this.structures,La(n);(!ba||ba.length>0)&&(ba=[])}else ya=Oa,(!ba||ba.length>0)&&(ba=[]);return La(n)}unpackMultiple(e,t){let n,r=0;try{ja=!0;let i=e.length,a=this?this.unpack(e,i):co.unpack(e,i);if(t){if(t(a,r,L)===!1)return;for(;L<i;)if(r=L,t(La(),r,L)===!1)return}else{for(n=[a];L<i;)r=L,n.push(La());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{ja=!1,oo()}}_mergeStructures(e,t){Pa&&(e=Pa.call(this,e)),e||=[],Object.isFrozen(e)&&(e=e.map(e=>e.slice(0)));for(let t=0,n=e.length;t<n;t++){let n=e[t];n&&(n.isShared=!0,t>=32&&(n.highByte=t-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let r=e[n],i=t[n];i&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[n]=r),e[n]=i)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function La(e){try{if(!ya.trusted&&!ja){let e=ba.sharedLength||0;e<ba.length&&(ba.length=e)}let t;if(ya.randomAccessStructure&&I[L]<64&&I[L]>=32&&Na?(t=Na(I,L,ha,ya),I=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),L=ha):t=za(),wa&&=(L=wa.postBundlePosition,null),ja&&(ba.restoreStructures=null),L==ha)ba&&ba.restoreStructures&&Ra(),ba=null,I=null,Ta&&=null;else if(L>ha)throw Error(`Unexpected end of MessagePack data`);else if(!ja){let e;try{e=JSON.stringify(t,(e,t)=>typeof t==`bigint`?`${t}n`:t).slice(0,100)}catch(t){e=`(JSON view not available `+t+`)`}throw Error(`Data read, but end of buffer not reached `+e)}return t}catch(e){throw ba&&ba.restoreStructures&&Ra(),oo(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`)||L>ha)&&(e.incomplete=!0),e}}function Ra(){for(let e in ba.restoreStructures)ba[e]=ba.restoreStructures[e];ba.restoreStructures=null}function za(){let e=I[L++];if(e<160)if(e<128){if(e<64)return e;{let t=ba[e&63]||ya.getStructures&&Ha()[e&63];return t?(t.read||=Ba(t,e&63),t.read()):e}}else if(e<144){if(e-=128,ya.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=eo();e===`__proto__`&&(e=`__proto_`),t[e]=za()}return t}{let t=new Map;for(let n=0;n<e;n++)t.set(za(),za());return t}}else{e-=144;let t=Array(e);for(let n=0;n<e;n++)t[n]=za();return ya.freezeData?Object.freeze(t):t}if(e<192){let t=e-160;if(Ca>=L)return xa.slice(L-Sa,(L+=t)-Sa);if(Ca==0&&ha<140){let e=t<16?Ya(t):Ja(t);if(e!=null)return e}return Ua(t)}{let t;switch(e){case 192:return null;case 193:return wa?(t=za(),t>0?wa[1].slice(wa.position1,wa.position1+=t):wa[0].slice(wa.position0,wa.position0-=t)):Aa;case 194:return!1;case 195:return!0;case 196:if(t=I[L++],t===void 0)throw Error(`Unexpected end of buffer`);return Za(t);case 197:return t=Da.getUint16(L),L+=2,Za(t);case 198:return t=Da.getUint32(L),L+=4,Za(t);case 199:return Qa(I[L++]);case 200:return t=Da.getUint16(L),L+=2,Qa(t);case 201:return t=Da.getUint32(L),L+=4,Qa(t);case 202:if(t=Da.getFloat32(L),ya.useFloat32>2){let e=so[(I[L]&127)<<1|I[L+1]>>7];return L+=4,(e*t+(t>0?.5:-.5)>>0)/e}return L+=4,t;case 203:return t=Da.getFloat64(L),L+=8,t;case 204:return I[L++];case 205:return t=Da.getUint16(L),L+=2,t;case 206:return t=Da.getUint32(L),L+=4,t;case 207:return ya.int64AsType===`number`?(t=Da.getUint32(L)*4294967296,t+=Da.getUint32(L+4)):ya.int64AsType===`string`?t=Da.getBigUint64(L).toString():ya.int64AsType===`auto`?(t=Da.getBigUint64(L),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=Da.getBigUint64(L),L+=8,t;case 208:return Da.getInt8(L++);case 209:return t=Da.getInt16(L),L+=2,t;case 210:return t=Da.getInt32(L),L+=4,t;case 211:return ya.int64AsType===`number`?(t=Da.getInt32(L)*4294967296,t+=Da.getUint32(L+4)):ya.int64AsType===`string`?t=Da.getBigInt64(L).toString():ya.int64AsType===`auto`?(t=Da.getBigInt64(L),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=Da.getBigInt64(L),L+=8,t;case 212:if(t=I[L++],t==114)return no(I[L++]&63);{let e=Ea[t];if(e)return e.read?(L++,e.read(za())):e.noBuffer?(L++,e()):e(I.subarray(L,++L));throw Error(`Unknown extension `+t)}case 213:return t=I[L],t==114?(L++,no(I[L++]&63,I[L++])):Qa(2);case 214:return Qa(4);case 215:return Qa(8);case 216:return Qa(16);case 217:return t=I[L++],Ca>=L?xa.slice(L-Sa,(L+=t)-Sa):xie(t);case 218:return t=Da.getUint16(L),L+=2,Ca>=L?xa.slice(L-Sa,(L+=t)-Sa):Sie(t);case 219:return t=Da.getUint32(L),L+=4,Ca>=L?xa.slice(L-Sa,(L+=t)-Sa):Cie(t);case 220:return t=Da.getUint16(L),L+=2,Ga(t);case 221:return t=Da.getUint32(L),L+=4,Ga(t);case 222:return t=Da.getUint16(L),L+=2,Ka(t);case 223:return t=Da.getUint32(L),L+=4,Ka(t);default:if(e>=224)return e-256;if(e===void 0){let e=Error(`Unexpected end of MessagePack data`);throw e.incomplete=!0,e}throw Error(`Unknown MessagePack token `+e)}}}var bie=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Ba(e,t){function n(){if(n.count++>Ma){let n=e.read=Function(`r`,`return function(){return `+(ya.freezeData?`Object.freeze`:``)+`({`+e.map(e=>e===`__proto__`?`__proto_:r()`:bie.test(e)?e+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`})}`)(za);return e.highByte===0&&(e.read=Va(t,e.read)),n()}let r={};for(let t=0,n=e.length;t<n;t++){let n=e[t];n===`__proto__`&&(n=`__proto_`),r[n]=za()}return ya.freezeData?Object.freeze(r):r}return n.count=0,e.highByte===0?Va(t,n):n}var Va=(e,t)=>function(){let n=I[L++];if(n===0)return t();let r=e<32?-(e+(n<<5)):e+(n<<5),i=ba[r]||Ha()[r];if(!i)throw Error(`Record id is not defined for `+r);return i.read||=Ba(i,e),i.read()};function Ha(){let e=ao(()=>(I=null,ya.getStructures()));return ba=ya._mergeStructures(e,ba)}var Ua=Wa,xie=Wa,Sie=Wa,Cie=Wa;function Wa(e){let t;if(e<16&&(t=Ya(e)))return t;if(e>64&&ma)return ma.decode(I.subarray(L,L+=e));let n=L+e,r=[];for(t=``;L<n;){let e=I[L++];if(!(e&128))r.push(e);else if((e&224)==192){let t=I[L++]&63,n=(e&31)<<6|t;n<128?r.push(65533):r.push(n)}else if((e&240)==224){let t=I[L++]&63,n=I[L++]&63,i=(e&31)<<12|t<<6|n;i<2048||i>=55296&&i<=57343?r.push(65533):r.push(i)}else if((e&248)==240){let t=I[L++]&63,n=I[L++]&63,i=I[L++]&63,a=(e&7)<<18|t<<12|n<<6|i;a<65536||a>1114111?r.push(65533):a>65535?(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023,r.push(a)):r.push(a)}else r.push(65533);r.length>=4096&&(t+=qa.apply(String,r),r.length=0)}return r.length>0&&(t+=qa.apply(String,r)),t}function Ga(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=za();return ya.freezeData?Object.freeze(t):t}function Ka(e){if(ya.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=eo();e===`__proto__`&&(e=`__proto_`),t[e]=za()}return t}{let t=new Map;for(let n=0;n<e;n++)t.set(za(),za());return t}}var qa=String.fromCharCode;function Ja(e){let t=L,n=Array(e);for(let r=0;r<e;r++){let e=I[L++];if((e&128)>0){L=t;return}n[r]=e}return qa.apply(String,n)}function Ya(e){if(e<4)if(e<2){if(e===0)return``;{let e=I[L++];if((e&128)>1){--L;return}return qa(e)}}else{let t=I[L++],n=I[L++];if((t&128)>0||(n&128)>0){L-=2;return}if(e<3)return qa(t,n);let r=I[L++];if((r&128)>0){L-=3;return}return qa(t,n,r)}{let t=I[L++],n=I[L++],r=I[L++],i=I[L++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){L-=4;return}if(e<6){if(e===4)return qa(t,n,r,i);{let e=I[L++];if((e&128)>0){L-=5;return}return qa(t,n,r,i,e)}}if(e<8){let a=I[L++],o=I[L++];if((a&128)>0||(o&128)>0){L-=6;return}if(e<7)return qa(t,n,r,i,a,o);let s=I[L++];if((s&128)>0){L-=7;return}return qa(t,n,r,i,a,o,s)}{let a=I[L++],o=I[L++],s=I[L++],c=I[L++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){L-=8;return}if(e<10){if(e===8)return qa(t,n,r,i,a,o,s,c);{let e=I[L++];if((e&128)>0){L-=9;return}return qa(t,n,r,i,a,o,s,c,e)}}if(e<12){let l=I[L++],u=I[L++];if((l&128)>0||(u&128)>0){L-=10;return}if(e<11)return qa(t,n,r,i,a,o,s,c,l,u);let d=I[L++];if((d&128)>0){L-=11;return}return qa(t,n,r,i,a,o,s,c,l,u,d)}{let l=I[L++],u=I[L++],d=I[L++],f=I[L++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){L-=12;return}if(e<14){if(e===12)return qa(t,n,r,i,a,o,s,c,l,u,d,f);{let e=I[L++];if((e&128)>0){L-=13;return}return qa(t,n,r,i,a,o,s,c,l,u,d,f,e)}}{let p=I[L++],m=I[L++];if((p&128)>0||(m&128)>0){L-=14;return}if(e<15)return qa(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=I[L++];if((h&128)>0){L-=15;return}return qa(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function Xa(){let e=I[L++],t;if(e<192)t=e-160;else switch(e){case 217:t=I[L++];break;case 218:t=Da.getUint16(L),L+=2;break;case 219:t=Da.getUint32(L),L+=4;break;default:throw Error(`Expected string`)}return Wa(t)}function Za(e){return ya.copyBuffers?Uint8Array.prototype.slice.call(I,L,L+=e):I.subarray(L,L+=e)}function Qa(e){let t=I[L++];if(Ea[t]){let n;return Ea[t](I.subarray(L,n=L+=e),e=>{L=e;try{return za()}finally{L=n}})}throw Error(`Unknown extension type `+t)}var $a=Array(4096);function eo(){let e=I[L++];if(e>=160&&e<192){if(e-=160,Ca>=L)return xa.slice(L-Sa,(L+=e)-Sa);if(!(Ca==0&&ha<180))return Ua(e)}else return L--,to(za());let t=(e<<5^(e>1?Da.getUint16(L):e>0?I[L]:0))&4095,n=$a[t],r=L,i=L+e-3,a,o=0;if(n&&n.bytes==e){for(;r<i;){if(a=Da.getUint32(r),a!=n[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(a=I[r++],a!=n[o++]){r=1879048192;break}if(r===i)return L=r,n.string;i-=3,r=L}for(n=[],$a[t]=n,n.bytes=e;r<i;)a=Da.getUint32(r),n.push(a),r+=4;for(i+=3;r<i;)a=I[r++],n.push(a);let s=e<16?Ya(e):Ja(e);return s==null?n.string=Ua(e):n.string=s}function to(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;if(ya.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(e=>[`string`,`number`,`boolean`,`bigint`].includes(typeof e)))return e.flat().toString();throw Error(`Invalid property type for record: ${typeof e}`)}var no=(e,t)=>{let n=za().map(to),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,n.highByte=t);let i=ba[e];return i&&(i.isShared||ja)&&((ba.restoreStructures||(ba.restoreStructures=[]))[e]=i),ba[e]=n,n.read=Ba(n,r),n.read()};Ea[0]=()=>{},Ea[0].noBuffer=!0,Ea[66]=e=>{let t=e.byteLength%8||8,n=BigInt(e[0]&128?e[0]-256:e[0]);for(let r=1;r<t;r++)n<<=BigInt(8),n+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=(e,t)=>{let n=t-e;if(n<=40){let n=r.getBigUint64(e);for(let i=e+8;i<t;i+=8)n<<=64n,n|=r.getBigUint64(i);return n}let a=e+(n>>4<<3),o=i(e,a),s=i(a,t);return o<<BigInt((t-a)*8)|s};n=n<<BigInt((r.byteLength-t)*8)|i(t,r.byteLength)}return n};var ro={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError==`function`?AggregateError:null};Ea[101]=()=>{let e=za();if(!ro[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return ro[e[0]](e[1],{cause:e[2]})},Ea[105]=e=>{if(ya.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=Da.getUint32(L-4);Ta||=new Map;let n=I[L],r;r=n>=144&&n<160||n==220||n==221?[]:n>=128&&n<144||n==222||n==223?new Map:(n>=199&&n<=201||n>=212&&n<=216)&&I[L+1]===115?new Set:{};let i={target:r};Ta.set(t,i);let a=za();if(i.used)Object.assign(r,a);else return i.target=a;if(r instanceof Map)for(let[e,t]of a.entries())r.set(e,t);if(r instanceof Set)for(let e of Array.from(a))r.add(e);return r},Ea[112]=e=>{if(ya.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=Da.getUint32(L-4),n=Ta.get(t);return n.used=!0,n.target},Ea[115]=()=>new Set(za());var io=[`Int8`,`Uint8`,`Uint8Clamped`,`Int16`,`Uint16`,`Int32`,`Uint32`,`Float32`,`Float64`,`BigInt64`,`BigUint64`].map(e=>e+`Array`),wie=typeof globalThis==`object`?globalThis:window;Ea[116]=e=>{let t=e[0],n=Uint8Array.prototype.slice.call(e,1).buffer,r=io[t];if(!r){if(t===16)return n;if(t===17)return new DataView(n);throw Error(`Could not find typed array for code `+t)}return new wie[r](n)},Ea[120]=()=>{let e=za();return new RegExp(e[0],e[1])};var Tie=[];Ea[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],n=L;return L+=t-e.length,wa=Tie,wa=[Xa(),Xa()],wa.position0=0,wa.position1=0,wa.postBundlePosition=L,L=n,za()},Ea[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date(`invalid`);function ao(e){Fa&&Fa();let t=ha,n=L,r=va,i=Sa,a=Ca,o=xa,s=_a,c=Ta,l=wa,u=new Uint8Array(I.slice(0,ha)),d=ba,f=ba.slice(0,ba.length),p=ya,m=ja,h=e();return ha=t,L=n,va=r,Sa=i,Ca=a,xa=o,_a=s,Ta=c,wa=l,I=u,ja=m,ba=d,ba.splice(0,ba.length,...f),ya=p,Da=new DataView(I.buffer,I.byteOffset,I.byteLength),h}function oo(){I=null,Ta=null,ba=null}var so=Array(147);for(let e=0;e<256;e++)so[e]=+(`1e`+Math.floor(45.15-e*.30103));var co=new Ia({useRecords:!1});co.unpack,co.unpackMultiple,co.unpack;var Eie={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};new Uint8Array(new Float32Array(1).buffer,0,4);var lo;try{lo=new TextEncoder}catch{}var uo,fo,po=typeof Buffer<`u`,mo=po?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,ho=po?Buffer:Uint8Array,go=po?4294967296:2144337920,R,_o,vo,z=0,yo,bo=null,Die,Oie=21760,kie=/[\u0080-\uFFFF]/,xo=Symbol(`record-id`),Aie=class extends Ia{constructor(e){super(e),this.offset=0;let t,n,r,i,a=ho.prototype.utf8Write?function(e,t){return R.utf8Write(e,t,R.byteLength-t)}:lo&&lo.encodeInto?function(e,t){return lo.encodeInto(e,R.subarray(t)).written}:!1,o=this;e||={};let s=e&&e.sequential,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?32:0,l>8160)throw Error(`Maximum maxSharedStructure is 8160`);e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let u=e.maxOwnStructures;u??=c?32:64,!this.structures&&e.useRecords!=0&&(this.structures=[]);let d=l>32||u+l>64,f=l+64,p=l+u+64;if(p>8256)throw Error(`Maximum maxSharedStructure + maxOwnStructure is 8192`);let m=[],h=0,g=0;this.pack=this.encode=function(e,a){if(R||(R=new mo(8192),vo=R.dataView||(R.dataView=new DataView(R.buffer,0,8192)),z=0),yo=R.length-10,yo-z<2048?(R=new mo(R.length),vo=R.dataView||(R.dataView=new DataView(R.buffer,0,R.length)),yo=R.length-10,z=0):z=z+7&2147483640,t=z,a&2048&&(z+=a&255),i=o.structuredClone?new Map:null,o.bundleStrings&&typeof e!=`string`?(bo=[],bo.size=1/0):bo=null,r=o.structures,r){r.uninitialized&&(r=o._mergeStructures(o.getStructures()));let e=r.sharedLength||0;if(e>l)throw Error(`Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to `+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let t=0;t<e;t++){let e=r[t];if(!e)continue;let n,i=r.transitions;for(let t=0,r=e.length;t<r;t++){let r=e[t];n=i[r],n||=i[r]=Object.create(null),i=n}i[xo]=t+64}this.lastNamedStructuresLength=e}s||(r.nextId=e+64)}n&&=!1;let c;try{o.randomAccessStructure&&e&&typeof e==`object`?e.constructor===Object?D(e):e.constructor!==Map&&!Array.isArray(e)&&!fo.some(t=>e instanceof t)?D(e.toJSON?e.toJSON():e):y(e):y(e);let n=bo;if(bo&&To(t,y,0),i&&i.idsToInsert){let e=i.idsToInsert.sort((e,t)=>e.offset>t.offset?1:-1),r=e.length,a=-1;for(;n&&r>0;){let i=e[--r].offset+t;i<n.stringsPosition+t&&a===-1&&(a=0),i>n.position+t?a>=0&&(a+=6):(a>=0&&(vo.setUint32(n.position+t,vo.getUint32(n.position+t)+a),a=-1),n=n.previous,r++)}a>=0&&n&&vo.setUint32(n.position+t,vo.getUint32(n.position+t)+a),z+=e.length*6,z>yo&&w(z),o.offset=z;let s=jie(R.subarray(t,z),e);return i=null,s}return o.offset=z,a&512?(R.start=t,R.end=z,R):R.subarray(t,z)}catch(e){throw c=e,e}finally{if(r&&(_(),n&&o.saveStructures)){let n=r.sharedLength||0,i=R.subarray(t,z),s=Mie(r,o);if(!c)return o.saveStructures(s,s.isCompatible)===!1?o.pack(e,a):(o.lastNamedStructuresLength=n,R.length>1073741824&&(R=null),i)}R.length>1073741824&&(R=null),a&1024&&(z=t)}};let _=()=>{g<10&&g++;let e=r.sharedLength||0;if(r.length>e&&!s&&(r.length=e),h>1e4)r.transitions=null,g=0,h=0,m.length>0&&(m=[]);else if(m.length>0&&!s){for(let e=0,t=m.length;e<t;e++)m[e][xo]=0;m=[]}},v=e=>{var t=e.length;t<16?R[z++]=144|t:t<65536?(R[z++]=220,R[z++]=t>>8,R[z++]=t&255):(R[z++]=221,vo.setUint32(z,t),z+=4);for(let n=0;n<t;n++)y(e[n])},y=e=>{z>yo&&(R=w(z));var n=typeof e,r;if(n===`string`){let n=e.length;if(bo&&n>=4&&n<4096){if((bo.size+=n)>Oie){let e,n=(bo[0]?bo[0].length*3+bo[1].length:0)+10;z+n>yo&&(R=w(z+n));let r;bo.position?(r=bo,R[z]=200,z+=3,R[z++]=98,e=z-t,z+=4,To(t,y,0),vo.setUint16(e+t-3,z-t-e)):(R[z++]=214,R[z++]=98,e=z-t,z+=4),bo=[``,``],bo.previous=r,bo.size=0,bo.position=e}let r=kie.test(e);bo[+!r]+=e,R[z++]=193,y(r?-n:n);return}let i;i=n<32?1:n<256?2:n<65536?3:5;let o=n*3;if(z+o>yo&&(R=w(z+o)),n<64||!a){let t,a,o,s=z+i;for(t=0;t<n;t++)a=e.charCodeAt(t),a<128?R[s++]=a:a<2048?(R[s++]=a>>6|192,R[s++]=a&63|128):(a&64512)==55296&&((o=e.charCodeAt(t+1))&64512)==56320?(a=65536+((a&1023)<<10)+(o&1023),t++,R[s++]=a>>18|240,R[s++]=a>>12&63|128,R[s++]=a>>6&63|128,R[s++]=a&63|128):(R[s++]=a>>12|224,R[s++]=a>>6&63|128,R[s++]=a&63|128);r=s-z-i}else r=a(e,z+i);r<32?R[z++]=160|r:r<256?(i<2&&R.copyWithin(z+2,z+1,z+1+r),R[z++]=217,R[z++]=r):r<65536?(i<3&&R.copyWithin(z+3,z+2,z+2+r),R[z++]=218,R[z++]=r>>8,R[z++]=r&255):(i<5&&R.copyWithin(z+5,z+3,z+3+r),R[z++]=219,vo.setUint32(z,r),z+=4),z+=r}else if(n===`number`)if(e>>>0===e)e<32||e<128&&this.useRecords===!1||e<64&&!this.randomAccessStructure?R[z++]=e:e<256?(R[z++]=204,R[z++]=e):e<65536?(R[z++]=205,R[z++]=e>>8,R[z++]=e&255):(R[z++]=206,vo.setUint32(z,e),z+=4);else if(e>>0===e)e>=-32?R[z++]=256+e:e>=-128?(R[z++]=208,R[z++]=e+256):e>=-32768?(R[z++]=209,vo.setInt16(z,e),z+=2):(R[z++]=210,vo.setInt32(z,e),z+=4);else{let t;if((t=this.useFloat32)>0&&e<4294967296&&e>=-2147483648){R[z++]=202,vo.setFloat32(z,e);let n;if(t<4||(n=e*so[(R[z]&127)<<1|R[z+1]>>7])>>0===n){z+=4;return}z--}R[z++]=203,vo.setFloat64(z,e),z+=8}else if(n===`object`||n===`function`)if(!e)R[z++]=192;else{if(i){let n=i.get(e);if(n){n.id||=(i.idsToInsert||(i.idsToInsert=[])).push(n),R[z++]=214,R[z++]=112,vo.setUint32(z,n.id),z+=4;return}i.set(e,{offset:z-t})}let a=e.constructor;if(a===Object)C(e);else if(a===Array)v(e);else if(a===Map)if(this.mapAsEmptyObject)R[z++]=128;else{r=e.size,r<16?R[z++]=128|r:r<65536?(R[z++]=222,R[z++]=r>>8,R[z++]=r&255):(R[z++]=223,vo.setUint32(z,r),z+=4);for(let[t,n]of e)y(t),y(n)}else{for(let t=0,n=uo.length;t<n;t++){let n=fo[t];if(e instanceof n){let n=uo[t];if(n.write){n.type&&(R[z++]=212,R[z++]=n.type,R[z++]=0);let t=n.write.call(this,e);t===e?Array.isArray(e)?v(e):C(e):y(t);return}let r=R,i=vo,a=z;R=null;let o;try{o=n.pack.call(this,e,e=>(R=r,r=null,z+=e,z>yo&&w(z),{target:R,targetView:vo,position:z-e}),y)}finally{r&&(R=r,vo=i,z=a,yo=R.length-10)}o&&(o.length+z>yo&&w(o.length+z),z=wo(o,R,z,n.type));return}}if(Array.isArray(e))v(e);else{if(e.toJSON){let t=e.toJSON();if(t!==e)return y(t)}if(n===`function`)return y(this.writeFunction&&this.writeFunction(e));C(e)}}}else if(n===`boolean`)R[z++]=e?195:194;else if(n===`bigint`){if(e<0x8000000000000000&&e>=-0x8000000000000000)R[z++]=211,vo.setBigInt64(z,e);else if(e<0x10000000000000000&&e>0)R[z++]=207,vo.setBigUint64(z,e);else if(this.largeBigIntToFloat)R[z++]=203,vo.setFloat64(z,Number(e));else if(this.largeBigIntToString)return y(e.toString());else if(this.useBigIntExtension||this.moreTypes){let t=BigInt(e<0?-1:0),n;if(e>>BigInt(65536)===t){let r=BigInt(0x10000000000000000)-BigInt(1),i=[];for(;i.push(e&r),e>>BigInt(63)!==t;)e>>=BigInt(64);n=new Uint8Array(new BigUint64Array(i).buffer),n.reverse()}else{let t=e<0,r=(t?~e:e).toString(16);if(r.length%2?r=`0`+r:parseInt(r.charAt(0),16)>=8&&(r=`00`+r),po)n=Buffer.from(r,`hex`);else{n=new Uint8Array(r.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(r.slice(e*2,e*2+2),16)}if(t)for(let e=0;e<n.length;e++)n[e]=~n[e]}n.length+z>yo&&w(n.length+z),z=wo(n,R,z,66);return}else throw RangeError(e+` was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string`);z+=8}else if(n===`undefined`)this.encodeUndefinedAsNil?R[z++]=192:(R[z++]=212,R[z++]=0,R[z++]=0);else throw Error(`Unknown type: `+n)},b=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?e=>{let t;if(this.skipValues){t=[];for(let n in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(n))&&!this.skipValues.includes(e[n])&&t.push(n)}else t=Object.keys(e);let n=t.length;n<16?R[z++]=128|n:n<65536?(R[z++]=222,R[z++]=n>>8,R[z++]=n&255):(R[z++]=223,vo.setUint32(z,n),z+=4);let r;if(this.coercibleKeyAsNumber)for(let i=0;i<n;i++){r=t[i];let n=Number(r);y(isNaN(n)?r:n),y(e[r])}else for(let i=0;i<n;i++)y(r=t[i]),y(e[r])}:e=>{R[z++]=222;let n=z-t;z+=2;let r=0;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(y(t),y(e[t]),r++);if(r>65535)throw Error(`Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object`);R[n+++t]=r>>8,R[n+t]=r&255},x=this.useRecords===!1?b:e.progressiveRecords&&!d?e=>{let n,i=r.transitions||(r.transitions=Object.create(null)),a=z++-t,o;for(let s in e)if(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(s)){if(n=i[s],n)i=n;else{let c=Object.keys(e),l=i;i=r.transitions;let u=0;for(let e=0,t=c.length;e<t;e++){let t=c[e];n=i[t],n||(n=i[t]=Object.create(null),u++),i=n}a+t+1==z?(z--,T(i,c,u)):E(i,c,a,u),o=!0,i=l[s]}y(e[s])}if(!o){let n=i[xo];n?R[a+t]=n:E(i,Object.keys(e),a,0)}}:e=>{let t,n=r.transitions||(r.transitions=Object.create(null)),i=0;for(let r in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(r))&&(t=n[r],t||(t=n[r]=Object.create(null),i++),n=t);let a=n[xo];a?a>=96&&d?(R[z++]=((a-=96)&31)+96,R[z++]=a>>5):R[z++]=a:T(n,n.__keys__||Object.keys(e),i);for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&y(e[t])},S=typeof this.useRecords==`function`&&this.useRecords,C=S?e=>{S(e)?x(e):b(e)}:x,w=e=>{let n;if(e>16777216){if(e-t>go)throw Error(`Packed buffer would be larger than maximum buffer size`);n=Math.min(go,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,R.length-1)>>12)+1<<12;let r=new mo(n);return vo=r.dataView||=new DataView(r.buffer,0,n),e=Math.min(e,R.length),R.copy?R.copy(r,0,t,e):r.set(R.slice(t,e)),z-=t,t=0,yo=r.length-10,R=r},T=(e,t,i)=>{let a=r.nextId;a||=64,a<f&&this.shouldShareStructure&&!this.shouldShareStructure(t)?(a=r.nextOwnId,a<p||(a=f),r.nextOwnId=a+1):(a>=p&&(a=f),r.nextId=a+1);let o=t.highByte=a>=96&&d?a-96>>5:-1;e[xo]=a,e.__keys__=t,r[a-64]=t,a<f?(t.isShared=!0,r.sharedLength=a-63,n=!0,o>=0?(R[z++]=(a&31)+96,R[z++]=o):R[z++]=a):(o>=0?(R[z++]=213,R[z++]=114,R[z++]=(a&31)+96,R[z++]=o):(R[z++]=212,R[z++]=114,R[z++]=a),i&&(h+=g*i),m.length>=u&&(m.shift()[xo]=0),m.push(e),y(t))},E=(e,n,r,i)=>{let a=R,o=z,s=yo,c=t;R=_o,z=0,t=0,R||(_o=R=new mo(8192)),yo=R.length-10,T(e,n,i),_o=R;let l=z;if(R=a,z=o,yo=s,t=c,l>1){let e=z+l-1;e>yo&&w(e);let n=r+t;R.copyWithin(n+l,n+1,z),R.set(_o.slice(0,l),n),z=e}else R[r+t]=_o[0]},D=e=>{let i=Die(e,R,t,z,r,w,(e,t,r)=>{if(r)return n=!0;z=t;let i=R;return y(e),_(),i===R?z:{position:z,targetView:vo,target:R}},this);if(i===0)return C(e);z=i}}useBuffer(e){R=e,R.dataView||(R.dataView=new DataView(R.buffer,R.byteOffset,R.byteLength)),vo=R.dataView,z=0}set position(e){z=e}get position(){return z}clearSharedData(){this.structures&&=[],this.typedStructs&&=[]}};fo=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,ka],uo=[{pack(e,t,n){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:e,targetView:n,position:i}=t(6);e[i++]=214,e[i++]=255,n.setUint32(i,r)}else if(r>0&&r<4294967296){let{target:n,targetView:i,position:a}=t(10);n[a++]=215,n[a++]=255,i.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),n(this.onInvalidDate());let{target:e,targetView:r,position:i}=t(3);e[i++]=212,e[i++]=255,e[i++]=255}else{let{target:n,targetView:i,position:a}=t(15);n[a++]=199,n[a++]=12,n[a++]=255,i.setUint32(a,e.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,n){if(this.setAsEmptyObject)return t(0),n({});let r=Array.from(e),{target:i,position:a}=t(this.moreTypes?3:0);this.moreTypes&&(i[a++]=212,i[a++]=115,i[a++]=0),n(r)}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=101,r[i++]=0),n([e.name,e.message,e.cause])}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=120,r[i++]=0),n([e.source,e.flags])}},{pack(e,t){this.moreTypes?So(e,16,t):Co(po?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let n=e.constructor;n!==ho&&this.moreTypes?So(e,io.indexOf(n.name),t):Co(e,t)}},{pack(e,t){this.moreTypes?So(e,17,t):Co(po?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:n,position:r}=t(1);n[r]=193}}];function So(e,t,n,r){let i=e.byteLength;if(i+1<256){var{target:a,position:o}=n(4+i);a[o++]=199,a[o++]=i+1}else if(i+1<65536){var{target:a,position:o}=n(5+i);a[o++]=200,a[o++]=i+1>>8,a[o++]=i+1&255}else{var{target:a,position:o,targetView:s}=n(7+i);a[o++]=201,s.setUint32(o,i+1),o+=4}a[o++]=116,a[o++]=t,e.buffer||(e=new Uint8Array(e)),a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),o)}function Co(e,t){let n=e.byteLength;var r,i;if(n<256){var{target:r,position:i}=t(n+2);r[i++]=196,r[i++]=n}else if(n<65536){var{target:r,position:i}=t(n+3);r[i++]=197,r[i++]=n>>8,r[i++]=n&255}else{var{target:r,position:i,targetView:a}=t(n+5);r[i++]=198,a.setUint32(i,n),i+=4}r.set(e,i)}function wo(e,t,n,r){let i=e.length;switch(i){case 1:t[n++]=212;break;case 2:t[n++]=213;break;case 4:t[n++]=214;break;case 8:t[n++]=215;break;case 16:t[n++]=216;break;default:i<256?(t[n++]=199,t[n++]=i):i<65536?(t[n++]=200,t[n++]=i>>8,t[n++]=i&255):(t[n++]=201,t[n++]=i>>24,t[n++]=i>>16&255,t[n++]=i>>8&255,t[n++]=i&255)}return t[n++]=r,t.set(e,n),n+=i,n}function jie(e,t){let n,r=t.length*6,i=e.length-r;for(;n=t.pop();){let t=n.offset,a=n.id;e.copyWithin(t+r,t,i),r-=6;let o=t+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,i=t}return e}function To(e,t,n){if(bo.length>0){vo.setUint32(bo.position+e,z+n-bo.position-e),bo.stringsPosition=z-e;let r=bo;bo=null,t(r[0]),t(r[1])}}function Mie(e,t){return e.isCompatible=e=>{let n=!e||(t.lastNamedStructuresLength||0)===e.length;return n||t._mergeStructures(e),n},e}var Eo=new Aie({useRecords:!1});Eo.pack,Eo.pack;var{NEVER:Nie,ALWAYS:Pie,DECIMAL_ROUND:Fie,DECIMAL_FIT:Iie}=Eie,Do=class extends Dt()(`effect/rpc/RpcSerialization`){},Lie=Do.of({contentType:`application/json`,includesFraming:!1,makeUnsafe:()=>{let e=new TextDecoder;return{decode:t=>{let n=JSON.parse(typeof t==`string`?t:e.decode(t));return Array.isArray(n)?n:[n]},encode:e=>JSON.stringify(e)}}}),Oo=pe(Do)(Lie),Rie=e=>Et(()=>{let t=new Set,n=new Map,r=new Map,i=(e,t)=>ie(r=>{let i=n.get(e);return i||(i=[],n.set(e,i)),i.push([t,r]),nt});return Ye(e((e,t)=>{let n=r.get(e);return n?n(t):i(e,t)},t),e=>({...e,run(e,i){return tt(function*(){t.add(e),r.set(e,i);let a=n.get(e);if(a){n.delete(e);for(let[e,t]of a)yield*Ce(Et(()=>i(e)),t)}return yield*iee(w,()=>(t.delete(e),r.delete(e),nt))})}}))}),zie=BigInt(0),Bie=Je(function*(e,t){let n=t?.spanPrefix??`RpcClient`,r=t?.supportsAck??!0,i=t?.disableTracing??!1,a=t?.generateRequestId??(()=>zie++),o=yield*wt(),s=kt(o,Ae),c=new Map,l=!1;yield*Rt(s,Mt(e=>(l=!0,u(Ree(e.id)))));let u=Je(function*(e){for(let[t,n]of c)c.delete(t),n._tag===`Queue`?yield*e._tag===`Success`?Nt(n.queue):Ne(n.queue,e.cause):n.resume(e)}),d=e=>{let r=une(e.successSchema),a=g(e);return(o,s)=>{let c=s?.headers?gn(s.headers):dn,l=s?.context??Kee();if(!r){let r=t=>p(e,a,t,e.payloadSchema.make(o),c,l,s?.discard??!1);return i?r(void 0):it(`${n}.${e._tag}`,{attributes:t.spanAttributes},r)}let u=m(e,a,e.payloadSchema.make(o),c,s?.streamBufferSize??16,l);return s?.asQueue?u:ute(Ye(u,nte))}},p=(e,n,r,i,o,s,u)=>Mt(d=>{if(l)return _t;let f=a(),p=n(e=>t.onFromClient({message:e,context:s,discard:u}),{_tag:`Request`,id:f,tag:e._tag,payload:i,...r?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{},headers:Qt(d.getRef(jo),o)});if(u)return p;let m;return ft(Ie(t=>{let n={_tag:`Effect`,rpc:e,context:s,resume(e){t(e),m&&!m.pollUnsafe()&&d.currentDispatcher.scheduleTask(()=>{m.interruptUnsafe(d.id)},0)}};c.set(f,n),m=p.pipe(r?It(r,{captureStackTrace:!1}):we,Ve(d.context)),m.addObserver(e=>{if(e._tag===`Failure`)return t(e)})}),e=>(c.delete(f),Lt(aee(m),_(f,Array.from(e),s))))}),m=Je(function*(e,r,o,s,u,d){if(l)return yield*_t;let p=i?void 0:yield*mte(`${n}.${e._tag}`,{attributes:t.spanAttributes}),m=xe(),g=a(),v=Pee(m.context,Ae);yield*f(v,e=>c.has(g)?(c.delete(g),_(g,vt(e)?Array.from(Eee(e.cause)):[],d)):nt);let y=yield*h(u);return c.set(g,{_tag:`Queue`,rpc:e,queue:y,scope:v,context:d}),yield*r(e=>t.onFromClient({message:e,context:d,discard:!1}),{_tag:`Request`,id:g,tag:e._tag,payload:o,...p?{traceId:p.traceId,spanId:p.spanId,sampled:p.sampled}:{},headers:Qt(m.getRef(jo),s)}).pipe(p?It(p,{captureStackTrace:!1}):we,He(e=>Ne(y,e)),ot,jt(v,{startImmediately:!0})),y}),g=e=>{let t=[];for(let n of e.middlewares.values()){let e=o.mapUnsafe.get(`${n.key}/Client`);e&&t.push(e)}return t.length===0?(e,t)=>e(t):function n(r,i,a=t.length-1){return a===-1?r(i):t[a]({rpc:e,request:i,next(e){return n(r,e,a-1)}})}},_=(e,n,r)=>Ie(i=>{let a=xe();t.onFromClient({message:{_tag:`Interrupt`,requestId:e,interruptors:n},context:r,discard:!1}).pipe(Xe(1e3),Ve(a.context)).addObserver(()=>{i(nt)})}),v=e=>{switch(e._tag){case`Chunk`:{let n=e.requestId,i=c.get(n);return!i||i._tag!==`Queue`?nt:tee(i.queue,e.values).pipe(r?yt(()=>t.onFromClient({message:{_tag:`Ack`,requestId:e.requestId},context:i.context,discard:!1})):we,He(e=>Ne(i.queue,e)))}case`Exit`:{let t=e.requestId,n=c.get(t);return n?(c.delete(t),n._tag===`Effect`?(n.resume(e.exit),nt):e.exit._tag===`Success`?Nt(n.queue):Ne(n.queue,e.exit.cause)):nt}case`Defect`:return u(vee(e.defect));case`ClientEnd`:return nt}},y;if(t.flatten){let t=new Map;y=function(n,r,i){let a=t.get(n);return a||(a=d(e.requests.get(n)),t.set(n,a)),a(r,i)}}else y={},e.requests.forEach(e=>{y[e._tag]=d(e)});return{client:y,write:v}}),Vie=0,ko=Je(function*(e,t){let n=Vie++,{run:r,send:i,supportsAck:a,supportsTransferables:o}=yield*Mo,s=new Map,{client:c,write:u}=yield*Bie(e,{...t,supportsAck:a,onFromClient({message:t}){switch(t._tag){case`Request`:{let r=e.requests.get(t.tag),a=o?pie():void 0,c=xe(),u={rpc:r,context:a?Nee(c.context,ca,a):c.context,schemas:Hie(r)};return s.set(t.id,u),u.schemas.encodePayload(t.payload).pipe(Ce(u.context),l,yt(e=>i(n,{...t,id:String(t.id),payload:e,headers:Object.entries(t.headers)},a&&a.readUnsafe())))}case`Ack`:return s.get(t.requestId)?i(n,{_tag:`Ack`,requestId:String(t.requestId)}):nt;case`Interrupt`:return s.get(t.requestId)?(s.delete(t.requestId),i(n,{_tag:`Interrupt`,requestId:String(t.requestId)})):nt;case`Eof`:return nt}}});return yield*r(n,e=>{switch(e._tag){case`Chunk`:{let t=pa(e.requestId),n=s.get(t);return!n||ste(n.schemas.decodeChunk)?nt:n.schemas.decodeChunk.value(e.values).pipe(Ce(n.context),l,yt(t=>u({_tag:`Chunk`,clientId:0,requestId:pa(e.requestId),values:t})),b(t=>u({_tag:`Exit`,clientId:0,requestId:pa(e.requestId),exit:De(t)})))}case`Exit`:{let t=pa(e.requestId),n=s.get(t);return n?(s.delete(t),n.schemas.decodeExit(e.exit).pipe(Ce(n.context),l,Fe({onSuccess:e=>u({_tag:`Exit`,clientId:0,requestId:t,exit:e}),onFailure:e=>u({_tag:`Exit`,clientId:0,requestId:t,exit:De(e)})}))):nt}case`Defect`:return u({_tag:`Defect`,clientId:0,defect:Kie(e.defect)});case`ClientProtocolError`:{let t=xee(e.error);return Ot(s.keys(),e=>u({_tag:`Exit`,clientId:0,requestId:e,exit:t}))}default:return nt}}).pipe(He(ote),ot,Qe),c}),Ao=new WeakMap,Hie=e=>{let t=Ao.get(e);if(t!==void 0)return t;let n=Ote(e.successSchema);return t={decodeChunk:Wee(n,e=>_n(mn(pne(e.success)))),encodePayload:Yte(mn(e.payloadSchema)),decodeExit:_n(mn(dne(e)))},Ao.set(e,t),t},jo=bt(`effect/rpc/RpcClient/CurrentHeaders`,{defaultValue:()=>dn}),Mo=class extends Dt()(`effect/rpc/RpcClient/Protocol`){static make=Rie},No=e=>Mo.make(Je(function*(t,n){let i=yield*$i,a=yield*Do,o=yield*oee(Gie),s=new Map,c=yield*i.writer,d=a.makeUnsafe(),f=yield*Wie(c(d.encode(yie))),p,m=Et(()=>(p=void 0,x(o)?o.value.onConnect:nt)),h=e=>Ot(n,n=>t(n,e));return yield*Et(()=>(d=a.makeUnsafe(),f.reset(),i.runRaw(e=>{try{let n=d.decode(e);if(n.length===0)return;let r=0;return Tee({while:()=>r<n.length,body:()=>{let e=n[r++];if(e._tag===`Pong`)return f.onPong(),nt;if(`requestId`in e){let n=s.get(e.requestId);if(n!==void 0)return e._tag===`Exit`&&s.delete(e.requestId),t(n,e)}return h(e)},step:Vee})}catch(e){return h({_tag:`ClientProtocolError`,error:new fa({reason:new da({message:`Error decoding message`,cause:e})})})}},{onOpen:m}).pipe(O(yt(f.timeout,()=>r(new aa({reason:new na({kind:`Timeout`,cause:Error(`ping timeout`)})}))))))).pipe(yt(()=>r(new aa({reason:new ra({code:1e3})}))),x(o)?Ge(o.value.onDisconnect):we,Xee(t=>{let n=zee(t),r=Yee(n);return e?.retryTransientErrors&&r&&n.success.reason._tag===`SocketOpenError`?nt:(p=new fa({reason:r?n.success.reason:new da({message:`Unknown socket error`,cause:Pe(t)})}),h({_tag:`ClientProtocolError`,error:p}))}),he(e?.retryPolicy??Uie),u({module:`RpcClient`,method:`makeProtocolSocket`}),Qe),{send(e,t){if(p)return r(p);t._tag===`Request`&&s.set(t.id,e);let n=d.encode(t);return n===void 0?nt:l(c(n))},supportsAck:!0,supportsTransferables:!1}})),Uie=_(500,1.5).pipe(cee(ree(5e3))),Wie=Je(function*(e){let t=!0,n=0,r=ct();return yield*Et(()=>t?(t=!1,n=0,e):(n+=1,n>=3?r.open:e)).pipe(yee(`5 seconds`),Ct,Ze,ot,Qe),{timeout:r.await,reset:()=>{t=!0,n=0,r.closeUnsafe()},onPong:()=>{t=!0,n=0}}}),Gie=class extends Dt()(`effect/rpc/RpcClient/ConnectionHooks`){},Kie=Dn(In);function Po(e){return{id:e.id??`ws:${e.label}`,label:e.label,source:e.source??`manual`,target:e.target}}function qie(e){return e?.target.wsBaseUrl??null}function Jie(e){return e?.target.httpBaseUrl??null}function Yie(e,t){return{...e,environmentId:t.environmentId,label:t.label}}function Xie(e){return e.cloudMode?`cmmd-cloud-runtime`:`local-web`}function Zie(e){let t=Xie(e);return{topology:t,controlPlane:t!==`cmmd-cloud-runtime`,executionPlane:!0,workspaceProxy:!1}}function Qie(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 $ie(e){let t=e.executionPlane;return{agents:t,browser:t,github:t,terminal:t,providerEgress:e.topology===`cmmd-control-plane`}}function eae(e,t){return{localProjects:t.executionPlane,cloudProjects:e.cloudMode}}function Fo(e){let t=e.capabilities,n=t.runtime??Zie(t);return{repositoryIdentity:t.repositoryIdentity,pullRequests:t.pullRequests??!1,cloudMode:t.cloudMode,posthogPublicKey:t.posthogPublicKey,posthogHost:t.posthogHost,runtime:n,auth:t.auth??Qie(n),tools:t.tools??$ie(n),projects:t.projects??eae(t,n)}}function tae(e){return e?Fo(e).projects.cloudProjects:!1}function nae(e){return e?Fo(e).runtime.workspaceProxy??!1:!1}function Io(e,t){return{environmentId:e,projectId:t}}function Lo(e,t){return{environmentId:e,threadId:t}}var Ro=`scoped:v1:`;function zo(e){let t=`projectId`in e?e.projectId:e.threadId;return t.includes(`:`)||e.environmentId.startsWith(Ro)?`${Ro}${encodeURIComponent(e.environmentId)}:${encodeURIComponent(t)}`:`${e.environmentId}:${t}`}function Bo(e){return zo(e)}function Vo(e){return zo(e)}function rae(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 Ho(e){if(e.startsWith(Ro))return rae(e);let t=e.lastIndexOf(`:`);return t<=0||t>=e.length-1?null:{environmentId:e.slice(0,t),localId:e.slice(t+1)}}function Uo(e){let t=Ho(e);return t?{environmentId:t.environmentId,projectId:t.localId}:null}function Wo(e){let t=Ho(e);return t?{environmentId:t.environmentId,threadId:t.localId}:null}var iae=1e3,aae=64e3;ko(Hn);function oae(e){return!Number.isInteger(e)||e<0||e>=10?null:Math.min(Math.round(iae*2**e),aae)}var Go=class extends Error{code;retryable;name=`RelayProtocolFailure`;constructor(e,t,n){super(t),this.code=e,this.retryable=n}};function Ko(e){return Array.isArray(e)?e.map(Ko):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,Ko(t)])):e}function sae(e){let t=JSON.stringify(Ko(e));if(t===void 0)throw Error(`Relay payload is not JSON serializable.`);return t}var cae={requestId:`@effect/rpc/Ping`,correlationId:`@effect/rpc/Ping`,method:`@effect/rpc/Ping`,requiredScope:null,deliveryClass:`read`,journalPersistence:`none`};function lae(e){return e._tag===`Ping`?cae:null}function uae(e){if(e.policy===null||e.policy.method!==e.method)throw new Go(`method_not_remotable`,`Relay method has no exact dispatch policy: ${e.method}`,!1);if(e.policy.requiredScope!==null&&!e.grantedScopes.includes(e.policy.requiredScope))throw new Go(`scope_denied`,`Relay method ${e.method} requires scope ${e.policy.requiredScope}`,!1);return{requiredScope:e.policy.requiredScope,deliveryClass:e.policy.deliveryClass,journalPersistence:e.policy.journalPersistence}}function dae(e){let t=new Set(e.registeredMethods),n=new Map;for(let r of e.policies){if(n.has(r.method))throw new Go(`method_not_remotable`,`Relay method has duplicate dispatch policies: ${r.method}`,!1);if(!t.has(r.method))throw new Go(`method_not_remotable`,`Relay dispatch policy targets an unregistered method: ${r.method}`,!1);if((r.deliveryClass===`idempotent-command`||r.deliveryClass===`create-command`)==(r.journalPersistence===`none`))throw new Go(`method_not_remotable`,`Relay dispatch policy has incompatible journal persistence: ${r.method}`,!1);n.set(r.method,r)}for(let t of e.registeredMethods)if(!n.has(t))throw new Go(`method_not_remotable`,`Remotely registered method has no dispatch policy: ${t}`,!1);return n}var fae=[{method:M.projectsSearchEntries,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.projectsListEntries,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.serverDiscoverSourceControl,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.serverReportClientActivity,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.codeGraphSummary,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.codeGraphNeighborhood,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.codeGraphSearch,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.projectsWriteFile,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.projectCheckoutDeletionPreview,requiredScope:`workspace.write`,deliveryClass:`read`},{method:M.projectCheckoutDeletionExecute,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.workspaceReadFile,requiredScope:`workspace.read`,deliveryClass:`bulk-transfer`},{method:M.workspaceBeginWriteFile,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.workspaceWriteFileChunk,requiredScope:`workspace.write`,deliveryClass:`bulk-transfer`},{method:M.workspaceCommitWriteFile,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.workspaceCancelWriteFile,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.shellOpenInEditor,requiredScope:`shell.open`,deliveryClass:`idempotent-command`},{method:M.gitPull,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitRefreshStatus,requiredScope:`git.read`,deliveryClass:`read`},{method:M.gitRunStackedAction,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitListBranches,requiredScope:`git.read`,deliveryClass:`read`},{method:M.vcsListRefs,requiredScope:`git.read`,deliveryClass:`read`},{method:M.vcsRefreshStatus,requiredScope:`git.read`,deliveryClass:`read`},{method:M.vcsPull,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.vcsCreateWorktree,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.vcsRemoveWorktree,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.vcsCreateRef,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.vcsSwitchRef,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.vcsInit,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitCreateWorktree,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.gitRemoveWorktree,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitCreateBranch,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.gitCheckout,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitInit,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitResolvePullRequest,requiredScope:`git.read`,deliveryClass:`read`},{method:M.gitPreparePullRequestThread,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.terminalOpen,requiredScope:`terminal.write`,deliveryClass:`create-command`},{method:M.terminalAttach,requiredScope:`terminal.write`,deliveryClass:`terminal-output`},{method:M.terminalWrite,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalResize,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalSignal,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalClear,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalRestart,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalClose,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.browserOpenSession,requiredScope:`browser.control`,deliveryClass:`create-command`},{method:M.browserListSessions,requiredScope:`browser.read`,deliveryClass:`read`},{method:M.browserCloseSession,requiredScope:`browser.control`,deliveryClass:`browser-control`},{method:M.browserGetSession,requiredScope:`browser.read`,deliveryClass:`read`},{method:M.browserCommand,requiredScope:`browser.control`,deliveryClass:`browser-control`},{method:M.browserClearBrowsingData,requiredScope:`browser.control`,deliveryClass:`browser-control`},{method:M.browserAttachDisplay,requiredScope:`browser.read`,deliveryClass:`subscription`},{method:M.computerInput,requiredScope:`browser.control`,deliveryClass:`browser-control`},{method:M.browserAddDisplayIceCandidate,requiredScope:`browser.read`,deliveryClass:`browser-control`},{method:M.devTunnelRegister,requiredScope:`browser.control`,deliveryClass:`idempotent-command`},{method:M.devTunnelUnregister,requiredScope:`browser.control`,deliveryClass:`idempotent-command`},{method:M.devTunnelList,requiredScope:`browser.read`,deliveryClass:`read`},{method:M.threadDevRuntimeGet,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.threadDevRuntimeAllocatePort,requiredScope:`runtime.manage`,deliveryClass:`idempotent-command`},{method:M.threadDevRuntimeRelease,requiredScope:`runtime.manage`,deliveryClass:`idempotent-command`},{method:M.workspaceEnvironmentPreflight,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.workspaceEnsureScratch,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.serverGetConfig,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.serverRefreshProviders,requiredScope:`provider.read`,deliveryClass:`read`},{method:M.serverStartProviderAuth,requiredScope:`provider.manage`,deliveryClass:`create-command`},{method:M.serverRepairProviderAuthRuntime,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverDisconnectProviderAuth,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverGetProviderAuthSession,requiredScope:`provider.read`,deliveryClass:`read`},{method:M.serverCancelProviderAuth,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverSubmitProviderAuthCode,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverSyncPersonalCodexToCloud,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverSyncPersonalClaudeToCloud,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverUpsertKeybinding,requiredScope:`settings.write`,deliveryClass:`idempotent-command`},{method:M.serverRemoveKeybinding,requiredScope:`settings.write`,deliveryClass:`idempotent-command`},{method:M.serverGetSettings,requiredScope:`settings.read`,deliveryClass:`read`},{method:M.serverUpdateSettings,requiredScope:`settings.write`,deliveryClass:`idempotent-command`},{method:M.serverUpdateEnvironmentDisplayName,requiredScope:`settings.write`,deliveryClass:`idempotent-command`},{method:M.serverGetTraceDiagnostics,requiredScope:`settings.read`,deliveryClass:`read`},{method:M.serverHeartbeat,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.usageGetSummary,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.pullRequestsList,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsListStats,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsDetail,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsActivity,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsThreadComments,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsDiffFileContents,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsRunAction,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsUpdate,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsComment,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.pullRequestsUpdateComment,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsSubmitReview,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.pullRequestsReplyToThread,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.pullRequestsSetThreadResolution,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsSetReaction,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsInvalidate,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsReviewerCandidates,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsRequestReviewers,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.subscribeGitStatus,requiredScope:`git.read`,deliveryClass:`subscription`},{method:M.subscribeVcsStatus,requiredScope:`git.read`,deliveryClass:`subscription`},{method:M.subscribeTerminalEvents,requiredScope:`terminal.read`,deliveryClass:`terminal-output`},{method:M.subscribeTerminalMetadata,requiredScope:`terminal.read`,deliveryClass:`read`},{method:M.subscribeBrowserEvents,requiredScope:`browser.read`,deliveryClass:`browser-frame`},{method:M.subscribeServerConfig,requiredScope:`runtime.read`,deliveryClass:`subscription`},{method:M.subscribeServerLifecycle,requiredScope:`runtime.read`,deliveryClass:`subscription`},{method:M.subscribeAuthAccess,requiredScope:`provider.read`,deliveryClass:`subscription`},{method:M.subscribeWorkspaceReadiness,requiredScope:`runtime.read`,deliveryClass:`subscription`},{method:sn.dispatchCommand,requiredScope:null,deliveryClass:`idempotent-command`},{method:sn.getTurnDiff,requiredScope:`diff.read`,deliveryClass:`read`},{method:sn.getFullThreadDiff,requiredScope:`diff.read`,deliveryClass:`read`},{method:sn.streamTurnDiff,requiredScope:`diff.read`,deliveryClass:`bulk-transfer`},{method:sn.streamFullThreadDiff,requiredScope:`diff.read`,deliveryClass:`bulk-transfer`},{method:sn.replayEvents,requiredScope:`thread.read`,deliveryClass:`subscription`},{method:sn.subscribeShell,requiredScope:`thread.read`,deliveryClass:`subscription`},{method:sn.subscribeThread,requiredScope:`thread.read`,deliveryClass:`subscription`}],pae=new Set([M.gitPull,M.gitRunStackedAction,M.gitCreateWorktree,M.gitRemoveWorktree,M.gitCreateBranch,M.gitCheckout,M.gitInit,M.gitPreparePullRequestThread,M.threadDevRuntimeAllocatePort,M.threadDevRuntimeRelease,M.serverUpsertKeybinding,M.serverRemoveKeybinding,M.serverUpdateEnvironmentDisplayName,sn.dispatchCommand]),mae=fae.map(e=>{let t=e.deliveryClass===`idempotent-command`||e.deliveryClass===`create-command`;return{method:e.method,requiredScope:e.requiredScope,deliveryClass:e.deliveryClass,journalPersistence:t?pae.has(e.method)?`frame`:`metadata-only`:`none`}}),hae=dae({registeredMethods:[...Hn.requests.keys()],policies:mae}),qo={"project.create":{requiredScope:`project.write`,deliveryClass:`create-command`},"project.meta.update":{requiredScope:`project.write`,deliveryClass:`idempotent-command`},"project.delete":{requiredScope:`project.write`,deliveryClass:`idempotent-command`},"thread.create":{requiredScope:`thread.create`,deliveryClass:`create-command`},"thread.delete":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.archive":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.settle":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.unsettle":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.unarchive":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.meta.update":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.runtime-mode.set":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.interaction-mode.set":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.turn.start":{requiredScope:`turn.dispatch`,deliveryClass:`create-command`},"thread.turn.interrupt":{requiredScope:`turn.stop`,deliveryClass:`idempotent-command`},"thread.approval.respond":{requiredScope:`approval.respond`,deliveryClass:`idempotent-command`},"thread.user-input.respond":{requiredScope:`approval.respond`,deliveryClass:`idempotent-command`},"thread.checkpoint.revert":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.session.stop":{requiredScope:`turn.stop`,deliveryClass:`idempotent-command`},"thread.plan-approval.respond":{requiredScope:`approval.respond`,deliveryClass:`idempotent-command`}},gae=new Set([`thread.approval.respond`,`thread.user-input.respond`,`thread.plan-approval.respond`]);function _ae(e){if(e.method!==sn.dispatchCommand||!e.payload||typeof e.payload!=`object`||Array.isArray(e.payload))return null;let t=e.payload;if(typeof t.type!=`string`||!gae.has(t.type))return null;let n=t.type===`thread.plan-approval.respond`?t.promptId:t.requestId;if(typeof t.commandId!=`string`||t.commandId.length===0||typeof n!=`string`||n.length===0)throw new Go(`action_grant_invalid`,`Relay sensitive action metadata is incomplete`,!1);return{commandType:t.type,commandId:t.commandId,targetId:n}}function Jo(e){let t=hae.get(e.method)??null,n=uae({method:e.method,grantedScopes:e.grantedScopes,policy:t});if(e.method!==sn.dispatchCommand)return n;if(!e.payload||typeof e.payload!=`object`||!(`type`in e.payload))throw new Go(`method_not_remotable`,`Relay orchestration dispatch payload has no command policy`,!1);let r=e.payload.type;if(typeof r!=`string`||!(r in qo))throw new Go(`method_not_remotable`,`Relay orchestration command has no dispatch policy: ${String(r)}`,!1);let i=qo[r];if(!e.grantedScopes.includes(i.requiredScope))throw new Go(`scope_denied`,`Relay orchestration command ${r} requires scope ${i.requiredScope}`,!1);return{requiredScope:i.requiredScope,deliveryClass:i.deliveryClass,journalPersistence:n.journalPersistence}}var Yo=class extends Error{constructor(e){let t;t=e instanceof Error?e.message:typeof e==`string`?e:``,super(t),this.name=this.constructor.name}},Xo=class extends Yo{},Zo=class extends Yo{},Qo=class extends Yo{},vae=class extends Yo{},yae=class extends Yo{},bae=class extends Yo{},xae=class extends Yo{},Sae=class extends Yo{},Cae=class extends Yo{},wae=class extends Yo{},$o=class extends Yo{},es=Tae(globalThis,{});function Tae(e,t){return new Proxy(e,{get(n,r,i){return r in t?t[r]:e[r]},set(n,r,i){return r in t&&delete t[r],e[r]=i,!0},deleteProperty(n,r){let i=!1;return r in t&&(delete t[r],i=!0),r in e&&(delete e[r],i=!0),i},ownKeys(n){let r=Reflect.ownKeys(e),i=Reflect.ownKeys(t),a=new Set(i);return[...r.filter(e=>!a.has(e)),...i]},defineProperty(n,r,i){return r in t&&delete t[r],Reflect.defineProperty(e,r,i),!0},getOwnPropertyDescriptor(n,r){return r in t?Reflect.getOwnPropertyDescriptor(t,r):Reflect.getOwnPropertyDescriptor(e,r)},has(n,r){return r in t||r in e}})}async function Eae(){if(es!==void 0&&globalThis.crypto!==void 0)return globalThis.crypto.subtle;try{let{webcrypto:e}=await N(async()=>{let{webcrypto:e}=await import(`./__vite-browser-external-2W3EstLn.js`).then(e=>t(e.default));return{webcrypto:e}},__vite__mapDeps([0,1]));return e.subtle}catch(e){throw new $o(e)}}var ts=class{constructor(){Object.defineProperty(this,"_api",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}async _setup(){this._api===void 0&&(this._api=await Eae())}},ns={Base:0,Psk:1,Auth:2,AuthPsk:3},Dae={NotAssigned:0,DhkemP256HkdfSha256:16,DhkemP384HkdfSha384:17,DhkemP521HkdfSha512:18,DhkemSecp256k1HkdfSha256:19,DhkemX25519HkdfSha256:32,DhkemX448HkdfSha512:33,HybridkemX25519Kyber768:48,MlKem512:64,MlKem768:65,MlKem1024:66,XWing:25722},rs={HkdfSha256:1,HkdfSha384:2,HkdfSha512:3,Sha3256:4,Sha3384:5,Sha3512:6,Shake128:16,Shake256:17,TurboShake128:18,TurboShake256:19},is={Aes128Gcm:1,Aes256Gcm:2,Chacha20Poly1305:3,ExportOnly:65535},as=new Uint8Array,os=0n,ss=1n,cs=2n,Oae=new Uint8Array([75,69,77,0,0]),ls=new Uint8Array([72,80,75,69,45,118,49]);function us(e){return new Uint8Array(ds(e))}function ds(e){return e instanceof ArrayBuffer?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength).slice().buffer:new Uint8Array(e).slice().buffer}var kae=class extends ts{constructor(){super(),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:rs.HkdfSha256}),Object.defineProperty(this,"hashSize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_suiteId",{enumerable:!0,configurable:!0,writable:!0,value:as}),Object.defineProperty(this,"algHash",{enumerable:!0,configurable:!0,writable:!0,value:{name:`HMAC`,hash:`SHA-256`,length:256}})}init(e){this._suiteId=e}buildLabeledIkm(e,t){this._checkInit();let n=new Uint8Array(7+this._suiteId.byteLength+e.byteLength+t.byteLength);return n.set(ls,0),n.set(this._suiteId,7),n.set(e,7+this._suiteId.byteLength),n.set(t,7+this._suiteId.byteLength+e.byteLength),n}buildLabeledInfo(e,t,n){this._checkInit();let r=new Uint8Array(9+this._suiteId.byteLength+e.byteLength+t.byteLength);return r.set(new Uint8Array([0,n]),0),r.set(ls,2),r.set(this._suiteId,9),r.set(e,9+this._suiteId.byteLength),r.set(t,9+this._suiteId.byteLength+e.byteLength),r}async extract(e,t){await this._setup();let n=e.byteLength===0?new ArrayBuffer(this.hashSize):ds(e);if(n.byteLength!==this.hashSize)throw new Xo(`The salt length must be the same as the hashSize`);let r=ds(t),i=await this._api.importKey(`raw`,n,this.algHash,!1,[`sign`]);return await this._api.sign(`HMAC`,i,r)}async expand(e,t,n){await this._setup();let r=ds(e),i=await this._api.importKey(`raw`,r,this.algHash,!1,[`sign`]),a=new ArrayBuffer(n),o=new Uint8Array(a),s=as,c=us(t),l=new Uint8Array(1);if(n>255*this.hashSize)throw Error(`Entropy limit reached`);let u=new Uint8Array(this.hashSize+c.length+1);for(let e=1,t=0;t<o.length;e++)l[0]=e,u.set(s,0),u.set(c,s.length),u.set(l,s.length+c.length),s=new Uint8Array(await this._api.sign(`HMAC`,i,u.slice(0,s.length+c.length+1))),o.length-t>=s.length?(o.set(s,t),t+=s.length):(o.set(s.slice(0,o.length-t),t),t+=o.length-t);return a}async extractAndExpand(e,t,n,r){await this._setup();let i=ds(t),a=await this._api.importKey(`raw`,i,`HKDF`,!1,[`deriveBits`]);return await this._api.deriveBits({name:`HKDF`,hash:this.algHash.hash,salt:ds(e),info:ds(n)},a,r*8)}async labeledExtract(e,t,n){return await this.extract(e,this.buildLabeledIkm(t,n))}async labeledExpand(e,t,n,r){return await this.expand(e,this.buildLabeledInfo(t,n,r),r)}_checkInit(){if(this._suiteId===as)throw Error(`Not initialized. Call init()`)}},Aae=class extends kae{constructor(){super(...arguments),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:rs.HkdfSha256}),Object.defineProperty(this,"hashSize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"algHash",{enumerable:!0,configurable:!0,writable:!0,value:{name:`HMAC`,hash:`SHA-256`,length:256}})}},fs=e=>typeof e==`object`&&!!e&&typeof e.privateKey==`object`&&typeof e.publicKey==`object`;function ps(e,t){if(t<=0)throw Error(`i2Osp: too small size`);if(e>=256**t)throw Error(`i2Osp: too large integer`);let n=new Uint8Array(t);for(let r=0;r<t&&e;r++)n[t-(r+1)]=e%256,e=Math.floor(e/256);return n}function ms(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}function hs(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}async function jae(){if(es!==void 0&&globalThis.crypto!==void 0)return globalThis.crypto;try{let{webcrypto:e}=await N(async()=>{let{webcrypto:e}=await import(`./__vite-browser-external-2W3EstLn.js`).then(e=>t(e.default));return{webcrypto:e}},__vite__mapDeps([0,1]));return e}catch{throw Error(`failed to load Crypto`)}}function Mae(e,t){if(e.byteLength!==t.byteLength)throw Error(`xor: different length inputs`);let n=new Uint8Array(e.byteLength);for(let r=0;r<e.byteLength;r++)n[r]=e[r]^t[r];return n}var Nae=new Uint8Array([101,97,101,95,112,114,107]),Pae=new Uint8Array([115,104,97,114,101,100,95,115,101,99,114,101,116]);function Fae(e,t,n){let r=new Uint8Array(e.length+t.length+n.length);return r.set(e,0),r.set(t,e.length),r.set(n,e.length+t.length),r}var Iae=class{constructor(e,t,n){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"secretSize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"encSize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"publicKeySize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"privateKeySize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_prim",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_kdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.id=e,this._prim=t,this._kdf=n;let r=new Uint8Array(Oae);r.set(ps(this.id,2),3),this._kdf.init(r)}async serializePublicKey(e){return await this._prim.serializePublicKey(e)}async deserializePublicKey(e){return await this._prim.deserializePublicKey(ds(e))}async serializePrivateKey(e){return await this._prim.serializePrivateKey(e)}async deserializePrivateKey(e){return await this._prim.deserializePrivateKey(ds(e))}async importKey(e,t,n=!0){return await this._prim.importKey(e,t,n)}async generateKeyPair(){return await this._prim.generateKeyPair()}async deriveKeyPair(e){let t=ds(e);if(t.byteLength>8192)throw new Xo(`Too long ikm`);return await this._prim.deriveKeyPair(t)}async encap(e){let t;t=e.ekm===void 0?await this.generateKeyPair():fs(e.ekm)?e.ekm:await this.deriveKeyPair(e.ekm);let n=await this._prim.serializePublicKey(t.publicKey),r=await this._prim.serializePublicKey(e.recipientPublicKey);try{let i;if(e.senderKey===void 0)i=new Uint8Array(await this._prim.dh(t.privateKey,e.recipientPublicKey));else{let n=fs(e.senderKey)?e.senderKey.privateKey:e.senderKey;i=ms(new Uint8Array(await this._prim.dh(t.privateKey,e.recipientPublicKey)),new Uint8Array(await this._prim.dh(n,e.recipientPublicKey)))}let a;if(e.senderKey===void 0)a=ms(new Uint8Array(n),new Uint8Array(r));else{let t=fs(e.senderKey)?e.senderKey.publicKey:await this._prim.derivePublicKey(e.senderKey),i=await this._prim.serializePublicKey(t);a=Fae(new Uint8Array(n),new Uint8Array(r),new Uint8Array(i))}return{enc:n,sharedSecret:await this._generateSharedSecret(i,a)}}catch(e){throw new vae(e)}}async decap(e){let t=ds(e.enc),n=await this._prim.deserializePublicKey(t),r=fs(e.recipientKey)?e.recipientKey.privateKey:e.recipientKey,i=fs(e.recipientKey)?e.recipientKey.publicKey:await this._prim.derivePublicKey(e.recipientKey),a=await this._prim.serializePublicKey(i);try{let i;i=e.senderPublicKey===void 0?new Uint8Array(await this._prim.dh(r,n)):ms(new Uint8Array(await this._prim.dh(r,n)),new Uint8Array(await this._prim.dh(r,e.senderPublicKey)));let o;if(e.senderPublicKey===void 0)o=ms(new Uint8Array(t),new Uint8Array(a));else{let n=await this._prim.serializePublicKey(e.senderPublicKey);o=new Uint8Array(t.byteLength+a.byteLength+n.byteLength),o.set(new Uint8Array(t),0),o.set(new Uint8Array(a),t.byteLength),o.set(new Uint8Array(n),t.byteLength+a.byteLength)}return await this._generateSharedSecret(i,o)}catch(e){throw new yae(e)}}async _generateSharedSecret(e,t){let n=this._kdf.buildLabeledIkm(Nae,e),r=this._kdf.buildLabeledInfo(Pae,t,this.secretSize);return await this._kdf.extractAndExpand(as,n,r,this.secretSize)}},gs=[`deriveBits`],Lae=new Uint8Array([100,107,112,95,112,114,107]),Rae=new Uint8Array([115,107]),_s=class{constructor(e,t,n,r=[]){Object.defineProperty(this,"key",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extractable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"algorithm",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"usages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.key=t,this.type=n,this.algorithm={name:e},this.usages=r,n===`public`&&(this.usages=[])}},zae=class{constructor(e,t,n,r){Object.defineProperty(this,"_algName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_curve",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_hkdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nPk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nSk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._algName=e,this._nPk=t,this._nSk=t,this._curve=n,this._hkdf=r}serializePublicKey(e){try{return Promise.resolve(e.key.buffer)}catch(e){return Promise.reject(new Zo(e))}}async deserializePublicKey(e){try{return await this._importRawKey(ds(e),!0)}catch(e){throw new Qo(e)}}serializePrivateKey(e){try{return Promise.resolve(e.key.buffer)}catch(e){return Promise.reject(new Zo(e))}}async deserializePrivateKey(e){try{return await this._importRawKey(ds(e),!1)}catch(e){throw new Qo(e)}}async importKey(e,t,n){try{if(e===`raw`)return await this._importRawKey(t,n);if(t instanceof ArrayBuffer)throw Error(`Invalid jwk key format`);return await this._importJWK(t,n)}catch(e){throw new Qo(e)}}async generateKeyPair(){try{let e=await this._curve.utils.randomSecretKey(),t=new _s(this._algName,e,`private`,gs);return{publicKey:await this.derivePublicKey(t),privateKey:t}}catch(e){throw new $o(e)}}async deriveKeyPair(e){try{let t=ds(e),n=await this._hkdf.labeledExtract(as.buffer,Lae,new Uint8Array(t)),r=await this._hkdf.labeledExpand(n,Rae,as,this._nSk),i=new _s(this._algName,new Uint8Array(r),`private`,gs);return{privateKey:i,publicKey:await this.derivePublicKey(i)}}catch(e){throw new wae(e)}}derivePublicKey(e){try{let t=this._curve.getPublicKey(e.key);return Promise.resolve(new _s(this._algName,t,`public`))}catch(e){return Promise.reject(new Qo(e))}}dh(e,t){try{return Promise.resolve(this._curve.getSharedSecret(e.key,t.key).buffer)}catch(e){return Promise.reject(new Zo(e))}}_importRawKey(e,t){return new Promise((n,r)=>{t&&e.byteLength!==this._nPk&&r(Error(`Invalid length of the key`)),!t&&e.byteLength!==this._nSk&&r(Error(`Invalid length of the key`)),n(new _s(this._algName,new Uint8Array(e),t?`public`:`private`,t?[]:gs))})}_importJWK(e,t){return new Promise((n,r)=>{e.kty!==`OKP`&&r(Error(`Invalid kty: ${e.kty}`)),e.crv!==this._algName&&r(Error(`Invalid crv: ${e.crv}`)),t?(e.d!==void 0&&r(Error("Invalid key: `d` should not be set")),typeof e.x!=`string`&&r(Error("Invalid key: `x` not found")),n(new _s(this._algName,hs(e.x),`public`))):(typeof e.d!=`string`&&r(Error("Invalid key: `d` not found")),n(new _s(this._algName,hs(e.d),`private`,gs)))})}};function Bae(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function vs(e,t=``){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw Error(`${n}expected integer >0, got ${e}`)}}function ys(e,t,n=``){let r=Bae(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`;throw Error(o+`expected Uint8Array`+s+`, got `+c)}return e}function bs(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function xs(e,t){ys(e,void 0,`digestInto() output`);let n=t.outputLen;if(e.length<n)throw Error(`"digestInto() output" expected to be of length >=`+n)}function Vae(e){if(typeof e==`bigint`){if(!Ms(e))throw Error(`positive bigint expected, got `+e)}else vs(e);return e}function Ss(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Cs(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var Hae=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ws(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ts(e,t){return e<<32-t|e>>>t}var Es=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,Uae=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`)),Wae=[0n,1n,2n,3n,4n,5n,6n,7n,8n,9n,10n,11n,12n,13n,14n,15n];function Gae(e){if(ys(e),Es)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=Uae[e[n]];return t}var Ds={_0:48,_9:57,A:65,F:70,a:97,f:102};function Os(e){if(e>=Ds._0&&e<=Ds._9)return e-Ds._0;if(e>=Ds.A&&e<=Ds.F)return e-(Ds.A-10);if(e>=Ds.a&&e<=Ds.f)return e-(Ds.a-10)}function Kae(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(Es)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=Os(e.charCodeAt(i)),a=Os(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function qae(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);let t=os;for(let n=0;n<e.length;n++){let r=Os(e.charCodeAt(n));if(r===void 0)throw Error(`hex string expected, got non-hex character "`+e[n]+`" at index `+n);t=t<<4n|Wae[r]}return t}function ks(e){vs(e,`numberToBigint`);let t=e,n=os,r=1n;for(;t>0;)t%2==1&&(n+=r),t=Math.floor(t/2),r<<=1n;return n}function As(e){return qae(Gae(js(ys(e)).reverse()))}function Jae(e,t){vs(t),e=Vae(e);let n=Kae(e.toString(16).padStart(t*2,`0`));if(n.length!==t)throw Error(`number too large`);return n}function Yae(e,t){return Jae(e,t).reverse()}function js(e){return Uint8Array.from(e)}function Ms(e){return typeof e==`bigint`&&0n<=e}function Xae(e,t,n){return Ms(e)&&Ms(t)&&Ms(n)&&t<=e&&e<n}function Ns(e,t,n,r){if(!Xae(t,n,r))throw Error(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function Zae(e,t={},n={}){if(!e||typeof e!=`object`)throw Error(`expected valid options object`);function r(t,n,r){let i=e[t];if(r&&i===void 0)return;let a=typeof i;if(a!==n||i===null)throw Error(`param "${t}" is invalid: expected ${n}, got ${a}`)}let i=(e,t)=>Object.entries(e).forEach(([e,n])=>r(e,n,t));i(t,!1),i(n,!0)}async function Qae(e=32){let t=await jae(),n=new Uint8Array(e);return t.getRandomValues(n),n}function $ae(e){return{oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])}}function eoe(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash must wrapped by utils.createHasher`);vs(e.outputLen),vs(e.blockLen)}function toe(e,t={}){let n=(t,n)=>e(n).update(t).digest(),r=e(void 0),i=Object.assign(n,{outputLen:r.outputLen,blockLen:r.blockLen,create:t=>e(t),...t});return Object.freeze(i)}var Ps=class{constructor(e,t){if(Object.defineProperty(this,"oHash",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"iHash",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"blockLen",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputLen",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"finished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),eoe(e),ys(t,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),Cs(r)}update(e){return bs(this),this.iHash.update(e),this}digestInto(e){bs(this),ys(e,this.outputLen,`output`),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Fs=(e,t,n)=>new Ps(e,t).update(n).digest();Fs.create=(e,t)=>new Ps(e,t);function noe(e,t,n){return e&t^~e&n}function roe(e,t,n){return e&t^e&n^t&n}var ioe=class{constructor(e,t,n,r){Object.defineProperty(this,"blockLen",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputLen",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"padOffset",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLE",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"view",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"finished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"length",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"pos",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=ws(this.buffer)}update(e){bs(this),ys(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=ws(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){bs(this),xs(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,Cs(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;n.setBigUint64(r-8,ks(this.length*8),i),this.process(n,0);let o=ws(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen must be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},Is=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),aoe=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ls=new Uint32Array(64),ooe=class extends ioe{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)Ls[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Ls[e-15],n=Ls[e-2],r=Ts(t,7)^Ts(t,18)^t>>>3,i=Ts(n,17)^Ts(n,19)^n>>>10;Ls[e]=i+Ls[e-7]+r+Ls[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=Ts(o,6)^Ts(o,11)^Ts(o,25),u=l+t+noe(o,s,c)+aoe[e]+Ls[e]|0,d=(Ts(n,2)^Ts(n,13)^Ts(n,22))+roe(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){Cs(Ls)}destroy(){this.set(0,0,0,0,0,0,0,0),Cs(this.buffer)}},soe=class extends ooe{constructor(){super(32),Object.defineProperty(this,"A",{enumerable:!0,configurable:!0,writable:!0,value:Is[0]|0}),Object.defineProperty(this,"B",{enumerable:!0,configurable:!0,writable:!0,value:Is[1]|0}),Object.defineProperty(this,"C",{enumerable:!0,configurable:!0,writable:!0,value:Is[2]|0}),Object.defineProperty(this,"D",{enumerable:!0,configurable:!0,writable:!0,value:Is[3]|0}),Object.defineProperty(this,"E",{enumerable:!0,configurable:!0,writable:!0,value:Is[4]|0}),Object.defineProperty(this,"F",{enumerable:!0,configurable:!0,writable:!0,value:Is[5]|0}),Object.defineProperty(this,"G",{enumerable:!0,configurable:!0,writable:!0,value:Is[6]|0}),Object.defineProperty(this,"H",{enumerable:!0,configurable:!0,writable:!0,value:Is[7]|0})}},Rs=toe(()=>new soe,$ae(1));function zs(e,t){let n=e%t;return n>=0n?n:t+n}function Bs(e,t,n){let r=e;for(;t-->os;)r*=r,r%=n;return r}function coe(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}function loe(e){return Zae(e,{adjustScalarBytes:`function`,powPminus2:`function`}),Object.freeze({...e})}function uoe(e){let{P:t,type:n,adjustScalarBytes:r,powPminus2:i,randomBytes:a}=loe(e),o=n===`x25519`;if(!o&&n!==`x448`)throw Error(`invalid type`);let s=a||Qae,c=o?255n:448n,l=o?32:56,u=o?9n:5n,d=o?121665n:39081n,f=o?cs**254n:cs**447n,p=f+(o?8n*cs**251n-ss:4n*cs**445n-ss)+ss,m=e=>zs(e,t),h=g(u);function g(e){return Yae(m(e),l)}function _(e){let t=js(ys(e,l,`uCoordinate`));return o&&(t[31]&=127),m(As(t))}function v(e){return As(r(js(ys(e,l,`scalar`))))}function y(e,t){let n=w(_(t),v(e));if(n===0n)throw Error(`invalid private or public key received`);return g(n)}function b(e){return y(e,h)}let x=b,S=y;function C(e,t,n){let r=m(e*(t-n));return t=m(t-r),n=m(n+r),{x_2:t,x_3:n}}function w(e,n){Ns(`u`,e,os,t),Ns(`scalar`,n,f,p);let r=n,a=e,o=ss,s=os,l=e,u=ss,h=os;for(let e=c-1n;e>=os;e--){let t=r>>e&ss;h^=t,{x_2:o,x_3:l}=C(h,o,l),{x_2:s,x_3:u}=C(h,s,u),h=t;let n=o+s,i=m(n*n),c=o-s,f=m(c*c),p=i-f,g=l+u,_=l-u,v=m(_*n),y=m(g*c),b=v+y,x=v-y;l=m(b*b),u=m(a*m(x*x)),o=m(i*f),s=m(p*(i+m(d*p)))}({x_2:o,x_3:l}=C(h,o,l)),{x_2:s,x_3:u}=C(h,s,u);let g=i(s);return m(o*g)}let T={secretKey:l,publicKey:l,seed:l},E=async e=>(e===void 0&&(e=await s(l)),ys(e,T.seed,`seed`),e),D={randomSecretKey:E};return Object.freeze({keygen:coe(E,x),getSharedSecret:S,getPublicKey:x,scalarMult:y,scalarMultBase:b,utils:D,GuBytes:h.slice(),lengths:T})}function Vs(e){if(typeof e!=`boolean`)throw Error(`boolean expected, not ${e}`)}var doe=(e,t)=>{function n(n,...r){if(ys(n,void 0,`key`),!Hae)throw Error(`Non little-endian hardware is not yet supported`);if(e.nonceLength!==void 0){let t=r[0];ys(t,e.varSizeNonce?void 0:e.nonceLength,`nonce`)}let i=e.tagLength;i&&r[1]!==void 0&&ys(r[1],void 0,`AAD`);let a=t(n,...r),o=(e,t)=>{if(t!==void 0){if(e!==2)throw Error(`cipher output not supported`);ys(t,void 0,`output`)}},s=!1;return{encrypt(e,t){if(s)throw Error(`cannot encrypt() twice with same key + nonce`);return s=!0,ys(e),o(a.encrypt.length,t),a.encrypt(e,t)},decrypt(e,t){if(ys(e),i&&e.length<i)throw Error(`"ciphertext" expected length bigger than tagLength=`+i);return o(a.decrypt.length,t),a.decrypt(e,t)}}}return Object.assign(n,e),n};function foe(e,t){if(typeof t!=`object`||!t)throw Error(`options must be defined`);return Object.assign(e,t)}function poe(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function Hs(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(t.length!==e)throw Error(`"output" expected Uint8Array of length `+e+`, got: `+t.length);if(n&&!hoe(t))throw Error(`invalid output, must be aligned`);return t}function moe(e,t,n){Vs(n);let r=new Uint8Array(16),i=ws(r);return i.setBigUint64(0,ks(t),n),i.setBigUint64(8,ks(e),n),r}function hoe(e){return e.byteOffset%4==0}var Us=e=>Uint8Array.from(e.split(``).map(e=>e.charCodeAt(0))),goe=Us(`expand 16-byte k`),_oe=Us(`expand 32-byte k`),voe=Ss(goe),yoe=Ss(_oe);function Ws(e,t){return e<<t|e>>>32-t}function Gs(e){return e.byteOffset%4==0}var Ks=64,boe=16,qs=2**32-1,Js=Uint32Array.of();function xoe(e,t,n,r,i,a,o,s){let c=i.length,l=new Uint8Array(Ks),u=Ss(l),d=Gs(i)&&Gs(a),f=d?Ss(i):Js,p=d?Ss(a):Js;for(let m=0;m<c;o++){if(e(t,n,r,u,o,s),o>=qs)throw Error(`arx: counter overflow`);let h=Math.min(Ks,c-m);if(d&&h===Ks){let e=m/4;if(m%4!=0)throw Error(`arx: invalid block position`);for(let t=0,n;t<boe;t++)n=e+t,p[n]=f[n]^u[t];m+=Ks;continue}for(let e=0,t;e<h;e++)t=m+e,a[t]=i[t]^l[e];m+=h}}function Soe(e,t){let{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:a,rounds:o}=foe({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=`function`)throw Error(`core must be a function`);return vs(i),vs(o),Vs(a),Vs(n),(t,s,c,l,u=0)=>{ys(t,void 0,`key`),ys(s,void 0,`nonce`),ys(c,void 0,`data`);let d=c.length;if(l===void 0&&(l=new Uint8Array(d)),ys(l,void 0,`output`),vs(u),u<0||u>=qs)throw Error(`arx: counter overflow`);if(l.length<d)throw Error(`arx: output (${l.length}) is shorter than data (${d})`);let f=[],p=t.length,m,h;if(p===32)f.push(m=js(t)),h=yoe;else if(p===16&&n)m=new Uint8Array(32),m.set(t),m.set(t,16),h=voe,f.push(m);else throw ys(t,32,`arx key`),Error(`invalid key size`);Gs(s)||f.push(s=js(s));let g=Ss(m);if(r){if(s.length!==24)throw Error(`arx: extended nonce must be 24 bytes`);r(h,g,Ss(s.subarray(0,16)),g),s=s.subarray(16)}let _=16-i;if(_!==s.length)throw Error(`arx: nonce must be ${_} or 16 bytes`);if(_!==12){let e=new Uint8Array(12);e.set(s,a?0:12-s.length),s=e,f.push(s)}let v=Ss(s);return xoe(e,h,g,v,c,l,u,o),Cs(...f),l}}function Ys(e,t){return e[t++]&255|(e[t++]&255)<<8}var Coe=class{constructor(e){Object.defineProperty(this,"blockLen",{enumerable:!0,configurable:!0,writable:!0,value:16}),Object.defineProperty(this,"outputLen",{enumerable:!0,configurable:!0,writable:!0,value:16}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:new Uint8Array(16)}),Object.defineProperty(this,"r",{enumerable:!0,configurable:!0,writable:!0,value:new Uint16Array(10)}),Object.defineProperty(this,"h",{enumerable:!0,configurable:!0,writable:!0,value:new Uint16Array(10)}),Object.defineProperty(this,"pad",{enumerable:!0,configurable:!0,writable:!0,value:new Uint16Array(8)}),Object.defineProperty(this,"pos",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"finished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),e=js(ys(e,32,`key`));let t=Ys(e,0),n=Ys(e,2),r=Ys(e,4),i=Ys(e,6),a=Ys(e,8),o=Ys(e,10),s=Ys(e,12),c=Ys(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|n<<3)&8191,this.r[2]=(n>>>10|r<<6)&7939,this.r[3]=(r>>>7|i<<9)&8191,this.r[4]=(i>>>4|a<<12)&255,this.r[5]=a>>>1&8190,this.r[6]=(a>>>14|o<<2)&8191,this.r[7]=(o>>>11|s<<5)&8065,this.r[8]=(s>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=Ys(e,16+2*t)}process(e,t,n=!1){let r=n?0:2048,{h:i,r:a}=this,o=a[0],s=a[1],c=a[2],l=a[3],u=a[4],d=a[5],f=a[6],p=a[7],m=a[8],h=a[9],g=Ys(e,t+0),_=Ys(e,t+2),v=Ys(e,t+4),y=Ys(e,t+6),b=Ys(e,t+8),x=Ys(e,t+10),S=Ys(e,t+12),C=Ys(e,t+14),w=i[0]+(g&8191),T=i[1]+((g>>>13|_<<3)&8191),E=i[2]+((_>>>10|v<<6)&8191),D=i[3]+((v>>>7|y<<9)&8191),O=i[4]+((y>>>4|b<<12)&8191),ee=i[5]+(b>>>1&8191),te=i[6]+((b>>>14|x<<2)&8191),k=i[7]+((x>>>11|S<<5)&8191),A=i[8]+((S>>>8|C<<8)&8191),ne=i[9]+(C>>>5|r),j=0,re=j+w*o+5*h*T+5*m*E+5*p*D+5*f*O;j=re>>>13,re&=8191,re+=5*d*ee+5*u*te+5*l*k+5*c*A+5*s*ne,j+=re>>>13,re&=8191;let ie=j+w*s+T*o+5*h*E+5*m*D+5*p*O;j=ie>>>13,ie&=8191,ie+=5*f*ee+5*d*te+5*u*k+5*l*A+5*c*ne,j+=ie>>>13,ie&=8191;let ae=j+w*c+T*s+E*o+5*h*D+5*m*O;j=ae>>>13,ae&=8191,ae+=5*p*ee+5*f*te+5*d*k+5*u*A+5*l*ne,j+=ae>>>13,ae&=8191;let oe=j+w*l+T*c+E*s+D*o+5*h*O;j=oe>>>13,oe&=8191,oe+=5*m*ee+5*p*te+5*f*k+5*d*A+5*u*ne,j+=oe>>>13,oe&=8191;let se=j+w*u+T*l+E*c+D*s+O*o;j=se>>>13,se&=8191,se+=5*h*ee+5*m*te+5*p*k+5*f*A+5*d*ne,j+=se>>>13,se&=8191;let ce=j+w*d+T*u+E*l+D*c+O*s;j=ce>>>13,ce&=8191,ce+=ee*o+5*h*te+5*m*k+5*p*A+5*f*ne,j+=ce>>>13,ce&=8191;let le=j+w*f+T*d+E*u+D*l+O*c;j=le>>>13,le&=8191,le+=ee*s+te*o+5*h*k+5*m*A+5*p*ne,j+=le>>>13,le&=8191;let ue=j+w*p+T*f+E*d+D*u+O*l;j=ue>>>13,ue&=8191,ue+=ee*c+te*s+k*o+5*h*A+5*m*ne,j+=ue>>>13,ue&=8191;let de=j+w*m+T*p+E*f+D*d+O*u;j=de>>>13,de&=8191,de+=ee*l+te*c+k*s+A*o+5*h*ne,j+=de>>>13,de&=8191;let fe=j+w*h+T*m+E*p+D*f+O*d;j=fe>>>13,fe&=8191,fe+=ee*u+te*l+k*c+A*s+ne*o,j+=fe>>>13,fe&=8191,j=(j<<2)+j|0,j=j+re|0,re=j&8191,j>>>=13,ie+=j,i[0]=re,i[1]=ie,i[2]=ae,i[3]=oe,i[4]=se,i[5]=ce,i[6]=le,i[7]=ue,i[8]=de,i[9]=fe}finalize(){let{h:e,pad:t}=this,n=new Uint16Array(10),r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=8191;e[0]+=r*5,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,n[0]=e[0]+5,r=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+r,r=n[t]>>>13,n[t]&=8191;n[9]-=8192;let i=(r^1)-1;for(let e=0;e<10;e++)n[e]&=i;i=~i;for(let t=0;t<10;t++)e[t]=e[t]&i|n[t];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let a=e[0]+t[0];e[0]=a&65535;for(let n=1;n<8;n++)a=(e[n]+t[n]|0)+(a>>>16)|0,e[n]=a&65535;Cs(n)}update(e){bs(this),ys(e),e=js(e);let{buffer:t,blockLen:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(n-this.pos,r-i);if(a===n){for(;n<=r-i;i+=n)this.process(e,i);continue}t.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){Cs(this.h,this.r,this.buffer,this.pad)}digestInto(e){bs(this),xs(e,this),this.finished=!0;let{buffer:t,h:n}=this,{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let t=0;t<8;t++)e[i++]=n[t]>>>0,e[i++]=n[t]>>>8;return e}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}};function woe(e){let t=(t,n)=>e(n).update(t).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}var Toe=woe(e=>new Coe(e));function Eoe(e,t,n,r,i,a=20){let o=e[0],s=e[1],c=e[2],l=e[3],u=t[0],d=t[1],f=t[2],p=t[3],m=t[4],h=t[5],g=t[6],_=t[7],v=i,y=n[0],b=n[1],x=n[2],S=o,C=s,w=c,T=l,E=u,D=d,O=f,ee=p,te=m,k=h,A=g,ne=_,j=v,re=y,ie=b,ae=x;for(let e=0;e<a;e+=2)S=S+E|0,j=Ws(j^S,16),te=te+j|0,E=Ws(E^te,12),S=S+E|0,j=Ws(j^S,8),te=te+j|0,E=Ws(E^te,7),C=C+D|0,re=Ws(re^C,16),k=k+re|0,D=Ws(D^k,12),C=C+D|0,re=Ws(re^C,8),k=k+re|0,D=Ws(D^k,7),w=w+O|0,ie=Ws(ie^w,16),A=A+ie|0,O=Ws(O^A,12),w=w+O|0,ie=Ws(ie^w,8),A=A+ie|0,O=Ws(O^A,7),T=T+ee|0,ae=Ws(ae^T,16),ne=ne+ae|0,ee=Ws(ee^ne,12),T=T+ee|0,ae=Ws(ae^T,8),ne=ne+ae|0,ee=Ws(ee^ne,7),S=S+D|0,ae=Ws(ae^S,16),A=A+ae|0,D=Ws(D^A,12),S=S+D|0,ae=Ws(ae^S,8),A=A+ae|0,D=Ws(D^A,7),C=C+O|0,j=Ws(j^C,16),ne=ne+j|0,O=Ws(O^ne,12),C=C+O|0,j=Ws(j^C,8),ne=ne+j|0,O=Ws(O^ne,7),w=w+ee|0,re=Ws(re^w,16),te=te+re|0,ee=Ws(ee^te,12),w=w+ee|0,re=Ws(re^w,8),te=te+re|0,ee=Ws(ee^te,7),T=T+E|0,ie=Ws(ie^T,16),k=k+ie|0,E=Ws(E^k,12),T=T+E|0,ie=Ws(ie^T,8),k=k+ie|0,E=Ws(E^k,7);let oe=0;r[oe++]=o+S|0,r[oe++]=s+C|0,r[oe++]=c+w|0,r[oe++]=l+T|0,r[oe++]=u+E|0,r[oe++]=d+D|0,r[oe++]=f+O|0,r[oe++]=p+ee|0,r[oe++]=m+te|0,r[oe++]=h+k|0,r[oe++]=g+A|0,r[oe++]=_+ne|0,r[oe++]=v+j|0,r[oe++]=y+re|0,r[oe++]=b+ie|0,r[oe++]=x+ae|0}var Doe=Soe(Eoe,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Ooe=new Uint8Array(16),Xs=(e,t)=>{e.update(t);let n=t.length%16;n&&e.update(Ooe.subarray(n))},koe=new Uint8Array(32);function Zs(e,t,n,r,i){i!==void 0&&ys(i,void 0,`AAD`);let a=e(t,n,koe),o=moe(r.length,i?i.length:0,!0),s=Toe.create(a);i&&Xs(s,i),Xs(s,r),s.update(o);let c=s.digest();return Cs(a,o),c}var Qs=doe({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,n,r)=>({encrypt(i,a){let o=i.length;a=Hs(o+16,a,!1),a.set(i);let s=a.subarray(0,-16);e(t,n,s,s,1);let c=Zs(e,t,n,s,r);return a.set(c,o),Cs(c),a},decrypt(i,a){a=Hs(i.length-16,a,!1);let o=i.subarray(0,-16),s=i.subarray(-16),c=Zs(e,t,n,o,r);if(!poe(s,c))throw Error(`invalid tag`);return a.set(i.subarray(0,-16)),e(t,n,a,a,1),Cs(c),a}}))(Doe)),Aoe=class{constructor(e){Object.defineProperty(this,"_key",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._key=new Uint8Array(ds(e))}async seal(e,t,n){return await this._seal(ds(e),ds(t),ds(n))}async open(e,t,n){return await this._open(ds(e),ds(t),ds(n))}_seal(e,t,n){return new Promise(r=>{r(Qs(this._key,new Uint8Array(e),new Uint8Array(n)).encrypt(new Uint8Array(t)).buffer)})}_open(e,t,n){return new Promise(r=>{r(Qs(this._key,new Uint8Array(e),new Uint8Array(n)).decrypt(new Uint8Array(t)).buffer)})}},joe=class{constructor(){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:is.Chacha20Poly1305}),Object.defineProperty(this,"keySize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"nonceSize",{enumerable:!0,configurable:!0,writable:!0,value:12}),Object.defineProperty(this,"tagSize",{enumerable:!0,configurable:!0,writable:!0,value:16})}createEncryptionContext(e){return new Aoe(e)}};function $s(){return new Promise((e,t)=>{t(new $o(`Not supported`))})}var Moe=new Uint8Array([115,101,99]),ec=class{constructor(e,t,n){Object.defineProperty(this,"_api",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"exporterSecret",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_kdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._api=e,this._kdf=t,this.exporterSecret=n}async seal(e,t){return await $s()}async open(e,t){return await $s()}async export(e,t){let n=ds(e);if(n.byteLength>8192)throw new Xo(`Too long exporter context`);try{return await this._kdf.labeledExpand(this.exporterSecret,Moe,new Uint8Array(n),t)}catch(e){throw new bae(e)}}},Noe=class extends ec{},Poe=class extends ec{constructor(e,t,n,r){super(e,t,n),Object.defineProperty(this,"enc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.enc=r}},tc=class extends ec{constructor(e,t,n){if(super(e,t,n.exporterSecret),Object.defineProperty(this,"_aead",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nK",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nN",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nT",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_ctx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n.key===void 0||n.baseNonce===void 0||n.seq===void 0)throw Error(`Required parameters are missing`);this._aead=n.aead,this._nK=this._aead.keySize,this._nN=this._aead.nonceSize,this._nT=this._aead.tagSize;let r=this._aead.createEncryptionContext(n.key);this._ctx={key:r,baseNonce:n.baseNonce,seq:n.seq}}computeNonce(e){let t=ps(e.seq,e.baseNonce.byteLength);return Mae(e.baseNonce,t).buffer}incrementSeq(e){if(e.seq>2**53-1)throw new Cae(`Message limit reached`);e.seq+=1}},Foe=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Ioe=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},nc,rc=class{constructor(){nc.set(this,Promise.resolve())}async lock(){let e,t=new Promise(t=>{e=t}),n=Foe(this,nc,`f`);return Ioe(this,nc,t,`f`),await n,e}};nc=new WeakMap;var ic=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Loe=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},ac,Roe=class extends tc{constructor(){super(...arguments),ac.set(this,void 0)}async open(e,t=as.buffer){Loe(this,ac,ic(this,ac,`f`)??new rc,`f`);let n=await ic(this,ac,`f`).lock(),r;try{r=await this._ctx.key.open(this.computeNonce(this._ctx),ds(e),ds(t))}catch(e){throw new Sae(e)}finally{n()}return this.incrementSeq(this._ctx),r}};ac=new WeakMap;var oc=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},zoe=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},sc,Boe=class extends tc{constructor(e,t,n,r){super(e,t,n),Object.defineProperty(this,"enc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),sc.set(this,void 0),this.enc=r}async seal(e,t=as.buffer){zoe(this,sc,oc(this,sc,`f`)??new rc,`f`);let n=await oc(this,sc,`f`).lock(),r;try{r=await this._ctx.key.seal(this.computeNonce(this._ctx),ds(e),ds(t))}catch(e){throw new xae(e)}finally{n()}return this.incrementSeq(this._ctx),r}};sc=new WeakMap;var Voe=new Uint8Array([98,97,115,101,95,110,111,110,99,101]),Hoe=new Uint8Array([101,120,112]),Uoe=new Uint8Array([105,110,102,111,95,104,97,115,104]),Woe=new Uint8Array([107,101,121]),Goe=new Uint8Array([112,115,107,95,105,100,95,104,97,115,104]),Koe=new Uint8Array([115,101,99,114,101,116]),qoe=new Uint8Array([72,80,75,69,0,0,0,0,0,0]),Joe=class extends ts{constructor(e){if(super(),Object.defineProperty(this,"_kem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_kdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_aead",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_suiteId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),typeof e.kem==`number`)throw new Xo(`KemId cannot be used`);if(this._kem=e.kem,typeof e.kdf==`number`)throw new Xo(`KdfId cannot be used`);if(this._kdf=e.kdf,typeof e.aead==`number`)throw new Xo(`AeadId cannot be used`);this._aead=e.aead,this._suiteId=new Uint8Array(qoe),this._suiteId.set(ps(this._kem.id,2),4),this._suiteId.set(ps(this._kdf.id,2),6),this._suiteId.set(ps(this._aead.id,2),8),this._kdf.init(this._suiteId)}get kem(){return this._kem}get kdf(){return this._kdf}get aead(){return this._aead}async createSenderContext(e){this._validateInputLength(e),await this._setup();let t=await this._kem.encap(e),n;return n=e.psk===void 0?e.senderKey===void 0?ns.Base:ns.Auth:e.senderKey===void 0?ns.Psk:ns.AuthPsk,await this._keyScheduleS(n,t.sharedSecret,t.enc,e)}async createRecipientContext(e){this._validateInputLength(e),await this._setup();let t=await this._kem.decap(e),n;return n=e.psk===void 0?e.senderPublicKey===void 0?ns.Base:ns.Auth:e.senderPublicKey===void 0?ns.Psk:ns.AuthPsk,await this._keyScheduleR(n,t,e)}async seal(e,t,n=as.buffer){let r=await this.createSenderContext(e);return{ct:await r.seal(t,n),enc:r.enc}}async open(e,t,n=as.buffer){return await(await this.createRecipientContext(e)).open(t,n)}async _keySchedule(e,t,n){let r=n.psk===void 0?as:us(n.psk.id),i=await this._kdf.labeledExtract(as,Goe,r),a=n.info===void 0?as:us(n.info),o=await this._kdf.labeledExtract(as,Uoe,a),s=new Uint8Array(1+i.byteLength+o.byteLength);s.set(new Uint8Array([e]),0),s.set(new Uint8Array(i),1),s.set(new Uint8Array(o),1+i.byteLength);let c=n.psk===void 0?as:us(n.psk.key),l=this._kdf.buildLabeledIkm(Koe,c),u=this._kdf.buildLabeledInfo(Hoe,s,this._kdf.hashSize),d=await this._kdf.extractAndExpand(t,l,u,this._kdf.hashSize);if(this._aead.id===is.ExportOnly)return{aead:this._aead,exporterSecret:d};let f=this._kdf.buildLabeledInfo(Woe,s,this._aead.keySize),p=await this._kdf.extractAndExpand(t,l,f,this._aead.keySize),m=this._kdf.buildLabeledInfo(Voe,s,this._aead.nonceSize),h=await this._kdf.extractAndExpand(t,l,m,this._aead.nonceSize);return{aead:this._aead,exporterSecret:d,key:p,baseNonce:new Uint8Array(h),seq:0}}async _keyScheduleS(e,t,n,r){let i=await this._keySchedule(e,t,r);return i.key===void 0?new Poe(this._api,this._kdf,i.exporterSecret,n):new Boe(this._api,this._kdf,i,n)}async _keyScheduleR(e,t,n){let r=await this._keySchedule(e,t,n);return r.key===void 0?new Noe(this._api,this._kdf,r.exporterSecret):new Roe(this._api,this._kdf,r)}_validateInputLength(e){if(e.info!==void 0&&e.info.byteLength>268435456)throw new Xo(`Too long info`);if(e.psk!==void 0){if(e.psk.key.byteLength<32)throw new Xo(`PSK must have at least 32 bytes`);if(e.psk.key.byteLength>8192)throw new Xo(`Too long psk.key`);if(e.psk.id.byteLength>8192)throw new Xo(`Too long psk.id`)}}},Yoe=class extends Joe{},Xoe=1n,cc=2n,Zoe=3n,Qoe=5n,lc=57896044618658097711785492504343953926634992332820282019728792003956564819949n;function $oe(e){let t=10n,n=80n,r=lc,i=e*e%r*e%r,a=Bs(Bs(i,cc,r)*i%r,Xoe,r)*e%r,o=Bs(a,Qoe,r)*a%r,s=Bs(o,t,r)*o%r,c=Bs(s,20n,r)*s%r,l=Bs(c,40n,r)*c%r;return{pow_p_5_8:Bs(Bs(Bs(Bs(l,n,r)*l%r,n,r)*l%r,t,r)*o%r,cc,r)*e%r,b2:i}}function ese(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var tse=(()=>{let e=lc;return uoe({P:e,type:`x25519`,powPminus2:t=>{let{pow_p_5_8:n,b2:r}=$oe(t);return zs(Bs(n,Zoe,e)*r,e)},adjustScalarBytes:ese})})(),nse=class extends zae{constructor(e){super(`X25519`,32,tse,e)}derive(e,t){try{return Promise.resolve(this._curve.getSharedSecret(e,t))}catch(e){return Promise.reject(new Zo(e))}}},uc=`DHKEM_X25519_HKDF_SHA256/HKDF_SHA256/CHACHA20_POLY1305/AUTH`,rse=2**31,ise=65536,ase=16,dc=32,fc=(1n<<255n)-19n,pc=new TextEncoder,mc=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`;function hc(e){let t=0n;for(let n=0;n<e.length;n+=2)t|=BigInt(Number.parseInt(e.slice(n,n+2),16))<<BigInt(n/2*8);return t}var ose=new Set([0n,1n,hc(`e0eb7a7c3b41b8ae1656e3faf19fc46ada098deb9c32b1fd866205165f49b800`),hc(`5f9c95bca3508c24b1d0b1559c83ef5b04445cc4581c8e86d8224eddd09f1157`),fc-1n]),sse=new Uint8Array,gc=class extends Aae{async extract(e,t){return ds(Fs(Rs,e.byteLength===0?new Uint8Array(this.hashSize):us(e),us(t)))}async expand(e,t,n){if(!Number.isSafeInteger(n)||n<0||n>255*this.hashSize)throw Error(`HKDF output length exceeds the RFC 5869 limit.`);let r=us(e),i=us(t),a=new Uint8Array(n),o=sse;for(let e=1,t=0;t<a.byteLength;e+=1){let n=bc([o,i,Uint8Array.of(e)]);o=new Uint8Array(Fs(Rs,r,n));let s=a.byteLength-t;a.set(o.subarray(0,Math.min(o.byteLength,s)),t),t+=Math.min(o.byteLength,s)}return ds(a)}async extractAndExpand(e,t,n,r){return this.expand(await this.extract(e,t),n,r)}},_c=new Yoe({kem:new class extends Iae{secretSize=32;encSize=32;publicKeySize=32;privateKeySize=32;constructor(e){super(Dae.DhkemX25519HkdfSha256,new nse(e),e)}}(new gc),kdf:new gc,aead:new joe}),vc=class extends Error{code;name=`RelayPayloadChannelFailure`;constructor(e,t){super(t),this.code=e}};function yc(e){return new Uint8Array(e.slice(0))}function cse(e){let t=new Uint8Array(e.byteLength);return t.set(e),t.buffer}function bc(e){let t=e.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function xc(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new vc(`channel_ticket_binding_invalid`,`Invalid uint32 value.`);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!1),t}function Sc(e){if(!Number.isSafeInteger(e)||e<0)throw new vc(`channel_ticket_binding_invalid`,`Invalid uint64 value.`);let t=new Uint8Array(8);return new DataView(t.buffer).setBigUint64(0,BigInt(e),!1),t}function lse(e){return bc([xc(e.byteLength),e])}function Cc(e){return Uint8Array.of(e===`control-to-runtime`?0:1)}function use(e){return e===`handshake`?Uint8Array.of(0):e===`application`?Uint8Array.of(1):Uint8Array.of(2)}function wc(e){let t=``;for(let n=0;n<e.byteLength;n+=3){let r=e[n]??0,i=e[n+1]??0,a=e[n+2]??0,o=r<<16|i<<8|a;t+=mc[o>>>18&63],t+=mc[o>>>12&63],n+1<e.byteLength&&(t+=mc[o>>>6&63]),n+2<e.byteLength&&(t+=mc[o&63])}return t}function Tc(e){if(!/^[A-Za-z0-9_-]*$/.test(e)||e.length%4==1)throw new vc(`channel_authentication_failed`,`Encrypted relay frame is not canonical base64url.`);let t=new Uint8Array(Math.floor(e.length*6/8)),n=0,r=0,i=0;for(let a of e){let e=mc.indexOf(a);n=n<<6|e,r+=6,r>=8&&(r-=8,t[i]=n>>>r&255,i+=1)}if(wc(t)!==e)throw new vc(`channel_authentication_failed`,`Encrypted relay frame has a non-canonical base64url encoding.`);return t}function dse(e){let t=new Uint8Array(e);t[31]=(t[31]??0)&127;let n=0n;for(let e=0;e<t.byteLength;e+=1)n|=BigInt(t[e]??0)<<BigInt(e*8);return ose.has(n%fc)}var fse={async sha256(e){if(globalThis.crypto?.subtle===void 0)throw new vc(`channel_authentication_failed`,`SHA-256 is unavailable in this runtime.`);return yc(await globalThis.crypto.subtle.digest(`SHA-256`,cse(e)))}},Ec={randomBytes(e){if(globalThis.crypto?.getRandomValues===void 0)throw new vc(`endpoint_key_invalid`,`A cryptographically secure random source is unavailable.`);return globalThis.crypto.getRandomValues(new Uint8Array(e))}};function Dc(e,t){let n=pc.encode(e).byteLength;if(n===0||n>256)throw new vc(`channel_ticket_binding_invalid`,`${t} must contain between 1 and 256 UTF-8 bytes.`)}function pse(e){let t=pc.encode(e).byteLength;if(t===0||t>65536)throw new vc(`channel_ticket_binding_invalid`,`Control ticket must contain between 1 and ${ise} UTF-8 bytes.`)}async function Oc(e,t=fse){pse(e.exactCompactTicket),Dc(e.channelId,`Channel ID`),Dc(e.runtimeId,`Runtime ID`),Sc(e.connectionEpoch);let n=await t.sha256(pc.encode(e.exactCompactTicket));if(n.byteLength!==32)throw new vc(`channel_ticket_binding_invalid`,`The control ticket digest must be 32 bytes.`);return{...e,ticketDigest:new Uint8Array(n)}}function mse(e){return wc(e.ticketDigest)}async function hse(e=Ec){let t=new Uint8Array(await e.randomBytes(dc));if(t.byteLength!==dc)throw new vc(`endpoint_key_invalid`,`The endpoint random source must return ${dc} bytes.`);try{return wc(t)}finally{t.fill(0)}}function kc(e){return bc([pc.encode(`forge-relay-v4`),Uint8Array.of(0),e.ticketDigest,Cc(e.direction)])}function Ac(e){return bc([pc.encode(`forge-relay`),xc(4),e.binding.ticketDigest,pc.encode(e.binding.channelId),Cc(e.binding.direction),use(e.frameClass),Sc(e.sequence),pc.encode(e.binding.runtimeId),Sc(e.binding.connectionEpoch),xc(e.ciphertextLength)].map(lse))}async function gse(e=Ec){let t=new Uint8Array(await e.randomBytes(dc));if(t.byteLength!==dc)throw new vc(`endpoint_key_invalid`,`The endpoint random source must return ${dc} bytes.`);try{return await _c.kem.deriveKeyPair(t)}catch(e){throw new vc(`endpoint_key_invalid`,e instanceof Error?e.message:`Endpoint key generation failed.`)}finally{t.fill(0)}}async function jc(e){try{return wc(yc(await _c.kem.serializePublicKey(e)))}catch(e){throw new vc(`endpoint_key_invalid`,e instanceof Error?e.message:`Endpoint public-key serialization failed.`)}}function _se(e,t){if(!/^[A-Za-z0-9_-]{43}$/u.test(t))throw new vc(`endpoint_key_invalid`,`The endpoint key ID requires a canonical X25519 public key.`);return`${e}:${t}`}async function vse(e){try{let t=Tc(e);if(t.byteLength!==dc)throw Error(`Invalid endpoint key length.`);if(dse(t))throw new vc(`endpoint_key_invalid`,`Low-order X25519 endpoint public keys are not allowed.`);return await _c.kem.deserializePublicKey(t)}catch(e){throw e instanceof vc?e:new vc(`endpoint_key_invalid`,e instanceof Error?e.message:`Endpoint public-key deserialization failed.`)}}var Mc=class{tail=Promise.resolve();run(e){let t=this.tail.then(e,e);return this.tail=t.then(()=>void 0,()=>void 0),t}},Nc=class{startedAt=Date.now();records=0;bytes=0;assertAvailable(e){if(this.records>=rse||this.bytes+e>1073741824||Date.now()-this.startedAt>=18e5)throw new vc(`channel_limit_reached`,`The encrypted relay channel must be renewed before another record is sent.`)}commit(e){this.records+=1,this.bytes+=e}};function yse(e,t){if(e.type!==`relay.encrypted-frame`||e.protocolVersion!==4||e.channelId!==t.channelId||e.direction!==t.direction||![`handshake`,`application`,`close`].includes(e.frameClass))throw new vc(`channel_ticket_binding_invalid`,`Encrypted relay frame does not match the CMMD-ticket-bound channel.`)}var bse=class{binding;context;encapsulatedKey;queue=new Mc;budget=new Nc;sequence=0;constructor(e,t){this.binding=e,this.context=t,this.encapsulatedKey=wc(yc(t.enc))}seal(e){return this.queue.run(async()=>{if(e.plaintext.byteLength>16777216)throw new vc(`channel_limit_reached`,`Encrypted relay plaintext exceeds the per-record byte limit.`);let t=e.plaintext.byteLength+ase;this.budget.assertAvailable(t);let n=this.sequence,r=Ac({binding:this.binding,frameClass:e.frameClass,sequence:n,ciphertextLength:t}),i;try{i=yc(await this.context.seal(e.plaintext,r))}catch(e){throw new vc(`channel_authentication_failed`,e instanceof Error?e.message:`Relay payload encryption failed.`)}if(i.byteLength!==t)throw new vc(`channel_authentication_failed`,`Relay payload encryption returned an invalid ciphertext length.`);return this.sequence+=1,this.budget.commit(i.byteLength),{type:`relay.encrypted-frame`,protocolVersion:4,channelId:this.binding.channelId,direction:this.binding.direction,frameClass:e.frameClass,sequence:n,ciphertext:wc(i)}})}},xse=class{binding;context;queue=new Mc;budget=new Nc;sequence=0;constructor(e,t){this.binding=e,this.context=t}open(e){return this.queue.run(async()=>{if(yse(e,this.binding),!Number.isSafeInteger(e.sequence)||e.sequence!==this.sequence)throw new vc(`channel_sequence_invalid`,`Expected encrypted relay sequence ${this.sequence}, received ${String(e.sequence)}.`);let t=Tc(e.ciphertext);this.budget.assertAvailable(t.byteLength);let n=Ac({binding:this.binding,frameClass:e.frameClass,sequence:e.sequence,ciphertextLength:t.byteLength}),r;try{r=yc(await this.context.open(t,n))}catch(e){throw new vc(`channel_authentication_failed`,e instanceof Error?e.message:`Relay payload authentication failed.`)}if(r.byteLength>16777216)throw new vc(`channel_limit_reached`,`Decrypted relay plaintext exceeds the per-record byte limit.`);return this.sequence+=1,this.budget.commit(t.byteLength),r})}};async function Sse(e){let t=null;try{if(t=new Uint8Array(await(e.randomSource??Ec).randomBytes(dc)),t.byteLength!==dc)throw Error(`The endpoint random source must return ${dc} bytes.`);let n=await _c.createSenderContext({recipientPublicKey:e.recipientPublicKey,senderKey:e.senderKey,info:kc(e.binding),ekm:t});return new bse(e.binding,n)}catch(e){throw new vc(`channel_authentication_failed`,e instanceof Error?e.message:`Relay payload sender setup failed.`)}finally{t?.fill(0)}}async function Cse(e){try{let t=await _c.createRecipientContext({recipientKey:e.recipientKey,senderPublicKey:e.senderPublicKey,enc:Tc(e.encapsulatedKey),info:kc(e.binding)});return new xse(e.binding,t)}catch(e){throw e instanceof vc?e:new vc(`channel_authentication_failed`,e instanceof Error?e.message:`Relay payload recipient setup failed.`)}}var wse=128,Tse=2097152,Ese=864e5,Pc=class extends Error{constructor(e){super(e),this.name=`RelayControlJournalError`}};function Fc(e){return typeof e==`string`&&e.length>0}function Ic(e){return Fc(e)&&Number.isFinite(Date.parse(e))}function Dse(e){return e===`pending`||e===`retrying`||e===`outcome-unknown`||e===`failed`}function Ose(e){return Fc(e.transportRequestId)&&Fc(e.runtimeId)&&Fc(e.actorSessionId)&&Fc(e.durableRequestId)&&Fc(e.method)}function kse(e){return Number.isSafeInteger(e.sequence)&&Number(e.sequence)>0&&Number.isSafeInteger(e.attemptCount)&&Number(e.attemptCount)>=0}function Ase(e){return e.persistence!==`frame`&&e.persistence!==`metadata-only`||e.frame!==null&&!Fc(e.frame)?!1:e.persistence!==`metadata-only`||e.frame===null}function jse(e){return!Dse(e.status)||e.errorCode!==null&&!Fc(e.errorCode)?!1:e.status===`outcome-unknown`||e.status===`failed`?e.frame===null&&Fc(e.errorCode):e.errorCode===null}function Mse(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return Ose(t)&&kse(t)&&Ase(t)&&jse(t)&&Ic(t.createdAt)&&Ic(t.updatedAt)}function Nse(e){try{return JSON.parse(e)}catch{throw new Pc(`Forge relay control journal is corrupt.`)}}function Pse(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return t.version===1&&Fc(t.controlSessionId)&&Number.isSafeInteger(t.nextSequence)&&Number(t.nextSequence)>=1&&Array.isArray(t.records)&&t.records.every(Mse)}function Fse(e){let t=new Set(e.map(Lc)),n=new Set(e.map(e=>e.durableRequestId)),r=new Set(e.map(e=>e.sequence));return t.size===e.length&&n.size===e.length&&r.size===e.length}function Ise(e){let t=Nse(e);if(!Pse(t))throw new Pc(`Forge relay control journal is corrupt.`);let n=t.records,r=n.reduce((e,t)=>Math.max(e,t.sequence),0);if(!Fse(n)||t.nextSequence<=r)throw new Pc(`Forge relay control journal is corrupt.`);return{version:1,controlSessionId:t.controlSessionId,nextSequence:t.nextSequence,records:n}}function Lse(){return crypto.randomUUID()}function Lc(e){return`${e.runtimeId}\0${e.actorSessionId}\0${e.transportRequestId}`}var Rc={pending:1,retrying:2,"outcome-unknown":3,failed:4};function Rse(e,t){let n=e.filter(e=>e.runtimeId===t);if(n.length===0)return{state:`idle`,count:0};let r=n.reduce((e,t)=>Rc[t.status]>Rc[e]?t.status:e,`pending`);return{state:r,count:n.filter(e=>e.status===r).length}}function zc(e){let t=e.randomUUID??Lse,n=e.now??(()=>new Date),r=e.maxRecords??wse,i=e.maxBytes??Tse,a=e.maxReplayAgeMs??Ese;if(r<1||i<1||a<1)throw new Pc(`Forge relay control journal limits must be positive.`);let o=e.storage.read(),s=n(),c=o?Ise(o):{version:1,controlSessionId:t(),nextSequence:1,records:[]},l=new Map,u=new Set;function d(){return{controlSessionId:c.controlSessionId,records:[...c.records]}}function f(t){if(t.records.length>r)throw new Pc(`Forge relay control journal reached its record limit.`);let n=JSON.stringify(t);if(new TextEncoder().encode(n).byteLength>i)throw new Pc(`Forge relay control journal reached its storage limit.`);e.storage.write(n),c=t;let a=d();for(let e of u)e(a)}function p(e,t){return e.status!==`pending`&&e.status!==`retrying`?e:e.persistence===`metadata-only`||e.frame===null?{...e,frame:null,status:`outcome-unknown`,errorCode:`RELAY_COMMAND_OUTCOME_UNKNOWN`,updatedAt:t.toISOString()}:t.getTime()-Date.parse(e.createdAt)>a?{...e,frame:null,status:`outcome-unknown`,errorCode:`RELAY_RECOVERY_EXPIRED`,updatedAt:t.toISOString()}:e}let m=c.records.map(e=>p(e,s)),h=m.some((e,t)=>e!==c.records[t]);(o===null||h)&&f({...c,records:m});function g(e){let t=Lc(e);return{key:t,existing:c.records.find(e=>Lc(e)===t)??null}}function _(e,t,n){if([e.method===t.method,e.persistence===t.persistence,n===void 0||n===t.frame,e.frame===null||e.frame===t.frame,t.durableRequestId===void 0||e.durableRequestId===t.durableRequestId].includes(!1))throw new Pc(`Relay transport request ${t.transportRequestId} was reused with different content.`);if(e.status===`failed`||e.status===`outcome-unknown`)throw new Pc(`Relay transport request ${t.transportRequestId} requires an explicit outcome acknowledgement.`)}function v(e){if(e.durableRequestId!==void 0&&c.records.some(t=>t.durableRequestId===e.durableRequestId))throw new Pc(`Relay durable request ${e.durableRequestId} was reused by another transport request.`)}function y(e){let r=n().toISOString();return{runtimeId:e.runtimeId,actorSessionId:e.actorSessionId,transportRequestId:e.transportRequestId,durableRequestId:e.durableRequestId??t(),sequence:c.nextSequence,method:e.method,persistence:e.persistence,frame:e.persistence===`frame`?e.frame:null,status:`pending`,attemptCount:0,errorCode:null,createdAt:r,updatedAt:r}}function b(e){let{key:t,existing:n}=g(e);if(n!==null)return _(n,e,l.get(t)),l.set(t,e.frame),n;v(e);let r=y(e);return l.set(t,e.frame),f({...c,nextSequence:c.nextSequence+1,records:[...c.records,r]}),r}function x(e,t,n){let r=c.records.find(r=>r.runtimeId===e&&r.actorSessionId===t&&r.transportRequestId===n);if(!r)throw new Pc(`Relay transport request ${n} is not journaled.`);return r}function S(e,t,r,i){x(e,t,r);let a=n().toISOString();l.delete(Lc({runtimeId:e,actorSessionId:t,transportRequestId:r})),f({...c,records:c.records.map(n=>n.runtimeId===e&&n.actorSessionId===t&&n.transportRequestId===r?{...n,frame:null,status:`failed`,errorCode:i,updatedAt:a}:n)})}function C(e,t,r){let i=x(e,t,r);if(i.status===`failed`||i.status===`outcome-unknown`)throw new Pc(`Relay transport request ${r} has no replayable outcome.`);let a={...i,status:i.attemptCount>0?`retrying`:`pending`,attemptCount:i.attemptCount+1,errorCode:null,updatedAt:n().toISOString()};return f({...c,records:c.records.map(n=>n.runtimeId===e&&n.actorSessionId===t&&n.transportRequestId===r?a:n)}),a}function w(e,t,n){let r=c.records.filter(r=>r.runtimeId!==e||r.actorSessionId!==t||r.transportRequestId!==n);r.length!==c.records.length&&(l.delete(Lc({runtimeId:e,actorSessionId:t,transportRequestId:n})),f({...c,records:r}))}function T(e,t,n){let r=x(e,t,n);if(r.status!==`failed`&&r.status!==`outcome-unknown`)throw new Pc(`Relay transport request ${n} does not have an acknowledgeable outcome.`);w(e,t,n)}function E(){let e=n(),t=c.records.map(t=>p(t,e));t.some((e,t)=>e!==c.records[t])&&f({...c,records:t})}function D(e,t){let r=n().toISOString(),i=c.records.map(n=>n.runtimeId!==e||n.actorSessionId===t||n.status!==`pending`&&n.status!==`retrying`?n:(l.delete(Lc(n)),{...n,frame:null,status:`outcome-unknown`,errorCode:`RELAY_ACTOR_SESSION_CHANGED`,updatedAt:r}));i.some((e,t)=>e!==c.records[t])&&f({...c,records:i})}return{controlSessionId:c.controlSessionId,prepare:b,records:()=>[...c.records],pending:()=>[...c.records],replayable:(e,t)=>(E(),c.records.filter(n=>n.runtimeId===e&&n.actorSessionId===t&&n.persistence===`frame`&&n.frame!==null&&(n.status===`pending`||n.status===`retrying`))),fenceActor:D,beginAttempt:C,markFailed:S,complete:w,acknowledge:T,subscribe:e=>(u.add(e),e(d()),()=>u.delete(e))}}function zse(e=null){let t=e;return{read:()=>t,write:e=>{t=e}}}var Bse=$t(ane),Vse=Qn(rne),Hse=Qn(bne),Use=[`rpc.read`,`rpc.mutate`,`cursor.resume`,`terminal.stream`,`browser.stream`,`bulk.transfer`,`envelope.validation`,`payload.e2e`];function Bc(e,t){if(!Array.isArray(e))return null;for(let n of e)if(Array.isArray(n)&&n.length===2&&n[0]===t&&typeof n[1]==`string`)return n[1];return null}function Vc(e,t){let n=JSON.parse(e),r=lae(n);if(r!==null)return{messageType:`request`,...r};let i=Wse(n,t);if(i!==null)return i;let a=Gse(n);if(a!==null)return a;throw Error(`Forge relay protocol v2 requires a recognized Effect RPC frame.`)}function Wse(e,t){if(e._tag!==`Request`||typeof e.id!=`string`||e.id.length===0||typeof e.tag!=`string`||e.tag.length===0)return null;let n=Jo({method:e.tag,payload:e.payload,grantedScopes:t});return{messageType:`request`,requestId:e.id,correlationId:Bc(e.headers,On.requestId)??e.id,method:e.tag,...n}}function Gse(e){return e._tag!==`Ack`&&e._tag!==`Interrupt`||typeof e.requestId!=`string`||e.requestId.length===0?null:{messageType:`acknowledgement`,requestId:e.requestId,correlationId:e.requestId,method:`@effect/rpc/${e._tag}`,requiredScope:null,deliveryClass:`read`,journalPersistence:`none`}}function Hc(e,t){let n=new Event(`error`);return Object.defineProperties(n,{error:{value:Error(t),enumerable:!0},message:{value:`${e}: ${t}`,enumerable:!0}}),n}var Kse=new Set([`network`,`server`,`auth`,`permission`,`client`]),qse=new Set([`network`,`server`]);function Jse(e){return e&&typeof e==`object`?e:{}}function Yse(e){return typeof e.code==`string`&&e.code.length>0?e.code:typeof e.kind==`string`&&Kse.has(e.kind)?`RELAY_ACTION_GRANT_UNAVAILABLE`:`MALFORMED_FRAME`}function Xse(e){if(e.retryable===!0||typeof e.kind==`string`&&qse.has(e.kind))return!0;let t=typeof e.status==`number`?e.status:null;return t===429||t!==null&&t>=500}function Uc(e){let t=Jse(e);return{code:Yse(t),message:e instanceof Error?e.message:`Forge relay frame encoding failed.`,retryable:Xse(t)}}function Wc(e,t){let n=new Event(e.type),r=e;for(let e of t)r[e]!==void 0&&Object.defineProperty(n,e,{value:r[e],enumerable:!0});return n}function Zse(e){return!Array.isArray(e)||e.length!==2||typeof e[0]!=`string`?!1:Object.values(On).includes(e[0])}function Gc(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Qse(e){if(!Array.isArray(e))return null;for(let t of e){let e=Gc(t);if(e?._tag!==`Fail`)continue;let n=Gc(e.error)?.code;if(typeof n==`string`&&n.length>0)return n}return null}function $se(e){let t=Gc(e.exit);return t===null?`RELAY_RPC_RESPONSE_INVALID`:t._tag===`Success`?null:t._tag!==`Failure`||!Array.isArray(t.cause)?`RELAY_RPC_RESPONSE_INVALID`:Qse(t.cause)??`RELAY_RPC_FAILED`}function Kc(e){if(typeof e!=`string`)return null;try{let t=Bse(JSON.parse(e));return t._tag===`Some`?t.value:null}catch{return null}}function ece(e,t){if(e.role===`control`&&e.protocolVersion===t&&e.protocolVersion>=1){if(e.protocolVersion===1)return null;if(e.actor!==void 0&&e.scopes!==void 0)return{runtimeId:e.runtimeId,connectionEpoch:e.connectionEpoch,protocolVersion:e.protocolVersion,actor:e.actor,scopes:e.scopes}}}function qc(e,t,n){if(typeof e==`string`)try{let r=Gc(JSON.parse(e));if(r?._tag!==`Exit`||typeof r.requestId!=`string`)return;let i=$se(r);if(i===null){n.complete(t.runtimeId,t.actor.sessionId,r.requestId);return}n.markFailed(t.runtimeId,t.actor.sessionId,r.requestId,i)}catch{}}function tce(e){let t=Bc(e,On.sequence);if(t===null)return;let n=Number(t);return Number.isSafeInteger(n)&&n>=0?n:void 0}function Jc(e){return{issuedAt:Bc(e,On.issuedAt)??new Date().toISOString(),expiresAt:Bc(e,On.expiresAt)??new Date(Date.now()+12e4).toISOString()}}function Yc(e){if(e!==2&&e!==3&&e!==4)throw new Go(`protocol_version_mismatch`,`Unsupported Forge relay envelope version: ${e}`,!1);return e}async function Xc(e){let t=_ae({method:e.identity.method,payload:e.payload});if(t===null)return;let n=Zc(e.context);if(e.acquire===void 0)throw new Go(`action_grant_required`,`CMMD action-grant issuance is unavailable for this remote response.`,!1);return e.acquire({...n,method:`orchestration.dispatchCommand`,...t,durableRequestId:e.identity.correlationId,payloadHash:e.payloadHash,requiredScope:`approval.respond`})}function Zc(e){if(e.protocolVersion===3)return{protocolVersion:3};if(e.protocolVersion!==4)throw new Go(`protocol_update_required`,`Update Forge on the target runtime before responding remotely.`,!1);return{protocolVersion:4,channelId:Qc(e.channelId),channelTicketDigest:Qc(e.channelTicketDigest),runtimeEndpointKeyId:Qc(e.runtimeEndpointKeyId),controlEndpointKeyId:Qc(e.controlEndpointKeyId)}}function Qc(e){if(typeof e==`string`&&e.length>0)return e;throw new Go(`channel_ticket_binding_invalid`,`The encrypted Forge relay channel is missing its CMMD ticket binding.`,!1)}function $c(e){return e===void 0?{}:{sequence:e}}function el(e){return e===void 0?{}:{actionGrant:e}}async function tl(e){let t=Vc(e.data,e.context.scopes),n=JSON.parse(e.data),r=Jc(n.headers),i=tce(n.headers),a=await e.crypto.sha256Base64Url(e.data),o=await Xc({context:e.context,identity:t,payload:n.payload,payloadHash:a,...e.acquireActionGrant===void 0?{}:{acquire:e.acquireActionGrant}}),s=Yc(e.context.protocolVersion),c={messageType:t.messageType,requestId:t.requestId,correlationId:t.correlationId,method:t.method,requiredScope:t.requiredScope,deliveryClass:t.deliveryClass,runtimeId:e.context.runtimeId,connectionEpoch:e.context.connectionEpoch,actor:e.context.actor,...r,payloadHash:a,...$c(i)};return s===2?{protocolVersion:2,...c}:s===3?{protocolVersion:3,...c,...el(o)}:{protocolVersion:4,...c,...el(o)}}function nl(e){return typeof e==`string`&&e.length>0}function rl(e){return[e.protocolVersion===4,nl(e.runtimeId),Number.isSafeInteger(e.connectionEpoch),Number(e.connectionEpoch)>0,e.hpkeSuite===uc,nl(e.channelId),nl(e.runtimeEndpointKeyId),nl(e.runtimeEndpointPublicKey),nl(e.controlEndpointKeyId),nl(e.controlEndpointPublicKey),nl(e.controlChannelNonce),e.controlEndpointKeyPair!==void 0].every(Boolean)}function il(e){if(!rl(e))throw new Go(`end_to_end_encryption_required`,`Forge relay protocol v4 requires complete endpoint encryption metadata.`,!1);return e}async function al(e){if(await jc(e.controlEndpointKeyPair.publicKey)!==e.controlEndpointPublicKey)throw new Go(`endpoint_key_invalid`,`The control endpoint private key does not match the CMMD route.`,!1);let t=await vse(e.runtimeEndpointPublicKey),[n,r]=await Promise.all([Oc({exactCompactTicket:e.token,channelId:e.channelId,direction:`control-to-runtime`,runtimeId:e.runtimeId,connectionEpoch:e.connectionEpoch},e.payloadDigestProvider),Oc({exactCompactTicket:e.token,channelId:e.channelId,direction:`runtime-to-control`,runtimeId:e.runtimeId,connectionEpoch:e.connectionEpoch},e.payloadDigestProvider)]);return{controlToRuntimeBinding:n,runtimeToControlBinding:r,sender:await Sse({binding:n,senderKey:e.controlEndpointKeyPair,recipientPublicKey:t,...e.payloadRandomSource?{randomSource:e.payloadRandomSource}:{}}),runtimePublicKey:t,recipient:null,phase:`awaiting-runtime-hello`}}function ol(e,t,n){return[e.direction===`runtime-to-control`,e.frameClass===n,e.channelId===t.channelId].every(Boolean)}function sl(e){return[e.confirmation.phase===e.expectedPhase,e.confirmation.channelId===e.route.channelId,e.confirmation.runtimeId===e.context.runtimeId,e.confirmation.connectionEpoch===e.context.connectionEpoch].every(Boolean)}function cl(e){let{envelope:t}=e.application;return[t.runtimeId===e.context.runtimeId,t.connectionEpoch===e.context.connectionEpoch,t.actor.userId===e.context.actor.userId,t.actor.deviceId===e.context.actor.deviceId,t.actor.sessionId===e.context.actor.sessionId,t.payloadHash===e.payloadHash].every(Boolean)}async function ll(e){if(e.channel.recipient!==null){if(e.message.encapsulatedKey!==void 0)throw new Go(`endpoint_key_invalid`,`The runtime attempted to replace its endpoint encapsulation.`,!1);return e.channel.recipient}if(e.message.sequence!==0||!e.message.encapsulatedKey)throw new Go(`channel_confirmation_failed`,`The runtime handshake omitted its endpoint encapsulation.`,!1);let t=await Cse({binding:e.channel.runtimeToControlBinding,recipientKey:e.route.controlEndpointKeyPair,senderPublicKey:e.channel.runtimePublicKey,encapsulatedKey:e.message.encapsulatedKey});return e.channel.recipient=t,t}var ul=class extends EventTarget{socket;route;relayCrypto;journal;lifecycle;acquireActionGrant;CONNECTING=WebSocket.CONNECTING;OPEN=WebSocket.OPEN;CLOSING=WebSocket.CLOSING;CLOSED=WebSocket.CLOSED;binaryType=`blob`;onopen=null;onclose=null;onerror=null;onmessage=null;authenticated=!1;context=null;payloadChannel=null;sendChain=Promise.resolve();constructor(e,t,n,r,i={},a){super(),this.socket=e,this.route=t,this.relayCrypto=n,this.journal=r,this.lifecycle=i,this.acquireActionGrant=a,e.addEventListener(`open`,()=>void this.beginAuthentication()),e.addEventListener(`message`,e=>void this.handleMessageSafely(e)),e.addEventListener(`error`,e=>{let t=Wc(e,[`error`,`message`]),n=typeof t.message==`string`?String(t.message):`Forge relay connection failed.`;this.lifecycle.onError?.({code:`RELAY_SOCKET_ERROR`,message:n}),this.emit(`error`,t)}),e.addEventListener(`close`,e=>{this.authenticated=!1,this.context=null,this.payloadChannel=null,this.lifecycle.onDisconnected?.({code:e.code,reason:e.reason}),this.emit(`close`,Wc(e,[`code`,`reason`,`wasClean`]))})}get bufferedAmount(){return this.socket.bufferedAmount}get extensions(){return this.socket.extensions}get protocol(){return this.socket.protocol}get readyState(){return this.authenticated?this.socket.readyState:WebSocket.CONNECTING}get url(){return this.route.relayWebSocketUrl}send(e){if(!this.authenticated||typeof e!=`string`)throw new DOMException(`Forge relay RPC socket is not open for text frames.`,`InvalidStateError`);if(this.route.protocolVersion===1){this.socket.send(JSON.stringify({type:`relay.frame`,payload:e}));return}let t=this.context;if(t===null)throw new DOMException(`Forge relay v2 context is unavailable.`,`InvalidStateError`);let n=Vc(e,t.scopes),r=n.messageType===`request`&&n.journalPersistence!==`none`?this.journal.prepare({runtimeId:t.runtimeId,actorSessionId:t.actor.sessionId,transportRequestId:n.requestId,...n.correlationId===n.requestId?{}:{durableRequestId:n.correlationId},method:n.method,frame:e,persistence:n.journalPersistence}):null;this.enqueueFrame(e,r)}enqueueFrame(e,t){this.sendChain=this.sendChain.then(()=>this.transmitFrame(e,t)).catch(e=>{let n=Uc(e);t!==null&&!n.retryable&&this.journal.markFailed(t.runtimeId,t.actorSessionId,t.transportRequestId,n.code),this.lifecycle.onError?.({code:n.code,message:n.message}),this.emit(`error`,Hc(n.code,n.message)),this.socket.readyState<WebSocket.CLOSING&&this.socket.close(4400,`${n.code}: ${n.message}`)})}async transmitFrame(e,t){let n=this.requireReadyContext(),r=await this.outboundFrame(e,t),i=await tl({data:r,context:n,crypto:this.relayCrypto,...this.acquireActionGrant?{acquireActionGrant:this.acquireActionGrant}:{}});if(n.protocolVersion===4){let e=await this.requirePayloadChannel().sender.seal({frameClass:`application`,plaintext:new TextEncoder().encode(JSON.stringify({payload:r,envelope:i}))});this.socket.send(JSON.stringify(e));return}this.socket.send(JSON.stringify({type:`relay.frame`,payload:r,envelope:i}))}requireReadyContext(){if(!this.authenticated||this.socket.readyState!==WebSocket.OPEN)throw new DOMException(`Forge relay RPC socket closed before send.`,`InvalidStateError`);if(this.context===null)throw new DOMException(`Forge relay v2 context is unavailable.`,`InvalidStateError`);return this.context}requirePayloadChannel(){let e=this.payloadChannel;if(e===null||e.phase!==`ready`)throw new Go(`channel_confirmation_failed`,`The Forge relay endpoint channel is not confirmed.`,!1);return e}async outboundFrame(e,t){return t===null?e:this.withDurableHeaders(t,e)}async withDurableHeaders(e,t){let n=this.journal.beginAttempt(e.runtimeId,e.actorSessionId,e.transportRequestId),r=JSON.parse(t),i=await ace({payload:r.payload,sequence:n.sequence,requestId:n.durableRequestId,issuedAt:new Date(n.updatedAt),crypto:this.relayCrypto}),a=Array.isArray(r.headers)?r.headers.filter(e=>!Zse(e)):[];return JSON.stringify({...r,headers:[...a,...Object.entries(i)]})}close(e,t){this.socket.close(e,t)}asWebSocket(){return this}emit(e,t){this.dispatchEvent(t);let n=this[`on${e}`];n&&n.call(this.asWebSocket(),t)}async handleMessage(e){if(this.authenticated){if(this.context?.protocolVersion===4){await this.handleEncryptedApplicationMessage(e.data);return}this.context!==null&&qc(e.data,this.context,this.journal),this.emit(`message`,new MessageEvent(`message`,{data:e.data}));return}await this.handleAuthenticationMessage(e.data)}async handleMessageSafely(e){try{await this.handleMessage(e)}catch(e){let t=Uc(e);this.lifecycle.onError?.({code:t.code,message:t.message}),this.emit(`error`,Hc(t.code,t.message)),this.socket.readyState<WebSocket.CLOSING&&this.socket.close(4400,`${t.code}: ${t.message}`)}}async beginAuthentication(){try{this.route.protocolVersion===4&&(this.payloadChannel=await al(il(this.route))),this.socket.send(JSON.stringify({type:`relay.auth`,ticket:this.route.token,protocolMinVersion:this.route.protocolVersion,protocolMaxVersion:this.route.protocolVersion,capabilities:Use,...this.payloadChannel?{controlToRuntimeEncapsulatedKey:this.payloadChannel.sender.encapsulatedKey}:{}}))}catch(e){let t=Uc(e);this.lifecycle.onError?.({code:t.code,message:t.message}),this.emit(`error`,Hc(t.code,t.message)),this.socket.close(4400,t.message)}}async handleAuthenticationMessage(e){let t=Kc(e);if(t!==null){if(t.type===`relay.encrypted-frame`&&this.context?.protocolVersion===4){await this.handleEncryptedHandshakeMessage(t);return}if(t.type===`relay.error`){this.lifecycle.onError?.({code:t.code,message:t.message}),this.emit(`error`,Hc(t.code,t.message)),this.socket.close(4403,t.message);return}t.type===`relay.authenticated`&&await this.handleAuthenticatedMessage(t)}}async handleAuthenticatedMessage(e){let t=ece(e,this.route.protocolVersion);if(t===void 0){this.socket.close(4400,`Forge relay authenticated the wrong role.`);return}if(t!==null&&t.protocolVersion===4){let n=il(this.route),r=this.payloadChannel;if(r===null||![e.runtimeId===n.runtimeId,e.connectionEpoch===n.connectionEpoch].every(Boolean)){this.socket.close(4400,`Forge relay authenticated stale endpoint metadata.`);return}t={...t,channelId:n.channelId,channelTicketDigest:mse(r.controlToRuntimeBinding),runtimeEndpointKeyId:n.runtimeEndpointKeyId,controlEndpointKeyId:n.controlEndpointKeyId},this.context=t;return}await this.activateAuthenticatedRelay(t)}async handleEncryptedHandshakeMessage(e){if(e.type!==`relay.encrypted-frame`)return;let t=this.payloadChannel,n=this.context,r=il(this.route);if(t===null||n===null||!ol(e,r,`handshake`))throw new Go(`channel_confirmation_failed`,`The runtime sent an invalid encrypted handshake frame.`,!1);let i=await(await ll({channel:t,route:r,message:e})).open(e),a=Vse(JSON.parse(new TextDecoder().decode(i))),o=t.phase===`awaiting-runtime-hello`?`runtime-hello`:`runtime-confirm`;if(!sl({confirmation:a,expectedPhase:o,route:r,context:n}))throw new Go(`channel_confirmation_failed`,`The runtime endpoint confirmation does not match the CMMD route.`,!1);if(o===`runtime-hello`){let e=await t.sender.seal({frameClass:`handshake`,plaintext:new TextEncoder().encode(JSON.stringify({type:`relay.endpoint-confirmation`,protocolVersion:4,phase:`control-confirm`,channelId:r.channelId,runtimeId:n.runtimeId,connectionEpoch:n.connectionEpoch}))});t.phase=`awaiting-runtime-confirm`,this.socket.send(JSON.stringify(e));return}t.phase=`ready`,await this.activateAuthenticatedRelay(n)}async handleEncryptedApplicationMessage(e){let t=Kc(e);if(t?.type!==`relay.encrypted-frame`)throw new Go(`end_to_end_encryption_required`,`The runtime sent plaintext after the encrypted channel was confirmed.`,!1);let n=this.requirePayloadChannel();if(!ol(t,il(this.route),`application`)||t.encapsulatedKey!==void 0||n.recipient===null)throw new Go(`channel_authentication_failed`,`The runtime sent an invalid encrypted application frame.`,!1);let r=await n.recipient.open(t),i=Hse(JSON.parse(new TextDecoder().decode(r))),a=this.requireReadyContext();if(!cl({application:i,context:a,payloadHash:await this.relayCrypto.sha256Base64Url(i.payload)}))throw new Go(`channel_authentication_failed`,`The decrypted runtime envelope does not match the active route.`,!1);qc(i.payload,a,this.journal),this.emit(`message`,new MessageEvent(`message`,{data:i.payload}))}async activateAuthenticatedRelay(e){this.context=e,this.authenticated=!0,this.lifecycle.onAuthenticated?.();let t=e===null?[]:this.replayForActor(e);for(let e of t)e.frame!==null&&this.enqueueFrame(e.frame,e);t.length>0&&await this.sendChain,this.emit(`open`,new Event(`open`))}replayForActor(e){return this.journal.fenceActor(e.runtimeId,e.actor.sessionId),this.journal.replayable(e.runtimeId,e.actor.sessionId)}};function dl(e,t,n=ml,r=zc({storage:zse(),randomUUID:n.randomUUID}),i={},a){return new ul(e,t,n,r,i,a).asWebSocket()}var fl=ko(cne);async function pl(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest(`SHA-256`,t);return btoa(String.fromCharCode(...new Uint8Array(n))).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replaceAll(`=`,``)}var ml={randomUUID:()=>crypto.randomUUID(),sha256Base64Url:pl},hl=`forge-relay-binding=`,nce=3e4;function rce(e){let t=new URL(String(e)).hash.slice(1);if(!t.startsWith(hl))throw Error(`Forge relay socket URL is missing its route binding.`);let n=decodeURIComponent(t.slice(20));if(n.length===0)throw Error(`Forge relay socket URL has an invalid route binding.`);return n}function ice(e){let t=e.crypto??ml,n=e.bindingTtlMs??nce,r=e.createSocket??((e,t)=>new globalThis.WebSocket(e,t)),i=new Map;return{acquireSocketUrl:async()=>{let r=await e.acquireRoute(),a=t.randomUUID();if(i.has(a))throw Error(`Forge relay route binding identifier was reused.`);let o=new URL(r.relayWebSocketUrl);o.hash=`${hl}${encodeURIComponent(a)}`;let s=setTimeout(()=>i.delete(a),n);return i.set(a,{route:r,expires:s}),o.toString()},constructSocket:(n,a)=>{let o=rce(n),s=i.get(o);if(s===void 0)throw Error(`Forge relay route binding is missing, expired, or already consumed.`);return i.delete(o),clearTimeout(s.expires),e.lifecycle?.onConnecting?.(),dl(r(s.route.relayWebSocketUrl,a),s.route,t,e.journal,e.lifecycle,e.acquireActionGrant)}}}async function ace(e){let t=e.issuedAt??new Date,n=e.crypto??ml;return{[On.requestId]:e.requestId??n.randomUUID(),[On.sequence]:String(e.sequence),[On.issuedAt]:t.toISOString(),[On.expiresAt]:new Date(t.getTime()+12e4).toISOString(),[On.payloadHash]:await n.sha256Base64Url(sae(e.payload))}}function oce(e,t){return tne(fne,({rpc:t,request:n,next:r})=>tt(function*(){return Jo({method:t._tag,payload:n.payload,grantedScopes:e}),yield*r(n)}))}function sce(e,t=ml){return fl.pipe(be(oce(e,t)))}function cce(e){let t=e.crypto??ml,n=ice({acquireRoute:e.acquireRoute,...e.acquireActionGrant?{acquireActionGrant:e.acquireActionGrant}:{},crypto:t,journal:e.journal,...e.lifecycle?{lifecycle:e.lifecycle}:{}}),r=dt(n.acquireSocketUrl).pipe(l),i=pe(oa,n.constructSocket),a=sa(r).pipe(E(i)),o=e.delayForRetry??oae,s=Ft(y(e.maxRetries??10),e=>$e(Be(o(e)??0)));return ut(Mo,No({retryPolicy:s,retryTransientErrors:!0})).pipe(E(Te(a,Oo)))}var gl=class extends Error{name=`RelayControlRouteSecurityFailure`};async function lce(e){let t=await gse(e),n=await jc(t.publicKey);return{keyPair:t,publicKey:n,keyId:_se(`control`,n),channelNonce:await hse(e)}}function uce(e){return{hpkeSuite:uc,controlEndpointKeyId:e.keyId,controlEndpointPublicKey:e.publicKey,controlChannelNonce:e.channelNonce}}function dce(e){let t=e.route;if(t.protocolVersion!==4||t.hpkeSuite!==`DHKEM_X25519_HKDF_SHA256/HKDF_SHA256/CHACHA20_POLY1305/AUTH`||!t.channelId||!t.runtimeEndpointKeyId||!t.runtimeEndpointPublicKey||t.controlEndpointKeyId!==e.endpoint.keyId||t.controlEndpointPublicKey!==e.endpoint.publicKey||t.controlChannelNonce!==e.endpoint.channelNonce)throw new gl(`Forge could not establish a verified end-to-end encrypted runtime route.`);return{...t,runtimeId:e.runtimeId,protocolVersion:4,channelId:t.channelId,hpkeSuite:uc,runtimeEndpointKeyId:t.runtimeEndpointKeyId,runtimeEndpointPublicKey:t.runtimeEndpointPublicKey,controlEndpointKeyId:e.endpoint.keyId,controlEndpointPublicKey:e.endpoint.publicKey,controlChannelNonce:e.endpoint.channelNonce,controlEndpointKeyPair:e.endpoint.keyPair,...e.digestProvider?{payloadDigestProvider:e.digestProvider}:{},...e.randomSource?{payloadRandomSource:e.randomSource}:{}}}var _l=`~effect/ManagedRuntime`,vl=(e,t)=>{let n=t?.memoMap??eee(),r=mee(`parallel`),i=k(r,`sequential`),a={onFiberStart:fe(r)},o=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,c,l=Mt(t=>(c||=m(kee(s(e,n,i),e=>st(()=>{u.cachedContext=e})),{...a,scheduler:t.currentScheduler}),Bee(ge(c)))),u={[_l]:_l,memoMap:n,scope:r,contextEffect:l,cachedContext:void 0,context(){return u.cachedContext===void 0?ne(u.contextEffect):Promise.resolve(u.cachedContext)},dispose(){return ne(u.disposeEffect)},disposeEffect:Et(()=>(u.contextEffect=_ee(`ManagedRuntime disposed`),u.cachedContext=void 0,ze(u.scope,xt))),runFork(e,t){return u.cachedContext===void 0?m(yl(u,e),o(t)):Ve(u.cachedContext)(e,o(t))},runCallback(e,t){return u.cachedContext===void 0?see(yl(u,e),o(t)):gte(u.cachedContext)(e,o(t))},runSyncExit(e){return u.cachedContext===void 0?Zee(yl(u,e)):se(u.cachedContext)(e)},runSync(e){return u.cachedContext===void 0?de(yl(u,e)):bee(u.cachedContext)(e)},runPromiseExit(e,t){return u.cachedContext===void 0?dee(yl(u,e),o(t)):gee(u.cachedContext)(e,o(t))},runPromise(e,t){return u.cachedContext===void 0?ne(yl(u,e),o(t)):te(u.cachedContext)(e,o(t))}};return u};function yl(e,t){return yt(e.contextEffect,e=>Ce(t,e))}function bl(e,t=xne){return`${e}\0${t}`}function fce(e){let t=new Map,n=!1;return{register(e){if(n)throw Error(`Terminal control sequencer is disposed.`);let r=bl(e.threadId,e.terminalId);t.get(r)?.sessionEpoch!==e.sessionEpoch&&t.set(r,{sessionEpoch:e.sessionEpoch,nextControlSequence:1,tail:Promise.resolve(),pendingWriteBytes:0})},enqueue(r){if(n)return Promise.reject(Error(`Terminal control sequencer is disposed.`));let i=r.terminalId??`default`,a=t.get(bl(r.threadId,i));if(!a)return Promise.reject(Error(`Terminal must be opened before sending controls.`));let o=r.writeBytes??0;if(a.pendingWriteBytes+o>e.maxPendingWriteBytes)return Promise.reject(Error(`Terminal input queue is full while reconnecting.`));a.pendingWriteBytes+=o;let s=a.tail.then(async()=>{let t=a.nextControlSequence;await r.execute({sessionEpoch:a.sessionEpoch,controllerId:e.controllerId,controlSequence:t}),a.nextControlSequence=t+1});return a.tail=s.finally(()=>{a.pendingWriteBytes-=o}).catch(()=>void 0),s},remove(e,n){if(n){t.delete(bl(e,n));return}let r=`${e}\0`;for(let e of t.keys())e.startsWith(r)&&t.delete(e)},terminalIds(e){let n=`${e}\0`;return[...t.keys()].filter(e=>e.startsWith(n)).map(e=>e.slice(n.length))},dispose(){n=!0,t.clear()}}}var xl={accept:!1,observe:!1,missingFrameCount:0,startsNewStream:!1};function Sl(e){let t=e===!0;return{accept:t,observe:t,missingFrameCount:0,startsNewStream:t}}function pce(e,t){let n=e.streamGeneration===void 0&&e.streamId===void 0,r=t.streamGeneration!==void 0||t.streamId!==void 0;return n&&r?Sl(t.keyframe):null}function mce(e,t){return e.streamGeneration===void 0||t.streamGeneration===void 0?null:t.streamGeneration<e.streamGeneration?xl:t.streamGeneration>e.streamGeneration?Sl(t.keyframe):null}function hce(e,t){if(!e.streamId||!t.streamId)return null;if(e.streamId!==t.streamId)return Sl(t.keyframe);if(t.sequence<=e.observedSequence)return xl;let n=Math.max(0,t.sequence-e.observedSequence-1);return{accept:n===0||t.keyframe===!0,observe:!0,missingFrameCount:n,startsNewStream:!1}}function gce(e,t){if(t.sequence>e.acceptedSequence)return{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1};if(!e.acceptedCapturedAt)return xl;let n=Date.parse(e.acceptedCapturedAt),r=Date.parse(t.capturedAt);return Number.isNaN(n)||Number.isNaN(r)||r<=n?xl:{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1}}function _ce(e,t){return pce(e,t)??mce(e,t)??hce(e,t)??gce(e,t)}function vce(e,t){let n=_ce(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}}Qn(mne);var Cl=hte(),wl=`Forge`,yce=`Alpha`,Tl=wl,El=`0.10.3`;function bce(e){return{_tag:`Value`,value:e}}function xce(e,t){return{_tag:`Record`,keys:e,value:t}}function Sce(e,t){return{_tag:`Array`,length:e,value:t}}Gn(`SourceError`);var Cce=bt(`effect/ConfigProvider`,{defaultValue:()=>Ece()}),wce={...le,toJSON(){return{_id:`ConfigProvider`}}};function Tce(e,t,n){let r=Object.create(wce);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 Ece(e){let t=e?.env??{APP_VERSION:`0.10.3`,BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`,VITE_COMMIT_SHA:``,VITE_HTTP_URL:``,VITE_SENTRY_COMMIT_SHA:`986939d02dd54d5adfd34ed23f2d67fece201f9a`,VITE_SENTRY_DEBUG:``,VITE_SENTRY_DSN:``,VITE_SENTRY_ENABLED:``,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_PROFILES_SAMPLE_RATE:``,VITE_SENTRY_RELEASE:`forge-web@0.10.3+986939d02dd54d5adfd34ed23f2d67fece201f9a`,VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE:``,VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE:``,VITE_SENTRY_TRACES_SAMPLE_RATE:``,VITE_WS_URL:``},n=Dce(t);return Tce(e=>$e(kce(n,t,e)))}function Dce(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 Oce=/^(0|[1-9][0-9]*)$/;function kce(e,t,n){let r=t[n.map(String).join(`_`)],i=Ace(e,n),a=i?.children?Object.keys(i.children):[];return a.length===0?r===void 0?void 0:bce(r):a.every(e=>Oce.test(e))?Sce(Math.max(...a.map(e=>parseInt(e,10)))+1,r):xce(new Set(a),r)}function Ace(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 Dl=`~effect/Config`,jce=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},Mce={...le,...ae,[Dl]:Dl,asEffect(){return yt(Cce.asEffect(),e=>this.parse(e))},toJSON(){return{_id:`Config`}}};function Nce(e){let t=Object.create(Mce);return t.parse=e,t}var Ol=Je(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*Ol(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*Ol(e,[...t,i]));return r}}}),kl=Je(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*kl(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=zte(a.parameter);for(let o of i.keys)if(!Object.hasOwn(r,o)&&e(o)){let e=yield*kl(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*kl(e.elements[r],t,[...n,r]));return i}case`Union`:return yield*Ol(t,n);case`Suspend`:return yield*kl(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 Al(e,t){let n=Ute(e),r=qte(n),i=Ate(n.ast),a=typeof t==`string`?[t]:t??[];return Nce(e=>{let t=e.prefix?[...e.prefix,...a]:a;return kl(i,e,a).pipe(tte(e=>r(e).pipe(Pt(e=>new Fte(t.length>0?new Zte(t,e):e)))),Pt(e=>new jce(e)))})}var Pce=(e,t,n)=>{let r=Mn(e,t),i=Un.pipe($n(Mn(Un,Un),Xte(n)),$n(r));return Tn([r,i])},Fce=yte(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),jl=!1,Ml=!1,Nl=null,Pl=null,Fl=null,Il=!1,Ll=new Set;function Ice(e){if(jl||Ml)return;if(!e.publicKey||!e.host){Ml=!0;return}if(Nl)return;if(typeof window>`u`||typeof location>`u`){Ml=!0;return}let t=e.publicKey,n=e.host;Nl=N(async()=>{let{default:e}=await import(`./module-CPO4cjSm.js`);return{default:e}},[]).then(({default:e})=>{Pl=e,e.init(t,{api_host:n,person_profiles:`identified_only`,capture_pageview:!1,capture_pageleave:!1,autocapture:!1,disable_session_recording:!0,loaded:()=>{jl=!0,Fl&&Rl(Fl),zl(),Ll.forEach(e=>e())}})}).catch(()=>{Ml=!0,Pl=null})}function Rl(e){if(Fl=e,!jl||!Pl)return;let t={};e.email!==void 0&&(t.email=e.email),e.displayName!==void 0&&(t.name=e.displayName),Pl.identify(e.cmmdUserId,t)}function Lce(e){return!jl||!Pl?!1:Pl.isFeatureEnabled(e)===!0}function zl(){!Pl||Il||(Il=!0,Pl.onFeatureFlags(()=>{Ll.forEach(e=>e())}))}function Rce(e){return Ll.add(e),jl&&Pl&&(zl(),e()),()=>{Ll.delete(e)}}var Bl=`token`;function Vl(e){return new URLSearchParams(e.hash.startsWith(`#`)?e.hash.slice(1):e.hash)}function Hl(e){let t=Vl(e).get(Bl)?.trim()??``;if(t.length>0)return t;let n=e.searchParams.get(Bl)?.trim()??``;return n.length>0?n:null}function zce(e){let t=new URL(e.toString()),n=Vl(t);return n.has(Bl)&&(n.delete(Bl),t.hash=n.toString()),t.searchParams.delete(Bl),t}function Ul(e,t){let n=new URL(e.toString());return n.searchParams.delete(Bl),n.hash=new URLSearchParams([[Bl,t]]).toString(),n}function Bce(e,t){let n=new URL(e);return n.pathname=`/login`,Ul(n,t).toString()}function Vce(e){return Ul(new URL(`/login`,window.location.href),e).toString()}function Hce(e){let t=new URL(e),n=Hl(t),r=new URL(`forge:///pair`);return r.searchParams.set(`serverUrl`,t.origin),n&&r.searchParams.set(Bl,n),r.toString()}var B=typeof __SENTRY_DEBUG__>`u`||__SENTRY_DEBUG__,V=globalThis,Wl=`10.70.0`;function Gl(){return Kl(V),V}function Kl(e){let t=e.__SENTRY__=e.__SENTRY__||{};return t.version=t.version||`10.70.0`,t[Wl]=t[`10.70.0`]||{}}function ql(e,t,n=V){let r=n.__SENTRY__=n.__SENTRY__||{},i=r[Wl]=r[`10.70.0`]||{};return i[e]||(i[e]=t())}var Jl=[`debug`,`info`,`warn`,`error`,`log`,`assert`,`trace`],Uce=`Sentry Logger `,Yl={};function Xl(e){if(!(`console`in V))return e();let t=V.console,n={},r=Object.keys(Yl);r.forEach(e=>{let r=Yl[e];n[e]=t[e],t[e]=r});try{return e()}finally{r.forEach(e=>{t[e]=n[e]})}}function Wce(){$l().enabled=!0}function Gce(){$l().enabled=!1}function Zl(){return $l().enabled}function Kce(...e){Ql(`log`,...e)}function qce(...e){Ql(`warn`,...e)}function Jce(...e){Ql(`error`,...e)}function Ql(e,...t){B&&Zl()&&Xl(()=>{V.console[e](`${Uce}[${e}]:`,...t)})}function $l(){return B?ql(`loggerSettings`,()=>({enabled:!1})):{enabled:!1}}var H={enable:Wce,disable:Gce,isEnabled:Zl,log:Kce,warn:qce,error:Jce},eu=50,tu=/\(error: (.*)\)/,nu=/captureMessage|captureException/;function ru(...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,$i as i,$t as a,Ai as o,An as s,Ar as c,At as l,B as u,Ba as d,Bn as f,Br as p,Bt as m,C as h,Ci as g,Cn as _,Da as v,Dn as y,Dt as b,Ei as x,En as S,Er as C,Et as w,F as T,Fn as E,Fr as D,Ft as O,Gn as ee,Gt as te,Hn as k,Hr as A,Ht as ne,Ir as j,It as re,J as ie,Ji as ae,Jn as oe,Jt as se,K as ce,Ki as le,Kn as ue,Kt as de,L as fe,Ln as pe,Lr as me,Lt as he,M as ge,Ma as _e,Mi as ve,Mr as ye,Mt as be,N as xe,Na as Se,Nn as eee,Nt as Ce,O as tee,Oa as nee,On as ree,Ot as iee,P as aee,Pa as we,Pn as Te,Pt as Ee,Qn as De,Qt as oee,R as Oe,Ra as ke,Rn as Ae,Rr as je,Rt as see,Sa as Me,Sn as cee,T as Ne,Ta as lee,Tn as uee,Tr as Pe,Tt as Fe,U as Ie,Un as Le,Ur as Re,Ut as dee,V as fee,Va as pee,Vn as ze,Vr as Be,Vt as Ve,W as He,Wn as mee,Wr as hee,Wt as gee,X as _ee,Xn as vee,Y as yee,Yi as Ue,Yn as We,Yt as bee,Z as Ge,Zi as Ke,Zn as xee,Zt as See,_ as Cee,_i as wee,_n as Tee,_r as Eee,_t as Dee,aa as qe,ai as Oee,an as kee,at as Je,bi as Aee,bn as jee,br as Mee,bt as Ye,ci as Nee,cn as Xe,ct as Ze,di as Pee,dn as Fee,dr as Iee,dt as Qe,ei as Lee,en as $e,er as Ree,et,fr as zee,ft as tt,gn as nt,gt as rt,hn as it,hr as at,ht as ot,in as st,it as Bee,j as ct,ja as Vee,ji as lt,jn as ut,jr as Hee,jt as dt,ka as Uee,ki as Wee,kr as Gee,kt as ft,li as Kee,ln as qee,m as Jee,ma as pt,mi as mt,mn as ht,mr as gt,mt as _t,ni as Yee,nr as vt,nt as yt,oi as bt,on as Xee,or as xt,pn as St,pt as Ct,q as wt,qn as Tt,qt as Zee,r as Qee,ra as $ee,rn as Et,rr as ete,rt as tte,s as nte,si as Dt,sn as rte,st as Ot,ti as ite,ui as kt,un as At,ut as jt,vn as Mt,vr as ate,vt as ote,w as Nt,wi as ste,wn as cte,wr as lte,wt as Pt,x as ute,xi as dte,xn as Ft,y as fte,yi as pte,yn as It,yt as mte,z as Lt,za as hte,zn as Rt,zt as gte}from"./Stream-C4tOsbfQ.js";import{i as _te,l as zt,n as Bt,o as Vt,s as Ht}from"./atomRegistry-C-gODSji.js";import{An as Ut,Fn as vte,Mn as Wt,Nn as yte,Pn as bte,Sn as xte,Z as Ste,_ as Cte,_n as Gt,b as Kt,g as qt,gn as Jt,i as wte,pn as Yt,v as Tte,xn as Xt,y as Ete}from"./CompositeItem-Cj6_oAlz.js";import{$t as Dte,An as Zt,At as Ote,B as kte,Bn as Ate,Bt as Qt,Cn as $t,Ct as en,D as jte,Dn as tn,Dt as nn,E as rn,En as Mte,Et as an,F as Nte,Ft as on,Gt as Pte,H as sn,Ht as cn,In as Fte,It as Ite,J as ln,Jt as Lte,Kt as un,L as Rte,Ln as zte,Lt as dn,Mn as fn,Mt as pn,Nn as mn,Nt as Bte,O as Vte,On as Hte,Ot as hn,Pn as Ute,Pt as Wte,Q as Gte,Qt as Kte,Rn as qte,Rt as gn,S as Jte,Sn as _n,T as vn,Tn as Yte,Ut as yn,V as bn,Vn as Xte,Vt as xn,Wn as Zte,Wt as Qte,X as Sn,Xt as $te,Y as Cn,Yt as ene,Zt as wn,_n as Tn,a as M,an as En,bn as Dn,bt as tne,c as On,cn as kn,ct as nne,d as rne,dn as An,en as ine,et as jn,f as ane,fn as Mn,ft as Nn,g as Pn,gn as Fn,hn as one,ht as sne,i as cne,in as In,it as lne,jn as Ln,jt as une,k as Rn,kt as dne,l as fne,ln as pne,m as mne,mn as zn,mt as hne,n as gne,nn as Bn,nt as Vn,o as Hn,pn as Un,pt as Wn,qn as Gn,qt as _ne,rn as Kn,s as qn,st as Jn,t as vne,tn as Yn,tt as yne,u as bne,un as Xn,ut as xne,v as Zn,vt as Sne,wn as Qn,x as Cne,xn as $n,xt as er,y as wne,zn as Tne,zt as tr}from"./src-CtyKlVph.js";import{A as nr,D as rr,E as ir,F as Ene,I as ar,M as Dne,O as or,P as One,S as kne,_ as Ane,a as sr,b as jne,c as Mne,j as cr,k as lr,l as Nne,n as ur,s as Pne,u as Fne,v as Ine,w as dr,x as Lne,y as Rne}from"./cmmdAuthRedirect-DWiMDVzN.js";import{t as N}from"./preload-helper-Czpn1I53.js";import{n as P,t as fr}from"./transport-CgH8pQK3.js";import{n as zne,t as Bne}from"./workspaceReadinessAtom-DZAbFDrM.js";function Vne(e){return e[e.length-1]}function Hne(e,t){return typeof e==`function`?e(t):e}var pr=Object.prototype.hasOwnProperty,Une=Object.prototype.propertyIsEnumerable;function Wne(e){for(let t in e)if(pr.call(e,t))return!0;return!1}var Gne=()=>Object.create(null),Kne=(e,t)=>mr(e,t,Gne);function mr(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=vr(e)&&vr(i);if(!a&&!(gr(e)&&gr(i)))return i;let o=a?e:hr(e);if(!o)return i;let s=a?i:hr(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:pr.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=mr(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function hr(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(!Une.call(e,r))return!1;t.push(r)}return t}function gr(e){if(!_r(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!_r(n)||!n.hasOwnProperty(`isPrototypeOf`))}function _r(e){return Object.prototype.toString.call(e)===`[object Object]`}function vr(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function yr(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(!yr(e[r],t[r],n))return!1;return!0}if(gr(e)&&gr(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!yr(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||!yr(e[o],t[o],n)))return!1;return i===a}return!1}var qne=/[\x00-\x1f\x7f"<>`{}]/g;function Jne(e){return e.replace(qne,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function br(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 Jne(t)}var Yne=[`http:`,`https:`,`mailto:`,`tel:`];function Xne(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+=br(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=br(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function Qne(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function $ne(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 xr(){throw Error(`Invariant failed`)}var F=t(pee(),1),Sr=F.createContext(null);function Cr(e){return F.useContext(Sr)}var wr=F.createContext(void 0),ere=F.createContext(void 0),tre=vte();function nre(e,t){return e===t}function Tr(e,t,n=nre){let r=(0,F.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,F.useCallback)(()=>e?.get(),[e]);return(0,tre.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var Er={};function Dr(e,t){let n=F.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=mr(n.current,i):i}}function Or(e){let t=Cr(),n=F.useContext(e.from?ere:wr),r=e.from??n,i=t.stores.getMatchStore(r),a=Dr(e,t),o=Tr(i,e=>e?a(e):Er);if(o!==Er)return o;(e.shouldThrow??!0)&&xr()}function rre(e){return Or({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 kr=d(),Ar=typeof window<`u`&&(window.desktopBridge!==void 0||window.nativeApi!==void 0),jr=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(){}},Mr=new class extends jr{#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`}},ire={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Nr=new class{#e=ire;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 are(e){setTimeout(e,0)}var ore=typeof window>`u`||`Deno`in globalThis;function Pr(){}function sre(e,t){return typeof e==`function`?e(t):e}function Fr(e){return typeof e==`number`&&e>=0&&e!==1/0}function Ir(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Lr(e,t){return typeof e==`function`?e(t):e}function Rr(e,t){return typeof e==`function`?e(t):e}function cre(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==zr(o,t.options))return!1}else if(!Vr(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 lre(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Br(t.options.mutationKey)!==Br(a))return!1}else if(!Vr(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function zr(e,t){return(t?.queryKeyHashFn||Br)(e)}function Br(e){return JSON.stringify(e,(e,t)=>Gr(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Vr(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(!Vr(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Vr(e[r],t[r]))return!1;return!0}return!1}var ure=Object.prototype.hasOwnProperty;function Hr(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Wr(e)&&Wr(t);if(!r&&!(Gr(e)&&Gr(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:ure.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Hr(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Ur(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 Wr(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Gr(e){if(!Kr(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Kr(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Kr(e){return Object.prototype.toString.call(e)===`[object Object]`}function dre(e){return new Promise(t=>{Nr.setTimeout(t,e)})}function qr(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Hr(e,t)}function fre(e){return e}function pre(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function mre(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Jr=Symbol();function Yr(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Jr?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Xr(e,t){return typeof e==`function`?e(...t):!!e}function hre(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 Zr=(()=>{let e=()=>ore;return{isServer(){return e()},setIsServer(t){e=t}}})();function Qr(){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 gre=are;function _re(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=gre,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 $r=_re(),ei=new class extends jr{#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 vre(e){return Math.min(1e3*2**e,3e4)}function ti(e){return(e??`online`)!==`online`||ei.isOnline()}var ni=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function ri(e){let t=!1,n=0,r,i=Qr(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new ni(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>Mr.isFocused()&&(e.networkMode===`always`||ei.isOnline())&&e.canRun(),u=()=>ti(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??(Zr.isServer()?0:3),o=e.retryDelay??vre,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),dre(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 ii=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Fr(this.gcTime)&&(this.#e=Nr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Zr.isServer()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(Nr.clearTimeout(this.#e),this.#e=void 0)}};function yre(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=>{hre(e,()=>t.signal,()=>n=!0)},u=Yr(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?mre:pre;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?oi:ai,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:ai(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 ai(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 oi(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function bre(e,t){return t?ai(e,t)!=null:!1}function xre(e,t){return!t||!e.getPreviousPageParam?!1:oi(e,t)!=null}var Sre=class extends ii{#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=li(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=li(this.options);e.data!==void 0&&(this.setState(ci(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=qr(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(Pr).catch(Pr):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=>Rr(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Jr||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Lr(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:!Ir(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=Yr(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`?yre(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=ri({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof ni&&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 ni){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,...si(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...ci(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),$r.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function si(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ti(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function ci(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function li(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 ui=class extends jr{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=Qr(),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),di(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return fi(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return fi(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 Rr(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&&!Ur(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&pi(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Rr(this.options.enabled,this.#t)!==Rr(t.enabled,this.#t)||Lr(this.options.staleTime,this.#t)!==Lr(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Rr(this.options.enabled,this.#t)!==Rr(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 wre(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(Pr)),t}#g(){this.#b();let e=Lr(this.options.staleTime,this.#t);if(Zr.isServer()||this.#r.isStale||!Fr(e))return;let t=Ir(this.#r.dataUpdatedAt,e)+1;this.#d=Nr.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,!(Zr.isServer()||Rr(this.options.enabled,this.#t)===!1||!Fr(this.#p)||this.#p===0)&&(this.#f=Nr.setInterval(()=>{(this.options.refetchIntervalInBackground||Mr.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(Nr.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(Nr.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&&di(e,t),o=i&&pi(e,n,t,r);(a||o)&&(l={...l,...si(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=qr(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=qr(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:mi(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Rr(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=Qr();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),!Ur(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){$r.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function Cre(e,t){return Rr(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||Rr(t.retryOnMount,e)!==!1)}function di(e,t){return Cre(e,t)||e.state.data!==void 0&&fi(e,t,t.refetchOnMount)}function fi(e,t,n){if(Rr(t.enabled,e)!==!1&&Lr(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&mi(e,t)}return!1}function pi(e,t,n,r){return(e!==t||Rr(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&mi(e,n)}function mi(e,t){return Rr(t.enabled,e)!==!1&&e.isStaleByTime(Lr(t.staleTime,e))}function wre(e,t){return!Ur(e.getCurrentResult(),t)}var hi=F.createContext(void 0),gi=e=>{let t=F.useContext(hi);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Tre=({client:e,children:t})=>(F.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,kr.jsx)(hi.Provider,{value:e,children:t})),_i=F.createContext(!1),vi=()=>F.useContext(_i);_i.Provider;function Ere(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Dre=F.createContext(Ere()),yi=()=>F.useContext(Dre),bi=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Xr(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},xi=e=>{F.useEffect(()=>{e.clearReset()},[e])},Si=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Xr(n,[e.error,r])),Ci=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))}},Ore=(e,t)=>e.isLoading&&e.isFetching&&!t,wi=(e,t)=>e?.suspense&&t.isPending,Ti=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ei(e,t,n){let r=vi(),i=yi(),a=gi(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,Ci(o),bi(o,i,s),xi(i);let l=!a.getQueryCache().get(o.queryHash),[u]=F.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(F.useSyncExternalStore(F.useCallback(e=>{let t=f?u.subscribe($r.batchCalls(e)):Pr;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),F.useEffect(()=>{u.setOptions(o)},[o,u]),wi(o,d))throw Ti(o,u,i);if(Si({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&&!Zr.isServer()&&Ore(d,r)&&(l?Ti(o,u,i):s?.promise)?.catch(Pr).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function Di(e,t){return Ei(e,ui,t)}function kre(e){return e}var Are={[Symbol.iterator](){return jre}},jre={next(){return{done:!0,value:void 0}}},Mre=()=>Are,Nre=C,Oi=globalThis.Number,Pre=e=>{if(e===`NaN`)return ve(NaN);if(e===`Infinity`)return ve(1/0);if(e===`-Infinity`)return ve(-1/0);if(e.trim()===``)return lt();let t=Oi(e);return Oi.isNaN(t)?lt():ve(t)},Fre=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`]],ki=`~effect/http/HttpClientRequest`,Ire={[ki]:ki,...Ue,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:$ee(this.headers),body:this.body.toJSON()}},pipe(){return ke(this,arguments)}};function Ai(e,t,n,r,i,a){let o=Object.create(Ire);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var Lre=Ai(`GET`,``,_ne,lt(),dn,Pte),ji=e=>(t,n)=>zre(Lre,{method:e,url:t,...n??void 0}),Rre=ji(`POST`),zre=_e(2,(e,t)=>{let n=e;return t.method&&(n=Bre(n,t.method)),t.url&&(n=Ure(n,t.url)),t.headers&&(n=Mi(n,t.headers)),t.urlParams&&(n=Wre(n,t.urlParams)),t.hash&&(n=Gre(n,t.hash)),t.body&&(n=Pi(n,t.body)),t.accept&&(n=Ni(n,t.accept)),t.acceptJson&&(n=Hre(n)),n}),Bre=_e(2,(e,t)=>Ai(t,e.url,e.urlParams,e.hash,e.headers,e.body)),Vre=_e(3,(e,t,n)=>Ai(e.method,e.url,e.urlParams,e.hash,yn(e.headers,t,n),e.body)),Mi=_e(2,(e,t)=>Ai(e.method,e.url,e.urlParams,e.hash,Qte(e.headers,t),e.body)),Ni=_e(2,(e,t)=>Vre(e,`Accept`,t)),Hre=Ni(`application/json`),Ure=_e(2,(e,t)=>{if(typeof t==`string`)return Ai(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Lte(n.searchParams),i=pte(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,Ai(e.method,n.toString(),r,i,e.headers,e.body)}),Wre=_e(2,(e,t)=>Ai(e.method,e.url,$te(e.urlParams,t),e.hash,e.headers,e.body)),Gre=_e(2,(e,t)=>Ai(e.method,e.url,e.urlParams,ve(t),e.headers,e.body)),Pi=_e(2,(e,t)=>{let n=e.headers;return t._tag===`Empty`||t._tag===`FormData`?n=cn(cn(n,`Content-Type`),`Content-length`):(t.contentType&&(n=yn(n,`content-type`,t.contentType)),t.contentLength!==void 0&&(n=yn(n,`content-length`,t.contentLength.toString()))),Ai(e.method,e.url,e.urlParams,e.hash,n,t)}),Kre=e=>tr({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${o(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),Fi=`~effect/http/HttpClient`,Ii=Dt(`effect/HttpClient`),Li=_e(2,(e,t)=>Ri(n=>t(e.postprocess(n)),e.preprocess)),qre=Li(yt(Bte)),Ri=(e,t)=>{let n=Object.create(Jre);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},Jre={[Fi]:Fi,pipe(){return ke(this,arguments)},...Ue,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(Fre.map(([e,t])=>[t,function(t,n){return this.execute(ji(e)(t,n))}]))},Yre=e=>Ri(t=>yt(t,t=>Mt(n=>{let i=$re.get(t),a=i??new AbortController,o=ene(t.url,t.urlParams,g(t.hash));if(ite(o))return r(new wn({reason:new Dte({request:t,cause:o.failure})}));let s=o.success;if(n.getRef(Gee)||n.getRef(zi)(t)){let r=e(t,s,a.signal,n);return i?r:St(e=>Fe(e(r),{onSuccess(e){return Vi.register(e,a),$e(new Hi(e,a))},onFailure(e){return gt(e)&&a.abort(),et(e)}}))}return it(n.getRef(Zre)(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(Ite),l=xn(t.headers,c);for(let e in l)r.attribute(`http.request.header.${e}`,String(l[e]));return t=n.getRef(Bi)?Mi(t,Kre(r)):t,St(o=>o(e(t,s,a.signal,n)).pipe(It(r,{captureStackTrace:!1}),Fe({onSuccess:e=>{r.attribute(`http.response.status_code`,e.status);let t=xn(e.headers,c);for(let e in t)r.attribute(`http.response.header.${e}`,String(t[e]));return i?$e(e):(Vi.register(e,a),$e(new Hi(e,a)))},onFailure(e){return!i&>(e)&&a.abort(),et(e)}})))})})),$e),Xre=_e(2,(e,t)=>{let n=uee(t),r=n?`errors-and-responses`:t.retryOn??`errors-and-responses`,i=n?t:t.schedule,a=i&&S(i),o=n?void 0:t.times;return Li(e,Se(r===`errors-only`?we:re({schedule:a,times:o,while:Wi}),r===`response-only`?we:he({while:n||t.while===void 0?Ui:v(Ui,t.while),schedule:i,times:o})))}),zi=bt(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>nee}),Bi=bt(`effect/HttpClient/TracerPropagationEnabled`,{defaultValue:Uee}),Zre=bt(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),Qre=e=>ut(Ii)(ie(t=>Ye(e,e=>Li(e,ht(e=>mt(t,e)))))),Vi=(()=>{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))}}})(),$re=new WeakMap,Hi=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[pn]=pn;[on]=on;applyInterrupt(e){return Et(()=>(Vi.unregister(this.original),ft(e,()=>st(()=>{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 Cee(()=>(Vi.unregister(this.original),Qee(this.original.stream,st(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Ke](){return this.original[Ke]()}pipe(){return ke(this,arguments)}},Ui=e=>Mee(e)||eie(e),eie=e=>Yn(e)&&(e.reason._tag===`TransportError`||e.reason._tag===`StatusCodeError`&&Wi(e.reason.response)),Wi=e=>e.status===408||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504,Gi=`~effect/FiberSet`,Ki=e=>pt(e,Gi),qi={[Gi]:Gi,[Symbol.iterator](){return this.state._tag===`Closed`?Mre():this.state.backing[Symbol.iterator]()},...le,toJSON(){return{_id:`FiberMap`,state:this.state}}},Ji=(e,t)=>{let n=Object.create(qi);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},Yi=()=>Oe(st(()=>Ji(new Set,We())),e=>Et(()=>{let t=e.state;if(t._tag===`Closed`)return nt;e.state={_tag:`Closed`};let n=t.backing;return T(n).pipe(oe(e.deferred))})),Xi=-1,tie=me(D(Iee,j(Xi))),nie=_e(e=>Ki(e[0]),(e,t,n)=>{if(e.state._tag===`Closed`){t.interruptUnsafe(Xi);return}e.state.backing.has(t)||(e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),vt(r)&&(n?.propagateInterruption===!0?!tie(r.cause):!at(r.cause))&&Tt(e.deferred,r))}))}),rie=function(){let e;return()=>(e===void 0&&(e=m(_t)),e)}(),iie=e=>()=>Ye(wt(),t=>{let n=Ve(t);return(t,r)=>{if(e.state._tag===`Closed`)return rie();let i=n(t,r);return nie(e,i),i}}),Zi=e=>ue(e.deferred),Qi=`~effect/socket/Socket`,$i=Dt(`effect/socket/Socket`),aie=`~effect/socket/Socket/CloseEvent`,oie=e=>pt(e,aie),ea=`~effect/socket/Socket/SocketError`,sie=e=>pt(e,ea),ta=class extends En(`effect/socket/Socket/SocketReadError`)({_tag:fn(`SocketReadError`),cause:In}){message=`An error occurred during Read`},cie=class extends En(`effect/socket/Socket/SocketWriteError`)({_tag:fn(`SocketWriteError`),cause:In}){message=`An error occurred during Write`},na=class extends En(`effect/socket/Socket/SocketOpenError`)({_tag:fn(`SocketOpenError`),kind:kn([`Unknown`,`Timeout`]),cause:In}){get message(){return this.kind===`Timeout`?`timeout waiting for "open"`:`An error occurred during Open`}},ra=class extends En(`effect/socket/Socket/SocketCloseError`)({_tag:fn(`SocketCloseError`),code:An,closeReason:Zt(Un)}){static filterClean(e){return function(t){return aa.is(t)&&t.reason._tag===`SocketCloseError`&&e(t.reason.code)?Oee(t.reason):Lee(t)}}get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},ia=Tn([ta,cie,na,ra]),aa=class extends one(ea)(`SocketError`,{_tag:fn(`SocketError`),reason:ia}){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[ea]=ea;static is(e){return sie(e)}message=this.reason.message},lie=e=>!0,uie=class extends Dt()(`~effect/socket/Socket/WebSocket`){},oa=class extends Dt()(`@effect/platform/Socket/WebSocketConstructor`){},die=(e,t)=>oa.use(n=>fie(Oe((typeof e==`string`?$e(e):e).pipe(Ye(e=>n(e,t?.protocols))),e=>st(()=>e.close(1e3))),t)),fie=(e,t)=>Mt(n=>{let i,a=ct(!1),o=n.context,s=t?.closeCodeIsError??lie,c=(n,c)=>See(Je(function*(o){let l=yield*Yi().pipe(ee(o)),u=yield*ee(e,o),d=yield*Ee(iie(l)(),uie,u),f=!1;function p(e){if(e.data instanceof Blob){let t=yt(dt(()=>e.data.arrayBuffer()),e=>{let t=n(new Uint8Array(e));return rt(t)?t:nt});return d(t)}let t=n(e.data);rt(t)&&d(t)}function m(e){u.removeEventListener(`message`,p),u.removeEventListener(`close`,h),Tt(l.deferred,r(new aa({reason:f?new ta({cause:e}):new na({kind:`Unknown`,cause:e})})))}function h(e){let t=typeof e.code==`number`?e.code:1001;u.removeEventListener(`message`,p),u.removeEventListener(`error`,m),Tt(l.deferred,r(new aa({reason:new ra({code:t,closeReason:e.reason})})))}if(u.addEventListener(`close`,h,{once:!0}),u.addEventListener(`error`,m,{once:!0}),u.addEventListener(`message`,p),u.readyState!==1){let e=We();u.addEventListener(`open`,()=>{f=!0,Tt(e,nt)},{once:!0}),yield*ue(e).pipe(At({duration:t?.openTimeout??1e4,orElse:()=>r(new aa({reason:new na({kind:`Timeout`,cause:Error(`timeout waiting for "open"`)})}))}),O(Zi(l)))}return f=!0,i=u,a.openUnsafe(),c?.onOpen&&(yield*c.onOpen),yield*ce(Zi(l),ra.filterClean(e=>!s(e)),()=>nt)})).pipe(ht(e=>mt(o,e)),Ge(st(()=>{a.closeUnsafe(),i=void 0}))),l=new TextEncoder,u=(e,t)=>c(t=>typeof t==`string`?e(l.encode(t)):t instanceof Uint8Array?e(t):e(new Uint8Array(t)),t),d=$e(e=>a.whenOpen(st(()=>{let t=i;oie(e)?t.close(e.code,e.reason):t.send(e)})));return $e($i.of({[Qi]:Qi,run:u,runRaw:c,writer:d}))}),sa=Se(die,ut($i)),ca=class extends Dt()(`effect/workers/Transferable/Collector`){},pie=()=>{let e=[],t=t=>{e.push(...t)},n=()=>e,r=()=>{let t=e;return e=[],t};return ca.of({addAllUnsafe:t,addAll:e=>st(()=>t(e)),readUnsafe:n,read:st(n),clearUnsafe:r,clear:st(r)})},mie=`~effect/workers/WorkerError`,hie=class extends En(`effect/workers/WorkerError/WorkerSpawnError`)({_tag:fn(`WorkerSpawnError`),message:Un,cause:Zt(In)}){},gie=class extends En(`effect/workers/WorkerError/WorkerSendError`)({_tag:fn(`WorkerSendError`),message:Un,cause:Zt(In)}){},_ie=class extends En(`effect/workers/WorkerError/WorkerReceiveError`)({_tag:fn(`WorkerReceiveError`),message:Un,cause:Zt(In)}){},vie=class extends En(`effect/workers/WorkerError/WorkerUnknownError`)({_tag:fn(`WorkerUnknownError`),message:Un,cause:Zt(In)}){},la=Tn([hie,gie,_ie,vie]);En(mie)({_tag:fn(`WorkerError`),reason:la});var ua=`~effect/rpc/RpcClientError`,da=class extends En(`effect/rpc/RpcClientError/RpcClientDefect`)({_tag:fn(`RpcClientDefect`),message:Un,cause:In}){},fa=class extends En(ua)({_tag:fn(`RpcClientError`),reason:Tn([la,ia,Kte,da])}){[ua]=ua;get message(){return`${this.reason._tag}: ${this.reason.message}`}},pa=e=>typeof e==`bigint`?e:BigInt(e),yie={_tag:`Ping`},ma;try{ma=new TextDecoder}catch{}var I,ha,L=0,ga=[],_a=ga,va=0,ya={},ba,xa,Sa=0,Ca=0,wa,Ta,Ea=[],Da,Oa={useRecords:!1,mapsAsObjects:!0},ka=class{},Aa=new ka;Aa.name=`MessagePack 0xC1`;var ja=!1,Ma=2,Na,Pa,Fa;try{Function(``)}catch{Ma=1/0}var Ia=class e{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=0&&(e.structures=[],e.maxSharedStructures||=0)),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType=`number`)),Object.assign(this,e)}unpack(t,n){if(I)return ao(()=>(oo(),this?this.unpack(t,n):e.prototype.unpack.call(Oa,t,n)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<`u`?Buffer.from(t):new Uint8Array(t)),typeof n==`object`?(ha=n.end||t.length,L=n.start||0):(L=0,ha=n>-1?n:t.length),va=0,Ca=0,xa=null,_a=ga,wa=null,I=t;try{Da=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(e){throw I=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(ya=this,this.structures)return ba=this.structures,La(n);(!ba||ba.length>0)&&(ba=[])}else ya=Oa,(!ba||ba.length>0)&&(ba=[]);return La(n)}unpackMultiple(e,t){let n,r=0;try{ja=!0;let i=e.length,a=this?this.unpack(e,i):co.unpack(e,i);if(t){if(t(a,r,L)===!1)return;for(;L<i;)if(r=L,t(La(),r,L)===!1)return}else{for(n=[a];L<i;)r=L,n.push(La());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{ja=!1,oo()}}_mergeStructures(e,t){Pa&&(e=Pa.call(this,e)),e||=[],Object.isFrozen(e)&&(e=e.map(e=>e.slice(0)));for(let t=0,n=e.length;t<n;t++){let n=e[t];n&&(n.isShared=!0,t>=32&&(n.highByte=t-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let r=e[n],i=t[n];i&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[n]=r),e[n]=i)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function La(e){try{if(!ya.trusted&&!ja){let e=ba.sharedLength||0;e<ba.length&&(ba.length=e)}let t;if(ya.randomAccessStructure&&I[L]<64&&I[L]>=32&&Na?(t=Na(I,L,ha,ya),I=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),L=ha):t=za(),wa&&=(L=wa.postBundlePosition,null),ja&&(ba.restoreStructures=null),L==ha)ba&&ba.restoreStructures&&Ra(),ba=null,I=null,Ta&&=null;else if(L>ha)throw Error(`Unexpected end of MessagePack data`);else if(!ja){let e;try{e=JSON.stringify(t,(e,t)=>typeof t==`bigint`?`${t}n`:t).slice(0,100)}catch(t){e=`(JSON view not available `+t+`)`}throw Error(`Data read, but end of buffer not reached `+e)}return t}catch(e){throw ba&&ba.restoreStructures&&Ra(),oo(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`)||L>ha)&&(e.incomplete=!0),e}}function Ra(){for(let e in ba.restoreStructures)ba[e]=ba.restoreStructures[e];ba.restoreStructures=null}function za(){let e=I[L++];if(e<160)if(e<128){if(e<64)return e;{let t=ba[e&63]||ya.getStructures&&Ha()[e&63];return t?(t.read||=Ba(t,e&63),t.read()):e}}else if(e<144){if(e-=128,ya.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=eo();e===`__proto__`&&(e=`__proto_`),t[e]=za()}return t}{let t=new Map;for(let n=0;n<e;n++)t.set(za(),za());return t}}else{e-=144;let t=Array(e);for(let n=0;n<e;n++)t[n]=za();return ya.freezeData?Object.freeze(t):t}if(e<192){let t=e-160;if(Ca>=L)return xa.slice(L-Sa,(L+=t)-Sa);if(Ca==0&&ha<140){let e=t<16?Ya(t):Ja(t);if(e!=null)return e}return Ua(t)}{let t;switch(e){case 192:return null;case 193:return wa?(t=za(),t>0?wa[1].slice(wa.position1,wa.position1+=t):wa[0].slice(wa.position0,wa.position0-=t)):Aa;case 194:return!1;case 195:return!0;case 196:if(t=I[L++],t===void 0)throw Error(`Unexpected end of buffer`);return Za(t);case 197:return t=Da.getUint16(L),L+=2,Za(t);case 198:return t=Da.getUint32(L),L+=4,Za(t);case 199:return Qa(I[L++]);case 200:return t=Da.getUint16(L),L+=2,Qa(t);case 201:return t=Da.getUint32(L),L+=4,Qa(t);case 202:if(t=Da.getFloat32(L),ya.useFloat32>2){let e=so[(I[L]&127)<<1|I[L+1]>>7];return L+=4,(e*t+(t>0?.5:-.5)>>0)/e}return L+=4,t;case 203:return t=Da.getFloat64(L),L+=8,t;case 204:return I[L++];case 205:return t=Da.getUint16(L),L+=2,t;case 206:return t=Da.getUint32(L),L+=4,t;case 207:return ya.int64AsType===`number`?(t=Da.getUint32(L)*4294967296,t+=Da.getUint32(L+4)):ya.int64AsType===`string`?t=Da.getBigUint64(L).toString():ya.int64AsType===`auto`?(t=Da.getBigUint64(L),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=Da.getBigUint64(L),L+=8,t;case 208:return Da.getInt8(L++);case 209:return t=Da.getInt16(L),L+=2,t;case 210:return t=Da.getInt32(L),L+=4,t;case 211:return ya.int64AsType===`number`?(t=Da.getInt32(L)*4294967296,t+=Da.getUint32(L+4)):ya.int64AsType===`string`?t=Da.getBigInt64(L).toString():ya.int64AsType===`auto`?(t=Da.getBigInt64(L),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=Da.getBigInt64(L),L+=8,t;case 212:if(t=I[L++],t==114)return no(I[L++]&63);{let e=Ea[t];if(e)return e.read?(L++,e.read(za())):e.noBuffer?(L++,e()):e(I.subarray(L,++L));throw Error(`Unknown extension `+t)}case 213:return t=I[L],t==114?(L++,no(I[L++]&63,I[L++])):Qa(2);case 214:return Qa(4);case 215:return Qa(8);case 216:return Qa(16);case 217:return t=I[L++],Ca>=L?xa.slice(L-Sa,(L+=t)-Sa):xie(t);case 218:return t=Da.getUint16(L),L+=2,Ca>=L?xa.slice(L-Sa,(L+=t)-Sa):Sie(t);case 219:return t=Da.getUint32(L),L+=4,Ca>=L?xa.slice(L-Sa,(L+=t)-Sa):Cie(t);case 220:return t=Da.getUint16(L),L+=2,Ga(t);case 221:return t=Da.getUint32(L),L+=4,Ga(t);case 222:return t=Da.getUint16(L),L+=2,Ka(t);case 223:return t=Da.getUint32(L),L+=4,Ka(t);default:if(e>=224)return e-256;if(e===void 0){let e=Error(`Unexpected end of MessagePack data`);throw e.incomplete=!0,e}throw Error(`Unknown MessagePack token `+e)}}}var bie=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Ba(e,t){function n(){if(n.count++>Ma){let n=e.read=Function(`r`,`return function(){return `+(ya.freezeData?`Object.freeze`:``)+`({`+e.map(e=>e===`__proto__`?`__proto_:r()`:bie.test(e)?e+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`})}`)(za);return e.highByte===0&&(e.read=Va(t,e.read)),n()}let r={};for(let t=0,n=e.length;t<n;t++){let n=e[t];n===`__proto__`&&(n=`__proto_`),r[n]=za()}return ya.freezeData?Object.freeze(r):r}return n.count=0,e.highByte===0?Va(t,n):n}var Va=(e,t)=>function(){let n=I[L++];if(n===0)return t();let r=e<32?-(e+(n<<5)):e+(n<<5),i=ba[r]||Ha()[r];if(!i)throw Error(`Record id is not defined for `+r);return i.read||=Ba(i,e),i.read()};function Ha(){let e=ao(()=>(I=null,ya.getStructures()));return ba=ya._mergeStructures(e,ba)}var Ua=Wa,xie=Wa,Sie=Wa,Cie=Wa;function Wa(e){let t;if(e<16&&(t=Ya(e)))return t;if(e>64&&ma)return ma.decode(I.subarray(L,L+=e));let n=L+e,r=[];for(t=``;L<n;){let e=I[L++];if(!(e&128))r.push(e);else if((e&224)==192){let t=I[L++]&63,n=(e&31)<<6|t;n<128?r.push(65533):r.push(n)}else if((e&240)==224){let t=I[L++]&63,n=I[L++]&63,i=(e&31)<<12|t<<6|n;i<2048||i>=55296&&i<=57343?r.push(65533):r.push(i)}else if((e&248)==240){let t=I[L++]&63,n=I[L++]&63,i=I[L++]&63,a=(e&7)<<18|t<<12|n<<6|i;a<65536||a>1114111?r.push(65533):a>65535?(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023,r.push(a)):r.push(a)}else r.push(65533);r.length>=4096&&(t+=qa.apply(String,r),r.length=0)}return r.length>0&&(t+=qa.apply(String,r)),t}function Ga(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=za();return ya.freezeData?Object.freeze(t):t}function Ka(e){if(ya.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=eo();e===`__proto__`&&(e=`__proto_`),t[e]=za()}return t}{let t=new Map;for(let n=0;n<e;n++)t.set(za(),za());return t}}var qa=String.fromCharCode;function Ja(e){let t=L,n=Array(e);for(let r=0;r<e;r++){let e=I[L++];if((e&128)>0){L=t;return}n[r]=e}return qa.apply(String,n)}function Ya(e){if(e<4)if(e<2){if(e===0)return``;{let e=I[L++];if((e&128)>1){--L;return}return qa(e)}}else{let t=I[L++],n=I[L++];if((t&128)>0||(n&128)>0){L-=2;return}if(e<3)return qa(t,n);let r=I[L++];if((r&128)>0){L-=3;return}return qa(t,n,r)}{let t=I[L++],n=I[L++],r=I[L++],i=I[L++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){L-=4;return}if(e<6){if(e===4)return qa(t,n,r,i);{let e=I[L++];if((e&128)>0){L-=5;return}return qa(t,n,r,i,e)}}if(e<8){let a=I[L++],o=I[L++];if((a&128)>0||(o&128)>0){L-=6;return}if(e<7)return qa(t,n,r,i,a,o);let s=I[L++];if((s&128)>0){L-=7;return}return qa(t,n,r,i,a,o,s)}{let a=I[L++],o=I[L++],s=I[L++],c=I[L++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){L-=8;return}if(e<10){if(e===8)return qa(t,n,r,i,a,o,s,c);{let e=I[L++];if((e&128)>0){L-=9;return}return qa(t,n,r,i,a,o,s,c,e)}}if(e<12){let l=I[L++],u=I[L++];if((l&128)>0||(u&128)>0){L-=10;return}if(e<11)return qa(t,n,r,i,a,o,s,c,l,u);let d=I[L++];if((d&128)>0){L-=11;return}return qa(t,n,r,i,a,o,s,c,l,u,d)}{let l=I[L++],u=I[L++],d=I[L++],f=I[L++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){L-=12;return}if(e<14){if(e===12)return qa(t,n,r,i,a,o,s,c,l,u,d,f);{let e=I[L++];if((e&128)>0){L-=13;return}return qa(t,n,r,i,a,o,s,c,l,u,d,f,e)}}{let p=I[L++],m=I[L++];if((p&128)>0||(m&128)>0){L-=14;return}if(e<15)return qa(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=I[L++];if((h&128)>0){L-=15;return}return qa(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function Xa(){let e=I[L++],t;if(e<192)t=e-160;else switch(e){case 217:t=I[L++];break;case 218:t=Da.getUint16(L),L+=2;break;case 219:t=Da.getUint32(L),L+=4;break;default:throw Error(`Expected string`)}return Wa(t)}function Za(e){return ya.copyBuffers?Uint8Array.prototype.slice.call(I,L,L+=e):I.subarray(L,L+=e)}function Qa(e){let t=I[L++];if(Ea[t]){let n;return Ea[t](I.subarray(L,n=L+=e),e=>{L=e;try{return za()}finally{L=n}})}throw Error(`Unknown extension type `+t)}var $a=Array(4096);function eo(){let e=I[L++];if(e>=160&&e<192){if(e-=160,Ca>=L)return xa.slice(L-Sa,(L+=e)-Sa);if(!(Ca==0&&ha<180))return Ua(e)}else return L--,to(za());let t=(e<<5^(e>1?Da.getUint16(L):e>0?I[L]:0))&4095,n=$a[t],r=L,i=L+e-3,a,o=0;if(n&&n.bytes==e){for(;r<i;){if(a=Da.getUint32(r),a!=n[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(a=I[r++],a!=n[o++]){r=1879048192;break}if(r===i)return L=r,n.string;i-=3,r=L}for(n=[],$a[t]=n,n.bytes=e;r<i;)a=Da.getUint32(r),n.push(a),r+=4;for(i+=3;r<i;)a=I[r++],n.push(a);let s=e<16?Ya(e):Ja(e);return s==null?n.string=Ua(e):n.string=s}function to(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;if(ya.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(e=>[`string`,`number`,`boolean`,`bigint`].includes(typeof e)))return e.flat().toString();throw Error(`Invalid property type for record: ${typeof e}`)}var no=(e,t)=>{let n=za().map(to),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,n.highByte=t);let i=ba[e];return i&&(i.isShared||ja)&&((ba.restoreStructures||(ba.restoreStructures=[]))[e]=i),ba[e]=n,n.read=Ba(n,r),n.read()};Ea[0]=()=>{},Ea[0].noBuffer=!0,Ea[66]=e=>{let t=e.byteLength%8||8,n=BigInt(e[0]&128?e[0]-256:e[0]);for(let r=1;r<t;r++)n<<=BigInt(8),n+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=(e,t)=>{let n=t-e;if(n<=40){let n=r.getBigUint64(e);for(let i=e+8;i<t;i+=8)n<<=64n,n|=r.getBigUint64(i);return n}let a=e+(n>>4<<3),o=i(e,a),s=i(a,t);return o<<BigInt((t-a)*8)|s};n=n<<BigInt((r.byteLength-t)*8)|i(t,r.byteLength)}return n};var ro={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError==`function`?AggregateError:null};Ea[101]=()=>{let e=za();if(!ro[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return ro[e[0]](e[1],{cause:e[2]})},Ea[105]=e=>{if(ya.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=Da.getUint32(L-4);Ta||=new Map;let n=I[L],r;r=n>=144&&n<160||n==220||n==221?[]:n>=128&&n<144||n==222||n==223?new Map:(n>=199&&n<=201||n>=212&&n<=216)&&I[L+1]===115?new Set:{};let i={target:r};Ta.set(t,i);let a=za();if(i.used)Object.assign(r,a);else return i.target=a;if(r instanceof Map)for(let[e,t]of a.entries())r.set(e,t);if(r instanceof Set)for(let e of Array.from(a))r.add(e);return r},Ea[112]=e=>{if(ya.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=Da.getUint32(L-4),n=Ta.get(t);return n.used=!0,n.target},Ea[115]=()=>new Set(za());var io=[`Int8`,`Uint8`,`Uint8Clamped`,`Int16`,`Uint16`,`Int32`,`Uint32`,`Float32`,`Float64`,`BigInt64`,`BigUint64`].map(e=>e+`Array`),wie=typeof globalThis==`object`?globalThis:window;Ea[116]=e=>{let t=e[0],n=Uint8Array.prototype.slice.call(e,1).buffer,r=io[t];if(!r){if(t===16)return n;if(t===17)return new DataView(n);throw Error(`Could not find typed array for code `+t)}return new wie[r](n)},Ea[120]=()=>{let e=za();return new RegExp(e[0],e[1])};var Tie=[];Ea[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],n=L;return L+=t-e.length,wa=Tie,wa=[Xa(),Xa()],wa.position0=0,wa.position1=0,wa.postBundlePosition=L,L=n,za()},Ea[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date(`invalid`);function ao(e){Fa&&Fa();let t=ha,n=L,r=va,i=Sa,a=Ca,o=xa,s=_a,c=Ta,l=wa,u=new Uint8Array(I.slice(0,ha)),d=ba,f=ba.slice(0,ba.length),p=ya,m=ja,h=e();return ha=t,L=n,va=r,Sa=i,Ca=a,xa=o,_a=s,Ta=c,wa=l,I=u,ja=m,ba=d,ba.splice(0,ba.length,...f),ya=p,Da=new DataView(I.buffer,I.byteOffset,I.byteLength),h}function oo(){I=null,Ta=null,ba=null}var so=Array(147);for(let e=0;e<256;e++)so[e]=+(`1e`+Math.floor(45.15-e*.30103));var co=new Ia({useRecords:!1});co.unpack,co.unpackMultiple,co.unpack;var Eie={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};new Uint8Array(new Float32Array(1).buffer,0,4);var lo;try{lo=new TextEncoder}catch{}var uo,fo,po=typeof Buffer<`u`,mo=po?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,ho=po?Buffer:Uint8Array,go=po?4294967296:2144337920,R,_o,vo,z=0,yo,bo=null,Die,Oie=21760,kie=/[\u0080-\uFFFF]/,xo=Symbol(`record-id`),Aie=class extends Ia{constructor(e){super(e),this.offset=0;let t,n,r,i,a=ho.prototype.utf8Write?function(e,t){return R.utf8Write(e,t,R.byteLength-t)}:lo&&lo.encodeInto?function(e,t){return lo.encodeInto(e,R.subarray(t)).written}:!1,o=this;e||={};let s=e&&e.sequential,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?32:0,l>8160)throw Error(`Maximum maxSharedStructure is 8160`);e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let u=e.maxOwnStructures;u??=c?32:64,!this.structures&&e.useRecords!=0&&(this.structures=[]);let d=l>32||u+l>64,f=l+64,p=l+u+64;if(p>8256)throw Error(`Maximum maxSharedStructure + maxOwnStructure is 8192`);let m=[],h=0,g=0;this.pack=this.encode=function(e,a){if(R||(R=new mo(8192),vo=R.dataView||(R.dataView=new DataView(R.buffer,0,8192)),z=0),yo=R.length-10,yo-z<2048?(R=new mo(R.length),vo=R.dataView||(R.dataView=new DataView(R.buffer,0,R.length)),yo=R.length-10,z=0):z=z+7&2147483640,t=z,a&2048&&(z+=a&255),i=o.structuredClone?new Map:null,o.bundleStrings&&typeof e!=`string`?(bo=[],bo.size=1/0):bo=null,r=o.structures,r){r.uninitialized&&(r=o._mergeStructures(o.getStructures()));let e=r.sharedLength||0;if(e>l)throw Error(`Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to `+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let t=0;t<e;t++){let e=r[t];if(!e)continue;let n,i=r.transitions;for(let t=0,r=e.length;t<r;t++){let r=e[t];n=i[r],n||=i[r]=Object.create(null),i=n}i[xo]=t+64}this.lastNamedStructuresLength=e}s||(r.nextId=e+64)}n&&=!1;let c;try{o.randomAccessStructure&&e&&typeof e==`object`?e.constructor===Object?D(e):e.constructor!==Map&&!Array.isArray(e)&&!fo.some(t=>e instanceof t)?D(e.toJSON?e.toJSON():e):y(e):y(e);let n=bo;if(bo&&To(t,y,0),i&&i.idsToInsert){let e=i.idsToInsert.sort((e,t)=>e.offset>t.offset?1:-1),r=e.length,a=-1;for(;n&&r>0;){let i=e[--r].offset+t;i<n.stringsPosition+t&&a===-1&&(a=0),i>n.position+t?a>=0&&(a+=6):(a>=0&&(vo.setUint32(n.position+t,vo.getUint32(n.position+t)+a),a=-1),n=n.previous,r++)}a>=0&&n&&vo.setUint32(n.position+t,vo.getUint32(n.position+t)+a),z+=e.length*6,z>yo&&w(z),o.offset=z;let s=jie(R.subarray(t,z),e);return i=null,s}return o.offset=z,a&512?(R.start=t,R.end=z,R):R.subarray(t,z)}catch(e){throw c=e,e}finally{if(r&&(_(),n&&o.saveStructures)){let n=r.sharedLength||0,i=R.subarray(t,z),s=Mie(r,o);if(!c)return o.saveStructures(s,s.isCompatible)===!1?o.pack(e,a):(o.lastNamedStructuresLength=n,R.length>1073741824&&(R=null),i)}R.length>1073741824&&(R=null),a&1024&&(z=t)}};let _=()=>{g<10&&g++;let e=r.sharedLength||0;if(r.length>e&&!s&&(r.length=e),h>1e4)r.transitions=null,g=0,h=0,m.length>0&&(m=[]);else if(m.length>0&&!s){for(let e=0,t=m.length;e<t;e++)m[e][xo]=0;m=[]}},v=e=>{var t=e.length;t<16?R[z++]=144|t:t<65536?(R[z++]=220,R[z++]=t>>8,R[z++]=t&255):(R[z++]=221,vo.setUint32(z,t),z+=4);for(let n=0;n<t;n++)y(e[n])},y=e=>{z>yo&&(R=w(z));var n=typeof e,r;if(n===`string`){let n=e.length;if(bo&&n>=4&&n<4096){if((bo.size+=n)>Oie){let e,n=(bo[0]?bo[0].length*3+bo[1].length:0)+10;z+n>yo&&(R=w(z+n));let r;bo.position?(r=bo,R[z]=200,z+=3,R[z++]=98,e=z-t,z+=4,To(t,y,0),vo.setUint16(e+t-3,z-t-e)):(R[z++]=214,R[z++]=98,e=z-t,z+=4),bo=[``,``],bo.previous=r,bo.size=0,bo.position=e}let r=kie.test(e);bo[+!r]+=e,R[z++]=193,y(r?-n:n);return}let i;i=n<32?1:n<256?2:n<65536?3:5;let o=n*3;if(z+o>yo&&(R=w(z+o)),n<64||!a){let t,a,o,s=z+i;for(t=0;t<n;t++)a=e.charCodeAt(t),a<128?R[s++]=a:a<2048?(R[s++]=a>>6|192,R[s++]=a&63|128):(a&64512)==55296&&((o=e.charCodeAt(t+1))&64512)==56320?(a=65536+((a&1023)<<10)+(o&1023),t++,R[s++]=a>>18|240,R[s++]=a>>12&63|128,R[s++]=a>>6&63|128,R[s++]=a&63|128):(R[s++]=a>>12|224,R[s++]=a>>6&63|128,R[s++]=a&63|128);r=s-z-i}else r=a(e,z+i);r<32?R[z++]=160|r:r<256?(i<2&&R.copyWithin(z+2,z+1,z+1+r),R[z++]=217,R[z++]=r):r<65536?(i<3&&R.copyWithin(z+3,z+2,z+2+r),R[z++]=218,R[z++]=r>>8,R[z++]=r&255):(i<5&&R.copyWithin(z+5,z+3,z+3+r),R[z++]=219,vo.setUint32(z,r),z+=4),z+=r}else if(n===`number`)if(e>>>0===e)e<32||e<128&&this.useRecords===!1||e<64&&!this.randomAccessStructure?R[z++]=e:e<256?(R[z++]=204,R[z++]=e):e<65536?(R[z++]=205,R[z++]=e>>8,R[z++]=e&255):(R[z++]=206,vo.setUint32(z,e),z+=4);else if(e>>0===e)e>=-32?R[z++]=256+e:e>=-128?(R[z++]=208,R[z++]=e+256):e>=-32768?(R[z++]=209,vo.setInt16(z,e),z+=2):(R[z++]=210,vo.setInt32(z,e),z+=4);else{let t;if((t=this.useFloat32)>0&&e<4294967296&&e>=-2147483648){R[z++]=202,vo.setFloat32(z,e);let n;if(t<4||(n=e*so[(R[z]&127)<<1|R[z+1]>>7])>>0===n){z+=4;return}z--}R[z++]=203,vo.setFloat64(z,e),z+=8}else if(n===`object`||n===`function`)if(!e)R[z++]=192;else{if(i){let n=i.get(e);if(n){n.id||=(i.idsToInsert||(i.idsToInsert=[])).push(n),R[z++]=214,R[z++]=112,vo.setUint32(z,n.id),z+=4;return}i.set(e,{offset:z-t})}let a=e.constructor;if(a===Object)C(e);else if(a===Array)v(e);else if(a===Map)if(this.mapAsEmptyObject)R[z++]=128;else{r=e.size,r<16?R[z++]=128|r:r<65536?(R[z++]=222,R[z++]=r>>8,R[z++]=r&255):(R[z++]=223,vo.setUint32(z,r),z+=4);for(let[t,n]of e)y(t),y(n)}else{for(let t=0,n=uo.length;t<n;t++){let n=fo[t];if(e instanceof n){let n=uo[t];if(n.write){n.type&&(R[z++]=212,R[z++]=n.type,R[z++]=0);let t=n.write.call(this,e);t===e?Array.isArray(e)?v(e):C(e):y(t);return}let r=R,i=vo,a=z;R=null;let o;try{o=n.pack.call(this,e,e=>(R=r,r=null,z+=e,z>yo&&w(z),{target:R,targetView:vo,position:z-e}),y)}finally{r&&(R=r,vo=i,z=a,yo=R.length-10)}o&&(o.length+z>yo&&w(o.length+z),z=wo(o,R,z,n.type));return}}if(Array.isArray(e))v(e);else{if(e.toJSON){let t=e.toJSON();if(t!==e)return y(t)}if(n===`function`)return y(this.writeFunction&&this.writeFunction(e));C(e)}}}else if(n===`boolean`)R[z++]=e?195:194;else if(n===`bigint`){if(e<0x8000000000000000&&e>=-0x8000000000000000)R[z++]=211,vo.setBigInt64(z,e);else if(e<0x10000000000000000&&e>0)R[z++]=207,vo.setBigUint64(z,e);else if(this.largeBigIntToFloat)R[z++]=203,vo.setFloat64(z,Number(e));else if(this.largeBigIntToString)return y(e.toString());else if(this.useBigIntExtension||this.moreTypes){let t=BigInt(e<0?-1:0),n;if(e>>BigInt(65536)===t){let r=BigInt(0x10000000000000000)-BigInt(1),i=[];for(;i.push(e&r),e>>BigInt(63)!==t;)e>>=BigInt(64);n=new Uint8Array(new BigUint64Array(i).buffer),n.reverse()}else{let t=e<0,r=(t?~e:e).toString(16);if(r.length%2?r=`0`+r:parseInt(r.charAt(0),16)>=8&&(r=`00`+r),po)n=Buffer.from(r,`hex`);else{n=new Uint8Array(r.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(r.slice(e*2,e*2+2),16)}if(t)for(let e=0;e<n.length;e++)n[e]=~n[e]}n.length+z>yo&&w(n.length+z),z=wo(n,R,z,66);return}else throw RangeError(e+` was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string`);z+=8}else if(n===`undefined`)this.encodeUndefinedAsNil?R[z++]=192:(R[z++]=212,R[z++]=0,R[z++]=0);else throw Error(`Unknown type: `+n)},b=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?e=>{let t;if(this.skipValues){t=[];for(let n in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(n))&&!this.skipValues.includes(e[n])&&t.push(n)}else t=Object.keys(e);let n=t.length;n<16?R[z++]=128|n:n<65536?(R[z++]=222,R[z++]=n>>8,R[z++]=n&255):(R[z++]=223,vo.setUint32(z,n),z+=4);let r;if(this.coercibleKeyAsNumber)for(let i=0;i<n;i++){r=t[i];let n=Number(r);y(isNaN(n)?r:n),y(e[r])}else for(let i=0;i<n;i++)y(r=t[i]),y(e[r])}:e=>{R[z++]=222;let n=z-t;z+=2;let r=0;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(y(t),y(e[t]),r++);if(r>65535)throw Error(`Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object`);R[n+++t]=r>>8,R[n+t]=r&255},x=this.useRecords===!1?b:e.progressiveRecords&&!d?e=>{let n,i=r.transitions||(r.transitions=Object.create(null)),a=z++-t,o;for(let s in e)if(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(s)){if(n=i[s],n)i=n;else{let c=Object.keys(e),l=i;i=r.transitions;let u=0;for(let e=0,t=c.length;e<t;e++){let t=c[e];n=i[t],n||(n=i[t]=Object.create(null),u++),i=n}a+t+1==z?(z--,T(i,c,u)):E(i,c,a,u),o=!0,i=l[s]}y(e[s])}if(!o){let n=i[xo];n?R[a+t]=n:E(i,Object.keys(e),a,0)}}:e=>{let t,n=r.transitions||(r.transitions=Object.create(null)),i=0;for(let r in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(r))&&(t=n[r],t||(t=n[r]=Object.create(null),i++),n=t);let a=n[xo];a?a>=96&&d?(R[z++]=((a-=96)&31)+96,R[z++]=a>>5):R[z++]=a:T(n,n.__keys__||Object.keys(e),i);for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&y(e[t])},S=typeof this.useRecords==`function`&&this.useRecords,C=S?e=>{S(e)?x(e):b(e)}:x,w=e=>{let n;if(e>16777216){if(e-t>go)throw Error(`Packed buffer would be larger than maximum buffer size`);n=Math.min(go,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,R.length-1)>>12)+1<<12;let r=new mo(n);return vo=r.dataView||=new DataView(r.buffer,0,n),e=Math.min(e,R.length),R.copy?R.copy(r,0,t,e):r.set(R.slice(t,e)),z-=t,t=0,yo=r.length-10,R=r},T=(e,t,i)=>{let a=r.nextId;a||=64,a<f&&this.shouldShareStructure&&!this.shouldShareStructure(t)?(a=r.nextOwnId,a<p||(a=f),r.nextOwnId=a+1):(a>=p&&(a=f),r.nextId=a+1);let o=t.highByte=a>=96&&d?a-96>>5:-1;e[xo]=a,e.__keys__=t,r[a-64]=t,a<f?(t.isShared=!0,r.sharedLength=a-63,n=!0,o>=0?(R[z++]=(a&31)+96,R[z++]=o):R[z++]=a):(o>=0?(R[z++]=213,R[z++]=114,R[z++]=(a&31)+96,R[z++]=o):(R[z++]=212,R[z++]=114,R[z++]=a),i&&(h+=g*i),m.length>=u&&(m.shift()[xo]=0),m.push(e),y(t))},E=(e,n,r,i)=>{let a=R,o=z,s=yo,c=t;R=_o,z=0,t=0,R||(_o=R=new mo(8192)),yo=R.length-10,T(e,n,i),_o=R;let l=z;if(R=a,z=o,yo=s,t=c,l>1){let e=z+l-1;e>yo&&w(e);let n=r+t;R.copyWithin(n+l,n+1,z),R.set(_o.slice(0,l),n),z=e}else R[r+t]=_o[0]},D=e=>{let i=Die(e,R,t,z,r,w,(e,t,r)=>{if(r)return n=!0;z=t;let i=R;return y(e),_(),i===R?z:{position:z,targetView:vo,target:R}},this);if(i===0)return C(e);z=i}}useBuffer(e){R=e,R.dataView||(R.dataView=new DataView(R.buffer,R.byteOffset,R.byteLength)),vo=R.dataView,z=0}set position(e){z=e}get position(){return z}clearSharedData(){this.structures&&=[],this.typedStructs&&=[]}};fo=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,ka],uo=[{pack(e,t,n){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:e,targetView:n,position:i}=t(6);e[i++]=214,e[i++]=255,n.setUint32(i,r)}else if(r>0&&r<4294967296){let{target:n,targetView:i,position:a}=t(10);n[a++]=215,n[a++]=255,i.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),n(this.onInvalidDate());let{target:e,targetView:r,position:i}=t(3);e[i++]=212,e[i++]=255,e[i++]=255}else{let{target:n,targetView:i,position:a}=t(15);n[a++]=199,n[a++]=12,n[a++]=255,i.setUint32(a,e.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,n){if(this.setAsEmptyObject)return t(0),n({});let r=Array.from(e),{target:i,position:a}=t(this.moreTypes?3:0);this.moreTypes&&(i[a++]=212,i[a++]=115,i[a++]=0),n(r)}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=101,r[i++]=0),n([e.name,e.message,e.cause])}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=120,r[i++]=0),n([e.source,e.flags])}},{pack(e,t){this.moreTypes?So(e,16,t):Co(po?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let n=e.constructor;n!==ho&&this.moreTypes?So(e,io.indexOf(n.name),t):Co(e,t)}},{pack(e,t){this.moreTypes?So(e,17,t):Co(po?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:n,position:r}=t(1);n[r]=193}}];function So(e,t,n,r){let i=e.byteLength;if(i+1<256){var{target:a,position:o}=n(4+i);a[o++]=199,a[o++]=i+1}else if(i+1<65536){var{target:a,position:o}=n(5+i);a[o++]=200,a[o++]=i+1>>8,a[o++]=i+1&255}else{var{target:a,position:o,targetView:s}=n(7+i);a[o++]=201,s.setUint32(o,i+1),o+=4}a[o++]=116,a[o++]=t,e.buffer||(e=new Uint8Array(e)),a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),o)}function Co(e,t){let n=e.byteLength;var r,i;if(n<256){var{target:r,position:i}=t(n+2);r[i++]=196,r[i++]=n}else if(n<65536){var{target:r,position:i}=t(n+3);r[i++]=197,r[i++]=n>>8,r[i++]=n&255}else{var{target:r,position:i,targetView:a}=t(n+5);r[i++]=198,a.setUint32(i,n),i+=4}r.set(e,i)}function wo(e,t,n,r){let i=e.length;switch(i){case 1:t[n++]=212;break;case 2:t[n++]=213;break;case 4:t[n++]=214;break;case 8:t[n++]=215;break;case 16:t[n++]=216;break;default:i<256?(t[n++]=199,t[n++]=i):i<65536?(t[n++]=200,t[n++]=i>>8,t[n++]=i&255):(t[n++]=201,t[n++]=i>>24,t[n++]=i>>16&255,t[n++]=i>>8&255,t[n++]=i&255)}return t[n++]=r,t.set(e,n),n+=i,n}function jie(e,t){let n,r=t.length*6,i=e.length-r;for(;n=t.pop();){let t=n.offset,a=n.id;e.copyWithin(t+r,t,i),r-=6;let o=t+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,i=t}return e}function To(e,t,n){if(bo.length>0){vo.setUint32(bo.position+e,z+n-bo.position-e),bo.stringsPosition=z-e;let r=bo;bo=null,t(r[0]),t(r[1])}}function Mie(e,t){return e.isCompatible=e=>{let n=!e||(t.lastNamedStructuresLength||0)===e.length;return n||t._mergeStructures(e),n},e}var Eo=new Aie({useRecords:!1});Eo.pack,Eo.pack;var{NEVER:Nie,ALWAYS:Pie,DECIMAL_ROUND:Fie,DECIMAL_FIT:Iie}=Eie,Do=class extends Dt()(`effect/rpc/RpcSerialization`){},Lie=Do.of({contentType:`application/json`,includesFraming:!1,makeUnsafe:()=>{let e=new TextDecoder;return{decode:t=>{let n=JSON.parse(typeof t==`string`?t:e.decode(t));return Array.isArray(n)?n:[n]},encode:e=>JSON.stringify(e)}}}),Oo=pe(Do)(Lie),Rie=e=>Et(()=>{let t=new Set,n=new Map,r=new Map,i=(e,t)=>ie(r=>{let i=n.get(e);return i||(i=[],n.set(e,i)),i.push([t,r]),nt});return Ye(e((e,t)=>{let n=r.get(e);return n?n(t):i(e,t)},t),e=>({...e,run(e,i){return tt(function*(){t.add(e),r.set(e,i);let a=n.get(e);if(a){n.delete(e);for(let[e,t]of a)yield*Ce(Et(()=>i(e)),t)}return yield*iee(w,()=>(t.delete(e),r.delete(e),nt))})}}))}),zie=BigInt(0),Bie=Je(function*(e,t){let n=t?.spanPrefix??`RpcClient`,r=t?.supportsAck??!0,i=t?.disableTracing??!1,a=t?.generateRequestId??(()=>zie++),o=yield*wt(),s=kt(o,Ae),c=new Map,l=!1;yield*Rt(s,Mt(e=>(l=!0,u(Ree(e.id)))));let u=Je(function*(e){for(let[t,n]of c)c.delete(t),n._tag===`Queue`?yield*e._tag===`Success`?Nt(n.queue):Ne(n.queue,e.cause):n.resume(e)}),d=e=>{let r=une(e.successSchema),a=g(e);return(o,s)=>{let c=s?.headers?gn(s.headers):dn,l=s?.context??Kee();if(!r){let r=t=>p(e,a,t,e.payloadSchema.make(o),c,l,s?.discard??!1);return i?r(void 0):it(`${n}.${e._tag}`,{attributes:t.spanAttributes},r)}let u=m(e,a,e.payloadSchema.make(o),c,s?.streamBufferSize??16,l);return s?.asQueue?u:ute(Ye(u,nte))}},p=(e,n,r,i,o,s,u)=>Mt(d=>{if(l)return _t;let f=a(),p=n(e=>t.onFromClient({message:e,context:s,discard:u}),{_tag:`Request`,id:f,tag:e._tag,payload:i,...r?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{},headers:Qt(d.getRef(jo),o)});if(u)return p;let m;return ft(Ie(t=>{let n={_tag:`Effect`,rpc:e,context:s,resume(e){t(e),m&&!m.pollUnsafe()&&d.currentDispatcher.scheduleTask(()=>{m.interruptUnsafe(d.id)},0)}};c.set(f,n),m=p.pipe(r?It(r,{captureStackTrace:!1}):we,Ve(d.context)),m.addObserver(e=>{if(e._tag===`Failure`)return t(e)})}),e=>(c.delete(f),Lt(aee(m),_(f,Array.from(e),s))))}),m=Je(function*(e,r,o,s,u,d){if(l)return yield*_t;let p=i?void 0:yield*mte(`${n}.${e._tag}`,{attributes:t.spanAttributes}),m=xe(),g=a(),v=Pee(m.context,Ae);yield*f(v,e=>c.has(g)?(c.delete(g),_(g,vt(e)?Array.from(Eee(e.cause)):[],d)):nt);let y=yield*h(u);return c.set(g,{_tag:`Queue`,rpc:e,queue:y,scope:v,context:d}),yield*r(e=>t.onFromClient({message:e,context:d,discard:!1}),{_tag:`Request`,id:g,tag:e._tag,payload:o,...p?{traceId:p.traceId,spanId:p.spanId,sampled:p.sampled}:{},headers:Qt(m.getRef(jo),s)}).pipe(p?It(p,{captureStackTrace:!1}):we,He(e=>Ne(y,e)),ot,jt(v,{startImmediately:!0})),y}),g=e=>{let t=[];for(let n of e.middlewares.values()){let e=o.mapUnsafe.get(`${n.key}/Client`);e&&t.push(e)}return t.length===0?(e,t)=>e(t):function n(r,i,a=t.length-1){return a===-1?r(i):t[a]({rpc:e,request:i,next(e){return n(r,e,a-1)}})}},_=(e,n,r)=>Ie(i=>{let a=xe();t.onFromClient({message:{_tag:`Interrupt`,requestId:e,interruptors:n},context:r,discard:!1}).pipe(Xe(1e3),Ve(a.context)).addObserver(()=>{i(nt)})}),v=e=>{switch(e._tag){case`Chunk`:{let n=e.requestId,i=c.get(n);return!i||i._tag!==`Queue`?nt:tee(i.queue,e.values).pipe(r?yt(()=>t.onFromClient({message:{_tag:`Ack`,requestId:e.requestId},context:i.context,discard:!1})):we,He(e=>Ne(i.queue,e)))}case`Exit`:{let t=e.requestId,n=c.get(t);return n?(c.delete(t),n._tag===`Effect`?(n.resume(e.exit),nt):e.exit._tag===`Success`?Nt(n.queue):Ne(n.queue,e.exit.cause)):nt}case`Defect`:return u(vee(e.defect));case`ClientEnd`:return nt}},y;if(t.flatten){let t=new Map;y=function(n,r,i){let a=t.get(n);return a||(a=d(e.requests.get(n)),t.set(n,a)),a(r,i)}}else y={},e.requests.forEach(e=>{y[e._tag]=d(e)});return{client:y,write:v}}),Vie=0,ko=Je(function*(e,t){let n=Vie++,{run:r,send:i,supportsAck:a,supportsTransferables:o}=yield*Mo,s=new Map,{client:c,write:u}=yield*Bie(e,{...t,supportsAck:a,onFromClient({message:t}){switch(t._tag){case`Request`:{let r=e.requests.get(t.tag),a=o?pie():void 0,c=xe(),u={rpc:r,context:a?Nee(c.context,ca,a):c.context,schemas:Hie(r)};return s.set(t.id,u),u.schemas.encodePayload(t.payload).pipe(Ce(u.context),l,yt(e=>i(n,{...t,id:String(t.id),payload:e,headers:Object.entries(t.headers)},a&&a.readUnsafe())))}case`Ack`:return s.get(t.requestId)?i(n,{_tag:`Ack`,requestId:String(t.requestId)}):nt;case`Interrupt`:return s.get(t.requestId)?(s.delete(t.requestId),i(n,{_tag:`Interrupt`,requestId:String(t.requestId)})):nt;case`Eof`:return nt}}});return yield*r(n,e=>{switch(e._tag){case`Chunk`:{let t=pa(e.requestId),n=s.get(t);return!n||ste(n.schemas.decodeChunk)?nt:n.schemas.decodeChunk.value(e.values).pipe(Ce(n.context),l,yt(t=>u({_tag:`Chunk`,clientId:0,requestId:pa(e.requestId),values:t})),b(t=>u({_tag:`Exit`,clientId:0,requestId:pa(e.requestId),exit:De(t)})))}case`Exit`:{let t=pa(e.requestId),n=s.get(t);return n?(s.delete(t),n.schemas.decodeExit(e.exit).pipe(Ce(n.context),l,Fe({onSuccess:e=>u({_tag:`Exit`,clientId:0,requestId:t,exit:e}),onFailure:e=>u({_tag:`Exit`,clientId:0,requestId:t,exit:De(e)})}))):nt}case`Defect`:return u({_tag:`Defect`,clientId:0,defect:Kie(e.defect)});case`ClientProtocolError`:{let t=xee(e.error);return Ot(s.keys(),e=>u({_tag:`Exit`,clientId:0,requestId:e,exit:t}))}default:return nt}}).pipe(He(ote),ot,Qe),c}),Ao=new WeakMap,Hie=e=>{let t=Ao.get(e);if(t!==void 0)return t;let n=Ote(e.successSchema);return t={decodeChunk:Wee(n,e=>_n(mn(pne(e.success)))),encodePayload:Yte(mn(e.payloadSchema)),decodeExit:_n(mn(dne(e)))},Ao.set(e,t),t},jo=bt(`effect/rpc/RpcClient/CurrentHeaders`,{defaultValue:()=>dn}),Mo=class extends Dt()(`effect/rpc/RpcClient/Protocol`){static make=Rie},No=e=>Mo.make(Je(function*(t,n){let i=yield*$i,a=yield*Do,o=yield*oee(Gie),s=new Map,c=yield*i.writer,d=a.makeUnsafe(),f=yield*Wie(c(d.encode(yie))),p,m=Et(()=>(p=void 0,x(o)?o.value.onConnect:nt)),h=e=>Ot(n,n=>t(n,e));return yield*Et(()=>(d=a.makeUnsafe(),f.reset(),i.runRaw(e=>{try{let n=d.decode(e);if(n.length===0)return;let r=0;return Tee({while:()=>r<n.length,body:()=>{let e=n[r++];if(e._tag===`Pong`)return f.onPong(),nt;if(`requestId`in e){let n=s.get(e.requestId);if(n!==void 0)return e._tag===`Exit`&&s.delete(e.requestId),t(n,e)}return h(e)},step:Vee})}catch(e){return h({_tag:`ClientProtocolError`,error:new fa({reason:new da({message:`Error decoding message`,cause:e})})})}},{onOpen:m}).pipe(O(yt(f.timeout,()=>r(new aa({reason:new na({kind:`Timeout`,cause:Error(`ping timeout`)})}))))))).pipe(yt(()=>r(new aa({reason:new ra({code:1e3})}))),x(o)?Ge(o.value.onDisconnect):we,Xee(t=>{let n=zee(t),r=Yee(n);return e?.retryTransientErrors&&r&&n.success.reason._tag===`SocketOpenError`?nt:(p=new fa({reason:r?n.success.reason:new da({message:`Unknown socket error`,cause:Pe(t)})}),h({_tag:`ClientProtocolError`,error:p}))}),he(e?.retryPolicy??Uie),u({module:`RpcClient`,method:`makeProtocolSocket`}),Qe),{send(e,t){if(p)return r(p);t._tag===`Request`&&s.set(t.id,e);let n=d.encode(t);return n===void 0?nt:l(c(n))},supportsAck:!0,supportsTransferables:!1}})),Uie=_(500,1.5).pipe(cee(ree(5e3))),Wie=Je(function*(e){let t=!0,n=0,r=ct();return yield*Et(()=>t?(t=!1,n=0,e):(n+=1,n>=3?r.open:e)).pipe(yee(`5 seconds`),Ct,Ze,ot,Qe),{timeout:r.await,reset:()=>{t=!0,n=0,r.closeUnsafe()},onPong:()=>{t=!0,n=0}}}),Gie=class extends Dt()(`effect/rpc/RpcClient/ConnectionHooks`){},Kie=Dn(In);function Po(e){return{id:e.id??`ws:${e.label}`,label:e.label,source:e.source??`manual`,target:e.target}}function qie(e){return e?.target.wsBaseUrl??null}function Jie(e){return e?.target.httpBaseUrl??null}function Yie(e,t){return{...e,environmentId:t.environmentId,label:t.label}}function Xie(e){return e.cloudMode?`cmmd-cloud-runtime`:`local-web`}function Zie(e){let t=Xie(e);return{topology:t,controlPlane:t!==`cmmd-cloud-runtime`,executionPlane:!0,workspaceProxy:!1}}function Qie(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 $ie(e){let t=e.executionPlane;return{agents:t,browser:t,github:t,terminal:t,providerEgress:e.topology===`cmmd-control-plane`}}function eae(e,t){return{localProjects:t.executionPlane,cloudProjects:e.cloudMode}}function Fo(e){let t=e.capabilities,n=t.runtime??Zie(t);return{repositoryIdentity:t.repositoryIdentity,pullRequests:t.pullRequests??!1,cloudMode:t.cloudMode,posthogPublicKey:t.posthogPublicKey,posthogHost:t.posthogHost,runtime:n,auth:t.auth??Qie(n),tools:t.tools??$ie(n),projects:t.projects??eae(t,n)}}function tae(e){return e?Fo(e).projects.cloudProjects:!1}function nae(e){return e?Fo(e).runtime.workspaceProxy??!1:!1}function Io(e,t){return{environmentId:e,projectId:t}}function Lo(e,t){return{environmentId:e,threadId:t}}var Ro=`scoped:v1:`;function zo(e){let t=`projectId`in e?e.projectId:e.threadId;return t.includes(`:`)||e.environmentId.startsWith(Ro)?`${Ro}${encodeURIComponent(e.environmentId)}:${encodeURIComponent(t)}`:`${e.environmentId}:${t}`}function Bo(e){return zo(e)}function Vo(e){return zo(e)}function rae(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 Ho(e){if(e.startsWith(Ro))return rae(e);let t=e.lastIndexOf(`:`);return t<=0||t>=e.length-1?null:{environmentId:e.slice(0,t),localId:e.slice(t+1)}}function Uo(e){let t=Ho(e);return t?{environmentId:t.environmentId,projectId:t.localId}:null}function Wo(e){let t=Ho(e);return t?{environmentId:t.environmentId,threadId:t.localId}:null}var iae=1e3,aae=64e3;ko(Hn);function oae(e){return!Number.isInteger(e)||e<0||e>=10?null:Math.min(Math.round(iae*2**e),aae)}var Go=class extends Error{code;retryable;name=`RelayProtocolFailure`;constructor(e,t,n){super(t),this.code=e,this.retryable=n}};function Ko(e){return Array.isArray(e)?e.map(Ko):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,Ko(t)])):e}function sae(e){let t=JSON.stringify(Ko(e));if(t===void 0)throw Error(`Relay payload is not JSON serializable.`);return t}var cae={requestId:`@effect/rpc/Ping`,correlationId:`@effect/rpc/Ping`,method:`@effect/rpc/Ping`,requiredScope:null,deliveryClass:`read`,journalPersistence:`none`};function lae(e){return e._tag===`Ping`?cae:null}function uae(e){if(e.policy===null||e.policy.method!==e.method)throw new Go(`method_not_remotable`,`Relay method has no exact dispatch policy: ${e.method}`,!1);if(e.policy.requiredScope!==null&&!e.grantedScopes.includes(e.policy.requiredScope))throw new Go(`scope_denied`,`Relay method ${e.method} requires scope ${e.policy.requiredScope}`,!1);return{requiredScope:e.policy.requiredScope,deliveryClass:e.policy.deliveryClass,journalPersistence:e.policy.journalPersistence}}function dae(e){let t=new Set(e.registeredMethods),n=new Map;for(let r of e.policies){if(n.has(r.method))throw new Go(`method_not_remotable`,`Relay method has duplicate dispatch policies: ${r.method}`,!1);if(!t.has(r.method))throw new Go(`method_not_remotable`,`Relay dispatch policy targets an unregistered method: ${r.method}`,!1);if((r.deliveryClass===`idempotent-command`||r.deliveryClass===`create-command`)==(r.journalPersistence===`none`))throw new Go(`method_not_remotable`,`Relay dispatch policy has incompatible journal persistence: ${r.method}`,!1);n.set(r.method,r)}for(let t of e.registeredMethods)if(!n.has(t))throw new Go(`method_not_remotable`,`Remotely registered method has no dispatch policy: ${t}`,!1);return n}var fae=[{method:M.projectsSearchEntries,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.projectsListEntries,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.serverDiscoverSourceControl,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.serverReportClientActivity,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.codeGraphSummary,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.codeGraphNeighborhood,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.codeGraphSearch,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.projectsWriteFile,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.projectCheckoutDeletionPreview,requiredScope:`workspace.write`,deliveryClass:`read`},{method:M.projectCheckoutDeletionExecute,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.workspaceReadFile,requiredScope:`workspace.read`,deliveryClass:`bulk-transfer`},{method:M.workspaceBeginWriteFile,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.workspaceWriteFileChunk,requiredScope:`workspace.write`,deliveryClass:`bulk-transfer`},{method:M.workspaceCommitWriteFile,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.workspaceCancelWriteFile,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.shellOpenInEditor,requiredScope:`shell.open`,deliveryClass:`idempotent-command`},{method:M.gitPull,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitRefreshStatus,requiredScope:`git.read`,deliveryClass:`read`},{method:M.gitRunStackedAction,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitListBranches,requiredScope:`git.read`,deliveryClass:`read`},{method:M.vcsListRefs,requiredScope:`git.read`,deliveryClass:`read`},{method:M.vcsRefreshStatus,requiredScope:`git.read`,deliveryClass:`read`},{method:M.vcsPull,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.vcsCreateWorktree,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.vcsRemoveWorktree,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.vcsCreateRef,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.vcsSwitchRef,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.vcsInit,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitCreateWorktree,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.gitRemoveWorktree,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitCreateBranch,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.gitCheckout,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitInit,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitResolvePullRequest,requiredScope:`git.read`,deliveryClass:`read`},{method:M.gitPreparePullRequestThread,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.terminalOpen,requiredScope:`terminal.write`,deliveryClass:`create-command`},{method:M.terminalAttach,requiredScope:`terminal.write`,deliveryClass:`terminal-output`},{method:M.terminalWrite,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalResize,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalSignal,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalClear,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalRestart,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalClose,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.browserOpenSession,requiredScope:`browser.control`,deliveryClass:`create-command`},{method:M.browserListSessions,requiredScope:`browser.read`,deliveryClass:`read`},{method:M.browserCloseSession,requiredScope:`browser.control`,deliveryClass:`browser-control`},{method:M.browserGetSession,requiredScope:`browser.read`,deliveryClass:`read`},{method:M.browserCommand,requiredScope:`browser.control`,deliveryClass:`browser-control`},{method:M.browserClearBrowsingData,requiredScope:`browser.control`,deliveryClass:`browser-control`},{method:M.browserAttachDisplay,requiredScope:`browser.read`,deliveryClass:`subscription`},{method:M.computerInput,requiredScope:`browser.control`,deliveryClass:`browser-control`},{method:M.browserAddDisplayIceCandidate,requiredScope:`browser.read`,deliveryClass:`browser-control`},{method:M.devTunnelRegister,requiredScope:`browser.control`,deliveryClass:`idempotent-command`},{method:M.devTunnelUnregister,requiredScope:`browser.control`,deliveryClass:`idempotent-command`},{method:M.devTunnelList,requiredScope:`browser.read`,deliveryClass:`read`},{method:M.threadDevRuntimeGet,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.threadDevRuntimeAllocatePort,requiredScope:`runtime.manage`,deliveryClass:`idempotent-command`},{method:M.threadDevRuntimeRelease,requiredScope:`runtime.manage`,deliveryClass:`idempotent-command`},{method:M.workspaceEnvironmentPreflight,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.workspaceEnsureScratch,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.serverGetConfig,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.serverRefreshProviders,requiredScope:`provider.read`,deliveryClass:`read`},{method:M.serverStartProviderAuth,requiredScope:`provider.manage`,deliveryClass:`create-command`},{method:M.serverRepairProviderAuthRuntime,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverDisconnectProviderAuth,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverGetProviderAuthSession,requiredScope:`provider.read`,deliveryClass:`read`},{method:M.serverCancelProviderAuth,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverSubmitProviderAuthCode,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverSyncPersonalCodexToCloud,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverSyncPersonalClaudeToCloud,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverUpsertKeybinding,requiredScope:`settings.write`,deliveryClass:`idempotent-command`},{method:M.serverRemoveKeybinding,requiredScope:`settings.write`,deliveryClass:`idempotent-command`},{method:M.serverGetSettings,requiredScope:`settings.read`,deliveryClass:`read`},{method:M.serverUpdateSettings,requiredScope:`settings.write`,deliveryClass:`idempotent-command`},{method:M.serverUpdateEnvironmentDisplayName,requiredScope:`settings.write`,deliveryClass:`idempotent-command`},{method:M.serverGetTraceDiagnostics,requiredScope:`settings.read`,deliveryClass:`read`},{method:M.serverHeartbeat,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.usageGetSummary,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.pullRequestsList,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsListStats,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsDetail,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsActivity,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsThreadComments,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsDiffFileContents,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsRunAction,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsUpdate,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsComment,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.pullRequestsUpdateComment,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsSubmitReview,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.pullRequestsReplyToThread,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.pullRequestsSetThreadResolution,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsSetReaction,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsInvalidate,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsReviewerCandidates,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsRequestReviewers,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.subscribeGitStatus,requiredScope:`git.read`,deliveryClass:`subscription`},{method:M.subscribeVcsStatus,requiredScope:`git.read`,deliveryClass:`subscription`},{method:M.subscribeTerminalEvents,requiredScope:`terminal.read`,deliveryClass:`terminal-output`},{method:M.subscribeTerminalMetadata,requiredScope:`terminal.read`,deliveryClass:`read`},{method:M.subscribeBrowserEvents,requiredScope:`browser.read`,deliveryClass:`browser-frame`},{method:M.subscribeServerConfig,requiredScope:`runtime.read`,deliveryClass:`subscription`},{method:M.subscribeServerLifecycle,requiredScope:`runtime.read`,deliveryClass:`subscription`},{method:M.subscribeAuthAccess,requiredScope:`provider.read`,deliveryClass:`subscription`},{method:M.subscribeWorkspaceReadiness,requiredScope:`runtime.read`,deliveryClass:`subscription`},{method:sn.dispatchCommand,requiredScope:null,deliveryClass:`idempotent-command`},{method:sn.getTurnDiff,requiredScope:`diff.read`,deliveryClass:`read`},{method:sn.getFullThreadDiff,requiredScope:`diff.read`,deliveryClass:`read`},{method:sn.streamTurnDiff,requiredScope:`diff.read`,deliveryClass:`bulk-transfer`},{method:sn.streamFullThreadDiff,requiredScope:`diff.read`,deliveryClass:`bulk-transfer`},{method:sn.replayEvents,requiredScope:`thread.read`,deliveryClass:`subscription`},{method:sn.subscribeShell,requiredScope:`thread.read`,deliveryClass:`subscription`},{method:sn.subscribeThread,requiredScope:`thread.read`,deliveryClass:`subscription`}],pae=new Set([M.gitPull,M.gitRunStackedAction,M.gitCreateWorktree,M.gitRemoveWorktree,M.gitCreateBranch,M.gitCheckout,M.gitInit,M.gitPreparePullRequestThread,M.threadDevRuntimeAllocatePort,M.threadDevRuntimeRelease,M.serverUpsertKeybinding,M.serverRemoveKeybinding,M.serverUpdateEnvironmentDisplayName,sn.dispatchCommand]),mae=fae.map(e=>{let t=e.deliveryClass===`idempotent-command`||e.deliveryClass===`create-command`;return{method:e.method,requiredScope:e.requiredScope,deliveryClass:e.deliveryClass,journalPersistence:t?pae.has(e.method)?`frame`:`metadata-only`:`none`}}),hae=dae({registeredMethods:[...Hn.requests.keys()],policies:mae}),qo={"project.create":{requiredScope:`project.write`,deliveryClass:`create-command`},"project.meta.update":{requiredScope:`project.write`,deliveryClass:`idempotent-command`},"project.delete":{requiredScope:`project.write`,deliveryClass:`idempotent-command`},"thread.create":{requiredScope:`thread.create`,deliveryClass:`create-command`},"thread.delete":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.archive":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.settle":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.unsettle":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.unarchive":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.meta.update":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.runtime-mode.set":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.interaction-mode.set":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.turn.start":{requiredScope:`turn.dispatch`,deliveryClass:`create-command`},"thread.turn.interrupt":{requiredScope:`turn.stop`,deliveryClass:`idempotent-command`},"thread.approval.respond":{requiredScope:`approval.respond`,deliveryClass:`idempotent-command`},"thread.user-input.respond":{requiredScope:`approval.respond`,deliveryClass:`idempotent-command`},"thread.checkpoint.revert":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.session.stop":{requiredScope:`turn.stop`,deliveryClass:`idempotent-command`},"thread.plan-approval.respond":{requiredScope:`approval.respond`,deliveryClass:`idempotent-command`}},gae=new Set([`thread.approval.respond`,`thread.user-input.respond`,`thread.plan-approval.respond`]);function _ae(e){if(e.method!==sn.dispatchCommand||!e.payload||typeof e.payload!=`object`||Array.isArray(e.payload))return null;let t=e.payload;if(typeof t.type!=`string`||!gae.has(t.type))return null;let n=t.type===`thread.plan-approval.respond`?t.promptId:t.requestId;if(typeof t.commandId!=`string`||t.commandId.length===0||typeof n!=`string`||n.length===0)throw new Go(`action_grant_invalid`,`Relay sensitive action metadata is incomplete`,!1);return{commandType:t.type,commandId:t.commandId,targetId:n}}function Jo(e){let t=hae.get(e.method)??null,n=uae({method:e.method,grantedScopes:e.grantedScopes,policy:t});if(e.method!==sn.dispatchCommand)return n;if(!e.payload||typeof e.payload!=`object`||!(`type`in e.payload))throw new Go(`method_not_remotable`,`Relay orchestration dispatch payload has no command policy`,!1);let r=e.payload.type;if(typeof r!=`string`||!(r in qo))throw new Go(`method_not_remotable`,`Relay orchestration command has no dispatch policy: ${String(r)}`,!1);let i=qo[r];if(!e.grantedScopes.includes(i.requiredScope))throw new Go(`scope_denied`,`Relay orchestration command ${r} requires scope ${i.requiredScope}`,!1);return{requiredScope:i.requiredScope,deliveryClass:i.deliveryClass,journalPersistence:n.journalPersistence}}var Yo=class extends Error{constructor(e){let t;t=e instanceof Error?e.message:typeof e==`string`?e:``,super(t),this.name=this.constructor.name}},Xo=class extends Yo{},Zo=class extends Yo{},Qo=class extends Yo{},vae=class extends Yo{},yae=class extends Yo{},bae=class extends Yo{},xae=class extends Yo{},Sae=class extends Yo{},Cae=class extends Yo{},wae=class extends Yo{},$o=class extends Yo{},es=Tae(globalThis,{});function Tae(e,t){return new Proxy(e,{get(n,r,i){return r in t?t[r]:e[r]},set(n,r,i){return r in t&&delete t[r],e[r]=i,!0},deleteProperty(n,r){let i=!1;return r in t&&(delete t[r],i=!0),r in e&&(delete e[r],i=!0),i},ownKeys(n){let r=Reflect.ownKeys(e),i=Reflect.ownKeys(t),a=new Set(i);return[...r.filter(e=>!a.has(e)),...i]},defineProperty(n,r,i){return r in t&&delete t[r],Reflect.defineProperty(e,r,i),!0},getOwnPropertyDescriptor(n,r){return r in t?Reflect.getOwnPropertyDescriptor(t,r):Reflect.getOwnPropertyDescriptor(e,r)},has(n,r){return r in t||r in e}})}async function Eae(){if(es!==void 0&&globalThis.crypto!==void 0)return globalThis.crypto.subtle;try{let{webcrypto:e}=await N(async()=>{let{webcrypto:e}=await import(`./__vite-browser-external-2W3EstLn.js`).then(e=>t(e.default));return{webcrypto:e}},__vite__mapDeps([0,1]));return e.subtle}catch(e){throw new $o(e)}}var ts=class{constructor(){Object.defineProperty(this,"_api",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}async _setup(){this._api===void 0&&(this._api=await Eae())}},ns={Base:0,Psk:1,Auth:2,AuthPsk:3},Dae={NotAssigned:0,DhkemP256HkdfSha256:16,DhkemP384HkdfSha384:17,DhkemP521HkdfSha512:18,DhkemSecp256k1HkdfSha256:19,DhkemX25519HkdfSha256:32,DhkemX448HkdfSha512:33,HybridkemX25519Kyber768:48,MlKem512:64,MlKem768:65,MlKem1024:66,XWing:25722},rs={HkdfSha256:1,HkdfSha384:2,HkdfSha512:3,Sha3256:4,Sha3384:5,Sha3512:6,Shake128:16,Shake256:17,TurboShake128:18,TurboShake256:19},is={Aes128Gcm:1,Aes256Gcm:2,Chacha20Poly1305:3,ExportOnly:65535},as=new Uint8Array,os=0n,ss=1n,cs=2n,Oae=new Uint8Array([75,69,77,0,0]),ls=new Uint8Array([72,80,75,69,45,118,49]);function us(e){return new Uint8Array(ds(e))}function ds(e){return e instanceof ArrayBuffer?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength).slice().buffer:new Uint8Array(e).slice().buffer}var kae=class extends ts{constructor(){super(),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:rs.HkdfSha256}),Object.defineProperty(this,"hashSize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_suiteId",{enumerable:!0,configurable:!0,writable:!0,value:as}),Object.defineProperty(this,"algHash",{enumerable:!0,configurable:!0,writable:!0,value:{name:`HMAC`,hash:`SHA-256`,length:256}})}init(e){this._suiteId=e}buildLabeledIkm(e,t){this._checkInit();let n=new Uint8Array(7+this._suiteId.byteLength+e.byteLength+t.byteLength);return n.set(ls,0),n.set(this._suiteId,7),n.set(e,7+this._suiteId.byteLength),n.set(t,7+this._suiteId.byteLength+e.byteLength),n}buildLabeledInfo(e,t,n){this._checkInit();let r=new Uint8Array(9+this._suiteId.byteLength+e.byteLength+t.byteLength);return r.set(new Uint8Array([0,n]),0),r.set(ls,2),r.set(this._suiteId,9),r.set(e,9+this._suiteId.byteLength),r.set(t,9+this._suiteId.byteLength+e.byteLength),r}async extract(e,t){await this._setup();let n=e.byteLength===0?new ArrayBuffer(this.hashSize):ds(e);if(n.byteLength!==this.hashSize)throw new Xo(`The salt length must be the same as the hashSize`);let r=ds(t),i=await this._api.importKey(`raw`,n,this.algHash,!1,[`sign`]);return await this._api.sign(`HMAC`,i,r)}async expand(e,t,n){await this._setup();let r=ds(e),i=await this._api.importKey(`raw`,r,this.algHash,!1,[`sign`]),a=new ArrayBuffer(n),o=new Uint8Array(a),s=as,c=us(t),l=new Uint8Array(1);if(n>255*this.hashSize)throw Error(`Entropy limit reached`);let u=new Uint8Array(this.hashSize+c.length+1);for(let e=1,t=0;t<o.length;e++)l[0]=e,u.set(s,0),u.set(c,s.length),u.set(l,s.length+c.length),s=new Uint8Array(await this._api.sign(`HMAC`,i,u.slice(0,s.length+c.length+1))),o.length-t>=s.length?(o.set(s,t),t+=s.length):(o.set(s.slice(0,o.length-t),t),t+=o.length-t);return a}async extractAndExpand(e,t,n,r){await this._setup();let i=ds(t),a=await this._api.importKey(`raw`,i,`HKDF`,!1,[`deriveBits`]);return await this._api.deriveBits({name:`HKDF`,hash:this.algHash.hash,salt:ds(e),info:ds(n)},a,r*8)}async labeledExtract(e,t,n){return await this.extract(e,this.buildLabeledIkm(t,n))}async labeledExpand(e,t,n,r){return await this.expand(e,this.buildLabeledInfo(t,n,r),r)}_checkInit(){if(this._suiteId===as)throw Error(`Not initialized. Call init()`)}},Aae=class extends kae{constructor(){super(...arguments),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:rs.HkdfSha256}),Object.defineProperty(this,"hashSize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"algHash",{enumerable:!0,configurable:!0,writable:!0,value:{name:`HMAC`,hash:`SHA-256`,length:256}})}},fs=e=>typeof e==`object`&&!!e&&typeof e.privateKey==`object`&&typeof e.publicKey==`object`;function ps(e,t){if(t<=0)throw Error(`i2Osp: too small size`);if(e>=256**t)throw Error(`i2Osp: too large integer`);let n=new Uint8Array(t);for(let r=0;r<t&&e;r++)n[t-(r+1)]=e%256,e=Math.floor(e/256);return n}function ms(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}function hs(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}async function jae(){if(es!==void 0&&globalThis.crypto!==void 0)return globalThis.crypto;try{let{webcrypto:e}=await N(async()=>{let{webcrypto:e}=await import(`./__vite-browser-external-2W3EstLn.js`).then(e=>t(e.default));return{webcrypto:e}},__vite__mapDeps([0,1]));return e}catch{throw Error(`failed to load Crypto`)}}function Mae(e,t){if(e.byteLength!==t.byteLength)throw Error(`xor: different length inputs`);let n=new Uint8Array(e.byteLength);for(let r=0;r<e.byteLength;r++)n[r]=e[r]^t[r];return n}var Nae=new Uint8Array([101,97,101,95,112,114,107]),Pae=new Uint8Array([115,104,97,114,101,100,95,115,101,99,114,101,116]);function Fae(e,t,n){let r=new Uint8Array(e.length+t.length+n.length);return r.set(e,0),r.set(t,e.length),r.set(n,e.length+t.length),r}var Iae=class{constructor(e,t,n){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"secretSize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"encSize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"publicKeySize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"privateKeySize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_prim",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_kdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.id=e,this._prim=t,this._kdf=n;let r=new Uint8Array(Oae);r.set(ps(this.id,2),3),this._kdf.init(r)}async serializePublicKey(e){return await this._prim.serializePublicKey(e)}async deserializePublicKey(e){return await this._prim.deserializePublicKey(ds(e))}async serializePrivateKey(e){return await this._prim.serializePrivateKey(e)}async deserializePrivateKey(e){return await this._prim.deserializePrivateKey(ds(e))}async importKey(e,t,n=!0){return await this._prim.importKey(e,t,n)}async generateKeyPair(){return await this._prim.generateKeyPair()}async deriveKeyPair(e){let t=ds(e);if(t.byteLength>8192)throw new Xo(`Too long ikm`);return await this._prim.deriveKeyPair(t)}async encap(e){let t;t=e.ekm===void 0?await this.generateKeyPair():fs(e.ekm)?e.ekm:await this.deriveKeyPair(e.ekm);let n=await this._prim.serializePublicKey(t.publicKey),r=await this._prim.serializePublicKey(e.recipientPublicKey);try{let i;if(e.senderKey===void 0)i=new Uint8Array(await this._prim.dh(t.privateKey,e.recipientPublicKey));else{let n=fs(e.senderKey)?e.senderKey.privateKey:e.senderKey;i=ms(new Uint8Array(await this._prim.dh(t.privateKey,e.recipientPublicKey)),new Uint8Array(await this._prim.dh(n,e.recipientPublicKey)))}let a;if(e.senderKey===void 0)a=ms(new Uint8Array(n),new Uint8Array(r));else{let t=fs(e.senderKey)?e.senderKey.publicKey:await this._prim.derivePublicKey(e.senderKey),i=await this._prim.serializePublicKey(t);a=Fae(new Uint8Array(n),new Uint8Array(r),new Uint8Array(i))}return{enc:n,sharedSecret:await this._generateSharedSecret(i,a)}}catch(e){throw new vae(e)}}async decap(e){let t=ds(e.enc),n=await this._prim.deserializePublicKey(t),r=fs(e.recipientKey)?e.recipientKey.privateKey:e.recipientKey,i=fs(e.recipientKey)?e.recipientKey.publicKey:await this._prim.derivePublicKey(e.recipientKey),a=await this._prim.serializePublicKey(i);try{let i;i=e.senderPublicKey===void 0?new Uint8Array(await this._prim.dh(r,n)):ms(new Uint8Array(await this._prim.dh(r,n)),new Uint8Array(await this._prim.dh(r,e.senderPublicKey)));let o;if(e.senderPublicKey===void 0)o=ms(new Uint8Array(t),new Uint8Array(a));else{let n=await this._prim.serializePublicKey(e.senderPublicKey);o=new Uint8Array(t.byteLength+a.byteLength+n.byteLength),o.set(new Uint8Array(t),0),o.set(new Uint8Array(a),t.byteLength),o.set(new Uint8Array(n),t.byteLength+a.byteLength)}return await this._generateSharedSecret(i,o)}catch(e){throw new yae(e)}}async _generateSharedSecret(e,t){let n=this._kdf.buildLabeledIkm(Nae,e),r=this._kdf.buildLabeledInfo(Pae,t,this.secretSize);return await this._kdf.extractAndExpand(as,n,r,this.secretSize)}},gs=[`deriveBits`],Lae=new Uint8Array([100,107,112,95,112,114,107]),Rae=new Uint8Array([115,107]),_s=class{constructor(e,t,n,r=[]){Object.defineProperty(this,"key",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extractable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"algorithm",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"usages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.key=t,this.type=n,this.algorithm={name:e},this.usages=r,n===`public`&&(this.usages=[])}},zae=class{constructor(e,t,n,r){Object.defineProperty(this,"_algName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_curve",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_hkdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nPk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nSk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._algName=e,this._nPk=t,this._nSk=t,this._curve=n,this._hkdf=r}serializePublicKey(e){try{return Promise.resolve(e.key.buffer)}catch(e){return Promise.reject(new Zo(e))}}async deserializePublicKey(e){try{return await this._importRawKey(ds(e),!0)}catch(e){throw new Qo(e)}}serializePrivateKey(e){try{return Promise.resolve(e.key.buffer)}catch(e){return Promise.reject(new Zo(e))}}async deserializePrivateKey(e){try{return await this._importRawKey(ds(e),!1)}catch(e){throw new Qo(e)}}async importKey(e,t,n){try{if(e===`raw`)return await this._importRawKey(t,n);if(t instanceof ArrayBuffer)throw Error(`Invalid jwk key format`);return await this._importJWK(t,n)}catch(e){throw new Qo(e)}}async generateKeyPair(){try{let e=await this._curve.utils.randomSecretKey(),t=new _s(this._algName,e,`private`,gs);return{publicKey:await this.derivePublicKey(t),privateKey:t}}catch(e){throw new $o(e)}}async deriveKeyPair(e){try{let t=ds(e),n=await this._hkdf.labeledExtract(as.buffer,Lae,new Uint8Array(t)),r=await this._hkdf.labeledExpand(n,Rae,as,this._nSk),i=new _s(this._algName,new Uint8Array(r),`private`,gs);return{privateKey:i,publicKey:await this.derivePublicKey(i)}}catch(e){throw new wae(e)}}derivePublicKey(e){try{let t=this._curve.getPublicKey(e.key);return Promise.resolve(new _s(this._algName,t,`public`))}catch(e){return Promise.reject(new Qo(e))}}dh(e,t){try{return Promise.resolve(this._curve.getSharedSecret(e.key,t.key).buffer)}catch(e){return Promise.reject(new Zo(e))}}_importRawKey(e,t){return new Promise((n,r)=>{t&&e.byteLength!==this._nPk&&r(Error(`Invalid length of the key`)),!t&&e.byteLength!==this._nSk&&r(Error(`Invalid length of the key`)),n(new _s(this._algName,new Uint8Array(e),t?`public`:`private`,t?[]:gs))})}_importJWK(e,t){return new Promise((n,r)=>{e.kty!==`OKP`&&r(Error(`Invalid kty: ${e.kty}`)),e.crv!==this._algName&&r(Error(`Invalid crv: ${e.crv}`)),t?(e.d!==void 0&&r(Error("Invalid key: `d` should not be set")),typeof e.x!=`string`&&r(Error("Invalid key: `x` not found")),n(new _s(this._algName,hs(e.x),`public`))):(typeof e.d!=`string`&&r(Error("Invalid key: `d` not found")),n(new _s(this._algName,hs(e.d),`private`,gs)))})}};function Bae(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function vs(e,t=``){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw Error(`${n}expected integer >0, got ${e}`)}}function ys(e,t,n=``){let r=Bae(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`;throw Error(o+`expected Uint8Array`+s+`, got `+c)}return e}function bs(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function xs(e,t){ys(e,void 0,`digestInto() output`);let n=t.outputLen;if(e.length<n)throw Error(`"digestInto() output" expected to be of length >=`+n)}function Vae(e){if(typeof e==`bigint`){if(!Ms(e))throw Error(`positive bigint expected, got `+e)}else vs(e);return e}function Ss(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Cs(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var Hae=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ws(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ts(e,t){return e<<32-t|e>>>t}var Es=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,Uae=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`)),Wae=[0n,1n,2n,3n,4n,5n,6n,7n,8n,9n,10n,11n,12n,13n,14n,15n];function Gae(e){if(ys(e),Es)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=Uae[e[n]];return t}var Ds={_0:48,_9:57,A:65,F:70,a:97,f:102};function Os(e){if(e>=Ds._0&&e<=Ds._9)return e-Ds._0;if(e>=Ds.A&&e<=Ds.F)return e-(Ds.A-10);if(e>=Ds.a&&e<=Ds.f)return e-(Ds.a-10)}function Kae(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(Es)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=Os(e.charCodeAt(i)),a=Os(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function qae(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);let t=os;for(let n=0;n<e.length;n++){let r=Os(e.charCodeAt(n));if(r===void 0)throw Error(`hex string expected, got non-hex character "`+e[n]+`" at index `+n);t=t<<4n|Wae[r]}return t}function ks(e){vs(e,`numberToBigint`);let t=e,n=os,r=1n;for(;t>0;)t%2==1&&(n+=r),t=Math.floor(t/2),r<<=1n;return n}function As(e){return qae(Gae(js(ys(e)).reverse()))}function Jae(e,t){vs(t),e=Vae(e);let n=Kae(e.toString(16).padStart(t*2,`0`));if(n.length!==t)throw Error(`number too large`);return n}function Yae(e,t){return Jae(e,t).reverse()}function js(e){return Uint8Array.from(e)}function Ms(e){return typeof e==`bigint`&&0n<=e}function Xae(e,t,n){return Ms(e)&&Ms(t)&&Ms(n)&&t<=e&&e<n}function Ns(e,t,n,r){if(!Xae(t,n,r))throw Error(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function Zae(e,t={},n={}){if(!e||typeof e!=`object`)throw Error(`expected valid options object`);function r(t,n,r){let i=e[t];if(r&&i===void 0)return;let a=typeof i;if(a!==n||i===null)throw Error(`param "${t}" is invalid: expected ${n}, got ${a}`)}let i=(e,t)=>Object.entries(e).forEach(([e,n])=>r(e,n,t));i(t,!1),i(n,!0)}async function Qae(e=32){let t=await jae(),n=new Uint8Array(e);return t.getRandomValues(n),n}function $ae(e){return{oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])}}function eoe(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash must wrapped by utils.createHasher`);vs(e.outputLen),vs(e.blockLen)}function toe(e,t={}){let n=(t,n)=>e(n).update(t).digest(),r=e(void 0),i=Object.assign(n,{outputLen:r.outputLen,blockLen:r.blockLen,create:t=>e(t),...t});return Object.freeze(i)}var Ps=class{constructor(e,t){if(Object.defineProperty(this,"oHash",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"iHash",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"blockLen",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputLen",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"finished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),eoe(e),ys(t,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),Cs(r)}update(e){return bs(this),this.iHash.update(e),this}digestInto(e){bs(this),ys(e,this.outputLen,`output`),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Fs=(e,t,n)=>new Ps(e,t).update(n).digest();Fs.create=(e,t)=>new Ps(e,t);function noe(e,t,n){return e&t^~e&n}function roe(e,t,n){return e&t^e&n^t&n}var ioe=class{constructor(e,t,n,r){Object.defineProperty(this,"blockLen",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputLen",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"padOffset",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLE",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"view",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"finished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"length",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"pos",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=ws(this.buffer)}update(e){bs(this),ys(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=ws(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){bs(this),xs(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,Cs(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;n.setBigUint64(r-8,ks(this.length*8),i),this.process(n,0);let o=ws(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen must be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},Is=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),aoe=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ls=new Uint32Array(64),ooe=class extends ioe{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)Ls[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Ls[e-15],n=Ls[e-2],r=Ts(t,7)^Ts(t,18)^t>>>3,i=Ts(n,17)^Ts(n,19)^n>>>10;Ls[e]=i+Ls[e-7]+r+Ls[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=Ts(o,6)^Ts(o,11)^Ts(o,25),u=l+t+noe(o,s,c)+aoe[e]+Ls[e]|0,d=(Ts(n,2)^Ts(n,13)^Ts(n,22))+roe(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){Cs(Ls)}destroy(){this.set(0,0,0,0,0,0,0,0),Cs(this.buffer)}},soe=class extends ooe{constructor(){super(32),Object.defineProperty(this,"A",{enumerable:!0,configurable:!0,writable:!0,value:Is[0]|0}),Object.defineProperty(this,"B",{enumerable:!0,configurable:!0,writable:!0,value:Is[1]|0}),Object.defineProperty(this,"C",{enumerable:!0,configurable:!0,writable:!0,value:Is[2]|0}),Object.defineProperty(this,"D",{enumerable:!0,configurable:!0,writable:!0,value:Is[3]|0}),Object.defineProperty(this,"E",{enumerable:!0,configurable:!0,writable:!0,value:Is[4]|0}),Object.defineProperty(this,"F",{enumerable:!0,configurable:!0,writable:!0,value:Is[5]|0}),Object.defineProperty(this,"G",{enumerable:!0,configurable:!0,writable:!0,value:Is[6]|0}),Object.defineProperty(this,"H",{enumerable:!0,configurable:!0,writable:!0,value:Is[7]|0})}},Rs=toe(()=>new soe,$ae(1));function zs(e,t){let n=e%t;return n>=0n?n:t+n}function Bs(e,t,n){let r=e;for(;t-->os;)r*=r,r%=n;return r}function coe(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}function loe(e){return Zae(e,{adjustScalarBytes:`function`,powPminus2:`function`}),Object.freeze({...e})}function uoe(e){let{P:t,type:n,adjustScalarBytes:r,powPminus2:i,randomBytes:a}=loe(e),o=n===`x25519`;if(!o&&n!==`x448`)throw Error(`invalid type`);let s=a||Qae,c=o?255n:448n,l=o?32:56,u=o?9n:5n,d=o?121665n:39081n,f=o?cs**254n:cs**447n,p=f+(o?8n*cs**251n-ss:4n*cs**445n-ss)+ss,m=e=>zs(e,t),h=g(u);function g(e){return Yae(m(e),l)}function _(e){let t=js(ys(e,l,`uCoordinate`));return o&&(t[31]&=127),m(As(t))}function v(e){return As(r(js(ys(e,l,`scalar`))))}function y(e,t){let n=w(_(t),v(e));if(n===0n)throw Error(`invalid private or public key received`);return g(n)}function b(e){return y(e,h)}let x=b,S=y;function C(e,t,n){let r=m(e*(t-n));return t=m(t-r),n=m(n+r),{x_2:t,x_3:n}}function w(e,n){Ns(`u`,e,os,t),Ns(`scalar`,n,f,p);let r=n,a=e,o=ss,s=os,l=e,u=ss,h=os;for(let e=c-1n;e>=os;e--){let t=r>>e&ss;h^=t,{x_2:o,x_3:l}=C(h,o,l),{x_2:s,x_3:u}=C(h,s,u),h=t;let n=o+s,i=m(n*n),c=o-s,f=m(c*c),p=i-f,g=l+u,_=l-u,v=m(_*n),y=m(g*c),b=v+y,x=v-y;l=m(b*b),u=m(a*m(x*x)),o=m(i*f),s=m(p*(i+m(d*p)))}({x_2:o,x_3:l}=C(h,o,l)),{x_2:s,x_3:u}=C(h,s,u);let g=i(s);return m(o*g)}let T={secretKey:l,publicKey:l,seed:l},E=async e=>(e===void 0&&(e=await s(l)),ys(e,T.seed,`seed`),e),D={randomSecretKey:E};return Object.freeze({keygen:coe(E,x),getSharedSecret:S,getPublicKey:x,scalarMult:y,scalarMultBase:b,utils:D,GuBytes:h.slice(),lengths:T})}function Vs(e){if(typeof e!=`boolean`)throw Error(`boolean expected, not ${e}`)}var doe=(e,t)=>{function n(n,...r){if(ys(n,void 0,`key`),!Hae)throw Error(`Non little-endian hardware is not yet supported`);if(e.nonceLength!==void 0){let t=r[0];ys(t,e.varSizeNonce?void 0:e.nonceLength,`nonce`)}let i=e.tagLength;i&&r[1]!==void 0&&ys(r[1],void 0,`AAD`);let a=t(n,...r),o=(e,t)=>{if(t!==void 0){if(e!==2)throw Error(`cipher output not supported`);ys(t,void 0,`output`)}},s=!1;return{encrypt(e,t){if(s)throw Error(`cannot encrypt() twice with same key + nonce`);return s=!0,ys(e),o(a.encrypt.length,t),a.encrypt(e,t)},decrypt(e,t){if(ys(e),i&&e.length<i)throw Error(`"ciphertext" expected length bigger than tagLength=`+i);return o(a.decrypt.length,t),a.decrypt(e,t)}}}return Object.assign(n,e),n};function foe(e,t){if(typeof t!=`object`||!t)throw Error(`options must be defined`);return Object.assign(e,t)}function poe(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function Hs(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(t.length!==e)throw Error(`"output" expected Uint8Array of length `+e+`, got: `+t.length);if(n&&!hoe(t))throw Error(`invalid output, must be aligned`);return t}function moe(e,t,n){Vs(n);let r=new Uint8Array(16),i=ws(r);return i.setBigUint64(0,ks(t),n),i.setBigUint64(8,ks(e),n),r}function hoe(e){return e.byteOffset%4==0}var Us=e=>Uint8Array.from(e.split(``).map(e=>e.charCodeAt(0))),goe=Us(`expand 16-byte k`),_oe=Us(`expand 32-byte k`),voe=Ss(goe),yoe=Ss(_oe);function Ws(e,t){return e<<t|e>>>32-t}function Gs(e){return e.byteOffset%4==0}var Ks=64,boe=16,qs=2**32-1,Js=Uint32Array.of();function xoe(e,t,n,r,i,a,o,s){let c=i.length,l=new Uint8Array(Ks),u=Ss(l),d=Gs(i)&&Gs(a),f=d?Ss(i):Js,p=d?Ss(a):Js;for(let m=0;m<c;o++){if(e(t,n,r,u,o,s),o>=qs)throw Error(`arx: counter overflow`);let h=Math.min(Ks,c-m);if(d&&h===Ks){let e=m/4;if(m%4!=0)throw Error(`arx: invalid block position`);for(let t=0,n;t<boe;t++)n=e+t,p[n]=f[n]^u[t];m+=Ks;continue}for(let e=0,t;e<h;e++)t=m+e,a[t]=i[t]^l[e];m+=h}}function Soe(e,t){let{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:a,rounds:o}=foe({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=`function`)throw Error(`core must be a function`);return vs(i),vs(o),Vs(a),Vs(n),(t,s,c,l,u=0)=>{ys(t,void 0,`key`),ys(s,void 0,`nonce`),ys(c,void 0,`data`);let d=c.length;if(l===void 0&&(l=new Uint8Array(d)),ys(l,void 0,`output`),vs(u),u<0||u>=qs)throw Error(`arx: counter overflow`);if(l.length<d)throw Error(`arx: output (${l.length}) is shorter than data (${d})`);let f=[],p=t.length,m,h;if(p===32)f.push(m=js(t)),h=yoe;else if(p===16&&n)m=new Uint8Array(32),m.set(t),m.set(t,16),h=voe,f.push(m);else throw ys(t,32,`arx key`),Error(`invalid key size`);Gs(s)||f.push(s=js(s));let g=Ss(m);if(r){if(s.length!==24)throw Error(`arx: extended nonce must be 24 bytes`);r(h,g,Ss(s.subarray(0,16)),g),s=s.subarray(16)}let _=16-i;if(_!==s.length)throw Error(`arx: nonce must be ${_} or 16 bytes`);if(_!==12){let e=new Uint8Array(12);e.set(s,a?0:12-s.length),s=e,f.push(s)}let v=Ss(s);return xoe(e,h,g,v,c,l,u,o),Cs(...f),l}}function Ys(e,t){return e[t++]&255|(e[t++]&255)<<8}var Coe=class{constructor(e){Object.defineProperty(this,"blockLen",{enumerable:!0,configurable:!0,writable:!0,value:16}),Object.defineProperty(this,"outputLen",{enumerable:!0,configurable:!0,writable:!0,value:16}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:new Uint8Array(16)}),Object.defineProperty(this,"r",{enumerable:!0,configurable:!0,writable:!0,value:new Uint16Array(10)}),Object.defineProperty(this,"h",{enumerable:!0,configurable:!0,writable:!0,value:new Uint16Array(10)}),Object.defineProperty(this,"pad",{enumerable:!0,configurable:!0,writable:!0,value:new Uint16Array(8)}),Object.defineProperty(this,"pos",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"finished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),e=js(ys(e,32,`key`));let t=Ys(e,0),n=Ys(e,2),r=Ys(e,4),i=Ys(e,6),a=Ys(e,8),o=Ys(e,10),s=Ys(e,12),c=Ys(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|n<<3)&8191,this.r[2]=(n>>>10|r<<6)&7939,this.r[3]=(r>>>7|i<<9)&8191,this.r[4]=(i>>>4|a<<12)&255,this.r[5]=a>>>1&8190,this.r[6]=(a>>>14|o<<2)&8191,this.r[7]=(o>>>11|s<<5)&8065,this.r[8]=(s>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=Ys(e,16+2*t)}process(e,t,n=!1){let r=n?0:2048,{h:i,r:a}=this,o=a[0],s=a[1],c=a[2],l=a[3],u=a[4],d=a[5],f=a[6],p=a[7],m=a[8],h=a[9],g=Ys(e,t+0),_=Ys(e,t+2),v=Ys(e,t+4),y=Ys(e,t+6),b=Ys(e,t+8),x=Ys(e,t+10),S=Ys(e,t+12),C=Ys(e,t+14),w=i[0]+(g&8191),T=i[1]+((g>>>13|_<<3)&8191),E=i[2]+((_>>>10|v<<6)&8191),D=i[3]+((v>>>7|y<<9)&8191),O=i[4]+((y>>>4|b<<12)&8191),ee=i[5]+(b>>>1&8191),te=i[6]+((b>>>14|x<<2)&8191),k=i[7]+((x>>>11|S<<5)&8191),A=i[8]+((S>>>8|C<<8)&8191),ne=i[9]+(C>>>5|r),j=0,re=j+w*o+5*h*T+5*m*E+5*p*D+5*f*O;j=re>>>13,re&=8191,re+=5*d*ee+5*u*te+5*l*k+5*c*A+5*s*ne,j+=re>>>13,re&=8191;let ie=j+w*s+T*o+5*h*E+5*m*D+5*p*O;j=ie>>>13,ie&=8191,ie+=5*f*ee+5*d*te+5*u*k+5*l*A+5*c*ne,j+=ie>>>13,ie&=8191;let ae=j+w*c+T*s+E*o+5*h*D+5*m*O;j=ae>>>13,ae&=8191,ae+=5*p*ee+5*f*te+5*d*k+5*u*A+5*l*ne,j+=ae>>>13,ae&=8191;let oe=j+w*l+T*c+E*s+D*o+5*h*O;j=oe>>>13,oe&=8191,oe+=5*m*ee+5*p*te+5*f*k+5*d*A+5*u*ne,j+=oe>>>13,oe&=8191;let se=j+w*u+T*l+E*c+D*s+O*o;j=se>>>13,se&=8191,se+=5*h*ee+5*m*te+5*p*k+5*f*A+5*d*ne,j+=se>>>13,se&=8191;let ce=j+w*d+T*u+E*l+D*c+O*s;j=ce>>>13,ce&=8191,ce+=ee*o+5*h*te+5*m*k+5*p*A+5*f*ne,j+=ce>>>13,ce&=8191;let le=j+w*f+T*d+E*u+D*l+O*c;j=le>>>13,le&=8191,le+=ee*s+te*o+5*h*k+5*m*A+5*p*ne,j+=le>>>13,le&=8191;let ue=j+w*p+T*f+E*d+D*u+O*l;j=ue>>>13,ue&=8191,ue+=ee*c+te*s+k*o+5*h*A+5*m*ne,j+=ue>>>13,ue&=8191;let de=j+w*m+T*p+E*f+D*d+O*u;j=de>>>13,de&=8191,de+=ee*l+te*c+k*s+A*o+5*h*ne,j+=de>>>13,de&=8191;let fe=j+w*h+T*m+E*p+D*f+O*d;j=fe>>>13,fe&=8191,fe+=ee*u+te*l+k*c+A*s+ne*o,j+=fe>>>13,fe&=8191,j=(j<<2)+j|0,j=j+re|0,re=j&8191,j>>>=13,ie+=j,i[0]=re,i[1]=ie,i[2]=ae,i[3]=oe,i[4]=se,i[5]=ce,i[6]=le,i[7]=ue,i[8]=de,i[9]=fe}finalize(){let{h:e,pad:t}=this,n=new Uint16Array(10),r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=8191;e[0]+=r*5,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,n[0]=e[0]+5,r=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+r,r=n[t]>>>13,n[t]&=8191;n[9]-=8192;let i=(r^1)-1;for(let e=0;e<10;e++)n[e]&=i;i=~i;for(let t=0;t<10;t++)e[t]=e[t]&i|n[t];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let a=e[0]+t[0];e[0]=a&65535;for(let n=1;n<8;n++)a=(e[n]+t[n]|0)+(a>>>16)|0,e[n]=a&65535;Cs(n)}update(e){bs(this),ys(e),e=js(e);let{buffer:t,blockLen:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(n-this.pos,r-i);if(a===n){for(;n<=r-i;i+=n)this.process(e,i);continue}t.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){Cs(this.h,this.r,this.buffer,this.pad)}digestInto(e){bs(this),xs(e,this),this.finished=!0;let{buffer:t,h:n}=this,{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let t=0;t<8;t++)e[i++]=n[t]>>>0,e[i++]=n[t]>>>8;return e}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}};function woe(e){let t=(t,n)=>e(n).update(t).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}var Toe=woe(e=>new Coe(e));function Eoe(e,t,n,r,i,a=20){let o=e[0],s=e[1],c=e[2],l=e[3],u=t[0],d=t[1],f=t[2],p=t[3],m=t[4],h=t[5],g=t[6],_=t[7],v=i,y=n[0],b=n[1],x=n[2],S=o,C=s,w=c,T=l,E=u,D=d,O=f,ee=p,te=m,k=h,A=g,ne=_,j=v,re=y,ie=b,ae=x;for(let e=0;e<a;e+=2)S=S+E|0,j=Ws(j^S,16),te=te+j|0,E=Ws(E^te,12),S=S+E|0,j=Ws(j^S,8),te=te+j|0,E=Ws(E^te,7),C=C+D|0,re=Ws(re^C,16),k=k+re|0,D=Ws(D^k,12),C=C+D|0,re=Ws(re^C,8),k=k+re|0,D=Ws(D^k,7),w=w+O|0,ie=Ws(ie^w,16),A=A+ie|0,O=Ws(O^A,12),w=w+O|0,ie=Ws(ie^w,8),A=A+ie|0,O=Ws(O^A,7),T=T+ee|0,ae=Ws(ae^T,16),ne=ne+ae|0,ee=Ws(ee^ne,12),T=T+ee|0,ae=Ws(ae^T,8),ne=ne+ae|0,ee=Ws(ee^ne,7),S=S+D|0,ae=Ws(ae^S,16),A=A+ae|0,D=Ws(D^A,12),S=S+D|0,ae=Ws(ae^S,8),A=A+ae|0,D=Ws(D^A,7),C=C+O|0,j=Ws(j^C,16),ne=ne+j|0,O=Ws(O^ne,12),C=C+O|0,j=Ws(j^C,8),ne=ne+j|0,O=Ws(O^ne,7),w=w+ee|0,re=Ws(re^w,16),te=te+re|0,ee=Ws(ee^te,12),w=w+ee|0,re=Ws(re^w,8),te=te+re|0,ee=Ws(ee^te,7),T=T+E|0,ie=Ws(ie^T,16),k=k+ie|0,E=Ws(E^k,12),T=T+E|0,ie=Ws(ie^T,8),k=k+ie|0,E=Ws(E^k,7);let oe=0;r[oe++]=o+S|0,r[oe++]=s+C|0,r[oe++]=c+w|0,r[oe++]=l+T|0,r[oe++]=u+E|0,r[oe++]=d+D|0,r[oe++]=f+O|0,r[oe++]=p+ee|0,r[oe++]=m+te|0,r[oe++]=h+k|0,r[oe++]=g+A|0,r[oe++]=_+ne|0,r[oe++]=v+j|0,r[oe++]=y+re|0,r[oe++]=b+ie|0,r[oe++]=x+ae|0}var Doe=Soe(Eoe,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Ooe=new Uint8Array(16),Xs=(e,t)=>{e.update(t);let n=t.length%16;n&&e.update(Ooe.subarray(n))},koe=new Uint8Array(32);function Zs(e,t,n,r,i){i!==void 0&&ys(i,void 0,`AAD`);let a=e(t,n,koe),o=moe(r.length,i?i.length:0,!0),s=Toe.create(a);i&&Xs(s,i),Xs(s,r),s.update(o);let c=s.digest();return Cs(a,o),c}var Qs=doe({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,n,r)=>({encrypt(i,a){let o=i.length;a=Hs(o+16,a,!1),a.set(i);let s=a.subarray(0,-16);e(t,n,s,s,1);let c=Zs(e,t,n,s,r);return a.set(c,o),Cs(c),a},decrypt(i,a){a=Hs(i.length-16,a,!1);let o=i.subarray(0,-16),s=i.subarray(-16),c=Zs(e,t,n,o,r);if(!poe(s,c))throw Error(`invalid tag`);return a.set(i.subarray(0,-16)),e(t,n,a,a,1),Cs(c),a}}))(Doe)),Aoe=class{constructor(e){Object.defineProperty(this,"_key",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._key=new Uint8Array(ds(e))}async seal(e,t,n){return await this._seal(ds(e),ds(t),ds(n))}async open(e,t,n){return await this._open(ds(e),ds(t),ds(n))}_seal(e,t,n){return new Promise(r=>{r(Qs(this._key,new Uint8Array(e),new Uint8Array(n)).encrypt(new Uint8Array(t)).buffer)})}_open(e,t,n){return new Promise(r=>{r(Qs(this._key,new Uint8Array(e),new Uint8Array(n)).decrypt(new Uint8Array(t)).buffer)})}},joe=class{constructor(){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:is.Chacha20Poly1305}),Object.defineProperty(this,"keySize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"nonceSize",{enumerable:!0,configurable:!0,writable:!0,value:12}),Object.defineProperty(this,"tagSize",{enumerable:!0,configurable:!0,writable:!0,value:16})}createEncryptionContext(e){return new Aoe(e)}};function $s(){return new Promise((e,t)=>{t(new $o(`Not supported`))})}var Moe=new Uint8Array([115,101,99]),ec=class{constructor(e,t,n){Object.defineProperty(this,"_api",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"exporterSecret",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_kdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._api=e,this._kdf=t,this.exporterSecret=n}async seal(e,t){return await $s()}async open(e,t){return await $s()}async export(e,t){let n=ds(e);if(n.byteLength>8192)throw new Xo(`Too long exporter context`);try{return await this._kdf.labeledExpand(this.exporterSecret,Moe,new Uint8Array(n),t)}catch(e){throw new bae(e)}}},Noe=class extends ec{},Poe=class extends ec{constructor(e,t,n,r){super(e,t,n),Object.defineProperty(this,"enc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.enc=r}},tc=class extends ec{constructor(e,t,n){if(super(e,t,n.exporterSecret),Object.defineProperty(this,"_aead",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nK",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nN",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nT",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_ctx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n.key===void 0||n.baseNonce===void 0||n.seq===void 0)throw Error(`Required parameters are missing`);this._aead=n.aead,this._nK=this._aead.keySize,this._nN=this._aead.nonceSize,this._nT=this._aead.tagSize;let r=this._aead.createEncryptionContext(n.key);this._ctx={key:r,baseNonce:n.baseNonce,seq:n.seq}}computeNonce(e){let t=ps(e.seq,e.baseNonce.byteLength);return Mae(e.baseNonce,t).buffer}incrementSeq(e){if(e.seq>2**53-1)throw new Cae(`Message limit reached`);e.seq+=1}},Foe=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Ioe=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},nc,rc=class{constructor(){nc.set(this,Promise.resolve())}async lock(){let e,t=new Promise(t=>{e=t}),n=Foe(this,nc,`f`);return Ioe(this,nc,t,`f`),await n,e}};nc=new WeakMap;var ic=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Loe=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},ac,Roe=class extends tc{constructor(){super(...arguments),ac.set(this,void 0)}async open(e,t=as.buffer){Loe(this,ac,ic(this,ac,`f`)??new rc,`f`);let n=await ic(this,ac,`f`).lock(),r;try{r=await this._ctx.key.open(this.computeNonce(this._ctx),ds(e),ds(t))}catch(e){throw new Sae(e)}finally{n()}return this.incrementSeq(this._ctx),r}};ac=new WeakMap;var oc=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},zoe=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},sc,Boe=class extends tc{constructor(e,t,n,r){super(e,t,n),Object.defineProperty(this,"enc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),sc.set(this,void 0),this.enc=r}async seal(e,t=as.buffer){zoe(this,sc,oc(this,sc,`f`)??new rc,`f`);let n=await oc(this,sc,`f`).lock(),r;try{r=await this._ctx.key.seal(this.computeNonce(this._ctx),ds(e),ds(t))}catch(e){throw new xae(e)}finally{n()}return this.incrementSeq(this._ctx),r}};sc=new WeakMap;var Voe=new Uint8Array([98,97,115,101,95,110,111,110,99,101]),Hoe=new Uint8Array([101,120,112]),Uoe=new Uint8Array([105,110,102,111,95,104,97,115,104]),Woe=new Uint8Array([107,101,121]),Goe=new Uint8Array([112,115,107,95,105,100,95,104,97,115,104]),Koe=new Uint8Array([115,101,99,114,101,116]),qoe=new Uint8Array([72,80,75,69,0,0,0,0,0,0]),Joe=class extends ts{constructor(e){if(super(),Object.defineProperty(this,"_kem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_kdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_aead",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_suiteId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),typeof e.kem==`number`)throw new Xo(`KemId cannot be used`);if(this._kem=e.kem,typeof e.kdf==`number`)throw new Xo(`KdfId cannot be used`);if(this._kdf=e.kdf,typeof e.aead==`number`)throw new Xo(`AeadId cannot be used`);this._aead=e.aead,this._suiteId=new Uint8Array(qoe),this._suiteId.set(ps(this._kem.id,2),4),this._suiteId.set(ps(this._kdf.id,2),6),this._suiteId.set(ps(this._aead.id,2),8),this._kdf.init(this._suiteId)}get kem(){return this._kem}get kdf(){return this._kdf}get aead(){return this._aead}async createSenderContext(e){this._validateInputLength(e),await this._setup();let t=await this._kem.encap(e),n;return n=e.psk===void 0?e.senderKey===void 0?ns.Base:ns.Auth:e.senderKey===void 0?ns.Psk:ns.AuthPsk,await this._keyScheduleS(n,t.sharedSecret,t.enc,e)}async createRecipientContext(e){this._validateInputLength(e),await this._setup();let t=await this._kem.decap(e),n;return n=e.psk===void 0?e.senderPublicKey===void 0?ns.Base:ns.Auth:e.senderPublicKey===void 0?ns.Psk:ns.AuthPsk,await this._keyScheduleR(n,t,e)}async seal(e,t,n=as.buffer){let r=await this.createSenderContext(e);return{ct:await r.seal(t,n),enc:r.enc}}async open(e,t,n=as.buffer){return await(await this.createRecipientContext(e)).open(t,n)}async _keySchedule(e,t,n){let r=n.psk===void 0?as:us(n.psk.id),i=await this._kdf.labeledExtract(as,Goe,r),a=n.info===void 0?as:us(n.info),o=await this._kdf.labeledExtract(as,Uoe,a),s=new Uint8Array(1+i.byteLength+o.byteLength);s.set(new Uint8Array([e]),0),s.set(new Uint8Array(i),1),s.set(new Uint8Array(o),1+i.byteLength);let c=n.psk===void 0?as:us(n.psk.key),l=this._kdf.buildLabeledIkm(Koe,c),u=this._kdf.buildLabeledInfo(Hoe,s,this._kdf.hashSize),d=await this._kdf.extractAndExpand(t,l,u,this._kdf.hashSize);if(this._aead.id===is.ExportOnly)return{aead:this._aead,exporterSecret:d};let f=this._kdf.buildLabeledInfo(Woe,s,this._aead.keySize),p=await this._kdf.extractAndExpand(t,l,f,this._aead.keySize),m=this._kdf.buildLabeledInfo(Voe,s,this._aead.nonceSize),h=await this._kdf.extractAndExpand(t,l,m,this._aead.nonceSize);return{aead:this._aead,exporterSecret:d,key:p,baseNonce:new Uint8Array(h),seq:0}}async _keyScheduleS(e,t,n,r){let i=await this._keySchedule(e,t,r);return i.key===void 0?new Poe(this._api,this._kdf,i.exporterSecret,n):new Boe(this._api,this._kdf,i,n)}async _keyScheduleR(e,t,n){let r=await this._keySchedule(e,t,n);return r.key===void 0?new Noe(this._api,this._kdf,r.exporterSecret):new Roe(this._api,this._kdf,r)}_validateInputLength(e){if(e.info!==void 0&&e.info.byteLength>268435456)throw new Xo(`Too long info`);if(e.psk!==void 0){if(e.psk.key.byteLength<32)throw new Xo(`PSK must have at least 32 bytes`);if(e.psk.key.byteLength>8192)throw new Xo(`Too long psk.key`);if(e.psk.id.byteLength>8192)throw new Xo(`Too long psk.id`)}}},Yoe=class extends Joe{},Xoe=1n,cc=2n,Zoe=3n,Qoe=5n,lc=57896044618658097711785492504343953926634992332820282019728792003956564819949n;function $oe(e){let t=10n,n=80n,r=lc,i=e*e%r*e%r,a=Bs(Bs(i,cc,r)*i%r,Xoe,r)*e%r,o=Bs(a,Qoe,r)*a%r,s=Bs(o,t,r)*o%r,c=Bs(s,20n,r)*s%r,l=Bs(c,40n,r)*c%r;return{pow_p_5_8:Bs(Bs(Bs(Bs(l,n,r)*l%r,n,r)*l%r,t,r)*o%r,cc,r)*e%r,b2:i}}function ese(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var tse=(()=>{let e=lc;return uoe({P:e,type:`x25519`,powPminus2:t=>{let{pow_p_5_8:n,b2:r}=$oe(t);return zs(Bs(n,Zoe,e)*r,e)},adjustScalarBytes:ese})})(),nse=class extends zae{constructor(e){super(`X25519`,32,tse,e)}derive(e,t){try{return Promise.resolve(this._curve.getSharedSecret(e,t))}catch(e){return Promise.reject(new Zo(e))}}},uc=`DHKEM_X25519_HKDF_SHA256/HKDF_SHA256/CHACHA20_POLY1305/AUTH`,rse=2**31,ise=65536,ase=16,dc=32,fc=(1n<<255n)-19n,pc=new TextEncoder,mc=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`;function hc(e){let t=0n;for(let n=0;n<e.length;n+=2)t|=BigInt(Number.parseInt(e.slice(n,n+2),16))<<BigInt(n/2*8);return t}var ose=new Set([0n,1n,hc(`e0eb7a7c3b41b8ae1656e3faf19fc46ada098deb9c32b1fd866205165f49b800`),hc(`5f9c95bca3508c24b1d0b1559c83ef5b04445cc4581c8e86d8224eddd09f1157`),fc-1n]),sse=new Uint8Array,gc=class extends Aae{async extract(e,t){return ds(Fs(Rs,e.byteLength===0?new Uint8Array(this.hashSize):us(e),us(t)))}async expand(e,t,n){if(!Number.isSafeInteger(n)||n<0||n>255*this.hashSize)throw Error(`HKDF output length exceeds the RFC 5869 limit.`);let r=us(e),i=us(t),a=new Uint8Array(n),o=sse;for(let e=1,t=0;t<a.byteLength;e+=1){let n=bc([o,i,Uint8Array.of(e)]);o=new Uint8Array(Fs(Rs,r,n));let s=a.byteLength-t;a.set(o.subarray(0,Math.min(o.byteLength,s)),t),t+=Math.min(o.byteLength,s)}return ds(a)}async extractAndExpand(e,t,n,r){return this.expand(await this.extract(e,t),n,r)}},_c=new Yoe({kem:new class extends Iae{secretSize=32;encSize=32;publicKeySize=32;privateKeySize=32;constructor(e){super(Dae.DhkemX25519HkdfSha256,new nse(e),e)}}(new gc),kdf:new gc,aead:new joe}),vc=class extends Error{code;name=`RelayPayloadChannelFailure`;constructor(e,t){super(t),this.code=e}};function yc(e){return new Uint8Array(e.slice(0))}function cse(e){let t=new Uint8Array(e.byteLength);return t.set(e),t.buffer}function bc(e){let t=e.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function xc(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new vc(`channel_ticket_binding_invalid`,`Invalid uint32 value.`);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!1),t}function Sc(e){if(!Number.isSafeInteger(e)||e<0)throw new vc(`channel_ticket_binding_invalid`,`Invalid uint64 value.`);let t=new Uint8Array(8);return new DataView(t.buffer).setBigUint64(0,BigInt(e),!1),t}function lse(e){return bc([xc(e.byteLength),e])}function Cc(e){return Uint8Array.of(e===`control-to-runtime`?0:1)}function use(e){return e===`handshake`?Uint8Array.of(0):e===`application`?Uint8Array.of(1):Uint8Array.of(2)}function wc(e){let t=``;for(let n=0;n<e.byteLength;n+=3){let r=e[n]??0,i=e[n+1]??0,a=e[n+2]??0,o=r<<16|i<<8|a;t+=mc[o>>>18&63],t+=mc[o>>>12&63],n+1<e.byteLength&&(t+=mc[o>>>6&63]),n+2<e.byteLength&&(t+=mc[o&63])}return t}function Tc(e){if(!/^[A-Za-z0-9_-]*$/.test(e)||e.length%4==1)throw new vc(`channel_authentication_failed`,`Encrypted relay frame is not canonical base64url.`);let t=new Uint8Array(Math.floor(e.length*6/8)),n=0,r=0,i=0;for(let a of e){let e=mc.indexOf(a);n=n<<6|e,r+=6,r>=8&&(r-=8,t[i]=n>>>r&255,i+=1)}if(wc(t)!==e)throw new vc(`channel_authentication_failed`,`Encrypted relay frame has a non-canonical base64url encoding.`);return t}function dse(e){let t=new Uint8Array(e);t[31]=(t[31]??0)&127;let n=0n;for(let e=0;e<t.byteLength;e+=1)n|=BigInt(t[e]??0)<<BigInt(e*8);return ose.has(n%fc)}var fse={async sha256(e){if(globalThis.crypto?.subtle===void 0)throw new vc(`channel_authentication_failed`,`SHA-256 is unavailable in this runtime.`);return yc(await globalThis.crypto.subtle.digest(`SHA-256`,cse(e)))}},Ec={randomBytes(e){if(globalThis.crypto?.getRandomValues===void 0)throw new vc(`endpoint_key_invalid`,`A cryptographically secure random source is unavailable.`);return globalThis.crypto.getRandomValues(new Uint8Array(e))}};function Dc(e,t){let n=pc.encode(e).byteLength;if(n===0||n>256)throw new vc(`channel_ticket_binding_invalid`,`${t} must contain between 1 and 256 UTF-8 bytes.`)}function pse(e){let t=pc.encode(e).byteLength;if(t===0||t>65536)throw new vc(`channel_ticket_binding_invalid`,`Control ticket must contain between 1 and ${ise} UTF-8 bytes.`)}async function Oc(e,t=fse){pse(e.exactCompactTicket),Dc(e.channelId,`Channel ID`),Dc(e.runtimeId,`Runtime ID`),Sc(e.connectionEpoch);let n=await t.sha256(pc.encode(e.exactCompactTicket));if(n.byteLength!==32)throw new vc(`channel_ticket_binding_invalid`,`The control ticket digest must be 32 bytes.`);return{...e,ticketDigest:new Uint8Array(n)}}function mse(e){return wc(e.ticketDigest)}async function hse(e=Ec){let t=new Uint8Array(await e.randomBytes(dc));if(t.byteLength!==dc)throw new vc(`endpoint_key_invalid`,`The endpoint random source must return ${dc} bytes.`);try{return wc(t)}finally{t.fill(0)}}function kc(e){return bc([pc.encode(`forge-relay-v4`),Uint8Array.of(0),e.ticketDigest,Cc(e.direction)])}function Ac(e){return bc([pc.encode(`forge-relay`),xc(4),e.binding.ticketDigest,pc.encode(e.binding.channelId),Cc(e.binding.direction),use(e.frameClass),Sc(e.sequence),pc.encode(e.binding.runtimeId),Sc(e.binding.connectionEpoch),xc(e.ciphertextLength)].map(lse))}async function gse(e=Ec){let t=new Uint8Array(await e.randomBytes(dc));if(t.byteLength!==dc)throw new vc(`endpoint_key_invalid`,`The endpoint random source must return ${dc} bytes.`);try{return await _c.kem.deriveKeyPair(t)}catch(e){throw new vc(`endpoint_key_invalid`,e instanceof Error?e.message:`Endpoint key generation failed.`)}finally{t.fill(0)}}async function jc(e){try{return wc(yc(await _c.kem.serializePublicKey(e)))}catch(e){throw new vc(`endpoint_key_invalid`,e instanceof Error?e.message:`Endpoint public-key serialization failed.`)}}function _se(e,t){if(!/^[A-Za-z0-9_-]{43}$/u.test(t))throw new vc(`endpoint_key_invalid`,`The endpoint key ID requires a canonical X25519 public key.`);return`${e}:${t}`}async function vse(e){try{let t=Tc(e);if(t.byteLength!==dc)throw Error(`Invalid endpoint key length.`);if(dse(t))throw new vc(`endpoint_key_invalid`,`Low-order X25519 endpoint public keys are not allowed.`);return await _c.kem.deserializePublicKey(t)}catch(e){throw e instanceof vc?e:new vc(`endpoint_key_invalid`,e instanceof Error?e.message:`Endpoint public-key deserialization failed.`)}}var Mc=class{tail=Promise.resolve();run(e){let t=this.tail.then(e,e);return this.tail=t.then(()=>void 0,()=>void 0),t}},Nc=class{startedAt=Date.now();records=0;bytes=0;assertAvailable(e){if(this.records>=rse||this.bytes+e>1073741824||Date.now()-this.startedAt>=18e5)throw new vc(`channel_limit_reached`,`The encrypted relay channel must be renewed before another record is sent.`)}commit(e){this.records+=1,this.bytes+=e}};function yse(e,t){if(e.type!==`relay.encrypted-frame`||e.protocolVersion!==4||e.channelId!==t.channelId||e.direction!==t.direction||![`handshake`,`application`,`close`].includes(e.frameClass))throw new vc(`channel_ticket_binding_invalid`,`Encrypted relay frame does not match the CMMD-ticket-bound channel.`)}var bse=class{binding;context;encapsulatedKey;queue=new Mc;budget=new Nc;sequence=0;constructor(e,t){this.binding=e,this.context=t,this.encapsulatedKey=wc(yc(t.enc))}seal(e){return this.queue.run(async()=>{if(e.plaintext.byteLength>16777216)throw new vc(`channel_limit_reached`,`Encrypted relay plaintext exceeds the per-record byte limit.`);let t=e.plaintext.byteLength+ase;this.budget.assertAvailable(t);let n=this.sequence,r=Ac({binding:this.binding,frameClass:e.frameClass,sequence:n,ciphertextLength:t}),i;try{i=yc(await this.context.seal(e.plaintext,r))}catch(e){throw new vc(`channel_authentication_failed`,e instanceof Error?e.message:`Relay payload encryption failed.`)}if(i.byteLength!==t)throw new vc(`channel_authentication_failed`,`Relay payload encryption returned an invalid ciphertext length.`);return this.sequence+=1,this.budget.commit(i.byteLength),{type:`relay.encrypted-frame`,protocolVersion:4,channelId:this.binding.channelId,direction:this.binding.direction,frameClass:e.frameClass,sequence:n,ciphertext:wc(i)}})}},xse=class{binding;context;queue=new Mc;budget=new Nc;sequence=0;constructor(e,t){this.binding=e,this.context=t}open(e){return this.queue.run(async()=>{if(yse(e,this.binding),!Number.isSafeInteger(e.sequence)||e.sequence!==this.sequence)throw new vc(`channel_sequence_invalid`,`Expected encrypted relay sequence ${this.sequence}, received ${String(e.sequence)}.`);let t=Tc(e.ciphertext);this.budget.assertAvailable(t.byteLength);let n=Ac({binding:this.binding,frameClass:e.frameClass,sequence:e.sequence,ciphertextLength:t.byteLength}),r;try{r=yc(await this.context.open(t,n))}catch(e){throw new vc(`channel_authentication_failed`,e instanceof Error?e.message:`Relay payload authentication failed.`)}if(r.byteLength>16777216)throw new vc(`channel_limit_reached`,`Decrypted relay plaintext exceeds the per-record byte limit.`);return this.sequence+=1,this.budget.commit(t.byteLength),r})}};async function Sse(e){let t=null;try{if(t=new Uint8Array(await(e.randomSource??Ec).randomBytes(dc)),t.byteLength!==dc)throw Error(`The endpoint random source must return ${dc} bytes.`);let n=await _c.createSenderContext({recipientPublicKey:e.recipientPublicKey,senderKey:e.senderKey,info:kc(e.binding),ekm:t});return new bse(e.binding,n)}catch(e){throw new vc(`channel_authentication_failed`,e instanceof Error?e.message:`Relay payload sender setup failed.`)}finally{t?.fill(0)}}async function Cse(e){try{let t=await _c.createRecipientContext({recipientKey:e.recipientKey,senderPublicKey:e.senderPublicKey,enc:Tc(e.encapsulatedKey),info:kc(e.binding)});return new xse(e.binding,t)}catch(e){throw e instanceof vc?e:new vc(`channel_authentication_failed`,e instanceof Error?e.message:`Relay payload recipient setup failed.`)}}var wse=128,Tse=2097152,Ese=864e5,Pc=class extends Error{constructor(e){super(e),this.name=`RelayControlJournalError`}};function Fc(e){return typeof e==`string`&&e.length>0}function Ic(e){return Fc(e)&&Number.isFinite(Date.parse(e))}function Dse(e){return e===`pending`||e===`retrying`||e===`outcome-unknown`||e===`failed`}function Ose(e){return Fc(e.transportRequestId)&&Fc(e.runtimeId)&&Fc(e.actorSessionId)&&Fc(e.durableRequestId)&&Fc(e.method)}function kse(e){return Number.isSafeInteger(e.sequence)&&Number(e.sequence)>0&&Number.isSafeInteger(e.attemptCount)&&Number(e.attemptCount)>=0}function Ase(e){return e.persistence!==`frame`&&e.persistence!==`metadata-only`||e.frame!==null&&!Fc(e.frame)?!1:e.persistence!==`metadata-only`||e.frame===null}function jse(e){return!Dse(e.status)||e.errorCode!==null&&!Fc(e.errorCode)?!1:e.status===`outcome-unknown`||e.status===`failed`?e.frame===null&&Fc(e.errorCode):e.errorCode===null}function Mse(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return Ose(t)&&kse(t)&&Ase(t)&&jse(t)&&Ic(t.createdAt)&&Ic(t.updatedAt)}function Nse(e){try{return JSON.parse(e)}catch{throw new Pc(`Forge relay control journal is corrupt.`)}}function Pse(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return t.version===1&&Fc(t.controlSessionId)&&Number.isSafeInteger(t.nextSequence)&&Number(t.nextSequence)>=1&&Array.isArray(t.records)&&t.records.every(Mse)}function Fse(e){let t=new Set(e.map(Lc)),n=new Set(e.map(e=>e.durableRequestId)),r=new Set(e.map(e=>e.sequence));return t.size===e.length&&n.size===e.length&&r.size===e.length}function Ise(e){let t=Nse(e);if(!Pse(t))throw new Pc(`Forge relay control journal is corrupt.`);let n=t.records,r=n.reduce((e,t)=>Math.max(e,t.sequence),0);if(!Fse(n)||t.nextSequence<=r)throw new Pc(`Forge relay control journal is corrupt.`);return{version:1,controlSessionId:t.controlSessionId,nextSequence:t.nextSequence,records:n}}function Lse(){return crypto.randomUUID()}function Lc(e){return`${e.runtimeId}\0${e.actorSessionId}\0${e.transportRequestId}`}var Rc={pending:1,retrying:2,"outcome-unknown":3,failed:4};function Rse(e,t){let n=e.filter(e=>e.runtimeId===t);if(n.length===0)return{state:`idle`,count:0};let r=n.reduce((e,t)=>Rc[t.status]>Rc[e]?t.status:e,`pending`);return{state:r,count:n.filter(e=>e.status===r).length}}function zc(e){let t=e.randomUUID??Lse,n=e.now??(()=>new Date),r=e.maxRecords??wse,i=e.maxBytes??Tse,a=e.maxReplayAgeMs??Ese;if(r<1||i<1||a<1)throw new Pc(`Forge relay control journal limits must be positive.`);let o=e.storage.read(),s=n(),c=o?Ise(o):{version:1,controlSessionId:t(),nextSequence:1,records:[]},l=new Map,u=new Set;function d(){return{controlSessionId:c.controlSessionId,records:[...c.records]}}function f(t){if(t.records.length>r)throw new Pc(`Forge relay control journal reached its record limit.`);let n=JSON.stringify(t);if(new TextEncoder().encode(n).byteLength>i)throw new Pc(`Forge relay control journal reached its storage limit.`);e.storage.write(n),c=t;let a=d();for(let e of u)e(a)}function p(e,t){return e.status!==`pending`&&e.status!==`retrying`?e:e.persistence===`metadata-only`||e.frame===null?{...e,frame:null,status:`outcome-unknown`,errorCode:`RELAY_COMMAND_OUTCOME_UNKNOWN`,updatedAt:t.toISOString()}:t.getTime()-Date.parse(e.createdAt)>a?{...e,frame:null,status:`outcome-unknown`,errorCode:`RELAY_RECOVERY_EXPIRED`,updatedAt:t.toISOString()}:e}let m=c.records.map(e=>p(e,s)),h=m.some((e,t)=>e!==c.records[t]);(o===null||h)&&f({...c,records:m});function g(e){let t=Lc(e);return{key:t,existing:c.records.find(e=>Lc(e)===t)??null}}function _(e,t,n){if([e.method===t.method,e.persistence===t.persistence,n===void 0||n===t.frame,e.frame===null||e.frame===t.frame,t.durableRequestId===void 0||e.durableRequestId===t.durableRequestId].includes(!1))throw new Pc(`Relay transport request ${t.transportRequestId} was reused with different content.`);if(e.status===`failed`||e.status===`outcome-unknown`)throw new Pc(`Relay transport request ${t.transportRequestId} requires an explicit outcome acknowledgement.`)}function v(e){if(e.durableRequestId!==void 0&&c.records.some(t=>t.durableRequestId===e.durableRequestId))throw new Pc(`Relay durable request ${e.durableRequestId} was reused by another transport request.`)}function y(e){let r=n().toISOString();return{runtimeId:e.runtimeId,actorSessionId:e.actorSessionId,transportRequestId:e.transportRequestId,durableRequestId:e.durableRequestId??t(),sequence:c.nextSequence,method:e.method,persistence:e.persistence,frame:e.persistence===`frame`?e.frame:null,status:`pending`,attemptCount:0,errorCode:null,createdAt:r,updatedAt:r}}function b(e){let{key:t,existing:n}=g(e);if(n!==null)return _(n,e,l.get(t)),l.set(t,e.frame),n;v(e);let r=y(e);return l.set(t,e.frame),f({...c,nextSequence:c.nextSequence+1,records:[...c.records,r]}),r}function x(e,t,n){let r=c.records.find(r=>r.runtimeId===e&&r.actorSessionId===t&&r.transportRequestId===n);if(!r)throw new Pc(`Relay transport request ${n} is not journaled.`);return r}function S(e,t,r,i){x(e,t,r);let a=n().toISOString();l.delete(Lc({runtimeId:e,actorSessionId:t,transportRequestId:r})),f({...c,records:c.records.map(n=>n.runtimeId===e&&n.actorSessionId===t&&n.transportRequestId===r?{...n,frame:null,status:`failed`,errorCode:i,updatedAt:a}:n)})}function C(e,t,r){let i=x(e,t,r);if(i.status===`failed`||i.status===`outcome-unknown`)throw new Pc(`Relay transport request ${r} has no replayable outcome.`);let a={...i,status:i.attemptCount>0?`retrying`:`pending`,attemptCount:i.attemptCount+1,errorCode:null,updatedAt:n().toISOString()};return f({...c,records:c.records.map(n=>n.runtimeId===e&&n.actorSessionId===t&&n.transportRequestId===r?a:n)}),a}function w(e,t,n){let r=c.records.filter(r=>r.runtimeId!==e||r.actorSessionId!==t||r.transportRequestId!==n);r.length!==c.records.length&&(l.delete(Lc({runtimeId:e,actorSessionId:t,transportRequestId:n})),f({...c,records:r}))}function T(e,t,n){let r=x(e,t,n);if(r.status!==`failed`&&r.status!==`outcome-unknown`)throw new Pc(`Relay transport request ${n} does not have an acknowledgeable outcome.`);w(e,t,n)}function E(){let e=n(),t=c.records.map(t=>p(t,e));t.some((e,t)=>e!==c.records[t])&&f({...c,records:t})}function D(e,t){let r=n().toISOString(),i=c.records.map(n=>n.runtimeId!==e||n.actorSessionId===t||n.status!==`pending`&&n.status!==`retrying`?n:(l.delete(Lc(n)),{...n,frame:null,status:`outcome-unknown`,errorCode:`RELAY_ACTOR_SESSION_CHANGED`,updatedAt:r}));i.some((e,t)=>e!==c.records[t])&&f({...c,records:i})}return{controlSessionId:c.controlSessionId,prepare:b,records:()=>[...c.records],pending:()=>[...c.records],replayable:(e,t)=>(E(),c.records.filter(n=>n.runtimeId===e&&n.actorSessionId===t&&n.persistence===`frame`&&n.frame!==null&&(n.status===`pending`||n.status===`retrying`))),fenceActor:D,beginAttempt:C,markFailed:S,complete:w,acknowledge:T,subscribe:e=>(u.add(e),e(d()),()=>u.delete(e))}}function zse(e=null){let t=e;return{read:()=>t,write:e=>{t=e}}}var Bse=$t(ane),Vse=Qn(rne),Hse=Qn(bne),Use=[`rpc.read`,`rpc.mutate`,`cursor.resume`,`terminal.stream`,`browser.stream`,`bulk.transfer`,`envelope.validation`,`payload.e2e`];function Bc(e,t){if(!Array.isArray(e))return null;for(let n of e)if(Array.isArray(n)&&n.length===2&&n[0]===t&&typeof n[1]==`string`)return n[1];return null}function Vc(e,t){let n=JSON.parse(e),r=lae(n);if(r!==null)return{messageType:`request`,...r};let i=Wse(n,t);if(i!==null)return i;let a=Gse(n);if(a!==null)return a;throw Error(`Forge relay protocol v2 requires a recognized Effect RPC frame.`)}function Wse(e,t){if(e._tag!==`Request`||typeof e.id!=`string`||e.id.length===0||typeof e.tag!=`string`||e.tag.length===0)return null;let n=Jo({method:e.tag,payload:e.payload,grantedScopes:t});return{messageType:`request`,requestId:e.id,correlationId:Bc(e.headers,On.requestId)??e.id,method:e.tag,...n}}function Gse(e){return e._tag!==`Ack`&&e._tag!==`Interrupt`||typeof e.requestId!=`string`||e.requestId.length===0?null:{messageType:`acknowledgement`,requestId:e.requestId,correlationId:e.requestId,method:`@effect/rpc/${e._tag}`,requiredScope:null,deliveryClass:`read`,journalPersistence:`none`}}function Hc(e,t){let n=new Event(`error`);return Object.defineProperties(n,{error:{value:Error(t),enumerable:!0},message:{value:`${e}: ${t}`,enumerable:!0}}),n}var Kse=new Set([`network`,`server`,`auth`,`permission`,`client`]),qse=new Set([`network`,`server`]);function Jse(e){return e&&typeof e==`object`?e:{}}function Yse(e){return typeof e.code==`string`&&e.code.length>0?e.code:typeof e.kind==`string`&&Kse.has(e.kind)?`RELAY_ACTION_GRANT_UNAVAILABLE`:`MALFORMED_FRAME`}function Xse(e){if(e.retryable===!0||typeof e.kind==`string`&&qse.has(e.kind))return!0;let t=typeof e.status==`number`?e.status:null;return t===429||t!==null&&t>=500}function Uc(e){let t=Jse(e);return{code:Yse(t),message:e instanceof Error?e.message:`Forge relay frame encoding failed.`,retryable:Xse(t)}}function Wc(e,t){let n=new Event(e.type),r=e;for(let e of t)r[e]!==void 0&&Object.defineProperty(n,e,{value:r[e],enumerable:!0});return n}function Zse(e){return!Array.isArray(e)||e.length!==2||typeof e[0]!=`string`?!1:Object.values(On).includes(e[0])}function Gc(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Qse(e){if(!Array.isArray(e))return null;for(let t of e){let e=Gc(t);if(e?._tag!==`Fail`)continue;let n=Gc(e.error)?.code;if(typeof n==`string`&&n.length>0)return n}return null}function $se(e){let t=Gc(e.exit);return t===null?`RELAY_RPC_RESPONSE_INVALID`:t._tag===`Success`?null:t._tag!==`Failure`||!Array.isArray(t.cause)?`RELAY_RPC_RESPONSE_INVALID`:Qse(t.cause)??`RELAY_RPC_FAILED`}function Kc(e){if(typeof e!=`string`)return null;try{let t=Bse(JSON.parse(e));return t._tag===`Some`?t.value:null}catch{return null}}function ece(e,t){if(e.role===`control`&&e.protocolVersion===t&&e.protocolVersion>=1){if(e.protocolVersion===1)return null;if(e.actor!==void 0&&e.scopes!==void 0)return{runtimeId:e.runtimeId,connectionEpoch:e.connectionEpoch,protocolVersion:e.protocolVersion,actor:e.actor,scopes:e.scopes}}}function qc(e,t,n){if(typeof e==`string`)try{let r=Gc(JSON.parse(e));if(r?._tag!==`Exit`||typeof r.requestId!=`string`)return;let i=$se(r);if(i===null){n.complete(t.runtimeId,t.actor.sessionId,r.requestId);return}n.markFailed(t.runtimeId,t.actor.sessionId,r.requestId,i)}catch{}}function tce(e){let t=Bc(e,On.sequence);if(t===null)return;let n=Number(t);return Number.isSafeInteger(n)&&n>=0?n:void 0}function Jc(e){return{issuedAt:Bc(e,On.issuedAt)??new Date().toISOString(),expiresAt:Bc(e,On.expiresAt)??new Date(Date.now()+12e4).toISOString()}}function Yc(e){if(e!==2&&e!==3&&e!==4)throw new Go(`protocol_version_mismatch`,`Unsupported Forge relay envelope version: ${e}`,!1);return e}async function Xc(e){let t=_ae({method:e.identity.method,payload:e.payload});if(t===null)return;let n=Zc(e.context);if(e.acquire===void 0)throw new Go(`action_grant_required`,`CMMD action-grant issuance is unavailable for this remote response.`,!1);return e.acquire({...n,method:`orchestration.dispatchCommand`,...t,durableRequestId:e.identity.correlationId,payloadHash:e.payloadHash,requiredScope:`approval.respond`})}function Zc(e){if(e.protocolVersion===3)return{protocolVersion:3};if(e.protocolVersion!==4)throw new Go(`protocol_update_required`,`Update Forge on the target runtime before responding remotely.`,!1);return{protocolVersion:4,channelId:Qc(e.channelId),channelTicketDigest:Qc(e.channelTicketDigest),runtimeEndpointKeyId:Qc(e.runtimeEndpointKeyId),controlEndpointKeyId:Qc(e.controlEndpointKeyId)}}function Qc(e){if(typeof e==`string`&&e.length>0)return e;throw new Go(`channel_ticket_binding_invalid`,`The encrypted Forge relay channel is missing its CMMD ticket binding.`,!1)}function $c(e){return e===void 0?{}:{sequence:e}}function el(e){return e===void 0?{}:{actionGrant:e}}async function tl(e){let t=Vc(e.data,e.context.scopes),n=JSON.parse(e.data),r=Jc(n.headers),i=tce(n.headers),a=await e.crypto.sha256Base64Url(e.data),o=await Xc({context:e.context,identity:t,payload:n.payload,payloadHash:a,...e.acquireActionGrant===void 0?{}:{acquire:e.acquireActionGrant}}),s=Yc(e.context.protocolVersion),c={messageType:t.messageType,requestId:t.requestId,correlationId:t.correlationId,method:t.method,requiredScope:t.requiredScope,deliveryClass:t.deliveryClass,runtimeId:e.context.runtimeId,connectionEpoch:e.context.connectionEpoch,actor:e.context.actor,...r,payloadHash:a,...$c(i)};return s===2?{protocolVersion:2,...c}:s===3?{protocolVersion:3,...c,...el(o)}:{protocolVersion:4,...c,...el(o)}}function nl(e){return typeof e==`string`&&e.length>0}function rl(e){return[e.protocolVersion===4,nl(e.runtimeId),Number.isSafeInteger(e.connectionEpoch),Number(e.connectionEpoch)>0,e.hpkeSuite===uc,nl(e.channelId),nl(e.runtimeEndpointKeyId),nl(e.runtimeEndpointPublicKey),nl(e.controlEndpointKeyId),nl(e.controlEndpointPublicKey),nl(e.controlChannelNonce),e.controlEndpointKeyPair!==void 0].every(Boolean)}function il(e){if(!rl(e))throw new Go(`end_to_end_encryption_required`,`Forge relay protocol v4 requires complete endpoint encryption metadata.`,!1);return e}async function al(e){if(await jc(e.controlEndpointKeyPair.publicKey)!==e.controlEndpointPublicKey)throw new Go(`endpoint_key_invalid`,`The control endpoint private key does not match the CMMD route.`,!1);let t=await vse(e.runtimeEndpointPublicKey),[n,r]=await Promise.all([Oc({exactCompactTicket:e.token,channelId:e.channelId,direction:`control-to-runtime`,runtimeId:e.runtimeId,connectionEpoch:e.connectionEpoch},e.payloadDigestProvider),Oc({exactCompactTicket:e.token,channelId:e.channelId,direction:`runtime-to-control`,runtimeId:e.runtimeId,connectionEpoch:e.connectionEpoch},e.payloadDigestProvider)]);return{controlToRuntimeBinding:n,runtimeToControlBinding:r,sender:await Sse({binding:n,senderKey:e.controlEndpointKeyPair,recipientPublicKey:t,...e.payloadRandomSource?{randomSource:e.payloadRandomSource}:{}}),runtimePublicKey:t,recipient:null,phase:`awaiting-runtime-hello`}}function ol(e,t,n){return[e.direction===`runtime-to-control`,e.frameClass===n,e.channelId===t.channelId].every(Boolean)}function sl(e){return[e.confirmation.phase===e.expectedPhase,e.confirmation.channelId===e.route.channelId,e.confirmation.runtimeId===e.context.runtimeId,e.confirmation.connectionEpoch===e.context.connectionEpoch].every(Boolean)}function cl(e){let{envelope:t}=e.application;return[t.runtimeId===e.context.runtimeId,t.connectionEpoch===e.context.connectionEpoch,t.actor.userId===e.context.actor.userId,t.actor.deviceId===e.context.actor.deviceId,t.actor.sessionId===e.context.actor.sessionId,t.payloadHash===e.payloadHash].every(Boolean)}async function ll(e){if(e.channel.recipient!==null){if(e.message.encapsulatedKey!==void 0)throw new Go(`endpoint_key_invalid`,`The runtime attempted to replace its endpoint encapsulation.`,!1);return e.channel.recipient}if(e.message.sequence!==0||!e.message.encapsulatedKey)throw new Go(`channel_confirmation_failed`,`The runtime handshake omitted its endpoint encapsulation.`,!1);let t=await Cse({binding:e.channel.runtimeToControlBinding,recipientKey:e.route.controlEndpointKeyPair,senderPublicKey:e.channel.runtimePublicKey,encapsulatedKey:e.message.encapsulatedKey});return e.channel.recipient=t,t}var ul=class extends EventTarget{socket;route;relayCrypto;journal;lifecycle;acquireActionGrant;CONNECTING=WebSocket.CONNECTING;OPEN=WebSocket.OPEN;CLOSING=WebSocket.CLOSING;CLOSED=WebSocket.CLOSED;binaryType=`blob`;onopen=null;onclose=null;onerror=null;onmessage=null;authenticated=!1;context=null;payloadChannel=null;sendChain=Promise.resolve();constructor(e,t,n,r,i={},a){super(),this.socket=e,this.route=t,this.relayCrypto=n,this.journal=r,this.lifecycle=i,this.acquireActionGrant=a,e.addEventListener(`open`,()=>void this.beginAuthentication()),e.addEventListener(`message`,e=>void this.handleMessageSafely(e)),e.addEventListener(`error`,e=>{let t=Wc(e,[`error`,`message`]),n=typeof t.message==`string`?String(t.message):`Forge relay connection failed.`;this.lifecycle.onError?.({code:`RELAY_SOCKET_ERROR`,message:n}),this.emit(`error`,t)}),e.addEventListener(`close`,e=>{this.authenticated=!1,this.context=null,this.payloadChannel=null,this.lifecycle.onDisconnected?.({code:e.code,reason:e.reason}),this.emit(`close`,Wc(e,[`code`,`reason`,`wasClean`]))})}get bufferedAmount(){return this.socket.bufferedAmount}get extensions(){return this.socket.extensions}get protocol(){return this.socket.protocol}get readyState(){return this.authenticated?this.socket.readyState:WebSocket.CONNECTING}get url(){return this.route.relayWebSocketUrl}send(e){if(!this.authenticated||typeof e!=`string`)throw new DOMException(`Forge relay RPC socket is not open for text frames.`,`InvalidStateError`);if(this.route.protocolVersion===1){this.socket.send(JSON.stringify({type:`relay.frame`,payload:e}));return}let t=this.context;if(t===null)throw new DOMException(`Forge relay v2 context is unavailable.`,`InvalidStateError`);let n=Vc(e,t.scopes),r=n.messageType===`request`&&n.journalPersistence!==`none`?this.journal.prepare({runtimeId:t.runtimeId,actorSessionId:t.actor.sessionId,transportRequestId:n.requestId,...n.correlationId===n.requestId?{}:{durableRequestId:n.correlationId},method:n.method,frame:e,persistence:n.journalPersistence}):null;this.enqueueFrame(e,r)}enqueueFrame(e,t){this.sendChain=this.sendChain.then(()=>this.transmitFrame(e,t)).catch(e=>{let n=Uc(e);t!==null&&!n.retryable&&this.journal.markFailed(t.runtimeId,t.actorSessionId,t.transportRequestId,n.code),this.lifecycle.onError?.({code:n.code,message:n.message}),this.emit(`error`,Hc(n.code,n.message)),this.socket.readyState<WebSocket.CLOSING&&this.socket.close(4400,`${n.code}: ${n.message}`)})}async transmitFrame(e,t){let n=this.requireReadyContext(),r=await this.outboundFrame(e,t),i=await tl({data:r,context:n,crypto:this.relayCrypto,...this.acquireActionGrant?{acquireActionGrant:this.acquireActionGrant}:{}});if(n.protocolVersion===4){let e=await this.requirePayloadChannel().sender.seal({frameClass:`application`,plaintext:new TextEncoder().encode(JSON.stringify({payload:r,envelope:i}))});this.socket.send(JSON.stringify(e));return}this.socket.send(JSON.stringify({type:`relay.frame`,payload:r,envelope:i}))}requireReadyContext(){if(!this.authenticated||this.socket.readyState!==WebSocket.OPEN)throw new DOMException(`Forge relay RPC socket closed before send.`,`InvalidStateError`);if(this.context===null)throw new DOMException(`Forge relay v2 context is unavailable.`,`InvalidStateError`);return this.context}requirePayloadChannel(){let e=this.payloadChannel;if(e===null||e.phase!==`ready`)throw new Go(`channel_confirmation_failed`,`The Forge relay endpoint channel is not confirmed.`,!1);return e}async outboundFrame(e,t){return t===null?e:this.withDurableHeaders(t,e)}async withDurableHeaders(e,t){let n=this.journal.beginAttempt(e.runtimeId,e.actorSessionId,e.transportRequestId),r=JSON.parse(t),i=await ace({payload:r.payload,sequence:n.sequence,requestId:n.durableRequestId,issuedAt:new Date(n.updatedAt),crypto:this.relayCrypto}),a=Array.isArray(r.headers)?r.headers.filter(e=>!Zse(e)):[];return JSON.stringify({...r,headers:[...a,...Object.entries(i)]})}close(e,t){this.socket.close(e,t)}asWebSocket(){return this}emit(e,t){this.dispatchEvent(t);let n=this[`on${e}`];n&&n.call(this.asWebSocket(),t)}async handleMessage(e){if(this.authenticated){if(this.context?.protocolVersion===4){await this.handleEncryptedApplicationMessage(e.data);return}this.context!==null&&qc(e.data,this.context,this.journal),this.emit(`message`,new MessageEvent(`message`,{data:e.data}));return}await this.handleAuthenticationMessage(e.data)}async handleMessageSafely(e){try{await this.handleMessage(e)}catch(e){let t=Uc(e);this.lifecycle.onError?.({code:t.code,message:t.message}),this.emit(`error`,Hc(t.code,t.message)),this.socket.readyState<WebSocket.CLOSING&&this.socket.close(4400,`${t.code}: ${t.message}`)}}async beginAuthentication(){try{this.route.protocolVersion===4&&(this.payloadChannel=await al(il(this.route))),this.socket.send(JSON.stringify({type:`relay.auth`,ticket:this.route.token,protocolMinVersion:this.route.protocolVersion,protocolMaxVersion:this.route.protocolVersion,capabilities:Use,...this.payloadChannel?{controlToRuntimeEncapsulatedKey:this.payloadChannel.sender.encapsulatedKey}:{}}))}catch(e){let t=Uc(e);this.lifecycle.onError?.({code:t.code,message:t.message}),this.emit(`error`,Hc(t.code,t.message)),this.socket.close(4400,t.message)}}async handleAuthenticationMessage(e){let t=Kc(e);if(t!==null){if(t.type===`relay.encrypted-frame`&&this.context?.protocolVersion===4){await this.handleEncryptedHandshakeMessage(t);return}if(t.type===`relay.error`){this.lifecycle.onError?.({code:t.code,message:t.message}),this.emit(`error`,Hc(t.code,t.message)),this.socket.close(4403,t.message);return}t.type===`relay.authenticated`&&await this.handleAuthenticatedMessage(t)}}async handleAuthenticatedMessage(e){let t=ece(e,this.route.protocolVersion);if(t===void 0){this.socket.close(4400,`Forge relay authenticated the wrong role.`);return}if(t!==null&&t.protocolVersion===4){let n=il(this.route),r=this.payloadChannel;if(r===null||![e.runtimeId===n.runtimeId,e.connectionEpoch===n.connectionEpoch].every(Boolean)){this.socket.close(4400,`Forge relay authenticated stale endpoint metadata.`);return}t={...t,channelId:n.channelId,channelTicketDigest:mse(r.controlToRuntimeBinding),runtimeEndpointKeyId:n.runtimeEndpointKeyId,controlEndpointKeyId:n.controlEndpointKeyId},this.context=t;return}await this.activateAuthenticatedRelay(t)}async handleEncryptedHandshakeMessage(e){if(e.type!==`relay.encrypted-frame`)return;let t=this.payloadChannel,n=this.context,r=il(this.route);if(t===null||n===null||!ol(e,r,`handshake`))throw new Go(`channel_confirmation_failed`,`The runtime sent an invalid encrypted handshake frame.`,!1);let i=await(await ll({channel:t,route:r,message:e})).open(e),a=Vse(JSON.parse(new TextDecoder().decode(i))),o=t.phase===`awaiting-runtime-hello`?`runtime-hello`:`runtime-confirm`;if(!sl({confirmation:a,expectedPhase:o,route:r,context:n}))throw new Go(`channel_confirmation_failed`,`The runtime endpoint confirmation does not match the CMMD route.`,!1);if(o===`runtime-hello`){let e=await t.sender.seal({frameClass:`handshake`,plaintext:new TextEncoder().encode(JSON.stringify({type:`relay.endpoint-confirmation`,protocolVersion:4,phase:`control-confirm`,channelId:r.channelId,runtimeId:n.runtimeId,connectionEpoch:n.connectionEpoch}))});t.phase=`awaiting-runtime-confirm`,this.socket.send(JSON.stringify(e));return}t.phase=`ready`,await this.activateAuthenticatedRelay(n)}async handleEncryptedApplicationMessage(e){let t=Kc(e);if(t?.type!==`relay.encrypted-frame`)throw new Go(`end_to_end_encryption_required`,`The runtime sent plaintext after the encrypted channel was confirmed.`,!1);let n=this.requirePayloadChannel();if(!ol(t,il(this.route),`application`)||t.encapsulatedKey!==void 0||n.recipient===null)throw new Go(`channel_authentication_failed`,`The runtime sent an invalid encrypted application frame.`,!1);let r=await n.recipient.open(t),i=Hse(JSON.parse(new TextDecoder().decode(r))),a=this.requireReadyContext();if(!cl({application:i,context:a,payloadHash:await this.relayCrypto.sha256Base64Url(i.payload)}))throw new Go(`channel_authentication_failed`,`The decrypted runtime envelope does not match the active route.`,!1);qc(i.payload,a,this.journal),this.emit(`message`,new MessageEvent(`message`,{data:i.payload}))}async activateAuthenticatedRelay(e){this.context=e,this.authenticated=!0,this.lifecycle.onAuthenticated?.();let t=e===null?[]:this.replayForActor(e);for(let e of t)e.frame!==null&&this.enqueueFrame(e.frame,e);t.length>0&&await this.sendChain,this.emit(`open`,new Event(`open`))}replayForActor(e){return this.journal.fenceActor(e.runtimeId,e.actor.sessionId),this.journal.replayable(e.runtimeId,e.actor.sessionId)}};function dl(e,t,n=ml,r=zc({storage:zse(),randomUUID:n.randomUUID}),i={},a){return new ul(e,t,n,r,i,a).asWebSocket()}var fl=ko(cne);async function pl(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest(`SHA-256`,t);return btoa(String.fromCharCode(...new Uint8Array(n))).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replaceAll(`=`,``)}var ml={randomUUID:()=>crypto.randomUUID(),sha256Base64Url:pl},hl=`forge-relay-binding=`,nce=3e4;function rce(e){let t=new URL(String(e)).hash.slice(1);if(!t.startsWith(hl))throw Error(`Forge relay socket URL is missing its route binding.`);let n=decodeURIComponent(t.slice(20));if(n.length===0)throw Error(`Forge relay socket URL has an invalid route binding.`);return n}function ice(e){let t=e.crypto??ml,n=e.bindingTtlMs??nce,r=e.createSocket??((e,t)=>new globalThis.WebSocket(e,t)),i=new Map;return{acquireSocketUrl:async()=>{let r=await e.acquireRoute(),a=t.randomUUID();if(i.has(a))throw Error(`Forge relay route binding identifier was reused.`);let o=new URL(r.relayWebSocketUrl);o.hash=`${hl}${encodeURIComponent(a)}`;let s=setTimeout(()=>i.delete(a),n);return i.set(a,{route:r,expires:s}),o.toString()},constructSocket:(n,a)=>{let o=rce(n),s=i.get(o);if(s===void 0)throw Error(`Forge relay route binding is missing, expired, or already consumed.`);return i.delete(o),clearTimeout(s.expires),e.lifecycle?.onConnecting?.(),dl(r(s.route.relayWebSocketUrl,a),s.route,t,e.journal,e.lifecycle,e.acquireActionGrant)}}}async function ace(e){let t=e.issuedAt??new Date,n=e.crypto??ml;return{[On.requestId]:e.requestId??n.randomUUID(),[On.sequence]:String(e.sequence),[On.issuedAt]:t.toISOString(),[On.expiresAt]:new Date(t.getTime()+12e4).toISOString(),[On.payloadHash]:await n.sha256Base64Url(sae(e.payload))}}function oce(e,t){return tne(fne,({rpc:t,request:n,next:r})=>tt(function*(){return Jo({method:t._tag,payload:n.payload,grantedScopes:e}),yield*r(n)}))}function sce(e,t=ml){return fl.pipe(be(oce(e,t)))}function cce(e){let t=e.crypto??ml,n=ice({acquireRoute:e.acquireRoute,...e.acquireActionGrant?{acquireActionGrant:e.acquireActionGrant}:{},crypto:t,journal:e.journal,...e.lifecycle?{lifecycle:e.lifecycle}:{}}),r=dt(n.acquireSocketUrl).pipe(l),i=pe(oa,n.constructSocket),a=sa(r).pipe(E(i)),o=e.delayForRetry??oae,s=Ft(y(e.maxRetries??10),e=>$e(Be(o(e)??0)));return ut(Mo,No({retryPolicy:s,retryTransientErrors:!0})).pipe(E(Te(a,Oo)))}var gl=class extends Error{name=`RelayControlRouteSecurityFailure`};async function lce(e){let t=await gse(e),n=await jc(t.publicKey);return{keyPair:t,publicKey:n,keyId:_se(`control`,n),channelNonce:await hse(e)}}function uce(e){return{hpkeSuite:uc,controlEndpointKeyId:e.keyId,controlEndpointPublicKey:e.publicKey,controlChannelNonce:e.channelNonce}}function dce(e){let t=e.route;if(t.protocolVersion!==4||t.hpkeSuite!==`DHKEM_X25519_HKDF_SHA256/HKDF_SHA256/CHACHA20_POLY1305/AUTH`||!t.channelId||!t.runtimeEndpointKeyId||!t.runtimeEndpointPublicKey||t.controlEndpointKeyId!==e.endpoint.keyId||t.controlEndpointPublicKey!==e.endpoint.publicKey||t.controlChannelNonce!==e.endpoint.channelNonce)throw new gl(`Forge could not establish a verified end-to-end encrypted runtime route.`);return{...t,runtimeId:e.runtimeId,protocolVersion:4,channelId:t.channelId,hpkeSuite:uc,runtimeEndpointKeyId:t.runtimeEndpointKeyId,runtimeEndpointPublicKey:t.runtimeEndpointPublicKey,controlEndpointKeyId:e.endpoint.keyId,controlEndpointPublicKey:e.endpoint.publicKey,controlChannelNonce:e.endpoint.channelNonce,controlEndpointKeyPair:e.endpoint.keyPair,...e.digestProvider?{payloadDigestProvider:e.digestProvider}:{},...e.randomSource?{payloadRandomSource:e.randomSource}:{}}}var _l=`~effect/ManagedRuntime`,vl=(e,t)=>{let n=t?.memoMap??eee(),r=mee(`parallel`),i=k(r,`sequential`),a={onFiberStart:fe(r)},o=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,c,l=Mt(t=>(c||=m(kee(s(e,n,i),e=>st(()=>{u.cachedContext=e})),{...a,scheduler:t.currentScheduler}),Bee(ge(c)))),u={[_l]:_l,memoMap:n,scope:r,contextEffect:l,cachedContext:void 0,context(){return u.cachedContext===void 0?ne(u.contextEffect):Promise.resolve(u.cachedContext)},dispose(){return ne(u.disposeEffect)},disposeEffect:Et(()=>(u.contextEffect=_ee(`ManagedRuntime disposed`),u.cachedContext=void 0,ze(u.scope,xt))),runFork(e,t){return u.cachedContext===void 0?m(yl(u,e),o(t)):Ve(u.cachedContext)(e,o(t))},runCallback(e,t){return u.cachedContext===void 0?see(yl(u,e),o(t)):gte(u.cachedContext)(e,o(t))},runSyncExit(e){return u.cachedContext===void 0?Zee(yl(u,e)):se(u.cachedContext)(e)},runSync(e){return u.cachedContext===void 0?de(yl(u,e)):bee(u.cachedContext)(e)},runPromiseExit(e,t){return u.cachedContext===void 0?dee(yl(u,e),o(t)):gee(u.cachedContext)(e,o(t))},runPromise(e,t){return u.cachedContext===void 0?ne(yl(u,e),o(t)):te(u.cachedContext)(e,o(t))}};return u};function yl(e,t){return yt(e.contextEffect,e=>Ce(t,e))}function bl(e,t=xne){return`${e}\0${t}`}function fce(e){let t=new Map,n=!1;return{register(e){if(n)throw Error(`Terminal control sequencer is disposed.`);let r=bl(e.threadId,e.terminalId);t.get(r)?.sessionEpoch!==e.sessionEpoch&&t.set(r,{sessionEpoch:e.sessionEpoch,nextControlSequence:1,tail:Promise.resolve(),pendingWriteBytes:0})},enqueue(r){if(n)return Promise.reject(Error(`Terminal control sequencer is disposed.`));let i=r.terminalId??`default`,a=t.get(bl(r.threadId,i));if(!a)return Promise.reject(Error(`Terminal must be opened before sending controls.`));let o=r.writeBytes??0;if(a.pendingWriteBytes+o>e.maxPendingWriteBytes)return Promise.reject(Error(`Terminal input queue is full while reconnecting.`));a.pendingWriteBytes+=o;let s=a.tail.then(async()=>{let t=a.nextControlSequence;await r.execute({sessionEpoch:a.sessionEpoch,controllerId:e.controllerId,controlSequence:t}),a.nextControlSequence=t+1});return a.tail=s.finally(()=>{a.pendingWriteBytes-=o}).catch(()=>void 0),s},remove(e,n){if(n){t.delete(bl(e,n));return}let r=`${e}\0`;for(let e of t.keys())e.startsWith(r)&&t.delete(e)},terminalIds(e){let n=`${e}\0`;return[...t.keys()].filter(e=>e.startsWith(n)).map(e=>e.slice(n.length))},dispose(){n=!0,t.clear()}}}var xl={accept:!1,observe:!1,missingFrameCount:0,startsNewStream:!1};function Sl(e){let t=e===!0;return{accept:t,observe:t,missingFrameCount:0,startsNewStream:t}}function pce(e,t){let n=e.streamGeneration===void 0&&e.streamId===void 0,r=t.streamGeneration!==void 0||t.streamId!==void 0;return n&&r?Sl(t.keyframe):null}function mce(e,t){return e.streamGeneration===void 0||t.streamGeneration===void 0?null:t.streamGeneration<e.streamGeneration?xl:t.streamGeneration>e.streamGeneration?Sl(t.keyframe):null}function hce(e,t){if(!e.streamId||!t.streamId)return null;if(e.streamId!==t.streamId)return Sl(t.keyframe);if(t.sequence<=e.observedSequence)return xl;let n=Math.max(0,t.sequence-e.observedSequence-1);return{accept:n===0||t.keyframe===!0,observe:!0,missingFrameCount:n,startsNewStream:!1}}function gce(e,t){if(t.sequence>e.acceptedSequence)return{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1};if(!e.acceptedCapturedAt)return xl;let n=Date.parse(e.acceptedCapturedAt),r=Date.parse(t.capturedAt);return Number.isNaN(n)||Number.isNaN(r)||r<=n?xl:{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1}}function _ce(e,t){return pce(e,t)??mce(e,t)??hce(e,t)??gce(e,t)}function vce(e,t){let n=_ce(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}}Qn(mne);var Cl=hte(),wl=`Forge`,yce=`Alpha`,Tl=wl,El=`0.10.4`;function bce(e){return{_tag:`Value`,value:e}}function xce(e,t){return{_tag:`Record`,keys:e,value:t}}function Sce(e,t){return{_tag:`Array`,length:e,value:t}}Gn(`SourceError`);var Cce=bt(`effect/ConfigProvider`,{defaultValue:()=>Ece()}),wce={...le,toJSON(){return{_id:`ConfigProvider`}}};function Tce(e,t,n){let r=Object.create(wce);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 Ece(e){let t=e?.env??{APP_VERSION:`0.10.4`,BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`,VITE_COMMIT_SHA:``,VITE_HTTP_URL:``,VITE_SENTRY_COMMIT_SHA:`5f0060a9696edd41f61f06cbf24450a5994fed33`,VITE_SENTRY_DEBUG:``,VITE_SENTRY_DSN:``,VITE_SENTRY_ENABLED:``,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_PROFILES_SAMPLE_RATE:``,VITE_SENTRY_RELEASE:`forge-web@0.10.4+5f0060a9696edd41f61f06cbf24450a5994fed33`,VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE:``,VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE:``,VITE_SENTRY_TRACES_SAMPLE_RATE:``,VITE_WS_URL:``},n=Dce(t);return Tce(e=>$e(kce(n,t,e)))}function Dce(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 Oce=/^(0|[1-9][0-9]*)$/;function kce(e,t,n){let r=t[n.map(String).join(`_`)],i=Ace(e,n),a=i?.children?Object.keys(i.children):[];return a.length===0?r===void 0?void 0:bce(r):a.every(e=>Oce.test(e))?Sce(Math.max(...a.map(e=>parseInt(e,10)))+1,r):xce(new Set(a),r)}function Ace(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 Dl=`~effect/Config`,jce=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},Mce={...le,...ae,[Dl]:Dl,asEffect(){return yt(Cce.asEffect(),e=>this.parse(e))},toJSON(){return{_id:`Config`}}};function Nce(e){let t=Object.create(Mce);return t.parse=e,t}var Ol=Je(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*Ol(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*Ol(e,[...t,i]));return r}}}),kl=Je(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*kl(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=zte(a.parameter);for(let o of i.keys)if(!Object.hasOwn(r,o)&&e(o)){let e=yield*kl(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*kl(e.elements[r],t,[...n,r]));return i}case`Union`:return yield*Ol(t,n);case`Suspend`:return yield*kl(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 Al(e,t){let n=Ute(e),r=qte(n),i=Ate(n.ast),a=typeof t==`string`?[t]:t??[];return Nce(e=>{let t=e.prefix?[...e.prefix,...a]:a;return kl(i,e,a).pipe(tte(e=>r(e).pipe(Pt(e=>new Fte(t.length>0?new Zte(t,e):e)))),Pt(e=>new jce(e)))})}var Pce=(e,t,n)=>{let r=Mn(e,t),i=Un.pipe($n(Mn(Un,Un),Xte(n)),$n(r));return Tn([r,i])},Fce=yte(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),jl=!1,Ml=!1,Nl=null,Pl=null,Fl=null,Il=!1,Ll=new Set;function Ice(e){if(jl||Ml)return;if(!e.publicKey||!e.host){Ml=!0;return}if(Nl)return;if(typeof window>`u`||typeof location>`u`){Ml=!0;return}let t=e.publicKey,n=e.host;Nl=N(async()=>{let{default:e}=await import(`./module-CPO4cjSm.js`);return{default:e}},[]).then(({default:e})=>{Pl=e,e.init(t,{api_host:n,person_profiles:`identified_only`,capture_pageview:!1,capture_pageleave:!1,autocapture:!1,disable_session_recording:!0,loaded:()=>{jl=!0,Fl&&Rl(Fl),zl(),Ll.forEach(e=>e())}})}).catch(()=>{Ml=!0,Pl=null})}function Rl(e){if(Fl=e,!jl||!Pl)return;let t={};e.email!==void 0&&(t.email=e.email),e.displayName!==void 0&&(t.name=e.displayName),Pl.identify(e.cmmdUserId,t)}function Lce(e){return!jl||!Pl?!1:Pl.isFeatureEnabled(e)===!0}function zl(){!Pl||Il||(Il=!0,Pl.onFeatureFlags(()=>{Ll.forEach(e=>e())}))}function Rce(e){return Ll.add(e),jl&&Pl&&(zl(),e()),()=>{Ll.delete(e)}}var Bl=`token`;function Vl(e){return new URLSearchParams(e.hash.startsWith(`#`)?e.hash.slice(1):e.hash)}function Hl(e){let t=Vl(e).get(Bl)?.trim()??``;if(t.length>0)return t;let n=e.searchParams.get(Bl)?.trim()??``;return n.length>0?n:null}function zce(e){let t=new URL(e.toString()),n=Vl(t);return n.has(Bl)&&(n.delete(Bl),t.hash=n.toString()),t.searchParams.delete(Bl),t}function Ul(e,t){let n=new URL(e.toString());return n.searchParams.delete(Bl),n.hash=new URLSearchParams([[Bl,t]]).toString(),n}function Bce(e,t){let n=new URL(e);return n.pathname=`/login`,Ul(n,t).toString()}function Vce(e){return Ul(new URL(`/login`,window.location.href),e).toString()}function Hce(e){let t=new URL(e),n=Hl(t),r=new URL(`forge:///pair`);return r.searchParams.set(`serverUrl`,t.origin),n&&r.searchParams.set(Bl,n),r.toString()}var B=typeof __SENTRY_DEBUG__>`u`||__SENTRY_DEBUG__,V=globalThis,Wl=`10.70.0`;function Gl(){return Kl(V),V}function Kl(e){let t=e.__SENTRY__=e.__SENTRY__||{};return t.version=t.version||`10.70.0`,t[Wl]=t[`10.70.0`]||{}}function ql(e,t,n=V){let r=n.__SENTRY__=n.__SENTRY__||{},i=r[Wl]=r[`10.70.0`]||{};return i[e]||(i[e]=t())}var Jl=[`debug`,`info`,`warn`,`error`,`log`,`assert`,`trace`],Uce=`Sentry Logger `,Yl={};function Xl(e){if(!(`console`in V))return e();let t=V.console,n={},r=Object.keys(Yl);r.forEach(e=>{let r=Yl[e];n[e]=t[e],t[e]=r});try{return e()}finally{r.forEach(e=>{t[e]=n[e]})}}function Wce(){$l().enabled=!0}function Gce(){$l().enabled=!1}function Zl(){return $l().enabled}function Kce(...e){Ql(`log`,...e)}function qce(...e){Ql(`warn`,...e)}function Jce(...e){Ql(`error`,...e)}function Ql(e,...t){B&&Zl()&&Xl(()=>{V.console[e](`${Uce}[${e}]:`,...t)})}function $l(){return B?ql(`loggerSettings`,()=>({enabled:!1})):{enabled:!1}}var H={enable:Wce,disable:Gce,isEnabled:Zl,log:Kce,warn:qce,error:Jce},eu=50,tu=/\(error: (.*)\)/,nu=/captureMessage|captureException/;function ru(...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=tu.test(n)?n.replace(tu,`$1`):n;if(!o.includes(`Error: `)){for(let e of t){let t=e(o);if(t){i.push(t);break}}if(i.length>=eu+r)break}}return Xce(i.slice(r))}}function Yce(e){return Array.isArray(e)?ru(...e):e}function Xce(e){if(!e.length)return[];let t=Array.from(e);return/sentryWrapped/.test(iu(t).function||``)&&t.pop(),t.reverse(),nu.test(iu(t).function||``)&&(t.pop(),nu.test(iu(t).function||``)&&t.pop()),t.slice(0,eu).map(e=>({...e,filename:e.filename||iu(t).filename,function:e.function||`?`}))}function iu(e){return e[e.length-1]||{}}var au=`<anonymous>`;function ou(e){try{return!e||typeof e!=`function`?au:e.name||au}catch{return au}}function su(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 Zce(e){let t=e?.startsWith(`file://`)?e.slice(7):e;return t?.match(/\/[A-Z]:/)&&(t=t.slice(1)),t}var cu={},lu={};function uu(e,t){return cu[e]=cu[e]||[],cu[e].push(t),()=>{let n=cu[e];if(n){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}function du(e,t){if(!lu[e]){lu[e]=!0;try{t()}catch(t){B&&H.error(`Error while instrumenting ${e}`,t)}}}function fu(e,t){let n=e&&cu[e];if(n)for(let r of n)try{r(t)}catch(t){B&&H.error(`Error while triggering instrumentation handler.
|
|
4
4
|
Type: ${e}
|
|
5
5
|
Name: ${ou(r)}
|
|
@@ -1002,33 +1002,33 @@ or you can use record.mirror to access the mirror instance during recording.`,RH
|
|
|
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.`,QW={map:{},getId(){return console.error(ZW),-1},getNode(){return console.error(ZW),null},removeNodeFromMap(){console.error(ZW)},has(){return console.error(ZW),!1},reset(){console.error(ZW)}};typeof window<`u`&&window.Proxy&&window.Reflect&&(QW=new Proxy(QW,{get(e,t,n){return t===`map`&&console.error(ZW),Reflect.get(e,t,n)}}));function $W(e,t,n,r,i=window){let a=i.Object.getOwnPropertyDescriptor(e,t);return i.Object.defineProperty(e,t,r?n:{set(e){aG(()=>{n.set.call(this,e)},0),a&&a.set&&a.set.call(this,e)}}),()=>$W(e,t,a||{},!0)}function eG(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 NHe(e){if(!e)return null;try{return e.nodeType===e.ELEMENT_NODE?e:e.parentElement}catch{return null}}function tG(e,t,n,r,i){if(!e)return!1;let a=NHe(e);if(!a)return!1;let o=XW(t,n);if(!i){let e=r&&a.matches(r);return o(a)&&!e}let s=YW(a,o),c=-1;return s<0?!1:(r&&(c=YW(a,XW(null,r))),s>-1&&c<0||s<c)}var nG={};function rG(e){let t=nG[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 nG[e]=r.bind(window)}function iG(...e){return rG(`requestAnimationFrame`)(...e)}function aG(...e){return rG(`setTimeout`)(...e)}var oG=(e=>(e[e[`2D`]=0]=`2D`,e[e.WebGL=1]=`WebGL`,e[e.WebGL2=2]=`WebGL2`,e))(oG||{}),sG;function PHe(e){sG=e}for(var cG=e=>sG?((...t)=>{try{return e(...t)}catch(e){if(sG&&sG(e)===!0)return()=>{};throw e}}):e,lG=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,FHe=typeof Uint8Array>`u`?[]:new Uint8Array(256),uG=0;uG<lG.length;uG++)FHe[lG.charCodeAt(uG)]=uG;var IHe=function(e){var t=new Uint8Array(e),n,r=t.length,i=``;for(n=0;n<r;n+=3)i+=lG[t[n]>>2],i+=lG[(t[n]&3)<<4|t[n+1]>>4],i+=lG[(t[n+1]&15)<<2|t[n+2]>>6],i+=lG[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},dG=new Map;function LHe(e,t){let n=dG.get(e);return n||(n=new Map,dG.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}var fG=(e,t,n)=>{if(!e||!(hG(e,t)||typeof e==`object`))return;let r=e.constructor.name,i=LHe(n,r),a=i.indexOf(e);return a===-1&&(a=i.length,i.push(e)),a};function pG(e,t,n){if(e instanceof Array)return e.map(e=>pG(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:IHe(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[pG(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:[pG(e.data,t,n),e.width,e.height]}:hG(e,t)||typeof e==`object`?{rr_type:e.constructor.name,index:fG(e,t,n)}:e}var mG=(e,t,n)=>e.map(e=>pG(e,t,n)),hG=(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 RHe(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=eG(t.CanvasRenderingContext2D.prototype,s,function(a){return function(...o){return tG(this.canvas,n,r,i,!0)||aG(()=>{let n=mG(o,t,this);e(this.canvas,{type:oG[`2D`],property:s,args:n})},0),a.apply(this,o)}});a.push(o)}catch{let n=$W(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:oG[`2D`],property:s,args:[t],setter:!0})}});a.push(n)}return()=>{a.forEach(e=>e())}}function zHe(e){return e===`experimental-webgl`?`webgl`:e}function gG(e,t,n,r,i){let a=[];try{let o=eG(e.HTMLCanvasElement.prototype,`getContext`,function(e){return function(a,...o){if(!tG(this,t,n,r,!0)){let e=zHe(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 _G(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=eG(e,o,function(e){return function(...c){let l=e.apply(this,c);if(fG(l,s,this),`tagName`in this.canvas&&!tG(this.canvas,r,i,a,!0)){let e=mG(c,s,this),r={type:t,property:o,args:e};n(this.canvas,r)}return l}});c.push(l)}catch{let r=$W(e,o,{set(e){n(this.canvas,{type:t,property:o,args:[e],setter:!0})}});c.push(r)}return c}function BHe(e,t,n,r,i,a){let o=[];return o.push(..._G(t.WebGLRenderingContext.prototype,oG.WebGL,e,n,r,i,a,t)),t.WebGL2RenderingContext!==void 0&&o.push(..._G(t.WebGL2RenderingContext.prototype,oG.WebGL2,e,n,r,i,a,t)),()=>{o.forEach(e=>e())}}var VHe=`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 HHe(){let e=new Blob([VHe]);return URL.createObjectURL(e)}var UHe=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&&PHe(a),(i&&typeof n==`number`||t)&&(this.worker=this.initFPSWorker()),this.addWindow(r),!t&&cG(()=>{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}cG(()=>{if(a&&t===`all`&&this.initCanvasMutationObserver(e,n,r,i),a&&typeof t==`number`){let t=gG(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}iG(t=>this.takeSnapshot(t,!0,e))}initFPSWorker(){let e=new Worker(HHe());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:oG[`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=iG(t)};e=iG(t),this.restoreHandlers.push(()=>{e&&cancelAnimationFrame(e)})}initCanvasMutationObserver(e,t,n,r){let i=gG(e,t,n,r,!1),a=RHe(this.processMutation.bind(this),e,t,n,r),o=BHe(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=>{tG(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=>{cG(()=>{throw this.snapshotInProgressMap.delete(n),e})()})}}),!0)}startPendingCanvasMutationFlusher(){iG(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){let e=t=>{this.rafStamps.latestId=t,iG(e)};iG(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{let n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),iG(()=>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)}jHe();var WHe;(function(e){e[e.NotStarted=0]=`NotStarted`,e[e.Running=1]=`Running`,e[e.Stopped=2]=`Stopped`})(WHe||={});var vG={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}}},GHe=`ReplayCanvas`,yG=1280,KHe=aP(((e={})=>{let[t,n]=e.maxCanvasSize||[],r={quality:e.quality||`medium`,enableManualSnapshot:e.enableManualSnapshot,maxCanvasSize:[t?Math.min(t,yG):yG,n?Math.min(n,yG):yG]},i,a,o=new Promise(e=>a=e);return{name:GHe,getOptions(){let{quality:e,enableManualSnapshot:t,maxCanvasSize:n}=r;return{enableManualSnapshot:t,recordCanvas:!0,getCanvasManager:e=>{let r=new UHe({...e,enableManualSnapshot:t,maxCanvasSize:n,errorHandler:e=>{try{typeof e==`object`&&(e.__rrweb__=!0)}catch{}}});return i=r,a(r),r},...vG[e]||vG.medium}},async snapshot(e,t){(i||await o).snapshot(e,t)}}}));function qHe(e){return e.split(`,`).some(e=>e.trim().startsWith(`sentry-`))}function bG(e){try{return new URL(e,Z.location.origin).href}catch{return}}function JHe(e){return e.entryType===`resource`&&`initiatorType`in e&&typeof e.nextHopProtocol==`string`&&(e.initiatorType===`fetch`||e.initiatorType===`xmlhttprequest`)}function xG(e){try{return new Headers(e)}catch{return}}var SG={traceFetch:!0,traceXHR:!0,enableHTTPTimings:!0,trackFetchStreamPerformance:!1};function CG(e,t){let{traceFetch:n,traceXHR:r,shouldCreateSpanForRequest:i,enableHTTPTimings:a,tracePropagationTargets:o,onRequestSpanStart:s,onRequestSpanEnd:c}={...SG,...t},l=typeof i==`function`?i:e=>!0,u=e=>XHe(e,o),d={},f=e.getOptions().propagateTraceparent;n&&WL(t=>{let n=xje(t,l,u,d,{propagateTraceparent:f,onRequestSpanEnd:c});if(n){let r=bG(t.fetchData.url),i=r?dF(r).host:void 0,o=r?pF(r):void 0;n.setAttributes({"http.url":o,"url.full":o,"server.address":i}),a&&wG(n,e),s?.(n,{headers:t.headers})}}),r&&pV(t=>{let n=ZHe(t,l,u,d,f,c);n&&(a&&wG(n,e),s?.(n,{headers:xG(t.xhr.__sentry_xhr_v3__?.request_headers)}))})}var YHe=300;function wG(e,t){let{url:n}=yj(e).data;if(!n||typeof n!=`string`)return;let r=()=>void setTimeout(i);if(lM(t)){let t=e.end.bind(e);e.end=e=>{let n=e??cA(),a=!1,o=()=>{a||(a=!0,setTimeout(i),t(n),clearTimeout(s))};r=o;let s=setTimeout(o,YHe)}}let i=DB(`resource`,({entries:t})=>{t.forEach(t=>{JHe(t)&&t.name.endsWith(n)&&(e.setAttributes(WB(t)),r())})})}function XHe(e,t){let n=XL();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?Qk(r.toString(),t)||a&&Qk(r.pathname,t):a}{let n=!!e.match(/^\/(?!\/)/);return t?Qk(e,t):n}}function ZHe(e,t,n,r,i,a){let o=e.xhr,s=o?.[fV];if(!o||o.__sentry_own_request__||!s)return;let{url:c,method:l}=s,u=zj()&&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&&(qA(n,s.status_code),n.end(),a?.(n,{headers:xG(_V(o)),error:e.error})),delete r[t]);return}let d=bG(c),f=dF(d||c),p=d?pF(d):void 0,m=pF(fF(c)),h=X(),g=!!Fj(),_=g||!!h&&lM(h),v=u&&_?vM({name:`${l} ${m}`,attributes:{url:pF(c),type:`xhr`,"http.method":l,"http.url":p,"url.full":p,"server.address":f?.host,[zA]:`auto.http.browser`,[RA]:`http.client`,...f?.search&&{"http.query":f?.search},...f?.hash&&{"http.fragment":f?.hash}}}):new Uj,y=kM(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)&&QHe(o,zj()&&_?y:void 0,i),h&&h.emit(`beforeOutgoingRequestSpan`,v,e),v}function QHe(e,t,n){let{"sentry-trace":r,baggage:i,traceparent:a}=_F({span:t,propagateTraceparent:n});r&&$He(e,r,i,a)}function $He(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||!qHe(t))&&e.setRequestHeader(`baggage`,n)}}catch{}}var TG=new WeakMap,EG=new WeakMap,eUe=9e4,tUe=[`text/event-stream`,`application/x-ndjson`,`application/stream+json`],DG=aP(()=>({name:`FetchStreamPerformance`,setup(){UNe(e=>{if(e.response){let t=TG.get(e.response);if(t&&e.endTimestamp){t.end(e.endTimestamp);let n=EG.get(e.response);n&&clearTimeout(n)}}}),WL(e=>{if(e.endTimestamp&&e.response){let t=e.response.headers?.get(`content-type`)||``;if(e.response.headers?.get(`content-length`)||!tUe.some(e=>t.startsWith(e)))return;let n=e.fetchData?.url||``,r=e.fetchData?.method||`GET`,i=lF(n),a=vM({name:`${r} ${n.startsWith(`data:`)?pF(n):i?uF(i):n}`,startTime:e.endTimestamp,attributes:{url:pF(n),"http.method":r,type:`fetch`,[RA]:`http.client.stream`,[zA]:`auto.http.browser.stream`}});TG.set(e.response,a);let o=setTimeout(()=>{a.isRecording()&&a.end()},eUe);EG.set(e.response,o)}})}})),nUe=`WebVitals`,OG=aP((e={})=>{let t=new Set(e.ignore??[]);return{name:nUe,setup(n){let r=lM(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=OIe({recordClsStandaloneSpans:o,recordLcpStandaloneSpans:s,client:n}),l=new WeakSet;n.on(`afterStartPageLoadSpan`,e=>{l.add(e)}),n.on(`spanEnd`,e=>{l.delete(e)&&(c(),LIe(e,{recordClsOnPageloadSpan:o===!1,recordLcpOnPageloadSpan:s===!1,spanStreamingEnabled:r}))}),r?(t.has(`lcp`)||nLe(n),t.has(`cls`)||iLe(n),t.has(`inp`)||oLe()):t.has(`inp`)||ZIe()},afterAllSetup(){t.has(`inp`)||tLe()}}});function rUe(){Z.document?Z.document.addEventListener(`visibilitychange`,()=>{let e=Fj();if(!e)return;let t=Nj(e);if(Z.document.hidden&&t){let e=`cancelled`,{op:n,status:r}=yj(t);Q&&Y.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()}}):Q&&Y.warn(`[Tracing] Could not set up background tab detection due to lack of global document`)}var kG=`sentry_previous_trace`,iUe=`sentry.previous_trace`;function aUe(e,{linkPreviousTrace:t,consistentTraceSampling:n}){let r=t===`session-storage`,i=r?cUe():void 0;e.on(`spanStart`,e=>{if(Nj(e)!==e)return;let t=jA().getPropagationContext();i=oUe(i,e,t),r&&sUe(i)});let a=!0;n&&e.on(`beforeSampling`,e=>{if(!i)return;let t=jA(),n=t.getPropagationContext();if(a&&n.parentSpanId){a=!1;return}t.setPropagationContext({...n,dsc:{...n.dsc,sample_rate:String(i.sampleRate),sampled:String(AG(i.spanContext))},sampleRand:i.sampleRand}),e.parentSampled=AG(i.spanContext),e.parentSampleRate=i.sampleRate,e.spanAttributes={...e.spanAttributes,[pOe]:i.sampleRate}})}function oUe(e,t,n){let r=yj(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&&(Q&&Y.log(`Adding previous_trace \`${JSON.stringify(o)}\` link to span \`${JSON.stringify({op:r.op,...t.spanContext()})}\``),t.addLink({context:o,attributes:{[SOe]:`previous_trace`}}),t.setAttribute(iUe,`${o.traceId}-${o.spanId}-${+!!AG(o)}`)),a)}function sUe(e){try{Z.sessionStorage.setItem(kG,JSON.stringify(e))}catch(e){Q&&Y.warn(`Could not store previous trace in sessionStorage`,e)}}function cUe(){try{let e=Z.sessionStorage?.getItem(kG);return JSON.parse(e)}catch{return}}function AG(e){return e.traceFlags===1}var lUe=`BrowserTracing`,uUe=/Googlebot|Google-InspectionTool|Storebot-Google|Bingbot|Slurp|DuckDuckBot|Baiduspider|YandexBot|Facebot|facebookexternalhit|LinkedInBot|Twitterbot|Applebot/i;function jG(){let e=Z.navigator;return e?.userAgent?uUe.test(e.userAgent):!1}var dUe={...AM,instrumentNavigation:!0,instrumentPageLoad:!0,markBackgroundSpan:!0,enableLongTask:!0,enableLongAnimationFrame:!0,enableInp:!0,ignoreResourceSpans:[],ignorePerformanceApiSpans:[],detectRedirects:!0,linkPreviousTrace:`in-memory`,consistentTraceSampling:!1,enableReportPageLoaded:!1,_experiments:{},...SG},MG=((e={})=>{`enableElementTiming`in e&&JO(()=>{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=Z.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:D,onRequestSpanEnd:O}={...dUe,...e},ee=jG(),te,k;function A(e,r,i=!0,a){let o=r.op===`pageload`,s=r.name,c=l?l(r):r,p=lF(a||XL()),m={...p?.pathname&&{"url.path":p.pathname},...p&&!cF(p)&&{"url.full":p.href},...c.attributes};if(s!==c.name&&(m[IA]=`custom`),c.attributes=m,!i){let e=sA();vM({...c,startTime:e}).end(e);return}t.name=c.name,t.source=m[IA];let h=jM(c,{idleTimeout:u,finalTimeout:d,childSpanTimeout:f,disableAutoFinish:o,beforeSpanEnd:t=>{IIe(t,{ignoreResourceSpans:y,ignorePerformanceApiSpans:b,spanStreamingEnabled:lM(e)}),zG(e,void 0);let n=jA(),r=n.getPropagationContext();n.setPropagationContext({...r,traceId:h.spanContext().traceId,sampled:Tj(h),dsc:Yj(t)}),o&&(k=void 0)},trimIdleSpanEndTimestamp:!E});o&&E&&(k=h),zG(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:lUe,setup(e){if(ee){Q&&Y.log(`[Tracing] Skipping browserTracingIntegration setup for bot user agent.`);return}if(Rj(),a&&J.PerformanceObserver&&PerformanceObserver.supportedEntryTypes?.includes(`long-animation-frame`)?AIe():i&&kIe(),o&&jIe(),C&&n){let e=()=>{te=cA()};addEventListener(`click`,e,{capture:!0}),addEventListener(`keydown`,e,{capture:!0,passive:!0})}function t(){let t=RG(e);t&&!yj(t).timestamp&&(Q&&Y.log(`[Tracing] Finishing current active span with op: ${yj(t).op}`),t.setAttribute(BA,`cancelled`),t.end())}e.on(`startNavigationSpan`,(n,r)=>{if(X()!==e)return;if(r?.isRedirect){Q&&Y.warn(`[Tracing] Detected redirect, navigation span will not be the root span, but a child span.`),A(e,{op:`navigation.redirect`,...n},!1,r.url);return}te=void 0,t(),MA().setPropagationContext({traceId:pA(),sampleRand:Math.random(),propagationSpanId:zj()?void 0:mA()});let i=jA();i.setPropagationContext({traceId:pA(),sampleRand:Math.random(),propagationSpanId:zj()?void 0:mA()}),i.setSDKProcessingMetadata({normalizedRequest:void 0}),A(e,{op:`navigation`,...n,parentSpan:null,forceTransaction:!0},!0,r?.url)}),e.on(`startPageLoadSpan`,(n,r={})=>{if(X()!==e)return;t();let i=uj(r.sentryTrace||FG(`sentry-trace`)||IG(`sentry-trace`),r.baggage||FG(`baggage`)||IG(`baggage`)),a=jA();a.setPropagationContext(i),zj()||(a.getPropagationContext().propagationSpanId=mA()),a.setSDKProcessingMetadata({normalizedRequest:Pz()}),A(e,{op:`pageload`,...n})}),e.on(`endPageloadSpan`,()=>{E&&k&&(k.setAttribute(BA,`reportPageLoaded`),k.end())})},afterAllSetup(e){if(ee)return;e.addIntegration&&!e.getIntegrationByName?.(`WebVitals`)&&e.addIntegration(OG({ignore:r?[]:[`inp`],_experiments:{enableStandaloneClsSpans:s,enableStandaloneLcpSpans:c}}));let n=XL();if(w!==`off`&&aUe(e,{linkPreviousTrace:w,consistentTraceSampling:T}),Z.location){if(x){let t=uA();NG(e,{name:Z.location.pathname,startTime:t?t/1e3:void 0,attributes:{[IA]:`url`,[zA]:`auto.pageload.browser`}})}S&&cV(({to:t,from:r})=>{if(r===void 0&&n?.indexOf(t)!==-1){n=void 0;return}n=void 0;let i=lF(t),a=RG(e),o=a&&C&&pUe(a,te);PG(e,{name:i?.pathname||Z.location.pathname,attributes:{[IA]:`url`,[zA]:`auto.navigation.browser`}},{url:t,isRedirect:o})})}p&&rUe(),o&&fUe(e,u,d,f,t),CG(e,{traceFetch:m,traceXHR:h,tracePropagationTargets:e.getOptions().tracePropagationTargets,shouldCreateSpanForRequest:_,enableHTTPTimings:v,onRequestSpanStart:D,onRequestSpanEnd:O}),g&&e.addIntegration(DG())}}});function NG(e,t,n){e.emit(`startPageLoadSpan`,t,n),jA().setTransactionName(t.name);let r=RG(e);return r&&e.emit(`afterStartPageLoadSpan`,r),r}function PG(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=jA();return a.setTransactionName(t.name),r&&!i&&a.setSDKProcessingMetadata({normalizedRequest:{...Pz(),url:r}}),RG(e)}function FG(e){return(Z.document?.querySelector(`meta[name=${e}]`))?.getAttribute(`content`)||void 0}function IG(e){return(Z.performance?.getEntriesByType?.(`navigation`)[0])?.serverTiming?.find(t=>t.name===e)?.description}function fUe(e,t,n,r,i){let a=Z.document,o;a&&addEventListener(`click`,()=>{let a=`ui.action.click`,s=RG(e);if(s){let e=yj(s).op;if([`navigation`,`pageload`].includes(e)){Q&&Y.warn(`[Tracing] Did not create ${a} span because a pageload or navigation span is in progress.`);return}}if(o&&=(o.setAttribute(BA,`interactionInterrupted`),o.end(),void 0),!i.name){Q&&Y.warn(`[Tracing] Did not create ${a} transaction because _latestRouteName is missing.`);return}o=jM({name:i.name,op:a,attributes:{[IA]:i.source||`url`}},{idleTimeout:t,finalTimeout:n,childSpanTimeout:r})},{capture:!0})}var LG=`_sentry_idleSpan`;function RG(e){return e[LG]}function zG(e,t){Mk(e,LG,t)}var BG=1.5;function pUe(e,t){let n=yj(e),r=sA();return!(r-n.start_timestamp>BG||t&&r-t<=BG)}function mUe(e=X()){e?.emit(`endPageloadSpan`)}function hUe(e){let t=Fj();if(t===e)return;let n=jA();e.end=new Proxy(e.end,{apply(e,r,i){return vA(n,t),Reflect.apply(e,r,i)}}),vA(n,e)}var gUe=aP(()=>({name:`SpanStreaming`,beforeSetup(e){let t=e.getOptions();t.traceLifecycle||=(Q&&Y.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(!lM(e)){r.traceLifecycle=`static`,Q&&Y.warn(`${t} \`traceLifecycle\` to be set to "stream"! ${n}`);return}let i=r.beforeSendSpan;if(i&&!Xj(i)){r.traceLifecycle=`static`,Q&&Y.warn(`${t} a beforeSendSpan callback using \`withStreamedSpan\`! ${n}`);return}let a=new zNe(e);e.on(`afterSpanEnd`,t=>{Tj(t)&&a.add(YM(t,e))}),e.on(`afterSegmentSpanEnd`,e=>{let t=e.spanContext().traceId;setTimeout(()=>{a.flush(t)},500)})}})),VG=1e6,_Ue=`window`in J&&J.window===J&&typeof importScripts>`u`,HG=`0`,UG=_Ue?`main`:`worker`,WG=Z.navigator,GG=``,KG=``,qG=``,JG=WG?.userAgent||``,YG=``,vUe=WG?.language||WG?.languages?.[0]||``;function yUe(e){return typeof e==`object`&&!!e&&`getHighEntropyValues`in e}var XG=WG?.userAgentData;yUe(XG)&&XG.getHighEntropyValues([`architecture`,`model`,`platform`,`platformVersion`,`fullVersionList`]).then(e=>{if(GG=e.platform||``,qG=e.architecture||``,YG=e.model||``,KG=e.platformVersion||``,e.fullVersionList?.length){let t=e.fullVersionList[e.fullVersionList.length-1];JG=`${t.brand} ${t.version}`}}).catch(e=>void 0);function bUe(e){return!(`thread_metadata`in e)}function xUe(e){return bUe(e)?DUe(e):e}function SUe(e){let t=e.contexts?.trace?.trace_id;return typeof t==`string`&&t.length!==32&&Q&&Y.log(`[Profiling] Invalid traceId: ${t} on profiled event`),typeof t==`string`?t:``}function CUe(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=SUe(r),a=xUe(n),o=t||(typeof r.start_timestamp==`number`?r.start_timestamp*1e3:cA()*1e3),s=typeof r.timestamp==`number`?r.timestamp*1e3:cA()*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:Z.navigator.userAgent},os:{name:GG,version:KG,build_number:JG},device:{locale:vUe,model:YG,manufacturer:JG,architecture:qG,is_emulator:!1},debug_meta:{images:QG(n.resources)},profile:a,transactions:[{name:r.transaction||``,id:r.event_id||eA(),trace_id:i,active_thread_id:HG,relative_start_ns:`0`,relative_end_ns:((s-o)*1e6).toFixed(0)}]}}function wUe(e,t,n){if(e==null)throw TypeError(`Cannot construct profiling event envelope without a valid profile. Got ${e} instead.`);let r=EUe(e),i=t.getOptions(),a=t.getSdkMetadata?.()?.sdk;return{chunk_id:eA(),client_sdk:{name:a?.name??`sentry.javascript.browser`,version:a?.version??`0.0.0`},profiler_id:n||eA(),platform:`javascript`,version:`2`,release:i.release??``,environment:i.environment??`production`,debug_meta:{images:QG(e.resources)},profile:r}}function TUe(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 EUe(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=uA(),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:HG,timestamp:r}}return{frames:t,stacks:n,samples:o,thread_metadata:{[HG]:{name:UG}}}}function ZG(e){return yj(e).op===`pageload`}function DUe(e){let t,n=0,r={samples:[],stacks:[],frames:[],thread_metadata:{[HG]:{name:UG}}},i=e.samples[0];if(!i)return r;let a=i.timestamp,o=uA(),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)*VG).toFixed(0),stack_id:t,thread_id:HG};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)*VG).toFixed(0),stack_id:n,thread_id:HG};r.stacks[n]=l,r.samples[o]=u,n++}),r}function OUe(e,t){if(!t.length)return e;for(let n of t)e[1].push([{type:`profile`},n]);return e}function kUe(e){let t=[];return $j(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 QG(e){let t=X()?.getOptions()?.stackParser;return t?mN(t,e):[]}function $G(e){return typeof e!=`number`&&typeof e!=`boolean`||typeof e==`number`&&isNaN(e)?(Q&&Y.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?(Q&&Y.warn(`[Profiling] Invalid sample rate. Sample rate must be between 0 and 1. Got ${e}.`),!1):!0}function AUe(e){return e.samples.length<2?(Q&&Y.log(`[Profiling] Discarding profile because it contains less than 2 samples`),!1):e.frames.length?!0:(Q&&Y.log(`[Profiling] Discarding profile because it contains no frames`),!1)}var eK=!1,tK=3e4;function jUe(e){return typeof e==`function`}function nK(){let e=Z.Profiler;if(!jUe(e)){Q&&Y.log(`[Profiling] Profiling is not supported by this browser, Profiler interface missing on window object.`);return}let t=Math.floor(tK/10);try{return new e({sampleInterval:10,maxBufferSize:t})}catch{Q&&(Y.log(`[Profiling] Failed to initialize the Profiling constructor, this is likely due to a missing 'Document-Policy': 'js-profiling' header.`),Y.log(`[Profiling] Disabling profiling for current user session.`)),eK=!0}}function rK(e){if(eK)return Q&&Y.log(`[Profiling] Profiling has been disabled for the duration of the current user session.`),!1;if(!e.isRecording())return Q&&Y.log(`[Profiling] Discarding profile because root span was not sampled.`),!1;let t=X()?.getOptions();if(!t)return Q&&Y.log(`[Profiling] Profiling disabled, no options found.`),!1;let n=t.profilesSampleRate;return $G(n)?n?n===!0||Math.random()<n||(Q&&Y.log(`[Profiling] Discarding profile because it's not included in the random sample (sampling rate = ${Number(n)})`),!1):(Q&&Y.log(`[Profiling] Discarding profile because a negative sampling decision was inherited or profileSampleRate is set to 0`),!1):(Q&&Y.warn(`[Profiling] Discarding profile because of invalid sample rate.`),!1)}function MUe(e){if(eK)return Q&&Y.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 Q&&Y.warn("[Profiling] Session not sampled. Invalid `profileLifecycle` option."),!1;let t=e.profileSessionSampleRate;return $G(t)?t?Math.random()<=t:(Q&&Y.log(`[Profiling] Discarding profile because profileSessionSampleRate is not defined or set to 0`),!1):(Q&&Y.warn(`[Profiling] Discarding profile because of invalid profileSessionSampleRate.`),!1)}function iK(e){return e.profilesSampleRate!==void 0}function NUe(e,t,n,r){return AUe(n)?CUe(e,t,n,r):null}var aK=new Map;function PUe(){return aK.size}function FUe(e){let t=aK.get(e);return t&&aK.delete(e),t}function IUe(e,t){if(aK.set(e,t),aK.size>30){let e=aK.keys().next().value;e!==void 0&&aK.delete(e)}}var oK=new WeakSet;function sK(e){e.setAttribute(`thread.id`,HG),e.setAttribute(`thread.name`,UG)}function cK(e){let t;ZG(e)&&(t=cA()*1e3);let n=nK();if(!n)return;Q&&Y.log(`[Profiling] started profiling span: ${yj(e).description}`);let r=eA(),i=null;jA().setContext(`profile`,{profile_id:r,start_timestamp:t}),oK.add(e),sK(e);async function a(){if(e&&n){if(i){Q&&Y.log(`[Profiling] profile for:`,yj(e).description,`already exists, returning early`);return}return n.stop().then(t=>{if(o&&=(Z.clearTimeout(o),void 0),Q&&Y.log(`[Profiling] stopped profiling of span: ${yj(e).description}`),!t){Q&&Y.log(`[Profiling] profiler returned null profile for: ${yj(e).description}`,`this may indicate an overlapping span or a call to stopProfiling with a profile title that was never started`);return}i=t,IUe(r,t)}).catch(e=>{Q&&Y.log(`[Profiling] error while stopping profiler:`,e)})}}let o=Z.setTimeout(()=>{Q&&Y.log(`[Profiling] max profile duration elapsed, stopping profiling for:`,yj(e).description),a()},tK),s=e.end.bind(e);function c(){return e?(a().then(()=>{s()},()=>{s()}),e):s()}e.end=c}var LUe=6e4,RUe=3e5,zUe=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=MUe(e.getOptions());Q&&Y.log(`[Profiling] Initializing profiler (lifecycle='${t}').`),n||Q&&Y.log(`[Profiling] Session not sampled. Skipping lifecycle profiler initialization.`),this._profilerId=eA(),this._client=e,this._sessionSampled=n,this._lifecycleMode=t,t===`trace`&&this._setupTraceLifecycleListeners(e),e.on(`spanStart`,e=>{this._isRunning&&sK(e)})}start(){if(this._lifecycleMode===`trace`){Q&&Y.warn('[Profiling] `profileLifecycle` is set to "trace". Calls to `uiProfiler.start()` are ignored in trace mode.');return}if(this._isRunning){Q&&Y.warn("[Profiling] Profile session is already running, `uiProfiler.start()` is a no-op.");return}if(!this._sessionSampled){Q&&Y.warn("[Profiling] Session is not sampled, `uiProfiler.start()` is a no-op.");return}this._beginProfiling()}stop(){if(this._lifecycleMode===`trace`){Q&&Y.warn('[Profiling] `profileLifecycle` is set to "trace". Calls to `uiProfiler.stop()` are ignored in trace mode.');return}if(!this._isRunning){Q&&Y.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&&(Q&&Y.log(`[Profiling] Detected already active root span during setup. Active root spans now:`,n),this._beginProfiling()),this._isRunning&&sK(e)}_beginProfiling(){if(!this._isRunning){if(this._isRunning=!0,Q&&Y.log(`[Profiling] Started profiling with profiler ID:`,this._profilerId),NA().setContext(`profile`,{profiler_id:this._profilerId}),this._startProfilerInstance(),!this._profiler){Q&&Y.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=>{Q&&Y.error("[Profiling] Failed to collect current profile chunk on `stop()`:",e)}),this._lifecycleMode===`manual`&&NA().setContext(`profile`,{}))}_setupTraceLifecycleListeners(e){e.on(`spanStart`,e=>{if(!this._sessionSampled){Q&&Y.log(`[Profiling] Span not profiled because of negative sampling decision for user session.`);return}if(e!==Nj(e))return;if(!e.isRecording()){Q&&Y.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&&(Q&&Y.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;Q&&Y.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=>{Q&&Y.error("[Profiling] Failed to collect current profile chunk on last `spanEnd`:",e)}),this._endProfiling())})}_resetProfilerInfo(){this._isRunning=!1,NA().setContext(`profile`,{})}_clearAllRootSpanTimeouts(){this._rootSpanTimeouts.forEach(e=>clearTimeout(e)),this._rootSpanTimeouts.clear()}_registerTraceRootSpan(e){this._activeRootSpanIds.add(e);let t=setTimeout(()=>this._onRootSpanTimeout(e),RUe);this._rootSpanTimeouts.set(e,t)}_startProfilerInstance(){if(this._profiler?.stopped===!1)return;let e=nK();if(!e){Q&&Y.log(`[Profiling] Failed to start JS Profiler.`);return}this._profiler=e}_startPeriodicChunking(){this._isRunning&&(this._chunkTimer=setTimeout(()=>{if(this._collectCurrentChunk().catch(e=>{Q&&Y.error(`[Profiling] Failed to collect current profile chunk during periodic chunking:`,e)}),this._isRunning){if(this._startProfilerInstance(),!this._profiler){this._resetProfilerInfo();return}this._startPeriodicChunking()}},LUe))}_onRootSpanTimeout(e){this._rootSpanTimeouts.has(e)&&(this._rootSpanTimeouts.delete(e),this._activeRootSpanIds.has(e)&&(Q&&Y.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=wUe(await e.stop(),this._client,this._profilerId),n=TUe(t);if(`reason`in n){Q&&Y.log(`[Profiling] Discarding invalid profile chunk (this is probably a bug in the SDK):`,n.reason);return}this._sendProfileChunk(t),Q&&Y.log(`[Profiling] Collected browser profile chunk.`)}catch(e){Q&&Y.log(`[Profiling] Error while stopping JS Profiler for chunk:`,e)}}_sendProfileChunk(e){let t=this._client,n=iM(t.getSdkMetadata?.()),r=t.getDsn(),i=t.getOptions().tunnel,a=Zj({event_id:eA(),sent_at:new Date().toISOString(),...n&&{sdk:n},...!!i&&r&&{dsn:ij(r)}},[[{type:`profile_chunk`,platform:`javascript`},e]]);t.sendEnvelope(a).then(null,e=>{Q&&Y.error(`Error while sending profile chunk envelope:`,e)})}},BUe=`BrowserProfiling`,VUe=aP((()=>({name:BUe,setup(e){let t=e.getOptions(),n=new zUe;if(!iK(t)&&!t.profileLifecycle&&(t.profileLifecycle=`manual`),iK(t)&&!t.profilesSampleRate){Q&&Y.log(`[Profiling] Profiling disabled, no profiling options found.`);return}let r=Fj(),i=r&&Nj(r);if(iK(t)&&t.profileSessionSampleRate!==void 0&&Q&&Y.warn("[Profiling] Both legacy profiling (`profilesSampleRate`) and UI profiling settings are defined. `profileSessionSampleRate` has no effect when legacy profiling is enabled."),iK(t))i&&ZG(i)&&rK(i)&&cK(i),e.on(`spanStart`,e=>{let t=Nj(e);e===t?rK(e)&&cK(e):oK.has(t)&&sK(e)}),e.on(`beforeEnvelope`,e=>{if(!PUe())return;let t=kUe(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`){Q&&Y.log(`[Profiling] cannot find profile for a span without a profile context`);continue}if(!r){Q&&Y.log(`[Profiling] cannot find profile for a span without a profile context`);continue}t?.profile&&delete t.profile;let a=FUe(r);if(!a){Q&&Y.log(`[Profiling] Could not retrieve profile for span: ${r}`);continue}let o=NUe(r,i,a,e);o&&n.push(o)}OUe(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(!zj(t)){Q&&Y.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),Z.setTimeout(()=>{let e=Fj(),t=e&&Nj(e);t&&n.notifyRootSpanActive(t)},0)}}}}))),HUe=`SpotlightBrowser`,UUe=[{op:`ui.interaction.click`,name:`#sentry-spotlight`}],WUe=((e={})=>{let t=e.sidecarUrl||`http://localhost:8969/stream`;return{name:HUe,setup:()=>{Q&&Y.log(`Using Sidecar URL`,t)},beforeSetup(e){let t=e.getOptions();t.ignoreSpans=[...t.ignoreSpans||[],...UUe]},afterAllSetup:e=>{GUe(e,t)}}});function GUe(e,t){let n=uV(`fetch`),r=0;e.on(`beforeEnvelope`,e=>{if(r>3){Y.warn(`[Spotlight] Disabled Sentry -> Spotlight integration due to too many failed requests:`,r);return}n(t,{method:`POST`,body:tM(e),headers:{"Content-Type":`application/x-sentry-envelope`},mode:`cors`}).then(e=>{e.status>=200&&e.status<400&&(r=0)},e=>{r++,Y.error(`Sentry SDK can't connect to Sidecar is it running? See: https://spotlightjs.com/sidecar/npx/`,e)})})}var KUe=aP(WUe),qUe=aP(()=>({name:`LaunchDarkly`,processEvent(e,t,n){return $F(e)}}));function JUe(){return{name:`sentry-flag-auditor`,type:`flag-used`,synchronous:!0,method:(e,t,n)=>{eI(e,t.value),tI(e,t.value)}}}var YUe=aP(()=>({name:`OpenFeature`,processEvent(e,t,n){return $F(e)}})),XUe=class{after(e,t){eI(t.flagKey,t.value),tI(t.flagKey,t.value)}error(e,t,n){eI(e.flagKey,e.defaultValue),tI(e.flagKey,e.defaultValue)}},ZUe=aP(({featureFlagClientClass:e})=>({name:`Unleash`,setupOnce(){let t=e.prototype;jk(t,`isEnabled`,QUe)},processEvent(e,t,n){return $F(e)}}));function QUe(e){return function(...t){let n=t[0],r=e.apply(this,t);return typeof n==`string`&&typeof r==`boolean`?(eI(n,r),tI(n,r)):Q&&Y.error(`[Feature Flags] UnleashClient.isEnabled does not match expected signature. arg0: ${n} (${typeof n}), result: ${r} (${typeof r})`),r}}var $Ue=(({growthbookClass:e})=>vje({growthbookClass:e})),eWe=aP(({featureFlagClient:e})=>({name:`Statsig`,setup(t){e.on(`gate_evaluation`,e=>{eI(e.gate.name,e.gate.value),tI(e.gate.name,e.gate.value)})},processEvent(e,t,n){return $F(e)}})),tWe=`WebWorker`,nWe=aP(({worker:e})=>({name:tWe,setupOnce:()=>{(Array.isArray(e)?e:[e]).forEach(e=>lK(e))},addWorker:e=>lK(e)}));function lK(e){e.addEventListener(`message`,e=>{if(aWe(e.data)){if(e.stopImmediatePropagation(),e.data._sentryDebugIds&&(Q&&Y.log(`Sentry debugId web worker message received`,e.data),Z._sentryDebugIds={...e.data._sentryDebugIds,...Z._sentryDebugIds}),e.data._sentryModuleMetadata&&(Q&&Y.log(`Sentry module metadata web worker message received`,e.data),Z._sentryModuleMetadata={...e.data._sentryModuleMetadata,...Z._sentryModuleMetadata}),e.data._sentryWasmImages){Q&&Y.log(`Sentry WASM images web worker message received`,e.data);let t=Z._sentryWasmImages||[],n=e.data._sentryWasmImages.filter(e=>Tk(e)&&typeof e.code_file==`string`&&!t.some(t=>t.code_file===e.code_file));Z._sentryWasmImages=[...t,...n]}e.data._sentryWorkerError&&(Q&&Y.log(`Sentry worker rejection message received`,e.data._sentryWorkerError),rWe(e.data._sentryWorkerError))}})}function rWe(e){let t=X();if(!t)return;let n=t.getOptions().stackParser,r=t.getOptions().attachStacktrace,i=e.reason,a=wk(i)?kV(i):Uz(n,i,void 0,r,!0);a.level=`error`,e.filename&&(a.contexts={...a.contexts,worker:{filename:e.filename}}),ON(a,{originalException:i,mechanism:{handled:!1,type:`auto.browser.web_worker.onunhandledrejection`}}),Q&&Y.log(`Captured worker unhandled rejection`,i)}function iWe({self:e}){e.postMessage({_sentryMessage:!0,_sentryDebugIds:e._sentryDebugIds??void 0,_sentryModuleMetadata:e._sentryModuleMetadata??void 0}),e.addEventListener(`unhandledrejection`,t=>{let n={reason:OV(t),filename:e.location?.href};e.postMessage({_sentryMessage:!0,_sentryWorkerError:n}),Q&&Y.log(`[Sentry Worker] Forwarding unhandled rejection to parent`,n)}),Q&&Y.log(`[Sentry Worker] Registered worker with unhandled rejection handling`)}function aWe(e){if(!Tk(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&&!(Tk(e._sentryDebugIds)||e._sentryDebugIds===void 0)||n&&!(Tk(e._sentryModuleMetadata)||e._sentryModuleMetadata===void 0)||r&&!Tk(e._sentryWorkerError)||i&&(!Array.isArray(e._sentryWasmImages)||!e._sentryWasmImages.every(e=>Tk(e)&&typeof e.code_file==`string`)))}var oWe=50,[,sWe]=yV,[,cWe]=XNe(),uK=(e,t=0)=>{let n=[];for(let r of e.split(`
|
|
1004
1004
|
`).slice(t)){let e=sWe(r),t=cWe(r);if(e&&t?.in_app!==!1?n.push(e):t&&(t.module===void 0&&delete t.module,n.push(t)),n.length>=oWe)break}return nk(n)},lWe=aP(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=$L(r);a.sendStatus({status:document.visibilityState,config:i}),setInterval(()=>{a.sendStatus({status:`alive`,config:i})},i.pollInterval)}}});function dK(){let e=NA().getScopeData(),t=MA().getScopeData(),n=jA().getScopeData();return BM(e,t),BM(e,n),e.eventProcessors=[],e}function uWe(e){MA().addScopeListener(t=>{e(dK(),t)}),jA().addScopeListener(t=>{e(dK(),t)}),NA().addScopeListener(t=>{e(dK(),t)})}var fK=aP(()=>({name:`ScopeToMain`,setup(e){let t=$L(e);uWe((e,n)=>{t.sendScope(JSON.stringify(Uk(e,20,2e3))),n.clearBreadcrumbs(),n.clearAttachments()})}}));function pK(e){let t;return zP(e,async e=>(t||=$L(),t.sendEnvelope(e.body),{statusCode:200}))}function mK(e){return[...FV(e).filter(e=>e.name!==`BrowserSession`&&e.name!==`CultureContext`),fK()]}function hK(e={},t=fRe){if(window?.__SENTRY__RENDERER_INIT__){Y.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=mK(e)),e.stackParser===void 0&&(e.stackParser=uK),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=pK),delete e.initialScope,t(e)}var gK=e({BrowserClient:()=>Gz,MULTIPLEXED_TRANSPORT_EXTRA_KEY:()=>Zke,OpenFeatureIntegrationHook:()=>XUe,SEMANTIC_ATTRIBUTE_SENTRY_OP:()=>RA,SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN:()=>zA,SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE:()=>LA,SEMANTIC_ATTRIBUTE_SENTRY_SOURCE:()=>IA,Scope:()=>bA,addBreadcrumb:()=>vF,addEventProcessor:()=>VN,addIntegration:()=>iP,bindScopeToEmitter:()=>Tke,breadcrumbsIntegration:()=>SV,browserApiErrorsIntegration:()=>CV,browserProfilingIntegration:()=>VUe,browserSessionIntegration:()=>TV,browserTracingIntegration:()=>MG,buildLaunchDarklyFlagUsedHandler:()=>JUe,captureConsoleIntegration:()=>EAe,captureEvent:()=>ON,captureException:()=>EN,captureFeedback:()=>aI,captureMessage:()=>DN,captureSession:()=>GN,chromeStackLineParser:()=>yV,consoleLoggingIntegration:()=>Aje,contextLinesIntegration:()=>jRe,continueTrace:()=>fke,createConsolaReporter:()=>Nje,createLangChainCallbackHandler:()=>NL,createTransport:()=>zP,createUserFeedbackEnvelope:()=>FLe,dedupeIntegration:()=>RF,defaultRequestInstrumentationOptions:()=>SG,defaultStackParser:()=>uK,elementTimingIntegration:()=>XIe,endSession:()=>UN,eventFiltersIntegration:()=>xF,eventFromException:()=>Vz,eventFromMessage:()=>Hz,eventLoopBlockIntegration:()=>lWe,exceptionFromError:()=>Lz,extraErrorDataIntegration:()=>NAe,featureFlagsIntegration:()=>_je,feedbackAsyncIntegration:()=>NFe,feedbackIntegration:()=>Iz,feedbackSyncIntegration:()=>Iz,fetchStreamPerformanceIntegration:()=>DG,forceLoad:()=>pRe,functionToStringIntegration:()=>bF,getAbsoluteUrl:()=>bLe,getActiveSpan:()=>Fj,getClient:()=>X,getCurrentScope:()=>jA,getDefaultIntegrations:()=>mK,getFeedback:()=>BPe,getGlobalScope:()=>NA,getIsolationScope:()=>MA,getReplay:()=>DHe,getRootSpan:()=>Nj,getSpanDescendants:()=>Mj,getSpanStatusFromHttpCode:()=>KA,getTraceData:()=>_F,globalHandlersIntegration:()=>DV,graphqlClientIntegration:()=>zRe,growthbookIntegration:()=>$Ue,httpClientIntegration:()=>yRe,httpContextIntegration:()=>MV,inboundFiltersIntegration:()=>SF,init:()=>hK,instrumentAnthropicAiClient:()=>YMe,instrumentCreateReactAgent:()=>NNe,instrumentGoogleGenAIClient:()=>sNe,instrumentLangChainEmbeddings:()=>SNe,instrumentLangGraph:()=>PNe,instrumentOpenAiClient:()=>AMe,instrumentOutgoingRequests:()=>CG,instrumentSupabaseClient:()=>XF,isBotUserAgent:()=>jG,isEnabled:()=>BN,isInitialized:()=>zN,lastEventId:()=>RN,launchDarklyIntegration:()=>qUe,linkedErrorsIntegration:()=>NV,logger:()=>nPe,makeRendererTransport:()=>pK,metrics:()=>lPe,moduleMetadataIntegration:()=>CAe,normalizeStringifyValue:()=>PV,onLoad:()=>mRe,openFeatureIntegration:()=>YUe,parameterize:()=>gF,registerSpanErrorInstrumentation:()=>Rj,registerWebWorker:()=>iWe,replayCanvasIntegration:()=>KHe,replayIntegration:()=>KW,reportPageLoaded:()=>mUe,reportingObserverIntegration:()=>_Re,rewriteFramesIntegration:()=>VAe,scopeToMainIntegration:()=>fK,sendFeedback:()=>pR,setActiveSpanInBrowser:()=>hUe,setAttribute:()=>FN,setAttributes:()=>PN,setContext:()=>kN,setConversationId:()=>LN,setCurrentClient:()=>iF,setExtra:()=>jN,setExtras:()=>AN,setHttpStatus:()=>qA,setMeasurement:()=>oM,setTag:()=>NN,setTags:()=>MN,setUser:()=>IN,showReportDialog:()=>IV,spanStreamingIntegration:()=>gUe,spanToBaggageHeader:()=>JOe,spanToJSON:()=>yj,spanToTraceHeader:()=>mj,spotlightBrowserIntegration:()=>KUe,startBrowserTracingNavigationSpan:()=>PG,startBrowserTracingPageLoadSpan:()=>NG,startInactiveSpan:()=>vM,startNewTrace:()=>xM,startSession:()=>HN,startSpan:()=>gM,startSpanManual:()=>_M,statsigIntegration:()=>eWe,supabaseIntegration:()=>tje,suppressTracing:()=>pke,thirdPartyErrorFilterIntegration:()=>uje,uiProfiler:()=>TLe,unleashIntegration:()=>ZUe,updateSpanName:()=>UOe,viewHierarchyIntegration:()=>BRe,webVitalsIntegration:()=>OG,webWorkerIntegration:()=>nWe,withActiveSpan:()=>yM,withIsolationScope:()=>fOe,withScope:()=>PA,withStreamedSpan:()=>YOe,zodErrorsIntegration:()=>lje}),dWe=100,fWe=5,pWe=[`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 _K(e){if(e)for(let t of Object.keys(e))/token|secret|password|api[_-]?key/i.test(t)&&(e[t]=`[redacted]`)}function mWe(e){e.request?.url&&(e.request.url=e.request.url.replace(/([?&](?:code|token|access_token|state)=)[^&]+/gi,`$1[redacted]`)),_K(e.extra),_K(e.tags)}function hWe(e){let t=yK(e.version)??`0.0.0`,n=yK(e.commitHash);return n?`${e.appName}@${t}+${n}`:`${e.appName}@${t}`}function vK(e,t){for(let n of t){let t=yK(e[n]);if(t)return t}}function gWe(e){return bK(e.enabled)??e.defaultEnabled??!1}function _We(e){let t=yK(e.dsn);return!t||gWe(e)===!1?null:{dsn:t,environment:yK(e.environment)??yK(e.defaultEnvironment)??`production`,release:yK(e.release)??yK(e.defaultRelease)??void 0,debug:bK(e.debug)??e.defaultDebug??!1,tracesSampleRate:SK(e.tracesSampleRate,e.defaultTracesSampleRate??.1),profilesSampleRate:xK(e.profilesSampleRate,e.defaultProfilesSampleRate),replaysSessionSampleRate:xK(e.replaysSessionSampleRate,e.defaultReplaysSessionSampleRate),replaysOnErrorSampleRate:xK(e.replaysOnErrorSampleRate,e.defaultReplaysOnErrorSampleRate),attachStacktrace:!0,maxBreadcrumbs:dWe,normalizeDepth:fWe,tags:vWe(e)}}function vWe(e){let t={app:e.appName,runtime:e.runtime};for(let[n,r]of Object.entries(e.tags??{})){let e=yK(r);e&&(t[n]=e)}return t}function yK(e){if(e==null)return null;let t=e.trim();return t.length>0?t:null}function bK(e){if(typeof e==`boolean`)return e;let t=yK(e);if(t){if(t===`1`||t.toLowerCase()===`true`)return!0;if(t===`0`||t.toLowerCase()===`false`)return!1}}function xK(e,t){if(t!==void 0||e!==void 0)return SK(e,t??0)}function SK(e,t){let n=yWe(e);return n===null||n<0||n>1?t:n}function yWe(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;let t=yK(e);if(!t)return null;let n=Number.parseFloat(t);return Number.isFinite(n)?n:null}var CK=Xt(`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`),bWe=`no-drag-region flex h-full min-w-0 items-center gap-1 md:gap-1.5`,wK=`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`,xWe={width:`calc(100% - var(--forge-right-panel-reserved-width, 0px))`};function TK(e){let t=(0,Cl.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,kr.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=Xt(`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,kr.jsx)(`span`,{className:m,children:wl}),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,kr.jsx)(`span`,{className:_,children:yce}),t[8]=_,t[9]=v);let y=v;if(a){let e;t[10]!==d||t[11]!==g?(e=(0,kr.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,kr.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md`,"aria-label":Tl,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,kr.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,"aria-label":Tl,children:[d,g]}),t[16]=d,t[17]=g,t[18]=b):b=t[18],b}function EK(e){let t=(0,Cl.c)(5),{className:n}=e,r;t[0]===n?r=t[1]:(r=Xt(`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,kr.jsx)(TK,{}),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,kr.jsx)(`div`,{className:r,children:i}),t[3]=r,t[4]=a),a}var SWe=[/\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/,/https?:\/\/[^\s'"<>)]*\/api\/provider-egress\/[^\s'"<>)]*/i,/https?:\/\/[^\s'"<>)]*(?:apex|deepseek|moonshot|kimi)[^\s'"<>)]*/i],CWe=`CMMD is temporarily unavailable. Check the workspace AI connection and retry.`;function wWe(e){if(!e)return null;let t=e.toLowerCase();return/\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.`:/\b(rate[\s-]?limit|too\s+many\s+requests|quota|insufficient_quota)\b/.test(t)||/\b429\b/.test(t)?`The AI service is rate-limited or out of quota. Wait a moment and 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}function TWe(e){return e?SWe.some(t=>t.test(e)):!1}function DK(e,t={}){if(e==null)return null;let n=e.trim();return n.length===0?null:TWe(n)?wWe(n)??t.fallback??`CMMD is temporarily unavailable. Check the workspace AI connection and retry.`:n}var EWe=[/\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 OK(e){if(typeof e!=`string`)return!1;let t=e.trim();return t.length!==0&&EWe.some(e=>e.test(t))}function kK(e){return OK(e)?null:DK(e,{fallback:CWe})}var AK=`forge-web`,jK=[`VITE_SENTRY_ENVIRONMENT`,`MODE`],MK=[`VITE_SENTRY_RELEASE`],DWe=[`VITE_SENTRY_DSN`],OWe=[`VITE_SENTRY_DEBUG`],kWe=[`VITE_SENTRY_ENABLED`],AWe=[`VITE_SENTRY_TRACES_SAMPLE_RATE`],jWe=[`VITE_SENTRY_PROFILES_SAMPLE_RATE`],MWe=[`VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE`],NWe=[`VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE`],PWe=[`VITE_SENTRY_COMMIT_SHA`,`VITE_COMMIT_SHA`],NK=!1,PK={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 FWe(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 IWe(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 LWe(e){return FWe(e).some(OK)||IWe(e)}function RWe(){let e=new URL(window.location.href);Ar?e.hash=`/new`:(e.pathname=`/new`,e.search=``,e.hash=``),window.location.assign(e.toString())}function zWe(){let e=Ar?`electron-renderer`:`browser`,t={APP_VERSION:`0.10.3`,BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`,VITE_COMMIT_SHA:``,VITE_HTTP_URL:``,VITE_SENTRY_COMMIT_SHA:`986939d02dd54d5adfd34ed23f2d67fece201f9a`,VITE_SENTRY_DEBUG:``,VITE_SENTRY_DSN:``,VITE_SENTRY_ENABLED:``,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_PROFILES_SAMPLE_RATE:``,VITE_SENTRY_RELEASE:`forge-web@0.10.3+986939d02dd54d5adfd34ed23f2d67fece201f9a`,VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE:``,VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE:``,VITE_SENTRY_TRACES_SAMPLE_RATE:``,VITE_WS_URL:``},n=vK(t,[...MK])??hWe({appName:AK,version:`0.10.3`,commitHash:vK(t,[...PWe])});return _We({appName:AK,runtime:e,defaultEnvironment:vK(t,[...jK])??`development`,defaultRelease:n,defaultEnabled:!0,defaultTracesSampleRate:0,defaultReplaysSessionSampleRate:0,defaultReplaysOnErrorSampleRate:0,enabled:vK(t,[...kWe]),dsn:vK(t,[...DWe]),environment:vK(t,[...jK]),release:vK(t,[...MK]),debug:vK(t,[...OWe]),tracesSampleRate:vK(t,[...AWe]),profilesSampleRate:vK(t,[...jWe]),replaysSessionSampleRate:vK(t,[...MWe]),replaysOnErrorSampleRate:vK(t,[...NWe]),tags:{platform:Ar?`desktop`:`web`}})}function FK(e){return mWe(e),LWe(e)?null:e}function BWe(e){return{...e.replaysOnErrorSampleRate===void 0?{}:{replaysOnErrorSampleRate:e.replaysOnErrorSampleRate},...e.replaysSessionSampleRate===void 0?{}:{replaysSessionSampleRate:e.replaysSessionSampleRate}}}function IK(e){return{attachStacktrace:e.attachStacktrace,debug:e.debug,dsn:e.dsn,environment:e.environment,ignoreErrors:[...pWe],initialScope:{tags:e.tags},maxBreadcrumbs:e.maxBreadcrumbs,normalizeDepth:e.normalizeDepth,sendDefaultPii:!1,tracesSampleRate:e.tracesSampleRate,...e.release===void 0?{}:{release:e.release},...BWe(e)}}function VWe(e){let t=[];e.tracesSampleRate>0&&t.push(MG()),((e.replaysSessionSampleRate??0)>0||(e.replaysOnErrorSampleRate??0)>0)&&t.push(KW());let n=Iz(PK);t.push(n);try{hK({...IK(e),beforeSend:e=>FK(e),integrations:t})}catch{return null}return NK=!0,gK}function HWe(e){let t=[];e.tracesSampleRate>0&&t.push(NE()),((e.replaysSessionSampleRate??0)>0||(e.replaysOnErrorSampleRate??0)>0)&&t.push(qT());let n=jb(PK);t.push(n);try{pD({...IK(e),beforeSend:e=>FK(e),integrations:t})}catch{return null}return NK=!0,VO}function LK(){if(NK)return Ar?gK:VO;let e=zWe();return e?Ar?VWe(e):HWe(e):null}function RK(e){if(LK()){if(Ar){IN(e);return}ym(e)}}function zK(e,t,n){if(!LK())return;let r=UWe(e);if(Ar){PA(e=>{t&&e.setTags(t);let i=EN(r);n?.showReportDialog&&IV({eventId:i})});return}Id(e=>{t&&e.setTags(t);let i=hm(r);n?.showReportDialog&&LS({eventId:i})})}function UWe(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 WWe=class extends F.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){zK(e,{origin:`react-boundary`},{showReportDialog:!0})}render(){return this.state.hasError?(0,kr.jsxs)(`div`,{className:`forge-app-shell flex min-h-svh w-full min-w-0 flex-col bg-background text-foreground`,children:[(0,kr.jsxs)(`header`,{className:CK,children:[(0,kr.jsx)(`div`,{className:`no-drag-region flex min-w-0 items-center pl-1 md:pl-2.5`,children:(0,kr.jsx)(`button`,{type:`button`,"aria-label":`Go to new chat`,onClick:RWe,className:`${wK} hover:bg-accent/70`,children:(0,kr.jsx)(EK,{})})}),(0,kr.jsx)(`div`,{})]}),(0,kr.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-4`,children:(0,kr.jsxs)(`div`,{className:`max-w-md rounded-xl border border-border bg-card p-6 text-center shadow-lg`,children:[(0,kr.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Something went wrong.`}),(0,kr.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Forge hit an unexpected error and reported it.`}),(0,kr.jsx)(`button`,{className:`mt-4 inline-flex rounded-md border border-border px-3 py-2 text-sm font-medium hover:bg-accent`,onClick:()=>window.location.reload(),type:`button`,children:`Reload app`})]})})]}):this.props.children}};function GWe(e,t){return P({method:`GET`,path:`/api/cmmd/billing`,...t?.organizationId===void 0?{}:{query:{orgId:t.organizationId}}},e)}function KWe(e,t){return P({method:`GET`,path:`/api/cmmd/billing/series`,query:{timeZone:t.timeZone}},e)}function qWe(e,t,n){return P({method:`POST`,path:`/api/cmmd/forge-runtimes/${encodeURIComponent(t)}/rename`,body:{displayName:n}},e)}function JWe(e,t,n){return P({method:`POST`,path:`/api/cmmd/devices/${encodeURIComponent(String(t))}/rename`,body:{displayName:n}},e)}function YWe(e,t){return P({method:`POST`,path:`/api/cmmd/devices/${encodeURIComponent(String(t))}/revoke`},e)}function BK(e){return{...e.limit===void 0?{}:{limit:e.limit},...e.cursor?{cursor:e.cursor}:{}}}var XWe=class extends Error{constructor(e){super(e),this.name=`CmmdApiAuthError`}},ZWe=class extends Error{status;constructor(e,t){super(e),this.name=`CmmdApiServerError`,this.status=t}},VK=class extends Error{constructor(e){super(`CmmdApiClient.${e} is not implemented yet`),this.name=`CmmdApiNotImplementedError`}};function HK(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 UK(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 WK(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 GK(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 QWe(e,t){if(!e||typeof e!=`object`)return null;let n=e[t];return typeof n==`boolean`?n:null}function KK(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 qK(e){let t=`${GK(e,`firstName`)??``} ${GK(e,`lastName`)??``}`.trim()||GK(e,`username`)||GK(e,`email`)||`Unknown`;return{id:KK(e,`userId`)??KK(e,`id`)??t,name:t,email:GK(e,`email`),role:GK(e,`role`),avatarUrl:GK(e,`profileImage`)??GK(e,`avatar`)}}function $We(e){let t=YK(e,`user`)??e;return qK({...typeof t==`object`&&t?t:{},userId:KK(e,`userId`)??KK(t,`id`),role:GK(e,`role`)})}function JK(e){let t=GK(e,`authorFirstName`)??``,n=GK(e,`authorLastName`)??``,r=GK(e,`status`),i=r===`at_risk`||r===`off_track`||r===`complete`?r:`on_track`;return{id:KK(e,`id`)??``,status:i,body:GK(e,`body`)??``,authorName:`${t} ${n}`.trim()||null,authorAvatarUrl:GK(e,`authorProfileImage`)??null,createdAt:GK(e,`createdAt`)??``,updatedAt:GK(e,`updatedAt`)??GK(e,`createdAt`)??``,canEdit:QWe(e,`canEdit`)??!1}}function eGe(e,t,n){let r=Array.isArray(e.data)?e.data.map(JK):[];return{updates:r,pagination:e.pagination??{page:t,limit:n,total:r.length,hasMore:!1}}}function YK(e,t){if(!e||typeof e!=`object`)return null;let n=e[t];return n&&typeof n==`object`?n:null}var tGe=[`avatarUrl`,`avatar_url`,`profileImage`,`profile_image`,`profileImageUrl`,`profile_image_url`,`image`,`imageUrl`,`image_url`,`picture`];function XK(e,t){let n=YK(e,t);if(!n)return null;for(let e of tGe){let t=GK(n,e);if(t)return t}return null}function ZK(e,t){let n=YK(e,t);return n?KK(n,`id`):null}function QK(e,t){return!!(e&&typeof e==`object`&&Object.hasOwn(e,t))}function nGe(e){let t={...e,id:KK(e,`id`)??e.id,title:e.title??GK(e,`name`)??``},n=KK(e,`workspaceId`)??KK(e,`workspace_id`)??ZK(e,`workspace`)??e.workspaceId??null;return n!==null||QK(e,`workspaceId`)?{...t,workspaceId:n,startDate:e.startDate??GK(e,`start_date`)??null,endDate:e.endDate??GK(e,`end_date`)??null}:t}function $K(e){let t=e.ownerAvatarUrl??GK(e,`owner_avatar_url`)??GK(e,`ownerProfileImage`)??GK(e,`owner_profile_image`)??GK(e,`ownerImage`)??GK(e,`owner_image`)??GK(e,`ownerImageUrl`)??GK(e,`owner_image_url`)??GK(e,`createdByAvatarUrl`)??GK(e,`created_by_avatar_url`)??GK(e,`createdByProfileImage`)??GK(e,`created_by_profile_image`)??XK(e,`owner`)??XK(e,`createdBy`)??XK(e,`created_by`)??null,n={...e,id:KK(e,`id`)??e.id},r=KK(e,`campaignId`)??KK(e,`campaign_id`)??ZK(e,`campaign`)??e.campaignId??null;(r!==null||QK(e,`campaignId`))&&(n.campaignId=r);let i=e.campaignTitle??GK(e,`campaignTitle`)??GK(e,`campaign_title`)??GK(YK(e,`campaign`),`title`)??GK(YK(e,`campaign`),`name`)??null;(i!==null||QK(e,`campaignTitle`))&&(n.campaignTitle=i);let a=KK(e,`workspaceId`)??KK(e,`workspace_id`)??ZK(e,`workspace`)??e.workspaceId??null;(a!==null||QK(e,`workspaceId`))&&(n.workspaceId=a);let o=e.workspaceName??GK(e,`workspace_name`)??GK(YK(e,`workspace`),`name`)??null;(o!==null||QK(e,`workspaceName`))&&(n.workspaceName=o);let s=GK(e,`workspaceIconUrl`)??GK(e,`workspace_icon_url`)??GK(YK(e,`workspace`),`iconUrl`)??null;(s!==null||QK(e,`workspaceIconUrl`))&&(n.workspaceIconUrl=s);let c=KK(e,`ownerId`)??KK(e,`owner_id`)??ZK(e,`owner`)??e.ownerId??null;(c!==null||QK(e,`ownerId`))&&(n.ownerId=c);let l=e.ownerName??GK(e,`owner_name`)??GK(YK(e,`owner`),`name`)??null;(l!==null||QK(e,`ownerName`))&&(n.ownerName=l),(t!==null||QK(e,`ownerAvatarUrl`))&&(n.ownerAvatarUrl=t);let u=KK(e,`teamId`)??KK(e,`team_id`)??ZK(e,`team`)??e.teamId??null;(u!==null||QK(e,`teamId`))&&(n.teamId=u);let d=e.teamName??GK(e,`team_name`)??GK(YK(e,`team`),`name`)??null;(d!==null||QK(e,`teamName`))&&(n.teamName=d);let f=e.startDate??GK(e,`start_date`)??null;(f!==null||QK(e,`startDate`))&&(n.startDate=f);let p=e.targetEndDate??GK(e,`target_end_date`)??null;return(p!==null||QK(e,`targetEndDate`))&&(n.targetEndDate=p),n}function eq(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 rGe(e){return eq(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 iGe(e){if(e&&typeof e==`object`){let t=e;if(t.project&&typeof t.project==`object`)return t.project}return e}function tq(e){if(e===null||e.trim()===``)return null;let t=Number(e);return Number.isSafeInteger(t)?t:e}async function nq(e){try{return await e}catch(e){throw e instanceof fr?e.kind===`auth`?new XWe(e.message):new ZWe(e.message,e.status??502):e}}var rq=class e{cfg;commentEditIdempotencyKeys=new Map;commentDeleteIdempotencyKeys=new Map;constructor(e={}){let t=e.forgeOrigin===void 0,n=e.forgeOrigin??`http://localhost:13773`;this.cfg={resolveUrl:t?lr:e=>`${n}${e}`,maxRetries:e.maxRetries??3,onAuthExpired:e.onAuthExpired??ur,...t?{resolveBearerToken:()=>or()?.bearerToken??null}:{}}}async getTask(e){return nq(P({method:`GET`,path:`/api/cmmd/tasks/${e}`},this.cfg))}async getForgeTaskDetail(e){return P({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 nq(P({method:`GET`,path:`/api/cmmd/tasks/search`,query:t},this.cfg))).tasks??[]}async getTaskComments(e){return(await nq(P({method:`GET`,path:`/api/cmmd/tasks/${e}/comments`},this.cfg))).comments??[]}async listProjectTaskComments(e){return(await nq(P({method:`GET`,path:`/api/cmmd/tasks/${e}/comments`},this.cfg))).comments??[]}async createProjectTaskComment(e,t){return(await nq(P({method:`POST`,path:`/api/cmmd/tasks/comment`,body:{taskId:e,content:t.content}},this.cfg))).details}async updateProjectTaskComment(e,t,n){return(await nq(P({method:`PATCH`,path:`/api/cmmd/tasks/${e}/comments/${encodeURIComponent(t)}`,body:n},this.cfg))).comment}async deleteProjectTaskComment(e,t,n){return nq(P({method:`DELETE`,path:`/api/cmmd/tasks/${e}/comments/${encodeURIComponent(t)}`,body:n},this.cfg))}async getTaskAttachments(e){return nq(P({method:`GET`,path:`/api/cmmd/tasks/${e}/attachments`},this.cfg))}async getProjectRepository(e){return nq(P({method:`GET`,path:`/api/cmmd/projects/${e}/repository`},this.cfg))}async listProjectRepositories(e){return(await nq(P({method:`GET`,path:`/api/cmmd/projects/${e}/repositories`},this.cfg))).repositories}async getWorkspaceMembers(e){return nq(P({method:`GET`,path:`/api/cmmd/organizations/${e}/members`},this.cfg))}async getWebSocketToken(e){return P({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 P({method:`GET`,path:`/api/cmmd/projects/${e}/comments`,query:n},this.cfg))?.comments??[]}async getProjectLink(e){return P({method:`GET`,path:`/.well-known/forge/project-link`,query:{environmentId:e.environmentId,projectId:e.projectId,cwd:e.cwd}},this.cfg)}async listProjectLinks(){return P({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 P({method:`GET`,path:`/.well-known/forge/cmmd/project-links`,query:t},this.cfg),r=$t(Sne)(n);return r._tag===`Some`?r.value.links:[]}async listCmmdWorkspaces(){return eq(await P({method:`GET`,path:`/.well-known/forge/cmmd/workspaces`},this.cfg))}async listCmmdCampaigns(e){return rGe(await P({method:`GET`,path:`/.well-known/forge/cmmd/campaigns`,query:{workspaceId:e.workspaceId}},this.cfg))}async listCmmdProjects(e){return eq(await P({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),nq(P({method:`POST`,path:`/api/cmmd/tasks/update`,body:n},this.cfg))}async createComment(e){return nq(P({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 nq(P({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 nq(P({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 P({method:`POST`,path:`/api/cmmd/projects/${e}/comments`,body:{content:t.content,organizationId:t.organizationId??null}},this.cfg))?.comment;if(!n)throw new fr({kind:`server`,message:`CMMD did not return the created project comment.`});return n}async updateProject(e,t){let n={};for(let e of gne){let r=t[e];r!==void 0&&(n[e]=vne[e]===`nullableId`?tq(r):r)}await P({method:`PATCH`,path:`/api/cmmd/projects/${e}`,body:n},this.cfg)}async setProjectLink(e){await P({method:`POST`,path:`/.well-known/forge/project-link`,body:e},this.cfg)}async deleteProjectLink(e){await P({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 P({method:`POST`,path:`/.well-known/forge/cmmd/projects`,body:e},this.cfg)}async ensureGitHubProjectContext(e){return P({method:`POST`,path:`/.well-known/forge/cmmd/github-project-contexts/ensure`,body:e},this.cfg)}async createBrainDoc(e){return P({method:`POST`,path:`/api/cmmd/brain-docs`,body:e},this.cfg)}async uploadTaskAttachment(e,t){let n=new FormData;return n.append(`file`,t),nq(P({method:`POST`,path:`/api/cmmd/tasks/${e}/attachments`,form:n},this.cfg))}async archiveTask(e){await P({method:`POST`,path:`/api/cmmd/tasks/${e}/archive`},this.cfg)}async unarchiveTask(e){await P({method:`POST`,path:`/api/cmmd/tasks/${e}/unarchive`},this.cfg)}async getProfile(){return P({method:`GET`,path:`/api/cmmd/profile`},this.cfg)}async getUsageSummary(e){return P({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 GWe(this.cfg,e)}getBillingSeries(e){return KWe(this.cfg,e)}async getBootstrap(){return P({method:`GET`,path:`/api/cmmd/bootstrap`},this.cfg)}async getForgeAccountPreferences(){return P({method:`GET`,path:`/api/cmmd/account/preferences`},this.cfg)}async updateForgeAccountPreferences(e){return P({method:`PATCH`,path:`/api/cmmd/account/preferences`,body:e},this.cfg)}async getOrgProviderPolicy(){return P({method:`GET`,path:`/api/cmmd/org/provider-policy`},this.cfg)}async listSavedDataViews(e){return P({method:`GET`,path:`/api/cmmd/saved-views`,query:{surface:e.surface,projectId:e.projectId}},this.cfg)}async createSavedDataView(e){return P({method:`POST`,path:`/api/cmmd/saved-views`,body:e},this.cfg)}async importSavedDataView(e){return P({method:`POST`,path:`/api/cmmd/saved-views/import`,body:e},this.cfg)}async updateSavedDataView(e,t){return P({method:`PATCH`,path:`/api/cmmd/saved-views/${encodeURIComponent(e)}`,body:t},this.cfg)}async deleteSavedDataView(e,t){return P({method:`DELETE`,path:`/api/cmmd/saved-views/${encodeURIComponent(e)}`,query:t},this.cfg)}async getDeviceRegistry(e){return P({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 P({method:`POST`,path:`/api/cmmd/devices/register`,body:e},this.cfg)}async grantRuntimeAccess(e,t){return P({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/access-grants`,body:t},this.cfg)}async revokeRuntimeAccess(e,t){return P({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/access-grants/${encodeURIComponent(String(t))}/revoke`},this.cfg)}async issueRelayControlRoute(e,t){return P({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/relay-routes`,body:t},this.cfg)}async issueRelayActionGrant(e,t){return P({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/relay-action-grants`,body:t},this.cfg)}async getRuntimeInventory(e){let t={...e?.projectId===void 0?{}:{projectId:String(e.projectId)},...e?.allWorkspaces===!0?{allWorkspaces:`true`}:{}};return P({method:`GET`,path:`/api/cmmd/runtime-inventory`,...Object.keys(t).length>0?{query:t}:{}},this.cfg)}async getRuntimeDiagnostics(e){return P({method:`GET`,path:`/api/cmmd/runtime-diagnostics/v2/runtimes/${encodeURIComponent(e)}`},this.cfg)}async getCloudProjectLifecyclePreflight(e){return(await P({method:`GET`,path:`/api/cmmd/forge-cloud-projects/${encodeURIComponent(String(e))}/lifecycle-preflight`},this.cfg)).preflight}async replaceRuntimeInventory(e,t){return P({method:`PUT`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/inventory`,body:t},this.cfg)}static AUTH_RUNTIME_PATH=`/api/cmmd/auth-runtime`;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`;static USER_CODEX_CREDENTIAL_PATH=`/api/cmmd/providers/codex/credential`;static USER_CLAUDE_CREDENTIAL_PATH=`/api/cmmd/providers/claude/credential`;async provisionAuthRuntime(){return P({method:`POST`,path:e.AUTH_RUNTIME_PATH},this.cfg)}async getAuthRuntimeState(){return P({method:`GET`,path:e.AUTH_RUNTIME_PATH},this.cfg)}async destroyAuthRuntime(){return P({method:`DELETE`,path:e.AUTH_RUNTIME_PATH},this.cfg)}async connectAuthRuntime(){return P({method:`POST`,path:`${e.AUTH_RUNTIME_PATH}/connect`},this.cfg)}async getUserCodexCredential(){return P({method:`GET`,path:e.USER_CODEX_CREDENTIAL_PATH},this.cfg)}async disconnectUserCodexCredential(){return P({method:`DELETE`,path:e.USER_CODEX_CREDENTIAL_PATH},this.cfg)}async getUserClaudeCredential(){return P({method:`GET`,path:e.USER_CLAUDE_CREDENTIAL_PATH},this.cfg)}async getProviderAccounts(){return P({method:`GET`,path:e.PROVIDER_ACCOUNTS_PATH},this.cfg)}async removeLinkedProviderAccount(t){return P({method:`DELETE`,path:`${e.PROVIDER_ACCOUNTS_PATH}/${t}`},this.cfg)}async setProviderAccountDefault(t){return P({method:`PUT`,path:`${e.PROVIDER_ACCOUNTS_PATH}/default`,body:{provider:t.provider,provider_account_id:t.providerAccountId}},this.cfg)}async getProviderUsage(){return P({method:`GET`,path:e.PROVIDER_USAGE_PATH},this.cfg)}async refreshProviderUsage(t,n){return P({method:`POST`,path:e.PROVIDER_USAGE_REFRESH_PATH,body:{provider:t,providerAccountId:n}},this.cfg)}async disconnectUserClaudeCredential(){return P({method:`DELETE`,path:e.USER_CLAUDE_CREDENTIAL_PATH},this.cfg)}async getClaudeRuntimeReadiness(e){return P({method:`GET`,path:`/api/cmmd/providers/claude/runtime-readiness/${encodeURIComponent(e)}`},this.cfg)}async appendRuntimeThreadEvents(e,t,n){return P({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/threads/${encodeURIComponent(t)}/events`,body:n},this.cfg)}async getRuntimeThreadReplica(e,t){return P({method:`GET`,path:`/api/cmmd/threads/${encodeURIComponent(e)}/${encodeURIComponent(t)}`},this.cfg)}renameCloudEnvironment(e,t){return qWe(this.cfg,e,t)}renameDevice(e,t){return JWe(this.cfg,e,t)}revokeDevice(e){return YWe(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 P({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 P({method:`GET`,path:`${e.SIM_PATH}/leases?${n.toString()}`},this.cfg)}async claimSimLease(t){return P({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 P({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 P({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`),HK(await P({method:`GET`,path:`/api/cmmd/campaigns`,query:t,...e?.signal?{signal:e.signal}:{}},this.cfg),`campaigns`).map(nGe)}async getCampaign(e){return P({method:`GET`,path:`/api/cmmd/campaigns/${e}`},this.cfg)}async createCampaign(e){return P({method:`POST`,path:`/api/cmmd/campaigns`,body:e},this.cfg)}async updateCampaign(e,t){return P({method:`PUT`,path:`/api/cmmd/campaigns/${e}`,body:t},this.cfg)}async deleteCampaign(e){await P({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`),HK(await P({method:`GET`,path:`/api/cmmd/projects`,query:t,...e?.signal?{signal:e.signal}:{}},this.cfg),`projects`).map($K)}async listTasks(e){let t={};return e?.projectId&&(t.projectId=e.projectId),e?.status&&(t.status=e.status),P({method:`GET`,path:`/api/cmmd/tasks`,query:t},this.cfg)}async getProject(e){return $K(await P({method:`GET`,path:`/api/cmmd/projects/${e}`},this.cfg))}async getProjectMembers(e){let t=await P({method:`GET`,path:`/api/cmmd/projects/${e}/members`},this.cfg);return Array.isArray(t)?t.map(qK):[]}async listWorkspaceMembers(){let e=await P({method:`GET`,path:`/api/cmmd/members`},this.cfg);return Array.isArray(e)?e.map($We):[]}async addProjectMember(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/members`,body:t},this.cfg)}async listProjectAgentMembers(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/agent-members`},this.cfg)}async createProjectAgentMember(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/agent-members`,body:t},this.cfg)}async renameProjectAgentMember(e,t,n){return P({method:`PATCH`,path:`/api/cmmd/projects/${e}/agent-members/${t}`,body:n},this.cfg)}async retireProjectAgentMember(e,t,n){return P({method:`POST`,path:`/api/cmmd/projects/${e}/agent-members/${t}/retire`,body:n},this.cfg)}async updateProjectAgentMemberAvatar(e,t,n){return P({method:`PUT`,path:`/api/cmmd/projects/${e}/agent-members/${t}/avatar`,body:n},this.cfg)}async listProjectAgentMemberInstances(e,t){return P({method:`GET`,path:`/api/cmmd/projects/${e}/agent-members/${t}/instances`},this.cfg)}async previewProjectAgentMemberConsolidation(e){return P({method:`POST`,path:`/api/cmmd/projects/${e}/agent-members/consolidation/preview`},this.cfg)}async applyProjectAgentMemberConsolidation(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/agent-members/consolidation/apply`,body:t},this.cfg)}async setProjectTaskAssignment(e,t,n){return P({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 eGe(await P({method:`GET`,path:`/api/cmmd/projects/${e}/updates`,query:{page:n,limit:r},unwrapEnvelope:!1},this.cfg),n,r)}async createProjectUpdate(e,t){return JK(await P({method:`POST`,path:`/api/cmmd/projects/${e}/updates`,body:t},this.cfg))}async updateProjectUpdate(e,t,n){return JK(await P({method:`PATCH`,path:`/api/cmmd/projects/${e}/updates/${t}`,body:n},this.cfg))}async deleteProjectUpdate(e,t){await P({method:`DELETE`,path:`/api/cmmd/projects/${e}/updates/${t}`},this.cfg)}async listProjectMilestones(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/milestones`},this.cfg)}async createProjectMilestone(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/milestones`,body:t},this.cfg)}async updateProjectMilestone(e,t,n){return P({method:`PATCH`,path:`/api/cmmd/projects/${e}/milestones/${t}`,body:n},this.cfg)}async deleteProjectMilestone(e,t){await P({method:`DELETE`,path:`/api/cmmd/projects/${e}/milestones/${t}`},this.cfg)}async improveProjectContent(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/content/readability`,body:t},this.cfg)}async listProjectBoard(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/board`},this.cfg)}async createProjectTaskDraft(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/task-drafts`,body:t},this.cfg)}async getProjectTaskDraft(e,t){return P({method:`GET`,path:`/api/cmmd/projects/${e}/task-drafts/${t}`},this.cfg)}async updateProjectTaskDraft(e,t,n){return P({method:`PATCH`,path:`/api/cmmd/projects/${e}/task-drafts/${t}`,body:n},this.cfg)}async previewProjectTaskDraft(e,t,n){return P({method:`POST`,path:`/api/cmmd/projects/${e}/task-drafts/${t}/preview`,body:n},this.cfg)}async commitProjectTaskDraft(e,t,n){return P({method:`POST`,path:`/api/cmmd/projects/${e}/task-drafts/${t}/commit`,body:n},this.cfg)}async discardProjectTaskDraft(e,t,n){return P({method:`POST`,path:`/api/cmmd/projects/${e}/task-drafts/${t}/discard`,body:n},this.cfg)}async getProjectTaskWorkflow(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/task-workflow`},this.cfg)}async updateProjectTaskWorkflow(e,t){return P({method:`PUT`,path:`/api/cmmd/projects/${e}/task-workflow`,body:t},this.cfg)}async getProjectLeadPlan(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/plan`},this.cfg)}async activateProjectLeadAutomaticStaffing(e){return P({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/authority/activate`,body:{}},this.cfg)}async getProjectLeadReadiness(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/readiness`},this.cfg)}async getProjectLeadCapabilities(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/capabilities`},this.cfg)}async getProjectLeadSummary(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/summary`},this.cfg)}async getProjectLeadDetail(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/detail`},this.cfg)}async getProjectLeadBriefing(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/briefing`},this.cfg)}async decideProjectLeadApproval(e,t,n){return P({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/approvals/${t}/decision`,body:n},this.cfg)}async listProjectLeadEvents(e,t){return P({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 P({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/explain`},this.cfg)}async pauseProjectLead(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/pause`,body:t},this.cfg)}async resumeProjectLead(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/resume`,body:t},this.cfg)}async reserveProjectLeadTask(e,t,n){return P({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/tasks/${t}/reservations`,body:n},this.cfg)}async releaseProjectLeadReservation(e,t,n){return P({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/reservations/${t}/release`,body:n},this.cfg)}async reconcileProjectLead(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/reconcile`,body:t},this.cfg)}async resolveProjectLeadAttention(e,t,n){return P({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),P({method:`GET`,path:`/api/cmmd/work-items/board`,query:t},this.cfg)}async listForgeAutomationPresets(){return UK(await P({method:`GET`,path:`/api/cmmd/automations/presets`},this.cfg),`presets`)}async listUserForgeAutomationRules(){return UK(await P({method:`GET`,path:`/api/cmmd/automations/user/rules`},this.cfg),`rules`)}async createUserForgeAutomationRule(e){return P({method:`POST`,path:`/api/cmmd/automations/user/rules`,body:e},this.cfg)}async updateUserForgeAutomationRule(e,t){return P({method:`PATCH`,path:`/api/cmmd/automations/user/rules/${e}`,body:t},this.cfg)}async listUserForgeAutomationRuns(e){return UK(await P({method:`GET`,path:`/api/cmmd/automations/user/rules/${e}/runs`},this.cfg),`runs`)}async startUserForgeAutomationRun(e,t){return P({method:`POST`,path:`/api/cmmd/automations/user/rules/${e}/runs`,body:t},this.cfg)}async listForgeAutomationRules(e,t){let n=WK(t);return UK(await P({method:`GET`,path:`/api/cmmd/automations/projects/${e}/rules`,...n?{query:n}:{}},this.cfg),`rules`)}async createForgeAutomationRule(e,t,n){let r=WK(n);return P({method:`POST`,path:`/api/cmmd/automations/projects/${e}/rules`,body:t,...r?{query:r}:{}},this.cfg)}async updateForgeAutomationRule(e,t,n,r){let i=WK(r);return P({method:`PATCH`,path:`/api/cmmd/automations/projects/${e}/rules/${t}`,body:n,...i?{query:i}:{}},this.cfg)}async listForgeAutomationRuns(e,t){let n=WK(t,t?.taskId);return UK(await P({method:`GET`,path:`/api/cmmd/automations/projects/${e}/runs`,...n?{query:n}:{}},this.cfg),`runs`)}async getForgeAutomationRun(e,t){let n=WK(t);return P({method:`GET`,path:`/api/cmmd/automations/runs/${e}`,...n?{query:n}:{}},this.cfg)}async startForgeAutomationRun(e,t,n,r){let i=WK(r);return P({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=WK(n);return P({method:`POST`,path:`/api/cmmd/automations/runs/${e}/retry`,body:t,...r?{query:r}:{}},this.cfg)}async cancelForgeAutomationRun(e,t,n){let r=WK(n);return P({method:`POST`,path:`/api/cmmd/automations/runs/${e}/cancel`,body:t,...r?{query:r}:{}},this.cfg)}async approveForgeAutomationEscalation(e,t,n){let r=WK(n);return P({method:`POST`,path:`/api/cmmd/automations/runs/${e}/escalations/approve`,body:t,...r?{query:r}:{}},this.cfg)}async rejectForgeAutomationEscalation(e,t,n){let r=WK(n);return P({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),P({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),P({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),P({method:`POST`,path:`/api/cmmd/feedback`,body:t},this.cfg)}async updateProjectBoardTask(e,t,n){return P({method:`PATCH`,path:`/api/cmmd/projects/${e}/board/${t}`,body:n},this.cfg)}async updateCenterBoardTask(e,t){return P({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),P({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),P({method:`PATCH`,path:`/api/cmmd/projects/${e}/board/${t}/move`,body:r},this.cfg)}async archiveProjectBoardTask(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/board/${t}/archive`},this.cfg)}async unarchiveProjectBoardTask(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/board/${t}/unarchive`},this.cfg)}async updateProjectBoardTaskStatus(e,t,n,r){return P({method:`PATCH`,path:`/api/cmmd/projects/${e}/board/${t}/status`,body:{status:n,...r?{workflowStageId:r}:{}}},this.cfg)}async spawnForgeThreadFromBoardTask(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/board/${t}/spawn-forge-thread`,body:{}},this.cfg)}async listTaskExecutionOptions(e,t){return P({method:`GET`,path:`/api/cmmd/projects/${e}/board/${t}/execution-options`},this.cfg)}async createTaskWorkSession(e,t,n){return P({method:`POST`,path:`/api/cmmd/projects/${e}/board/${t}/work-sessions`,body:n},this.cfg)}async listProjectWorkSessions(e,t={}){return P({method:`GET`,path:`/api/cmmd/projects/${e}/work-sessions`,query:t},this.cfg)}async getWorkSession(e){return P({method:`GET`,path:`/api/cmmd/work-sessions/${e}`},this.cfg)}async updateWorkSessionStatus(e,t){return P({method:`PATCH`,path:`/api/cmmd/work-sessions/${e}`,body:{status:t}},this.cfg)}async attachWorkSessionThread(e,t){return P({method:`POST`,path:`/api/cmmd/work-sessions/${e}/threads`,body:t},this.cfg)}async listTaskConversations(e,t={}){return P({method:`GET`,path:`/api/cmmd/tasks/${e}/conversations`,query:BK(t)},this.cfg)}async linkTaskConversation(e,t){return P({method:`POST`,path:`/api/cmmd/tasks/${e}/conversations`,body:t},this.cfg)}async getTaskHistory(e){return P({method:`GET`,path:`/api/cmmd/tasks/${e}/history`},this.cfg)}async upsertTaskPullRequest(e,t){return P({method:`PUT`,path:`/api/cmmd/tasks/${e}/pull-requests`,body:t},this.cfg)}postPullRequest(e,t){return P({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 P({method:`GET`,path:`/api/cmmd/tasks/${e}/conversations/${encodeURIComponent(t)}`,query:BK(n)},this.cfg)}async createTask(e){return P({method:`POST`,path:`/api/cmmd/tasks`,body:e},this.cfg)}async createSubtask(e){throw new VK(`createSubtask`)}async createBoardTask(e){throw new VK(`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=tq(e.campaignId)),e.organizationId!==void 0&&e.organizationId!==null&&(t.organizationId=tq(e.organizationId)),iGe(await P({method:`POST`,path:`/api/cmmd/projects`,body:t},this.cfg))}async moveProject(e,t){let n={targetOrgId:tq(t.targetOrgId)};return t.campaignStrategy!==void 0&&(n.campaignStrategy=t.campaignStrategy),t.targetCampaignId!==void 0&&(n.targetCampaignId=tq(t.targetCampaignId)),t.dryRun!==void 0&&(n.dryRun=t.dryRun),P({method:`POST`,path:`/api/cmmd/projects/${e}/move`,body:n},this.cfg)}async uploadBrainDoc(e,t){throw new VK(`uploadBrainDoc`)}};function iq(e){return new rq(e)}var aq=new rq({onAuthExpired:ur}),oq=class extends Gn(`BootstrapHttpError`){},sq=e=>lee(e,`BootstrapHttpError`);function cq(e){return typeof e!=`object`||!e?!1:!!(sq(e)&&e.status===401||e instanceof Error&&e.name===`RemoteEnvironmentAuthHttpError`&&`status`in e&&e.status===401||e instanceof fr&&e.kind===`auth`)}function lq(e={resolveUrl:lr}){let t=or()?.bearerToken;return t?{...e,bearerToken:t}:e}var uq=null,dq=null,fq=null,pq=new Set,mq=`cmmd-forge.loggedOutLocalBootstrapCredentials.v1`;function aGe(e){let t=`${e.firstName??``} ${e.lastName??``}`.trim();RK({id:e.id,email:e.email,...t.length>0?{username:t}:{}}),Rl({cmmdUserId:e.id,...e.email?{email:e.email}:{},...t.length>0?{displayName:t}:{}})}function hq(){if(typeof window>`u`||fq)return;let e=window.desktopBridge?.desktopAuth?.onStateChange;e&&(fq=e(e=>{uq=null,dq=null,e.sessionLifecycle.status!==`ready`&&RK(null),(e.sessionLifecycle.status===`expired`||e.sessionLifecycle.status===`signed-out`&&e.sessionLifecycle.reason===`refresh-revoked`)&&Mne().catch(e=>{zK(e,{route:`desktop-auth-session-expired`})})}))}function oGe(e){let t=e.replace(/\s+/g,` `).trim();return t.length===0?`<empty response>`:t.slice(0,120)}async function gq(e,t){let n=await e.text();try{return JSON.parse(n)}catch{throw new oq({message:`${t} returned a non-JSON response (${oGe(n)}). Ensure the Forge server is running and this route is proxied correctly.`,status:e.status})}}function sGe(){return Hl(new URL(window.location.href))}function _q(){let e=new URL(window.location.href),t=zce(e);t.toString()!==e.toString()&&window.history.replaceState({},document.title,t.toString())}async function cGe(){return Eq(async()=>{let e=lr(`/api/auth/session`),t=await fetch(e,rr({credentials:`include`}));if(!t.ok)throw new oq({message:`Failed to load server auth session state (${t.status}).`,status:t.status});return gq(t,e)})}async function lGe(e,t){return await e.text()||t}var vq=new Set([`CMMD_AUTH_REQUIRED`,`CMMD_AUTH_EXPIRED`]);async function uGe(e){return Eq(async()=>{let t={credential:e},n=lr(`/api/auth/bootstrap`),r=await fetch(n,rr({body:JSON.stringify(t),credentials:`include`,headers:{"content-type":`application/json`},method:`POST`}));if(!r.ok)throw new oq({message:await r.text()||`Failed to bootstrap auth session (${r.status}).`,status:r.status});return gq(r,n)})}function yq(e){return new URL(e,window.location.origin).toString()}function bq(e){let t=(e?.primaryMode===`cloud`?null:e)?.bootstrapToken?.trim();return t&&t.length>0?t:null}function xq(){return typeof window>`u`?null:bq(window.desktopBridge?.getLocalEnvironmentBootstrap?.()??null)}function dGe(){return typeof window>`u`?!1:Pne()===`session-expired`}function Sq(){if(typeof window>`u`)return new Set;try{let e=window.sessionStorage.getItem(mq),t=e?JSON.parse(e):[];return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function Cq(e){if(!(typeof window>`u`))try{if(e.size===0){window.sessionStorage.removeItem(mq);return}window.sessionStorage.setItem(mq,JSON.stringify([...e]))}catch{}}function fGe(){let e=xq();if(!e)return;let t=new Set(Sq());t.add(e),Cq(t)}function pGe(e){return Sq().has(e)}function wq(){let e=xq();if(!e){Cq(new Set);return}let t=new Set(Sq());t.delete(e),Cq(t)}async function Tq(){let e=yq(`/api/auth/session`),t=await fetch(e,{credentials:`include`});return t.ok?gq(t,e):null}async function mGe(e){if(typeof window>`u`)return;let t=bq(e);if(!t||dGe()||pq.has(t)||pGe(t))return;if((await Tq().catch(()=>null))?.authenticated){pq.add(t);return}let n=yq(`/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 oq({message:await r.text()||`Failed to bootstrap local web owner session (${r.status}).`,status:r.status})}await gq(r,n),pq.add(t)}async function hGe(){let e=await cGe();if(e.authenticated)return e;let t=or();if(t?.source!==`desktop-managed`||!t.bearerToken)return e;let n=await Tq().catch(()=>null);return n?.authenticated?n:e}var gGe=new Set([404,502,503,504]),_Ge=15e3,vGe=500;function yGe(e){or()?.source===`paired-bearer`&&cq(e)&&dr(`http`)}async function Eq(e){let t=Date.now();for(;;)try{return await e()}catch(e){if(yGe(e),!xGe(e))throw e;if(Date.now()-t>=_Ge)throw zK(e,{route:`bootstrap-retry-exhausted`}),e;await bGe(vGe)}}function bGe(e){return new Promise(t=>{setTimeout(t,e)})}function xGe(e){return sq(e)?gGe.has(e.status):e instanceof TypeError||e instanceof DOMException&&e.name===`AbortError`}function SGe(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 CGe(e){if(typeof window>`u`||!window.desktopBridge)return null;let t=window.desktopBridge.desktopAuth?.getState;if(!t)return`desktop-state-unavailable`;try{return SGe(await t(),e)}catch(e){return zK(e,{route:`desktop-auth-gate-state`}),`desktop-state-unavailable`}}async function wGe(e,t){return RK(null),Fne(t),await ir().catch(e=>{zK(e,{route:`desktop-auth-gate-logout`})}),{status:`requires-auth`,auth:e.auth,errorMessage:Nne(t)??`Forge Desktop requires CMMD authentication.`}}async function TGe(){let e=await hGe();if(e.authenticated){if(e.cmmdIdentity){let t=await CGe(e.cmmdIdentity);return t?(sr(),wGe(e,t)):(sr(),aGe(e.cmmdIdentity),{status:`authenticated`})}return{status:`requires-auth`,auth:e.auth}}return{status:`requires-auth`,auth:e.auth}}async function EGe(e){let t=e.trim();if(!t)throw Error(`Enter a pairing token to continue.`);dq=null,wq(),await uGe(t),uq=null,_q()}function Dq(){wq(),dq=null,uq=null}async function Oq(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=lr(`/api/auth/bootstrap/command`),s=await fetch(o,rr({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 oq({message:await s.text()||`Failed to bootstrap with CMMD OAuth token (${s.status}).`,status:s.status});await gq(s,o),Dq()}async function DGe(){let e=lr(`/api/auth/ws-token`),t=await fetch(e,rr({credentials:`include`,method:`POST`}));if(!t.ok)throw new oq({message:await t.text()||`Failed to issue websocket token (${t.status}).`,status:t.status});return gq(t,e)}async function OGe(e){let t=await DGe(),n=new URL(e,window.location.origin);return n.searchParams.set(`wsToken`,t.token),n.toString()}async function kGe(e,t){let n=e?.trim(),r={...n?{label:n}:{},...t?{role:t}:{}},i=lr(`/api/auth/pairing-token`),a=await fetch(i,rr({body:JSON.stringify(r),credentials:`include`,headers:{"content-type":`application/json`},method:`POST`}));if(!a.ok)throw Error(await lGe(a,`Failed to create pairing credential (${a.status}).`));return gq(a,i)}async function AGe(){let e=new URL(`/api/auth/session`,window.location.origin).toString(),t=await fetch(e,{credentials:`include`});if(!t.ok)throw new oq({message:`Failed to load current app auth session state (${t.status}).`,status:t.status});return jGe(await gq(t,e))}function jGe(e){if(!e.authenticated||!e.role)throw Error(`Authenticated session is required.`);let t=MGe(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 MGe(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 NGe(e){let t=`/api/cmmd/work-intake`,n;try{n=await P({method:`GET`,path:t,allowRetry:!1,...e?{query:{fresh:1}}:{}},lq())}catch(e){throw e instanceof fr&&e.kind!==`auth`&&e.code!==null&&vq.has(e.code)?new fr({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 PGe(e={}){return NGe(e.forceFresh===!0)}async function kq(e,t){try{return await P({method:`POST`,path:e,body:t,allowRetry:!1},lq())}catch(e){throw e instanceof fr&&e.kind!==`auth`&&e.code!==null&&vq.has(e.code)?new fr({kind:`auth`,message:e.message,status:e.status??401,code:e.code}):e}}async function FGe(e){try{return await kq(`/api/cmmd/tasks/update`,e)}catch(t){if(t instanceof fr&&(t.kind===`auth`||t.kind===`permission`))throw t;if(t instanceof fr||t instanceof Error)return kq(`/api/command/tasks/update`,e);throw t}}async function IGe(){typeof window>`u`||await window.desktopBridge?.desktopAuth?.logoutCloud?.()}async function LGe(){let e=await Promise.allSettled([ir(),IGe()]);RK(null),fGe(),uq=null,dq=null;let t=e.find(e=>e.status===`rejected`);if(t)throw t.reason}async function RGe(){if(hq(),dq?.status===`authenticated`)return sr(),dq;if(uq)return uq;let e=Aq();return uq=e,e.then(e=>(e.status===`authenticated`&&(dq=e),e)).finally(()=>{uq===e&&(uq=null)})}async function Aq(){return cr().then(e=>mGe(e)).then(()=>TGe())}async function zGe(){hq(),uq=null,dq=null;let e=await Aq();return e.status===`authenticated`&&(dq=e,sr()),e}async function BGe(e){let t=e.email.trim();if(!t||!e.password)throw Error(`Enter your CMMD email and password.`);let n=lr(`/api/auth/cmmd-password/token`),r=await fetch(n,rr({body:JSON.stringify({email:t,password:e.password}),credentials:`include`,headers:{"content-type":`application/json`},method:`POST`}));if(!r.ok)throw new oq({message:await r.text()||`CMMD login failed (${r.status}).`,status:r.status});let i=await gq(r,n);if(i.authenticated===!0)return Dq(),{serverEstablishedSession:!0};if(typeof i.access_token!=`string`||i.access_token.trim().length===0)throw Error(`CMMD login did not return an access token.`);return await Oq(i.access_token,i.user,{refreshToken:typeof i.refresh_token==`string`?i.refresh_token:void 0,mcpToken:typeof i.mcp_token==`string`?i.mcp_token:void 0}),{serverEstablishedSession:!1}}var VGe=`/.well-known/forge/environment`,jq=Wt()(e=>({descriptor:null,setDescriptor:t=>e({descriptor:t}),reset:()=>e({descriptor:null})})),Mq=null;function HGe(e){let t=Nq();return t?Yie(Po({id:t.environmentId,label:t.label,source:e.source,target:e.target}),t):null}async function UGe(){return Eq(async()=>{await cr();let e=or()?.bearerToken,t=lr(VGe),n=e?await fetch(t,{headers:{Authorization:`Bearer ${e}`}}):await fetch(t);if(!n.ok)throw new oq({message:`Failed to load server environment descriptor (${n.status}).`,status:n.status});let r=await gq(n,t);return Pq(r),r})}function Nq(){return jq.getState().descriptor}function WGe(){return jq(GGe)}function GGe(e){return e.descriptor?.environmentId??null}function KGe(){return jq(qGe)}function qGe(e){return e.descriptor}function JGe(){return jq(YGe)}function YGe(e){return tae(e.descriptor)}function XGe(){return jq(ZGe)}function ZGe(e){return nae(e.descriptor)}function Pq(e){jq.getState().setDescriptor(e)}function QGe(e,t){return t?.primaryMode!==`cloud`||e.environmentId===t.environmentId}function Fq(){let e=or();return e?HGe({source:e.source,target:e.target}):null}function $Ge(){return eKe()}async function eKe(){let e=await cr(),t=Nq();if(t&&QGe(t,e))return Promise.resolve(t);if(t&&Pq(null),Mq)return Mq;let n=UGe();return Mq=n,n.finally(()=>{Mq===n&&(Mq=null)})}function tKe(e,t){return e.reasoningEffortLevels.some(e=>e.value===t)}function Iq(e){return e.reasoningEffortLevels.find(e=>e.isDefault)?.value??null}function Lq(e,t){let n=Iq(e),r=typeof t==`string`?t.trim():null;return r&&!e.promptInjectedEffortLevels.includes(r)&&tKe(e,r)?r:n??void 0}function Rq(e,t){return e.contextWindowOptions.some(e=>e.value===t)}function zq(e){return e.contextWindowOptions.find(e=>e.isDefault)?.value??null}function nKe(e,t){let n=zq(e);return t&&Rq(e,t)?t:n??void 0}function rKe(e,t){let n=Lq(e,t?.reasoningEffort),r=e.supportsFastMode?t?.fastMode:void 0,i={...n?{reasoningEffort:n}:{},...r===void 0?{}:{fastMode:r}};return Object.keys(i).length>0?i:void 0}function iKe(e,t){let n=Lq(e,t?.effort),r=e.supportsThinkingToggle?t?.thinking:void 0,i=e.supportsFastMode?t?.fastMode:void 0,a=nKe(e,t?.contextWindow),o={...r===void 0?{}:{thinking:r},...n?{effort:n}:{},...i===void 0?{}:{fastMode:i},...a===void 0?{}:{contextWindow:a}};return Object.keys(o).length>0?o:void 0}function Bq(e){return typeof e==`string`&&/\bultrathink\b/i.test(e)}function Vq(e,t=`codex`){if(typeof e!=`string`)return null;let n=e.trim();if(!n)return null;let r=lne[t],i=Object.prototype.hasOwnProperty.call(r,n)?r[n]:void 0;return typeof i==`string`?i:n}function Hq(e,t,n){if(typeof t!=`string`)return null;let r=t.trim();if(!r)return null;let i=n.find(e=>e.slug===r);if(i)return i.slug;let a=n.find(e=>e.name.toLowerCase()===r.toLowerCase());if(a)return a.slug;let o=Vq(r,e),s=n.find(e=>e.slug===o);return s?s.slug:null}var aKe=[`codex`,`claudeAgent`];function Uq(e,t){return aKe.filter(e=>e!==t).some(t=>nne(t,e)!==void 0)}function oKe(e,t){let n=Vq(e,t);return!n||Uq(n,t)?Vn[t]:n}function Wq(e,t){return oKe(t,e)}function sKe(e){return typeof e==`string`&&e.trim()||null}function cKe(e,t){let n=e.trim();return!n||t!==`ultrathink`||n.startsWith(`Ultrathink:`)?n:`Ultrathink:\n${n}`}function lKe(){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 Gq=typeof window<`u`?window.localStorage:lKe(),uKe=(e,t)=>Dn(tn(e))(t),dKe=(e,t)=>Mte(tn(e))(t),Kq=(e,t)=>{let n=Gq.getItem(e);return n?uKe(t,n):null},qq=(e,t,n)=>{let r=dKe(n,t);Gq.setItem(e,r)},Jq=e=>{Gq.removeItem(e)},Yq=`forge:local_storage_change`;function fKe(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(Yq,{detail:{key:e}}))}function pKe(e,t,n){let[r,i]=(0,F.useState)(()=>{try{return Kq(e,n)??t}catch(e){return console.error(`[LOCALSTORAGE] Error:`,e),t}}),a=(0,F.useCallback)(t=>{i(r=>{try{let i=typeof t==`function`?t(r):t;return i===null?Jq(e):qq(e,i,n),queueMicrotask(()=>fKe(e)),i}catch(e){return console.error(`[LOCALSTORAGE] Error:`,e),r}})},[e,n]),o=(0,F.useRef)(e);return(0,F.useEffect)(()=>{if(o.current!==e){o.current=e;try{let r=Kq(e,n);i(r??t)}catch(e){console.error(`[LOCALSTORAGE] Error:`,e)}}},[e,t,n]),(0,F.useEffect)(()=>{let r=()=>{try{let r=Kq(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(Yq,o),()=>{window.removeEventListener(`storage`,a),window.removeEventListener(Yq,o)}},[e,t,n]),[r,a]}var Xq=`full-access`,Zq=`default`,Qq=`default`,mKe=/\n*<terminal_context>\n([\s\S]*?)\n<\/terminal_context>\s*$/,hKe=/^\s*<cmmd_context>\n?([\s\S]*?)\n?<\/cmmd_context>\s*/;function $q(e){return e.replace(/\r\n/g,`
|
|
1006
|
-
`).replace(/^\n+|\n+$/g,``)}function eJ(e){return $q(e.text).length>0}function
|
|
1007
|
-
`).map((t,n)=>` ${e.lineStart+n} | ${t}`)}function
|
|
1008
|
-
`)}function
|
|
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=mK(e)),e.stackParser===void 0&&(e.stackParser=uK),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=pK),delete e.initialScope,t(e)}var gK=e({BrowserClient:()=>Gz,MULTIPLEXED_TRANSPORT_EXTRA_KEY:()=>Zke,OpenFeatureIntegrationHook:()=>XUe,SEMANTIC_ATTRIBUTE_SENTRY_OP:()=>RA,SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN:()=>zA,SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE:()=>LA,SEMANTIC_ATTRIBUTE_SENTRY_SOURCE:()=>IA,Scope:()=>bA,addBreadcrumb:()=>vF,addEventProcessor:()=>VN,addIntegration:()=>iP,bindScopeToEmitter:()=>Tke,breadcrumbsIntegration:()=>SV,browserApiErrorsIntegration:()=>CV,browserProfilingIntegration:()=>VUe,browserSessionIntegration:()=>TV,browserTracingIntegration:()=>MG,buildLaunchDarklyFlagUsedHandler:()=>JUe,captureConsoleIntegration:()=>EAe,captureEvent:()=>ON,captureException:()=>EN,captureFeedback:()=>aI,captureMessage:()=>DN,captureSession:()=>GN,chromeStackLineParser:()=>yV,consoleLoggingIntegration:()=>Aje,contextLinesIntegration:()=>jRe,continueTrace:()=>fke,createConsolaReporter:()=>Nje,createLangChainCallbackHandler:()=>NL,createTransport:()=>zP,createUserFeedbackEnvelope:()=>FLe,dedupeIntegration:()=>RF,defaultRequestInstrumentationOptions:()=>SG,defaultStackParser:()=>uK,elementTimingIntegration:()=>XIe,endSession:()=>UN,eventFiltersIntegration:()=>xF,eventFromException:()=>Vz,eventFromMessage:()=>Hz,eventLoopBlockIntegration:()=>lWe,exceptionFromError:()=>Lz,extraErrorDataIntegration:()=>NAe,featureFlagsIntegration:()=>_je,feedbackAsyncIntegration:()=>NFe,feedbackIntegration:()=>Iz,feedbackSyncIntegration:()=>Iz,fetchStreamPerformanceIntegration:()=>DG,forceLoad:()=>pRe,functionToStringIntegration:()=>bF,getAbsoluteUrl:()=>bLe,getActiveSpan:()=>Fj,getClient:()=>X,getCurrentScope:()=>jA,getDefaultIntegrations:()=>mK,getFeedback:()=>BPe,getGlobalScope:()=>NA,getIsolationScope:()=>MA,getReplay:()=>DHe,getRootSpan:()=>Nj,getSpanDescendants:()=>Mj,getSpanStatusFromHttpCode:()=>KA,getTraceData:()=>_F,globalHandlersIntegration:()=>DV,graphqlClientIntegration:()=>zRe,growthbookIntegration:()=>$Ue,httpClientIntegration:()=>yRe,httpContextIntegration:()=>MV,inboundFiltersIntegration:()=>SF,init:()=>hK,instrumentAnthropicAiClient:()=>YMe,instrumentCreateReactAgent:()=>NNe,instrumentGoogleGenAIClient:()=>sNe,instrumentLangChainEmbeddings:()=>SNe,instrumentLangGraph:()=>PNe,instrumentOpenAiClient:()=>AMe,instrumentOutgoingRequests:()=>CG,instrumentSupabaseClient:()=>XF,isBotUserAgent:()=>jG,isEnabled:()=>BN,isInitialized:()=>zN,lastEventId:()=>RN,launchDarklyIntegration:()=>qUe,linkedErrorsIntegration:()=>NV,logger:()=>nPe,makeRendererTransport:()=>pK,metrics:()=>lPe,moduleMetadataIntegration:()=>CAe,normalizeStringifyValue:()=>PV,onLoad:()=>mRe,openFeatureIntegration:()=>YUe,parameterize:()=>gF,registerSpanErrorInstrumentation:()=>Rj,registerWebWorker:()=>iWe,replayCanvasIntegration:()=>KHe,replayIntegration:()=>KW,reportPageLoaded:()=>mUe,reportingObserverIntegration:()=>_Re,rewriteFramesIntegration:()=>VAe,scopeToMainIntegration:()=>fK,sendFeedback:()=>pR,setActiveSpanInBrowser:()=>hUe,setAttribute:()=>FN,setAttributes:()=>PN,setContext:()=>kN,setConversationId:()=>LN,setCurrentClient:()=>iF,setExtra:()=>jN,setExtras:()=>AN,setHttpStatus:()=>qA,setMeasurement:()=>oM,setTag:()=>NN,setTags:()=>MN,setUser:()=>IN,showReportDialog:()=>IV,spanStreamingIntegration:()=>gUe,spanToBaggageHeader:()=>JOe,spanToJSON:()=>yj,spanToTraceHeader:()=>mj,spotlightBrowserIntegration:()=>KUe,startBrowserTracingNavigationSpan:()=>PG,startBrowserTracingPageLoadSpan:()=>NG,startInactiveSpan:()=>vM,startNewTrace:()=>xM,startSession:()=>HN,startSpan:()=>gM,startSpanManual:()=>_M,statsigIntegration:()=>eWe,supabaseIntegration:()=>tje,suppressTracing:()=>pke,thirdPartyErrorFilterIntegration:()=>uje,uiProfiler:()=>TLe,unleashIntegration:()=>ZUe,updateSpanName:()=>UOe,viewHierarchyIntegration:()=>BRe,webVitalsIntegration:()=>OG,webWorkerIntegration:()=>nWe,withActiveSpan:()=>yM,withIsolationScope:()=>fOe,withScope:()=>PA,withStreamedSpan:()=>YOe,zodErrorsIntegration:()=>lje}),dWe=100,fWe=5,pWe=[`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 _K(e){if(e)for(let t of Object.keys(e))/token|secret|password|api[_-]?key/i.test(t)&&(e[t]=`[redacted]`)}function mWe(e){e.request?.url&&(e.request.url=e.request.url.replace(/([?&](?:code|token|access_token|state)=)[^&]+/gi,`$1[redacted]`)),_K(e.extra),_K(e.tags)}function hWe(e){let t=yK(e.version)??`0.0.0`,n=yK(e.commitHash);return n?`${e.appName}@${t}+${n}`:`${e.appName}@${t}`}function vK(e,t){for(let n of t){let t=yK(e[n]);if(t)return t}}function gWe(e){return bK(e.enabled)??e.defaultEnabled??!1}function _We(e){let t=yK(e.dsn);return!t||gWe(e)===!1?null:{dsn:t,environment:yK(e.environment)??yK(e.defaultEnvironment)??`production`,release:yK(e.release)??yK(e.defaultRelease)??void 0,debug:bK(e.debug)??e.defaultDebug??!1,tracesSampleRate:SK(e.tracesSampleRate,e.defaultTracesSampleRate??.1),profilesSampleRate:xK(e.profilesSampleRate,e.defaultProfilesSampleRate),replaysSessionSampleRate:xK(e.replaysSessionSampleRate,e.defaultReplaysSessionSampleRate),replaysOnErrorSampleRate:xK(e.replaysOnErrorSampleRate,e.defaultReplaysOnErrorSampleRate),attachStacktrace:!0,maxBreadcrumbs:dWe,normalizeDepth:fWe,tags:vWe(e)}}function vWe(e){let t={app:e.appName,runtime:e.runtime};for(let[n,r]of Object.entries(e.tags??{})){let e=yK(r);e&&(t[n]=e)}return t}function yK(e){if(e==null)return null;let t=e.trim();return t.length>0?t:null}function bK(e){if(typeof e==`boolean`)return e;let t=yK(e);if(t){if(t===`1`||t.toLowerCase()===`true`)return!0;if(t===`0`||t.toLowerCase()===`false`)return!1}}function xK(e,t){if(t!==void 0||e!==void 0)return SK(e,t??0)}function SK(e,t){let n=yWe(e);return n===null||n<0||n>1?t:n}function yWe(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;let t=yK(e);if(!t)return null;let n=Number.parseFloat(t);return Number.isFinite(n)?n:null}var CK=Xt(`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`),bWe=`no-drag-region flex h-full min-w-0 items-center gap-1 md:gap-1.5`,wK=`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`,xWe={width:`calc(100% - var(--forge-right-panel-reserved-width, 0px))`};function TK(e){let t=(0,Cl.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,kr.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=Xt(`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,kr.jsx)(`span`,{className:m,children:wl}),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,kr.jsx)(`span`,{className:_,children:yce}),t[8]=_,t[9]=v);let y=v;if(a){let e;t[10]!==d||t[11]!==g?(e=(0,kr.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,kr.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md`,"aria-label":Tl,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,kr.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,"aria-label":Tl,children:[d,g]}),t[16]=d,t[17]=g,t[18]=b):b=t[18],b}function EK(e){let t=(0,Cl.c)(5),{className:n}=e,r;t[0]===n?r=t[1]:(r=Xt(`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,kr.jsx)(TK,{}),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,kr.jsx)(`div`,{className:r,children:i}),t[3]=r,t[4]=a),a}var SWe=[/\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/,/https?:\/\/[^\s'"<>)]*\/api\/provider-egress\/[^\s'"<>)]*/i,/https?:\/\/[^\s'"<>)]*(?:apex|deepseek|moonshot|kimi)[^\s'"<>)]*/i],CWe=`CMMD is temporarily unavailable. Check the workspace AI connection and retry.`;function wWe(e){if(!e)return null;let t=e.toLowerCase();return/\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.`:/\b(rate[\s-]?limit|too\s+many\s+requests|quota|insufficient_quota)\b/.test(t)||/\b429\b/.test(t)?`The AI service is rate-limited or out of quota. Wait a moment and 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}function TWe(e){return e?SWe.some(t=>t.test(e)):!1}function DK(e,t={}){if(e==null)return null;let n=e.trim();return n.length===0?null:TWe(n)?wWe(n)??t.fallback??`CMMD is temporarily unavailable. Check the workspace AI connection and retry.`:n}var EWe=[/\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 OK(e){if(typeof e!=`string`)return!1;let t=e.trim();return t.length!==0&&EWe.some(e=>e.test(t))}function kK(e){return OK(e)?null:DK(e,{fallback:CWe})}var AK=`forge-web`,jK=[`VITE_SENTRY_ENVIRONMENT`,`MODE`],MK=[`VITE_SENTRY_RELEASE`],DWe=[`VITE_SENTRY_DSN`],OWe=[`VITE_SENTRY_DEBUG`],kWe=[`VITE_SENTRY_ENABLED`],AWe=[`VITE_SENTRY_TRACES_SAMPLE_RATE`],jWe=[`VITE_SENTRY_PROFILES_SAMPLE_RATE`],MWe=[`VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE`],NWe=[`VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE`],PWe=[`VITE_SENTRY_COMMIT_SHA`,`VITE_COMMIT_SHA`],NK=!1,PK={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 FWe(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 IWe(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 LWe(e){return FWe(e).some(OK)||IWe(e)}function RWe(){let e=new URL(window.location.href);Ar?e.hash=`/new`:(e.pathname=`/new`,e.search=``,e.hash=``),window.location.assign(e.toString())}function zWe(){let e=Ar?`electron-renderer`:`browser`,t={APP_VERSION:`0.10.4`,BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`,VITE_COMMIT_SHA:``,VITE_HTTP_URL:``,VITE_SENTRY_COMMIT_SHA:`5f0060a9696edd41f61f06cbf24450a5994fed33`,VITE_SENTRY_DEBUG:``,VITE_SENTRY_DSN:``,VITE_SENTRY_ENABLED:``,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_PROFILES_SAMPLE_RATE:``,VITE_SENTRY_RELEASE:`forge-web@0.10.4+5f0060a9696edd41f61f06cbf24450a5994fed33`,VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE:``,VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE:``,VITE_SENTRY_TRACES_SAMPLE_RATE:``,VITE_WS_URL:``},n=vK(t,[...MK])??hWe({appName:AK,version:`0.10.4`,commitHash:vK(t,[...PWe])});return _We({appName:AK,runtime:e,defaultEnvironment:vK(t,[...jK])??`development`,defaultRelease:n,defaultEnabled:!0,defaultTracesSampleRate:0,defaultReplaysSessionSampleRate:0,defaultReplaysOnErrorSampleRate:0,enabled:vK(t,[...kWe]),dsn:vK(t,[...DWe]),environment:vK(t,[...jK]),release:vK(t,[...MK]),debug:vK(t,[...OWe]),tracesSampleRate:vK(t,[...AWe]),profilesSampleRate:vK(t,[...jWe]),replaysSessionSampleRate:vK(t,[...MWe]),replaysOnErrorSampleRate:vK(t,[...NWe]),tags:{platform:Ar?`desktop`:`web`}})}function FK(e){return mWe(e),LWe(e)?null:e}function BWe(e){return{...e.replaysOnErrorSampleRate===void 0?{}:{replaysOnErrorSampleRate:e.replaysOnErrorSampleRate},...e.replaysSessionSampleRate===void 0?{}:{replaysSessionSampleRate:e.replaysSessionSampleRate}}}function IK(e){return{attachStacktrace:e.attachStacktrace,debug:e.debug,dsn:e.dsn,environment:e.environment,ignoreErrors:[...pWe],initialScope:{tags:e.tags},maxBreadcrumbs:e.maxBreadcrumbs,normalizeDepth:e.normalizeDepth,sendDefaultPii:!1,tracesSampleRate:e.tracesSampleRate,...e.release===void 0?{}:{release:e.release},...BWe(e)}}function VWe(e){let t=[];e.tracesSampleRate>0&&t.push(MG()),((e.replaysSessionSampleRate??0)>0||(e.replaysOnErrorSampleRate??0)>0)&&t.push(KW());let n=Iz(PK);t.push(n);try{hK({...IK(e),beforeSend:e=>FK(e),integrations:t})}catch{return null}return NK=!0,gK}function HWe(e){let t=[];e.tracesSampleRate>0&&t.push(NE()),((e.replaysSessionSampleRate??0)>0||(e.replaysOnErrorSampleRate??0)>0)&&t.push(qT());let n=jb(PK);t.push(n);try{pD({...IK(e),beforeSend:e=>FK(e),integrations:t})}catch{return null}return NK=!0,VO}function LK(){if(NK)return Ar?gK:VO;let e=zWe();return e?Ar?VWe(e):HWe(e):null}function RK(e){if(LK()){if(Ar){IN(e);return}ym(e)}}function zK(e,t,n){if(!LK())return;let r=UWe(e);if(Ar){PA(e=>{t&&e.setTags(t);let i=EN(r);n?.showReportDialog&&IV({eventId:i})});return}Id(e=>{t&&e.setTags(t);let i=hm(r);n?.showReportDialog&&LS({eventId:i})})}function UWe(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 WWe=class extends F.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){zK(e,{origin:`react-boundary`},{showReportDialog:!0})}render(){return this.state.hasError?(0,kr.jsxs)(`div`,{className:`forge-app-shell flex min-h-svh w-full min-w-0 flex-col bg-background text-foreground`,children:[(0,kr.jsxs)(`header`,{className:CK,children:[(0,kr.jsx)(`div`,{className:`no-drag-region flex min-w-0 items-center pl-1 md:pl-2.5`,children:(0,kr.jsx)(`button`,{type:`button`,"aria-label":`Go to new chat`,onClick:RWe,className:`${wK} hover:bg-accent/70`,children:(0,kr.jsx)(EK,{})})}),(0,kr.jsx)(`div`,{})]}),(0,kr.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-4`,children:(0,kr.jsxs)(`div`,{className:`max-w-md rounded-xl border border-border bg-card p-6 text-center shadow-lg`,children:[(0,kr.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Something went wrong.`}),(0,kr.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Forge hit an unexpected error and reported it.`}),(0,kr.jsx)(`button`,{className:`mt-4 inline-flex rounded-md border border-border px-3 py-2 text-sm font-medium hover:bg-accent`,onClick:()=>window.location.reload(),type:`button`,children:`Reload app`})]})})]}):this.props.children}};function GWe(e,t){return P({method:`GET`,path:`/api/cmmd/billing`,...t?.organizationId===void 0?{}:{query:{orgId:t.organizationId}}},e)}function KWe(e,t){return P({method:`GET`,path:`/api/cmmd/billing/series`,query:{timeZone:t.timeZone}},e)}function qWe(e,t,n){return P({method:`POST`,path:`/api/cmmd/forge-runtimes/${encodeURIComponent(t)}/rename`,body:{displayName:n}},e)}function JWe(e,t,n){return P({method:`POST`,path:`/api/cmmd/devices/${encodeURIComponent(String(t))}/rename`,body:{displayName:n}},e)}function YWe(e,t){return P({method:`POST`,path:`/api/cmmd/devices/${encodeURIComponent(String(t))}/revoke`},e)}function BK(e){return{...e.limit===void 0?{}:{limit:e.limit},...e.cursor?{cursor:e.cursor}:{}}}var XWe=class extends Error{constructor(e){super(e),this.name=`CmmdApiAuthError`}},ZWe=class extends Error{status;constructor(e,t){super(e),this.name=`CmmdApiServerError`,this.status=t}},VK=class extends Error{constructor(e){super(`CmmdApiClient.${e} is not implemented yet`),this.name=`CmmdApiNotImplementedError`}};function HK(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 UK(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 WK(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 GK(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 QWe(e,t){if(!e||typeof e!=`object`)return null;let n=e[t];return typeof n==`boolean`?n:null}function KK(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 qK(e){let t=`${GK(e,`firstName`)??``} ${GK(e,`lastName`)??``}`.trim()||GK(e,`username`)||GK(e,`email`)||`Unknown`;return{id:KK(e,`userId`)??KK(e,`id`)??t,name:t,email:GK(e,`email`),role:GK(e,`role`),avatarUrl:GK(e,`profileImage`)??GK(e,`avatar`)}}function $We(e){let t=YK(e,`user`)??e;return qK({...typeof t==`object`&&t?t:{},userId:KK(e,`userId`)??KK(t,`id`),role:GK(e,`role`)})}function JK(e){let t=GK(e,`authorFirstName`)??``,n=GK(e,`authorLastName`)??``,r=GK(e,`status`),i=r===`at_risk`||r===`off_track`||r===`complete`?r:`on_track`;return{id:KK(e,`id`)??``,status:i,body:GK(e,`body`)??``,authorName:`${t} ${n}`.trim()||null,authorAvatarUrl:GK(e,`authorProfileImage`)??null,createdAt:GK(e,`createdAt`)??``,updatedAt:GK(e,`updatedAt`)??GK(e,`createdAt`)??``,canEdit:QWe(e,`canEdit`)??!1}}function eGe(e,t,n){let r=Array.isArray(e.data)?e.data.map(JK):[];return{updates:r,pagination:e.pagination??{page:t,limit:n,total:r.length,hasMore:!1}}}function YK(e,t){if(!e||typeof e!=`object`)return null;let n=e[t];return n&&typeof n==`object`?n:null}var tGe=[`avatarUrl`,`avatar_url`,`profileImage`,`profile_image`,`profileImageUrl`,`profile_image_url`,`image`,`imageUrl`,`image_url`,`picture`];function XK(e,t){let n=YK(e,t);if(!n)return null;for(let e of tGe){let t=GK(n,e);if(t)return t}return null}function ZK(e,t){let n=YK(e,t);return n?KK(n,`id`):null}function QK(e,t){return!!(e&&typeof e==`object`&&Object.hasOwn(e,t))}function nGe(e){let t={...e,id:KK(e,`id`)??e.id,title:e.title??GK(e,`name`)??``},n=KK(e,`workspaceId`)??KK(e,`workspace_id`)??ZK(e,`workspace`)??e.workspaceId??null;return n!==null||QK(e,`workspaceId`)?{...t,workspaceId:n,startDate:e.startDate??GK(e,`start_date`)??null,endDate:e.endDate??GK(e,`end_date`)??null}:t}function $K(e){let t=e.ownerAvatarUrl??GK(e,`owner_avatar_url`)??GK(e,`ownerProfileImage`)??GK(e,`owner_profile_image`)??GK(e,`ownerImage`)??GK(e,`owner_image`)??GK(e,`ownerImageUrl`)??GK(e,`owner_image_url`)??GK(e,`createdByAvatarUrl`)??GK(e,`created_by_avatar_url`)??GK(e,`createdByProfileImage`)??GK(e,`created_by_profile_image`)??XK(e,`owner`)??XK(e,`createdBy`)??XK(e,`created_by`)??null,n={...e,id:KK(e,`id`)??e.id},r=KK(e,`campaignId`)??KK(e,`campaign_id`)??ZK(e,`campaign`)??e.campaignId??null;(r!==null||QK(e,`campaignId`))&&(n.campaignId=r);let i=e.campaignTitle??GK(e,`campaignTitle`)??GK(e,`campaign_title`)??GK(YK(e,`campaign`),`title`)??GK(YK(e,`campaign`),`name`)??null;(i!==null||QK(e,`campaignTitle`))&&(n.campaignTitle=i);let a=KK(e,`workspaceId`)??KK(e,`workspace_id`)??ZK(e,`workspace`)??e.workspaceId??null;(a!==null||QK(e,`workspaceId`))&&(n.workspaceId=a);let o=e.workspaceName??GK(e,`workspace_name`)??GK(YK(e,`workspace`),`name`)??null;(o!==null||QK(e,`workspaceName`))&&(n.workspaceName=o);let s=GK(e,`workspaceIconUrl`)??GK(e,`workspace_icon_url`)??GK(YK(e,`workspace`),`iconUrl`)??null;(s!==null||QK(e,`workspaceIconUrl`))&&(n.workspaceIconUrl=s);let c=KK(e,`ownerId`)??KK(e,`owner_id`)??ZK(e,`owner`)??e.ownerId??null;(c!==null||QK(e,`ownerId`))&&(n.ownerId=c);let l=e.ownerName??GK(e,`owner_name`)??GK(YK(e,`owner`),`name`)??null;(l!==null||QK(e,`ownerName`))&&(n.ownerName=l),(t!==null||QK(e,`ownerAvatarUrl`))&&(n.ownerAvatarUrl=t);let u=KK(e,`teamId`)??KK(e,`team_id`)??ZK(e,`team`)??e.teamId??null;(u!==null||QK(e,`teamId`))&&(n.teamId=u);let d=e.teamName??GK(e,`team_name`)??GK(YK(e,`team`),`name`)??null;(d!==null||QK(e,`teamName`))&&(n.teamName=d);let f=e.startDate??GK(e,`start_date`)??null;(f!==null||QK(e,`startDate`))&&(n.startDate=f);let p=e.targetEndDate??GK(e,`target_end_date`)??null;return(p!==null||QK(e,`targetEndDate`))&&(n.targetEndDate=p),n}function eq(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 rGe(e){return eq(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 iGe(e){if(e&&typeof e==`object`){let t=e;if(t.project&&typeof t.project==`object`)return t.project}return e}function tq(e){if(e===null||e.trim()===``)return null;let t=Number(e);return Number.isSafeInteger(t)?t:e}async function nq(e){try{return await e}catch(e){throw e instanceof fr?e.kind===`auth`?new XWe(e.message):new ZWe(e.message,e.status??502):e}}var rq=class e{cfg;commentEditIdempotencyKeys=new Map;commentDeleteIdempotencyKeys=new Map;constructor(e={}){let t=e.forgeOrigin===void 0,n=e.forgeOrigin??`http://localhost:13773`;this.cfg={resolveUrl:t?lr:e=>`${n}${e}`,maxRetries:e.maxRetries??3,onAuthExpired:e.onAuthExpired??ur,...t?{resolveBearerToken:()=>or()?.bearerToken??null}:{}}}async getTask(e){return nq(P({method:`GET`,path:`/api/cmmd/tasks/${e}`},this.cfg))}async getForgeTaskDetail(e){return P({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 nq(P({method:`GET`,path:`/api/cmmd/tasks/search`,query:t},this.cfg))).tasks??[]}async getTaskComments(e){return(await nq(P({method:`GET`,path:`/api/cmmd/tasks/${e}/comments`},this.cfg))).comments??[]}async listProjectTaskComments(e){return(await nq(P({method:`GET`,path:`/api/cmmd/tasks/${e}/comments`},this.cfg))).comments??[]}async createProjectTaskComment(e,t){return(await nq(P({method:`POST`,path:`/api/cmmd/tasks/comment`,body:{taskId:e,content:t.content}},this.cfg))).details}async updateProjectTaskComment(e,t,n){return(await nq(P({method:`PATCH`,path:`/api/cmmd/tasks/${e}/comments/${encodeURIComponent(t)}`,body:n},this.cfg))).comment}async deleteProjectTaskComment(e,t,n){return nq(P({method:`DELETE`,path:`/api/cmmd/tasks/${e}/comments/${encodeURIComponent(t)}`,body:n},this.cfg))}async getTaskAttachments(e){return nq(P({method:`GET`,path:`/api/cmmd/tasks/${e}/attachments`},this.cfg))}async getProjectRepository(e){return nq(P({method:`GET`,path:`/api/cmmd/projects/${e}/repository`},this.cfg))}async listProjectRepositories(e){return(await nq(P({method:`GET`,path:`/api/cmmd/projects/${e}/repositories`},this.cfg))).repositories}async getWorkspaceMembers(e){return nq(P({method:`GET`,path:`/api/cmmd/organizations/${e}/members`},this.cfg))}async getWebSocketToken(e){return P({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 P({method:`GET`,path:`/api/cmmd/projects/${e}/comments`,query:n},this.cfg))?.comments??[]}async getProjectLink(e){return P({method:`GET`,path:`/.well-known/forge/project-link`,query:{environmentId:e.environmentId,projectId:e.projectId,cwd:e.cwd}},this.cfg)}async listProjectLinks(){return P({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 P({method:`GET`,path:`/.well-known/forge/cmmd/project-links`,query:t},this.cfg),r=$t(Sne)(n);return r._tag===`Some`?r.value.links:[]}async listCmmdWorkspaces(){return eq(await P({method:`GET`,path:`/.well-known/forge/cmmd/workspaces`},this.cfg))}async listCmmdCampaigns(e){return rGe(await P({method:`GET`,path:`/.well-known/forge/cmmd/campaigns`,query:{workspaceId:e.workspaceId}},this.cfg))}async listCmmdProjects(e){return eq(await P({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),nq(P({method:`POST`,path:`/api/cmmd/tasks/update`,body:n},this.cfg))}async createComment(e){return nq(P({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 nq(P({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 nq(P({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 P({method:`POST`,path:`/api/cmmd/projects/${e}/comments`,body:{content:t.content,organizationId:t.organizationId??null}},this.cfg))?.comment;if(!n)throw new fr({kind:`server`,message:`CMMD did not return the created project comment.`});return n}async updateProject(e,t){let n={};for(let e of gne){let r=t[e];r!==void 0&&(n[e]=vne[e]===`nullableId`?tq(r):r)}await P({method:`PATCH`,path:`/api/cmmd/projects/${e}`,body:n},this.cfg)}async setProjectLink(e){await P({method:`POST`,path:`/.well-known/forge/project-link`,body:e},this.cfg)}async deleteProjectLink(e){await P({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 P({method:`POST`,path:`/.well-known/forge/cmmd/projects`,body:e},this.cfg)}async ensureGitHubProjectContext(e){return P({method:`POST`,path:`/.well-known/forge/cmmd/github-project-contexts/ensure`,body:e},this.cfg)}async createBrainDoc(e){return P({method:`POST`,path:`/api/cmmd/brain-docs`,body:e},this.cfg)}async uploadTaskAttachment(e,t){let n=new FormData;return n.append(`file`,t),nq(P({method:`POST`,path:`/api/cmmd/tasks/${e}/attachments`,form:n},this.cfg))}async archiveTask(e){await P({method:`POST`,path:`/api/cmmd/tasks/${e}/archive`},this.cfg)}async unarchiveTask(e){await P({method:`POST`,path:`/api/cmmd/tasks/${e}/unarchive`},this.cfg)}async getProfile(){return P({method:`GET`,path:`/api/cmmd/profile`},this.cfg)}async getUsageSummary(e){return P({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 GWe(this.cfg,e)}getBillingSeries(e){return KWe(this.cfg,e)}async getBootstrap(){return P({method:`GET`,path:`/api/cmmd/bootstrap`},this.cfg)}async getForgeAccountPreferences(){return P({method:`GET`,path:`/api/cmmd/account/preferences`},this.cfg)}async updateForgeAccountPreferences(e){return P({method:`PATCH`,path:`/api/cmmd/account/preferences`,body:e},this.cfg)}async getOrgProviderPolicy(){return P({method:`GET`,path:`/api/cmmd/org/provider-policy`},this.cfg)}async listSavedDataViews(e){return P({method:`GET`,path:`/api/cmmd/saved-views`,query:{surface:e.surface,projectId:e.projectId}},this.cfg)}async createSavedDataView(e){return P({method:`POST`,path:`/api/cmmd/saved-views`,body:e},this.cfg)}async importSavedDataView(e){return P({method:`POST`,path:`/api/cmmd/saved-views/import`,body:e},this.cfg)}async updateSavedDataView(e,t){return P({method:`PATCH`,path:`/api/cmmd/saved-views/${encodeURIComponent(e)}`,body:t},this.cfg)}async deleteSavedDataView(e,t){return P({method:`DELETE`,path:`/api/cmmd/saved-views/${encodeURIComponent(e)}`,query:t},this.cfg)}async getDeviceRegistry(e){return P({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 P({method:`POST`,path:`/api/cmmd/devices/register`,body:e},this.cfg)}async grantRuntimeAccess(e,t){return P({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/access-grants`,body:t},this.cfg)}async revokeRuntimeAccess(e,t){return P({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/access-grants/${encodeURIComponent(String(t))}/revoke`},this.cfg)}async issueRelayControlRoute(e,t){return P({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/relay-routes`,body:t},this.cfg)}async issueRelayActionGrant(e,t){return P({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/relay-action-grants`,body:t},this.cfg)}async getRuntimeInventory(e){let t={...e?.projectId===void 0?{}:{projectId:String(e.projectId)},...e?.allWorkspaces===!0?{allWorkspaces:`true`}:{}};return P({method:`GET`,path:`/api/cmmd/runtime-inventory`,...Object.keys(t).length>0?{query:t}:{}},this.cfg)}async getRuntimeDiagnostics(e){return P({method:`GET`,path:`/api/cmmd/runtime-diagnostics/v2/runtimes/${encodeURIComponent(e)}`},this.cfg)}async getCloudProjectLifecyclePreflight(e){return(await P({method:`GET`,path:`/api/cmmd/forge-cloud-projects/${encodeURIComponent(String(e))}/lifecycle-preflight`},this.cfg)).preflight}async replaceRuntimeInventory(e,t){return P({method:`PUT`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/inventory`,body:t},this.cfg)}static AUTH_RUNTIME_PATH=`/api/cmmd/auth-runtime`;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`;static USER_CODEX_CREDENTIAL_PATH=`/api/cmmd/providers/codex/credential`;static USER_CLAUDE_CREDENTIAL_PATH=`/api/cmmd/providers/claude/credential`;async provisionAuthRuntime(){return P({method:`POST`,path:e.AUTH_RUNTIME_PATH},this.cfg)}async getAuthRuntimeState(){return P({method:`GET`,path:e.AUTH_RUNTIME_PATH},this.cfg)}async destroyAuthRuntime(){return P({method:`DELETE`,path:e.AUTH_RUNTIME_PATH},this.cfg)}async connectAuthRuntime(){return P({method:`POST`,path:`${e.AUTH_RUNTIME_PATH}/connect`},this.cfg)}async getUserCodexCredential(){return P({method:`GET`,path:e.USER_CODEX_CREDENTIAL_PATH},this.cfg)}async disconnectUserCodexCredential(){return P({method:`DELETE`,path:e.USER_CODEX_CREDENTIAL_PATH},this.cfg)}async getUserClaudeCredential(){return P({method:`GET`,path:e.USER_CLAUDE_CREDENTIAL_PATH},this.cfg)}async getProviderAccounts(){return P({method:`GET`,path:e.PROVIDER_ACCOUNTS_PATH},this.cfg)}async removeLinkedProviderAccount(t){return P({method:`DELETE`,path:`${e.PROVIDER_ACCOUNTS_PATH}/${t}`},this.cfg)}async setProviderAccountDefault(t){return P({method:`PUT`,path:`${e.PROVIDER_ACCOUNTS_PATH}/default`,body:{provider:t.provider,provider_account_id:t.providerAccountId}},this.cfg)}async getProviderUsage(){return P({method:`GET`,path:e.PROVIDER_USAGE_PATH},this.cfg)}async refreshProviderUsage(t,n){return P({method:`POST`,path:e.PROVIDER_USAGE_REFRESH_PATH,body:{provider:t,providerAccountId:n}},this.cfg)}async disconnectUserClaudeCredential(){return P({method:`DELETE`,path:e.USER_CLAUDE_CREDENTIAL_PATH},this.cfg)}async getClaudeRuntimeReadiness(e){return P({method:`GET`,path:`/api/cmmd/providers/claude/runtime-readiness/${encodeURIComponent(e)}`},this.cfg)}async appendRuntimeThreadEvents(e,t,n){return P({method:`POST`,path:`/api/cmmd/devices/runtimes/${encodeURIComponent(e)}/threads/${encodeURIComponent(t)}/events`,body:n},this.cfg)}async getRuntimeThreadReplica(e,t){return P({method:`GET`,path:`/api/cmmd/threads/${encodeURIComponent(e)}/${encodeURIComponent(t)}`},this.cfg)}renameCloudEnvironment(e,t){return qWe(this.cfg,e,t)}renameDevice(e,t){return JWe(this.cfg,e,t)}revokeDevice(e){return YWe(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 P({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 P({method:`GET`,path:`${e.SIM_PATH}/leases?${n.toString()}`},this.cfg)}async claimSimLease(t){return P({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 P({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 P({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`),HK(await P({method:`GET`,path:`/api/cmmd/campaigns`,query:t,...e?.signal?{signal:e.signal}:{}},this.cfg),`campaigns`).map(nGe)}async getCampaign(e){return P({method:`GET`,path:`/api/cmmd/campaigns/${e}`},this.cfg)}async createCampaign(e){return P({method:`POST`,path:`/api/cmmd/campaigns`,body:e},this.cfg)}async updateCampaign(e,t){return P({method:`PUT`,path:`/api/cmmd/campaigns/${e}`,body:t},this.cfg)}async deleteCampaign(e){await P({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`),HK(await P({method:`GET`,path:`/api/cmmd/projects`,query:t,...e?.signal?{signal:e.signal}:{}},this.cfg),`projects`).map($K)}async listTasks(e){let t={};return e?.projectId&&(t.projectId=e.projectId),e?.status&&(t.status=e.status),P({method:`GET`,path:`/api/cmmd/tasks`,query:t},this.cfg)}async getProject(e){return $K(await P({method:`GET`,path:`/api/cmmd/projects/${e}`},this.cfg))}async getProjectMembers(e){let t=await P({method:`GET`,path:`/api/cmmd/projects/${e}/members`},this.cfg);return Array.isArray(t)?t.map(qK):[]}async listWorkspaceMembers(){let e=await P({method:`GET`,path:`/api/cmmd/members`},this.cfg);return Array.isArray(e)?e.map($We):[]}async addProjectMember(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/members`,body:t},this.cfg)}async listProjectAgentMembers(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/agent-members`},this.cfg)}async createProjectAgentMember(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/agent-members`,body:t},this.cfg)}async renameProjectAgentMember(e,t,n){return P({method:`PATCH`,path:`/api/cmmd/projects/${e}/agent-members/${t}`,body:n},this.cfg)}async retireProjectAgentMember(e,t,n){return P({method:`POST`,path:`/api/cmmd/projects/${e}/agent-members/${t}/retire`,body:n},this.cfg)}async updateProjectAgentMemberAvatar(e,t,n){return P({method:`PUT`,path:`/api/cmmd/projects/${e}/agent-members/${t}/avatar`,body:n},this.cfg)}async listProjectAgentMemberInstances(e,t){return P({method:`GET`,path:`/api/cmmd/projects/${e}/agent-members/${t}/instances`},this.cfg)}async previewProjectAgentMemberConsolidation(e){return P({method:`POST`,path:`/api/cmmd/projects/${e}/agent-members/consolidation/preview`},this.cfg)}async applyProjectAgentMemberConsolidation(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/agent-members/consolidation/apply`,body:t},this.cfg)}async setProjectTaskAssignment(e,t,n){return P({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 eGe(await P({method:`GET`,path:`/api/cmmd/projects/${e}/updates`,query:{page:n,limit:r},unwrapEnvelope:!1},this.cfg),n,r)}async createProjectUpdate(e,t){return JK(await P({method:`POST`,path:`/api/cmmd/projects/${e}/updates`,body:t},this.cfg))}async updateProjectUpdate(e,t,n){return JK(await P({method:`PATCH`,path:`/api/cmmd/projects/${e}/updates/${t}`,body:n},this.cfg))}async deleteProjectUpdate(e,t){await P({method:`DELETE`,path:`/api/cmmd/projects/${e}/updates/${t}`},this.cfg)}async listProjectMilestones(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/milestones`},this.cfg)}async createProjectMilestone(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/milestones`,body:t},this.cfg)}async updateProjectMilestone(e,t,n){return P({method:`PATCH`,path:`/api/cmmd/projects/${e}/milestones/${t}`,body:n},this.cfg)}async deleteProjectMilestone(e,t){await P({method:`DELETE`,path:`/api/cmmd/projects/${e}/milestones/${t}`},this.cfg)}async improveProjectContent(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/content/readability`,body:t},this.cfg)}async listProjectBoard(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/board`},this.cfg)}async createProjectTaskDraft(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/task-drafts`,body:t},this.cfg)}async getProjectTaskDraft(e,t){return P({method:`GET`,path:`/api/cmmd/projects/${e}/task-drafts/${t}`},this.cfg)}async updateProjectTaskDraft(e,t,n){return P({method:`PATCH`,path:`/api/cmmd/projects/${e}/task-drafts/${t}`,body:n},this.cfg)}async previewProjectTaskDraft(e,t,n){return P({method:`POST`,path:`/api/cmmd/projects/${e}/task-drafts/${t}/preview`,body:n},this.cfg)}async commitProjectTaskDraft(e,t,n){return P({method:`POST`,path:`/api/cmmd/projects/${e}/task-drafts/${t}/commit`,body:n},this.cfg)}async discardProjectTaskDraft(e,t,n){return P({method:`POST`,path:`/api/cmmd/projects/${e}/task-drafts/${t}/discard`,body:n},this.cfg)}async getProjectTaskWorkflow(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/task-workflow`},this.cfg)}async updateProjectTaskWorkflow(e,t){return P({method:`PUT`,path:`/api/cmmd/projects/${e}/task-workflow`,body:t},this.cfg)}async getProjectLeadPlan(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/plan`},this.cfg)}async activateProjectLeadAutomaticStaffing(e){return P({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/authority/activate`,body:{}},this.cfg)}async getProjectLeadReadiness(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/readiness`},this.cfg)}async getProjectLeadCapabilities(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/capabilities`},this.cfg)}async getProjectLeadSummary(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/summary`},this.cfg)}async getProjectLeadDetail(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/detail`},this.cfg)}async getProjectLeadBriefing(e){return P({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/briefing`},this.cfg)}async decideProjectLeadApproval(e,t,n){return P({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/approvals/${t}/decision`,body:n},this.cfg)}async listProjectLeadEvents(e,t){return P({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 P({method:`GET`,path:`/api/cmmd/projects/${e}/project-lead/explain`},this.cfg)}async pauseProjectLead(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/pause`,body:t},this.cfg)}async resumeProjectLead(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/resume`,body:t},this.cfg)}async reserveProjectLeadTask(e,t,n){return P({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/tasks/${t}/reservations`,body:n},this.cfg)}async releaseProjectLeadReservation(e,t,n){return P({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/reservations/${t}/release`,body:n},this.cfg)}async reconcileProjectLead(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/project-lead/reconcile`,body:t},this.cfg)}async resolveProjectLeadAttention(e,t,n){return P({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),P({method:`GET`,path:`/api/cmmd/work-items/board`,query:t},this.cfg)}async listForgeAutomationPresets(){return UK(await P({method:`GET`,path:`/api/cmmd/automations/presets`},this.cfg),`presets`)}async listUserForgeAutomationRules(){return UK(await P({method:`GET`,path:`/api/cmmd/automations/user/rules`},this.cfg),`rules`)}async createUserForgeAutomationRule(e){return P({method:`POST`,path:`/api/cmmd/automations/user/rules`,body:e},this.cfg)}async updateUserForgeAutomationRule(e,t){return P({method:`PATCH`,path:`/api/cmmd/automations/user/rules/${e}`,body:t},this.cfg)}async listUserForgeAutomationRuns(e){return UK(await P({method:`GET`,path:`/api/cmmd/automations/user/rules/${e}/runs`},this.cfg),`runs`)}async startUserForgeAutomationRun(e,t){return P({method:`POST`,path:`/api/cmmd/automations/user/rules/${e}/runs`,body:t},this.cfg)}async listForgeAutomationRules(e,t){let n=WK(t);return UK(await P({method:`GET`,path:`/api/cmmd/automations/projects/${e}/rules`,...n?{query:n}:{}},this.cfg),`rules`)}async createForgeAutomationRule(e,t,n){let r=WK(n);return P({method:`POST`,path:`/api/cmmd/automations/projects/${e}/rules`,body:t,...r?{query:r}:{}},this.cfg)}async updateForgeAutomationRule(e,t,n,r){let i=WK(r);return P({method:`PATCH`,path:`/api/cmmd/automations/projects/${e}/rules/${t}`,body:n,...i?{query:i}:{}},this.cfg)}async listForgeAutomationRuns(e,t){let n=WK(t,t?.taskId);return UK(await P({method:`GET`,path:`/api/cmmd/automations/projects/${e}/runs`,...n?{query:n}:{}},this.cfg),`runs`)}async getForgeAutomationRun(e,t){let n=WK(t);return P({method:`GET`,path:`/api/cmmd/automations/runs/${e}`,...n?{query:n}:{}},this.cfg)}async startForgeAutomationRun(e,t,n,r){let i=WK(r);return P({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=WK(n);return P({method:`POST`,path:`/api/cmmd/automations/runs/${e}/retry`,body:t,...r?{query:r}:{}},this.cfg)}async cancelForgeAutomationRun(e,t,n){let r=WK(n);return P({method:`POST`,path:`/api/cmmd/automations/runs/${e}/cancel`,body:t,...r?{query:r}:{}},this.cfg)}async approveForgeAutomationEscalation(e,t,n){let r=WK(n);return P({method:`POST`,path:`/api/cmmd/automations/runs/${e}/escalations/approve`,body:t,...r?{query:r}:{}},this.cfg)}async rejectForgeAutomationEscalation(e,t,n){let r=WK(n);return P({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),P({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),P({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),P({method:`POST`,path:`/api/cmmd/feedback`,body:t},this.cfg)}async updateProjectBoardTask(e,t,n){return P({method:`PATCH`,path:`/api/cmmd/projects/${e}/board/${t}`,body:n},this.cfg)}async updateCenterBoardTask(e,t){return P({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),P({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),P({method:`PATCH`,path:`/api/cmmd/projects/${e}/board/${t}/move`,body:r},this.cfg)}async archiveProjectBoardTask(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/board/${t}/archive`},this.cfg)}async unarchiveProjectBoardTask(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/board/${t}/unarchive`},this.cfg)}async updateProjectBoardTaskStatus(e,t,n,r){return P({method:`PATCH`,path:`/api/cmmd/projects/${e}/board/${t}/status`,body:{status:n,...r?{workflowStageId:r}:{}}},this.cfg)}async spawnForgeThreadFromBoardTask(e,t){return P({method:`POST`,path:`/api/cmmd/projects/${e}/board/${t}/spawn-forge-thread`,body:{}},this.cfg)}async listTaskExecutionOptions(e,t){return P({method:`GET`,path:`/api/cmmd/projects/${e}/board/${t}/execution-options`},this.cfg)}async createTaskWorkSession(e,t,n){return P({method:`POST`,path:`/api/cmmd/projects/${e}/board/${t}/work-sessions`,body:n},this.cfg)}async listProjectWorkSessions(e,t={}){return P({method:`GET`,path:`/api/cmmd/projects/${e}/work-sessions`,query:t},this.cfg)}async getWorkSession(e){return P({method:`GET`,path:`/api/cmmd/work-sessions/${e}`},this.cfg)}async updateWorkSessionStatus(e,t){return P({method:`PATCH`,path:`/api/cmmd/work-sessions/${e}`,body:{status:t}},this.cfg)}async attachWorkSessionThread(e,t){return P({method:`POST`,path:`/api/cmmd/work-sessions/${e}/threads`,body:t},this.cfg)}async listTaskConversations(e,t={}){return P({method:`GET`,path:`/api/cmmd/tasks/${e}/conversations`,query:BK(t)},this.cfg)}async linkTaskConversation(e,t){return P({method:`POST`,path:`/api/cmmd/tasks/${e}/conversations`,body:t},this.cfg)}async getTaskHistory(e){return P({method:`GET`,path:`/api/cmmd/tasks/${e}/history`},this.cfg)}async upsertTaskPullRequest(e,t){return P({method:`PUT`,path:`/api/cmmd/tasks/${e}/pull-requests`,body:t},this.cfg)}postPullRequest(e,t){return P({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 P({method:`GET`,path:`/api/cmmd/tasks/${e}/conversations/${encodeURIComponent(t)}`,query:BK(n)},this.cfg)}async createTask(e){return P({method:`POST`,path:`/api/cmmd/tasks`,body:e},this.cfg)}async createSubtask(e){throw new VK(`createSubtask`)}async createBoardTask(e){throw new VK(`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=tq(e.campaignId)),e.organizationId!==void 0&&e.organizationId!==null&&(t.organizationId=tq(e.organizationId)),iGe(await P({method:`POST`,path:`/api/cmmd/projects`,body:t},this.cfg))}async moveProject(e,t){let n={targetOrgId:tq(t.targetOrgId)};return t.campaignStrategy!==void 0&&(n.campaignStrategy=t.campaignStrategy),t.targetCampaignId!==void 0&&(n.targetCampaignId=tq(t.targetCampaignId)),t.dryRun!==void 0&&(n.dryRun=t.dryRun),P({method:`POST`,path:`/api/cmmd/projects/${e}/move`,body:n},this.cfg)}async uploadBrainDoc(e,t){throw new VK(`uploadBrainDoc`)}};function iq(e){return new rq(e)}var aq=new rq({onAuthExpired:ur}),oq=class extends Gn(`BootstrapHttpError`){},sq=e=>lee(e,`BootstrapHttpError`);function cq(e){return typeof e!=`object`||!e?!1:!!(sq(e)&&e.status===401||e instanceof Error&&e.name===`RemoteEnvironmentAuthHttpError`&&`status`in e&&e.status===401||e instanceof fr&&e.kind===`auth`)}function lq(e={resolveUrl:lr}){let t=or()?.bearerToken;return t?{...e,bearerToken:t}:e}var uq=null,dq=null,fq=null,pq=new Set,mq=`cmmd-forge.loggedOutLocalBootstrapCredentials.v1`;function aGe(e){let t=`${e.firstName??``} ${e.lastName??``}`.trim();RK({id:e.id,email:e.email,...t.length>0?{username:t}:{}}),Rl({cmmdUserId:e.id,...e.email?{email:e.email}:{},...t.length>0?{displayName:t}:{}})}function hq(){if(typeof window>`u`||fq)return;let e=window.desktopBridge?.desktopAuth?.onStateChange;e&&(fq=e(e=>{uq=null,dq=null,e.sessionLifecycle.status!==`ready`&&RK(null),(e.sessionLifecycle.status===`expired`||e.sessionLifecycle.status===`signed-out`&&e.sessionLifecycle.reason===`refresh-revoked`)&&Mne().catch(e=>{zK(e,{route:`desktop-auth-session-expired`})})}))}function oGe(e){let t=e.replace(/\s+/g,` `).trim();return t.length===0?`<empty response>`:t.slice(0,120)}async function gq(e,t){let n=await e.text();try{return JSON.parse(n)}catch{throw new oq({message:`${t} returned a non-JSON response (${oGe(n)}). Ensure the Forge server is running and this route is proxied correctly.`,status:e.status})}}function sGe(){return Hl(new URL(window.location.href))}function _q(){let e=new URL(window.location.href),t=zce(e);t.toString()!==e.toString()&&window.history.replaceState({},document.title,t.toString())}async function cGe(){return Eq(async()=>{let e=lr(`/api/auth/session`),t=await fetch(e,rr({credentials:`include`}));if(!t.ok)throw new oq({message:`Failed to load server auth session state (${t.status}).`,status:t.status});return gq(t,e)})}async function lGe(e,t){return await e.text()||t}var vq=new Set([`CMMD_AUTH_REQUIRED`,`CMMD_AUTH_EXPIRED`]);async function uGe(e){return Eq(async()=>{let t={credential:e},n=lr(`/api/auth/bootstrap`),r=await fetch(n,rr({body:JSON.stringify(t),credentials:`include`,headers:{"content-type":`application/json`},method:`POST`}));if(!r.ok)throw new oq({message:await r.text()||`Failed to bootstrap auth session (${r.status}).`,status:r.status});return gq(r,n)})}function yq(e){return new URL(e,window.location.origin).toString()}function bq(e){let t=(e?.primaryMode===`cloud`?null:e)?.bootstrapToken?.trim();return t&&t.length>0?t:null}function xq(){return typeof window>`u`?null:bq(window.desktopBridge?.getLocalEnvironmentBootstrap?.()??null)}function dGe(){return typeof window>`u`?!1:Pne()===`session-expired`}function Sq(){if(typeof window>`u`)return new Set;try{let e=window.sessionStorage.getItem(mq),t=e?JSON.parse(e):[];return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function Cq(e){if(!(typeof window>`u`))try{if(e.size===0){window.sessionStorage.removeItem(mq);return}window.sessionStorage.setItem(mq,JSON.stringify([...e]))}catch{}}function fGe(){let e=xq();if(!e)return;let t=new Set(Sq());t.add(e),Cq(t)}function pGe(e){return Sq().has(e)}function wq(){let e=xq();if(!e){Cq(new Set);return}let t=new Set(Sq());t.delete(e),Cq(t)}async function Tq(){let e=yq(`/api/auth/session`),t=await fetch(e,{credentials:`include`});return t.ok?gq(t,e):null}async function mGe(e){if(typeof window>`u`)return;let t=bq(e);if(!t||dGe()||pq.has(t)||pGe(t))return;if((await Tq().catch(()=>null))?.authenticated){pq.add(t);return}let n=yq(`/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 oq({message:await r.text()||`Failed to bootstrap local web owner session (${r.status}).`,status:r.status})}await gq(r,n),pq.add(t)}async function hGe(){let e=await cGe();if(e.authenticated)return e;let t=or();if(t?.source!==`desktop-managed`||!t.bearerToken)return e;let n=await Tq().catch(()=>null);return n?.authenticated?n:e}var gGe=new Set([404,502,503,504]),_Ge=15e3,vGe=500;function yGe(e){or()?.source===`paired-bearer`&&cq(e)&&dr(`http`)}async function Eq(e){let t=Date.now();for(;;)try{return await e()}catch(e){if(yGe(e),!xGe(e))throw e;if(Date.now()-t>=_Ge)throw zK(e,{route:`bootstrap-retry-exhausted`}),e;await bGe(vGe)}}function bGe(e){return new Promise(t=>{setTimeout(t,e)})}function xGe(e){return sq(e)?gGe.has(e.status):e instanceof TypeError||e instanceof DOMException&&e.name===`AbortError`}function SGe(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 CGe(e){if(typeof window>`u`||!window.desktopBridge)return null;let t=window.desktopBridge.desktopAuth?.getState;if(!t)return`desktop-state-unavailable`;try{return SGe(await t(),e)}catch(e){return zK(e,{route:`desktop-auth-gate-state`}),`desktop-state-unavailable`}}async function wGe(e,t){return RK(null),Fne(t),await ir().catch(e=>{zK(e,{route:`desktop-auth-gate-logout`})}),{status:`requires-auth`,auth:e.auth,errorMessage:Nne(t)??`Forge Desktop requires CMMD authentication.`}}async function TGe(){let e=await hGe();if(e.authenticated){if(e.cmmdIdentity){let t=await CGe(e.cmmdIdentity);return t?(sr(),wGe(e,t)):(sr(),aGe(e.cmmdIdentity),{status:`authenticated`})}return{status:`requires-auth`,auth:e.auth}}return{status:`requires-auth`,auth:e.auth}}async function EGe(e){let t=e.trim();if(!t)throw Error(`Enter a pairing token to continue.`);dq=null,wq(),await uGe(t),uq=null,_q()}function Dq(){wq(),dq=null,uq=null}async function Oq(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=lr(`/api/auth/bootstrap/command`),s=await fetch(o,rr({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 oq({message:await s.text()||`Failed to bootstrap with CMMD OAuth token (${s.status}).`,status:s.status});await gq(s,o),Dq()}async function DGe(){let e=lr(`/api/auth/ws-token`),t=await fetch(e,rr({credentials:`include`,method:`POST`}));if(!t.ok)throw new oq({message:await t.text()||`Failed to issue websocket token (${t.status}).`,status:t.status});return gq(t,e)}async function OGe(e){let t=await DGe(),n=new URL(e,window.location.origin);return n.searchParams.set(`wsToken`,t.token),n.toString()}async function kGe(e,t){let n=e?.trim(),r={...n?{label:n}:{},...t?{role:t}:{}},i=lr(`/api/auth/pairing-token`),a=await fetch(i,rr({body:JSON.stringify(r),credentials:`include`,headers:{"content-type":`application/json`},method:`POST`}));if(!a.ok)throw Error(await lGe(a,`Failed to create pairing credential (${a.status}).`));return gq(a,i)}async function AGe(){let e=new URL(`/api/auth/session`,window.location.origin).toString(),t=await fetch(e,{credentials:`include`});if(!t.ok)throw new oq({message:`Failed to load current app auth session state (${t.status}).`,status:t.status});return jGe(await gq(t,e))}function jGe(e){if(!e.authenticated||!e.role)throw Error(`Authenticated session is required.`);let t=MGe(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 MGe(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 NGe(e){let t=`/api/cmmd/work-intake`,n;try{n=await P({method:`GET`,path:t,allowRetry:!1,...e?{query:{fresh:1}}:{}},lq())}catch(e){throw e instanceof fr&&e.kind!==`auth`&&e.code!==null&&vq.has(e.code)?new fr({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 PGe(e={}){return NGe(e.forceFresh===!0)}async function kq(e,t){try{return await P({method:`POST`,path:e,body:t,allowRetry:!1},lq())}catch(e){throw e instanceof fr&&e.kind!==`auth`&&e.code!==null&&vq.has(e.code)?new fr({kind:`auth`,message:e.message,status:e.status??401,code:e.code}):e}}async function FGe(e){try{return await kq(`/api/cmmd/tasks/update`,e)}catch(t){if(t instanceof fr&&(t.kind===`auth`||t.kind===`permission`))throw t;if(t instanceof fr||t instanceof Error)return kq(`/api/command/tasks/update`,e);throw t}}async function IGe(){typeof window>`u`||await window.desktopBridge?.desktopAuth?.logoutCloud?.()}async function LGe(){let e=await Promise.allSettled([ir(),IGe()]);RK(null),fGe(),uq=null,dq=null;let t=e.find(e=>e.status===`rejected`);if(t)throw t.reason}async function RGe(){if(hq(),dq?.status===`authenticated`)return sr(),dq;if(uq)return uq;let e=Aq();return uq=e,e.then(e=>(e.status===`authenticated`&&(dq=e),e)).finally(()=>{uq===e&&(uq=null)})}async function Aq(){return cr().then(e=>mGe(e)).then(()=>TGe())}async function zGe(){hq(),uq=null,dq=null;let e=await Aq();return e.status===`authenticated`&&(dq=e,sr()),e}async function BGe(e){let t=e.email.trim();if(!t||!e.password)throw Error(`Enter your CMMD email and password.`);let n=lr(`/api/auth/cmmd-password/token`),r=await fetch(n,rr({body:JSON.stringify({email:t,password:e.password}),credentials:`include`,headers:{"content-type":`application/json`},method:`POST`}));if(!r.ok)throw new oq({message:await r.text()||`CMMD login failed (${r.status}).`,status:r.status});let i=await gq(r,n);if(i.authenticated===!0)return Dq(),{serverEstablishedSession:!0};if(typeof i.access_token!=`string`||i.access_token.trim().length===0)throw Error(`CMMD login did not return an access token.`);return await Oq(i.access_token,i.user,{refreshToken:typeof i.refresh_token==`string`?i.refresh_token:void 0,mcpToken:typeof i.mcp_token==`string`?i.mcp_token:void 0}),{serverEstablishedSession:!1}}var VGe=`/.well-known/forge/environment`,jq=Wt()(e=>({descriptor:null,setDescriptor:t=>e({descriptor:t}),reset:()=>e({descriptor:null})})),Mq=null;function HGe(e){let t=Nq();return t?Yie(Po({id:t.environmentId,label:t.label,source:e.source,target:e.target}),t):null}async function UGe(){return Eq(async()=>{await cr();let e=or()?.bearerToken,t=lr(VGe),n=e?await fetch(t,{headers:{Authorization:`Bearer ${e}`}}):await fetch(t);if(!n.ok)throw new oq({message:`Failed to load server environment descriptor (${n.status}).`,status:n.status});let r=await gq(n,t);return Pq(r),r})}function Nq(){return jq.getState().descriptor}function WGe(){return jq(GGe)}function GGe(e){return e.descriptor?.environmentId??null}function KGe(){return jq(qGe)}function qGe(e){return e.descriptor}function JGe(){return jq(YGe)}function YGe(e){return e.descriptor?.deviceRuntimeId??null}function XGe(){return Nq()?.deviceRuntimeId??null}function ZGe(){return jq(QGe)}function QGe(e){return tae(e.descriptor)}function $Ge(){return jq(eKe)}function eKe(e){return nae(e.descriptor)}function Pq(e){jq.getState().setDescriptor(e)}function tKe(e,t){return t?.primaryMode!==`cloud`||e.environmentId===t.environmentId}function Fq(){let e=or();return e?HGe({source:e.source,target:e.target}):null}function nKe(){return rKe()}async function rKe(){let e=await cr(),t=Nq();if(t&&tKe(t,e))return Promise.resolve(t);if(t&&Pq(null),Mq)return Mq;let n=UGe();return Mq=n,n.finally(()=>{Mq===n&&(Mq=null)})}function iKe(e,t){return e.reasoningEffortLevels.some(e=>e.value===t)}function Iq(e){return e.reasoningEffortLevels.find(e=>e.isDefault)?.value??null}function Lq(e,t){let n=Iq(e),r=typeof t==`string`?t.trim():null;return r&&!e.promptInjectedEffortLevels.includes(r)&&iKe(e,r)?r:n??void 0}function Rq(e,t){return e.contextWindowOptions.some(e=>e.value===t)}function zq(e){return e.contextWindowOptions.find(e=>e.isDefault)?.value??null}function aKe(e,t){let n=zq(e);return t&&Rq(e,t)?t:n??void 0}function oKe(e,t){let n=Lq(e,t?.reasoningEffort),r=e.supportsFastMode?t?.fastMode:void 0,i={...n?{reasoningEffort:n}:{},...r===void 0?{}:{fastMode:r}};return Object.keys(i).length>0?i:void 0}function sKe(e,t){let n=Lq(e,t?.effort),r=e.supportsThinkingToggle?t?.thinking:void 0,i=e.supportsFastMode?t?.fastMode:void 0,a=aKe(e,t?.contextWindow),o={...r===void 0?{}:{thinking:r},...n?{effort:n}:{},...i===void 0?{}:{fastMode:i},...a===void 0?{}:{contextWindow:a}};return Object.keys(o).length>0?o:void 0}function Bq(e){return typeof e==`string`&&/\bultrathink\b/i.test(e)}function Vq(e,t=`codex`){if(typeof e!=`string`)return null;let n=e.trim();if(!n)return null;let r=lne[t],i=Object.prototype.hasOwnProperty.call(r,n)?r[n]:void 0;return typeof i==`string`?i:n}function Hq(e,t,n){if(typeof t!=`string`)return null;let r=t.trim();if(!r)return null;let i=n.find(e=>e.slug===r);if(i)return i.slug;let a=n.find(e=>e.name.toLowerCase()===r.toLowerCase());if(a)return a.slug;let o=Vq(r,e),s=n.find(e=>e.slug===o);return s?s.slug:null}var cKe=[`codex`,`claudeAgent`];function Uq(e,t){return cKe.filter(e=>e!==t).some(t=>nne(t,e)!==void 0)}function lKe(e,t){let n=Vq(e,t);return!n||Uq(n,t)?Vn[t]:n}function Wq(e,t){return lKe(t,e)}function uKe(e){return typeof e==`string`&&e.trim()||null}function dKe(e,t){let n=e.trim();return!n||t!==`ultrathink`||n.startsWith(`Ultrathink:`)?n:`Ultrathink:\n${n}`}function fKe(){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 Gq=typeof window<`u`?window.localStorage:fKe(),pKe=(e,t)=>Dn(tn(e))(t),mKe=(e,t)=>Mte(tn(e))(t),Kq=(e,t)=>{let n=Gq.getItem(e);return n?pKe(t,n):null},qq=(e,t,n)=>{let r=mKe(n,t);Gq.setItem(e,r)},Jq=e=>{Gq.removeItem(e)},Yq=`forge:local_storage_change`;function hKe(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(Yq,{detail:{key:e}}))}function gKe(e,t,n){let[r,i]=(0,F.useState)(()=>{try{return Kq(e,n)??t}catch(e){return console.error(`[LOCALSTORAGE] Error:`,e),t}}),a=(0,F.useCallback)(t=>{i(r=>{try{let i=typeof t==`function`?t(r):t;return i===null?Jq(e):qq(e,i,n),queueMicrotask(()=>hKe(e)),i}catch(e){return console.error(`[LOCALSTORAGE] Error:`,e),r}})},[e,n]),o=(0,F.useRef)(e);return(0,F.useEffect)(()=>{if(o.current!==e){o.current=e;try{let r=Kq(e,n);i(r??t)}catch(e){console.error(`[LOCALSTORAGE] Error:`,e)}}},[e,t,n]),(0,F.useEffect)(()=>{let r=()=>{try{let r=Kq(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(Yq,o),()=>{window.removeEventListener(`storage`,a),window.removeEventListener(Yq,o)}},[e,t,n]),[r,a]}var Xq=`full-access`,Zq=`default`,Qq=`default`,_Ke=/\n*<terminal_context>\n([\s\S]*?)\n<\/terminal_context>\s*$/,vKe=/^\s*<cmmd_context>\n?([\s\S]*?)\n?<\/cmmd_context>\s*/;function $q(e){return e.replace(/\r\n/g,`
|
|
1006
|
+
`).replace(/^\n+|\n+$/g,``)}function eJ(e){return $q(e.text).length>0}function yKe(e){return!eJ(e)}function bKe(e){return e.filter(e=>eJ(e))}function xKe(e){let t=$q(e.text),n=e.terminalId.trim(),r=e.terminalLabel.trim();if(t.length===0||n.length===0||r.length===0)return null;let i=Math.max(1,Math.floor(e.lineStart));return{terminalId:n,terminalLabel:r,lineStart:i,lineEnd:Math.max(i,Math.floor(e.lineEnd)),text:t}}function SKe(e){return e.lineStart===e.lineEnd?`line ${e.lineStart}`:`lines ${e.lineStart}-${e.lineEnd}`}function tJ(e){return`${e.terminalLabel} ${SKe(e)}`}function nJ(e){return`@${e.terminalLabel.trim().toLowerCase().replace(/\s+/g,`-`)}:${e.lineStart===e.lineEnd?`${e.lineStart}`:`${e.lineStart}-${e.lineEnd}`}`}function CKe(e){return $q(e.text).split(`
|
|
1007
|
+
`).map((t,n)=>` ${e.lineStart+n} | ${t}`)}function wKe(e){let t=e.map(e=>xKe(e)).filter(e=>e!==null);if(t.length===0)return``;let n=[];for(let e=0;e<t.length;e+=1){let r=t[e];n.push(`- ${tJ(r)}:`),n.push(...CKe(r)),e<t.length-1&&n.push(``)}return[`<terminal_context>`,...n,`</terminal_context>`].join(`
|
|
1008
|
+
`)}function TKe(e,t){let n=0,r=``;for(let i of e){if(i!==``){r+=i;continue}let e=t[n]??null;n+=1,e&&(r+=nJ(e))}return r}function EKe(e,t){let n=TKe(e,t).trim(),r=wKe(t);return r.length===0?n:n.length>0?`${n}\n\n${r}`:r}function DKe(e){let t=_Ke.exec(e);if(!t)return{promptText:e,contextCount:0,previewTitle:null,contexts:[]};let n=e.slice(0,t.index).replace(/\n+$/,``),r=AKe(t[1]??``);return{promptText:n,contextCount:r.length,previewTitle:r.length>0?r.map(({header:e,body:t})=>t.length>0?`${e}\n${t}`:e).join(`
|
|
1009
1009
|
|
|
1010
|
-
`):null,contexts:r}}function
|
|
1010
|
+
`):null,contexts:r}}function OKe(e){let t=vKe.exec(e);if(!t)return{promptText:e,cmmdContext:null};let n=(t[1]??``).trim();return{promptText:e.slice(t[0].length).replace(/^\n+/,``),cmmdContext:n.length>0?{body:n}:null}}function kKe(e){let t=OKe(e),n=DKe(t.promptText);return{visibleText:n.promptText,copyText:e,contextCount:n.contextCount,previewTitle:n.previewTitle,contexts:n.contexts,cmmdContext:t.cmmdContext}}function AKe(e){let t=[],n=null,r=()=>{n&&=(t.push({header:n.header,body:n.bodyLines.join(`
|
|
1011
1011
|
`).trimEnd()}),null)};for(let t of e.split(`
|
|
1012
|
-
`)){let e=/^- (.+):$/.exec(t);if(e){r(),n={header:e[1],bodyLines:[]};continue}if(n){if(t.startsWith(` `)){n.bodyLines.push(t.slice(2));continue}t.length===0&&n.bodyLines.push(``)}}return r(),t}function rJ(e){let t=0;for(let n of e)n===``&&(t+=1);return t}function iJ(e,t){let n=t-rJ(e);return n<=0?e:`${``.repeat(n)}${e}`}function
|
|
1013
|
-
`||e===` `||e===`\r`}function kKe(e,t){let n=Math.max(0,Math.min(e.length,Math.floor(t))),r=`${OKe(e[n-1])?``:` `} `,i=e[n]===` `?n+1:n;return{prompt:`${e.slice(0,n)}${r}${e.slice(i)}`,cursor:n+r.length,contextIndex:rJ(e.slice(0,n))}}function AKe(e){return e.replaceAll(``,``)}function jKe(e,t){if(t<0)return{prompt:e,cursor:e.length};let n=0;for(let r=0;r<e.length;r+=1)if(e[r]===``){if(n===t)return{prompt:e.slice(0,r)+e.slice(r+1),cursor:r};n+=1}return{prompt:e,cursor:e.length}}function aJ(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var oJ=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return oJ(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return oJ(t)(e)}}}},sJ=(e,t)=>(n,r,i)=>{let a={storage:aJ(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,l=new Set,u=a.storage;if(!u)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let d=()=>{let e=a.partialize({...r()});return u.setItem(a.name,{state:e,version:a.version})},f=i.setState;i.setState=(e,t)=>(f(e,t),d());let p=e((...e)=>(n(...e),d()),r,i);i.getInitialState=()=>p;let m,h=()=>{if(!u)return;let e=++s;o=!1,c.forEach(e=>e(r()??p));let t=a.onRehydrateStorage?.call(a,r()??p)||void 0;return oJ(u.getItem.bind(u))(a.name).then(e=>{if(e)if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state];return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(m=a.merge(o,r()??p),n(m,!0),i)return d()}).then(()=>{e===s&&(t?.(r(),void 0),m=r(),o=!0,l.forEach(e=>e(m)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(u=e.storage)},clearStorage:()=>{++s,u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>h(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(l.add(e),()=>{l.delete(e)})},a.skipHydration||h(),m||p},cJ=e=>Symbol.iterator in e,lJ=e=>`entries`in e,uJ=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},MKe=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function NKe(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:cJ(e)&&cJ(t)?lJ(e)&&lJ(t)?uJ(e,t):MKe(e,t):uJ({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function dJ(e){let t=F.useRef(void 0);return n=>{let r=e(n);return NKe(t.current,r)?t.current:t.current=r}}function fJ(){return{executionCount:0,isPending:!1,lastArgs:void 0,lastExecutionTime:0,nextExecutionTime:0,status:`idle`,maybeExecuteCount:0}}var PKe={enabled:!0,leading:!0,trailing:!0,wait:0},FKe=class{#e;constructor(e,t){this.fn=e,this.store=new Ete(fJ()),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`}}),Cte(`Throttler`,this)},this.#n=()=>!!Kt(this.options.enabled,this),this.#r=()=>Kt(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(fJ())},this.key=t.key,this.options={...PKe,...t},this.#t(this.options.initialState??{}),this.key&&Tte.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};function pJ(){let e=new Map;return{getItem:t=>e.get(t)??null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}function IKe(e){return e!=null&&typeof e.getItem==`function`&&typeof e.setItem==`function`&&typeof e.removeItem==`function`}function mJ(e){return IKe(e)?e:pJ()}var hJ=pJ();function gJ(){return globalThis.localStorage||globalThis.window?.localStorage}var _J={getItem:e=>{try{let t=gJ()?.getItem(e);if(t!==void 0)return t}catch{}return hJ.getItem(e)},setItem:(e,t)=>{try{let n=gJ();if(n){n.setItem(e,t);return}}catch{}hJ.setItem(e,t)},removeItem:e=>{try{let t=gJ();if(t){t.removeItem(e);return}}catch{}hJ.removeItem(e)}};function vJ(e){let t=_J.getItem(e);return typeof t==`string`?t:null}function yJ(e,t){_J.setItem(e,t)}function LKe(e){_J.removeItem(e)}function RKe(e,t=300){let n=mJ(e),r=new qt((e,t)=>{n.setItem(e,t)},{wait:t});return{getItem:e=>n.getItem(e),setItem:(e,t)=>{r.maybeExecute(e,t)},removeItem:e=>{r.cancel(),n.removeItem(e)},flush:()=>{r.flush()}}}function bJ(e){let t=e.auth.status!==`unauthenticated`||e.auth.provenance?.credentialScope===`proxied`;return e.enabled&&e.installed&&e.status===`ready`&&t&&e.models.length>0}var xJ={providers:{codex:!0,claude:!1,cmmd:!0},allowedWallets:[`personal`],updatedAt:`1970-01-01T00:00:00.000Z`};function SJ(e){if(e==null)return xJ;let t=e.providers,n=e.allowedWallets;return{providers:{...xJ.providers,...t},allowedWallets:Array.isArray(n)&&n.length>0?n:xJ.allowedWallets,updatedAt:typeof e.updatedAt==`string`?e.updatedAt:xJ.updatedAt}}function zKe(e){switch(e){case`codex`:return`codex`;case`claudeAgent`:return`claude`;case`cmmd`:case`apex`:return`cmmd`;default:return null}}var BKe=[`codex`,`claudeAgent`,`cmmd`];function VKe(e,t){if(t==null)return null;let n=t.providers;if(typeof n!=`object`||!n)return null;let r=n[e];return typeof r==`boolean`?r:null}function CJ(e,t){let n=zKe(e);if(n===null)return{offered:!1,reason:`unknown-provider`};let r=VKe(n,t);return r===!0?{offered:!0}:r===!1?{offered:!1,reason:`org-disabled`}:SJ(t).providers[n]===!0?{offered:!0}:{offered:!1,reason:`policy-unavailable`}}function wJ(e,t){return CJ(e,t).offered}function HKe(e,t){return TJ(e,t).offered}function TJ(e,t){return t===null?{offered:!0}:CJ(e,t)}function EJ(e,t){return SJ(t).allowedWallets.includes(e)}function DJ(e){return EJ(`personal`,e)}function UKe(e){return e===`claudeAgent`||e===`codex`}function WKe(e,t){return e!==`claudeAgent`||DJ(t)||wJ(`claudeAgent`,t)}function GKe(e){return e.isDebugDisclosureEnabled||UKe(e.provider)&&DJ(e.policy)?!1:!wJ(e.provider===`apex`?`apex`:e.provider,e.policy)}var KKe=new Set([`pending`,`claimed`,`activating`]);function qKe(e){let t=e.current.runtimeId===e.runtimeId?e.current:{runtimeId:e.runtimeId,dataUpdatedAt:0,consecutiveUnavailableResponses:0};return e.dataUpdatedAt===0||e.dataUpdatedAt===t.dataUpdatedAt?t:{runtimeId:e.runtimeId,dataUpdatedAt:e.dataUpdatedAt,consecutiveUnavailableResponses:e.readinessUnavailable?t.consecutiveUnavailableResponses+1:0}}function JKe(e){return!e.claudeOffered||!e.claudeConnected?!1:e.deliveryStatus===null?e.consecutiveUnavailableResponses>0&&e.consecutiveUnavailableResponses<3:KKe.has(e.deliveryStatus)}function OJ(e){return e.credentialMode===`runtime`?e.provider&&bJ(e.provider)?{eligible:!0}:{eligible:!1,reason:`runtime-unavailable`}:e.access.status===`loading`?{eligible:!1,reason:`access-loading`}:e.access.status===`error`?{eligible:!1,reason:`access-error`}:YKe({provider:e.provider,providerKind:e.providerKind,policy:e.access.policy,personalConnections:e.access.personalConnections,personalReconnectRequired:e.access.personalReconnectRequired,claudeRuntimeReadiness:e.access.claudeRuntimeReadiness})}function YKe(e){return!e.provider||!bJ(e.provider)?{eligible:!1,reason:`runtime-unavailable`}:e.policy===null?{eligible:!1,reason:`access-error`}:wJ(e.providerKind,e.policy)?kJ({providerKind:e.providerKind,policy:e.policy,personalConnections:e.personalConnections,personalReconnectRequired:e.personalReconnectRequired,claudeRuntimeReadiness:e.claudeRuntimeReadiness,stage:`live-runtime`}):{eligible:!1,reason:`not-offered`}}function XKe(e){return e.access.status===`loading`?{eligible:!1,reason:`access-loading`}:e.access.status===`error`||e.access.policy===null?{eligible:!1,reason:`access-error`}:wJ(e.providerKind,e.access.policy)?kJ({providerKind:e.providerKind,policy:e.access.policy,personalConnections:e.access.personalConnections,personalReconnectRequired:e.access.personalReconnectRequired,claudeRuntimeReadiness:e.access.claudeRuntimeReadiness,stage:`provisioning`}):{eligible:!1,reason:`not-offered`}}function kJ(e){return e.providerKind===`cmmd`||e.providerKind===`apex`?{eligible:!0}:e.providerKind!==`codex`&&e.providerKind!==`claudeAgent`?{eligible:!1,reason:`not-offered`}:ZKe({providerKind:e.providerKind,personalConnections:e.personalConnections,personalReconnectRequired:e.personalReconnectRequired,claudeRuntimeReadiness:e.claudeRuntimeReadiness,workspaceWalletAllowed:EJ(`workspace`,e.policy),stage:e.stage})}function ZKe(e){return QKe(e.workspaceWalletAllowed)?{eligible:!0}:$Ke(e.providerKind,e.personalReconnectRequired)?{eligible:!1,reason:`personal-credential-reconnect-required`}:eqe(e.providerKind,e.personalConnections)?tqe(e)?{eligible:!0}:{eligible:!1,reason:`native-runtime-not-ready`}:{eligible:!1,reason:`personal-credential-required`}}function QKe(e){return e&&!1}function $Ke(e,t){return e===`codex`&&t?.codex===!0}function eqe(e,t){return t?.[e]===!0}function tqe(e){return e.providerKind!==`claudeAgent`||e.stage===`provisioning`||nqe(e.claudeRuntimeReadiness)}function nqe(e){if(!rqe(e))return!1;let t=e.deliveryReceipt?.identity;return t?.kind===`credential_generation`&&t.provider===`claude`&&t.credentialGenerationId===e.generationId}function rqe(e){return e?.connected===!0&&e.deliveryStatus===`applied`&&e.nativeExecutable===!0&&typeof e.generationId==`string`&&e.generationId.trim().length>0}function AJ(e){return e.providers.filter(t=>OJ({provider:t,providerKind:t.provider,access:e.access,credentialMode:e.credentialMode}).eligible)}function iqe(e){if(e.status!==`ready`)return!1;if(e.policy===null)return!0;let t=e.policy.providers,n=EJ(`workspace`,e.policy);return t.cmmd?!0:EJ(`personal`,e.policy)||n?t.codex&&e.personalConnections?.codex===!0||t.claude&&e.personalConnections?.claudeAgent===!0:!1}var aqe={providers:{codex:!1,claude:!1,cmmd:!1},allowedWallets:[`personal`],updatedAt:`1970-01-01T00:00:00.000Z`},jJ=[`cmmd`,`forge-provider-access`],oqe=2e3,sqe=new Set([`not_connected`,`pending`,`claimed`,`activating`,`applied`,`failed`,`stale`]),cqe=[`generationId`,`nativeVerifiedAt`,`reason`,`lastErrorCode`,`lastErrorMessage`],MJ=class extends Error{constructor(e){super(e===`auth`?`Your CMMD session expired. Sign in again to verify Claude runtime readiness.`:`CMMD denied access to verify Claude runtime readiness. Check your organization permissions.`),this.name=`ForgeProviderAccessAuthorityError`}};function lqe(e,t){return!(t instanceof MJ)&&e<3}function uqe(e,t=null){return[...jJ,e,t]}async function dqe(e){e.queryClient.setQueriesData({queryKey:jJ},t=>fqe(t,e.provider,e.connected)),await e.queryClient.invalidateQueries({queryKey:jJ,refetchType:`all`})}function fqe(e,t,n){return e?.status!==`ready`||e.personalConnections===null?e:{...e,personalConnections:{...e.personalConnections,[t]:n},...t===`codex`?{personalReconnectRequired:{codex:!1}}:{},...t===`claudeAgent`?{claudeRuntimeReadiness:null}:{}}}async function NJ(e,t=null){if(e===`runtime`)return{status:`ready`,policy:null,personalConnections:null,providerAccounts:[],claudeRuntimeReadiness:null};let n=iq(),r=jqe(await n.getOrgProviderPolicy());EJ(`workspace`,r);let[i,a,o,s]=await Promise.all([hqe(()=>n.getProviderAccounts()),FJ({enabled:r.providers.codex,load:()=>n.getUserCodexCredential(),provider:`codex`}),FJ({enabled:r.providers.claude,load:()=>n.getUserClaudeCredential(),provider:`claudeAgent`}),bqe({enabled:r.providers.claude,runtimeId:t,load:e=>n.getClaudeRuntimeReadiness(e)})]),c=i.accounts.filter(e=>e.provider===`codex`?r.providers.codex:r.providers.claude),l=pqe(c),u=l.codex||a.connected,d=l.claudeAgent||o.connected,f=c.some(e=>e.provider===`codex`&&e.needsReconnect)||a.reconnectRequired;return{status:`ready`,policy:r,personalConnections:{codex:u,claudeAgent:d},providerAccounts:c,...f?{personalReconnectRequired:{codex:!0}}:{},claudeRuntimeReadiness:s}}function pqe(e){return{codex:e.some(e=>e.provider===`codex`&&!e.needsReconnect),claudeAgent:e.some(e=>e.provider===`claudeAgent`&&!e.needsReconnect)}}function mqe(e,t){if(e.status!==`ready`)return;let n=e.providerAccounts??[];return(n.find(e=>e.provider===t&&e.isDefault&&!e.needsReconnect)??n.find(e=>e.provider===t&&!e.needsReconnect))?.providerAccountId}async function hqe(e){try{return gqe(await e())}catch{return{accounts:[]}}}function gqe(e){if(!IJ(e)||!Array.isArray(e.accounts))throw Error(`CMMD returned invalid provider accounts.`);return{accounts:e.accounts.filter(_qe)}}function _qe(e){return IJ(e)?vqe(e.provider)&&yqe(e.providerAccountId)&&PJ(e.accountEmail)&&(e.accountDisplayName===void 0||PJ(e.accountDisplayName))&&PJ(e.planType)&&typeof e.isDefault==`boolean`&&typeof e.needsReconnect==`boolean`:!1}function vqe(e){return e===`codex`||e===`claudeAgent`}function yqe(e){return typeof e==`string`&&e.trim().length>0}function PJ(e){return typeof e==`string`||e===null}async function bqe(e){if(!e.enabled||e.runtimeId===null)return null;try{return Cqe(await e.load(e.runtimeId),e.runtimeId)}catch(e){if(e instanceof fr&&(e.kind===`auth`||e.kind===`permission`))throw new MJ(e.kind);return null}}async function FJ(e){if(!e.enabled)return{connected:!1,reconnectRequired:!1};try{return Pqe(await e.load(),e.provider)}catch{return{connected:!1,reconnectRequired:!1}}}function xqe(e){let t=e?.policy?.providers.claude===!0,n=e?.personalConnections?.claudeAgent===!0;return{claudeOffered:t,claudeConnected:n,deliveryStatus:e?.claudeRuntimeReadiness?.deliveryStatus??null,readinessUnavailable:t&&n&&e?.claudeRuntimeReadiness===null}}function Sqe(e){let t=(0,Cl.c)(18),n=e.runtimeId??null,r;t[0]===n?r=t[1]:(r={runtimeId:n,dataUpdatedAt:0,consecutiveUnavailableResponses:0},t[0]=n,t[1]=r);let i=(0,F.useRef)(r),a;t[2]!==e.credentialMode||t[3]!==n?(a=uqe(e.credentialMode,n),t[2]=e.credentialMode,t[3]=n,t[4]=a):a=t[4];let o;t[5]===n?o=t[6]:(o=()=>NJ(`cmmd-cloud`,n),t[5]=n,t[6]=o);let s=e.enabled&&e.credentialMode===`cmmd-cloud`,c;t[7]===n?c=t[8]:(c=e=>{if(e.state.error instanceof MJ)return!1;let t=xqe(e.state.data);return i.current=qKe({current:i.current,runtimeId:n,dataUpdatedAt:e.state.dataUpdatedAt,readinessUnavailable:n!==null&&t.readinessUnavailable}),n!==null&&JKe({claudeOffered:t.claudeOffered,claudeConnected:t.claudeConnected,deliveryStatus:t.deliveryStatus,consecutiveUnavailableResponses:i.current.consecutiveUnavailableResponses})?oqe:!1},t[7]=n,t[8]=c);let l;t[9]!==a||t[10]!==o||t[11]!==s||t[12]!==c?(l={queryKey:a,queryFn:o,enabled:s,retry:lqe,staleTime:3e4,refetchInterval:c},t[9]=a,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13];let u=Di(l);if(!e.enabled){let e;return t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e={status:`loading`},t[14]=e):e=t[14],e}if(e.credentialMode===`runtime`){let e;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e={status:`ready`,policy:null,personalConnections:null,providerAccounts:[],claudeRuntimeReadiness:null},t[15]=e):e=t[15],e}if(u.isPending){let e;return t[16]===Symbol.for(`react.memo_cache_sentinel`)?(e={status:`loading`},t[16]=e):e=t[16],e}if(u.isError||!u.data){let e;return t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e={status:`error`},t[17]=e):e=t[17],e}return u.data}function Cqe(e,t){if(!IJ(e)||!kqe(e)||!wqe(e,t))throw Error(`CMMD returned invalid Claude runtime readiness.`);return e}function wqe(e,t){if(e.deliveryReceipt===null)return e.deliveryStatus!==`applied`||e.nativeExecutable!==!0;if(!IJ(e.deliveryReceipt))return!1;let n=e.deliveryReceipt,r=IJ(n.identity)?n.identity:null;return r!==null&&Tqe(n,t)&&Oqe(r,e.generationId)}function Tqe(e,t){return Eqe(e,t)&&Dqe(e)}function Eqe(e,t){return typeof e.receiptId==`string`&&e.receiptId.trim().length>0&&e.runtimeId===t&&typeof e.machineId==`string`&&e.machineId.trim().length>0&&typeof e.credentialEpoch==`number`&&Number.isSafeInteger(e.credentialEpoch)&&e.credentialEpoch>=0}function Dqe(e){return typeof e.issuedAt==`string`&&Number.isFinite(Date.parse(e.issuedAt))&&e.expiresAt===null}function Oqe(e,t){return e.kind===`credential_generation`&&e.provider===`claude`&&typeof e.credentialGenerationId==`string`&&e.credentialGenerationId===t}function kqe(e){return typeof e.connected==`boolean`&&sqe.has(String(e.deliveryStatus))&&typeof e.nativeExecutable==`boolean`&&cqe.every(t=>Aqe(e[t]))}function Aqe(e){return e===null||typeof e==`string`}function jqe(e){if(!IJ(e)||!IJ(e.providers))throw Error(`CMMD returned an invalid organization provider policy.`);let{providers:t,allowedWallets:n,updatedAt:r}=e,i=Nqe(n,r);if(!Mqe(t)||i===null)throw Error(`CMMD returned an invalid organization provider policy.`);return{providers:{codex:t.codex,claude:t.claude,cmmd:t.cmmd},allowedWallets:[...new Set(i.allowedWallets)],updatedAt:i.updatedAt}}function Mqe(e){return typeof e.codex==`boolean`&&typeof e.claude==`boolean`&&typeof e.cmmd==`boolean`}function Nqe(e,t){return Array.isArray(e)&&e.length>0&&e.every(Fqe)&&typeof t==`string`&&t.trim().length>0?{allowedWallets:e,updatedAt:t}:null}function Pqe(e,t){if(!IJ(e)||typeof e.connected!=`boolean`)throw Error(`CMMD returned an invalid ${t} connection state.`);if(!e.connected)return{connected:!1,reconnectRequired:!1};if(t===`codex`){if(typeof e.needsReconnect!=`boolean`)throw Error(`CMMD returned an invalid Codex connection state.`);return{connected:!e.needsReconnect,reconnectRequired:e.needsReconnect}}if(typeof e.generationId!=`string`||e.generationId.trim().length===0)throw Error(`CMMD returned an invalid Claude connection state.`);return{connected:!0,reconnectRequired:!1}}function Fqe(e){return e===`personal`||e===`workspace`}function IJ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Iqe(e){return e.status===`ready`?e.policy:aqe}var Lqe={reasoningEffortLevels:[],supportsFastMode:!1,supportsThinkingToggle:!1,contextWindowOptions:[],promptInjectedEffortLevels:[]},LJ=[`codex`,`claudeAgent`,`apex`];function RJ(e){for(let t of LJ){let n=e.find(e=>e.provider===t);if(n&&BJ(n))return t}return e.find(BJ)?.provider??null}function zJ(e,t){return e.find(e=>e.provider===t)?.models??[]}function BJ(e){return bJ(e)}function VJ(e,t){let n=t??RJ(e)??`codex`,r=e.find(e=>e.provider===n);if(r&&BJ(r)||n===`codex`)return n;for(let t of LJ){let n=e.find(e=>e.provider===t);if(n&&BJ(n))return t}return`codex`}function HJ(e,t,n,r){let i=AJ({providers:e,access:n,credentialMode:r});return t&&i.some(e=>e.provider===t)?t:RJ(i)}function Rqe(e,t,n,r){return t==null?HJ(e,null,n,r):AJ({providers:e,access:n,credentialMode:r}).some(e=>e.provider===t)?t:null}function UJ(e,t,n){let r=Vq(t,n);return e.find(e=>e.slug===r)?.capabilities??Lqe}function WJ(e,t,n){let r=zJ(e,t).filter(e=>!e.isLegacy);return r.find(e=>e.slug===n)?.slug??r.find(e=>e.isDefault)?.slug??r.find(e=>e.slug===Vn[t])?.slug??r.find(e=>!e.isCustom)?.slug??r[0]?.slug??Vn[t]}function GJ(e){let{provider:t,model:n,models:r,prompt:i,modelOptions:a}=e,o=UJ(r,n,t),s=a?.[t],c=Lq(o,s?`effort`in s?s.effort:`reasoningEffort`in s?s.reasoningEffort:null:null)??null,l=t===`codex`?rKe(o,s):iKe(o,s),u=o.promptInjectedEffortLevels.length>0&&Bq(i);return{provider:t,promptEffort:c,modelOptionsForDispatch:l,...u?{composerFrameClassName:`ultrathink-frame`}:{},...u?{composerSurfaceClassName:`shadow-[0_0_0_1px_rgba(255,255,255,0.04)_inset]`}:{},...u?{modelPickerIconClassName:`ultrathink-chroma`}:{}}}function KJ(e,t,n,r){return zJ(t,n).map(({slug:e,name:t,isCustom:n,isDefault:r,isLegacy:i})=>({slug:e,name:t,isCustom:n,isDefault:r,isLegacy:i}))}function qJ(e,t,n,r,i){let a=Hq(e,r,KJ(t,n,e,r));if(a&&!Uq(a,e))return a;let o=JJ(n,e,i),s=Hq(o,r,KJ(t,n,o,r))??WJ(n,o);return e&&Uq(s,e)?WJ(n,e):s}function JJ(e,t,n){return!t||!wJ(t,n)?VJ(e,`codex`):VJ(e,t)}function zqe(e,t,n,r){return{codex:KJ(e,t,`codex`,n===`codex`?r:void 0),claudeAgent:KJ(e,t,`claudeAgent`,n===`claudeAgent`?r:void 0),ollama:KJ(e,t,`ollama`,n===`ollama`?r:void 0),cmmd:KJ(e,t,`cmmd`,n===`cmmd`?r:void 0),apex:KJ(e,t,`apex`,n===`apex`?r:void 0),cursor:KJ(e,t,`cursor`,n===`cursor`?r:void 0),opencode:KJ(e,t,`opencode`,n===`opencode`?r:void 0)}}function Bqe(e,t,n){let r=e.textGenerationModelSelection??{provider:`codex`,model:yne.codex},i=JJ(t,r.provider,n),a=qJ(i,e,t,i===r.provider?r.model:null,n),{modelOptionsForDispatch:o}=GJ({provider:i,model:a,models:zJ(t,i),prompt:``,modelOptions:{[i]:i===r.provider?r.options:void 0}});return{provider:i,model:a,...o?{options:o}:{}}}function YJ(e){return e?.options?{[e.provider]:e.options}:null}function Vqe(e){if(!e)return null;let t={};for(let[n,r]of Object.entries(e))r?.options&&(t[n]=r.options);return Object.keys(t).length>0?t:null}function Hqe(e){if(e.activeSelection&&`providerAccountId`in e.activeSelection)return e.activeSelection.providerAccountId;for(let t of e.candidates)if(t?.provider===e.selectedProvider&&`providerAccountId`in t)return t.providerAccountId}function Uqe(e){let t=t=>t!==void 0&&Uq(t,e.selectedProvider)?void 0:t,n=t(e.threadModelSelection?.provider===e.selectedProvider?e.threadModelSelection.model:void 0),r=t(e.projectModelSelection?.provider===e.selectedProvider?e.projectModelSelection.model:void 0),i=Vq(n??r,e.selectedProvider)??WJ(e.providers,e.selectedProvider),a=e.draft?.modelSelectionByProvider?.[e.selectedProvider],o=Hqe({activeSelection:a,selectedProvider:e.selectedProvider,candidates:[e.threadModelSelection,e.projectModelSelection]}),s=t(a?.model),c=s?qJ(e.selectedProvider,e.settings,e.providers,s):i,l=Vqe(e.draft?.modelSelectionByProvider)??YJ(e.threadModelSelection)??YJ(e.projectModelSelection)??null;return{selectedModel:c,...o?{selectedProviderAccountId:o}:{},modelOptions:l}}var XJ=`forge:composer-drafts:v1`,ZJ=5,Wqe=kn([`local`,`worktree`]),QJ=Hte(Sn),$J=RKe(typeof localStorage<`u`?localStorage:pJ(),300);typeof window<`u`&&typeof window.addEventListener==`function`&&window.addEventListener(`beforeunload`,()=>{$J.flush()});var eY=zn({id:Un,name:Un,mimeType:Un,sizeBytes:An,dataUrl:Un}),tY=zn({id:Un,threadId:nn,createdAt:Un,terminalId:Un,terminalLabel:Un,lineStart:An,lineEnd:An}),Gqe=zn({prompt:Un,attachments:Bn(eY),terminalContexts:Bn(tY),startedAt:Un}),Kqe=zn({prompt:Un,lastGeneratedPullRequestPrompt:Ln(Un),attachments:Bn(eY),terminalContexts:Ln(Bn(tY)),modelSelectionByProvider:Ln(Mn(Cn,Ln(bn))),activeProvider:Ln(Xn(Cn)),runtimeMode:Ln(Sn),interactionMode:Ln(ln),stagedSubmission:Ln(Gqe)});zn({effort:Ln(kn(jn)),codexFastMode:Ln(Kn),serviceTier:Ln(Un)}),zn({provider:Ln(Cn),model:Ln(Un),modelOptions:Ln(Xn(Jn))}),zn({stickyProvider:Ln(Cn),stickyModel:Ln(Un),stickyModelOptions:Ln(Xn(Jn))});var qqe=zn({threadId:nn,environmentId:Un,projectId:an,logicalProjectKey:Ln(Un),createdAt:Un,runtimeMode:Sn,interactionMode:ln,branch:Xn(Un),worktreePath:Xn(Un),envMode:Wqe,promotedTo:Ln(Xn(zn({environmentId:Un,threadId:Un}))),anchorKind:Ln(Rte),anchorCmmdId:Ln(Xn(Un)),linkedPullRequest:Ln(Xn(kte))}),Jqe=zn({draftsByThreadKey:Mn(Un,Kqe),draftThreadsByThreadKey:Mn(Un,qqe),logicalProjectDraftThreadKeyByLogicalProjectKey:Mn(Un,Un),stickyModelSelectionByProvider:Ln(Mn(Cn,Ln(bn))),stickyActiveProvider:Ln(Xn(Cn))}),Yqe=zn({version:An,state:Jqe}),nY=Object.freeze({draftsByThreadKey:{},draftThreadsByThreadKey:{},logicalProjectDraftThreadKeyByLogicalProjectKey:{},stickyModelSelectionByProvider:{},stickyActiveProvider:null}),rY=[],iY=[],aY=[],Xqe=[];Object.freeze(rY),Object.freeze(iY),Object.freeze(aY);var oY=Object.freeze({}),Zqe=Object.freeze({activeProvider:null,modelSelectionByProvider:oY}),Qqe=Object.freeze({prompt:``,images:rY,nonPersistedImageIds:iY,persistedAttachments:aY,terminalContexts:Xqe,modelSelectionByProvider:oY,activeProvider:null,runtimeMode:null,interactionMode:null,stagedSubmission:null});function sY(){return{prompt:``,images:[],nonPersistedImageIds:[],persistedAttachments:[],terminalContexts:[],modelSelectionByProvider:{},activeProvider:null,runtimeMode:null,interactionMode:null,stagedSubmission:null}}function cY(e){return`${e.mimeType}\u0000${e.sizeBytes}\u0000${e.name}`}function lY(e){return`${e.terminalId}\u0000${e.lineStart}\u0000${e.lineEnd}`}function uY(e,t){let n=t.terminalId.trim(),r=t.terminalLabel.trim();if(n.length===0||r.length===0)return null;let i=Math.max(1,Math.floor(t.lineStart)),a=Math.max(i,Math.floor(t.lineEnd));return{...t,threadId:e,terminalId:n,terminalLabel:r,lineStart:i,lineEnd:a,text:$q(t.text)}}function dY(e,t){let n=new Set,r=new Set,i=[];for(let a of t){let t=uY(e,a);if(!t)continue;let o=lY(t);n.has(t.id)||r.has(o)||(i.push(t),n.add(t.id),r.add(o))}return i}function fY(e){return e.prompt.length===0&&e.lastGeneratedPullRequestPrompt===void 0&&e.images.length===0&&e.persistedAttachments.length===0&&e.terminalContexts.length===0&&Object.keys(e.modelSelectionByProvider).length===0&&e.activeProvider===null&&e.runtimeMode===null&&e.interactionMode===null&&e.stagedSubmission==null}function pY(e){switch(e){case`codex`:case`claudeAgent`:case`ollama`:case`cmmd`:case`apex`:case`cursor`:case`opencode`:return e;default:return null}}function mY(e){return jn.some(t=>t===e)}function $qe(e){return Gte.some(t=>t===e)}function hY(e,t,n){let r=e&&typeof e==`object`?e:null,i=r?.codex&&typeof r.codex==`object`?r.codex:null,a=r?.claudeAgent&&typeof r.claudeAgent==`object`?r.claudeAgent:null,o=mY(i?.reasoningEffort)?i.reasoningEffort:t===`codex`&&mY(n?.effort)?n.effort:void 0,s=i?.fastMode===!0?!0:i?.fastMode===!1?!1:t===`codex`&&n?.codexFastMode===!0||typeof n?.serviceTier==`string`&&n.serviceTier===`fast`||void 0,c=o!==void 0||s!==void 0?{...o===void 0?{}:{reasoningEffort:o},...s===void 0?{}:{fastMode:s}}:void 0,l=a?.thinking===!0||a?.thinking!==!1&&void 0,u=$qe(a?.effort)?a.effort:void 0,d=a?.fastMode===!0||a?.fastMode!==!1&&void 0,f=typeof a?.contextWindow==`string`&&a.contextWindow.length>0?a.contextWindow:void 0,p=l!==void 0||u!==void 0||d!==void 0||f!==void 0?{...l===void 0?{}:{thinking:l},...u===void 0?{}:{effort:u},...d===void 0?{}:{fastMode:d},...f===void 0?{}:{contextWindow:f}}:void 0;return!c&&!p?null:{...c?{codex:c}:{},...p?{claudeAgent:p}:{}}}function gY(e,t){let n=e&&typeof e==`object`?e:null,r=pY(n?.provider??t?.provider);if(r===null)return null;let i=n?.model??t?.model;if(typeof i!=`string`)return null;let a=Vq(i,r);if(!a)return null;let o=hY(n?.options?{[r]:n.options}:t?.modelOptions,r,r===`codex`?t?.legacyCodex:void 0),s=r===`codex`?o?.codex:o?.claudeAgent,c=n?.providerAccountId,l=typeof c==`string`&&c.trim().length>0?c.trim():void 0;return{provider:r,model:a,...l?{providerAccountId:l}:{},...s?{options:s}:{}}}function _Y(e,t){if(e===null)return null;let n=t?.[e.provider];return{provider:e.provider,model:e.model,...`providerAccountId`in e&&e.providerAccountId?{providerAccountId:e.providerAccountId}:{},...n?{options:n}:{}}}function vY(e,t){return e?.options===void 0?hY(t):eJe(hY(t),e.provider,e.options)}function eJe(e,t,n){let{[t]:r,...i}=e??{},a=hY({[t]:n},t);return hY({...i,...a||{}})}function yY(e,t){let n={};if(t)for(let r of[`codex`,`claudeAgent`]){let i=t[r];i&&Object.keys(i).length>0&&(n[r]={provider:r,model:e?.provider===r?e.model:Vn[r],options:i})}return e&&(n[e.provider]=e),n}function bY(e){typeof URL>`u`||e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}function xY(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.id,r=t.name,i=t.mimeType,a=t.sizeBytes,o=t.dataUrl;return typeof n!=`string`||typeof r!=`string`||typeof i!=`string`||typeof a!=`number`||!Number.isFinite(a)||typeof o!=`string`||n.length===0||o.length===0?null:{id:n,name:r,mimeType:i,sizeBytes:a,dataUrl:o}}function SY(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.id,r=t.threadId,i=t.createdAt,a=t.lineStart,o=t.lineEnd;if(typeof n!=`string`||n.length===0||typeof r!=`string`||r.length===0||typeof i!=`string`||i.length===0||typeof a!=`number`||!Number.isFinite(a)||typeof o!=`number`||!Number.isFinite(o))return null;let s=typeof t.terminalId==`string`?t.terminalId.trim():``,c=typeof t.terminalLabel==`string`?t.terminalLabel.trim():``;if(s.length===0||c.length===0)return null;let l=Math.max(1,Math.floor(a));return{id:n,threadId:r,createdAt:i,terminalId:s,terminalLabel:c,lineStart:l,lineEnd:Math.max(l,Math.floor(o))}}function tJe(e,t){return e===`local`||e===`worktree`?e:t?`worktree`:`local`}function CY(e){return Bo(e)}function wY(e){return e.trim()}function TY(e){return typeof e==`string`?e.trim():Vo(e)}function EY(e,t){let n=Wo(e);return n?TY(n):t?.environmentId?TY(Lo(t.environmentId,e)):e}function nJe(e){return Wo(e)}function DY(e,t){if(typeof t==`string`){let e=t.trim();return e.length>0?Ut.make(e):null}return t}function OY(e,t){let n=DY(e,t);if(!n)return null;if(typeof n!=`string`){let t=TY(n);if(e.draftsByThreadKey[t])return t;for(let[t,r]of Object.entries(e.draftThreadsByThreadKey))if(r.environmentId===n.environmentId&&r.threadId===n.threadId)return t;return t}let r=TY(n);return r.length>0?r:null}function kY(e,t){let n=DY(e,t);return n?typeof n==`string`?e.draftThreadsByThreadKey[n]?.threadId??null:n.threadId:null}function AY(e,t){let n=OY(e,t);return n?e.draftsByThreadKey[n]??null:null}function rJe(e,t){return Object.values(e).includes(t)}function jY(e,t){return{draftId:e,...t}}function iJe(e,t,n,r,i){let a=r!==void 0&&(r.environmentId!==e.environmentId||r.projectId!==e.projectId),o=i?.worktreePath===void 0?a?null:r?.worktreePath??null:i.worktreePath??null,s=i?.branch===void 0?a?null:r?.branch??null:i.branch??null,c=i?.anchorKind===void 0?r?.anchorKind:i.anchorKind??void 0;return{threadId:t,environmentId:e.environmentId,projectId:e.projectId,logicalProjectKey:n,createdAt:i?.createdAt??r?.createdAt??new Date().toISOString(),runtimeMode:i?.runtimeMode??r?.runtimeMode??`full-access`,interactionMode:i?.interactionMode??r?.interactionMode??`default`,branch:s,worktreePath:o,envMode:i?.envMode??(o?`worktree`:a?`local`:r?.envMode??`local`),promotedTo:null,cmmdTaskId:i?.cmmdTaskId===void 0?r?.cmmdTaskId??null:i.cmmdTaskId,anchorCmmdId:i?.anchorCmmdId===void 0?r?.anchorCmmdId??null:i.anchorCmmdId,linkedPullRequest:i?.linkedPullRequest===void 0?r?.linkedPullRequest??null:i.linkedPullRequest,...c===void 0?{}:{anchorKind:c}}}function MY(e,t){return!e||!t?e===t:e.environmentId===t.environmentId&&e.threadId===t.threadId}function NY(e){return e?.promotedTo!==null&&e?.promotedTo!==void 0}function aJe(e,t){return!!e&&e.threadId===t.threadId&&e.environmentId===t.environmentId&&e.projectId===t.projectId&&e.logicalProjectKey===t.logicalProjectKey&&e.createdAt===t.createdAt&&e.runtimeMode===t.runtimeMode&&e.interactionMode===t.interactionMode&&e.branch===t.branch&&e.worktreePath===t.worktreePath&&e.envMode===t.envMode&&(e.anchorKind??void 0)===(t.anchorKind??void 0)&&(e.anchorCmmdId??null)===(t.anchorCmmdId??null)&&PY(e.linkedPullRequest,t.linkedPullRequest)&&MY(e.promotedTo,t.promotedTo)}function PY(e,t){return(e?.projectId??null)===(t?.projectId??null)&&(e?.projectRepositoryId??null)===(t?.projectRepositoryId??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.host??null)===(t?.host??null)&&(e?.repository??null)===(t?.repository??null)&&(e?.number??null)===(t?.number??null)&&(e?.url??null)===(t?.url??null)}function FY(e,t){let n=Object.fromEntries(Object.entries(e.logicalProjectDraftThreadKeyByLogicalProjectKey).filter(([,e])=>e!==t)),{[t]:r,...i}=e.draftThreadsByThreadKey,{[t]:a,...o}=e.draftsByThreadKey;return{draftsByThreadKey:o,draftThreadsByThreadKey:i,logicalProjectDraftThreadKeyByLogicalProjectKey:n}}function IY(e,t){let n={},r=new Map;if(t&&typeof t==`object`)for(let[e,n]of Object.entries(t)){if(typeof n!=`string`||n.length===0)continue;let t=Uo(e);if(!t)continue;let i=Wo(n);if(i){r.set(i.threadId,i.environmentId);continue}r.set(n,t.environmentId)}if(e&&typeof e==`object`)for(let[t,i]of Object.entries(e)){if(typeof t!=`string`||t.length===0||!i||typeof i!=`object`)continue;let e=i,a=Wo(t),o=EY(t),s=a?.threadId??(typeof e.threadId==`string`&&e.threadId.length>0?e.threadId:t),c=a?.environmentId??(typeof e.environmentId==`string`&&e.environmentId.length>0?e.environmentId:r.get(t)),l=e.projectId,u=e.createdAt,d=e.branch,f=e.worktreePath,p=typeof f==`string`?f:null,m=e.promotedTo,h=m&&typeof m==`object`?m:null,g=h&&typeof h.environmentId==`string`&&h.environmentId.length>0&&typeof h.threadId==`string`&&h.threadId.length>0?Lo(h.environmentId,h.threadId):null;if(typeof l!=`string`||l.length===0||c===void 0)continue;let _=c;n[o]={threadId:s,environmentId:_,projectId:l,logicalProjectKey:typeof e.logicalProjectKey==`string`&&e.logicalProjectKey.length>0?e.logicalProjectKey:a?CY(Io(_,l)):t,createdAt:typeof u==`string`&&u.length>0?u:new Date().toISOString(),runtimeMode:QJ(e.runtimeMode)?e.runtimeMode:Xq,interactionMode:e.interactionMode===`plan`||e.interactionMode==="default"?e.interactionMode:Zq,branch:typeof d==`string`?d:null,worktreePath:p,envMode:tJe(e.envMode,p),promotedTo:g}}let i={};if(t&&typeof t==`object`)for(let[e,a]of Object.entries(t)){if(typeof a!=`string`||a.length===0)continue;let t=Uo(e),o=Wo(a),s=EY(a);if(i[e]=s,o&&r.set(o.threadId,o.environmentId),!t){let t=n[s];t&&!t.logicalProjectKey&&(n[s]={...t,logicalProjectKey:e});continue}n[s]?(n[s]?.projectId!==t.projectId||n[s]?.environmentId!==t.environmentId)&&(n[s]={...n[s],threadId:n[s].threadId,environmentId:t.environmentId,projectId:t.projectId,logicalProjectKey:e}):n[s]={threadId:o?.threadId??s,environmentId:t.environmentId,projectId:t.projectId,logicalProjectKey:e,createdAt:new Date().toISOString(),runtimeMode:Xq,interactionMode:Zq,branch:null,worktreePath:null,envMode:`local`,promotedTo:null}}return{draftThreadsByThreadKey:n,logicalProjectDraftThreadKeyByLogicalProjectKey:i}}function LY(e,t){if(!e||typeof e!=`object`)return{};let n=new Map;for(let[e,r]of Object.entries(t)){let t=nJe(e);t&&n.set(t.threadId,r.environmentId)}let r={};for(let[i,a]of Object.entries(e)){if(typeof i!=`string`||i.length===0||!a||typeof a!=`object`)continue;let e=a,o=typeof e.prompt==`string`?e.prompt:``,s=typeof e.lastGeneratedPullRequestPrompt==`string`?e.lastGeneratedPullRequestPrompt:void 0,c=Array.isArray(e.attachments)?e.attachments.flatMap(e=>{let t=xY(e);return t?[t]:[]}):[],l=Array.isArray(e.terminalContexts)?e.terminalContexts.flatMap(e=>{let t=SY(e);return t?[t]:[]}):[],u=QJ(e.runtimeMode)?e.runtimeMode:null,d=e.interactionMode===`plan`||e.interactionMode==="default"?e.interactionMode:null,f=oJe(e.stagedSubmission),p=iJ(o,l.length),m=a,h={},g=null;if(e.modelSelectionByProvider&&typeof e.modelSelectionByProvider==`object`)h=e.modelSelectionByProvider,g=pY(e.activeProvider);else{let e=hY(m.modelOptions,void 0,m)??null,t=gY(m.modelSelection,{provider:m.provider,model:m.model,modelOptions:e??m.modelOptions,legacyCodex:m}),n=vY(t,e),r=_Y(t,n);h=yY(r,n),g=r?.provider??null}let _=Object.keys(h).length>0||g!==null;if(o.length===0&&c.length===0&&l.length===0&&!_&&!u&&!d&&!f)continue;let v=Wo(i)===null?t[i]===void 0?(()=>{let e=n.get(i);return e?EY(i,{environmentId:e}):i})():i:EY(i);r[v]={prompt:p,...s===void 0?{}:{lastGeneratedPullRequestPrompt:s},attachments:c,...l.length>0?{terminalContexts:l}:{},..._?{modelSelectionByProvider:h,activeProvider:g}:{},...u?{runtimeMode:u}:{},...d?{interactionMode:d}:{},...f?{stagedSubmission:f}:{}}}return r}function oJe(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.prompt!=`string`||typeof t.startedAt!=`string`)return null;let n=Array.isArray(t.attachments)?t.attachments.flatMap(e=>{let t=xY(e);return t?[t]:[]}):[],r=Array.isArray(t.terminalContexts)?t.terminalContexts.flatMap(e=>{let t=SY(e);return t?[t]:[]}):[];return{prompt:t.prompt,attachments:n,terminalContexts:r,startedAt:t.startedAt}}function sJe(e){if(!e||typeof e!=`object`)return nY;let t=e,n=t.draftsByThreadKey??t.draftsByThreadId,r=t.draftThreadsByThreadKey??t.draftThreadsByThreadId,i=t.logicalProjectDraftThreadKeyByLogicalProjectKey??t.projectDraftThreadKeyByProjectKey??t.projectDraftThreadIdByProjectKey??t.projectDraftThreadIdByProjectId,a=hY(t.stickyModelOptions)??{},o=gY(t.stickyModelSelection,{provider:t.stickyProvider??`codex`,model:t.stickyModel,modelOptions:a}),s=vY(o,a),c=yY(_Y(o,s),s),l=pY(t.stickyProvider)??null,{draftThreadsByThreadKey:u,logicalProjectDraftThreadKeyByLogicalProjectKey:d}=IY(r,i);return{draftsByThreadKey:LY(n,u),draftThreadsByThreadKey:u,logicalProjectDraftThreadKeyByLogicalProjectKey:d,stickyModelSelectionByProvider:c,stickyActiveProvider:l}}function cJe(e){let t={};for(let[n,r]of Object.entries(e.draftsByThreadKey)){if(typeof n!=`string`||n.length===0)continue;let e=Object.keys(r.modelSelectionByProvider).length>0||r.activeProvider!==null;r.prompt.length===0&&r.lastGeneratedPullRequestPrompt===void 0&&r.persistedAttachments.length===0&&r.terminalContexts.length===0&&!e&&r.runtimeMode===null&&r.interactionMode===null&&r.stagedSubmission==null||(t[n]={prompt:r.prompt,...r.lastGeneratedPullRequestPrompt===void 0?{}:{lastGeneratedPullRequestPrompt:r.lastGeneratedPullRequestPrompt},attachments:r.persistedAttachments,...r.terminalContexts.length>0?{terminalContexts:r.terminalContexts.map(e=>({id:e.id,threadId:e.threadId,createdAt:e.createdAt,terminalId:e.terminalId,terminalLabel:e.terminalLabel,lineStart:e.lineStart,lineEnd:e.lineEnd}))}:{},...e?{modelSelectionByProvider:r.modelSelectionByProvider,activeProvider:r.activeProvider}:{},...r.runtimeMode?{runtimeMode:r.runtimeMode}:{},...r.interactionMode?{interactionMode:r.interactionMode}:{},...r.stagedSubmission?{stagedSubmission:{prompt:r.stagedSubmission.prompt,attachments:[...r.stagedSubmission.attachments],terminalContexts:r.stagedSubmission.terminalContexts.map(e=>({id:e.id,threadId:e.threadId,createdAt:e.createdAt,terminalId:e.terminalId,terminalLabel:e.terminalLabel,lineStart:e.lineStart,lineEnd:e.lineEnd})),startedAt:r.stagedSubmission.startedAt}}:{}})}return{draftsByThreadKey:t,draftThreadsByThreadKey:e.draftThreadsByThreadKey,logicalProjectDraftThreadKeyByLogicalProjectKey:e.logicalProjectDraftThreadKeyByLogicalProjectKey,stickyModelSelectionByProvider:e.stickyModelSelectionByProvider,stickyActiveProvider:e.stickyActiveProvider}}function lJe(e){if(!e||typeof e!=`object`)return nY;let t=e,{draftThreadsByThreadKey:n,logicalProjectDraftThreadKeyByLogicalProjectKey:r}=IY(t.draftThreadsByThreadKey??t.draftThreadsByThreadId,t.logicalProjectDraftThreadKeyByLogicalProjectKey??t.projectDraftThreadKeyByProjectKey??t.projectDraftThreadIdByProjectKey??t.projectDraftThreadIdByProjectId),i={},a=null;if(t.stickyModelSelectionByProvider&&typeof t.stickyModelSelectionByProvider==`object`)i=t.stickyModelSelectionByProvider,a=pY(t.stickyActiveProvider);else{let e=hY(t.stickyModelOptions)??{},n=gY(t.stickyModelSelection,{provider:t.stickyProvider,model:t.stickyModel,modelOptions:e}),r=vY(n,e);i=yY(_Y(n,r),r),a=pY(t.stickyProvider)}return{draftsByThreadKey:LY(t.draftsByThreadKey??t.draftsByThreadId,n),draftThreadsByThreadKey:n,logicalProjectDraftThreadKeyByLogicalProjectKey:r,stickyModelSelectionByProvider:i,stickyActiveProvider:a}}function uJe(e){if(e.length===0)return[];try{let t=Kq(XJ,Yqe);return!t||t.version!==ZJ?[]:(t.state.draftsByThreadKey[e]?.attachments??[]).map(e=>e.id)}catch{return[]}}function dJe(e,t,n){let r=new Set;try{$J.flush(),r=new Set(uJe(e))}catch{r=new Set}n(n=>{let i=n.draftsByThreadKey[e];if(!i)return n;let a=new Set(i.images.map(e=>e.id)),o=t.filter(e=>a.has(e.id)&&r.has(e.id)),s=i.images.map(e=>e.id).filter(e=>!r.has(e)),c={...i,persistedAttachments:o,nonPersistedImageIds:s},l={...n.draftsByThreadKey};return fY(c)?delete l[e]:l[e]=c,{draftsByThreadKey:l}})}function fJe(e){let t=e.dataUrl.indexOf(`,`),n=t===-1?e.dataUrl:e.dataUrl.slice(0,t),r=t===-1?``:e.dataUrl.slice(t+1);if(r.length===0)return null;try{if(!n.includes(`;base64`)){let t=decodeURIComponent(r),i=n.startsWith(`data:`)&&n.includes(`;`)?n.slice(5,n.indexOf(`;`)):e.mimeType;return new File([t],e.name,{type:i||e.mimeType})}let t=atob(r),i=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)i[e]=t.charCodeAt(e);return new File([i],e.name,{type:e.mimeType})}catch{return null}}function pJe(e){return e.flatMap(e=>{let t=fJe(e);return t?[{type:`image`,id:e.id,name:e.name,mimeType:e.mimeType,sizeBytes:e.sizeBytes,previewUrl:e.dataUrl,file:t}]:[]})}function mJe(e,t){return e.length>0?e:t?.prompt??``}function hJe(e,t){return e.length>0?e:t?.attachments??[]}function gJe(e,t){return e&&e.length>0?e:t?.terminalContexts??[]}function _Je(e){let t=e.stagedSubmission;return{prompt:mJe(e.prompt,t),attachments:hJe(e.attachments,t),terminalContexts:gJe(e.terminalContexts,t)}}function vJe(e){let t=e.modelSelectionByProvider??{},n=pY(e.activeProvider)??null,r=_Je(e);return{prompt:r.prompt,...e.lastGeneratedPullRequestPrompt===void 0?{}:{lastGeneratedPullRequestPrompt:e.lastGeneratedPullRequestPrompt},images:pJe(r.attachments),nonPersistedImageIds:[],persistedAttachments:[...r.attachments],terminalContexts:r.terminalContexts.map(e=>({id:e.id,threadId:e.threadId,createdAt:e.createdAt,terminalId:e.terminalId,terminalLabel:e.terminalLabel,lineStart:e.lineStart,lineEnd:e.lineEnd,text:``})),modelSelectionByProvider:t,activeProvider:n,runtimeMode:e.runtimeMode??null,interactionMode:e.interactionMode??null,stagedSubmission:null}}function yJe(e){return{threadId:e.threadId,environmentId:e.environmentId,projectId:e.projectId,logicalProjectKey:e.logicalProjectKey??CY(Io(e.environmentId,e.projectId)),createdAt:e.createdAt,runtimeMode:e.runtimeMode,interactionMode:e.interactionMode,branch:e.branch,worktreePath:e.worktreePath,envMode:e.envMode,promotedTo:e.promotedTo?Lo(e.promotedTo.environmentId,e.promotedTo.threadId):null,linkedPullRequest:e.linkedPullRequest??null}}var RY=Wt()(sJ((e,t)=>{let n=e;return{draftsByThreadKey:{},draftThreadsByThreadKey:{},logicalProjectDraftThreadKeyByLogicalProjectKey:{},stickyModelSelectionByProvider:{},stickyActiveProvider:null,getComposerDraft:e=>AY(t(),e),getDraftThreadByLogicalProjectKey:e=>t().getDraftSessionByLogicalProjectKey(e),getDraftSessionByLogicalProjectKey:e=>{let n=wY(e);if(n.length===0)return null;let r=t().logicalProjectDraftThreadKeyByLogicalProjectKey[n];if(!r)return null;let i=t().draftThreadsByThreadKey[r];return!i||NY(i)?null:jY(Ut.make(r),i)},getDraftThreadByProjectRef:e=>t().getDraftSessionByProjectRef(e),getDraftSessionByProjectRef:e=>{for(let[n,r]of Object.entries(t().draftThreadsByThreadKey))if(!NY(r)&&r.projectId===e.projectId&&r.environmentId===e.environmentId)return jY(Ut.make(n),r);return null},getDraftSession:e=>t().draftThreadsByThreadKey[e]??null,getDraftSessionByRef:e=>{for(let n of Object.values(t().draftThreadsByThreadKey))if(n.environmentId===e.environmentId&&n.threadId===e.threadId)return n;return null},getDraftThread:e=>typeof e==`string`?t().getDraftSession(Ut.make(e)):t().getDraftSessionByRef(e),getDraftThreadByRef:e=>t().getDraftSessionByRef(e),listDraftThreadKeys:()=>Object.values(t().draftThreadsByThreadKey).map(e=>Vo(Lo(e.environmentId,e.threadId))),hasDraftThreadsInEnvironment:e=>Object.values(t().draftThreadsByThreadKey).some(t=>t.environmentId===e),setLogicalProjectDraftThreadId:(e,t,r,i)=>{let a=wY(e);a.length!==0&&r.length!==0&&n(e=>{let n=e.draftThreadsByThreadKey[r],o=e.logicalProjectDraftThreadKeyByLogicalProjectKey[a],s=iJe(t,i?.threadId??n?.threadId??nn.make(r),a,n,i);if(o===r&&aJe(n,s))return e;let c={...e.logicalProjectDraftThreadKeyByLogicalProjectKey,[a]:r},l={...e.draftThreadsByThreadKey,[r]:s},u=e.draftsByThreadKey,d=o===void 0?void 0:l[o];return o&&o!==r&&!rJe(c,o)&&!NY(d)&&(delete l[o],e.draftsByThreadKey[o]!==void 0&&(u={...e.draftsByThreadKey},delete u[o])),{draftsByThreadKey:u,draftThreadsByThreadKey:l,logicalProjectDraftThreadKeyByLogicalProjectKey:c}})},setProjectDraftThreadId:(e,n,r)=>{t().setLogicalProjectDraftThreadId(CY(e),e,n,r)},setDraftThreadContext:(e,r)=>{let i=OY(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftThreadsByThreadKey[i];if(!t)return e;let n=r.projectRef??{environmentId:t.environmentId,projectId:t.projectId};if(n.projectId.length===0||n.environmentId.length===0)return e;let a=n.environmentId!==t.environmentId||n.projectId!==t.projectId,o=r.worktreePath===void 0?a?null:t.worktreePath:r.worktreePath??null,s=r.branch===void 0?a?null:t.branch:r.branch??null,c=r.anchorKind===void 0?t.anchorKind:r.anchorKind??void 0,l={threadId:t.threadId,environmentId:n.environmentId,projectId:n.projectId,logicalProjectKey:t.logicalProjectKey,createdAt:r.createdAt===void 0?t.createdAt:r.createdAt||t.createdAt,runtimeMode:r.runtimeMode??t.runtimeMode,interactionMode:r.interactionMode??t.interactionMode,branch:s,worktreePath:o,envMode:r.envMode??(o?`worktree`:a?`local`:t.envMode??`local`),promotedTo:t.promotedTo??null,cmmdTaskId:r.cmmdTaskId===void 0?t.cmmdTaskId??null:r.cmmdTaskId,anchorCmmdId:r.anchorCmmdId===void 0?t.anchorCmmdId??null:r.anchorCmmdId,linkedPullRequest:r.linkedPullRequest===void 0?t.linkedPullRequest??null:r.linkedPullRequest,...c===void 0?{}:{anchorKind:c}};return l.environmentId===t.environmentId&&l.projectId===t.projectId&&l.logicalProjectKey===t.logicalProjectKey&&l.createdAt===t.createdAt&&l.runtimeMode===t.runtimeMode&&l.interactionMode===t.interactionMode&&l.branch===t.branch&&l.worktreePath===t.worktreePath&&l.envMode===t.envMode&&(l.anchorKind??void 0)===(t.anchorKind??void 0)&&(l.anchorCmmdId??null)===(t.anchorCmmdId??null)&&PY(l.linkedPullRequest,t.linkedPullRequest)&&MY(l.promotedTo,t.promotedTo)?e:{draftThreadsByThreadKey:{...e.draftThreadsByThreadKey,[i]:l}}})},clearProjectDraftThreadId:e=>{n(t=>{let n=Object.entries(t.draftThreadsByThreadKey).find(([,t])=>t.projectId===e.projectId&&t.environmentId===e.environmentId);return n?FY(t,n[0]):t})},clearProjectDraftThreadById:(e,r)=>{let i=OY(t(),r)??``;i.length!==0&&n(t=>{let n=t.draftThreadsByThreadKey[i];return!n||n.projectId!==e.projectId||n.environmentId!==e.environmentId?t:FY(t,i)})},markDraftThreadPromoting:(e,r)=>{let i=OY(t(),e);i&&n(e=>{let t=e.draftThreadsByThreadKey[i];if(!t)return e;let n=r??Lo(t.environmentId,t.threadId);return MY(t.promotedTo,n)?e:{draftThreadsByThreadKey:{...e.draftThreadsByThreadKey,[i]:{...t,promotedTo:n}}}})},finalizePromotedDraftThread:e=>{let r=OY(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftThreadsByThreadKey[r];if(!NY(t))return e;let n=TY(t.promotedTo),i=e.draftsByThreadKey[n],a=e.draftsByThreadKey[r];return FY(a?{...e,draftsByThreadKey:{...e.draftsByThreadKey,[n]:i?{...i,modelSelectionByProvider:{...i.modelSelectionByProvider,...a.modelSelectionByProvider},activeProvider:a.activeProvider,runtimeMode:a.runtimeMode,interactionMode:a.interactionMode}:a}}:e,r)})},clearDraftThread:e=>{let r=OY(t(),e)??``;if(r.length===0)return;let i=t().draftsByThreadKey[r];if(i)for(let e of i.images)bY(e.previewUrl);n(e=>{let t=e.draftThreadsByThreadKey[r]!==void 0,n=Object.values(e.logicalProjectDraftThreadKeyByLogicalProjectKey).includes(r),i=e.draftsByThreadKey[r]!==void 0;return!t&&!n&&!i?e:FY(e,r)})},setStickyModelSelection:e=>{let t=gY(e);n(e=>{if(!t)return e;let n={...e.stickyModelSelectionByProvider,[t.provider]:t};return qe(e.stickyModelSelectionByProvider,n)?e.stickyActiveProvider===t.provider?e:{stickyActiveProvider:t.provider}:{stickyModelSelectionByProvider:n,stickyActiveProvider:t.provider}})},applyStickyState:e=>{let r=OY(t(),e)??``;r.length!==0&&n(e=>{let t=e.stickyModelSelectionByProvider,n=e.stickyActiveProvider;if(Object.keys(t).length===0&&n===null)return e;let i=e.draftsByThreadKey[r]??sY(),a={...i.modelSelectionByProvider};for(let[e,n]of Object.entries(t))if(n){let t=a[e];a[e]={...n,model:t?.model??n.model}}if(qe(i.modelSelectionByProvider,a)&&i.activeProvider===n)return e;let o={...i,modelSelectionByProvider:a,activeProvider:n},s={...e.draftsByThreadKey};return fY(o)?delete s[r]:s[r]=o,{draftsByThreadKey:s}})},setPrompt:(e,r)=>{let i=OY(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??sY();if(t.prompt===r)return e;let n={...t,prompt:r},a={...e.draftsByThreadKey};return fY(n)?delete a[i]:a[i]=n,{draftsByThreadKey:a}})},setGeneratedPullRequestPrompt:(e,r)=>{let i=OY(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??sY();return{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,lastGeneratedPullRequestPrompt:r}}}})},setPendingAutoSubmit:(e,r)=>{let i=OY(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??sY();if((t.pendingAutoSubmit??!1)===r)return e;let n=r?{...t,pendingAutoSubmit:!0}:(()=>{let{pendingAutoSubmit:e,...n}=t;return n})(),a={...e.draftsByThreadKey};return fY(n)?delete a[i]:a[i]=n,{draftsByThreadKey:a}})},stageComposerSubmission:(e,r)=>{let i=OY(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftsByThreadKey[i];if(!t)return e;let n={prompt:t.prompt,attachments:[...t.persistedAttachments],terminalContexts:[...t.terminalContexts],startedAt:r},a={...e.draftsByThreadKey};return a[i]={...t,stagedSubmission:n},{draftsByThreadKey:a}})},clearStagedComposerSubmission:e=>{let r=OY(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftsByThreadKey[r];if(!t?.stagedSubmission)return e;let n={...t,stagedSubmission:null},i={...e.draftsByThreadKey};return fY(n)?delete i[r]:i[r]=n,{draftsByThreadKey:i}})},setTerminalContexts:(e,r)=>{let i=OY(t(),e),a=kY(t(),e);if(!i||!a)return;let o=dY(a,r);n(e=>{let t=e.draftsByThreadKey[i]??sY(),n={...t,prompt:iJ(t.prompt,o.length),terminalContexts:o},r={...e.draftsByThreadKey};return fY(n)?delete r[i]:r[i]=n,{draftsByThreadKey:r}})},setModelSelection:(e,r)=>{let i=OY(t(),e)??``;if(i.length===0)return;let a=gY(r);n(e=>{let t=e.draftsByThreadKey[i];if(!t&&a===null)return e;let n=t??sY(),r={...n.modelSelectionByProvider};if(a){let e=r[a.provider];a.options===void 0?r[a.provider]={provider:a.provider,model:a.model,...`providerAccountId`in a&&a.providerAccountId?{providerAccountId:a.providerAccountId}:e&&`providerAccountId`in e&&e.providerAccountId?{providerAccountId:e.providerAccountId}:{},...e?.options?{options:e.options}:{}}:r[a.provider]=a}let o=a?.provider??n.activeProvider;if(qe(n.modelSelectionByProvider,r)&&n.activeProvider===o)return e;let s={...n,modelSelectionByProvider:r,activeProvider:o},c={...e.draftsByThreadKey};return fY(s)?delete c[i]:c[i]=s,{draftsByThreadKey:c}})},setModelOptions:(e,r)=>{let i=OY(t(),e)??``;if(i.length===0)return;let a=hY(r);n(e=>{let t=e.draftsByThreadKey[i];if(!t&&a===null)return e;let n=t??sY(),r={...n.modelSelectionByProvider};for(let e of[`codex`,`claudeAgent`]){if(!a||!(e in a))continue;let t=a[e],n=r[e];if(t)r[e]={provider:e,model:n?.model??Vn[e],...n&&`providerAccountId`in n&&n.providerAccountId?{providerAccountId:n.providerAccountId}:{},options:t};else if(n?.options){let{options:t,...i}=n;r[e]=i}}if(qe(n.modelSelectionByProvider,r))return e;let o={...n,modelSelectionByProvider:r},s={...e.draftsByThreadKey};return fY(o)?delete s[i]:s[i]=o,{draftsByThreadKey:s}})},setProviderModelOptions:(e,r,i,a)=>{let o=OY(t(),e)??``;if(o.length===0)return;let s=pY(r);if(s===null)return;let c=hY({[s]:i},s)?.[s];n(e=>{let t=e.draftsByThreadKey[o]??sY(),n={...t.modelSelectionByProvider},r=n[s];if(c)n[s]={provider:s,model:r?.model??Vn[s],...r&&`providerAccountId`in r&&r.providerAccountId?{providerAccountId:r.providerAccountId}:{},options:c};else if(r?.options){let{options:e,...t}=r;n[s]=t}let i=e.stickyModelSelectionByProvider,l=e.stickyActiveProvider;if(a?.persistSticky===!0){i={...e.stickyModelSelectionByProvider};let n=i[s]??t.modelSelectionByProvider[s]??{provider:s,model:Vn[s]};if(c)i[s]={...n,provider:s,options:c};else if(n.options){let{options:e,...t}=n;i[s]=t}l=t.activeProvider??s}if(qe(t.modelSelectionByProvider,n)&&qe(e.stickyModelSelectionByProvider,i)&&e.stickyActiveProvider===l)return e;let u={...t,modelSelectionByProvider:n},d={...e.draftsByThreadKey};return fY(u)?delete d[o]:d[o]=u,{draftsByThreadKey:d,...a?.persistSticky===!0?{stickyModelSelectionByProvider:i,stickyActiveProvider:l}:{}}})},setRuntimeMode:(e,r)=>{let i=OY(t(),e)??``;if(i.length===0)return;let a=QJ(r)?r:null;n(e=>{let t=e.draftsByThreadKey[i];if(!t&&a===null)return e;let n=t??sY();if(n.runtimeMode===a)return e;let r={...n,runtimeMode:a},o={...e.draftsByThreadKey};return fY(r)?delete o[i]:o[i]=r,{draftsByThreadKey:o}})},setInteractionMode:(e,r)=>{let i=OY(t(),e)??``;if(i.length===0)return;let a=r===`plan`||r==="default"?r:null;n(e=>{let t=e.draftsByThreadKey[i];if(!t&&a===null)return e;let n=t??sY();if(n.interactionMode===a)return e;let r={...n,interactionMode:a},o={...e.draftsByThreadKey};return fY(r)?delete o[i]:o[i]=r,{draftsByThreadKey:o}})},addImage:(e,n)=>{let r=OY(t(),e),i=kY(t(),e);!r||!i||t().addImages(typeof e==`string`?Ut.make(r):e,[n])},addImages:(e,r)=>{let i=OY(t(),e)??``;i.length!==0&&r.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??sY(),n=new Set(t.images.map(e=>e.id)),a=new Set(t.images.map(e=>cY(e))),o=new Set(t.images.map(e=>e.previewUrl)),s=[];for(let e of r){let t=cY(e);if(n.has(e.id)||a.has(t)){o.has(e.previewUrl)||bY(e.previewUrl);continue}s.push(e),n.add(e.id),a.add(t),o.add(e.previewUrl)}return s.length===0?e:{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,images:[...t.images,...s]}}}})},removeImage:(e,r)=>{let i=OY(t(),e)??``;if(i.length===0)return;let a=t().draftsByThreadKey[i];if(!a)return;let o=a.images.find(e=>e.id===r);o&&bY(o.previewUrl),n(e=>{let t=e.draftsByThreadKey[i];if(!t)return e;let n={...t,images:t.images.filter(e=>e.id!==r),nonPersistedImageIds:t.nonPersistedImageIds.filter(e=>e!==r),persistedAttachments:t.persistedAttachments.filter(e=>e.id!==r)},a={...e.draftsByThreadKey};return fY(n)?delete a[i]:a[i]=n,{draftsByThreadKey:a}})},insertTerminalContext:(e,r,i,a)=>{let o=OY(t(),e),s=kY(t(),e);if(!o||!s)return!1;let c=!1;return n(e=>{let t=e.draftsByThreadKey[o]??sY(),n=uY(s,i);if(!n)return e;let l=lY(n);if(t.terminalContexts.some(e=>e.id===n.id)||t.terminalContexts.some(e=>lY(e)===l))return e;c=!0;let u=Math.max(0,Math.min(t.terminalContexts.length,a)),d={...t,prompt:r,terminalContexts:[...t.terminalContexts.slice(0,u),n,...t.terminalContexts.slice(u)]};return{draftsByThreadKey:{...e.draftsByThreadKey,[o]:d}}}),c},addTerminalContext:(e,n)=>{let r=OY(t(),e),i=kY(t(),e);!r||!i||t().addTerminalContexts(typeof e==`string`?Ut.make(r):e,[n])},addTerminalContexts:(e,r)=>{let i=OY(t(),e),a=kY(t(),e);!i||!a||r.length===0||n(e=>{let t=e.draftsByThreadKey[i]??sY(),n=dY(a,[...t.terminalContexts,...r]).slice(t.terminalContexts.length);return n.length===0?e:{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,prompt:iJ(t.prompt,t.terminalContexts.length+n.length),terminalContexts:[...t.terminalContexts,...n]}}}})},removeTerminalContext:(e,r)=>{let i=OY(t(),e)??``;i.length!==0&&r.length!==0&&n(e=>{let t=e.draftsByThreadKey[i];if(!t)return e;let n={...t,terminalContexts:t.terminalContexts.filter(e=>e.id!==r)},a={...e.draftsByThreadKey};return fY(n)?delete a[i]:a[i]=n,{draftsByThreadKey:a}})},clearTerminalContexts:e=>{let r=OY(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftsByThreadKey[r];if(!t||t.terminalContexts.length===0)return e;let n={...t,terminalContexts:[]},i={...e.draftsByThreadKey};return fY(n)?delete i[r]:i[r]=n,{draftsByThreadKey:i}})},clearPersistedAttachments:e=>{let r=OY(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftsByThreadKey[r];if(!t)return e;let n={...t,persistedAttachments:[],nonPersistedImageIds:[]},i={...e.draftsByThreadKey};return fY(n)?delete i[r]:i[r]=n,{draftsByThreadKey:i}})},syncPersistedAttachments:(e,r)=>{let i=OY(t(),e);if(!i)return;let a=new Set(r.map(e=>e.id));n(e=>{let t=e.draftsByThreadKey[i];if(!t)return e;let n={...t,persistedAttachments:r,nonPersistedImageIds:t.nonPersistedImageIds.filter(e=>!a.has(e))},o={...e.draftsByThreadKey};return fY(n)?delete o[i]:o[i]=n,{draftsByThreadKey:o}}),Promise.resolve().then(()=>{dJe(i,r,n)})},clearComposerContent:e=>{let r=OY(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftsByThreadKey[r];if(!t)return e;let{lastGeneratedPullRequestPrompt:n,...i}=t,a={...i,prompt:``,images:[],nonPersistedImageIds:[],persistedAttachments:[],terminalContexts:[]},o={...e.draftsByThreadKey};return fY(a)?delete o[r]:o[r]=a,{draftsByThreadKey:o}})}}},{name:XJ,version:ZJ,storage:aJ(()=>$J),migrate:sJe,partialize:cJe,merge:(e,t)=>{let n=lJe(e),r=Object.fromEntries(Object.entries(n.draftsByThreadKey).map(([e,t])=>[e,vJe(t)])),i=Object.fromEntries(Object.entries(n.draftThreadsByThreadKey).map(([e,t])=>[e,yJe(t)]));return{...t,draftsByThreadKey:r,draftThreadsByThreadKey:i,logicalProjectDraftThreadKeyByLogicalProjectKey:n.logicalProjectDraftThreadKeyByLogicalProjectKey,stickyModelSelectionByProvider:n.stickyModelSelectionByProvider??{},stickyActiveProvider:n.stickyActiveProvider??null}}}));function bJe(e){let t=(0,Cl.c)(2),n;return t[0]===e?n=t[1]:(n=t=>AY(t,e)??Qqe,t[0]=e,t[1]=n),RY(n)}function xJe(e){let t=(0,Cl.c)(2),n;return t[0]===e?n=t[1]:(n=t=>{let n=AY(t,e);return n?{activeProvider:n.activeProvider,modelSelectionByProvider:n.modelSelectionByProvider}:Zqe},t[0]=e,t[1]=n),RY(dJ(n))}function SJe(e){let t=(0,Cl.c)(10),n;t[0]!==e.draftId||t[1]!==e.threadRef?(n=e.threadRef??e.draftId??Ut.make(``),t[0]=e.draftId,t[1]=e.threadRef,t[2]=n):n=t[2];let r=xJe(n),i,a;return t[3]!==r||t[4]!==e.projectModelSelection||t[5]!==e.providers||t[6]!==e.selectedProvider||t[7]!==e.settings||t[8]!==e.threadModelSelection?(a=Uqe({draft:r,providers:e.providers,selectedProvider:e.selectedProvider,threadModelSelection:e.threadModelSelection,projectModelSelection:e.projectModelSelection,settings:e.settings}),t[3]=r,t[4]=e.projectModelSelection,t[5]=e.providers,t[6]=e.selectedProvider,t[7]=e.settings,t[8]=e.threadModelSelection,t[9]=a):a=t[9],i=a,i}function zY(e){let t=RY.getState();for(let[n,r]of Object.entries(t.draftThreadsByThreadKey))r.environmentId===e.environmentId&&r.threadId===e.threadId&&t.markDraftThreadPromoting(Ut.make(n),e)}function CJe(e){for(let t of e)zY(t)}function wJe(e){let t=RY.getState();for(let[n,r]of Object.entries(t.draftThreadsByThreadKey))r.promotedTo&&r.promotedTo.environmentId===e.environmentId&&r.promotedTo.threadId===e.threadId&&t.finalizePromotedDraftThread(Ut.make(n))}function TJe(e){return{environmentId:e.environmentId,threadId:e.threadId}}function EJe(e){return{draftId:e}}function DJe(e){return!e.environmentId||!e.threadId?null:Lo(e.environmentId,e.threadId)}function OJe(e){return e.environmentId&&e.threadId?{kind:`server`,threadRef:Lo(e.environmentId,e.threadId)}:e.draftId?{kind:`draft`,draftId:e.draftId}:null}var kJe=F.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Ste(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function BY(e){let t=(0,Cl.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=Xt(`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,kr.jsx)(`div`,{className:i,"data-slot":`skeleton`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var VY=`cmmd-runtime:`;function AJe(e){return`${VY}${e}`}function HY(e){return UY(e)!==null}function UY(e){let t=String(e);if(!t.startsWith(`cmmd-runtime:`))return null;let n=t.slice(13);return/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(n)?n:null}var WY=`forge:client-settings:v1`,jJe=`forge:saved-environment-registry:v1`,MJe=zn({environmentId:en,label:Un,httpBaseUrl:Un,wsBaseUrl:Un,createdAt:Un,lastConnectedAt:Xn(Un),cmmdOrganizationId:Ln(Un),cmmdProjectId:Ln(Un),runtimeId:Ln(Un),runtimeTicketExpiresAt:Ln(Un),lastAuthenticatedPullRequestCapability:Ln(Kn),bearerToken:Ln(Un)}),GY=zn({version:Ln(An),records:Ln(Bn(MJe))});function KY(){return typeof window<`u`}var NJe={uiFontSize:14,codeFontSize:15},PJe=[[`uiFontSize`,11,20],[`codeFontSize`,11,20]];function FJe(e){return e.defaultThreadRuntime===`desktop-cloud-bridge`?{...e,defaultThreadRuntime:`cloud`}:null}function IJe(e){if(typeof e.fontDefaultsVersion==`number`)return null;let t=Object.entries(NJe).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 LJe(e){let t=PJe.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 qY(e){if(!e||typeof e!=`object`)return e;let t=e,n=!1;for(let e of[FJe,IJe,LJe]){let r=e(t);r!==null&&(t=r,n=!0)}return n?t:e}function RJe(){if(!KY())return null;try{let e=window.localStorage.getItem(WY);return e?Qn(Pn)(qY(JSON.parse(e))):null}catch{return null}}function zJe(e){KY()&&qq(WY,e,Pn)}function JY(){if(!KY())return{};try{return Kq(`forge:saved-environment-registry:v1`,GY)??{}}catch{return{}}}function YY(e){KY()&&qq(jJe,e,GY)}function XY(){return JY().records??[]}function BJe(e){YY({version:1,records:e})}function VJe(){return XY().map(e=>Nn(e))}function HJe(e){let t=new Map(XY().map(e=>[e.environmentId,e]));BJe(e.map(e=>{let n=HY(e.environmentId)?void 0:t.get(e.environmentId)?.bearerToken;return n?{...Nn(e),bearerToken:n}:Nn(e)}))}function UJe(e){return XY().find(t=>t.environmentId===e)?.bearerToken??null}function WJe(e,t){let n=JY(),r=n.records??[],i=!1;return YY({version:n.version??1,records:r.map(n=>n.environmentId===e?(i=!0,Object.assign(Nn(n),{bearerToken:t})):n)}),i}function GJe(e){let t=JY();YY({version:t.version??1,records:(t.records??[]).map(t=>t.environmentId===e?Nn(t):t)})}var KJe=Qn(Pn);function qJe(){return typeof window>`u`?void 0:window.desktopBridge}function ZY(e){let t=qJe(),n=t?.[e];return typeof n==`function`?n.bind(t):null}async function QY(){let e=ZY(`getClientSettings`);if(e){let t=await e();return t?KJe(t):null}return RJe()}async function $Y(e){let t=ZY(`setClientSettings`);if(t)return t(e);zJe(e)}async function eX(){let e=ZY(`getSavedEnvironmentRegistry`);return e?e():VJe()}async function tX(e){let t=ZY(`setSavedEnvironmentRegistry`);if(t)return t(e);HJe(e)}async function nX(e){let t=ZY(`getSavedEnvironmentSecret`);return t?t(e):UJe(e)}async function rX(e,t){let n=ZY(`setSavedEnvironmentSecret`);return n?n(e,t):WJe(e,t)}async function iX(e){let t=ZY(`removeSavedEnvironmentSecret`);if(t)return t(e);GJe(e)}var aX=!1,oX=null;function sX(e){return Object.values(e)}function cX(e){return e.map(e=>Nn(e))}function lX(e){try{tX(cX(sX(e))).catch(e=>{console.error(`[SAVED_ENVIRONMENTS] persist failed`,e)})}catch(e){console.error(`[SAVED_ENVIRONMENTS] persist failed`,e)}}function JJe(e){let t=uX.getState().byId,n=Object.fromEntries(e.map(e=>[e.environmentId,e]));uX.setState({byId:{...n,...t}})}async function YJe(){if(aX)return;if(oX)return oX;let e=(async()=>{try{JJe(await eX())}catch(e){console.error(`[SAVED_ENVIRONMENTS] hydrate failed`,e)}finally{aX=!0,uX.setState({hydrated:!0})}})().finally(()=>{oX===e&&(oX=null)});return oX=e,oX}var uX=Wt()(e=>({byId:{},hydrated:aX,upsert:t=>e(e=>{let n={...e.byId,[t.environmentId]:t};return lX(n),{byId:n}}),remove:t=>e(e=>{let{[t]:n,...r}=e.byId;return lX(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 lX(i),{byId:i}}),reset:()=>{lX({}),e({byId:{}})}}));function dX(){return aX}function fX(){return dX()?Promise.resolve():YJe()}function pX(){return Object.values(uX.getState().byId).toSorted((e,t)=>e.label.localeCompare(t.label))}function XJe(){return pX().filter(e=>e.lastAuthenticatedPullRequestCapability===!0)}function mX(e){return uX.getState().byId[e]??null}function ZJe(e){let t=Fq();return t?.environmentId===e?Jie(t):mX(e)?.httpBaseUrl??null}function hX(e){let t=ZJe(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()}async function gX(e){await tX(cX(sX({...uX.getState().byId,[e.environmentId]:e})))}async function _X(e){return nX(e)}async function QJe(e,t){return rX(e,t)}async function vX(e){await iX(e)}var $Je=Object.freeze({connectionState:`disconnected`,authState:`unknown`,lastError:null,lastErrorAt:null,role:null,descriptor:null,serverConfig:null,connectedAt:null,disconnectedAt:null,providerAuthority:null});function yX(){return{...$Je}}var bX=Wt()(e=>({byId:{},ensure:t=>e(e=>e.byId[t]?e:{byId:{...e.byId,[t]:yX()}}),patch:(t,n)=>e(e=>({byId:{...e.byId,[t]:{...e.byId[t]??yX(),...n}}})),clear:t=>e(e=>{let{[t]:n,...r}=e.byId;return{byId:r}}),reset:()=>e({byId:{}})})),eYe=[/(?:^|\s)\/(?:Users|var|private|tmp|project|repo|home)\/[^\s'"<>)]*/i,/(?:^|\s)[A-Za-z]:\\[^\s'"<>)]*/];function xX(e){let t=e?.trim();return t&&t.length>0?t:null}function tYe(e){return xX(e)??`Project`}function nYe(e,t=`safe`){let n=xX(e);return n?t===`full`?n:n.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)??`Local checkout`:`Local checkout`}function SX(e,t=`Something went wrong. Try again.`){let n=DK(e instanceof Error?e.message:typeof e==`string`?e:String(e),{fallback:t});return!n||eYe.some(e=>e.test(n))?t:n}function CX(e,t){return{id:e.id,environmentId:t,name:e.title,cwd:e.workspaceRoot,repositoryIdentity:e.repositoryIdentity??null,availability:e.availability,defaultThreadEnvMode:e.defaultThreadEnvMode??null,cmmdRegistration:e.cmmdRegistration??null,defaultModelSelection:e.defaultModelSelection?wX(e.defaultModelSelection):null,createdAt:e.createdAt,updatedAt:e.updatedAt,scripts:TX(e.scripts)}}function wX(e){return{...e,model:Wq(e.provider,e.model)}}function TX(e){return e.map(e=>({...e}))}function rYe(e,t){return{...e,...t.title===void 0?{}:{name:t.title},...t.workspaceRoot===void 0?{}:{cwd:t.workspaceRoot},...t.repositoryIdentity===void 0?{}:{repositoryIdentity:t.repositoryIdentity??null},...t.defaultThreadEnvMode===void 0?{}:{defaultThreadEnvMode:t.defaultThreadEnvMode},...t.cmmdRegistration===void 0?{}:{cmmdRegistration:t.cmmdRegistration},...t.defaultModelSelection===void 0?{}:{defaultModelSelection:t.defaultModelSelection?wX(t.defaultModelSelection):null},...t.scripts===void 0?{}:{scripts:TX(t.scripts)},updatedAt:t.updatedAt}}var iYe=[],aYe=[],oYe=[],sYe=[],cYe={},lYe={},uYe={},dYe={},fYe=[],EX=new WeakMap,DX=new WeakMap;function OX(e,t,n){if(!e||e.length===0||!t)return n;let r=EX.get(e),i=r?.get(t);if(i)return i;let a=e.flatMap(e=>{let n=t[e];return n?[n]:[]}),o=r??new WeakMap;return o.set(t,a),r||EX.set(e,o),a}function pYe(e,t){return OX(e.messageIdsByThreadId[t],e.messageByThreadId[t]??cYe,iYe)}function mYe(e,t){return OX(e.activityIdsByThreadId[t],e.activityByThreadId[t]??lYe,aYe)}function hYe(e,t){return OX(e.proposedPlanIdsByThreadId[t],e.proposedPlanByThreadId[t]??uYe,oYe)}function gYe(e,t){return OX(e.turnDiffIdsByThreadId[t],e.turnDiffSummaryByThreadId[t]??dYe,sYe)}function kX(e,t){let n=e.threadShellById[t];if(!n)return;let r=e.threadSessionById[t]??null,i=e.threadTurnStateById[t],a=e.threadRateLimitStatusById[t]??fYe,o=pYe(e,t),s=mYe(e,t),c=hYe(e,t),l=gYe(e,t),u=DX.get(n);if(u&&u.session===r&&u.turnState===i&&u.rateLimitStatus===a&&u.messages===o&&u.activities===s&&u.proposedPlans===c&&u.turnDiffSummaries===l)return u.thread;let d={...n,session:r,latestTurn:i?.latestTurn??null,pendingSourceProposedPlan:i?.pendingSourceProposedPlan,rateLimitStatus:a,messages:o,activities:s,proposedPlans:c,turnDiffSummaries:l};return DX.set(n,{session:r,turnState:i,rateLimitStatus:a,messages:o,activities:s,proposedPlans:c,turnDiffSummaries:l,thread:d}),d}function AX(e){return{settledAt:e.settledAt??null,settledOverride:e.settledOverride??null}}function jX(e,t,n,r){let i=oZ(e,t,e=>({...e,...r,updatedAt:n})),a=i.sidebarThreadSummaryById[t];return!a||Object.keys(r).every(e=>a[e]===r[e])?i:{...i,sidebarThreadSummaryById:{...i.sidebarThreadSummaryById,[t]:{...a,...r}}}}function _Ye(e,t){let n=t.providerAccountId??null,r=e=>e.provider===t.provider&&(e.providerAccountId??null)===n,i=e.find(r),a={status:t.status,usedPercent:t.usedPercent,resetsAt:t.resetsAt},o={provider:t.provider,providerAccountId:n,fiveHour:t.window===`five_hour`?a:i?.fiveHour??null,sevenDay:t.window===`seven_day`?a:i?.sevenDay??null};return[...e.filter(e=>!r(e)),o]}var MX={projectIds:[],projectById:{},threadIds:[],threadIdsByProjectId:{},threadShellById:{},threadSessionById:{},threadTurnStateById:{},threadRateLimitStatusById:{},messageIdsByThreadId:{},messageByThreadId:{},activityIdsByThreadId:{},activityByThreadId:{},proposedPlanIdsByThreadId:{},proposedPlanByThreadId:{},turnDiffIdsByThreadId:{},turnDiffSummaryByThreadId:{},sidebarThreadSummaryById:{},threadSubscriptionErrorById:{},bootstrapComplete:!1},vYe={activeEnvironmentId:null,environmentStateById:{}},NX=[],PX=[];function FX(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function IX(e){let t=kK(e.lastError);return{provider:PYe(e.providerName),status:NYe(e.status),orchestrationStatus:e.status,activeTurnId:e.activeTurnId??void 0,createdAt:e.updatedAt,updatedAt:e.updatedAt,...t?{lastError:t}:{}}}function LX(e,t){let n=t.attachments?.map(t=>({type:`image`,id:t.id,name:t.name,mimeType:t.mimeType,sizeBytes:t.sizeBytes,previewUrl:hX({environmentId:e,pathname:FYe(t.id)})}));return{id:t.id,role:t.role,text:t.text,turnId:t.turnId,createdAt:t.createdAt,streaming:t.streaming,...t.streaming?{}:{completedAt:t.updatedAt},...n&&n.length>0?{attachments:n}:{}}}function RX(e){return{id:e.id,turnId:e.turnId,planMarkdown:e.planMarkdown,implementedAt:e.implementedAt,implementationThreadId:e.implementationThreadId,createdAt:e.createdAt,updatedAt:e.updatedAt}}function zX(e){return{turnId:e.turnId,completedAt:e.completedAt,status:e.status,assistantMessageId:e.assistantMessageId??void 0,checkpointTurnCount:e.checkpointTurnCount,checkpointRef:e.checkpointRef,files:e.files.map(e=>({...e}))}}function BX(e,t){return{id:e.id,environmentId:t,codexThreadId:null,projectId:e.projectId,title:e.title,modelSelection:wX(e.modelSelection),runtimeMode:e.runtimeMode,interactionMode:e.interactionMode,session:e.session?IX(e.session):null,messages:e.messages.map(e=>LX(t,e)),proposedPlans:e.proposedPlans.map(RX),error:kK(e.session?.lastError),createdAt:e.createdAt,archivedAt:e.archivedAt,...AX(e),updatedAt:e.updatedAt,latestTurn:e.latestTurn,pendingSourceProposedPlan:e.latestTurn?.sourceProposedPlan,branch:e.branch,worktreePath:e.worktreePath,turnDiffSummaries:e.checkpoints.map(zX),activities:e.activities.map(e=>({...e})),anchorKind:e.anchorKind,anchorCmmdId:e.anchorCmmdId,linkedPullRequest:e.linkedPullRequest??null,goal:e.goal??null,titleRegeneration:e.titleRegeneration??null,kind:e.kind,parentThreadId:e.parentThreadId,status:e.status,workerRole:e.workerRole??null,pendingAutoCreatePrompt:e.pendingAutoCreatePrompt??null,rateLimitStatus:e.rateLimitStatus??[]}}function VX(e,t){let n={id:e.id,environmentId:t,codexThreadId:null,projectId:e.projectId,title:e.title,modelSelection:wX(e.modelSelection),runtimeMode:e.runtimeMode,interactionMode:e.interactionMode,error:kK(e.session?.lastError),createdAt:e.createdAt,archivedAt:e.archivedAt,...AX(e),updatedAt:e.updatedAt,branch:e.branch,worktreePath:e.worktreePath,anchorKind:e.anchorKind,anchorCmmdId:e.anchorCmmdId,linkedPullRequest:e.linkedPullRequest??null,goal:e.goal??null,titleRegeneration:e.titleRegeneration??null,kind:e.kind,parentThreadId:e.parentThreadId,status:e.status,workerRole:e.workerRole??null},r=e.session?IX(e.session):null;return{shell:n,session:r,turnState:{latestTurn:e.latestTurn,pendingSourceProposedPlan:e.latestTurn?.sourceProposedPlan},summary:{id:e.id,modelSelection:n.modelSelection,environmentId:t,projectId:e.projectId,title:e.title,interactionMode:e.interactionMode,session:r,createdAt:e.createdAt,archivedAt:e.archivedAt,...AX(e),updatedAt:e.updatedAt,latestTurn:e.latestTurn,branch:e.branch,worktreePath:e.worktreePath,latestUserMessageAt:e.latestUserMessageAt,hasPendingApprovals:e.hasPendingApprovals,hasPendingUserInput:e.hasPendingUserInput,hasActionableProposedPlan:e.hasActionableProposedPlan,anchorKind:e.anchorKind,anchorCmmdId:e.anchorCmmdId,linkedPullRequest:e.linkedPullRequest??null,goal:e.goal??null,titleRegeneration:e.titleRegeneration??null,kind:e.kind,parentThreadId:e.parentThreadId,status:e.status,workerRole:e.workerRole??null}}}function yYe(e){return{id:e.id,environmentId:e.environmentId,codexThreadId:e.codexThreadId,projectId:e.projectId,title:e.title,modelSelection:e.modelSelection,runtimeMode:e.runtimeMode,interactionMode:e.interactionMode,error:e.error,createdAt:e.createdAt,archivedAt:e.archivedAt,settledAt:e.settledAt,settledOverride:e.settledOverride,updatedAt:e.updatedAt,branch:e.branch,worktreePath:e.worktreePath,anchorKind:e.anchorKind,anchorCmmdId:e.anchorCmmdId,linkedPullRequest:e.linkedPullRequest??null,kind:e.kind,parentThreadId:e.parentThreadId,status:e.status,workerRole:e.workerRole??null,goal:e.goal??null,titleRegeneration:e.titleRegeneration??null}}function bYe(e){return{latestTurn:e.latestTurn,...e.pendingSourceProposedPlan?{pendingSourceProposedPlan:e.pendingSourceProposedPlan}:{}}}function HX(e,t){return e===t?!0:e===void 0||t===void 0?!1:e.threadId===t.threadId&&e.planId===t.planId}function UX(e,t){return e===t?!0:e==null||t==null?!1:e.turnId===t.turnId&&e.state===t.state&&e.requestedAt===t.requestedAt&&e.startedAt===t.startedAt&&e.completedAt===t.completedAt&&e.assistantMessageId===t.assistantMessageId&&HX(e.sourceProposedPlan,t.sourceProposedPlan)}function WX(e,t){return e===t?!0:e==null||t==null?!1:e.provider===t.provider&&e.status===t.status&&e.orchestrationStatus===t.orchestrationStatus&&e.activeTurnId===t.activeTurnId&&e.createdAt===t.createdAt&&e.updatedAt===t.updatedAt&&e.lastError===t.lastError}function GX(e,t){return e===t?!0:e==null||t==null?!1:e.projectId===t.projectId&&e.projectRepositoryId===t.projectRepositoryId&&e.provider===t.provider&&e.host===t.host&&e.repository===t.repository&&e.number===t.number&&e.url===t.url}function KX(e,t){return e!==void 0&&e.id===t.id&&e.environmentId===t.environmentId&&e.projectId===t.projectId&&e.title===t.title&&qX(e.titleRegeneration,t.titleRegeneration)&&e.interactionMode===t.interactionMode&&WX(e.session,t.session)&&e.createdAt===t.createdAt&&e.archivedAt===t.archivedAt&&e.settledAt===t.settledAt&&e.settledOverride===t.settledOverride&&e.updatedAt===t.updatedAt&&UX(e.latestTurn,t.latestTurn)&&e.branch===t.branch&&e.worktreePath===t.worktreePath&&e.latestUserMessageAt===t.latestUserMessageAt&&e.hasPendingApprovals===t.hasPendingApprovals&&e.hasPendingUserInput===t.hasPendingUserInput&&e.hasActionableProposedPlan===t.hasActionableProposedPlan&&e.anchorKind===t.anchorKind&&e.anchorCmmdId===t.anchorCmmdId&&GX(e.linkedPullRequest,t.linkedPullRequest)&&e.kind===t.kind&&e.parentThreadId===t.parentThreadId&&e.status===t.status}function qX(e,t){return e===t?!0:e==null||t==null?!1:e.requestId===t.requestId&&e.startedAt===t.startedAt}function JX(e,t){return e!==void 0&&e.id===t.id&&e.environmentId===t.environmentId&&e.codexThreadId===t.codexThreadId&&e.projectId===t.projectId&&e.title===t.title&&e.modelSelection===t.modelSelection&&e.runtimeMode===t.runtimeMode&&e.interactionMode===t.interactionMode&&e.error===t.error&&e.createdAt===t.createdAt&&e.archivedAt===t.archivedAt&&e.settledAt===t.settledAt&&e.settledOverride===t.settledOverride&&e.updatedAt===t.updatedAt&&e.branch===t.branch&&e.worktreePath===t.worktreePath&&e.anchorKind===t.anchorKind&&e.anchorCmmdId===t.anchorCmmdId&&GX(e.linkedPullRequest,t.linkedPullRequest)&&e.kind===t.kind&&e.parentThreadId===t.parentThreadId&&e.status===t.status&&e.goal===t.goal&&qX(e.titleRegeneration,t.titleRegeneration)}function YX(e,t){return e!==void 0&&UX(e.latestTurn,t.latestTurn)&&HX(e.pendingSourceProposedPlan,t.pendingSourceProposedPlan)}function xYe(e,t){return e.includes(t)?[...e]:[...e,t]}function XX(e,t){return e.filter(e=>e!==t)}function SYe(e){return{ids:e.messages.map(e=>e.id),byId:Object.fromEntries(e.messages.map(e=>[e.id,e]))}}function CYe(e){return{ids:e.activities.map(e=>e.id),byId:Object.fromEntries(e.activities.map(e=>[e.id,e]))}}function wYe(e){return{ids:e.proposedPlans.map(e=>e.id),byId:Object.fromEntries(e.proposedPlans.map(e=>[e.id,e]))}}function TYe(e){return{ids:e.turnDiffSummaries.map(e=>e.turnId),byId:Object.fromEntries(e.turnDiffSummaries.map(e=>[e.turnId,e]))}}function EYe(e){return e.projectIds.flatMap(t=>{let n=e.projectById[t];return n?[n]:[]})}function ZX(e){return e.threadIds.flatMap(t=>{let n=kX(e,t);return n?[n]:[]})}function QX(e,t,n,r){let i=e;if(e.threadIds.includes(t)||(i={...i,threadIds:[...i.threadIds,t]}),r!==n){let e=i.threadIdsByProjectId;if(r){let n=e[r]??NX,i=XX(n,t);if(i.length===0){let{[r]:t,...n}=e;e=n}else FX(n,i)||(e={...e,[r]:i})}let a=e[n]??NX,o=xYe(a,t);FX(a,o)||(e={...e,[n]:o}),e!==i.threadIdsByProjectId&&(i={...i,threadIdsByProjectId:e})}return i}function $X(e,t,n){let r=yYe(t),i=bYe(t),a=e.threadShellById[t.id],o=e.threadTurnStateById[t.id],s=QX(e,t.id,t.projectId,n?.projectId);JX(a,r)||(s={...s,threadShellById:{...s.threadShellById,[t.id]:r}});let c=e.sidebarThreadSummaryById[t.id];if(c!==void 0){let e={...c,title:t.title,modelSelection:t.modelSelection,interactionMode:t.interactionMode,session:t.session,createdAt:t.createdAt,archivedAt:t.archivedAt,settledAt:t.settledAt,settledOverride:t.settledOverride,updatedAt:t.updatedAt,latestTurn:t.latestTurn,branch:t.branch,worktreePath:t.worktreePath,anchorKind:t.anchorKind,anchorCmmdId:t.anchorCmmdId,linkedPullRequest:t.linkedPullRequest??null,goal:t.goal,titleRegeneration:t.titleRegeneration??null,kind:t.kind,parentThreadId:t.parentThreadId,status:t.status,workerRole:t.workerRole};KX(c,e)||(s={...s,sidebarThreadSummaryById:{...s.sidebarThreadSummaryById,[t.id]:e}})}if(WX(n?.session??null,t.session)||(s={...s,threadSessionById:{...s.threadSessionById,[t.id]:t.session}}),(n?.rateLimitStatus??PX)!==(t.rateLimitStatus??PX)&&(s={...s,threadRateLimitStatusById:{...s.threadRateLimitStatusById,[t.id]:t.rateLimitStatus??PX}}),YX(o,i)||(s={...s,threadTurnStateById:{...s.threadTurnStateById,[t.id]:i}}),n?.messages!==t.messages){let e=SYe(t);s={...s,messageIdsByThreadId:{...s.messageIdsByThreadId,[t.id]:e.ids},messageByThreadId:{...s.messageByThreadId,[t.id]:e.byId}}}if(n?.activities!==t.activities){let e=CYe(t);s={...s,activityIdsByThreadId:{...s.activityIdsByThreadId,[t.id]:e.ids},activityByThreadId:{...s.activityByThreadId,[t.id]:e.byId}}}if(n?.proposedPlans!==t.proposedPlans){let e=wYe(t);s={...s,proposedPlanIdsByThreadId:{...s.proposedPlanIdsByThreadId,[t.id]:e.ids},proposedPlanByThreadId:{...s.proposedPlanByThreadId,[t.id]:e.byId}}}if(n?.turnDiffSummaries!==t.turnDiffSummaries){let e=TYe(t);s={...s,turnDiffIdsByThreadId:{...s.turnDiffIdsByThreadId,[t.id]:e.ids},turnDiffSummaryByThreadId:{...s.turnDiffSummaryByThreadId,[t.id]:e.byId}}}return s}function eZ(e,t){let n=e.threadShellById[t.shell.id],r=QX(e,t.shell.id,t.shell.projectId,n?.projectId);return JX(n,t.shell)||(r={...r,threadShellById:{...r.threadShellById,[t.shell.id]:t.shell}}),WX(e.threadSessionById[t.shell.id]??null,t.session)||(r={...r,threadSessionById:{...r.threadSessionById,[t.shell.id]:t.session}}),YX(e.threadTurnStateById[t.shell.id],t.turnState)||(r={...r,threadTurnStateById:{...r.threadTurnStateById,[t.shell.id]:t.turnState}}),KX(e.sidebarThreadSummaryById[t.shell.id],t.summary)||(r={...r,sidebarThreadSummaryById:{...r.sidebarThreadSummaryById,[t.shell.id]:t.summary}}),r}function tZ(e,t){return Object.fromEntries(Object.entries(e).flatMap(([e,n])=>t.has(e)?[[e,n]]:[]))}function nZ(e,t){let n=e.threadShellById[t],r=e.sidebarThreadSummaryById[t],i=n?.projectId??r?.projectId;if(!i)return e;let a=XX(e.threadIds,t),o=XX(e.threadIdsByProjectId[i]??NX,t),s=o.length===0?(()=>{let{[i]:t,...n}=e.threadIdsByProjectId;return n})():{...e.threadIdsByProjectId,[i]:o},{[t]:c,...l}=e.threadShellById,{[t]:u,...d}=e.threadSessionById,{[t]:f,...p}=e.threadTurnStateById,{[t]:m,...h}=e.messageIdsByThreadId,{[t]:g,..._}=e.messageByThreadId,{[t]:v,...y}=e.activityIdsByThreadId,{[t]:b,...x}=e.activityByThreadId,{[t]:S,...C}=e.proposedPlanIdsByThreadId,{[t]:w,...T}=e.proposedPlanByThreadId,{[t]:E,...D}=e.turnDiffIdsByThreadId,{[t]:O,...ee}=e.turnDiffSummaryByThreadId,{[t]:te,...k}=e.sidebarThreadSummaryById;return{...e,threadIds:a,threadIdsByProjectId:s,threadShellById:l,threadSessionById:d,threadTurnStateById:p,messageIdsByThreadId:h,messageByThreadId:_,activityIdsByThreadId:y,activityByThreadId:x,proposedPlanIdsByThreadId:C,proposedPlanByThreadId:T,turnDiffIdsByThreadId:D,turnDiffSummaryByThreadId:ee,sidebarThreadSummaryById:k}}function DYe(e,t){let n=new Set(e.threadIdsByProjectId[t]??NX);for(let[r,i]of Object.entries(e.threadShellById))i.projectId===t&&n.add(r);for(let[r,i]of Object.entries(e.sidebarThreadSummaryById))i.projectId===t&&n.add(r);return[...n]}function rZ(e,t){let n=DYe(e,t);if(!e.projectById[t]&&n.length===0&&!e.projectIds.includes(t))return e;let r=e;for(let e of n)r=nZ(r,e);let{[t]:i,...a}=r.projectById;return{...r,projectById:a,projectIds:XX(r.projectIds,t)}}function iZ(e){return e===`error`?`error`:e===`missing`?`interrupted`:`completed`}function OYe(e,t){if(e.sequence!==void 0&&t.sequence!==void 0){if(e.sequence!==t.sequence)return e.sequence-t.sequence}else if(e.sequence!==void 0)return 1;else if(t.sequence!==void 0)return-1;return e.createdAt.localeCompare(t.createdAt)||e.id.localeCompare(t.id)}function aZ(e){let t=e.previous?.turnId===e.turnId?e.previous.sourceProposedPlan:e.sourceProposedPlan;return{turnId:e.turnId,state:e.state,requestedAt:e.requestedAt,startedAt:e.startedAt,completedAt:e.completedAt,assistantMessageId:e.assistantMessageId,...t?{sourceProposedPlan:t}:{}}}function kYe(e,t,n){let r=!1,i=e.map(e=>e.turnId!==t||e.assistantMessageId===n?e:(r=!0,{...e,assistantMessageId:n??void 0}));return r?i:[...e]}function AYe(e,t,n){let r=new Set;for(let n of e){if(n.role===`system`){r.add(n.id);continue}n.turnId!==void 0&&n.turnId!==null&&t.has(n.turnId)&&r.add(n.id)}let i=e.filter(e=>e.role===`user`&&r.has(e.id)).length,a=Math.max(0,n-i);if(a>0){let n=e.filter(e=>e.role===`user`&&!r.has(e.id)&&(e.turnId===void 0||e.turnId===null||t.has(e.turnId))).toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.id.localeCompare(t.id)).slice(0,a);for(let e of n)r.add(e.id)}let o=e.filter(e=>e.role===`assistant`&&r.has(e.id)).length,s=Math.max(0,n-o);if(s>0){let n=e.filter(e=>e.role===`assistant`&&!r.has(e.id)&&(e.turnId===void 0||e.turnId===null||t.has(e.turnId))).toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.id.localeCompare(t.id)).slice(0,s);for(let e of n)r.add(e.id)}return e.filter(e=>r.has(e.id))}function jYe(e,t){return e.filter(e=>e.turnId===null||t.has(e.turnId))}function MYe(e,t){return e.filter(e=>e.turnId===null||t.has(e.turnId))}function NYe(e){switch(e){case`starting`:return`connecting`;case`running`:return`running`;case`error`:return`error`;case`ready`:case`interrupted`:return`ready`;case`idle`:case`stopped`:return`closed`}}function PYe(e){return e===`codex`||e===`claudeAgent`||e===`ollama`||e===`cmmd`||e===`apex`?e:`codex`}function FYe(e){return`/attachments/${encodeURIComponent(e)}`}function oZ(e,t,n){let r=kX(e,t);if(!r)return e;let i=n(r);return i===r?e:$X(e,i,r)}function IYe(e){return{projectIds:e.map(e=>e.id),projectById:Object.fromEntries(e.map(e=>[e.id,e]))}}function sZ(e,t){return e.environmentStateById[t]??MX}function cZ(e,t,n){let r=e.environmentStateById[t]===n?e.environmentStateById:{...e.environmentStateById,[t]:n};return r===e.environmentStateById?e:{...e,environmentStateById:r}}function LYe(e,t,n){let r=t.projects.map(e=>CX(e,n)),i=new Set(t.threads.map(e=>e.id)),a={...e,...IYe(r),threadIds:[],threadIdsByProjectId:{},threadShellById:{},threadSessionById:{},threadTurnStateById:{},threadRateLimitStatusById:tZ(e.threadRateLimitStatusById,i),sidebarThreadSummaryById:{},messageIdsByThreadId:tZ(e.messageIdsByThreadId,i),messageByThreadId:tZ(e.messageByThreadId,i),activityIdsByThreadId:tZ(e.activityIdsByThreadId,i),activityByThreadId:tZ(e.activityByThreadId,i),proposedPlanIdsByThreadId:tZ(e.proposedPlanIdsByThreadId,i),proposedPlanByThreadId:tZ(e.proposedPlanByThreadId,i),turnDiffIdsByThreadId:tZ(e.turnDiffIdsByThreadId,i),turnDiffSummaryByThreadId:tZ(e.turnDiffSummaryByThreadId,i),bootstrapComplete:!0};for(let e of t.threads)a=eZ(a,VX(e,n));return a}function RYe(e,t,n){return cZ(e,n,LYe(sZ(e,n),t,n))}function zYe(e,t,n){let r=sZ(e,n),i=kX(r,t.id);return cZ(e,n,$X(r,BX(t,n),i))}function BYe(e,t,n,r){let i=sZ(e,t);return cZ(e,t,{...i,threadSubscriptionErrorById:{...i.threadSubscriptionErrorById,[n]:r}})}function VYe(e,t,n){let r=sZ(e,t);if(!(n in r.threadSubscriptionErrorById))return e;let{[n]:i,...a}=r.threadSubscriptionErrorById;return cZ(e,t,{...r,threadSubscriptionErrorById:a})}function lZ(e,t,n){switch(t.type){case`project.created`:{let r=CX({id:t.payload.projectId,title:t.payload.title,workspaceRoot:t.payload.workspaceRoot,repositoryIdentity:t.payload.repositoryIdentity??null,defaultModelSelection:t.payload.defaultModelSelection,defaultThreadEnvMode:t.payload.defaultThreadEnvMode??null,cmmdRegistration:t.payload.cmmdRegistration??null,scripts:t.payload.scripts,createdAt:t.payload.createdAt,updatedAt:t.payload.updatedAt,deletedAt:null},n),i=e.projectIds.find(n=>n===t.payload.projectId||e.projectById[n]?.cwd===t.payload.workspaceRoot)??null,a=e.projectById,o=e.projectIds;if(i!==null&&i!==r.id){let{[i]:t,...n}=e.projectById;a={...n,[r.id]:r},o=e.projectIds.map(e=>e===i?r.id:e)}else a={...e.projectById,[r.id]:r},o=i===null&&!e.projectIds.includes(r.id)?[...e.projectIds,r.id]:e.projectIds;return{...e,projectById:a,projectIds:o}}case`project.meta-updated`:{let n=e.projectById[t.payload.projectId];if(!n)return e;let r=rYe(n,t.payload);return{...e,projectById:{...e.projectById,[t.payload.projectId]:r}}}case`project.deleted`:return rZ(e,t.payload.projectId);case`thread.created`:{let r=kX(e,t.payload.threadId);return $X(e,BX({id:t.payload.threadId,projectId:t.payload.projectId,title:t.payload.title,modelSelection:t.payload.modelSelection,runtimeMode:t.payload.runtimeMode,interactionMode:t.payload.interactionMode,branch:t.payload.branch,worktreePath:t.payload.worktreePath,latestTurn:null,createdAt:t.payload.createdAt,updatedAt:t.payload.updatedAt,archivedAt:null,deletedAt:null,messages:[],proposedPlans:[],activities:[],checkpoints:[],session:null,anchorKind:t.payload.anchorKind,anchorCmmdId:t.payload.anchorCmmdId,kind:t.payload.kind,parentThreadId:t.payload.parentThreadId,status:t.payload.status,workerRole:t.payload.workerRole,goal:t.payload.goal??null,titleRegeneration:null,pendingAutoCreatePrompt:null},n),r)}case`thread.deleted`:return nZ(e,t.payload.threadId);case`thread.archived`:return jX(e,t.payload.threadId,t.payload.updatedAt,{archivedAt:t.payload.archivedAt});case`thread.unarchived`:return jX(e,t.payload.threadId,t.payload.updatedAt,{archivedAt:null});case`thread.settled`:return jX(e,t.payload.threadId,t.payload.updatedAt,{settledAt:t.payload.settledAt,settledOverride:t.payload.settledOverride});case`thread.unsettled`:return jX(e,t.payload.threadId,t.payload.updatedAt,{settledAt:null,settledOverride:`active`});case`thread.meta-updated`:return oZ(e,t.payload.threadId,e=>({...e,...t.payload.title===void 0?{}:{title:t.payload.title},...t.payload.modelSelection===void 0?{}:{modelSelection:wX(t.payload.modelSelection)},...t.payload.branch===void 0?{}:{branch:t.payload.branch},...t.payload.worktreePath===void 0?{}:{worktreePath:t.payload.worktreePath},...t.payload.anchorKind===void 0?{}:{anchorKind:t.payload.anchorKind},...t.payload.anchorCmmdId===void 0?{}:{anchorCmmdId:t.payload.anchorCmmdId},...t.payload.status===void 0?{}:{status:t.payload.status},...t.payload.parentThreadId===void 0?{}:{parentThreadId:t.payload.parentThreadId},...t.payload.goal===void 0?{}:{goal:t.payload.goal},...t.payload.linkedPullRequest===void 0?{}:{linkedPullRequest:t.payload.linkedPullRequest},...t.payload.titleRegeneration===void 0?{}:{titleRegeneration:t.payload.titleRegeneration},updatedAt:t.payload.updatedAt}));case`thread.runtime-mode-set`:return oZ(e,t.payload.threadId,e=>({...e,runtimeMode:t.payload.runtimeMode,updatedAt:t.payload.updatedAt}));case`thread.interaction-mode-set`:return oZ(e,t.payload.threadId,e=>({...e,interactionMode:t.payload.interactionMode,updatedAt:t.payload.updatedAt}));case`thread.turn-start-requested`:return oZ(e,t.payload.threadId,e=>({...e,...t.payload.modelSelection===void 0?{}:{modelSelection:wX(t.payload.modelSelection)},runtimeMode:t.payload.runtimeMode,interactionMode:t.payload.interactionMode,pendingSourceProposedPlan:t.payload.sourceProposedPlan,latestTurn:aZ({previous:e.latestTurn,turnId:hn.make(t.payload.messageId),state:`running`,requestedAt:t.payload.createdAt,startedAt:t.payload.createdAt,completedAt:null,assistantMessageId:null,sourceProposedPlan:t.payload.sourceProposedPlan}),updatedAt:t.occurredAt}));case`thread.turn-interrupt-requested`:return t.payload.turnId===void 0?e:oZ(e,t.payload.threadId,e=>{let n=e.latestTurn;return n===null||n.turnId!==t.payload.turnId?e:{...e,latestTurn:aZ({previous:n,turnId:t.payload.turnId,state:`interrupted`,requestedAt:n.requestedAt,startedAt:n.startedAt??t.payload.createdAt,completedAt:n.completedAt??t.payload.createdAt,assistantMessageId:n.assistantMessageId}),updatedAt:t.occurredAt}});case`thread.message-sent`:return oZ(e,t.payload.threadId,e=>{let n=LX(e.environmentId,{id:t.payload.messageId,role:t.payload.role,text:t.payload.text,...t.payload.attachments===void 0?{}:{attachments:t.payload.attachments},turnId:t.payload.turnId,streaming:t.payload.streaming,createdAt:t.payload.createdAt,updatedAt:t.payload.updatedAt}),r=(e.messages.find(e=>e.id===n.id)?e.messages.map(e=>e.id===n.id?{...e,text:n.streaming?`${e.text}${n.text}`:n.text.length>0?n.text:e.text,streaming:n.streaming,...n.turnId===void 0?{}:{turnId:n.turnId},...n.streaming?e.completedAt===void 0?{}:{completedAt:e.completedAt}:n.completedAt===void 0?{}:{completedAt:n.completedAt},...n.attachments===void 0?{}:{attachments:n.attachments}}:e):[...e.messages,n]).slice(-2e3),i=t.payload.role===`assistant`&&t.payload.turnId!==null?kYe(e.turnDiffSummaries,t.payload.turnId,t.payload.messageId):e.turnDiffSummaries,a=t.payload.role===`assistant`&&t.payload.turnId!==null&&(e.latestTurn===null||e.latestTurn.turnId===t.payload.turnId)?aZ({previous:e.latestTurn,turnId:t.payload.turnId,state:t.payload.streaming?`running`:e.latestTurn?.state===`interrupted`?`interrupted`:e.latestTurn?.state===`error`?`error`:`completed`,requestedAt:e.latestTurn?.turnId===t.payload.turnId?e.latestTurn.requestedAt:t.payload.createdAt,startedAt:e.latestTurn?.turnId===t.payload.turnId?e.latestTurn.startedAt??t.payload.createdAt:t.payload.createdAt,sourceProposedPlan:e.pendingSourceProposedPlan,completedAt:t.payload.streaming?e.latestTurn?.turnId===t.payload.turnId?e.latestTurn.completedAt??null:null:t.payload.updatedAt,assistantMessageId:t.payload.messageId}):e.latestTurn;return{...e,messages:r,turnDiffSummaries:i,latestTurn:a,updatedAt:t.occurredAt}});case`thread.session-set`:return oZ(e,t.payload.threadId,e=>({...e,session:IX(t.payload.session),error:kK(t.payload.session.lastError),latestTurn:t.payload.session.status===`running`&&t.payload.session.activeTurnId!==null?aZ({previous:e.latestTurn,turnId:t.payload.session.activeTurnId,state:`running`,requestedAt:e.latestTurn?.turnId===t.payload.session.activeTurnId?e.latestTurn.requestedAt:t.payload.session.updatedAt,startedAt:e.latestTurn?.turnId===t.payload.session.activeTurnId?e.latestTurn.startedAt??t.payload.session.updatedAt:t.payload.session.updatedAt,completedAt:null,assistantMessageId:e.latestTurn?.turnId===t.payload.session.activeTurnId?e.latestTurn.assistantMessageId:null,sourceProposedPlan:e.pendingSourceProposedPlan}):e.latestTurn,updatedAt:t.occurredAt}));case`thread.session-stop-requested`:return oZ(e,t.payload.threadId,e=>e.session===null?e:{...e,session:{...e.session,status:`closed`,orchestrationStatus:`stopped`,activeTurnId:void 0,updatedAt:t.payload.createdAt},updatedAt:t.occurredAt});case`thread.proposed-plan-upserted`:return oZ(e,t.payload.threadId,e=>{let n=RX(t.payload.proposedPlan),r=[...e.proposedPlans.filter(e=>e.id!==n.id),n].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.id.localeCompare(t.id)).slice(-200);return{...e,proposedPlans:r,updatedAt:t.occurredAt}});case`thread.turn-diff-completed`:return oZ(e,t.payload.threadId,e=>{let n=zX({turnId:t.payload.turnId,checkpointTurnCount:t.payload.checkpointTurnCount,checkpointRef:t.payload.checkpointRef,status:t.payload.status,files:t.payload.files,assistantMessageId:t.payload.assistantMessageId,completedAt:t.payload.completedAt}),r=e.turnDiffSummaries.find(e=>e.turnId===n.turnId);if(r&&r.status!==`missing`&&n.status===`missing`)return e;let i=[...e.turnDiffSummaries.filter(e=>e.turnId!==n.turnId),n].toSorted((e,t)=>(e.checkpointTurnCount??2**53-1)-(t.checkpointTurnCount??2**53-1)).slice(-500),a=e.latestTurn===null||e.latestTurn.turnId===t.payload.turnId?aZ({previous:e.latestTurn,turnId:t.payload.turnId,state:iZ(t.payload.status),requestedAt:e.latestTurn?.requestedAt??t.payload.completedAt,startedAt:e.latestTurn?.startedAt??t.payload.completedAt,completedAt:t.payload.completedAt,assistantMessageId:t.payload.assistantMessageId,sourceProposedPlan:e.pendingSourceProposedPlan}):e.latestTurn;return{...e,turnDiffSummaries:i,latestTurn:a,updatedAt:t.occurredAt}});case`thread.reverted`:return oZ(e,t.payload.threadId,e=>{let n=e.turnDiffSummaries.filter(e=>e.checkpointTurnCount!==void 0&&e.checkpointTurnCount<=t.payload.turnCount).toSorted((e,t)=>(e.checkpointTurnCount??2**53-1)-(t.checkpointTurnCount??2**53-1)).slice(-500),r=new Set(n.map(e=>e.turnId)),i=AYe(e.messages,r,t.payload.turnCount).slice(-2e3),a=MYe(e.proposedPlans,r).slice(-200),o=jYe(e.activities,r),s=n.at(-1)??null;return{...e,turnDiffSummaries:n,messages:i,proposedPlans:a,activities:o,pendingSourceProposedPlan:void 0,latestTurn:s===null?null:{turnId:s.turnId,state:iZ(s.status??`ready`),requestedAt:s.completedAt,startedAt:s.completedAt,completedAt:s.completedAt,assistantMessageId:s.assistantMessageId??null},updatedAt:t.occurredAt}});case`thread.activity-appended`:return oZ(e,t.payload.threadId,e=>{let n=[...e.activities.filter(e=>e.id!==t.payload.activity.id),{...t.payload.activity}].toSorted(OYe).slice(-500);return{...e,activities:n,updatedAt:t.occurredAt}});case`thread.rate-limit-set`:return oZ(e,t.payload.threadId,e=>({...e,rateLimitStatus:_Ye(e.rateLimitStatus??[],t.payload),updatedAt:t.occurredAt}));case`thread.worker-spawned`:return oZ(e,t.payload.workerThreadId,e=>({...e,kind:`worker`,parentThreadId:t.payload.masterThreadId,branch:t.payload.branch,worktreePath:t.payload.worktreePath,workerRole:t.payload.workerRole??e.workerRole??null,updatedAt:t.occurredAt}));case`thread.approval-response-requested`:case`thread.user-input-response-requested`:return e}return e}function HYe(e,t,n){switch(t.kind){case`project-upserted`:{let r=CX(t.project,n),i=e.projectIds.find(n=>n===t.project.id||e.projectById[n]?.cwd===t.project.workspaceRoot)??null,a=e.projectById,o=e.projectIds;if(i!==null&&i!==r.id){let{[i]:t,...n}=e.projectById;a={...n,[r.id]:r},o=e.projectIds.map(e=>e===i?r.id:e)}else a={...e.projectById,[r.id]:r},o=i===null&&!e.projectIds.includes(r.id)?[...e.projectIds,r.id]:e.projectIds;return{...e,projectById:a,projectIds:o}}case`project-removed`:return rZ(e,t.projectId);case`thread-upserted`:return eZ(e,VX(t.thread,n));case`thread-removed`:return nZ(e,t.threadId)}}function UYe(e,t,n){if(t.length===0)return e;let r=sZ(e,n);return cZ(e,n,t.reduce((e,t)=>lZ(e,t,n),r))}function uZ(e){return Object.entries(e.environmentStateById)}function dZ(e,t){return t?sZ(e,t):MX}function WYe(e,t){return ZX(dZ(e,t))}function fZ(e){return uZ(e).flatMap(([,e])=>EYe(e))}function pZ(e){return uZ(e).flatMap(([,e])=>ZX(e))}function GYe(e){return uZ(e).flatMap(([,e])=>mZ(e).flatMap(t=>{let n=e.threadShellById[t];return n?[n]:[]}))}function mZ(e){let t=[],n=new Set,r=e=>{n.has(e)||(n.add(e),t.push(e))};for(let t of e.threadIds)r(t);for(let t of Object.keys(e.threadShellById))r(t);for(let t of Object.keys(e.sidebarThreadSummaryById))r(t);return t}function hZ(e,t,n){let r=t.sidebarThreadSummaryById[n];if(r)return r.environmentId===e?r:{...r,environmentId:e};let i=t.threadShellById[n];return i?{id:i.id,environmentId:e,projectId:i.projectId,title:i.title,modelSelection:i.modelSelection,interactionMode:i.interactionMode,session:t.threadSessionById[n]??null,createdAt:i.createdAt,archivedAt:i.archivedAt,settledAt:i.settledAt,settledOverride:i.settledOverride,updatedAt:i.updatedAt,latestTurn:t.threadTurnStateById[n]?.latestTurn??null,branch:i.branch,worktreePath:i.worktreePath,latestUserMessageAt:null,hasPendingApprovals:!1,hasPendingUserInput:!1,hasActionableProposedPlan:!1,anchorKind:i.anchorKind,anchorCmmdId:i.anchorCmmdId,goal:i.goal,titleRegeneration:i.titleRegeneration,kind:i.kind,parentThreadId:i.parentThreadId,workerRole:i.workerRole,status:i.status}:null}function KYe(e){return uZ(e).flatMap(([e,t])=>mZ(t).flatMap(n=>{let r=hZ(e,t,n);return r?[r]:[]}))}function gZ(e,t){if(!t)return[];let n=dZ(e,t.environmentId),r=n.threadIdsByProjectId[t.projectId]??NX;return(r.length>0?r:mZ(n)).flatMap(e=>{let r=hZ(t.environmentId,n,e);return!r||r.projectId!==t.projectId?[]:[r]})}function qYe(e,t){return t.length===0?[]:t.length===1?gZ(e,t[0]):t.flatMap(t=>gZ(e,t))}function JYe(e){return e.activeEnvironmentId===null?Object.values(e.environmentStateById).some(e=>e.bootstrapComplete):dZ(e,e.activeEnvironmentId).bootstrapComplete}function YYe(e,t){return t?dZ(e,t.environmentId).projectById[t.projectId]:void 0}function _Z(e,t){return t?kX(dZ(e,t.environmentId),t.threadId):void 0}function XYe(e,t){return t?dZ(e,t.environmentId).threadShellById[t.threadId]!==void 0:!1}function vZ(e,t){return t?hZ(t.environmentId,dZ(e,t.environmentId),t.threadId)??void 0:void 0}function ZYe(e,t,n){if(e.activeEnvironmentId===null)return e;let r=oZ(sZ(e,e.activeEnvironmentId),t,e=>e.error===n?e:{...e,error:n});return cZ(e,e.activeEnvironmentId,r)}function QYe(e,t,n){return cZ(e,n,lZ(sZ(e,n),t,n))}function $Ye(e,t,n){return cZ(e,n,HYe(sZ(e,n),t,n))}function eXe(e,t){return e.activeEnvironmentId===t?e:{...e,activeEnvironmentId:t}}function tXe(e,t,n,r){let i=oZ(sZ(e,t.environmentId),t.threadId,e=>{if(e.branch===n&&e.worktreePath===r)return e;let t=e.worktreePath!==r;return{...e,branch:n,worktreePath:r,...t?{session:null}:{}}});return cZ(e,t.environmentId,i)}var yZ=Wt(e=>({...vYe,setActiveEnvironmentId:t=>e(e=>eXe(e,t)),syncServerShellSnapshot:(t,n)=>e(e=>RYe(e,t,n)),syncServerThreadDetail:(t,n)=>e(e=>zYe(e,t,n)),setThreadSubscriptionError:(t,n,r)=>e(e=>BYe(e,t,n,r)),clearThreadSubscriptionError:(t,n)=>e(e=>VYe(e,t,n)),applyOrchestrationEvent:(t,n)=>e(e=>QYe(e,t,n)),applyOrchestrationEvents:(t,n)=>e(e=>UYe(e,t,n)),applyShellEvent:(t,n)=>e(e=>$Ye(e,t,n)),setError:(t,n)=>e(e=>ZYe(e,t,n)),setThreadBranch:(t,n,r)=>e(e=>tXe(e,t,n,r))})),bZ=`Thread not found or you no longer have access.`;function nXe(e){if(e==null)return bZ;let t=SX(ate(e)?Pe(e):e,bZ);return/\bnot found\b/i.test(t)?bZ:t}function rXe(e,t,n){yZ.getState().setThreadSubscriptionError(e,t,nXe(n))}function iXe(e){let t=new Set,n=new Map(e.snapshotThreads.map(e=>[e.key,e]));for(let n of e.snapshotThreads)n.deletedAt===null&&n.archivedAt===null&&t.add(n.key);for(let r of e.draftThreadKeys){let e=n.get(r);e&&(e.deletedAt!==null||e.archivedAt!==null)||t.add(r)}return t}function aXe(e){let t=new Map,n=!1;for(let r of e)switch(r.type){case`thread.turn-diff-completed`:case`thread.reverted`:n=!0;break;case`thread.created`:t.set(r.payload.threadId,{clearPromotedDraft:!0,clearDeletedThread:!1,removeTerminalState:!1});break;case`thread.deleted`:t.set(r.payload.threadId,{clearPromotedDraft:!1,clearDeletedThread:!0,removeTerminalState:!0});break;case`thread.archived`:t.set(r.payload.threadId,{clearPromotedDraft:!1,clearDeletedThread:!1,removeTerminalState:!0});break;case`thread.unarchived`:t.set(r.payload.threadId,{clearPromotedDraft:!1,clearDeletedThread:!1,removeTerminalState:!1})}let r=[],i=[],a=[];for(let[e,n]of t)n.clearPromotedDraft&&r.push(e),n.clearDeletedThread&&i.push(e),n.removeTerminalState&&a.push(e);return{promoteDraftThreadIds:r,clearDeletedThreadIds:i,removeTerminalStateThreadIds:a,needsProviderInvalidation:n}}var xZ={all:[`projects`],searchEntries:(e,t,n,r)=>[`projects`,`search-entries`,e??null,t,n,r]},SZ={all:[`providers`],checkpointDiff:e=>[`providers`,`checkpointDiff`,e.environmentId??null,e.threadId,e.fromTurnCount,e.toTurnCount,e.cacheScope??null]};function oXe(e){if(e!==void 0)return Object.fromEntries(Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t)))}function sXe(e){return{...e,...e.projectIds===void 0?{}:{projectIds:[...e.projectIds].toSorted((e,t)=>e.localeCompare(t))},...e.cursors===void 0?{}:{cursors:oXe(e.cursors)}}}var CZ={all:e=>[`pullRequests`,e],list:(e,t)=>[`pullRequests`,e,`list`,sXe(t)],stats:(e,t)=>[`pullRequests`,e,`stats`,[...t].toSorted((e,t)=>`${e.projectId}:${e.repository}#${e.number}`.localeCompare(`${t.projectId}:${t.repository}#${t.number}`))],detail:(e,t)=>[`pullRequests`,e,`detail`,t],activity:(e,t)=>[`pullRequests`,e,`activity`,t],diff:(e,t)=>[`pullRequests`,e,`diff`,t],threadComments:(e,t)=>[`pullRequests`,e,`thread-comments`,t],diffFileContents:(e,t)=>[`pullRequests`,e,`diff-file-contents`,t],reviewerCandidates:(e,t)=>[`pullRequests`,e,`reviewer-candidates`,t]},cXe=class extends Error{status;constructor(e,t){super(e),this.name=`RemoteEnvironmentAuthHttpError`,this.status=t}};function lXe(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 uXe(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 wZ(e){let t=lXe(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 cXe(await uXe(n,`Remote auth request failed (${n.status}).`),n.status);return await n.json()}async function TZ(e){return wZ({httpBaseUrl:e.httpBaseUrl,pathname:`/api/auth/session`,bearerToken:e.bearerToken,...e.signal?{signal:e.signal}:{}})}async function dXe(e){return wZ({httpBaseUrl:e.httpBaseUrl,pathname:`/.well-known/forge/environment`,...e.bearerToken?{bearerToken:e.bearerToken}:{}})}async function fXe(e){return wZ({httpBaseUrl:e.httpBaseUrl,pathname:`/api/auth/ws-token`,method:`POST`,bearerToken:e.bearerToken})}async function EZ(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 fXe({httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken});return t.searchParams.set(`wsToken`,n.token),t.toString()}function pXe(e,t){if(t){zne(t,e);return}Bne(e)}function mXe(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(`
|
|
1014
|
-
`)}}function
|
|
1012
|
+
`)){let e=/^- (.+):$/.exec(t);if(e){r(),n={header:e[1],bodyLines:[]};continue}if(n){if(t.startsWith(` `)){n.bodyLines.push(t.slice(2));continue}t.length===0&&n.bodyLines.push(``)}}return r(),t}function rJ(e){let t=0;for(let n of e)n===``&&(t+=1);return t}function iJ(e,t){let n=t-rJ(e);return n<=0?e:`${``.repeat(n)}${e}`}function jKe(e){return e===void 0||e===` `||e===`
|
|
1013
|
+
`||e===` `||e===`\r`}function MKe(e,t){let n=Math.max(0,Math.min(e.length,Math.floor(t))),r=`${jKe(e[n-1])?``:` `} `,i=e[n]===` `?n+1:n;return{prompt:`${e.slice(0,n)}${r}${e.slice(i)}`,cursor:n+r.length,contextIndex:rJ(e.slice(0,n))}}function NKe(e){return e.replaceAll(``,``)}function PKe(e,t){if(t<0)return{prompt:e,cursor:e.length};let n=0;for(let r=0;r<e.length;r+=1)if(e[r]===``){if(n===t)return{prompt:e.slice(0,r)+e.slice(r+1),cursor:r};n+=1}return{prompt:e,cursor:e.length}}function aJ(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var oJ=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return oJ(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return oJ(t)(e)}}}},sJ=(e,t)=>(n,r,i)=>{let a={storage:aJ(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,l=new Set,u=a.storage;if(!u)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let d=()=>{let e=a.partialize({...r()});return u.setItem(a.name,{state:e,version:a.version})},f=i.setState;i.setState=(e,t)=>(f(e,t),d());let p=e((...e)=>(n(...e),d()),r,i);i.getInitialState=()=>p;let m,h=()=>{if(!u)return;let e=++s;o=!1,c.forEach(e=>e(r()??p));let t=a.onRehydrateStorage?.call(a,r()??p)||void 0;return oJ(u.getItem.bind(u))(a.name).then(e=>{if(e)if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state];return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(m=a.merge(o,r()??p),n(m,!0),i)return d()}).then(()=>{e===s&&(t?.(r(),void 0),m=r(),o=!0,l.forEach(e=>e(m)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(u=e.storage)},clearStorage:()=>{++s,u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>h(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(l.add(e),()=>{l.delete(e)})},a.skipHydration||h(),m||p},cJ=e=>Symbol.iterator in e,lJ=e=>`entries`in e,uJ=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},FKe=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function IKe(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:cJ(e)&&cJ(t)?lJ(e)&&lJ(t)?uJ(e,t):FKe(e,t):uJ({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function dJ(e){let t=F.useRef(void 0);return n=>{let r=e(n);return IKe(t.current,r)?t.current:t.current=r}}function fJ(){return{executionCount:0,isPending:!1,lastArgs:void 0,lastExecutionTime:0,nextExecutionTime:0,status:`idle`,maybeExecuteCount:0}}var LKe={enabled:!0,leading:!0,trailing:!0,wait:0},RKe=class{#e;constructor(e,t){this.fn=e,this.store=new Ete(fJ()),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`}}),Cte(`Throttler`,this)},this.#n=()=>!!Kt(this.options.enabled,this),this.#r=()=>Kt(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(fJ())},this.key=t.key,this.options={...LKe,...t},this.#t(this.options.initialState??{}),this.key&&Tte.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};function pJ(){let e=new Map;return{getItem:t=>e.get(t)??null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}function zKe(e){return e!=null&&typeof e.getItem==`function`&&typeof e.setItem==`function`&&typeof e.removeItem==`function`}function mJ(e){return zKe(e)?e:pJ()}var hJ=pJ();function gJ(){return globalThis.localStorage||globalThis.window?.localStorage}var _J={getItem:e=>{try{let t=gJ()?.getItem(e);if(t!==void 0)return t}catch{}return hJ.getItem(e)},setItem:(e,t)=>{try{let n=gJ();if(n){n.setItem(e,t);return}}catch{}hJ.setItem(e,t)},removeItem:e=>{try{let t=gJ();if(t){t.removeItem(e);return}}catch{}hJ.removeItem(e)}};function vJ(e){let t=_J.getItem(e);return typeof t==`string`?t:null}function yJ(e,t){_J.setItem(e,t)}function BKe(e){_J.removeItem(e)}function VKe(e,t=300){let n=mJ(e),r=new qt((e,t)=>{n.setItem(e,t)},{wait:t});return{getItem:e=>n.getItem(e),setItem:(e,t)=>{r.maybeExecute(e,t)},removeItem:e=>{r.cancel(),n.removeItem(e)},flush:()=>{r.flush()}}}function bJ(e){let t=e.auth.status!==`unauthenticated`||e.auth.provenance?.credentialScope===`proxied`;return e.enabled&&e.installed&&e.status===`ready`&&t&&e.models.length>0}var xJ={providers:{codex:!0,claude:!1,cmmd:!0},allowedWallets:[`personal`],updatedAt:`1970-01-01T00:00:00.000Z`};function SJ(e){if(e==null)return xJ;let t=e.providers,n=e.allowedWallets;return{providers:{...xJ.providers,...t},allowedWallets:Array.isArray(n)&&n.length>0?n:xJ.allowedWallets,updatedAt:typeof e.updatedAt==`string`?e.updatedAt:xJ.updatedAt}}function HKe(e){switch(e){case`codex`:return`codex`;case`claudeAgent`:return`claude`;case`cmmd`:case`apex`:return`cmmd`;default:return null}}var UKe=[`codex`,`claudeAgent`,`cmmd`];function WKe(e,t){if(t==null)return null;let n=t.providers;if(typeof n!=`object`||!n)return null;let r=n[e];return typeof r==`boolean`?r:null}function CJ(e,t){let n=HKe(e);if(n===null)return{offered:!1,reason:`unknown-provider`};let r=WKe(n,t);return r===!0?{offered:!0}:r===!1?{offered:!1,reason:`org-disabled`}:SJ(t).providers[n]===!0?{offered:!0}:{offered:!1,reason:`policy-unavailable`}}function wJ(e,t){return CJ(e,t).offered}function GKe(e,t){return TJ(e,t).offered}function TJ(e,t){return t===null?{offered:!0}:CJ(e,t)}function EJ(e,t){return SJ(t).allowedWallets.includes(e)}function DJ(e){return EJ(`personal`,e)}function KKe(e){return e===`claudeAgent`||e===`codex`}function qKe(e,t){return e!==`claudeAgent`||DJ(t)||wJ(`claudeAgent`,t)}function JKe(e){return e.isDebugDisclosureEnabled||KKe(e.provider)&&DJ(e.policy)?!1:!wJ(e.provider===`apex`?`apex`:e.provider,e.policy)}var YKe=new Set([`pending`,`claimed`,`activating`]);function XKe(e){let t=e.current.runtimeId===e.runtimeId?e.current:{runtimeId:e.runtimeId,dataUpdatedAt:0,consecutiveUnavailableResponses:0};return e.dataUpdatedAt===0||e.dataUpdatedAt===t.dataUpdatedAt?t:{runtimeId:e.runtimeId,dataUpdatedAt:e.dataUpdatedAt,consecutiveUnavailableResponses:e.readinessUnavailable?t.consecutiveUnavailableResponses+1:0}}function ZKe(e){return!e.claudeOffered||!e.claudeConnected?!1:e.deliveryStatus===null?e.consecutiveUnavailableResponses>0&&e.consecutiveUnavailableResponses<3:YKe.has(e.deliveryStatus)}function OJ(e){return e.credentialMode===`runtime`?e.provider&&bJ(e.provider)?{eligible:!0}:{eligible:!1,reason:`runtime-unavailable`}:e.access.status===`loading`?{eligible:!1,reason:`access-loading`}:e.access.status===`error`?{eligible:!1,reason:`access-error`}:QKe({provider:e.provider,providerKind:e.providerKind,policy:e.access.policy,personalConnections:e.access.personalConnections,personalReconnectRequired:e.access.personalReconnectRequired,claudeRuntimeReadiness:e.access.claudeRuntimeReadiness})}function QKe(e){return!e.provider||!bJ(e.provider)?{eligible:!1,reason:`runtime-unavailable`}:e.policy===null?{eligible:!1,reason:`access-error`}:wJ(e.providerKind,e.policy)?kJ({providerKind:e.providerKind,policy:e.policy,personalConnections:e.personalConnections,personalReconnectRequired:e.personalReconnectRequired,claudeRuntimeReadiness:e.claudeRuntimeReadiness,stage:`live-runtime`}):{eligible:!1,reason:`not-offered`}}function $Ke(e){return e.access.status===`loading`?{eligible:!1,reason:`access-loading`}:e.access.status===`error`||e.access.policy===null?{eligible:!1,reason:`access-error`}:wJ(e.providerKind,e.access.policy)?kJ({providerKind:e.providerKind,policy:e.access.policy,personalConnections:e.access.personalConnections,personalReconnectRequired:e.access.personalReconnectRequired,claudeRuntimeReadiness:e.access.claudeRuntimeReadiness,stage:`provisioning`}):{eligible:!1,reason:`not-offered`}}function kJ(e){return e.providerKind===`cmmd`||e.providerKind===`apex`?{eligible:!0}:e.providerKind!==`codex`&&e.providerKind!==`claudeAgent`?{eligible:!1,reason:`not-offered`}:eqe({providerKind:e.providerKind,personalConnections:e.personalConnections,personalReconnectRequired:e.personalReconnectRequired,claudeRuntimeReadiness:e.claudeRuntimeReadiness,workspaceWalletAllowed:EJ(`workspace`,e.policy),stage:e.stage})}function eqe(e){return tqe(e.workspaceWalletAllowed)?{eligible:!0}:nqe(e.providerKind,e.personalReconnectRequired)?{eligible:!1,reason:`personal-credential-reconnect-required`}:rqe(e.providerKind,e.personalConnections)?oqe(e)?{eligible:!1,reason:`environment-not-running`}:iqe(e)?{eligible:!0}:{eligible:!1,reason:`native-runtime-not-ready`}:{eligible:!1,reason:`personal-credential-required`}}function tqe(e){return e&&!1}function nqe(e,t){return e===`codex`&&t?.codex===!0}function rqe(e,t){return t?.[e]===!0}function iqe(e){return e.providerKind!==`claudeAgent`||e.stage===`provisioning`||sqe(e.claudeRuntimeReadiness)}var aqe=`runtime_unavailable`;function oqe(e){return e.providerKind!==`claudeAgent`||e.stage===`provisioning`?!1:e.claudeRuntimeReadiness?.reason===aqe}function sqe(e){if(!cqe(e))return!1;let t=e.deliveryReceipt?.identity;return t?.kind===`credential_generation`&&t.provider===`claude`&&t.credentialGenerationId===e.generationId}function cqe(e){return e?.connected===!0&&e.deliveryStatus===`applied`&&e.nativeExecutable===!0&&typeof e.generationId==`string`&&e.generationId.trim().length>0}function AJ(e){return e.providers.filter(t=>OJ({provider:t,providerKind:t.provider,access:e.access,credentialMode:e.credentialMode}).eligible)}function lqe(e){if(e.status!==`ready`)return!1;if(e.policy===null)return!0;let t=e.policy.providers,n=EJ(`workspace`,e.policy);return t.cmmd?!0:EJ(`personal`,e.policy)||n?t.codex&&e.personalConnections?.codex===!0||t.claude&&e.personalConnections?.claudeAgent===!0:!1}var uqe={providers:{codex:!1,claude:!1,cmmd:!1},allowedWallets:[`personal`],updatedAt:`1970-01-01T00:00:00.000Z`},jJ=[`cmmd`,`forge-provider-access`],dqe=2e3,fqe=new Set([`not_connected`,`pending`,`claimed`,`activating`,`applied`,`failed`,`stale`]),pqe=[`generationId`,`nativeVerifiedAt`,`reason`,`lastErrorCode`,`lastErrorMessage`],MJ=class extends Error{constructor(e){super(e===`auth`?`Your CMMD session expired. Sign in again to verify Claude runtime readiness.`:`CMMD denied access to verify Claude runtime readiness. Check your organization permissions.`),this.name=`ForgeProviderAccessAuthorityError`}};function mqe(e,t){return!(t instanceof MJ)&&e<3}function hqe(e,t=null){return[...jJ,e,t]}async function gqe(e){e.queryClient.setQueriesData({queryKey:jJ},t=>_qe(t,e.provider,e.connected)),await e.queryClient.invalidateQueries({queryKey:jJ,refetchType:`all`})}function _qe(e,t,n){return e?.status!==`ready`||e.personalConnections===null?e:{...e,personalConnections:{...e.personalConnections,[t]:n},...t===`codex`?{personalReconnectRequired:{codex:!1}}:{},...t===`claudeAgent`?{claudeRuntimeReadiness:null}:{}}}async function NJ(e,t=null){if(e===`runtime`)return{status:`ready`,policy:null,personalConnections:null,providerAccounts:[],claudeRuntimeReadiness:null};let n=iq(),r=Iqe(await n.getOrgProviderPolicy());EJ(`workspace`,r);let[i,a,o,s]=await Promise.all([bqe(()=>n.getProviderAccounts()),FJ({enabled:r.providers.codex,load:()=>n.getUserCodexCredential(),provider:`codex`}),FJ({enabled:r.providers.claude,load:()=>n.getUserClaudeCredential(),provider:`claudeAgent`}),Tqe({enabled:r.providers.claude,runtimeId:t,load:e=>n.getClaudeRuntimeReadiness(e)})]),c=i.accounts.filter(e=>e.provider===`codex`?r.providers.codex:r.providers.claude),l=vqe(c),u=l.codex||a.connected,d=l.claudeAgent||o.connected,f=c.some(e=>e.provider===`codex`&&e.needsReconnect)||a.reconnectRequired;return{status:`ready`,policy:r,personalConnections:{codex:u,claudeAgent:d},providerAccounts:c,...f?{personalReconnectRequired:{codex:!0}}:{},claudeRuntimeReadiness:s}}function vqe(e){return{codex:e.some(e=>e.provider===`codex`&&!e.needsReconnect),claudeAgent:e.some(e=>e.provider===`claudeAgent`&&!e.needsReconnect)}}function yqe(e,t){if(e.status!==`ready`)return;let n=e.providerAccounts??[];return(n.find(e=>e.provider===t&&e.isDefault&&!e.needsReconnect)??n.find(e=>e.provider===t&&!e.needsReconnect))?.providerAccountId}async function bqe(e){try{return xqe(await e())}catch{return{accounts:[]}}}function xqe(e){if(!IJ(e)||!Array.isArray(e.accounts))throw Error(`CMMD returned invalid provider accounts.`);return{accounts:e.accounts.filter(Sqe)}}function Sqe(e){return IJ(e)?Cqe(e.provider)&&wqe(e.providerAccountId)&&PJ(e.accountEmail)&&(e.accountDisplayName===void 0||PJ(e.accountDisplayName))&&PJ(e.planType)&&typeof e.isDefault==`boolean`&&typeof e.needsReconnect==`boolean`:!1}function Cqe(e){return e===`codex`||e===`claudeAgent`}function wqe(e){return typeof e==`string`&&e.trim().length>0}function PJ(e){return typeof e==`string`||e===null}async function Tqe(e){if(!e.enabled||e.runtimeId===null)return null;try{return Oqe(await e.load(e.runtimeId),e.runtimeId)}catch(e){if(e instanceof fr&&(e.kind===`auth`||e.kind===`permission`))throw new MJ(e.kind);return null}}async function FJ(e){if(!e.enabled)return{connected:!1,reconnectRequired:!1};try{return zqe(await e.load(),e.provider)}catch{return{connected:!1,reconnectRequired:!1}}}function Eqe(e){let t=e?.policy?.providers.claude===!0,n=e?.personalConnections?.claudeAgent===!0;return{claudeOffered:t,claudeConnected:n,deliveryStatus:e?.claudeRuntimeReadiness?.deliveryStatus??null,readinessUnavailable:t&&n&&e?.claudeRuntimeReadiness===null}}function Dqe(e){let t=(0,Cl.c)(18),n=e.runtimeId??null,r;t[0]===n?r=t[1]:(r={runtimeId:n,dataUpdatedAt:0,consecutiveUnavailableResponses:0},t[0]=n,t[1]=r);let i=(0,F.useRef)(r),a;t[2]!==e.credentialMode||t[3]!==n?(a=hqe(e.credentialMode,n),t[2]=e.credentialMode,t[3]=n,t[4]=a):a=t[4];let o;t[5]===n?o=t[6]:(o=()=>NJ(`cmmd-cloud`,n),t[5]=n,t[6]=o);let s=e.enabled&&e.credentialMode===`cmmd-cloud`,c;t[7]===n?c=t[8]:(c=e=>{if(e.state.error instanceof MJ)return!1;let t=Eqe(e.state.data);return i.current=XKe({current:i.current,runtimeId:n,dataUpdatedAt:e.state.dataUpdatedAt,readinessUnavailable:n!==null&&t.readinessUnavailable}),n!==null&&ZKe({claudeOffered:t.claudeOffered,claudeConnected:t.claudeConnected,deliveryStatus:t.deliveryStatus,consecutiveUnavailableResponses:i.current.consecutiveUnavailableResponses})?dqe:!1},t[7]=n,t[8]=c);let l;t[9]!==a||t[10]!==o||t[11]!==s||t[12]!==c?(l={queryKey:a,queryFn:o,enabled:s,retry:mqe,staleTime:3e4,refetchInterval:c},t[9]=a,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13];let u=Di(l);if(!e.enabled){let e;return t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e={status:`loading`},t[14]=e):e=t[14],e}if(e.credentialMode===`runtime`){let e;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e={status:`ready`,policy:null,personalConnections:null,providerAccounts:[],claudeRuntimeReadiness:null},t[15]=e):e=t[15],e}if(u.isPending){let e;return t[16]===Symbol.for(`react.memo_cache_sentinel`)?(e={status:`loading`},t[16]=e):e=t[16],e}if(u.isError||!u.data){let e;return t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e={status:`error`},t[17]=e):e=t[17],e}return u.data}function Oqe(e,t){if(!IJ(e)||!Pqe(e)||!kqe(e,t))throw Error(`CMMD returned invalid Claude runtime readiness.`);return e}function kqe(e,t){if(e.deliveryReceipt===null)return e.deliveryStatus!==`applied`||e.nativeExecutable!==!0;if(!IJ(e.deliveryReceipt))return!1;let n=e.deliveryReceipt,r=IJ(n.identity)?n.identity:null;return r!==null&&Aqe(n,t)&&Nqe(r,e.generationId)}function Aqe(e,t){return jqe(e,t)&&Mqe(e)}function jqe(e,t){return typeof e.receiptId==`string`&&e.receiptId.trim().length>0&&e.runtimeId===t&&typeof e.machineId==`string`&&e.machineId.trim().length>0&&typeof e.credentialEpoch==`number`&&Number.isSafeInteger(e.credentialEpoch)&&e.credentialEpoch>=0}function Mqe(e){return typeof e.issuedAt==`string`&&Number.isFinite(Date.parse(e.issuedAt))&&e.expiresAt===null}function Nqe(e,t){return e.kind===`credential_generation`&&e.provider===`claude`&&typeof e.credentialGenerationId==`string`&&e.credentialGenerationId===t}function Pqe(e){return typeof e.connected==`boolean`&&fqe.has(String(e.deliveryStatus))&&typeof e.nativeExecutable==`boolean`&&pqe.every(t=>Fqe(e[t]))}function Fqe(e){return e===null||typeof e==`string`}function Iqe(e){if(!IJ(e)||!IJ(e.providers))throw Error(`CMMD returned an invalid organization provider policy.`);let{providers:t,allowedWallets:n,updatedAt:r}=e,i=Rqe(n,r);if(!Lqe(t)||i===null)throw Error(`CMMD returned an invalid organization provider policy.`);return{providers:{codex:t.codex,claude:t.claude,cmmd:t.cmmd},allowedWallets:[...new Set(i.allowedWallets)],updatedAt:i.updatedAt}}function Lqe(e){return typeof e.codex==`boolean`&&typeof e.claude==`boolean`&&typeof e.cmmd==`boolean`}function Rqe(e,t){return Array.isArray(e)&&e.length>0&&e.every(Bqe)&&typeof t==`string`&&t.trim().length>0?{allowedWallets:e,updatedAt:t}:null}function zqe(e,t){if(!IJ(e)||typeof e.connected!=`boolean`)throw Error(`CMMD returned an invalid ${t} connection state.`);if(!e.connected)return{connected:!1,reconnectRequired:!1};if(t===`codex`){if(typeof e.needsReconnect!=`boolean`)throw Error(`CMMD returned an invalid Codex connection state.`);return{connected:!e.needsReconnect,reconnectRequired:e.needsReconnect}}if(typeof e.generationId!=`string`||e.generationId.trim().length===0)throw Error(`CMMD returned an invalid Claude connection state.`);return{connected:!0,reconnectRequired:!1}}function Bqe(e){return e===`personal`||e===`workspace`}function IJ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Vqe(e){return e.status===`ready`?e.policy:uqe}var Hqe={reasoningEffortLevels:[],supportsFastMode:!1,supportsThinkingToggle:!1,contextWindowOptions:[],promptInjectedEffortLevels:[]},LJ=[`codex`,`claudeAgent`,`apex`];function RJ(e){for(let t of LJ){let n=e.find(e=>e.provider===t);if(n&&BJ(n))return t}return e.find(BJ)?.provider??null}function zJ(e,t){return e.find(e=>e.provider===t)?.models??[]}function BJ(e){return bJ(e)}function VJ(e,t){let n=t??RJ(e)??`codex`,r=e.find(e=>e.provider===n);if(r&&BJ(r)||n===`codex`)return n;for(let t of LJ){let n=e.find(e=>e.provider===t);if(n&&BJ(n))return t}return`codex`}function HJ(e,t,n,r){let i=AJ({providers:e,access:n,credentialMode:r});return t&&i.some(e=>e.provider===t)?t:RJ(i)}function Uqe(e,t,n,r){return t==null?HJ(e,null,n,r):AJ({providers:e,access:n,credentialMode:r}).some(e=>e.provider===t)?t:null}function UJ(e,t,n){let r=Vq(t,n);return e.find(e=>e.slug===r)?.capabilities??Hqe}function WJ(e,t,n){let r=zJ(e,t).filter(e=>!e.isLegacy);return r.find(e=>e.slug===n)?.slug??r.find(e=>e.isDefault)?.slug??r.find(e=>e.slug===Vn[t])?.slug??r.find(e=>!e.isCustom)?.slug??r[0]?.slug??Vn[t]}function GJ(e){let{provider:t,model:n,models:r,prompt:i,modelOptions:a}=e,o=UJ(r,n,t),s=a?.[t],c=Lq(o,s?`effort`in s?s.effort:`reasoningEffort`in s?s.reasoningEffort:null:null)??null,l=t===`codex`?oKe(o,s):sKe(o,s),u=o.promptInjectedEffortLevels.length>0&&Bq(i);return{provider:t,promptEffort:c,modelOptionsForDispatch:l,...u?{composerFrameClassName:`ultrathink-frame`}:{},...u?{composerSurfaceClassName:`shadow-[0_0_0_1px_rgba(255,255,255,0.04)_inset]`}:{},...u?{modelPickerIconClassName:`ultrathink-chroma`}:{}}}function KJ(e,t,n,r){return zJ(t,n).map(({slug:e,name:t,isCustom:n,isDefault:r,isLegacy:i})=>({slug:e,name:t,isCustom:n,isDefault:r,isLegacy:i}))}function qJ(e,t,n,r,i){let a=Hq(e,r,KJ(t,n,e,r));if(a&&!Uq(a,e))return a;let o=JJ(n,e,i),s=Hq(o,r,KJ(t,n,o,r))??WJ(n,o);return e&&Uq(s,e)?WJ(n,e):s}function JJ(e,t,n){return!t||!wJ(t,n)?VJ(e,`codex`):VJ(e,t)}function Wqe(e,t,n,r){return{codex:KJ(e,t,`codex`,n===`codex`?r:void 0),claudeAgent:KJ(e,t,`claudeAgent`,n===`claudeAgent`?r:void 0),ollama:KJ(e,t,`ollama`,n===`ollama`?r:void 0),cmmd:KJ(e,t,`cmmd`,n===`cmmd`?r:void 0),apex:KJ(e,t,`apex`,n===`apex`?r:void 0),cursor:KJ(e,t,`cursor`,n===`cursor`?r:void 0),opencode:KJ(e,t,`opencode`,n===`opencode`?r:void 0)}}function Gqe(e,t,n){let r=e.textGenerationModelSelection??{provider:`codex`,model:yne.codex},i=JJ(t,r.provider,n),a=qJ(i,e,t,i===r.provider?r.model:null,n),{modelOptionsForDispatch:o}=GJ({provider:i,model:a,models:zJ(t,i),prompt:``,modelOptions:{[i]:i===r.provider?r.options:void 0}});return{provider:i,model:a,...o?{options:o}:{}}}function YJ(e){return e?.options?{[e.provider]:e.options}:null}function Kqe(e){if(!e)return null;let t={};for(let[n,r]of Object.entries(e))r?.options&&(t[n]=r.options);return Object.keys(t).length>0?t:null}function qqe(e){if(e.activeSelection&&`providerAccountId`in e.activeSelection)return e.activeSelection.providerAccountId;for(let t of e.candidates)if(t?.provider===e.selectedProvider&&`providerAccountId`in t)return t.providerAccountId}function Jqe(e){let t=t=>t!==void 0&&Uq(t,e.selectedProvider)?void 0:t,n=t(e.threadModelSelection?.provider===e.selectedProvider?e.threadModelSelection.model:void 0),r=t(e.projectModelSelection?.provider===e.selectedProvider?e.projectModelSelection.model:void 0),i=Vq(n??r,e.selectedProvider)??WJ(e.providers,e.selectedProvider),a=e.draft?.modelSelectionByProvider?.[e.selectedProvider],o=qqe({activeSelection:a,selectedProvider:e.selectedProvider,candidates:[e.threadModelSelection,e.projectModelSelection]}),s=t(a?.model),c=s?qJ(e.selectedProvider,e.settings,e.providers,s):i,l=Kqe(e.draft?.modelSelectionByProvider)??YJ(e.threadModelSelection)??YJ(e.projectModelSelection)??null;return{selectedModel:c,...o?{selectedProviderAccountId:o}:{},modelOptions:l}}var XJ=`forge:composer-drafts:v1`,ZJ=5,Yqe=kn([`local`,`worktree`]),QJ=Hte(Sn),$J=VKe(typeof localStorage<`u`?localStorage:pJ(),300);typeof window<`u`&&typeof window.addEventListener==`function`&&window.addEventListener(`beforeunload`,()=>{$J.flush()});var eY=zn({id:Un,name:Un,mimeType:Un,sizeBytes:An,dataUrl:Un}),tY=zn({id:Un,threadId:nn,createdAt:Un,terminalId:Un,terminalLabel:Un,lineStart:An,lineEnd:An}),Xqe=zn({prompt:Un,attachments:Bn(eY),terminalContexts:Bn(tY),startedAt:Un}),Zqe=zn({prompt:Un,lastGeneratedPullRequestPrompt:Ln(Un),attachments:Bn(eY),terminalContexts:Ln(Bn(tY)),modelSelectionByProvider:Ln(Mn(Cn,Ln(bn))),activeProvider:Ln(Xn(Cn)),runtimeMode:Ln(Sn),interactionMode:Ln(ln),stagedSubmission:Ln(Xqe)});zn({effort:Ln(kn(jn)),codexFastMode:Ln(Kn),serviceTier:Ln(Un)}),zn({provider:Ln(Cn),model:Ln(Un),modelOptions:Ln(Xn(Jn))}),zn({stickyProvider:Ln(Cn),stickyModel:Ln(Un),stickyModelOptions:Ln(Xn(Jn))});var Qqe=zn({threadId:nn,environmentId:Un,projectId:an,logicalProjectKey:Ln(Un),createdAt:Un,runtimeMode:Sn,interactionMode:ln,branch:Xn(Un),worktreePath:Xn(Un),envMode:Yqe,promotedTo:Ln(Xn(zn({environmentId:Un,threadId:Un}))),anchorKind:Ln(Rte),anchorCmmdId:Ln(Xn(Un)),linkedPullRequest:Ln(Xn(kte))}),$qe=zn({draftsByThreadKey:Mn(Un,Zqe),draftThreadsByThreadKey:Mn(Un,Qqe),logicalProjectDraftThreadKeyByLogicalProjectKey:Mn(Un,Un),stickyModelSelectionByProvider:Ln(Mn(Cn,Ln(bn))),stickyActiveProvider:Ln(Xn(Cn))}),eJe=zn({version:An,state:$qe}),nY=Object.freeze({draftsByThreadKey:{},draftThreadsByThreadKey:{},logicalProjectDraftThreadKeyByLogicalProjectKey:{},stickyModelSelectionByProvider:{},stickyActiveProvider:null}),rY=[],iY=[],aY=[],tJe=[];Object.freeze(rY),Object.freeze(iY),Object.freeze(aY);var oY=Object.freeze({}),nJe=Object.freeze({activeProvider:null,modelSelectionByProvider:oY}),rJe=Object.freeze({prompt:``,images:rY,nonPersistedImageIds:iY,persistedAttachments:aY,terminalContexts:tJe,modelSelectionByProvider:oY,activeProvider:null,runtimeMode:null,interactionMode:null,stagedSubmission:null});function sY(){return{prompt:``,images:[],nonPersistedImageIds:[],persistedAttachments:[],terminalContexts:[],modelSelectionByProvider:{},activeProvider:null,runtimeMode:null,interactionMode:null,stagedSubmission:null}}function cY(e){return`${e.mimeType}\u0000${e.sizeBytes}\u0000${e.name}`}function lY(e){return`${e.terminalId}\u0000${e.lineStart}\u0000${e.lineEnd}`}function uY(e,t){let n=t.terminalId.trim(),r=t.terminalLabel.trim();if(n.length===0||r.length===0)return null;let i=Math.max(1,Math.floor(t.lineStart)),a=Math.max(i,Math.floor(t.lineEnd));return{...t,threadId:e,terminalId:n,terminalLabel:r,lineStart:i,lineEnd:a,text:$q(t.text)}}function dY(e,t){let n=new Set,r=new Set,i=[];for(let a of t){let t=uY(e,a);if(!t)continue;let o=lY(t);n.has(t.id)||r.has(o)||(i.push(t),n.add(t.id),r.add(o))}return i}function fY(e){return e.prompt.length===0&&e.lastGeneratedPullRequestPrompt===void 0&&e.images.length===0&&e.persistedAttachments.length===0&&e.terminalContexts.length===0&&Object.keys(e.modelSelectionByProvider).length===0&&e.activeProvider===null&&e.runtimeMode===null&&e.interactionMode===null&&e.stagedSubmission==null}function pY(e){switch(e){case`codex`:case`claudeAgent`:case`ollama`:case`cmmd`:case`apex`:case`cursor`:case`opencode`:return e;default:return null}}function mY(e){return jn.some(t=>t===e)}function iJe(e){return Gte.some(t=>t===e)}function hY(e,t,n){let r=e&&typeof e==`object`?e:null,i=r?.codex&&typeof r.codex==`object`?r.codex:null,a=r?.claudeAgent&&typeof r.claudeAgent==`object`?r.claudeAgent:null,o=mY(i?.reasoningEffort)?i.reasoningEffort:t===`codex`&&mY(n?.effort)?n.effort:void 0,s=i?.fastMode===!0?!0:i?.fastMode===!1?!1:t===`codex`&&n?.codexFastMode===!0||typeof n?.serviceTier==`string`&&n.serviceTier===`fast`||void 0,c=o!==void 0||s!==void 0?{...o===void 0?{}:{reasoningEffort:o},...s===void 0?{}:{fastMode:s}}:void 0,l=a?.thinking===!0||a?.thinking!==!1&&void 0,u=iJe(a?.effort)?a.effort:void 0,d=a?.fastMode===!0||a?.fastMode!==!1&&void 0,f=typeof a?.contextWindow==`string`&&a.contextWindow.length>0?a.contextWindow:void 0,p=l!==void 0||u!==void 0||d!==void 0||f!==void 0?{...l===void 0?{}:{thinking:l},...u===void 0?{}:{effort:u},...d===void 0?{}:{fastMode:d},...f===void 0?{}:{contextWindow:f}}:void 0;return!c&&!p?null:{...c?{codex:c}:{},...p?{claudeAgent:p}:{}}}function gY(e,t){let n=e&&typeof e==`object`?e:null,r=pY(n?.provider??t?.provider);if(r===null)return null;let i=n?.model??t?.model;if(typeof i!=`string`)return null;let a=Vq(i,r);if(!a)return null;let o=hY(n?.options?{[r]:n.options}:t?.modelOptions,r,r===`codex`?t?.legacyCodex:void 0),s=r===`codex`?o?.codex:o?.claudeAgent,c=n?.providerAccountId,l=typeof c==`string`&&c.trim().length>0?c.trim():void 0;return{provider:r,model:a,...l?{providerAccountId:l}:{},...s?{options:s}:{}}}function _Y(e,t){if(e===null)return null;let n=t?.[e.provider];return{provider:e.provider,model:e.model,...`providerAccountId`in e&&e.providerAccountId?{providerAccountId:e.providerAccountId}:{},...n?{options:n}:{}}}function vY(e,t){return e?.options===void 0?hY(t):aJe(hY(t),e.provider,e.options)}function aJe(e,t,n){let{[t]:r,...i}=e??{},a=hY({[t]:n},t);return hY({...i,...a||{}})}function yY(e,t){let n={};if(t)for(let r of[`codex`,`claudeAgent`]){let i=t[r];i&&Object.keys(i).length>0&&(n[r]={provider:r,model:e?.provider===r?e.model:Vn[r],options:i})}return e&&(n[e.provider]=e),n}function bY(e){typeof URL>`u`||e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}function xY(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.id,r=t.name,i=t.mimeType,a=t.sizeBytes,o=t.dataUrl;return typeof n!=`string`||typeof r!=`string`||typeof i!=`string`||typeof a!=`number`||!Number.isFinite(a)||typeof o!=`string`||n.length===0||o.length===0?null:{id:n,name:r,mimeType:i,sizeBytes:a,dataUrl:o}}function SY(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.id,r=t.threadId,i=t.createdAt,a=t.lineStart,o=t.lineEnd;if(typeof n!=`string`||n.length===0||typeof r!=`string`||r.length===0||typeof i!=`string`||i.length===0||typeof a!=`number`||!Number.isFinite(a)||typeof o!=`number`||!Number.isFinite(o))return null;let s=typeof t.terminalId==`string`?t.terminalId.trim():``,c=typeof t.terminalLabel==`string`?t.terminalLabel.trim():``;if(s.length===0||c.length===0)return null;let l=Math.max(1,Math.floor(a));return{id:n,threadId:r,createdAt:i,terminalId:s,terminalLabel:c,lineStart:l,lineEnd:Math.max(l,Math.floor(o))}}function oJe(e,t){return e===`local`||e===`worktree`?e:t?`worktree`:`local`}function CY(e){return Bo(e)}function wY(e){return e.trim()}function TY(e){return typeof e==`string`?e.trim():Vo(e)}function EY(e,t){let n=Wo(e);return n?TY(n):t?.environmentId?TY(Lo(t.environmentId,e)):e}function sJe(e){return Wo(e)}function DY(e,t){if(typeof t==`string`){let e=t.trim();return e.length>0?Ut.make(e):null}return t}function OY(e,t){let n=DY(e,t);if(!n)return null;if(typeof n!=`string`){let t=TY(n);if(e.draftsByThreadKey[t])return t;for(let[t,r]of Object.entries(e.draftThreadsByThreadKey))if(r.environmentId===n.environmentId&&r.threadId===n.threadId)return t;return t}let r=TY(n);return r.length>0?r:null}function kY(e,t){let n=DY(e,t);return n?typeof n==`string`?e.draftThreadsByThreadKey[n]?.threadId??null:n.threadId:null}function AY(e,t){let n=OY(e,t);return n?e.draftsByThreadKey[n]??null:null}function cJe(e,t){return Object.values(e).includes(t)}function jY(e,t){return{draftId:e,...t}}function lJe(e,t,n,r,i){let a=r!==void 0&&(r.environmentId!==e.environmentId||r.projectId!==e.projectId),o=i?.worktreePath===void 0?a?null:r?.worktreePath??null:i.worktreePath??null,s=i?.branch===void 0?a?null:r?.branch??null:i.branch??null,c=i?.anchorKind===void 0?r?.anchorKind:i.anchorKind??void 0;return{threadId:t,environmentId:e.environmentId,projectId:e.projectId,logicalProjectKey:n,createdAt:i?.createdAt??r?.createdAt??new Date().toISOString(),runtimeMode:i?.runtimeMode??r?.runtimeMode??`full-access`,interactionMode:i?.interactionMode??r?.interactionMode??`default`,branch:s,worktreePath:o,envMode:i?.envMode??(o?`worktree`:a?`local`:r?.envMode??`local`),promotedTo:null,cmmdTaskId:i?.cmmdTaskId===void 0?r?.cmmdTaskId??null:i.cmmdTaskId,anchorCmmdId:i?.anchorCmmdId===void 0?r?.anchorCmmdId??null:i.anchorCmmdId,linkedPullRequest:i?.linkedPullRequest===void 0?r?.linkedPullRequest??null:i.linkedPullRequest,...c===void 0?{}:{anchorKind:c}}}function MY(e,t){return!e||!t?e===t:e.environmentId===t.environmentId&&e.threadId===t.threadId}function NY(e){return e?.promotedTo!==null&&e?.promotedTo!==void 0}function uJe(e,t){return!!e&&e.threadId===t.threadId&&e.environmentId===t.environmentId&&e.projectId===t.projectId&&e.logicalProjectKey===t.logicalProjectKey&&e.createdAt===t.createdAt&&e.runtimeMode===t.runtimeMode&&e.interactionMode===t.interactionMode&&e.branch===t.branch&&e.worktreePath===t.worktreePath&&e.envMode===t.envMode&&(e.anchorKind??void 0)===(t.anchorKind??void 0)&&(e.anchorCmmdId??null)===(t.anchorCmmdId??null)&&PY(e.linkedPullRequest,t.linkedPullRequest)&&MY(e.promotedTo,t.promotedTo)}function PY(e,t){return(e?.projectId??null)===(t?.projectId??null)&&(e?.projectRepositoryId??null)===(t?.projectRepositoryId??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.host??null)===(t?.host??null)&&(e?.repository??null)===(t?.repository??null)&&(e?.number??null)===(t?.number??null)&&(e?.url??null)===(t?.url??null)}function FY(e,t){let n=Object.fromEntries(Object.entries(e.logicalProjectDraftThreadKeyByLogicalProjectKey).filter(([,e])=>e!==t)),{[t]:r,...i}=e.draftThreadsByThreadKey,{[t]:a,...o}=e.draftsByThreadKey;return{draftsByThreadKey:o,draftThreadsByThreadKey:i,logicalProjectDraftThreadKeyByLogicalProjectKey:n}}function IY(e,t){let n={},r=new Map;if(t&&typeof t==`object`)for(let[e,n]of Object.entries(t)){if(typeof n!=`string`||n.length===0)continue;let t=Uo(e);if(!t)continue;let i=Wo(n);if(i){r.set(i.threadId,i.environmentId);continue}r.set(n,t.environmentId)}if(e&&typeof e==`object`)for(let[t,i]of Object.entries(e)){if(typeof t!=`string`||t.length===0||!i||typeof i!=`object`)continue;let e=i,a=Wo(t),o=EY(t),s=a?.threadId??(typeof e.threadId==`string`&&e.threadId.length>0?e.threadId:t),c=a?.environmentId??(typeof e.environmentId==`string`&&e.environmentId.length>0?e.environmentId:r.get(t)),l=e.projectId,u=e.createdAt,d=e.branch,f=e.worktreePath,p=typeof f==`string`?f:null,m=e.promotedTo,h=m&&typeof m==`object`?m:null,g=h&&typeof h.environmentId==`string`&&h.environmentId.length>0&&typeof h.threadId==`string`&&h.threadId.length>0?Lo(h.environmentId,h.threadId):null;if(typeof l!=`string`||l.length===0||c===void 0)continue;let _=c;n[o]={threadId:s,environmentId:_,projectId:l,logicalProjectKey:typeof e.logicalProjectKey==`string`&&e.logicalProjectKey.length>0?e.logicalProjectKey:a?CY(Io(_,l)):t,createdAt:typeof u==`string`&&u.length>0?u:new Date().toISOString(),runtimeMode:QJ(e.runtimeMode)?e.runtimeMode:Xq,interactionMode:e.interactionMode===`plan`||e.interactionMode==="default"?e.interactionMode:Zq,branch:typeof d==`string`?d:null,worktreePath:p,envMode:oJe(e.envMode,p),promotedTo:g}}let i={};if(t&&typeof t==`object`)for(let[e,a]of Object.entries(t)){if(typeof a!=`string`||a.length===0)continue;let t=Uo(e),o=Wo(a),s=EY(a);if(i[e]=s,o&&r.set(o.threadId,o.environmentId),!t){let t=n[s];t&&!t.logicalProjectKey&&(n[s]={...t,logicalProjectKey:e});continue}n[s]?(n[s]?.projectId!==t.projectId||n[s]?.environmentId!==t.environmentId)&&(n[s]={...n[s],threadId:n[s].threadId,environmentId:t.environmentId,projectId:t.projectId,logicalProjectKey:e}):n[s]={threadId:o?.threadId??s,environmentId:t.environmentId,projectId:t.projectId,logicalProjectKey:e,createdAt:new Date().toISOString(),runtimeMode:Xq,interactionMode:Zq,branch:null,worktreePath:null,envMode:`local`,promotedTo:null}}return{draftThreadsByThreadKey:n,logicalProjectDraftThreadKeyByLogicalProjectKey:i}}function LY(e,t){if(!e||typeof e!=`object`)return{};let n=new Map;for(let[e,r]of Object.entries(t)){let t=sJe(e);t&&n.set(t.threadId,r.environmentId)}let r={};for(let[i,a]of Object.entries(e)){if(typeof i!=`string`||i.length===0||!a||typeof a!=`object`)continue;let e=a,o=typeof e.prompt==`string`?e.prompt:``,s=typeof e.lastGeneratedPullRequestPrompt==`string`?e.lastGeneratedPullRequestPrompt:void 0,c=Array.isArray(e.attachments)?e.attachments.flatMap(e=>{let t=xY(e);return t?[t]:[]}):[],l=Array.isArray(e.terminalContexts)?e.terminalContexts.flatMap(e=>{let t=SY(e);return t?[t]:[]}):[],u=QJ(e.runtimeMode)?e.runtimeMode:null,d=e.interactionMode===`plan`||e.interactionMode==="default"?e.interactionMode:null,f=dJe(e.stagedSubmission),p=iJ(o,l.length),m=a,h={},g=null;if(e.modelSelectionByProvider&&typeof e.modelSelectionByProvider==`object`)h=e.modelSelectionByProvider,g=pY(e.activeProvider);else{let e=hY(m.modelOptions,void 0,m)??null,t=gY(m.modelSelection,{provider:m.provider,model:m.model,modelOptions:e??m.modelOptions,legacyCodex:m}),n=vY(t,e),r=_Y(t,n);h=yY(r,n),g=r?.provider??null}let _=Object.keys(h).length>0||g!==null;if(o.length===0&&c.length===0&&l.length===0&&!_&&!u&&!d&&!f)continue;let v=Wo(i)===null?t[i]===void 0?(()=>{let e=n.get(i);return e?EY(i,{environmentId:e}):i})():i:EY(i);r[v]={prompt:p,...s===void 0?{}:{lastGeneratedPullRequestPrompt:s},attachments:c,...l.length>0?{terminalContexts:l}:{},..._?{modelSelectionByProvider:h,activeProvider:g}:{},...u?{runtimeMode:u}:{},...d?{interactionMode:d}:{},...f?{stagedSubmission:f}:{}}}return r}function dJe(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.prompt!=`string`||typeof t.startedAt!=`string`)return null;let n=Array.isArray(t.attachments)?t.attachments.flatMap(e=>{let t=xY(e);return t?[t]:[]}):[],r=Array.isArray(t.terminalContexts)?t.terminalContexts.flatMap(e=>{let t=SY(e);return t?[t]:[]}):[];return{prompt:t.prompt,attachments:n,terminalContexts:r,startedAt:t.startedAt}}function fJe(e){if(!e||typeof e!=`object`)return nY;let t=e,n=t.draftsByThreadKey??t.draftsByThreadId,r=t.draftThreadsByThreadKey??t.draftThreadsByThreadId,i=t.logicalProjectDraftThreadKeyByLogicalProjectKey??t.projectDraftThreadKeyByProjectKey??t.projectDraftThreadIdByProjectKey??t.projectDraftThreadIdByProjectId,a=hY(t.stickyModelOptions)??{},o=gY(t.stickyModelSelection,{provider:t.stickyProvider??`codex`,model:t.stickyModel,modelOptions:a}),s=vY(o,a),c=yY(_Y(o,s),s),l=pY(t.stickyProvider)??null,{draftThreadsByThreadKey:u,logicalProjectDraftThreadKeyByLogicalProjectKey:d}=IY(r,i);return{draftsByThreadKey:LY(n,u),draftThreadsByThreadKey:u,logicalProjectDraftThreadKeyByLogicalProjectKey:d,stickyModelSelectionByProvider:c,stickyActiveProvider:l}}function pJe(e){let t={};for(let[n,r]of Object.entries(e.draftsByThreadKey)){if(typeof n!=`string`||n.length===0)continue;let e=Object.keys(r.modelSelectionByProvider).length>0||r.activeProvider!==null;r.prompt.length===0&&r.lastGeneratedPullRequestPrompt===void 0&&r.persistedAttachments.length===0&&r.terminalContexts.length===0&&!e&&r.runtimeMode===null&&r.interactionMode===null&&r.stagedSubmission==null||(t[n]={prompt:r.prompt,...r.lastGeneratedPullRequestPrompt===void 0?{}:{lastGeneratedPullRequestPrompt:r.lastGeneratedPullRequestPrompt},attachments:r.persistedAttachments,...r.terminalContexts.length>0?{terminalContexts:r.terminalContexts.map(e=>({id:e.id,threadId:e.threadId,createdAt:e.createdAt,terminalId:e.terminalId,terminalLabel:e.terminalLabel,lineStart:e.lineStart,lineEnd:e.lineEnd}))}:{},...e?{modelSelectionByProvider:r.modelSelectionByProvider,activeProvider:r.activeProvider}:{},...r.runtimeMode?{runtimeMode:r.runtimeMode}:{},...r.interactionMode?{interactionMode:r.interactionMode}:{},...r.stagedSubmission?{stagedSubmission:{prompt:r.stagedSubmission.prompt,attachments:[...r.stagedSubmission.attachments],terminalContexts:r.stagedSubmission.terminalContexts.map(e=>({id:e.id,threadId:e.threadId,createdAt:e.createdAt,terminalId:e.terminalId,terminalLabel:e.terminalLabel,lineStart:e.lineStart,lineEnd:e.lineEnd})),startedAt:r.stagedSubmission.startedAt}}:{}})}return{draftsByThreadKey:t,draftThreadsByThreadKey:e.draftThreadsByThreadKey,logicalProjectDraftThreadKeyByLogicalProjectKey:e.logicalProjectDraftThreadKeyByLogicalProjectKey,stickyModelSelectionByProvider:e.stickyModelSelectionByProvider,stickyActiveProvider:e.stickyActiveProvider}}function mJe(e){if(!e||typeof e!=`object`)return nY;let t=e,{draftThreadsByThreadKey:n,logicalProjectDraftThreadKeyByLogicalProjectKey:r}=IY(t.draftThreadsByThreadKey??t.draftThreadsByThreadId,t.logicalProjectDraftThreadKeyByLogicalProjectKey??t.projectDraftThreadKeyByProjectKey??t.projectDraftThreadIdByProjectKey??t.projectDraftThreadIdByProjectId),i={},a=null;if(t.stickyModelSelectionByProvider&&typeof t.stickyModelSelectionByProvider==`object`)i=t.stickyModelSelectionByProvider,a=pY(t.stickyActiveProvider);else{let e=hY(t.stickyModelOptions)??{},n=gY(t.stickyModelSelection,{provider:t.stickyProvider,model:t.stickyModel,modelOptions:e}),r=vY(n,e);i=yY(_Y(n,r),r),a=pY(t.stickyProvider)}return{draftsByThreadKey:LY(t.draftsByThreadKey??t.draftsByThreadId,n),draftThreadsByThreadKey:n,logicalProjectDraftThreadKeyByLogicalProjectKey:r,stickyModelSelectionByProvider:i,stickyActiveProvider:a}}function hJe(e){if(e.length===0)return[];try{let t=Kq(XJ,eJe);return!t||t.version!==ZJ?[]:(t.state.draftsByThreadKey[e]?.attachments??[]).map(e=>e.id)}catch{return[]}}function gJe(e,t,n){let r=new Set;try{$J.flush(),r=new Set(hJe(e))}catch{r=new Set}n(n=>{let i=n.draftsByThreadKey[e];if(!i)return n;let a=new Set(i.images.map(e=>e.id)),o=t.filter(e=>a.has(e.id)&&r.has(e.id)),s=i.images.map(e=>e.id).filter(e=>!r.has(e)),c={...i,persistedAttachments:o,nonPersistedImageIds:s},l={...n.draftsByThreadKey};return fY(c)?delete l[e]:l[e]=c,{draftsByThreadKey:l}})}function _Je(e){let t=e.dataUrl.indexOf(`,`),n=t===-1?e.dataUrl:e.dataUrl.slice(0,t),r=t===-1?``:e.dataUrl.slice(t+1);if(r.length===0)return null;try{if(!n.includes(`;base64`)){let t=decodeURIComponent(r),i=n.startsWith(`data:`)&&n.includes(`;`)?n.slice(5,n.indexOf(`;`)):e.mimeType;return new File([t],e.name,{type:i||e.mimeType})}let t=atob(r),i=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)i[e]=t.charCodeAt(e);return new File([i],e.name,{type:e.mimeType})}catch{return null}}function vJe(e){return e.flatMap(e=>{let t=_Je(e);return t?[{type:`image`,id:e.id,name:e.name,mimeType:e.mimeType,sizeBytes:e.sizeBytes,previewUrl:e.dataUrl,file:t}]:[]})}function yJe(e,t){return e.length>0?e:t?.prompt??``}function bJe(e,t){return e.length>0?e:t?.attachments??[]}function xJe(e,t){return e&&e.length>0?e:t?.terminalContexts??[]}function SJe(e){let t=e.stagedSubmission;return{prompt:yJe(e.prompt,t),attachments:bJe(e.attachments,t),terminalContexts:xJe(e.terminalContexts,t)}}function CJe(e){let t=e.modelSelectionByProvider??{},n=pY(e.activeProvider)??null,r=SJe(e);return{prompt:r.prompt,...e.lastGeneratedPullRequestPrompt===void 0?{}:{lastGeneratedPullRequestPrompt:e.lastGeneratedPullRequestPrompt},images:vJe(r.attachments),nonPersistedImageIds:[],persistedAttachments:[...r.attachments],terminalContexts:r.terminalContexts.map(e=>({id:e.id,threadId:e.threadId,createdAt:e.createdAt,terminalId:e.terminalId,terminalLabel:e.terminalLabel,lineStart:e.lineStart,lineEnd:e.lineEnd,text:``})),modelSelectionByProvider:t,activeProvider:n,runtimeMode:e.runtimeMode??null,interactionMode:e.interactionMode??null,stagedSubmission:null}}function wJe(e){return{threadId:e.threadId,environmentId:e.environmentId,projectId:e.projectId,logicalProjectKey:e.logicalProjectKey??CY(Io(e.environmentId,e.projectId)),createdAt:e.createdAt,runtimeMode:e.runtimeMode,interactionMode:e.interactionMode,branch:e.branch,worktreePath:e.worktreePath,envMode:e.envMode,promotedTo:e.promotedTo?Lo(e.promotedTo.environmentId,e.promotedTo.threadId):null,linkedPullRequest:e.linkedPullRequest??null}}var RY=Wt()(sJ((e,t)=>{let n=e;return{draftsByThreadKey:{},draftThreadsByThreadKey:{},logicalProjectDraftThreadKeyByLogicalProjectKey:{},stickyModelSelectionByProvider:{},stickyActiveProvider:null,getComposerDraft:e=>AY(t(),e),getDraftThreadByLogicalProjectKey:e=>t().getDraftSessionByLogicalProjectKey(e),getDraftSessionByLogicalProjectKey:e=>{let n=wY(e);if(n.length===0)return null;let r=t().logicalProjectDraftThreadKeyByLogicalProjectKey[n];if(!r)return null;let i=t().draftThreadsByThreadKey[r];return!i||NY(i)?null:jY(Ut.make(r),i)},getDraftThreadByProjectRef:e=>t().getDraftSessionByProjectRef(e),getDraftSessionByProjectRef:e=>{for(let[n,r]of Object.entries(t().draftThreadsByThreadKey))if(!NY(r)&&r.projectId===e.projectId&&r.environmentId===e.environmentId)return jY(Ut.make(n),r);return null},getDraftSession:e=>t().draftThreadsByThreadKey[e]??null,getDraftSessionByRef:e=>{for(let n of Object.values(t().draftThreadsByThreadKey))if(n.environmentId===e.environmentId&&n.threadId===e.threadId)return n;return null},getDraftThread:e=>typeof e==`string`?t().getDraftSession(Ut.make(e)):t().getDraftSessionByRef(e),getDraftThreadByRef:e=>t().getDraftSessionByRef(e),listDraftThreadKeys:()=>Object.values(t().draftThreadsByThreadKey).map(e=>Vo(Lo(e.environmentId,e.threadId))),hasDraftThreadsInEnvironment:e=>Object.values(t().draftThreadsByThreadKey).some(t=>t.environmentId===e),setLogicalProjectDraftThreadId:(e,t,r,i)=>{let a=wY(e);a.length!==0&&r.length!==0&&n(e=>{let n=e.draftThreadsByThreadKey[r],o=e.logicalProjectDraftThreadKeyByLogicalProjectKey[a],s=lJe(t,i?.threadId??n?.threadId??nn.make(r),a,n,i);if(o===r&&uJe(n,s))return e;let c={...e.logicalProjectDraftThreadKeyByLogicalProjectKey,[a]:r},l={...e.draftThreadsByThreadKey,[r]:s},u=e.draftsByThreadKey,d=o===void 0?void 0:l[o];return o&&o!==r&&!cJe(c,o)&&!NY(d)&&(delete l[o],e.draftsByThreadKey[o]!==void 0&&(u={...e.draftsByThreadKey},delete u[o])),{draftsByThreadKey:u,draftThreadsByThreadKey:l,logicalProjectDraftThreadKeyByLogicalProjectKey:c}})},setProjectDraftThreadId:(e,n,r)=>{t().setLogicalProjectDraftThreadId(CY(e),e,n,r)},setDraftThreadContext:(e,r)=>{let i=OY(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftThreadsByThreadKey[i];if(!t)return e;let n=r.projectRef??{environmentId:t.environmentId,projectId:t.projectId};if(n.projectId.length===0||n.environmentId.length===0)return e;let a=n.environmentId!==t.environmentId||n.projectId!==t.projectId,o=r.worktreePath===void 0?a?null:t.worktreePath:r.worktreePath??null,s=r.branch===void 0?a?null:t.branch:r.branch??null,c=r.anchorKind===void 0?t.anchorKind:r.anchorKind??void 0,l={threadId:t.threadId,environmentId:n.environmentId,projectId:n.projectId,logicalProjectKey:t.logicalProjectKey,createdAt:r.createdAt===void 0?t.createdAt:r.createdAt||t.createdAt,runtimeMode:r.runtimeMode??t.runtimeMode,interactionMode:r.interactionMode??t.interactionMode,branch:s,worktreePath:o,envMode:r.envMode??(o?`worktree`:a?`local`:t.envMode??`local`),promotedTo:t.promotedTo??null,cmmdTaskId:r.cmmdTaskId===void 0?t.cmmdTaskId??null:r.cmmdTaskId,anchorCmmdId:r.anchorCmmdId===void 0?t.anchorCmmdId??null:r.anchorCmmdId,linkedPullRequest:r.linkedPullRequest===void 0?t.linkedPullRequest??null:r.linkedPullRequest,...c===void 0?{}:{anchorKind:c}};return l.environmentId===t.environmentId&&l.projectId===t.projectId&&l.logicalProjectKey===t.logicalProjectKey&&l.createdAt===t.createdAt&&l.runtimeMode===t.runtimeMode&&l.interactionMode===t.interactionMode&&l.branch===t.branch&&l.worktreePath===t.worktreePath&&l.envMode===t.envMode&&(l.anchorKind??void 0)===(t.anchorKind??void 0)&&(l.anchorCmmdId??null)===(t.anchorCmmdId??null)&&PY(l.linkedPullRequest,t.linkedPullRequest)&&MY(l.promotedTo,t.promotedTo)?e:{draftThreadsByThreadKey:{...e.draftThreadsByThreadKey,[i]:l}}})},clearProjectDraftThreadId:e=>{n(t=>{let n=Object.entries(t.draftThreadsByThreadKey).find(([,t])=>t.projectId===e.projectId&&t.environmentId===e.environmentId);return n?FY(t,n[0]):t})},clearProjectDraftThreadById:(e,r)=>{let i=OY(t(),r)??``;i.length!==0&&n(t=>{let n=t.draftThreadsByThreadKey[i];return!n||n.projectId!==e.projectId||n.environmentId!==e.environmentId?t:FY(t,i)})},markDraftThreadPromoting:(e,r)=>{let i=OY(t(),e);i&&n(e=>{let t=e.draftThreadsByThreadKey[i];if(!t)return e;let n=r??Lo(t.environmentId,t.threadId);return MY(t.promotedTo,n)?e:{draftThreadsByThreadKey:{...e.draftThreadsByThreadKey,[i]:{...t,promotedTo:n}}}})},finalizePromotedDraftThread:e=>{let r=OY(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftThreadsByThreadKey[r];if(!NY(t))return e;let n=TY(t.promotedTo),i=e.draftsByThreadKey[n],a=e.draftsByThreadKey[r];return FY(a?{...e,draftsByThreadKey:{...e.draftsByThreadKey,[n]:i?{...i,modelSelectionByProvider:{...i.modelSelectionByProvider,...a.modelSelectionByProvider},activeProvider:a.activeProvider,runtimeMode:a.runtimeMode,interactionMode:a.interactionMode}:a}}:e,r)})},clearDraftThread:e=>{let r=OY(t(),e)??``;if(r.length===0)return;let i=t().draftsByThreadKey[r];if(i)for(let e of i.images)bY(e.previewUrl);n(e=>{let t=e.draftThreadsByThreadKey[r]!==void 0,n=Object.values(e.logicalProjectDraftThreadKeyByLogicalProjectKey).includes(r),i=e.draftsByThreadKey[r]!==void 0;return!t&&!n&&!i?e:FY(e,r)})},setStickyModelSelection:e=>{let t=gY(e);n(e=>{if(!t)return e;let n={...e.stickyModelSelectionByProvider,[t.provider]:t};return qe(e.stickyModelSelectionByProvider,n)?e.stickyActiveProvider===t.provider?e:{stickyActiveProvider:t.provider}:{stickyModelSelectionByProvider:n,stickyActiveProvider:t.provider}})},applyStickyState:e=>{let r=OY(t(),e)??``;r.length!==0&&n(e=>{let t=e.stickyModelSelectionByProvider,n=e.stickyActiveProvider;if(Object.keys(t).length===0&&n===null)return e;let i=e.draftsByThreadKey[r]??sY(),a={...i.modelSelectionByProvider};for(let[e,n]of Object.entries(t))if(n){let t=a[e];a[e]={...n,model:t?.model??n.model}}if(qe(i.modelSelectionByProvider,a)&&i.activeProvider===n)return e;let o={...i,modelSelectionByProvider:a,activeProvider:n},s={...e.draftsByThreadKey};return fY(o)?delete s[r]:s[r]=o,{draftsByThreadKey:s}})},setPrompt:(e,r)=>{let i=OY(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??sY();if(t.prompt===r)return e;let n={...t,prompt:r},a={...e.draftsByThreadKey};return fY(n)?delete a[i]:a[i]=n,{draftsByThreadKey:a}})},setGeneratedPullRequestPrompt:(e,r)=>{let i=OY(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??sY();return{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,lastGeneratedPullRequestPrompt:r}}}})},setPendingAutoSubmit:(e,r)=>{let i=OY(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??sY();if((t.pendingAutoSubmit??!1)===r)return e;let n=r?{...t,pendingAutoSubmit:!0}:(()=>{let{pendingAutoSubmit:e,...n}=t;return n})(),a={...e.draftsByThreadKey};return fY(n)?delete a[i]:a[i]=n,{draftsByThreadKey:a}})},stageComposerSubmission:(e,r)=>{let i=OY(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftsByThreadKey[i];if(!t)return e;let n={prompt:t.prompt,attachments:[...t.persistedAttachments],terminalContexts:[...t.terminalContexts],startedAt:r},a={...e.draftsByThreadKey};return a[i]={...t,stagedSubmission:n},{draftsByThreadKey:a}})},clearStagedComposerSubmission:e=>{let r=OY(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftsByThreadKey[r];if(!t?.stagedSubmission)return e;let n={...t,stagedSubmission:null},i={...e.draftsByThreadKey};return fY(n)?delete i[r]:i[r]=n,{draftsByThreadKey:i}})},setTerminalContexts:(e,r)=>{let i=OY(t(),e),a=kY(t(),e);if(!i||!a)return;let o=dY(a,r);n(e=>{let t=e.draftsByThreadKey[i]??sY(),n={...t,prompt:iJ(t.prompt,o.length),terminalContexts:o},r={...e.draftsByThreadKey};return fY(n)?delete r[i]:r[i]=n,{draftsByThreadKey:r}})},setModelSelection:(e,r)=>{let i=OY(t(),e)??``;if(i.length===0)return;let a=gY(r);n(e=>{let t=e.draftsByThreadKey[i];if(!t&&a===null)return e;let n=t??sY(),r={...n.modelSelectionByProvider};if(a){let e=r[a.provider];a.options===void 0?r[a.provider]={provider:a.provider,model:a.model,...`providerAccountId`in a&&a.providerAccountId?{providerAccountId:a.providerAccountId}:e&&`providerAccountId`in e&&e.providerAccountId?{providerAccountId:e.providerAccountId}:{},...e?.options?{options:e.options}:{}}:r[a.provider]=a}let o=a?.provider??n.activeProvider;if(qe(n.modelSelectionByProvider,r)&&n.activeProvider===o)return e;let s={...n,modelSelectionByProvider:r,activeProvider:o},c={...e.draftsByThreadKey};return fY(s)?delete c[i]:c[i]=s,{draftsByThreadKey:c}})},setModelOptions:(e,r)=>{let i=OY(t(),e)??``;if(i.length===0)return;let a=hY(r);n(e=>{let t=e.draftsByThreadKey[i];if(!t&&a===null)return e;let n=t??sY(),r={...n.modelSelectionByProvider};for(let e of[`codex`,`claudeAgent`]){if(!a||!(e in a))continue;let t=a[e],n=r[e];if(t)r[e]={provider:e,model:n?.model??Vn[e],...n&&`providerAccountId`in n&&n.providerAccountId?{providerAccountId:n.providerAccountId}:{},options:t};else if(n?.options){let{options:t,...i}=n;r[e]=i}}if(qe(n.modelSelectionByProvider,r))return e;let o={...n,modelSelectionByProvider:r},s={...e.draftsByThreadKey};return fY(o)?delete s[i]:s[i]=o,{draftsByThreadKey:s}})},setProviderModelOptions:(e,r,i,a)=>{let o=OY(t(),e)??``;if(o.length===0)return;let s=pY(r);if(s===null)return;let c=hY({[s]:i},s)?.[s];n(e=>{let t=e.draftsByThreadKey[o]??sY(),n={...t.modelSelectionByProvider},r=n[s];if(c)n[s]={provider:s,model:r?.model??Vn[s],...r&&`providerAccountId`in r&&r.providerAccountId?{providerAccountId:r.providerAccountId}:{},options:c};else if(r?.options){let{options:e,...t}=r;n[s]=t}let i=e.stickyModelSelectionByProvider,l=e.stickyActiveProvider;if(a?.persistSticky===!0){i={...e.stickyModelSelectionByProvider};let n=i[s]??t.modelSelectionByProvider[s]??{provider:s,model:Vn[s]};if(c)i[s]={...n,provider:s,options:c};else if(n.options){let{options:e,...t}=n;i[s]=t}l=t.activeProvider??s}if(qe(t.modelSelectionByProvider,n)&&qe(e.stickyModelSelectionByProvider,i)&&e.stickyActiveProvider===l)return e;let u={...t,modelSelectionByProvider:n},d={...e.draftsByThreadKey};return fY(u)?delete d[o]:d[o]=u,{draftsByThreadKey:d,...a?.persistSticky===!0?{stickyModelSelectionByProvider:i,stickyActiveProvider:l}:{}}})},setRuntimeMode:(e,r)=>{let i=OY(t(),e)??``;if(i.length===0)return;let a=QJ(r)?r:null;n(e=>{let t=e.draftsByThreadKey[i];if(!t&&a===null)return e;let n=t??sY();if(n.runtimeMode===a)return e;let r={...n,runtimeMode:a},o={...e.draftsByThreadKey};return fY(r)?delete o[i]:o[i]=r,{draftsByThreadKey:o}})},setInteractionMode:(e,r)=>{let i=OY(t(),e)??``;if(i.length===0)return;let a=r===`plan`||r==="default"?r:null;n(e=>{let t=e.draftsByThreadKey[i];if(!t&&a===null)return e;let n=t??sY();if(n.interactionMode===a)return e;let r={...n,interactionMode:a},o={...e.draftsByThreadKey};return fY(r)?delete o[i]:o[i]=r,{draftsByThreadKey:o}})},addImage:(e,n)=>{let r=OY(t(),e),i=kY(t(),e);!r||!i||t().addImages(typeof e==`string`?Ut.make(r):e,[n])},addImages:(e,r)=>{let i=OY(t(),e)??``;i.length!==0&&r.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??sY(),n=new Set(t.images.map(e=>e.id)),a=new Set(t.images.map(e=>cY(e))),o=new Set(t.images.map(e=>e.previewUrl)),s=[];for(let e of r){let t=cY(e);if(n.has(e.id)||a.has(t)){o.has(e.previewUrl)||bY(e.previewUrl);continue}s.push(e),n.add(e.id),a.add(t),o.add(e.previewUrl)}return s.length===0?e:{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,images:[...t.images,...s]}}}})},removeImage:(e,r)=>{let i=OY(t(),e)??``;if(i.length===0)return;let a=t().draftsByThreadKey[i];if(!a)return;let o=a.images.find(e=>e.id===r);o&&bY(o.previewUrl),n(e=>{let t=e.draftsByThreadKey[i];if(!t)return e;let n={...t,images:t.images.filter(e=>e.id!==r),nonPersistedImageIds:t.nonPersistedImageIds.filter(e=>e!==r),persistedAttachments:t.persistedAttachments.filter(e=>e.id!==r)},a={...e.draftsByThreadKey};return fY(n)?delete a[i]:a[i]=n,{draftsByThreadKey:a}})},insertTerminalContext:(e,r,i,a)=>{let o=OY(t(),e),s=kY(t(),e);if(!o||!s)return!1;let c=!1;return n(e=>{let t=e.draftsByThreadKey[o]??sY(),n=uY(s,i);if(!n)return e;let l=lY(n);if(t.terminalContexts.some(e=>e.id===n.id)||t.terminalContexts.some(e=>lY(e)===l))return e;c=!0;let u=Math.max(0,Math.min(t.terminalContexts.length,a)),d={...t,prompt:r,terminalContexts:[...t.terminalContexts.slice(0,u),n,...t.terminalContexts.slice(u)]};return{draftsByThreadKey:{...e.draftsByThreadKey,[o]:d}}}),c},addTerminalContext:(e,n)=>{let r=OY(t(),e),i=kY(t(),e);!r||!i||t().addTerminalContexts(typeof e==`string`?Ut.make(r):e,[n])},addTerminalContexts:(e,r)=>{let i=OY(t(),e),a=kY(t(),e);!i||!a||r.length===0||n(e=>{let t=e.draftsByThreadKey[i]??sY(),n=dY(a,[...t.terminalContexts,...r]).slice(t.terminalContexts.length);return n.length===0?e:{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,prompt:iJ(t.prompt,t.terminalContexts.length+n.length),terminalContexts:[...t.terminalContexts,...n]}}}})},removeTerminalContext:(e,r)=>{let i=OY(t(),e)??``;i.length!==0&&r.length!==0&&n(e=>{let t=e.draftsByThreadKey[i];if(!t)return e;let n={...t,terminalContexts:t.terminalContexts.filter(e=>e.id!==r)},a={...e.draftsByThreadKey};return fY(n)?delete a[i]:a[i]=n,{draftsByThreadKey:a}})},clearTerminalContexts:e=>{let r=OY(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftsByThreadKey[r];if(!t||t.terminalContexts.length===0)return e;let n={...t,terminalContexts:[]},i={...e.draftsByThreadKey};return fY(n)?delete i[r]:i[r]=n,{draftsByThreadKey:i}})},clearPersistedAttachments:e=>{let r=OY(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftsByThreadKey[r];if(!t)return e;let n={...t,persistedAttachments:[],nonPersistedImageIds:[]},i={...e.draftsByThreadKey};return fY(n)?delete i[r]:i[r]=n,{draftsByThreadKey:i}})},syncPersistedAttachments:(e,r)=>{let i=OY(t(),e);if(!i)return;let a=new Set(r.map(e=>e.id));n(e=>{let t=e.draftsByThreadKey[i];if(!t)return e;let n={...t,persistedAttachments:r,nonPersistedImageIds:t.nonPersistedImageIds.filter(e=>!a.has(e))},o={...e.draftsByThreadKey};return fY(n)?delete o[i]:o[i]=n,{draftsByThreadKey:o}}),Promise.resolve().then(()=>{gJe(i,r,n)})},clearComposerContent:e=>{let r=OY(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftsByThreadKey[r];if(!t)return e;let{lastGeneratedPullRequestPrompt:n,...i}=t,a={...i,prompt:``,images:[],nonPersistedImageIds:[],persistedAttachments:[],terminalContexts:[]},o={...e.draftsByThreadKey};return fY(a)?delete o[r]:o[r]=a,{draftsByThreadKey:o}})}}},{name:XJ,version:ZJ,storage:aJ(()=>$J),migrate:fJe,partialize:pJe,merge:(e,t)=>{let n=mJe(e),r=Object.fromEntries(Object.entries(n.draftsByThreadKey).map(([e,t])=>[e,CJe(t)])),i=Object.fromEntries(Object.entries(n.draftThreadsByThreadKey).map(([e,t])=>[e,wJe(t)]));return{...t,draftsByThreadKey:r,draftThreadsByThreadKey:i,logicalProjectDraftThreadKeyByLogicalProjectKey:n.logicalProjectDraftThreadKeyByLogicalProjectKey,stickyModelSelectionByProvider:n.stickyModelSelectionByProvider??{},stickyActiveProvider:n.stickyActiveProvider??null}}}));function TJe(e){let t=(0,Cl.c)(2),n;return t[0]===e?n=t[1]:(n=t=>AY(t,e)??rJe,t[0]=e,t[1]=n),RY(n)}function EJe(e){let t=(0,Cl.c)(2),n;return t[0]===e?n=t[1]:(n=t=>{let n=AY(t,e);return n?{activeProvider:n.activeProvider,modelSelectionByProvider:n.modelSelectionByProvider}:nJe},t[0]=e,t[1]=n),RY(dJ(n))}function DJe(e){let t=(0,Cl.c)(10),n;t[0]!==e.draftId||t[1]!==e.threadRef?(n=e.threadRef??e.draftId??Ut.make(``),t[0]=e.draftId,t[1]=e.threadRef,t[2]=n):n=t[2];let r=EJe(n),i,a;return t[3]!==r||t[4]!==e.projectModelSelection||t[5]!==e.providers||t[6]!==e.selectedProvider||t[7]!==e.settings||t[8]!==e.threadModelSelection?(a=Jqe({draft:r,providers:e.providers,selectedProvider:e.selectedProvider,threadModelSelection:e.threadModelSelection,projectModelSelection:e.projectModelSelection,settings:e.settings}),t[3]=r,t[4]=e.projectModelSelection,t[5]=e.providers,t[6]=e.selectedProvider,t[7]=e.settings,t[8]=e.threadModelSelection,t[9]=a):a=t[9],i=a,i}function zY(e){let t=RY.getState();for(let[n,r]of Object.entries(t.draftThreadsByThreadKey))r.environmentId===e.environmentId&&r.threadId===e.threadId&&t.markDraftThreadPromoting(Ut.make(n),e)}function OJe(e){for(let t of e)zY(t)}function kJe(e){let t=RY.getState();for(let[n,r]of Object.entries(t.draftThreadsByThreadKey))r.promotedTo&&r.promotedTo.environmentId===e.environmentId&&r.promotedTo.threadId===e.threadId&&t.finalizePromotedDraftThread(Ut.make(n))}function AJe(e){return{environmentId:e.environmentId,threadId:e.threadId}}function jJe(e){return{draftId:e}}function MJe(e){return!e.environmentId||!e.threadId?null:Lo(e.environmentId,e.threadId)}function NJe(e){return e.environmentId&&e.threadId?{kind:`server`,threadRef:Lo(e.environmentId,e.threadId)}:e.draftId?{kind:`draft`,draftId:e.draftId}:null}var PJe=F.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Ste(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function BY(e){let t=(0,Cl.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=Xt(`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,kr.jsx)(`div`,{className:i,"data-slot":`skeleton`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var VY=`cmmd-runtime:`;function FJe(e){return`${VY}${e}`}function HY(e){return UY(e)!==null}function UY(e){let t=String(e);if(!t.startsWith(`cmmd-runtime:`))return null;let n=t.slice(13);return/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(n)?n:null}var WY=`forge:client-settings:v1`,IJe=`forge:saved-environment-registry:v1`,LJe=zn({environmentId:en,label:Un,httpBaseUrl:Un,wsBaseUrl:Un,createdAt:Un,lastConnectedAt:Xn(Un),cmmdOrganizationId:Ln(Un),cmmdProjectId:Ln(Un),runtimeId:Ln(Un),runtimeTicketExpiresAt:Ln(Un),lastAuthenticatedPullRequestCapability:Ln(Kn),bearerToken:Ln(Un)}),GY=zn({version:Ln(An),records:Ln(Bn(LJe))});function KY(){return typeof window<`u`}var RJe={uiFontSize:14,codeFontSize:15},zJe=[[`uiFontSize`,11,20],[`codeFontSize`,11,20]];function BJe(e){return e.defaultThreadRuntime===`desktop-cloud-bridge`?{...e,defaultThreadRuntime:`cloud`}:null}function VJe(e){if(typeof e.fontDefaultsVersion==`number`)return null;let t=Object.entries(RJe).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 HJe(e){let t=zJe.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 qY(e){if(!e||typeof e!=`object`)return e;let t=e,n=!1;for(let e of[BJe,VJe,HJe]){let r=e(t);r!==null&&(t=r,n=!0)}return n?t:e}function UJe(){if(!KY())return null;try{let e=window.localStorage.getItem(WY);return e?Qn(Pn)(qY(JSON.parse(e))):null}catch{return null}}function WJe(e){KY()&&qq(WY,e,Pn)}function JY(){if(!KY())return{};try{return Kq(`forge:saved-environment-registry:v1`,GY)??{}}catch{return{}}}function YY(e){KY()&&qq(IJe,e,GY)}function XY(){return JY().records??[]}function GJe(e){YY({version:1,records:e})}function KJe(){return XY().map(e=>Nn(e))}function qJe(e){let t=new Map(XY().map(e=>[e.environmentId,e]));GJe(e.map(e=>{let n=HY(e.environmentId)?void 0:t.get(e.environmentId)?.bearerToken;return n?{...Nn(e),bearerToken:n}:Nn(e)}))}function JJe(e){return XY().find(t=>t.environmentId===e)?.bearerToken??null}function YJe(e,t){let n=JY(),r=n.records??[],i=!1;return YY({version:n.version??1,records:r.map(n=>n.environmentId===e?(i=!0,Object.assign(Nn(n),{bearerToken:t})):n)}),i}function XJe(e){let t=JY();YY({version:t.version??1,records:(t.records??[]).map(t=>t.environmentId===e?Nn(t):t)})}var ZJe=Qn(Pn);function QJe(){return typeof window>`u`?void 0:window.desktopBridge}function ZY(e){let t=QJe(),n=t?.[e];return typeof n==`function`?n.bind(t):null}async function QY(){let e=ZY(`getClientSettings`);if(e){let t=await e();return t?ZJe(t):null}return UJe()}async function $Y(e){let t=ZY(`setClientSettings`);if(t)return t(e);WJe(e)}async function eX(){let e=ZY(`getSavedEnvironmentRegistry`);return e?e():KJe()}async function tX(e){let t=ZY(`setSavedEnvironmentRegistry`);if(t)return t(e);qJe(e)}async function nX(e){let t=ZY(`getSavedEnvironmentSecret`);return t?t(e):JJe(e)}async function rX(e,t){let n=ZY(`setSavedEnvironmentSecret`);return n?n(e,t):YJe(e,t)}async function iX(e){let t=ZY(`removeSavedEnvironmentSecret`);if(t)return t(e);XJe(e)}var aX=!1,oX=null;function sX(e){return Object.values(e)}function cX(e){return e.map(e=>Nn(e))}function lX(e){try{tX(cX(sX(e))).catch(e=>{console.error(`[SAVED_ENVIRONMENTS] persist failed`,e)})}catch(e){console.error(`[SAVED_ENVIRONMENTS] persist failed`,e)}}function $Je(e){let t=uX.getState().byId,n=Object.fromEntries(e.map(e=>[e.environmentId,e]));uX.setState({byId:{...n,...t}})}async function eYe(){if(aX)return;if(oX)return oX;let e=(async()=>{try{$Je(await eX())}catch(e){console.error(`[SAVED_ENVIRONMENTS] hydrate failed`,e)}finally{aX=!0,uX.setState({hydrated:!0})}})().finally(()=>{oX===e&&(oX=null)});return oX=e,oX}var uX=Wt()(e=>({byId:{},hydrated:aX,upsert:t=>e(e=>{let n={...e.byId,[t.environmentId]:t};return lX(n),{byId:n}}),remove:t=>e(e=>{let{[t]:n,...r}=e.byId;return lX(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 lX(i),{byId:i}}),reset:()=>{lX({}),e({byId:{}})}}));function dX(){return aX}function fX(){return dX()?Promise.resolve():eYe()}function pX(){return Object.values(uX.getState().byId).toSorted((e,t)=>e.label.localeCompare(t.label))}function tYe(){return pX().filter(e=>e.lastAuthenticatedPullRequestCapability===!0)}function mX(e){return uX.getState().byId[e]??null}function nYe(e){let t=Fq();return t?.environmentId===e?Jie(t):mX(e)?.httpBaseUrl??null}function hX(e){let t=nYe(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()}async function gX(e){await tX(cX(sX({...uX.getState().byId,[e.environmentId]:e})))}async function _X(e){return nX(e)}async function rYe(e,t){return rX(e,t)}async function vX(e){await iX(e)}var iYe=Object.freeze({connectionState:`disconnected`,authState:`unknown`,lastError:null,lastErrorAt:null,role:null,descriptor:null,serverConfig:null,connectedAt:null,disconnectedAt:null,providerAuthority:null});function yX(){return{...iYe}}var bX=Wt()(e=>({byId:{},ensure:t=>e(e=>e.byId[t]?e:{byId:{...e.byId,[t]:yX()}}),patch:(t,n)=>e(e=>({byId:{...e.byId,[t]:{...e.byId[t]??yX(),...n}}})),clear:t=>e(e=>{let{[t]:n,...r}=e.byId;return{byId:r}}),reset:()=>e({byId:{}})})),aYe=[/(?:^|\s)\/(?:Users|var|private|tmp|project|repo|home)\/[^\s'"<>)]*/i,/(?:^|\s)[A-Za-z]:\\[^\s'"<>)]*/];function xX(e){let t=e?.trim();return t&&t.length>0?t:null}function oYe(e){return xX(e)??`Project`}function sYe(e,t=`safe`){let n=xX(e);return n?t===`full`?n:n.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)??`Local checkout`:`Local checkout`}function SX(e,t=`Something went wrong. Try again.`){let n=DK(e instanceof Error?e.message:typeof e==`string`?e:String(e),{fallback:t});return!n||aYe.some(e=>e.test(n))?t:n}function CX(e,t){return{id:e.id,environmentId:t,name:e.title,cwd:e.workspaceRoot,repositoryIdentity:e.repositoryIdentity??null,availability:e.availability,defaultThreadEnvMode:e.defaultThreadEnvMode??null,cmmdRegistration:e.cmmdRegistration??null,defaultModelSelection:e.defaultModelSelection?wX(e.defaultModelSelection):null,createdAt:e.createdAt,updatedAt:e.updatedAt,scripts:TX(e.scripts)}}function wX(e){return{...e,model:Wq(e.provider,e.model)}}function TX(e){return e.map(e=>({...e}))}function cYe(e,t){return{...e,...t.title===void 0?{}:{name:t.title},...t.workspaceRoot===void 0?{}:{cwd:t.workspaceRoot},...t.repositoryIdentity===void 0?{}:{repositoryIdentity:t.repositoryIdentity??null},...t.defaultThreadEnvMode===void 0?{}:{defaultThreadEnvMode:t.defaultThreadEnvMode},...t.cmmdRegistration===void 0?{}:{cmmdRegistration:t.cmmdRegistration},...t.defaultModelSelection===void 0?{}:{defaultModelSelection:t.defaultModelSelection?wX(t.defaultModelSelection):null},...t.scripts===void 0?{}:{scripts:TX(t.scripts)},updatedAt:t.updatedAt}}var lYe=[],uYe=[],dYe=[],fYe=[],pYe={},mYe={},hYe={},gYe={},_Ye=[],EX=new WeakMap,DX=new WeakMap;function OX(e,t,n){if(!e||e.length===0||!t)return n;let r=EX.get(e),i=r?.get(t);if(i)return i;let a=e.flatMap(e=>{let n=t[e];return n?[n]:[]}),o=r??new WeakMap;return o.set(t,a),r||EX.set(e,o),a}function vYe(e,t){return OX(e.messageIdsByThreadId[t],e.messageByThreadId[t]??pYe,lYe)}function yYe(e,t){return OX(e.activityIdsByThreadId[t],e.activityByThreadId[t]??mYe,uYe)}function bYe(e,t){return OX(e.proposedPlanIdsByThreadId[t],e.proposedPlanByThreadId[t]??hYe,dYe)}function xYe(e,t){return OX(e.turnDiffIdsByThreadId[t],e.turnDiffSummaryByThreadId[t]??gYe,fYe)}function kX(e,t){let n=e.threadShellById[t];if(!n)return;let r=e.threadSessionById[t]??null,i=e.threadTurnStateById[t],a=e.threadRateLimitStatusById[t]??_Ye,o=vYe(e,t),s=yYe(e,t),c=bYe(e,t),l=xYe(e,t),u=DX.get(n);if(u&&u.session===r&&u.turnState===i&&u.rateLimitStatus===a&&u.messages===o&&u.activities===s&&u.proposedPlans===c&&u.turnDiffSummaries===l)return u.thread;let d={...n,session:r,latestTurn:i?.latestTurn??null,pendingSourceProposedPlan:i?.pendingSourceProposedPlan,rateLimitStatus:a,messages:o,activities:s,proposedPlans:c,turnDiffSummaries:l};return DX.set(n,{session:r,turnState:i,rateLimitStatus:a,messages:o,activities:s,proposedPlans:c,turnDiffSummaries:l,thread:d}),d}function AX(e){return{settledAt:e.settledAt??null,settledOverride:e.settledOverride??null}}function jX(e,t,n,r){let i=oZ(e,t,e=>({...e,...r,updatedAt:n})),a=i.sidebarThreadSummaryById[t];return!a||Object.keys(r).every(e=>a[e]===r[e])?i:{...i,sidebarThreadSummaryById:{...i.sidebarThreadSummaryById,[t]:{...a,...r}}}}function SYe(e,t){let n=t.providerAccountId??null,r=e=>e.provider===t.provider&&(e.providerAccountId??null)===n,i=e.find(r),a={status:t.status,usedPercent:t.usedPercent,resetsAt:t.resetsAt},o={provider:t.provider,providerAccountId:n,fiveHour:t.window===`five_hour`?a:i?.fiveHour??null,sevenDay:t.window===`seven_day`?a:i?.sevenDay??null};return[...e.filter(e=>!r(e)),o]}var MX={projectIds:[],projectById:{},threadIds:[],threadIdsByProjectId:{},threadShellById:{},threadSessionById:{},threadTurnStateById:{},threadRateLimitStatusById:{},messageIdsByThreadId:{},messageByThreadId:{},activityIdsByThreadId:{},activityByThreadId:{},proposedPlanIdsByThreadId:{},proposedPlanByThreadId:{},turnDiffIdsByThreadId:{},turnDiffSummaryByThreadId:{},sidebarThreadSummaryById:{},threadSubscriptionErrorById:{},bootstrapComplete:!1},CYe={activeEnvironmentId:null,environmentStateById:{}},NX=[],PX=[];function FX(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function IX(e){let t=kK(e.lastError);return{provider:zYe(e.providerName),status:RYe(e.status),orchestrationStatus:e.status,activeTurnId:e.activeTurnId??void 0,createdAt:e.updatedAt,updatedAt:e.updatedAt,...t?{lastError:t}:{}}}function LX(e,t){let n=t.attachments?.map(t=>({type:`image`,id:t.id,name:t.name,mimeType:t.mimeType,sizeBytes:t.sizeBytes,previewUrl:hX({environmentId:e,pathname:BYe(t.id)})}));return{id:t.id,role:t.role,text:t.text,turnId:t.turnId,createdAt:t.createdAt,streaming:t.streaming,...t.streaming?{}:{completedAt:t.updatedAt},...n&&n.length>0?{attachments:n}:{}}}function RX(e){return{id:e.id,turnId:e.turnId,planMarkdown:e.planMarkdown,implementedAt:e.implementedAt,implementationThreadId:e.implementationThreadId,createdAt:e.createdAt,updatedAt:e.updatedAt}}function zX(e){return{turnId:e.turnId,completedAt:e.completedAt,status:e.status,assistantMessageId:e.assistantMessageId??void 0,checkpointTurnCount:e.checkpointTurnCount,checkpointRef:e.checkpointRef,files:e.files.map(e=>({...e}))}}function BX(e,t){return{id:e.id,environmentId:t,codexThreadId:null,projectId:e.projectId,title:e.title,modelSelection:wX(e.modelSelection),runtimeMode:e.runtimeMode,interactionMode:e.interactionMode,session:e.session?IX(e.session):null,messages:e.messages.map(e=>LX(t,e)),proposedPlans:e.proposedPlans.map(RX),error:kK(e.session?.lastError),createdAt:e.createdAt,archivedAt:e.archivedAt,...AX(e),updatedAt:e.updatedAt,latestTurn:e.latestTurn,pendingSourceProposedPlan:e.latestTurn?.sourceProposedPlan,branch:e.branch,worktreePath:e.worktreePath,turnDiffSummaries:e.checkpoints.map(zX),activities:e.activities.map(e=>({...e})),anchorKind:e.anchorKind,anchorCmmdId:e.anchorCmmdId,linkedPullRequest:e.linkedPullRequest??null,goal:e.goal??null,titleRegeneration:e.titleRegeneration??null,kind:e.kind,parentThreadId:e.parentThreadId,status:e.status,workerRole:e.workerRole??null,pendingAutoCreatePrompt:e.pendingAutoCreatePrompt??null,rateLimitStatus:e.rateLimitStatus??[]}}function VX(e,t){let n={id:e.id,environmentId:t,codexThreadId:null,projectId:e.projectId,title:e.title,modelSelection:wX(e.modelSelection),runtimeMode:e.runtimeMode,interactionMode:e.interactionMode,error:kK(e.session?.lastError),createdAt:e.createdAt,archivedAt:e.archivedAt,...AX(e),updatedAt:e.updatedAt,branch:e.branch,worktreePath:e.worktreePath,anchorKind:e.anchorKind,anchorCmmdId:e.anchorCmmdId,linkedPullRequest:e.linkedPullRequest??null,goal:e.goal??null,titleRegeneration:e.titleRegeneration??null,kind:e.kind,parentThreadId:e.parentThreadId,status:e.status,workerRole:e.workerRole??null},r=e.session?IX(e.session):null;return{shell:n,session:r,turnState:{latestTurn:e.latestTurn,pendingSourceProposedPlan:e.latestTurn?.sourceProposedPlan},summary:{id:e.id,modelSelection:n.modelSelection,environmentId:t,projectId:e.projectId,title:e.title,interactionMode:e.interactionMode,session:r,createdAt:e.createdAt,archivedAt:e.archivedAt,...AX(e),updatedAt:e.updatedAt,latestTurn:e.latestTurn,branch:e.branch,worktreePath:e.worktreePath,latestUserMessageAt:e.latestUserMessageAt,hasPendingApprovals:e.hasPendingApprovals,hasPendingUserInput:e.hasPendingUserInput,hasActionableProposedPlan:e.hasActionableProposedPlan,anchorKind:e.anchorKind,anchorCmmdId:e.anchorCmmdId,linkedPullRequest:e.linkedPullRequest??null,goal:e.goal??null,titleRegeneration:e.titleRegeneration??null,kind:e.kind,parentThreadId:e.parentThreadId,status:e.status,workerRole:e.workerRole??null}}}function wYe(e){return{id:e.id,environmentId:e.environmentId,codexThreadId:e.codexThreadId,projectId:e.projectId,title:e.title,modelSelection:e.modelSelection,runtimeMode:e.runtimeMode,interactionMode:e.interactionMode,error:e.error,createdAt:e.createdAt,archivedAt:e.archivedAt,settledAt:e.settledAt,settledOverride:e.settledOverride,updatedAt:e.updatedAt,branch:e.branch,worktreePath:e.worktreePath,anchorKind:e.anchorKind,anchorCmmdId:e.anchorCmmdId,linkedPullRequest:e.linkedPullRequest??null,kind:e.kind,parentThreadId:e.parentThreadId,status:e.status,workerRole:e.workerRole??null,goal:e.goal??null,titleRegeneration:e.titleRegeneration??null}}function TYe(e){return{latestTurn:e.latestTurn,...e.pendingSourceProposedPlan?{pendingSourceProposedPlan:e.pendingSourceProposedPlan}:{}}}function HX(e,t){return e===t?!0:e===void 0||t===void 0?!1:e.threadId===t.threadId&&e.planId===t.planId}function UX(e,t){return e===t?!0:e==null||t==null?!1:e.turnId===t.turnId&&e.state===t.state&&e.requestedAt===t.requestedAt&&e.startedAt===t.startedAt&&e.completedAt===t.completedAt&&e.assistantMessageId===t.assistantMessageId&&HX(e.sourceProposedPlan,t.sourceProposedPlan)}function WX(e,t){return e===t?!0:e==null||t==null?!1:e.provider===t.provider&&e.status===t.status&&e.orchestrationStatus===t.orchestrationStatus&&e.activeTurnId===t.activeTurnId&&e.createdAt===t.createdAt&&e.updatedAt===t.updatedAt&&e.lastError===t.lastError}function GX(e,t){return e===t?!0:e==null||t==null?!1:e.projectId===t.projectId&&e.projectRepositoryId===t.projectRepositoryId&&e.provider===t.provider&&e.host===t.host&&e.repository===t.repository&&e.number===t.number&&e.url===t.url}function KX(e,t){return e!==void 0&&e.id===t.id&&e.environmentId===t.environmentId&&e.projectId===t.projectId&&e.title===t.title&&qX(e.titleRegeneration,t.titleRegeneration)&&e.interactionMode===t.interactionMode&&WX(e.session,t.session)&&e.createdAt===t.createdAt&&e.archivedAt===t.archivedAt&&e.settledAt===t.settledAt&&e.settledOverride===t.settledOverride&&e.updatedAt===t.updatedAt&&UX(e.latestTurn,t.latestTurn)&&e.branch===t.branch&&e.worktreePath===t.worktreePath&&e.latestUserMessageAt===t.latestUserMessageAt&&e.hasPendingApprovals===t.hasPendingApprovals&&e.hasPendingUserInput===t.hasPendingUserInput&&e.hasActionableProposedPlan===t.hasActionableProposedPlan&&e.anchorKind===t.anchorKind&&e.anchorCmmdId===t.anchorCmmdId&&GX(e.linkedPullRequest,t.linkedPullRequest)&&e.kind===t.kind&&e.parentThreadId===t.parentThreadId&&e.status===t.status}function qX(e,t){return e===t?!0:e==null||t==null?!1:e.requestId===t.requestId&&e.startedAt===t.startedAt}function JX(e,t){return e!==void 0&&e.id===t.id&&e.environmentId===t.environmentId&&e.codexThreadId===t.codexThreadId&&e.projectId===t.projectId&&e.title===t.title&&e.modelSelection===t.modelSelection&&e.runtimeMode===t.runtimeMode&&e.interactionMode===t.interactionMode&&e.error===t.error&&e.createdAt===t.createdAt&&e.archivedAt===t.archivedAt&&e.settledAt===t.settledAt&&e.settledOverride===t.settledOverride&&e.updatedAt===t.updatedAt&&e.branch===t.branch&&e.worktreePath===t.worktreePath&&e.anchorKind===t.anchorKind&&e.anchorCmmdId===t.anchorCmmdId&&GX(e.linkedPullRequest,t.linkedPullRequest)&&e.kind===t.kind&&e.parentThreadId===t.parentThreadId&&e.status===t.status&&e.goal===t.goal&&qX(e.titleRegeneration,t.titleRegeneration)}function YX(e,t){return e!==void 0&&UX(e.latestTurn,t.latestTurn)&&HX(e.pendingSourceProposedPlan,t.pendingSourceProposedPlan)}function EYe(e,t){return e.includes(t)?[...e]:[...e,t]}function XX(e,t){return e.filter(e=>e!==t)}function DYe(e){return{ids:e.messages.map(e=>e.id),byId:Object.fromEntries(e.messages.map(e=>[e.id,e]))}}function OYe(e){return{ids:e.activities.map(e=>e.id),byId:Object.fromEntries(e.activities.map(e=>[e.id,e]))}}function kYe(e){return{ids:e.proposedPlans.map(e=>e.id),byId:Object.fromEntries(e.proposedPlans.map(e=>[e.id,e]))}}function AYe(e){return{ids:e.turnDiffSummaries.map(e=>e.turnId),byId:Object.fromEntries(e.turnDiffSummaries.map(e=>[e.turnId,e]))}}function jYe(e){return e.projectIds.flatMap(t=>{let n=e.projectById[t];return n?[n]:[]})}function ZX(e){return e.threadIds.flatMap(t=>{let n=kX(e,t);return n?[n]:[]})}function QX(e,t,n,r){let i=e;if(e.threadIds.includes(t)||(i={...i,threadIds:[...i.threadIds,t]}),r!==n){let e=i.threadIdsByProjectId;if(r){let n=e[r]??NX,i=XX(n,t);if(i.length===0){let{[r]:t,...n}=e;e=n}else FX(n,i)||(e={...e,[r]:i})}let a=e[n]??NX,o=EYe(a,t);FX(a,o)||(e={...e,[n]:o}),e!==i.threadIdsByProjectId&&(i={...i,threadIdsByProjectId:e})}return i}function $X(e,t,n){let r=wYe(t),i=TYe(t),a=e.threadShellById[t.id],o=e.threadTurnStateById[t.id],s=QX(e,t.id,t.projectId,n?.projectId);JX(a,r)||(s={...s,threadShellById:{...s.threadShellById,[t.id]:r}});let c=e.sidebarThreadSummaryById[t.id];if(c!==void 0){let e={...c,title:t.title,modelSelection:t.modelSelection,interactionMode:t.interactionMode,session:t.session,createdAt:t.createdAt,archivedAt:t.archivedAt,settledAt:t.settledAt,settledOverride:t.settledOverride,updatedAt:t.updatedAt,latestTurn:t.latestTurn,branch:t.branch,worktreePath:t.worktreePath,anchorKind:t.anchorKind,anchorCmmdId:t.anchorCmmdId,linkedPullRequest:t.linkedPullRequest??null,goal:t.goal,titleRegeneration:t.titleRegeneration??null,kind:t.kind,parentThreadId:t.parentThreadId,status:t.status,workerRole:t.workerRole};KX(c,e)||(s={...s,sidebarThreadSummaryById:{...s.sidebarThreadSummaryById,[t.id]:e}})}if(WX(n?.session??null,t.session)||(s={...s,threadSessionById:{...s.threadSessionById,[t.id]:t.session}}),(n?.rateLimitStatus??PX)!==(t.rateLimitStatus??PX)&&(s={...s,threadRateLimitStatusById:{...s.threadRateLimitStatusById,[t.id]:t.rateLimitStatus??PX}}),YX(o,i)||(s={...s,threadTurnStateById:{...s.threadTurnStateById,[t.id]:i}}),n?.messages!==t.messages){let e=DYe(t);s={...s,messageIdsByThreadId:{...s.messageIdsByThreadId,[t.id]:e.ids},messageByThreadId:{...s.messageByThreadId,[t.id]:e.byId}}}if(n?.activities!==t.activities){let e=OYe(t);s={...s,activityIdsByThreadId:{...s.activityIdsByThreadId,[t.id]:e.ids},activityByThreadId:{...s.activityByThreadId,[t.id]:e.byId}}}if(n?.proposedPlans!==t.proposedPlans){let e=kYe(t);s={...s,proposedPlanIdsByThreadId:{...s.proposedPlanIdsByThreadId,[t.id]:e.ids},proposedPlanByThreadId:{...s.proposedPlanByThreadId,[t.id]:e.byId}}}if(n?.turnDiffSummaries!==t.turnDiffSummaries){let e=AYe(t);s={...s,turnDiffIdsByThreadId:{...s.turnDiffIdsByThreadId,[t.id]:e.ids},turnDiffSummaryByThreadId:{...s.turnDiffSummaryByThreadId,[t.id]:e.byId}}}return s}function eZ(e,t){let n=e.threadShellById[t.shell.id],r=QX(e,t.shell.id,t.shell.projectId,n?.projectId);return JX(n,t.shell)||(r={...r,threadShellById:{...r.threadShellById,[t.shell.id]:t.shell}}),WX(e.threadSessionById[t.shell.id]??null,t.session)||(r={...r,threadSessionById:{...r.threadSessionById,[t.shell.id]:t.session}}),YX(e.threadTurnStateById[t.shell.id],t.turnState)||(r={...r,threadTurnStateById:{...r.threadTurnStateById,[t.shell.id]:t.turnState}}),KX(e.sidebarThreadSummaryById[t.shell.id],t.summary)||(r={...r,sidebarThreadSummaryById:{...r.sidebarThreadSummaryById,[t.shell.id]:t.summary}}),r}function tZ(e,t){return Object.fromEntries(Object.entries(e).flatMap(([e,n])=>t.has(e)?[[e,n]]:[]))}function nZ(e,t){let n=e.threadShellById[t],r=e.sidebarThreadSummaryById[t],i=n?.projectId??r?.projectId;if(!i)return e;let a=XX(e.threadIds,t),o=XX(e.threadIdsByProjectId[i]??NX,t),s=o.length===0?(()=>{let{[i]:t,...n}=e.threadIdsByProjectId;return n})():{...e.threadIdsByProjectId,[i]:o},{[t]:c,...l}=e.threadShellById,{[t]:u,...d}=e.threadSessionById,{[t]:f,...p}=e.threadTurnStateById,{[t]:m,...h}=e.messageIdsByThreadId,{[t]:g,..._}=e.messageByThreadId,{[t]:v,...y}=e.activityIdsByThreadId,{[t]:b,...x}=e.activityByThreadId,{[t]:S,...C}=e.proposedPlanIdsByThreadId,{[t]:w,...T}=e.proposedPlanByThreadId,{[t]:E,...D}=e.turnDiffIdsByThreadId,{[t]:O,...ee}=e.turnDiffSummaryByThreadId,{[t]:te,...k}=e.sidebarThreadSummaryById;return{...e,threadIds:a,threadIdsByProjectId:s,threadShellById:l,threadSessionById:d,threadTurnStateById:p,messageIdsByThreadId:h,messageByThreadId:_,activityIdsByThreadId:y,activityByThreadId:x,proposedPlanIdsByThreadId:C,proposedPlanByThreadId:T,turnDiffIdsByThreadId:D,turnDiffSummaryByThreadId:ee,sidebarThreadSummaryById:k}}function MYe(e,t){let n=new Set(e.threadIdsByProjectId[t]??NX);for(let[r,i]of Object.entries(e.threadShellById))i.projectId===t&&n.add(r);for(let[r,i]of Object.entries(e.sidebarThreadSummaryById))i.projectId===t&&n.add(r);return[...n]}function rZ(e,t){let n=MYe(e,t);if(!e.projectById[t]&&n.length===0&&!e.projectIds.includes(t))return e;let r=e;for(let e of n)r=nZ(r,e);let{[t]:i,...a}=r.projectById;return{...r,projectById:a,projectIds:XX(r.projectIds,t)}}function iZ(e){return e===`error`?`error`:e===`missing`?`interrupted`:`completed`}function NYe(e,t){if(e.sequence!==void 0&&t.sequence!==void 0){if(e.sequence!==t.sequence)return e.sequence-t.sequence}else if(e.sequence!==void 0)return 1;else if(t.sequence!==void 0)return-1;return e.createdAt.localeCompare(t.createdAt)||e.id.localeCompare(t.id)}function aZ(e){let t=e.previous?.turnId===e.turnId?e.previous.sourceProposedPlan:e.sourceProposedPlan;return{turnId:e.turnId,state:e.state,requestedAt:e.requestedAt,startedAt:e.startedAt,completedAt:e.completedAt,assistantMessageId:e.assistantMessageId,...t?{sourceProposedPlan:t}:{}}}function PYe(e,t,n){let r=!1,i=e.map(e=>e.turnId!==t||e.assistantMessageId===n?e:(r=!0,{...e,assistantMessageId:n??void 0}));return r?i:[...e]}function FYe(e,t,n){let r=new Set;for(let n of e){if(n.role===`system`){r.add(n.id);continue}n.turnId!==void 0&&n.turnId!==null&&t.has(n.turnId)&&r.add(n.id)}let i=e.filter(e=>e.role===`user`&&r.has(e.id)).length,a=Math.max(0,n-i);if(a>0){let n=e.filter(e=>e.role===`user`&&!r.has(e.id)&&(e.turnId===void 0||e.turnId===null||t.has(e.turnId))).toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.id.localeCompare(t.id)).slice(0,a);for(let e of n)r.add(e.id)}let o=e.filter(e=>e.role===`assistant`&&r.has(e.id)).length,s=Math.max(0,n-o);if(s>0){let n=e.filter(e=>e.role===`assistant`&&!r.has(e.id)&&(e.turnId===void 0||e.turnId===null||t.has(e.turnId))).toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.id.localeCompare(t.id)).slice(0,s);for(let e of n)r.add(e.id)}return e.filter(e=>r.has(e.id))}function IYe(e,t){return e.filter(e=>e.turnId===null||t.has(e.turnId))}function LYe(e,t){return e.filter(e=>e.turnId===null||t.has(e.turnId))}function RYe(e){switch(e){case`starting`:return`connecting`;case`running`:return`running`;case`error`:return`error`;case`ready`:case`interrupted`:return`ready`;case`idle`:case`stopped`:return`closed`}}function zYe(e){return e===`codex`||e===`claudeAgent`||e===`ollama`||e===`cmmd`||e===`apex`?e:`codex`}function BYe(e){return`/attachments/${encodeURIComponent(e)}`}function oZ(e,t,n){let r=kX(e,t);if(!r)return e;let i=n(r);return i===r?e:$X(e,i,r)}function VYe(e){return{projectIds:e.map(e=>e.id),projectById:Object.fromEntries(e.map(e=>[e.id,e]))}}function sZ(e,t){return e.environmentStateById[t]??MX}function cZ(e,t,n){let r=e.environmentStateById[t]===n?e.environmentStateById:{...e.environmentStateById,[t]:n};return r===e.environmentStateById?e:{...e,environmentStateById:r}}function HYe(e,t,n){let r=t.projects.map(e=>CX(e,n)),i=new Set(t.threads.map(e=>e.id)),a={...e,...VYe(r),threadIds:[],threadIdsByProjectId:{},threadShellById:{},threadSessionById:{},threadTurnStateById:{},threadRateLimitStatusById:tZ(e.threadRateLimitStatusById,i),sidebarThreadSummaryById:{},messageIdsByThreadId:tZ(e.messageIdsByThreadId,i),messageByThreadId:tZ(e.messageByThreadId,i),activityIdsByThreadId:tZ(e.activityIdsByThreadId,i),activityByThreadId:tZ(e.activityByThreadId,i),proposedPlanIdsByThreadId:tZ(e.proposedPlanIdsByThreadId,i),proposedPlanByThreadId:tZ(e.proposedPlanByThreadId,i),turnDiffIdsByThreadId:tZ(e.turnDiffIdsByThreadId,i),turnDiffSummaryByThreadId:tZ(e.turnDiffSummaryByThreadId,i),bootstrapComplete:!0};for(let e of t.threads)a=eZ(a,VX(e,n));return a}function UYe(e,t,n){return cZ(e,n,HYe(sZ(e,n),t,n))}function WYe(e,t,n){let r=sZ(e,n),i=kX(r,t.id);return cZ(e,n,$X(r,BX(t,n),i))}function GYe(e,t,n,r){let i=sZ(e,t);return cZ(e,t,{...i,threadSubscriptionErrorById:{...i.threadSubscriptionErrorById,[n]:r}})}function KYe(e,t,n){let r=sZ(e,t);if(!(n in r.threadSubscriptionErrorById))return e;let{[n]:i,...a}=r.threadSubscriptionErrorById;return cZ(e,t,{...r,threadSubscriptionErrorById:a})}function lZ(e,t,n){switch(t.type){case`project.created`:{let r=CX({id:t.payload.projectId,title:t.payload.title,workspaceRoot:t.payload.workspaceRoot,repositoryIdentity:t.payload.repositoryIdentity??null,defaultModelSelection:t.payload.defaultModelSelection,defaultThreadEnvMode:t.payload.defaultThreadEnvMode??null,cmmdRegistration:t.payload.cmmdRegistration??null,scripts:t.payload.scripts,createdAt:t.payload.createdAt,updatedAt:t.payload.updatedAt,deletedAt:null},n),i=e.projectIds.find(n=>n===t.payload.projectId||e.projectById[n]?.cwd===t.payload.workspaceRoot)??null,a=e.projectById,o=e.projectIds;if(i!==null&&i!==r.id){let{[i]:t,...n}=e.projectById;a={...n,[r.id]:r},o=e.projectIds.map(e=>e===i?r.id:e)}else a={...e.projectById,[r.id]:r},o=i===null&&!e.projectIds.includes(r.id)?[...e.projectIds,r.id]:e.projectIds;return{...e,projectById:a,projectIds:o}}case`project.meta-updated`:{let n=e.projectById[t.payload.projectId];if(!n)return e;let r=cYe(n,t.payload);return{...e,projectById:{...e.projectById,[t.payload.projectId]:r}}}case`project.deleted`:return rZ(e,t.payload.projectId);case`thread.created`:{let r=kX(e,t.payload.threadId);return $X(e,BX({id:t.payload.threadId,projectId:t.payload.projectId,title:t.payload.title,modelSelection:t.payload.modelSelection,runtimeMode:t.payload.runtimeMode,interactionMode:t.payload.interactionMode,branch:t.payload.branch,worktreePath:t.payload.worktreePath,latestTurn:null,createdAt:t.payload.createdAt,updatedAt:t.payload.updatedAt,archivedAt:null,deletedAt:null,messages:[],proposedPlans:[],activities:[],checkpoints:[],session:null,anchorKind:t.payload.anchorKind,anchorCmmdId:t.payload.anchorCmmdId,kind:t.payload.kind,parentThreadId:t.payload.parentThreadId,status:t.payload.status,workerRole:t.payload.workerRole,goal:t.payload.goal??null,titleRegeneration:null,pendingAutoCreatePrompt:null},n),r)}case`thread.deleted`:return nZ(e,t.payload.threadId);case`thread.archived`:return jX(e,t.payload.threadId,t.payload.updatedAt,{archivedAt:t.payload.archivedAt});case`thread.unarchived`:return jX(e,t.payload.threadId,t.payload.updatedAt,{archivedAt:null});case`thread.settled`:return jX(e,t.payload.threadId,t.payload.updatedAt,{settledAt:t.payload.settledAt,settledOverride:t.payload.settledOverride});case`thread.unsettled`:return jX(e,t.payload.threadId,t.payload.updatedAt,{settledAt:null,settledOverride:`active`});case`thread.meta-updated`:return oZ(e,t.payload.threadId,e=>({...e,...t.payload.title===void 0?{}:{title:t.payload.title},...t.payload.modelSelection===void 0?{}:{modelSelection:wX(t.payload.modelSelection)},...t.payload.branch===void 0?{}:{branch:t.payload.branch},...t.payload.worktreePath===void 0?{}:{worktreePath:t.payload.worktreePath},...t.payload.anchorKind===void 0?{}:{anchorKind:t.payload.anchorKind},...t.payload.anchorCmmdId===void 0?{}:{anchorCmmdId:t.payload.anchorCmmdId},...t.payload.status===void 0?{}:{status:t.payload.status},...t.payload.parentThreadId===void 0?{}:{parentThreadId:t.payload.parentThreadId},...t.payload.goal===void 0?{}:{goal:t.payload.goal},...t.payload.linkedPullRequest===void 0?{}:{linkedPullRequest:t.payload.linkedPullRequest},...t.payload.titleRegeneration===void 0?{}:{titleRegeneration:t.payload.titleRegeneration},updatedAt:t.payload.updatedAt}));case`thread.runtime-mode-set`:return oZ(e,t.payload.threadId,e=>({...e,runtimeMode:t.payload.runtimeMode,updatedAt:t.payload.updatedAt}));case`thread.interaction-mode-set`:return oZ(e,t.payload.threadId,e=>({...e,interactionMode:t.payload.interactionMode,updatedAt:t.payload.updatedAt}));case`thread.turn-start-requested`:return oZ(e,t.payload.threadId,e=>({...e,...t.payload.modelSelection===void 0?{}:{modelSelection:wX(t.payload.modelSelection)},runtimeMode:t.payload.runtimeMode,interactionMode:t.payload.interactionMode,pendingSourceProposedPlan:t.payload.sourceProposedPlan,latestTurn:aZ({previous:e.latestTurn,turnId:hn.make(t.payload.messageId),state:`running`,requestedAt:t.payload.createdAt,startedAt:t.payload.createdAt,completedAt:null,assistantMessageId:null,sourceProposedPlan:t.payload.sourceProposedPlan}),updatedAt:t.occurredAt}));case`thread.turn-interrupt-requested`:return t.payload.turnId===void 0?e:oZ(e,t.payload.threadId,e=>{let n=e.latestTurn;return n===null||n.turnId!==t.payload.turnId?e:{...e,latestTurn:aZ({previous:n,turnId:t.payload.turnId,state:`interrupted`,requestedAt:n.requestedAt,startedAt:n.startedAt??t.payload.createdAt,completedAt:n.completedAt??t.payload.createdAt,assistantMessageId:n.assistantMessageId}),updatedAt:t.occurredAt}});case`thread.message-sent`:return oZ(e,t.payload.threadId,e=>{let n=LX(e.environmentId,{id:t.payload.messageId,role:t.payload.role,text:t.payload.text,...t.payload.attachments===void 0?{}:{attachments:t.payload.attachments},turnId:t.payload.turnId,streaming:t.payload.streaming,createdAt:t.payload.createdAt,updatedAt:t.payload.updatedAt}),r=(e.messages.find(e=>e.id===n.id)?e.messages.map(e=>e.id===n.id?{...e,text:n.streaming?`${e.text}${n.text}`:n.text.length>0?n.text:e.text,streaming:n.streaming,...n.turnId===void 0?{}:{turnId:n.turnId},...n.streaming?e.completedAt===void 0?{}:{completedAt:e.completedAt}:n.completedAt===void 0?{}:{completedAt:n.completedAt},...n.attachments===void 0?{}:{attachments:n.attachments}}:e):[...e.messages,n]).slice(-2e3),i=t.payload.role===`assistant`&&t.payload.turnId!==null?PYe(e.turnDiffSummaries,t.payload.turnId,t.payload.messageId):e.turnDiffSummaries,a=t.payload.role===`assistant`&&t.payload.turnId!==null&&(e.latestTurn===null||e.latestTurn.turnId===t.payload.turnId)?aZ({previous:e.latestTurn,turnId:t.payload.turnId,state:t.payload.streaming?`running`:e.latestTurn?.state===`interrupted`?`interrupted`:e.latestTurn?.state===`error`?`error`:`completed`,requestedAt:e.latestTurn?.turnId===t.payload.turnId?e.latestTurn.requestedAt:t.payload.createdAt,startedAt:e.latestTurn?.turnId===t.payload.turnId?e.latestTurn.startedAt??t.payload.createdAt:t.payload.createdAt,sourceProposedPlan:e.pendingSourceProposedPlan,completedAt:t.payload.streaming?e.latestTurn?.turnId===t.payload.turnId?e.latestTurn.completedAt??null:null:t.payload.updatedAt,assistantMessageId:t.payload.messageId}):e.latestTurn;return{...e,messages:r,turnDiffSummaries:i,latestTurn:a,updatedAt:t.occurredAt}});case`thread.session-set`:return oZ(e,t.payload.threadId,e=>({...e,session:IX(t.payload.session),error:kK(t.payload.session.lastError),latestTurn:t.payload.session.status===`running`&&t.payload.session.activeTurnId!==null?aZ({previous:e.latestTurn,turnId:t.payload.session.activeTurnId,state:`running`,requestedAt:e.latestTurn?.turnId===t.payload.session.activeTurnId?e.latestTurn.requestedAt:t.payload.session.updatedAt,startedAt:e.latestTurn?.turnId===t.payload.session.activeTurnId?e.latestTurn.startedAt??t.payload.session.updatedAt:t.payload.session.updatedAt,completedAt:null,assistantMessageId:e.latestTurn?.turnId===t.payload.session.activeTurnId?e.latestTurn.assistantMessageId:null,sourceProposedPlan:e.pendingSourceProposedPlan}):e.latestTurn,updatedAt:t.occurredAt}));case`thread.session-stop-requested`:return oZ(e,t.payload.threadId,e=>e.session===null?e:{...e,session:{...e.session,status:`closed`,orchestrationStatus:`stopped`,activeTurnId:void 0,updatedAt:t.payload.createdAt},updatedAt:t.occurredAt});case`thread.proposed-plan-upserted`:return oZ(e,t.payload.threadId,e=>{let n=RX(t.payload.proposedPlan),r=[...e.proposedPlans.filter(e=>e.id!==n.id),n].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.id.localeCompare(t.id)).slice(-200);return{...e,proposedPlans:r,updatedAt:t.occurredAt}});case`thread.turn-diff-completed`:return oZ(e,t.payload.threadId,e=>{let n=zX({turnId:t.payload.turnId,checkpointTurnCount:t.payload.checkpointTurnCount,checkpointRef:t.payload.checkpointRef,status:t.payload.status,files:t.payload.files,assistantMessageId:t.payload.assistantMessageId,completedAt:t.payload.completedAt}),r=e.turnDiffSummaries.find(e=>e.turnId===n.turnId);if(r&&r.status!==`missing`&&n.status===`missing`)return e;let i=[...e.turnDiffSummaries.filter(e=>e.turnId!==n.turnId),n].toSorted((e,t)=>(e.checkpointTurnCount??2**53-1)-(t.checkpointTurnCount??2**53-1)).slice(-500),a=e.latestTurn===null||e.latestTurn.turnId===t.payload.turnId?aZ({previous:e.latestTurn,turnId:t.payload.turnId,state:iZ(t.payload.status),requestedAt:e.latestTurn?.requestedAt??t.payload.completedAt,startedAt:e.latestTurn?.startedAt??t.payload.completedAt,completedAt:t.payload.completedAt,assistantMessageId:t.payload.assistantMessageId,sourceProposedPlan:e.pendingSourceProposedPlan}):e.latestTurn;return{...e,turnDiffSummaries:i,latestTurn:a,updatedAt:t.occurredAt}});case`thread.reverted`:return oZ(e,t.payload.threadId,e=>{let n=e.turnDiffSummaries.filter(e=>e.checkpointTurnCount!==void 0&&e.checkpointTurnCount<=t.payload.turnCount).toSorted((e,t)=>(e.checkpointTurnCount??2**53-1)-(t.checkpointTurnCount??2**53-1)).slice(-500),r=new Set(n.map(e=>e.turnId)),i=FYe(e.messages,r,t.payload.turnCount).slice(-2e3),a=LYe(e.proposedPlans,r).slice(-200),o=IYe(e.activities,r),s=n.at(-1)??null;return{...e,turnDiffSummaries:n,messages:i,proposedPlans:a,activities:o,pendingSourceProposedPlan:void 0,latestTurn:s===null?null:{turnId:s.turnId,state:iZ(s.status??`ready`),requestedAt:s.completedAt,startedAt:s.completedAt,completedAt:s.completedAt,assistantMessageId:s.assistantMessageId??null},updatedAt:t.occurredAt}});case`thread.activity-appended`:return oZ(e,t.payload.threadId,e=>{let n=[...e.activities.filter(e=>e.id!==t.payload.activity.id),{...t.payload.activity}].toSorted(NYe).slice(-500);return{...e,activities:n,updatedAt:t.occurredAt}});case`thread.rate-limit-set`:return oZ(e,t.payload.threadId,e=>({...e,rateLimitStatus:SYe(e.rateLimitStatus??[],t.payload),updatedAt:t.occurredAt}));case`thread.worker-spawned`:return oZ(e,t.payload.workerThreadId,e=>({...e,kind:`worker`,parentThreadId:t.payload.masterThreadId,branch:t.payload.branch,worktreePath:t.payload.worktreePath,workerRole:t.payload.workerRole??e.workerRole??null,updatedAt:t.occurredAt}));case`thread.approval-response-requested`:case`thread.user-input-response-requested`:return e}return e}function qYe(e,t,n){switch(t.kind){case`project-upserted`:{let r=CX(t.project,n),i=e.projectIds.find(n=>n===t.project.id||e.projectById[n]?.cwd===t.project.workspaceRoot)??null,a=e.projectById,o=e.projectIds;if(i!==null&&i!==r.id){let{[i]:t,...n}=e.projectById;a={...n,[r.id]:r},o=e.projectIds.map(e=>e===i?r.id:e)}else a={...e.projectById,[r.id]:r},o=i===null&&!e.projectIds.includes(r.id)?[...e.projectIds,r.id]:e.projectIds;return{...e,projectById:a,projectIds:o}}case`project-removed`:return rZ(e,t.projectId);case`thread-upserted`:return eZ(e,VX(t.thread,n));case`thread-removed`:return nZ(e,t.threadId)}}function JYe(e,t,n){if(t.length===0)return e;let r=sZ(e,n);return cZ(e,n,t.reduce((e,t)=>lZ(e,t,n),r))}function uZ(e){return Object.entries(e.environmentStateById)}function dZ(e,t){return t?sZ(e,t):MX}function YYe(e,t){return ZX(dZ(e,t))}function fZ(e){return uZ(e).flatMap(([,e])=>jYe(e))}function pZ(e){return uZ(e).flatMap(([,e])=>ZX(e))}function XYe(e){return uZ(e).flatMap(([,e])=>mZ(e).flatMap(t=>{let n=e.threadShellById[t];return n?[n]:[]}))}function mZ(e){let t=[],n=new Set,r=e=>{n.has(e)||(n.add(e),t.push(e))};for(let t of e.threadIds)r(t);for(let t of Object.keys(e.threadShellById))r(t);for(let t of Object.keys(e.sidebarThreadSummaryById))r(t);return t}function hZ(e,t,n){let r=t.sidebarThreadSummaryById[n];if(r)return r.environmentId===e?r:{...r,environmentId:e};let i=t.threadShellById[n];return i?{id:i.id,environmentId:e,projectId:i.projectId,title:i.title,modelSelection:i.modelSelection,interactionMode:i.interactionMode,session:t.threadSessionById[n]??null,createdAt:i.createdAt,archivedAt:i.archivedAt,settledAt:i.settledAt,settledOverride:i.settledOverride,updatedAt:i.updatedAt,latestTurn:t.threadTurnStateById[n]?.latestTurn??null,branch:i.branch,worktreePath:i.worktreePath,latestUserMessageAt:null,hasPendingApprovals:!1,hasPendingUserInput:!1,hasActionableProposedPlan:!1,anchorKind:i.anchorKind,anchorCmmdId:i.anchorCmmdId,goal:i.goal,titleRegeneration:i.titleRegeneration,kind:i.kind,parentThreadId:i.parentThreadId,workerRole:i.workerRole,status:i.status}:null}function ZYe(e){return uZ(e).flatMap(([e,t])=>mZ(t).flatMap(n=>{let r=hZ(e,t,n);return r?[r]:[]}))}function gZ(e,t){if(!t)return[];let n=dZ(e,t.environmentId),r=n.threadIdsByProjectId[t.projectId]??NX;return(r.length>0?r:mZ(n)).flatMap(e=>{let r=hZ(t.environmentId,n,e);return!r||r.projectId!==t.projectId?[]:[r]})}function QYe(e,t){return t.length===0?[]:t.length===1?gZ(e,t[0]):t.flatMap(t=>gZ(e,t))}function $Ye(e){return e.activeEnvironmentId===null?Object.values(e.environmentStateById).some(e=>e.bootstrapComplete):dZ(e,e.activeEnvironmentId).bootstrapComplete}function eXe(e,t){return t?dZ(e,t.environmentId).projectById[t.projectId]:void 0}function _Z(e,t){return t?kX(dZ(e,t.environmentId),t.threadId):void 0}function tXe(e,t){return t?dZ(e,t.environmentId).threadShellById[t.threadId]!==void 0:!1}function vZ(e,t){return t?hZ(t.environmentId,dZ(e,t.environmentId),t.threadId)??void 0:void 0}function nXe(e,t,n){if(e.activeEnvironmentId===null)return e;let r=oZ(sZ(e,e.activeEnvironmentId),t,e=>e.error===n?e:{...e,error:n});return cZ(e,e.activeEnvironmentId,r)}function rXe(e,t,n){return cZ(e,n,lZ(sZ(e,n),t,n))}function iXe(e,t,n){return cZ(e,n,qYe(sZ(e,n),t,n))}function aXe(e,t){return e.activeEnvironmentId===t?e:{...e,activeEnvironmentId:t}}function oXe(e,t,n,r){let i=oZ(sZ(e,t.environmentId),t.threadId,e=>{if(e.branch===n&&e.worktreePath===r)return e;let t=e.worktreePath!==r;return{...e,branch:n,worktreePath:r,...t?{session:null}:{}}});return cZ(e,t.environmentId,i)}var yZ=Wt(e=>({...CYe,setActiveEnvironmentId:t=>e(e=>aXe(e,t)),syncServerShellSnapshot:(t,n)=>e(e=>UYe(e,t,n)),syncServerThreadDetail:(t,n)=>e(e=>WYe(e,t,n)),setThreadSubscriptionError:(t,n,r)=>e(e=>GYe(e,t,n,r)),clearThreadSubscriptionError:(t,n)=>e(e=>KYe(e,t,n)),applyOrchestrationEvent:(t,n)=>e(e=>rXe(e,t,n)),applyOrchestrationEvents:(t,n)=>e(e=>JYe(e,t,n)),applyShellEvent:(t,n)=>e(e=>iXe(e,t,n)),setError:(t,n)=>e(e=>nXe(e,t,n)),setThreadBranch:(t,n,r)=>e(e=>oXe(e,t,n,r))})),bZ=`Thread not found or you no longer have access.`;function sXe(e){if(e==null)return bZ;let t=SX(ate(e)?Pe(e):e,bZ);return/\bnot found\b/i.test(t)?bZ:t}function cXe(e,t,n){yZ.getState().setThreadSubscriptionError(e,t,sXe(n))}function lXe(e){let t=new Set,n=new Map(e.snapshotThreads.map(e=>[e.key,e]));for(let n of e.snapshotThreads)n.deletedAt===null&&n.archivedAt===null&&t.add(n.key);for(let r of e.draftThreadKeys){let e=n.get(r);e&&(e.deletedAt!==null||e.archivedAt!==null)||t.add(r)}return t}function uXe(e){let t=new Map,n=!1;for(let r of e)switch(r.type){case`thread.turn-diff-completed`:case`thread.reverted`:n=!0;break;case`thread.created`:t.set(r.payload.threadId,{clearPromotedDraft:!0,clearDeletedThread:!1,removeTerminalState:!1});break;case`thread.deleted`:t.set(r.payload.threadId,{clearPromotedDraft:!1,clearDeletedThread:!0,removeTerminalState:!0});break;case`thread.archived`:t.set(r.payload.threadId,{clearPromotedDraft:!1,clearDeletedThread:!1,removeTerminalState:!0});break;case`thread.unarchived`:t.set(r.payload.threadId,{clearPromotedDraft:!1,clearDeletedThread:!1,removeTerminalState:!1})}let r=[],i=[],a=[];for(let[e,n]of t)n.clearPromotedDraft&&r.push(e),n.clearDeletedThread&&i.push(e),n.removeTerminalState&&a.push(e);return{promoteDraftThreadIds:r,clearDeletedThreadIds:i,removeTerminalStateThreadIds:a,needsProviderInvalidation:n}}var xZ={all:[`projects`],searchEntries:(e,t,n,r)=>[`projects`,`search-entries`,e??null,t,n,r]},SZ={all:[`providers`],checkpointDiff:e=>[`providers`,`checkpointDiff`,e.environmentId??null,e.threadId,e.fromTurnCount,e.toTurnCount,e.cacheScope??null]};function dXe(e){if(e!==void 0)return Object.fromEntries(Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t)))}function fXe(e){return{...e,...e.projectIds===void 0?{}:{projectIds:[...e.projectIds].toSorted((e,t)=>e.localeCompare(t))},...e.cursors===void 0?{}:{cursors:dXe(e.cursors)}}}var CZ={all:e=>[`pullRequests`,e],list:(e,t)=>[`pullRequests`,e,`list`,fXe(t)],stats:(e,t)=>[`pullRequests`,e,`stats`,[...t].toSorted((e,t)=>`${e.projectId}:${e.repository}#${e.number}`.localeCompare(`${t.projectId}:${t.repository}#${t.number}`))],detail:(e,t)=>[`pullRequests`,e,`detail`,t],activity:(e,t)=>[`pullRequests`,e,`activity`,t],diff:(e,t)=>[`pullRequests`,e,`diff`,t],threadComments:(e,t)=>[`pullRequests`,e,`thread-comments`,t],diffFileContents:(e,t)=>[`pullRequests`,e,`diff-file-contents`,t],reviewerCandidates:(e,t)=>[`pullRequests`,e,`reviewer-candidates`,t]},pXe=class extends Error{status;constructor(e,t){super(e),this.name=`RemoteEnvironmentAuthHttpError`,this.status=t}};function mXe(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 hXe(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 wZ(e){let t=mXe(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 pXe(await hXe(n,`Remote auth request failed (${n.status}).`),n.status);return await n.json()}async function TZ(e){return wZ({httpBaseUrl:e.httpBaseUrl,pathname:`/api/auth/session`,bearerToken:e.bearerToken,...e.signal?{signal:e.signal}:{}})}async function gXe(e){return wZ({httpBaseUrl:e.httpBaseUrl,pathname:`/.well-known/forge/environment`,...e.bearerToken?{bearerToken:e.bearerToken}:{}})}async function _Xe(e){return wZ({httpBaseUrl:e.httpBaseUrl,pathname:`/api/auth/ws-token`,method:`POST`,bearerToken:e.bearerToken})}async function EZ(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 _Xe({httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken});return t.searchParams.set(`wsToken`,n.token),t.toString()}function vXe(e,t){if(t){zne(t,e);return}Bne(e)}function yXe(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(`
|
|
1014
|
+
`)}}function bXe(e,t){let n=yXe(e);if(n.eventName!==`phase`||!n.data)return!1;try{let e=JSON.parse(n.data);return vXe(e,t),e.phase===`app-ready`||e.phase===`error`}catch{return!1}}async function xXe(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(`
|
|
1015
1015
|
|
|
1016
|
-
`);for(;o!==-1;){let e=a.slice(0,o);if(a=a.slice(o+2),
|
|
1016
|
+
`);for(;o!==-1;){let e=a.slice(0,o);if(a=a.slice(o+2),bXe(e,t))return;o=a.indexOf(`
|
|
1017
1017
|
|
|
1018
|
-
`)}}}var _Xe=(e=`/api/workspace/readiness`)=>{if(typeof fetch>`u`)return{close:()=>{}};let t=typeof e==`string`?{url:e}:e,n=!1,r=new AbortController;return fetch(t.url,{credentials:t.bearerToken?`omit`:`include`,signal:r.signal,...t.bearerToken?{headers:{Authorization:`Bearer ${t.bearerToken}`}}:{}}).then(e=>{if(e.ok)return gXe(e,t.environmentId,r.signal)}).catch(()=>{}),{close:()=>{n||(n=!0,r.abort())}}},vXe=6e4;function yXe(e){let t=new URL(e.target.httpBaseUrl);return t.pathname=`${t.pathname.endsWith(`/`)?t.pathname.slice(0,-1):t.pathname}/api/workspace/readiness`,t.search=``,t.hash=``,t.toString()}function bXe(e){let t=new Set,n=null,r=!1,i=!1;return{hasWaiters:()=>t.size>0,wait:()=>{if(r)return Promise.reject(n);if(i)return Promise.resolve();let a=null,o=null,s=new Promise((e,n)=>{o={resolve:e,reject:n},t.add(o)}),c=new Promise((t,n)=>{a=globalThis.setTimeout(()=>{n(Error(`Timed out while waiting for ${e.label} (${e.environmentId}) to stream its shell snapshot.`))},e.timeoutMs)});return Promise.race([s,c]).finally(()=>{a!==null&&globalThis.clearTimeout(a),o!==null&&t.delete(o)})},resolve:()=>{r=!1,n=null,i=!0;let e=[...t];t.clear();for(let t of e)t.resolve()},reject:e=>{r=!0,n=e,i=!1;let a=[...t];t.clear();for(let t of a)t.reject(e)},reset:()=>{r=!1,n=null,i=!1}}}function DZ(e){let t=e.knownEnvironment.environmentId;if(!t)throw Error(`Known environment ${e.knownEnvironment.label} is missing its environmentId.`);let n=!1,r=!1,i=null,a=null,o=bXe({environmentId:t,label:e.knownEnvironment.label,timeoutMs:e.bootstrapTimeoutMs??vXe}),s=e.readiness?(e.readiness.openStream??_Xe)({url:yXe(e.knownEnvironment),environmentId:t,...e.readiness.bearerToken?{bearerToken:e.readiness.bearerToken}:{}}):null,c=t=>{if(!r){r=!0;let n=Error(t);_(),e.client.dispose(),e.onIdentityMismatch?.(n)}return!1},l=(n,r)=>{if(e.tolerateReportedEnvironmentIdentity)return a===null?(a=n,!0):a===n||c(`Environment connection ${t} reported a changed runtime identity (${a} -> ${n}) via ${r}.`);let i=e.resolveEnvironmentId?.()??t;return i===n||c(`Environment connection ${i} changed identity to ${n} via ${r}.`)},u=()=>e.resolveEnvironmentId?.()??t,d=e.client.server.subscribeLifecycle(t=>{t.type===`welcome`&&l(t.payload.environment.environmentId,`server lifecycle welcome`)&&e.onWelcome?.(t.payload,u())}),f=e.client.server.subscribeConfig(t=>{if(t.type===`snapshot`){if(!l(t.config.environment.environmentId,`server config snapshot`))return;i=t.config,e.onConfigSnapshot?.(t.config);return}if(t.type!==`providerStatuses`||!i)return;let n={...i,providers:t.payload.providers};i=n,e.onConfigSnapshot?.(n)}),p=e.client.orchestration.subscribeShell(t=>{if(t.kind===`snapshot`){e.syncShellSnapshot(t.snapshot,u()),o.resolve();return}e.applyShellEvent(t,u())},{onResubscribe:()=>{n||o.reset()},onError:t=>{if(!n){if(o.hasWaiters()){o.reject(t);return}e.onShellSubscriptionError?.(t,u())}}}),m=e.client.terminal.onEvent(t=>{e.applyTerminalEvent(t,u())}),h=e.client.browser?.onEvent({},t=>{e.applyBrowserEvent(t,u())}),g=e.client.server.subscribeWorkspaceReadiness(e=>{n||N(async()=>{let{setWorkspaceReadinessPhaseForEnvironment:e}=await import(`./workspaceReadinessAtom-DZAbFDrM.js`).then(e=>e.r);return{setWorkspaceReadinessPhaseForEnvironment:e}},__vite__mapDeps([2,1,3,4])).then(({setWorkspaceReadinessPhaseForEnvironment:t})=>{n||t(u(),e)})}),_=()=>{n||(n=!0,e.onDispose?.(),s?.close(),p(),m(),h?.(),d(),f(),g())};return{kind:e.kind,environmentId:t,knownEnvironment:e.knownEnvironment,client:e.client,ensureBootstrapped:()=>o.wait(),reconnect:async()=>{o.reset();try{await e.client.reconnect(),await e.refreshMetadata?.(),await o.wait()}catch(e){throw o.reject(e),e}},...e.ensureProviderAuthority?{ensureProviderAuthority:e.ensureProviderAuthority}:{},dispose:async()=>{_(),await e.client.dispose()}}}function xXe(e){return!e.isWorking||e.msSinceLastEvent<e.stallThresholdMs?`none`:e.recoveryAttempts<e.maxResubscribeAttempts?`resubscribe`:e.recoveryAttempts<e.maxTotalAttempts?`reconnect`:`none`}var SXe=3e4,CXe=1e4,wXe=/^(localhost|[a-z0-9.-]+\.localhost|127(?:\.\d{1,3}){3}|\[[0:]+1\]|::1)(?::\d+)?(?:[/?#]|$)/i,OZ=/https?:\/\/[^\s"'`<>]+/gu,TXe=new RegExp(String.raw`\u001B(?:\][\s\S]*?(?:\u0007|\u001B\\)|[@-_][0-?]*[ -/]*[@-~])`,`gu`),EXe=/(https?:\/\/(?:localhost|[a-z0-9.-]+\.localhost|127(?:\.\d{1,3}){3}|\[[0:]+1\]|::1|10(?:\.\d{1,3}){3}|172\.(?:1[6-9]|2\d|3[01])(?:\.\d{1,3}){2}|192\.168(?:\.\d{1,3}){2}):)\s+(\d{1,5})(?=[/?#\s]|$)/giu;function kZ(e){let t=e.trim();if(!t||/^[a-z][a-z0-9+.-]*:\/\//i.test(t)&&!/^https?:\/\//i.test(t))return null;let n=t.split(/[/:?#]/,1)[0]??``,r=wXe.test(t)||jZ(n)?`http`:`https`,i=/^https?:\/\//i.test(t)?t:`${r}://${t}`;try{let e=new URL(i);return e.protocol!==`http:`&&e.protocol!==`https:`?null:e.toString()}catch{return null}}function DXe(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function AZ(e){try{let t=new URL(e);return Dne(t.hostname)}catch{return!1}}function jZ(e){return One(e)}function MZ(e){try{let t=new URL(e);if(t.protocol!==`http:`||!AZ(t.toString())&&!jZ(t.hostname)||!t.port)return null;let n=Number(t.port);return Number.isInteger(n)&&n>0&&n<=65535?n:null}catch{return null}}function OXe(e){let t=e.replace(/[.,;!?]+$/u,``);for(;t.endsWith(`)`)||t.endsWith(`]`)||t.endsWith(`}`);){let e=t.at(-1);if(!e)break;let n=e===`)`?`(`:e===`]`?`[`:`{`;if(t.split(n).length-1>=t.split(e).length-1)break;t=t.slice(0,-1)}return t}function kXe(e){return e.replace(TXe,``).replaceAll(/./gsu,e=>AXe(e)?``:e).replace(EXe,`$1$2`)}function AXe(e){let t=e.charCodeAt(0);return t>=0&&t<=8||t===11||t===12||t>=14&&t<=31||t===127}function NZ(e){let t=null,n=null,r=kXe(e);OZ.lastIndex=0;for(let e of r.matchAll(OZ)){let r=kZ(OXe(e[0]));!r||!MZ(r)||(t=r,AZ(r)&&(n=r))}return n??t}function jXe(e){let t=null;for(let n of e){let e=n.event,r=NZ(e.type===`output`?e.data:e.type===`started`||e.type===`restarted`?e.snapshot.history:``);r&&(t=r)}return t}function MXe(e){switch(e.type){case`activity`:return e.hasRunningSubprocess;case`started`:case`restarted`:case`exited`:return!1;default:return null}}var NXe=`forge:terminal-state:v1`,PZ=[],PXe=200,FZ=8;function FXe(e,t){if(t<=3&&e&&typeof e==`object`){let t=e;return{terminalStateByThreadKey:GZ(t.terminalStateByThreadKey??{}),terminalPreviewUrlByThreadKey:Object.fromEntries(Object.entries(t.terminalPreviewUrlByThreadKey??{}).filter(([e,t])=>!!Wo(e)&&typeof t?.url==`string`&&!!MZ(t.url)&&typeof t?.observedAt==`string`))}}return{terminalStateByThreadKey:{},terminalPreviewUrlByThreadKey:{}}}function IXe(){return mJ(typeof window<`u`?window.localStorage:void 0)}function LXe(e){let t=[...new Set(e.map(e=>e.trim()).filter(e=>e.length>0))];return t.length>0?t:[Qq]}function RXe(e,t){if(e.length===0)return[];let n=new Set(t);return[...new Set(e)].map(e=>e.trim()).filter(e=>e.length>0&&n.has(e))}function IZ(e){return`group-${e}`}function LZ(e,t){let n=e,r=2;for(;t.has(n);)n=`${e}-${r}`,r+=1;return t.add(n),n}function RZ(e,t){return e.findIndex(e=>e.terminalIds.includes(t))}function zXe(e){return[...new Set(e.map(e=>e.trim()).filter(e=>e.length>0))]}function BXe(e,t){let n=new Set(t),r=new Set,i=[],a=new Set;for(let t of e){let e=zXe(t.terminalIds).filter(e=>!(!n.has(e)||r.has(e)));if(e.length===0)continue;for(let t of e)r.add(t);let o=t.id.trim().length>0?t.id.trim():IZ(e[0]??`default`);i.push({id:LZ(o,a),terminalIds:e})}for(let e of t)r.has(e)||i.push({id:LZ(IZ(e),a),terminalIds:[e]});return i.length===0?[{id:IZ(Qq),terminalIds:[Qq]}]:i}function zZ(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function VXe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.id!==i.id||!zZ(r.terminalIds,i.terminalIds))return!1}return!0}function BZ(e,t){return e.terminalOpen===t.terminalOpen&&e.terminalHeight===t.terminalHeight&&e.activeTerminalId===t.activeTerminalId&&e.activeTerminalGroupId===t.activeTerminalGroupId&&zZ(e.terminalIds,t.terminalIds)&&zZ(e.runningTerminalIds,t.runningTerminalIds)&&VXe(e.terminalGroups,t.terminalGroups)}var VZ=Object.freeze({terminalOpen:!1,terminalHeight:280,terminalIds:[Qq],runningTerminalIds:[],activeTerminalId:Qq,terminalGroups:[{id:IZ(Qq),terminalIds:[Qq]}],activeTerminalGroupId:IZ(Qq)});function HZ(){return{...VZ,terminalIds:[...VZ.terminalIds],runningTerminalIds:[...VZ.runningTerminalIds],terminalGroups:$Z(VZ.terminalGroups)}}function UZ(){return VZ}function WZ(e){let t=LXe(e.terminalIds),n=t.length>0?t:[Qq],r=RXe(e.runningTerminalIds,n),i=n.includes(e.activeTerminalId)?e.activeTerminalId:n[0]??`default`,a=BXe(e.terminalGroups,n),o=a.some(t=>t.id===e.activeTerminalGroupId)?e.activeTerminalGroupId:null,s=a.find(e=>e.terminalIds.includes(i))?.id??null,c={terminalOpen:e.terminalOpen,terminalHeight:Number.isFinite(e.terminalHeight)&&e.terminalHeight>0?e.terminalHeight:280,terminalIds:n,runningTerminalIds:r,activeTerminalId:i,terminalGroups:a,activeTerminalGroupId:o??s??a[0]?.id??IZ(`default`)};return BZ(e,c)?e:c}function HXe(e){let t=WZ(e);if(t.terminalIds.length<=FZ)return t;let n=new Set,r=e=>{!e||n.size>=FZ||t.terminalIds.includes(e)&&n.add(e)};r(Qq),r(t.activeTerminalId);for(let e of t.runningTerminalIds)r(e);for(let e of t.terminalIds.toReversed())r(e);let i=t.terminalIds.filter(e=>n.has(e)),a=i[i.length-1]??i[0]??`default`,o=i.includes(t.activeTerminalId)?t.activeTerminalId:a;return WZ({...t,terminalIds:i.length>0?i:[Qq],runningTerminalIds:t.runningTerminalIds.filter(e=>n.has(e)),activeTerminalId:o,terminalGroups:t.terminalGroups.map(e=>({id:e.id,terminalIds:e.terminalIds.filter(e=>n.has(e))})).filter(e=>e.terminalIds.length>0)})}function GZ(e){return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>Wo(e)?[[e,HXe(t)]]:[]))}function UXe(e){return BZ(WZ(e),VZ)}function WXe(e){return e.trim().length>0}function KZ(e){return Vo(e)}function qZ(e,t){return`${KZ(e)}\u0000${t}`}function JZ(e,t){return qZ(e,t)}function YZ(e){let t=Date.parse(e);return Number.isFinite(t)?t:0}function XZ(e,t){let n=NZ(e);return n?{url:n,observedAt:t}:null}function GXe(e){return XZ(e.history,e.updatedAt)}function ZZ(e){return e.type===`output`?XZ(e.data,e.createdAt):e.type===`started`||e.type===`restarted`?XZ(e.snapshot.history,e.snapshot.updatedAt):null}function QZ(e,t,n){if(!n)return e;let r=KZ(t),i=e[r];return i&&YZ(i.observedAt)>YZ(n.observedAt)||i?.url===n.url&&i.observedAt===n.observedAt?e:{...e,[r]:n}}function $Z(e){return e.map(e=>({id:e.id,terminalIds:[...e.terminalIds]}))}function eQ(e,t,n,r){let i=qZ(n,r.terminalId),a=e[i]??PZ,o={id:t,event:r},s=a.length>=PXe?[...a.slice(1),o]:[...a,o];return{terminalEventEntriesByKey:{...e,[i]:s},nextTerminalEventId:t+1}}function tQ(e,t,n,r){let i=qZ(n,r.terminalId);return{terminalEventEntriesByKey:{...e,[i]:[{id:t,event:r}]},nextTerminalEventId:t+1}}function nQ(e){return e.sessionEpoch&&e.sequence!==void 0?{sessionEpoch:e.sessionEpoch,sequence:e.sequence}:null}function rQ(e,t,n){return!t||!e?!1:t.sessionEpoch===e.sessionEpoch?n?t.sequence<e.sequence:t.sequence<=e.sequence:!n}function iQ(e,t){let n={...e},r=!1;for(let e of Object.keys(n))e.startsWith(`${t}\u0000`)&&(delete n[e],r=!0);return r?n:e}function KXe(e){return{terminalId:e.terminalId,cwd:e.snapshot.cwd,worktreePath:e.snapshot.worktreePath}}function qXe(e,t){let n=KXe(t);return e?.runtimeEnv&&e.cwd===n.cwd&&e.worktreePath===n.worktreePath&&(e.terminalId===void 0||e.terminalId===t.terminalId)?{...n,runtimeEnv:e.runtimeEnv}:n}function aQ(e,t,n){let r=WZ(e);if(!WXe(t))return r;let i=!r.terminalIds.includes(t),a=i?[...r.terminalIds,t]:r.terminalIds,o=$Z(r.terminalGroups),s=RZ(o,t);if(s>=0&&(o[s].terminalIds=o[s].terminalIds.filter(e=>e!==t),o[s].terminalIds.length===0&&o.splice(s,1)),n===`new`){let e=new Set(o.map(e=>e.id)),n=LZ(IZ(t),e);return o.push({id:n,terminalIds:[t]}),WZ({...r,terminalOpen:!0,terminalIds:a,activeTerminalId:t,terminalGroups:o,activeTerminalGroupId:n})}let c=o.findIndex(e=>e.id===r.activeTerminalGroupId);if(c<0&&(c=RZ(o,r.activeTerminalId)),c<0){let e=new Set(o.map(e=>e.id)),t=LZ(IZ(r.activeTerminalId),e);o.push({id:t,terminalIds:[r.activeTerminalId]}),c=o.length-1}let l=o[c];if(!l||i&&!l.terminalIds.includes(t)&&l.terminalIds.length>=4)return r;if(!l.terminalIds.includes(t)){let e=l.terminalIds.indexOf(r.activeTerminalId);e>=0?l.terminalIds.splice(e+1,0,t):l.terminalIds.push(t)}return WZ({...r,terminalOpen:!0,terminalIds:a,activeTerminalId:t,terminalGroups:o,activeTerminalGroupId:l.id})}function oQ(e,t){let n=WZ(e);return n.terminalOpen===t?n:{...n,terminalOpen:t}}function JXe(e,t){let n=WZ(e);return!Number.isFinite(t)||t<=0||n.terminalHeight===t?n:{...n,terminalHeight:t}}function YXe(e,t){return aQ(e,t,`split`)}function sQ(e,t,n){let r=aQ(e,t,`new`);return n?.openDrawer===!1?{...r,terminalOpen:e.terminalOpen}:r}function cQ(e,t){let n=WZ(e);if(!n.terminalIds.includes(t))return n;let r=n.terminalGroups.find(e=>e.terminalIds.includes(t))?.id??n.activeTerminalGroupId;return n.activeTerminalId===t&&n.activeTerminalGroupId===r?n:{...n,activeTerminalId:t,activeTerminalGroupId:r}}function XXe(e,t){let n=WZ(e);if(!n.terminalIds.includes(t))return n;let r=n.terminalIds.filter(e=>e!==t);if(r.length===0)return HZ();let i=n.terminalIds.indexOf(t),a=n.activeTerminalId===t?r[Math.min(i,r.length-1)]??r[0]??`default`:n.activeTerminalId,o=n.terminalGroups.map(e=>({...e,terminalIds:e.terminalIds.filter(e=>e!==t)})).filter(e=>e.terminalIds.length>0),s=o.find(e=>e.terminalIds.includes(a))?.id??o[0]?.id??IZ(a);return WZ({terminalOpen:n.terminalOpen,terminalHeight:n.terminalHeight,terminalIds:r,runningTerminalIds:n.runningTerminalIds.filter(e=>e!==t),activeTerminalId:a,terminalGroups:o,activeTerminalGroupId:s})}function lQ(e,t,n){let r=WZ(e);if(!r.terminalIds.includes(t)||n===r.runningTerminalIds.includes(t))return r;let i=new Set(r.runningTerminalIds);return n?i.add(t):i.delete(t),{...r,runningTerminalIds:[...i]}}function uQ(e,t){return!t||t.threadId.length===0?UZ():e[KZ(t)]??UZ()}function dQ(e,t,n){if(t.threadId.length===0)return e;let r=KZ(t),i=uQ(e,t),a=n(i);if(a===i)return e;if(UXe(a)){if(e[r]===void 0)return e;let{[r]:t,...n}=e;return n}return{...e,[r]:a}}function ZXe(e,t,n){return!t||t.threadId.length===0||n.trim().length===0?PZ:e[qZ(t,n)]??PZ}function QXe(e,t,n){return!t||t.threadId.length===0||n.trim().length===0?null:e[JZ(t,n)]??null}function $Xe(e,t){if(!t||t.threadId.length===0)return[];let n=`${KZ(t)}\u0000`;return Object.entries(e).filter(([e])=>e.startsWith(n)).map(([,e])=>e)}function eZe(e,t){return!t||t.threadId.length===0?null:e[KZ(t)]??null}var fQ=Wt()(sJ(e=>{let t=(t,n)=>{e(e=>{let r=dQ(e.terminalStateByThreadKey,t,n);return r===e.terminalStateByThreadKey?e:{terminalStateByThreadKey:r}})};return{terminalStateByThreadKey:{},terminalLaunchContextByThreadKey:{},terminalEventEntriesByKey:{},terminalSessionSnapshotByKey:{},terminalStreamCursorByKey:{},terminalPreviewUrlByThreadKey:{},nextTerminalEventId:1,setTerminalOpen:(e,n)=>t(e,e=>oQ(e,n)),setTerminalHeight:(e,n)=>t(e,e=>JXe(e,n)),splitTerminal:(e,n)=>t(e,e=>YXe(e,n)),newTerminal:(e,n,r)=>t(e,e=>sQ(e,n,r)),ensureTerminal:(e,n,r)=>t(e,e=>{let t=e;return e.terminalIds.includes(n)||(t=sQ(t,n)),r?.active===!1&&(t={...t,activeTerminalId:e.activeTerminalId,activeTerminalGroupId:e.activeTerminalGroupId}),(r?.active??!0)&&(t=cQ(t,n)),r?.open&&(t=oQ(t,!0)),WZ(t)}),setActiveTerminal:(e,n)=>t(e,e=>cQ(e,n)),closeTerminal:(e,n)=>t(e,e=>XXe(e,n)),setTerminalLaunchContext:(t,n)=>e(e=>({terminalLaunchContextByThreadKey:{...e.terminalLaunchContextByThreadKey,[KZ(t)]:n}})),clearTerminalLaunchContext:t=>e(e=>{let n=KZ(t);if(!e.terminalLaunchContextByThreadKey[n])return e;let{[n]:r,...i}=e.terminalLaunchContextByThreadKey;return{terminalLaunchContextByThreadKey:i}}),setTerminalActivity:(e,n,r)=>t(e,e=>lQ(e,n,r)),recordTerminalEvent:(t,n)=>e(e=>{let r=JZ(t,n.terminalId),i=nQ(n),a=n.type===`started`||n.type===`restarted`;if(rQ(e.terminalStreamCursorByKey[r],i,a))return e;let o=a&&i?tQ(e.terminalEventEntriesByKey,e.nextTerminalEventId,t,n):eQ(e.terminalEventEntriesByKey,e.nextTerminalEventId,t,n),s=i?{...e.terminalStreamCursorByKey,[r]:i}:e.terminalStreamCursorByKey,c=QZ(e.terminalPreviewUrlByThreadKey,t,ZZ(n));return n.type!==`started`&&n.type!==`restarted`?{...o,terminalStreamCursorByKey:s,terminalPreviewUrlByThreadKey:c}:{...o,terminalStreamCursorByKey:s,terminalPreviewUrlByThreadKey:c,terminalSessionSnapshotByKey:{...e.terminalSessionSnapshotByKey,[JZ(t,n.terminalId)]:n.snapshot}}}),applyTerminalEvent:(t,n)=>e(e=>{let r=KZ(t),i=JZ(t,n.terminalId),a=nQ(n),o=n.type===`started`||n.type===`restarted`;if(rQ(e.terminalStreamCursorByKey[i],a,o))return e;let s=e.terminalStateByThreadKey,c=e.terminalLaunchContextByThreadKey,l=e.terminalSessionSnapshotByKey,u=QZ(e.terminalPreviewUrlByThreadKey,t,ZZ(n));(n.type===`started`||n.type===`restarted`)&&(l={...l,[JZ(t,n.terminalId)]:n.snapshot},s=dQ(s,t,e=>{let t=e.activeTerminalId===n.terminalId,r=e;return e.terminalIds.includes(n.terminalId)||(r=sQ(r,n.terminalId)),t?(r=cQ(r,n.terminalId),r=oQ(r,!0)):(r=cQ(r,e.activeTerminalId),r=oQ(r,e.terminalOpen)),WZ(r)}),c={...c,[r]:qXe(c[r],n)});let d=MXe(n);d!==null&&(s=dQ(s,t,e=>lQ(e,n.terminalId,d)));let f=o&&a?tQ(e.terminalEventEntriesByKey,e.nextTerminalEventId,t,n):eQ(e.terminalEventEntriesByKey,e.nextTerminalEventId,t,n),p=a?{...e.terminalStreamCursorByKey,[i]:a}:e.terminalStreamCursorByKey;return{terminalStateByThreadKey:s,terminalLaunchContextByThreadKey:c,terminalSessionSnapshotByKey:l,terminalStreamCursorByKey:p,terminalPreviewUrlByThreadKey:u,...f}}),setTerminalSessionSnapshot:(t,n)=>e(e=>({terminalSessionSnapshotByKey:{...e.terminalSessionSnapshotByKey,[JZ(t,n.terminalId)]:n},terminalPreviewUrlByThreadKey:QZ(e.terminalPreviewUrlByThreadKey,t,GXe(n))})),clearTerminalState:t=>e(e=>{let n=KZ(t),r=dQ(e.terminalStateByThreadKey,t,()=>HZ()),i=e.terminalLaunchContextByThreadKey[n]!==void 0,a=e.terminalPreviewUrlByThreadKey[n]!==void 0,{[n]:o,...s}=e.terminalLaunchContextByThreadKey,{[n]:c,...l}=e.terminalPreviewUrlByThreadKey,u={...e.terminalEventEntriesByKey},d=!1;for(let e of Object.keys(u))e.startsWith(`${n}\u0000`)&&(delete u[e],d=!0);let f={...e.terminalSessionSnapshotByKey},p=!1;for(let e of Object.keys(f))e.startsWith(`${n}\u0000`)&&(delete f[e],p=!0);let m=iQ(e.terminalStreamCursorByKey,n);return r===e.terminalStateByThreadKey&&!i&&!a&&!d&&!p&&m===e.terminalStreamCursorByKey?e:{terminalStateByThreadKey:r,terminalLaunchContextByThreadKey:s,terminalPreviewUrlByThreadKey:l,terminalEventEntriesByKey:u,terminalSessionSnapshotByKey:f,terminalStreamCursorByKey:m}}),removeTerminalState:t=>e(e=>{let n=KZ(t),r=e.terminalStateByThreadKey[n]!==void 0,i=e.terminalLaunchContextByThreadKey[n]!==void 0,a=e.terminalPreviewUrlByThreadKey[n]!==void 0,o={...e.terminalEventEntriesByKey},s=!1;for(let e of Object.keys(o))e.startsWith(`${n}\u0000`)&&(delete o[e],s=!0);let c={...e.terminalSessionSnapshotByKey},l=!1;for(let e of Object.keys(c))e.startsWith(`${n}\u0000`)&&(delete c[e],l=!0);let u=iQ(e.terminalStreamCursorByKey,n);if(!r&&!i&&!a&&!s&&!l&&u===e.terminalStreamCursorByKey)return e;let d={...e.terminalStateByThreadKey};delete d[n];let f={...e.terminalLaunchContextByThreadKey};delete f[n];let p={...e.terminalPreviewUrlByThreadKey};return delete p[n],{terminalStateByThreadKey:d,terminalLaunchContextByThreadKey:f,terminalPreviewUrlByThreadKey:p,terminalEventEntriesByKey:o,terminalSessionSnapshotByKey:c,terminalStreamCursorByKey:u}}),removeOrphanedTerminalStates:t=>e(e=>{let n=Object.keys(e.terminalStateByThreadKey).filter(e=>!t.has(e)),r=Object.keys(e.terminalLaunchContextByThreadKey).filter(e=>!t.has(e)),i=Object.keys(e.terminalPreviewUrlByThreadKey).filter(e=>!t.has(e)),a={...e.terminalEventEntriesByKey},o=!1;for(let e of Object.keys(a)){let[n]=e.split(`\0`);n&&!t.has(n)&&(delete a[e],o=!0)}let s={...e.terminalSessionSnapshotByKey},c=!1;for(let e of Object.keys(s)){let[n]=e.split(`\0`);n&&!t.has(n)&&(delete s[e],c=!0)}let l={...e.terminalStreamCursorByKey},u=!1;for(let e of Object.keys(l)){let[n]=e.split(`\0`);n&&!t.has(n)&&(delete l[e],u=!0)}if(n.length===0&&r.length===0&&i.length===0&&!o&&!c&&!u)return e;let d={...e.terminalStateByThreadKey};for(let e of n)delete d[e];let f={...e.terminalLaunchContextByThreadKey};for(let e of r)delete f[e];let p={...e.terminalPreviewUrlByThreadKey};for(let e of i)delete p[e];return{terminalStateByThreadKey:d,terminalLaunchContextByThreadKey:f,terminalPreviewUrlByThreadKey:p,terminalEventEntriesByKey:a,terminalSessionSnapshotByKey:s,terminalStreamCursorByKey:l}})}},{name:NXe,version:4,storage:aJ(IXe),migrate:FXe,partialize:e=>({terminalStateByThreadKey:GZ(e.terminalStateByThreadKey),terminalPreviewUrlByThreadKey:e.terminalPreviewUrlByThreadKey})}));function tZe(e){return typeof e==`string`?e:typeof e==`object`&&e&&`detail`in e&&typeof e.detail==`string`?e.detail:e instanceof Error?e.message:String(e)}function nZe(e){return e.match(/blocked by policy for\s+([^.\s]+(?:\.[^.\s]+)*)\.?/i)?.[1]||(e.match(/navigation to\s+([^.\s]+(?:\.[^.\s]+)*)\s+is restricted/i)?.[1]??null)}function pQ(e){let t=tZe(e).trim()||`Unknown browser error.`,n=nZe(t);return/blocked by policy|restricted to allowed domains/i.test(t)?{title:`Browser navigation blocked`,cause:`${n??`This URL`} is not allowed by the current browser policy.`,nextAction:`Use an allowed URL or update the browser allowed-domain setting.`,technicalDetail:t}:/does not match thread|session .*not found|no active browser tab|tab .*not found/i.test(t)?{title:`Browser session is stale`,cause:`Forge no longer has a matching live browser session for this thread.`,nextAction:`Restart the browser session from the Browser options menu.`,technicalDetail:t}:/screenshot|capture|Page\.capture/i.test(t)?{title:`Browser screenshot failed`,cause:`The browser could not capture the current page frame.`,nextAction:`Reload the page, then try the screenshot again.`,technicalDetail:t}:/timed out|timeout/i.test(t)?{title:`Browser action timed out`,cause:`Forge did not receive a response from the browser runtime in time.`,nextAction:`Retry the action. If it keeps failing, restart the browser session.`,technicalDetail:t}:/runtime is not available|browser.*unavailable|not supported|disabled/i.test(t)?{title:`Browser session unavailable`,cause:`This environment does not currently expose the in-app browser runtime.`,nextAction:`Use a workspace with browser support or restart Forge after browser support is enabled.`,technicalDetail:t}:/navigate|navigation|net::|ERR_/i.test(t)?{title:`Browser navigation failed`,cause:`The browser could not load the requested page.`,nextAction:`Check the URL and network access, then try again.`,technicalDetail:t}:{title:`Browser action failed`,cause:`Forge could not complete the browser action.`,nextAction:`Retry the action. If it keeps failing, restart the browser session from the Browser options menu.`,technicalDetail:t}}function rZe(e){let t=pQ(e);return`${t.cause} ${t.nextAction}`}function iZe(e){let t=pQ(e);return`${t.title}: ${t.cause} ${t.nextAction}`}var mQ={session:null,selectedBrowserId:null,sessionsByBrowserId:{},lastActivityByTabId:{},lastSnapshotContentByTabId:{},lastScreenshotDataUrlByTabId:{},lastScreenshotMetaByTabId:{},lastConsoleLogsByTabId:{},lastConsoleLogsMetaByTabId:{},lastFrameByTabId:{},lastFrameSequenceByTabId:{},lastObservedFrameSequenceByTabId:{},lastFrameStreamIdByTabId:{},lastFrameStreamGenerationByTabId:{},frameGapCountByTabId:{},lastFrameMetaByTabId:{},displayIceCandidatesByClientId:{},lastError:null};function hQ(e){return Vo(e)}function aZe(e){let t=e.status===`reconnecting`&&e.reason===`network_unreachable`;return e.transport===`remote-webrtc`&&(e.status===`connected`||e.status===`connecting`||e.status===`reconnecting`)&&(e.reason!==`network_unreachable`||t)&&e.reason!==`unsupported_host`}function oZe(e){return e.transport!==`remote-webrtc`||e.status===`failed`||e.status===`unsupported`?!1:e.reason!==`network_unreachable`&&e.reason!==`unsupported_host`}function gQ(e){let{currentSession:t,nextSession:n}=e;return!t||t.browserId!==n.browserId||t.sessionId!==n.sessionId||!aZe(t.display)||!oZe(n.display)?n:{...n,display:{...t.display,viewport:n.display.viewport??n.viewport??t.display.viewport,devicePixelRatio:n.display.devicePixelRatio??t.display.devicePixelRatio,iceServers:n.display.iceServers??t.display.iceServers,reconnect:t.display.reconnect??n.display.reconnect}}}function sZe(e){let{storedSession:t,nextSession:n}=e;if(!t||t.browserId!==n.browserId||t.sessionId!==n.sessionId)return!1;let r=n.tabs.some(e=>e.navigationStatus===`pending`),i=t.tabs.some(e=>e.navigationStatus===`complete`||e.navigationStatus===`failed`);if(!r||!i)return!1;let a=Date.parse(t.updatedAt),o=Date.parse(n.updatedAt);return Number.isNaN(a)||Number.isNaN(o)?!1:o<a}function _Q(e,t,n){return e[t]===n?e:{...e,[t]:n}}function cZe(e){switch(e.type){case`tab.updated`:return e.payload.tab.tabId;case`tab.closed`:case`snapshot.ready`:case`screenshot.ready`:case`frame.ready`:case`console.logs.ready`:case`display.iceCandidate`:case`display.metrics`:return e.payload.tabId;case`action.failed`:return e.payload.tabId??null;case`display.updated`:case`session.started`:case`session.updated`:case`session.closed`:return null}}function lZe(e,t){let n=cZe(t);return n?{...e,lastActivityByTabId:{...e.lastActivityByTabId,[n]:{actor:t.agentId?`agent`:`human`,agentId:t.agentId,browserId:t.browserId,eventType:t.type,...t.type===`action.failed`?{commandType:t.payload.commandType}:{},...t.type===`action.failed`?{message:t.payload.message}:{},createdAt:t.createdAt}}}:e}function uZe(e){switch(e.type){case`session.started`:case`session.updated`:case`tab.updated`:case`snapshot.ready`:case`screenshot.ready`:case`frame.ready`:case`display.updated`:return!0;case`session.closed`:case`tab.closed`:case`console.logs.ready`:case`action.failed`:case`display.iceCandidate`:case`display.metrics`:return!1}}function vQ(e){return e===null?`end-of-candidates`:JSON.stringify([e.candidate,e.sdpMid??null,e.sdpMLineIndex??null,e.usernameFragment??null])}function dZe(e,t){let n=vQ(t);return e.some(e=>vQ(e)===n)?e:[...e,t]}function fZe(e){if(e.type!==`session.closed`)return null;switch(e.payload.reason){case`idle_timeout`:return`The browser was closed after being idle. Reopen the preview to restore this thread's browser.`;case`runtime_shutdown`:return`The browser runtime shut down. Reopen the preview to restore this thread's browser.`;case`thread_archived`:case`clear_browsing_data`:case`user_closed`:case void 0:return null}}function pZe(e){let t=e.event.payload.display;return t.status===`failed`||t.status===`unsupported`?t.detail??`Browser display is unavailable.`:e.currentLastError&&/browser display/i.test(e.currentLastError)?null:e.currentLastError}function mZe(e,t){let n=e.sessionsByBrowserId[t.browserId]??(e.session?.browserId===t.browserId?e.session:null);if(!n)return!0;let r=n.sessionId===t.payload.sessionId,i=!t.sessionEpoch||!n.sessionEpoch||t.sessionEpoch===n.sessionEpoch;return r&&i}function hZe(e,t){let n=e.lastFrameSequenceByTabId[t]??0;return{acceptedSequence:n,observedSequence:e.lastObservedFrameSequenceByTabId[t]??n,...e.lastFrameStreamIdByTabId[t]?{streamId:e.lastFrameStreamIdByTabId[t]}:{},...e.lastFrameStreamGenerationByTabId[t]===void 0?{}:{streamGeneration:e.lastFrameStreamGenerationByTabId[t]},...e.lastFrameMetaByTabId[t]?.capturedAt?{acceptedCapturedAt:e.lastFrameMetaByTabId[t].capturedAt}:{},gapCount:e.frameGapCountByTabId[t]??0}}function gZe(e,t){let n=t.payload.tabId,r=vce(hZe(e,n),{sequence:t.payload.sequence,capturedAt:t.payload.capturedAt,...t.payload.streamId?{streamId:t.payload.streamId}:{},...t.payload.streamGeneration===void 0?{}:{streamGeneration:t.payload.streamGeneration},...t.payload.keyframe===void 0?{}:{keyframe:t.payload.keyframe}});return{decision:r,observedSequence:r.state.observedSequence,frameGapCount:r.state.gapCount}}function _Ze(e,t,n){let r=t.payload.tabId;return{...e,lastObservedFrameSequenceByTabId:{...e.lastObservedFrameSequenceByTabId,[r]:n.observedSequence},frameGapCountByTabId:{...e.frameGapCountByTabId,[r]:n.frameGapCount}}}function vZe(e,t){let n=t.payload.tabId;return{...e,lastFrameByTabId:{...e.lastFrameByTabId,[n]:t.payload.imageDataUrl},lastFrameSequenceByTabId:{...e.lastFrameSequenceByTabId,[n]:t.payload.sequence},lastFrameStreamIdByTabId:t.payload.streamId?{...e.lastFrameStreamIdByTabId,[n]:t.payload.streamId}:e.lastFrameStreamIdByTabId,lastFrameStreamGenerationByTabId:t.payload.streamGeneration===void 0?e.lastFrameStreamGenerationByTabId:{...e.lastFrameStreamGenerationByTabId,[n]:t.payload.streamGeneration},lastFrameMetaByTabId:{...e.lastFrameMetaByTabId,[n]:{capturedAt:t.payload.capturedAt,url:t.payload.url,viewport:t.payload.viewport}},lastError:null}}function yZe(e){let{current:t,event:n,pendingAutoRevealKeys:r,state:i,threadKey:a}=e;if(!mZe(t,n))return i;let o=gZe(t,n);if(!o.decision.observe)return i;let s=_Ze(t,n,o),c=o.decision.accept?vZe(s,n):s;return{browserStateByThreadKey:_Q(i.browserStateByThreadKey,a,c),pendingAutoRevealKeys:r}}var yQ=Wt(e=>({browserStateByThreadKey:{},pendingAutoRevealKeys:new Set,setSessionSnapshot:(t,n)=>e(e=>{let r=hQ(t),i=e.browserStateByThreadKey[r]??mQ,a=n?gQ({currentSession:i.sessionsByBrowserId[n.browserId]??i.session,nextSession:n}):null;return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...i,session:a,selectedBrowserId:a?.browserId??i.selectedBrowserId,sessionsByBrowserId:a?{...i.sessionsByBrowserId,[a.browserId]:a}:i.sessionsByBrowserId,lastError:a?null:i.lastError})}}),selectBrowserSession:(t,n)=>e(e=>{let r=hQ(t),i=e.browserStateByThreadKey[r]??mQ,a=i.sessionsByBrowserId[n]??i.session;return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...i,selectedBrowserId:n,session:a})}}),applyBrowserEvent:(t,n)=>e(e=>{let r=hQ(t),i=uZe(n)?new Set(e.pendingAutoRevealKeys).add(r):e.pendingAutoRevealKeys,a=lZe(e.browserStateByThreadKey[r]??mQ,n);switch(n.type){case`session.started`:{if(sZe({storedSession:a.sessionsByBrowserId[n.payload.snapshot.browserId]??a.session,nextSession:n.payload.snapshot}))return e;let t=gQ({currentSession:a.sessionsByBrowserId[n.payload.snapshot.browserId]??a.session,nextSession:n.payload.snapshot});return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,session:t,selectedBrowserId:a.selectedBrowserId??t.browserId,sessionsByBrowserId:{...a.sessionsByBrowserId,[t.browserId]:t},lastError:null}),pendingAutoRevealKeys:i}}case`session.updated`:{let t=gQ({currentSession:a.sessionsByBrowserId[n.payload.snapshot.browserId]??a.session,nextSession:n.payload.snapshot});return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,session:a.selectedBrowserId&&a.selectedBrowserId!==n.payload.snapshot.browserId?a.session:t,selectedBrowserId:a.selectedBrowserId??n.payload.snapshot.browserId,sessionsByBrowserId:{...a.sessionsByBrowserId,[t.browserId]:t},lastError:null}),pendingAutoRevealKeys:i}}case`session.closed`:let t=a.selectedBrowserId===n.browserId||a.session?.browserId===n.browserId;return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,session:t?null:a.session,selectedBrowserId:t?null:a.selectedBrowserId,sessionsByBrowserId:Object.fromEntries(Object.entries(a.sessionsByBrowserId).filter(([e])=>e!==n.browserId)),lastError:fZe(n)})};case`display.updated`:{let t=a.session;if(!t||t.sessionId!==n.payload.sessionId)return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,a),pendingAutoRevealKeys:i};let o={...t,display:n.payload.display,updatedAt:n.createdAt};return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,session:o,sessionsByBrowserId:{...a.sessionsByBrowserId,[o.browserId]:o},lastError:pZe({currentLastError:a.lastError,event:n})}),pendingAutoRevealKeys:i}}case`tab.updated`:{let t=a.session;if(!t||t.sessionId!==n.payload.sessionId)return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,a),pendingAutoRevealKeys:i};let o=t.tabs.map(e=>e.tabId===n.payload.tab.tabId?{...n.payload.tab,isActive:e.tabId===t.activeTabId}:{...e,isActive:e.tabId===t.activeTabId}).concat(t.tabs.some(e=>e.tabId===n.payload.tab.tabId)?[]:[{...n.payload.tab,isActive:n.payload.tab.tabId===t.activeTabId}]);return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,session:{...t,tabs:o},lastError:null}),pendingAutoRevealKeys:i}}case`tab.closed`:{let t=a.session;if(!t||t.sessionId!==n.payload.sessionId)return e;let i=t.tabs.filter(e=>e.tabId!==n.payload.tabId);return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,session:{...t,tabs:i,activeTabId:t.activeTabId===n.payload.tabId?i[0]?.tabId??null:t.activeTabId}})}}case`snapshot.ready`:return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,lastSnapshotContentByTabId:{...a.lastSnapshotContentByTabId,[n.payload.tabId]:n.payload.content},lastError:null}),pendingAutoRevealKeys:i};case`screenshot.ready`:return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,lastScreenshotDataUrlByTabId:{...a.lastScreenshotDataUrlByTabId,[n.payload.tabId]:n.payload.imageDataUrl},lastScreenshotMetaByTabId:{...a.lastScreenshotMetaByTabId,[n.payload.tabId]:{captureId:n.payload.captureId,capturedAt:n.payload.capturedAt,url:n.payload.url,viewport:n.payload.viewport}},lastError:null}),pendingAutoRevealKeys:i};case`frame.ready`:return yZe({state:e,current:a,event:n,threadKey:r,pendingAutoRevealKeys:i});case`console.logs.ready`:return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,lastConsoleLogsByTabId:{...a.lastConsoleLogsByTabId,[n.payload.tabId]:n.payload.logs},lastConsoleLogsMetaByTabId:{...a.lastConsoleLogsMetaByTabId,[n.payload.tabId]:{capturedAt:n.createdAt,tabId:n.payload.tabId,count:n.payload.logs.length}},lastError:null})};case`display.iceCandidate`:{let t=a.displayIceCandidatesByClientId[n.payload.clientId]??[];return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,displayIceCandidatesByClientId:{...a.displayIceCandidatesByClientId,[n.payload.clientId]:dZe(t,n.payload.candidate)}}),pendingAutoRevealKeys:i}}case`display.metrics`:return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,a),pendingAutoRevealKeys:i};case`action.failed`:return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,lastError:iZe(n.payload.message)})};default:return e}}),clearBrowserState:t=>e(e=>{let n=hQ(t);if(!(n in e.browserStateByThreadKey))return e;let{[n]:r,...i}=e.browserStateByThreadKey;return{browserStateByThreadKey:i}}),consumeAutoReveal:t=>e(e=>{if(!e.pendingAutoRevealKeys.has(t))return e;let n=new Set(e.pendingAutoRevealKeys);return n.delete(t),{pendingAutoRevealKeys:n}})}));function bZe(e,t){return t?e[hQ(t)]??null:null}var xZe={threadRef:null,open:!1,minimized:!1,dock:`floating`,position:null};function SZe(e){return{x:Math.max(12,Math.min(e.position.x,e.viewportWidth-e.width-12)),y:Math.max(12,Math.min(e.position.y,e.viewportHeight-e.height-12))}}function CZe(e,t){return{...e,threadRef:t,open:!0,minimized:!1}}function wZe(e){let t=e.companion.threadRef;return!e.companion.open||t===null?!1:e.routeThreadRef?.environmentId!==t.environmentId||e.routeThreadRef.threadId!==t.threadId}var bQ=`forge:ui-state:v1`,xQ=[`t3code:ui-state:v1`,`t3code:renderer-state:v8`,`t3code:renderer-state:v7`,`t3code:renderer-state:v6`,`t3code:renderer-state:v5`,`t3code:renderer-state:v4`,`t3code:renderer-state:v3`,`codething:renderer-state:v4`,`codething:renderer-state:v3`,`codething:renderer-state:v2`,`codething:renderer-state:v1`],SQ=`months`,TZe=new Set([`weeks`,`months`,`quarters`]);function EZe(e){return typeof e==`string`&&TZe.has(e)?e:SQ}function CQ(e){return Number.isFinite(e)?Math.round(Math.min(560,Math.max(200,e))):360}var wQ={projectExpandedById:{},projectOrder:[],projectGroupOrder:[],lastActiveProject:null,threadLastVisitedAtById:{},threadChangedFilesExpandedById:{},pinnedThreadById:{},threadLinkedPrById:{},workspaceDensityById:{},timelineWorkColumnWidth:360,timelineScale:SQ,projectLeadCompanion:xZe},TQ=new Set,EQ=[],DQ=new Map,OQ=!1;function DZe(){if(typeof window>`u`)return wQ;try{let e=window.localStorage.getItem(bQ);if(!e){for(let e of xQ){let t=window.localStorage.getItem(e);if(t)return kQ(JSON.parse(t)),wQ}return wQ}let t=JSON.parse(e);return kQ(t),{...wQ,projectGroupOrder:OZe(t.projectGroupOrderKeys),threadChangedFilesExpandedById:jZe(t.threadChangedFilesExpandedById),pinnedThreadById:kZe(t.pinnedThreadKeys),threadLinkedPrById:AZe(t.threadLinkedPrById),timelineWorkColumnWidth:CQ(t.timelineWorkColumnWidth??360),timelineScale:EZe(t.timelineScale)}}catch{return wQ}}function OZe(e){return Array.isArray(e)?[...new Set(e.filter(e=>typeof e==`string`&&e.length>0))]:[]}function kZe(e){if(!Array.isArray(e))return{};let t={};for(let n of e)typeof n==`string`&&n.length>0&&(t[n]=!0);return t}function AZe(e){if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e))typeof n==`string`&&n.length!==0&&typeof r==`string`&&r.trim().length!==0&&(t[n]=r);return t}function jZe(e){if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e)){if(!n||!r||typeof r!=`object`)continue;let e={};for(let[t,n]of Object.entries(r))t&&typeof n==`boolean`&&n===!1&&(e[t]=!1);Object.keys(e).length>0&&(t[n]=e)}return t}function kQ(e){TQ.clear(),EQ.length=0;for(let t of e.expandedProjectCwds??[])typeof t==`string`&&t.length>0&&TQ.add(t);for(let t of e.projectOrderCwds??[])typeof t==`string`&&t.length>0&&!EQ.includes(t)&&EQ.push(t)}function MZe(e){if(!(typeof window>`u`))try{let t=Object.entries(e.projectExpandedById).filter(([,e])=>e).flatMap(([e])=>{let t=DQ.get(e);return t?[t]:[]}),n=e.projectOrder.flatMap(e=>{let t=DQ.get(e);return t?[t]:[]}),r=Object.fromEntries(Object.entries(e.threadChangedFilesExpandedById).flatMap(([e,t])=>{let n=Object.fromEntries(Object.entries(t).filter(([,e])=>e===!1));return Object.keys(n).length>0?[[e,n]]:[]}));if(window.localStorage.setItem(bQ,JSON.stringify({expandedProjectCwds:t,projectOrderCwds:n,projectGroupOrderKeys:e.projectGroupOrder,threadChangedFilesExpandedById:r,pinnedThreadKeys:Object.keys(e.pinnedThreadById).filter(t=>e.pinnedThreadById[t]),threadLinkedPrById:e.threadLinkedPrById,timelineWorkColumnWidth:e.timelineWorkColumnWidth,timelineScale:e.timelineScale})),!OQ){OQ=!0;for(let e of xQ)window.localStorage.removeItem(e)}}catch{}}var AQ=new qt(MZe,{wait:500});function jQ(e,t){let n=Object.entries(e),r=Object.entries(t);if(n.length!==r.length)return!1;for(let[e,r]of n)if(t[e]!==r)return!1;return!0}function MQ(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function NZe(e,t){let n=Object.entries(e),r=Object.entries(t);if(n.length!==r.length)return!1;for(let[e,r]of n)if(!(e in t)||!jQ(r,t[e]))return!1;return!0}function PZe(e,t){let n=new Map(DQ),r=new Map([...n.entries()].map(([e,t])=>[t,e]));DQ.clear();for(let e of t)DQ.set(e.key,e.cwd);let i=n.size!==DQ.size||t.some(e=>n.get(e.key)!==e.cwd),a={},o=e.projectExpandedById,s=new Map(EQ.map((e,t)=>[e,t])),c=t.map((e,t)=>{let n=r.get(e.cwd),i=o[e.key]??(n?o[n]:void 0)??(TQ.size>0?TQ.has(e.cwd):!0);return a[e.key]=i,{id:e.key,cwd:e.cwd,incomingIndex:t}}),l=e.projectOrder.length>0?(()=>{let t=new Map(c.map(e=>[e.cwd,e.id])),r=new Set,i=[];for(let o of e.projectOrder){let e=(o in a?o:void 0)??(()=>{let e=n.get(o);return e?t.get(e):void 0})();!e||r.has(e)||(r.add(e),i.push(e))}for(let e of c)r.has(e.id)||i.push(e.id);return i})():c.map(e=>({id:e.id,incomingIndex:e.incomingIndex,orderIndex:s.get(e.cwd)??EQ.length+e.incomingIndex})).toSorted((e,t)=>{let n=e.orderIndex-t.orderIndex;return n===0?e.incomingIndex-t.incomingIndex:n}).map(e=>e.id);return jQ(e.projectExpandedById,a)&&MQ(e.projectOrder,l)&&!i?e:{...e,projectExpandedById:a,projectOrder:l}}function FZe(e,t){let n=new Set(t.map(e=>e.key)),r=Object.fromEntries(Object.entries(e.threadLastVisitedAtById).filter(([e])=>n.has(e)));for(let e of t)r[e.key]===void 0&&e.seedVisitedAt!==void 0&&e.seedVisitedAt.length>0&&(r[e.key]=e.seedVisitedAt);let i=Object.fromEntries(Object.entries(e.threadChangedFilesExpandedById).filter(([e])=>n.has(e))),a=Object.fromEntries(Object.entries(e.pinnedThreadById).filter(([e,t])=>n.has(e)&&t)),o=Object.fromEntries(Object.entries(e.threadLinkedPrById).filter(([e])=>n.has(e)));return jQ(e.threadLastVisitedAtById,r)&&NZe(e.threadChangedFilesExpandedById,i)&&jQ(e.pinnedThreadById,a)&&jQ(e.threadLinkedPrById,o)?e:{...e,threadLastVisitedAtById:r,threadChangedFilesExpandedById:i,pinnedThreadById:a,threadLinkedPrById:o}}function IZe(e,t,n){let r=n??new Date().toISOString(),i=Date.parse(r),a=e.threadLastVisitedAtById[t],o=a?Date.parse(a):NaN;return Number.isFinite(o)&&Number.isFinite(i)&&o>=i?e:{...e,threadLastVisitedAtById:{...e.threadLastVisitedAtById,[t]:r}}}function LZe(e,t,n){if(!n)return e;let r=Date.parse(n);if(Number.isNaN(r))return e;let i=new Date(r-1).toISOString();return e.threadLastVisitedAtById[t]===i?e:{...e,threadLastVisitedAtById:{...e.threadLastVisitedAtById,[t]:i}}}function RZe(e,t){let n=t in e.threadLastVisitedAtById,r=t in e.threadChangedFilesExpandedById,i=t in e.pinnedThreadById,a=t in e.threadLinkedPrById;if(!n&&!r&&!i&&!a)return e;let o={...e.threadLastVisitedAtById},s={...e.threadChangedFilesExpandedById},c={...e.pinnedThreadById},l={...e.threadLinkedPrById};return delete o[t],delete s[t],delete c[t],delete l[t],{...e,threadLastVisitedAtById:o,threadChangedFilesExpandedById:s,pinnedThreadById:c,threadLinkedPrById:l}}function NQ(e,t,n){if(e.pinnedThreadById[t]===!0===n)return e;if(n)return{...e,pinnedThreadById:{...e.pinnedThreadById,[t]:!0}};let r={...e.pinnedThreadById};return delete r[t],{...e,pinnedThreadById:r}}function zZe(e,t){return NQ(e,t,e.pinnedThreadById[t]!==!0)}function BZe(e,t,n){return e.threadLinkedPrById[t]===n?e:{...e,threadLinkedPrById:{...e.threadLinkedPrById,[t]:n}}}function VZe(e,t){if(!(t in e.threadLinkedPrById))return e;let n={...e.threadLinkedPrById};return delete n[t],{...e,threadLinkedPrById:n}}function HZe(e,t,n,r){let i=e.threadChangedFilesExpandedById[t]??{};return i[n]===r?e:{...e,threadChangedFilesExpandedById:{...e.threadChangedFilesExpandedById,[t]:{...i,[n]:r}}}}function UZe(e,t){return e.lastActiveProject?.environmentId===t?.environmentId&&e.lastActiveProject?.projectId===t?.projectId?e:{...e,lastActiveProject:t}}function WZe(e,t,n){return e.workspaceDensityById[t]===n?e:{...e,workspaceDensityById:{...e.workspaceDensityById,[t]:n}}}function GZe(e,t){let n=e.projectExpandedById[t]??!0;return{...e,projectExpandedById:{...e.projectExpandedById,[t]:!n}}}function KZe(e,t,n){return(e.projectExpandedById[t]??!0)===n?e:{...e,projectExpandedById:{...e.projectExpandedById,[t]:n}}}function qZe(e,t,n){if(t.length===0)return e;let r=new Set(t),i=new Set(n);if(t.every(e=>i.has(e)))return e;let a=e.projectOrder.findIndex(e=>i.has(e));if(a<0)return e;let o=[...e.projectOrder],s=[],c=0;for(let e=o.length-1;e>=0;e--)r.has(o[e])&&(s.unshift(o.splice(e,1)[0]),e<a&&c++);if(s.length===0)return e;let l=a-Math.max(0,c-1);return o.splice(l,0,...s),{...e,projectOrder:o}}function JZe(e,t){let n=[...new Set(t)],r=new Set(n),i=e.projectGroupOrder.filter(e=>r.has(e)),a=new Set(i);for(let e of n)a.has(e)||i.push(e);return MQ(e.projectGroupOrder,i)?e:{...e,projectGroupOrder:i}}function YZe(e,t,n){if(t===n)return e;let r=e.projectGroupOrder.indexOf(t),i=e.projectGroupOrder.indexOf(n);if(r<0||i<0)return e;let a=[...e.projectGroupOrder],[o]=a.splice(r,1);return o===void 0?e:(a.splice(i,0,o),{...e,projectGroupOrder:a})}var PQ=Wt(e=>({...DZe(),syncProjects:t=>e(e=>PZe(e,t)),syncProjectGroups:t=>e(e=>JZe(e,t)),syncThreads:t=>e(e=>FZe(e,t)),markThreadVisited:(t,n)=>e(e=>IZe(e,t,n)),markThreadUnread:(t,n)=>e(e=>LZe(e,t,n)),clearThreadUi:t=>e(e=>RZe(e,t)),setThreadPinned:(t,n)=>e(e=>NQ(e,t,n)),toggleThreadPinned:t=>e(e=>zZe(e,t)),setThreadLinkedPr:(t,n)=>e(e=>BZe(e,t,n)),clearThreadLinkedPr:t=>e(e=>VZe(e,t)),setThreadChangedFilesExpanded:(t,n,r)=>e(e=>HZe(e,t,n,r)),setWorkspaceDensity:(t,n)=>e(e=>WZe(e,t,n)),toggleProject:t=>e(e=>GZe(e,t)),setProjectExpanded:(t,n)=>e(e=>KZe(e,t,n)),reorderProjects:(t,n)=>e(e=>qZe(e,t,n)),reorderProjectGroups:(t,n)=>e(e=>YZe(e,t,n)),setLastActiveProject:t=>e(e=>UZe(e,t)),setTimelineWorkColumnWidth:t=>e(e=>({...e,timelineWorkColumnWidth:CQ(t)})),setTimelineScale:t=>e(e=>({...e,timelineScale:t})),openProjectLeadCompanion:t=>e(e=>({...e,projectLeadCompanion:CZe(e.projectLeadCompanion,t)})),closeProjectLeadCompanion:()=>e(e=>({...e,projectLeadCompanion:{...e.projectLeadCompanion,open:!1}})),setProjectLeadCompanionMinimized:t=>e(e=>({...e,projectLeadCompanion:{...e.projectLeadCompanion,minimized:t}})),setProjectLeadCompanionDock:t=>e(e=>({...e,projectLeadCompanion:{...e.projectLeadCompanion,dock:t}})),setProjectLeadCompanionPosition:t=>e(e=>({...e,projectLeadCompanion:{...e.projectLeadCompanion,position:t}}))}));function XZe(e){PQ.getState().openProjectLeadCompanion(e)}PQ.subscribe(e=>AQ.maybeExecute(e)),typeof window<`u`&&typeof window.addEventListener==`function`&&window.addEventListener(`beforeunload`,()=>{AQ.flush()});var ZZe=bt(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),QZe=class extends Dt()(`effect/http/FetchHttpClient/RequestInit`){},$Ze=Qre($e(Yre((e,t,n,r)=>{let i=r.getRef(ZZe),a=r.context.mapUnsafe.get(QZe.key)??{},o=a.headers?Qt(gn(a.headers),e.headers):e.headers,s=r=>Ye(Fee({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:e.body._tag===`Stream`?`half`:void 0,signal:n}),catch:t=>new wn({reason:new ine({request:e,cause:t})})}),t=>Wte(e,t));switch(e.body._tag){case`Raw`:case`Uint8Array`:return s(e.body.body);case`FormData`:return s(e.body.formData);case`Stream`:return yt(fte(e.body.stream),s)}return s(void 0)}))),eQe=cte.pipe(S,Ft(e=>{if(Yn(e)&&e.reason._tag===`StatusCodeError`&&e.reason.response.status===429){let t=Aee(e.reason.response.headers[`retry-after`]).pipe(wee(Pre),dte(()=>5));return $e(A(t))}return $e(A(1))})),tQe=Je(function*(e){let t=yield*wt(),n=kt(t,Nre),r=kt(t,Ae),i=Ve(t),o=p(je(e.exportInterval),hee),s,c=qre(kt(t,Ii)).pipe(Li(Ee(Bi,!1)),Xre({schedule:eQe,times:3})),l=tr({"user-agent":`effect-opentelemetry-${e.label}/0.0.0`});e.headers&&(l=Qt(gn(e.headers),l));let d=Rre(e.url,{headers:l}),f=[],m=Et(()=>{if(s!==void 0&&n.currentTimeMillisUnsafe()<s)return nt;s!==void 0&&(s=void 0);let t=f;if(e.maxBatchSize!==`disabled`){if(f.length===0)return nt;f=[]}return c.execute(Pi(d,e.body(t))).pipe(fee,jee(!1))}).pipe(He(e=>s===void 0?(s=n.currentTimeMillisUnsafe()+6e4,f=[],Dee(`Disabling exporter for 60 seconds`,e)):nt),u({package:`@effect/opentelemetry`,module:e.label}));return yield*Rt(r,m.pipe(Ct,ot,qee(e.shutdownTimeout))),yield*a(o).pipe(Lt(m),Ze,jt(r)),{push(t){s===void 0&&(f.push(t),e.maxBatchSize!==`disabled`&&f.length>=e.maxBatchSize&&fe(i(m),r))}}}),nQe=e=>{let t=e.attributes?FQ(Object.entries(e.attributes)):[];return t.push({key:`service.name`,value:{stringValue:e.serviceName}}),e.serviceVersion&&t.push({key:`service.version`,value:{stringValue:e.serviceVersion}}),{attributes:t,droppedAttributesCount:0}},rQe=Je(function*(e){let t={...yield*Al(Fn(Pce(Un,Un)),`OTEL_RESOURCE_ATTRIBUTES`),...e?.attributes},n=e?.serviceName??t[`service.name`]??(yield*Al(Un,`OTEL_SERVICE_NAME`));delete t[`service.name`];let r=e?.serviceVersion??t[`service.version`]??(yield*Al(Fn(Un),`OTEL_SERVICE_VERSION`));return delete t[`service.version`],nQe({serviceName:n,serviceVersion:r,attributes:t})},l),iQe=e=>{let t=e.attributes.find(e=>e.key===`service.name`);if(!t||!t.value.stringValue)throw Error(`Resource does not contain a service name`);return t.value.stringValue},FQ=e=>{let t=[];for(let[n,r]of e)t.push({key:n,value:IQ(r)});return t},IQ=e=>{if(Array.isArray(e))return{arrayValue:{values:e.map(IQ)}};switch(typeof e){case`string`:return{stringValue:e};case`bigint`:return{intValue:Number(e)};case`number`:return Number.isInteger(e)?{intValue:e}:{doubleValue:e};case`boolean`:return{boolValue:e};default:return{stringValue:i(e)}}},LQ=class extends Dt()(`effect/observability/OtlpSerialization`){},aQe=pe(LQ,{traces:e=>un(e),metrics:e=>un(e),logs:e=>un(e)}),oQe=Je(function*(e){let t=yield*rQe(e.resource),n=yield*LQ,r={name:iQe(t)},i=yield*tQe({label:`OtlpTracer`,url:e.url,headers:e.headers,exportInterval:e.exportInterval??A(5),maxBatchSize:e.maxBatchSize??1e3,body(e){let i={resourceSpans:[{resource:t,scopeSpans:[{scope:r,spans:e}]}]};return n.traces(i)},shutdownTimeout:e.shutdownTimeout??A(3)});function a(e){e.sampled&&i.push(lQe(e))}return ye({span(e){return cQe({...e,status:{_tag:`Started`,startTime:e.startTime},attributes:new Map,export:a})},context:e.context?function(t,n){return n.currentSpan===void 0?t[`~effect/Effect/evaluate`](n):e.context(t,n.currentSpan)}:void 0})}),sQe={_tag:`Span`,end(e,t){this.status={_tag:`Ended`,startTime:this.status.startTime,endTime:e,exit:t},this.export(this)},attribute(e,t){this.attributes.set(e,t)},event(e,t,n){this.events.push([e,t,n])},addLinks(e){this.links.push(...e)}},cQe=e=>{let t=Object.assign(Object.create(sQe),e);return t.traceId=x(t.parent)?t.parent.value.traceId:RQ(32),t.spanId=RQ(16),t.events=[],t},RQ=e=>{let t=``;for(let n=0;n<e;n++)t+=`0123456789abcdef`[Math.floor(Math.random()*16)];return t},lQe=e=>{let t=e.status,n=FQ(e.attributes.entries()),r=e.events.map(([e,t,n])=>({name:e,timeUnixNano:String(t),attributes:n?FQ(Object.entries(n)):[],droppedAttributesCount:0})),i;if(t.exit._tag===`Success`)i=dQe;else if(at(t.exit.cause))i={code:zQ.Ok,message:`Interrupted`},n.push({key:`span.label`,value:{stringValue:`⚠︎ Interrupted`}},{key:`status.interrupted`,value:{boolValue:!0}});else{let e=lte(t.exit.cause);if(i={code:zQ.Error},e.length>0){i.message=e[0].message;for(let n of e)r.push({name:`exception`,timeUnixNano:String(t.endTime),droppedAttributesCount:0,attributes:[{key:`exception.type`,value:{stringValue:n.name}},{key:`exception.message`,value:{stringValue:n.message}},{key:`exception.stacktrace`,value:{stringValue:n.stack??`No stack trace available`}}]})}}return{traceId:e.traceId,spanId:e.spanId,parentSpanId:o(e.parent,{onNone:()=>void 0,onSome:e=>e.spanId}),name:e.name,kind:uQe[e.kind],startTimeUnixNano:String(t.startTime),endTimeUnixNano:String(t.endTime),attributes:n,droppedAttributesCount:0,events:r,droppedEventsCount:0,status:i,links:e.links.map(e=>({traceId:e.span.traceId,spanId:e.span.spanId,attributes:FQ(Object.entries(e.attributes)),droppedAttributesCount:0})),droppedLinksCount:0}},zQ={Unset:0,Ok:1,Error:2},uQe={unspecified:0,internal:1,server:2,client:3,producer:4,consumer:5},dQe={code:zQ.Ok},fQe=1e4,pQe={serviceName:`forge-web`,attributes:{"service.runtime":`forge-web`,"service.mode":Ar?`electron`:`browser`,"service.version":El}},mQe=Te($Ze,aQe,pe(zi,()=>!0)),BQ=null,VQ=null,HQ=null,UQ=null,WQ=0,GQ=Promise.resolve(),hQe=pe(Hee,ye({span(e){return BQ?.span(e)??new c(e)}}));function gQe(e={}){return e.exportIntervalMs===void 0&&UQ!==null||(GQ=GQ.finally(()=>_Qe(e))),GQ}async function _Qe(e){let t=lr(`/api/observability/v1/traces`),n=or()?.bearerToken,r=Math.max(10,e.exportIntervalMs??fQe),i=`${t}|${r}|${n?`bearer`:`cookie`}`;if(UQ===i&&BQ!==null)return;UQ=i;let a=++WQ,o=VQ,s=HQ;BQ=null,VQ=null,HQ=null,await KQ(o,s);let c=vl(mQe),l=c.runSync(Le());try{let e=await c.runPromise(ee(l)(oQe({url:t,...n?{headers:{Authorization:`Bearer ${n}`}}:{},exportInterval:`${r} millis`,resource:pQe})));if(a!==WQ){await KQ(c,l);return}BQ=e,VQ=c,HQ=l}catch(e){await KQ(c,l),a===WQ&&console.warn(`Failed to configure client tracing exporter`,{error:vQe(e),otlpTracesUrl:t})}}async function KQ(e,t){e!==null&&t!==null&&await e.runPromise(ze(t,xt)).catch(()=>void 0).finally(()=>{e.dispose()})}function vQe(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}var qQ=15e3,JQ=new Map,YQ=Ht([]).pipe(Vt,zt(`slow-rpc-ack-requests`));function XQ(e){Bt.set(YQ,[...e])}function ZQ(){return Bt.get(YQ)}var QQ=`global`;function yQe(e){return!(e.split(`.`).at(-1)??e).startsWith(`subscribe`)}function bQe(e,t,n=QQ){if(!yQe(t))return;t$(e,n),wQe();let r=Date.now(),i={clientId:n,requestId:e,startedAt:new Date(r).toISOString(),startedAtMs:r,tag:t,thresholdMs:qQ},a=e$(n,e),o=setTimeout(()=>{JQ.delete(a),CQe(i)},qQ);JQ.set(a,{request:i,timeoutId:o})}function xQe(e,t=QQ){t$(e,t);let n=ZQ();n.some(n=>n.clientId===t&&n.requestId===e)&&XQ(n.filter(n=>n.clientId!==t||n.requestId!==e))}function $Q(e){for(let[t,n]of JQ)n.request.clientId===e&&(clearTimeout(n.timeoutId),JQ.delete(t));XQ(ZQ().filter(t=>t.clientId!==e))}function SQe(){for(let e of JQ.values())clearTimeout(e.timeoutId);JQ.clear(),XQ([])}function e$(e,t){return`${e}:${t}`}function t$(e,t){let n=e$(t,e),r=JQ.get(n);r&&(clearTimeout(r.timeoutId),JQ.delete(n))}function CQe(e){let t=[...ZQ(),e];if(t.length<=256){XQ(t);return}XQ(t.slice(-256))}function wQe(){for(;JQ.size>=256;){let e=JQ.keys().next().value;if(e===void 0)return;let t=JQ.get(e);if(!t)return;t$(t.request.requestId,t.request.clientId)}}function TQe(){return ar(YQ)}var EQe=ko(Hn),n$=1;function DQe(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}function r$(e){let t=new URL(e);if(t.protocol!==`ws:`&&t.protocol!==`wss:`)throw Error(`Unsupported websocket transport URL protocol: ${t.protocol}`);return t.pathname=`/ws`,t.toString()}function OQe(){return{onAttempt:Ine,onOpen:Lne,onError:e=>{jne(e)},onClose:e=>{Rne(e)},trackGlobalConnection:!0}}function kQe(e){let t=OQe(),n=e?.trackGlobalConnection??!0;return{onAttempt:r=>{n&&t.onAttempt(r),e?.onAttempt?.(r)},onOpen:()=>{n&&t.onOpen(),e?.onOpen?.()},onError:r=>{n&&t.onError(r),e?.onError?.(r)},onClose:r=>{n&&t.onClose(r),e?.onClose?.(r)},trackGlobalConnection:n}}function AQe(e,t){let n=n$;n$+=1;let r=kQe(t),i=typeof e==`function`?dt(()=>e()).pipe(Ye(e=>r$(e)),rte(e=>st(()=>{r.onError(DQe(e))})),l):r$(e),a=pe(oa,(e,t)=>{r.onAttempt(e);let n=new globalThis.WebSocket(e,t);return n.addEventListener(`open`,()=>{r.onOpen()},{once:!0}),n.addEventListener(`error`,()=>{r.onError(`Unable to connect to the Forge server WebSocket.`)},{once:!0}),n.addEventListener(`close`,e=>{r.onClose({code:e.code,reason:e.reason})},{once:!0}),n}),o=sa(i).pipe(E(a)),s=Ft(y(10),e=>$e(Be(Ane(e)??0)));return ut(Mo,Ye(No({retryPolicy:s,retryTransientErrors:!0}),e=>({...e,run:(t,r)=>{let i=`${n}:${String(t)}`;return e.run(t,e=>(e._tag===`Chunk`||e._tag===`Exit`?xQe(e.requestId,i):(e._tag===`ClientProtocolError`||e._tag===`Defect`)&&$Q(i),r(e))).pipe(Ge(st(()=>{$Q(i)})))},send:(t,r,i)=>{let a=`${n}:${String(t)}`;return r._tag===`Request`&&bQe(r.id,r.tag,a),e.send(t,r,i)}}))).pipe(E(Te(o,Oo)))}var jQe=Be(250),i$=()=>void 0,a$=class extends Error{name=`WsRequestTimeoutError`;timeoutMs;constructor(e){let t=Re(je(e));super(`WebSocket RPC request timed out after ${t}ms.`),this.timeoutMs=t}},MQe=new Set([`OrchestrationGetSnapshotError`]);function NQe(e){if(typeof e!=`object`||!e)return!1;let t=e._tag;return typeof t==`string`&&MQe.has(t)}function PQe(e){let t=e instanceof Error?e.message.trim():``;return t.length>0?t:typeof e==`object`&&e?FQe(e):String(e)}function FQe(e){try{return JSON.stringify(e)}catch{let t=e;return[typeof t._tag==`string`?t._tag:void 0,typeof t.message==`string`?t.message:void 0].filter(Boolean).join(`: `)||Object.prototype.toString.call(e)}}var IQe=4e3,LQe=1e4,RQe=500,o$=class{url;lifecycleHandlers;disposed=!1;hasReportedTransportDisconnect=!1;reconnectChain=Promise.resolve();session;heartbeatTimer=null;heartbeatInFlight=!1;protocol;timing;constructor(e,t,n,r){this.url=e,this.lifecycleHandlers=t,this.protocol=n??null,this.timing={heartbeatIntervalMs:r?.heartbeatIntervalMs??IQe,heartbeatTimeoutMs:r?.heartbeatTimeoutMs??LQe,sessionCloseGraceMs:r?.sessionCloseGraceMs??RQe},this.session=this.createSession(),this.startHeartbeat()}startHeartbeat(){this.heartbeatTimer===null&&(this.heartbeatTimer=setInterval(()=>{if(this.disposed||this.heartbeatInFlight)return;this.heartbeatInFlight=!0;let e=this.session;this.request(e=>e[M.serverHeartbeat]({}),{timeout:this.timing.heartbeatTimeoutMs}).catch(async()=>{this.disposed||e!==this.session||await this.reconnect()}).finally(()=>{this.heartbeatInFlight=!1})},this.timing.heartbeatIntervalMs))}async request(e,t){if(this.disposed)throw Error(`Transport disposed`);let n=this.session,i=await n.clientPromise,a=Et(()=>e(i)),o=t?.timeout,s=o===void 0?a:a.pipe(At({duration:o,orElse:()=>r(new a$(o))}));return await n.runtime.runPromise(s)}async requestStream(e,t,n){if(this.disposed)throw Error(`Transport disposed`);let r=this.session,i=this.runStreamOnSession(r,e,t,()=>!0,()=>void 0),a=()=>i.cancel();n?.signal?.aborted&&a(),n?.signal?.addEventListener(`abort`,a,{once:!0});try{await i.completed}catch(e){if(n?.signal?.aborted){let e=Error(`RPC stream request was cancelled.`);throw e.name=`AbortError`,e}throw e}finally{n?.signal?.removeEventListener(`abort`,a)}}subscribe(e,t,n){if(this.disposed)return()=>void 0;let r={active:!0,hasReceivedValue:!1,cancelCurrentStream:i$},i=Re(je(n?.retryDelay??jQe));return this.runSubscriptionLoop(e,t,n,r,i),()=>{r.active=!1,r.cancelCurrentStream()}}async runSubscriptionLoop(e,t,n,r,i){for(;r.active&&!this.disposed;){let a=this.session;try{this.notifyResubscribe(r,n);let i=this.startSubscriptionStream(a,e,t,r);r.cancelCurrentStream=i.cancel,await i.completed,r.cancelCurrentStream=i$}catch(e){if(r.cancelCurrentStream=i$,!await this.handleSubscriptionFailure(e,a,r,n,i))return}}}notifyResubscribe(e,t){if(e.hasReceivedValue)try{t?.onResubscribe?.()}catch{}}startSubscriptionStream(e,t,n,r){return this.runStreamOnSession(e,t,n,()=>r.active,()=>{this.hasReportedTransportDisconnect=!1,r.hasReceivedValue=!0})}async handleSubscriptionFailure(e,t,n,r,i){if(!n.active||this.disposed)return!1;if(t!==this.session)return!0;let a=PQe(e);return OK(a)?(this.hasReportedTransportDisconnect||console.warn(`WebSocket RPC subscription disconnected`,{error:a}),this.hasReportedTransportDisconnect=!0,await zQe(i),!0):(this.reportNonTransportSubscriptionError(e,r),!1)}reportNonTransportSubscriptionError(e,t){NQe(e)||zK(e,{route:`ws-subscribe`,reason:`non-transport-error`}),t?.onError?.(e)}async reconnect(){if(this.disposed)throw Error(`Transport disposed`);let e=this.reconnectChain.then(async()=>{if(this.disposed)throw Error(`Transport disposed`);let e=this.session;this.session=this.createSession(),await this.closeSession(e)});this.reconnectChain=e.catch(e=>{zK(e,{route:`ws-reconnect`})}),await e}async dispose(){this.disposed||(this.disposed=!0,this.heartbeatTimer!==null&&this.heartbeatTimer!==void 0&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),await this.closeSession(this.session))}async closeSession(e){let t=e.runtime.runPromise(ze(e.clientScope,xt)),n=!1,r=null,i=new Promise(e=>{r=setTimeout(()=>{n=!0,e()},this.timing.sessionCloseGraceMs)});try{await Promise.race([t,i])}finally{r!==null&&clearTimeout(r),n&&(console.warn(`WebSocket session close exceeded its grace period; forcing disposal`,{graceMs:this.timing.sessionCloseGraceMs}),t.catch(()=>void 0)),await e.runtime.dispose()}}createSession(){let e=this.protocol??{layer:AQe(this.url,this.lifecycleHandlers),makeClient:EQe},t=vl(Te(e.layer,hQe)),n=t.runSync(Le());return{runtime:t,clientScope:n,clientPromise:t.runPromise(ee(n)(e.makeClient))}}runStreamOnSession(e,t,n,r,i){let a,o,s=new Promise((e,t)=>{a=e,o=t});return{cancel:e.runtime.runCallback(dt(()=>e.clientPromise).pipe(yt(e=>Jee(t(e),e=>st(()=>{if(r()){i();try{n(e)}catch{}}})))),{onExit:e=>{if(ete(e)){a();return}o(Pe(e.cause))}}),completed:s}}};function zQe(e){return new Promise(t=>{setTimeout(t,e)})}var s$=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,BQe=/^[A-Za-z0-9_-]+$/;function VQe(e){let t=``;for(let n=0;n<e.byteLength;n+=3){let r=e[n]??0,i=e[n+1]??0,a=e[n+2]??0,o=r<<16|i<<8|a;t+=s$[o>>>18&63],t+=s$[o>>>12&63],n+1<e.byteLength&&(t+=s$[o>>>6&63]),n+2<e.byteLength&&(t+=s$[o&63])}return t.replaceAll(`+`,`-`).replaceAll(`/`,`_`)}function HQe(e){if(e.length===0||!BQe.test(e))throw Error(`Bulk transfer chunk is not valid base64url data.`);let t=e.replaceAll(`-`,`+`).replaceAll(`_`,`/`),n=Math.floor(t.length*6/8),r=new Uint8Array(n),i=0,a=0,o=0;for(let e of t){let t=s$.indexOf(e);if(t<0)throw Error(`Bulk transfer chunk is not valid base64url data.`);i=i<<6|t,a+=6,a>=8&&(a-=8,r[o]=i>>>a&255,o+=1)}return r}async function c$(e){let t=new Uint8Array(e.byteLength);t.set(e);let n=await crypto.subtle.digest(`SHA-256`,t.buffer);return Array.from(new Uint8Array(n),e=>e.toString(16).padStart(2,`0`)).join(``)}async function UQe(e,t){let n=t?.chunkBytes??262144;if(!Number.isSafeInteger(n)||n<1||n>262144)throw Error(`Bulk transfer chunk size must be between 1 and ${hne}.`);let r=t?.transferId??crypto.randomUUID().replaceAll(`-`,`_`),i=[];for(let t=0;t<e.byteLength;t+=n){let a=e.slice(t,Math.min(t+n,e.byteLength));i.push({kind:`chunk`,transferId:r,offset:t,bytes:a.byteLength,data:VQe(a),sha256:await c$(a)})}return{totalBytes:e.byteLength,sha256:await c$(e),chunks:i}}async function WQe(e){let t=HQe(e.data);if(t.byteLength!==e.bytes)throw Error(`Bulk transfer chunk byte count mismatch at offset ${e.offset}: expected ${e.bytes}, received ${t.byteLength}.`);if(await c$(t)!==e.sha256)throw Error(`Bulk transfer chunk integrity mismatch at offset ${e.offset}.`);return t}async function GQe(e){let t=new Map,n=[],r=0;for(let i of e.chunks){let e=t.get(i.offset);if(e!==void 0){if(e.bytes!==i.bytes||e.sha256!==i.sha256||e.data!==i.data)throw Error(`Bulk transfer has a conflicting duplicate chunk at offset ${i.offset}.`);continue}if(i.offset!==r)throw Error(`Bulk transfer chunk offset mismatch: expected ${r}, received ${i.offset}.`);let a=await WQe(i);t.set(i.offset,i),n.push({chunk:i,bytes:a}),r+=a.byteLength}if(r!==e.totalBytes)throw Error(`Bulk transfer total byte count mismatch: expected ${e.totalBytes}, received ${r}.`);let i=new Uint8Array(e.totalBytes);for(let e of n)i.set(e.bytes,e.chunk.offset);if(await c$(i)!==e.sha256)throw Error(`Bulk transfer payload integrity mismatch.`);return i}var l$=`forge`,KQe=RegExp(`^${l$}\\/[0-9a-f]{8}$`);function qQe(){return`${l$}/${de(bte).replace(/-/g,``).slice(0,8).toLowerCase()}`}function JQe(e){return KQe.test(e.trim().toLowerCase())}function YQe(e){let t=e.trim().replace(/\/+$/g,``).replace(/\.git$/i,``).toLowerCase();if(/^(?:ssh|https?|git):\/\//i.test(t))try{let e=new URL(t),n=e.pathname.split(`/`).filter(e=>e.length>0).join(`/`);if(e.hostname&&n.includes(`/`))return`${e.hostname}/${n}`}catch{return t}let n=/^git@([^:/\s]+)[:/]([^/\s]+(?:\/[^/\s]+)+)$/i.exec(t);return n?.[1]&&n[2]?`${n[1]}/${n[2]}`:t}function XQe(e){let t=e?.trim()??``;if(t.length===0)return null;let n=/^(?:git@github\.com:|ssh:\/\/git@github\.com\/|https:\/\/github\.com\/|git:\/\/github\.com\/)([^/\s]+\/[^/\s]+?)(?:\.git)?\/?$/i.exec(t)?.[1]?.trim()??``;return n.length>0?n:null}function ZQe(e){let t=e.trim();if(t.length===0)return null;if(t.startsWith(`git@`)){let e=t.slice(4),n=e.search(/[:/]/);return n<=0?null:e.slice(0,n).toLowerCase()}try{return new URL(t).hostname.toLowerCase()}catch{return null}}function u$(e){return`https://${e}`}function QQe(e){return e===`github.com`||e.includes(`github`)}function $Qe(e){return e===`gitlab.com`||e.includes(`gitlab`)}function e$e(e){return e===`bitbucket.org`}function t$e(e){return e===`dev.azure.com`||e===`ssh.dev.azure.com`||e===`vs-ssh.visualstudio.com`||e.endsWith(`.visualstudio.com`)}function n$e(e){let t=ZQe(e);if(!t)return null;let n=YQe(e),r=`${t}/`;if(!n.startsWith(r))return null;let i=n.slice(r.length);return i.includes(`/`)?QQe(t)?{kind:`github`,name:t===`github.com`?`GitHub`:`GitHub Self-Hosted`,host:t,repositoryPath:i,baseUrl:u$(t)}:$Qe(t)?{kind:`gitlab`,name:t===`gitlab.com`?`GitLab`:`GitLab Self-Hosted`,host:t,repositoryPath:i,baseUrl:u$(t)}:e$e(t)?{kind:`bitbucket`,name:`Bitbucket Cloud`,host:t,repositoryPath:i,baseUrl:u$(t)}:t$e(t)?{kind:`azure-devops`,name:`Azure DevOps`,host:t,repositoryPath:i,baseUrl:u$(t)}:{kind:`unknown`,name:t,host:t,repositoryPath:i,baseUrl:u$(t)}:null}var r$e={hasUpstream:!1,aheadCount:0,behindCount:0,pr:null,defaultBranch:null,diffVsBase:null};function d$(e,t){return{...e,...t??r$e}}function i$e(e){return{hasUpstream:e.hasUpstream,aheadCount:e.aheadCount,behindCount:e.behindCount,pr:e.pr,defaultBranch:e.defaultBranch,diffVsBase:e.diffVsBase}}function a$e(e){return{isRepo:e.isRepo,...e.hostingProvider?{hostingProvider:e.hostingProvider}:{},hasOriginRemote:e.hasOriginRemote,isDefaultBranch:e.isDefaultBranch,branch:e.branch,hasWorkingTreeChanges:e.hasWorkingTreeChanges,workingTree:e.workingTree}}function o$e(e,t){switch(t._tag){case`snapshot`:return d$(t.local,t.remote);case`localUpdated`:return d$(t.local,e?i$e(e):null);case`remoteUpdated`:return d$(e===null?{isRepo:!0,hasOriginRemote:!1,isDefaultBranch:!1,branch:null,hasWorkingTreeChanges:!1,workingTree:{files:[],insertions:0,deletions:0}}:a$e(e),t.remote)}}var s$e=262144,c$e=250;function l$e(e){if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch{return String(e)}}function u$e(e){return new Promise(t=>setTimeout(t,e))}function d$e(e){let t=fce({controllerId:crypto.randomUUID(),maxPendingWriteBytes:s$e}),n=!1,r=e=>{if(!e.sessionEpoch)throw Error(`Connected Forge runtime does not support epoch-fenced terminal controls.`);t.register({threadId:e.threadId,terminalId:e.terminalId,sessionEpoch:e.sessionEpoch})},i=async e=>{for(;!n;)try{return await e()}catch(e){if(!OK(l$e(e)))throw e;await u$e(c$e)}throw Error(`Terminal control client was disposed before acknowledgement.`)};return{terminal:{open:async t=>{let n=await e.request(e=>e[M.terminalOpen]({...t,terminalId:t.terminalId??`default`}));return r(n),n},write:async n=>{let r=n.terminalId??`default`;await t.enqueue({threadId:n.threadId,terminalId:r,writeBytes:new TextEncoder().encode(n.data).byteLength,execute:t=>i(()=>e.request(e=>e[M.terminalWrite]({...n,terminalId:r,...t})))})},resize:async n=>{let r=n.terminalId??`default`;await t.enqueue({threadId:n.threadId,terminalId:r,execute:t=>i(()=>e.request(e=>e[M.terminalResize]({...n,terminalId:r,...t})))})},signal:async n=>{let r=n.terminalId??`default`;await t.enqueue({threadId:n.threadId,terminalId:r,execute:t=>i(()=>e.request(e=>e[M.terminalSignal]({...n,terminalId:r,...t})))})},clear:async n=>{let r=n.terminalId??`default`;await t.enqueue({threadId:n.threadId,terminalId:r,execute:t=>i(()=>e.request(e=>e[M.terminalClear]({...n,terminalId:r,...t})))})},restart:async n=>{let a=n.terminalId??`default`,o=null;if(await t.enqueue({threadId:n.threadId,terminalId:a,execute:async t=>{o=(await i(()=>e.request(e=>e[M.terminalRestart]({...n,terminalId:a,...t})))).snapshot}}),o===null)throw Error(`Terminal restart completed without a snapshot.`);return r(o),o},close:async n=>{let r=n.terminalId?[n.terminalId]:t.terminalIds(n.threadId);for(let a of r)await t.enqueue({threadId:n.threadId,terminalId:a,execute:t=>i(()=>e.request(e=>e[M.terminalClose]({...n,terminalId:a,...t})))}),t.remove(n.threadId,a)},onEvent:t=>e.subscribe(e=>e[M.subscribeTerminalEvents]({}),e=>{(e.type===`started`||e.type===`restarted`)&&r(e.snapshot),t(e)})},dispose:()=>{n=!0,t.dispose()}}}var f$e=2e4,p$e=12e4,m$e=3e5;function h$e(e){return e instanceof a$||OK(e instanceof Error?e.message:String(e))}async function g$e(e,t){let n=t.type===`thread.turn.start`&&t.bootstrap!==void 0?m$e:f$e,r=()=>e.request(e=>e[sn.dispatchCommand](t),{timeout:n});try{return await r()}catch(t){if(!h$e(t))throw t;return await e.reconnect(),await r()}}function f$(e){if(!e?.aborted)return;let t=Error(`Bulk transfer was cancelled.`);throw t.name=`AbortError`,t}async function p$(e,t,n){let r={started:null,completed:null,chunks:[],protocolError:null,receivedBytes:0};if(await e.requestStream(t,e=>_$e(r,e,n),n),r.protocolError!==null)throw r.protocolError;let i=r.started,a=r.completed;if(i===null||a===null)throw Error(`Bulk transfer stream completed without start and completion metadata.`);if(a.transferId!==i.transferId||a.totalBytes!==i.totalBytes||a.sha256!==i.sha256)throw Error(`Bulk transfer completion metadata mismatch.`);return await GQe({totalBytes:i.totalBytes,sha256:i.sha256,chunks:r.chunks})}function _$e(e,t,n){if(e.protocolError===null){if(t.kind===`started`){v$e(e,t,n);return}if(e.started===null||t.transferId!==e.started.transferId){e.protocolError=Error(`Bulk transfer event identity mismatch.`);return}if(t.kind===`chunk`){y$e(e,t,n);return}e.completed=t,n?.onProgress?.({completedBytes:t.totalBytes,totalBytes:t.totalBytes})}}function v$e(e,t,n){if(e.started!==null||t.totalBytes>16777216){e.protocolError=Error(`Bulk transfer started with invalid or oversized metadata.`);return}e.started=t,n?.onProgress?.({completedBytes:0,totalBytes:t.totalBytes})}function y$e(e,t,n){let r=e.started;if(r!==null){if(e.receivedBytes+=t.bytes,e.receivedBytes>r.totalBytes){e.protocolError=Error(`Bulk transfer exceeded its declared byte count.`);return}e.chunks.push(t),n?.onProgress?.({completedBytes:e.receivedBytes,totalBytes:r.totalBytes})}}async function b$e(e,t,n){let r=new TextEncoder().encode(t.contents);if(r.byteLength>16777216)throw Error(`Project file exceeds the ${sne}-byte write limit.`);let i=await UQe(r),a=i.chunks[0]?.transferId??crypto.randomUUID().replaceAll(`-`,`_`),o=!1;try{f$(n?.signal);let r=await x$e(e,t,a,i);return o=!0,n?.onProgress?.({completedBytes:r.nextOffset,totalBytes:i.totalBytes}),await S$e(e,a,i,r,n),{relativePath:t.relativePath}}catch(t){throw o&&await C$e(e,a),t}}function x$e(e,t,n,r){return e.request(e=>e[M.workspaceBeginWriteFile]({transferId:n,cwd:t.cwd,relativePath:t.relativePath,totalBytes:r.totalBytes,sha256:r.sha256}))}async function S$e(e,t,n,r,i){if(r.state!==`completed`){for(let t of n.chunks){if(t.offset<r.nextOffset)continue;f$(i?.signal);let{kind:a,...o}=t,s=await e.request(e=>e[M.workspaceWriteFileChunk](o));i?.onProgress?.({completedBytes:s.nextOffset,totalBytes:n.totalBytes})}f$(i?.signal),await e.request(e=>e[M.workspaceCommitWriteFile]({transferId:t}))}}async function C$e(e,t){await e.request(e=>e[M.workspaceCancelWriteFile]({transferId:t})).catch(()=>void 0)}function m$(e){let t=d$e(e);return{dispose:()=>(t.dispose(),e.dispose()),reconnect:async()=>{kne(),await e.reconnect()},terminal:t.terminal,browser:{openSession:t=>e.request(e=>e[M.browserOpenSession](t)),listSessions:t=>e.request(e=>e[M.browserListSessions](t)),closeSession:t=>e.request(e=>e[M.browserCloseSession](t)),getSession:t=>e.request(e=>e[M.browserGetSession](t)),command:t=>e.request(e=>e[M.browserCommand](t)),clearBrowsingData:t=>e.request(e=>e[M.browserClearBrowsingData](t)),attachDisplay:t=>e.request(e=>e[M.browserAttachDisplay](t)),addDisplayIceCandidate:t=>e.request(e=>e[M.browserAddDisplayIceCandidate](t)),onEvent:(t,n,r)=>e.subscribe(e=>e[M.subscribeBrowserEvents](t),n,r)},computer:{input:t=>e.request(e=>e[M.computerInput](t))},threadDevRuntime:{get:t=>e.request(e=>e[M.threadDevRuntimeGet](t)),allocatePort:t=>e.request(e=>e[M.threadDevRuntimeAllocatePort](t)),release:t=>e.request(e=>e[M.threadDevRuntimeRelease](t))},devTunnel:{register:t=>e.request(e=>e[M.devTunnelRegister](t)),unregister:t=>e.request(e=>e[M.devTunnelUnregister](t)),list:t=>e.request(e=>e[M.devTunnelList](t))},projects:{searchEntries:t=>e.request(e=>e[M.projectsSearchEntries](t)),readFile:(t,n)=>p$(e,e=>e[M.workspaceReadFile](t),n),writeFile:(t,n)=>b$e(e,t,n)},projectCheckoutDeletion:{preview:t=>e.request(e=>e[M.projectCheckoutDeletionPreview](t)),execute:t=>e.request(e=>e[M.projectCheckoutDeletionExecute](t))},codeGraph:{summary:t=>e.request(e=>e[M.codeGraphSummary](t)),neighborhood:t=>e.request(e=>e[M.codeGraphNeighborhood](t)),search:t=>e.request(e=>e[M.codeGraphSearch](t))},workspace:{environmentPreflight:t=>e.request(e=>e[M.workspaceEnvironmentPreflight](t)),ensureScratch:t=>e.request(e=>e[M.workspaceEnsureScratch](t))},shell:{openInEditor:t=>e.request(e=>e[M.shellOpenInEditor](t))},git:{pull:t=>e.request(e=>e[M.gitPull](t)),refreshStatus:t=>e.request(e=>e[M.gitRefreshStatus](t)),onStatus:(t,n,r)=>{let i=null;return e.subscribe(e=>e[M.subscribeGitStatus](t),e=>{i=o$e(i,e),n(i)},r)},runStackedAction:async(t,n)=>{let r=null;if(await e.requestStream(e=>e[M.gitRunStackedAction](t),e=>{n?.onProgress?.(e),e.kind===`action_finished`&&(r=e.result)}),r)return r;throw Error(`Git action stream completed without a final result.`)},listBranches:t=>e.request(e=>e[M.gitListBranches](t)),createWorktree:t=>e.request(e=>e[M.gitCreateWorktree](t)),removeWorktree:t=>e.request(e=>e[M.gitRemoveWorktree](t)),createBranch:t=>e.request(e=>e[M.gitCreateBranch](t)),checkout:t=>e.request(e=>e[M.gitCheckout](t)),init:t=>e.request(e=>e[M.gitInit](t)),resolvePullRequest:t=>e.request(e=>e[M.gitResolvePullRequest](t)),preparePullRequestThread:t=>e.request(e=>e[M.gitPreparePullRequestThread](t))},pullRequests:{list:t=>e.request(e=>e[M.pullRequestsList](t)),listStats:t=>e.request(e=>e[M.pullRequestsListStats](t)),detail:t=>e.request(e=>e[M.pullRequestsDetail](t)),activity:t=>e.request(e=>e[M.pullRequestsActivity](t)),threadComments:t=>e.request(e=>e[M.pullRequestsThreadComments](t)),diffFileContents:t=>e.request(e=>e[M.pullRequestsDiffFileContents](t)),runAction:t=>e.request(e=>e[M.pullRequestsRunAction](t)),update:t=>e.request(e=>e[M.pullRequestsUpdate](t)),comment:t=>e.request(e=>e[M.pullRequestsComment](t)),updateComment:t=>e.request(e=>e[M.pullRequestsUpdateComment](t)),submitReview:t=>e.request(e=>e[M.pullRequestsSubmitReview](t)),replyToThread:t=>e.request(e=>e[M.pullRequestsReplyToThread](t)),setThreadResolution:t=>e.request(e=>e[M.pullRequestsSetThreadResolution](t)),setReaction:t=>e.request(e=>e[M.pullRequestsSetReaction](t)),invalidate:t=>e.request(e=>e[M.pullRequestsInvalidate](t)),reviewerCandidates:t=>e.request(e=>e[M.pullRequestsReviewerCandidates](t)),requestReviewers:t=>e.request(e=>e[M.pullRequestsRequestReviewers](t))},server:{getConfig:()=>e.request(e=>e[M.serverGetConfig]({})),refreshProviders:()=>e.request(e=>e[M.serverRefreshProviders]({})),startProviderAuth:t=>e.request(e=>e[M.serverStartProviderAuth](t)),repairProviderAuthRuntime:t=>e.request(e=>e[M.serverRepairProviderAuthRuntime](t)),disconnectProviderAuth:t=>e.request(e=>e[M.serverDisconnectProviderAuth](t)),getProviderAuthSession:t=>e.request(e=>e[M.serverGetProviderAuthSession](t)),cancelProviderAuth:t=>e.request(e=>e[M.serverCancelProviderAuth](t)),submitProviderAuthCode:t=>e.request(e=>e[M.serverSubmitProviderAuthCode](t)),syncPersonalCodexToCloud:t=>e.request(e=>e[M.serverSyncPersonalCodexToCloud](t)),syncPersonalClaudeToCloud:t=>e.request(e=>e[M.serverSyncPersonalClaudeToCloud](t)),upsertKeybinding:t=>e.request(e=>e[M.serverUpsertKeybinding](t)),removeKeybinding:t=>e.request(e=>e[M.serverRemoveKeybinding](t)),getSettings:()=>e.request(e=>e[M.serverGetSettings]({})),updateSettings:t=>e.request(e=>e[M.serverUpdateSettings]({patch:t})),updateEnvironmentDisplayName:t=>e.request(e=>e[M.serverUpdateEnvironmentDisplayName](t)),getTraceDiagnostics:t=>e.request(e=>e[M.serverGetTraceDiagnostics](t)),subscribeConfig:(t,n)=>e.subscribe(e=>e[M.subscribeServerConfig]({}),t,n),subscribeLifecycle:(t,n)=>e.subscribe(e=>e[M.subscribeServerLifecycle]({}),t,n),subscribeAuthAccess:(t,n)=>e.subscribe(e=>e[M.subscribeAuthAccess]({}),t,n),subscribeWorkspaceReadiness:(t,n)=>e.subscribe(e=>e[M.subscribeWorkspaceReadiness]({}),t,n)},usage:{getSummary:t=>e.request(e=>e[M.usageGetSummary](t),{timeout:p$e})},orchestration:{dispatchCommand:t=>g$e(e,t),getTurnDiff:(t,n)=>p$(e,e=>e[sn.streamTurnDiff](t),n).then(e=>({...t,diff:new TextDecoder().decode(e)})),getFullThreadDiff:(t,n)=>p$(e,e=>e[sn.streamFullThreadDiff](t),n).then(e=>({...t,fromTurnCount:0,diff:new TextDecoder().decode(e)})),subscribeShell:(t,n)=>e.subscribe(e=>e[sn.subscribeShell]({}),t,n),subscribeThread:(t,n,r)=>e.subscribe(e=>e[sn.subscribeThread](t),n,r)}}}var w$e=new Set([`CMMD_AUTH_REQUIRED`,`CMMD_AUTH_EXPIRED`,`INVALID_OR_NON_USER_TOKEN`,`NON_USER_BEARER`,`CMMD_REST_AUTH_ERROR`]);function h$(e){if(!e||typeof e!=`object`)return null;let t=e.code;return typeof t!=`string`||!w$e.has(t)?null:t}function g$(e,t){return e===401||e===403||h$(t)!==null}function T$e(e){if(!e||typeof e!=`object`)return!1;let t=e.status,n=e.code;return g$(typeof t==`number`?t:void 0,typeof n==`string`?{code:n}:void 0)}function E$e(e){return new Promise(t=>globalThis.setTimeout(t,e))}function _$(){let e=Error(`The environment connection attempt was cancelled.`);return e.name=`AbortError`,e}function v$(e){if(e?.aborted)throw _$()}function D$e(e,t){return t?t.aborted?Promise.reject(_$()):new Promise((n,r)=>{let i=()=>r(_$());t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>{t.removeEventListener(`abort`,i)})}):e}function O$e(e,t){return t?t.aborted?Promise.reject(_$()):new Promise((n,r)=>{let i=globalThis.setTimeout(()=>{t.removeEventListener(`abort`,a),n()},e),a=()=>{globalThis.clearTimeout(i),r(_$())};t.addEventListener(`abort`,a,{once:!0})}):E$e(e)}var y$=`forge.deviceRegistry.deviceKey`,b$=`forge.deviceRegistry.runtimeId`;function k$e(e){let t=C$(y$,e.desktopIdentity?.deviceKey,`device`),n=C$(b$,e.desktopIdentity?.runtimeId,`runtime`),r=S$(e.desktopIdentity?.hostKey),i=N$e(),a=e.desktopAvailable?`desktop`:P$e(),o=e.desktopAvailable?M$e(e.desktopIdentity)??F$e(i):I$e(i);return{device:{...r?{hostKey:r}:{},deviceKey:t,displayName:o,platform:i,deviceType:a,metadata:{clientKind:e.desktopAvailable?`forge-desktop`:`forge-web`,userAgent:window.navigator.userAgent,origin:window.location.origin,...e.desktopIdentity?{desktopIdentity:{hostName:e.desktopIdentity.hostName,computerName:e.desktopIdentity.computerName,platform:e.desktopIdentity.platform}}:{}}},...e.desktopAvailable&&e.includeExecutableRuntime!==!1?{runtime:{runtimeId:n,runtimeKind:`desktop-local`,displayName:`Local Forge Desktop`,endpointUrl:e.desktopEndpointUrl??null,status:`online`,metadata:{origin:window.location.origin}}}:{}}}async function x$(){let e=await window.desktopBridge?.getDeviceIdentity?.()??null;return k$e({desktopAvailable:!!window.desktopBridge,desktopIdentity:e,includeExecutableRuntime:!1})}function S$(e){let t=e?.trim()??``;return t.length>0?t:null}function C$(e,t,n){let r=S$(t);return r?(yJ(e,r),r):j$e(e,n)}function A$e(){return vJ(b$)}function w$(){return vJ(y$)}function j$e(e,t){let n=vJ(e);if(n)return n;let r=`${t}_${crypto.randomUUID()}`;return yJ(e,r),r}function M$e(e){let t=e?.displayName?.trim()??``;return t.length>0?t:null}function N$e(){let e=window.navigator.userAgent.toLowerCase();return e.includes(`iphone`)||e.includes(`ipad`)?`ios`:e.includes(`android`)?`android`:e.includes(`mac`)?`macos`:e.includes(`win`)?`windows`:e.includes(`linux`)?`linux`:`unknown`}function P$e(){let e=window.navigator.userAgent.toLowerCase();return e.includes(`ipad`)||e.includes(`tablet`)?`tablet`:e.includes(`mobi`)||e.includes(`iphone`)||e.includes(`android`)?`mobile`:`browser`}function F$e(e){return e===`macos`?`Mac`:e===`windows`?`Windows PC`:e===`linux`?`Linux Desktop`:`Desktop`}function I$e(e){return e===`web`?`Browser`:e===`macos`?`Mac Browser`:e===`windows`?`Windows Browser`:e===`linux`?`Linux Browser`:`Browser`}var T$=class extends Error{code;constructor(e,t){super(t),this.name=`RelayControlRouteError`,this.code=e}};function E$(e){let t=e&&typeof e==`object`?e.code:null;throw t===`PROTOCOL_INCOMPATIBLE`?new T$(`FORGE_RUNTIME_UPDATE_REQUIRED`,`Update Forge on the target runtime before connecting remotely.`):t===`PROTOCOL_ROLLOUT_DENIED`?new T$(`FORGE_REMOTE_CONTROL_NOT_ENABLED`,`Remote control is not enabled for this CMMD account. Synced runtime inventory remains available.`):e}async function L$e(e){let t=e.getStoredDeviceKey(),n=t?await e.apiClient.getDeviceRegistry():await e.apiClient.registerDevice(await e.buildDeviceRegistration());return t&&!n.devices.some(e=>e.deviceKey===t)&&(n=await e.apiClient.registerDevice(await e.buildDeviceRegistration())),t??=e.getStoredDeviceKey(),{deviceKey:t,registry:n}}function R$e(e){if(!e.deviceKey)throw new T$(`FORGE_CONTROL_DEVICE_UNAUTHORIZED`,`This Forge control surface could not establish CMMD identity.`);let t=e.registry.devices.find(t=>t.deviceKey===e.deviceKey);if(t?.trustState===`revoked`||t?.authorization?.revoked===!0)throw new T$(`FORGE_CONTROL_DEVICE_REVOKED`,`This Forge control surface was revoked by CMMD.`);if(!t||t.trustState!==`trusted`)throw new T$(`FORGE_CONTROL_DEVICE_UNAUTHORIZED`,`This Forge control surface is not trusted by CMMD.`);return t}function z$e(e,t){let n=async()=>R$e(await L$e(t));return{acquireRoute:async()=>{let r=await n(),i=await lce();try{return dce({route:await t.apiClient.issueRelayControlRoute(e,{controlDeviceId:r.id,controlSessionId:t.controlSessionId,scopes:[...qn],protocolMinVersion:4,protocolMaxVersion:4,...uce(i)}),runtimeId:e,endpoint:i})}catch(e){if(e instanceof gl)throw new T$(`FORGE_RUNTIME_UPDATE_REQUIRED`,e.message);return E$(e)}},acquireActionGrant:async r=>{let i=await n();try{return(await t.apiClient.issueRelayActionGrant(e,{controlDeviceId:i.id,controlSessionId:t.controlSessionId,...r})).token}catch(e){return E$(e)}}}}var D$=`forge.relayControlJournal.v1`;function O$(){if(globalThis.localStorage===void 0)throw Error(`Forge relay control recovery requires durable browser storage.`);return globalThis.localStorage}var B$e={read:()=>O$().getItem(D$),write:e=>O$().setItem(D$,e)},k$=null,A$=Wt()(e=>({byRuntimeId:{},replace:t=>e({byRuntimeId:t})}));function V$e(e){e.subscribe(e=>{let t=new Set(e.records.map(e=>e.runtimeId));A$.getState().replace(Object.fromEntries([...t].map(t=>[t,Rse(e.records,t)])))})}function j$(){return k$===null&&(k$=zc({storage:B$e}),V$e(k$)),k$}function H$e(){let e=(0,Cl.c)(1),t=A$(W$e),n;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],e[0]=n):n=e[0],(0,F.useEffect)(U$e,n),t}function U$e(){j$()}function W$e(e){return e.byRuntimeId}function G$e(e){let t=j$();for(let n of t.records())n.runtimeId===e&&(n.status===`failed`||n.status===`outcome-unknown`)&&t.acknowledge(n.runtimeId,n.actorSessionId,n.transportRequestId)}var K$e=6e4;function q$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 M$=`CMMD returned an invalid Cloud runtime connection descriptor.`;function N$(e,t){let n=e[t];if(typeof n!=`string`||n.length===0)throw Error(M$);return n}function J$e(e){if(!e||typeof e!=`object`)throw Error(M$);let t=e;return{httpBaseUrl:N$(t,`httpBaseUrl`),wsBaseUrl:N$(t,`wsBaseUrl`),bearerToken:N$(t,`bearerToken`),expiresAt:N$(t,`expiresAt`)}}async function Y$e(e){let t=await fetch(lr(`/api/cmmd/forge-runtimes/${encodeURIComponent(e.runtimeId)}/connect`),rr({method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e.organizationId===void 0?{}:{organizationId:e.organizationId})})),n=await t.json().catch(()=>null);if(!t.ok){let e=g$(t.status,n)?`CMMD authentication expired while renewing the Cloud runtime connection. Sign in again.`:`CMMD could not renew the Cloud runtime connection (${t.status}).`;throw Object.assign(Error(q$e(n,e)),{status:t.status,...h$(n)?{code:h$(n)}:{}})}return J$e(n)}function X$e(e,t){if(!e?.expiresAt)return!0;let n=Date.parse(e.expiresAt);return!Number.isFinite(n)||n<=t+K$e}function P$(e){let t=e.requestDescriptor??Y$e,n=e.now??Date.now,r=e.initialDescriptor??null,i=null,a=!1,o=()=>i||(i=t({runtimeId:e.runtimeId,...e.organizationId===void 0?{}:{organizationId:e.organizationId}}).then(async t=>(await e.validateDescriptor?.(t),await e.persistDescriptor?.(t),r=t,a=!1,t)).then(e=>(i=null,e),e=>{throw i=null,e}),i);return{acquire:e=>e?.forceRefresh||a||X$e(r,n())?o():Promise.resolve(r),invalidate:()=>{a=!0}}}var Z$e=12e4,Q$e=3e4,F$=3e4;function I$(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){if(!e||typeof e!=`object`)return!1;let t=e.status;return t===401||t===403}function e1e(e){let t=e.now??Date.now,n=e.renewalSkewMs??Z$e,r=!1,i=null,a=null,o=I$(e.initialDescriptor),s=()=>{i!==null&&(globalThis.clearTimeout(i),i=null)},c=a=>{if(r)return;s();let c=I$(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()+F$;return e>=o?null:(i=globalThis.setTimeout(()=>{i=null,u().catch(()=>void 0)},F$),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=I$(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(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()+Q$e?Promise.resolve():u(),renewNow:u,dispose:()=>{r=!0,s()}}}var L$=new Map,R$=new Map,z$=new Map,B$=new Map,V$=new Map,H$=new Set,U$=new Map,W$=null,G$=!1;function K$(e){return B$.get(e)??0}function q$(e){B$.set(e,K$(e)+1)}function J$(e,t){return e.environmentId===t.environmentId&&e.httpBaseUrl===t.httpBaseUrl&&e.wsBaseUrl===t.wsBaseUrl&&e.runtimeId===t.runtimeId&&e.cmmdOrganizationId===t.cmmdOrganizationId}function Y$(e){if(K$(e.record.environmentId)!==e.generation)return!1;let t=mX(e.record.environmentId);return e.registryExpectation.kind===`initial-add`?t===null||J$(t,e.record):t!==null&&J$(t,e.registryExpectation.record)}var t1e=9e5,X$=32,Z$=()=>void 0;function Q$(e,t){return Vo(Lo(e,t))}function $$(e){return e.evictionTimeoutId!==null&&(clearTimeout(e.evictionTimeoutId),e.evictionTimeoutId=null),e}function n1e(e){let t=Lo(e.environmentId,e.threadId),n=yZ.getState(),r=vZ(n,t);if(r){if(r.hasPendingApprovals||r.hasPendingUserInput||r.hasActionableProposedPlan)return!0;let e=r.session?.orchestrationStatus;if(e&&e!==`idle`&&e!==`stopped`||r.latestTurn?.state===`running`)return!0}let i=_Z(n,t);if(!i)return!1;let a=i.session?.orchestrationStatus;return!!(a&&a!==`idle`&&a!==`stopped`)||i.latestTurn?.state===`running`||i.pendingSourceProposedPlan!==void 0}function e1(e){return e.refCount===0&&!n1e(e)}function t1(e){if(e.unsubscribeConnectionListener!==null&&(e.unsubscribeConnectionListener(),e.unsubscribeConnectionListener=null),e.unsubscribe!==Z$)return!0;let t=j1(e.environmentId);return t?(e.unsubscribe=t.client.orchestration.subscribeThread({threadId:e.threadId},t=>{if(e.lastEventAt=Date.now(),e.recoveryAttempts=0,t.kind===`snapshot`){yZ.getState().syncServerThreadDetail(t.snapshot.thread,e.environmentId),yZ.getState().clearThreadSubscriptionError(e.environmentId,e.threadId);return}E1e(t.event,e.environmentId)},{onError:t=>rXe(e.environmentId,e.threadId,t)}),!0):!1}function n1(e){e.unsubscribeConnectionListener===null&&(e.unsubscribeConnectionListener=A1(()=>{t1(e)&&(e.lastAccessedAt=Date.now())}),t1(e))}function r1(e){let t=U$.get(e);return t?($$(t),t.unsubscribeConnectionListener?.(),t.unsubscribeConnectionListener=null,U$.delete(e),t.unsubscribe(),t.unsubscribe=Z$,c1e(),!0):!1}var i1=null;function r1e(e){let t=Lo(e.environmentId,e.threadId),n=yZ.getState(),r=vZ(n,t);if(r?.latestTurn?.state===`running`||r?.session?.orchestrationStatus===`running`)return!0;let i=_Z(n,t);return i?.latestTurn?.state===`running`||i?.session?.orchestrationStatus===`running`}function i1e(e){e.unsubscribe!==Z$&&(e.unsubscribe(),e.unsubscribe=Z$),t1(e)||n1(e)}function a1e(e,t,n){if(e.recoveryAttempts+=1,e.lastEventAt=Date.now(),console.warn(`[forge] thread-detail liveness watchdog recovering`,{action:t,threadId:String(e.threadId),environmentId:String(e.environmentId),msSinceLastEvent:Math.round(n),recoveryAttempts:e.recoveryAttempts}),t===`resubscribe`){i1e(e);return}j1(e.environmentId)?.reconnect().catch(t=>{zK(t,{route:`thread-detail-liveness-watchdog-reconnect-failed`,threadId:String(e.threadId),environmentId:String(e.environmentId),msSinceLastEvent:String(Math.round(n)),recoveryAttempts:String(e.recoveryAttempts)})})}function o1e(){let e=Date.now();for(let t of U$.values()){let n=xXe({isWorking:r1e(t),msSinceLastEvent:e-t.lastEventAt,stallThresholdMs:SXe,recoveryAttempts:t.recoveryAttempts,maxResubscribeAttempts:2,maxTotalAttempts:4});n!==`none`&&a1e(t,n,e-t.lastEventAt)}}function s1e(){i1===null&&(i1=setInterval(o1e,CXe))}function c1e(){U$.size>0||i1!==null&&(clearInterval(i1),i1=null)}function l1e(e){for(let[t,n]of U$)n.environmentId===e&&r1(t)}function u1e(e){let t=Lo(e.environmentId,e.threadId),n=yZ.getState(),r=_Z(n,t);if(!r)return null;let i=vZ(n,t),a=i?.latestUserMessageAt??null;if(a===null)for(let e=r.messages.length-1;e>=0;--e){let t=r.messages[e];if(t?.role===`user`){a=t.createdAt;break}}return{id:r.id,projectId:r.projectId,title:r.title,modelSelection:r.modelSelection,runtimeMode:r.runtimeMode,interactionMode:r.interactionMode,branch:r.branch,worktreePath:r.worktreePath,latestTurn:r.latestTurn,createdAt:r.createdAt,updatedAt:r.updatedAt??r.createdAt,archivedAt:r.archivedAt,session:r.session?{threadId:r.id,updatedAt:r.session.updatedAt,providerName:r.session.provider,runtimeMode:r.runtimeMode,activeTurnId:r.session.activeTurnId??null,lastError:r.session.lastError??null,status:r.session.orchestrationStatus}:null,latestUserMessageAt:a,hasPendingApprovals:i?.hasPendingApprovals??!1,hasPendingUserInput:i?.hasPendingUserInput??!1,hasActionableProposedPlan:i?.hasActionableProposedPlan??!1,anchorKind:r.anchorKind,anchorCmmdId:r.anchorCmmdId,kind:r.kind,parentThreadId:r.parentThreadId,status:r.status,workerRole:r.workerRole,goal:r.goal,titleRegeneration:r.titleRegeneration??null}}function d1e(e,t){if(U$.size===0)return e;let n=new Set(e.threads.map(e=>e.id)),r=[];for(let e of U$.values()){if(e.environmentId!==t||e.refCount<=0||n.has(e.threadId))continue;let i=u1e(e);i&&(n.add(i.id),r.push(i))}return r.length===0?e:{...e,threads:[...e.threads,...r]}}function f1e(e,t){let n=new Set(t);for(let[t,r]of U$)r.environmentId===e&&!n.has(r.threadId)&&e1(r)&&r1(t)}function p1e(e){$$(e),e1(e)&&(e.evictionTimeoutId=setTimeout(()=>{let t=U$.get(Q$(e.environmentId,e.threadId));t&&(t.evictionTimeoutId=null,e1(t)&&r1(Q$(e.environmentId,e.threadId)))},t1e))}function a1(){if(U$.size<=X$)return;let e=[...U$.entries()].filter(([,e])=>e1(e)).toSorted(([,e],[,t])=>e.lastAccessedAt-t.lastAccessedAt);for(let[t]of e){if(U$.size<=X$)return;r1(t)}}function o1(e){$$(e),e1(e)&&p1e(e)}function m1e(e,t){let n=U$.get(Q$(e,t));n&&o1(n)}function s1(e){for(let t of U$.values())t.environmentId===e&&o1(t);a1()}function h1e(e,t){let n=Q$(e,t),r=U$.get(n);if(r){$$(r),r.refCount+=1,r.lastAccessedAt=Date.now(),t1(r)||n1(r);let e=!1;return()=>{e||(e=!0,r.refCount=Math.max(0,r.refCount-1),r.lastAccessedAt=Date.now(),r.refCount===0&&(o1(r),a1()))}}let i={environmentId:e,threadId:t,unsubscribe:Z$,unsubscribeConnectionListener:null,refCount:1,lastAccessedAt:Date.now(),evictionTimeoutId:null,lastEventAt:Date.now(),recoveryAttempts:0};U$.set(n,i),t1(i)||n1(i),s1e(),a1();let a=!1;return()=>{a||(a=!0,i.refCount=Math.max(0,i.refCount-1),i.lastAccessedAt=Date.now(),i.refCount===0&&(o1(i),a1()))}}function c1(){for(let e of H$)e()}function g1e(e){return{lastError:e instanceof Error?e.message:String(e),lastErrorAt:new Date().toISOString()}}function l1(){return new Date().toISOString()}var u1=8,d1=[1e3,2e3,4e3,8e3,12e3,16e3,2e4],_1e=9e4;function v1e(e){if(typeof e!=`object`||!e)return null;let t=e.status;return typeof t==`number`&&Number.isInteger(t)?t:null}function y1e(e){if(T$e(e))return!1;let t=v1e(e);if(t===502||t===503||t===504||e._tag===`OrchestrationGetSnapshotError`)return!0;let n=e instanceof Error?e.message:String(e),r=n.toLowerCase();return r.includes(`all fibers interrupted without error`)||r.includes(`timed out while waiting for forge cloud runtime metadata`)||r.includes(`timed out while waiting for`)||r.includes(`to stream its shell snapshot`)||r.includes(`forge runtime route not found`)||r.includes(`fly-replay`)||r.includes(`could not find a good candidate`)||r.includes(`instance refused connection`)||n.includes(`Unknown socket error`)||n.includes(`Failed to fetch remote auth endpoint`)||n.includes(`Forge runtime replay target is unavailable`)||n.includes(`Remote auth request failed (502)`)||n.includes(`Remote auth request failed (503)`)||n.includes(`Remote auth request failed (504)`)||n.includes(`Unable to connect to the Forge server WebSocket`)}function b1e(e){return d1[e]??d1[d1.length-1]}function x1e(){return _1e}function S1e(e,t){if(!HY(e))return t;let n=null,r=new Promise((t,r)=>{n=globalThis.setTimeout(()=>{r(Error(`Timed out while waiting for Forge Cloud runtime metadata for ${e}. The VM may still be starting.`))},x1e())});return Promise.race([t,r]).finally(()=>{n!==null&&globalThis.clearTimeout(n)})}function f1(e){bX.getState().patch(e,{connectionState:`connecting`,lastError:null,lastErrorAt:null})}function p1(e){let t=l1();bX.getState().patch(e,{connectionState:`connected`,authState:`authenticated`,connectedAt:t,disconnectedAt:null,lastError:null,lastErrorAt:null}),uX.getState().markConnected(e,t)}function m1(e,t){bX.getState().patch(e,{descriptor:t.environment,serverConfig:t})}function h1(e,t){bX.getState().patch(e,{connectionState:`disconnected`,disconnectedAt:l1(),...t&&t.trim().length>0?{lastError:t,lastErrorAt:l1()}:{}})}function g1(e,t){bX.getState().patch(e,{connectionState:`error`,...g1e(t)})}function C1e(e){if(e.length<2)return[...e];let t=[];for(let n of e){let e=t.at(-1);if(e?.type===`thread.message-sent`&&n.type===`thread.message-sent`&&e.payload.threadId===n.payload.threadId&&e.payload.messageId===n.payload.messageId){t[t.length-1]={...n,payload:{...n.payload,attachments:n.payload.attachments??e.payload.attachments,createdAt:e.payload.createdAt,text:!n.payload.streaming&&n.payload.text.length>0?n.payload.text:e.payload.text+n.payload.text}};continue}t.push(n)}return t}function _1(){let e=fZ(yZ.getState());PQ.getState().syncProjects(e.map(e=>({key:Bo(Io(e.environmentId,e.id)),cwd:e.cwd})))}function v1(){let e=pZ(yZ.getState());PQ.getState().syncThreads(e.map(e=>({key:Vo(Lo(e.environmentId,e.id)),seedVisitedAt:e.updatedAt??e.createdAt}))),CJe(e.map(e=>Lo(e.environmentId,e.id)))}function w1e(){_1(),v1();let e=iXe({snapshotThreads:pZ(yZ.getState()).map(e=>({key:Vo(Lo(e.environmentId,e.id)),deletedAt:null,archivedAt:e.archivedAt})),draftThreadKeys:RY.getState().listDraftThreadKeys()});fQ.getState().removeOrphanedTerminalStates(e)}function y1(e){return e.serverThreadArchivedAt===void 0?e.hasDraftThread:e.serverThreadArchivedAt===null}function T1e(e,t){if(e.length===0)return;let n=aXe(e),r=C1e(e),i=e.some(e=>e.type===`project.created`||e.type===`project.meta-updated`||e.type===`project.deleted`);if(n.needsProviderInvalidation&&(G$=!0,W$?.queryInvalidationThrottler.maybeExecute()),yZ.getState().applyOrchestrationEvents(r,t),i){let e=fZ(yZ.getState());PQ.getState().syncProjects(e.map(e=>({key:Bo(Io(e.environmentId,e.id)),cwd:e.cwd})))}if(e.some(e=>e.type===`thread.created`||e.type===`thread.deleted`)){let e=pZ(yZ.getState());PQ.getState().syncThreads(e.map(e=>({key:Vo(Lo(e.environmentId,e.id)),seedVisitedAt:e.updatedAt??e.createdAt})))}let a=RY.getState();for(let e of n.promoteDraftThreadIds)zY(Lo(t,e));for(let e of n.clearDeletedThreadIds)a.clearDraftThread(Lo(t,e)),PQ.getState().clearThreadUi(Vo(Lo(t,e)));for(let e of n.removeTerminalStateThreadIds){let n=Lo(t,e);fQ.getState().removeTerminalState(n),yQ.getState().clearBrowserState(n)}s1(t)}function E1e(e,t){T1e([e],t)}function D1e(e,t){let n=e.kind===`thread-upserted`?e.thread.id:e.kind===`thread-removed`?e.threadId:null,r=n?Lo(t,n):null,i=r?_Z(yZ.getState(),r):void 0;switch(yZ.getState().applyShellEvent(e,t),e.kind){case`project-upserted`:case`project-removed`:_1();return;case`thread-upserted`:v1(),!i&&r&&zY(r),i?.archivedAt===null&&e.thread.archivedAt!==null&&r&&(fQ.getState().removeTerminalState(r),yQ.getState().clearBrowserState(r)),m1e(t,e.thread.id),a1();return;case`thread-removed`:r&&(r1(Vo(r)),RY.getState().clearDraftThread(r),PQ.getState().clearThreadUi(Vo(r)),fQ.getState().removeTerminalState(r),yQ.getState().clearBrowserState(r)),v1();return}}function O1e(e,t){return e.invalidateQueries({queryKey:CZ.all(t)})}function b1(e){return{onWelcome:(t,n)=>{e?.(t),W$&&O1e(W$.queryClient,n)},applyShellEvent:D1e,syncShellSnapshot:(e,t)=>{let n=d1e(e,t);yZ.getState().syncServerShellSnapshot(n,t),f1e(t,n.threads.map(e=>e.id)),s1(t),w1e()},applyTerminalEvent:(e,t)=>{let n=Lo(t,nn.make(e.threadId)),r=_Z(yZ.getState(),n),i=RY.getState().getDraftThreadByRef(n)!==null;y1({serverThreadArchivedAt:r?.archivedAt,hasDraftThread:i})&&fQ.getState().applyTerminalEvent(n,e)},applyBrowserEvent:(e,t)=>{let n=Lo(t,nn.make(e.threadId)),r=_Z(yZ.getState(),n),i=RY.getState().getDraftThreadByRef(n)!==null;y1({serverThreadArchivedAt:r?.archivedAt,hasDraftThread:i})&&yQ.getState().applyBrowserEvent(n,e)},onShellSubscriptionError:(e,t)=>{g1(t,e)}}}function x1(){if(typeof window>`u`)return;let e=nr();if(e?.primaryMode===`cloud`&&e.bearerToken)return{bearerToken:e.bearerToken,httpBaseUrl:e.httpBaseUrl,wsBaseUrl:e.wsBaseUrl}}function k1e(){if(typeof window>`u`)return;let e=nr(),t=e?.primaryMode===`cloud`?e.desktopLocal??null:e??null;if(!(!t?.httpBaseUrl||!t.wsBaseUrl||!t.bearerToken))return{bearerToken:t.bearerToken,httpBaseUrl:t.httpBaseUrl,wsBaseUrl:t.wsBaseUrl,label:t.label}}function A1e(e){let t=qie(e);if(!t)throw Error(`Unable to resolve websocket URL for ${e?.label??`primary environment`}.`);return m$(new o$(async()=>{await cr().catch(()=>null);let e=x1();if(e)try{return await EZ({wsBaseUrl:e.wsBaseUrl,httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken})}catch(e){throw cq(e)&&dr(`ws-token`),e}return OGe(t)}))}function j1e(e){return m$(new o$(()=>EZ({wsBaseUrl:e.wsBaseUrl,httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken}),{trackGlobalConnection:!1,onAttempt:()=>{f1(e.environmentId)},onOpen:()=>{p1(e.environmentId)},onError:t=>{bX.getState().patch(e.environmentId,{connectionState:`error`,lastError:t,lastErrorAt:l1()})},onClose:t=>{h1(e.environmentId,t.reason)}}))}function S1(e){let t=e.toLowerCase();return t.includes(`authentication`)||t.includes(`unauthorized`)||t.includes(`forbidden`)||t.includes(`credential`)||t.includes(`runtime ticket`)||t.includes(`status 401`)||t.includes(`status 403`)}function M1e(e){let t=e.runtimeId?.trim();if(t)return t;let n=UY(e.environmentId);if(!n)throw Error(`Saved Cloud environment ${e.environmentId} is missing its runtime id.`);return n}function N1e(e,t,n){let r=e;return P$({runtimeId:M1e(e),...e.cmmdOrganizationId===void 0?{}:{organizationId:e.cmmdOrganizationId},...t===void 0?{}:{initialDescriptor:{httpBaseUrl:e.httpBaseUrl,wsBaseUrl:e.wsBaseUrl,bearerToken:t,expiresAt:e.runtimeTicketExpiresAt??null}},validateDescriptor:async e=>{await TZ({httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken})},persistDescriptor:async e=>{if(n&&!n())throw Error(`Saved environment changed while its connection was being acquired.`);let t={...F1(r),httpBaseUrl:e.httpBaseUrl,wsBaseUrl:Wn(e.wsBaseUrl),...e.expiresAt===null?{}:{runtimeTicketExpiresAt:e.expiresAt},lastConnectedAt:l1()};await gX(t),await vX(t.environmentId),uX.getState().upsert(t),r=t}})}function P1e(e){let t={wsBaseUrl:e.record.wsBaseUrl,httpBaseUrl:e.record.httpBaseUrl,bearerToken:e.bearerToken,expiresAt:e.record.runtimeTicketExpiresAt??null};return{acquire:()=>Promise.resolve(t)}}function F1e(e,t,n){return n()&&bX.getState().ensure(e.environmentId),m$(new o$(async()=>{let n=await t.acquire(),r=t=>EZ({wsBaseUrl:t.wsBaseUrl,httpBaseUrl:t.httpBaseUrl,bearerToken:t.bearerToken,...HY(e.environmentId)?{runtimeTicket:t.bearerToken}:{}});try{return await r(n)}catch(n){if(!HY(e.environmentId)||!cq(n))throw n;return r(await t.acquire({forceRefresh:!0}))}},{trackGlobalConnection:!1,onAttempt:()=>{n()&&f1(e.environmentId)},onOpen:()=>{n()&&p1(e.environmentId)},onError:r=>{HY(e.environmentId)&&S1(r)&&t.invalidate?.(),n()&&bX.getState().patch(e.environmentId,{connectionState:`error`,lastError:r,lastErrorAt:l1()})},onClose:r=>{HY(e.environmentId)&&(r.code===1008||S1(r.reason))&&t.invalidate?.(),n()&&h1(e.environmentId,r.reason)}}))}async function C1(e,t,n,r,i,a,o){let s=await t.acquire(),[c,l]=await Promise.all([a?Promise.resolve(a):n.server.getConfig(),TZ({httpBaseUrl:s.httpBaseUrl,bearerToken:s.bearerToken,...o?{signal:o}:{}})]);if(!r())return!1;bX.getState().patch(e.environmentId,{authState:l.authenticated?`authenticated`:`requires-auth`,descriptor:c.environment,serverConfig:c,role:l.authenticated?l.role??i??null:null});let u=mX(e.environmentId);return r()&&l.authenticated&&u&&uX.getState().upsert({...u,lastAuthenticatedPullRequestCapability:c.environment.capabilities?.pullRequests===!0}),!0}function w1(e){let t=L$.get(e.environmentId);if(t&&t!==e)throw Error(`Environment ${e.environmentId} already has an active connection.`);return L$.set(e.environmentId,e),c1(),e}async function T1(e){let t=L$.get(e);return t?(L$.delete(e),l1e(e),c1(),await t.dispose(),!0):!1}function E1(){let e=Fq();if(!e?.environmentId)throw Error(`Unable to resolve the primary environment.`);let t=L$.get(e.environmentId);if(t)return t;let n=x1(),r=e.source===`paired-bearer`||!0;return w1(DZ({kind:`primary`,knownEnvironment:e,client:A1e(e),resolveEnvironmentId:()=>Fq()?.environmentId??e.environmentId,...r?{readiness:n?{bearerToken:n.bearerToken}:{}}:{},...b1()}))}async function I1e(e,t,n){let r=L$.get(e.environmentId);if(r)return r;let i=HY(e.environmentId),a=()=>Y$({record:e,generation:t,registryExpectation:n?.registryExpectation??{kind:`existing-record`,record:e}}),o=i?n?.bearerToken:n?.bearerToken??await _X(e.environmentId);if(!i&&!o)throw a()&&bX.getState().patch(e.environmentId,{authState:`requires-auth`,role:null,connectionState:`disconnected`,lastError:`Saved environment is missing its saved credential. Pair it again.`,lastErrorAt:l1()}),Error(`Saved environment is missing its saved credential.`);let s=i?N1e(e,o??void 0,a):P1e({record:e,bearerToken:o}),c=await s.acquire();if(!a())throw Error(`Saved environment changed while its connection was being acquired.`);let l=n?.client??F1e(e,s,a),u=Po({id:e.environmentId,label:e.label,source:`manual`,target:{httpBaseUrl:c.httpBaseUrl,wsBaseUrl:c.wsBaseUrl}}),d=i&&c.expiresAt?e1e({initialDescriptor:{httpBaseUrl:c.httpBaseUrl,wsBaseUrl:c.wsBaseUrl,bearerToken:c.bearerToken,expiresAt:c.expiresAt},renew:async()=>{let e=await s.acquire({forceRefresh:!0});return{httpBaseUrl:e.httpBaseUrl,wsBaseUrl:e.wsBaseUrl,bearerToken:e.bearerToken,expiresAt:e.expiresAt??null}},onState:t=>{a()&&bX.getState().patch(e.environmentId,{providerAuthority:t})}}):null,f=DZ({kind:`saved`,knownEnvironment:{...u,environmentId:e.environmentId},client:l,readiness:{bearerToken:c.bearerToken},tolerateReportedEnvironmentIdentity:i,refreshMetadata:async()=>{await C1(e,s,l,a)},...d?{ensureProviderAuthority:d.ensureLive,onDispose:d.dispose}:{},onConfigSnapshot:t=>{a()&&bX.getState().patch(e.environmentId,{descriptor:t.environment,serverConfig:t})},...b1(t=>{a()&&bX.getState().patch(e.environmentId,{descriptor:t.environment})})});try{if(!await S1e(e.environmentId,C1(e,s,l,a,n?.role??null,n?.serverConfig??null,n?.signal))||!a())throw Error(`Saved environment changed while its connection was being acquired.`);return w1(f)}catch(t){throw a()&&g1(e.environmentId,t),await f.dispose().catch(()=>void 0),t}}async function D1(e,t){let n=L$.get(e.environmentId);if(n)return n;let r=K$(e.environmentId),i=V$.get(e.environmentId);if(i&&i.generation===r&&J$(i.record,e))return i.promise;let a=I1e(e,r,t).finally(()=>{V$.get(e.environmentId)?.promise===a&&V$.delete(e.environmentId)});return V$.set(e.environmentId,{generation:r,record:e,promise:a}),a}async function O1(e){await tX(e);let t=new Map(e.map(e=>[e.environmentId,e]));for(let[e,n]of V$){let r=t.get(e);(!r||!J$(r,n.record))&&q$(e)}let n=new Set(e.map(e=>e.environmentId)),r=[...L$.values()].filter(e=>e.kind===`saved`).map(e=>e.environmentId).filter(e=>!n.has(e));await Promise.all(r.map(async e=>{q$(e),await N1(e)}))}function k1(){W$?.stop(),W$=null}function A1(e){return H$.add(e),()=>{H$.delete(e)}}function j1(e){return L$.get(e)??null}function L1e(e){let t=j1(e);if(!t)throw Error(`No websocket client registered for environment ${e}.`);return t}function M1(){return E1()}async function R1e(){let e=k1e();if(!e)throw Error(`Desktop Local runtime is not authenticated. Sign in with CMMD again before importing local projects.`);let t=await dXe({httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken});return L$.get(t.environmentId)||w1(DZ({kind:`desktop-local`,knownEnvironment:{...Po({id:t.environmentId,label:e.label,source:`desktop-managed`,target:{httpBaseUrl:e.httpBaseUrl,wsBaseUrl:e.wsBaseUrl}}),environmentId:t.environmentId,label:t.label},client:j1e({environmentId:t.environmentId,httpBaseUrl:e.httpBaseUrl,wsBaseUrl:e.wsBaseUrl,bearerToken:e.bearerToken}),...b1()}))}async function z1e(e){let t=en.make(e.runtimeId),n=L$.get(t);if(n)return n;f1(t);let r=j$(),i=z$e(e.runtimeId,{apiClient:aq,getStoredDeviceKey:w$,buildDeviceRegistration:x$,controlSessionId:r.controlSessionId}),a=await i.acquireRoute(),o=a,s=cce({acquireRoute:async()=>{let e=o;return o=null,e??i.acquireRoute()},acquireActionGrant:i.acquireActionGrant,journal:r,lifecycle:{onConnecting:()=>{f1(t)},onAuthenticated:()=>{p1(t)},onDisconnected:e=>{h1(t,e.reason)},onError:e=>{g1(t,Object.assign(Error(e.message),e))}}}),c=m$(new o$(a.relayWebSocketUrl,{trackGlobalConnection:!1},{layer:s,makeClient:sce(qn)})),l=DZ({kind:`saved`,knownEnvironment:{...Po({id:t,label:e.label,source:`manual`,target:{httpBaseUrl:or()?.target.httpBaseUrl??a.relayWebSocketUrl,wsBaseUrl:a.relayWebSocketUrl}}),environmentId:t},client:c,tolerateReportedEnvironmentIdentity:!0,onConfigSnapshot:e=>{m1(t,e)},...b1(e=>{bX.getState().patch(t,{descriptor:e.environment})})});try{let[,e]=await Promise.all([l.ensureBootstrapped(),c.server.getConfig()]);return m1(t,e),p1(t),w1(l)}catch(e){throw g1(t,e),await l.dispose().catch(()=>void 0),e}}function B1e(e){let t=en.make(e.runtimeId),n=L$.get(t);if(n)return Promise.resolve(n);let r=R$.get(t);if(r)return r;let i=z1e(e).finally(()=>{R$.delete(t)});return R$.set(t,i),i}async function N1(e){L$.get(e)?.kind===`saved`&&(bX.getState().clear(e),await T1(e).catch(()=>!1))}function P1(e){for(let t of e){let e=z$.get(t);e===void 0||e<=1?z$.delete(t):z$.set(t,e-1)}}async function V1e(e){let t=e.environmentId;z$.set(t,(z$.get(t)??0)+1);try{return j1(t)||await I1(e),!0}catch{return P1([t]),!1}}async function H1e(){await fX();let e=(await Promise.all(XJe().map(async e=>await V1e(e)?e.environmentId:null))).flatMap(e=>e===null?[]:[e]),t=!1;return()=>{t||(t=!0,P1(e))}}async function U1e(e){q$(e),uX.getState().remove(e),await vX(e),await N1(e)}function F1(e){let t=mX(e.environmentId);if(t?.lastAuthenticatedPullRequestCapability!==void 0)return{...e,lastAuthenticatedPullRequestCapability:t.lastAuthenticatedPullRequestCapability};let n=bX.getState().byId?.[e.environmentId];return n?.authState===`authenticated`&&n.descriptor?{...e,lastAuthenticatedPullRequestCapability:n.descriptor.capabilities.pullRequests===!0}:e}async function W1e(e){let t=en.make(e.environment.environmentId),n=mX(t),{kind:r,cmmdOrganizationId:i,cmmdProjectId:a,runtimeId:o,runtimeTicketExpiresAt:s}=e.environment,c={environmentId:t,label:e.environment.label,wsBaseUrl:Wn(e.environment.wsBaseUrl),httpBaseUrl:e.environment.httpBaseUrl,createdAt:n?.createdAt??l1(),lastConnectedAt:l1(),...r===void 0?{}:{kind:r},...i===void 0?{}:{cmmdOrganizationId:i},...a===void 0?{}:{cmmdProjectId:a},...o===void 0?{}:{runtimeId:o},...s===void 0?{}:{runtimeTicketExpiresAt:s}};v$(e.signal);let l=pX(),u=n?await _X(c.environmentId):null;q$(c.environmentId),await T1(c.environmentId).catch(()=>!1),await I1(c,{bearerToken:e.bearerToken,registryExpectation:n?{kind:`existing-record`,record:n}:{kind:`initial-add`},...e.signal?{signal:e.signal}:{},...e.onBootstrapRetry?{onBootstrapRetry:e.onBootstrapRetry}:{}});let d=!1;try{return v$(e.signal),await gX(c),d=!0,v$(e.signal),await vX(c.environmentId),v$(e.signal),uX.getState().upsert(F1(c)),c}catch(t){throw await T1(c.environmentId).catch(()=>!1),u&&await QJe(c.environmentId,u),d&&await tX(l),v$(e.signal),t}}async function I1(e,t){if(!HY(e.environmentId))return D1(e,t);let n=K$(e.environmentId),r=()=>Y$({record:e,generation:n,registryExpectation:t?.registryExpectation??{kind:`existing-record`,record:e}}),i=null;for(let n=0;n<u1;n+=1){v$(t?.signal);try{let n=await D1(e,t);return await D$e(n.ensureBootstrapped(),t?.signal),n}catch(a){if(i=a,!r())throw a;if(await T1(e.environmentId).catch(()=>!1),v$(t?.signal),n>=7||!y1e(a))throw r()&&g1(e.environmentId,a),a;let o=b1e(n);t?.onBootstrapRetry?.({attempt:n+2,maxAttempts:u1,retryDelayMs:o,error:a}),r()&&bX.getState().patch(e.environmentId,{connectionState:`connecting`,lastError:null,lastErrorAt:null}),await O$e(o,t?.signal)}}let a=i instanceof Error?i:Error(String(i));throw r()&&g1(e.environmentId,a),a}async function G1e(e){await L$.get(e)?.ensureBootstrapped()}async function K1e(e){let t=L$.get(e);if(!HY(e)){await t?.ensureProviderAuthority?.();return}if(!t?.ensureProviderAuthority)throw Error(`Cloud runtime provider authority is not available.`);await t.ensureProviderAuthority()}function q1e(e){if(W$?.queryClient===e)return W$.refCount+=1,()=>{!W$||W$.queryClient!==e||(--W$.refCount,W$.refCount===0&&k1())};k1(),G$=!1;let t=new FKe(()=>{G$&&(G$=!1,e.invalidateQueries({queryKey:SZ.all}),e.invalidateQueries({queryKey:xZ.all}))},{wait:100,leading:!1,trailing:!0});E1(),cr().catch(()=>void 0);let n=uX.subscribe(()=>{dX()&&O1(pX())});return fX().then(()=>O1(pX())).catch(()=>void 0),W$={queryClient:e,queryInvalidationThrottler:t,refCount:1,stop:()=>{n(),t.cancel()}},()=>{!W$||W$.queryClient!==e||(--W$.refCount,W$.refCount===0&&k1())}}function L1(e){if(e===null)return null;let t=e.trim();return t.length>0?t:null}var R1=Object.freeze({data:null,error:null,cause:null,isPending:!1}),z1=Object.freeze({...R1,isPending:!0}),J1e=Ht(R1).pipe(Vt,zt(`git-status:null`)),B1=()=>void 0,V1=new Map,Y1e=new Set,H1=new Map,U1=new Map,X1e=1e3,W1=_te(e=>(Y1e.add(e),Ht(z1).pipe(Vt,zt(`git-status:${e}`))));function G1(e){return e.environmentId===null||L1(e.cwd)===null?null:`${e.environmentId}:${e.cwd}`}function K1(e){if(e.environmentId===null)return null;let t=j1(e.environmentId);return t?{clientIdentity:t.environmentId,client:t.client.git}:null}function q1(e){let t=G1(e);return t===null?R1:Bt.get(W1(t))}function Z1e(e,t){let n=G1(e);if(n===null)return B1;let r=V1.get(n);return r?(r.refCount+=1,()=>J1(n)):(V1.set(n,{refCount:1,unsubscribe:e0e(n,e,t)}),()=>J1(n))}function Q1e(e,t){let n=G1(e),r=L1(e.cwd);if(n===null||r===null)return Promise.resolve(null);let i=t??K1(e)?.client;if(!i)return Promise.resolve(q1(e).data);let a=H1.get(n);if(a)return a;let o=U1.get(n)??0;if(Date.now()-o<X1e)return Promise.resolve(q1(e).data);U1.set(n,Date.now());let s=i.refreshStatus({cwd:r}).finally(()=>{H1.delete(n)});return H1.set(n,s),s}function $1e(e){let t=(0,Cl.c)(4),n=G1(e),r,i;t[0]!==e.cwd||t[1]!==e.environmentId?(r=()=>Z1e({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,F.useEffect)(r,i);let a=ar(n===null?J1e:W1(n));return n===null?R1:a}function J1(e){let t=V1.get(e);t&&(--t.refCount,!(t.refCount>0)&&(t.unsubscribe(),V1.delete(e)))}function e0e(e,t,n){let r=L1(t.cwd);if(r===null)return B1;let i=null,a=B1,o=()=>{let o=n?{clientIdentity:`provided:${e}`,client:n}:K1(t);if(!o){i!==null&&(a(),a=B1,i=null),Y1(e);return}i!==o.clientIdentity&&(a(),i=o.clientIdentity,a=t0e(e,r,o.client))},s=n?B1:A1(o);return o(),()=>{s(),a()}}function t0e(e,t,n){return Y1(e),n.onStatus({cwd:t},t=>{Bt.set(W1(e),{data:t,error:null,cause:null,isPending:!1})},{onResubscribe:()=>{Y1(e)}})}function Y1(e){let t=W1(e),n=Bt.get(t),r=n.data===null?z1:{...n,error:null,cause:null,isPending:!0};(n.data!==r.data||n.error!==r.error||n.cause!==r.cause||n.isPending!==r.isPending)&&Bt.set(t,r)}function X1(e,t){return Ht(t).pipe(Vt,zt(e))}function Z1(e){return{issues:e.issues,providers:e.providers,settings:e.settings}}var n0e=[],r0e=[],i0e=[],a0e=e=>e?.availableEditors??n0e,o0e=e=>e?.keybindings??r0e,s0e=e=>e?.keybindingsConfigPath??null,c0e=e=>e?.observability??null,l0e=e=>e?.providers??i0e,u0e=e=>e?.settings??wne,Q1=X1(`server-welcome`,null),$1=X1(`server-config`,null),e0=X1(`server-config-updated`,null),d0e=X1(`server-providers-updated`,null);function t0(){return Bt.get($1)}function f0e(){return Bt.get(e0)}function n0(e){o0(e),s0({providers:e.providers}),c0(Z1(e),`snapshot`)}function p0e(e){switch(e.type){case`snapshot`:n0(e.config);return;case`keybindingsUpdated`:{let t=t0();if(!t)return;let n={...t,issues:e.payload.issues,keybindings:e.payload.keybindings};o0(n),c0(Z1(n),e.type);return}case`providerStatuses`:r0(e.payload);return;case`settingsUpdated`:i0(e.payload.settings);return;case`environmentUpdated`:a0(e.payload.environment);return}}function r0(e){let t=t0();if(s0(e),!t)return;let n={...t,providers:e.providers};o0(n),c0(Z1(n),`providerStatuses`)}function i0(e){let t=t0();if(!t)return;let n={...t,settings:e};o0(n),c0(Z1(n),`settingsUpdated`)}function a0(e){let t=t0();if(Nq()?.environmentId===e.environmentId&&Pq(e),!t)return;let n={...t,environment:e};o0(n),c0(Z1(n),`environmentUpdated`)}function m0e(e){Bt.set(Q1,e)}function h0e(e){let t=!1,n=[e.subscribeLifecycle(e=>{e.type===`welcome`&&m0e(e.payload)}),e.subscribeConfig(e=>{p0e(e)})];return t0()===null&&e.getConfig().then(e=>{t||t0()!==null||n0(e)}).catch(()=>void 0),()=>{t=!0;for(let e of n)e()}}var g0e=1;function o0(e){Bt.set($1,e)}function s0(e){Bt.set(d0e,e)}function c0(e,t){Bt.set(e0,{id:g0e++,payload:e,source:t})}function l0(e,t){let n=(0,F.useRef)(t);n.current=t;let r=(0,F.useCallback)(e=>{e!==null&&n.current(e)},[]);Ene(e,r,{immediate:!0})}function _0e(){return ar($1)}function u0(){return ar($1,u0e)}function v0e(){return ar($1,l0e)}function y0e(){return ar($1,o0e)}function b0e(){return ar($1,a0e)}function x0e(){return ar($1,s0e)}function S0e(){return ar($1,c0e)}function C0e(e){l0(Q1,e)}function w0e(e){l0(e0,e)}function T0e(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 E0e(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 D0e(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 O0e(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 T0e(e)){if(n){i.appendChild(E0e(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=D0e({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 d0;function k0e(){return f0(M1().client)}function f0(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 a0(n.environment),n}}}function A0e(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 j0e(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):O0e(e,t)},persistence:{getClientSettings:QY,setClientSettings:$Y,getSavedEnvironmentRegistry:eX,setSavedEnvironmentRegistry:tX,getSavedEnvironmentSecret:nX,setSavedEnvironmentSecret:rX,removeSavedEnvironmentSecret:iX},server:f0(e)}}function p0(){if(typeof window>`u`)return;if(d0)return d0;let e=j0e(M1().client);return window.nativeApi?(d0=A0e(e,window.nativeApi),d0):(d0=e,d0)}function M0e(){let e=p0();if(!e)throw Error(`Local API not found`);return e}function m0(e,t){if(!Me(e)||!Me(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]=Me(t)&&Me(r)?m0(t,r):r}return n}var h0=`[CLIENT_SETTINGS]`,g0=new Set,_0=Zn,v0=!1,y0=null;function N0e(){for(let e of g0)e()}function b0(){return _0}function x0(e){_0=e,N0e()}function P0e(e){return g0.add(e),F0e(),()=>{g0.delete(e)}}async function F0e(){if(v0)return;if(y0)return y0;let e=(async()=>{try{let e=await QY();e&&x0(e)}catch(e){console.error(`${h0} hydrate failed`,e)}finally{v0=!0}})().finally(()=>{y0===e&&(y0=null)});return y0=e,y0}function I0e(e){x0(e),$Y(e).catch(e=>{console.error(`${h0} persist failed`,e)})}var L0e=new Set(Tne(Jte.fields));function R0e(e){let t={},n={};for(let[r,i]of Object.entries(e))L0e.has(r)?t[r]=i:n[r]=i;return{serverPatch:t,clientPatch:n}}function S0(e){let t=u0(),n=(0,F.useSyncExternalStore)(P0e,b0,()=>Zn),r=(0,F.useMemo)(()=>({...t,...n}),[n,t]);return(0,F.useMemo)(()=>e?e(r):r,[r,e])}function C0(){let e=(0,Cl.c)(2),t=z0e,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{t(Cne)},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 z0e(e){let{serverPatch:t,clientPatch:n}=R0e(e);if(Object.keys(t).length>0){let e=t0();e&&i0(m0(e.settings,t)),M1().client.server.updateSettings(t)}Object.keys(n).length>0&&I0e({...b0(),...n})}function B0e(e,t){let n={hour:`numeric`,minute:`2-digit`,...t?{second:`2-digit`}:{}};return e===`locale`?n:{...n,hour12:e===`12-hour`}}var w0=new Map;function T0(e,t){let n=`${e}:${t?`seconds`:`minutes`}`,r=w0.get(n);if(r)return r;let i=new Intl.DateTimeFormat(void 0,B0e(e,t));return w0.set(n,i),i}function V0e(e,t){return T0(t,!0).format(new Date(e))}function H0e(e,t){return T0(t,!1).format(new Date(e))}function E0(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 U0e(e){let t=E0(e);return t.suffix?`${t.value} ${t.suffix}`:t.value}var W0e=new Set([`tool.started`,`task.started`,`context-window.updated`,`text-generation.usage`]);function G0e(e){return W0e.has(e.kind)||e.summary===`Checkpoint captured`}var K0e=[{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 q0e(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 J0e(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:q0e(r-n)}function D0(e,t){return!e?.startedAt||!e.completedAt?!1:!t||t.orchestrationStatus!==`running`}function Y0e(e,t,n){let r=t?.orchestrationStatus===`running`?t.activeTurnId??null:null;return r===null?D0(e,t)?n:e?.startedAt??n:e?.turnId===r?e.startedAt??n:n}function O0(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 k0(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 X0e(e){let t=new Map,n=[...e].toSorted(q0);for(let e of n){let n=e.payload&&typeof e.payload==`object`?e.payload:null,r=n&&typeof n.requestId==`string`?er.make(n.requestId):null,i=n&&(n.requestKind===`command`||n.requestKind===`file-read`||n.requestKind===`file-change`)?n.requestKind:n?O0(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&&k0(a)){t.delete(r);continue}}return[...t.values()].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}function Z0e(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 Q0e(e){let t=new Map,n=[...e].toSorted(q0);for(let e of n){let n=e.payload&&typeof e.payload==`object`?e.payload:null,r=n&&typeof n.requestId==`string`?er.make(n.requestId):null,i=n&&typeof n.detail==`string`?n.detail:void 0;if(e.kind===`user-input.requested`&&r){let i=Z0e(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&&k0(i)&&t.delete(r)}return[...t.values()].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}function $0e(e,t){if(!t)return null;let n=[...e].toSorted(q0),r=null;for(let e of n){let t=j0(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 e2e(e,t){let n=[...e].toSorted(q0),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=i.payload&&typeof i.payload==`object`?i.payload:null,o=a?.plan;if(!Array.isArray(o))return null;let s=o.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.step!=`string`)return null;let n=t.status===`completed`||t.status===`inProgress`?t.status:`pending`;return{step:t.step,status:n}}).filter(e=>e!==null);if(s.length===0)return null;let c=i.turnId!==null&&n.some(e=>e.kind===`turn.completed`&&e.turnId===i.turnId&&q0(i,e)<0)?s.map(e=>e.status===`inProgress`?{...e,status:`completed`}:e):s;return{createdAt:i.createdAt,turnId:i.turnId,...a&&`explanation`in a?{explanation:a.explanation}:{},steps:c}}function A0(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 R0(n)}let n=[...e].toSorted((e,t)=>e.updatedAt.localeCompare(t.updatedAt)||e.id.localeCompare(t.id)).at(-1);return n?R0(n):null}function t2e(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 R0(n)}}return A0(t,e.latestTurn?.turnId??null)}function n2e(e){return e!==null&&e.implementedAt===null}function r2e(e,t){let n=i2e();return p2e([...e].toSorted(q0).filter(e=>!t||e.turnId===t||a2e(e)).filter(e=>!G0e(e)).filter(e=>n||e.kind!==`runtime.warning`).filter(e=>!o2e(e)).map(s2e)).map(({activityKind:e,collapseKey:t,...n})=>n)}function i2e(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`forge:debug-mode`)===`true`}catch{return!1}}function a2e(e){return e.kind.startsWith(`worktree.`)||e.kind.startsWith(`setup-script.`)}function o2e(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 s2e(e){let t=e.payload&&typeof e.payload==`object`?e.payload:null,n=O2e(t),r=P2e(t),i=k2e(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=M2e(t),d=N2e(t);if(!s&&t&&typeof t.detail==`string`&&t.detail.length>0){let e=W0(t.detail).output;e&&(l.detail=e)}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 f=c2e(t);if(f)l.githubConfirmation=f,l.tone=`approval`,l.label=`GitHub action needs approval`,l.toolTitle=N0(f.operation),l.detail=P0(f);else{let e=j0(t);e&&(l.githubActionRequired=e,l.tone=`approval`,l.label=F0(e.action),l.toolTitle=`GitHub setup required`,l.detail=L0(e))}let p=_2e(l);return p&&(l.collapseKey=p),l}function c2e(e){for(let t of M0(e)){if(t.userActionRequired!==`confirm_github_tool`)continue;let e=z0(t.confirmation),n=z0(e?.request),r=B0(e?.confirmationId),i=B0(e?.toolName),a=B0(e?.operation);if(!(!r||!i||!a||!n))return{confirmationId:r,toolName:i,operation:a,request:n}}return null}function j0(e){let t=M0(e)[0];if(!t)return null;let n=B0(t.userActionRequired);return!n||n===`confirm_github_tool`?null:{action:n,toolName:B0(t.toolName),message:B0(t.error)??B0(t.message)}}function M0(e){if(!e)return[];let t=[],n=new Set,r=(e,i)=>{if(i>8||e==null)return;if(typeof e==`string`){let n=B0(e);if(!n)return;let r=l2e(n);r&&B0(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(B0(a.userActionRequired)){t.push(a);return}for(let e of Object.values(a))r(e,i+1)};return r(e,0),t}function l2e(e){try{return z0(JSON.parse(e))}catch{return null}}function N0(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 P0(e){return[B0(e.request.repoFullName)??(B0(e.request.owner)&&B0(e.request.name)?`${B0(e.request.owner)}/${B0(e.request.name)}`:null),B0(e.request.cwd),B0(e.request.branch),B0(e.request.title)].filter(Boolean).join(` - `)}function F0(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 I0(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 L0(e){return e.action===`connect_cmmd`?I0(e.action):e.message??I0(e.action)}function u2e(e,t){return e.action===t.action&&e.toolName===t.toolName&&e.message===t.message}function d2e(e){switch(e){case`connect_cmmd`:return`Reconnect Forge`;case`connect_github`:return`Connect GitHub`;default:return`Open Git settings`}}function f2e(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(`
|
|
1019
|
-
`)}function p2e(e){let t=[];for(let n of e){let e=t.at(-1);if(e&&m2e(e,n)){t[t.length-1]=h2e(e,n);continue}t.push(n)}return t}function m2e(e,t){return e.activityKind!==`tool.updated`&&e.activityKind!==`tool.completed`||t.activityKind!==`tool.updated`&&t.activityKind!==`tool.completed`||e.activityKind===`tool.completed`?!1:e.collapseKey!==void 0&&e.collapseKey===t.collapseKey}function h2e(e,t){let n=g2e(e.changedFiles,t.changedFiles),r=t.detail??e.detail,i=t.command??e.command,a=t.rawCommand??e.rawCommand,o=t.toolTitle??e.toolTitle,s=t.itemType??e.itemType,c=t.requestKind??e.requestKind,l=t.collapseKey??e.collapseKey;return{...e,...t,...r?{detail:r}:{},...i?{command:i}:{},...a?{rawCommand:a}:{},...n.length>0?{changedFiles:n}:{},...o?{toolTitle:o}:{},...s?{itemType:s}:{},...c?{requestKind:c}:{},...l?{collapseKey:l}:{}}}function g2e(e,t){let n=[...e??[],...t??[]];return n.length===0?[]:[...new Set(n)]}function _2e(e){if(e.activityKind!==`tool.updated`&&e.activityKind!==`tool.completed`)return;let t=v2e(e.toolTitle??e.label),n=e.detail?.trim()??``,r=e.itemType??``;if(t.length!==0||n.length!==0||r.length!==0)return[r,t,n].join(``)}function v2e(e){return e.replace(/\s+(?:complete|completed)\s*$/i,``).trim()}function R0(e){return{id:e.id,createdAt:e.createdAt,updatedAt:e.updatedAt,turnId:e.turnId,planMarkdown:e.planMarkdown,implementedAt:e.implementedAt,implementationThreadId:e.implementationThreadId}}function z0(e){return e&&typeof e==`object`?e:null}function B0(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function V0(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 y2e(e){let t=V0(e);if(t.length===0)return null;let n=t.replace(/\\/g,`/`).split(`/`).at(-1)?.trim()??``;return n.length>0?n.toLowerCase():null}function b2e(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 x2e=[{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 S2e(e){return x2e.find(t=>t.executables.includes(e))}function C2e(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=V0(r);return i.length>0?i:null}function w2e(e){let t=b2e(e);if(!t||t.rest.length===0)return e;let n=y2e(t.executable);if(!n)return e;let r=S2e(n);return r?C2e(t.rest,r.wrapperFlagPattern)??e:e}function T2e(e){return/[\s"'`]/.test(e)?`"${e.replace(/"/g,`\\"`)}"`:e}function H0(e){let t=B0(e);if(t)return t;if(!Array.isArray(e))return null;let n=e.map(e=>B0(e)).filter(e=>e!==null);return n.length===0?null:n.map(e=>T2e(e)).join(` `)}function E2e(e){let t=H0(e);return t?w2e(t):null}function D2e(e,t){let n=H0(e);return!n||t===null||n===t?null:n}function O2e(e){let t=z0(e?.data),n=z0(t?.item),r=z0(n?.result),i=z0(n?.input),a=B0(e?.itemType),o=B0(e?.detail),s=[e?.command,n?.command,i?.command,r?.command,t?.command,a===`command_execution`&&o?W0(o).output:null];for(let e of s){let t=E2e(e);if(t)return{command:t,rawCommand:D2e(e,t)}}return{command:null,rawCommand:null}}function k2e(e){return A2e(e)??B0(e?.title)}function A2e(e){if(!e)return null;let t=z0(e.data),n=z0(t?.item),r=z0(n?.input)??z0(t?.input),i=B0(e.title),a=B0(e.itemType),o=B0(n?.name)??B0(n?.toolName)??B0(t?.name)??B0(e.toolName)??i,s=B0(e.detail),c=[o,i,a,s].filter(Boolean).join(` `).toLowerCase();if(!c.includes(`browser`)&&!c.includes(`forge-browser`))return null;switch(j2e(o,r,s)){case`open-session`:return`Opened browser session`;case`name-session`:return`Named browser session`;case`new-tab`:return U0(r)??`Opened browser tab`;case`navigate`:return U0(r)??`Navigated browser`;case`reload`:return`Reloaded page`;case`back`:return`Went back`;case`forward`:return`Went forward`;case`screenshot`:return`Captured screenshot`;case`snapshot`:return`Read DOM snapshot`;case`logs`:return`Read console logs`;case`click`:return`Clicked page`;case`type`:return`Typed text`;case`scroll`:return`Scrolled page`;case`viewport`:return`Updated viewport`;case`visibility`:return`Updated browser visibility`;default:return null}}function j2e(e,t,n){let r=[B0(t?.type)??B0(t?.command),e,n].filter(Boolean).join(` `).toLowerCase();return/\b(open[-_.\s]?session|create[-_.\s]?session|session[-_.\s]?open)\b/.test(r)?`open-session`:/\b(name[-_.\s]?session|session[-_.\s]?name)\b/.test(r)?`name-session`:/\b(new[-_.\s]?tab|create[-_.\s]?tab|open[-_.\s]?tab)\b/.test(r)?`new-tab`:/\b(navigate|goto|go[-_.\s]?to)\b/.test(r)?`navigate`:/\breload\b/.test(r)?`reload`:/\b(go[-_.\s]?back|back)\b/.test(r)?`back`:/\b(go[-_.\s]?forward|forward)\b/.test(r)?`forward`:/\b(screenshot|capture)\b/.test(r)?`screenshot`:/\b(snapshot|dom[-_.\s]?snapshot|read[-_.\s]?dom)\b/.test(r)?`snapshot`:/\b(console[-_.\s]?logs?|logs?)\b/.test(r)?`logs`:/\bclick\b/.test(r)?`click`:/\btype|fill\b/.test(r)?`type`:/\bscroll\b/.test(r)?`scroll`:/\bviewport\b/.test(r)?`viewport`:/\bvisibility|visible|hidden\b/.test(r)?`visibility`:null}function U0(e){let t=B0(e?.url)??B0(e?.initialUrl);if(!t)return null;try{let e=new URL(t);return e.hostname.length===0?null:`Navigated to ${e.hostname}`}catch{return null}}function W0(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 M2e(e){if(typeof e?.itemType==`string`&&Nte(e.itemType))return e.itemType}function N2e(e){return e?.requestKind===`command`||e?.requestKind===`file-read`||e?.requestKind===`file-change`?e.requestKind:O0(e?.requestType)??void 0}function G0(e,t,n){let r=B0(n);!r||t.has(r)||(t.add(r),e.push(r))}function K0(e,t,n,r){if(r>4||t.length>=12)return;if(Array.isArray(e)){for(let i of e)if(K0(i,t,n,r+1),t.length>=12)return;return}let i=z0(e);if(i){G0(t,n,i.path),G0(t,n,i.filePath),G0(t,n,i.relativePath),G0(t,n,i.filename),G0(t,n,i.newPath),G0(t,n,i.oldPath);for(let e of[`item`,`result`,`input`,`data`,`changes`,`files`,`edits`,`patch`,`patches`,`operations`])if(e in i&&(K0(i[e],t,n,r+1),t.length>=12))return}}function P2e(e){let t=[],n=new Set;return K0(z0(e?.data),t,n,0),t}function q0(e,t){if(e.sequence!==void 0&&t.sequence!==void 0){if(e.sequence!==t.sequence)return e.sequence-t.sequence}else if(e.sequence!==void 0)return 1;else if(t.sequence!==void 0)return-1;let n=e.createdAt.localeCompare(t.createdAt);if(n!==0)return n;let r=J0(e.kind)-J0(t.kind);return r===0?e.id.localeCompare(t.id):r}function J0(e){return e.endsWith(`.started`)||e===`tool.started`?0:e.endsWith(`.progress`)||e.endsWith(`.updated`)?1:e.endsWith(`.completed`)||e.endsWith(`.resolved`)?2:1}function F2e(e,t){return t?e.some(e=>e.turnId===t&&e.tone===`tool`):!1}function I2e(e,t,n){let r=e.map(e=>({id:e.id,kind:`message`,createdAt:e.createdAt,message:e})),i=t.map(e=>({id:e.id,kind:`proposed-plan`,createdAt:e.createdAt,proposedPlan:e})),a=n.map(e=>({id:e.id,kind:`work`,createdAt:e.createdAt,entry:e})),o=e.flatMap(e=>{if(e.role!==`assistant`)return[];let t=L2e(e.text,{workEntries:n,createdAt:e.createdAt});return t?[{id:`${e.id}:github-confirmation:${t.confirmationId}`,kind:`work`,createdAt:e.createdAt,entry:{id:`${e.id}:github-confirmation:${t.confirmationId}`,createdAt:e.createdAt,label:`GitHub action needs approval`,detail:P0(t),tone:`approval`,toolTitle:N0(t.operation),githubConfirmation:t}}]:[]});return[...r,...i,...a,...o].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}function L2e(e,t){if(!e.includes(`confirm_github_tool`))return null;let n=V2e(e,/\b(?:New confirmation id|Confirmation id):\s*`?([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})`?/i)??null,r=/\bRepo(?: to create)?:\s*(private|public|internal)\s+`?([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)`?/i.exec(e);if(!n)return null;let i=R2e(e,n,t);if(i)return i;if(!r)return null;let a=r[1]?.toLowerCase(),o=r[2],s=r[3];return!o||!s?null:{confirmationId:n,toolName:`forge_github_create_repository`,operation:`create_repository`,request:{owner:o,name:s,visibility:a}}}function R2e(e,t,n){if(!z2e(e))return null;let r=B2e(n?.workEntries??[],n?.createdAt,`forge_github_refresh_credentials`)?.request,i=r?B0(r.cwd):null;return i?{confirmationId:t,toolName:`forge_github_refresh_credentials`,operation:`refresh_credentials`,request:{cwd:i}}:null}function z2e(e){return/\bforge_github_refresh_credentials\b/i.test(e)||/\bcredential refresh\b/i.test(e)||/\brefresh(?:ing)? GitHub credentials\b/i.test(e)}function B2e(e,t,n){for(let r of e.toReversed()){if(t!==void 0&&r.createdAt>t)continue;let e=r.githubConfirmation;if(e?.toolName===n)return e}return null}function V2e(e,t){return t.exec(e)?.[1]??null}function H2e(e,t){if(!t?.startedAt||!t.completedAt)return null;if(t.assistantMessageId){let n=e.find(e=>e.kind===`message`&&e.message.role===`assistant`&&e.message.id===t.assistantMessageId);if(n)return n.id}let n=Date.parse(t.startedAt),r=Date.parse(t.completedAt);if(Number.isNaN(n)||Number.isNaN(r))return null;let i=null,a=null;for(let t of e){if(t.kind!==`message`||t.message.role!==`assistant`)continue;let e=Date.parse(t.message.createdAt);Number.isNaN(e)||e<n||(a=t.id,e<=r&&(i=t.id))}return i??a}function U2e(e){let t=[...e].toSorted((e,t)=>e.completedAt.localeCompare(t.completedAt)),n={};for(let e=0;e<t.length;e+=1){let r=t[e];r&&(n[r.turnId]=e+1)}return n}function W2e(e){return!e||e.status===`closed`?`disconnected`:e.status===`connecting`?`connecting`:e.status===`running`?`running`:`ready`}function G2e(e,t){if(t===`disconnected`||t===`connecting`)return null;for(let t of e.toReversed())if(t.kind===`work`&&t.entry.githubConfirmation)return t.entry.githubConfirmation;return null}function Y0(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}:{},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:{searchEntries:e.projects.searchEntries,readFile:e.projects.readFile,writeFile:e.projects.writeFile},codeGraph:{summary:e.codeGraph.summary,neighborhood:e.codeGraph.neighborhood,search:e.codeGraph.search},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 X0(e){if(typeof window>`u`||!e)return;let t=j1(e);return t?Y0(t.client):void 0}function K2e(e){let t=(0,Cl.c)(4),n;t[0]===e?n=t[1]:(n=()=>j1(e),t[0]=e,t[1]=n);let r=(0,F.useSyncExternalStore)(A1,n,q2e),i,a;return t[2]===r?a=t[3]:(a=r?Y0(r.client):void 0,t[2]=r,t[3]=a),i=a,i}function q2e(){return null}function J2e(e){let t=X0(e);if(!t)throw Error(`Environment API not found for environment ${e}`);return t}function Y2e(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Yt(i),[,o]=F.useState(!1),s=Gt(Z2e).current,c=Gt(X2e).current,l=F.useRef(0),u=F.useRef(!0),d=F.useRef([]),f=F.useRef(null),p=Yt(()=>{u.current||(u.current=!0,o(e=>!e))}),m=Yt((e,t)=>{c.set(e,t),p()}),h=Yt(e=>{c.delete(e),p()}),g=Yt(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(!e4e(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&Z0(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=$2e(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=Yt(()=>{let[e,t]=Q2e(c),n=g(e);_(t),d.current=e,u.current=!1,s.forEach(e=>e(n)),a(n)});Jt(()=>(u.current||g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),Jt(()=>{u.current&&v()}),Jt(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=Yt(e=>(s.add(e),()=>{s.delete(e)})),b=F.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,kr.jsx)(wte.Provider,{value:b,children:t})}function X2e(){return new Map}function Z2e(){return new Set}function Q2e(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)=>Z0(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 $2e(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function e4e(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 Z0(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var Q0=[`preview`,`canvas`,`diff`,`plan`,`task`,`simulator`,`display`,`agents`,`file`,`graph`,`pull-request`],$0={isOpen:!1,isMaximized:!1,activeSurfaceId:null,surfaces:[]};function e2(e){return e===null?{id:`browser:new`,kind:`preview`,resourceId:null}:{id:`browser:${e}`,kind:`preview`,resourceId:e}}function t4e(e,t,n){return{id:`file:${e}`,kind:`file`,relativePath:e,revealLine:t,revealRequestId:n}}function t2(e){let t=[e.provider,e.environmentId,e.repositoryLinkId??``,e.projectId,e.host.toLowerCase(),e.repository,String(e.number)].map(e=>encodeURIComponent(e)).join(`:`);return{...e,id:`pull-request:${t}`,kind:`pull-request`}}function n2(e){return e===`diff`?{id:`diff`,kind:`diff`,turnId:null,filePath:null}:{id:e,kind:e}}var n4e=`workspace:pull-requests`;function r2(e){return typeof e==`object`&&!!e}function r4e(e){return typeof e==`string`&&Q0.includes(e)}function i2(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(1,Math.trunc(e)):null}function i4e(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:0}function a4e(e){let t=e.relativePath;return typeof t!=`string`||t.length===0?null:{id:`file:${t}`,kind:`file`,relativePath:t,revealLine:i2(e.revealLine),revealRequestId:i4e(e.revealRequestId)}}function o4e(e){let t=e.resourceId;return t==null?{id:`browser:new`,kind:`preview`,resourceId:null}:typeof t!=`string`||t.length===0?null:{id:`browser:${t}`,kind:`preview`,resourceId:t}}function s4e(e){let t=e.turnId,n=e.filePath,r=typeof t==`string`&&t.length>0?hn.make(t):null;return{id:`diff`,kind:`diff`,turnId:r,filePath:r&&typeof n==`string`&&n.length>0?n:null}}var c4e=new Set([`github`,`gitlab`,`azure-devops`,`bitbucket`,`unknown`]);function a2(e){return typeof e==`string`&&e.length>0}function o2(e){return e===null||typeof e==`string`}function l4e(e){return e===void 0||o2(e)}function u4e(e){let t=e.provider,n=e.environmentId,r=e.repositoryLinkId,i=e.projectId,a=e.host,o=e.repository,s=i2(e.number),c=e.title;return![a2(t)&&c4e.has(t),a2(n),o2(r),a2(i),a2(a),a2(o),s!==null,l4e(c)].every(Boolean)||!a2(t)||!a2(n)?null:t2({provider:t,environmentId:en.make(n),repositoryLinkId:r,projectId:an.make(i),host:a,repository:o,number:s,...typeof c==`string`||c===null?{title:c}:{}})}function d4e(e){if(!r2(e)||!r4e(e.kind))return null;let t=e.kind;return t===`file`?a4e(e):t===`preview`?o4e(e):t===`diff`?s4e(e):t===`pull-request`?u4e(e):{id:t,kind:t}}function f4e(e){let t=[],n=new Set;for(let r of Array.isArray(e)?e:[]){let e=d4e(r);!e||n.has(e.id)||(n.add(e.id),t.push(e))}return t}function p4e(e){if(!r2(e))return null;let t=f4e(e.surfaces);if(t.length===0)return null;let n=e.activeSurfaceId,r=t.some(e=>e.id===n),i=typeof n==`string`&&r?n:t[0]?.id??null;return{isOpen:e.isOpen===!0,activeSurfaceId:i,surfaces:t}}function m4e(e){if(!r2(e)||!r2(e.byThreadKey))return{byThreadKey:{}};let t={};for(let[n,r]of Object.entries(e.byThreadKey)){if(n===n4e)continue;let e=p4e(r);e&&(t[n]=e)}return{byThreadKey:t}}var h4e=`forge:right-panel-state`,g4e=3,_4e=e=>e===`workspace:pull-requests`;function v4e(e){return`draft:${e}`}function y4e(e){return e.startsWith(`draft:`)}function b4e(e){return e==null||!Number.isFinite(e)?null:Math.max(1,Math.trunc(e))}var s2=(e,t,n=!0)=>({...e,isOpen:!0,surfaces:e.surfaces.some(e=>e.id===t.id)?e.surfaces:[...e.surfaces,t],activeSurfaceId:n?t.id:e.activeSurfaceId}),c2=(e,t,n)=>{let r=e[t]??$0,i=n(r);if(!i.isOpen&&i.activeSurfaceId===null&&i.surfaces.length===0){if(!(t in e))return e;let{[t]:n,...r}=e;return r}return i===r?e:{...e,[t]:i}},x4e=Wt()(sJ(e=>({byThreadKey:{},open:(t,n)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>s2(e,e.surfaces.find(e=>e.kind===n)??n2(n)))})),openBrowser:(t,n)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>{let t=n?e.surfaces.filter(e=>e.id!==`browser:new`):e.surfaces;return s2({...e,surfaces:t},e2(n))})})),revealBrowser:t=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>s2(e,e.surfaces.find(e=>e.kind===`preview`)??e2(null)))})),openDiff:(t,n,r)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>{let t={id:`diff`,kind:`diff`,turnId:n??null,filePath:n?r??null:null};return{...e,isOpen:!0,activeSurfaceId:t.id,surfaces:e.surfaces.some(e=>e.id===`diff`)?e.surfaces.map(e=>e.id===`diff`?t:e):[...e.surfaces,t]}})})),openFile:(t,n,r)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>{let t=`file:${n}`,i=e.surfaces.find(e=>e.id===t&&e.kind===`file`),a=t4e(n,b4e(r),(i?.revealRequestId??0)+1);return{...e,isOpen:!0,activeSurfaceId:a.id,surfaces:i?e.surfaces.map(e=>e.id===a.id?a:e):[...e.surfaces,a]}})})),openPullRequest:(t,n)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>s2(e,t2(n)))})),activateSurface:(t,n)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>e.surfaces.some(e=>e.id===n)?{...e,isOpen:!0,activeSurfaceId:n}:e)})),closeSurface:(t,n)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>{let t=e.surfaces.findIndex(e=>e.id===n);if(t<0)return e;let r=e.surfaces.filter(e=>e.id!==n);if(e.activeSurfaceId!==n)return{...e,isOpen:r.length>0&&e.isOpen,surfaces:r};let i=r[Math.min(t,r.length-1)]??null;return{...e,isOpen:r.length>0&&e.isOpen,surfaces:r,activeSurfaceId:i?.id??null}})})),closeOtherSurfaces:(t,n)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>{let t=e.surfaces.find(e=>e.id===n);return!t||e.surfaces.length===1?e:{...e,isOpen:!0,surfaces:[t],activeSurfaceId:t.id}})})),closeSurfacesToRight:(t,n)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>{let t=e.surfaces.findIndex(e=>e.id===n);if(t<0||t===e.surfaces.length-1)return e;let r=e.surfaces.slice(0,t+1),i=r.some(t=>t.id===e.activeSurfaceId);return{...e,surfaces:r,activeSurfaceId:i?e.activeSurfaceId:n}})})),closeAllSurfaces:t=>e(e=>({byThreadKey:c2(e.byThreadKey,t,()=>$0)})),show:t=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>({...e,isOpen:!0}))})),close:t=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>e.isOpen?{...e,isOpen:!1,isMaximized:!1}:e)})),toggleVisibility:t=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>({...e,isOpen:!e.isOpen}))})),toggleMaximized:t=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>e.isOpen?{...e,isMaximized:!(e.isMaximized??!1)}:e)})),removeThread:t=>e(e=>{if(!(t in e.byThreadKey))return e;let{[t]:n,...r}=e.byThreadKey;return{byThreadKey:r}})}),{name:h4e,version:g4e,storage:aJ(()=>_J),partialize:e=>({byThreadKey:Object.fromEntries(Object.entries(e.byThreadKey).filter(([e])=>!y4e(e)&&!_4e(e)))}),migrate:e=>m4e(e)}));function S4e(e){return t=>e?dZ(t,e.environmentId).projectById[e.projectId]:void 0}function l2(e){let t,n,r;return i=>{let a=e(i);if(!a)return;let o=dZ(i,a.environmentId);return r&&t===o&&n===a.threadId?r:(t=o,n=a.threadId,r=kX(o,a.threadId),r)}}function C4e(e){return l2(()=>e)}function w4e(e){return t=>{if(e)return dZ(t,e.environmentId).threadSubscriptionErrorById[e.threadId]}}function T4e(e){let t,n,r,i;return a=>{if(!e){i=void 0,t=void 0,n=void 0,r=void 0;return}let o=dZ(a,e.environmentId).threadShellById,s=o[e.threadId];if(!s){i=void 0,t=void 0,n=void 0,r=void 0;return}let c=s.kind===`master`?s.id:s.parentThreadId,l=c==null?void 0:o[c];if(i&&t===o&&n===s&&r===l)return i;let u=[];if(c!=null){for(let e of Object.values(o))e.kind===`worker`&&e.parentThreadId===c&&u.push(e);u.sort((e,t)=>e.createdAt.localeCompare(t.createdAt))}return t=o,n=s,r=l,i={you:s,master:l,workers:u},i}}function E4e(e){return l2(t=>{if(!e)return;let n,r,i;for(let[a,o]of Object.entries(t.environmentStateById))if(o.threadShellById[e]){let s={environmentId:a,threadId:e};if(n??=s,t.activeEnvironmentId===a&&(r=s),o.bootstrapComplete&&(i=s,t.activeEnvironmentId===a))break}return i??r??n})}var u2=`forge:last-editor`;function d2(e){let t=new Set(e),n=Kq(u2,Rn);if(n&&t.has(n))return n;let r=Vte.find(e=>t.has(e.id))?.id??null;return r&&qq(u2,r,Rn),r??null}async function D4e(e,t){let{availableEditors:n}=await e.server.getConfig(),r=d2(n);if(!r)throw Error(`No available editors found.`);return await e.shell.openInEditor(t,r),r}var O4e=/https?:\/\/[^\s"'`<>]+/g,k4e=/(?:~\/|\.{1,2}\/|\/|[A-Za-z]:[\\/]|\\\\)[^\s"'`<>]+|[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+(?::\d+){0,2}/g,A4e=/[.,;!?]+$/;function j4e(e){let t=e.replace(A4e,``);if(t.length===0)return t;let n=(e,n)=>{for(;t.endsWith(n);){if(t.split(e).length-1>=t.split(n).length-1)return;t=t.slice(0,-1)}};return n(`(`,`)`),n(`[`,`]`),n(`{`,`}`),t}function M4e(e,t){return e.start<t.end&&t.start<e.end}function f2(e,t,n,r){let i=[];n.lastIndex=0;for(let a of e.matchAll(n)){let e=a[0],n=a.index??-1;if(n<0||e.length===0)continue;let o=j4e(e);if(o.length===0||t===`path`&&/^https?:\/\//i.test(o))continue;let s={kind:t,text:o,start:n,end:n+o.length};[...r,...i].some(e=>M4e(s,e))||i.push(s)}return i}function p2(e){return/^[A-Za-z]:[\\/]/.test(e)||e.startsWith(`\\\\`)}function N4e(e){return e.startsWith(`/`)||p2(e)}function m2(e){return p2(e)||/[A-Za-z]:\\/.test(e)}function h2(e,t,n){let r=e.replace(/[\\/]+$/,``);return n===`\\`?`${r}\\${t.replaceAll(`/`,`\\`)}`:`${r}/${t.replace(/^\/+/,``)}`}function P4e(e){let t=e.match(/^\/Users\/([^/]+)/);if(t?.[1])return`/Users/${t[1]}`;let n=e.match(/^\/home\/([^/]+)/);if(n?.[1])return`/home/${n[1]}`;let r=e.match(/^([A-Za-z]:\\Users\\[^\\]+)/);if(r?.[1])return r[1]}function g2(e){let t=e,n,r,i=t.match(/:(\d+)$/);if(!i?.[1])return{path:t,line:void 0,column:void 0};n=i[1],t=t.slice(0,-i[0].length);let a=t.match(/:(\d+)$/);return a?.[1]?(r=a[1],t=t.slice(0,-a[0].length)):(r=n,n=void 0),{path:t,line:r,column:n}}function F4e(e){let t=f2(e,`url`,O4e,[]),n=f2(e,`path`,k4e,t);return[...t,...n].toSorted((e,t)=>e.start-t.start)}function I4e(e,t){let n=t(e-1);if(!n)return null;let r=e,i=n;for(;r>1&&i.isWrapped;){let e=t(r-2);if(!e)return null;--r,i=e}let a=[],o=0,s=r;for(;;){let e=t(s-1);if(!e)break;let n=t(s)?.isWrapped===!0,r=e.translateToString(!n);if(a.push({bufferLineNumber:s,text:r,startIndex:o,endIndex:o+r.length}),o+=r.length,!n)break;s+=1}return{text:a.map(e=>e.text).join(``),segments:a}}function _2(e,t){for(let n of e)if(t<n.endIndex)return{x:t-n.startIndex+1,y:n.bufferLineNumber};let n=e[e.length-1];return{x:Math.max(n?.text.length??0,1),y:n?.bufferLineNumber??1}}function L4e(e,t){return{start:_2(e.segments,t.start),end:_2(e.segments,t.end-1)}}function R4e(e,t){return e.start.y<=t&&t<=e.end.y}function z4e(e,t=typeof navigator>`u`?``:navigator.platform){return t.length===0?!1:xte(t)?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function B4e(e,t){let{path:n,line:r,column:i}=g2(e),a=n;if(n.startsWith(`~/`)){let e=P4e(t);if(e){let t=m2(e)?`\\`:`/`;a=h2(e,n.slice(2),t)}}else N4e(n)||(a=h2(t,n,m2(t)?`\\`:`/`));return r?`${a}:${r}${i?`:${i}`:``}`:a}var v2=`diffs-container`,V4e=(()=>{try{return!1}catch{return!1}})(),H4e=/(?=^From [a-f0-9]+ .+$)/m,U4e=/(?=^diff --git)/gm,W4e=/(?<=\n)/,G4e=/^(---|\+\+\+)\s+([^\t\r\n]+)/,K4e=/^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/,q4e=/^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/,J4e=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,y2=`header-prefix`,b2=`header-filename-suffix`,x2=`header-metadata`,S2=`header-custom`,C2={dark:`pierre-dark`,light:`pierre-light`},Y4e=`data-theme-css`,X4e=`data-unsafe-css`,Z4e=`data-diffs-scrollbar-measure`,Q4e=`data-diffs-code-view-header`,$4e=`data-diffs-code-view-footer`,w2=`--diffs-scrollbar-gutter-measured`,e3e=1e5,T2={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8},t3e={...T2,hunkLineCount:1},n3e={paddingTop:8,paddingBottom:8,gap:8},r3e={omega:.015,positionEpsilon:.5,velocityEpsilon:.05},i3e=Object.freeze({fromStart:0,fromEnd:0}),a3e={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},o3e={startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:0},E2=new Set,D2=null;function O2(e){E2.add(e),D2??=requestAnimationFrame(A2)}function k2(e){E2.delete(e)&&E2.size===0&&D2!=null&&(cancelAnimationFrame(D2),D2=null)}function A2(e){let t=new Set(E2);E2.clear();for(let n of t)try{n(e)}catch(e){console.error(e)}D2=E2.size>0?requestAnimationFrame(A2):null}function j2(e,t,n){if(e===t||e==null||t==null)return e===t;let r=new Set(n),i=Object.keys(e),a=new Set(Object.keys(t));for(let n of i)if(a.delete(n),!r.has(n)&&(!(n in t)||e[n]!==t[n]))return!1;for(let e of Array.from(a))if(!r.has(e))return!1;return!0}function M2(e,t){return e==null||t==null||typeof e==`string`||typeof t==`string`?e===t:e.dark===t.dark&&e.light===t.light}function s3e(e,t){let n=e?.theme??C2,r=t?.theme??C2,i=N2(e),a=N2(t);return M2(n,r)&&j2(e,t,[`theme`,`parseDiffOptions`])&&j2(i,a)}function N2(e){if(e!=null&&`parseDiffOptions`in e)return e.parseDiffOptions}function P2(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}function c3e({scrollTop:e,scrollHeight:t,height:n,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:a}){let o=n+a*2,s=r?n+i*2:o;if(t=Math.max(t,s),o>=t||r){let n=Math.max(e-i,0),r=Math.min(e+s,t);return{top:n,bottom:Math.max(r,n)}}let c=e+n/2-o/2,l=c+o;return c<0&&(c=0),l>t&&(l=t),c=Math.floor(Math.max(c,0)),{top:c,bottom:Math.ceil(Math.max(Math.min(l,t),c))}}function F2(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}function I2(e,t){return e-(t===0?0:1)}function L2(e,t){return I2(e,t)+t}var R2=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},l3e=new class extends R2{};function u3e(e,t,n){return l3e.diff(e,t,n)}function z2(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function B2(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function V2(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function H2(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function U2(e,t){return V2(e,t,``)}function W2(e,t){return H2(e,t,``)}function G2(e,t){return t.slice(0,d3e(e,t))}function d3e(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function K2(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function q2(e,t){if(t)return Y2(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function J2(e,t){if(t)return Y2(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function Y2(e,t){if(!t)return[J2(e),q2(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=K2(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var X2=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,f3e=RegExp(`[${X2}]+|\\s+|[^${X2}]`,`ug`);new class extends R2{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=K2(e,r)}else n=e.match(f3e)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&Z2(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&Z2(n,i,r,null,t.intlSegmenter),e}};function Z2(e,t,n,r,i){if(t&&n){let[a,o]=Y2(t.value,i),[s,c]=Y2(n.value,i);if(e){let r=z2(a,s);e.value=H2(e.value,s,r),t.value=U2(t.value,r),n.value=U2(n.value,r)}if(r){let e=B2(o,c);r.value=V2(r.value,c,e),t.value=W2(t.value,e),n.value=W2(n.value,e)}}else if(n){if(e){let e=J2(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=J2(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=J2(r.value,i),[a,o]=Y2(t.value,i),s=z2(n,a);t.value=U2(t.value,s);let c=B2(U2(n,s),o);t.value=W2(t.value,c),r.value=V2(r.value,n,c),e.value=H2(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=J2(r.value,i),n=G2(q2(t.value,i),e);t.value=W2(t.value,n)}else if(e){let n=G2(q2(e.value,i),J2(t.value,i));t.value=U2(t.value,n)}}var p3e=new class extends R2{tokenize(e){let t=RegExp(`(\\r?\\n)|[${X2}]+|[^\\S\\n\\r]+|[^${X2}]`,`ug`);return e.match(t)||[]}};function m3e(e,t,n){return p3e.diff(e,t,n)}var h3e=new class extends R2{constructor(){super(...arguments),this.tokenize=$2}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
1018
|
+
`)}}}var SXe=(e=`/api/workspace/readiness`)=>{if(typeof fetch>`u`)return{close:()=>{}};let t=typeof e==`string`?{url:e}:e,n=!1,r=new AbortController;return fetch(t.url,{credentials:t.bearerToken?`omit`:`include`,signal:r.signal,...t.bearerToken?{headers:{Authorization:`Bearer ${t.bearerToken}`}}:{}}).then(e=>{if(e.ok)return xXe(e,t.environmentId,r.signal)}).catch(()=>{}),{close:()=>{n||(n=!0,r.abort())}}},CXe=6e4;function wXe(e){let t=new URL(e.target.httpBaseUrl);return t.pathname=`${t.pathname.endsWith(`/`)?t.pathname.slice(0,-1):t.pathname}/api/workspace/readiness`,t.search=``,t.hash=``,t.toString()}function TXe(e){let t=new Set,n=null,r=!1,i=!1;return{hasWaiters:()=>t.size>0,wait:()=>{if(r)return Promise.reject(n);if(i)return Promise.resolve();let a=null,o=null,s=new Promise((e,n)=>{o={resolve:e,reject:n},t.add(o)}),c=new Promise((t,n)=>{a=globalThis.setTimeout(()=>{n(Error(`Timed out while waiting for ${e.label} (${e.environmentId}) to stream its shell snapshot.`))},e.timeoutMs)});return Promise.race([s,c]).finally(()=>{a!==null&&globalThis.clearTimeout(a),o!==null&&t.delete(o)})},resolve:()=>{r=!1,n=null,i=!0;let e=[...t];t.clear();for(let t of e)t.resolve()},reject:e=>{r=!0,n=e,i=!1;let a=[...t];t.clear();for(let t of a)t.reject(e)},reset:()=>{r=!1,n=null,i=!1}}}function DZ(e){let t=e.knownEnvironment.environmentId;if(!t)throw Error(`Known environment ${e.knownEnvironment.label} is missing its environmentId.`);let n=!1,r=!1,i=null,a=null,o=TXe({environmentId:t,label:e.knownEnvironment.label,timeoutMs:e.bootstrapTimeoutMs??CXe}),s=e.readiness?(e.readiness.openStream??SXe)({url:wXe(e.knownEnvironment),environmentId:t,...e.readiness.bearerToken?{bearerToken:e.readiness.bearerToken}:{}}):null,c=t=>{if(!r){r=!0;let n=Error(t);_(),e.client.dispose(),e.onIdentityMismatch?.(n)}return!1},l=(n,r)=>{if(e.tolerateReportedEnvironmentIdentity)return a===null?(a=n,!0):a===n||c(`Environment connection ${t} reported a changed runtime identity (${a} -> ${n}) via ${r}.`);let i=e.resolveEnvironmentId?.()??t;return i===n||c(`Environment connection ${i} changed identity to ${n} via ${r}.`)},u=()=>e.resolveEnvironmentId?.()??t,d=e.client.server.subscribeLifecycle(t=>{t.type===`welcome`&&l(t.payload.environment.environmentId,`server lifecycle welcome`)&&e.onWelcome?.(t.payload,u())}),f=e.client.server.subscribeConfig(t=>{if(t.type===`snapshot`){if(!l(t.config.environment.environmentId,`server config snapshot`))return;i=t.config,e.onConfigSnapshot?.(t.config);return}if(t.type!==`providerStatuses`||!i)return;let n={...i,providers:t.payload.providers};i=n,e.onConfigSnapshot?.(n)}),p=e.client.orchestration.subscribeShell(t=>{if(t.kind===`snapshot`){e.syncShellSnapshot(t.snapshot,u()),o.resolve();return}e.applyShellEvent(t,u())},{onResubscribe:()=>{n||o.reset()},onError:t=>{if(!n){if(o.hasWaiters()){o.reject(t);return}e.onShellSubscriptionError?.(t,u())}}}),m=e.client.terminal.onEvent(t=>{e.applyTerminalEvent(t,u())}),h=e.client.browser?.onEvent({},t=>{e.applyBrowserEvent(t,u())}),g=e.client.server.subscribeWorkspaceReadiness(e=>{n||N(async()=>{let{setWorkspaceReadinessPhaseForEnvironment:e}=await import(`./workspaceReadinessAtom-DZAbFDrM.js`).then(e=>e.r);return{setWorkspaceReadinessPhaseForEnvironment:e}},__vite__mapDeps([2,1,3,4])).then(({setWorkspaceReadinessPhaseForEnvironment:t})=>{n||t(u(),e)})}),_=()=>{n||(n=!0,e.onDispose?.(),s?.close(),p(),m(),h?.(),d(),f(),g())};return{kind:e.kind,environmentId:t,knownEnvironment:e.knownEnvironment,client:e.client,ensureBootstrapped:()=>o.wait(),reconnect:async()=>{o.reset();try{await e.client.reconnect(),await e.refreshMetadata?.(),await o.wait()}catch(e){throw o.reject(e),e}},...e.ensureProviderAuthority?{ensureProviderAuthority:e.ensureProviderAuthority}:{},dispose:async()=>{_(),await e.client.dispose()}}}function EXe(e){return!e.isWorking||e.msSinceLastEvent<e.stallThresholdMs?`none`:e.recoveryAttempts<e.maxResubscribeAttempts?`resubscribe`:e.recoveryAttempts<e.maxTotalAttempts?`reconnect`:`none`}var DXe=3e4,OXe=1e4,kXe=/^(localhost|[a-z0-9.-]+\.localhost|127(?:\.\d{1,3}){3}|\[[0:]+1\]|::1)(?::\d+)?(?:[/?#]|$)/i,OZ=/https?:\/\/[^\s"'`<>]+/gu,AXe=new RegExp(String.raw`\u001B(?:\][\s\S]*?(?:\u0007|\u001B\\)|[@-_][0-?]*[ -/]*[@-~])`,`gu`),jXe=/(https?:\/\/(?:localhost|[a-z0-9.-]+\.localhost|127(?:\.\d{1,3}){3}|\[[0:]+1\]|::1|10(?:\.\d{1,3}){3}|172\.(?:1[6-9]|2\d|3[01])(?:\.\d{1,3}){2}|192\.168(?:\.\d{1,3}){2}):)\s+(\d{1,5})(?=[/?#\s]|$)/giu;function kZ(e){let t=e.trim();if(!t||/^[a-z][a-z0-9+.-]*:\/\//i.test(t)&&!/^https?:\/\//i.test(t))return null;let n=t.split(/[/:?#]/,1)[0]??``,r=kXe.test(t)||jZ(n)?`http`:`https`,i=/^https?:\/\//i.test(t)?t:`${r}://${t}`;try{let e=new URL(i);return e.protocol!==`http:`&&e.protocol!==`https:`?null:e.toString()}catch{return null}}function MXe(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function AZ(e){try{let t=new URL(e);return Dne(t.hostname)}catch{return!1}}function jZ(e){return One(e)}function MZ(e){try{let t=new URL(e);if(t.protocol!==`http:`||!AZ(t.toString())&&!jZ(t.hostname)||!t.port)return null;let n=Number(t.port);return Number.isInteger(n)&&n>0&&n<=65535?n:null}catch{return null}}function NXe(e){let t=e.replace(/[.,;!?]+$/u,``);for(;t.endsWith(`)`)||t.endsWith(`]`)||t.endsWith(`}`);){let e=t.at(-1);if(!e)break;let n=e===`)`?`(`:e===`]`?`[`:`{`;if(t.split(n).length-1>=t.split(e).length-1)break;t=t.slice(0,-1)}return t}function PXe(e){return e.replace(AXe,``).replaceAll(/./gsu,e=>FXe(e)?``:e).replace(jXe,`$1$2`)}function FXe(e){let t=e.charCodeAt(0);return t>=0&&t<=8||t===11||t===12||t>=14&&t<=31||t===127}function NZ(e){let t=null,n=null,r=PXe(e);OZ.lastIndex=0;for(let e of r.matchAll(OZ)){let r=kZ(NXe(e[0]));!r||!MZ(r)||(t=r,AZ(r)&&(n=r))}return n??t}function IXe(e){let t=null;for(let n of e){let e=n.event,r=NZ(e.type===`output`?e.data:e.type===`started`||e.type===`restarted`?e.snapshot.history:``);r&&(t=r)}return t}function LXe(e){switch(e.type){case`activity`:return e.hasRunningSubprocess;case`started`:case`restarted`:case`exited`:return!1;default:return null}}var RXe=`forge:terminal-state:v1`,PZ=[],zXe=200,FZ=8;function BXe(e,t){if(t<=3&&e&&typeof e==`object`){let t=e;return{terminalStateByThreadKey:GZ(t.terminalStateByThreadKey??{}),terminalPreviewUrlByThreadKey:Object.fromEntries(Object.entries(t.terminalPreviewUrlByThreadKey??{}).filter(([e,t])=>!!Wo(e)&&typeof t?.url==`string`&&!!MZ(t.url)&&typeof t?.observedAt==`string`))}}return{terminalStateByThreadKey:{},terminalPreviewUrlByThreadKey:{}}}function VXe(){return mJ(typeof window<`u`?window.localStorage:void 0)}function HXe(e){let t=[...new Set(e.map(e=>e.trim()).filter(e=>e.length>0))];return t.length>0?t:[Qq]}function UXe(e,t){if(e.length===0)return[];let n=new Set(t);return[...new Set(e)].map(e=>e.trim()).filter(e=>e.length>0&&n.has(e))}function IZ(e){return`group-${e}`}function LZ(e,t){let n=e,r=2;for(;t.has(n);)n=`${e}-${r}`,r+=1;return t.add(n),n}function RZ(e,t){return e.findIndex(e=>e.terminalIds.includes(t))}function WXe(e){return[...new Set(e.map(e=>e.trim()).filter(e=>e.length>0))]}function GXe(e,t){let n=new Set(t),r=new Set,i=[],a=new Set;for(let t of e){let e=WXe(t.terminalIds).filter(e=>!(!n.has(e)||r.has(e)));if(e.length===0)continue;for(let t of e)r.add(t);let o=t.id.trim().length>0?t.id.trim():IZ(e[0]??`default`);i.push({id:LZ(o,a),terminalIds:e})}for(let e of t)r.has(e)||i.push({id:LZ(IZ(e),a),terminalIds:[e]});return i.length===0?[{id:IZ(Qq),terminalIds:[Qq]}]:i}function zZ(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function KXe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.id!==i.id||!zZ(r.terminalIds,i.terminalIds))return!1}return!0}function BZ(e,t){return e.terminalOpen===t.terminalOpen&&e.terminalHeight===t.terminalHeight&&e.activeTerminalId===t.activeTerminalId&&e.activeTerminalGroupId===t.activeTerminalGroupId&&zZ(e.terminalIds,t.terminalIds)&&zZ(e.runningTerminalIds,t.runningTerminalIds)&&KXe(e.terminalGroups,t.terminalGroups)}var VZ=Object.freeze({terminalOpen:!1,terminalHeight:280,terminalIds:[Qq],runningTerminalIds:[],activeTerminalId:Qq,terminalGroups:[{id:IZ(Qq),terminalIds:[Qq]}],activeTerminalGroupId:IZ(Qq)});function HZ(){return{...VZ,terminalIds:[...VZ.terminalIds],runningTerminalIds:[...VZ.runningTerminalIds],terminalGroups:$Z(VZ.terminalGroups)}}function UZ(){return VZ}function WZ(e){let t=HXe(e.terminalIds),n=t.length>0?t:[Qq],r=UXe(e.runningTerminalIds,n),i=n.includes(e.activeTerminalId)?e.activeTerminalId:n[0]??`default`,a=GXe(e.terminalGroups,n),o=a.some(t=>t.id===e.activeTerminalGroupId)?e.activeTerminalGroupId:null,s=a.find(e=>e.terminalIds.includes(i))?.id??null,c={terminalOpen:e.terminalOpen,terminalHeight:Number.isFinite(e.terminalHeight)&&e.terminalHeight>0?e.terminalHeight:280,terminalIds:n,runningTerminalIds:r,activeTerminalId:i,terminalGroups:a,activeTerminalGroupId:o??s??a[0]?.id??IZ(`default`)};return BZ(e,c)?e:c}function qXe(e){let t=WZ(e);if(t.terminalIds.length<=FZ)return t;let n=new Set,r=e=>{!e||n.size>=FZ||t.terminalIds.includes(e)&&n.add(e)};r(Qq),r(t.activeTerminalId);for(let e of t.runningTerminalIds)r(e);for(let e of t.terminalIds.toReversed())r(e);let i=t.terminalIds.filter(e=>n.has(e)),a=i[i.length-1]??i[0]??`default`,o=i.includes(t.activeTerminalId)?t.activeTerminalId:a;return WZ({...t,terminalIds:i.length>0?i:[Qq],runningTerminalIds:t.runningTerminalIds.filter(e=>n.has(e)),activeTerminalId:o,terminalGroups:t.terminalGroups.map(e=>({id:e.id,terminalIds:e.terminalIds.filter(e=>n.has(e))})).filter(e=>e.terminalIds.length>0)})}function GZ(e){return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>Wo(e)?[[e,qXe(t)]]:[]))}function JXe(e){return BZ(WZ(e),VZ)}function YXe(e){return e.trim().length>0}function KZ(e){return Vo(e)}function qZ(e,t){return`${KZ(e)}\u0000${t}`}function JZ(e,t){return qZ(e,t)}function YZ(e){let t=Date.parse(e);return Number.isFinite(t)?t:0}function XZ(e,t){let n=NZ(e);return n?{url:n,observedAt:t}:null}function XXe(e){return XZ(e.history,e.updatedAt)}function ZZ(e){return e.type===`output`?XZ(e.data,e.createdAt):e.type===`started`||e.type===`restarted`?XZ(e.snapshot.history,e.snapshot.updatedAt):null}function QZ(e,t,n){if(!n)return e;let r=KZ(t),i=e[r];return i&&YZ(i.observedAt)>YZ(n.observedAt)||i?.url===n.url&&i.observedAt===n.observedAt?e:{...e,[r]:n}}function $Z(e){return e.map(e=>({id:e.id,terminalIds:[...e.terminalIds]}))}function eQ(e,t,n,r){let i=qZ(n,r.terminalId),a=e[i]??PZ,o={id:t,event:r},s=a.length>=zXe?[...a.slice(1),o]:[...a,o];return{terminalEventEntriesByKey:{...e,[i]:s},nextTerminalEventId:t+1}}function tQ(e,t,n,r){let i=qZ(n,r.terminalId);return{terminalEventEntriesByKey:{...e,[i]:[{id:t,event:r}]},nextTerminalEventId:t+1}}function nQ(e){return e.sessionEpoch&&e.sequence!==void 0?{sessionEpoch:e.sessionEpoch,sequence:e.sequence}:null}function rQ(e,t,n){return!t||!e?!1:t.sessionEpoch===e.sessionEpoch?n?t.sequence<e.sequence:t.sequence<=e.sequence:!n}function iQ(e,t){let n={...e},r=!1;for(let e of Object.keys(n))e.startsWith(`${t}\u0000`)&&(delete n[e],r=!0);return r?n:e}function ZXe(e){return{terminalId:e.terminalId,cwd:e.snapshot.cwd,worktreePath:e.snapshot.worktreePath}}function QXe(e,t){let n=ZXe(t);return e?.runtimeEnv&&e.cwd===n.cwd&&e.worktreePath===n.worktreePath&&(e.terminalId===void 0||e.terminalId===t.terminalId)?{...n,runtimeEnv:e.runtimeEnv}:n}function aQ(e,t,n){let r=WZ(e);if(!YXe(t))return r;let i=!r.terminalIds.includes(t),a=i?[...r.terminalIds,t]:r.terminalIds,o=$Z(r.terminalGroups),s=RZ(o,t);if(s>=0&&(o[s].terminalIds=o[s].terminalIds.filter(e=>e!==t),o[s].terminalIds.length===0&&o.splice(s,1)),n===`new`){let e=new Set(o.map(e=>e.id)),n=LZ(IZ(t),e);return o.push({id:n,terminalIds:[t]}),WZ({...r,terminalOpen:!0,terminalIds:a,activeTerminalId:t,terminalGroups:o,activeTerminalGroupId:n})}let c=o.findIndex(e=>e.id===r.activeTerminalGroupId);if(c<0&&(c=RZ(o,r.activeTerminalId)),c<0){let e=new Set(o.map(e=>e.id)),t=LZ(IZ(r.activeTerminalId),e);o.push({id:t,terminalIds:[r.activeTerminalId]}),c=o.length-1}let l=o[c];if(!l||i&&!l.terminalIds.includes(t)&&l.terminalIds.length>=4)return r;if(!l.terminalIds.includes(t)){let e=l.terminalIds.indexOf(r.activeTerminalId);e>=0?l.terminalIds.splice(e+1,0,t):l.terminalIds.push(t)}return WZ({...r,terminalOpen:!0,terminalIds:a,activeTerminalId:t,terminalGroups:o,activeTerminalGroupId:l.id})}function oQ(e,t){let n=WZ(e);return n.terminalOpen===t?n:{...n,terminalOpen:t}}function $Xe(e,t){let n=WZ(e);return!Number.isFinite(t)||t<=0||n.terminalHeight===t?n:{...n,terminalHeight:t}}function eZe(e,t){return aQ(e,t,`split`)}function sQ(e,t,n){let r=aQ(e,t,`new`);return n?.openDrawer===!1?{...r,terminalOpen:e.terminalOpen}:r}function cQ(e,t){let n=WZ(e);if(!n.terminalIds.includes(t))return n;let r=n.terminalGroups.find(e=>e.terminalIds.includes(t))?.id??n.activeTerminalGroupId;return n.activeTerminalId===t&&n.activeTerminalGroupId===r?n:{...n,activeTerminalId:t,activeTerminalGroupId:r}}function tZe(e,t){let n=WZ(e);if(!n.terminalIds.includes(t))return n;let r=n.terminalIds.filter(e=>e!==t);if(r.length===0)return HZ();let i=n.terminalIds.indexOf(t),a=n.activeTerminalId===t?r[Math.min(i,r.length-1)]??r[0]??`default`:n.activeTerminalId,o=n.terminalGroups.map(e=>({...e,terminalIds:e.terminalIds.filter(e=>e!==t)})).filter(e=>e.terminalIds.length>0),s=o.find(e=>e.terminalIds.includes(a))?.id??o[0]?.id??IZ(a);return WZ({terminalOpen:n.terminalOpen,terminalHeight:n.terminalHeight,terminalIds:r,runningTerminalIds:n.runningTerminalIds.filter(e=>e!==t),activeTerminalId:a,terminalGroups:o,activeTerminalGroupId:s})}function lQ(e,t,n){let r=WZ(e);if(!r.terminalIds.includes(t)||n===r.runningTerminalIds.includes(t))return r;let i=new Set(r.runningTerminalIds);return n?i.add(t):i.delete(t),{...r,runningTerminalIds:[...i]}}function uQ(e,t){return!t||t.threadId.length===0?UZ():e[KZ(t)]??UZ()}function dQ(e,t,n){if(t.threadId.length===0)return e;let r=KZ(t),i=uQ(e,t),a=n(i);if(a===i)return e;if(JXe(a)){if(e[r]===void 0)return e;let{[r]:t,...n}=e;return n}return{...e,[r]:a}}function nZe(e,t,n){return!t||t.threadId.length===0||n.trim().length===0?PZ:e[qZ(t,n)]??PZ}function rZe(e,t,n){return!t||t.threadId.length===0||n.trim().length===0?null:e[JZ(t,n)]??null}function iZe(e,t){if(!t||t.threadId.length===0)return[];let n=`${KZ(t)}\u0000`;return Object.entries(e).filter(([e])=>e.startsWith(n)).map(([,e])=>e)}function aZe(e,t){return!t||t.threadId.length===0?null:e[KZ(t)]??null}var fQ=Wt()(sJ(e=>{let t=(t,n)=>{e(e=>{let r=dQ(e.terminalStateByThreadKey,t,n);return r===e.terminalStateByThreadKey?e:{terminalStateByThreadKey:r}})};return{terminalStateByThreadKey:{},terminalLaunchContextByThreadKey:{},terminalEventEntriesByKey:{},terminalSessionSnapshotByKey:{},terminalStreamCursorByKey:{},terminalPreviewUrlByThreadKey:{},nextTerminalEventId:1,setTerminalOpen:(e,n)=>t(e,e=>oQ(e,n)),setTerminalHeight:(e,n)=>t(e,e=>$Xe(e,n)),splitTerminal:(e,n)=>t(e,e=>eZe(e,n)),newTerminal:(e,n,r)=>t(e,e=>sQ(e,n,r)),ensureTerminal:(e,n,r)=>t(e,e=>{let t=e;return e.terminalIds.includes(n)||(t=sQ(t,n)),r?.active===!1&&(t={...t,activeTerminalId:e.activeTerminalId,activeTerminalGroupId:e.activeTerminalGroupId}),(r?.active??!0)&&(t=cQ(t,n)),r?.open&&(t=oQ(t,!0)),WZ(t)}),setActiveTerminal:(e,n)=>t(e,e=>cQ(e,n)),closeTerminal:(e,n)=>t(e,e=>tZe(e,n)),setTerminalLaunchContext:(t,n)=>e(e=>({terminalLaunchContextByThreadKey:{...e.terminalLaunchContextByThreadKey,[KZ(t)]:n}})),clearTerminalLaunchContext:t=>e(e=>{let n=KZ(t);if(!e.terminalLaunchContextByThreadKey[n])return e;let{[n]:r,...i}=e.terminalLaunchContextByThreadKey;return{terminalLaunchContextByThreadKey:i}}),setTerminalActivity:(e,n,r)=>t(e,e=>lQ(e,n,r)),recordTerminalEvent:(t,n)=>e(e=>{let r=JZ(t,n.terminalId),i=nQ(n),a=n.type===`started`||n.type===`restarted`;if(rQ(e.terminalStreamCursorByKey[r],i,a))return e;let o=a&&i?tQ(e.terminalEventEntriesByKey,e.nextTerminalEventId,t,n):eQ(e.terminalEventEntriesByKey,e.nextTerminalEventId,t,n),s=i?{...e.terminalStreamCursorByKey,[r]:i}:e.terminalStreamCursorByKey,c=QZ(e.terminalPreviewUrlByThreadKey,t,ZZ(n));return n.type!==`started`&&n.type!==`restarted`?{...o,terminalStreamCursorByKey:s,terminalPreviewUrlByThreadKey:c}:{...o,terminalStreamCursorByKey:s,terminalPreviewUrlByThreadKey:c,terminalSessionSnapshotByKey:{...e.terminalSessionSnapshotByKey,[JZ(t,n.terminalId)]:n.snapshot}}}),applyTerminalEvent:(t,n)=>e(e=>{let r=KZ(t),i=JZ(t,n.terminalId),a=nQ(n),o=n.type===`started`||n.type===`restarted`;if(rQ(e.terminalStreamCursorByKey[i],a,o))return e;let s=e.terminalStateByThreadKey,c=e.terminalLaunchContextByThreadKey,l=e.terminalSessionSnapshotByKey,u=QZ(e.terminalPreviewUrlByThreadKey,t,ZZ(n));(n.type===`started`||n.type===`restarted`)&&(l={...l,[JZ(t,n.terminalId)]:n.snapshot},s=dQ(s,t,e=>{let t=e.activeTerminalId===n.terminalId,r=e;return e.terminalIds.includes(n.terminalId)||(r=sQ(r,n.terminalId)),t?(r=cQ(r,n.terminalId),r=oQ(r,!0)):(r=cQ(r,e.activeTerminalId),r=oQ(r,e.terminalOpen)),WZ(r)}),c={...c,[r]:QXe(c[r],n)});let d=LXe(n);d!==null&&(s=dQ(s,t,e=>lQ(e,n.terminalId,d)));let f=o&&a?tQ(e.terminalEventEntriesByKey,e.nextTerminalEventId,t,n):eQ(e.terminalEventEntriesByKey,e.nextTerminalEventId,t,n),p=a?{...e.terminalStreamCursorByKey,[i]:a}:e.terminalStreamCursorByKey;return{terminalStateByThreadKey:s,terminalLaunchContextByThreadKey:c,terminalSessionSnapshotByKey:l,terminalStreamCursorByKey:p,terminalPreviewUrlByThreadKey:u,...f}}),setTerminalSessionSnapshot:(t,n)=>e(e=>({terminalSessionSnapshotByKey:{...e.terminalSessionSnapshotByKey,[JZ(t,n.terminalId)]:n},terminalPreviewUrlByThreadKey:QZ(e.terminalPreviewUrlByThreadKey,t,XXe(n))})),clearTerminalState:t=>e(e=>{let n=KZ(t),r=dQ(e.terminalStateByThreadKey,t,()=>HZ()),i=e.terminalLaunchContextByThreadKey[n]!==void 0,a=e.terminalPreviewUrlByThreadKey[n]!==void 0,{[n]:o,...s}=e.terminalLaunchContextByThreadKey,{[n]:c,...l}=e.terminalPreviewUrlByThreadKey,u={...e.terminalEventEntriesByKey},d=!1;for(let e of Object.keys(u))e.startsWith(`${n}\u0000`)&&(delete u[e],d=!0);let f={...e.terminalSessionSnapshotByKey},p=!1;for(let e of Object.keys(f))e.startsWith(`${n}\u0000`)&&(delete f[e],p=!0);let m=iQ(e.terminalStreamCursorByKey,n);return r===e.terminalStateByThreadKey&&!i&&!a&&!d&&!p&&m===e.terminalStreamCursorByKey?e:{terminalStateByThreadKey:r,terminalLaunchContextByThreadKey:s,terminalPreviewUrlByThreadKey:l,terminalEventEntriesByKey:u,terminalSessionSnapshotByKey:f,terminalStreamCursorByKey:m}}),removeTerminalState:t=>e(e=>{let n=KZ(t),r=e.terminalStateByThreadKey[n]!==void 0,i=e.terminalLaunchContextByThreadKey[n]!==void 0,a=e.terminalPreviewUrlByThreadKey[n]!==void 0,o={...e.terminalEventEntriesByKey},s=!1;for(let e of Object.keys(o))e.startsWith(`${n}\u0000`)&&(delete o[e],s=!0);let c={...e.terminalSessionSnapshotByKey},l=!1;for(let e of Object.keys(c))e.startsWith(`${n}\u0000`)&&(delete c[e],l=!0);let u=iQ(e.terminalStreamCursorByKey,n);if(!r&&!i&&!a&&!s&&!l&&u===e.terminalStreamCursorByKey)return e;let d={...e.terminalStateByThreadKey};delete d[n];let f={...e.terminalLaunchContextByThreadKey};delete f[n];let p={...e.terminalPreviewUrlByThreadKey};return delete p[n],{terminalStateByThreadKey:d,terminalLaunchContextByThreadKey:f,terminalPreviewUrlByThreadKey:p,terminalEventEntriesByKey:o,terminalSessionSnapshotByKey:c,terminalStreamCursorByKey:u}}),removeOrphanedTerminalStates:t=>e(e=>{let n=Object.keys(e.terminalStateByThreadKey).filter(e=>!t.has(e)),r=Object.keys(e.terminalLaunchContextByThreadKey).filter(e=>!t.has(e)),i=Object.keys(e.terminalPreviewUrlByThreadKey).filter(e=>!t.has(e)),a={...e.terminalEventEntriesByKey},o=!1;for(let e of Object.keys(a)){let[n]=e.split(`\0`);n&&!t.has(n)&&(delete a[e],o=!0)}let s={...e.terminalSessionSnapshotByKey},c=!1;for(let e of Object.keys(s)){let[n]=e.split(`\0`);n&&!t.has(n)&&(delete s[e],c=!0)}let l={...e.terminalStreamCursorByKey},u=!1;for(let e of Object.keys(l)){let[n]=e.split(`\0`);n&&!t.has(n)&&(delete l[e],u=!0)}if(n.length===0&&r.length===0&&i.length===0&&!o&&!c&&!u)return e;let d={...e.terminalStateByThreadKey};for(let e of n)delete d[e];let f={...e.terminalLaunchContextByThreadKey};for(let e of r)delete f[e];let p={...e.terminalPreviewUrlByThreadKey};for(let e of i)delete p[e];return{terminalStateByThreadKey:d,terminalLaunchContextByThreadKey:f,terminalPreviewUrlByThreadKey:p,terminalEventEntriesByKey:a,terminalSessionSnapshotByKey:s,terminalStreamCursorByKey:l}})}},{name:RXe,version:4,storage:aJ(VXe),migrate:BXe,partialize:e=>({terminalStateByThreadKey:GZ(e.terminalStateByThreadKey),terminalPreviewUrlByThreadKey:e.terminalPreviewUrlByThreadKey})}));function oZe(e){return typeof e==`string`?e:typeof e==`object`&&e&&`detail`in e&&typeof e.detail==`string`?e.detail:e instanceof Error?e.message:String(e)}function sZe(e){return e.match(/blocked by policy for\s+([^.\s]+(?:\.[^.\s]+)*)\.?/i)?.[1]||(e.match(/navigation to\s+([^.\s]+(?:\.[^.\s]+)*)\s+is restricted/i)?.[1]??null)}function pQ(e){let t=oZe(e).trim()||`Unknown browser error.`,n=sZe(t);return/blocked by policy|restricted to allowed domains/i.test(t)?{title:`Browser navigation blocked`,cause:`${n??`This URL`} is not allowed by the current browser policy.`,nextAction:`Use an allowed URL or update the browser allowed-domain setting.`,technicalDetail:t}:/does not match thread|session .*not found|no active browser tab|tab .*not found/i.test(t)?{title:`Browser session is stale`,cause:`Forge no longer has a matching live browser session for this thread.`,nextAction:`Restart the browser session from the Browser options menu.`,technicalDetail:t}:/screenshot|capture|Page\.capture/i.test(t)?{title:`Browser screenshot failed`,cause:`The browser could not capture the current page frame.`,nextAction:`Reload the page, then try the screenshot again.`,technicalDetail:t}:/timed out|timeout/i.test(t)?{title:`Browser action timed out`,cause:`Forge did not receive a response from the browser runtime in time.`,nextAction:`Retry the action. If it keeps failing, restart the browser session.`,technicalDetail:t}:/runtime is not available|browser.*unavailable|not supported|disabled/i.test(t)?{title:`Browser session unavailable`,cause:`This environment does not currently expose the in-app browser runtime.`,nextAction:`Use a workspace with browser support or restart Forge after browser support is enabled.`,technicalDetail:t}:/navigate|navigation|net::|ERR_/i.test(t)?{title:`Browser navigation failed`,cause:`The browser could not load the requested page.`,nextAction:`Check the URL and network access, then try again.`,technicalDetail:t}:{title:`Browser action failed`,cause:`Forge could not complete the browser action.`,nextAction:`Retry the action. If it keeps failing, restart the browser session from the Browser options menu.`,technicalDetail:t}}function cZe(e){let t=pQ(e);return`${t.cause} ${t.nextAction}`}function lZe(e){let t=pQ(e);return`${t.title}: ${t.cause} ${t.nextAction}`}var mQ={session:null,selectedBrowserId:null,sessionsByBrowserId:{},lastActivityByTabId:{},lastSnapshotContentByTabId:{},lastScreenshotDataUrlByTabId:{},lastScreenshotMetaByTabId:{},lastConsoleLogsByTabId:{},lastConsoleLogsMetaByTabId:{},lastFrameByTabId:{},lastFrameSequenceByTabId:{},lastObservedFrameSequenceByTabId:{},lastFrameStreamIdByTabId:{},lastFrameStreamGenerationByTabId:{},frameGapCountByTabId:{},lastFrameMetaByTabId:{},displayIceCandidatesByClientId:{},lastError:null};function hQ(e){return Vo(e)}function uZe(e){let t=e.status===`reconnecting`&&e.reason===`network_unreachable`;return e.transport===`remote-webrtc`&&(e.status===`connected`||e.status===`connecting`||e.status===`reconnecting`)&&(e.reason!==`network_unreachable`||t)&&e.reason!==`unsupported_host`}function dZe(e){return e.transport!==`remote-webrtc`||e.status===`failed`||e.status===`unsupported`?!1:e.reason!==`network_unreachable`&&e.reason!==`unsupported_host`}function gQ(e){let{currentSession:t,nextSession:n}=e;return!t||t.browserId!==n.browserId||t.sessionId!==n.sessionId||!uZe(t.display)||!dZe(n.display)?n:{...n,display:{...t.display,viewport:n.display.viewport??n.viewport??t.display.viewport,devicePixelRatio:n.display.devicePixelRatio??t.display.devicePixelRatio,iceServers:n.display.iceServers??t.display.iceServers,reconnect:t.display.reconnect??n.display.reconnect}}}function fZe(e){let{storedSession:t,nextSession:n}=e;if(!t||t.browserId!==n.browserId||t.sessionId!==n.sessionId)return!1;let r=n.tabs.some(e=>e.navigationStatus===`pending`),i=t.tabs.some(e=>e.navigationStatus===`complete`||e.navigationStatus===`failed`);if(!r||!i)return!1;let a=Date.parse(t.updatedAt),o=Date.parse(n.updatedAt);return Number.isNaN(a)||Number.isNaN(o)?!1:o<a}function _Q(e,t,n){return e[t]===n?e:{...e,[t]:n}}function pZe(e){switch(e.type){case`tab.updated`:return e.payload.tab.tabId;case`tab.closed`:case`snapshot.ready`:case`screenshot.ready`:case`frame.ready`:case`console.logs.ready`:case`display.iceCandidate`:case`display.metrics`:return e.payload.tabId;case`action.failed`:return e.payload.tabId??null;case`display.updated`:case`session.started`:case`session.updated`:case`session.closed`:return null}}function mZe(e,t){let n=pZe(t);return n?{...e,lastActivityByTabId:{...e.lastActivityByTabId,[n]:{actor:t.agentId?`agent`:`human`,agentId:t.agentId,browserId:t.browserId,eventType:t.type,...t.type===`action.failed`?{commandType:t.payload.commandType}:{},...t.type===`action.failed`?{message:t.payload.message}:{},createdAt:t.createdAt}}}:e}function hZe(e){switch(e.type){case`session.started`:case`session.updated`:case`tab.updated`:case`snapshot.ready`:case`screenshot.ready`:case`frame.ready`:case`display.updated`:return!0;case`session.closed`:case`tab.closed`:case`console.logs.ready`:case`action.failed`:case`display.iceCandidate`:case`display.metrics`:return!1}}function vQ(e){return e===null?`end-of-candidates`:JSON.stringify([e.candidate,e.sdpMid??null,e.sdpMLineIndex??null,e.usernameFragment??null])}function gZe(e,t){let n=vQ(t);return e.some(e=>vQ(e)===n)?e:[...e,t]}function _Ze(e){if(e.type!==`session.closed`)return null;switch(e.payload.reason){case`idle_timeout`:return`The browser was closed after being idle. Reopen the preview to restore this thread's browser.`;case`runtime_shutdown`:return`The browser runtime shut down. Reopen the preview to restore this thread's browser.`;case`thread_archived`:case`clear_browsing_data`:case`user_closed`:case void 0:return null}}function vZe(e){let t=e.event.payload.display;return t.status===`failed`||t.status===`unsupported`?t.detail??`Browser display is unavailable.`:e.currentLastError&&/browser display/i.test(e.currentLastError)?null:e.currentLastError}function yZe(e,t){let n=e.sessionsByBrowserId[t.browserId]??(e.session?.browserId===t.browserId?e.session:null);if(!n)return!0;let r=n.sessionId===t.payload.sessionId,i=!t.sessionEpoch||!n.sessionEpoch||t.sessionEpoch===n.sessionEpoch;return r&&i}function bZe(e,t){let n=e.lastFrameSequenceByTabId[t]??0;return{acceptedSequence:n,observedSequence:e.lastObservedFrameSequenceByTabId[t]??n,...e.lastFrameStreamIdByTabId[t]?{streamId:e.lastFrameStreamIdByTabId[t]}:{},...e.lastFrameStreamGenerationByTabId[t]===void 0?{}:{streamGeneration:e.lastFrameStreamGenerationByTabId[t]},...e.lastFrameMetaByTabId[t]?.capturedAt?{acceptedCapturedAt:e.lastFrameMetaByTabId[t].capturedAt}:{},gapCount:e.frameGapCountByTabId[t]??0}}function xZe(e,t){let n=t.payload.tabId,r=vce(bZe(e,n),{sequence:t.payload.sequence,capturedAt:t.payload.capturedAt,...t.payload.streamId?{streamId:t.payload.streamId}:{},...t.payload.streamGeneration===void 0?{}:{streamGeneration:t.payload.streamGeneration},...t.payload.keyframe===void 0?{}:{keyframe:t.payload.keyframe}});return{decision:r,observedSequence:r.state.observedSequence,frameGapCount:r.state.gapCount}}function SZe(e,t,n){let r=t.payload.tabId;return{...e,lastObservedFrameSequenceByTabId:{...e.lastObservedFrameSequenceByTabId,[r]:n.observedSequence},frameGapCountByTabId:{...e.frameGapCountByTabId,[r]:n.frameGapCount}}}function CZe(e,t){let n=t.payload.tabId;return{...e,lastFrameByTabId:{...e.lastFrameByTabId,[n]:t.payload.imageDataUrl},lastFrameSequenceByTabId:{...e.lastFrameSequenceByTabId,[n]:t.payload.sequence},lastFrameStreamIdByTabId:t.payload.streamId?{...e.lastFrameStreamIdByTabId,[n]:t.payload.streamId}:e.lastFrameStreamIdByTabId,lastFrameStreamGenerationByTabId:t.payload.streamGeneration===void 0?e.lastFrameStreamGenerationByTabId:{...e.lastFrameStreamGenerationByTabId,[n]:t.payload.streamGeneration},lastFrameMetaByTabId:{...e.lastFrameMetaByTabId,[n]:{capturedAt:t.payload.capturedAt,url:t.payload.url,viewport:t.payload.viewport}},lastError:null}}function wZe(e){let{current:t,event:n,pendingAutoRevealKeys:r,state:i,threadKey:a}=e;if(!yZe(t,n))return i;let o=xZe(t,n);if(!o.decision.observe)return i;let s=SZe(t,n,o),c=o.decision.accept?CZe(s,n):s;return{browserStateByThreadKey:_Q(i.browserStateByThreadKey,a,c),pendingAutoRevealKeys:r}}var yQ=Wt(e=>({browserStateByThreadKey:{},pendingAutoRevealKeys:new Set,setSessionSnapshot:(t,n)=>e(e=>{let r=hQ(t),i=e.browserStateByThreadKey[r]??mQ,a=n?gQ({currentSession:i.sessionsByBrowserId[n.browserId]??i.session,nextSession:n}):null;return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...i,session:a,selectedBrowserId:a?.browserId??i.selectedBrowserId,sessionsByBrowserId:a?{...i.sessionsByBrowserId,[a.browserId]:a}:i.sessionsByBrowserId,lastError:a?null:i.lastError})}}),selectBrowserSession:(t,n)=>e(e=>{let r=hQ(t),i=e.browserStateByThreadKey[r]??mQ,a=i.sessionsByBrowserId[n]??i.session;return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...i,selectedBrowserId:n,session:a})}}),applyBrowserEvent:(t,n)=>e(e=>{let r=hQ(t),i=hZe(n)?new Set(e.pendingAutoRevealKeys).add(r):e.pendingAutoRevealKeys,a=mZe(e.browserStateByThreadKey[r]??mQ,n);switch(n.type){case`session.started`:{if(fZe({storedSession:a.sessionsByBrowserId[n.payload.snapshot.browserId]??a.session,nextSession:n.payload.snapshot}))return e;let t=gQ({currentSession:a.sessionsByBrowserId[n.payload.snapshot.browserId]??a.session,nextSession:n.payload.snapshot});return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,session:t,selectedBrowserId:a.selectedBrowserId??t.browserId,sessionsByBrowserId:{...a.sessionsByBrowserId,[t.browserId]:t},lastError:null}),pendingAutoRevealKeys:i}}case`session.updated`:{let t=gQ({currentSession:a.sessionsByBrowserId[n.payload.snapshot.browserId]??a.session,nextSession:n.payload.snapshot});return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,session:a.selectedBrowserId&&a.selectedBrowserId!==n.payload.snapshot.browserId?a.session:t,selectedBrowserId:a.selectedBrowserId??n.payload.snapshot.browserId,sessionsByBrowserId:{...a.sessionsByBrowserId,[t.browserId]:t},lastError:null}),pendingAutoRevealKeys:i}}case`session.closed`:let t=a.selectedBrowserId===n.browserId||a.session?.browserId===n.browserId;return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,session:t?null:a.session,selectedBrowserId:t?null:a.selectedBrowserId,sessionsByBrowserId:Object.fromEntries(Object.entries(a.sessionsByBrowserId).filter(([e])=>e!==n.browserId)),lastError:_Ze(n)})};case`display.updated`:{let t=a.session;if(!t||t.sessionId!==n.payload.sessionId)return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,a),pendingAutoRevealKeys:i};let o={...t,display:n.payload.display,updatedAt:n.createdAt};return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,session:o,sessionsByBrowserId:{...a.sessionsByBrowserId,[o.browserId]:o},lastError:vZe({currentLastError:a.lastError,event:n})}),pendingAutoRevealKeys:i}}case`tab.updated`:{let t=a.session;if(!t||t.sessionId!==n.payload.sessionId)return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,a),pendingAutoRevealKeys:i};let o=t.tabs.map(e=>e.tabId===n.payload.tab.tabId?{...n.payload.tab,isActive:e.tabId===t.activeTabId}:{...e,isActive:e.tabId===t.activeTabId}).concat(t.tabs.some(e=>e.tabId===n.payload.tab.tabId)?[]:[{...n.payload.tab,isActive:n.payload.tab.tabId===t.activeTabId}]);return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,session:{...t,tabs:o},lastError:null}),pendingAutoRevealKeys:i}}case`tab.closed`:{let t=a.session;if(!t||t.sessionId!==n.payload.sessionId)return e;let i=t.tabs.filter(e=>e.tabId!==n.payload.tabId);return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,session:{...t,tabs:i,activeTabId:t.activeTabId===n.payload.tabId?i[0]?.tabId??null:t.activeTabId}})}}case`snapshot.ready`:return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,lastSnapshotContentByTabId:{...a.lastSnapshotContentByTabId,[n.payload.tabId]:n.payload.content},lastError:null}),pendingAutoRevealKeys:i};case`screenshot.ready`:return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,lastScreenshotDataUrlByTabId:{...a.lastScreenshotDataUrlByTabId,[n.payload.tabId]:n.payload.imageDataUrl},lastScreenshotMetaByTabId:{...a.lastScreenshotMetaByTabId,[n.payload.tabId]:{captureId:n.payload.captureId,capturedAt:n.payload.capturedAt,url:n.payload.url,viewport:n.payload.viewport}},lastError:null}),pendingAutoRevealKeys:i};case`frame.ready`:return wZe({state:e,current:a,event:n,threadKey:r,pendingAutoRevealKeys:i});case`console.logs.ready`:return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,lastConsoleLogsByTabId:{...a.lastConsoleLogsByTabId,[n.payload.tabId]:n.payload.logs},lastConsoleLogsMetaByTabId:{...a.lastConsoleLogsMetaByTabId,[n.payload.tabId]:{capturedAt:n.createdAt,tabId:n.payload.tabId,count:n.payload.logs.length}},lastError:null})};case`display.iceCandidate`:{let t=a.displayIceCandidatesByClientId[n.payload.clientId]??[];return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,displayIceCandidatesByClientId:{...a.displayIceCandidatesByClientId,[n.payload.clientId]:gZe(t,n.payload.candidate)}}),pendingAutoRevealKeys:i}}case`display.metrics`:return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,a),pendingAutoRevealKeys:i};case`action.failed`:return{browserStateByThreadKey:_Q(e.browserStateByThreadKey,r,{...a,lastError:lZe(n.payload.message)})};default:return e}}),clearBrowserState:t=>e(e=>{let n=hQ(t);if(!(n in e.browserStateByThreadKey))return e;let{[n]:r,...i}=e.browserStateByThreadKey;return{browserStateByThreadKey:i}}),consumeAutoReveal:t=>e(e=>{if(!e.pendingAutoRevealKeys.has(t))return e;let n=new Set(e.pendingAutoRevealKeys);return n.delete(t),{pendingAutoRevealKeys:n}})}));function TZe(e,t){return t?e[hQ(t)]??null:null}var EZe={threadRef:null,open:!1,minimized:!1,dock:`floating`,position:null};function DZe(e){return{x:Math.max(12,Math.min(e.position.x,e.viewportWidth-e.width-12)),y:Math.max(12,Math.min(e.position.y,e.viewportHeight-e.height-12))}}function OZe(e,t){return{...e,threadRef:t,open:!0,minimized:!1}}function kZe(e){let t=e.companion.threadRef;return!e.companion.open||t===null?!1:e.routeThreadRef?.environmentId!==t.environmentId||e.routeThreadRef.threadId!==t.threadId}var bQ=`forge:ui-state:v1`,xQ=[`t3code:ui-state:v1`,`t3code:renderer-state:v8`,`t3code:renderer-state:v7`,`t3code:renderer-state:v6`,`t3code:renderer-state:v5`,`t3code:renderer-state:v4`,`t3code:renderer-state:v3`,`codething:renderer-state:v4`,`codething:renderer-state:v3`,`codething:renderer-state:v2`,`codething:renderer-state:v1`],SQ=`months`,AZe=new Set([`weeks`,`months`,`quarters`]);function jZe(e){return typeof e==`string`&&AZe.has(e)?e:SQ}function CQ(e){return Number.isFinite(e)?Math.round(Math.min(560,Math.max(200,e))):360}var wQ={projectExpandedById:{},projectOrder:[],projectGroupOrder:[],lastActiveProject:null,threadLastVisitedAtById:{},threadChangedFilesExpandedById:{},pinnedThreadById:{},threadLinkedPrById:{},workspaceDensityById:{},timelineWorkColumnWidth:360,timelineScale:SQ,projectLeadCompanion:EZe},TQ=new Set,EQ=[],DQ=new Map,OQ=!1;function MZe(){if(typeof window>`u`)return wQ;try{let e=window.localStorage.getItem(bQ);if(!e){for(let e of xQ){let t=window.localStorage.getItem(e);if(t)return kQ(JSON.parse(t)),wQ}return wQ}let t=JSON.parse(e);return kQ(t),{...wQ,projectGroupOrder:NZe(t.projectGroupOrderKeys),threadChangedFilesExpandedById:IZe(t.threadChangedFilesExpandedById),pinnedThreadById:PZe(t.pinnedThreadKeys),threadLinkedPrById:FZe(t.threadLinkedPrById),timelineWorkColumnWidth:CQ(t.timelineWorkColumnWidth??360),timelineScale:jZe(t.timelineScale)}}catch{return wQ}}function NZe(e){return Array.isArray(e)?[...new Set(e.filter(e=>typeof e==`string`&&e.length>0))]:[]}function PZe(e){if(!Array.isArray(e))return{};let t={};for(let n of e)typeof n==`string`&&n.length>0&&(t[n]=!0);return t}function FZe(e){if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e))typeof n==`string`&&n.length!==0&&typeof r==`string`&&r.trim().length!==0&&(t[n]=r);return t}function IZe(e){if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e)){if(!n||!r||typeof r!=`object`)continue;let e={};for(let[t,n]of Object.entries(r))t&&typeof n==`boolean`&&n===!1&&(e[t]=!1);Object.keys(e).length>0&&(t[n]=e)}return t}function kQ(e){TQ.clear(),EQ.length=0;for(let t of e.expandedProjectCwds??[])typeof t==`string`&&t.length>0&&TQ.add(t);for(let t of e.projectOrderCwds??[])typeof t==`string`&&t.length>0&&!EQ.includes(t)&&EQ.push(t)}function LZe(e){if(!(typeof window>`u`))try{let t=Object.entries(e.projectExpandedById).filter(([,e])=>e).flatMap(([e])=>{let t=DQ.get(e);return t?[t]:[]}),n=e.projectOrder.flatMap(e=>{let t=DQ.get(e);return t?[t]:[]}),r=Object.fromEntries(Object.entries(e.threadChangedFilesExpandedById).flatMap(([e,t])=>{let n=Object.fromEntries(Object.entries(t).filter(([,e])=>e===!1));return Object.keys(n).length>0?[[e,n]]:[]}));if(window.localStorage.setItem(bQ,JSON.stringify({expandedProjectCwds:t,projectOrderCwds:n,projectGroupOrderKeys:e.projectGroupOrder,threadChangedFilesExpandedById:r,pinnedThreadKeys:Object.keys(e.pinnedThreadById).filter(t=>e.pinnedThreadById[t]),threadLinkedPrById:e.threadLinkedPrById,timelineWorkColumnWidth:e.timelineWorkColumnWidth,timelineScale:e.timelineScale})),!OQ){OQ=!0;for(let e of xQ)window.localStorage.removeItem(e)}}catch{}}var AQ=new qt(LZe,{wait:500});function jQ(e,t){let n=Object.entries(e),r=Object.entries(t);if(n.length!==r.length)return!1;for(let[e,r]of n)if(t[e]!==r)return!1;return!0}function MQ(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function RZe(e,t){let n=Object.entries(e),r=Object.entries(t);if(n.length!==r.length)return!1;for(let[e,r]of n)if(!(e in t)||!jQ(r,t[e]))return!1;return!0}function zZe(e,t){let n=new Map(DQ),r=new Map([...n.entries()].map(([e,t])=>[t,e]));DQ.clear();for(let e of t)DQ.set(e.key,e.cwd);let i=n.size!==DQ.size||t.some(e=>n.get(e.key)!==e.cwd),a={},o=e.projectExpandedById,s=new Map(EQ.map((e,t)=>[e,t])),c=t.map((e,t)=>{let n=r.get(e.cwd),i=o[e.key]??(n?o[n]:void 0)??(TQ.size>0?TQ.has(e.cwd):!0);return a[e.key]=i,{id:e.key,cwd:e.cwd,incomingIndex:t}}),l=e.projectOrder.length>0?(()=>{let t=new Map(c.map(e=>[e.cwd,e.id])),r=new Set,i=[];for(let o of e.projectOrder){let e=(o in a?o:void 0)??(()=>{let e=n.get(o);return e?t.get(e):void 0})();!e||r.has(e)||(r.add(e),i.push(e))}for(let e of c)r.has(e.id)||i.push(e.id);return i})():c.map(e=>({id:e.id,incomingIndex:e.incomingIndex,orderIndex:s.get(e.cwd)??EQ.length+e.incomingIndex})).toSorted((e,t)=>{let n=e.orderIndex-t.orderIndex;return n===0?e.incomingIndex-t.incomingIndex:n}).map(e=>e.id);return jQ(e.projectExpandedById,a)&&MQ(e.projectOrder,l)&&!i?e:{...e,projectExpandedById:a,projectOrder:l}}function BZe(e,t){let n=new Set(t.map(e=>e.key)),r=Object.fromEntries(Object.entries(e.threadLastVisitedAtById).filter(([e])=>n.has(e)));for(let e of t)r[e.key]===void 0&&e.seedVisitedAt!==void 0&&e.seedVisitedAt.length>0&&(r[e.key]=e.seedVisitedAt);let i=Object.fromEntries(Object.entries(e.threadChangedFilesExpandedById).filter(([e])=>n.has(e))),a=Object.fromEntries(Object.entries(e.pinnedThreadById).filter(([e,t])=>n.has(e)&&t)),o=Object.fromEntries(Object.entries(e.threadLinkedPrById).filter(([e])=>n.has(e)));return jQ(e.threadLastVisitedAtById,r)&&RZe(e.threadChangedFilesExpandedById,i)&&jQ(e.pinnedThreadById,a)&&jQ(e.threadLinkedPrById,o)?e:{...e,threadLastVisitedAtById:r,threadChangedFilesExpandedById:i,pinnedThreadById:a,threadLinkedPrById:o}}function VZe(e,t,n){let r=n??new Date().toISOString(),i=Date.parse(r),a=e.threadLastVisitedAtById[t],o=a?Date.parse(a):NaN;return Number.isFinite(o)&&Number.isFinite(i)&&o>=i?e:{...e,threadLastVisitedAtById:{...e.threadLastVisitedAtById,[t]:r}}}function HZe(e,t,n){if(!n)return e;let r=Date.parse(n);if(Number.isNaN(r))return e;let i=new Date(r-1).toISOString();return e.threadLastVisitedAtById[t]===i?e:{...e,threadLastVisitedAtById:{...e.threadLastVisitedAtById,[t]:i}}}function UZe(e,t){let n=t in e.threadLastVisitedAtById,r=t in e.threadChangedFilesExpandedById,i=t in e.pinnedThreadById,a=t in e.threadLinkedPrById;if(!n&&!r&&!i&&!a)return e;let o={...e.threadLastVisitedAtById},s={...e.threadChangedFilesExpandedById},c={...e.pinnedThreadById},l={...e.threadLinkedPrById};return delete o[t],delete s[t],delete c[t],delete l[t],{...e,threadLastVisitedAtById:o,threadChangedFilesExpandedById:s,pinnedThreadById:c,threadLinkedPrById:l}}function NQ(e,t,n){if(e.pinnedThreadById[t]===!0===n)return e;if(n)return{...e,pinnedThreadById:{...e.pinnedThreadById,[t]:!0}};let r={...e.pinnedThreadById};return delete r[t],{...e,pinnedThreadById:r}}function WZe(e,t){return NQ(e,t,e.pinnedThreadById[t]!==!0)}function GZe(e,t,n){return e.threadLinkedPrById[t]===n?e:{...e,threadLinkedPrById:{...e.threadLinkedPrById,[t]:n}}}function KZe(e,t){if(!(t in e.threadLinkedPrById))return e;let n={...e.threadLinkedPrById};return delete n[t],{...e,threadLinkedPrById:n}}function qZe(e,t,n,r){let i=e.threadChangedFilesExpandedById[t]??{};return i[n]===r?e:{...e,threadChangedFilesExpandedById:{...e.threadChangedFilesExpandedById,[t]:{...i,[n]:r}}}}function JZe(e,t){return e.lastActiveProject?.environmentId===t?.environmentId&&e.lastActiveProject?.projectId===t?.projectId?e:{...e,lastActiveProject:t}}function YZe(e,t,n){return e.workspaceDensityById[t]===n?e:{...e,workspaceDensityById:{...e.workspaceDensityById,[t]:n}}}function XZe(e,t){let n=e.projectExpandedById[t]??!0;return{...e,projectExpandedById:{...e.projectExpandedById,[t]:!n}}}function ZZe(e,t,n){return(e.projectExpandedById[t]??!0)===n?e:{...e,projectExpandedById:{...e.projectExpandedById,[t]:n}}}function QZe(e,t,n){if(t.length===0)return e;let r=new Set(t),i=new Set(n);if(t.every(e=>i.has(e)))return e;let a=e.projectOrder.findIndex(e=>i.has(e));if(a<0)return e;let o=[...e.projectOrder],s=[],c=0;for(let e=o.length-1;e>=0;e--)r.has(o[e])&&(s.unshift(o.splice(e,1)[0]),e<a&&c++);if(s.length===0)return e;let l=a-Math.max(0,c-1);return o.splice(l,0,...s),{...e,projectOrder:o}}function $Ze(e,t){let n=[...new Set(t)],r=new Set(n),i=e.projectGroupOrder.filter(e=>r.has(e)),a=new Set(i);for(let e of n)a.has(e)||i.push(e);return MQ(e.projectGroupOrder,i)?e:{...e,projectGroupOrder:i}}function eQe(e,t,n){if(t===n)return e;let r=e.projectGroupOrder.indexOf(t),i=e.projectGroupOrder.indexOf(n);if(r<0||i<0)return e;let a=[...e.projectGroupOrder],[o]=a.splice(r,1);return o===void 0?e:(a.splice(i,0,o),{...e,projectGroupOrder:a})}var PQ=Wt(e=>({...MZe(),syncProjects:t=>e(e=>zZe(e,t)),syncProjectGroups:t=>e(e=>$Ze(e,t)),syncThreads:t=>e(e=>BZe(e,t)),markThreadVisited:(t,n)=>e(e=>VZe(e,t,n)),markThreadUnread:(t,n)=>e(e=>HZe(e,t,n)),clearThreadUi:t=>e(e=>UZe(e,t)),setThreadPinned:(t,n)=>e(e=>NQ(e,t,n)),toggleThreadPinned:t=>e(e=>WZe(e,t)),setThreadLinkedPr:(t,n)=>e(e=>GZe(e,t,n)),clearThreadLinkedPr:t=>e(e=>KZe(e,t)),setThreadChangedFilesExpanded:(t,n,r)=>e(e=>qZe(e,t,n,r)),setWorkspaceDensity:(t,n)=>e(e=>YZe(e,t,n)),toggleProject:t=>e(e=>XZe(e,t)),setProjectExpanded:(t,n)=>e(e=>ZZe(e,t,n)),reorderProjects:(t,n)=>e(e=>QZe(e,t,n)),reorderProjectGroups:(t,n)=>e(e=>eQe(e,t,n)),setLastActiveProject:t=>e(e=>JZe(e,t)),setTimelineWorkColumnWidth:t=>e(e=>({...e,timelineWorkColumnWidth:CQ(t)})),setTimelineScale:t=>e(e=>({...e,timelineScale:t})),openProjectLeadCompanion:t=>e(e=>({...e,projectLeadCompanion:OZe(e.projectLeadCompanion,t)})),closeProjectLeadCompanion:()=>e(e=>({...e,projectLeadCompanion:{...e.projectLeadCompanion,open:!1}})),setProjectLeadCompanionMinimized:t=>e(e=>({...e,projectLeadCompanion:{...e.projectLeadCompanion,minimized:t}})),setProjectLeadCompanionDock:t=>e(e=>({...e,projectLeadCompanion:{...e.projectLeadCompanion,dock:t}})),setProjectLeadCompanionPosition:t=>e(e=>({...e,projectLeadCompanion:{...e.projectLeadCompanion,position:t}}))}));function tQe(e){PQ.getState().openProjectLeadCompanion(e)}PQ.subscribe(e=>AQ.maybeExecute(e)),typeof window<`u`&&typeof window.addEventListener==`function`&&window.addEventListener(`beforeunload`,()=>{AQ.flush()});var nQe=bt(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),rQe=class extends Dt()(`effect/http/FetchHttpClient/RequestInit`){},iQe=Qre($e(Yre((e,t,n,r)=>{let i=r.getRef(nQe),a=r.context.mapUnsafe.get(rQe.key)??{},o=a.headers?Qt(gn(a.headers),e.headers):e.headers,s=r=>Ye(Fee({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:e.body._tag===`Stream`?`half`:void 0,signal:n}),catch:t=>new wn({reason:new ine({request:e,cause:t})})}),t=>Wte(e,t));switch(e.body._tag){case`Raw`:case`Uint8Array`:return s(e.body.body);case`FormData`:return s(e.body.formData);case`Stream`:return yt(fte(e.body.stream),s)}return s(void 0)}))),aQe=cte.pipe(S,Ft(e=>{if(Yn(e)&&e.reason._tag===`StatusCodeError`&&e.reason.response.status===429){let t=Aee(e.reason.response.headers[`retry-after`]).pipe(wee(Pre),dte(()=>5));return $e(A(t))}return $e(A(1))})),oQe=Je(function*(e){let t=yield*wt(),n=kt(t,Nre),r=kt(t,Ae),i=Ve(t),o=p(je(e.exportInterval),hee),s,c=qre(kt(t,Ii)).pipe(Li(Ee(Bi,!1)),Xre({schedule:aQe,times:3})),l=tr({"user-agent":`effect-opentelemetry-${e.label}/0.0.0`});e.headers&&(l=Qt(gn(e.headers),l));let d=Rre(e.url,{headers:l}),f=[],m=Et(()=>{if(s!==void 0&&n.currentTimeMillisUnsafe()<s)return nt;s!==void 0&&(s=void 0);let t=f;if(e.maxBatchSize!==`disabled`){if(f.length===0)return nt;f=[]}return c.execute(Pi(d,e.body(t))).pipe(fee,jee(!1))}).pipe(He(e=>s===void 0?(s=n.currentTimeMillisUnsafe()+6e4,f=[],Dee(`Disabling exporter for 60 seconds`,e)):nt),u({package:`@effect/opentelemetry`,module:e.label}));return yield*Rt(r,m.pipe(Ct,ot,qee(e.shutdownTimeout))),yield*a(o).pipe(Lt(m),Ze,jt(r)),{push(t){s===void 0&&(f.push(t),e.maxBatchSize!==`disabled`&&f.length>=e.maxBatchSize&&fe(i(m),r))}}}),sQe=e=>{let t=e.attributes?FQ(Object.entries(e.attributes)):[];return t.push({key:`service.name`,value:{stringValue:e.serviceName}}),e.serviceVersion&&t.push({key:`service.version`,value:{stringValue:e.serviceVersion}}),{attributes:t,droppedAttributesCount:0}},cQe=Je(function*(e){let t={...yield*Al(Fn(Pce(Un,Un)),`OTEL_RESOURCE_ATTRIBUTES`),...e?.attributes},n=e?.serviceName??t[`service.name`]??(yield*Al(Un,`OTEL_SERVICE_NAME`));delete t[`service.name`];let r=e?.serviceVersion??t[`service.version`]??(yield*Al(Fn(Un),`OTEL_SERVICE_VERSION`));return delete t[`service.version`],sQe({serviceName:n,serviceVersion:r,attributes:t})},l),lQe=e=>{let t=e.attributes.find(e=>e.key===`service.name`);if(!t||!t.value.stringValue)throw Error(`Resource does not contain a service name`);return t.value.stringValue},FQ=e=>{let t=[];for(let[n,r]of e)t.push({key:n,value:IQ(r)});return t},IQ=e=>{if(Array.isArray(e))return{arrayValue:{values:e.map(IQ)}};switch(typeof e){case`string`:return{stringValue:e};case`bigint`:return{intValue:Number(e)};case`number`:return Number.isInteger(e)?{intValue:e}:{doubleValue:e};case`boolean`:return{boolValue:e};default:return{stringValue:i(e)}}},LQ=class extends Dt()(`effect/observability/OtlpSerialization`){},uQe=pe(LQ,{traces:e=>un(e),metrics:e=>un(e),logs:e=>un(e)}),dQe=Je(function*(e){let t=yield*cQe(e.resource),n=yield*LQ,r={name:lQe(t)},i=yield*oQe({label:`OtlpTracer`,url:e.url,headers:e.headers,exportInterval:e.exportInterval??A(5),maxBatchSize:e.maxBatchSize??1e3,body(e){let i={resourceSpans:[{resource:t,scopeSpans:[{scope:r,spans:e}]}]};return n.traces(i)},shutdownTimeout:e.shutdownTimeout??A(3)});function a(e){e.sampled&&i.push(mQe(e))}return ye({span(e){return pQe({...e,status:{_tag:`Started`,startTime:e.startTime},attributes:new Map,export:a})},context:e.context?function(t,n){return n.currentSpan===void 0?t[`~effect/Effect/evaluate`](n):e.context(t,n.currentSpan)}:void 0})}),fQe={_tag:`Span`,end(e,t){this.status={_tag:`Ended`,startTime:this.status.startTime,endTime:e,exit:t},this.export(this)},attribute(e,t){this.attributes.set(e,t)},event(e,t,n){this.events.push([e,t,n])},addLinks(e){this.links.push(...e)}},pQe=e=>{let t=Object.assign(Object.create(fQe),e);return t.traceId=x(t.parent)?t.parent.value.traceId:RQ(32),t.spanId=RQ(16),t.events=[],t},RQ=e=>{let t=``;for(let n=0;n<e;n++)t+=`0123456789abcdef`[Math.floor(Math.random()*16)];return t},mQe=e=>{let t=e.status,n=FQ(e.attributes.entries()),r=e.events.map(([e,t,n])=>({name:e,timeUnixNano:String(t),attributes:n?FQ(Object.entries(n)):[],droppedAttributesCount:0})),i;if(t.exit._tag===`Success`)i=gQe;else if(at(t.exit.cause))i={code:zQ.Ok,message:`Interrupted`},n.push({key:`span.label`,value:{stringValue:`⚠︎ Interrupted`}},{key:`status.interrupted`,value:{boolValue:!0}});else{let e=lte(t.exit.cause);if(i={code:zQ.Error},e.length>0){i.message=e[0].message;for(let n of e)r.push({name:`exception`,timeUnixNano:String(t.endTime),droppedAttributesCount:0,attributes:[{key:`exception.type`,value:{stringValue:n.name}},{key:`exception.message`,value:{stringValue:n.message}},{key:`exception.stacktrace`,value:{stringValue:n.stack??`No stack trace available`}}]})}}return{traceId:e.traceId,spanId:e.spanId,parentSpanId:o(e.parent,{onNone:()=>void 0,onSome:e=>e.spanId}),name:e.name,kind:hQe[e.kind],startTimeUnixNano:String(t.startTime),endTimeUnixNano:String(t.endTime),attributes:n,droppedAttributesCount:0,events:r,droppedEventsCount:0,status:i,links:e.links.map(e=>({traceId:e.span.traceId,spanId:e.span.spanId,attributes:FQ(Object.entries(e.attributes)),droppedAttributesCount:0})),droppedLinksCount:0}},zQ={Unset:0,Ok:1,Error:2},hQe={unspecified:0,internal:1,server:2,client:3,producer:4,consumer:5},gQe={code:zQ.Ok},_Qe=1e4,vQe={serviceName:`forge-web`,attributes:{"service.runtime":`forge-web`,"service.mode":Ar?`electron`:`browser`,"service.version":El}},yQe=Te(iQe,uQe,pe(zi,()=>!0)),BQ=null,VQ=null,HQ=null,UQ=null,WQ=0,GQ=Promise.resolve(),bQe=pe(Hee,ye({span(e){return BQ?.span(e)??new c(e)}}));function xQe(e={}){return e.exportIntervalMs===void 0&&UQ!==null||(GQ=GQ.finally(()=>SQe(e))),GQ}async function SQe(e){let t=lr(`/api/observability/v1/traces`),n=or()?.bearerToken,r=Math.max(10,e.exportIntervalMs??_Qe),i=`${t}|${r}|${n?`bearer`:`cookie`}`;if(UQ===i&&BQ!==null)return;UQ=i;let a=++WQ,o=VQ,s=HQ;BQ=null,VQ=null,HQ=null,await KQ(o,s);let c=vl(yQe),l=c.runSync(Le());try{let e=await c.runPromise(ee(l)(dQe({url:t,...n?{headers:{Authorization:`Bearer ${n}`}}:{},exportInterval:`${r} millis`,resource:vQe})));if(a!==WQ){await KQ(c,l);return}BQ=e,VQ=c,HQ=l}catch(e){await KQ(c,l),a===WQ&&console.warn(`Failed to configure client tracing exporter`,{error:CQe(e),otlpTracesUrl:t})}}async function KQ(e,t){e!==null&&t!==null&&await e.runPromise(ze(t,xt)).catch(()=>void 0).finally(()=>{e.dispose()})}function CQe(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}var qQ=15e3,JQ=new Map,YQ=Ht([]).pipe(Vt,zt(`slow-rpc-ack-requests`));function XQ(e){Bt.set(YQ,[...e])}function ZQ(){return Bt.get(YQ)}var QQ=`global`;function wQe(e){return!(e.split(`.`).at(-1)??e).startsWith(`subscribe`)}function TQe(e,t,n=QQ){if(!wQe(t))return;t$(e,n),kQe();let r=Date.now(),i={clientId:n,requestId:e,startedAt:new Date(r).toISOString(),startedAtMs:r,tag:t,thresholdMs:qQ},a=e$(n,e),o=setTimeout(()=>{JQ.delete(a),OQe(i)},qQ);JQ.set(a,{request:i,timeoutId:o})}function EQe(e,t=QQ){t$(e,t);let n=ZQ();n.some(n=>n.clientId===t&&n.requestId===e)&&XQ(n.filter(n=>n.clientId!==t||n.requestId!==e))}function $Q(e){for(let[t,n]of JQ)n.request.clientId===e&&(clearTimeout(n.timeoutId),JQ.delete(t));XQ(ZQ().filter(t=>t.clientId!==e))}function DQe(){for(let e of JQ.values())clearTimeout(e.timeoutId);JQ.clear(),XQ([])}function e$(e,t){return`${e}:${t}`}function t$(e,t){let n=e$(t,e),r=JQ.get(n);r&&(clearTimeout(r.timeoutId),JQ.delete(n))}function OQe(e){let t=[...ZQ(),e];if(t.length<=256){XQ(t);return}XQ(t.slice(-256))}function kQe(){for(;JQ.size>=256;){let e=JQ.keys().next().value;if(e===void 0)return;let t=JQ.get(e);if(!t)return;t$(t.request.requestId,t.request.clientId)}}function AQe(){return ar(YQ)}var jQe=ko(Hn),n$=1;function MQe(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}function r$(e){let t=new URL(e);if(t.protocol!==`ws:`&&t.protocol!==`wss:`)throw Error(`Unsupported websocket transport URL protocol: ${t.protocol}`);return t.pathname=`/ws`,t.toString()}function NQe(){return{onAttempt:Ine,onOpen:Lne,onError:e=>{jne(e)},onClose:e=>{Rne(e)},trackGlobalConnection:!0}}function PQe(e){let t=NQe(),n=e?.trackGlobalConnection??!0;return{onAttempt:r=>{n&&t.onAttempt(r),e?.onAttempt?.(r)},onOpen:()=>{n&&t.onOpen(),e?.onOpen?.()},onError:r=>{n&&t.onError(r),e?.onError?.(r)},onClose:r=>{n&&t.onClose(r),e?.onClose?.(r)},trackGlobalConnection:n}}function FQe(e,t){let n=n$;n$+=1;let r=PQe(t),i=typeof e==`function`?dt(()=>e()).pipe(Ye(e=>r$(e)),rte(e=>st(()=>{r.onError(MQe(e))})),l):r$(e),a=pe(oa,(e,t)=>{r.onAttempt(e);let n=new globalThis.WebSocket(e,t);return n.addEventListener(`open`,()=>{r.onOpen()},{once:!0}),n.addEventListener(`error`,()=>{r.onError(`Unable to connect to the Forge server WebSocket.`)},{once:!0}),n.addEventListener(`close`,e=>{r.onClose({code:e.code,reason:e.reason})},{once:!0}),n}),o=sa(i).pipe(E(a)),s=Ft(y(10),e=>$e(Be(Ane(e)??0)));return ut(Mo,Ye(No({retryPolicy:s,retryTransientErrors:!0}),e=>({...e,run:(t,r)=>{let i=`${n}:${String(t)}`;return e.run(t,e=>(e._tag===`Chunk`||e._tag===`Exit`?EQe(e.requestId,i):(e._tag===`ClientProtocolError`||e._tag===`Defect`)&&$Q(i),r(e))).pipe(Ge(st(()=>{$Q(i)})))},send:(t,r,i)=>{let a=`${n}:${String(t)}`;return r._tag===`Request`&&TQe(r.id,r.tag,a),e.send(t,r,i)}}))).pipe(E(Te(o,Oo)))}var IQe=Be(250),i$=()=>void 0,a$=class extends Error{name=`WsRequestTimeoutError`;timeoutMs;constructor(e){let t=Re(je(e));super(`WebSocket RPC request timed out after ${t}ms.`),this.timeoutMs=t}},LQe=new Set([`OrchestrationGetSnapshotError`]);function RQe(e){if(typeof e!=`object`||!e)return!1;let t=e._tag;return typeof t==`string`&&LQe.has(t)}function zQe(e){let t=e instanceof Error?e.message.trim():``;return t.length>0?t:typeof e==`object`&&e?BQe(e):String(e)}function BQe(e){try{return JSON.stringify(e)}catch{let t=e;return[typeof t._tag==`string`?t._tag:void 0,typeof t.message==`string`?t.message:void 0].filter(Boolean).join(`: `)||Object.prototype.toString.call(e)}}var VQe=4e3,HQe=1e4,UQe=500,o$=class{url;lifecycleHandlers;disposed=!1;hasReportedTransportDisconnect=!1;reconnectChain=Promise.resolve();session;heartbeatTimer=null;heartbeatInFlight=!1;protocol;timing;constructor(e,t,n,r){this.url=e,this.lifecycleHandlers=t,this.protocol=n??null,this.timing={heartbeatIntervalMs:r?.heartbeatIntervalMs??VQe,heartbeatTimeoutMs:r?.heartbeatTimeoutMs??HQe,sessionCloseGraceMs:r?.sessionCloseGraceMs??UQe},this.session=this.createSession(),this.startHeartbeat()}startHeartbeat(){this.heartbeatTimer===null&&(this.heartbeatTimer=setInterval(()=>{if(this.disposed||this.heartbeatInFlight)return;this.heartbeatInFlight=!0;let e=this.session;this.request(e=>e[M.serverHeartbeat]({}),{timeout:this.timing.heartbeatTimeoutMs}).catch(async()=>{this.disposed||e!==this.session||await this.reconnect()}).finally(()=>{this.heartbeatInFlight=!1})},this.timing.heartbeatIntervalMs))}async request(e,t){if(this.disposed)throw Error(`Transport disposed`);let n=this.session,i=await n.clientPromise,a=Et(()=>e(i)),o=t?.timeout,s=o===void 0?a:a.pipe(At({duration:o,orElse:()=>r(new a$(o))}));return await n.runtime.runPromise(s)}async requestStream(e,t,n){if(this.disposed)throw Error(`Transport disposed`);let r=this.session,i=this.runStreamOnSession(r,e,t,()=>!0,()=>void 0),a=()=>i.cancel();n?.signal?.aborted&&a(),n?.signal?.addEventListener(`abort`,a,{once:!0});try{await i.completed}catch(e){if(n?.signal?.aborted){let e=Error(`RPC stream request was cancelled.`);throw e.name=`AbortError`,e}throw e}finally{n?.signal?.removeEventListener(`abort`,a)}}subscribe(e,t,n){if(this.disposed)return()=>void 0;let r={active:!0,hasReceivedValue:!1,cancelCurrentStream:i$},i=Re(je(n?.retryDelay??IQe));return this.runSubscriptionLoop(e,t,n,r,i),()=>{r.active=!1,r.cancelCurrentStream()}}async runSubscriptionLoop(e,t,n,r,i){for(;r.active&&!this.disposed;){let a=this.session;try{this.notifyResubscribe(r,n);let i=this.startSubscriptionStream(a,e,t,r);r.cancelCurrentStream=i.cancel,await i.completed,r.cancelCurrentStream=i$}catch(e){if(r.cancelCurrentStream=i$,!await this.handleSubscriptionFailure(e,a,r,n,i))return}}}notifyResubscribe(e,t){if(e.hasReceivedValue)try{t?.onResubscribe?.()}catch{}}startSubscriptionStream(e,t,n,r){return this.runStreamOnSession(e,t,n,()=>r.active,()=>{this.hasReportedTransportDisconnect=!1,r.hasReceivedValue=!0})}async handleSubscriptionFailure(e,t,n,r,i){if(!n.active||this.disposed)return!1;if(t!==this.session)return!0;let a=zQe(e);return OK(a)?(this.hasReportedTransportDisconnect||console.warn(`WebSocket RPC subscription disconnected`,{error:a}),this.hasReportedTransportDisconnect=!0,await WQe(i),!0):(this.reportNonTransportSubscriptionError(e,r),!1)}reportNonTransportSubscriptionError(e,t){RQe(e)||zK(e,{route:`ws-subscribe`,reason:`non-transport-error`}),t?.onError?.(e)}async reconnect(){if(this.disposed)throw Error(`Transport disposed`);let e=this.reconnectChain.then(async()=>{if(this.disposed)throw Error(`Transport disposed`);let e=this.session;this.session=this.createSession(),await this.closeSession(e)});this.reconnectChain=e.catch(e=>{zK(e,{route:`ws-reconnect`})}),await e}async dispose(){this.disposed||(this.disposed=!0,this.heartbeatTimer!==null&&this.heartbeatTimer!==void 0&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),await this.closeSession(this.session))}async closeSession(e){let t=e.runtime.runPromise(ze(e.clientScope,xt)),n=!1,r=null,i=new Promise(e=>{r=setTimeout(()=>{n=!0,e()},this.timing.sessionCloseGraceMs)});try{await Promise.race([t,i])}finally{r!==null&&clearTimeout(r),n&&(console.warn(`WebSocket session close exceeded its grace period; forcing disposal`,{graceMs:this.timing.sessionCloseGraceMs}),t.catch(()=>void 0)),await e.runtime.dispose()}}createSession(){let e=this.protocol??{layer:FQe(this.url,this.lifecycleHandlers),makeClient:jQe},t=vl(Te(e.layer,bQe)),n=t.runSync(Le());return{runtime:t,clientScope:n,clientPromise:t.runPromise(ee(n)(e.makeClient))}}runStreamOnSession(e,t,n,r,i){let a,o,s=new Promise((e,t)=>{a=e,o=t});return{cancel:e.runtime.runCallback(dt(()=>e.clientPromise).pipe(yt(e=>Jee(t(e),e=>st(()=>{if(r()){i();try{n(e)}catch{}}})))),{onExit:e=>{if(ete(e)){a();return}o(Pe(e.cause))}}),completed:s}}};function WQe(e){return new Promise(t=>{setTimeout(t,e)})}var s$=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,GQe=/^[A-Za-z0-9_-]+$/;function KQe(e){let t=``;for(let n=0;n<e.byteLength;n+=3){let r=e[n]??0,i=e[n+1]??0,a=e[n+2]??0,o=r<<16|i<<8|a;t+=s$[o>>>18&63],t+=s$[o>>>12&63],n+1<e.byteLength&&(t+=s$[o>>>6&63]),n+2<e.byteLength&&(t+=s$[o&63])}return t.replaceAll(`+`,`-`).replaceAll(`/`,`_`)}function qQe(e){if(e.length===0||!GQe.test(e))throw Error(`Bulk transfer chunk is not valid base64url data.`);let t=e.replaceAll(`-`,`+`).replaceAll(`_`,`/`),n=Math.floor(t.length*6/8),r=new Uint8Array(n),i=0,a=0,o=0;for(let e of t){let t=s$.indexOf(e);if(t<0)throw Error(`Bulk transfer chunk is not valid base64url data.`);i=i<<6|t,a+=6,a>=8&&(a-=8,r[o]=i>>>a&255,o+=1)}return r}async function c$(e){let t=new Uint8Array(e.byteLength);t.set(e);let n=await crypto.subtle.digest(`SHA-256`,t.buffer);return Array.from(new Uint8Array(n),e=>e.toString(16).padStart(2,`0`)).join(``)}async function JQe(e,t){let n=t?.chunkBytes??262144;if(!Number.isSafeInteger(n)||n<1||n>262144)throw Error(`Bulk transfer chunk size must be between 1 and ${hne}.`);let r=t?.transferId??crypto.randomUUID().replaceAll(`-`,`_`),i=[];for(let t=0;t<e.byteLength;t+=n){let a=e.slice(t,Math.min(t+n,e.byteLength));i.push({kind:`chunk`,transferId:r,offset:t,bytes:a.byteLength,data:KQe(a),sha256:await c$(a)})}return{totalBytes:e.byteLength,sha256:await c$(e),chunks:i}}async function YQe(e){let t=qQe(e.data);if(t.byteLength!==e.bytes)throw Error(`Bulk transfer chunk byte count mismatch at offset ${e.offset}: expected ${e.bytes}, received ${t.byteLength}.`);if(await c$(t)!==e.sha256)throw Error(`Bulk transfer chunk integrity mismatch at offset ${e.offset}.`);return t}async function XQe(e){let t=new Map,n=[],r=0;for(let i of e.chunks){let e=t.get(i.offset);if(e!==void 0){if(e.bytes!==i.bytes||e.sha256!==i.sha256||e.data!==i.data)throw Error(`Bulk transfer has a conflicting duplicate chunk at offset ${i.offset}.`);continue}if(i.offset!==r)throw Error(`Bulk transfer chunk offset mismatch: expected ${r}, received ${i.offset}.`);let a=await YQe(i);t.set(i.offset,i),n.push({chunk:i,bytes:a}),r+=a.byteLength}if(r!==e.totalBytes)throw Error(`Bulk transfer total byte count mismatch: expected ${e.totalBytes}, received ${r}.`);let i=new Uint8Array(e.totalBytes);for(let e of n)i.set(e.bytes,e.chunk.offset);if(await c$(i)!==e.sha256)throw Error(`Bulk transfer payload integrity mismatch.`);return i}var l$=`forge`,ZQe=RegExp(`^${l$}\\/[0-9a-f]{8}$`);function QQe(){return`${l$}/${de(bte).replace(/-/g,``).slice(0,8).toLowerCase()}`}function $Qe(e){return ZQe.test(e.trim().toLowerCase())}function e$e(e){let t=e.trim().replace(/\/+$/g,``).replace(/\.git$/i,``).toLowerCase();if(/^(?:ssh|https?|git):\/\//i.test(t))try{let e=new URL(t),n=e.pathname.split(`/`).filter(e=>e.length>0).join(`/`);if(e.hostname&&n.includes(`/`))return`${e.hostname}/${n}`}catch{return t}let n=/^git@([^:/\s]+)[:/]([^/\s]+(?:\/[^/\s]+)+)$/i.exec(t);return n?.[1]&&n[2]?`${n[1]}/${n[2]}`:t}function t$e(e){let t=e?.trim()??``;if(t.length===0)return null;let n=/^(?:git@github\.com:|ssh:\/\/git@github\.com\/|https:\/\/github\.com\/|git:\/\/github\.com\/)([^/\s]+\/[^/\s]+?)(?:\.git)?\/?$/i.exec(t)?.[1]?.trim()??``;return n.length>0?n:null}function n$e(e){let t=e.trim();if(t.length===0)return null;if(t.startsWith(`git@`)){let e=t.slice(4),n=e.search(/[:/]/);return n<=0?null:e.slice(0,n).toLowerCase()}try{return new URL(t).hostname.toLowerCase()}catch{return null}}function u$(e){return`https://${e}`}function r$e(e){return e===`github.com`||e.includes(`github`)}function i$e(e){return e===`gitlab.com`||e.includes(`gitlab`)}function a$e(e){return e===`bitbucket.org`}function o$e(e){return e===`dev.azure.com`||e===`ssh.dev.azure.com`||e===`vs-ssh.visualstudio.com`||e.endsWith(`.visualstudio.com`)}function s$e(e){let t=n$e(e);if(!t)return null;let n=e$e(e),r=`${t}/`;if(!n.startsWith(r))return null;let i=n.slice(r.length);return i.includes(`/`)?r$e(t)?{kind:`github`,name:t===`github.com`?`GitHub`:`GitHub Self-Hosted`,host:t,repositoryPath:i,baseUrl:u$(t)}:i$e(t)?{kind:`gitlab`,name:t===`gitlab.com`?`GitLab`:`GitLab Self-Hosted`,host:t,repositoryPath:i,baseUrl:u$(t)}:a$e(t)?{kind:`bitbucket`,name:`Bitbucket Cloud`,host:t,repositoryPath:i,baseUrl:u$(t)}:o$e(t)?{kind:`azure-devops`,name:`Azure DevOps`,host:t,repositoryPath:i,baseUrl:u$(t)}:{kind:`unknown`,name:t,host:t,repositoryPath:i,baseUrl:u$(t)}:null}var c$e={hasUpstream:!1,aheadCount:0,behindCount:0,pr:null,defaultBranch:null,diffVsBase:null};function d$(e,t){return{...e,...t??c$e}}function l$e(e){return{hasUpstream:e.hasUpstream,aheadCount:e.aheadCount,behindCount:e.behindCount,pr:e.pr,defaultBranch:e.defaultBranch,diffVsBase:e.diffVsBase}}function u$e(e){return{isRepo:e.isRepo,...e.hostingProvider?{hostingProvider:e.hostingProvider}:{},hasOriginRemote:e.hasOriginRemote,isDefaultBranch:e.isDefaultBranch,branch:e.branch,hasWorkingTreeChanges:e.hasWorkingTreeChanges,workingTree:e.workingTree}}function d$e(e,t){switch(t._tag){case`snapshot`:return d$(t.local,t.remote);case`localUpdated`:return d$(t.local,e?l$e(e):null);case`remoteUpdated`:return d$(e===null?{isRepo:!0,hasOriginRemote:!1,isDefaultBranch:!1,branch:null,hasWorkingTreeChanges:!1,workingTree:{files:[],insertions:0,deletions:0}}:u$e(e),t.remote)}}var f$e=262144,p$e=250;function m$e(e){if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch{return String(e)}}function h$e(e){return new Promise(t=>setTimeout(t,e))}function g$e(e){let t=fce({controllerId:crypto.randomUUID(),maxPendingWriteBytes:f$e}),n=!1,r=e=>{if(!e.sessionEpoch)throw Error(`Connected Forge runtime does not support epoch-fenced terminal controls.`);t.register({threadId:e.threadId,terminalId:e.terminalId,sessionEpoch:e.sessionEpoch})},i=async e=>{for(;!n;)try{return await e()}catch(e){if(!OK(m$e(e)))throw e;await h$e(p$e)}throw Error(`Terminal control client was disposed before acknowledgement.`)};return{terminal:{open:async t=>{let n=await e.request(e=>e[M.terminalOpen]({...t,terminalId:t.terminalId??`default`}));return r(n),n},write:async n=>{let r=n.terminalId??`default`;await t.enqueue({threadId:n.threadId,terminalId:r,writeBytes:new TextEncoder().encode(n.data).byteLength,execute:t=>i(()=>e.request(e=>e[M.terminalWrite]({...n,terminalId:r,...t})))})},resize:async n=>{let r=n.terminalId??`default`;await t.enqueue({threadId:n.threadId,terminalId:r,execute:t=>i(()=>e.request(e=>e[M.terminalResize]({...n,terminalId:r,...t})))})},signal:async n=>{let r=n.terminalId??`default`;await t.enqueue({threadId:n.threadId,terminalId:r,execute:t=>i(()=>e.request(e=>e[M.terminalSignal]({...n,terminalId:r,...t})))})},clear:async n=>{let r=n.terminalId??`default`;await t.enqueue({threadId:n.threadId,terminalId:r,execute:t=>i(()=>e.request(e=>e[M.terminalClear]({...n,terminalId:r,...t})))})},restart:async n=>{let a=n.terminalId??`default`,o=null;if(await t.enqueue({threadId:n.threadId,terminalId:a,execute:async t=>{o=(await i(()=>e.request(e=>e[M.terminalRestart]({...n,terminalId:a,...t})))).snapshot}}),o===null)throw Error(`Terminal restart completed without a snapshot.`);return r(o),o},close:async n=>{let r=n.terminalId?[n.terminalId]:t.terminalIds(n.threadId);for(let a of r)await t.enqueue({threadId:n.threadId,terminalId:a,execute:t=>i(()=>e.request(e=>e[M.terminalClose]({...n,terminalId:a,...t})))}),t.remove(n.threadId,a)},onEvent:t=>e.subscribe(e=>e[M.subscribeTerminalEvents]({}),e=>{(e.type===`started`||e.type===`restarted`)&&r(e.snapshot),t(e)})},dispose:()=>{n=!0,t.dispose()}}}var _$e=2e4,v$e=12e4,y$e=3e5;function b$e(e){return e instanceof a$||OK(e instanceof Error?e.message:String(e))}async function x$e(e,t){let n=t.type===`thread.turn.start`&&t.bootstrap!==void 0?y$e:_$e,r=()=>e.request(e=>e[sn.dispatchCommand](t),{timeout:n});try{return await r()}catch(t){if(!b$e(t))throw t;return await e.reconnect(),await r()}}function f$(e){if(!e?.aborted)return;let t=Error(`Bulk transfer was cancelled.`);throw t.name=`AbortError`,t}async function p$(e,t,n){let r={started:null,completed:null,chunks:[],protocolError:null,receivedBytes:0};if(await e.requestStream(t,e=>S$e(r,e,n),n),r.protocolError!==null)throw r.protocolError;let i=r.started,a=r.completed;if(i===null||a===null)throw Error(`Bulk transfer stream completed without start and completion metadata.`);if(a.transferId!==i.transferId||a.totalBytes!==i.totalBytes||a.sha256!==i.sha256)throw Error(`Bulk transfer completion metadata mismatch.`);return await XQe({totalBytes:i.totalBytes,sha256:i.sha256,chunks:r.chunks})}function S$e(e,t,n){if(e.protocolError===null){if(t.kind===`started`){C$e(e,t,n);return}if(e.started===null||t.transferId!==e.started.transferId){e.protocolError=Error(`Bulk transfer event identity mismatch.`);return}if(t.kind===`chunk`){w$e(e,t,n);return}e.completed=t,n?.onProgress?.({completedBytes:t.totalBytes,totalBytes:t.totalBytes})}}function C$e(e,t,n){if(e.started!==null||t.totalBytes>16777216){e.protocolError=Error(`Bulk transfer started with invalid or oversized metadata.`);return}e.started=t,n?.onProgress?.({completedBytes:0,totalBytes:t.totalBytes})}function w$e(e,t,n){let r=e.started;if(r!==null){if(e.receivedBytes+=t.bytes,e.receivedBytes>r.totalBytes){e.protocolError=Error(`Bulk transfer exceeded its declared byte count.`);return}e.chunks.push(t),n?.onProgress?.({completedBytes:e.receivedBytes,totalBytes:r.totalBytes})}}async function T$e(e,t,n){let r=new TextEncoder().encode(t.contents);if(r.byteLength>16777216)throw Error(`Project file exceeds the ${sne}-byte write limit.`);let i=await JQe(r),a=i.chunks[0]?.transferId??crypto.randomUUID().replaceAll(`-`,`_`),o=!1;try{f$(n?.signal);let r=await E$e(e,t,a,i);return o=!0,n?.onProgress?.({completedBytes:r.nextOffset,totalBytes:i.totalBytes}),await D$e(e,a,i,r,n),{relativePath:t.relativePath}}catch(t){throw o&&await O$e(e,a),t}}function E$e(e,t,n,r){return e.request(e=>e[M.workspaceBeginWriteFile]({transferId:n,cwd:t.cwd,relativePath:t.relativePath,totalBytes:r.totalBytes,sha256:r.sha256}))}async function D$e(e,t,n,r,i){if(r.state!==`completed`){for(let t of n.chunks){if(t.offset<r.nextOffset)continue;f$(i?.signal);let{kind:a,...o}=t,s=await e.request(e=>e[M.workspaceWriteFileChunk](o));i?.onProgress?.({completedBytes:s.nextOffset,totalBytes:n.totalBytes})}f$(i?.signal),await e.request(e=>e[M.workspaceCommitWriteFile]({transferId:t}))}}async function O$e(e,t){await e.request(e=>e[M.workspaceCancelWriteFile]({transferId:t})).catch(()=>void 0)}function m$(e){let t=g$e(e);return{dispose:()=>(t.dispose(),e.dispose()),reconnect:async()=>{kne(),await e.reconnect()},terminal:t.terminal,browser:{openSession:t=>e.request(e=>e[M.browserOpenSession](t)),listSessions:t=>e.request(e=>e[M.browserListSessions](t)),closeSession:t=>e.request(e=>e[M.browserCloseSession](t)),getSession:t=>e.request(e=>e[M.browserGetSession](t)),command:t=>e.request(e=>e[M.browserCommand](t)),clearBrowsingData:t=>e.request(e=>e[M.browserClearBrowsingData](t)),attachDisplay:t=>e.request(e=>e[M.browserAttachDisplay](t)),addDisplayIceCandidate:t=>e.request(e=>e[M.browserAddDisplayIceCandidate](t)),onEvent:(t,n,r)=>e.subscribe(e=>e[M.subscribeBrowserEvents](t),n,r)},computer:{input:t=>e.request(e=>e[M.computerInput](t))},threadDevRuntime:{get:t=>e.request(e=>e[M.threadDevRuntimeGet](t)),allocatePort:t=>e.request(e=>e[M.threadDevRuntimeAllocatePort](t)),release:t=>e.request(e=>e[M.threadDevRuntimeRelease](t))},devTunnel:{register:t=>e.request(e=>e[M.devTunnelRegister](t)),unregister:t=>e.request(e=>e[M.devTunnelUnregister](t)),list:t=>e.request(e=>e[M.devTunnelList](t))},projects:{searchEntries:t=>e.request(e=>e[M.projectsSearchEntries](t)),readFile:(t,n)=>p$(e,e=>e[M.workspaceReadFile](t),n),writeFile:(t,n)=>T$e(e,t,n)},projectCheckoutDeletion:{preview:t=>e.request(e=>e[M.projectCheckoutDeletionPreview](t)),execute:t=>e.request(e=>e[M.projectCheckoutDeletionExecute](t))},codeGraph:{summary:t=>e.request(e=>e[M.codeGraphSummary](t)),neighborhood:t=>e.request(e=>e[M.codeGraphNeighborhood](t)),search:t=>e.request(e=>e[M.codeGraphSearch](t))},workspace:{environmentPreflight:t=>e.request(e=>e[M.workspaceEnvironmentPreflight](t)),ensureScratch:t=>e.request(e=>e[M.workspaceEnsureScratch](t))},shell:{openInEditor:t=>e.request(e=>e[M.shellOpenInEditor](t))},git:{pull:t=>e.request(e=>e[M.gitPull](t)),refreshStatus:t=>e.request(e=>e[M.gitRefreshStatus](t)),onStatus:(t,n,r)=>{let i=null;return e.subscribe(e=>e[M.subscribeGitStatus](t),e=>{i=d$e(i,e),n(i)},r)},runStackedAction:async(t,n)=>{let r=null;if(await e.requestStream(e=>e[M.gitRunStackedAction](t),e=>{n?.onProgress?.(e),e.kind===`action_finished`&&(r=e.result)}),r)return r;throw Error(`Git action stream completed without a final result.`)},listBranches:t=>e.request(e=>e[M.gitListBranches](t)),createWorktree:t=>e.request(e=>e[M.gitCreateWorktree](t)),removeWorktree:t=>e.request(e=>e[M.gitRemoveWorktree](t)),createBranch:t=>e.request(e=>e[M.gitCreateBranch](t)),checkout:t=>e.request(e=>e[M.gitCheckout](t)),init:t=>e.request(e=>e[M.gitInit](t)),resolvePullRequest:t=>e.request(e=>e[M.gitResolvePullRequest](t)),preparePullRequestThread:t=>e.request(e=>e[M.gitPreparePullRequestThread](t))},pullRequests:{list:t=>e.request(e=>e[M.pullRequestsList](t)),listStats:t=>e.request(e=>e[M.pullRequestsListStats](t)),detail:t=>e.request(e=>e[M.pullRequestsDetail](t)),activity:t=>e.request(e=>e[M.pullRequestsActivity](t)),threadComments:t=>e.request(e=>e[M.pullRequestsThreadComments](t)),diffFileContents:t=>e.request(e=>e[M.pullRequestsDiffFileContents](t)),runAction:t=>e.request(e=>e[M.pullRequestsRunAction](t)),update:t=>e.request(e=>e[M.pullRequestsUpdate](t)),comment:t=>e.request(e=>e[M.pullRequestsComment](t)),updateComment:t=>e.request(e=>e[M.pullRequestsUpdateComment](t)),submitReview:t=>e.request(e=>e[M.pullRequestsSubmitReview](t)),replyToThread:t=>e.request(e=>e[M.pullRequestsReplyToThread](t)),setThreadResolution:t=>e.request(e=>e[M.pullRequestsSetThreadResolution](t)),setReaction:t=>e.request(e=>e[M.pullRequestsSetReaction](t)),invalidate:t=>e.request(e=>e[M.pullRequestsInvalidate](t)),reviewerCandidates:t=>e.request(e=>e[M.pullRequestsReviewerCandidates](t)),requestReviewers:t=>e.request(e=>e[M.pullRequestsRequestReviewers](t))},server:{getConfig:()=>e.request(e=>e[M.serverGetConfig]({})),refreshProviders:()=>e.request(e=>e[M.serverRefreshProviders]({})),startProviderAuth:t=>e.request(e=>e[M.serverStartProviderAuth](t)),repairProviderAuthRuntime:t=>e.request(e=>e[M.serverRepairProviderAuthRuntime](t)),disconnectProviderAuth:t=>e.request(e=>e[M.serverDisconnectProviderAuth](t)),getProviderAuthSession:t=>e.request(e=>e[M.serverGetProviderAuthSession](t)),cancelProviderAuth:t=>e.request(e=>e[M.serverCancelProviderAuth](t)),submitProviderAuthCode:t=>e.request(e=>e[M.serverSubmitProviderAuthCode](t)),syncPersonalCodexToCloud:t=>e.request(e=>e[M.serverSyncPersonalCodexToCloud](t)),syncPersonalClaudeToCloud:t=>e.request(e=>e[M.serverSyncPersonalClaudeToCloud](t)),upsertKeybinding:t=>e.request(e=>e[M.serverUpsertKeybinding](t)),removeKeybinding:t=>e.request(e=>e[M.serverRemoveKeybinding](t)),getSettings:()=>e.request(e=>e[M.serverGetSettings]({})),updateSettings:t=>e.request(e=>e[M.serverUpdateSettings]({patch:t})),updateEnvironmentDisplayName:t=>e.request(e=>e[M.serverUpdateEnvironmentDisplayName](t)),getTraceDiagnostics:t=>e.request(e=>e[M.serverGetTraceDiagnostics](t)),subscribeConfig:(t,n)=>e.subscribe(e=>e[M.subscribeServerConfig]({}),t,n),subscribeLifecycle:(t,n)=>e.subscribe(e=>e[M.subscribeServerLifecycle]({}),t,n),subscribeAuthAccess:(t,n)=>e.subscribe(e=>e[M.subscribeAuthAccess]({}),t,n),subscribeWorkspaceReadiness:(t,n)=>e.subscribe(e=>e[M.subscribeWorkspaceReadiness]({}),t,n)},usage:{getSummary:t=>e.request(e=>e[M.usageGetSummary](t),{timeout:v$e})},orchestration:{dispatchCommand:t=>x$e(e,t),getTurnDiff:(t,n)=>p$(e,e=>e[sn.streamTurnDiff](t),n).then(e=>({...t,diff:new TextDecoder().decode(e)})),getFullThreadDiff:(t,n)=>p$(e,e=>e[sn.streamFullThreadDiff](t),n).then(e=>({...t,fromTurnCount:0,diff:new TextDecoder().decode(e)})),subscribeShell:(t,n)=>e.subscribe(e=>e[sn.subscribeShell]({}),t,n),subscribeThread:(t,n,r)=>e.subscribe(e=>e[sn.subscribeThread](t),n,r)}}}var k$e=new Set([`CMMD_AUTH_REQUIRED`,`CMMD_AUTH_EXPIRED`,`INVALID_OR_NON_USER_TOKEN`,`NON_USER_BEARER`,`CMMD_REST_AUTH_ERROR`]);function h$(e){if(!e||typeof e!=`object`)return null;let t=e.code;return typeof t!=`string`||!k$e.has(t)?null:t}function g$(e,t){return e===401||e===403||h$(t)!==null}function A$e(e){if(!e||typeof e!=`object`)return!1;let t=e.status,n=e.code;return g$(typeof t==`number`?t:void 0,typeof n==`string`?{code:n}:void 0)}function j$e(e){return new Promise(t=>globalThis.setTimeout(t,e))}function _$(){let e=Error(`The environment connection attempt was cancelled.`);return e.name=`AbortError`,e}function v$(e){if(e?.aborted)throw _$()}function M$e(e,t){return t?t.aborted?Promise.reject(_$()):new Promise((n,r)=>{let i=()=>r(_$());t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>{t.removeEventListener(`abort`,i)})}):e}function N$e(e,t){return t?t.aborted?Promise.reject(_$()):new Promise((n,r)=>{let i=globalThis.setTimeout(()=>{t.removeEventListener(`abort`,a),n()},e),a=()=>{globalThis.clearTimeout(i),r(_$())};t.addEventListener(`abort`,a,{once:!0})}):j$e(e)}var y$=`forge.deviceRegistry.deviceKey`,b$=`forge.deviceRegistry.runtimeId`;function P$e(e){let t=C$(y$,e.desktopIdentity?.deviceKey,`device`),n=C$(b$,e.desktopIdentity?.runtimeId,`runtime`),r=S$(e.desktopIdentity?.hostKey),i=R$e(),a=e.desktopAvailable?`desktop`:z$e(),o=e.desktopAvailable?L$e(e.desktopIdentity)??B$e(i):V$e(i);return{device:{...r?{hostKey:r}:{},deviceKey:t,displayName:o,platform:i,deviceType:a,metadata:{clientKind:e.desktopAvailable?`forge-desktop`:`forge-web`,userAgent:window.navigator.userAgent,origin:window.location.origin,...e.desktopIdentity?{desktopIdentity:{hostName:e.desktopIdentity.hostName,computerName:e.desktopIdentity.computerName,platform:e.desktopIdentity.platform}}:{}}},...e.desktopAvailable&&e.includeExecutableRuntime!==!1?{runtime:{runtimeId:n,runtimeKind:`desktop-local`,displayName:`Local Forge Desktop`,endpointUrl:e.desktopEndpointUrl??null,status:`online`,metadata:{origin:window.location.origin}}}:{}}}async function x$(){let e=await window.desktopBridge?.getDeviceIdentity?.()??null;return P$e({desktopAvailable:!!window.desktopBridge,desktopIdentity:e,includeExecutableRuntime:!1})}function S$(e){let t=e?.trim()??``;return t.length>0?t:null}function C$(e,t,n){let r=S$(t);return r?(yJ(e,r),r):I$e(e,n)}function F$e(){return vJ(b$)}function w$(){return vJ(y$)}function I$e(e,t){let n=vJ(e);if(n)return n;let r=`${t}_${crypto.randomUUID()}`;return yJ(e,r),r}function L$e(e){let t=e?.displayName?.trim()??``;return t.length>0?t:null}function R$e(){let e=window.navigator.userAgent.toLowerCase();return e.includes(`iphone`)||e.includes(`ipad`)?`ios`:e.includes(`android`)?`android`:e.includes(`mac`)?`macos`:e.includes(`win`)?`windows`:e.includes(`linux`)?`linux`:`unknown`}function z$e(){let e=window.navigator.userAgent.toLowerCase();return e.includes(`ipad`)||e.includes(`tablet`)?`tablet`:e.includes(`mobi`)||e.includes(`iphone`)||e.includes(`android`)?`mobile`:`browser`}function B$e(e){return e===`macos`?`Mac`:e===`windows`?`Windows PC`:e===`linux`?`Linux Desktop`:`Desktop`}function V$e(e){return e===`web`?`Browser`:e===`macos`?`Mac Browser`:e===`windows`?`Windows Browser`:e===`linux`?`Linux Browser`:`Browser`}var T$=class extends Error{code;constructor(e,t){super(t),this.name=`RelayControlRouteError`,this.code=e}};function E$(e){let t=e&&typeof e==`object`?e.code:null;throw t===`PROTOCOL_INCOMPATIBLE`?new T$(`FORGE_RUNTIME_UPDATE_REQUIRED`,`Update Forge on the target runtime before connecting remotely.`):t===`PROTOCOL_ROLLOUT_DENIED`?new T$(`FORGE_REMOTE_CONTROL_NOT_ENABLED`,`Remote control is not enabled for this CMMD account. Synced runtime inventory remains available.`):e}async function H$e(e){let t=e.getStoredDeviceKey(),n=t?await e.apiClient.getDeviceRegistry():await e.apiClient.registerDevice(await e.buildDeviceRegistration());return t&&!n.devices.some(e=>e.deviceKey===t)&&(n=await e.apiClient.registerDevice(await e.buildDeviceRegistration())),t??=e.getStoredDeviceKey(),{deviceKey:t,registry:n}}function U$e(e){if(!e.deviceKey)throw new T$(`FORGE_CONTROL_DEVICE_UNAUTHORIZED`,`This Forge control surface could not establish CMMD identity.`);let t=e.registry.devices.find(t=>t.deviceKey===e.deviceKey);if(t?.trustState===`revoked`||t?.authorization?.revoked===!0)throw new T$(`FORGE_CONTROL_DEVICE_REVOKED`,`This Forge control surface was revoked by CMMD.`);if(!t||t.trustState!==`trusted`)throw new T$(`FORGE_CONTROL_DEVICE_UNAUTHORIZED`,`This Forge control surface is not trusted by CMMD.`);return t}function W$e(e,t){let n=async()=>U$e(await H$e(t));return{acquireRoute:async()=>{let r=await n(),i=await lce();try{return dce({route:await t.apiClient.issueRelayControlRoute(e,{controlDeviceId:r.id,controlSessionId:t.controlSessionId,scopes:[...qn],protocolMinVersion:4,protocolMaxVersion:4,...uce(i)}),runtimeId:e,endpoint:i})}catch(e){if(e instanceof gl)throw new T$(`FORGE_RUNTIME_UPDATE_REQUIRED`,e.message);return E$(e)}},acquireActionGrant:async r=>{let i=await n();try{return(await t.apiClient.issueRelayActionGrant(e,{controlDeviceId:i.id,controlSessionId:t.controlSessionId,...r})).token}catch(e){return E$(e)}}}}var D$=`forge.relayControlJournal.v1`;function O$(){if(globalThis.localStorage===void 0)throw Error(`Forge relay control recovery requires durable browser storage.`);return globalThis.localStorage}var G$e={read:()=>O$().getItem(D$),write:e=>O$().setItem(D$,e)},k$=null,A$=Wt()(e=>({byRuntimeId:{},replace:t=>e({byRuntimeId:t})}));function K$e(e){e.subscribe(e=>{let t=new Set(e.records.map(e=>e.runtimeId));A$.getState().replace(Object.fromEntries([...t].map(t=>[t,Rse(e.records,t)])))})}function j$(){return k$===null&&(k$=zc({storage:G$e}),K$e(k$)),k$}function q$e(){let e=(0,Cl.c)(1),t=A$(Y$e),n;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],e[0]=n):n=e[0],(0,F.useEffect)(J$e,n),t}function J$e(){j$()}function Y$e(e){return e.byRuntimeId}function X$e(e){let t=j$();for(let n of t.records())n.runtimeId===e&&(n.status===`failed`||n.status===`outcome-unknown`)&&t.acknowledge(n.runtimeId,n.actorSessionId,n.transportRequestId)}var Z$e=6e4;function Q$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 M$=`CMMD returned an invalid Cloud runtime connection descriptor.`;function N$(e,t){let n=e[t];if(typeof n!=`string`||n.length===0)throw Error(M$);return n}function $$e(e){if(!e||typeof e!=`object`)throw Error(M$);let t=e;return{httpBaseUrl:N$(t,`httpBaseUrl`),wsBaseUrl:N$(t,`wsBaseUrl`),bearerToken:N$(t,`bearerToken`),expiresAt:N$(t,`expiresAt`)}}async function e1e(e){let t=await fetch(lr(`/api/cmmd/forge-runtimes/${encodeURIComponent(e.runtimeId)}/connect`),rr({method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e.organizationId===void 0?{}:{organizationId:e.organizationId})})),n=await t.json().catch(()=>null);if(!t.ok){let e=g$(t.status,n)?`CMMD authentication expired while renewing the Cloud runtime connection. Sign in again.`:`CMMD could not renew the Cloud runtime connection (${t.status}).`;throw Object.assign(Error(Q$e(n,e)),{status:t.status,...h$(n)?{code:h$(n)}:{}})}return $$e(n)}function t1e(e,t){if(!e?.expiresAt)return!0;let n=Date.parse(e.expiresAt);return!Number.isFinite(n)||n<=t+Z$e}function P$(e){let t=e.requestDescriptor??e1e,n=e.now??Date.now,r=e.initialDescriptor??null,i=null,a=!1,o=()=>i||(i=t({runtimeId:e.runtimeId,...e.organizationId===void 0?{}:{organizationId:e.organizationId}}).then(async t=>(await e.validateDescriptor?.(t),await e.persistDescriptor?.(t),r=t,a=!1,t)).then(e=>(i=null,e),e=>{throw i=null,e}),i);return{acquire:e=>e?.forceRefresh||a||t1e(r,n())?o():Promise.resolve(r),invalidate:()=>{a=!0}}}var n1e=12e4,r1e=3e4,F$=3e4;function I$(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 i1e(e){if(!e||typeof e!=`object`)return!1;let t=e.status;return t===401||t===403}function a1e(e){let t=e.now??Date.now,n=e.renewalSkewMs??n1e,r=!1,i=null,a=null,o=I$(e.initialDescriptor),s=()=>{i!==null&&(globalThis.clearTimeout(i),i=null)},c=a=>{if(r)return;s();let c=I$(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()+F$;return e>=o?null:(i=globalThis.setTimeout(()=>{i=null,u().catch(()=>void 0)},F$),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=I$(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=i1e(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()+r1e?Promise.resolve():u(),renewNow:u,dispose:()=>{r=!0,s()}}}var L$=new Map,R$=new Map,z$=new Map,B$=new Map,V$=new Map,H$=new Set,U$=new Map,W$=null,G$=!1;function K$(e){return B$.get(e)??0}function q$(e){B$.set(e,K$(e)+1)}function J$(e,t){return e.environmentId===t.environmentId&&e.httpBaseUrl===t.httpBaseUrl&&e.wsBaseUrl===t.wsBaseUrl&&e.runtimeId===t.runtimeId&&e.cmmdOrganizationId===t.cmmdOrganizationId}function Y$(e){if(K$(e.record.environmentId)!==e.generation)return!1;let t=mX(e.record.environmentId);return e.registryExpectation.kind===`initial-add`?t===null||J$(t,e.record):t!==null&&J$(t,e.registryExpectation.record)}var o1e=9e5,X$=32,Z$=()=>void 0;function Q$(e,t){return Vo(Lo(e,t))}function $$(e){return e.evictionTimeoutId!==null&&(clearTimeout(e.evictionTimeoutId),e.evictionTimeoutId=null),e}function s1e(e){let t=Lo(e.environmentId,e.threadId),n=yZ.getState(),r=vZ(n,t);if(r){if(r.hasPendingApprovals||r.hasPendingUserInput||r.hasActionableProposedPlan)return!0;let e=r.session?.orchestrationStatus;if(e&&e!==`idle`&&e!==`stopped`||r.latestTurn?.state===`running`)return!0}let i=_Z(n,t);if(!i)return!1;let a=i.session?.orchestrationStatus;return!!(a&&a!==`idle`&&a!==`stopped`)||i.latestTurn?.state===`running`||i.pendingSourceProposedPlan!==void 0}function e1(e){return e.refCount===0&&!s1e(e)}function t1(e){if(e.unsubscribeConnectionListener!==null&&(e.unsubscribeConnectionListener(),e.unsubscribeConnectionListener=null),e.unsubscribe!==Z$)return!0;let t=j1(e.environmentId);return t?(e.unsubscribe=t.client.orchestration.subscribeThread({threadId:e.threadId},t=>{if(e.lastEventAt=Date.now(),e.recoveryAttempts=0,t.kind===`snapshot`){yZ.getState().syncServerThreadDetail(t.snapshot.thread,e.environmentId),yZ.getState().clearThreadSubscriptionError(e.environmentId,e.threadId);return}j1e(t.event,e.environmentId)},{onError:t=>cXe(e.environmentId,e.threadId,t)}),!0):!1}function n1(e){e.unsubscribeConnectionListener===null&&(e.unsubscribeConnectionListener=A1(()=>{t1(e)&&(e.lastAccessedAt=Date.now())}),t1(e))}function r1(e){let t=U$.get(e);return t?($$(t),t.unsubscribeConnectionListener?.(),t.unsubscribeConnectionListener=null,U$.delete(e),t.unsubscribe(),t.unsubscribe=Z$,p1e(),!0):!1}var i1=null;function c1e(e){let t=Lo(e.environmentId,e.threadId),n=yZ.getState(),r=vZ(n,t);if(r?.latestTurn?.state===`running`||r?.session?.orchestrationStatus===`running`)return!0;let i=_Z(n,t);return i?.latestTurn?.state===`running`||i?.session?.orchestrationStatus===`running`}function l1e(e){e.unsubscribe!==Z$&&(e.unsubscribe(),e.unsubscribe=Z$),t1(e)||n1(e)}function u1e(e,t,n){if(e.recoveryAttempts+=1,e.lastEventAt=Date.now(),console.warn(`[forge] thread-detail liveness watchdog recovering`,{action:t,threadId:String(e.threadId),environmentId:String(e.environmentId),msSinceLastEvent:Math.round(n),recoveryAttempts:e.recoveryAttempts}),t===`resubscribe`){l1e(e);return}j1(e.environmentId)?.reconnect().catch(t=>{zK(t,{route:`thread-detail-liveness-watchdog-reconnect-failed`,threadId:String(e.threadId),environmentId:String(e.environmentId),msSinceLastEvent:String(Math.round(n)),recoveryAttempts:String(e.recoveryAttempts)})})}function d1e(){let e=Date.now();for(let t of U$.values()){let n=EXe({isWorking:c1e(t),msSinceLastEvent:e-t.lastEventAt,stallThresholdMs:DXe,recoveryAttempts:t.recoveryAttempts,maxResubscribeAttempts:2,maxTotalAttempts:4});n!==`none`&&u1e(t,n,e-t.lastEventAt)}}function f1e(){i1===null&&(i1=setInterval(d1e,OXe))}function p1e(){U$.size>0||i1!==null&&(clearInterval(i1),i1=null)}function m1e(e){for(let[t,n]of U$)n.environmentId===e&&r1(t)}function h1e(e){let t=Lo(e.environmentId,e.threadId),n=yZ.getState(),r=_Z(n,t);if(!r)return null;let i=vZ(n,t),a=i?.latestUserMessageAt??null;if(a===null)for(let e=r.messages.length-1;e>=0;--e){let t=r.messages[e];if(t?.role===`user`){a=t.createdAt;break}}return{id:r.id,projectId:r.projectId,title:r.title,modelSelection:r.modelSelection,runtimeMode:r.runtimeMode,interactionMode:r.interactionMode,branch:r.branch,worktreePath:r.worktreePath,latestTurn:r.latestTurn,createdAt:r.createdAt,updatedAt:r.updatedAt??r.createdAt,archivedAt:r.archivedAt,session:r.session?{threadId:r.id,updatedAt:r.session.updatedAt,providerName:r.session.provider,runtimeMode:r.runtimeMode,activeTurnId:r.session.activeTurnId??null,lastError:r.session.lastError??null,status:r.session.orchestrationStatus}:null,latestUserMessageAt:a,hasPendingApprovals:i?.hasPendingApprovals??!1,hasPendingUserInput:i?.hasPendingUserInput??!1,hasActionableProposedPlan:i?.hasActionableProposedPlan??!1,anchorKind:r.anchorKind,anchorCmmdId:r.anchorCmmdId,kind:r.kind,parentThreadId:r.parentThreadId,status:r.status,workerRole:r.workerRole,goal:r.goal,titleRegeneration:r.titleRegeneration??null}}function g1e(e,t){if(U$.size===0)return e;let n=new Set(e.threads.map(e=>e.id)),r=[];for(let e of U$.values()){if(e.environmentId!==t||e.refCount<=0||n.has(e.threadId))continue;let i=h1e(e);i&&(n.add(i.id),r.push(i))}return r.length===0?e:{...e,threads:[...e.threads,...r]}}function _1e(e,t){let n=new Set(t);for(let[t,r]of U$)r.environmentId===e&&!n.has(r.threadId)&&e1(r)&&r1(t)}function v1e(e){$$(e),e1(e)&&(e.evictionTimeoutId=setTimeout(()=>{let t=U$.get(Q$(e.environmentId,e.threadId));t&&(t.evictionTimeoutId=null,e1(t)&&r1(Q$(e.environmentId,e.threadId)))},o1e))}function a1(){if(U$.size<=X$)return;let e=[...U$.entries()].filter(([,e])=>e1(e)).toSorted(([,e],[,t])=>e.lastAccessedAt-t.lastAccessedAt);for(let[t]of e){if(U$.size<=X$)return;r1(t)}}function o1(e){$$(e),e1(e)&&v1e(e)}function y1e(e,t){let n=U$.get(Q$(e,t));n&&o1(n)}function s1(e){for(let t of U$.values())t.environmentId===e&&o1(t);a1()}function b1e(e,t){let n=Q$(e,t),r=U$.get(n);if(r){$$(r),r.refCount+=1,r.lastAccessedAt=Date.now(),t1(r)||n1(r);let e=!1;return()=>{e||(e=!0,r.refCount=Math.max(0,r.refCount-1),r.lastAccessedAt=Date.now(),r.refCount===0&&(o1(r),a1()))}}let i={environmentId:e,threadId:t,unsubscribe:Z$,unsubscribeConnectionListener:null,refCount:1,lastAccessedAt:Date.now(),evictionTimeoutId:null,lastEventAt:Date.now(),recoveryAttempts:0};U$.set(n,i),t1(i)||n1(i),f1e(),a1();let a=!1;return()=>{a||(a=!0,i.refCount=Math.max(0,i.refCount-1),i.lastAccessedAt=Date.now(),i.refCount===0&&(o1(i),a1()))}}function c1(){for(let e of H$)e()}function x1e(e){return{lastError:e instanceof Error?e.message:String(e),lastErrorAt:new Date().toISOString()}}function l1(){return new Date().toISOString()}var u1=8,d1=[1e3,2e3,4e3,8e3,12e3,16e3,2e4],S1e=9e4;function C1e(e){if(typeof e!=`object`||!e)return null;let t=e.status;return typeof t==`number`&&Number.isInteger(t)?t:null}function w1e(e){if(A$e(e))return!1;let t=C1e(e);if(t===502||t===503||t===504||e._tag===`OrchestrationGetSnapshotError`)return!0;let n=e instanceof Error?e.message:String(e),r=n.toLowerCase();return r.includes(`all fibers interrupted without error`)||r.includes(`timed out while waiting for forge cloud runtime metadata`)||r.includes(`timed out while waiting for`)||r.includes(`to stream its shell snapshot`)||r.includes(`forge runtime route not found`)||r.includes(`fly-replay`)||r.includes(`could not find a good candidate`)||r.includes(`instance refused connection`)||n.includes(`Unknown socket error`)||n.includes(`Failed to fetch remote auth endpoint`)||n.includes(`Forge runtime replay target is unavailable`)||n.includes(`Remote auth request failed (502)`)||n.includes(`Remote auth request failed (503)`)||n.includes(`Remote auth request failed (504)`)||n.includes(`Unable to connect to the Forge server WebSocket`)}function T1e(e){return d1[e]??d1[d1.length-1]}function E1e(){return S1e}function D1e(e,t){if(!HY(e))return t;let n=null,r=new Promise((t,r)=>{n=globalThis.setTimeout(()=>{r(Error(`Timed out while waiting for Forge Cloud runtime metadata for ${e}. The VM may still be starting.`))},E1e())});return Promise.race([t,r]).finally(()=>{n!==null&&globalThis.clearTimeout(n)})}function f1(e){bX.getState().patch(e,{connectionState:`connecting`,lastError:null,lastErrorAt:null})}function p1(e){let t=l1();bX.getState().patch(e,{connectionState:`connected`,authState:`authenticated`,connectedAt:t,disconnectedAt:null,lastError:null,lastErrorAt:null}),uX.getState().markConnected(e,t)}function m1(e,t){bX.getState().patch(e,{descriptor:t.environment,serverConfig:t})}function h1(e,t){bX.getState().patch(e,{connectionState:`disconnected`,disconnectedAt:l1(),...t&&t.trim().length>0?{lastError:t,lastErrorAt:l1()}:{}})}function g1(e,t){bX.getState().patch(e,{connectionState:`error`,...x1e(t)})}function O1e(e){if(e.length<2)return[...e];let t=[];for(let n of e){let e=t.at(-1);if(e?.type===`thread.message-sent`&&n.type===`thread.message-sent`&&e.payload.threadId===n.payload.threadId&&e.payload.messageId===n.payload.messageId){t[t.length-1]={...n,payload:{...n.payload,attachments:n.payload.attachments??e.payload.attachments,createdAt:e.payload.createdAt,text:!n.payload.streaming&&n.payload.text.length>0?n.payload.text:e.payload.text+n.payload.text}};continue}t.push(n)}return t}function _1(){let e=fZ(yZ.getState());PQ.getState().syncProjects(e.map(e=>({key:Bo(Io(e.environmentId,e.id)),cwd:e.cwd})))}function v1(){let e=pZ(yZ.getState());PQ.getState().syncThreads(e.map(e=>({key:Vo(Lo(e.environmentId,e.id)),seedVisitedAt:e.updatedAt??e.createdAt}))),OJe(e.map(e=>Lo(e.environmentId,e.id)))}function k1e(){_1(),v1();let e=lXe({snapshotThreads:pZ(yZ.getState()).map(e=>({key:Vo(Lo(e.environmentId,e.id)),deletedAt:null,archivedAt:e.archivedAt})),draftThreadKeys:RY.getState().listDraftThreadKeys()});fQ.getState().removeOrphanedTerminalStates(e)}function y1(e){return e.serverThreadArchivedAt===void 0?e.hasDraftThread:e.serverThreadArchivedAt===null}function A1e(e,t){if(e.length===0)return;let n=uXe(e),r=O1e(e),i=e.some(e=>e.type===`project.created`||e.type===`project.meta-updated`||e.type===`project.deleted`);if(n.needsProviderInvalidation&&(G$=!0,W$?.queryInvalidationThrottler.maybeExecute()),yZ.getState().applyOrchestrationEvents(r,t),i){let e=fZ(yZ.getState());PQ.getState().syncProjects(e.map(e=>({key:Bo(Io(e.environmentId,e.id)),cwd:e.cwd})))}if(e.some(e=>e.type===`thread.created`||e.type===`thread.deleted`)){let e=pZ(yZ.getState());PQ.getState().syncThreads(e.map(e=>({key:Vo(Lo(e.environmentId,e.id)),seedVisitedAt:e.updatedAt??e.createdAt})))}let a=RY.getState();for(let e of n.promoteDraftThreadIds)zY(Lo(t,e));for(let e of n.clearDeletedThreadIds)a.clearDraftThread(Lo(t,e)),PQ.getState().clearThreadUi(Vo(Lo(t,e)));for(let e of n.removeTerminalStateThreadIds){let n=Lo(t,e);fQ.getState().removeTerminalState(n),yQ.getState().clearBrowserState(n)}s1(t)}function j1e(e,t){A1e([e],t)}function M1e(e,t){let n=e.kind===`thread-upserted`?e.thread.id:e.kind===`thread-removed`?e.threadId:null,r=n?Lo(t,n):null,i=r?_Z(yZ.getState(),r):void 0;switch(yZ.getState().applyShellEvent(e,t),e.kind){case`project-upserted`:case`project-removed`:_1();return;case`thread-upserted`:v1(),!i&&r&&zY(r),i?.archivedAt===null&&e.thread.archivedAt!==null&&r&&(fQ.getState().removeTerminalState(r),yQ.getState().clearBrowserState(r)),y1e(t,e.thread.id),a1();return;case`thread-removed`:r&&(r1(Vo(r)),RY.getState().clearDraftThread(r),PQ.getState().clearThreadUi(Vo(r)),fQ.getState().removeTerminalState(r),yQ.getState().clearBrowserState(r)),v1();return}}function N1e(e,t){return e.invalidateQueries({queryKey:CZ.all(t)})}function b1(e){return{onWelcome:(t,n)=>{e?.(t),W$&&N1e(W$.queryClient,n)},applyShellEvent:M1e,syncShellSnapshot:(e,t)=>{let n=g1e(e,t);yZ.getState().syncServerShellSnapshot(n,t),_1e(t,n.threads.map(e=>e.id)),s1(t),k1e()},applyTerminalEvent:(e,t)=>{let n=Lo(t,nn.make(e.threadId)),r=_Z(yZ.getState(),n),i=RY.getState().getDraftThreadByRef(n)!==null;y1({serverThreadArchivedAt:r?.archivedAt,hasDraftThread:i})&&fQ.getState().applyTerminalEvent(n,e)},applyBrowserEvent:(e,t)=>{let n=Lo(t,nn.make(e.threadId)),r=_Z(yZ.getState(),n),i=RY.getState().getDraftThreadByRef(n)!==null;y1({serverThreadArchivedAt:r?.archivedAt,hasDraftThread:i})&&yQ.getState().applyBrowserEvent(n,e)},onShellSubscriptionError:(e,t)=>{g1(t,e)}}}function x1(){if(typeof window>`u`)return;let e=nr();if(e?.primaryMode===`cloud`&&e.bearerToken)return{bearerToken:e.bearerToken,httpBaseUrl:e.httpBaseUrl,wsBaseUrl:e.wsBaseUrl}}function P1e(){if(typeof window>`u`)return;let e=nr(),t=e?.primaryMode===`cloud`?e.desktopLocal??null:e??null;if(!(!t?.httpBaseUrl||!t.wsBaseUrl||!t.bearerToken))return{bearerToken:t.bearerToken,httpBaseUrl:t.httpBaseUrl,wsBaseUrl:t.wsBaseUrl,label:t.label}}function F1e(e){let t=qie(e);if(!t)throw Error(`Unable to resolve websocket URL for ${e?.label??`primary environment`}.`);return m$(new o$(async()=>{await cr().catch(()=>null);let e=x1();if(e)try{return await EZ({wsBaseUrl:e.wsBaseUrl,httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken})}catch(e){throw cq(e)&&dr(`ws-token`),e}return OGe(t)}))}function I1e(e){return m$(new o$(()=>EZ({wsBaseUrl:e.wsBaseUrl,httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken}),{trackGlobalConnection:!1,onAttempt:()=>{f1(e.environmentId)},onOpen:()=>{p1(e.environmentId)},onError:t=>{bX.getState().patch(e.environmentId,{connectionState:`error`,lastError:t,lastErrorAt:l1()})},onClose:t=>{h1(e.environmentId,t.reason)}}))}function S1(e){let t=e.toLowerCase();return t.includes(`authentication`)||t.includes(`unauthorized`)||t.includes(`forbidden`)||t.includes(`credential`)||t.includes(`runtime ticket`)||t.includes(`status 401`)||t.includes(`status 403`)}function L1e(e){let t=e.runtimeId?.trim();if(t)return t;let n=UY(e.environmentId);if(!n)throw Error(`Saved Cloud environment ${e.environmentId} is missing its runtime id.`);return n}function R1e(e,t,n){let r=e;return P$({runtimeId:L1e(e),...e.cmmdOrganizationId===void 0?{}:{organizationId:e.cmmdOrganizationId},...t===void 0?{}:{initialDescriptor:{httpBaseUrl:e.httpBaseUrl,wsBaseUrl:e.wsBaseUrl,bearerToken:t,expiresAt:e.runtimeTicketExpiresAt??null}},validateDescriptor:async e=>{await TZ({httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken})},persistDescriptor:async e=>{if(n&&!n())throw Error(`Saved environment changed while its connection was being acquired.`);let t={...F1(r),httpBaseUrl:e.httpBaseUrl,wsBaseUrl:Wn(e.wsBaseUrl),...e.expiresAt===null?{}:{runtimeTicketExpiresAt:e.expiresAt},lastConnectedAt:l1()};await gX(t),await vX(t.environmentId),uX.getState().upsert(t),r=t}})}function z1e(e){let t={wsBaseUrl:e.record.wsBaseUrl,httpBaseUrl:e.record.httpBaseUrl,bearerToken:e.bearerToken,expiresAt:e.record.runtimeTicketExpiresAt??null};return{acquire:()=>Promise.resolve(t)}}function B1e(e,t,n){return n()&&bX.getState().ensure(e.environmentId),m$(new o$(async()=>{let n=await t.acquire(),r=t=>EZ({wsBaseUrl:t.wsBaseUrl,httpBaseUrl:t.httpBaseUrl,bearerToken:t.bearerToken,...HY(e.environmentId)?{runtimeTicket:t.bearerToken}:{}});try{return await r(n)}catch(n){if(!HY(e.environmentId)||!cq(n))throw n;return r(await t.acquire({forceRefresh:!0}))}},{trackGlobalConnection:!1,onAttempt:()=>{n()&&f1(e.environmentId)},onOpen:()=>{n()&&p1(e.environmentId)},onError:r=>{HY(e.environmentId)&&S1(r)&&t.invalidate?.(),n()&&bX.getState().patch(e.environmentId,{connectionState:`error`,lastError:r,lastErrorAt:l1()})},onClose:r=>{HY(e.environmentId)&&(r.code===1008||S1(r.reason))&&t.invalidate?.(),n()&&h1(e.environmentId,r.reason)}}))}async function C1(e,t,n,r,i,a,o){let s=await t.acquire(),[c,l]=await Promise.all([a?Promise.resolve(a):n.server.getConfig(),TZ({httpBaseUrl:s.httpBaseUrl,bearerToken:s.bearerToken,...o?{signal:o}:{}})]);if(!r())return!1;bX.getState().patch(e.environmentId,{authState:l.authenticated?`authenticated`:`requires-auth`,descriptor:c.environment,serverConfig:c,role:l.authenticated?l.role??i??null:null});let u=mX(e.environmentId);return r()&&l.authenticated&&u&&uX.getState().upsert({...u,lastAuthenticatedPullRequestCapability:c.environment.capabilities?.pullRequests===!0}),!0}function w1(e){let t=L$.get(e.environmentId);if(t&&t!==e)throw Error(`Environment ${e.environmentId} already has an active connection.`);return L$.set(e.environmentId,e),c1(),e}async function T1(e){let t=L$.get(e);return t?(L$.delete(e),m1e(e),c1(),await t.dispose(),!0):!1}function E1(){let e=Fq();if(!e?.environmentId)throw Error(`Unable to resolve the primary environment.`);let t=L$.get(e.environmentId);if(t)return t;let n=x1(),r=e.source===`paired-bearer`||!0;return w1(DZ({kind:`primary`,knownEnvironment:e,client:F1e(e),resolveEnvironmentId:()=>Fq()?.environmentId??e.environmentId,...r?{readiness:n?{bearerToken:n.bearerToken}:{}}:{},...b1()}))}async function V1e(e,t,n){let r=L$.get(e.environmentId);if(r)return r;let i=HY(e.environmentId),a=()=>Y$({record:e,generation:t,registryExpectation:n?.registryExpectation??{kind:`existing-record`,record:e}}),o=i?n?.bearerToken:n?.bearerToken??await _X(e.environmentId);if(!i&&!o)throw a()&&bX.getState().patch(e.environmentId,{authState:`requires-auth`,role:null,connectionState:`disconnected`,lastError:`Saved environment is missing its saved credential. Pair it again.`,lastErrorAt:l1()}),Error(`Saved environment is missing its saved credential.`);let s=i?R1e(e,o??void 0,a):z1e({record:e,bearerToken:o}),c=await s.acquire();if(!a())throw Error(`Saved environment changed while its connection was being acquired.`);let l=n?.client??B1e(e,s,a),u=Po({id:e.environmentId,label:e.label,source:`manual`,target:{httpBaseUrl:c.httpBaseUrl,wsBaseUrl:c.wsBaseUrl}}),d=i&&c.expiresAt?a1e({initialDescriptor:{httpBaseUrl:c.httpBaseUrl,wsBaseUrl:c.wsBaseUrl,bearerToken:c.bearerToken,expiresAt:c.expiresAt},renew:async()=>{let e=await s.acquire({forceRefresh:!0});return{httpBaseUrl:e.httpBaseUrl,wsBaseUrl:e.wsBaseUrl,bearerToken:e.bearerToken,expiresAt:e.expiresAt??null}},onState:t=>{a()&&bX.getState().patch(e.environmentId,{providerAuthority:t})}}):null,f=DZ({kind:`saved`,knownEnvironment:{...u,environmentId:e.environmentId},client:l,readiness:{bearerToken:c.bearerToken},tolerateReportedEnvironmentIdentity:i,refreshMetadata:async()=>{await C1(e,s,l,a)},...d?{ensureProviderAuthority:d.ensureLive,onDispose:d.dispose}:{},onConfigSnapshot:t=>{a()&&bX.getState().patch(e.environmentId,{descriptor:t.environment,serverConfig:t})},...b1(t=>{a()&&bX.getState().patch(e.environmentId,{descriptor:t.environment})})});try{if(!await D1e(e.environmentId,C1(e,s,l,a,n?.role??null,n?.serverConfig??null,n?.signal))||!a())throw Error(`Saved environment changed while its connection was being acquired.`);return w1(f)}catch(t){throw a()&&g1(e.environmentId,t),await f.dispose().catch(()=>void 0),t}}async function D1(e,t){let n=L$.get(e.environmentId);if(n)return n;let r=K$(e.environmentId),i=V$.get(e.environmentId);if(i&&i.generation===r&&J$(i.record,e))return i.promise;let a=V1e(e,r,t).finally(()=>{V$.get(e.environmentId)?.promise===a&&V$.delete(e.environmentId)});return V$.set(e.environmentId,{generation:r,record:e,promise:a}),a}async function O1(e){await tX(e);let t=new Map(e.map(e=>[e.environmentId,e]));for(let[e,n]of V$){let r=t.get(e);(!r||!J$(r,n.record))&&q$(e)}let n=new Set(e.map(e=>e.environmentId)),r=[...L$.values()].filter(e=>e.kind===`saved`).map(e=>e.environmentId).filter(e=>!n.has(e));await Promise.all(r.map(async e=>{q$(e),await N1(e)}))}function k1(){W$?.stop(),W$=null}function A1(e){return H$.add(e),()=>{H$.delete(e)}}function j1(e){return L$.get(e)??null}function H1e(e){let t=j1(e);if(!t)throw Error(`No websocket client registered for environment ${e}.`);return t}function M1(){return E1()}async function U1e(){let e=P1e();if(!e)throw Error(`Desktop Local runtime is not authenticated. Sign in with CMMD again before importing local projects.`);let t=await gXe({httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken});return L$.get(t.environmentId)||w1(DZ({kind:`desktop-local`,knownEnvironment:{...Po({id:t.environmentId,label:e.label,source:`desktop-managed`,target:{httpBaseUrl:e.httpBaseUrl,wsBaseUrl:e.wsBaseUrl}}),environmentId:t.environmentId,label:t.label},client:I1e({environmentId:t.environmentId,httpBaseUrl:e.httpBaseUrl,wsBaseUrl:e.wsBaseUrl,bearerToken:e.bearerToken}),...b1()}))}async function W1e(e){let t=en.make(e.runtimeId),n=L$.get(t);if(n)return n;f1(t);let r=j$(),i=W$e(e.runtimeId,{apiClient:aq,getStoredDeviceKey:w$,buildDeviceRegistration:x$,controlSessionId:r.controlSessionId}),a=await i.acquireRoute(),o=a,s=cce({acquireRoute:async()=>{let e=o;return o=null,e??i.acquireRoute()},acquireActionGrant:i.acquireActionGrant,journal:r,lifecycle:{onConnecting:()=>{f1(t)},onAuthenticated:()=>{p1(t)},onDisconnected:e=>{h1(t,e.reason)},onError:e=>{g1(t,Object.assign(Error(e.message),e))}}}),c=m$(new o$(a.relayWebSocketUrl,{trackGlobalConnection:!1},{layer:s,makeClient:sce(qn)})),l=DZ({kind:`saved`,knownEnvironment:{...Po({id:t,label:e.label,source:`manual`,target:{httpBaseUrl:or()?.target.httpBaseUrl??a.relayWebSocketUrl,wsBaseUrl:a.relayWebSocketUrl}}),environmentId:t},client:c,tolerateReportedEnvironmentIdentity:!0,onConfigSnapshot:e=>{m1(t,e)},...b1(e=>{bX.getState().patch(t,{descriptor:e.environment})})});try{let[,e]=await Promise.all([l.ensureBootstrapped(),c.server.getConfig()]);return m1(t,e),p1(t),w1(l)}catch(e){throw g1(t,e),await l.dispose().catch(()=>void 0),e}}function G1e(e){let t=en.make(e.runtimeId),n=L$.get(t);if(n)return Promise.resolve(n);let r=R$.get(t);if(r)return r;let i=W1e(e).finally(()=>{R$.delete(t)});return R$.set(t,i),i}async function N1(e){L$.get(e)?.kind===`saved`&&(bX.getState().clear(e),await T1(e).catch(()=>!1))}function P1(e){for(let t of e){let e=z$.get(t);e===void 0||e<=1?z$.delete(t):z$.set(t,e-1)}}async function K1e(e){let t=e.environmentId;z$.set(t,(z$.get(t)??0)+1);try{return j1(t)||await I1(e),!0}catch{return P1([t]),!1}}async function q1e(){await fX();let e=(await Promise.all(tYe().map(async e=>await K1e(e)?e.environmentId:null))).flatMap(e=>e===null?[]:[e]),t=!1;return()=>{t||(t=!0,P1(e))}}async function J1e(e){q$(e),uX.getState().remove(e),await vX(e),await N1(e)}function F1(e){let t=mX(e.environmentId);if(t?.lastAuthenticatedPullRequestCapability!==void 0)return{...e,lastAuthenticatedPullRequestCapability:t.lastAuthenticatedPullRequestCapability};let n=bX.getState().byId?.[e.environmentId];return n?.authState===`authenticated`&&n.descriptor?{...e,lastAuthenticatedPullRequestCapability:n.descriptor.capabilities.pullRequests===!0}:e}async function Y1e(e){let t=en.make(e.environment.environmentId),n=mX(t),{kind:r,cmmdOrganizationId:i,cmmdProjectId:a,runtimeId:o,runtimeTicketExpiresAt:s}=e.environment,c={environmentId:t,label:e.environment.label,wsBaseUrl:Wn(e.environment.wsBaseUrl),httpBaseUrl:e.environment.httpBaseUrl,createdAt:n?.createdAt??l1(),lastConnectedAt:l1(),...r===void 0?{}:{kind:r},...i===void 0?{}:{cmmdOrganizationId:i},...a===void 0?{}:{cmmdProjectId:a},...o===void 0?{}:{runtimeId:o},...s===void 0?{}:{runtimeTicketExpiresAt:s}};v$(e.signal);let l=pX(),u=n?await _X(c.environmentId):null;q$(c.environmentId),await T1(c.environmentId).catch(()=>!1),await I1(c,{bearerToken:e.bearerToken,registryExpectation:n?{kind:`existing-record`,record:n}:{kind:`initial-add`},...e.signal?{signal:e.signal}:{},...e.onBootstrapRetry?{onBootstrapRetry:e.onBootstrapRetry}:{}});let d=!1;try{return v$(e.signal),await gX(c),d=!0,v$(e.signal),await vX(c.environmentId),v$(e.signal),uX.getState().upsert(F1(c)),c}catch(t){throw await T1(c.environmentId).catch(()=>!1),u&&await rYe(c.environmentId,u),d&&await tX(l),v$(e.signal),t}}async function I1(e,t){if(!HY(e.environmentId))return D1(e,t);let n=K$(e.environmentId),r=()=>Y$({record:e,generation:n,registryExpectation:t?.registryExpectation??{kind:`existing-record`,record:e}}),i=null;for(let n=0;n<u1;n+=1){v$(t?.signal);try{let n=await D1(e,t);return await M$e(n.ensureBootstrapped(),t?.signal),n}catch(a){if(i=a,!r())throw a;if(await T1(e.environmentId).catch(()=>!1),v$(t?.signal),n>=7||!w1e(a))throw r()&&g1(e.environmentId,a),a;let o=T1e(n);t?.onBootstrapRetry?.({attempt:n+2,maxAttempts:u1,retryDelayMs:o,error:a}),r()&&bX.getState().patch(e.environmentId,{connectionState:`connecting`,lastError:null,lastErrorAt:null}),await N$e(o,t?.signal)}}let a=i instanceof Error?i:Error(String(i));throw r()&&g1(e.environmentId,a),a}async function X1e(e){await L$.get(e)?.ensureBootstrapped()}async function Z1e(e){let t=L$.get(e);if(!HY(e)){await t?.ensureProviderAuthority?.();return}if(!t?.ensureProviderAuthority)throw Error(`Cloud runtime provider authority is not available.`);await t.ensureProviderAuthority()}function Q1e(e){if(W$?.queryClient===e)return W$.refCount+=1,()=>{!W$||W$.queryClient!==e||(--W$.refCount,W$.refCount===0&&k1())};k1(),G$=!1;let t=new RKe(()=>{G$&&(G$=!1,e.invalidateQueries({queryKey:SZ.all}),e.invalidateQueries({queryKey:xZ.all}))},{wait:100,leading:!1,trailing:!0});E1(),cr().catch(()=>void 0);let n=uX.subscribe(()=>{dX()&&O1(pX())});return fX().then(()=>O1(pX())).catch(()=>void 0),W$={queryClient:e,queryInvalidationThrottler:t,refCount:1,stop:()=>{n(),t.cancel()}},()=>{!W$||W$.queryClient!==e||(--W$.refCount,W$.refCount===0&&k1())}}function L1(e){if(e===null)return null;let t=e.trim();return t.length>0?t:null}var R1=Object.freeze({data:null,error:null,cause:null,isPending:!1}),z1=Object.freeze({...R1,isPending:!0}),$1e=Ht(R1).pipe(Vt,zt(`git-status:null`)),B1=()=>void 0,V1=new Map,e0e=new Set,H1=new Map,U1=new Map,t0e=1e3,W1=_te(e=>(e0e.add(e),Ht(z1).pipe(Vt,zt(`git-status:${e}`))));function G1(e){return e.environmentId===null||L1(e.cwd)===null?null:`${e.environmentId}:${e.cwd}`}function K1(e){if(e.environmentId===null)return null;let t=j1(e.environmentId);return t?{clientIdentity:t.environmentId,client:t.client.git}:null}function q1(e){let t=G1(e);return t===null?R1:Bt.get(W1(t))}function n0e(e,t){let n=G1(e);if(n===null)return B1;let r=V1.get(n);return r?(r.refCount+=1,()=>J1(n)):(V1.set(n,{refCount:1,unsubscribe:a0e(n,e,t)}),()=>J1(n))}function r0e(e,t){let n=G1(e),r=L1(e.cwd);if(n===null||r===null)return Promise.resolve(null);let i=t??K1(e)?.client;if(!i)return Promise.resolve(q1(e).data);let a=H1.get(n);if(a)return a;let o=U1.get(n)??0;if(Date.now()-o<t0e)return Promise.resolve(q1(e).data);U1.set(n,Date.now());let s=i.refreshStatus({cwd:r}).finally(()=>{H1.delete(n)});return H1.set(n,s),s}function i0e(e){let t=(0,Cl.c)(4),n=G1(e),r,i;t[0]!==e.cwd||t[1]!==e.environmentId?(r=()=>n0e({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,F.useEffect)(r,i);let a=ar(n===null?$1e:W1(n));return n===null?R1:a}function J1(e){let t=V1.get(e);t&&(--t.refCount,!(t.refCount>0)&&(t.unsubscribe(),V1.delete(e)))}function a0e(e,t,n){let r=L1(t.cwd);if(r===null)return B1;let i=null,a=B1,o=()=>{let o=n?{clientIdentity:`provided:${e}`,client:n}:K1(t);if(!o){i!==null&&(a(),a=B1,i=null),Y1(e);return}i!==o.clientIdentity&&(a(),i=o.clientIdentity,a=o0e(e,r,o.client))},s=n?B1:A1(o);return o(),()=>{s(),a()}}function o0e(e,t,n){return Y1(e),n.onStatus({cwd:t},t=>{Bt.set(W1(e),{data:t,error:null,cause:null,isPending:!1})},{onResubscribe:()=>{Y1(e)}})}function Y1(e){let t=W1(e),n=Bt.get(t),r=n.data===null?z1:{...n,error:null,cause:null,isPending:!0};(n.data!==r.data||n.error!==r.error||n.cause!==r.cause||n.isPending!==r.isPending)&&Bt.set(t,r)}function X1(e,t){return Ht(t).pipe(Vt,zt(e))}function Z1(e){return{issues:e.issues,providers:e.providers,settings:e.settings}}var s0e=[],c0e=[],l0e=[],u0e=e=>e?.availableEditors??s0e,d0e=e=>e?.keybindings??c0e,f0e=e=>e?.keybindingsConfigPath??null,p0e=e=>e?.observability??null,m0e=e=>e?.providers??l0e,h0e=e=>e?.settings??wne,Q1=X1(`server-welcome`,null),$1=X1(`server-config`,null),e0=X1(`server-config-updated`,null),g0e=X1(`server-providers-updated`,null);function t0(){return Bt.get($1)}function _0e(){return Bt.get(e0)}function n0(e){o0(e),s0({providers:e.providers}),c0(Z1(e),`snapshot`)}function v0e(e){switch(e.type){case`snapshot`:n0(e.config);return;case`keybindingsUpdated`:{let t=t0();if(!t)return;let n={...t,issues:e.payload.issues,keybindings:e.payload.keybindings};o0(n),c0(Z1(n),e.type);return}case`providerStatuses`:r0(e.payload);return;case`settingsUpdated`:i0(e.payload.settings);return;case`environmentUpdated`:a0(e.payload.environment);return}}function r0(e){let t=t0();if(s0(e),!t)return;let n={...t,providers:e.providers};o0(n),c0(Z1(n),`providerStatuses`)}function i0(e){let t=t0();if(!t)return;let n={...t,settings:e};o0(n),c0(Z1(n),`settingsUpdated`)}function a0(e){let t=t0();if(Nq()?.environmentId===e.environmentId&&Pq(e),!t)return;let n={...t,environment:e};o0(n),c0(Z1(n),`environmentUpdated`)}function y0e(e){Bt.set(Q1,e)}function b0e(e){let t=!1,n=[e.subscribeLifecycle(e=>{e.type===`welcome`&&y0e(e.payload)}),e.subscribeConfig(e=>{v0e(e)})];return t0()===null&&e.getConfig().then(e=>{t||t0()!==null||n0(e)}).catch(()=>void 0),()=>{t=!0;for(let e of n)e()}}var x0e=1;function o0(e){Bt.set($1,e)}function s0(e){Bt.set(g0e,e)}function c0(e,t){Bt.set(e0,{id:x0e++,payload:e,source:t})}function l0(e,t){let n=(0,F.useRef)(t);n.current=t;let r=(0,F.useCallback)(e=>{e!==null&&n.current(e)},[]);Ene(e,r,{immediate:!0})}function S0e(){return ar($1)}function u0(){return ar($1,h0e)}function C0e(){return ar($1,m0e)}function w0e(){return ar($1,d0e)}function T0e(){return ar($1,u0e)}function E0e(){return ar($1,f0e)}function D0e(){return ar($1,p0e)}function O0e(e){l0(Q1,e)}function k0e(e){l0(e0,e)}function A0e(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 j0e(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 M0e(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 N0e(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 A0e(e)){if(n){i.appendChild(j0e(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=M0e({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 d0;function P0e(){return f0(M1().client)}function f0(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 a0(n.environment),n}}}function F0e(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 I0e(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):N0e(e,t)},persistence:{getClientSettings:QY,setClientSettings:$Y,getSavedEnvironmentRegistry:eX,setSavedEnvironmentRegistry:tX,getSavedEnvironmentSecret:nX,setSavedEnvironmentSecret:rX,removeSavedEnvironmentSecret:iX},server:f0(e)}}function p0(){if(typeof window>`u`)return;if(d0)return d0;let e=I0e(M1().client);return window.nativeApi?(d0=F0e(e,window.nativeApi),d0):(d0=e,d0)}function L0e(){let e=p0();if(!e)throw Error(`Local API not found`);return e}function m0(e,t){if(!Me(e)||!Me(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]=Me(t)&&Me(r)?m0(t,r):r}return n}var h0=`[CLIENT_SETTINGS]`,g0=new Set,_0=Zn,v0=!1,y0=null;function R0e(){for(let e of g0)e()}function b0(){return _0}function x0(e){_0=e,R0e()}function z0e(e){return g0.add(e),B0e(),()=>{g0.delete(e)}}async function B0e(){if(v0)return;if(y0)return y0;let e=(async()=>{try{let e=await QY();e&&x0(e)}catch(e){console.error(`${h0} hydrate failed`,e)}finally{v0=!0}})().finally(()=>{y0===e&&(y0=null)});return y0=e,y0}function V0e(e){x0(e),$Y(e).catch(e=>{console.error(`${h0} persist failed`,e)})}var H0e=new Set(Tne(Jte.fields));function U0e(e){let t={},n={};for(let[r,i]of Object.entries(e))H0e.has(r)?t[r]=i:n[r]=i;return{serverPatch:t,clientPatch:n}}function S0(e){let t=u0(),n=(0,F.useSyncExternalStore)(z0e,b0,()=>Zn),r=(0,F.useMemo)(()=>({...t,...n}),[n,t]);return(0,F.useMemo)(()=>e?e(r):r,[r,e])}function C0(){let e=(0,Cl.c)(2),t=W0e,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{t(Cne)},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 W0e(e){let{serverPatch:t,clientPatch:n}=U0e(e);if(Object.keys(t).length>0){let e=t0();e&&i0(m0(e.settings,t)),M1().client.server.updateSettings(t)}Object.keys(n).length>0&&V0e({...b0(),...n})}function G0e(e,t){let n={hour:`numeric`,minute:`2-digit`,...t?{second:`2-digit`}:{}};return e===`locale`?n:{...n,hour12:e===`12-hour`}}var w0=new Map;function T0(e,t){let n=`${e}:${t?`seconds`:`minutes`}`,r=w0.get(n);if(r)return r;let i=new Intl.DateTimeFormat(void 0,G0e(e,t));return w0.set(n,i),i}function K0e(e,t){return T0(t,!0).format(new Date(e))}function q0e(e,t){return T0(t,!1).format(new Date(e))}function E0(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 J0e(e){let t=E0(e);return t.suffix?`${t.value} ${t.suffix}`:t.value}var Y0e=new Set([`tool.started`,`task.started`,`context-window.updated`,`text-generation.usage`]);function X0e(e){return Y0e.has(e.kind)||e.summary===`Checkpoint captured`}function Z0e(e,t){return!t.latestTurnId||e.turnId===t.latestTurnId||Q0e(e)?!0:$0e(e,t.latestTurnStartedAt)}function Q0e(e){return e.kind.startsWith(`worktree.`)||e.kind.startsWith(`setup-script.`)}function $0e(e,t){return e.turnId!==null||e.tone!==`error`||t===null?!1:e.createdAt>=t}var e2e=[{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 t2e(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 n2e(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:t2e(r-n)}function D0(e,t){return!e?.startedAt||!e.completedAt?!1:!t||t.orchestrationStatus!==`running`}function r2e(e,t,n){let r=t?.orchestrationStatus===`running`?t.activeTurnId??null:null;return r===null?D0(e,t)?n:e?.startedAt??n:e?.turnId===r?e.startedAt??n:n}function O0(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 k0(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 i2e(e){let t=new Map,n=[...e].toSorted(q0);for(let e of n){let n=e.payload&&typeof e.payload==`object`?e.payload:null,r=n&&typeof n.requestId==`string`?er.make(n.requestId):null,i=n&&(n.requestKind===`command`||n.requestKind===`file-read`||n.requestKind===`file-change`)?n.requestKind:n?O0(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&&k0(a)){t.delete(r);continue}}return[...t.values()].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}function a2e(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 o2e(e){let t=new Map,n=[...e].toSorted(q0);for(let e of n){let n=e.payload&&typeof e.payload==`object`?e.payload:null,r=n&&typeof n.requestId==`string`?er.make(n.requestId):null,i=n&&typeof n.detail==`string`?n.detail:void 0;if(e.kind===`user-input.requested`&&r){let i=a2e(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&&k0(i)&&t.delete(r)}return[...t.values()].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}function s2e(e,t){if(!t)return null;let n=[...e].toSorted(q0),r=null;for(let e of n){let t=j0(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 c2e(e,t){let n=[...e].toSorted(q0),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=i.payload&&typeof i.payload==`object`?i.payload:null,o=a?.plan;if(!Array.isArray(o))return null;let s=o.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.step!=`string`)return null;let n=t.status===`completed`||t.status===`inProgress`?t.status:`pending`;return{step:t.step,status:n}}).filter(e=>e!==null);if(s.length===0)return null;let c=i.turnId!==null&&n.some(e=>e.kind===`turn.completed`&&e.turnId===i.turnId&&q0(i,e)<0)?s.map(e=>e.status===`inProgress`?{...e,status:`completed`}:e):s;return{createdAt:i.createdAt,turnId:i.turnId,...a&&`explanation`in a?{explanation:a.explanation}:{},steps:c}}function A0(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 R0(n)}let n=[...e].toSorted((e,t)=>e.updatedAt.localeCompare(t.updatedAt)||e.id.localeCompare(t.id)).at(-1);return n?R0(n):null}function l2e(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 R0(n)}}return A0(t,e.latestTurn?.turnId??null)}function u2e(e){return e!==null&&e.implementedAt===null}function d2e(e,t,n){let r=f2e(),i={latestTurnId:t,latestTurnStartedAt:n??null};return b2e([...e].toSorted(q0).filter(e=>Z0e(e,i)).filter(e=>!X0e(e)).filter(e=>r||e.kind!==`runtime.warning`).filter(e=>!p2e(e)).map(m2e)).map(({activityKind:e,collapseKey:t,...n})=>n)}function f2e(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`forge:debug-mode`)===`true`}catch{return!1}}function p2e(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 m2e(e){let t=e.payload&&typeof e.payload==`object`?e.payload:null,n=F2e(t),r=V2e(t),i=I2e(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=z2e(t),d=B2e(t);if(!s&&t&&typeof t.detail==`string`&&t.detail.length>0){let e=W0(t.detail).output;e&&(l.detail=e)}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 f=h2e(t);if(f)l.githubConfirmation=f,l.tone=`approval`,l.label=`GitHub action needs approval`,l.toolTitle=N0(f.operation),l.detail=P0(f);else{let e=j0(t);e&&(l.githubActionRequired=e,l.tone=`approval`,l.label=F0(e.action),l.toolTitle=`GitHub setup required`,l.detail=L0(e))}let p=w2e(l);return p&&(l.collapseKey=p),l}function h2e(e){for(let t of M0(e)){if(t.userActionRequired!==`confirm_github_tool`)continue;let e=z0(t.confirmation),n=z0(e?.request),r=B0(e?.confirmationId),i=B0(e?.toolName),a=B0(e?.operation);if(!(!r||!i||!a||!n))return{confirmationId:r,toolName:i,operation:a,request:n}}return null}function j0(e){let t=M0(e)[0];if(!t)return null;let n=B0(t.userActionRequired);return!n||n===`confirm_github_tool`?null:{action:n,toolName:B0(t.toolName),message:B0(t.error)??B0(t.message)}}function M0(e){if(!e)return[];let t=[],n=new Set,r=(e,i)=>{if(i>8||e==null)return;if(typeof e==`string`){let n=B0(e);if(!n)return;let r=g2e(n);r&&B0(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(B0(a.userActionRequired)){t.push(a);return}for(let e of Object.values(a))r(e,i+1)};return r(e,0),t}function g2e(e){try{return z0(JSON.parse(e))}catch{return null}}function N0(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 P0(e){return[B0(e.request.repoFullName)??(B0(e.request.owner)&&B0(e.request.name)?`${B0(e.request.owner)}/${B0(e.request.name)}`:null),B0(e.request.cwd),B0(e.request.branch),B0(e.request.title)].filter(Boolean).join(` - `)}function F0(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 I0(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 L0(e){return e.action===`connect_cmmd`?I0(e.action):e.message??I0(e.action)}function _2e(e,t){return e.action===t.action&&e.toolName===t.toolName&&e.message===t.message}function v2e(e){switch(e){case`connect_cmmd`:return`Reconnect Forge`;case`connect_github`:return`Connect GitHub`;default:return`Open Git settings`}}function y2e(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(`
|
|
1019
|
+
`)}function b2e(e){let t=[];for(let n of e){let e=t.at(-1);if(e&&x2e(e,n)){t[t.length-1]=S2e(e,n);continue}t.push(n)}return t}function x2e(e,t){return e.activityKind!==`tool.updated`&&e.activityKind!==`tool.completed`||t.activityKind!==`tool.updated`&&t.activityKind!==`tool.completed`||e.activityKind===`tool.completed`?!1:e.collapseKey!==void 0&&e.collapseKey===t.collapseKey}function S2e(e,t){let n=C2e(e.changedFiles,t.changedFiles),r=t.detail??e.detail,i=t.command??e.command,a=t.rawCommand??e.rawCommand,o=t.toolTitle??e.toolTitle,s=t.itemType??e.itemType,c=t.requestKind??e.requestKind,l=t.collapseKey??e.collapseKey;return{...e,...t,...r?{detail:r}:{},...i?{command:i}:{},...a?{rawCommand:a}:{},...n.length>0?{changedFiles:n}:{},...o?{toolTitle:o}:{},...s?{itemType:s}:{},...c?{requestKind:c}:{},...l?{collapseKey:l}:{}}}function C2e(e,t){let n=[...e??[],...t??[]];return n.length===0?[]:[...new Set(n)]}function w2e(e){if(e.activityKind!==`tool.updated`&&e.activityKind!==`tool.completed`)return;let t=T2e(e.toolTitle??e.label),n=e.detail?.trim()??``,r=e.itemType??``;if(t.length!==0||n.length!==0||r.length!==0)return[r,t,n].join(``)}function T2e(e){return e.replace(/\s+(?:complete|completed)\s*$/i,``).trim()}function R0(e){return{id:e.id,createdAt:e.createdAt,updatedAt:e.updatedAt,turnId:e.turnId,planMarkdown:e.planMarkdown,implementedAt:e.implementedAt,implementationThreadId:e.implementationThreadId}}function z0(e){return e&&typeof e==`object`?e:null}function B0(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function V0(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 E2e(e){let t=V0(e);if(t.length===0)return null;let n=t.replace(/\\/g,`/`).split(`/`).at(-1)?.trim()??``;return n.length>0?n.toLowerCase():null}function D2e(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 O2e=[{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 k2e(e){return O2e.find(t=>t.executables.includes(e))}function A2e(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=V0(r);return i.length>0?i:null}function j2e(e){let t=D2e(e);if(!t||t.rest.length===0)return e;let n=E2e(t.executable);if(!n)return e;let r=k2e(n);return r?A2e(t.rest,r.wrapperFlagPattern)??e:e}function M2e(e){return/[\s"'`]/.test(e)?`"${e.replace(/"/g,`\\"`)}"`:e}function H0(e){let t=B0(e);if(t)return t;if(!Array.isArray(e))return null;let n=e.map(e=>B0(e)).filter(e=>e!==null);return n.length===0?null:n.map(e=>M2e(e)).join(` `)}function N2e(e){let t=H0(e);return t?j2e(t):null}function P2e(e,t){let n=H0(e);return!n||t===null||n===t?null:n}function F2e(e){let t=z0(e?.data),n=z0(t?.item),r=z0(n?.result),i=z0(n?.input),a=B0(e?.itemType),o=B0(e?.detail),s=[e?.command,n?.command,i?.command,r?.command,t?.command,a===`command_execution`&&o?W0(o).output:null];for(let e of s){let t=N2e(e);if(t)return{command:t,rawCommand:P2e(e,t)}}return{command:null,rawCommand:null}}function I2e(e){return L2e(e)??B0(e?.title)}function L2e(e){if(!e)return null;let t=z0(e.data),n=z0(t?.item),r=z0(n?.input)??z0(t?.input),i=B0(e.title),a=B0(e.itemType),o=B0(n?.name)??B0(n?.toolName)??B0(t?.name)??B0(e.toolName)??i,s=B0(e.detail),c=[o,i,a,s].filter(Boolean).join(` `).toLowerCase();if(!c.includes(`browser`)&&!c.includes(`forge-browser`))return null;switch(R2e(o,r,s)){case`open-session`:return`Opened browser session`;case`name-session`:return`Named browser session`;case`new-tab`:return U0(r)??`Opened browser tab`;case`navigate`:return U0(r)??`Navigated browser`;case`reload`:return`Reloaded page`;case`back`:return`Went back`;case`forward`:return`Went forward`;case`screenshot`:return`Captured screenshot`;case`snapshot`:return`Read DOM snapshot`;case`logs`:return`Read console logs`;case`click`:return`Clicked page`;case`type`:return`Typed text`;case`scroll`:return`Scrolled page`;case`viewport`:return`Updated viewport`;case`visibility`:return`Updated browser visibility`;default:return null}}function R2e(e,t,n){let r=[B0(t?.type)??B0(t?.command),e,n].filter(Boolean).join(` `).toLowerCase();return/\b(open[-_.\s]?session|create[-_.\s]?session|session[-_.\s]?open)\b/.test(r)?`open-session`:/\b(name[-_.\s]?session|session[-_.\s]?name)\b/.test(r)?`name-session`:/\b(new[-_.\s]?tab|create[-_.\s]?tab|open[-_.\s]?tab)\b/.test(r)?`new-tab`:/\b(navigate|goto|go[-_.\s]?to)\b/.test(r)?`navigate`:/\breload\b/.test(r)?`reload`:/\b(go[-_.\s]?back|back)\b/.test(r)?`back`:/\b(go[-_.\s]?forward|forward)\b/.test(r)?`forward`:/\b(screenshot|capture)\b/.test(r)?`screenshot`:/\b(snapshot|dom[-_.\s]?snapshot|read[-_.\s]?dom)\b/.test(r)?`snapshot`:/\b(console[-_.\s]?logs?|logs?)\b/.test(r)?`logs`:/\bclick\b/.test(r)?`click`:/\btype|fill\b/.test(r)?`type`:/\bscroll\b/.test(r)?`scroll`:/\bviewport\b/.test(r)?`viewport`:/\bvisibility|visible|hidden\b/.test(r)?`visibility`:null}function U0(e){let t=B0(e?.url)??B0(e?.initialUrl);if(!t)return null;try{let e=new URL(t);return e.hostname.length===0?null:`Navigated to ${e.hostname}`}catch{return null}}function W0(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 z2e(e){if(typeof e?.itemType==`string`&&Nte(e.itemType))return e.itemType}function B2e(e){return e?.requestKind===`command`||e?.requestKind===`file-read`||e?.requestKind===`file-change`?e.requestKind:O0(e?.requestType)??void 0}function G0(e,t,n){let r=B0(n);!r||t.has(r)||(t.add(r),e.push(r))}function K0(e,t,n,r){if(r>4||t.length>=12)return;if(Array.isArray(e)){for(let i of e)if(K0(i,t,n,r+1),t.length>=12)return;return}let i=z0(e);if(i){G0(t,n,i.path),G0(t,n,i.filePath),G0(t,n,i.relativePath),G0(t,n,i.filename),G0(t,n,i.newPath),G0(t,n,i.oldPath);for(let e of[`item`,`result`,`input`,`data`,`changes`,`files`,`edits`,`patch`,`patches`,`operations`])if(e in i&&(K0(i[e],t,n,r+1),t.length>=12))return}}function V2e(e){let t=[],n=new Set;return K0(z0(e?.data),t,n,0),t}function q0(e,t){if(e.sequence!==void 0&&t.sequence!==void 0){if(e.sequence!==t.sequence)return e.sequence-t.sequence}else if(e.sequence!==void 0)return 1;else if(t.sequence!==void 0)return-1;let n=e.createdAt.localeCompare(t.createdAt);if(n!==0)return n;let r=J0(e.kind)-J0(t.kind);return r===0?e.id.localeCompare(t.id):r}function J0(e){return e.endsWith(`.started`)||e===`tool.started`?0:e.endsWith(`.progress`)||e.endsWith(`.updated`)?1:e.endsWith(`.completed`)||e.endsWith(`.resolved`)?2:1}function H2e(e,t){return t?e.some(e=>e.turnId===t&&e.tone===`tool`):!1}function U2e(e,t,n){let r=e.map(e=>({id:e.id,kind:`message`,createdAt:e.createdAt,message:e})),i=t.map(e=>({id:e.id,kind:`proposed-plan`,createdAt:e.createdAt,proposedPlan:e})),a=n.map(e=>({id:e.id,kind:`work`,createdAt:e.createdAt,entry:e})),o=e.flatMap(e=>{if(e.role!==`assistant`)return[];let t=W2e(e.text,{workEntries:n,createdAt:e.createdAt});return t?[{id:`${e.id}:github-confirmation:${t.confirmationId}`,kind:`work`,createdAt:e.createdAt,entry:{id:`${e.id}:github-confirmation:${t.confirmationId}`,createdAt:e.createdAt,label:`GitHub action needs approval`,detail:P0(t),tone:`approval`,toolTitle:N0(t.operation),githubConfirmation:t}}]:[]});return[...r,...i,...a,...o].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}function W2e(e,t){if(!e.includes(`confirm_github_tool`))return null;let n=J2e(e,/\b(?:New confirmation id|Confirmation id):\s*`?([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})`?/i)??null,r=/\bRepo(?: to create)?:\s*(private|public|internal)\s+`?([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)`?/i.exec(e);if(!n)return null;let i=G2e(e,n,t);if(i)return i;if(!r)return null;let a=r[1]?.toLowerCase(),o=r[2],s=r[3];return!o||!s?null:{confirmationId:n,toolName:`forge_github_create_repository`,operation:`create_repository`,request:{owner:o,name:s,visibility:a}}}function G2e(e,t,n){if(!K2e(e))return null;let r=q2e(n?.workEntries??[],n?.createdAt,`forge_github_refresh_credentials`)?.request,i=r?B0(r.cwd):null;return i?{confirmationId:t,toolName:`forge_github_refresh_credentials`,operation:`refresh_credentials`,request:{cwd:i}}:null}function K2e(e){return/\bforge_github_refresh_credentials\b/i.test(e)||/\bcredential refresh\b/i.test(e)||/\brefresh(?:ing)? GitHub credentials\b/i.test(e)}function q2e(e,t,n){for(let r of e.toReversed()){if(t!==void 0&&r.createdAt>t)continue;let e=r.githubConfirmation;if(e?.toolName===n)return e}return null}function J2e(e,t){return t.exec(e)?.[1]??null}function Y2e(e,t){if(!t?.startedAt||!t.completedAt)return null;if(t.assistantMessageId){let n=e.find(e=>e.kind===`message`&&e.message.role===`assistant`&&e.message.id===t.assistantMessageId);if(n)return n.id}let n=Date.parse(t.startedAt),r=Date.parse(t.completedAt);if(Number.isNaN(n)||Number.isNaN(r))return null;let i=null,a=null;for(let t of e){if(t.kind!==`message`||t.message.role!==`assistant`)continue;let e=Date.parse(t.message.createdAt);Number.isNaN(e)||e<n||(a=t.id,e<=r&&(i=t.id))}return i??a}function X2e(e){let t=[...e].toSorted((e,t)=>e.completedAt.localeCompare(t.completedAt)),n={};for(let e=0;e<t.length;e+=1){let r=t[e];r&&(n[r.turnId]=e+1)}return n}function Z2e(e){return!e||e.status===`closed`?`disconnected`:e.status===`connecting`?`connecting`:e.status===`running`?`running`:`ready`}function Q2e(e,t){if(t===`disconnected`||t===`connecting`)return null;for(let t of e.toReversed())if(t.kind===`work`&&t.entry.githubConfirmation)return t.entry.githubConfirmation;return null}function Y0(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}:{},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:{searchEntries:e.projects.searchEntries,readFile:e.projects.readFile,writeFile:e.projects.writeFile},codeGraph:{summary:e.codeGraph.summary,neighborhood:e.codeGraph.neighborhood,search:e.codeGraph.search},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 X0(e){if(typeof window>`u`||!e)return;let t=j1(e);return t?Y0(t.client):void 0}function $2e(e){let t=(0,Cl.c)(4),n;t[0]===e?n=t[1]:(n=()=>j1(e),t[0]=e,t[1]=n);let r=(0,F.useSyncExternalStore)(A1,n,e4e),i,a;return t[2]===r?a=t[3]:(a=r?Y0(r.client):void 0,t[2]=r,t[3]=a),i=a,i}function e4e(){return null}function t4e(e){let t=X0(e);if(!t)throw Error(`Environment API not found for environment ${e}`);return t}function n4e(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Yt(i),[,o]=F.useState(!1),s=Gt(i4e).current,c=Gt(r4e).current,l=F.useRef(0),u=F.useRef(!0),d=F.useRef([]),f=F.useRef(null),p=Yt(()=>{u.current||(u.current=!0,o(e=>!e))}),m=Yt((e,t)=>{c.set(e,t),p()}),h=Yt(e=>{c.delete(e),p()}),g=Yt(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(!s4e(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&Z0(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=o4e(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=Yt(()=>{let[e,t]=a4e(c),n=g(e);_(t),d.current=e,u.current=!1,s.forEach(e=>e(n)),a(n)});Jt(()=>(u.current||g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),Jt(()=>{u.current&&v()}),Jt(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=Yt(e=>(s.add(e),()=>{s.delete(e)})),b=F.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,kr.jsx)(wte.Provider,{value:b,children:t})}function r4e(){return new Map}function i4e(){return new Set}function a4e(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)=>Z0(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 o4e(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function s4e(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 Z0(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var Q0=[`preview`,`canvas`,`diff`,`plan`,`task`,`simulator`,`display`,`agents`,`file`,`graph`,`pull-request`],$0={isOpen:!1,isMaximized:!1,activeSurfaceId:null,surfaces:[]};function e2(e){return e===null?{id:`browser:new`,kind:`preview`,resourceId:null}:{id:`browser:${e}`,kind:`preview`,resourceId:e}}function c4e(e,t,n){return{id:`file:${e}`,kind:`file`,relativePath:e,revealLine:t,revealRequestId:n}}function t2(e){let t=[e.provider,e.environmentId,e.repositoryLinkId??``,e.projectId,e.host.toLowerCase(),e.repository,String(e.number)].map(e=>encodeURIComponent(e)).join(`:`);return{...e,id:`pull-request:${t}`,kind:`pull-request`}}function n2(e){return e===`diff`?{id:`diff`,kind:`diff`,turnId:null,filePath:null}:{id:e,kind:e}}var l4e=`workspace:pull-requests`;function r2(e){return typeof e==`object`&&!!e}function u4e(e){return typeof e==`string`&&Q0.includes(e)}function i2(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(1,Math.trunc(e)):null}function d4e(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:0}function f4e(e){let t=e.relativePath;return typeof t!=`string`||t.length===0?null:{id:`file:${t}`,kind:`file`,relativePath:t,revealLine:i2(e.revealLine),revealRequestId:d4e(e.revealRequestId)}}function p4e(e){let t=e.resourceId;return t==null?{id:`browser:new`,kind:`preview`,resourceId:null}:typeof t!=`string`||t.length===0?null:{id:`browser:${t}`,kind:`preview`,resourceId:t}}function m4e(e){let t=e.turnId,n=e.filePath,r=typeof t==`string`&&t.length>0?hn.make(t):null;return{id:`diff`,kind:`diff`,turnId:r,filePath:r&&typeof n==`string`&&n.length>0?n:null}}var h4e=new Set([`github`,`gitlab`,`azure-devops`,`bitbucket`,`unknown`]);function a2(e){return typeof e==`string`&&e.length>0}function o2(e){return e===null||typeof e==`string`}function g4e(e){return e===void 0||o2(e)}function _4e(e){let t=e.provider,n=e.environmentId,r=e.repositoryLinkId,i=e.projectId,a=e.host,o=e.repository,s=i2(e.number),c=e.title;return![a2(t)&&h4e.has(t),a2(n),o2(r),a2(i),a2(a),a2(o),s!==null,g4e(c)].every(Boolean)||!a2(t)||!a2(n)?null:t2({provider:t,environmentId:en.make(n),repositoryLinkId:r,projectId:an.make(i),host:a,repository:o,number:s,...typeof c==`string`||c===null?{title:c}:{}})}function v4e(e){if(!r2(e)||!u4e(e.kind))return null;let t=e.kind;return t===`file`?f4e(e):t===`preview`?p4e(e):t===`diff`?m4e(e):t===`pull-request`?_4e(e):{id:t,kind:t}}function y4e(e){let t=[],n=new Set;for(let r of Array.isArray(e)?e:[]){let e=v4e(r);!e||n.has(e.id)||(n.add(e.id),t.push(e))}return t}function b4e(e){if(!r2(e))return null;let t=y4e(e.surfaces);if(t.length===0)return null;let n=e.activeSurfaceId,r=t.some(e=>e.id===n),i=typeof n==`string`&&r?n:t[0]?.id??null;return{isOpen:e.isOpen===!0,activeSurfaceId:i,surfaces:t}}function x4e(e){if(!r2(e)||!r2(e.byThreadKey))return{byThreadKey:{}};let t={};for(let[n,r]of Object.entries(e.byThreadKey)){if(n===l4e)continue;let e=b4e(r);e&&(t[n]=e)}return{byThreadKey:t}}var S4e=`forge:right-panel-state`,C4e=3,w4e=e=>e===`workspace:pull-requests`;function T4e(e){return`draft:${e}`}function E4e(e){return e.startsWith(`draft:`)}function D4e(e){return e==null||!Number.isFinite(e)?null:Math.max(1,Math.trunc(e))}var s2=(e,t,n=!0)=>({...e,isOpen:!0,surfaces:e.surfaces.some(e=>e.id===t.id)?e.surfaces:[...e.surfaces,t],activeSurfaceId:n?t.id:e.activeSurfaceId}),c2=(e,t,n)=>{let r=e[t]??$0,i=n(r);if(!i.isOpen&&i.activeSurfaceId===null&&i.surfaces.length===0){if(!(t in e))return e;let{[t]:n,...r}=e;return r}return i===r?e:{...e,[t]:i}},O4e=Wt()(sJ(e=>({byThreadKey:{},open:(t,n)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>s2(e,e.surfaces.find(e=>e.kind===n)??n2(n)))})),openBrowser:(t,n)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>{let t=n?e.surfaces.filter(e=>e.id!==`browser:new`):e.surfaces;return s2({...e,surfaces:t},e2(n))})})),revealBrowser:t=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>s2(e,e.surfaces.find(e=>e.kind===`preview`)??e2(null)))})),openDiff:(t,n,r)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>{let t={id:`diff`,kind:`diff`,turnId:n??null,filePath:n?r??null:null};return{...e,isOpen:!0,activeSurfaceId:t.id,surfaces:e.surfaces.some(e=>e.id===`diff`)?e.surfaces.map(e=>e.id===`diff`?t:e):[...e.surfaces,t]}})})),openFile:(t,n,r)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>{let t=`file:${n}`,i=e.surfaces.find(e=>e.id===t&&e.kind===`file`),a=c4e(n,D4e(r),(i?.revealRequestId??0)+1);return{...e,isOpen:!0,activeSurfaceId:a.id,surfaces:i?e.surfaces.map(e=>e.id===a.id?a:e):[...e.surfaces,a]}})})),openPullRequest:(t,n)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>s2(e,t2(n)))})),activateSurface:(t,n)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>e.surfaces.some(e=>e.id===n)?{...e,isOpen:!0,activeSurfaceId:n}:e)})),closeSurface:(t,n)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>{let t=e.surfaces.findIndex(e=>e.id===n);if(t<0)return e;let r=e.surfaces.filter(e=>e.id!==n);if(e.activeSurfaceId!==n)return{...e,isOpen:r.length>0&&e.isOpen,surfaces:r};let i=r[Math.min(t,r.length-1)]??null;return{...e,isOpen:r.length>0&&e.isOpen,surfaces:r,activeSurfaceId:i?.id??null}})})),closeOtherSurfaces:(t,n)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>{let t=e.surfaces.find(e=>e.id===n);return!t||e.surfaces.length===1?e:{...e,isOpen:!0,surfaces:[t],activeSurfaceId:t.id}})})),closeSurfacesToRight:(t,n)=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>{let t=e.surfaces.findIndex(e=>e.id===n);if(t<0||t===e.surfaces.length-1)return e;let r=e.surfaces.slice(0,t+1),i=r.some(t=>t.id===e.activeSurfaceId);return{...e,surfaces:r,activeSurfaceId:i?e.activeSurfaceId:n}})})),closeAllSurfaces:t=>e(e=>({byThreadKey:c2(e.byThreadKey,t,()=>$0)})),show:t=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>({...e,isOpen:!0}))})),close:t=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>e.isOpen?{...e,isOpen:!1,isMaximized:!1}:e)})),toggleVisibility:t=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>({...e,isOpen:!e.isOpen}))})),toggleMaximized:t=>e(e=>({byThreadKey:c2(e.byThreadKey,t,e=>e.isOpen?{...e,isMaximized:!(e.isMaximized??!1)}:e)})),removeThread:t=>e(e=>{if(!(t in e.byThreadKey))return e;let{[t]:n,...r}=e.byThreadKey;return{byThreadKey:r}})}),{name:S4e,version:C4e,storage:aJ(()=>_J),partialize:e=>({byThreadKey:Object.fromEntries(Object.entries(e.byThreadKey).filter(([e])=>!E4e(e)&&!w4e(e)))}),migrate:e=>x4e(e)}));function k4e(e){return t=>e?dZ(t,e.environmentId).projectById[e.projectId]:void 0}function l2(e){let t,n,r;return i=>{let a=e(i);if(!a)return;let o=dZ(i,a.environmentId);return r&&t===o&&n===a.threadId?r:(t=o,n=a.threadId,r=kX(o,a.threadId),r)}}function A4e(e){return l2(()=>e)}function j4e(e){return t=>{if(e)return dZ(t,e.environmentId).threadSubscriptionErrorById[e.threadId]}}function M4e(e){let t,n,r,i;return a=>{if(!e){i=void 0,t=void 0,n=void 0,r=void 0;return}let o=dZ(a,e.environmentId).threadShellById,s=o[e.threadId];if(!s){i=void 0,t=void 0,n=void 0,r=void 0;return}let c=s.kind===`master`?s.id:s.parentThreadId,l=c==null?void 0:o[c];if(i&&t===o&&n===s&&r===l)return i;let u=[];if(c!=null){for(let e of Object.values(o))e.kind===`worker`&&e.parentThreadId===c&&u.push(e);u.sort((e,t)=>e.createdAt.localeCompare(t.createdAt))}return t=o,n=s,r=l,i={you:s,master:l,workers:u},i}}function N4e(e){return l2(t=>{if(!e)return;let n,r,i;for(let[a,o]of Object.entries(t.environmentStateById))if(o.threadShellById[e]){let s={environmentId:a,threadId:e};if(n??=s,t.activeEnvironmentId===a&&(r=s),o.bootstrapComplete&&(i=s,t.activeEnvironmentId===a))break}return i??r??n})}var u2=`forge:last-editor`;function d2(e){let t=new Set(e),n=Kq(u2,Rn);if(n&&t.has(n))return n;let r=Vte.find(e=>t.has(e.id))?.id??null;return r&&qq(u2,r,Rn),r??null}async function P4e(e,t){let{availableEditors:n}=await e.server.getConfig(),r=d2(n);if(!r)throw Error(`No available editors found.`);return await e.shell.openInEditor(t,r),r}var F4e=/https?:\/\/[^\s"'`<>]+/g,I4e=/(?:~\/|\.{1,2}\/|\/|[A-Za-z]:[\\/]|\\\\)[^\s"'`<>]+|[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+(?::\d+){0,2}/g,L4e=/[.,;!?]+$/;function R4e(e){let t=e.replace(L4e,``);if(t.length===0)return t;let n=(e,n)=>{for(;t.endsWith(n);){if(t.split(e).length-1>=t.split(n).length-1)return;t=t.slice(0,-1)}};return n(`(`,`)`),n(`[`,`]`),n(`{`,`}`),t}function z4e(e,t){return e.start<t.end&&t.start<e.end}function f2(e,t,n,r){let i=[];n.lastIndex=0;for(let a of e.matchAll(n)){let e=a[0],n=a.index??-1;if(n<0||e.length===0)continue;let o=R4e(e);if(o.length===0||t===`path`&&/^https?:\/\//i.test(o))continue;let s={kind:t,text:o,start:n,end:n+o.length};[...r,...i].some(e=>z4e(s,e))||i.push(s)}return i}function p2(e){return/^[A-Za-z]:[\\/]/.test(e)||e.startsWith(`\\\\`)}function B4e(e){return e.startsWith(`/`)||p2(e)}function m2(e){return p2(e)||/[A-Za-z]:\\/.test(e)}function h2(e,t,n){let r=e.replace(/[\\/]+$/,``);return n===`\\`?`${r}\\${t.replaceAll(`/`,`\\`)}`:`${r}/${t.replace(/^\/+/,``)}`}function V4e(e){let t=e.match(/^\/Users\/([^/]+)/);if(t?.[1])return`/Users/${t[1]}`;let n=e.match(/^\/home\/([^/]+)/);if(n?.[1])return`/home/${n[1]}`;let r=e.match(/^([A-Za-z]:\\Users\\[^\\]+)/);if(r?.[1])return r[1]}function g2(e){let t=e,n,r,i=t.match(/:(\d+)$/);if(!i?.[1])return{path:t,line:void 0,column:void 0};n=i[1],t=t.slice(0,-i[0].length);let a=t.match(/:(\d+)$/);return a?.[1]?(r=a[1],t=t.slice(0,-a[0].length)):(r=n,n=void 0),{path:t,line:r,column:n}}function H4e(e){let t=f2(e,`url`,F4e,[]),n=f2(e,`path`,I4e,t);return[...t,...n].toSorted((e,t)=>e.start-t.start)}function U4e(e,t){let n=t(e-1);if(!n)return null;let r=e,i=n;for(;r>1&&i.isWrapped;){let e=t(r-2);if(!e)return null;--r,i=e}let a=[],o=0,s=r;for(;;){let e=t(s-1);if(!e)break;let n=t(s)?.isWrapped===!0,r=e.translateToString(!n);if(a.push({bufferLineNumber:s,text:r,startIndex:o,endIndex:o+r.length}),o+=r.length,!n)break;s+=1}return{text:a.map(e=>e.text).join(``),segments:a}}function _2(e,t){for(let n of e)if(t<n.endIndex)return{x:t-n.startIndex+1,y:n.bufferLineNumber};let n=e[e.length-1];return{x:Math.max(n?.text.length??0,1),y:n?.bufferLineNumber??1}}function W4e(e,t){return{start:_2(e.segments,t.start),end:_2(e.segments,t.end-1)}}function G4e(e,t){return e.start.y<=t&&t<=e.end.y}function K4e(e,t=typeof navigator>`u`?``:navigator.platform){return t.length===0?!1:xte(t)?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function q4e(e,t){let{path:n,line:r,column:i}=g2(e),a=n;if(n.startsWith(`~/`)){let e=V4e(t);if(e){let t=m2(e)?`\\`:`/`;a=h2(e,n.slice(2),t)}}else B4e(n)||(a=h2(t,n,m2(t)?`\\`:`/`));return r?`${a}:${r}${i?`:${i}`:``}`:a}var v2=`diffs-container`,J4e=(()=>{try{return!1}catch{return!1}})(),Y4e=/(?=^From [a-f0-9]+ .+$)/m,X4e=/(?=^diff --git)/gm,Z4e=/(?<=\n)/,Q4e=/^(---|\+\+\+)\s+([^\t\r\n]+)/,$4e=/^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/,e3e=/^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/,t3e=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,y2=`header-prefix`,b2=`header-filename-suffix`,x2=`header-metadata`,S2=`header-custom`,C2={dark:`pierre-dark`,light:`pierre-light`},n3e=`data-theme-css`,r3e=`data-unsafe-css`,i3e=`data-diffs-scrollbar-measure`,a3e=`data-diffs-code-view-header`,o3e=`data-diffs-code-view-footer`,w2=`--diffs-scrollbar-gutter-measured`,s3e=1e5,T2={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8},c3e={...T2,hunkLineCount:1},l3e={paddingTop:8,paddingBottom:8,gap:8},u3e={omega:.015,positionEpsilon:.5,velocityEpsilon:.05},d3e=Object.freeze({fromStart:0,fromEnd:0}),f3e={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},p3e={startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:0},E2=new Set,D2=null;function O2(e){E2.add(e),D2??=requestAnimationFrame(A2)}function k2(e){E2.delete(e)&&E2.size===0&&D2!=null&&(cancelAnimationFrame(D2),D2=null)}function A2(e){let t=new Set(E2);E2.clear();for(let n of t)try{n(e)}catch(e){console.error(e)}D2=E2.size>0?requestAnimationFrame(A2):null}function j2(e,t,n){if(e===t||e==null||t==null)return e===t;let r=new Set(n),i=Object.keys(e),a=new Set(Object.keys(t));for(let n of i)if(a.delete(n),!r.has(n)&&(!(n in t)||e[n]!==t[n]))return!1;for(let e of Array.from(a))if(!r.has(e))return!1;return!0}function M2(e,t){return e==null||t==null||typeof e==`string`||typeof t==`string`?e===t:e.dark===t.dark&&e.light===t.light}function m3e(e,t){let n=e?.theme??C2,r=t?.theme??C2,i=N2(e),a=N2(t);return M2(n,r)&&j2(e,t,[`theme`,`parseDiffOptions`])&&j2(i,a)}function N2(e){if(e!=null&&`parseDiffOptions`in e)return e.parseDiffOptions}function P2(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}function h3e({scrollTop:e,scrollHeight:t,height:n,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:a}){let o=n+a*2,s=r?n+i*2:o;if(t=Math.max(t,s),o>=t||r){let n=Math.max(e-i,0),r=Math.min(e+s,t);return{top:n,bottom:Math.max(r,n)}}let c=e+n/2-o/2,l=c+o;return c<0&&(c=0),l>t&&(l=t),c=Math.floor(Math.max(c,0)),{top:c,bottom:Math.ceil(Math.max(Math.min(l,t),c))}}function F2(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}function I2(e,t){return e-(t===0?0:1)}function L2(e,t){return I2(e,t)+t}var R2=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},g3e=new class extends R2{};function _3e(e,t,n){return g3e.diff(e,t,n)}function z2(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function B2(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function V2(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function H2(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function U2(e,t){return V2(e,t,``)}function W2(e,t){return H2(e,t,``)}function G2(e,t){return t.slice(0,v3e(e,t))}function v3e(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function K2(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function q2(e,t){if(t)return Y2(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function J2(e,t){if(t)return Y2(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function Y2(e,t){if(!t)return[J2(e),q2(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=K2(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var X2=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,y3e=RegExp(`[${X2}]+|\\s+|[^${X2}]`,`ug`);new class extends R2{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=K2(e,r)}else n=e.match(y3e)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&Z2(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&Z2(n,i,r,null,t.intlSegmenter),e}};function Z2(e,t,n,r,i){if(t&&n){let[a,o]=Y2(t.value,i),[s,c]=Y2(n.value,i);if(e){let r=z2(a,s);e.value=H2(e.value,s,r),t.value=U2(t.value,r),n.value=U2(n.value,r)}if(r){let e=B2(o,c);r.value=V2(r.value,c,e),t.value=W2(t.value,e),n.value=W2(n.value,e)}}else if(n){if(e){let e=J2(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=J2(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=J2(r.value,i),[a,o]=Y2(t.value,i),s=z2(n,a);t.value=U2(t.value,s);let c=B2(U2(n,s),o);t.value=W2(t.value,c),r.value=V2(r.value,n,c),e.value=H2(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=J2(r.value,i),n=G2(q2(t.value,i),e);t.value=W2(t.value,n)}else if(e){let n=G2(q2(e.value,i),J2(t.value,i));t.value=U2(t.value,n)}}var b3e=new class extends R2{tokenize(e){let t=RegExp(`(\\r?\\n)|[${X2}]+|[^\\S\\n\\r]+|[^${X2}]`,`ug`);return e.match(t)||[]}};function x3e(e,t,n){return b3e.diff(e,t,n)}var S3e=new class extends R2{constructor(){super(...arguments),this.tokenize=$2}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
1020
1020
|
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
1021
1021
|
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
1022
1022
|
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
1023
|
-
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function Q2(e,t,n){return
|
|
1024
|
-
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function
|
|
1023
|
+
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function Q2(e,t,n){return S3e.diff(e,t,n)}function $2(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
1024
|
+
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function C3e(e){return e==`.`||e==`!`||e==`?`}new class extends R2{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(C3e(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends R2{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends R2{constructor(){super(...arguments),this.tokenize=$2}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(e4(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function e4(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a;for(a=0;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=e4(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=e4(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends R2{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};function w3e(e){for(let t=0;t<e.length;t++)if(e[t]<` `||e[t]>`~`||e[t]===`"`||e[t]===`\\`)return!0;return!1}function t4(e){if(!w3e(e))return e;let t=`"`,n=new TextEncoder().encode(e),r=0;for(;r<n.length;){let e=n[r];t+=e===7?`\\a`:e===8?`\\b`:e===9?`\\t`:e===10?`\\n`:e===11?`\\v`:e===12?`\\f`:e===13?`\\r`:e===34?`\\"`:e===92?`\\\\`:e>=32&&e<=126?String.fromCharCode(e):`\\`+e.toString(8).padStart(3,`0`),r++}return t+=`"`,t}var n4={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function r4(e,t,n,r,i,a,o){let s;s=o?typeof o==`function`?{callback:o}:o:{},s.context===void 0&&(s.context=4);let c=s.context;if(s.newlineIsToken)throw Error(`newlineIsToken may not be used with patch-generation functions, only with diffing functions`);if(s.callback){let{callback:e}=s;Q2(n,r,Object.assign(Object.assign({},s),{callback:t=>{let n=l(t);e(n)}}))}else return l(Q2(n,r,s));function l(n){if(!n)return;n.push({value:``,lines:[]});function r(e){return e.map(function(e){return` `+e})}let o=[],s=0,l=0,u=[],d=1,f=1;for(let e=0;e<n.length;e++){let t=n[e],i=t.lines||E3e(t.value);if(t.lines=i,t.added||t.removed){if(!s){let t=n[e-1];s=d,l=f,t&&(u=c>0?r(t.lines.slice(-c)):[],s-=u.length,l-=u.length)}for(let e of i)u.push((t.added?`+`:`-`)+e);t.added?f+=i.length:d+=i.length}else{if(s)if(i.length<=c*2&&e<n.length-2)for(let e of r(i))u.push(e);else{let e=Math.min(i.length,c);for(let t of r(i.slice(0,e)))u.push(t);let t={oldStart:s,oldLines:d-s+e,newStart:l,newLines:f-l+e,lines:u};o.push(t),s=0,l=0,u=[]}d+=i.length,f+=i.length}}for(let e of o)for(let t=0;t<e.lines.length;t++)e.lines[t].endsWith(`
|
|
1025
1025
|
`)?e.lines[t]=e.lines[t].slice(0,-1):(e.lines.splice(t+1,0,`\`),t++);return{oldFileName:e,newFileName:t,oldHeader:i,newHeader:a,hunks:o}}}function i4(e,t){if(t||=n4,Array.isArray(e)){if(e.length>1&&!t.includeFileHeaders&&!e.every(e=>e.isGit))throw Error(`Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)`);return e.map(e=>i4(e,t)).join(`
|
|
1026
1026
|
`)}let n=[];if(e.isGit){if(t=n4,!e.oldFileName)throw Error(`oldFileName must be specified for Git patches`);if(!e.newFileName)throw Error(`newFileName must be specified for Git patches`);let r=e.oldFileName,i=e.newFileName;e.isCreate&&r===`/dev/null`?r=i.replace(/^b\//,`a/`):e.isDelete&&i===`/dev/null`&&(i=r.replace(/^a\//,`b/`)),n.push(`diff --git `+t4(r)+` `+t4(i)),e.isDelete&&n.push(`deleted file mode `+(e.oldMode??`100644`)),e.isCreate&&n.push(`new file mode `+(e.newMode??`100644`)),e.oldMode&&e.newMode&&!e.isDelete&&!e.isCreate&&(n.push(`old mode `+e.oldMode),n.push(`new mode `+e.newMode)),e.isRename&&(n.push(`rename from `+t4((e.oldFileName??``).replace(/^a\//,``))),n.push(`rename to `+t4((e.newFileName??``).replace(/^b\//,``)))),e.isCopy&&(n.push(`copy from `+t4((e.oldFileName??``).replace(/^a\//,``))),n.push(`copy to `+t4((e.newFileName??``).replace(/^b\//,``))))}else t.includeIndex&&e.oldFileName==e.newFileName&&e.oldFileName!==void 0&&n.push(`Index: `+e.oldFileName),t.includeUnderline&&n.push(`===================================================================`);let r=e.hunks.length>0;t.includeFileHeaders&&e.oldFileName!==void 0&&e.newFileName!==void 0&&(!e.isGit||r)&&(n.push(`--- `+t4(e.oldFileName)+(e.oldHeader?` `+e.oldHeader:``)),n.push(`+++ `+t4(e.newFileName)+(e.newHeader?` `+e.newHeader:``)));for(let t=0;t<e.hunks.length;t++){let r=e.hunks[t],i=r.oldLines===0?r.oldStart-1:r.oldStart,a=r.newLines===0?r.newStart-1:r.newStart;n.push(`@@ -`+i+`,`+r.oldLines+` +`+a+`,`+r.newLines+` @@`);for(let e of r.lines)n.push(e)}return n.join(`
|
|
1027
1027
|
`)+`
|
|
1028
|
-
`}function
|
|
1028
|
+
`}function T3e(e,t,n,r,i,a,o){if(typeof o==`function`&&(o={callback:o}),o?.callback){let{callback:s}=o;r4(e,t,n,r,i,a,Object.assign(Object.assign({},o),{callback:e=>{s(e?i4(e,o.headerOptions):void 0)}}))}else{let s=r4(e,t,n,r,i,a,o);return s?i4(s,o?.headerOptions):void 0}}function E3e(e){let t=e.endsWith(`
|
|
1029
1029
|
`),n=e.split(`
|
|
1030
1030
|
`).map(e=>e+`
|
|
1031
|
-
`);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function a4(e,t){return e?.cacheKey===t?.cacheKey&&e?.contents===t?.contents&&e?.name===t?.name&&e?.lang===t?.lang}function o4(e){return{type:`text`,value:e}}function s4({tagName:e,children:t=[],properties:n={}}){return{type:`element`,tagName:e,properties:n,children:t}}function c4({name:e,width:t=16,height:n=16,properties:r}){return s4({tagName:`svg`,properties:{width:t,height:n,viewBox:`0 0 16 16`,...r},children:[s4({tagName:`use`,properties:{href:`#${e.replace(/^#/,``)}`}})]})}function b3e(e){let t=e.children[0];for(;t!=null;){if(t.type===`element`&&t.tagName===`code`)return t;t=`children`in t?t.children[0]:null}}function x3e(e){return s4({tagName:`div`,properties:{"data-gutter":``},children:e})}function S3e(e,t,n,r={}){return s4({tagName:`div`,properties:{"data-line-type":e,"data-column-number":t,"data-line-index":n,...r},children:t==null?void 0:[s4({tagName:`span`,properties:{"data-line-number-content":``},children:[o4(`${t}`)]})]})}function C3e(e,t,n){return s4({tagName:`div`,properties:{"data-gutter-buffer":t,"data-buffer-size":n,"data-line-type":t===`annotation`?void 0:e,style:t===`annotation`?`grid-row: span ${n};`:`grid-row: span ${n};min-height:calc(${n} * 1lh);`}})}function w3e(){return s4({tagName:`button`,properties:{"data-utility-button":``,type:`button`},children:[c4({name:`diffs-icon-plus`,properties:{"data-icon":``}})]})}function T3e(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side}function l4(e){for(let t of e)if(t instanceof HTMLElement&&(t.hasAttribute(`data-utility-button`)||t.hasAttribute(`data-gutter-utility-slot`)||t.getAttribute(`slot`)===`gutter-utility-slot`||t.getAttribute(`name`)===`gutter-utility-slot`))return!0;return!1}var u4=[`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`command`,`embed`,`frame`,`hr`,`image`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`],d4=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};d4.prototype.normal={},d4.prototype.property={},d4.prototype.space=void 0;function f4(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new d4(n,r,t)}function p4(e){return e.toLowerCase()}var m4=class{constructor(e,t){this.attribute=t,this.property=e}};m4.prototype.attribute=``,m4.prototype.booleanish=!1,m4.prototype.boolean=!1,m4.prototype.commaOrSpaceSeparated=!1,m4.prototype.commaSeparated=!1,m4.prototype.defined=!1,m4.prototype.mustUseProperty=!1,m4.prototype.number=!1,m4.prototype.overloadedBoolean=!1,m4.prototype.property=``,m4.prototype.spaceSeparated=!1,m4.prototype.space=void 0;var h4=e({boolean:()=>g4,booleanish:()=>_4,commaOrSpaceSeparated:()=>x4,commaSeparated:()=>b4,number:()=>$,overloadedBoolean:()=>v4,spaceSeparated:()=>y4}),E3e=0,g4=S4(),_4=S4(),v4=S4(),$=S4(),y4=S4(),b4=S4(),x4=S4();function S4(){return 2**++E3e}var C4=Object.keys(h4),w4=class extends m4{constructor(e,t,n,r){let i=-1;if(super(e,t),T4(this,`space`,r),typeof n==`number`)for(;++i<C4.length;){let e=C4[i];T4(this,C4[i],(n&h4[e])===h4[e])}}};w4.prototype.defined=!0;function T4(e,t,n){n&&(e[t]=n)}function E4(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new w4(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[p4(r)]=r,n[p4(a.attribute)]=r}return new d4(t,n,e.space)}var D4=E4({properties:{ariaActiveDescendant:null,ariaAtomic:_4,ariaAutoComplete:null,ariaBusy:_4,ariaChecked:_4,ariaColCount:$,ariaColIndex:$,ariaColSpan:$,ariaControls:y4,ariaCurrent:null,ariaDescribedBy:y4,ariaDetails:null,ariaDisabled:_4,ariaDropEffect:y4,ariaErrorMessage:null,ariaExpanded:_4,ariaFlowTo:y4,ariaGrabbed:_4,ariaHasPopup:null,ariaHidden:_4,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:y4,ariaLevel:$,ariaLive:null,ariaModal:_4,ariaMultiLine:_4,ariaMultiSelectable:_4,ariaOrientation:null,ariaOwns:y4,ariaPlaceholder:null,ariaPosInSet:$,ariaPressed:_4,ariaReadOnly:_4,ariaRelevant:null,ariaRequired:_4,ariaRoleDescription:y4,ariaRowCount:$,ariaRowIndex:$,ariaRowSpan:$,ariaSelected:_4,ariaSetSize:$,ariaSort:null,ariaValueMax:$,ariaValueMin:$,ariaValueNow:$,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function O4(e,t){return t in e?e[t]:t}function k4(e,t){return O4(e,t.toLowerCase())}var D3e=E4({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:b4,acceptCharset:y4,accessKey:y4,action:null,allow:null,allowFullScreen:g4,allowPaymentRequest:g4,allowUserMedia:g4,alt:null,as:null,async:g4,autoCapitalize:null,autoComplete:y4,autoFocus:g4,autoPlay:g4,blocking:y4,capture:null,charSet:null,checked:g4,cite:null,className:y4,cols:$,colSpan:null,content:null,contentEditable:_4,controls:g4,controlsList:y4,coords:$|b4,crossOrigin:null,data:null,dateTime:null,decoding:null,default:g4,defer:g4,dir:null,dirName:null,disabled:g4,download:v4,draggable:_4,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:g4,formTarget:null,headers:y4,height:$,hidden:v4,high:$,href:null,hrefLang:null,htmlFor:y4,httpEquiv:y4,id:null,imageSizes:null,imageSrcSet:null,inert:g4,inputMode:null,integrity:null,is:null,isMap:g4,itemId:null,itemProp:y4,itemRef:y4,itemScope:g4,itemType:y4,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:g4,low:$,manifest:null,max:null,maxLength:$,media:null,method:null,min:null,minLength:$,multiple:g4,muted:g4,name:null,nonce:null,noModule:g4,noValidate:g4,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:g4,optimum:$,pattern:null,ping:y4,placeholder:null,playsInline:g4,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:g4,referrerPolicy:null,rel:y4,required:g4,reversed:g4,rows:$,rowSpan:$,sandbox:y4,scope:null,scoped:g4,seamless:g4,selected:g4,shadowRootClonable:g4,shadowRootDelegatesFocus:g4,shadowRootMode:null,shape:null,size:$,sizes:null,slot:null,span:$,spellCheck:_4,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$,step:null,style:null,tabIndex:$,target:null,title:null,translate:null,type:null,typeMustMatch:g4,useMap:null,value:_4,width:$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:y4,axis:null,background:null,bgColor:null,border:$,borderColor:null,bottomMargin:$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:g4,declare:g4,event:null,face:null,frame:null,frameBorder:null,hSpace:$,leftMargin:$,link:null,longDesc:null,lowSrc:null,marginHeight:$,marginWidth:$,noResize:g4,noHref:g4,noShade:g4,noWrap:g4,object:null,profile:null,prompt:null,rev:null,rightMargin:$,rules:null,scheme:null,scrolling:_4,standby:null,summary:null,text:null,topMargin:$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:g4,disableRemotePlayback:g4,prefix:null,property:null,results:$,security:null,unselectable:null},space:`html`,transform:k4}),O3e=E4({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:x4,accentHeight:$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$,amplitude:$,arabicForm:null,ascent:$,attributeName:null,attributeType:null,azimuth:$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$,by:null,calcMode:null,capHeight:$,className:y4,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:$,diffuseConstant:$,direction:null,display:null,dur:null,divisor:$,dominantBaseline:null,download:g4,dx:null,dy:null,edgeMode:null,editable:null,elevation:$,enableBackground:null,end:null,event:null,exponent:$,externalResourcesRequired:null,fill:null,fillOpacity:$,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:b4,g2:b4,glyphName:b4,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$,horizOriginX:$,horizOriginY:$,id:null,ideographic:$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$,k:$,k1:$,k2:$,k3:$,k4:$,kernelMatrix:x4,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:$,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:$,overlineThickness:$,paintOrder:null,panose1:null,path:null,pathLength:$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:y4,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$,pointsAtY:$,pointsAtZ:$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:x4,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:x4,rev:x4,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:x4,requiredFeatures:x4,requiredFonts:x4,requiredFormats:x4,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:$,specularExponent:$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$,strikethroughThickness:$,string:null,stroke:null,strokeDashArray:x4,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$,strokeOpacity:$,strokeWidth:null,style:null,surfaceScale:$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:x4,tabIndex:$,tableValues:null,target:null,targetX:$,targetY:$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:x4,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$,underlineThickness:$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$,values:null,vAlphabetic:$,vMathematical:$,vectorEffect:null,vHanging:$,vIdeographic:$,version:null,vertAdvY:$,vertOriginX:$,vertOriginY:$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:O4}),A4=E4({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),j4=E4({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:k4}),M4=E4({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),k3e=/[A-Z]/g,N4=/-[a-z]/g,A3e=/^data[-\w.:]+$/i;function P4(e,t){let n=p4(t),r=t,i=m4;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&A3e.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(N4,M3e);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!N4.test(e)){let n=e.replace(k3e,j3e);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=w4}return new i(r,t)}function j3e(e){return`-`+e.toLowerCase()}function M3e(e){return e.charAt(1).toUpperCase()}var F4=f4([D4,D3e,A4,j4,M4],`html`),I4=f4([D4,O3e,A4,j4,M4],`svg`),L4={}.hasOwnProperty;function R4(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&L4.call(t,e)){let n=String(t[e]);i=L4.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var N3e=/["&'<>`]/g,P3e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,F3e=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,I3e=/[|\\{}()[\]^$+*?.]/g,z4=new WeakMap;function L3e(e,t){if(e=e.replace(t.subset?R3e(t.subset):N3e,r),t.subset||t.escapeOnly)return e;return e.replace(P3e,n).replace(F3e,r);function n(e,n,r){return t.format((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),t)}function r(e,n,r){return t.format(e.charCodeAt(0),r.charCodeAt(n+1),t)}}function R3e(e){let t=z4.get(e);return t||(t=z3e(e),z4.set(e,t)),t}function z3e(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(I3e,`\\$&`));return RegExp(`(?:`+t.join(`|`)+`)`,`g`)}var B3e=/[\dA-Fa-f]/;function V3e(e,t,n){let r=`&#x`+e.toString(16).toUpperCase();return n&&t&&!B3e.test(String.fromCharCode(t))?r:r+`;`}var H3e=/\d/;function U3e(e,t,n){let r=`&#`+String(e);return n&&t&&!H3e.test(String.fromCharCode(t))?r:r+`;`}var W3e=`AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`),B4={nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:``,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,quot:`"`,amp:`&`,lt:`<`,gt:`>`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:``,zwj:``,lrm:``,rlm:``,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`,euro:`€`},G3e=[`cent`,`copy`,`divide`,`gt`,`lt`,`not`,`para`,`times`],V4={}.hasOwnProperty,H4={},U4;for(U4 in B4)V4.call(B4,U4)&&(H4[B4[U4]]=U4);var K3e=/[^\dA-Za-z]/;function q3e(e,t,n,r){let i=String.fromCharCode(e);if(V4.call(H4,i)){let e=H4[i],a=`&`+e;return n&&W3e.includes(e)&&!G3e.includes(e)&&(!r||t&&t!==61&&K3e.test(String.fromCharCode(t)))?a:a+`;`}return``}function J3e(e,t,n){let r=V3e(e,t,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=q3e(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){let i=U3e(e,t,n.omitOptionalSemicolons);i.length<r.length&&(r=i)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function W4(e,t){return L3e(e,Object.assign({format:J3e},t))}var Y3e=/^>|^->|<!--|-->|--!>|<!-$/g,X3e=[`>`],Z3e=[`<`,`>`];function Q3e(e,t,n,r){return r.settings.bogusComments?`<?`+W4(e.value,Object.assign({},r.settings.characterReferences,{subset:X3e}))+`>`:`<!--`+e.value.replace(Y3e,i)+`-->`;function i(e){return W4(e,Object.assign({},r.settings.characterReferences,{subset:Z3e}))}}function $3e(e,t,n,r){return`<!`+(r.settings.upperDoctype?`DOCTYPE`:`doctype`)+(r.settings.tightDoctype?``:` `)+`html>`}function G4(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function e6e(e){let t=[],n=String(e||``),r=n.indexOf(`,`),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);let e=n.slice(i,r).trim();(e||!a)&&t.push(e),i=r+1,r=n.indexOf(`,`,i)}return t}function K4(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}function t6e(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function q4(e){return e.join(` `).trim()}var n6e=/[ \t\n\f\r]/g;function J4(e){return typeof e==`object`?e.type===`text`&&Y4(e.value):Y4(e)}function Y4(e){return e.replace(n6e,``)===``}var X4=Q4(1),Z4=Q4(-1),r6e=[];function Q4(e){return t;function t(t,n,r){let i=t?t.children:r6e,a=(n||0)+e,o=i[a];if(!r)for(;o&&J4(o);)a+=e,o=i[a];return o}}var i6e={}.hasOwnProperty;function $4(e){return t;function t(t,n,r){return i6e.call(e,t.tagName)&&e[t.tagName](t,n,r)}}var e3=$4({body:o6e,caption:t3,colgroup:t3,dd:u6e,dt:l6e,head:t3,html:a6e,li:c6e,optgroup:d6e,option:f6e,p:s6e,rp:n3,rt:n3,tbody:m6e,td:r3,tfoot:h6e,th:r3,thead:p6e,tr:g6e});function t3(e,t,n){let r=X4(n,t,!0);return!r||r.type!==`comment`&&!(r.type===`text`&&J4(r.value.charAt(0)))}function a6e(e,t,n){let r=X4(n,t);return!r||r.type!==`comment`}function o6e(e,t,n){let r=X4(n,t);return!r||r.type!==`comment`}function s6e(e,t,n){let r=X4(n,t);return r?r.type===`element`&&(r.tagName===`address`||r.tagName===`article`||r.tagName===`aside`||r.tagName===`blockquote`||r.tagName===`details`||r.tagName===`div`||r.tagName===`dl`||r.tagName===`fieldset`||r.tagName===`figcaption`||r.tagName===`figure`||r.tagName===`footer`||r.tagName===`form`||r.tagName===`h1`||r.tagName===`h2`||r.tagName===`h3`||r.tagName===`h4`||r.tagName===`h5`||r.tagName===`h6`||r.tagName===`header`||r.tagName===`hgroup`||r.tagName===`hr`||r.tagName===`main`||r.tagName===`menu`||r.tagName===`nav`||r.tagName===`ol`||r.tagName===`p`||r.tagName===`pre`||r.tagName===`section`||r.tagName===`table`||r.tagName===`ul`):!n||n.type!==`element`||n.tagName!==`a`&&n.tagName!==`audio`&&n.tagName!==`del`&&n.tagName!==`ins`&&n.tagName!==`map`&&n.tagName!==`noscript`&&n.tagName!==`video`}function c6e(e,t,n){let r=X4(n,t);return!r||r.type===`element`&&r.tagName===`li`}function l6e(e,t,n){let r=X4(n,t);return!!(r&&r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`))}function u6e(e,t,n){let r=X4(n,t);return!r||r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`)}function n3(e,t,n){let r=X4(n,t);return!r||r.type===`element`&&(r.tagName===`rp`||r.tagName===`rt`)}function d6e(e,t,n){let r=X4(n,t);return!r||r.type===`element`&&r.tagName===`optgroup`}function f6e(e,t,n){let r=X4(n,t);return!r||r.type===`element`&&(r.tagName===`option`||r.tagName===`optgroup`)}function p6e(e,t,n){let r=X4(n,t);return!!(r&&r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`))}function m6e(e,t,n){let r=X4(n,t);return!r||r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`)}function h6e(e,t,n){return!X4(n,t)}function g6e(e,t,n){let r=X4(n,t);return!r||r.type===`element`&&r.tagName===`tr`}function r3(e,t,n){let r=X4(n,t);return!r||r.type===`element`&&(r.tagName===`td`||r.tagName===`th`)}var _6e=$4({body:b6e,colgroup:x6e,head:y6e,html:v6e,tbody:S6e});function v6e(e){let t=X4(e,-1);return!t||t.type!==`comment`}function y6e(e){let t=new Set;for(let n of e.children)if(n.type===`element`&&(n.tagName===`base`||n.tagName===`title`)){if(t.has(n.tagName))return!1;t.add(n.tagName)}let n=e.children[0];return!n||n.type===`element`}function b6e(e){let t=X4(e,-1,!0);return!t||t.type!==`comment`&&!(t.type===`text`&&J4(t.value.charAt(0)))&&(t.type!==`element`||t.tagName!==`meta`&&t.tagName!==`link`&&t.tagName!==`script`&&t.tagName!==`style`&&t.tagName!==`template`)}function x6e(e,t,n){let r=Z4(n,t),i=X4(e,-1,!0);return n&&r&&r.type===`element`&&r.tagName===`colgroup`&&e3(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`col`)}function S6e(e,t,n){let r=Z4(n,t),i=X4(e,-1);return n&&r&&r.type===`element`&&(r.tagName===`thead`||r.tagName===`tbody`)&&e3(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`tr`)}var i3={name:[[`
|
|
1031
|
+
`);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function a4(e,t){return e?.cacheKey===t?.cacheKey&&e?.contents===t?.contents&&e?.name===t?.name&&e?.lang===t?.lang}function o4(e){return{type:`text`,value:e}}function s4({tagName:e,children:t=[],properties:n={}}){return{type:`element`,tagName:e,properties:n,children:t}}function c4({name:e,width:t=16,height:n=16,properties:r}){return s4({tagName:`svg`,properties:{width:t,height:n,viewBox:`0 0 16 16`,...r},children:[s4({tagName:`use`,properties:{href:`#${e.replace(/^#/,``)}`}})]})}function D3e(e){let t=e.children[0];for(;t!=null;){if(t.type===`element`&&t.tagName===`code`)return t;t=`children`in t?t.children[0]:null}}function O3e(e){return s4({tagName:`div`,properties:{"data-gutter":``},children:e})}function k3e(e,t,n,r={}){return s4({tagName:`div`,properties:{"data-line-type":e,"data-column-number":t,"data-line-index":n,...r},children:t==null?void 0:[s4({tagName:`span`,properties:{"data-line-number-content":``},children:[o4(`${t}`)]})]})}function A3e(e,t,n){return s4({tagName:`div`,properties:{"data-gutter-buffer":t,"data-buffer-size":n,"data-line-type":t===`annotation`?void 0:e,style:t===`annotation`?`grid-row: span ${n};`:`grid-row: span ${n};min-height:calc(${n} * 1lh);`}})}function j3e(){return s4({tagName:`button`,properties:{"data-utility-button":``,type:`button`},children:[c4({name:`diffs-icon-plus`,properties:{"data-icon":``}})]})}function M3e(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side}function l4(e){for(let t of e)if(t instanceof HTMLElement&&(t.hasAttribute(`data-utility-button`)||t.hasAttribute(`data-gutter-utility-slot`)||t.getAttribute(`slot`)===`gutter-utility-slot`||t.getAttribute(`name`)===`gutter-utility-slot`))return!0;return!1}var u4=[`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`command`,`embed`,`frame`,`hr`,`image`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`],d4=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};d4.prototype.normal={},d4.prototype.property={},d4.prototype.space=void 0;function f4(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new d4(n,r,t)}function p4(e){return e.toLowerCase()}var m4=class{constructor(e,t){this.attribute=t,this.property=e}};m4.prototype.attribute=``,m4.prototype.booleanish=!1,m4.prototype.boolean=!1,m4.prototype.commaOrSpaceSeparated=!1,m4.prototype.commaSeparated=!1,m4.prototype.defined=!1,m4.prototype.mustUseProperty=!1,m4.prototype.number=!1,m4.prototype.overloadedBoolean=!1,m4.prototype.property=``,m4.prototype.spaceSeparated=!1,m4.prototype.space=void 0;var h4=e({boolean:()=>g4,booleanish:()=>_4,commaOrSpaceSeparated:()=>x4,commaSeparated:()=>b4,number:()=>$,overloadedBoolean:()=>v4,spaceSeparated:()=>y4}),N3e=0,g4=S4(),_4=S4(),v4=S4(),$=S4(),y4=S4(),b4=S4(),x4=S4();function S4(){return 2**++N3e}var C4=Object.keys(h4),w4=class extends m4{constructor(e,t,n,r){let i=-1;if(super(e,t),T4(this,`space`,r),typeof n==`number`)for(;++i<C4.length;){let e=C4[i];T4(this,C4[i],(n&h4[e])===h4[e])}}};w4.prototype.defined=!0;function T4(e,t,n){n&&(e[t]=n)}function E4(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new w4(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[p4(r)]=r,n[p4(a.attribute)]=r}return new d4(t,n,e.space)}var D4=E4({properties:{ariaActiveDescendant:null,ariaAtomic:_4,ariaAutoComplete:null,ariaBusy:_4,ariaChecked:_4,ariaColCount:$,ariaColIndex:$,ariaColSpan:$,ariaControls:y4,ariaCurrent:null,ariaDescribedBy:y4,ariaDetails:null,ariaDisabled:_4,ariaDropEffect:y4,ariaErrorMessage:null,ariaExpanded:_4,ariaFlowTo:y4,ariaGrabbed:_4,ariaHasPopup:null,ariaHidden:_4,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:y4,ariaLevel:$,ariaLive:null,ariaModal:_4,ariaMultiLine:_4,ariaMultiSelectable:_4,ariaOrientation:null,ariaOwns:y4,ariaPlaceholder:null,ariaPosInSet:$,ariaPressed:_4,ariaReadOnly:_4,ariaRelevant:null,ariaRequired:_4,ariaRoleDescription:y4,ariaRowCount:$,ariaRowIndex:$,ariaRowSpan:$,ariaSelected:_4,ariaSetSize:$,ariaSort:null,ariaValueMax:$,ariaValueMin:$,ariaValueNow:$,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function O4(e,t){return t in e?e[t]:t}function k4(e,t){return O4(e,t.toLowerCase())}var P3e=E4({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:b4,acceptCharset:y4,accessKey:y4,action:null,allow:null,allowFullScreen:g4,allowPaymentRequest:g4,allowUserMedia:g4,alt:null,as:null,async:g4,autoCapitalize:null,autoComplete:y4,autoFocus:g4,autoPlay:g4,blocking:y4,capture:null,charSet:null,checked:g4,cite:null,className:y4,cols:$,colSpan:null,content:null,contentEditable:_4,controls:g4,controlsList:y4,coords:$|b4,crossOrigin:null,data:null,dateTime:null,decoding:null,default:g4,defer:g4,dir:null,dirName:null,disabled:g4,download:v4,draggable:_4,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:g4,formTarget:null,headers:y4,height:$,hidden:v4,high:$,href:null,hrefLang:null,htmlFor:y4,httpEquiv:y4,id:null,imageSizes:null,imageSrcSet:null,inert:g4,inputMode:null,integrity:null,is:null,isMap:g4,itemId:null,itemProp:y4,itemRef:y4,itemScope:g4,itemType:y4,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:g4,low:$,manifest:null,max:null,maxLength:$,media:null,method:null,min:null,minLength:$,multiple:g4,muted:g4,name:null,nonce:null,noModule:g4,noValidate:g4,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:g4,optimum:$,pattern:null,ping:y4,placeholder:null,playsInline:g4,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:g4,referrerPolicy:null,rel:y4,required:g4,reversed:g4,rows:$,rowSpan:$,sandbox:y4,scope:null,scoped:g4,seamless:g4,selected:g4,shadowRootClonable:g4,shadowRootDelegatesFocus:g4,shadowRootMode:null,shape:null,size:$,sizes:null,slot:null,span:$,spellCheck:_4,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$,step:null,style:null,tabIndex:$,target:null,title:null,translate:null,type:null,typeMustMatch:g4,useMap:null,value:_4,width:$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:y4,axis:null,background:null,bgColor:null,border:$,borderColor:null,bottomMargin:$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:g4,declare:g4,event:null,face:null,frame:null,frameBorder:null,hSpace:$,leftMargin:$,link:null,longDesc:null,lowSrc:null,marginHeight:$,marginWidth:$,noResize:g4,noHref:g4,noShade:g4,noWrap:g4,object:null,profile:null,prompt:null,rev:null,rightMargin:$,rules:null,scheme:null,scrolling:_4,standby:null,summary:null,text:null,topMargin:$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:g4,disableRemotePlayback:g4,prefix:null,property:null,results:$,security:null,unselectable:null},space:`html`,transform:k4}),F3e=E4({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:x4,accentHeight:$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$,amplitude:$,arabicForm:null,ascent:$,attributeName:null,attributeType:null,azimuth:$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$,by:null,calcMode:null,capHeight:$,className:y4,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:$,diffuseConstant:$,direction:null,display:null,dur:null,divisor:$,dominantBaseline:null,download:g4,dx:null,dy:null,edgeMode:null,editable:null,elevation:$,enableBackground:null,end:null,event:null,exponent:$,externalResourcesRequired:null,fill:null,fillOpacity:$,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:b4,g2:b4,glyphName:b4,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$,horizOriginX:$,horizOriginY:$,id:null,ideographic:$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$,k:$,k1:$,k2:$,k3:$,k4:$,kernelMatrix:x4,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:$,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:$,overlineThickness:$,paintOrder:null,panose1:null,path:null,pathLength:$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:y4,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$,pointsAtY:$,pointsAtZ:$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:x4,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:x4,rev:x4,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:x4,requiredFeatures:x4,requiredFonts:x4,requiredFormats:x4,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:$,specularExponent:$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$,strikethroughThickness:$,string:null,stroke:null,strokeDashArray:x4,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$,strokeOpacity:$,strokeWidth:null,style:null,surfaceScale:$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:x4,tabIndex:$,tableValues:null,target:null,targetX:$,targetY:$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:x4,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$,underlineThickness:$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$,values:null,vAlphabetic:$,vMathematical:$,vectorEffect:null,vHanging:$,vIdeographic:$,version:null,vertAdvY:$,vertOriginX:$,vertOriginY:$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:O4}),A4=E4({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),j4=E4({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:k4}),M4=E4({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),I3e=/[A-Z]/g,N4=/-[a-z]/g,L3e=/^data[-\w.:]+$/i;function P4(e,t){let n=p4(t),r=t,i=m4;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&L3e.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(N4,z3e);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!N4.test(e)){let n=e.replace(I3e,R3e);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=w4}return new i(r,t)}function R3e(e){return`-`+e.toLowerCase()}function z3e(e){return e.charAt(1).toUpperCase()}var F4=f4([D4,P3e,A4,j4,M4],`html`),I4=f4([D4,F3e,A4,j4,M4],`svg`),L4={}.hasOwnProperty;function R4(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&L4.call(t,e)){let n=String(t[e]);i=L4.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var B3e=/["&'<>`]/g,V3e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,H3e=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,U3e=/[|\\{}()[\]^$+*?.]/g,z4=new WeakMap;function W3e(e,t){if(e=e.replace(t.subset?G3e(t.subset):B3e,r),t.subset||t.escapeOnly)return e;return e.replace(V3e,n).replace(H3e,r);function n(e,n,r){return t.format((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),t)}function r(e,n,r){return t.format(e.charCodeAt(0),r.charCodeAt(n+1),t)}}function G3e(e){let t=z4.get(e);return t||(t=K3e(e),z4.set(e,t)),t}function K3e(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(U3e,`\\$&`));return RegExp(`(?:`+t.join(`|`)+`)`,`g`)}var q3e=/[\dA-Fa-f]/;function J3e(e,t,n){let r=`&#x`+e.toString(16).toUpperCase();return n&&t&&!q3e.test(String.fromCharCode(t))?r:r+`;`}var Y3e=/\d/;function X3e(e,t,n){let r=`&#`+String(e);return n&&t&&!Y3e.test(String.fromCharCode(t))?r:r+`;`}var Z3e=`AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`),B4={nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:``,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,quot:`"`,amp:`&`,lt:`<`,gt:`>`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:``,zwj:``,lrm:``,rlm:``,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`,euro:`€`},Q3e=[`cent`,`copy`,`divide`,`gt`,`lt`,`not`,`para`,`times`],V4={}.hasOwnProperty,H4={},U4;for(U4 in B4)V4.call(B4,U4)&&(H4[B4[U4]]=U4);var $3e=/[^\dA-Za-z]/;function e6e(e,t,n,r){let i=String.fromCharCode(e);if(V4.call(H4,i)){let e=H4[i],a=`&`+e;return n&&Z3e.includes(e)&&!Q3e.includes(e)&&(!r||t&&t!==61&&$3e.test(String.fromCharCode(t)))?a:a+`;`}return``}function t6e(e,t,n){let r=J3e(e,t,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=e6e(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){let i=X3e(e,t,n.omitOptionalSemicolons);i.length<r.length&&(r=i)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function W4(e,t){return W3e(e,Object.assign({format:t6e},t))}var n6e=/^>|^->|<!--|-->|--!>|<!-$/g,r6e=[`>`],i6e=[`<`,`>`];function a6e(e,t,n,r){return r.settings.bogusComments?`<?`+W4(e.value,Object.assign({},r.settings.characterReferences,{subset:r6e}))+`>`:`<!--`+e.value.replace(n6e,i)+`-->`;function i(e){return W4(e,Object.assign({},r.settings.characterReferences,{subset:i6e}))}}function o6e(e,t,n,r){return`<!`+(r.settings.upperDoctype?`DOCTYPE`:`doctype`)+(r.settings.tightDoctype?``:` `)+`html>`}function G4(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function s6e(e){let t=[],n=String(e||``),r=n.indexOf(`,`),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);let e=n.slice(i,r).trim();(e||!a)&&t.push(e),i=r+1,r=n.indexOf(`,`,i)}return t}function K4(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}function c6e(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function q4(e){return e.join(` `).trim()}var l6e=/[ \t\n\f\r]/g;function J4(e){return typeof e==`object`?e.type===`text`&&Y4(e.value):Y4(e)}function Y4(e){return e.replace(l6e,``)===``}var X4=Q4(1),Z4=Q4(-1),u6e=[];function Q4(e){return t;function t(t,n,r){let i=t?t.children:u6e,a=(n||0)+e,o=i[a];if(!r)for(;o&&J4(o);)a+=e,o=i[a];return o}}var d6e={}.hasOwnProperty;function $4(e){return t;function t(t,n,r){return d6e.call(e,t.tagName)&&e[t.tagName](t,n,r)}}var e3=$4({body:p6e,caption:t3,colgroup:t3,dd:_6e,dt:g6e,head:t3,html:f6e,li:h6e,optgroup:v6e,option:y6e,p:m6e,rp:n3,rt:n3,tbody:x6e,td:r3,tfoot:S6e,th:r3,thead:b6e,tr:C6e});function t3(e,t,n){let r=X4(n,t,!0);return!r||r.type!==`comment`&&!(r.type===`text`&&J4(r.value.charAt(0)))}function f6e(e,t,n){let r=X4(n,t);return!r||r.type!==`comment`}function p6e(e,t,n){let r=X4(n,t);return!r||r.type!==`comment`}function m6e(e,t,n){let r=X4(n,t);return r?r.type===`element`&&(r.tagName===`address`||r.tagName===`article`||r.tagName===`aside`||r.tagName===`blockquote`||r.tagName===`details`||r.tagName===`div`||r.tagName===`dl`||r.tagName===`fieldset`||r.tagName===`figcaption`||r.tagName===`figure`||r.tagName===`footer`||r.tagName===`form`||r.tagName===`h1`||r.tagName===`h2`||r.tagName===`h3`||r.tagName===`h4`||r.tagName===`h5`||r.tagName===`h6`||r.tagName===`header`||r.tagName===`hgroup`||r.tagName===`hr`||r.tagName===`main`||r.tagName===`menu`||r.tagName===`nav`||r.tagName===`ol`||r.tagName===`p`||r.tagName===`pre`||r.tagName===`section`||r.tagName===`table`||r.tagName===`ul`):!n||n.type!==`element`||n.tagName!==`a`&&n.tagName!==`audio`&&n.tagName!==`del`&&n.tagName!==`ins`&&n.tagName!==`map`&&n.tagName!==`noscript`&&n.tagName!==`video`}function h6e(e,t,n){let r=X4(n,t);return!r||r.type===`element`&&r.tagName===`li`}function g6e(e,t,n){let r=X4(n,t);return!!(r&&r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`))}function _6e(e,t,n){let r=X4(n,t);return!r||r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`)}function n3(e,t,n){let r=X4(n,t);return!r||r.type===`element`&&(r.tagName===`rp`||r.tagName===`rt`)}function v6e(e,t,n){let r=X4(n,t);return!r||r.type===`element`&&r.tagName===`optgroup`}function y6e(e,t,n){let r=X4(n,t);return!r||r.type===`element`&&(r.tagName===`option`||r.tagName===`optgroup`)}function b6e(e,t,n){let r=X4(n,t);return!!(r&&r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`))}function x6e(e,t,n){let r=X4(n,t);return!r||r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`)}function S6e(e,t,n){return!X4(n,t)}function C6e(e,t,n){let r=X4(n,t);return!r||r.type===`element`&&r.tagName===`tr`}function r3(e,t,n){let r=X4(n,t);return!r||r.type===`element`&&(r.tagName===`td`||r.tagName===`th`)}var w6e=$4({body:D6e,colgroup:O6e,head:E6e,html:T6e,tbody:k6e});function T6e(e){let t=X4(e,-1);return!t||t.type!==`comment`}function E6e(e){let t=new Set;for(let n of e.children)if(n.type===`element`&&(n.tagName===`base`||n.tagName===`title`)){if(t.has(n.tagName))return!1;t.add(n.tagName)}let n=e.children[0];return!n||n.type===`element`}function D6e(e){let t=X4(e,-1,!0);return!t||t.type!==`comment`&&!(t.type===`text`&&J4(t.value.charAt(0)))&&(t.type!==`element`||t.tagName!==`meta`&&t.tagName!==`link`&&t.tagName!==`script`&&t.tagName!==`style`&&t.tagName!==`template`)}function O6e(e,t,n){let r=Z4(n,t),i=X4(e,-1,!0);return n&&r&&r.type===`element`&&r.tagName===`colgroup`&&e3(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`col`)}function k6e(e,t,n){let r=Z4(n,t),i=X4(e,-1);return n&&r&&r.type===`element`&&(r.tagName===`thead`||r.tagName===`tbody`)&&e3(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`tr`)}var i3={name:[[`
|
|
1032
1032
|
\f\r &/=>`.split(``),`
|
|
1033
1033
|
\f\r "&'/=>\``.split(``)],[`\0
|
|
1034
1034
|
\f\r "&'/<=>`.split(``),`\0
|
|
@@ -1036,10 +1036,10 @@ If init has been called in the preload and contextIsolation is disabled, is not
|
|
|
1036
1036
|
\f\r &>`.split(``),`\0
|
|
1037
1037
|
\f\r "&'<=>\``.split(``)],[`\0
|
|
1038
1038
|
\f\r "&'<=>\``.split(``),`\0
|
|
1039
|
-
\f\r "&'<=>\``.split(``)]],single:[[`&'`.split(``),`"&'\``.split(``)],[`\0&'`.split(``),`\0"&'\``.split(``)]],double:[[`"&`.split(``),`"&'\``.split(``)],[`\0"&`.split(``),`\0"&'\``.split(``)]]};function C6e(e,t,n,r){let i=r.schema,a=i.space!==`svg`&&r.settings.omitOptionalTags,o=i.space===`svg`?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),s=[],c;i.space===`html`&&e.tagName===`svg`&&(r.schema=I4);let l=w6e(r,e.properties),u=r.all(i.space===`html`&&e.tagName===`template`?e.content:e);return r.schema=i,u&&(o=!1),(l||!a||!_6e(e,t,n))&&(s.push(`<`,e.tagName,l?` `+l:``),o&&(i.space===`svg`||r.settings.closeSelfClosing)&&(c=l.charAt(l.length-1),(!r.settings.tightSelfClosing||c===`/`||c&&c!==`"`&&c!==`'`)&&s.push(` `),s.push(`/`)),s.push(`>`)),s.push(u),!o&&(!a||!e3(e,t,n))&&s.push(`</`+e.tagName+`>`),s.join(``)}function w6e(e,t){let n=[],r=-1,i;if(t){for(i in t)if(t[i]!==null&&t[i]!==void 0){let r=T6e(e,i,t[i]);r&&n.push(r)}}for(;++r<n.length;){let t=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&t!==`"`&&t!==`'`&&(n[r]+=` `)}return n.join(``)}function T6e(e,t,n){let r=P4(e.schema,t),i=e.settings.allowParseErrors&&e.schema.space===`html`?0:1,a=+!e.settings.allowDangerousCharacters,o=e.quote,s;if(r.overloadedBoolean&&(n===r.attribute||n===``)?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!=`string`||n===r.attribute||n===``)&&(n=!!n),n==null||n===!1||typeof n==`number`&&Number.isNaN(n))return``;let c=W4(r.attribute,Object.assign({},e.settings.characterReferences,{subset:i3.name[i][a]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?K4:q4)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?c:(e.settings.preferUnquoted&&(s=W4(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:i3.unquoted[i][a]}))),s!==n&&(e.settings.quoteSmart&&G4(n,o)>G4(n,e.alternative)&&(o=e.alternative),s=o+W4(n,Object.assign({},e.settings.characterReferences,{subset:(o===`'`?i3.single:i3.double)[i][a],attribute:!0}))+o),c+(s&&`=`+s))}var E6e=[`<`,`&`];function a3(e,t,n,r){return n&&n.type===`element`&&(n.tagName===`script`||n.tagName===`style`)?e.value:W4(e.value,Object.assign({},r.settings.characterReferences,{subset:E6e}))}function D6e(e,t,n,r){return r.settings.allowDangerousHtml?e.value:a3(e,t,n,r)}function O6e(e,t,n,r){return r.all(e)}var k6e=R4(`type`,{invalid:A6e,unknown:j6e,handlers:{comment:Q3e,doctype:$3e,element:C6e,raw:D6e,root:O6e,text:a3}});function A6e(e){throw Error("Expected node, not `"+e+"`")}function j6e(e){throw Error("Cannot compile unknown node `"+e.type+"`")}var M6e={},N6e={},P6e=[];function o3(e,t){let n=t||M6e,r=n.quote||`"`,i=r===`"`?`'`:`"`;if(r!==`"`&&r!==`'`)throw Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:F6e,all:I6e,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||u4,characterReferences:n.characterReferences||N6e,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space===`svg`?I4:F4,quote:r,alternative:i}.one(Array.isArray(e)?{type:`root`,children:e}:e,void 0,void 0)}function F6e(e,t,n){return k6e(e,t,n,this)}function I6e(e){let t=[],n=e&&e.children||P6e,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join(``)}var L6e=class{mode;options;hoveredLine;hoveredToken;pre;gutterUtilityLine;gutterUtilityContainer;gutterUtilityButton;gutterUtilitySlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasPointerListeners=!1;hasDocumentPointerListeners=!1;selectedRange=null;selectedRangeHighlightSide;selectedRangeLineNumberOnly=!1;editorActiveLine=null;editorActiveLineSide;editorLineNumberOnly=!1;proposedSelectedRange;renderedSelectedLinesState;renderedEditorActiveLineState;selectionAnchor;pointerSession={mode:`idle`};constructor(e,t){this.mode=e,this.options=t}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener(`click`,this.handlePointerClick),this.pre?.removeEventListener(`pointerdown`,this.handlePointerDown),this.pre?.removeEventListener(`pointermove`,this.handlePointerMove),this.pre?.removeEventListener(`pointerleave`,this.handlePointerLeave),this.pre?.removeAttribute(`data-interactive-lines`),this.pre?.removeAttribute(`data-interactive-line-numbers`),this.pre=void 0,this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.clearHoveredLine(),this.clearHoveredToken(),this.detachDocumentPointerListeners(),this.clearPointerSession(),k2(this.renderSelection),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasPointerListeners=!1,this.setSelectionDirty()}setup(e){this.setSelectionDirty();let{usesCustomGutterUtility:t=!1,enableGutterUtility:n=!1}=this.options;this.pre!==e&&(this.cleanUp(),this.pre=e),n?this.ensureGutterUtilityNode(t):this.gutterUtilityContainer!=null&&(this.gutterUtilityContainer.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.pointerSession.mode===`gutterSelecting`&&(this.clearPointerSession(),this.detachDocumentPointerListeners())),this.syncPointerListeners(e),this.updateInteractiveLineAttributes(),this.renderSelection(),this.placeUtility()}setSelectionDirty(){this.renderedSelectedLinesState=void 0,this.renderedEditorActiveLineState=void 0}isSelectionDirty(){return this.renderedSelectedLinesState===void 0||this.renderedEditorActiveLineState===void 0}setSelection(e,t){let n=!(e===this.selectedRange||P2(e??void 0,this.selectedRange??void 0)),r=t?.lineNumberOnly??!1,i=t?.activeLineSide!==this.selectedRangeHighlightSide||r!==this.selectedRangeLineNumberOnly;!this.isSelectionDirty()&&!n&&!i||(this.proposedSelectedRange=void 0,this.selectedRange=e,this.selectedRangeHighlightSide=t?.activeLineSide,this.selectedRangeLineNumberOnly=r,this.renderSelection(),this.placeUtility(),n&&t?.notify!==!1&&this.notifySelectionCommitted(e))}setEditorActiveLine(e,{lineNumberOnly:t=!1,side:n}={}){let r=e!==this.editorActiveLine,i=n!==this.editorActiveLineSide||t!==this.editorLineNumberOnly;!this.isSelectionDirty()&&!r&&!i||(this.editorActiveLine=e,this.editorActiveLineSide=n,this.editorLineNumberOnly=t,this.renderSelection())}getSelection(){return this.selectedRange}getHoveredLine=()=>{let e=this.gutterUtilityLine??this.hoveredLine;if(e!=null){if(this.mode===`diff`&&e.type===`diff-line`)return{lineNumber:e.lineNumber,side:e.annotationSide};if(this.mode===`file`&&e.type===`line`)return{lineNumber:e.lineNumber}}};handlePointerClick=e=>{let{onHunkExpand:t,onLineClick:n,onLineNumberClick:r,onTokenClick:i,onMergeConflictActionClick:a}=this.options;(t!=null||n!=null||r!=null||a!=null||i!=null)&&(this.options.onGutterUtilityClick!=null&&l4(e.composedPath())||(g3(this.options.__debugPointerEvents,`click`,`FileDiff.DEBUG.handlePointerClick:`,e),this.handlePointerEvent({eventType:`click`,event:e})))};handlePointerMove=e=>{if(e.pointerType!==`mouse`)return;let{lineHoverHighlight:t=`disabled`,onLineEnter:n,onLineLeave:r,onTokenEnter:i,onTokenLeave:a,enableGutterUtility:o=!1}=this.options;t===`disabled`&&!o&&n==null&&r==null&&i==null&&a==null||(g3(this.options.__debugPointerEvents,`move`,`FileDiff.DEBUG.handlePointerMove:`,e),this.handlePointerEvent({eventType:`move`,event:e}))};handlePointerLeave=e=>{let{__debugPointerEvents:t}=this.options;if(g3(t,`move`,`FileDiff.DEBUG.handlePointerLeave: no event`),this.hoveredLine==null&&this.hoveredToken==null){g3(t,`move`,`FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token`);return}this.hoveredToken!=null&&(this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken()),this.hoveredLine!=null&&(this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()),this.placeUtility()};handlePointerEvent({eventType:e,event:t}){let{__debugPointerEvents:n}=this.options,r=t.composedPath();g3(n,e,`FileDiff.DEBUG.handlePointerEvent:`,{eventType:e,composedPath:r});let i=this.resolvePointerTarget(r);g3(n,e,`FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:`,i);let{onLineClick:a,onLineNumberClick:o,onLineEnter:s,onLineLeave:c,onTokenClick:l,onTokenEnter:u,onTokenLeave:d,onHunkExpand:f,onMergeConflictActionClick:p}=this.options;switch(e){case`move`:{let e=l3(i)&&this.hoveredLine?.lineElement===i.lineElement;c3(i)&&this.hoveredToken?.tokenElement===i.tokenElement||(this.hoveredToken!=null&&(d?.(this.hoveredToken,t),this.clearHoveredToken()),c3(i)&&(this.setHoveredToken(this.toTokenEventBaseProps(i)),u?.(this.hoveredToken,t))),e||(this.hoveredLine!=null&&(c?.({...this.hoveredLine,event:t}),this.clearHoveredLine()),l3(i)?(this.setHoveredLine(this.toEventBaseProps(i)),this.placeUtility(),s?.({...this.hoveredLine,event:t})):this.placeUtility());break}case`click`:{if(i==null)break;if(V6e(i)&&p!=null){p(i);break}if(B6e(i)&&f!=null){f(i.hunkIndex,i.all||t.shiftKey?`both`:i.direction,i.all||t.shiftKey?1/0:void 0);break}if(!l3(i))break;c3(i)&&l!=null&&l(this.toTokenEventBaseProps(i),t);let e=this.toEventBaseProps(i);o!=null&&i.numberColumn?o({...e,event:t}):a?.({...e,event:t});break}}}syncPointerListeners(e){let{__debugPointerEvents:t,lineHoverHighlight:n=`disabled`,onLineClick:r,onLineNumberClick:i,onLineEnter:a,onLineLeave:o,onTokenClick:s,onTokenEnter:c,onTokenLeave:l,onHunkExpand:u,onMergeConflictActionClick:d,enableGutterUtility:f=!1,enableLineSelection:p=!1,onGutterUtilityClick:m}=this.options,h=m!=null,g=n!==`disabled`||r!=null||i!=null||a!=null||o!=null||s!=null||c!=null||l!=null||u!=null||d!=null||f||p||h;g&&!this.hasPointerListeners?(e.addEventListener(`click`,this.handlePointerClick),e.addEventListener(`pointerdown`,this.handlePointerDown),e.addEventListener(`pointermove`,this.handlePointerMove),e.addEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!0,g3(t,`click`,`FileDiff.DEBUG.attachEventListeners: Attaching click events for:`,(()=>{let e=[];return(t===`both`||t===`click`)&&(r!=null&&e.push(`onLineClick`),i!=null&&e.push(`onLineNumberClick`),u!=null&&e.push(`expandable hunk separators`),d!=null&&e.push(`merge conflict actions`)),e})()),g3(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer move event`),g3(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event`)):!g&&this.hasPointerListeners&&(e.removeEventListener(`click`,this.handlePointerClick),e.removeEventListener(`pointerdown`,this.handlePointerDown),e.removeEventListener(`pointermove`,this.handlePointerMove),e.removeEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!1);let _=this.pointerSession.mode===`selecting`||this.pointerSession.mode===`pendingSingleLineUnselect`,v=this.pointerSession.mode===`gutterSelecting`;(!p&&_||!h&&v)&&(this.clearPointerSession(),this.detachDocumentPointerListeners(),this.selectionAnchor=void 0,this.clearPendingSingleLineState())}updateInteractiveLineAttributes(){if(this.pre==null)return;let{onLineClick:e,onLineNumberClick:t,enableLineSelection:n=!1}=this.options,r=e!=null,i=t!=null||n;r&&!this.interactiveLinesAttr?(this.pre.setAttribute(`data-interactive-lines`,``),this.interactiveLinesAttr=!0):!r&&this.interactiveLinesAttr&&(this.pre.removeAttribute(`data-interactive-lines`),this.interactiveLinesAttr=!1),i&&!this.interactiveLineNumbersAttr?(this.pre.setAttribute(`data-interactive-line-numbers`,``),this.interactiveLineNumbersAttr=!0):!i&&this.interactiveLineNumbersAttr&&(this.pre.removeAttribute(`data-interactive-line-numbers`),this.interactiveLineNumbersAttr=!1)}handlePointerDown=e=>{if(e.pointerType===`mouse`&&e.button!==0||this.pre==null||this.pointerSession.mode!==`idle`)return;let t=e.composedPath();l4(t)&&this.options.onGutterUtilityClick!=null?this.startGutterSelectionFromPointerDown(e):(e.pointerType!==`mouse`&&this.revealUtilityFromGutterPath(t),this.startLineSelectionFromPointerDown(e))};startLineSelectionFromPointerDown(e){let{enableLineSelection:t=!1}=this.options;if(!t)return;let n=this.resolveSelectionInfo(e,{source:`event-path`,requireNumberColumn:!0});if(n==null)return;let{pre:r}=this;if(r==null)return;let{lineNumber:i,eventSide:a,lineIndex:o}=n;if(e.shiftKey&&this.selectedRange!=null){let t=this.getIndexesFromSelection(this.selectedRange,r.getAttribute(`data-diff-type`)===`split`);if(t==null)return;let n=t.start<=t.end?o>=t.start:o<=t.end;this.selectionAnchor={lineNumber:n?this.selectedRange.start:this.selectedRange.end,side:n?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners();return}if(this.selectedRange?.start===i&&this.selectedRange?.end===i){let t={lineNumber:i,side:a};this.selectionAnchor=t,this.pointerSession={mode:`pendingSingleLineUnselect`,pointerId:e.pointerId,anchor:t,pending:t},this.attachDocumentPointerListeners();return}this.options.controlledSelection===!0?this.proposedSelectedRange=null:this.selectedRange=null,this.placeUtility(),this.selectionAnchor={lineNumber:i,side:a},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners()}startGutterSelectionFromPointerDown(e){let{onGutterUtilityClick:t}=this.options;if(t==null)return;let n=this.currentSelectionEnds(),r=n?.bottom??this.resolveSelectionPoint(e,{source:`event-path`,excludeUtility:!1}),i=n?.top??r;r!=null&&i!=null&&(e.preventDefault(),e.stopPropagation(),this.pointerSession={mode:`gutterSelecting`,pointerId:e.pointerId,anchor:i,current:r},this.selectionAnchor={lineNumber:i.lineNumber,side:i.side},this.updateSelection(r.lineNumber,r.side,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.attachDocumentPointerListeners())}handleDocumentPointerMove=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionPoint(e,{source:`coordinates-first`});if(t==null)return;this.pointerSession.current=t,this.updateSelection(t.lineNumber,t.side);return}case`selecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;this.updateSelection(t.lineNumber,t.eventSide);return}case`pendingSingleLineUnselect`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;let n={lineNumber:t.lineNumber,side:t.eventSide};if(T3e(this.pointerSession.pending,n))return;this.updateSelection(t.lineNumber,t.eventSide,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.notifySelectionChangeDelta(),this.pointerSession={mode:`selecting`,pointerId:e.pointerId};return}}};handleDocumentPointerUp=e=>{let{onGutterUtilityClick:t}=this.options;switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{let{pointerSession:n}=this;if(e.pointerId!==n.pointerId)return;e.preventDefault();let r=this.resolveSelectionPoint(e,{source:`coordinates-first`});r!=null&&(n.current=r,this.updateSelection(r.lineNumber,r.side));let i=this.buildSelectedLineRange(n.anchor,n.current);t?.({...i}),this.selectionAnchor=void 0,this.notifySelectionEnd(i),this.notifySelectionCommitted(i),this.clearProposedSelection(),this.clearPointerSession(),this.detachDocumentPointerListeners();return}case`pendingSingleLineUnselect`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.updateSelection(null,void 0,!1),this.selectionAnchor=void 0,this.clearPendingSingleLineState(),this.detachDocumentPointerListeners(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection();return;case`selecting`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.selectionAnchor=void 0,this.detachDocumentPointerListeners(),this.clearPointerSession(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection()}};handleDocumentPointerCancel=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:case`selecting`:case`pendingSingleLineUnselect`:if(`pointerId`in this.pointerSession&&e.pointerId!==this.pointerSession.pointerId)return;this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){this.hoveredLine!=null&&(this.hoveredLine.lineElement.removeAttribute(`data-hovered`),this.hoveredLine.numberElement.removeAttribute(`data-hovered`),this.hoveredLine=void 0)}setHoveredLine(e){let{lineHoverHighlight:t=`disabled`}=this.options;this.hoveredLine!=null&&this.clearHoveredLine(),this.hoveredLine=e,t!==`disabled`&&((t===`both`||t===`line`)&&this.hoveredLine.lineElement.setAttribute(`data-hovered`,``),(t===`both`||t===`number`)&&this.hoveredLine.numberElement.setAttribute(`data-hovered`,``))}clearHoveredToken(){this.hoveredToken!=null&&(this.hoveredToken=void 0)}setHoveredToken(e){this.hoveredToken!=null&&this.clearHoveredToken(),this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer??(this.gutterUtilityContainer=document.createElement(`div`),this.gutterUtilityContainer.setAttribute(`data-gutter-utility-slot`,``)),e)this.gutterUtilityButton!=null&&(this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0),this.gutterUtilitySlot??(this.gutterUtilitySlot=document.createElement(`slot`),this.gutterUtilitySlot.name=`gutter-utility-slot`),this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){let e=document.createElement(`div`);e.innerHTML=o3(w3e());let t=e.firstElementChild;if(!(t instanceof HTMLButtonElement))throw Error(`InteractionManager.ensureGutterUtilityNode: Node element should be a button`);t.remove(),this.gutterUtilityButton=t}this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;let t=this.resolvePointerTarget(e);s3(t)&&t.numberColumn&&this.showUtilityOnLine(this.toEventBaseProps(t))}placeUtility(){if(!this.placeUtilityFromSelection()){if(this.hoveredLine!=null){this.showUtilityOnLine(this.hoveredLine);return}this.hideUtility()}}placeUtilityFromSelection(){let e=this.currentSelectionEnds();if(e==null)return!1;let t=this.targetForSelectionPoint(e.bottom);return t==null?this.hideUtility():this.showUtilityOnLine(this.toEventBaseProps(t)),!0}showUtilityOnLine(e){this.gutterUtilityContainer!=null&&(this.gutterUtilityLine=e,e.numberElement.appendChild(this.gutterUtilityContainer))}hideUtility(){this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0}currentSelectionEnds(){let e=this.getCurrentSelectionRange();return e==null?void 0:this.selectionEnds(e)}selectionEnds(e){let t={lineNumber:e.start,side:e.side},n={lineNumber:e.end,side:e.endSide??e.side},r=this.selectionPointRowIndex(t),i=this.selectionPointRowIndex(n);if(r!=null&&i!=null)return r>i?{top:n,bottom:t}:{top:t,bottom:n}}selectionPointRowIndex(e){let t=this.getLineIndex(e.lineNumber,e.side);if(t!=null)return this.isSplitDiff()?t[1]:t[0]}targetForSelectionPoint(e){if(this.pre==null)return;let t=this.getLineIndex(e.lineNumber,e.side);if(t==null)return;let n=this.mode===`diff`?`${t[0]},${t[1]}`:`${t[0]}`,r=this.pre.querySelectorAll(`[data-column-number="${e.lineNumber}"][data-line-index="${n}"]`);for(let t of r){if(!(t instanceof HTMLElement))continue;let n=this.resolvePointerTarget(d3(t));if(s3(n)&&(this.mode!==`diff`||e.side==null||n.side===e.side))return n}}attachDocumentPointerListeners(){this.hasDocumentPointerListeners||=(document.addEventListener(`pointermove`,this.handleDocumentPointerMove),document.addEventListener(`pointerup`,this.handleDocumentPointerUp),document.addEventListener(`pointercancel`,this.handleDocumentPointerCancel),!0)}detachDocumentPointerListeners(){this.hasDocumentPointerListeners&&=(document.removeEventListener(`pointermove`,this.handleDocumentPointerMove),document.removeEventListener(`pointerup`,this.handleDocumentPointerUp),document.removeEventListener(`pointercancel`,this.handleDocumentPointerCancel),!1)}clearPointerSession(){this.pointerSession={mode:`idle`}}clearPendingSingleLineState(){this.pointerSession.mode===`pendingSingleLineUnselect`&&(this.pointerSession={mode:`idle`})}selectionInfoFromPath(e,t){let n=this.resolvePointerTarget(e);if(s3(n)&&!(t&&!n.numberColumn)&&n.splitLineIndex!=null)return{lineIndex:n.splitLineIndex,lineNumber:n.lineNumber,eventSide:this.mode===`diff`?n.side:void 0}}resolveSelectionInfo(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionInfoFromPath(n,t.requireNumberColumn)}selectionPointFromPath(e){let t=this.resolvePointerTarget(e);if(s3(t))return{lineNumber:t.lineNumber,side:this.mode===`diff`?t.side:void 0}}resolveSelectionPoint(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionPointFromPath(n)}resolveSelectionPath(e,t){let n=t.excludeUtility!==!1;switch(t.source){case`event-path`:return this.pathFromEventPath(e.composedPath(),n);case`coordinates-first`:{let t=this.pathFromCoordinates(e,n);return t===void 0?this.pathFromEventPath(e.composedPath(),n):t??void 0}}}pathFromCoordinates(e,t){let n=this.hitTest(e);if(n!==void 0)return n===null?null:this.pathFromElement(n,t)??null}pathFromEventPath(e,t){if(!(t&&l4(e))){for(let n of e)if(n instanceof Element)return this.pathFromElement(n,t)}}pathFromElement(e,t){let n=d3(e);if(t&&l4(n))return;let r=U6e(e);return r==null?this.pathFromAnnotationSlot(e):d3(r)}pathFromAnnotationSlot(e){let t=G6e(W6e(e));if(t==null)return;let n=this.targetForSelectionPoint(t);return n==null?void 0:d3(n.lineElement)}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;let t=this.pre?.getRootNode(),n=f3(t)?t:f3(document)?document:void 0;if(n!=null)return n.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,t){let{getLineIndex:n}=this.options;return n==null?[e-1,e-1]:n(e,t)}getCurrentSelectionRange(){return this.proposedSelectedRange===void 0?this.selectedRange:this.proposedSelectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,t,n=!0){let r=this.getCurrentSelectionRange(),i;if(e==null)i=null;else{let n=this.selectionAnchor?.side??t,r=this.selectionAnchor?.lineNumber??e;i=this.buildSelectionRange(r,e,n,t)}P2(r??void 0,i??void 0)||(this.selectedRangeHighlightSide=void 0,this.selectedRangeLineNumberOnly=!1,this.options.controlledSelection===!0?this.proposedSelectedRange=i:(this.selectedRange=i,O2(this.renderSelection)),this.placeUtility(),n&&this.notifySelectionChangeDelta())}getIndexesFromSelection(e,t){if(this.pre==null)return;let n=this.getLineIndex(e.start,e.side),r=this.getLineIndex(e.end,e.endSide??e.side);return n!=null&&r!=null?{start:t?n[1]:n[0],end:t?r[1]:r[0]}:void 0}getSelectionRenderState(){return{selectedLines:{range:this.selectedRange,highlightSide:this.selectedRangeHighlightSide,lineNumberOnly:this.selectedRangeLineNumberOnly},editorActiveLine:{range:this.editorActiveLine==null?null:{start:this.editorActiveLine,end:this.editorActiveLine,side:this.editorActiveLineSide},highlightSide:this.editorActiveLineSide,lineNumberOnly:this.editorLineNumberOnly}}}resolveLineRenderRange(e,t,n){if(e.range==null)return;let r=this.getIndexesFromSelection(e.range,t);if(r==null)throw console.error({rowRange:r,range:e.range}),Error(`InteractionManager.renderSelection: No valid ${n} rowRange`);return r}getLineRenderColumns(e,t,n,r){if(this.pre==null||t==null&&r==null)return[];let{children:i}=this.pre;if(i.length>2)throw console.error(i),Error(`InteractionManager.renderSelection: Somehow there are more than 2 code elements...`);let a=[];for(let o of i){let i=o.hasAttribute(`data-deletions`)?`deletions`:o.hasAttribute(`data-additions`)?`additions`:void 0,s=e!=null&&t!=null&&(e.highlightSide==null||i==null||e.highlightSide===i),c=n!=null&&r!=null&&(n.highlightSide==null||i==null||n.highlightSide===i);if(!s&&!c)continue;let[l,u]=o.children;if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))throw Error(`InteractionManager.renderSelection: missing gutter or content element`);if(u.children.length!==l.children.length)throw Error(`InteractionManager.renderSelection: gutter and content children dont match, something is wrong`);a.push({content:u,gutter:l,renderEditorActiveLine:c,renderSelectedLines:s})}return a}renderSelection=()=>{k2(this.renderSelection);let e=this.getSelectionRenderState();if(this.pre==null)return;let{editorActiveLine:t,selectedLines:n}=e,r=!p3(this.renderedSelectedLinesState,n),i=!p3(this.renderedEditorActiveLineState,t);if(!r&&!i)return;r&&(this.renderedSelectedLinesState=void 0),i&&(this.renderedEditorActiveLineState=void 0);let a=this.pre.getAttribute(`data-diff-type`)===`split`,o=r?this.resolveLineRenderRange(n,a,`selected-lines`):void 0,s=i?this.resolveLineRenderRange(t,a,`editor-active-line`):void 0,c=this.getLineRenderColumns(r?n:void 0,o,i?t:void 0,s),l=n.range==null||c.some(e=>e.renderSelectedLines),u=t.range==null||c.some(e=>e.renderEditorActiveLine);if(r)for(let e of this.pre.querySelectorAll(`[data-selected-line]`))e.removeAttribute(`data-selected-line`);if(i)for(let e of this.pre.querySelectorAll(`[data-editor-active-line]`))e.removeAttribute(`data-editor-active-line`);let d=o==null?void 0:Math.min(o.start,o.end),f=o==null?void 0:Math.max(o.start,o.end),p=d===f,m=s?.start;for(let e of c){let{content:r,gutter:i,renderEditorActiveLine:o,renderSelectedLines:s}=e,c=Math.max(s?f??-1/0:-1/0,o?m??-1/0:-1/0),l=r.children.length;for(let e=0;e<l;e++){let l=r.children[e],u=i.children[e];if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))continue;let h=this.parseLineIndex(l,a);if((h??0)>c)break;if(h!=null){if(s&&d!=null&&f!=null&&h>=d&&h<=f){let e=p?`single`:h===d?`first`:h===f?`last`:``;u.setAttribute(`data-selected-line`,e),n.lineNumberOnly||(l.setAttribute(`data-selected-line`,e),u.nextSibling instanceof HTMLElement&&l.nextSibling instanceof HTMLElement&&(l.nextSibling.hasAttribute(`data-line-annotation`)||l.nextSibling.hasAttribute(`data-merge-conflict-actions`))&&(p?(e=`last`,l.setAttribute(`data-selected-line`,`first`)):h===d?e=``:h===f&&l.setAttribute(`data-selected-line`,``),l.nextSibling.setAttribute(`data-selected-line`,e),u.nextSibling.setAttribute(`data-selected-line`,e)))}o&&h===m&&(u.setAttribute(`data-editor-active-line`,``),t.lineNumberOnly||l.setAttribute(`data-editor-active-line`,``))}}}r&&l&&(this.renderedSelectedLinesState=n),i&&u&&(this.renderedEditorActiveLineState=t)};notifySelectionCommitted(e){this.options.onLineSelected?.(e)}notifySelectionChangeDelta(){this.options.onLineSelectionChange?.(this.getCurrentSelectionRange()??null)}notifySelectionStart(e){this.options.onLineSelectionStart?.(e)}notifySelectionEnd(e){this.options.onLineSelectionEnd?.(e)}toEventBaseProps(e){return this.mode===`file`?{type:`line`,lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement}:{type:`diff-line`,annotationSide:e.side,lineType:e.lineType,lineElement:e.lineElement,numberElement:e.numberElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn}}toTokenEventBaseProps({lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}){return this.mode===`file`?{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,tokenElement:i,tokenText:a}:{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}}buildSelectedLineRange(e,t){return this.buildSelectionRange(e.lineNumber,t.lineNumber,e.side,t.side)}buildSelectionRange(e,t,n,r){return{start:e,end:t,...n==null?{}:{side:n},...n!==r&&r!=null?{endSide:r}:{}}}resolvePointerTarget(e){let t=!1,n,r,i,a,o,s,c,l,u,d;for(let f of e){if(!(f instanceof HTMLElement))continue;if(d==null&&f.hasAttribute(`data-merge-conflict-action`)){let e=f.getAttribute(`data-merge-conflict-action`)??void 0,t=f.getAttribute(`data-merge-conflict-conflict-index`)??void 0,n=t==null?NaN:Number.parseInt(t,10);H6e(e)&&Number.isFinite(n)&&(d={kind:`merge-conflict-action`,resolution:e,conflictIndex:n})}if(s==null&&f.hasAttribute(`data-char`)){s=f;let e=f.getAttribute(`data-char`);if(e!=null){let t=Number.parseInt(e,10);if(!Number.isNaN(t)){let e=f.textContent??``,n=t+e.length;(e.trim()!==``||this.options.enableTokenInteractionsOnWhitespace===!0)&&(c={tokenElement:s,lineCharStart:t,lineCharEnd:n,tokenText:e});continue}}}let e=o==null?f.getAttribute(`data-column-number`)??void 0:void 0;if(e!=null){o=f,u=Number.parseInt(e,10),t=!0,n=h3(f),a=f.getAttribute(`data-line-index`)??void 0;continue}let p=i==null?f.getAttribute(`data-line`)??void 0:void 0;if(p!=null){i=f,u=Number.parseInt(p,10),n=h3(f),a=f.getAttribute(`data-line-index`)??void 0;continue}if(l==null&&(f.hasAttribute(`data-expand-button`)||f.hasAttribute(`data-unmodified-lines`))){l={hunkIndex:void 0,direction:f.hasAttribute(`data-expand-up`)?`up`:f.hasAttribute(`data-expand-down`)?`down`:`both`,all:f.hasAttribute(`data-expand-all-button`)};continue}let m=l==null?void 0:f.getAttribute(`data-expand-index`)??void 0;if(l!=null&&m!=null){let e=Number.parseInt(m,10);Number.isNaN(e)||(l.hunkIndex=e);continue}if(r==null&&f.hasAttribute(`data-code`)){r=f;break}}if(d!=null)return d;if(l?.hunkIndex!=null)return{type:`line-info`,hunkIndex:l.hunkIndex,direction:l.direction,all:l.all};if(i??=a==null?void 0:u3(r,`[data-line][data-line-index="${a}"]`),o??=a==null?void 0:u3(r,`[data-column-number][data-line-index="${a}"]`),r==null||i==null||o==null||n==null||u==null||Number.isNaN(u))return;let f=this.parseLineIndex(i,this.isSplitDiff());return c==null?this.mode===`file`?{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f}:{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:m3(n,r),splitLineIndex:f}:this.mode===`file`?{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f,...c}:{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:m3(n,r),splitLineIndex:f,...c}}isSplitDiff(){return this.pre?.getAttribute(`data-diff-type`)===`split`}parseLineIndex(e,t){let n=(e.getAttribute(`data-line-index`)??``).split(`,`).map(e=>Number.parseInt(e,10)).filter(e=>!Number.isNaN(e));if(t&&n.length===2)return n[1];if(!t)return n[0]}};function R6e({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:t,lineHoverHighlight:n,onGutterUtilityClick:r,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,renderGutterUtility:d,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v},y,b,x){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:z6e({enableGutterUtility:t,renderGutterUtility:d,onGutterUtilityClick:r}),usesCustomGutterUtility:d!=null,lineHoverHighlight:n,onGutterUtilityClick:r,onHunkExpand:y,onMergeConflictActionClick:x,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v,getLineIndex:b}}function z6e({enableGutterUtility:e,renderGutterUtility:t,onGutterUtilityClick:n}){if(n!=null&&t!=null)throw Error(`Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.`);return e??!1}function s3(e){return e!=null&&`kind`in e&&e.kind===`line`}function c3(e){return e!=null&&`kind`in e&&e.kind===`token`}function l3(e){return s3(e)||c3(e)}function B6e(e){return`type`in e&&e.type===`line-info`}function V6e(e){return`kind`in e&&e.kind===`merge-conflict-action`}function H6e(e){return e===`current`||e===`incoming`||e===`both`}function u3(e,t){let n=e?.querySelector(t);return n instanceof HTMLElement?n:void 0}function d3(e){let t=[],n=e;for(;n!=null;)t.push(n),n=n.parentNode;return t}function U6e(e){let t=e.closest(`[data-line], [data-column-number]`);if(t instanceof HTMLElement)return t;let n=e.closest(`[data-line-annotation], [data-gutter-buffer="annotation"]`);if(!(n instanceof HTMLElement))return;let r=n.previousElementSibling;return r instanceof HTMLElement&&(r.hasAttribute(`data-line`)||r.hasAttribute(`data-column-number`))?r:void 0}function W6e(e){let t=e.closest(`[slot^="annotation-"]`);if(t instanceof HTMLElement)return t.getAttribute(`slot`)??void 0;if(e instanceof HTMLElement){let t=e.getAttribute(`name`)??void 0;return t!=null&&t.startsWith(`annotation-`)?t:void 0}}function G6e(e){if(e==null)return;let t=/^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(e);if(t==null)return;let n=Number.parseInt(t[2],10);if(!(!Number.isFinite(n)||n<=0))return{lineNumber:n,side:t[1]}}function f3(e){return e!=null&&typeof e.elementFromPoint==`function`}function K6e(e,t){return e===t||P2(e??void 0,t??void 0)}function p3(e,t){return e?.highlightSide===t.highlightSide&&e?.lineNumberOnly===t.lineNumberOnly&&K6e(e?.range??null,t.range)}function m3(e,t){switch(e){case`change-deletion`:return`deletions`;case`change-addition`:return`additions`;default:return t.hasAttribute(`data-deletions`)?`deletions`:`additions`}}function h3(e){let t=e.getAttribute(`data-line-type`);if(t!=null)switch(t){case`change-deletion`:case`change-addition`:case`context`:case`context-expanded`:return t;default:return}}function g3(e=`none`,t,...n){switch(e){case`none`:return;case`both`:break;case`click`:if(t!==`click`)return;break;case`move`:if(t!==`move`)return}console.log(...n)}var q6e=class e{static resizeObserver;static managersByElement=new Map;static getResizeObserver(){let t=e.resizeObserver??new ResizeObserver(e.handleSharedResizeEntries);return e.resizeObserver=t,t}static handleSharedResizeEntries(t){let n=new Map;for(let r of t){let t=e.managersByElement.get(r.target);if(t==null)continue;let i=n.get(t);i==null?n.set(t,[r]):i.push(r)}for(let[e,t]of n)e.handleResizeEntries(t)}observedNodes=new Map;setup(e,{disableAnnotations:t,columnVariables:n=`apply`}){let r=new Set,i=n===`apply`,a=0,o=new Map(this.observedNodes);this.observedNodes.clear();for(let t of e.children){if(a===2)break;let e=(()=>{if(t instanceof HTMLElement&&t.tagName===`CODE`)return t})();if(e==null)continue;a++;let n=o.get(e);if(n!=null&&n.type!==`code`)throw Error(`ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible`);let r=e.firstElementChild;r instanceof HTMLElement||(r=null),n==null?(n={type:`code`,codeElement:e,numberElement:r,codeWidth:`auto`,numberWidth:0,applyColumnVariables:i},this.observedNodes.set(e,n),this.observe(e),r!=null&&(this.observedNodes.set(r,n),this.observe(r))):(this.observedNodes.set(e,n),o.delete(e),n.numberElement===r?n.numberElement==null?n.numberWidth=0:(o.delete(n.numberElement),this.observedNodes.set(n.numberElement,n)):(n.numberElement!=null&&(this.unobserve(n.numberElement),o.delete(n.numberElement)),r!=null&&(this.observe(r),o.delete(r),this.observedNodes.set(r,n)),n.numberElement=r,n.numberWidth=0),X6e(n,i))}if(a>1&&!t){let t=e.querySelectorAll(`[data-line-annotation*=","]`),n=new Map;for(let e of t){if(!(e instanceof HTMLElement))continue;let t=e.getAttribute(`data-line-annotation`)??``;if(!/^-?\d+,-?\d+$/.test(t)){console.error(`DiffFileRenderer.setupResizeObserver: Invalid element or annotation`,{lineAnnotation:t,element:e});continue}let r=n.get(t);r??(r=[],n.set(t,r)),r.push(e)}for(let[e,t]of n){if(t.length!==2){console.error(`DiffFileRenderer.setupResizeObserver: Bad Pair`,e,t);continue}let[n,i]=t,a=n.firstElementChild,s=i.firstElementChild;if(!(n instanceof HTMLElement)||!(i instanceof HTMLElement)||!(a instanceof HTMLElement)||!(s instanceof HTMLElement))continue;let c=o.get(a);if(c!=null){this.observedNodes.set(a,c),this.observedNodes.set(s,c),o.delete(a),o.delete(s);continue}let l=a.getBoundingClientRect().height,u=s.getBoundingClientRect().height;c={type:`annotations`,column1:{container:n,child:a,childHeight:l},column2:{container:i,child:s,childHeight:u},currentHeight:`auto`},r.add({child1:a,child2:s,item:c,newHeight:Math.max(l,u)})}for(let e of r)this.applyNewHeight(e.item,e.newHeight),this.observedNodes.set(e.child1,e.item),this.observedNodes.set(e.child2,e.item),this.observe(e.child1),this.observe(e.child2);r.clear()}for(let[e,t]of o)this.unobserve(e),t.type===`code`?Z6e(t):Q6e(t);o.clear()}cleanUp(){for(let e of this.observedNodes.keys())this.unobserve(e);this.observedNodes.clear()}observe(t){let{managersByElement:n}=e,r=n.get(t);if(r!==this){if(r!=null&&r!==this)throw Error(`ResizeManager.observe: element is already owned by another ResizeManager`);n.set(t,this),e.getResizeObserver().observe(t)}}unobserve(t){let{managersByElement:n,resizeObserver:r}=e,i=n.get(t);if(i!=null){if(i!==this)throw Error(`ResizeManager.unobserve: element is owned by another ResizeManager`);n.delete(t),r?.unobserve(t),r!=null&&n.size===0&&(r.disconnect(),e.resizeObserver=void 0)}}handleResizeEntries(e){let t=new Map,n=new Set;for(let r of e){let{target:e,borderBoxSize:i,contentBoxSize:a}=r;if(!(e instanceof HTMLElement)){console.error(`ResizeManager.handleResizeEntries: Invalid element for ResizeObserver`,r);continue}let o=this.observedNodes.get(e);if(o==null){console.error(`ResizeManager.handleResizeEntries: Not a valid observed node`,r);continue}if(o.type===`annotations`){let t=(()=>{if(e===o.column1.child)return o.column1;if(e===o.column2.child)return o.column2})();if(t==null){console.error(`ResizeManager.handleResizeEntries: Couldn't find a column for`,{item:o,target:e});continue}t.childHeight=i[0].blockSize,n.add(o)}else if(o.type===`code`){let n=t.get(o)??{},r=a[0].inlineSize;e===o.codeElement?n.codeInlineSize=r:e===o.numberElement&&(n.numberInlineSize=r),t.set(o,n)}}this.applyAnnotationUpdates(n),n.clear(),this.applyColumnUpdates(t),t.clear()}applyAnnotationUpdates(e){for(let t of e)this.applyNewHeight(t,Math.max(t.column1.childHeight,t.column2.childHeight))}applyColumnUpdates=e=>{for(let[t,n]of e){let e=n.codeInlineSize==null?t.codeWidth:J6e(n.codeInlineSize),r=n.numberInlineSize==null?t.numberWidth:Y6e(n.numberInlineSize),i=e!==t.codeWidth,a=r!==t.numberWidth;!i&&!a||(t.codeWidth=e,t.numberWidth=r,t.applyColumnVariables&&_3(t,{codeWidthChanged:i,numberWidthChanged:a}))}};applyNewHeight(e,t){t!==e.currentHeight&&(e.currentHeight=Math.max(t,0),e.column1.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`),e.column2.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`))}};function J6e(e){let t=Math.max(Math.floor(e),0);return t===0?`auto`:t}function Y6e(e){return Math.max(Math.ceil(e),0)}function X6e(e,t){e.applyColumnVariables!==t&&(e.applyColumnVariables=t,t?_3(e,{codeWidthChanged:!0,numberWidthChanged:!0}):v3(e))}function _3(e,{codeWidthChanged:t,numberWidthChanged:n}){let{codeElement:r,codeWidth:i,numberWidth:a}=e;if(t&&r.style.setProperty(`--diffs-column-width`,`${typeof i==`number`?`${i}px`:`auto`}`),n&&r.style.setProperty(`--diffs-column-number-width`,`${a===0?`auto`:`${a}px`}`),t||n&&i!==`auto`){let e=typeof i==`number`?Math.max(i-a,0):0;r.style.setProperty(`--diffs-column-content-width`,`${e>0?`${e}px`:`auto`}`)}}function v3(e){e.codeElement.style.removeProperty(`--diffs-column-content-width`),e.codeElement.style.removeProperty(`--diffs-column-number-width`),e.codeElement.style.removeProperty(`--diffs-column-width`)}function Z6e(e){e.codeElement.isConnected&&v3(e)}function Q6e(e){e.column1.container.isConnected&&e.column1.container.style.removeProperty(`--diffs-annotation-min-height`),e.column2.container.isConnected&&e.column2.container.style.removeProperty(`--diffs-annotation-min-height`)}var y3=new Map,b3=new Map,$6e=new Map,x3=new Set;function e8e(e){for(let t of Array.isArray(e)?e:[e])if(t!==`text`&&t!==`ansi`&&!x3.has(t))return!1;return!0}function S3(e,t){e=Array.isArray(e)?e:[e];for(let n of e){if(x3.has(n.name))continue;let e=y3.get(n.name);e??(e=n,y3.set(n.name,e)),x3.add(e.name),t.loadLanguageSync(e.data)}}function C3(){return typeof WorkerGlobalScope<`u`&&typeof self<`u`&&self instanceof WorkerGlobalScope}var w3=Object.defineProperty,t8e=Object.getOwnPropertyDescriptor,n8e=Object.getOwnPropertyNames,r8e=Object.prototype.hasOwnProperty,i8e=(e,t)=>{let n={};for(var r in e)w3(n,r,{get:e[r],enumerable:!0});return t||w3(n,Symbol.toStringTag,{value:`Module`}),n},T3=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=n8e(t),a=0,o=i.length,s;a<o;a++)s=i[a],!r8e.call(e,s)&&s!==n&&w3(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=t8e(t,s))||r.enumerable});return e},a8e=(e,t,n)=>(T3(e,t,`default`),n&&T3(n,t,`default`)),E3=[{id:`abap`,name:`ABAP`,import:(()=>N(()=>import(`./abap-CLvhMVsD.js`),[]))},{id:`actionscript-3`,name:`ActionScript`,import:(()=>N(()=>import(`./actionscript-3--17pq3dv.js`),[]))},{id:`ada`,name:`Ada`,import:(()=>N(()=>import(`./ada-C5qYipkI.js`),[]))},{id:`angular-html`,name:`Angular HTML`,import:(()=>N(()=>import(`./angular-html-B8mrqUL5.js`).then(e=>e.n),__vite__mapDeps([5,1,6,7,8])))},{id:`angular-ts`,name:`Angular TypeScript`,import:(()=>N(()=>import(`./angular-ts-Bzix210W.js`),__vite__mapDeps([9,5,1,6,7,8,10])))},{id:`apache`,name:`Apache Conf`,import:(()=>N(()=>import(`./apache-U0d_L8uA.js`),[]))},{id:`apex`,name:`Apex`,import:(()=>N(()=>import(`./apex-CGTLDQj6.js`),[]))},{id:`apl`,name:`APL`,import:(()=>N(()=>import(`./apl-Dhin1L29.js`),__vite__mapDeps([11,7,1,8,6,12,13,14])))},{id:`applescript`,name:`AppleScript`,import:(()=>N(()=>import(`./applescript-CCn79oCD.js`),[]))},{id:`ara`,name:`Ara`,import:(()=>N(()=>import(`./ara-4CJ0cIlV.js`),[]))},{id:`asciidoc`,name:`AsciiDoc`,aliases:[`adoc`],import:(()=>N(()=>import(`./asciidoc-DE70LPWp.js`),[]))},{id:`asm`,name:`Assembly`,import:(()=>N(()=>import(`./asm-Cmm7eHzH.js`),[]))},{id:`astro`,name:`Astro`,import:(()=>N(()=>import(`./astro-B-4NNgOP.js`),__vite__mapDeps([15,7,1,8,14,16,17,18])))},{id:`awk`,name:`AWK`,import:(()=>N(()=>import(`./awk-BWXHIvNe.js`),[]))},{id:`ballerina`,name:`Ballerina`,import:(()=>N(()=>import(`./ballerina-B7ZEbQpA.js`),[]))},{id:`bat`,name:`Batch File`,aliases:[`batch`],import:(()=>N(()=>import(`./bat-Bo4NYOV-.js`),[]))},{id:`beancount`,name:`Beancount`,import:(()=>N(()=>import(`./beancount-D-usSTwE.js`),[]))},{id:`berry`,name:`Berry`,aliases:[`be`],import:(()=>N(()=>import(`./berry-DKpUyyne.js`),[]))},{id:`bibtex`,name:`BibTeX`,import:(()=>N(()=>import(`./bibtex-Ci_nEsc7.js`),[]))},{id:`bicep`,name:`Bicep`,import:(()=>N(()=>import(`./bicep-CUHmPFLl.js`),[]))},{id:`bird2`,name:`BIRD2 Configuration`,aliases:[`bird`],import:(()=>N(()=>import(`./bird2-C6vDhewU.js`),[]))},{id:`blade`,name:`Blade`,import:(()=>N(()=>import(`./blade-Wr94ul2N.js`),__vite__mapDeps([19,7,1,8,6,12,13,14,20,21])))},{id:`bsl`,name:`1C (Enterprise)`,aliases:[`1c`],import:(()=>N(()=>import(`./bsl-BkkzgIyY.js`),__vite__mapDeps([22,23])))},{id:`c`,name:`C`,import:(()=>N(()=>import(`./c-iCihek07.js`).then(e=>e.n),__vite__mapDeps([24,1])))},{id:`c3`,name:`C3`,import:(()=>N(()=>import(`./c3-CnJL0r0V.js`),[]))},{id:`cadence`,name:`Cadence`,aliases:[`cdc`],import:(()=>N(()=>import(`./cadence-CQ2zXKGN.js`),[]))},{id:`cairo`,name:`Cairo`,import:(()=>N(()=>import(`./cairo-DLTphjLi.js`),__vite__mapDeps([25,26])))},{id:`clarity`,name:`Clarity`,import:(()=>N(()=>import(`./clarity-SemFz856.js`),[]))},{id:`clojure`,name:`Clojure`,aliases:[`clj`],import:(()=>N(()=>import(`./clojure-DqKBuwfJ.js`),[]))},{id:`cmake`,name:`CMake`,import:(()=>N(()=>import(`./cmake-Bj61d0ZC.js`),[]))},{id:`cobol`,name:`COBOL`,import:(()=>N(()=>import(`./cobol-Cw2-KvLW.js`),__vite__mapDeps([27,6,1,7,8,13])))},{id:`codeowners`,name:`CODEOWNERS`,import:(()=>N(()=>import(`./codeowners-C8r90Shi.js`),[]))},{id:`codeql`,name:`CodeQL`,aliases:[`ql`],import:(()=>N(()=>import(`./codeql-oeQT6MSM.js`),[]))},{id:`coffee`,name:`CoffeeScript`,aliases:[`coffeescript`],import:(()=>N(()=>import(`./coffee-CiiSLhB6.js`),__vite__mapDeps([28,7,1])))},{id:`common-lisp`,name:`Common Lisp`,aliases:[`lisp`],import:(()=>N(()=>import(`./common-lisp-Cv5bFMCO.js`),[]))},{id:`coq`,name:`Coq`,import:(()=>N(()=>import(`./coq-BrsZFFmf.js`),[]))},{id:`cpp`,name:`C++`,aliases:[`c++`],import:(()=>N(()=>import(`./cpp-DjoE5qBx.js`).then(e=>e.n),__vite__mapDeps([29,1,21,30,31,24])))},{id:`crystal`,name:`Crystal`,import:(()=>N(()=>import(`./crystal-wCJpIkgB.js`),__vite__mapDeps([32,7,1,8,6,21,24,33])))},{id:`csharp`,name:`C#`,aliases:[`c#`,`cs`],import:(()=>N(()=>import(`./csharp-Ct8U2NOr.js`),[]))},{id:`css`,name:`CSS`,import:(()=>N(()=>import(`./css-CNuuLpMC.js`).then(e=>e.n),__vite__mapDeps([8,1])))},{id:`csv`,name:`CSV`,import:(()=>N(()=>import(`./csv-Dx-8-gkx.js`),[]))},{id:`cue`,name:`CUE`,import:(()=>N(()=>import(`./cue-CE9AQfxI.js`),[]))},{id:`cypher`,name:`Cypher`,aliases:[`cql`],import:(()=>N(()=>import(`./cypher-ClKdZ_lG.js`),[]))},{id:`d`,name:`D`,import:(()=>N(()=>import(`./d-qD-0Kul2.js`),[]))},{id:`dart`,name:`Dart`,import:(()=>N(()=>import(`./dart-CnvKMtbv.js`),[]))},{id:`dax`,name:`DAX`,import:(()=>N(()=>import(`./dax-BkyTk9wS.js`),[]))},{id:`desktop`,name:`Desktop`,import:(()=>N(()=>import(`./desktop-Dlh5hvp9.js`),[]))},{id:`diff`,name:`Diff`,import:(()=>N(()=>import(`./diff-woXpYk--.js`),[]))},{id:`docker`,name:`Dockerfile`,aliases:[`dockerfile`],import:(()=>N(()=>import(`./docker-IyjqRm3v.js`),[]))},{id:`dotenv`,name:`dotEnv`,import:(()=>N(()=>import(`./dotenv-_5a1GRtc.js`),[]))},{id:`dream-maker`,name:`Dream Maker`,import:(()=>N(()=>import(`./dream-maker-DW3nJb8Q.js`),[]))},{id:`edge`,name:`Edge`,import:(()=>N(()=>import(`./edge-DCY0a-ow.js`),__vite__mapDeps([34,6,1,7,8,16,20])))},{id:`elixir`,name:`Elixir`,import:(()=>N(()=>import(`./elixir-DP304Xio.js`),__vite__mapDeps([35,6,1,7,8])))},{id:`elm`,name:`Elm`,import:(()=>N(()=>import(`./elm-o4NJxfws.js`),__vite__mapDeps([36,31,1,24])))},{id:`emacs-lisp`,name:`Emacs Lisp`,aliases:[`elisp`],import:(()=>N(()=>import(`./emacs-lisp-B4R74twV.js`),[]))},{id:`erb`,name:`ERB`,import:(()=>N(()=>import(`./erb-BcNYoZVd.js`),__vite__mapDeps([37,6,1,7,8,38,12,13,21,24,29,30,31,33,39,40,16,18,41,42,43])))},{id:`erlang`,name:`Erlang`,aliases:[`erl`],import:(()=>N(()=>import(`./erlang-Cphh6RMH.js`),__vite__mapDeps([44,45])))},{id:`fennel`,name:`Fennel`,import:(()=>N(()=>import(`./fennel-DQxkIbk2.js`),[]))},{id:`fish`,name:`Fish`,import:(()=>N(()=>import(`./fish-BJitypiv.js`),[]))},{id:`fluent`,name:`Fluent`,aliases:[`ftl`],import:(()=>N(()=>import(`./fluent-C03EYrpw.js`),[]))},{id:`fortran-fixed-form`,name:`Fortran (Fixed Form)`,aliases:[`f`,`for`,`f77`],import:(()=>N(()=>import(`./fortran-fixed-form-DEKoE2YW.js`),__vite__mapDeps([46,47])))},{id:`fortran-free-form`,name:`Fortran (Free Form)`,aliases:[`f90`,`f95`,`f03`,`f08`,`f18`],import:(()=>N(()=>import(`./fortran-free-form-CYNrtFtB.js`),[]))},{id:`fsharp`,name:`F#`,aliases:[`f#`,`fs`],import:(()=>N(()=>import(`./fsharp-D13ZGOAj.js`),__vite__mapDeps([48,45])))},{id:`gdresource`,name:`GDResource`,aliases:[`tscn`,`tres`],import:(()=>N(()=>import(`./gdresource-C0sCabJj.js`),__vite__mapDeps([49,50,51])))},{id:`gdscript`,name:`GDScript`,aliases:[`gd`],import:(()=>N(()=>import(`./gdscript-Cp2uCuqX.js`),[]))},{id:`gdshader`,name:`GDShader`,import:(()=>N(()=>import(`./gdshader-CBce3t8t.js`),[]))},{id:`genie`,name:`Genie`,import:(()=>N(()=>import(`./genie-CV2tkWYe.js`),[]))},{id:`gherkin`,name:`Gherkin`,import:(()=>N(()=>import(`./gherkin-DExj1W_8.js`),[]))},{id:`git-commit`,name:`Git Commit Message`,import:(()=>N(()=>import(`./git-commit-BSykSTBG.js`),__vite__mapDeps([52,53])))},{id:`git-rebase`,name:`Git Rebase Message`,import:(()=>N(()=>import(`./git-rebase-BDPpS8w6.js`),__vite__mapDeps([54,33,1])))},{id:`gleam`,name:`Gleam`,import:(()=>N(()=>import(`./gleam-CSRkHgEL.js`),[]))},{id:`glimmer-js`,name:`Glimmer JS`,aliases:[`gjs`],import:(()=>N(()=>import(`./glimmer-js-BONyzAsu.js`),__vite__mapDeps([55,7,1,8,6,16])))},{id:`glimmer-ts`,name:`Glimmer TS`,aliases:[`gts`],import:(()=>N(()=>import(`./glimmer-ts-f9c0GCOe.js`),__vite__mapDeps([56,7,1,8,6,16])))},{id:`glsl`,name:`GLSL`,import:(()=>N(()=>import(`./glsl-D5MA2a_X.js`).then(e=>e.n),__vite__mapDeps([31,1,24])))},{id:`gn`,name:`GN`,import:(()=>N(()=>import(`./gn-ilITqXS6.js`),[]))},{id:`gnuplot`,name:`Gnuplot`,import:(()=>N(()=>import(`./gnuplot-7GGW24-e.js`),[]))},{id:`go`,name:`Go`,import:(()=>N(()=>import(`./go-rLFTqkRN.js`),[]))},{id:`graphql`,name:`GraphQL`,aliases:[`gql`],import:(()=>N(()=>import(`./graphql-Ctjuxyvl.js`).then(e=>e.n),__vite__mapDeps([40,1,7,16,18,41])))},{id:`groovy`,name:`Groovy`,import:(()=>N(()=>import(`./groovy-CacY0gHj.js`),[]))},{id:`hack`,name:`Hack`,import:(()=>N(()=>import(`./hack-7ztQ7Up-.js`),__vite__mapDeps([57,6,1,7,8,21])))},{id:`haml`,name:`Ruby Haml`,import:(()=>N(()=>import(`./haml-CwEpbK1d.js`).then(e=>e.n),__vite__mapDeps([39,1,7,8])))},{id:`handlebars`,name:`Handlebars`,aliases:[`hbs`],import:(()=>N(()=>import(`./handlebars-ryMP1rBR.js`),__vite__mapDeps([58,7,1,8,6,43])))},{id:`haskell`,name:`Haskell`,aliases:[`hs`],import:(()=>N(()=>import(`./haskell-D8IpX4py.js`),[]))},{id:`haxe`,name:`Haxe`,import:(()=>N(()=>import(`./haxe-OTjmBuCE.js`),[]))},{id:`hcl`,name:`HashiCorp HCL`,import:(()=>N(()=>import(`./hcl-Dh228itO.js`),[]))},{id:`hjson`,name:`Hjson`,import:(()=>N(()=>import(`./hjson-CxZEssPk.js`),[]))},{id:`hlsl`,name:`HLSL`,import:(()=>N(()=>import(`./hlsl-Cvrh5tZx.js`),[]))},{id:`html`,name:`HTML`,import:(()=>N(()=>import(`./html-XwrE-1r6.js`).then(e=>e.n),__vite__mapDeps([6,1,7,8])))},{id:`html-derivative`,name:`HTML (Derivative)`,import:(()=>N(()=>import(`./html-derivative-i4STDFnl.js`),__vite__mapDeps([20,6,1,7,8])))},{id:`http`,name:`HTTP`,import:(()=>N(()=>import(`./http-kmH8AyfE.js`),__vite__mapDeps([59,12,1,13,14,33,40,7,16,18,41])))},{id:`hurl`,name:`Hurl`,import:(()=>N(()=>import(`./hurl-DCZHXKU4.js`),__vite__mapDeps([60,12,1,13,61,40,7,16,18,41])))},{id:`hxml`,name:`HXML`,import:(()=>N(()=>import(`./hxml-B0Qn7Nwc.js`),__vite__mapDeps([62,63])))},{id:`hy`,name:`Hy`,import:(()=>N(()=>import(`./hy-CZbG8q4J.js`),[]))},{id:`imba`,name:`Imba`,import:(()=>N(()=>import(`./imba-DsUTQ-LC.js`),[]))},{id:`ini`,name:`INI`,aliases:[`properties`],import:(()=>N(()=>import(`./ini-B5eOa1yu.js`),[]))},{id:`java`,name:`Java`,import:(()=>N(()=>import(`./java-DdHNQ9hk.js`).then(e=>e.n),__vite__mapDeps([13,1])))},{id:`javascript`,name:`JavaScript`,aliases:[`js`,`cjs`,`mjs`],import:(()=>N(()=>import(`./javascript-obGGvMPs.js`).then(e=>e.n),__vite__mapDeps([7,1])))},{id:`jinja`,name:`Jinja`,import:(()=>N(()=>import(`./jinja-B-tLrNsM.js`),__vite__mapDeps([64,6,1,7,8])))},{id:`jison`,name:`Jison`,import:(()=>N(()=>import(`./jison-CBjhYtSs.js`),__vite__mapDeps([65,7,1])))},{id:`json`,name:`JSON`,import:(()=>N(()=>import(`./json-DAgxKhMr.js`).then(e=>e.n),__vite__mapDeps([14,1])))},{id:`json5`,name:`JSON5`,import:(()=>N(()=>import(`./json5-BR5RXkoi.js`),[]))},{id:`jsonc`,name:`JSON with Comments`,import:(()=>N(()=>import(`./jsonc-CYpm1nAK.js`),[]))},{id:`jsonl`,name:`JSON Lines`,import:(()=>N(()=>import(`./jsonl-CmCQp5Yx.js`),[]))},{id:`jsonnet`,name:`Jsonnet`,import:(()=>N(()=>import(`./jsonnet-CJTPZ8u_.js`),[]))},{id:`jssm`,name:`JSSM`,aliases:[`fsl`],import:(()=>N(()=>import(`./jssm-DXw9l8Rf.js`),[]))},{id:`jsx`,name:`JSX`,import:(()=>N(()=>import(`./jsx-gTgmArGx.js`).then(e=>e.n),__vite__mapDeps([41,1])))},{id:`julia`,name:`Julia`,aliases:[`jl`],import:(()=>N(()=>import(`./julia-CjHxn3vf.js`),__vite__mapDeps([66,7,1,21,26,29,30,31,24,67])))},{id:`just`,name:`Just`,import:(()=>N(()=>import(`./just-CZ9bduw9.js`),__vite__mapDeps([68,7,1,16,26,33,38,8,6,12,13,21,24,29,30,31,39,40,18,41,42,43,69])))},{id:`kdl`,name:`KDL`,import:(()=>N(()=>import(`./kdl-CsD5j6eV.js`),[]))},{id:`kotlin`,name:`Kotlin`,aliases:[`kt`,`kts`],import:(()=>N(()=>import(`./kotlin-DhhofPvG.js`),[]))},{id:`kusto`,name:`Kusto`,aliases:[`kql`],import:(()=>N(()=>import(`./kusto-C7mF5XQf.js`),[]))},{id:`latex`,name:`LaTeX`,import:(()=>N(()=>import(`./latex-D9bvcAJr.js`),__vite__mapDeps([70,71,67,1])))},{id:`lean`,name:`Lean 4`,aliases:[`lean4`],import:(()=>N(()=>import(`./lean-CewbzKMR.js`),[]))},{id:`less`,name:`Less`,import:(()=>N(()=>import(`./less-DVTAwKKz.js`),[]))},{id:`liquid`,name:`Liquid`,import:(()=>N(()=>import(`./liquid-G0MH4h_m.js`),__vite__mapDeps([72,7,1,8,6,14])))},{id:`llvm`,name:`LLVM IR`,import:(()=>N(()=>import(`./llvm-Cm23YOpf.js`),[]))},{id:`log`,name:`Log file`,import:(()=>N(()=>import(`./log-BNLmms1o.js`),[]))},{id:`logo`,name:`Logo`,import:(()=>N(()=>import(`./logo-Cluzi2Zq.js`),[]))},{id:`lua`,name:`Lua`,import:(()=>N(()=>import(`./lua-FONpmTUP.js`).then(e=>e.n),__vite__mapDeps([42,1,24])))},{id:`luau`,name:`Luau`,import:(()=>N(()=>import(`./luau-CNKltnaQ.js`),[]))},{id:`make`,name:`Makefile`,aliases:[`makefile`],import:(()=>N(()=>import(`./make-Dixweg8N.js`),[]))},{id:`markdown`,name:`Markdown`,aliases:[`md`],import:(()=>N(()=>import(`./markdown-BYOwaDjH.js`),[]))},{id:`marko`,name:`Marko`,import:(()=>N(()=>import(`./marko-DV5GrDmo.js`),__vite__mapDeps([73,8,1,10,16,74])))},{id:`matlab`,name:`MATLAB`,import:(()=>N(()=>import(`./matlab-D7qyCx1q.js`),[]))},{id:`mdc`,name:`MDC`,import:(()=>N(()=>import(`./mdc-cg1lnqpW.js`),__vite__mapDeps([75,20,6,1,7,8,43,45])))},{id:`mdx`,name:`MDX`,import:(()=>N(()=>import(`./mdx-DQZ5AkYe.js`),[]))},{id:`mermaid`,name:`Mermaid`,aliases:[`mmd`],import:(()=>N(()=>import(`./mermaid-Bk4SNUv9.js`),[]))},{id:`mipsasm`,name:`MIPS Assembly`,aliases:[`mips`],import:(()=>N(()=>import(`./mipsasm-BMqwQI7S.js`),[]))},{id:`mojo`,name:`Mojo`,import:(()=>N(()=>import(`./mojo-BgCJLMeH.js`),[]))},{id:`moonbit`,name:`MoonBit`,aliases:[`mbt`,`mbti`],import:(()=>N(()=>import(`./moonbit-CaWjb8XO.js`),[]))},{id:`move`,name:`Move`,import:(()=>N(()=>import(`./move-B1IS1UjX.js`),[]))},{id:`narrat`,name:`Narrat Language`,aliases:[`nar`],import:(()=>N(()=>import(`./narrat-_X_XdTYD.js`),[]))},{id:`nextflow`,name:`Nextflow`,aliases:[`nf`],import:(()=>N(()=>import(`./nextflow-BJtWHP5T.js`),__vite__mapDeps([76,77])))},{id:`nextflow-groovy`,name:`Nextflow Groovy`,import:(()=>N(()=>import(`./nextflow-groovy-DJMQeKeT.js`),[]))},{id:`nginx`,name:`Nginx`,import:(()=>N(()=>import(`./nginx-BTMw9COX.js`),__vite__mapDeps([78,42,1,24])))},{id:`nim`,name:`Nim`,import:(()=>N(()=>import(`./nim-B6yJ_yaC.js`),__vite__mapDeps([79,7,1,8,6,12,13,24,31,45])))},{id:`nix`,name:`Nix`,import:(()=>N(()=>import(`./nix-IvuFDN5E.js`),[]))},{id:`nushell`,name:`nushell`,aliases:[`nu`],import:(()=>N(()=>import(`./nushell-DcLAeLz5.js`),[]))},{id:`objective-c`,name:`Objective-C`,aliases:[`objc`],import:(()=>N(()=>import(`./objective-c-D1A_Heim.js`),[]))},{id:`objective-cpp`,name:`Objective-C++`,import:(()=>N(()=>import(`./objective-cpp-BsSzOQcm.js`),[]))},{id:`ocaml`,name:`OCaml`,import:(()=>N(()=>import(`./ocaml-O90oeIOV.js`),[]))},{id:`odin`,name:`Odin`,import:(()=>N(()=>import(`./odin-B1RWQWA5.js`),[]))},{id:`openscad`,name:`OpenSCAD`,aliases:[`scad`],import:(()=>N(()=>import(`./openscad-BUDT5pXO.js`),[]))},{id:`pascal`,name:`Pascal`,import:(()=>N(()=>import(`./pascal-4ZHwLPI5.js`),[]))},{id:`perl`,name:`Perl`,import:(()=>N(()=>import(`./perl-BAov3eih.js`),__vite__mapDeps([69,7,1,8,6,12,13,21])))},{id:`php`,name:`PHP`,import:(()=>N(()=>import(`./php-Cg76ANFt.js`),__vite__mapDeps([80,7,1,8,6,12,13,14,21])))},{id:`pkl`,name:`Pkl`,import:(()=>N(()=>import(`./pkl-ot-7Btpt.js`),[]))},{id:`plsql`,name:`PL/SQL`,import:(()=>N(()=>import(`./plsql-DGHpHOYJ.js`),[]))},{id:`po`,name:`Gettext PO`,aliases:[`pot`,`potx`],import:(()=>N(()=>import(`./po-BiJDBrnU.js`),[]))},{id:`polar`,name:`Polar`,import:(()=>N(()=>import(`./polar-C7UOKdEL.js`),[]))},{id:`postcss`,name:`PostCSS`,import:(()=>N(()=>import(`./postcss-BXeXVLqQ.js`),[]))},{id:`powerquery`,name:`PowerQuery`,import:(()=>N(()=>import(`./powerquery-DNMTfnFr.js`),[]))},{id:`powershell`,name:`PowerShell`,aliases:[`ps`,`ps1`],import:(()=>N(()=>import(`./powershell-DshXNtvi.js`),[]))},{id:`prisma`,name:`Prisma`,import:(()=>N(()=>import(`./prisma-BsRQq5mF.js`),[]))},{id:`prolog`,name:`Prolog`,import:(()=>N(()=>import(`./prolog-iXnhIJG7.js`),[]))},{id:`proto`,name:`Protocol Buffer 3`,aliases:[`protobuf`],import:(()=>N(()=>import(`./proto-DB4EqR-F.js`),[]))},{id:`pug`,name:`Pug`,aliases:[`jade`],import:(()=>N(()=>import(`./pug-DkgDHZci.js`),__vite__mapDeps([81,7,1,8,6])))},{id:`puppet`,name:`Puppet`,import:(()=>N(()=>import(`./puppet-CDv2pdJW.js`),[]))},{id:`purescript`,name:`PureScript`,import:(()=>N(()=>import(`./purescript-9MfHhQsQ.js`),[]))},{id:`python`,name:`Python`,aliases:[`py`],import:(()=>N(()=>import(`./python-gzcpVVnB.js`),[]))},{id:`qml`,name:`QML`,import:(()=>N(()=>import(`./qml-_a-QhfPD.js`),__vite__mapDeps([82,7,1])))},{id:`qmldir`,name:`QML Directory`,import:(()=>N(()=>import(`./qmldir-DCQb3MpD.js`),[]))},{id:`qss`,name:`Qt Style Sheets`,import:(()=>N(()=>import(`./qss-Fe1Jh2GI.js`),[]))},{id:`r`,name:`R`,import:(()=>N(()=>import(`./r-D6UWEOL2.js`).then(e=>e.n),__vite__mapDeps([67,1])))},{id:`racket`,name:`Racket`,import:(()=>N(()=>import(`./racket-DcIDlBhZ.js`),[]))},{id:`raku`,name:`Raku`,aliases:[`perl6`],import:(()=>N(()=>import(`./raku-B3gFvitq.js`),[]))},{id:`razor`,name:`ASP.NET Razor`,import:(()=>N(()=>import(`./razor-D3EoCAik.js`),__vite__mapDeps([83,6,1,7,8,84])))},{id:`reg`,name:`Windows Registry Script`,import:(()=>N(()=>import(`./reg-CRGYupPL.js`),[]))},{id:`regexp`,name:`RegExp`,aliases:[`regex`],import:(()=>N(()=>import(`./regexp-DR20uMnK.js`).then(e=>e.n),__vite__mapDeps([30,1])))},{id:`rel`,name:`Rel`,import:(()=>N(()=>import(`./rel-BtDbiS_P.js`),[]))},{id:`riscv`,name:`RISC-V`,import:(()=>N(()=>import(`./riscv-Ckw8ddFX.js`),[]))},{id:`ron`,name:`RON`,import:(()=>N(()=>import(`./ron-VUp2lXgN.js`),[]))},{id:`rosmsg`,name:`ROS Interface`,import:(()=>N(()=>import(`./rosmsg-CAekHB0j.js`),[]))},{id:`rst`,name:`reStructuredText`,import:(()=>N(()=>import(`./rst-YTmaoyaq.js`),__vite__mapDeps([85,7,1,20,6,8,26,86,29,21,30,31,24,33,43,38,12,13,39,40,16,18,41,42])))},{id:`ruby`,name:`Ruby`,aliases:[`rb`],import:(()=>N(()=>import(`./ruby-2bd251b9.js`),__vite__mapDeps([38,7,1,8,6,12,13,21,24,29,30,31,33,39,40,16,18,41,42,43])))},{id:`rust`,name:`Rust`,aliases:[`rs`],import:(()=>N(()=>import(`./rust-Cfkwpbl8.js`),[]))},{id:`sas`,name:`SAS`,import:(()=>N(()=>import(`./sas-B6p8-ynO.js`),__vite__mapDeps([87,21,1])))},{id:`sass`,name:`Sass`,import:(()=>N(()=>import(`./sass-DXrisJhu.js`),[]))},{id:`scala`,name:`Scala`,import:(()=>N(()=>import(`./scala-DKOlJaKm.js`),[]))},{id:`scheme`,name:`Scheme`,import:(()=>N(()=>import(`./scheme-DQCgrYNe.js`),[]))},{id:`scss`,name:`SCSS`,import:(()=>N(()=>import(`./scss-YesllqfO.js`).then(e=>e.n),__vite__mapDeps([10,1,8])))},{id:`sdbl`,name:`1C (Query)`,aliases:[`1c-query`],import:(()=>N(()=>import(`./sdbl-bTVj8UrX.js`),[]))},{id:`shaderlab`,name:`ShaderLab`,aliases:[`shader`],import:(()=>N(()=>import(`./shaderlab-TOUzSsQk.js`),__vite__mapDeps([88,89])))},{id:`shellscript`,name:`Shell`,aliases:[`bash`,`sh`,`shell`,`zsh`],import:(()=>N(()=>import(`./shellscript-Da78Ox-3.js`).then(e=>e.n),__vite__mapDeps([33,1])))},{id:`shellsession`,name:`Shell Session`,aliases:[`console`],import:(()=>N(()=>import(`./shellsession-CVsQGYfZ.js`),__vite__mapDeps([90,33,1])))},{id:`smalltalk`,name:`Smalltalk`,import:(()=>N(()=>import(`./smalltalk-B16xEiuN.js`),[]))},{id:`solidity`,name:`Solidity`,import:(()=>N(()=>import(`./solidity-CKzVLygQ.js`),[]))},{id:`soy`,name:`Closure Templates`,aliases:[`closure-templates`],import:(()=>N(()=>import(`./soy-DEd-qcad.js`),__vite__mapDeps([91,6,1,7,8])))},{id:`sparql`,name:`SPARQL`,import:(()=>N(()=>import(`./sparql-D_iOobhT.js`),__vite__mapDeps([92,93])))},{id:`splunk`,name:`Splunk Query Language`,aliases:[`spl`],import:(()=>N(()=>import(`./splunk-BC2Px7Mm.js`),[]))},{id:`sql`,name:`SQL`,import:(()=>N(()=>import(`./sql-ClgswhA6.js`).then(e=>e.n),__vite__mapDeps([21,1])))},{id:`ssh-config`,name:`SSH Config`,import:(()=>N(()=>import(`./ssh-config-BgfXC-Er.js`),[]))},{id:`stata`,name:`Stata`,import:(()=>N(()=>import(`./stata-RoaAgbqU.js`),__vite__mapDeps([94,21,1])))},{id:`stylus`,name:`Stylus`,aliases:[`styl`],import:(()=>N(()=>import(`./stylus-B6D30XZt.js`),[]))},{id:`surrealql`,name:`SurrealQL`,aliases:[`surql`],import:(()=>N(()=>import(`./surrealql-DIn4NJsS.js`),__vite__mapDeps([95,7,1])))},{id:`svelte`,name:`Svelte`,import:(()=>N(()=>import(`./svelte-Bj3Hmc9F.js`),__vite__mapDeps([96,7,1,8,16,17])))},{id:`swift`,name:`Swift`,import:(()=>N(()=>import(`./swift-DonLKvLd.js`),[]))},{id:`system-verilog`,name:`SystemVerilog`,import:(()=>N(()=>import(`./system-verilog-DJ5XKQeo.js`),[]))},{id:`systemd`,name:`Systemd Units`,import:(()=>N(()=>import(`./systemd-BxMlprV5.js`),[]))},{id:`talonscript`,name:`TalonScript`,aliases:[`talon`],import:(()=>N(()=>import(`./talonscript-CohzipZa.js`),[]))},{id:`tasl`,name:`Tasl`,import:(()=>N(()=>import(`./tasl-DMoTqEGO.js`),[]))},{id:`tcl`,name:`Tcl`,import:(()=>N(()=>import(`./tcl-CZd0xW_V.js`),[]))},{id:`templ`,name:`Templ`,import:(()=>N(()=>import(`./templ-TjxbArHn.js`),__vite__mapDeps([97,7,1,8,98])))},{id:`terraform`,name:`Terraform`,aliases:[`tf`,`tfvars`],import:(()=>N(()=>import(`./terraform-DswuEJGm.js`),[]))},{id:`tex`,name:`TeX`,import:(()=>N(()=>import(`./tex-0w6-Dtgt.js`),__vite__mapDeps([71,67,1])))},{id:`toml`,name:`TOML`,import:(()=>N(()=>import(`./toml-CcmNWLt0.js`),[]))},{id:`ts-tags`,name:`TypeScript with Tags`,aliases:[`lit`],import:(()=>N(()=>import(`./ts-tags-DFwAVxhO.js`),__vite__mapDeps([99,7,1,8,6,12,13,16,21,31,24])))},{id:`tsv`,name:`TSV`,import:(()=>N(()=>import(`./tsv-sltzmVWM.js`),[]))},{id:`tsx`,name:`TSX`,import:(()=>N(()=>import(`./tsx-CUOciP0b.js`).then(e=>e.n),__vite__mapDeps([18,1])))},{id:`turtle`,name:`Turtle`,import:(()=>N(()=>import(`./turtle-ByJddavk.js`),[]))},{id:`twig`,name:`Twig`,import:(()=>N(()=>import(`./twig-BbcH-NR0.js`),__vite__mapDeps([100,7,1,8,10,26,38,6,12,13,21,24,29,30,31,33,39,40,16,18,41,42,43,80,14])))},{id:`typescript`,name:`TypeScript`,aliases:[`ts`,`cts`,`mts`],import:(()=>N(()=>import(`./typescript-BydbNFcO.js`).then(e=>e.n),__vite__mapDeps([16,1])))},{id:`typespec`,name:`TypeSpec`,aliases:[`tsp`],import:(()=>N(()=>import(`./typespec-BRdr0IET.js`),[]))},{id:`typst`,name:`Typst`,aliases:[`typ`],import:(()=>N(()=>import(`./typst-DI99ib-x.js`),[]))},{id:`v`,name:`V`,import:(()=>N(()=>import(`./v-DETTlOr0.js`),[]))},{id:`vala`,name:`Vala`,import:(()=>N(()=>import(`./vala-zf12oZj6.js`),[]))},{id:`vb`,name:`Visual Basic`,aliases:[`cmd`],import:(()=>N(()=>import(`./vb-Djn5o6TS.js`),[]))},{id:`verilog`,name:`Verilog`,import:(()=>N(()=>import(`./verilog-CiiDBU1e.js`),[]))},{id:`vhdl`,name:`VHDL`,import:(()=>N(()=>import(`./vhdl-BroJfC0k.js`),[]))},{id:`viml`,name:`Vim Script`,aliases:[`vim`,`vimscript`],import:(()=>N(()=>import(`./viml-DvXPmvsu.js`),[]))},{id:`vue`,name:`Vue`,import:(()=>N(()=>import(`./vue-BNi0qJZP.js`),__vite__mapDeps([101,7,1,8,6,14,16,20])))},{id:`vue-html`,name:`Vue HTML`,import:(()=>N(()=>import(`./vue-html-DkKkQnZL.js`),__vite__mapDeps([102,7,1])))},{id:`vue-vine`,name:`Vue Vine`,import:(()=>N(()=>import(`./vue-vine-DFaKYU4X.js`),__vite__mapDeps([103,7,1,8,10,17,74,104])))},{id:`vyper`,name:`Vyper`,aliases:[`vy`],import:(()=>N(()=>import(`./vyper-CgoNMtux.js`),[]))},{id:`wasm`,name:`WebAssembly`,import:(()=>N(()=>import(`./wasm-ByWQv1Qj.js`),[]))},{id:`wenyan`,name:`Wenyan`,aliases:[`文言`],import:(()=>N(()=>import(`./wenyan-C8pVoKbM.js`),[]))},{id:`wgsl`,name:`WGSL`,import:(()=>N(()=>import(`./wgsl-BsKzXJz4.js`),[]))},{id:`wikitext`,name:`Wikitext`,aliases:[`mediawiki`,`wiki`],import:(()=>N(()=>import(`./wikitext-ClFFjSW2.js`),[]))},{id:`wit`,name:`WebAssembly Interface Types`,import:(()=>N(()=>import(`./wit-DdvCle-K.js`),[]))},{id:`wolfram`,name:`Wolfram`,aliases:[`wl`],import:(()=>N(()=>import(`./wolfram-DLL8P-h_.js`),[]))},{id:`xml`,name:`XML`,import:(()=>N(()=>import(`./xml-BlnrEAEy.js`).then(e=>e.n),__vite__mapDeps([12,1,13])))},{id:`xsl`,name:`XSL`,import:(()=>N(()=>import(`./xsl-BOPS8gLt.js`),__vite__mapDeps([105,12,1,13])))},{id:`yaml`,name:`YAML`,aliases:[`yml`],import:(()=>N(()=>import(`./yaml-Du_6cdrH.js`).then(e=>e.n),__vite__mapDeps([43,1])))},{id:`zenscript`,name:`ZenScript`,import:(()=>N(()=>import(`./zenscript-BnlCZFoB.js`),[]))},{id:`zig`,name:`Zig`,import:(()=>N(()=>import(`./zig-CMLA9XwU.js`),[]))}],o8e=Object.fromEntries(E3.map(e=>[e.id,e.import])),s8e=Object.fromEntries(E3.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),D3={...o8e,...s8e},c8e=Object.fromEntries([{id:`andromeeda`,displayName:`Andromeeda`,type:`dark`,import:(()=>N(()=>import(`./andromeeda-WkhI09AS.js`),[]))},{id:`aurora-x`,displayName:`Aurora X`,type:`dark`,import:(()=>N(()=>import(`./aurora-x-C7CFqhAd.js`),[]))},{id:`ayu-dark`,displayName:`Ayu Dark`,type:`dark`,import:(()=>N(()=>import(`./ayu-dark-CRu61w6_.js`),[]))},{id:`ayu-light`,displayName:`Ayu Light`,type:`light`,import:(()=>N(()=>import(`./ayu-light-Dn6O_aYR.js`),[]))},{id:`ayu-mirage`,displayName:`Ayu Mirage`,type:`dark`,import:(()=>N(()=>import(`./ayu-mirage-CTjYAbs-.js`),[]))},{id:`catppuccin-frappe`,displayName:`Catppuccin Frappé`,type:`dark`,import:(()=>N(()=>import(`./catppuccin-frappe-DFlFW5gh.js`),[]))},{id:`catppuccin-latte`,displayName:`Catppuccin Latte`,type:`light`,import:(()=>N(()=>import(`./catppuccin-latte-CpxdcXpJ.js`),[]))},{id:`catppuccin-macchiato`,displayName:`Catppuccin Macchiato`,type:`dark`,import:(()=>N(()=>import(`./catppuccin-macchiato-DIdIQ04K.js`),[]))},{id:`catppuccin-mocha`,displayName:`Catppuccin Mocha`,type:`dark`,import:(()=>N(()=>import(`./catppuccin-mocha-Co3Xjl64.js`),[]))},{id:`dark-plus`,displayName:`Dark Plus`,type:`dark`,import:(()=>N(()=>import(`./dark-plus-GAt2ZgX8.js`),[]))},{id:`dracula`,displayName:`Dracula Theme`,type:`dark`,import:(()=>N(()=>import(`./dracula-C2uKkzgK.js`),[]))},{id:`dracula-soft`,displayName:`Dracula Theme Soft`,type:`dark`,import:(()=>N(()=>import(`./dracula-soft-D1bVjxWZ.js`),[]))},{id:`everforest-dark`,displayName:`Everforest Dark`,type:`dark`,import:(()=>N(()=>import(`./everforest-dark-D-DlICQR.js`),[]))},{id:`everforest-light`,displayName:`Everforest Light`,type:`light`,import:(()=>N(()=>import(`./everforest-light-CeVdGHYG.js`),[]))},{id:`github-dark`,displayName:`GitHub Dark`,type:`dark`,import:(()=>N(()=>import(`./github-dark-DwbbXv51.js`),[]))},{id:`github-dark-default`,displayName:`GitHub Dark Default`,type:`dark`,import:(()=>N(()=>import(`./github-dark-default-CxjRwzl6.js`),[]))},{id:`github-dark-dimmed`,displayName:`GitHub Dark Dimmed`,type:`dark`,import:(()=>N(()=>import(`./github-dark-dimmed-Cr1oaoul.js`),[]))},{id:`github-dark-high-contrast`,displayName:`GitHub Dark High Contrast`,type:`dark`,import:(()=>N(()=>import(`./github-dark-high-contrast-B4qJZLZa.js`),[]))},{id:`github-light`,displayName:`GitHub Light`,type:`light`,import:(()=>N(()=>import(`./github-light-CsVXhIlR.js`),[]))},{id:`github-light-default`,displayName:`GitHub Light Default`,type:`light`,import:(()=>N(()=>import(`./github-light-default-DB_IwZa6.js`),[]))},{id:`github-light-high-contrast`,displayName:`GitHub Light High Contrast`,type:`light`,import:(()=>N(()=>import(`./github-light-high-contrast-DLgVeSB-.js`),[]))},{id:`gruvbox-dark-hard`,displayName:`Gruvbox Dark Hard`,type:`dark`,import:(()=>N(()=>import(`./gruvbox-dark-hard-DXm60lX3.js`),[]))},{id:`gruvbox-dark-medium`,displayName:`Gruvbox Dark Medium`,type:`dark`,import:(()=>N(()=>import(`./gruvbox-dark-medium-GE2thSmD.js`),[]))},{id:`gruvbox-dark-soft`,displayName:`Gruvbox Dark Soft`,type:`dark`,import:(()=>N(()=>import(`./gruvbox-dark-soft-04Cj-4VZ.js`),[]))},{id:`gruvbox-light-hard`,displayName:`Gruvbox Light Hard`,type:`light`,import:(()=>N(()=>import(`./gruvbox-light-hard-K6wSn29D.js`),[]))},{id:`gruvbox-light-medium`,displayName:`Gruvbox Light Medium`,type:`light`,import:(()=>N(()=>import(`./gruvbox-light-medium-CVy3aSlc.js`),[]))},{id:`gruvbox-light-soft`,displayName:`Gruvbox Light Soft`,type:`light`,import:(()=>N(()=>import(`./gruvbox-light-soft-DNgJjaY0.js`),[]))},{id:`horizon`,displayName:`Horizon`,type:`dark`,import:(()=>N(()=>import(`./horizon-0-RkHfro.js`),[]))},{id:`horizon-bright`,displayName:`Horizon Bright`,type:`light`,import:(()=>N(()=>import(`./horizon-bright-BgL2X9oq.js`),[]))},{id:`houston`,displayName:`Houston`,type:`dark`,import:(()=>N(()=>import(`./houston-KyjWKfuY.js`),[]))},{id:`kanagawa-dragon`,displayName:`Kanagawa Dragon`,type:`dark`,import:(()=>N(()=>import(`./kanagawa-dragon-7TqgsUPC.js`),[]))},{id:`kanagawa-lotus`,displayName:`Kanagawa Lotus`,type:`light`,import:(()=>N(()=>import(`./kanagawa-lotus-CqxMQulh.js`),[]))},{id:`kanagawa-wave`,displayName:`Kanagawa Wave`,type:`dark`,import:(()=>N(()=>import(`./kanagawa-wave-D8CNn6T_.js`),[]))},{id:`laserwave`,displayName:`LaserWave`,type:`dark`,import:(()=>N(()=>import(`./laserwave-CQkdhozh.js`),[]))},{id:`light-plus`,displayName:`Light Plus`,type:`light`,import:(()=>N(()=>import(`./light-plus-CNQ8_7Y0.js`),[]))},{id:`material-theme`,displayName:`Material Theme`,type:`dark`,import:(()=>N(()=>import(`./material-theme-CAtLaHa3.js`),[]))},{id:`material-theme-darker`,displayName:`Material Theme Darker`,type:`dark`,import:(()=>N(()=>import(`./material-theme-darker-k-s5Bc6K.js`),[]))},{id:`material-theme-lighter`,displayName:`Material Theme Lighter`,type:`light`,import:(()=>N(()=>import(`./material-theme-lighter-CD6a-c4d.js`),[]))},{id:`material-theme-ocean`,displayName:`Material Theme Ocean`,type:`dark`,import:(()=>N(()=>import(`./material-theme-ocean-B3mraInd.js`),[]))},{id:`material-theme-palenight`,displayName:`Material Theme Palenight`,type:`dark`,import:(()=>N(()=>import(`./material-theme-palenight-DEhAARHw.js`),[]))},{id:`min-dark`,displayName:`Min Dark`,type:`dark`,import:(()=>N(()=>import(`./min-dark-BFqTAwCr.js`),[]))},{id:`min-light`,displayName:`Min Light`,type:`light`,import:(()=>N(()=>import(`./min-light-O7UdaaxX.js`),[]))},{id:`monokai`,displayName:`Monokai`,type:`dark`,import:(()=>N(()=>import(`./monokai-C0p7Qecz.js`),[]))},{id:`night-owl`,displayName:`Night Owl`,type:`dark`,import:(()=>N(()=>import(`./night-owl-BsnCLAKc.js`),[]))},{id:`night-owl-light`,displayName:`Night Owl Light`,type:`light`,import:(()=>N(()=>import(`./night-owl-light-BODRhcTU.js`),[]))},{id:`nord`,displayName:`Nord`,type:`dark`,import:(()=>N(()=>import(`./nord-Cd-F4txO.js`),[]))},{id:`one-dark-pro`,displayName:`One Dark Pro`,type:`dark`,import:(()=>N(()=>import(`./one-dark-pro-DUS_IGRK.js`),[]))},{id:`one-light`,displayName:`One Light`,type:`light`,import:(()=>N(()=>import(`./one-light-CVUd7yD5.js`),[]))},{id:`plastic`,displayName:`Plastic`,type:`dark`,import:(()=>N(()=>import(`./plastic-CF8VZTnn.js`),[]))},{id:`poimandres`,displayName:`Poimandres`,type:`dark`,import:(()=>N(()=>import(`./poimandres-BX2TyY6j.js`),[]))},{id:`red`,displayName:`Red`,type:`dark`,import:(()=>N(()=>import(`./red-7ga_dcKu.js`),[]))},{id:`rose-pine`,displayName:`Rosé Pine`,type:`dark`,import:(()=>N(()=>import(`./rose-pine-rh6ipraJ.js`),[]))},{id:`rose-pine-dawn`,displayName:`Rosé Pine Dawn`,type:`light`,import:(()=>N(()=>import(`./rose-pine-dawn-DSuRaP6u.js`),[]))},{id:`rose-pine-moon`,displayName:`Rosé Pine Moon`,type:`dark`,import:(()=>N(()=>import(`./rose-pine-moon-DdHjCvFQ.js`),[]))},{id:`slack-dark`,displayName:`Slack Dark`,type:`dark`,import:(()=>N(()=>import(`./slack-dark-DYvUXyrP.js`),[]))},{id:`slack-ochin`,displayName:`Slack Ochin`,type:`light`,import:(()=>N(()=>import(`./slack-ochin-bqtMVDfH.js`),[]))},{id:`snazzy-light`,displayName:`Snazzy Light`,type:`light`,import:(()=>N(()=>import(`./snazzy-light-D8dzFmq5.js`),[]))},{id:`solarized-dark`,displayName:`Solarized Dark`,type:`dark`,import:(()=>N(()=>import(`./solarized-dark-BQwPDzxK.js`),[]))},{id:`solarized-light`,displayName:`Solarized Light`,type:`light`,import:(()=>N(()=>import(`./solarized-light-BLaijb3X.js`),[]))},{id:`synthwave-84`,displayName:`Synthwave '84`,type:`dark`,import:(()=>N(()=>import(`./synthwave-84-CIknw8y7.js`),[]))},{id:`tokyo-night`,displayName:`Tokyo Night`,type:`dark`,import:(()=>N(()=>import(`./tokyo-night-iIspnLcq.js`),[]))},{id:`vesper`,displayName:`Vesper`,type:`dark`,import:(()=>N(()=>import(`./vesper-D5bVUKB1.js`),[]))},{id:`vitesse-black`,displayName:`Vitesse Black`,type:`dark`,import:(()=>N(()=>import(`./vitesse-black-D082JcaE.js`),[]))},{id:`vitesse-dark`,displayName:`Vitesse Dark`,type:`dark`,import:(()=>N(()=>import(`./vitesse-dark-z-nr_5O8.js`),[]))},{id:`vitesse-light`,displayName:`Vitesse Light`,type:`light`,import:(()=>N(()=>import(`./vitesse-light-ojz42ZLy.js`),[]))}].map(e=>[e.id,e.import])),l8e=e({createOnigurumaEngine:()=>R3,getDefaultWasmLoader:()=>E8e,loadWasm:()=>F3,setDefaultWasmLoader:()=>T8e}),O3=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function u8e(){return 2147483648}function d8e(){return typeof performance<`u`?performance.now():Date.now()}var f8e=(e,t)=>e+(t-e%t)%t;async function p8e(e){let t,n,r={};function i(e){n=e,r.HEAPU8=new Uint8Array(e),r.HEAPU32=new Uint32Array(e)}function a(e,t,n){r.HEAPU8.copyWithin(e,t,t+n)}function o(e){try{return t.grow(e-n.byteLength+65535>>>16),i(t.buffer),1}catch{}}function s(e){let t=r.HEAPU8.length;e>>>=0;let n=u8e();if(e>n)return!1;for(let r=1;r<=4;r*=2){let i=t*(1+.2/r);if(i=Math.min(i,e+100663296),o(Math.min(n,f8e(Math.max(e,i),65536))))return!0}return!1}let c=typeof TextDecoder<`u`?new TextDecoder(`utf8`):void 0;function l(e,t,n=1024){let r=t+n,i=t;for(;e[i]&&!(i>=r);)++i;if(i-t>16&&e.buffer&&c)return c.decode(e.subarray(t,i));let a=``;for(;t<i;){let n=e[t++];if(!(n&128)){a+=String.fromCharCode(n);continue}let r=e[t++]&63;if((n&224)==192){a+=String.fromCharCode((n&31)<<6|r);continue}let i=e[t++]&63;if(n=(n&240)==224?(n&15)<<12|r<<6|i:(n&7)<<18|r<<12|i<<6|e[t++]&63,n<65536)a+=String.fromCharCode(n);else{let e=n-65536;a+=String.fromCharCode(55296|e>>10,56320|e&1023)}}return a}function u(e,t){return e?l(r.HEAPU8,e,t):``}let d={emscripten_get_now:d8e,emscripten_memcpy_big:a,emscripten_resize_heap:s,fd_write:()=>0};async function f(){let n=await e({env:d,wasi_snapshot_preview1:d});t=n.memory,i(t.buffer),Object.assign(r,n),r.UTF8ToString=u}return await f(),r}var m8e=Object.defineProperty,h8e=(e,t,n)=>t in e?m8e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,k3=(e,t,n)=>h8e(e,typeof t==`symbol`?t:t+``,n),A3=null;function g8e(e){throw new O3(e.UTF8ToString(e.getLastOnigError()))}var j3=class e{constructor(t){k3(this,`utf16Length`),k3(this,`utf8Length`),k3(this,`utf16Value`),k3(this,`utf8Value`),k3(this,`utf16OffsetToUtf8`),k3(this,`utf8OffsetToUtf16`);let n=t.length,r=e._utf8ByteLength(t),i=r!==n,a=i?new Uint32Array(n+1):null;i&&(a[n]=r);let o=i?new Uint32Array(r+1):null;i&&(o[r]=n);let s=new Uint8Array(r),c=0;for(let e=0;e<n;e++){let r=t.charCodeAt(e),l=r,u=!1;if(r>=55296&&r<=56319&&e+1<n){let n=t.charCodeAt(e+1);n>=56320&&n<=57343&&(l=(r-55296<<10)+65536|n-56320,u=!0)}i&&(a[e]=c,u&&(a[e+1]=c),l<=127?o[c+0]=e:l<=2047?(o[c+0]=e,o[c+1]=e):l<=65535?(o[c+0]=e,o[c+1]=e,o[c+2]=e):(o[c+0]=e,o[c+1]=e,o[c+2]=e,o[c+3]=e)),l<=127?s[c++]=l:l<=2047?(s[c++]=192|(l&1984)>>>6,s[c++]=128|(l&63)>>>0):l<=65535?(s[c++]=224|(l&61440)>>>12,s[c++]=128|(l&4032)>>>6,s[c++]=128|(l&63)>>>0):(s[c++]=240|(l&1835008)>>>18,s[c++]=128|(l&258048)>>>12,s[c++]=128|(l&4032)>>>6,s[c++]=128|(l&63)>>>0),u&&e++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=s,this.utf16OffsetToUtf8=a,this.utf8OffsetToUtf16=o}static _utf8ByteLength(e){let t=0;for(let n=0,r=e.length;n<r;n++){let i=e.charCodeAt(n),a=i,o=!1;if(i>=55296&&i<=56319&&n+1<r){let t=e.charCodeAt(n+1);t>=56320&&t<=57343&&(a=(i-55296<<10)+65536|t-56320,o=!0)}t+=a<=127?1:a<=2047?2:a<=65535?3:4,o&&n++}return t}createString(e){let t=e.omalloc(this.utf8Length);return e.HEAPU8.set(this.utf8Value,t),t}},M3=class e{constructor(t){if(k3(this,`id`,++e.LAST_ID),k3(this,`_onigBinding`),k3(this,`content`),k3(this,`utf16Length`),k3(this,`utf8Length`),k3(this,`utf16OffsetToUtf8`),k3(this,`utf8OffsetToUtf16`),k3(this,`ptr`),!A3)throw new O3(`Must invoke loadWasm first.`);this._onigBinding=A3,this.content=t;let n=new j3(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!e._sharedPtrInUse?(e._sharedPtr||=A3.omalloc(1e4),e._sharedPtrInUse=!0,A3.HEAPU8.set(n.utf8Value,e._sharedPtr),this.ptr=e._sharedPtr):this.ptr=n.createString(A3)}convertUtf8OffsetToUtf16(e){return this.utf8OffsetToUtf16?e<0?0:e>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[e]:e}convertUtf16OffsetToUtf8(e){return this.utf16OffsetToUtf8?e<0?0:e>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[e]:e}dispose(){this.ptr===e._sharedPtr?e._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};k3(M3,`LAST_ID`,0),k3(M3,`_sharedPtr`,0),k3(M3,`_sharedPtrInUse`,!1);var N3=M3,_8e=class{constructor(e){if(k3(this,`_onigBinding`),k3(this,`_ptr`),!A3)throw new O3(`Must invoke loadWasm first.`);let t=[],n=[];for(let r=0,i=e.length;r<i;r++){let i=new j3(e[r]);t[r]=i.createString(A3),n[r]=i.utf8Length}let r=A3.omalloc(4*e.length);A3.HEAPU32.set(t,r/4);let i=A3.omalloc(4*e.length);A3.HEAPU32.set(n,i/4);let a=A3.createOnigScanner(r,i,e.length);for(let n=0,r=e.length;n<r;n++)A3.ofree(t[n]);A3.ofree(i),A3.ofree(r),a===0&&g8e(A3),this._onigBinding=A3,this._ptr=a}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(e,t,n){let r=0;if(typeof n==`number`&&(r=n),typeof e==`string`){e=new N3(e);let n=this._findNextMatchSync(e,t,!1,r);return e.dispose(),n}return this._findNextMatchSync(e,t,!1,r)}_findNextMatchSync(e,t,n,r){let i=this._onigBinding,a=i.findNextOnigScannerMatch(this._ptr,e.id,e.ptr,e.utf8Length,e.convertUtf16OffsetToUtf8(t),r);if(a===0)return null;let o=i.HEAPU32,s=a/4,c=o[s++],l=o[s++],u=[];for(let t=0;t<l;t++){let n=e.convertUtf8OffsetToUtf16(o[s++]),r=e.convertUtf8OffsetToUtf16(o[s++]);u[t]={start:n,end:r,length:r-n}}return{index:c,captureIndices:u}}};function v8e(e){return typeof e.instantiator==`function`}function y8e(e){return typeof e.default==`function`}function b8e(e){return e.data!==void 0}function x8e(e){return typeof Response<`u`&&e instanceof Response}function S8e(e){return typeof ArrayBuffer<`u`&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<`u`&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||typeof Uint32Array<`u`&&e instanceof Uint32Array}var P3;function F3(e){if(P3)return P3;async function t(){A3=await p8e(async t=>{let n=e;return n=await n,typeof n==`function`&&(n=await n(t)),typeof n==`function`&&(n=await n(t)),v8e(n)?n=await n.instantiator(t):y8e(n)?n=await n.default(t):(b8e(n)&&(n=n.data),x8e(n)?n=typeof WebAssembly.instantiateStreaming==`function`?await C8e(n)(t):await w8e(n)(t):S8e(n)||n instanceof WebAssembly.Module?n=await I3(n)(t):`default`in n&&n.default instanceof WebAssembly.Module&&(n=await I3(n.default)(t))),`instance`in n&&(n=n.instance),`exports`in n&&(n=n.exports),n})}return P3=t(),P3}function I3(e){return t=>WebAssembly.instantiate(e,t)}function C8e(e){return t=>WebAssembly.instantiateStreaming(e,t)}function w8e(e){return async t=>{let n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}var L3;function T8e(e){L3=e}function E8e(){return L3}async function R3(e){return e&&await F3(e),{createScanner(e){return new _8e(e.map(e=>typeof e==`string`?e:e.source))},createString(e){return new N3(e)}}}var z3=i8e({});a8e(z3,l8e);var B3=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function D8e(e){return V3(e)}function V3(e){return Array.isArray(e)?O8e(e):e instanceof RegExp?e:typeof e==`object`?k8e(e):e}function O8e(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=V3(e[n]);return t}function k8e(e){let t={};for(let n in e)t[n]=V3(e[n]);return t}function H3(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function U3(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?U3(e.substring(0,e.length-1)):e.substr(~t+1)}var W3=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,G3=class{static hasCaptures(e){return e!==null&&(W3.lastIndex=0,W3.test(e))}static replaceCaptures(e,t,n){return e.replace(W3,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function K3(e,t){return e<t?-1:+(e>t)}function q3(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=K3(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function J3(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function Y3(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var X3=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},Z3=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(M8e(e),t)}static createFromParsedTheme(e,t){return P8e(e,t)}_cachedMatchRoot=new X3(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>A8e(e.parent,t.parentScopes));return n?new $3(n.fontStyle,n.foreground,n.background):null}},Q3=class e{constructor(e,t){this.parent=e,this.scopeName=t}static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e||this.parent!==null&&this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function A8e(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!j8e(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function j8e(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var $3=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function M8e(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8}}let s=null;typeof i.settings.foreground==`string`&&J3(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&J3(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new N8e(l,u,e,o,s,c)}}return n}var N8e=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}},e6=(e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(e6||{});function P8e(e,t){e.sort((e,t)=>{let n=K3(e.scope,t.scope);return n!==0||(n=q3(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new F8e(t),o=new $3(n,a.getId(r),a.getId(i)),s=new L8e(new t6(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new Z3(a,o,s)}var F8e=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},I8e=Object.freeze([]),t6=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||I8e,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},L8e=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),t6.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null){this._mainRule.acceptOverwrite(e,n,r,i);return}for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if(q3(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new t6(e,t,n,r,i))}},n6=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return!!(e&1024)}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=+!!e.containsBalancedBrackets(t),d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=z8e(r)),i!==null&&(u=+!!i),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c<<0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function R8e(e){return e}function z8e(e){return e}function r6(e,t){let n=[],r=B8e(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(i6(i)){let e=[];do e.push(i),i=r.next();while(i6(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function i6(e){return!!e&&!!e.match(/[\w\.:]+/)}function B8e(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function a6(e){typeof e.dispose==`function`&&e.dispose()}var o6=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},V8e=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},H8e=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},U8e=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new o6(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new H8e;for(let n of e)W8e(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof o6){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function W8e(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof o6?c6({baseGrammar:a,selfGrammar:i},r):s6(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new o6(e))}function s6(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];l6([r],t,n)}}function c6(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&l6(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&l6(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function l6(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?H3({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&l6(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=u6(i);switch(a.kind){case 0:c6({...t,selfGrammar:t.baseGrammar},n);break;case 1:c6(t,n);break;case 2:s6(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?s6(a.ruleName,i,n):c6(i,n)}else a.kind===4?n.add(new V8e(a.scopeName,a.ruleName)):n.add(new o6(a.scopeName))}}}var G8e=class{kind=0},K8e=class{kind=1},q8e=class{constructor(e){this.ruleName=e}kind=2},J8e=class{constructor(e){this.scopeName=e}kind=3},Y8e=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function u6(e){if(e===`$base`)return new G8e;if(e===`$self`)return new K8e;let t=e.indexOf(`#`);return t===-1?new J8e(e):t===0?new q8e(e.substring(1)):new Y8e(e.substring(0,t),e.substring(t+1))}var X8e=/\\(\d+)/,d6=/\\(\d+)/g,Z8e=-1,f6=-2;function p6(e){return e}function m6(e){return e}var h6=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=G3.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=G3.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${U3(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:G3.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:G3.replaceCaptures(this._contentName,e,t)}},Q8e=class extends h6{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},$8e=class extends h6{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new b6(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new x6,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},g6=class extends h6{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new x6,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},_6=class extends h6{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new b6(i,this.id),this.beginCaptures=a,this._end=new b6(o||``,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new x6;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},v6=class extends h6{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new b6(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new b6(o,f6),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new x6;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new x6,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||``),this._cachedCompiledWhilePatterns}},y6=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new Q8e(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new $8e(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=H3({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new g6(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new v6(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new _6(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=u6(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l)if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository)}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof g6||e instanceof _6||e instanceof v6)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},b6=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this._anchorCache=this.hasAnchor?this._buildAnchorCache():null,this.ruleId=t,this.hasBackReferences=typeof this.source==`string`&&X8e.test(this.source)}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return d6.lastIndex=0,this.source.replace(d6,(e,t)=>Y3(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=``,t[i+1]=``,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=``,t[i+1]=`G`,n[i+1]=``,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},x6=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new S6(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new S6(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},S6=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
|
|
1040
|
-
`)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},C6=class{constructor(e,t){this.languageId=e,this.tokenType=t}},
|
|
1041
|
-
`;let a=this.createOnigString(e),o=a.content.length,s=new f5e(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=T6(this,a,i,0,t,s,!0,r);return a6(a),{lineLength:o,lineTokens:s,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function A6(e,t){return e=D8e(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var j6=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}static fromExtension(t,n){let r=t,i=t?.scopePath??null;for(let t of n)i=Q3.push(i,t.scopeNames),r=new e(r,i,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new Q3(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let i=r.getMetadataForScope(t),a=new Q3(null,t),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(n,i,o);return new e(null,a,s)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(` `)}equals(t){return e.equals(this,t)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(!0)}static mergeAttributes(e,t,n){let r=-1,i=0,a=0;return n!==null&&(r=n.fontStyle,i=n.foregroundId,a=n.backgroundId),n6.set(e,t.languageId,t.tokenType,null,r,i,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(` `)===-1)return e._pushAttributed(this,t,n);let r=t.split(/ /g),i=this;for(let t of r)i=e._pushAttributed(i,t,n);return i}static _pushAttributed(t,n,r){let i=r.getMetadataForScope(n),a=t.scopePath.push(n),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(t.tokenAttributes,i,o);return new e(t,a,s)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},M6=class e{constructor(e,t,n,r,i,a,o,s){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=o,this.contentNameScopesList=s,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t!==null&&e._equals(this,t)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?j6.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,a,o,s){return new e(this,t,n,r,i,a,o,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),`[`+e.join(`,`)+`]`}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:m6(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=j6.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,p6(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,j6.fromExtension(r,n.contentNameScopesList))}},d5e=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>e===`*`?(this.allowAny=!0,[]):r6(e,k6).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>r6(e,k6).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},f5e=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let t=e?.getScopeNames()??[];for(let e of this._tokenTypeOverrides)e.matcher(t)&&(n=n6.set(n,0,R8e(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}if(r&&(n=n6.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},p5e=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,c5e(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},m5e=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new p5e(Z3.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(Z3.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new d5e(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,i){let a=new U8e(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(e=>this._loadSingleGrammar(e.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,n,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections==`function`?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,i)}},N6=M6.NULL;function P6(e,t){let n=typeof e==`string`?{}:{...e.colorReplacements},r=typeof e==`string`?e:e.name;for(let[e,i]of Object.entries(t?.colorReplacements||{}))typeof i==`string`?n[e]=i:e===r&&Object.assign(n,i);return n}function F6(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function h5e(e){return Array.isArray(e)?e:[e]}async function I6(e){return Promise.resolve(typeof e==`function`?e():e).then(e=>e.default||e)}function L6(e){return!e||[`plaintext`,`txt`,`text`,`plain`].includes(e)}function R6(e){return e===`ansi`||L6(e)}function z6(e){return e===`none`}function B6(e){return z6(e)}function V6(e,t=!1){if(e.length===0)return[[``,0]];let n=e.split(/(\r?\n)/g),r=0,i=[];for(let e=0;e<n.length;e+=2){let a=t?n[e]+(n[e+1]||``):n[e];i.push([a,r]),r+=n[e].length,r+=n[e+1]?.length||0}return i}var H6={light:`#333333`,dark:`#bbbbbb`},U6={light:`#fffffe`,dark:`#1e1e1e`},W6=`__shiki_resolved`;function G6(e){if(e?.[W6])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||=`dark`,t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(r=e.settings.foreground),e?.settings?.background&&(n=e.settings.background),!r&&t?.colors?.[`editor.foreground`]&&(r=t.colors[`editor.foreground`]),!n&&t?.colors?.[`editor.background`]&&(n=t.colors[`editor.background`]),r||=t.type===`light`?H6.light:H6.dark,n||=t.type===`light`?U6.light:U6.dark,t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,a=new Map;function o(e){if(a.has(e))return a.get(e);i+=1;let n=`#${i.toString(16).padStart(8,`0`).toLowerCase()}`;return t.colorReplacements?.[`#${n}`]?o(e):(a.set(e,n),n)}t.settings=t.settings.map(e=>{let n=e.settings?.foreground&&!e.settings.foreground.startsWith(`#`),r=e.settings?.background&&!e.settings.background.startsWith(`#`);if(!n&&!r)return e;let i={...e,settings:{...e.settings}};if(n){let n=o(e.settings.foreground);t.colorReplacements[n]=e.settings.foreground,i.settings.foreground=n}if(r){let n=o(e.settings.background);t.colorReplacements[n]=e.settings.background,i.settings.background=n}return i});for(let e of Object.keys(t.colors||{}))if((e===`editor.foreground`||e===`editor.background`||e.startsWith(`terminal.ansi`))&&!t.colors[e]?.startsWith(`#`)){let n=o(t.colors[e]);t.colorReplacements[n]=t.colors[e],t.colors[e]=n}return Object.defineProperty(t,W6,{enumerable:!1,writable:!1,value:!0}),t}async function K6(e){return Array.from(new Set((await Promise.all(e.filter(e=>!R6(e)).map(async e=>await I6(e).then(e=>Array.isArray(e)?e:[e])))).flat()))}async function q6(e){return(await Promise.all(e.map(async e=>B6(e)?null:G6(await I6(e))))).filter(e=>!!e)}function J6(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new B3(`Circular alias \`${Array.from(n).join(` -> `)} -> ${e}\``);n.add(e)}}return e}var g5e=class extends m5e{_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}getTheme(e){return typeof e==`string`?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=G6(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||=[...this._resolvedThemes.keys()],this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=Z3.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=J6(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||[`*`],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null,t.size)for(let e of t)this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(e.scopeName),this._syncRegistry?._grammars?.delete(e.scopeName),this.loadLanguage(this._langMap.get(e.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let t of e)this.resolveEmbeddedLanguages(t);let t=Array.from(this._langGraph.entries()),n=t.filter(([e,t])=>!t);if(n.length){let e=t.filter(([e,t])=>t?(t.embeddedLanguages||t.embeddedLangs)?.some(e=>n.map(([e])=>e).includes(e)):!1).filter(e=>!n.includes(e));throw new B3(`Missing languages ${n.map(([e])=>`\`${e}\``).join(`, `)}, required by ${e.map(([e])=>`\`${e}\``).join(`, `)}`)}for(let[e,n]of t)this._resolver.addLanguage(n);for(let[e,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])],this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let e of t)this._langGraph.set(e,this._langMap.get(e))}},_5e=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split(`.`),n=[];for(let e=1;e<=t.length;e++){let r=t.slice(0,e).join(`.`);n=[...n,...this._injections.get(r)||[]]}return n}},Y6=0;function v5e(e){Y6+=1,e.warnings!==!1&&Y6>=10&&Y6%10==0&&console.warn(`[Shiki] ${Y6} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new B3("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(G6),i=new g5e(new _5e(e.engine,n),r,n,e.langAlias),a;function o(t){return J6(t,e.langAlias)}function s(e){g();let t=i.getGrammar(typeof e==`string`?e:e.name);if(!t)throw new B3(`Language \`${e}\` not found, you may need to load it first`);return t}function c(e){if(e===`none`)return{bg:``,fg:``,name:`none`,settings:[],type:`dark`};g();let t=i.getTheme(e);if(!t)throw new B3(`Theme \`${e}\` not found, you may need to load it first`);return t}function l(e){g();let t=c(e);return a!==e&&(i.setTheme(t),a=e),{theme:t,colorMap:i.getColorMap()}}function u(){return g(),i.getLoadedThemes()}function d(){return g(),i.getLoadedLanguages()}function f(...e){g(),i.loadLanguages(e.flat(1))}async function p(...e){return f(await K6(e))}function m(...e){g();for(let t of e.flat(1))i.loadTheme(t)}async function h(...e){return g(),m(await q6(e))}function g(){if(t)throw new B3(`Shiki instance has been disposed`)}function _(){t||(t=!0,i.dispose(),--Y6)}return{setTheme:l,getTheme:c,getLanguage:s,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:o,loadLanguage:p,loadLanguageSync:f,loadTheme:h,loadThemeSync:m,dispose:_,[Symbol.dispose]:_}}async function y5e(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([q6(e.themes||[]),K6(e.langs||[]),e.engine]);return v5e({...e,themes:t,langs:n,engine:r})}var X6=new WeakMap;function Z6(e,t){X6.set(e,t)}function Q6(e){return X6.get(e)}var $6=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new e(Object.fromEntries(h5e(n).map(e=>[e,N6])),t)}constructor(...e){if(e.length===2){let[t,n]=e;this.lang=n,this._stacks=t}else{let[t,n,r]=e;this.lang=n,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return b5e(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function b5e(e){let t=[],n=new Set;function r(e){if(n.has(e))return;n.add(e);let i=e?.nameScopesList?.scopeName;i&&t.push(i),e.parent&&r(e.parent)}return r(e),t}function x5e(e,t){if(!(e instanceof $6))throw new B3(`Invalid grammar state`);return e.getInternalStack(t)}function e8(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(L6(e.resolveLangAlias(n.lang||`text`))||z6(r))return V6(t).map(e=>[{content:e[0],offset:e[1]}]);let{theme:i,colorMap:a}=e.setTheme(r),o=e.getLanguage(n.lang||`text`);if(n.grammarState){if(n.grammarState.lang!==o.name)throw new B3(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(i.name))throw new B3(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return C5e(t,o,i,a,n)}function S5e(...e){if(e.length===2)return Q6(e[1]);let[t,n,r={}]=e,{lang:i=`text`,theme:a=t.getLoadedThemes()[0]}=r;if(L6(i)||z6(a))throw new B3(`Plain language does not have grammar state`);if(i===`ansi`)throw new B3(`ANSI language does not have grammar state`);let{theme:o,colorMap:s}=t.setTheme(a),c=t.getLanguage(i);return new $6(t8(n,c,o,s,r).stateStack,c.name,o.name)}function C5e(e,t,n,r,i){let a=t8(e,t,n,r,i),o=new $6(a.stateStack,t.name,n.name);return Z6(a.tokens,o),a.tokens}function t8(e,t,n,r,i){let a=P6(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:s=500}=i,c=V6(e),l=i.grammarState?x5e(i.grammarState,n.name)??N6:i.grammarContextCode==null?N6:t8(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack,u=[],d=[];for(let e=0,f=c.length;e<f;e++){let[f,p]=c[e];if(f===``){u=[],d.push([]);continue}if(o>0&&f.length>=o){u=[],d.push([{content:f,offset:p,color:``,fontStyle:0}]);continue}let m,h,g;i.includeExplanation&&(m=t.tokenizeLine(f,l,s),h=m.tokens,g=0);let _=t.tokenizeLine2(f,l,s),v=_.tokens.length/2;for(let e=0;e<v;e++){let t=_.tokens[2*e],o=e+1<v?_.tokens[2*e+2]:f.length;if(t===o)continue;let s=_.tokens[2*e+1],c=F6(r[n6.getForeground(s)],a),l=n6.getFontStyle(s),d={content:f.substring(t,o),offset:p+t,color:c,fontStyle:l};if(i.includeExplanation){let e=[];if(i.includeExplanation!==`scopeName`)for(let t of n.settings){let n;switch(typeof t.scope){case`string`:n=t.scope.split(/,/).map(e=>e.trim());break;case`object`:n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split(/ /))})}d.explanation=[];let r=0;for(;t+r<o;){let t=h[g],n=f.substring(t.startIndex,t.endIndex);r+=n.length,d.explanation.push({content:n,scopes:i.includeExplanation===`scopeName`?w5e(t.scopes):T5e(e,t.scopes)}),g+=1}}u.push(d)}d.push(u),u=[],l=_.ruleStack}return{tokens:d,stateStack:l}}function w5e(e){return e.map(e=>({scopeName:e}))}function T5e(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];n[r]={scopeName:i,themeMatches:D5e(e,i,t.slice(0,r))}}return n}function n8(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]===`.`}function E5e(e,t,n){if(!n8(e[e.length-1],t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)n8(e[r],n[i])&&--r,--i;return r===-1}function D5e(e,t,n){let r=[];for(let{selectors:i,settings:a}of e)for(let e of i)if(E5e(e,t,n)){r.push(a);break}return r}function r8(e,t,n,r=e8){let i=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),a=i.map(i=>{let a=r(e,t,{...n,theme:i.theme});return{tokens:a,state:Q6(a),theme:typeof i.theme==`string`?i.theme:i.theme.name}}),o=O5e(...a.map(e=>e.tokens)),s=o[0].map((e,t)=>e.map((e,r)=>{let a={content:e.content,variants:{},offset:e.offset};return`includeExplanation`in n&&n.includeExplanation&&(a.explanation=e.explanation),o.forEach((e,n)=>{let{content:o,explanation:s,offset:c,...l}=e[t][r];a.variants[i[n].color]=l}),a})),c=a[0].state?new $6(Object.fromEntries(a.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),a[0].state.lang):void 0;return c&&Z6(s,c),s}function O5e(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let i=e.map(e=>e[r]),a=t.map(()=>[]);t.forEach((e,t)=>e.push(a[t]));let o=i.map(()=>0),s=i.map(e=>e[0]);for(;s.every(e=>e);){let e=Math.min(...s.map(e=>e.content.length));for(let t=0;t<n;t++){let n=s[t];n.content.length===e?(a[t].push(n),o[t]+=1,s[t]=i[t][o[t]]):(a[t].push({...n,content:n.content.slice(0,e)}),s[t]={...n,content:n.content.slice(e),offset:n.offset+e})}}}return t}function i8(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class==`string`&&(e.properties.class=e.properties.class.split(/\s+/g)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(/\s+/g);for(let t of n)t&&!e.properties.class.includes(t)&&e.properties.class.push(t);return e}function k5e(e){let t=V6(e,!0).map(([e])=>e);function n(n){if(n===e.length)return{line:t.length-1,character:t[t.length-1].length};let r=n,i=0;for(let e of t){if(r<e.length)break;r-=e.length,i++}return{line:i,character:r}}function r(e,n){let r=0;for(let n=0;n<e;n++)r+=t[n].length;return r+=n,r}return{lines:t,indexToPos:n,posToIndex:r}}function A5e(e,t,n){let r=new Set;for(let t of e.matchAll(/:?lang=["']([^"']+)["']/g)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(/(?:```|~~~)([\w-]+)/g)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(/\\begin\{([\w-]+)\}/g)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){let e=t[1].toLowerCase().trim(),n=e.includes(`/`)?e.split(`/`).pop():e;n&&r.add(n)}if(!n)return Array.from(r);let i=n.getBundledLanguages();return Array.from(r).filter(e=>e&&i[e])}var a8=`light-dark()`,j5e=[`color`,`background-color`];function M5e(e,t){let n=0,r=[];for(let i of t)i>n&&r.push({...e,content:e.content.slice(n,i),offset:e.offset+n}),n=i;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function N5e(e,t){let n=Array.from(t instanceof Set?t:new Set(t)).sort((e,t)=>e-t);return n.length?e.map(e=>e.flatMap(e=>{let t=n.filter(t=>e.offset<t&&t<e.offset+e.content.length).map(t=>t-e.offset).sort((e,t)=>e-t);return t.length?M5e(e,t):e})):e}function P5e(e,t,n,r,i=`css-vars`){let a={content:e.content,explanation:e.explanation,offset:e.offset},o=t.map(t=>o8(e.variants[t])),s=new Set(o.flatMap(e=>Object.keys(e))),c={},l=(e,r)=>{let i=r===`color`?``:r===`background-color`?`-bg`:`-${r}`;return n+t[e]+(r===`color`?``:i)};return o.forEach((e,n)=>{for(let a of s){let s=e[a]||`inherit`;if(n===0&&r&&j5e.includes(a))if(r===a8&&o.length>1){let e=t.findIndex(e=>e===`light`),r=t.findIndex(e=>e===`dark`);if(e===-1||r===-1)throw new B3('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');c[a]=`light-dark(${o[e][a]||`inherit`}, ${o[r][a]||`inherit`})`,i===`css-vars`&&(c[l(n,a)]=s)}else c[a]=s;else i===`css-vars`&&(c[l(n,a)]=s)}}),a.htmlStyle=c,a}function o8(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t[`background-color`]=e.bgColor),e.fontStyle){e.fontStyle&e6.Italic&&(t[`font-style`]=`italic`),e.fontStyle&e6.Bold&&(t[`font-weight`]=`bold`);let n=[];e.fontStyle&e6.Underline&&n.push(`underline`),e.fontStyle&e6.Strikethrough&&n.push(`line-through`),n.length&&(t[`text-decoration`]=n.join(` `))}return t}function s8(e){return typeof e==`string`?e:Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function F5e(){let e=new WeakMap;function t(t){if(!e.has(t.meta)){let n=k5e(t.source);function r(e){if(typeof e==`number`){if(e<0||e>t.source.length)throw new B3(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);return{...n.indexToPos(e),offset:e}}{let t=n.lines[e.line];if(t===void 0)throw new B3(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${n.lines.length}`);let r=e.character;if(r<0&&(r=t.length+r),r<0||r>t.length)throw new B3(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);return{...e,character:r,offset:n.posToIndex(e.line,r)}}}let i=(t.options.decorations||[]).map(e=>({...e,start:r(e.start),end:r(e.end)}));I5e(i),e.set(t.meta,{decorations:i,converter:n,source:t.source})}return e.get(t.meta)}return{name:`shiki:decorations`,tokens(e){if(this.options.decorations?.length)return N5e(e,t(this).decorations.flatMap(e=>[e.start.offset,e.end.offset]))},code(e){if(!this.options.decorations?.length)return;let n=t(this),r=Array.from(e.children).filter(e=>e.type===`element`&&e.tagName===`span`);if(r.length!==n.converter.lines.length)throw new B3(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${n.converter.lines.length}). Failed to apply decorations.`);function i(e,t,n,i){let a=r[e],s=``,c=-1,l=-1;if(t===0&&(c=0),n===0&&(l=0),n===1/0&&(l=a.children.length),c===-1||l===-1)for(let e=0;e<a.children.length;e++)s+=c8(a.children[e]),c===-1&&s.length===t&&(c=e+1),l===-1&&s.length===n&&(l=e+1);if(c===-1)throw new B3(`Failed to find start index for decoration ${JSON.stringify(i.start)}`);if(l===-1)throw new B3(`Failed to find end index for decoration ${JSON.stringify(i.end)}`);let u=a.children.slice(c,l);if(!i.alwaysWrap&&u.length===a.children.length)o(a,i,`line`);else if(!i.alwaysWrap&&u.length===1&&u[0].type===`element`)o(u[0],i,`token`);else{let e={type:`element`,tagName:`span`,properties:{},children:u};o(e,i,`wrapper`),a.children.splice(c,u.length,e)}}function a(e,t){r[e]=o(r[e],t,`line`)}function o(e,t,n){let r=t.properties||{},i=t.transform||(e=>e);return e.tagName=t.tagName||`span`,e.properties={...e.properties,...r,class:e.properties.class},t.properties?.class&&i8(e,t.properties.class),e=i(e,n)||e,e}let s=[],c=n.decorations.sort((e,t)=>t.start.offset-e.start.offset||e.end.offset-t.end.offset);for(let e of c){let{start:t,end:n}=e;if(t.line===n.line)i(t.line,t.character,n.character,e);else if(t.line<n.line){i(t.line,t.character,1/0,e);for(let r=t.line+1;r<n.line;r++)s.unshift(()=>a(r,e));i(n.line,0,n.character,e)}}s.forEach(e=>e())}}}function I5e(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new B3(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let t=e[r],i=n.start.offset<=t.start.offset&&t.start.offset<n.end.offset,a=n.start.offset<t.end.offset&&t.end.offset<=n.end.offset,o=t.start.offset<=n.start.offset&&n.start.offset<t.end.offset,s=t.start.offset<n.end.offset&&n.end.offset<=t.end.offset;if(i||a||o||s){if(i&&a||o&&s||o&&n.start.offset===n.end.offset||a&&t.start.offset===t.end.offset)continue;throw new B3(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(t.start)} intersect.`)}}}}function c8(e){return e.type===`text`?e.value:e.type===`element`?e.children.map(c8).join(``):``}var L5e=[F5e()];function l8(e){let t=R5e(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...L5e]}function R5e(e){let t=[],n=[],r=[];for(let i of e)switch(i.enforce){case`pre`:t.push(i);break;case`post`:n.push(i);break;default:r.push(i)}return{pre:t,post:n,normal:r}}var u8=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],d8={1:`bold`,2:`dim`,3:`italic`,4:`underline`,7:`reverse`,8:`hidden`,9:`strikethrough`};function z5e(e,t){let n=e.indexOf(`\x1B`,t);if(n!==-1&&e[n+1]===`[`){let t=e.indexOf(`m`,n);if(t!==-1)return{sequence:e.substring(n+2,t).split(`;`),startPosition:n,position:t+1}}return{position:e.length}}function f8(e){let t=e.shift();if(t===`2`){let t=e.splice(0,3).map(e=>Number.parseInt(e));return t.length!==3||t.some(e=>Number.isNaN(e))?void 0:{type:`rgb`,rgb:t}}if(t===`5`){let t=e.shift();if(t)return{type:`table`,index:Number(t)}}}function B5e(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:`resetAll`});else if(r<=9)d8[r]&&t.push({type:`setDecoration`,value:d8[r]});else if(r<=29){let e=d8[r-20];e&&(t.push({type:`resetDecoration`,value:e}),e===`dim`&&t.push({type:`resetDecoration`,value:`bold`}))}else if(r<=37)t.push({type:`setForegroundColor`,value:{type:`named`,name:u8[r-30]}});else if(r===38){let n=f8(e);n&&t.push({type:`setForegroundColor`,value:n})}else if(r===39)t.push({type:`resetForegroundColor`});else if(r<=47)t.push({type:`setBackgroundColor`,value:{type:`named`,name:u8[r-40]}});else if(r===48){let n=f8(e);n&&t.push({type:`setBackgroundColor`,value:n})}else r===49?t.push({type:`resetBackgroundColor`}):r===53?t.push({type:`setDecoration`,value:`overline`}):r===55?t.push({type:`resetDecoration`,value:`overline`}):r>=90&&r<=97?t.push({type:`setForegroundColor`,value:{type:`named`,name:u8[r-90+8]}}):r>=100&&r<=107&&t.push({type:`setBackgroundColor`,value:{type:`named`,name:u8[r-100+8]}})}return t}function V5e(){let e=null,t=null,n=new Set;return{parse(r){let i=[],a=0;do{let o=z5e(r,a),s=o.sequence?r.substring(a,o.startPosition):r.substring(a);if(s.length>0&&i.push({value:s,foreground:e,background:t,decorations:new Set(n)}),o.sequence){let r=B5e(o.sequence);for(let i of r)i.type===`resetAll`?(e=null,t=null,n.clear()):i.type===`resetForegroundColor`?e=null:i.type===`resetBackgroundColor`?t=null:i.type===`resetDecoration`&&n.delete(i.value);for(let i of r)i.type===`setForegroundColor`?e=i.value:i.type===`setBackgroundColor`?t=i.value:i.type===`setDecoration`&&n.add(i.value)}a=o.position}while(a<r.length);return i}}}var H5e={black:`#000000`,red:`#bb0000`,green:`#00bb00`,yellow:`#bbbb00`,blue:`#0000bb`,magenta:`#ff00ff`,cyan:`#00bbbb`,white:`#eeeeee`,brightBlack:`#555555`,brightRed:`#ff5555`,brightGreen:`#00ff00`,brightYellow:`#ffff55`,brightBlue:`#5555ff`,brightMagenta:`#ff55ff`,brightCyan:`#55ffff`,brightWhite:`#ffffff`};function U5e(e=H5e){function t(t){return e[t]}function n(e){return`#${e.map(e=>Math.max(0,Math.min(e,255)).toString(16).padStart(2,`0`)).join(``)}`}let r;function i(){if(r)return r;r=[];for(let e=0;e<u8.length;e++)r.push(t(u8[e]));let e=[0,95,135,175,215,255];for(let t=0;t<6;t++)for(let i=0;i<6;i++)for(let a=0;a<6;a++)r.push(n([e[t],e[i],e[a]]));let i=8;for(let e=0;e<24;e++,i+=10)r.push(n([i,i,i]));return r}function a(e){return i()[e]}function o(e){switch(e.type){case`named`:return t(e.name);case`rgb`:return n(e.rgb);case`table`:return a(e.index)}}return{value:o}}var W5e={black:`#000000`,red:`#cd3131`,green:`#0DBC79`,yellow:`#E5E510`,blue:`#2472C8`,magenta:`#BC3FBC`,cyan:`#11A8CD`,white:`#E5E5E5`,brightBlack:`#666666`,brightRed:`#F14C4C`,brightGreen:`#23D18B`,brightYellow:`#F5F543`,brightBlue:`#3B8EEA`,brightMagenta:`#D670D6`,brightCyan:`#29B8DB`,brightWhite:`#FFFFFF`};function G5e(e,t,n){let r=P6(e,n),i=V6(t),a=U5e(Object.fromEntries(u8.map(t=>{let n=`terminal.ansi${t[0].toUpperCase()}${t.substring(1)}`;return[t,e.colors?.[n]||W5e[t]]}))),o=V5e();return i.map(t=>o.parse(t[0]).map(n=>{let i,o;n.decorations.has(`reverse`)?(i=n.background?a.value(n.background):e.bg,o=n.foreground?a.value(n.foreground):e.fg):(i=n.foreground?a.value(n.foreground):e.fg,o=n.background?a.value(n.background):void 0),i=F6(i,r),o=F6(o,r),n.decorations.has(`dim`)&&(i=K5e(i));let s=e6.None;return n.decorations.has(`bold`)&&(s|=e6.Bold),n.decorations.has(`italic`)&&(s|=e6.Italic),n.decorations.has(`underline`)&&(s|=e6.Underline),n.decorations.has(`strikethrough`)&&(s|=e6.Strikethrough),{content:n.value,offset:t[1],color:i,bgColor:o,fontStyle:s}}))}function K5e(e){let t=e.match(/#([0-9a-f]{3,8})/i);if(t){let e=t[1];if(e.length===8){let t=Math.round(Number.parseInt(e.slice(6,8),16)/2).toString(16).padStart(2,`0`);return`#${e.slice(0,6)}${t}`}if(e.length===6)return`#${e}80`;if(e.length===4){let t=e[0],n=e[1],r=e[2],i=e[3];return`#${t}${t}${n}${n}${r}${r}${Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,`0`)}`}if(e.length===3){let t=e[0],n=e[1],r=e[2];return`#${t}${t}${n}${n}${r}${r}80`}}let n=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:e}function p8(e,t,n={}){let r=e.resolveLangAlias(n.lang||`text`),{theme:i=e.getLoadedThemes()[0]}=n;if(!L6(r)&&!z6(i)&&r===`ansi`){let{theme:r}=e.setTheme(i);return G5e(r,t,n)}return e8(e,t,n)}function m8(e,t,n){let r,i,a,o,s,c;if(`themes`in n){let{defaultColor:l=`light`,cssVariablePrefix:u=`--shiki-`,colorsRendering:d=`css-vars`}=n,f=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})).sort((e,t)=>e.color===l?-1:+(t.color===l));if(f.length===0)throw new B3("`themes` option must not be empty");let p=r8(e,t,n,p8);if(c=Q6(p),l&&a8!==l&&!f.find(e=>e.color===l))throw new B3(`\`themes\` option must contain the defaultColor key \`${l}\``);let m=f.map(t=>e.getTheme(t.theme)),h=f.map(e=>e.color);a=p.map(e=>e.map(e=>P5e(e,h,u,l,d))),c&&Z6(a,c);let g=f.map(e=>P6(e.theme,n));i=h8(f,m,g,u,l,`fg`,d),r=h8(f,m,g,u,l,`bg`,d),o=`shiki-themes ${m.map(e=>e.name).join(` `)}`,s=l?void 0:[i,r].join(`;`)}else if(`theme`in n){let s=P6(n.theme,n);a=p8(e,t,n);let l=e.getTheme(n.theme);r=F6(l.bg,s),i=F6(l.fg,s),o=l.name,c=Q6(a)}else throw new B3("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:i,bg:r,themeName:o,rootStyle:s,grammarState:c}}function h8(e,t,n,r,i,a,o){return e.map((s,c)=>{let l=F6(t[c][a],n[c])||`inherit`,u=`${r+s.color}${a===`bg`?`-bg`:``}:${l}`;if(c===0&&i){if(i===a8&&e.length>1){let r=e.findIndex(e=>e.color===`light`),i=e.findIndex(e=>e.color===`dark`);if(r===-1||i===-1)throw new B3('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${F6(t[r][a],n[r])||`inherit`}, ${F6(t[i][a],n[i])||`inherit`});${u}`}return l}return o===`css-vars`?u:null}).filter(e=>!!e).join(`;`)}function g8(e,t,n,r={meta:{},options:n,codeToHast:(t,n)=>g8(e,t,n),codeToTokens:(t,n)=>m8(e,t,n)}){let i=t;for(let e of l8(n))i=e.preprocess?.call(r,i,n)||i;let{tokens:a,fg:o,bg:s,themeName:c,rootStyle:l,grammarState:u}=m8(e,i,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:f=!1}=n;d===!0?a=J5e(a):d===`never`&&(a=Y5e(a)),f&&(a=X5e(a));let p={...r,get source(){return i}};for(let e of l8(n))a=e.tokens?.call(p,a)||a;return q5e(a,{...n,fg:o,bg:s,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??l},p,u)}function q5e(e,t,n,r=Q6(e)){let i=l8(t),a=[],o={type:`root`,children:[]},{structure:s=`classic`,tabindex:c=`0`}=t,l={class:`shiki ${t.themeName||``}`};t.rootStyle!==!1&&(l.style=t.rootStyle==null?`background-color:${t.bg};color:${t.fg}`:t.rootStyle),c!==!1&&c!=null&&(l.tabindex=c.toString());for(let[e,n]of Object.entries(t.meta||{}))e.startsWith(`_`)||(l[e]=n);let u={type:`element`,tagName:`pre`,properties:l,children:[],data:t.data},d={type:`element`,tagName:`code`,properties:{},children:a},f=[],p={...n,structure:s,addClassToHast:i8,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return o},get pre(){return u},get code(){return d},get lines(){return f}};if(e.forEach((e,t)=>{t&&(s===`inline`?o.children.push({type:`element`,tagName:`br`,properties:{},children:[]}):s===`classic`&&a.push({type:`text`,value:`
|
|
1042
|
-
`}));let n={type:`element`,tagName:`span`,properties:{class:`line`},children:[]},r=0;for(let a of e){let e={type:`element`,tagName:`span`,properties:{...a.htmlAttrs},children:[{type:`text`,value:a.content}]},c=s8(a.htmlStyle||o8(a));c&&(e.properties.style=c);for(let o of i)e=o?.span?.call(p,e,t+1,r,n,a)||e;s===`inline`?o.children.push(e):s===`classic`&&n.children.push(e),r+=a.content.length}if(s===`classic`){for(let e of i)n=e?.line?.call(p,n,t+1)||n;f.push(n),a.push(n)}else s===`inline`&&f.push(n)}),s===`classic`){for(let e of i)d=e?.code?.call(p,d)||d;u.children.push(d);for(let e of i)u=e?.pre?.call(p,u)||u;o.children.push(u)}else if(s===`inline`){let e=[],t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]};for(let n of o.children)n.type===`element`&&n.tagName===`br`?(e.push(t),t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]}):(n.type===`element`||n.type===`text`)&&t.children.push(n);e.push(t);let n={type:`element`,tagName:`code`,properties:{},children:e};for(let e of i)n=e?.code?.call(p,n)||n;o.children=[];for(let e=0;e<n.children.length;e++){e>0&&o.children.push({type:`element`,tagName:`br`,properties:{},children:[]});let t=n.children[e];t.type===`element`&&o.children.push(...t.children)}}let m=o;for(let e of i)m=e?.root?.call(p,m)||m;return r&&Z6(m,r),m}function
|
|
1039
|
+
\f\r "&'<=>\``.split(``)]],single:[[`&'`.split(``),`"&'\``.split(``)],[`\0&'`.split(``),`\0"&'\``.split(``)]],double:[[`"&`.split(``),`"&'\``.split(``)],[`\0"&`.split(``),`\0"&'\``.split(``)]]};function A6e(e,t,n,r){let i=r.schema,a=i.space!==`svg`&&r.settings.omitOptionalTags,o=i.space===`svg`?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),s=[],c;i.space===`html`&&e.tagName===`svg`&&(r.schema=I4);let l=j6e(r,e.properties),u=r.all(i.space===`html`&&e.tagName===`template`?e.content:e);return r.schema=i,u&&(o=!1),(l||!a||!w6e(e,t,n))&&(s.push(`<`,e.tagName,l?` `+l:``),o&&(i.space===`svg`||r.settings.closeSelfClosing)&&(c=l.charAt(l.length-1),(!r.settings.tightSelfClosing||c===`/`||c&&c!==`"`&&c!==`'`)&&s.push(` `),s.push(`/`)),s.push(`>`)),s.push(u),!o&&(!a||!e3(e,t,n))&&s.push(`</`+e.tagName+`>`),s.join(``)}function j6e(e,t){let n=[],r=-1,i;if(t){for(i in t)if(t[i]!==null&&t[i]!==void 0){let r=M6e(e,i,t[i]);r&&n.push(r)}}for(;++r<n.length;){let t=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&t!==`"`&&t!==`'`&&(n[r]+=` `)}return n.join(``)}function M6e(e,t,n){let r=P4(e.schema,t),i=e.settings.allowParseErrors&&e.schema.space===`html`?0:1,a=+!e.settings.allowDangerousCharacters,o=e.quote,s;if(r.overloadedBoolean&&(n===r.attribute||n===``)?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!=`string`||n===r.attribute||n===``)&&(n=!!n),n==null||n===!1||typeof n==`number`&&Number.isNaN(n))return``;let c=W4(r.attribute,Object.assign({},e.settings.characterReferences,{subset:i3.name[i][a]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?K4:q4)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?c:(e.settings.preferUnquoted&&(s=W4(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:i3.unquoted[i][a]}))),s!==n&&(e.settings.quoteSmart&&G4(n,o)>G4(n,e.alternative)&&(o=e.alternative),s=o+W4(n,Object.assign({},e.settings.characterReferences,{subset:(o===`'`?i3.single:i3.double)[i][a],attribute:!0}))+o),c+(s&&`=`+s))}var N6e=[`<`,`&`];function a3(e,t,n,r){return n&&n.type===`element`&&(n.tagName===`script`||n.tagName===`style`)?e.value:W4(e.value,Object.assign({},r.settings.characterReferences,{subset:N6e}))}function P6e(e,t,n,r){return r.settings.allowDangerousHtml?e.value:a3(e,t,n,r)}function F6e(e,t,n,r){return r.all(e)}var I6e=R4(`type`,{invalid:L6e,unknown:R6e,handlers:{comment:a6e,doctype:o6e,element:A6e,raw:P6e,root:F6e,text:a3}});function L6e(e){throw Error("Expected node, not `"+e+"`")}function R6e(e){throw Error("Cannot compile unknown node `"+e.type+"`")}var z6e={},B6e={},V6e=[];function o3(e,t){let n=t||z6e,r=n.quote||`"`,i=r===`"`?`'`:`"`;if(r!==`"`&&r!==`'`)throw Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:H6e,all:U6e,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||u4,characterReferences:n.characterReferences||B6e,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space===`svg`?I4:F4,quote:r,alternative:i}.one(Array.isArray(e)?{type:`root`,children:e}:e,void 0,void 0)}function H6e(e,t,n){return I6e(e,t,n,this)}function U6e(e){let t=[],n=e&&e.children||V6e,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join(``)}var W6e=class{mode;options;hoveredLine;hoveredToken;pre;gutterUtilityLine;gutterUtilityContainer;gutterUtilityButton;gutterUtilitySlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasPointerListeners=!1;hasDocumentPointerListeners=!1;selectedRange=null;selectedRangeHighlightSide;selectedRangeLineNumberOnly=!1;editorActiveLine=null;editorActiveLineSide;editorLineNumberOnly=!1;proposedSelectedRange;renderedSelectedLinesState;renderedEditorActiveLineState;selectionAnchor;pointerSession={mode:`idle`};constructor(e,t){this.mode=e,this.options=t}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener(`click`,this.handlePointerClick),this.pre?.removeEventListener(`pointerdown`,this.handlePointerDown),this.pre?.removeEventListener(`pointermove`,this.handlePointerMove),this.pre?.removeEventListener(`pointerleave`,this.handlePointerLeave),this.pre?.removeAttribute(`data-interactive-lines`),this.pre?.removeAttribute(`data-interactive-line-numbers`),this.pre=void 0,this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.clearHoveredLine(),this.clearHoveredToken(),this.detachDocumentPointerListeners(),this.clearPointerSession(),k2(this.renderSelection),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasPointerListeners=!1,this.setSelectionDirty()}setup(e){this.setSelectionDirty();let{usesCustomGutterUtility:t=!1,enableGutterUtility:n=!1}=this.options;this.pre!==e&&(this.cleanUp(),this.pre=e),n?this.ensureGutterUtilityNode(t):this.gutterUtilityContainer!=null&&(this.gutterUtilityContainer.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.pointerSession.mode===`gutterSelecting`&&(this.clearPointerSession(),this.detachDocumentPointerListeners())),this.syncPointerListeners(e),this.updateInteractiveLineAttributes(),this.renderSelection(),this.placeUtility()}setSelectionDirty(){this.renderedSelectedLinesState=void 0,this.renderedEditorActiveLineState=void 0}isSelectionDirty(){return this.renderedSelectedLinesState===void 0||this.renderedEditorActiveLineState===void 0}setSelection(e,t){let n=!(e===this.selectedRange||P2(e??void 0,this.selectedRange??void 0)),r=t?.lineNumberOnly??!1,i=t?.activeLineSide!==this.selectedRangeHighlightSide||r!==this.selectedRangeLineNumberOnly;!this.isSelectionDirty()&&!n&&!i||(this.proposedSelectedRange=void 0,this.selectedRange=e,this.selectedRangeHighlightSide=t?.activeLineSide,this.selectedRangeLineNumberOnly=r,this.renderSelection(),this.placeUtility(),n&&t?.notify!==!1&&this.notifySelectionCommitted(e))}setEditorActiveLine(e,{lineNumberOnly:t=!1,side:n}={}){let r=e!==this.editorActiveLine,i=n!==this.editorActiveLineSide||t!==this.editorLineNumberOnly;!this.isSelectionDirty()&&!r&&!i||(this.editorActiveLine=e,this.editorActiveLineSide=n,this.editorLineNumberOnly=t,this.renderSelection())}getSelection(){return this.selectedRange}getHoveredLine=()=>{let e=this.gutterUtilityLine??this.hoveredLine;if(e!=null){if(this.mode===`diff`&&e.type===`diff-line`)return{lineNumber:e.lineNumber,side:e.annotationSide};if(this.mode===`file`&&e.type===`line`)return{lineNumber:e.lineNumber}}};handlePointerClick=e=>{let{onHunkExpand:t,onLineClick:n,onLineNumberClick:r,onTokenClick:i,onMergeConflictActionClick:a}=this.options;(t!=null||n!=null||r!=null||a!=null||i!=null)&&(this.options.onGutterUtilityClick!=null&&l4(e.composedPath())||(g3(this.options.__debugPointerEvents,`click`,`FileDiff.DEBUG.handlePointerClick:`,e),this.handlePointerEvent({eventType:`click`,event:e})))};handlePointerMove=e=>{if(e.pointerType!==`mouse`)return;let{lineHoverHighlight:t=`disabled`,onLineEnter:n,onLineLeave:r,onTokenEnter:i,onTokenLeave:a,enableGutterUtility:o=!1}=this.options;t===`disabled`&&!o&&n==null&&r==null&&i==null&&a==null||(g3(this.options.__debugPointerEvents,`move`,`FileDiff.DEBUG.handlePointerMove:`,e),this.handlePointerEvent({eventType:`move`,event:e}))};handlePointerLeave=e=>{let{__debugPointerEvents:t}=this.options;if(g3(t,`move`,`FileDiff.DEBUG.handlePointerLeave: no event`),this.hoveredLine==null&&this.hoveredToken==null){g3(t,`move`,`FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token`);return}this.hoveredToken!=null&&(this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken()),this.hoveredLine!=null&&(this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()),this.placeUtility()};handlePointerEvent({eventType:e,event:t}){let{__debugPointerEvents:n}=this.options,r=t.composedPath();g3(n,e,`FileDiff.DEBUG.handlePointerEvent:`,{eventType:e,composedPath:r});let i=this.resolvePointerTarget(r);g3(n,e,`FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:`,i);let{onLineClick:a,onLineNumberClick:o,onLineEnter:s,onLineLeave:c,onTokenClick:l,onTokenEnter:u,onTokenLeave:d,onHunkExpand:f,onMergeConflictActionClick:p}=this.options;switch(e){case`move`:{let e=l3(i)&&this.hoveredLine?.lineElement===i.lineElement;c3(i)&&this.hoveredToken?.tokenElement===i.tokenElement||(this.hoveredToken!=null&&(d?.(this.hoveredToken,t),this.clearHoveredToken()),c3(i)&&(this.setHoveredToken(this.toTokenEventBaseProps(i)),u?.(this.hoveredToken,t))),e||(this.hoveredLine!=null&&(c?.({...this.hoveredLine,event:t}),this.clearHoveredLine()),l3(i)?(this.setHoveredLine(this.toEventBaseProps(i)),this.placeUtility(),s?.({...this.hoveredLine,event:t})):this.placeUtility());break}case`click`:{if(i==null)break;if(J6e(i)&&p!=null){p(i);break}if(q6e(i)&&f!=null){f(i.hunkIndex,i.all||t.shiftKey?`both`:i.direction,i.all||t.shiftKey?1/0:void 0);break}if(!l3(i))break;c3(i)&&l!=null&&l(this.toTokenEventBaseProps(i),t);let e=this.toEventBaseProps(i);o!=null&&i.numberColumn?o({...e,event:t}):a?.({...e,event:t});break}}}syncPointerListeners(e){let{__debugPointerEvents:t,lineHoverHighlight:n=`disabled`,onLineClick:r,onLineNumberClick:i,onLineEnter:a,onLineLeave:o,onTokenClick:s,onTokenEnter:c,onTokenLeave:l,onHunkExpand:u,onMergeConflictActionClick:d,enableGutterUtility:f=!1,enableLineSelection:p=!1,onGutterUtilityClick:m}=this.options,h=m!=null,g=n!==`disabled`||r!=null||i!=null||a!=null||o!=null||s!=null||c!=null||l!=null||u!=null||d!=null||f||p||h;g&&!this.hasPointerListeners?(e.addEventListener(`click`,this.handlePointerClick),e.addEventListener(`pointerdown`,this.handlePointerDown),e.addEventListener(`pointermove`,this.handlePointerMove),e.addEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!0,g3(t,`click`,`FileDiff.DEBUG.attachEventListeners: Attaching click events for:`,(()=>{let e=[];return(t===`both`||t===`click`)&&(r!=null&&e.push(`onLineClick`),i!=null&&e.push(`onLineNumberClick`),u!=null&&e.push(`expandable hunk separators`),d!=null&&e.push(`merge conflict actions`)),e})()),g3(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer move event`),g3(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event`)):!g&&this.hasPointerListeners&&(e.removeEventListener(`click`,this.handlePointerClick),e.removeEventListener(`pointerdown`,this.handlePointerDown),e.removeEventListener(`pointermove`,this.handlePointerMove),e.removeEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!1);let _=this.pointerSession.mode===`selecting`||this.pointerSession.mode===`pendingSingleLineUnselect`,v=this.pointerSession.mode===`gutterSelecting`;(!p&&_||!h&&v)&&(this.clearPointerSession(),this.detachDocumentPointerListeners(),this.selectionAnchor=void 0,this.clearPendingSingleLineState())}updateInteractiveLineAttributes(){if(this.pre==null)return;let{onLineClick:e,onLineNumberClick:t,enableLineSelection:n=!1}=this.options,r=e!=null,i=t!=null||n;r&&!this.interactiveLinesAttr?(this.pre.setAttribute(`data-interactive-lines`,``),this.interactiveLinesAttr=!0):!r&&this.interactiveLinesAttr&&(this.pre.removeAttribute(`data-interactive-lines`),this.interactiveLinesAttr=!1),i&&!this.interactiveLineNumbersAttr?(this.pre.setAttribute(`data-interactive-line-numbers`,``),this.interactiveLineNumbersAttr=!0):!i&&this.interactiveLineNumbersAttr&&(this.pre.removeAttribute(`data-interactive-line-numbers`),this.interactiveLineNumbersAttr=!1)}handlePointerDown=e=>{if(e.pointerType===`mouse`&&e.button!==0||this.pre==null||this.pointerSession.mode!==`idle`)return;let t=e.composedPath();l4(t)&&this.options.onGutterUtilityClick!=null?this.startGutterSelectionFromPointerDown(e):(e.pointerType!==`mouse`&&this.revealUtilityFromGutterPath(t),this.startLineSelectionFromPointerDown(e))};startLineSelectionFromPointerDown(e){let{enableLineSelection:t=!1}=this.options;if(!t)return;let n=this.resolveSelectionInfo(e,{source:`event-path`,requireNumberColumn:!0});if(n==null)return;let{pre:r}=this;if(r==null)return;let{lineNumber:i,eventSide:a,lineIndex:o}=n;if(e.shiftKey&&this.selectedRange!=null){let t=this.getIndexesFromSelection(this.selectedRange,r.getAttribute(`data-diff-type`)===`split`);if(t==null)return;let n=t.start<=t.end?o>=t.start:o<=t.end;this.selectionAnchor={lineNumber:n?this.selectedRange.start:this.selectedRange.end,side:n?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners();return}if(this.selectedRange?.start===i&&this.selectedRange?.end===i){let t={lineNumber:i,side:a};this.selectionAnchor=t,this.pointerSession={mode:`pendingSingleLineUnselect`,pointerId:e.pointerId,anchor:t,pending:t},this.attachDocumentPointerListeners();return}this.options.controlledSelection===!0?this.proposedSelectedRange=null:this.selectedRange=null,this.placeUtility(),this.selectionAnchor={lineNumber:i,side:a},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners()}startGutterSelectionFromPointerDown(e){let{onGutterUtilityClick:t}=this.options;if(t==null)return;let n=this.currentSelectionEnds(),r=n?.bottom??this.resolveSelectionPoint(e,{source:`event-path`,excludeUtility:!1}),i=n?.top??r;r!=null&&i!=null&&(e.preventDefault(),e.stopPropagation(),this.pointerSession={mode:`gutterSelecting`,pointerId:e.pointerId,anchor:i,current:r},this.selectionAnchor={lineNumber:i.lineNumber,side:i.side},this.updateSelection(r.lineNumber,r.side,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.attachDocumentPointerListeners())}handleDocumentPointerMove=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionPoint(e,{source:`coordinates-first`});if(t==null)return;this.pointerSession.current=t,this.updateSelection(t.lineNumber,t.side);return}case`selecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;this.updateSelection(t.lineNumber,t.eventSide);return}case`pendingSingleLineUnselect`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;let n={lineNumber:t.lineNumber,side:t.eventSide};if(M3e(this.pointerSession.pending,n))return;this.updateSelection(t.lineNumber,t.eventSide,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.notifySelectionChangeDelta(),this.pointerSession={mode:`selecting`,pointerId:e.pointerId};return}}};handleDocumentPointerUp=e=>{let{onGutterUtilityClick:t}=this.options;switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{let{pointerSession:n}=this;if(e.pointerId!==n.pointerId)return;e.preventDefault();let r=this.resolveSelectionPoint(e,{source:`coordinates-first`});r!=null&&(n.current=r,this.updateSelection(r.lineNumber,r.side));let i=this.buildSelectedLineRange(n.anchor,n.current);t?.({...i}),this.selectionAnchor=void 0,this.notifySelectionEnd(i),this.notifySelectionCommitted(i),this.clearProposedSelection(),this.clearPointerSession(),this.detachDocumentPointerListeners();return}case`pendingSingleLineUnselect`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.updateSelection(null,void 0,!1),this.selectionAnchor=void 0,this.clearPendingSingleLineState(),this.detachDocumentPointerListeners(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection();return;case`selecting`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.selectionAnchor=void 0,this.detachDocumentPointerListeners(),this.clearPointerSession(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection()}};handleDocumentPointerCancel=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:case`selecting`:case`pendingSingleLineUnselect`:if(`pointerId`in this.pointerSession&&e.pointerId!==this.pointerSession.pointerId)return;this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){this.hoveredLine!=null&&(this.hoveredLine.lineElement.removeAttribute(`data-hovered`),this.hoveredLine.numberElement.removeAttribute(`data-hovered`),this.hoveredLine=void 0)}setHoveredLine(e){let{lineHoverHighlight:t=`disabled`}=this.options;this.hoveredLine!=null&&this.clearHoveredLine(),this.hoveredLine=e,t!==`disabled`&&((t===`both`||t===`line`)&&this.hoveredLine.lineElement.setAttribute(`data-hovered`,``),(t===`both`||t===`number`)&&this.hoveredLine.numberElement.setAttribute(`data-hovered`,``))}clearHoveredToken(){this.hoveredToken!=null&&(this.hoveredToken=void 0)}setHoveredToken(e){this.hoveredToken!=null&&this.clearHoveredToken(),this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer??(this.gutterUtilityContainer=document.createElement(`div`),this.gutterUtilityContainer.setAttribute(`data-gutter-utility-slot`,``)),e)this.gutterUtilityButton!=null&&(this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0),this.gutterUtilitySlot??(this.gutterUtilitySlot=document.createElement(`slot`),this.gutterUtilitySlot.name=`gutter-utility-slot`),this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){let e=document.createElement(`div`);e.innerHTML=o3(j3e());let t=e.firstElementChild;if(!(t instanceof HTMLButtonElement))throw Error(`InteractionManager.ensureGutterUtilityNode: Node element should be a button`);t.remove(),this.gutterUtilityButton=t}this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;let t=this.resolvePointerTarget(e);s3(t)&&t.numberColumn&&this.showUtilityOnLine(this.toEventBaseProps(t))}placeUtility(){if(!this.placeUtilityFromSelection()){if(this.hoveredLine!=null){this.showUtilityOnLine(this.hoveredLine);return}this.hideUtility()}}placeUtilityFromSelection(){let e=this.currentSelectionEnds();if(e==null)return!1;let t=this.targetForSelectionPoint(e.bottom);return t==null?this.hideUtility():this.showUtilityOnLine(this.toEventBaseProps(t)),!0}showUtilityOnLine(e){this.gutterUtilityContainer!=null&&(this.gutterUtilityLine=e,e.numberElement.appendChild(this.gutterUtilityContainer))}hideUtility(){this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0}currentSelectionEnds(){let e=this.getCurrentSelectionRange();return e==null?void 0:this.selectionEnds(e)}selectionEnds(e){let t={lineNumber:e.start,side:e.side},n={lineNumber:e.end,side:e.endSide??e.side},r=this.selectionPointRowIndex(t),i=this.selectionPointRowIndex(n);if(r!=null&&i!=null)return r>i?{top:n,bottom:t}:{top:t,bottom:n}}selectionPointRowIndex(e){let t=this.getLineIndex(e.lineNumber,e.side);if(t!=null)return this.isSplitDiff()?t[1]:t[0]}targetForSelectionPoint(e){if(this.pre==null)return;let t=this.getLineIndex(e.lineNumber,e.side);if(t==null)return;let n=this.mode===`diff`?`${t[0]},${t[1]}`:`${t[0]}`,r=this.pre.querySelectorAll(`[data-column-number="${e.lineNumber}"][data-line-index="${n}"]`);for(let t of r){if(!(t instanceof HTMLElement))continue;let n=this.resolvePointerTarget(d3(t));if(s3(n)&&(this.mode!==`diff`||e.side==null||n.side===e.side))return n}}attachDocumentPointerListeners(){this.hasDocumentPointerListeners||=(document.addEventListener(`pointermove`,this.handleDocumentPointerMove),document.addEventListener(`pointerup`,this.handleDocumentPointerUp),document.addEventListener(`pointercancel`,this.handleDocumentPointerCancel),!0)}detachDocumentPointerListeners(){this.hasDocumentPointerListeners&&=(document.removeEventListener(`pointermove`,this.handleDocumentPointerMove),document.removeEventListener(`pointerup`,this.handleDocumentPointerUp),document.removeEventListener(`pointercancel`,this.handleDocumentPointerCancel),!1)}clearPointerSession(){this.pointerSession={mode:`idle`}}clearPendingSingleLineState(){this.pointerSession.mode===`pendingSingleLineUnselect`&&(this.pointerSession={mode:`idle`})}selectionInfoFromPath(e,t){let n=this.resolvePointerTarget(e);if(s3(n)&&!(t&&!n.numberColumn)&&n.splitLineIndex!=null)return{lineIndex:n.splitLineIndex,lineNumber:n.lineNumber,eventSide:this.mode===`diff`?n.side:void 0}}resolveSelectionInfo(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionInfoFromPath(n,t.requireNumberColumn)}selectionPointFromPath(e){let t=this.resolvePointerTarget(e);if(s3(t))return{lineNumber:t.lineNumber,side:this.mode===`diff`?t.side:void 0}}resolveSelectionPoint(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionPointFromPath(n)}resolveSelectionPath(e,t){let n=t.excludeUtility!==!1;switch(t.source){case`event-path`:return this.pathFromEventPath(e.composedPath(),n);case`coordinates-first`:{let t=this.pathFromCoordinates(e,n);return t===void 0?this.pathFromEventPath(e.composedPath(),n):t??void 0}}}pathFromCoordinates(e,t){let n=this.hitTest(e);if(n!==void 0)return n===null?null:this.pathFromElement(n,t)??null}pathFromEventPath(e,t){if(!(t&&l4(e))){for(let n of e)if(n instanceof Element)return this.pathFromElement(n,t)}}pathFromElement(e,t){let n=d3(e);if(t&&l4(n))return;let r=X6e(e);return r==null?this.pathFromAnnotationSlot(e):d3(r)}pathFromAnnotationSlot(e){let t=Q6e(Z6e(e));if(t==null)return;let n=this.targetForSelectionPoint(t);return n==null?void 0:d3(n.lineElement)}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;let t=this.pre?.getRootNode(),n=f3(t)?t:f3(document)?document:void 0;if(n!=null)return n.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,t){let{getLineIndex:n}=this.options;return n==null?[e-1,e-1]:n(e,t)}getCurrentSelectionRange(){return this.proposedSelectedRange===void 0?this.selectedRange:this.proposedSelectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,t,n=!0){let r=this.getCurrentSelectionRange(),i;if(e==null)i=null;else{let n=this.selectionAnchor?.side??t,r=this.selectionAnchor?.lineNumber??e;i=this.buildSelectionRange(r,e,n,t)}P2(r??void 0,i??void 0)||(this.selectedRangeHighlightSide=void 0,this.selectedRangeLineNumberOnly=!1,this.options.controlledSelection===!0?this.proposedSelectedRange=i:(this.selectedRange=i,O2(this.renderSelection)),this.placeUtility(),n&&this.notifySelectionChangeDelta())}getIndexesFromSelection(e,t){if(this.pre==null)return;let n=this.getLineIndex(e.start,e.side),r=this.getLineIndex(e.end,e.endSide??e.side);return n!=null&&r!=null?{start:t?n[1]:n[0],end:t?r[1]:r[0]}:void 0}getSelectionRenderState(){return{selectedLines:{range:this.selectedRange,highlightSide:this.selectedRangeHighlightSide,lineNumberOnly:this.selectedRangeLineNumberOnly},editorActiveLine:{range:this.editorActiveLine==null?null:{start:this.editorActiveLine,end:this.editorActiveLine,side:this.editorActiveLineSide},highlightSide:this.editorActiveLineSide,lineNumberOnly:this.editorLineNumberOnly}}}resolveLineRenderRange(e,t,n){if(e.range==null)return;let r=this.getIndexesFromSelection(e.range,t);if(r==null)throw console.error({rowRange:r,range:e.range}),Error(`InteractionManager.renderSelection: No valid ${n} rowRange`);return r}getLineRenderColumns(e,t,n,r){if(this.pre==null||t==null&&r==null)return[];let{children:i}=this.pre;if(i.length>2)throw console.error(i),Error(`InteractionManager.renderSelection: Somehow there are more than 2 code elements...`);let a=[];for(let o of i){let i=o.hasAttribute(`data-deletions`)?`deletions`:o.hasAttribute(`data-additions`)?`additions`:void 0,s=e!=null&&t!=null&&(e.highlightSide==null||i==null||e.highlightSide===i),c=n!=null&&r!=null&&(n.highlightSide==null||i==null||n.highlightSide===i);if(!s&&!c)continue;let[l,u]=o.children;if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))throw Error(`InteractionManager.renderSelection: missing gutter or content element`);if(u.children.length!==l.children.length)throw Error(`InteractionManager.renderSelection: gutter and content children dont match, something is wrong`);a.push({content:u,gutter:l,renderEditorActiveLine:c,renderSelectedLines:s})}return a}renderSelection=()=>{k2(this.renderSelection);let e=this.getSelectionRenderState();if(this.pre==null)return;let{editorActiveLine:t,selectedLines:n}=e,r=!p3(this.renderedSelectedLinesState,n),i=!p3(this.renderedEditorActiveLineState,t);if(!r&&!i)return;r&&(this.renderedSelectedLinesState=void 0),i&&(this.renderedEditorActiveLineState=void 0);let a=this.pre.getAttribute(`data-diff-type`)===`split`,o=r?this.resolveLineRenderRange(n,a,`selected-lines`):void 0,s=i?this.resolveLineRenderRange(t,a,`editor-active-line`):void 0,c=this.getLineRenderColumns(r?n:void 0,o,i?t:void 0,s),l=n.range==null||c.some(e=>e.renderSelectedLines),u=t.range==null||c.some(e=>e.renderEditorActiveLine);if(r)for(let e of this.pre.querySelectorAll(`[data-selected-line]`))e.removeAttribute(`data-selected-line`);if(i)for(let e of this.pre.querySelectorAll(`[data-editor-active-line]`))e.removeAttribute(`data-editor-active-line`);let d=o==null?void 0:Math.min(o.start,o.end),f=o==null?void 0:Math.max(o.start,o.end),p=d===f,m=s?.start;for(let e of c){let{content:r,gutter:i,renderEditorActiveLine:o,renderSelectedLines:s}=e,c=Math.max(s?f??-1/0:-1/0,o?m??-1/0:-1/0),l=r.children.length;for(let e=0;e<l;e++){let l=r.children[e],u=i.children[e];if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))continue;let h=this.parseLineIndex(l,a);if((h??0)>c)break;if(h!=null){if(s&&d!=null&&f!=null&&h>=d&&h<=f){let e=p?`single`:h===d?`first`:h===f?`last`:``;u.setAttribute(`data-selected-line`,e),n.lineNumberOnly||(l.setAttribute(`data-selected-line`,e),u.nextSibling instanceof HTMLElement&&l.nextSibling instanceof HTMLElement&&(l.nextSibling.hasAttribute(`data-line-annotation`)||l.nextSibling.hasAttribute(`data-merge-conflict-actions`))&&(p?(e=`last`,l.setAttribute(`data-selected-line`,`first`)):h===d?e=``:h===f&&l.setAttribute(`data-selected-line`,``),l.nextSibling.setAttribute(`data-selected-line`,e),u.nextSibling.setAttribute(`data-selected-line`,e)))}o&&h===m&&(u.setAttribute(`data-editor-active-line`,``),t.lineNumberOnly||l.setAttribute(`data-editor-active-line`,``))}}}r&&l&&(this.renderedSelectedLinesState=n),i&&u&&(this.renderedEditorActiveLineState=t)};notifySelectionCommitted(e){this.options.onLineSelected?.(e)}notifySelectionChangeDelta(){this.options.onLineSelectionChange?.(this.getCurrentSelectionRange()??null)}notifySelectionStart(e){this.options.onLineSelectionStart?.(e)}notifySelectionEnd(e){this.options.onLineSelectionEnd?.(e)}toEventBaseProps(e){return this.mode===`file`?{type:`line`,lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement}:{type:`diff-line`,annotationSide:e.side,lineType:e.lineType,lineElement:e.lineElement,numberElement:e.numberElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn}}toTokenEventBaseProps({lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}){return this.mode===`file`?{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,tokenElement:i,tokenText:a}:{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}}buildSelectedLineRange(e,t){return this.buildSelectionRange(e.lineNumber,t.lineNumber,e.side,t.side)}buildSelectionRange(e,t,n,r){return{start:e,end:t,...n==null?{}:{side:n},...n!==r&&r!=null?{endSide:r}:{}}}resolvePointerTarget(e){let t=!1,n,r,i,a,o,s,c,l,u,d;for(let f of e){if(!(f instanceof HTMLElement))continue;if(d==null&&f.hasAttribute(`data-merge-conflict-action`)){let e=f.getAttribute(`data-merge-conflict-action`)??void 0,t=f.getAttribute(`data-merge-conflict-conflict-index`)??void 0,n=t==null?NaN:Number.parseInt(t,10);Y6e(e)&&Number.isFinite(n)&&(d={kind:`merge-conflict-action`,resolution:e,conflictIndex:n})}if(s==null&&f.hasAttribute(`data-char`)){s=f;let e=f.getAttribute(`data-char`);if(e!=null){let t=Number.parseInt(e,10);if(!Number.isNaN(t)){let e=f.textContent??``,n=t+e.length;(e.trim()!==``||this.options.enableTokenInteractionsOnWhitespace===!0)&&(c={tokenElement:s,lineCharStart:t,lineCharEnd:n,tokenText:e});continue}}}let e=o==null?f.getAttribute(`data-column-number`)??void 0:void 0;if(e!=null){o=f,u=Number.parseInt(e,10),t=!0,n=h3(f),a=f.getAttribute(`data-line-index`)??void 0;continue}let p=i==null?f.getAttribute(`data-line`)??void 0:void 0;if(p!=null){i=f,u=Number.parseInt(p,10),n=h3(f),a=f.getAttribute(`data-line-index`)??void 0;continue}if(l==null&&(f.hasAttribute(`data-expand-button`)||f.hasAttribute(`data-unmodified-lines`))){l={hunkIndex:void 0,direction:f.hasAttribute(`data-expand-up`)?`up`:f.hasAttribute(`data-expand-down`)?`down`:`both`,all:f.hasAttribute(`data-expand-all-button`)};continue}let m=l==null?void 0:f.getAttribute(`data-expand-index`)??void 0;if(l!=null&&m!=null){let e=Number.parseInt(m,10);Number.isNaN(e)||(l.hunkIndex=e);continue}if(r==null&&f.hasAttribute(`data-code`)){r=f;break}}if(d!=null)return d;if(l?.hunkIndex!=null)return{type:`line-info`,hunkIndex:l.hunkIndex,direction:l.direction,all:l.all};if(i??=a==null?void 0:u3(r,`[data-line][data-line-index="${a}"]`),o??=a==null?void 0:u3(r,`[data-column-number][data-line-index="${a}"]`),r==null||i==null||o==null||n==null||u==null||Number.isNaN(u))return;let f=this.parseLineIndex(i,this.isSplitDiff());return c==null?this.mode===`file`?{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f}:{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:m3(n,r),splitLineIndex:f}:this.mode===`file`?{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f,...c}:{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:m3(n,r),splitLineIndex:f,...c}}isSplitDiff(){return this.pre?.getAttribute(`data-diff-type`)===`split`}parseLineIndex(e,t){let n=(e.getAttribute(`data-line-index`)??``).split(`,`).map(e=>Number.parseInt(e,10)).filter(e=>!Number.isNaN(e));if(t&&n.length===2)return n[1];if(!t)return n[0]}};function G6e({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:t,lineHoverHighlight:n,onGutterUtilityClick:r,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,renderGutterUtility:d,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v},y,b,x){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:K6e({enableGutterUtility:t,renderGutterUtility:d,onGutterUtilityClick:r}),usesCustomGutterUtility:d!=null,lineHoverHighlight:n,onGutterUtilityClick:r,onHunkExpand:y,onMergeConflictActionClick:x,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v,getLineIndex:b}}function K6e({enableGutterUtility:e,renderGutterUtility:t,onGutterUtilityClick:n}){if(n!=null&&t!=null)throw Error(`Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.`);return e??!1}function s3(e){return e!=null&&`kind`in e&&e.kind===`line`}function c3(e){return e!=null&&`kind`in e&&e.kind===`token`}function l3(e){return s3(e)||c3(e)}function q6e(e){return`type`in e&&e.type===`line-info`}function J6e(e){return`kind`in e&&e.kind===`merge-conflict-action`}function Y6e(e){return e===`current`||e===`incoming`||e===`both`}function u3(e,t){let n=e?.querySelector(t);return n instanceof HTMLElement?n:void 0}function d3(e){let t=[],n=e;for(;n!=null;)t.push(n),n=n.parentNode;return t}function X6e(e){let t=e.closest(`[data-line], [data-column-number]`);if(t instanceof HTMLElement)return t;let n=e.closest(`[data-line-annotation], [data-gutter-buffer="annotation"]`);if(!(n instanceof HTMLElement))return;let r=n.previousElementSibling;return r instanceof HTMLElement&&(r.hasAttribute(`data-line`)||r.hasAttribute(`data-column-number`))?r:void 0}function Z6e(e){let t=e.closest(`[slot^="annotation-"]`);if(t instanceof HTMLElement)return t.getAttribute(`slot`)??void 0;if(e instanceof HTMLElement){let t=e.getAttribute(`name`)??void 0;return t!=null&&t.startsWith(`annotation-`)?t:void 0}}function Q6e(e){if(e==null)return;let t=/^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(e);if(t==null)return;let n=Number.parseInt(t[2],10);if(!(!Number.isFinite(n)||n<=0))return{lineNumber:n,side:t[1]}}function f3(e){return e!=null&&typeof e.elementFromPoint==`function`}function $6e(e,t){return e===t||P2(e??void 0,t??void 0)}function p3(e,t){return e?.highlightSide===t.highlightSide&&e?.lineNumberOnly===t.lineNumberOnly&&$6e(e?.range??null,t.range)}function m3(e,t){switch(e){case`change-deletion`:return`deletions`;case`change-addition`:return`additions`;default:return t.hasAttribute(`data-deletions`)?`deletions`:`additions`}}function h3(e){let t=e.getAttribute(`data-line-type`);if(t!=null)switch(t){case`change-deletion`:case`change-addition`:case`context`:case`context-expanded`:return t;default:return}}function g3(e=`none`,t,...n){switch(e){case`none`:return;case`both`:break;case`click`:if(t!==`click`)return;break;case`move`:if(t!==`move`)return}console.log(...n)}var e8e=class e{static resizeObserver;static managersByElement=new Map;static getResizeObserver(){let t=e.resizeObserver??new ResizeObserver(e.handleSharedResizeEntries);return e.resizeObserver=t,t}static handleSharedResizeEntries(t){let n=new Map;for(let r of t){let t=e.managersByElement.get(r.target);if(t==null)continue;let i=n.get(t);i==null?n.set(t,[r]):i.push(r)}for(let[e,t]of n)e.handleResizeEntries(t)}observedNodes=new Map;setup(e,{disableAnnotations:t,columnVariables:n=`apply`}){let r=new Set,i=n===`apply`,a=0,o=new Map(this.observedNodes);this.observedNodes.clear();for(let t of e.children){if(a===2)break;let e=(()=>{if(t instanceof HTMLElement&&t.tagName===`CODE`)return t})();if(e==null)continue;a++;let n=o.get(e);if(n!=null&&n.type!==`code`)throw Error(`ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible`);let r=e.firstElementChild;r instanceof HTMLElement||(r=null),n==null?(n={type:`code`,codeElement:e,numberElement:r,codeWidth:`auto`,numberWidth:0,applyColumnVariables:i},this.observedNodes.set(e,n),this.observe(e),r!=null&&(this.observedNodes.set(r,n),this.observe(r))):(this.observedNodes.set(e,n),o.delete(e),n.numberElement===r?n.numberElement==null?n.numberWidth=0:(o.delete(n.numberElement),this.observedNodes.set(n.numberElement,n)):(n.numberElement!=null&&(this.unobserve(n.numberElement),o.delete(n.numberElement)),r!=null&&(this.observe(r),o.delete(r),this.observedNodes.set(r,n)),n.numberElement=r,n.numberWidth=0),r8e(n,i))}if(a>1&&!t){let t=e.querySelectorAll(`[data-line-annotation*=","]`),n=new Map;for(let e of t){if(!(e instanceof HTMLElement))continue;let t=e.getAttribute(`data-line-annotation`)??``;if(!/^-?\d+,-?\d+$/.test(t)){console.error(`DiffFileRenderer.setupResizeObserver: Invalid element or annotation`,{lineAnnotation:t,element:e});continue}let r=n.get(t);r??(r=[],n.set(t,r)),r.push(e)}for(let[e,t]of n){if(t.length!==2){console.error(`DiffFileRenderer.setupResizeObserver: Bad Pair`,e,t);continue}let[n,i]=t,a=n.firstElementChild,s=i.firstElementChild;if(!(n instanceof HTMLElement)||!(i instanceof HTMLElement)||!(a instanceof HTMLElement)||!(s instanceof HTMLElement))continue;let c=o.get(a);if(c!=null){this.observedNodes.set(a,c),this.observedNodes.set(s,c),o.delete(a),o.delete(s);continue}let l=a.getBoundingClientRect().height,u=s.getBoundingClientRect().height;c={type:`annotations`,column1:{container:n,child:a,childHeight:l},column2:{container:i,child:s,childHeight:u},currentHeight:`auto`},r.add({child1:a,child2:s,item:c,newHeight:Math.max(l,u)})}for(let e of r)this.applyNewHeight(e.item,e.newHeight),this.observedNodes.set(e.child1,e.item),this.observedNodes.set(e.child2,e.item),this.observe(e.child1),this.observe(e.child2);r.clear()}for(let[e,t]of o)this.unobserve(e),t.type===`code`?i8e(t):a8e(t);o.clear()}cleanUp(){for(let e of this.observedNodes.keys())this.unobserve(e);this.observedNodes.clear()}observe(t){let{managersByElement:n}=e,r=n.get(t);if(r!==this){if(r!=null&&r!==this)throw Error(`ResizeManager.observe: element is already owned by another ResizeManager`);n.set(t,this),e.getResizeObserver().observe(t)}}unobserve(t){let{managersByElement:n,resizeObserver:r}=e,i=n.get(t);if(i!=null){if(i!==this)throw Error(`ResizeManager.unobserve: element is owned by another ResizeManager`);n.delete(t),r?.unobserve(t),r!=null&&n.size===0&&(r.disconnect(),e.resizeObserver=void 0)}}handleResizeEntries(e){let t=new Map,n=new Set;for(let r of e){let{target:e,borderBoxSize:i,contentBoxSize:a}=r;if(!(e instanceof HTMLElement)){console.error(`ResizeManager.handleResizeEntries: Invalid element for ResizeObserver`,r);continue}let o=this.observedNodes.get(e);if(o==null){console.error(`ResizeManager.handleResizeEntries: Not a valid observed node`,r);continue}if(o.type===`annotations`){let t=(()=>{if(e===o.column1.child)return o.column1;if(e===o.column2.child)return o.column2})();if(t==null){console.error(`ResizeManager.handleResizeEntries: Couldn't find a column for`,{item:o,target:e});continue}t.childHeight=i[0].blockSize,n.add(o)}else if(o.type===`code`){let n=t.get(o)??{},r=a[0].inlineSize;e===o.codeElement?n.codeInlineSize=r:e===o.numberElement&&(n.numberInlineSize=r),t.set(o,n)}}this.applyAnnotationUpdates(n),n.clear(),this.applyColumnUpdates(t),t.clear()}applyAnnotationUpdates(e){for(let t of e)this.applyNewHeight(t,Math.max(t.column1.childHeight,t.column2.childHeight))}applyColumnUpdates=e=>{for(let[t,n]of e){let e=n.codeInlineSize==null?t.codeWidth:t8e(n.codeInlineSize),r=n.numberInlineSize==null?t.numberWidth:n8e(n.numberInlineSize),i=e!==t.codeWidth,a=r!==t.numberWidth;!i&&!a||(t.codeWidth=e,t.numberWidth=r,t.applyColumnVariables&&_3(t,{codeWidthChanged:i,numberWidthChanged:a}))}};applyNewHeight(e,t){t!==e.currentHeight&&(e.currentHeight=Math.max(t,0),e.column1.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`),e.column2.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`))}};function t8e(e){let t=Math.max(Math.floor(e),0);return t===0?`auto`:t}function n8e(e){return Math.max(Math.ceil(e),0)}function r8e(e,t){e.applyColumnVariables!==t&&(e.applyColumnVariables=t,t?_3(e,{codeWidthChanged:!0,numberWidthChanged:!0}):v3(e))}function _3(e,{codeWidthChanged:t,numberWidthChanged:n}){let{codeElement:r,codeWidth:i,numberWidth:a}=e;if(t&&r.style.setProperty(`--diffs-column-width`,`${typeof i==`number`?`${i}px`:`auto`}`),n&&r.style.setProperty(`--diffs-column-number-width`,`${a===0?`auto`:`${a}px`}`),t||n&&i!==`auto`){let e=typeof i==`number`?Math.max(i-a,0):0;r.style.setProperty(`--diffs-column-content-width`,`${e>0?`${e}px`:`auto`}`)}}function v3(e){e.codeElement.style.removeProperty(`--diffs-column-content-width`),e.codeElement.style.removeProperty(`--diffs-column-number-width`),e.codeElement.style.removeProperty(`--diffs-column-width`)}function i8e(e){e.codeElement.isConnected&&v3(e)}function a8e(e){e.column1.container.isConnected&&e.column1.container.style.removeProperty(`--diffs-annotation-min-height`),e.column2.container.isConnected&&e.column2.container.style.removeProperty(`--diffs-annotation-min-height`)}var y3=new Map,b3=new Map,o8e=new Map,x3=new Set;function s8e(e){for(let t of Array.isArray(e)?e:[e])if(t!==`text`&&t!==`ansi`&&!x3.has(t))return!1;return!0}function S3(e,t){e=Array.isArray(e)?e:[e];for(let n of e){if(x3.has(n.name))continue;let e=y3.get(n.name);e??(e=n,y3.set(n.name,e)),x3.add(e.name),t.loadLanguageSync(e.data)}}function C3(){return typeof WorkerGlobalScope<`u`&&typeof self<`u`&&self instanceof WorkerGlobalScope}var w3=Object.defineProperty,c8e=Object.getOwnPropertyDescriptor,l8e=Object.getOwnPropertyNames,u8e=Object.prototype.hasOwnProperty,d8e=(e,t)=>{let n={};for(var r in e)w3(n,r,{get:e[r],enumerable:!0});return t||w3(n,Symbol.toStringTag,{value:`Module`}),n},T3=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l8e(t),a=0,o=i.length,s;a<o;a++)s=i[a],!u8e.call(e,s)&&s!==n&&w3(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=c8e(t,s))||r.enumerable});return e},f8e=(e,t,n)=>(T3(e,t,`default`),n&&T3(n,t,`default`)),E3=[{id:`abap`,name:`ABAP`,import:(()=>N(()=>import(`./abap-CLvhMVsD.js`),[]))},{id:`actionscript-3`,name:`ActionScript`,import:(()=>N(()=>import(`./actionscript-3--17pq3dv.js`),[]))},{id:`ada`,name:`Ada`,import:(()=>N(()=>import(`./ada-C5qYipkI.js`),[]))},{id:`angular-html`,name:`Angular HTML`,import:(()=>N(()=>import(`./angular-html-B8mrqUL5.js`).then(e=>e.n),__vite__mapDeps([5,1,6,7,8])))},{id:`angular-ts`,name:`Angular TypeScript`,import:(()=>N(()=>import(`./angular-ts-Bzix210W.js`),__vite__mapDeps([9,5,1,6,7,8,10])))},{id:`apache`,name:`Apache Conf`,import:(()=>N(()=>import(`./apache-U0d_L8uA.js`),[]))},{id:`apex`,name:`Apex`,import:(()=>N(()=>import(`./apex-CGTLDQj6.js`),[]))},{id:`apl`,name:`APL`,import:(()=>N(()=>import(`./apl-Dhin1L29.js`),__vite__mapDeps([11,7,1,8,6,12,13,14])))},{id:`applescript`,name:`AppleScript`,import:(()=>N(()=>import(`./applescript-CCn79oCD.js`),[]))},{id:`ara`,name:`Ara`,import:(()=>N(()=>import(`./ara-4CJ0cIlV.js`),[]))},{id:`asciidoc`,name:`AsciiDoc`,aliases:[`adoc`],import:(()=>N(()=>import(`./asciidoc-DE70LPWp.js`),[]))},{id:`asm`,name:`Assembly`,import:(()=>N(()=>import(`./asm-Cmm7eHzH.js`),[]))},{id:`astro`,name:`Astro`,import:(()=>N(()=>import(`./astro-B-4NNgOP.js`),__vite__mapDeps([15,7,1,8,14,16,17,18])))},{id:`awk`,name:`AWK`,import:(()=>N(()=>import(`./awk-BWXHIvNe.js`),[]))},{id:`ballerina`,name:`Ballerina`,import:(()=>N(()=>import(`./ballerina-B7ZEbQpA.js`),[]))},{id:`bat`,name:`Batch File`,aliases:[`batch`],import:(()=>N(()=>import(`./bat-Bo4NYOV-.js`),[]))},{id:`beancount`,name:`Beancount`,import:(()=>N(()=>import(`./beancount-D-usSTwE.js`),[]))},{id:`berry`,name:`Berry`,aliases:[`be`],import:(()=>N(()=>import(`./berry-DKpUyyne.js`),[]))},{id:`bibtex`,name:`BibTeX`,import:(()=>N(()=>import(`./bibtex-Ci_nEsc7.js`),[]))},{id:`bicep`,name:`Bicep`,import:(()=>N(()=>import(`./bicep-CUHmPFLl.js`),[]))},{id:`bird2`,name:`BIRD2 Configuration`,aliases:[`bird`],import:(()=>N(()=>import(`./bird2-C6vDhewU.js`),[]))},{id:`blade`,name:`Blade`,import:(()=>N(()=>import(`./blade-Wr94ul2N.js`),__vite__mapDeps([19,7,1,8,6,12,13,14,20,21])))},{id:`bsl`,name:`1C (Enterprise)`,aliases:[`1c`],import:(()=>N(()=>import(`./bsl-BkkzgIyY.js`),__vite__mapDeps([22,23])))},{id:`c`,name:`C`,import:(()=>N(()=>import(`./c-iCihek07.js`).then(e=>e.n),__vite__mapDeps([24,1])))},{id:`c3`,name:`C3`,import:(()=>N(()=>import(`./c3-CnJL0r0V.js`),[]))},{id:`cadence`,name:`Cadence`,aliases:[`cdc`],import:(()=>N(()=>import(`./cadence-CQ2zXKGN.js`),[]))},{id:`cairo`,name:`Cairo`,import:(()=>N(()=>import(`./cairo-DLTphjLi.js`),__vite__mapDeps([25,26])))},{id:`clarity`,name:`Clarity`,import:(()=>N(()=>import(`./clarity-SemFz856.js`),[]))},{id:`clojure`,name:`Clojure`,aliases:[`clj`],import:(()=>N(()=>import(`./clojure-DqKBuwfJ.js`),[]))},{id:`cmake`,name:`CMake`,import:(()=>N(()=>import(`./cmake-Bj61d0ZC.js`),[]))},{id:`cobol`,name:`COBOL`,import:(()=>N(()=>import(`./cobol-Cw2-KvLW.js`),__vite__mapDeps([27,6,1,7,8,13])))},{id:`codeowners`,name:`CODEOWNERS`,import:(()=>N(()=>import(`./codeowners-C8r90Shi.js`),[]))},{id:`codeql`,name:`CodeQL`,aliases:[`ql`],import:(()=>N(()=>import(`./codeql-oeQT6MSM.js`),[]))},{id:`coffee`,name:`CoffeeScript`,aliases:[`coffeescript`],import:(()=>N(()=>import(`./coffee-CiiSLhB6.js`),__vite__mapDeps([28,7,1])))},{id:`common-lisp`,name:`Common Lisp`,aliases:[`lisp`],import:(()=>N(()=>import(`./common-lisp-Cv5bFMCO.js`),[]))},{id:`coq`,name:`Coq`,import:(()=>N(()=>import(`./coq-BrsZFFmf.js`),[]))},{id:`cpp`,name:`C++`,aliases:[`c++`],import:(()=>N(()=>import(`./cpp-DjoE5qBx.js`).then(e=>e.n),__vite__mapDeps([29,1,21,30,31,24])))},{id:`crystal`,name:`Crystal`,import:(()=>N(()=>import(`./crystal-wCJpIkgB.js`),__vite__mapDeps([32,7,1,8,6,21,24,33])))},{id:`csharp`,name:`C#`,aliases:[`c#`,`cs`],import:(()=>N(()=>import(`./csharp-Ct8U2NOr.js`),[]))},{id:`css`,name:`CSS`,import:(()=>N(()=>import(`./css-CNuuLpMC.js`).then(e=>e.n),__vite__mapDeps([8,1])))},{id:`csv`,name:`CSV`,import:(()=>N(()=>import(`./csv-Dx-8-gkx.js`),[]))},{id:`cue`,name:`CUE`,import:(()=>N(()=>import(`./cue-CE9AQfxI.js`),[]))},{id:`cypher`,name:`Cypher`,aliases:[`cql`],import:(()=>N(()=>import(`./cypher-ClKdZ_lG.js`),[]))},{id:`d`,name:`D`,import:(()=>N(()=>import(`./d-qD-0Kul2.js`),[]))},{id:`dart`,name:`Dart`,import:(()=>N(()=>import(`./dart-CnvKMtbv.js`),[]))},{id:`dax`,name:`DAX`,import:(()=>N(()=>import(`./dax-BkyTk9wS.js`),[]))},{id:`desktop`,name:`Desktop`,import:(()=>N(()=>import(`./desktop-Dlh5hvp9.js`),[]))},{id:`diff`,name:`Diff`,import:(()=>N(()=>import(`./diff-woXpYk--.js`),[]))},{id:`docker`,name:`Dockerfile`,aliases:[`dockerfile`],import:(()=>N(()=>import(`./docker-IyjqRm3v.js`),[]))},{id:`dotenv`,name:`dotEnv`,import:(()=>N(()=>import(`./dotenv-_5a1GRtc.js`),[]))},{id:`dream-maker`,name:`Dream Maker`,import:(()=>N(()=>import(`./dream-maker-DW3nJb8Q.js`),[]))},{id:`edge`,name:`Edge`,import:(()=>N(()=>import(`./edge-DCY0a-ow.js`),__vite__mapDeps([34,6,1,7,8,16,20])))},{id:`elixir`,name:`Elixir`,import:(()=>N(()=>import(`./elixir-DP304Xio.js`),__vite__mapDeps([35,6,1,7,8])))},{id:`elm`,name:`Elm`,import:(()=>N(()=>import(`./elm-o4NJxfws.js`),__vite__mapDeps([36,31,1,24])))},{id:`emacs-lisp`,name:`Emacs Lisp`,aliases:[`elisp`],import:(()=>N(()=>import(`./emacs-lisp-B4R74twV.js`),[]))},{id:`erb`,name:`ERB`,import:(()=>N(()=>import(`./erb-BcNYoZVd.js`),__vite__mapDeps([37,6,1,7,8,38,12,13,21,24,29,30,31,33,39,40,16,18,41,42,43])))},{id:`erlang`,name:`Erlang`,aliases:[`erl`],import:(()=>N(()=>import(`./erlang-Cphh6RMH.js`),__vite__mapDeps([44,45])))},{id:`fennel`,name:`Fennel`,import:(()=>N(()=>import(`./fennel-DQxkIbk2.js`),[]))},{id:`fish`,name:`Fish`,import:(()=>N(()=>import(`./fish-BJitypiv.js`),[]))},{id:`fluent`,name:`Fluent`,aliases:[`ftl`],import:(()=>N(()=>import(`./fluent-C03EYrpw.js`),[]))},{id:`fortran-fixed-form`,name:`Fortran (Fixed Form)`,aliases:[`f`,`for`,`f77`],import:(()=>N(()=>import(`./fortran-fixed-form-DEKoE2YW.js`),__vite__mapDeps([46,47])))},{id:`fortran-free-form`,name:`Fortran (Free Form)`,aliases:[`f90`,`f95`,`f03`,`f08`,`f18`],import:(()=>N(()=>import(`./fortran-free-form-CYNrtFtB.js`),[]))},{id:`fsharp`,name:`F#`,aliases:[`f#`,`fs`],import:(()=>N(()=>import(`./fsharp-D13ZGOAj.js`),__vite__mapDeps([48,45])))},{id:`gdresource`,name:`GDResource`,aliases:[`tscn`,`tres`],import:(()=>N(()=>import(`./gdresource-C0sCabJj.js`),__vite__mapDeps([49,50,51])))},{id:`gdscript`,name:`GDScript`,aliases:[`gd`],import:(()=>N(()=>import(`./gdscript-Cp2uCuqX.js`),[]))},{id:`gdshader`,name:`GDShader`,import:(()=>N(()=>import(`./gdshader-CBce3t8t.js`),[]))},{id:`genie`,name:`Genie`,import:(()=>N(()=>import(`./genie-CV2tkWYe.js`),[]))},{id:`gherkin`,name:`Gherkin`,import:(()=>N(()=>import(`./gherkin-DExj1W_8.js`),[]))},{id:`git-commit`,name:`Git Commit Message`,import:(()=>N(()=>import(`./git-commit-BSykSTBG.js`),__vite__mapDeps([52,53])))},{id:`git-rebase`,name:`Git Rebase Message`,import:(()=>N(()=>import(`./git-rebase-BDPpS8w6.js`),__vite__mapDeps([54,33,1])))},{id:`gleam`,name:`Gleam`,import:(()=>N(()=>import(`./gleam-CSRkHgEL.js`),[]))},{id:`glimmer-js`,name:`Glimmer JS`,aliases:[`gjs`],import:(()=>N(()=>import(`./glimmer-js-BONyzAsu.js`),__vite__mapDeps([55,7,1,8,6,16])))},{id:`glimmer-ts`,name:`Glimmer TS`,aliases:[`gts`],import:(()=>N(()=>import(`./glimmer-ts-f9c0GCOe.js`),__vite__mapDeps([56,7,1,8,6,16])))},{id:`glsl`,name:`GLSL`,import:(()=>N(()=>import(`./glsl-D5MA2a_X.js`).then(e=>e.n),__vite__mapDeps([31,1,24])))},{id:`gn`,name:`GN`,import:(()=>N(()=>import(`./gn-ilITqXS6.js`),[]))},{id:`gnuplot`,name:`Gnuplot`,import:(()=>N(()=>import(`./gnuplot-7GGW24-e.js`),[]))},{id:`go`,name:`Go`,import:(()=>N(()=>import(`./go-rLFTqkRN.js`),[]))},{id:`graphql`,name:`GraphQL`,aliases:[`gql`],import:(()=>N(()=>import(`./graphql-Ctjuxyvl.js`).then(e=>e.n),__vite__mapDeps([40,1,7,16,18,41])))},{id:`groovy`,name:`Groovy`,import:(()=>N(()=>import(`./groovy-CacY0gHj.js`),[]))},{id:`hack`,name:`Hack`,import:(()=>N(()=>import(`./hack-7ztQ7Up-.js`),__vite__mapDeps([57,6,1,7,8,21])))},{id:`haml`,name:`Ruby Haml`,import:(()=>N(()=>import(`./haml-CwEpbK1d.js`).then(e=>e.n),__vite__mapDeps([39,1,7,8])))},{id:`handlebars`,name:`Handlebars`,aliases:[`hbs`],import:(()=>N(()=>import(`./handlebars-ryMP1rBR.js`),__vite__mapDeps([58,7,1,8,6,43])))},{id:`haskell`,name:`Haskell`,aliases:[`hs`],import:(()=>N(()=>import(`./haskell-D8IpX4py.js`),[]))},{id:`haxe`,name:`Haxe`,import:(()=>N(()=>import(`./haxe-OTjmBuCE.js`),[]))},{id:`hcl`,name:`HashiCorp HCL`,import:(()=>N(()=>import(`./hcl-Dh228itO.js`),[]))},{id:`hjson`,name:`Hjson`,import:(()=>N(()=>import(`./hjson-CxZEssPk.js`),[]))},{id:`hlsl`,name:`HLSL`,import:(()=>N(()=>import(`./hlsl-Cvrh5tZx.js`),[]))},{id:`html`,name:`HTML`,import:(()=>N(()=>import(`./html-XwrE-1r6.js`).then(e=>e.n),__vite__mapDeps([6,1,7,8])))},{id:`html-derivative`,name:`HTML (Derivative)`,import:(()=>N(()=>import(`./html-derivative-i4STDFnl.js`),__vite__mapDeps([20,6,1,7,8])))},{id:`http`,name:`HTTP`,import:(()=>N(()=>import(`./http-kmH8AyfE.js`),__vite__mapDeps([59,12,1,13,14,33,40,7,16,18,41])))},{id:`hurl`,name:`Hurl`,import:(()=>N(()=>import(`./hurl-DCZHXKU4.js`),__vite__mapDeps([60,12,1,13,61,40,7,16,18,41])))},{id:`hxml`,name:`HXML`,import:(()=>N(()=>import(`./hxml-B0Qn7Nwc.js`),__vite__mapDeps([62,63])))},{id:`hy`,name:`Hy`,import:(()=>N(()=>import(`./hy-CZbG8q4J.js`),[]))},{id:`imba`,name:`Imba`,import:(()=>N(()=>import(`./imba-DsUTQ-LC.js`),[]))},{id:`ini`,name:`INI`,aliases:[`properties`],import:(()=>N(()=>import(`./ini-B5eOa1yu.js`),[]))},{id:`java`,name:`Java`,import:(()=>N(()=>import(`./java-DdHNQ9hk.js`).then(e=>e.n),__vite__mapDeps([13,1])))},{id:`javascript`,name:`JavaScript`,aliases:[`js`,`cjs`,`mjs`],import:(()=>N(()=>import(`./javascript-obGGvMPs.js`).then(e=>e.n),__vite__mapDeps([7,1])))},{id:`jinja`,name:`Jinja`,import:(()=>N(()=>import(`./jinja-B-tLrNsM.js`),__vite__mapDeps([64,6,1,7,8])))},{id:`jison`,name:`Jison`,import:(()=>N(()=>import(`./jison-CBjhYtSs.js`),__vite__mapDeps([65,7,1])))},{id:`json`,name:`JSON`,import:(()=>N(()=>import(`./json-DAgxKhMr.js`).then(e=>e.n),__vite__mapDeps([14,1])))},{id:`json5`,name:`JSON5`,import:(()=>N(()=>import(`./json5-BR5RXkoi.js`),[]))},{id:`jsonc`,name:`JSON with Comments`,import:(()=>N(()=>import(`./jsonc-CYpm1nAK.js`),[]))},{id:`jsonl`,name:`JSON Lines`,import:(()=>N(()=>import(`./jsonl-CmCQp5Yx.js`),[]))},{id:`jsonnet`,name:`Jsonnet`,import:(()=>N(()=>import(`./jsonnet-CJTPZ8u_.js`),[]))},{id:`jssm`,name:`JSSM`,aliases:[`fsl`],import:(()=>N(()=>import(`./jssm-DXw9l8Rf.js`),[]))},{id:`jsx`,name:`JSX`,import:(()=>N(()=>import(`./jsx-gTgmArGx.js`).then(e=>e.n),__vite__mapDeps([41,1])))},{id:`julia`,name:`Julia`,aliases:[`jl`],import:(()=>N(()=>import(`./julia-CjHxn3vf.js`),__vite__mapDeps([66,7,1,21,26,29,30,31,24,67])))},{id:`just`,name:`Just`,import:(()=>N(()=>import(`./just-CZ9bduw9.js`),__vite__mapDeps([68,7,1,16,26,33,38,8,6,12,13,21,24,29,30,31,39,40,18,41,42,43,69])))},{id:`kdl`,name:`KDL`,import:(()=>N(()=>import(`./kdl-CsD5j6eV.js`),[]))},{id:`kotlin`,name:`Kotlin`,aliases:[`kt`,`kts`],import:(()=>N(()=>import(`./kotlin-DhhofPvG.js`),[]))},{id:`kusto`,name:`Kusto`,aliases:[`kql`],import:(()=>N(()=>import(`./kusto-C7mF5XQf.js`),[]))},{id:`latex`,name:`LaTeX`,import:(()=>N(()=>import(`./latex-D9bvcAJr.js`),__vite__mapDeps([70,71,67,1])))},{id:`lean`,name:`Lean 4`,aliases:[`lean4`],import:(()=>N(()=>import(`./lean-CewbzKMR.js`),[]))},{id:`less`,name:`Less`,import:(()=>N(()=>import(`./less-DVTAwKKz.js`),[]))},{id:`liquid`,name:`Liquid`,import:(()=>N(()=>import(`./liquid-G0MH4h_m.js`),__vite__mapDeps([72,7,1,8,6,14])))},{id:`llvm`,name:`LLVM IR`,import:(()=>N(()=>import(`./llvm-Cm23YOpf.js`),[]))},{id:`log`,name:`Log file`,import:(()=>N(()=>import(`./log-BNLmms1o.js`),[]))},{id:`logo`,name:`Logo`,import:(()=>N(()=>import(`./logo-Cluzi2Zq.js`),[]))},{id:`lua`,name:`Lua`,import:(()=>N(()=>import(`./lua-FONpmTUP.js`).then(e=>e.n),__vite__mapDeps([42,1,24])))},{id:`luau`,name:`Luau`,import:(()=>N(()=>import(`./luau-CNKltnaQ.js`),[]))},{id:`make`,name:`Makefile`,aliases:[`makefile`],import:(()=>N(()=>import(`./make-Dixweg8N.js`),[]))},{id:`markdown`,name:`Markdown`,aliases:[`md`],import:(()=>N(()=>import(`./markdown-BYOwaDjH.js`),[]))},{id:`marko`,name:`Marko`,import:(()=>N(()=>import(`./marko-DV5GrDmo.js`),__vite__mapDeps([73,8,1,10,16,74])))},{id:`matlab`,name:`MATLAB`,import:(()=>N(()=>import(`./matlab-D7qyCx1q.js`),[]))},{id:`mdc`,name:`MDC`,import:(()=>N(()=>import(`./mdc-cg1lnqpW.js`),__vite__mapDeps([75,20,6,1,7,8,43,45])))},{id:`mdx`,name:`MDX`,import:(()=>N(()=>import(`./mdx-DQZ5AkYe.js`),[]))},{id:`mermaid`,name:`Mermaid`,aliases:[`mmd`],import:(()=>N(()=>import(`./mermaid-Bk4SNUv9.js`),[]))},{id:`mipsasm`,name:`MIPS Assembly`,aliases:[`mips`],import:(()=>N(()=>import(`./mipsasm-BMqwQI7S.js`),[]))},{id:`mojo`,name:`Mojo`,import:(()=>N(()=>import(`./mojo-BgCJLMeH.js`),[]))},{id:`moonbit`,name:`MoonBit`,aliases:[`mbt`,`mbti`],import:(()=>N(()=>import(`./moonbit-CaWjb8XO.js`),[]))},{id:`move`,name:`Move`,import:(()=>N(()=>import(`./move-B1IS1UjX.js`),[]))},{id:`narrat`,name:`Narrat Language`,aliases:[`nar`],import:(()=>N(()=>import(`./narrat-_X_XdTYD.js`),[]))},{id:`nextflow`,name:`Nextflow`,aliases:[`nf`],import:(()=>N(()=>import(`./nextflow-BJtWHP5T.js`),__vite__mapDeps([76,77])))},{id:`nextflow-groovy`,name:`Nextflow Groovy`,import:(()=>N(()=>import(`./nextflow-groovy-DJMQeKeT.js`),[]))},{id:`nginx`,name:`Nginx`,import:(()=>N(()=>import(`./nginx-BTMw9COX.js`),__vite__mapDeps([78,42,1,24])))},{id:`nim`,name:`Nim`,import:(()=>N(()=>import(`./nim-B6yJ_yaC.js`),__vite__mapDeps([79,7,1,8,6,12,13,24,31,45])))},{id:`nix`,name:`Nix`,import:(()=>N(()=>import(`./nix-IvuFDN5E.js`),[]))},{id:`nushell`,name:`nushell`,aliases:[`nu`],import:(()=>N(()=>import(`./nushell-DcLAeLz5.js`),[]))},{id:`objective-c`,name:`Objective-C`,aliases:[`objc`],import:(()=>N(()=>import(`./objective-c-D1A_Heim.js`),[]))},{id:`objective-cpp`,name:`Objective-C++`,import:(()=>N(()=>import(`./objective-cpp-BsSzOQcm.js`),[]))},{id:`ocaml`,name:`OCaml`,import:(()=>N(()=>import(`./ocaml-O90oeIOV.js`),[]))},{id:`odin`,name:`Odin`,import:(()=>N(()=>import(`./odin-B1RWQWA5.js`),[]))},{id:`openscad`,name:`OpenSCAD`,aliases:[`scad`],import:(()=>N(()=>import(`./openscad-BUDT5pXO.js`),[]))},{id:`pascal`,name:`Pascal`,import:(()=>N(()=>import(`./pascal-4ZHwLPI5.js`),[]))},{id:`perl`,name:`Perl`,import:(()=>N(()=>import(`./perl-BAov3eih.js`),__vite__mapDeps([69,7,1,8,6,12,13,21])))},{id:`php`,name:`PHP`,import:(()=>N(()=>import(`./php-Cg76ANFt.js`),__vite__mapDeps([80,7,1,8,6,12,13,14,21])))},{id:`pkl`,name:`Pkl`,import:(()=>N(()=>import(`./pkl-ot-7Btpt.js`),[]))},{id:`plsql`,name:`PL/SQL`,import:(()=>N(()=>import(`./plsql-DGHpHOYJ.js`),[]))},{id:`po`,name:`Gettext PO`,aliases:[`pot`,`potx`],import:(()=>N(()=>import(`./po-BiJDBrnU.js`),[]))},{id:`polar`,name:`Polar`,import:(()=>N(()=>import(`./polar-C7UOKdEL.js`),[]))},{id:`postcss`,name:`PostCSS`,import:(()=>N(()=>import(`./postcss-BXeXVLqQ.js`),[]))},{id:`powerquery`,name:`PowerQuery`,import:(()=>N(()=>import(`./powerquery-DNMTfnFr.js`),[]))},{id:`powershell`,name:`PowerShell`,aliases:[`ps`,`ps1`],import:(()=>N(()=>import(`./powershell-DshXNtvi.js`),[]))},{id:`prisma`,name:`Prisma`,import:(()=>N(()=>import(`./prisma-BsRQq5mF.js`),[]))},{id:`prolog`,name:`Prolog`,import:(()=>N(()=>import(`./prolog-iXnhIJG7.js`),[]))},{id:`proto`,name:`Protocol Buffer 3`,aliases:[`protobuf`],import:(()=>N(()=>import(`./proto-DB4EqR-F.js`),[]))},{id:`pug`,name:`Pug`,aliases:[`jade`],import:(()=>N(()=>import(`./pug-DkgDHZci.js`),__vite__mapDeps([81,7,1,8,6])))},{id:`puppet`,name:`Puppet`,import:(()=>N(()=>import(`./puppet-CDv2pdJW.js`),[]))},{id:`purescript`,name:`PureScript`,import:(()=>N(()=>import(`./purescript-9MfHhQsQ.js`),[]))},{id:`python`,name:`Python`,aliases:[`py`],import:(()=>N(()=>import(`./python-gzcpVVnB.js`),[]))},{id:`qml`,name:`QML`,import:(()=>N(()=>import(`./qml-_a-QhfPD.js`),__vite__mapDeps([82,7,1])))},{id:`qmldir`,name:`QML Directory`,import:(()=>N(()=>import(`./qmldir-DCQb3MpD.js`),[]))},{id:`qss`,name:`Qt Style Sheets`,import:(()=>N(()=>import(`./qss-Fe1Jh2GI.js`),[]))},{id:`r`,name:`R`,import:(()=>N(()=>import(`./r-D6UWEOL2.js`).then(e=>e.n),__vite__mapDeps([67,1])))},{id:`racket`,name:`Racket`,import:(()=>N(()=>import(`./racket-DcIDlBhZ.js`),[]))},{id:`raku`,name:`Raku`,aliases:[`perl6`],import:(()=>N(()=>import(`./raku-B3gFvitq.js`),[]))},{id:`razor`,name:`ASP.NET Razor`,import:(()=>N(()=>import(`./razor-D3EoCAik.js`),__vite__mapDeps([83,6,1,7,8,84])))},{id:`reg`,name:`Windows Registry Script`,import:(()=>N(()=>import(`./reg-CRGYupPL.js`),[]))},{id:`regexp`,name:`RegExp`,aliases:[`regex`],import:(()=>N(()=>import(`./regexp-DR20uMnK.js`).then(e=>e.n),__vite__mapDeps([30,1])))},{id:`rel`,name:`Rel`,import:(()=>N(()=>import(`./rel-BtDbiS_P.js`),[]))},{id:`riscv`,name:`RISC-V`,import:(()=>N(()=>import(`./riscv-Ckw8ddFX.js`),[]))},{id:`ron`,name:`RON`,import:(()=>N(()=>import(`./ron-VUp2lXgN.js`),[]))},{id:`rosmsg`,name:`ROS Interface`,import:(()=>N(()=>import(`./rosmsg-CAekHB0j.js`),[]))},{id:`rst`,name:`reStructuredText`,import:(()=>N(()=>import(`./rst-YTmaoyaq.js`),__vite__mapDeps([85,7,1,20,6,8,26,86,29,21,30,31,24,33,43,38,12,13,39,40,16,18,41,42])))},{id:`ruby`,name:`Ruby`,aliases:[`rb`],import:(()=>N(()=>import(`./ruby-2bd251b9.js`),__vite__mapDeps([38,7,1,8,6,12,13,21,24,29,30,31,33,39,40,16,18,41,42,43])))},{id:`rust`,name:`Rust`,aliases:[`rs`],import:(()=>N(()=>import(`./rust-Cfkwpbl8.js`),[]))},{id:`sas`,name:`SAS`,import:(()=>N(()=>import(`./sas-B6p8-ynO.js`),__vite__mapDeps([87,21,1])))},{id:`sass`,name:`Sass`,import:(()=>N(()=>import(`./sass-DXrisJhu.js`),[]))},{id:`scala`,name:`Scala`,import:(()=>N(()=>import(`./scala-DKOlJaKm.js`),[]))},{id:`scheme`,name:`Scheme`,import:(()=>N(()=>import(`./scheme-DQCgrYNe.js`),[]))},{id:`scss`,name:`SCSS`,import:(()=>N(()=>import(`./scss-YesllqfO.js`).then(e=>e.n),__vite__mapDeps([10,1,8])))},{id:`sdbl`,name:`1C (Query)`,aliases:[`1c-query`],import:(()=>N(()=>import(`./sdbl-bTVj8UrX.js`),[]))},{id:`shaderlab`,name:`ShaderLab`,aliases:[`shader`],import:(()=>N(()=>import(`./shaderlab-TOUzSsQk.js`),__vite__mapDeps([88,89])))},{id:`shellscript`,name:`Shell`,aliases:[`bash`,`sh`,`shell`,`zsh`],import:(()=>N(()=>import(`./shellscript-Da78Ox-3.js`).then(e=>e.n),__vite__mapDeps([33,1])))},{id:`shellsession`,name:`Shell Session`,aliases:[`console`],import:(()=>N(()=>import(`./shellsession-CVsQGYfZ.js`),__vite__mapDeps([90,33,1])))},{id:`smalltalk`,name:`Smalltalk`,import:(()=>N(()=>import(`./smalltalk-B16xEiuN.js`),[]))},{id:`solidity`,name:`Solidity`,import:(()=>N(()=>import(`./solidity-CKzVLygQ.js`),[]))},{id:`soy`,name:`Closure Templates`,aliases:[`closure-templates`],import:(()=>N(()=>import(`./soy-DEd-qcad.js`),__vite__mapDeps([91,6,1,7,8])))},{id:`sparql`,name:`SPARQL`,import:(()=>N(()=>import(`./sparql-D_iOobhT.js`),__vite__mapDeps([92,93])))},{id:`splunk`,name:`Splunk Query Language`,aliases:[`spl`],import:(()=>N(()=>import(`./splunk-BC2Px7Mm.js`),[]))},{id:`sql`,name:`SQL`,import:(()=>N(()=>import(`./sql-ClgswhA6.js`).then(e=>e.n),__vite__mapDeps([21,1])))},{id:`ssh-config`,name:`SSH Config`,import:(()=>N(()=>import(`./ssh-config-BgfXC-Er.js`),[]))},{id:`stata`,name:`Stata`,import:(()=>N(()=>import(`./stata-RoaAgbqU.js`),__vite__mapDeps([94,21,1])))},{id:`stylus`,name:`Stylus`,aliases:[`styl`],import:(()=>N(()=>import(`./stylus-B6D30XZt.js`),[]))},{id:`surrealql`,name:`SurrealQL`,aliases:[`surql`],import:(()=>N(()=>import(`./surrealql-DIn4NJsS.js`),__vite__mapDeps([95,7,1])))},{id:`svelte`,name:`Svelte`,import:(()=>N(()=>import(`./svelte-Bj3Hmc9F.js`),__vite__mapDeps([96,7,1,8,16,17])))},{id:`swift`,name:`Swift`,import:(()=>N(()=>import(`./swift-DonLKvLd.js`),[]))},{id:`system-verilog`,name:`SystemVerilog`,import:(()=>N(()=>import(`./system-verilog-DJ5XKQeo.js`),[]))},{id:`systemd`,name:`Systemd Units`,import:(()=>N(()=>import(`./systemd-BxMlprV5.js`),[]))},{id:`talonscript`,name:`TalonScript`,aliases:[`talon`],import:(()=>N(()=>import(`./talonscript-CohzipZa.js`),[]))},{id:`tasl`,name:`Tasl`,import:(()=>N(()=>import(`./tasl-DMoTqEGO.js`),[]))},{id:`tcl`,name:`Tcl`,import:(()=>N(()=>import(`./tcl-CZd0xW_V.js`),[]))},{id:`templ`,name:`Templ`,import:(()=>N(()=>import(`./templ-TjxbArHn.js`),__vite__mapDeps([97,7,1,8,98])))},{id:`terraform`,name:`Terraform`,aliases:[`tf`,`tfvars`],import:(()=>N(()=>import(`./terraform-DswuEJGm.js`),[]))},{id:`tex`,name:`TeX`,import:(()=>N(()=>import(`./tex-0w6-Dtgt.js`),__vite__mapDeps([71,67,1])))},{id:`toml`,name:`TOML`,import:(()=>N(()=>import(`./toml-CcmNWLt0.js`),[]))},{id:`ts-tags`,name:`TypeScript with Tags`,aliases:[`lit`],import:(()=>N(()=>import(`./ts-tags-DFwAVxhO.js`),__vite__mapDeps([99,7,1,8,6,12,13,16,21,31,24])))},{id:`tsv`,name:`TSV`,import:(()=>N(()=>import(`./tsv-sltzmVWM.js`),[]))},{id:`tsx`,name:`TSX`,import:(()=>N(()=>import(`./tsx-CUOciP0b.js`).then(e=>e.n),__vite__mapDeps([18,1])))},{id:`turtle`,name:`Turtle`,import:(()=>N(()=>import(`./turtle-ByJddavk.js`),[]))},{id:`twig`,name:`Twig`,import:(()=>N(()=>import(`./twig-BbcH-NR0.js`),__vite__mapDeps([100,7,1,8,10,26,38,6,12,13,21,24,29,30,31,33,39,40,16,18,41,42,43,80,14])))},{id:`typescript`,name:`TypeScript`,aliases:[`ts`,`cts`,`mts`],import:(()=>N(()=>import(`./typescript-BydbNFcO.js`).then(e=>e.n),__vite__mapDeps([16,1])))},{id:`typespec`,name:`TypeSpec`,aliases:[`tsp`],import:(()=>N(()=>import(`./typespec-BRdr0IET.js`),[]))},{id:`typst`,name:`Typst`,aliases:[`typ`],import:(()=>N(()=>import(`./typst-DI99ib-x.js`),[]))},{id:`v`,name:`V`,import:(()=>N(()=>import(`./v-DETTlOr0.js`),[]))},{id:`vala`,name:`Vala`,import:(()=>N(()=>import(`./vala-zf12oZj6.js`),[]))},{id:`vb`,name:`Visual Basic`,aliases:[`cmd`],import:(()=>N(()=>import(`./vb-Djn5o6TS.js`),[]))},{id:`verilog`,name:`Verilog`,import:(()=>N(()=>import(`./verilog-CiiDBU1e.js`),[]))},{id:`vhdl`,name:`VHDL`,import:(()=>N(()=>import(`./vhdl-BroJfC0k.js`),[]))},{id:`viml`,name:`Vim Script`,aliases:[`vim`,`vimscript`],import:(()=>N(()=>import(`./viml-DvXPmvsu.js`),[]))},{id:`vue`,name:`Vue`,import:(()=>N(()=>import(`./vue-BNi0qJZP.js`),__vite__mapDeps([101,7,1,8,6,14,16,20])))},{id:`vue-html`,name:`Vue HTML`,import:(()=>N(()=>import(`./vue-html-DkKkQnZL.js`),__vite__mapDeps([102,7,1])))},{id:`vue-vine`,name:`Vue Vine`,import:(()=>N(()=>import(`./vue-vine-DFaKYU4X.js`),__vite__mapDeps([103,7,1,8,10,17,74,104])))},{id:`vyper`,name:`Vyper`,aliases:[`vy`],import:(()=>N(()=>import(`./vyper-CgoNMtux.js`),[]))},{id:`wasm`,name:`WebAssembly`,import:(()=>N(()=>import(`./wasm-ByWQv1Qj.js`),[]))},{id:`wenyan`,name:`Wenyan`,aliases:[`文言`],import:(()=>N(()=>import(`./wenyan-C8pVoKbM.js`),[]))},{id:`wgsl`,name:`WGSL`,import:(()=>N(()=>import(`./wgsl-BsKzXJz4.js`),[]))},{id:`wikitext`,name:`Wikitext`,aliases:[`mediawiki`,`wiki`],import:(()=>N(()=>import(`./wikitext-ClFFjSW2.js`),[]))},{id:`wit`,name:`WebAssembly Interface Types`,import:(()=>N(()=>import(`./wit-DdvCle-K.js`),[]))},{id:`wolfram`,name:`Wolfram`,aliases:[`wl`],import:(()=>N(()=>import(`./wolfram-DLL8P-h_.js`),[]))},{id:`xml`,name:`XML`,import:(()=>N(()=>import(`./xml-BlnrEAEy.js`).then(e=>e.n),__vite__mapDeps([12,1,13])))},{id:`xsl`,name:`XSL`,import:(()=>N(()=>import(`./xsl-BOPS8gLt.js`),__vite__mapDeps([105,12,1,13])))},{id:`yaml`,name:`YAML`,aliases:[`yml`],import:(()=>N(()=>import(`./yaml-Du_6cdrH.js`).then(e=>e.n),__vite__mapDeps([43,1])))},{id:`zenscript`,name:`ZenScript`,import:(()=>N(()=>import(`./zenscript-BnlCZFoB.js`),[]))},{id:`zig`,name:`Zig`,import:(()=>N(()=>import(`./zig-CMLA9XwU.js`),[]))}],p8e=Object.fromEntries(E3.map(e=>[e.id,e.import])),m8e=Object.fromEntries(E3.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),D3={...p8e,...m8e},h8e=Object.fromEntries([{id:`andromeeda`,displayName:`Andromeeda`,type:`dark`,import:(()=>N(()=>import(`./andromeeda-WkhI09AS.js`),[]))},{id:`aurora-x`,displayName:`Aurora X`,type:`dark`,import:(()=>N(()=>import(`./aurora-x-C7CFqhAd.js`),[]))},{id:`ayu-dark`,displayName:`Ayu Dark`,type:`dark`,import:(()=>N(()=>import(`./ayu-dark-CRu61w6_.js`),[]))},{id:`ayu-light`,displayName:`Ayu Light`,type:`light`,import:(()=>N(()=>import(`./ayu-light-Dn6O_aYR.js`),[]))},{id:`ayu-mirage`,displayName:`Ayu Mirage`,type:`dark`,import:(()=>N(()=>import(`./ayu-mirage-CTjYAbs-.js`),[]))},{id:`catppuccin-frappe`,displayName:`Catppuccin Frappé`,type:`dark`,import:(()=>N(()=>import(`./catppuccin-frappe-DFlFW5gh.js`),[]))},{id:`catppuccin-latte`,displayName:`Catppuccin Latte`,type:`light`,import:(()=>N(()=>import(`./catppuccin-latte-CpxdcXpJ.js`),[]))},{id:`catppuccin-macchiato`,displayName:`Catppuccin Macchiato`,type:`dark`,import:(()=>N(()=>import(`./catppuccin-macchiato-DIdIQ04K.js`),[]))},{id:`catppuccin-mocha`,displayName:`Catppuccin Mocha`,type:`dark`,import:(()=>N(()=>import(`./catppuccin-mocha-Co3Xjl64.js`),[]))},{id:`dark-plus`,displayName:`Dark Plus`,type:`dark`,import:(()=>N(()=>import(`./dark-plus-GAt2ZgX8.js`),[]))},{id:`dracula`,displayName:`Dracula Theme`,type:`dark`,import:(()=>N(()=>import(`./dracula-C2uKkzgK.js`),[]))},{id:`dracula-soft`,displayName:`Dracula Theme Soft`,type:`dark`,import:(()=>N(()=>import(`./dracula-soft-D1bVjxWZ.js`),[]))},{id:`everforest-dark`,displayName:`Everforest Dark`,type:`dark`,import:(()=>N(()=>import(`./everforest-dark-D-DlICQR.js`),[]))},{id:`everforest-light`,displayName:`Everforest Light`,type:`light`,import:(()=>N(()=>import(`./everforest-light-CeVdGHYG.js`),[]))},{id:`github-dark`,displayName:`GitHub Dark`,type:`dark`,import:(()=>N(()=>import(`./github-dark-DwbbXv51.js`),[]))},{id:`github-dark-default`,displayName:`GitHub Dark Default`,type:`dark`,import:(()=>N(()=>import(`./github-dark-default-CxjRwzl6.js`),[]))},{id:`github-dark-dimmed`,displayName:`GitHub Dark Dimmed`,type:`dark`,import:(()=>N(()=>import(`./github-dark-dimmed-Cr1oaoul.js`),[]))},{id:`github-dark-high-contrast`,displayName:`GitHub Dark High Contrast`,type:`dark`,import:(()=>N(()=>import(`./github-dark-high-contrast-B4qJZLZa.js`),[]))},{id:`github-light`,displayName:`GitHub Light`,type:`light`,import:(()=>N(()=>import(`./github-light-CsVXhIlR.js`),[]))},{id:`github-light-default`,displayName:`GitHub Light Default`,type:`light`,import:(()=>N(()=>import(`./github-light-default-DB_IwZa6.js`),[]))},{id:`github-light-high-contrast`,displayName:`GitHub Light High Contrast`,type:`light`,import:(()=>N(()=>import(`./github-light-high-contrast-DLgVeSB-.js`),[]))},{id:`gruvbox-dark-hard`,displayName:`Gruvbox Dark Hard`,type:`dark`,import:(()=>N(()=>import(`./gruvbox-dark-hard-DXm60lX3.js`),[]))},{id:`gruvbox-dark-medium`,displayName:`Gruvbox Dark Medium`,type:`dark`,import:(()=>N(()=>import(`./gruvbox-dark-medium-GE2thSmD.js`),[]))},{id:`gruvbox-dark-soft`,displayName:`Gruvbox Dark Soft`,type:`dark`,import:(()=>N(()=>import(`./gruvbox-dark-soft-04Cj-4VZ.js`),[]))},{id:`gruvbox-light-hard`,displayName:`Gruvbox Light Hard`,type:`light`,import:(()=>N(()=>import(`./gruvbox-light-hard-K6wSn29D.js`),[]))},{id:`gruvbox-light-medium`,displayName:`Gruvbox Light Medium`,type:`light`,import:(()=>N(()=>import(`./gruvbox-light-medium-CVy3aSlc.js`),[]))},{id:`gruvbox-light-soft`,displayName:`Gruvbox Light Soft`,type:`light`,import:(()=>N(()=>import(`./gruvbox-light-soft-DNgJjaY0.js`),[]))},{id:`horizon`,displayName:`Horizon`,type:`dark`,import:(()=>N(()=>import(`./horizon-0-RkHfro.js`),[]))},{id:`horizon-bright`,displayName:`Horizon Bright`,type:`light`,import:(()=>N(()=>import(`./horizon-bright-BgL2X9oq.js`),[]))},{id:`houston`,displayName:`Houston`,type:`dark`,import:(()=>N(()=>import(`./houston-KyjWKfuY.js`),[]))},{id:`kanagawa-dragon`,displayName:`Kanagawa Dragon`,type:`dark`,import:(()=>N(()=>import(`./kanagawa-dragon-7TqgsUPC.js`),[]))},{id:`kanagawa-lotus`,displayName:`Kanagawa Lotus`,type:`light`,import:(()=>N(()=>import(`./kanagawa-lotus-CqxMQulh.js`),[]))},{id:`kanagawa-wave`,displayName:`Kanagawa Wave`,type:`dark`,import:(()=>N(()=>import(`./kanagawa-wave-D8CNn6T_.js`),[]))},{id:`laserwave`,displayName:`LaserWave`,type:`dark`,import:(()=>N(()=>import(`./laserwave-CQkdhozh.js`),[]))},{id:`light-plus`,displayName:`Light Plus`,type:`light`,import:(()=>N(()=>import(`./light-plus-CNQ8_7Y0.js`),[]))},{id:`material-theme`,displayName:`Material Theme`,type:`dark`,import:(()=>N(()=>import(`./material-theme-CAtLaHa3.js`),[]))},{id:`material-theme-darker`,displayName:`Material Theme Darker`,type:`dark`,import:(()=>N(()=>import(`./material-theme-darker-k-s5Bc6K.js`),[]))},{id:`material-theme-lighter`,displayName:`Material Theme Lighter`,type:`light`,import:(()=>N(()=>import(`./material-theme-lighter-CD6a-c4d.js`),[]))},{id:`material-theme-ocean`,displayName:`Material Theme Ocean`,type:`dark`,import:(()=>N(()=>import(`./material-theme-ocean-B3mraInd.js`),[]))},{id:`material-theme-palenight`,displayName:`Material Theme Palenight`,type:`dark`,import:(()=>N(()=>import(`./material-theme-palenight-DEhAARHw.js`),[]))},{id:`min-dark`,displayName:`Min Dark`,type:`dark`,import:(()=>N(()=>import(`./min-dark-BFqTAwCr.js`),[]))},{id:`min-light`,displayName:`Min Light`,type:`light`,import:(()=>N(()=>import(`./min-light-O7UdaaxX.js`),[]))},{id:`monokai`,displayName:`Monokai`,type:`dark`,import:(()=>N(()=>import(`./monokai-C0p7Qecz.js`),[]))},{id:`night-owl`,displayName:`Night Owl`,type:`dark`,import:(()=>N(()=>import(`./night-owl-BsnCLAKc.js`),[]))},{id:`night-owl-light`,displayName:`Night Owl Light`,type:`light`,import:(()=>N(()=>import(`./night-owl-light-BODRhcTU.js`),[]))},{id:`nord`,displayName:`Nord`,type:`dark`,import:(()=>N(()=>import(`./nord-Cd-F4txO.js`),[]))},{id:`one-dark-pro`,displayName:`One Dark Pro`,type:`dark`,import:(()=>N(()=>import(`./one-dark-pro-DUS_IGRK.js`),[]))},{id:`one-light`,displayName:`One Light`,type:`light`,import:(()=>N(()=>import(`./one-light-CVUd7yD5.js`),[]))},{id:`plastic`,displayName:`Plastic`,type:`dark`,import:(()=>N(()=>import(`./plastic-CF8VZTnn.js`),[]))},{id:`poimandres`,displayName:`Poimandres`,type:`dark`,import:(()=>N(()=>import(`./poimandres-BX2TyY6j.js`),[]))},{id:`red`,displayName:`Red`,type:`dark`,import:(()=>N(()=>import(`./red-7ga_dcKu.js`),[]))},{id:`rose-pine`,displayName:`Rosé Pine`,type:`dark`,import:(()=>N(()=>import(`./rose-pine-rh6ipraJ.js`),[]))},{id:`rose-pine-dawn`,displayName:`Rosé Pine Dawn`,type:`light`,import:(()=>N(()=>import(`./rose-pine-dawn-DSuRaP6u.js`),[]))},{id:`rose-pine-moon`,displayName:`Rosé Pine Moon`,type:`dark`,import:(()=>N(()=>import(`./rose-pine-moon-DdHjCvFQ.js`),[]))},{id:`slack-dark`,displayName:`Slack Dark`,type:`dark`,import:(()=>N(()=>import(`./slack-dark-DYvUXyrP.js`),[]))},{id:`slack-ochin`,displayName:`Slack Ochin`,type:`light`,import:(()=>N(()=>import(`./slack-ochin-bqtMVDfH.js`),[]))},{id:`snazzy-light`,displayName:`Snazzy Light`,type:`light`,import:(()=>N(()=>import(`./snazzy-light-D8dzFmq5.js`),[]))},{id:`solarized-dark`,displayName:`Solarized Dark`,type:`dark`,import:(()=>N(()=>import(`./solarized-dark-BQwPDzxK.js`),[]))},{id:`solarized-light`,displayName:`Solarized Light`,type:`light`,import:(()=>N(()=>import(`./solarized-light-BLaijb3X.js`),[]))},{id:`synthwave-84`,displayName:`Synthwave '84`,type:`dark`,import:(()=>N(()=>import(`./synthwave-84-CIknw8y7.js`),[]))},{id:`tokyo-night`,displayName:`Tokyo Night`,type:`dark`,import:(()=>N(()=>import(`./tokyo-night-iIspnLcq.js`),[]))},{id:`vesper`,displayName:`Vesper`,type:`dark`,import:(()=>N(()=>import(`./vesper-D5bVUKB1.js`),[]))},{id:`vitesse-black`,displayName:`Vitesse Black`,type:`dark`,import:(()=>N(()=>import(`./vitesse-black-D082JcaE.js`),[]))},{id:`vitesse-dark`,displayName:`Vitesse Dark`,type:`dark`,import:(()=>N(()=>import(`./vitesse-dark-z-nr_5O8.js`),[]))},{id:`vitesse-light`,displayName:`Vitesse Light`,type:`light`,import:(()=>N(()=>import(`./vitesse-light-ojz42ZLy.js`),[]))}].map(e=>[e.id,e.import])),g8e=e({createOnigurumaEngine:()=>R3,getDefaultWasmLoader:()=>N8e,loadWasm:()=>F3,setDefaultWasmLoader:()=>M8e}),O3=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function _8e(){return 2147483648}function v8e(){return typeof performance<`u`?performance.now():Date.now()}var y8e=(e,t)=>e+(t-e%t)%t;async function b8e(e){let t,n,r={};function i(e){n=e,r.HEAPU8=new Uint8Array(e),r.HEAPU32=new Uint32Array(e)}function a(e,t,n){r.HEAPU8.copyWithin(e,t,t+n)}function o(e){try{return t.grow(e-n.byteLength+65535>>>16),i(t.buffer),1}catch{}}function s(e){let t=r.HEAPU8.length;e>>>=0;let n=_8e();if(e>n)return!1;for(let r=1;r<=4;r*=2){let i=t*(1+.2/r);if(i=Math.min(i,e+100663296),o(Math.min(n,y8e(Math.max(e,i),65536))))return!0}return!1}let c=typeof TextDecoder<`u`?new TextDecoder(`utf8`):void 0;function l(e,t,n=1024){let r=t+n,i=t;for(;e[i]&&!(i>=r);)++i;if(i-t>16&&e.buffer&&c)return c.decode(e.subarray(t,i));let a=``;for(;t<i;){let n=e[t++];if(!(n&128)){a+=String.fromCharCode(n);continue}let r=e[t++]&63;if((n&224)==192){a+=String.fromCharCode((n&31)<<6|r);continue}let i=e[t++]&63;if(n=(n&240)==224?(n&15)<<12|r<<6|i:(n&7)<<18|r<<12|i<<6|e[t++]&63,n<65536)a+=String.fromCharCode(n);else{let e=n-65536;a+=String.fromCharCode(55296|e>>10,56320|e&1023)}}return a}function u(e,t){return e?l(r.HEAPU8,e,t):``}let d={emscripten_get_now:v8e,emscripten_memcpy_big:a,emscripten_resize_heap:s,fd_write:()=>0};async function f(){let n=await e({env:d,wasi_snapshot_preview1:d});t=n.memory,i(t.buffer),Object.assign(r,n),r.UTF8ToString=u}return await f(),r}var x8e=Object.defineProperty,S8e=(e,t,n)=>t in e?x8e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,k3=(e,t,n)=>S8e(e,typeof t==`symbol`?t:t+``,n),A3=null;function C8e(e){throw new O3(e.UTF8ToString(e.getLastOnigError()))}var j3=class e{constructor(t){k3(this,`utf16Length`),k3(this,`utf8Length`),k3(this,`utf16Value`),k3(this,`utf8Value`),k3(this,`utf16OffsetToUtf8`),k3(this,`utf8OffsetToUtf16`);let n=t.length,r=e._utf8ByteLength(t),i=r!==n,a=i?new Uint32Array(n+1):null;i&&(a[n]=r);let o=i?new Uint32Array(r+1):null;i&&(o[r]=n);let s=new Uint8Array(r),c=0;for(let e=0;e<n;e++){let r=t.charCodeAt(e),l=r,u=!1;if(r>=55296&&r<=56319&&e+1<n){let n=t.charCodeAt(e+1);n>=56320&&n<=57343&&(l=(r-55296<<10)+65536|n-56320,u=!0)}i&&(a[e]=c,u&&(a[e+1]=c),l<=127?o[c+0]=e:l<=2047?(o[c+0]=e,o[c+1]=e):l<=65535?(o[c+0]=e,o[c+1]=e,o[c+2]=e):(o[c+0]=e,o[c+1]=e,o[c+2]=e,o[c+3]=e)),l<=127?s[c++]=l:l<=2047?(s[c++]=192|(l&1984)>>>6,s[c++]=128|(l&63)>>>0):l<=65535?(s[c++]=224|(l&61440)>>>12,s[c++]=128|(l&4032)>>>6,s[c++]=128|(l&63)>>>0):(s[c++]=240|(l&1835008)>>>18,s[c++]=128|(l&258048)>>>12,s[c++]=128|(l&4032)>>>6,s[c++]=128|(l&63)>>>0),u&&e++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=s,this.utf16OffsetToUtf8=a,this.utf8OffsetToUtf16=o}static _utf8ByteLength(e){let t=0;for(let n=0,r=e.length;n<r;n++){let i=e.charCodeAt(n),a=i,o=!1;if(i>=55296&&i<=56319&&n+1<r){let t=e.charCodeAt(n+1);t>=56320&&t<=57343&&(a=(i-55296<<10)+65536|t-56320,o=!0)}t+=a<=127?1:a<=2047?2:a<=65535?3:4,o&&n++}return t}createString(e){let t=e.omalloc(this.utf8Length);return e.HEAPU8.set(this.utf8Value,t),t}},M3=class e{constructor(t){if(k3(this,`id`,++e.LAST_ID),k3(this,`_onigBinding`),k3(this,`content`),k3(this,`utf16Length`),k3(this,`utf8Length`),k3(this,`utf16OffsetToUtf8`),k3(this,`utf8OffsetToUtf16`),k3(this,`ptr`),!A3)throw new O3(`Must invoke loadWasm first.`);this._onigBinding=A3,this.content=t;let n=new j3(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!e._sharedPtrInUse?(e._sharedPtr||=A3.omalloc(1e4),e._sharedPtrInUse=!0,A3.HEAPU8.set(n.utf8Value,e._sharedPtr),this.ptr=e._sharedPtr):this.ptr=n.createString(A3)}convertUtf8OffsetToUtf16(e){return this.utf8OffsetToUtf16?e<0?0:e>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[e]:e}convertUtf16OffsetToUtf8(e){return this.utf16OffsetToUtf8?e<0?0:e>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[e]:e}dispose(){this.ptr===e._sharedPtr?e._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};k3(M3,`LAST_ID`,0),k3(M3,`_sharedPtr`,0),k3(M3,`_sharedPtrInUse`,!1);var N3=M3,w8e=class{constructor(e){if(k3(this,`_onigBinding`),k3(this,`_ptr`),!A3)throw new O3(`Must invoke loadWasm first.`);let t=[],n=[];for(let r=0,i=e.length;r<i;r++){let i=new j3(e[r]);t[r]=i.createString(A3),n[r]=i.utf8Length}let r=A3.omalloc(4*e.length);A3.HEAPU32.set(t,r/4);let i=A3.omalloc(4*e.length);A3.HEAPU32.set(n,i/4);let a=A3.createOnigScanner(r,i,e.length);for(let n=0,r=e.length;n<r;n++)A3.ofree(t[n]);A3.ofree(i),A3.ofree(r),a===0&&C8e(A3),this._onigBinding=A3,this._ptr=a}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(e,t,n){let r=0;if(typeof n==`number`&&(r=n),typeof e==`string`){e=new N3(e);let n=this._findNextMatchSync(e,t,!1,r);return e.dispose(),n}return this._findNextMatchSync(e,t,!1,r)}_findNextMatchSync(e,t,n,r){let i=this._onigBinding,a=i.findNextOnigScannerMatch(this._ptr,e.id,e.ptr,e.utf8Length,e.convertUtf16OffsetToUtf8(t),r);if(a===0)return null;let o=i.HEAPU32,s=a/4,c=o[s++],l=o[s++],u=[];for(let t=0;t<l;t++){let n=e.convertUtf8OffsetToUtf16(o[s++]),r=e.convertUtf8OffsetToUtf16(o[s++]);u[t]={start:n,end:r,length:r-n}}return{index:c,captureIndices:u}}};function T8e(e){return typeof e.instantiator==`function`}function E8e(e){return typeof e.default==`function`}function D8e(e){return e.data!==void 0}function O8e(e){return typeof Response<`u`&&e instanceof Response}function k8e(e){return typeof ArrayBuffer<`u`&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<`u`&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||typeof Uint32Array<`u`&&e instanceof Uint32Array}var P3;function F3(e){if(P3)return P3;async function t(){A3=await b8e(async t=>{let n=e;return n=await n,typeof n==`function`&&(n=await n(t)),typeof n==`function`&&(n=await n(t)),T8e(n)?n=await n.instantiator(t):E8e(n)?n=await n.default(t):(D8e(n)&&(n=n.data),O8e(n)?n=typeof WebAssembly.instantiateStreaming==`function`?await A8e(n)(t):await j8e(n)(t):k8e(n)||n instanceof WebAssembly.Module?n=await I3(n)(t):`default`in n&&n.default instanceof WebAssembly.Module&&(n=await I3(n.default)(t))),`instance`in n&&(n=n.instance),`exports`in n&&(n=n.exports),n})}return P3=t(),P3}function I3(e){return t=>WebAssembly.instantiate(e,t)}function A8e(e){return t=>WebAssembly.instantiateStreaming(e,t)}function j8e(e){return async t=>{let n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}var L3;function M8e(e){L3=e}function N8e(){return L3}async function R3(e){return e&&await F3(e),{createScanner(e){return new w8e(e.map(e=>typeof e==`string`?e:e.source))},createString(e){return new N3(e)}}}var z3=d8e({});f8e(z3,g8e);var B3=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function P8e(e){return V3(e)}function V3(e){return Array.isArray(e)?F8e(e):e instanceof RegExp?e:typeof e==`object`?I8e(e):e}function F8e(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=V3(e[n]);return t}function I8e(e){let t={};for(let n in e)t[n]=V3(e[n]);return t}function H3(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function U3(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?U3(e.substring(0,e.length-1)):e.substr(~t+1)}var W3=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,G3=class{static hasCaptures(e){return e!==null&&(W3.lastIndex=0,W3.test(e))}static replaceCaptures(e,t,n){return e.replace(W3,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function K3(e,t){return e<t?-1:+(e>t)}function q3(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=K3(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function J3(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function Y3(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var X3=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},Z3=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(z8e(e),t)}static createFromParsedTheme(e,t){return V8e(e,t)}_cachedMatchRoot=new X3(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>L8e(e.parent,t.parentScopes));return n?new $3(n.fontStyle,n.foreground,n.background):null}},Q3=class e{constructor(e,t){this.parent=e,this.scopeName=t}static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e||this.parent!==null&&this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function L8e(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!R8e(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function R8e(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var $3=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function z8e(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8}}let s=null;typeof i.settings.foreground==`string`&&J3(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&J3(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new B8e(l,u,e,o,s,c)}}return n}var B8e=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}},e6=(e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(e6||{});function V8e(e,t){e.sort((e,t)=>{let n=K3(e.scope,t.scope);return n!==0||(n=q3(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new H8e(t),o=new $3(n,a.getId(r),a.getId(i)),s=new W8e(new t6(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new Z3(a,o,s)}var H8e=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},U8e=Object.freeze([]),t6=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||U8e,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},W8e=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),t6.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null){this._mainRule.acceptOverwrite(e,n,r,i);return}for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if(q3(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new t6(e,t,n,r,i))}},n6=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return!!(e&1024)}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=+!!e.containsBalancedBrackets(t),d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=K8e(r)),i!==null&&(u=+!!i),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c<<0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function G8e(e){return e}function K8e(e){return e}function r6(e,t){let n=[],r=q8e(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(i6(i)){let e=[];do e.push(i),i=r.next();while(i6(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function i6(e){return!!e&&!!e.match(/[\w\.:]+/)}function q8e(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function a6(e){typeof e.dispose==`function`&&e.dispose()}var o6=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},J8e=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Y8e=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},X8e=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new o6(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Y8e;for(let n of e)Z8e(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof o6){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function Z8e(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof o6?c6({baseGrammar:a,selfGrammar:i},r):s6(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new o6(e))}function s6(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];l6([r],t,n)}}function c6(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&l6(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&l6(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function l6(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?H3({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&l6(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=u6(i);switch(a.kind){case 0:c6({...t,selfGrammar:t.baseGrammar},n);break;case 1:c6(t,n);break;case 2:s6(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?s6(a.ruleName,i,n):c6(i,n)}else a.kind===4?n.add(new J8e(a.scopeName,a.ruleName)):n.add(new o6(a.scopeName))}}}var Q8e=class{kind=0},$8e=class{kind=1},e5e=class{constructor(e){this.ruleName=e}kind=2},t5e=class{constructor(e){this.scopeName=e}kind=3},n5e=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function u6(e){if(e===`$base`)return new Q8e;if(e===`$self`)return new $8e;let t=e.indexOf(`#`);return t===-1?new t5e(e):t===0?new e5e(e.substring(1)):new n5e(e.substring(0,t),e.substring(t+1))}var r5e=/\\(\d+)/,d6=/\\(\d+)/g,i5e=-1,f6=-2;function p6(e){return e}function m6(e){return e}var h6=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=G3.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=G3.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${U3(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:G3.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:G3.replaceCaptures(this._contentName,e,t)}},a5e=class extends h6{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},o5e=class extends h6{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new b6(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new x6,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},g6=class extends h6{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new x6,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},_6=class extends h6{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new b6(i,this.id),this.beginCaptures=a,this._end=new b6(o||``,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new x6;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},v6=class extends h6{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new b6(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new b6(o,f6),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new x6;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new x6,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||``),this._cachedCompiledWhilePatterns}},y6=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new a5e(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new o5e(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=H3({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new g6(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new v6(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new _6(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=u6(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l)if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository)}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof g6||e instanceof _6||e instanceof v6)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},b6=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this._anchorCache=this.hasAnchor?this._buildAnchorCache():null,this.ruleId=t,this.hasBackReferences=typeof this.source==`string`&&r5e.test(this.source)}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return d6.lastIndex=0,this.source.replace(d6,(e,t)=>Y3(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=``,t[i+1]=``,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=``,t[i+1]=`G`,n[i+1]=``,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},x6=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new S6(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new S6(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},S6=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
|
|
1040
|
+
`)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},C6=class{constructor(e,t){this.languageId=e,this.tokenType=t}},s5e=class e{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new C6(e,8),this._embeddedLanguagesMatcher=new c5e(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?e._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new C6(0,0);_getBasicScopeAttributes=new X3(e=>new C6(this._scopeToLanguage(e),this._toStandardTokenType(e)));_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(t){let n=t.match(e.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case`comment`:return 1;case`string`:return 2;case`regex`:return 3;case`meta.embedded`:return 0}throw Error(`Unexpected match for standard token type!`)}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},c5e=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([e,t])=>Y3(e));t.sort(),t.reverse(),this.scopesRegExp=RegExp(`^((${t.join(`)|(`)}))($|\\.)`,``)}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}};typeof process<`u`&&{}.VSCODE_TEXTMATE_DEBUG;var w6=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function T6(e,t,n,r,i,a,o,s){let c=t.content.length,l=!1,u=-1;if(o){let o=l5e(e,t,n,r,i,a);i=o.stack,r=o.linePos,n=o.isFirstLine,u=o.anchorPosition}let d=Date.now();for(;!l;){if(s!==0&&Date.now()-d>s)return new w6(i,!0);f()}return new w6(i,!1);function f(){let o=u5e(e,t,n,r,i,u);if(!o){a.produce(i,c),l=!0;return}let s=o.captureIndices,d=o.matchedRuleId,f=s&&s.length>0?s[0].end>r:!1;if(d===i5e){let o=i.getRule(e);a.produce(i,s[0].start),i=i.withContentNameScopesList(i.nameScopesList),D6(e,t,n,i,a,o.endCaptures,s),a.produce(i,s[0].end);let d=i;if(i=i.parent,u=d.getAnchorPos(),!f&&d.getEnterPos()===r){i=d,a.produce(i,c),l=!0;return}}else{let o=e.getRule(d);a.produce(i,s[0].start);let p=i,m=o.getName(t.content,s),h=i.contentNameScopesList.pushAttributed(m,e);if(i=i.push(d,r,u,s[0].end===c,null,h,h),o instanceof _6){let r=o;D6(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.endHasBackReferences&&(i=i.withEndRule(r.getEndWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(o instanceof v6){let r=o;D6(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.whileHasBackReferences&&(i=i.withEndRule(r.getWhileWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(D6(e,t,n,i,a,o.captures,s),a.produce(i,s[0].end),i=i.pop(),!f){i=i.safePop(),a.produce(i,c),l=!0;return}}s[0].end>r&&(r=s[0].end,n=!1)}}function l5e(e,t,n,r,i,a){let o=i.beginRuleCapturedEOL?0:-1,s=[];for(let t=i;t;t=t.pop()){let n=t.getRule(e);n instanceof v6&&s.push({rule:n,stack:t})}for(let c=s.pop();c;c=s.pop()){let{ruleScanner:s,findOptions:l}=p5e(c.rule,e,c.stack.endRule,n,r===o),u=s.findNextMatchSync(t,r,l);if(u){if(u.ruleId!==f6){i=c.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(a.produce(c.stack,u.captureIndices[0].start),D6(e,t,n,c.stack,a,c.rule.whileCaptures,u.captureIndices),a.produce(c.stack,u.captureIndices[0].end),o=u.captureIndices[0].end,u.captureIndices[0].end>r&&(r=u.captureIndices[0].end,n=!1))}else{i=c.stack.pop();break}}return{stack:i,linePos:r,anchorPosition:o,isFirstLine:n}}function u5e(e,t,n,r,i,a){let o=d5e(e,t,n,r,i,a),s=e.getInjections();if(s.length===0)return o;let c=f5e(s,e,t,n,r,i,a);if(!c)return o;if(!o)return c;let l=o.captureIndices[0].start,u=c.captureIndices[0].start;return u<l||c.priorityMatch&&u===l?c:o}function d5e(e,t,n,r,i,a){let{ruleScanner:o,findOptions:s}=E6(i.getRule(e),e,i.endRule,n,r===a),c=o.findNextMatchSync(t,r,s);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function f5e(e,t,n,r,i,a,o){let s=Number.MAX_VALUE,c=null,l,u=0,d=a.contentNameScopesList.getScopeNames();for(let a=0,f=e.length;a<f;a++){let f=e[a];if(!f.matcher(d))continue;let{ruleScanner:p,findOptions:m}=E6(t.getRule(f.ruleId),t,null,r,i===o),h=p.findNextMatchSync(n,i,m);if(!h)continue;let g=h.captureIndices[0].start;if(!(g>=s)&&(s=g,c=h.captureIndices,l=h.ruleId,u=f.priority,s===i))break}return c?{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l}:null}function E6(e,t,n,r,i){return{ruleScanner:e.compileAG(t,n,r,i),findOptions:0}}function p5e(e,t,n,r,i){return{ruleScanner:e.compileWhileAG(t,n,r,i),findOptions:0}}function D6(e,t,n,r,i,a,o){if(a.length===0)return;let s=t.content,c=Math.min(a.length,o.length),l=[],u=o[0].end;for(let t=0;t<c;t++){let c=a[t];if(c===null)continue;let d=o[t];if(d.length===0)continue;if(d.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=d.start;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?i.produceFromScopes(l[l.length-1].scopes,d.start):i.produce(r,d.start),c.retokenizeCapturedWithRuleId){let t=c.getName(s,o),a=r.contentNameScopesList.pushAttributed(t,e),l=c.getContentName(s,o),u=a.pushAttributed(l,e),f=r.push(c.retokenizeCapturedWithRuleId,d.start,-1,!1,null,a,u),p=e.createOnigString(s.substring(0,d.end));T6(e,p,n&&d.start===0,d.start,f,i,!1,0),a6(p);continue}let f=c.getName(s,o);if(f!==null){let t=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(f,e);l.push(new m5e(t,d.end))}}for(;l.length>0;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var m5e=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function h5e(e,t,n,r,i,a,o,s){return new _5e(e,t,n,r,i,a,o,s)}function O6(e,t,n,r,i){let a=r6(t,k6),o=y6.getCompiledRuleId(n,r,i.repository);for(let n of a)e.push({debugSelector:t,matcher:n.matcher,ruleId:o,grammar:i,priority:n.priority})}function k6(e,t){if(t.length<e.length)return!1;let n=0;return e.every(e=>{for(let r=n;r<t.length;r++)if(g5e(t[r],e))return n=r+1,!0;return!1})}function g5e(e,t){if(!e)return!1;if(e===t)return!0;let n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]===`.`}var _5e=class{constructor(e,t,n,r,i,a,o,s){if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=s,this._basicScopeAttributesProvider=new s5e(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=A6(t,null),this._injections=null,this._tokenTypeMatchers=[],i)for(let e of Object.keys(i)){let t=r6(e,k6);for(let n of t)this._tokenTypeMatchers.push({matcher:n.matcher,type:i[e]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:e=>e===this._rootScopeName?this._grammar:this.getExternalGrammar(e),injections:e=>this._grammarRepository.injections(e)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){let e=r.injections;if(e)for(let n in e)O6(t,n,e[n],this,r);let i=this._grammarRepository.injections(n);i&&i.forEach(e=>{let n=this.getExternalGrammar(e);if(n){let e=n.injectionSelector;e&&O6(t,e,n,this,n)}})}return t.sort((e,t)=>e.priority-t.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,n=e(p6(t));return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[m6(e)]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=A6(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){let r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){let r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=y6.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!t||t===M6.NULL){i=!0;let e=this._basicScopeAttributesProvider.getDefaultAttributes(),n=this.themeProvider.getDefaults(),r=n6.set(0,e.languageId,e.tokenType,null,n.fontStyle,n.foregroundId,n.backgroundId),a=this.getRule(this._rootId).getName(null,null),o;o=a?j6.createRootAndLookUpScopeName(a,r,this):j6.createRoot(`unknown`,r),t=new M6(null,this._rootId,-1,-1,!1,null,o,o)}else i=!1,t.reset();e+=`
|
|
1041
|
+
`;let a=this.createOnigString(e),o=a.content.length,s=new y5e(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=T6(this,a,i,0,t,s,!0,r);return a6(a),{lineLength:o,lineTokens:s,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function A6(e,t){return e=P8e(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var j6=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}static fromExtension(t,n){let r=t,i=t?.scopePath??null;for(let t of n)i=Q3.push(i,t.scopeNames),r=new e(r,i,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new Q3(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let i=r.getMetadataForScope(t),a=new Q3(null,t),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(n,i,o);return new e(null,a,s)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(` `)}equals(t){return e.equals(this,t)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(!0)}static mergeAttributes(e,t,n){let r=-1,i=0,a=0;return n!==null&&(r=n.fontStyle,i=n.foregroundId,a=n.backgroundId),n6.set(e,t.languageId,t.tokenType,null,r,i,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(` `)===-1)return e._pushAttributed(this,t,n);let r=t.split(/ /g),i=this;for(let t of r)i=e._pushAttributed(i,t,n);return i}static _pushAttributed(t,n,r){let i=r.getMetadataForScope(n),a=t.scopePath.push(n),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(t.tokenAttributes,i,o);return new e(t,a,s)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},M6=class e{constructor(e,t,n,r,i,a,o,s){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=o,this.contentNameScopesList=s,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t!==null&&e._equals(this,t)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?j6.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,a,o,s){return new e(this,t,n,r,i,a,o,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),`[`+e.join(`,`)+`]`}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:m6(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=j6.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,p6(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,j6.fromExtension(r,n.contentNameScopesList))}},v5e=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>e===`*`?(this.allowAny=!0,[]):r6(e,k6).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>r6(e,k6).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},y5e=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let t=e?.getScopeNames()??[];for(let e of this._tokenTypeOverrides)e.matcher(t)&&(n=n6.set(n,0,G8e(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}if(r&&(n=n6.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},b5e=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,h5e(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},x5e=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new b5e(Z3.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(Z3.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new v5e(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,i){let a=new X8e(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(e=>this._loadSingleGrammar(e.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,n,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections==`function`?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,i)}},N6=M6.NULL;function P6(e,t){let n=typeof e==`string`?{}:{...e.colorReplacements},r=typeof e==`string`?e:e.name;for(let[e,i]of Object.entries(t?.colorReplacements||{}))typeof i==`string`?n[e]=i:e===r&&Object.assign(n,i);return n}function F6(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function S5e(e){return Array.isArray(e)?e:[e]}async function I6(e){return Promise.resolve(typeof e==`function`?e():e).then(e=>e.default||e)}function L6(e){return!e||[`plaintext`,`txt`,`text`,`plain`].includes(e)}function R6(e){return e===`ansi`||L6(e)}function z6(e){return e===`none`}function B6(e){return z6(e)}function V6(e,t=!1){if(e.length===0)return[[``,0]];let n=e.split(/(\r?\n)/g),r=0,i=[];for(let e=0;e<n.length;e+=2){let a=t?n[e]+(n[e+1]||``):n[e];i.push([a,r]),r+=n[e].length,r+=n[e+1]?.length||0}return i}var H6={light:`#333333`,dark:`#bbbbbb`},U6={light:`#fffffe`,dark:`#1e1e1e`},W6=`__shiki_resolved`;function G6(e){if(e?.[W6])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||=`dark`,t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(r=e.settings.foreground),e?.settings?.background&&(n=e.settings.background),!r&&t?.colors?.[`editor.foreground`]&&(r=t.colors[`editor.foreground`]),!n&&t?.colors?.[`editor.background`]&&(n=t.colors[`editor.background`]),r||=t.type===`light`?H6.light:H6.dark,n||=t.type===`light`?U6.light:U6.dark,t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,a=new Map;function o(e){if(a.has(e))return a.get(e);i+=1;let n=`#${i.toString(16).padStart(8,`0`).toLowerCase()}`;return t.colorReplacements?.[`#${n}`]?o(e):(a.set(e,n),n)}t.settings=t.settings.map(e=>{let n=e.settings?.foreground&&!e.settings.foreground.startsWith(`#`),r=e.settings?.background&&!e.settings.background.startsWith(`#`);if(!n&&!r)return e;let i={...e,settings:{...e.settings}};if(n){let n=o(e.settings.foreground);t.colorReplacements[n]=e.settings.foreground,i.settings.foreground=n}if(r){let n=o(e.settings.background);t.colorReplacements[n]=e.settings.background,i.settings.background=n}return i});for(let e of Object.keys(t.colors||{}))if((e===`editor.foreground`||e===`editor.background`||e.startsWith(`terminal.ansi`))&&!t.colors[e]?.startsWith(`#`)){let n=o(t.colors[e]);t.colorReplacements[n]=t.colors[e],t.colors[e]=n}return Object.defineProperty(t,W6,{enumerable:!1,writable:!1,value:!0}),t}async function K6(e){return Array.from(new Set((await Promise.all(e.filter(e=>!R6(e)).map(async e=>await I6(e).then(e=>Array.isArray(e)?e:[e])))).flat()))}async function q6(e){return(await Promise.all(e.map(async e=>B6(e)?null:G6(await I6(e))))).filter(e=>!!e)}function J6(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new B3(`Circular alias \`${Array.from(n).join(` -> `)} -> ${e}\``);n.add(e)}}return e}var C5e=class extends x5e{_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}getTheme(e){return typeof e==`string`?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=G6(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||=[...this._resolvedThemes.keys()],this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=Z3.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=J6(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||[`*`],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null,t.size)for(let e of t)this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(e.scopeName),this._syncRegistry?._grammars?.delete(e.scopeName),this.loadLanguage(this._langMap.get(e.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let t of e)this.resolveEmbeddedLanguages(t);let t=Array.from(this._langGraph.entries()),n=t.filter(([e,t])=>!t);if(n.length){let e=t.filter(([e,t])=>t?(t.embeddedLanguages||t.embeddedLangs)?.some(e=>n.map(([e])=>e).includes(e)):!1).filter(e=>!n.includes(e));throw new B3(`Missing languages ${n.map(([e])=>`\`${e}\``).join(`, `)}, required by ${e.map(([e])=>`\`${e}\``).join(`, `)}`)}for(let[e,n]of t)this._resolver.addLanguage(n);for(let[e,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])],this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let e of t)this._langGraph.set(e,this._langMap.get(e))}},w5e=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split(`.`),n=[];for(let e=1;e<=t.length;e++){let r=t.slice(0,e).join(`.`);n=[...n,...this._injections.get(r)||[]]}return n}},Y6=0;function T5e(e){Y6+=1,e.warnings!==!1&&Y6>=10&&Y6%10==0&&console.warn(`[Shiki] ${Y6} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new B3("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(G6),i=new C5e(new w5e(e.engine,n),r,n,e.langAlias),a;function o(t){return J6(t,e.langAlias)}function s(e){g();let t=i.getGrammar(typeof e==`string`?e:e.name);if(!t)throw new B3(`Language \`${e}\` not found, you may need to load it first`);return t}function c(e){if(e===`none`)return{bg:``,fg:``,name:`none`,settings:[],type:`dark`};g();let t=i.getTheme(e);if(!t)throw new B3(`Theme \`${e}\` not found, you may need to load it first`);return t}function l(e){g();let t=c(e);return a!==e&&(i.setTheme(t),a=e),{theme:t,colorMap:i.getColorMap()}}function u(){return g(),i.getLoadedThemes()}function d(){return g(),i.getLoadedLanguages()}function f(...e){g(),i.loadLanguages(e.flat(1))}async function p(...e){return f(await K6(e))}function m(...e){g();for(let t of e.flat(1))i.loadTheme(t)}async function h(...e){return g(),m(await q6(e))}function g(){if(t)throw new B3(`Shiki instance has been disposed`)}function _(){t||(t=!0,i.dispose(),--Y6)}return{setTheme:l,getTheme:c,getLanguage:s,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:o,loadLanguage:p,loadLanguageSync:f,loadTheme:h,loadThemeSync:m,dispose:_,[Symbol.dispose]:_}}async function E5e(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([q6(e.themes||[]),K6(e.langs||[]),e.engine]);return T5e({...e,themes:t,langs:n,engine:r})}var X6=new WeakMap;function Z6(e,t){X6.set(e,t)}function Q6(e){return X6.get(e)}var $6=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new e(Object.fromEntries(S5e(n).map(e=>[e,N6])),t)}constructor(...e){if(e.length===2){let[t,n]=e;this.lang=n,this._stacks=t}else{let[t,n,r]=e;this.lang=n,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return D5e(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function D5e(e){let t=[],n=new Set;function r(e){if(n.has(e))return;n.add(e);let i=e?.nameScopesList?.scopeName;i&&t.push(i),e.parent&&r(e.parent)}return r(e),t}function O5e(e,t){if(!(e instanceof $6))throw new B3(`Invalid grammar state`);return e.getInternalStack(t)}function e8(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(L6(e.resolveLangAlias(n.lang||`text`))||z6(r))return V6(t).map(e=>[{content:e[0],offset:e[1]}]);let{theme:i,colorMap:a}=e.setTheme(r),o=e.getLanguage(n.lang||`text`);if(n.grammarState){if(n.grammarState.lang!==o.name)throw new B3(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(i.name))throw new B3(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return A5e(t,o,i,a,n)}function k5e(...e){if(e.length===2)return Q6(e[1]);let[t,n,r={}]=e,{lang:i=`text`,theme:a=t.getLoadedThemes()[0]}=r;if(L6(i)||z6(a))throw new B3(`Plain language does not have grammar state`);if(i===`ansi`)throw new B3(`ANSI language does not have grammar state`);let{theme:o,colorMap:s}=t.setTheme(a),c=t.getLanguage(i);return new $6(t8(n,c,o,s,r).stateStack,c.name,o.name)}function A5e(e,t,n,r,i){let a=t8(e,t,n,r,i),o=new $6(a.stateStack,t.name,n.name);return Z6(a.tokens,o),a.tokens}function t8(e,t,n,r,i){let a=P6(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:s=500}=i,c=V6(e),l=i.grammarState?O5e(i.grammarState,n.name)??N6:i.grammarContextCode==null?N6:t8(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack,u=[],d=[];for(let e=0,f=c.length;e<f;e++){let[f,p]=c[e];if(f===``){u=[],d.push([]);continue}if(o>0&&f.length>=o){u=[],d.push([{content:f,offset:p,color:``,fontStyle:0}]);continue}let m,h,g;i.includeExplanation&&(m=t.tokenizeLine(f,l,s),h=m.tokens,g=0);let _=t.tokenizeLine2(f,l,s),v=_.tokens.length/2;for(let e=0;e<v;e++){let t=_.tokens[2*e],o=e+1<v?_.tokens[2*e+2]:f.length;if(t===o)continue;let s=_.tokens[2*e+1],c=F6(r[n6.getForeground(s)],a),l=n6.getFontStyle(s),d={content:f.substring(t,o),offset:p+t,color:c,fontStyle:l};if(i.includeExplanation){let e=[];if(i.includeExplanation!==`scopeName`)for(let t of n.settings){let n;switch(typeof t.scope){case`string`:n=t.scope.split(/,/).map(e=>e.trim());break;case`object`:n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split(/ /))})}d.explanation=[];let r=0;for(;t+r<o;){let t=h[g],n=f.substring(t.startIndex,t.endIndex);r+=n.length,d.explanation.push({content:n,scopes:i.includeExplanation===`scopeName`?j5e(t.scopes):M5e(e,t.scopes)}),g+=1}}u.push(d)}d.push(u),u=[],l=_.ruleStack}return{tokens:d,stateStack:l}}function j5e(e){return e.map(e=>({scopeName:e}))}function M5e(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];n[r]={scopeName:i,themeMatches:P5e(e,i,t.slice(0,r))}}return n}function n8(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]===`.`}function N5e(e,t,n){if(!n8(e[e.length-1],t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)n8(e[r],n[i])&&--r,--i;return r===-1}function P5e(e,t,n){let r=[];for(let{selectors:i,settings:a}of e)for(let e of i)if(N5e(e,t,n)){r.push(a);break}return r}function r8(e,t,n,r=e8){let i=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),a=i.map(i=>{let a=r(e,t,{...n,theme:i.theme});return{tokens:a,state:Q6(a),theme:typeof i.theme==`string`?i.theme:i.theme.name}}),o=F5e(...a.map(e=>e.tokens)),s=o[0].map((e,t)=>e.map((e,r)=>{let a={content:e.content,variants:{},offset:e.offset};return`includeExplanation`in n&&n.includeExplanation&&(a.explanation=e.explanation),o.forEach((e,n)=>{let{content:o,explanation:s,offset:c,...l}=e[t][r];a.variants[i[n].color]=l}),a})),c=a[0].state?new $6(Object.fromEntries(a.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),a[0].state.lang):void 0;return c&&Z6(s,c),s}function F5e(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let i=e.map(e=>e[r]),a=t.map(()=>[]);t.forEach((e,t)=>e.push(a[t]));let o=i.map(()=>0),s=i.map(e=>e[0]);for(;s.every(e=>e);){let e=Math.min(...s.map(e=>e.content.length));for(let t=0;t<n;t++){let n=s[t];n.content.length===e?(a[t].push(n),o[t]+=1,s[t]=i[t][o[t]]):(a[t].push({...n,content:n.content.slice(0,e)}),s[t]={...n,content:n.content.slice(e),offset:n.offset+e})}}}return t}function i8(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class==`string`&&(e.properties.class=e.properties.class.split(/\s+/g)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(/\s+/g);for(let t of n)t&&!e.properties.class.includes(t)&&e.properties.class.push(t);return e}function I5e(e){let t=V6(e,!0).map(([e])=>e);function n(n){if(n===e.length)return{line:t.length-1,character:t[t.length-1].length};let r=n,i=0;for(let e of t){if(r<e.length)break;r-=e.length,i++}return{line:i,character:r}}function r(e,n){let r=0;for(let n=0;n<e;n++)r+=t[n].length;return r+=n,r}return{lines:t,indexToPos:n,posToIndex:r}}function L5e(e,t,n){let r=new Set;for(let t of e.matchAll(/:?lang=["']([^"']+)["']/g)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(/(?:```|~~~)([\w-]+)/g)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(/\\begin\{([\w-]+)\}/g)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){let e=t[1].toLowerCase().trim(),n=e.includes(`/`)?e.split(`/`).pop():e;n&&r.add(n)}if(!n)return Array.from(r);let i=n.getBundledLanguages();return Array.from(r).filter(e=>e&&i[e])}var a8=`light-dark()`,R5e=[`color`,`background-color`];function z5e(e,t){let n=0,r=[];for(let i of t)i>n&&r.push({...e,content:e.content.slice(n,i),offset:e.offset+n}),n=i;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function B5e(e,t){let n=Array.from(t instanceof Set?t:new Set(t)).sort((e,t)=>e-t);return n.length?e.map(e=>e.flatMap(e=>{let t=n.filter(t=>e.offset<t&&t<e.offset+e.content.length).map(t=>t-e.offset).sort((e,t)=>e-t);return t.length?z5e(e,t):e})):e}function V5e(e,t,n,r,i=`css-vars`){let a={content:e.content,explanation:e.explanation,offset:e.offset},o=t.map(t=>o8(e.variants[t])),s=new Set(o.flatMap(e=>Object.keys(e))),c={},l=(e,r)=>{let i=r===`color`?``:r===`background-color`?`-bg`:`-${r}`;return n+t[e]+(r===`color`?``:i)};return o.forEach((e,n)=>{for(let a of s){let s=e[a]||`inherit`;if(n===0&&r&&R5e.includes(a))if(r===a8&&o.length>1){let e=t.findIndex(e=>e===`light`),r=t.findIndex(e=>e===`dark`);if(e===-1||r===-1)throw new B3('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');c[a]=`light-dark(${o[e][a]||`inherit`}, ${o[r][a]||`inherit`})`,i===`css-vars`&&(c[l(n,a)]=s)}else c[a]=s;else i===`css-vars`&&(c[l(n,a)]=s)}}),a.htmlStyle=c,a}function o8(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t[`background-color`]=e.bgColor),e.fontStyle){e.fontStyle&e6.Italic&&(t[`font-style`]=`italic`),e.fontStyle&e6.Bold&&(t[`font-weight`]=`bold`);let n=[];e.fontStyle&e6.Underline&&n.push(`underline`),e.fontStyle&e6.Strikethrough&&n.push(`line-through`),n.length&&(t[`text-decoration`]=n.join(` `))}return t}function s8(e){return typeof e==`string`?e:Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function H5e(){let e=new WeakMap;function t(t){if(!e.has(t.meta)){let n=I5e(t.source);function r(e){if(typeof e==`number`){if(e<0||e>t.source.length)throw new B3(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);return{...n.indexToPos(e),offset:e}}{let t=n.lines[e.line];if(t===void 0)throw new B3(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${n.lines.length}`);let r=e.character;if(r<0&&(r=t.length+r),r<0||r>t.length)throw new B3(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);return{...e,character:r,offset:n.posToIndex(e.line,r)}}}let i=(t.options.decorations||[]).map(e=>({...e,start:r(e.start),end:r(e.end)}));U5e(i),e.set(t.meta,{decorations:i,converter:n,source:t.source})}return e.get(t.meta)}return{name:`shiki:decorations`,tokens(e){if(this.options.decorations?.length)return B5e(e,t(this).decorations.flatMap(e=>[e.start.offset,e.end.offset]))},code(e){if(!this.options.decorations?.length)return;let n=t(this),r=Array.from(e.children).filter(e=>e.type===`element`&&e.tagName===`span`);if(r.length!==n.converter.lines.length)throw new B3(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${n.converter.lines.length}). Failed to apply decorations.`);function i(e,t,n,i){let a=r[e],s=``,c=-1,l=-1;if(t===0&&(c=0),n===0&&(l=0),n===1/0&&(l=a.children.length),c===-1||l===-1)for(let e=0;e<a.children.length;e++)s+=c8(a.children[e]),c===-1&&s.length===t&&(c=e+1),l===-1&&s.length===n&&(l=e+1);if(c===-1)throw new B3(`Failed to find start index for decoration ${JSON.stringify(i.start)}`);if(l===-1)throw new B3(`Failed to find end index for decoration ${JSON.stringify(i.end)}`);let u=a.children.slice(c,l);if(!i.alwaysWrap&&u.length===a.children.length)o(a,i,`line`);else if(!i.alwaysWrap&&u.length===1&&u[0].type===`element`)o(u[0],i,`token`);else{let e={type:`element`,tagName:`span`,properties:{},children:u};o(e,i,`wrapper`),a.children.splice(c,u.length,e)}}function a(e,t){r[e]=o(r[e],t,`line`)}function o(e,t,n){let r=t.properties||{},i=t.transform||(e=>e);return e.tagName=t.tagName||`span`,e.properties={...e.properties,...r,class:e.properties.class},t.properties?.class&&i8(e,t.properties.class),e=i(e,n)||e,e}let s=[],c=n.decorations.sort((e,t)=>t.start.offset-e.start.offset||e.end.offset-t.end.offset);for(let e of c){let{start:t,end:n}=e;if(t.line===n.line)i(t.line,t.character,n.character,e);else if(t.line<n.line){i(t.line,t.character,1/0,e);for(let r=t.line+1;r<n.line;r++)s.unshift(()=>a(r,e));i(n.line,0,n.character,e)}}s.forEach(e=>e())}}}function U5e(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new B3(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let t=e[r],i=n.start.offset<=t.start.offset&&t.start.offset<n.end.offset,a=n.start.offset<t.end.offset&&t.end.offset<=n.end.offset,o=t.start.offset<=n.start.offset&&n.start.offset<t.end.offset,s=t.start.offset<n.end.offset&&n.end.offset<=t.end.offset;if(i||a||o||s){if(i&&a||o&&s||o&&n.start.offset===n.end.offset||a&&t.start.offset===t.end.offset)continue;throw new B3(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(t.start)} intersect.`)}}}}function c8(e){return e.type===`text`?e.value:e.type===`element`?e.children.map(c8).join(``):``}var W5e=[H5e()];function l8(e){let t=G5e(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...W5e]}function G5e(e){let t=[],n=[],r=[];for(let i of e)switch(i.enforce){case`pre`:t.push(i);break;case`post`:n.push(i);break;default:r.push(i)}return{pre:t,post:n,normal:r}}var u8=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],d8={1:`bold`,2:`dim`,3:`italic`,4:`underline`,7:`reverse`,8:`hidden`,9:`strikethrough`};function K5e(e,t){let n=e.indexOf(`\x1B`,t);if(n!==-1&&e[n+1]===`[`){let t=e.indexOf(`m`,n);if(t!==-1)return{sequence:e.substring(n+2,t).split(`;`),startPosition:n,position:t+1}}return{position:e.length}}function f8(e){let t=e.shift();if(t===`2`){let t=e.splice(0,3).map(e=>Number.parseInt(e));return t.length!==3||t.some(e=>Number.isNaN(e))?void 0:{type:`rgb`,rgb:t}}if(t===`5`){let t=e.shift();if(t)return{type:`table`,index:Number(t)}}}function q5e(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:`resetAll`});else if(r<=9)d8[r]&&t.push({type:`setDecoration`,value:d8[r]});else if(r<=29){let e=d8[r-20];e&&(t.push({type:`resetDecoration`,value:e}),e===`dim`&&t.push({type:`resetDecoration`,value:`bold`}))}else if(r<=37)t.push({type:`setForegroundColor`,value:{type:`named`,name:u8[r-30]}});else if(r===38){let n=f8(e);n&&t.push({type:`setForegroundColor`,value:n})}else if(r===39)t.push({type:`resetForegroundColor`});else if(r<=47)t.push({type:`setBackgroundColor`,value:{type:`named`,name:u8[r-40]}});else if(r===48){let n=f8(e);n&&t.push({type:`setBackgroundColor`,value:n})}else r===49?t.push({type:`resetBackgroundColor`}):r===53?t.push({type:`setDecoration`,value:`overline`}):r===55?t.push({type:`resetDecoration`,value:`overline`}):r>=90&&r<=97?t.push({type:`setForegroundColor`,value:{type:`named`,name:u8[r-90+8]}}):r>=100&&r<=107&&t.push({type:`setBackgroundColor`,value:{type:`named`,name:u8[r-100+8]}})}return t}function J5e(){let e=null,t=null,n=new Set;return{parse(r){let i=[],a=0;do{let o=K5e(r,a),s=o.sequence?r.substring(a,o.startPosition):r.substring(a);if(s.length>0&&i.push({value:s,foreground:e,background:t,decorations:new Set(n)}),o.sequence){let r=q5e(o.sequence);for(let i of r)i.type===`resetAll`?(e=null,t=null,n.clear()):i.type===`resetForegroundColor`?e=null:i.type===`resetBackgroundColor`?t=null:i.type===`resetDecoration`&&n.delete(i.value);for(let i of r)i.type===`setForegroundColor`?e=i.value:i.type===`setBackgroundColor`?t=i.value:i.type===`setDecoration`&&n.add(i.value)}a=o.position}while(a<r.length);return i}}}var Y5e={black:`#000000`,red:`#bb0000`,green:`#00bb00`,yellow:`#bbbb00`,blue:`#0000bb`,magenta:`#ff00ff`,cyan:`#00bbbb`,white:`#eeeeee`,brightBlack:`#555555`,brightRed:`#ff5555`,brightGreen:`#00ff00`,brightYellow:`#ffff55`,brightBlue:`#5555ff`,brightMagenta:`#ff55ff`,brightCyan:`#55ffff`,brightWhite:`#ffffff`};function X5e(e=Y5e){function t(t){return e[t]}function n(e){return`#${e.map(e=>Math.max(0,Math.min(e,255)).toString(16).padStart(2,`0`)).join(``)}`}let r;function i(){if(r)return r;r=[];for(let e=0;e<u8.length;e++)r.push(t(u8[e]));let e=[0,95,135,175,215,255];for(let t=0;t<6;t++)for(let i=0;i<6;i++)for(let a=0;a<6;a++)r.push(n([e[t],e[i],e[a]]));let i=8;for(let e=0;e<24;e++,i+=10)r.push(n([i,i,i]));return r}function a(e){return i()[e]}function o(e){switch(e.type){case`named`:return t(e.name);case`rgb`:return n(e.rgb);case`table`:return a(e.index)}}return{value:o}}var Z5e={black:`#000000`,red:`#cd3131`,green:`#0DBC79`,yellow:`#E5E510`,blue:`#2472C8`,magenta:`#BC3FBC`,cyan:`#11A8CD`,white:`#E5E5E5`,brightBlack:`#666666`,brightRed:`#F14C4C`,brightGreen:`#23D18B`,brightYellow:`#F5F543`,brightBlue:`#3B8EEA`,brightMagenta:`#D670D6`,brightCyan:`#29B8DB`,brightWhite:`#FFFFFF`};function Q5e(e,t,n){let r=P6(e,n),i=V6(t),a=X5e(Object.fromEntries(u8.map(t=>{let n=`terminal.ansi${t[0].toUpperCase()}${t.substring(1)}`;return[t,e.colors?.[n]||Z5e[t]]}))),o=J5e();return i.map(t=>o.parse(t[0]).map(n=>{let i,o;n.decorations.has(`reverse`)?(i=n.background?a.value(n.background):e.bg,o=n.foreground?a.value(n.foreground):e.fg):(i=n.foreground?a.value(n.foreground):e.fg,o=n.background?a.value(n.background):void 0),i=F6(i,r),o=F6(o,r),n.decorations.has(`dim`)&&(i=$5e(i));let s=e6.None;return n.decorations.has(`bold`)&&(s|=e6.Bold),n.decorations.has(`italic`)&&(s|=e6.Italic),n.decorations.has(`underline`)&&(s|=e6.Underline),n.decorations.has(`strikethrough`)&&(s|=e6.Strikethrough),{content:n.value,offset:t[1],color:i,bgColor:o,fontStyle:s}}))}function $5e(e){let t=e.match(/#([0-9a-f]{3,8})/i);if(t){let e=t[1];if(e.length===8){let t=Math.round(Number.parseInt(e.slice(6,8),16)/2).toString(16).padStart(2,`0`);return`#${e.slice(0,6)}${t}`}if(e.length===6)return`#${e}80`;if(e.length===4){let t=e[0],n=e[1],r=e[2],i=e[3];return`#${t}${t}${n}${n}${r}${r}${Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,`0`)}`}if(e.length===3){let t=e[0],n=e[1],r=e[2];return`#${t}${t}${n}${n}${r}${r}80`}}let n=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:e}function p8(e,t,n={}){let r=e.resolveLangAlias(n.lang||`text`),{theme:i=e.getLoadedThemes()[0]}=n;if(!L6(r)&&!z6(i)&&r===`ansi`){let{theme:r}=e.setTheme(i);return Q5e(r,t,n)}return e8(e,t,n)}function m8(e,t,n){let r,i,a,o,s,c;if(`themes`in n){let{defaultColor:l=`light`,cssVariablePrefix:u=`--shiki-`,colorsRendering:d=`css-vars`}=n,f=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})).sort((e,t)=>e.color===l?-1:+(t.color===l));if(f.length===0)throw new B3("`themes` option must not be empty");let p=r8(e,t,n,p8);if(c=Q6(p),l&&a8!==l&&!f.find(e=>e.color===l))throw new B3(`\`themes\` option must contain the defaultColor key \`${l}\``);let m=f.map(t=>e.getTheme(t.theme)),h=f.map(e=>e.color);a=p.map(e=>e.map(e=>V5e(e,h,u,l,d))),c&&Z6(a,c);let g=f.map(e=>P6(e.theme,n));i=h8(f,m,g,u,l,`fg`,d),r=h8(f,m,g,u,l,`bg`,d),o=`shiki-themes ${m.map(e=>e.name).join(` `)}`,s=l?void 0:[i,r].join(`;`)}else if(`theme`in n){let s=P6(n.theme,n);a=p8(e,t,n);let l=e.getTheme(n.theme);r=F6(l.bg,s),i=F6(l.fg,s),o=l.name,c=Q6(a)}else throw new B3("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:i,bg:r,themeName:o,rootStyle:s,grammarState:c}}function h8(e,t,n,r,i,a,o){return e.map((s,c)=>{let l=F6(t[c][a],n[c])||`inherit`,u=`${r+s.color}${a===`bg`?`-bg`:``}:${l}`;if(c===0&&i){if(i===a8&&e.length>1){let r=e.findIndex(e=>e.color===`light`),i=e.findIndex(e=>e.color===`dark`);if(r===-1||i===-1)throw new B3('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${F6(t[r][a],n[r])||`inherit`}, ${F6(t[i][a],n[i])||`inherit`});${u}`}return l}return o===`css-vars`?u:null}).filter(e=>!!e).join(`;`)}function g8(e,t,n,r={meta:{},options:n,codeToHast:(t,n)=>g8(e,t,n),codeToTokens:(t,n)=>m8(e,t,n)}){let i=t;for(let e of l8(n))i=e.preprocess?.call(r,i,n)||i;let{tokens:a,fg:o,bg:s,themeName:c,rootStyle:l,grammarState:u}=m8(e,i,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:f=!1}=n;d===!0?a=t7e(a):d===`never`&&(a=n7e(a)),f&&(a=r7e(a));let p={...r,get source(){return i}};for(let e of l8(n))a=e.tokens?.call(p,a)||a;return e7e(a,{...n,fg:o,bg:s,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??l},p,u)}function e7e(e,t,n,r=Q6(e)){let i=l8(t),a=[],o={type:`root`,children:[]},{structure:s=`classic`,tabindex:c=`0`}=t,l={class:`shiki ${t.themeName||``}`};t.rootStyle!==!1&&(l.style=t.rootStyle==null?`background-color:${t.bg};color:${t.fg}`:t.rootStyle),c!==!1&&c!=null&&(l.tabindex=c.toString());for(let[e,n]of Object.entries(t.meta||{}))e.startsWith(`_`)||(l[e]=n);let u={type:`element`,tagName:`pre`,properties:l,children:[],data:t.data},d={type:`element`,tagName:`code`,properties:{},children:a},f=[],p={...n,structure:s,addClassToHast:i8,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return o},get pre(){return u},get code(){return d},get lines(){return f}};if(e.forEach((e,t)=>{t&&(s===`inline`?o.children.push({type:`element`,tagName:`br`,properties:{},children:[]}):s===`classic`&&a.push({type:`text`,value:`
|
|
1042
|
+
`}));let n={type:`element`,tagName:`span`,properties:{class:`line`},children:[]},r=0;for(let a of e){let e={type:`element`,tagName:`span`,properties:{...a.htmlAttrs},children:[{type:`text`,value:a.content}]},c=s8(a.htmlStyle||o8(a));c&&(e.properties.style=c);for(let o of i)e=o?.span?.call(p,e,t+1,r,n,a)||e;s===`inline`?o.children.push(e):s===`classic`&&n.children.push(e),r+=a.content.length}if(s===`classic`){for(let e of i)n=e?.line?.call(p,n,t+1)||n;f.push(n),a.push(n)}else s===`inline`&&f.push(n)}),s===`classic`){for(let e of i)d=e?.code?.call(p,d)||d;u.children.push(d);for(let e of i)u=e?.pre?.call(p,u)||u;o.children.push(u)}else if(s===`inline`){let e=[],t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]};for(let n of o.children)n.type===`element`&&n.tagName===`br`?(e.push(t),t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]}):(n.type===`element`||n.type===`text`)&&t.children.push(n);e.push(t);let n={type:`element`,tagName:`code`,properties:{},children:e};for(let e of i)n=e?.code?.call(p,n)||n;o.children=[];for(let e=0;e<n.children.length;e++){e>0&&o.children.push({type:`element`,tagName:`br`,properties:{},children:[]});let t=n.children[e];t.type===`element`&&o.children.push(...t.children)}}let m=o;for(let e of i)m=e?.root?.call(p,m)||m;return r&&Z6(m,r),m}function t7e(e){return e.map(e=>{let t=[],n=``,r;return e.forEach((i,a)=>{let o=!(i.fontStyle&&(i.fontStyle&e6.Underline||i.fontStyle&e6.Strikethrough));o&&i.content.match(/^\s+$/)&&e[a+1]?(r===void 0&&(r=i.offset),n+=i.content):n?(o?t.push({...i,offset:r,content:n+i.content}):t.push({content:n,offset:r},i),r=void 0,n=``):t.push(i)}),t})}function n7e(e){return e.map(e=>e.flatMap(e=>{if(e.content.match(/^\s+$/))return e;let t=e.content.match(/^(\s*)(.*?)(\s*)$/);if(!t)return e;let[,n,r,i]=t;if(!n&&!i)return e;let a=[{...e,offset:e.offset+n.length,content:r}];return n&&a.unshift({content:n,offset:e.offset}),i&&a.push({content:i,offset:e.offset+n.length+r.length}),a}))}function r7e(e){return e.map(e=>{let t=[];for(let n of e){if(t.length===0){t.push({...n});continue}let e=t[t.length-1],r=s8(e.htmlStyle||o8(e)),i=s8(n.htmlStyle||o8(n)),a=e.fontStyle&&(e.fontStyle&e6.Underline||e.fontStyle&e6.Strikethrough),o=n.fontStyle&&(n.fontStyle&e6.Underline||n.fontStyle&e6.Strikethrough);!a&&!o&&r===i?e.content+=n.content:t.push({...n})}return t})}var i7e=o3;function a7e(e,t,n){let r={meta:{},options:n,codeToHast:(t,n)=>g8(e,t,n),codeToTokens:(t,n)=>m8(e,t,n)},i=i7e(g8(e,t,n,r));for(let e of l8(n))i=e.postprocess?.call(r,i,n)||i;return i}async function o7e(e){let t=await E5e(e);return{getLastGrammarState:(...e)=>k5e(t,...e),codeToTokensBase:(e,n)=>p8(t,e,n),codeToTokensWithThemes:(e,n)=>r8(t,e,n),codeToTokens:(e,n)=>m8(t,e,n),codeToHast:(e,n)=>g8(t,e,n),codeToHtml:(e,n)=>a7e(t,e,n),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function s7e(e){let t=e.langs,n=e.themes,r=e.engine;async function i(e){function i(n){if(typeof n==`string`){if(n=e.langAlias?.[n]||n,R6(n))return[];let r=t[n];if(!r)throw new B3(`Language \`${n}\` is not included in this bundle. You may want to load it from external source.`);return r}return n}function a(e){if(B6(e))return`none`;if(typeof e==`string`){let t=n[e];if(!t)throw new B3(`Theme \`${e}\` is not included in this bundle. You may want to load it from external source.`);return t}return e}let o=(e.themes??[]).map(e=>a(e)),s=(e.langs??[]).map(e=>i(e)),c=await o7e({engine:e.engine??r(),...e,themes:o,langs:s});return{...c,loadLanguage(...e){return c.loadLanguage(...e.map(i))},loadTheme(...e){return c.loadTheme(...e.map(a))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return i}function c7e(e){let t;async function n(n={}){if(t){let e=await t;return await Promise.all([e.loadTheme(...n.themes||[]),e.loadLanguage(...n.langs||[])]),e}{t=e({...n,themes:[],langs:[]});let r=await t;return await Promise.all([r.loadTheme(...n.themes||[]),r.loadLanguage(...n.langs||[])]),r}}return n}function l7e(e,t){let n=c7e(e);async function r(e,r){let i=await n({langs:[r.lang],themes:`theme`in r?[r.theme]:Object.values(r.themes)}),a=await t?.guessEmbeddedLanguages?.(e,r.lang,i);return a&&await i.loadLanguage(...a),i}return{getSingletonHighlighter(e){return n(e)},async codeToHtml(e,t){return(await r(e,t)).codeToHtml(e,t)},async codeToHast(e,t){return(await r(e,t)).codeToHast(e,t)},async codeToTokens(e,t){return(await r(e,t)).codeToTokens(e,t)},async codeToTokensBase(e,t){return(await r(e,t)).codeToTokensBase(e,t)},async codeToTokensWithThemes(e,t){return(await r(e,t)).codeToTokensWithThemes(e,t)},async getLastGrammarState(e,t){return(await n({langs:[t.lang],themes:[t.theme]})).getLastGrammarState(e,t)}}}var _8=s7e({langs:D3,themes:h8e,engine:()=>(0,z3.createOnigurumaEngine)(N(()=>import(`./wasm-BnjxR4X6.js`),[]))}),{codeToHtml:u7e,codeToHast:d7e,codeToTokens:f7e,codeToTokensBase:p7e,codeToTokensWithThemes:m7e,getSingletonHighlighter:h7e,getLastGrammarState:g7e}=l7e(_8,{guessEmbeddedLanguages:L5e}),v8=4294967295,_7e=class{regexps;constructor(e,t={}){this.patterns=e,this.options=t;let{forgiving:n=!1,cache:r,regexConstructor:i}=t;if(!i)throw Error("Option `regexConstructor` is not provided");this.regexps=e.map(e=>{if(typeof e!=`string`)return e;let t=r?.get(e);if(t){if(t instanceof RegExp)return t;if(n)return null;throw t}try{let t=i(e);return r?.set(e,t),t}catch(t){if(r?.set(e,t),n)return null;throw t}})}findNextMatchSync(e,t,n){let r=typeof e==`string`?e:e.content,i=[];function a(e,t,n=0){return{index:e,captureIndices:t.indices.map(e=>e==null?{start:v8,end:v8,length:0}:{start:e[0]+n,end:e[1]+n,length:e[1]-e[0]})}}for(let e=0;e<this.regexps.length;e++){let n=this.regexps[e];if(n)try{n.lastIndex=t;let o=n.exec(r);if(!o)continue;if(o.index===t)return a(e,o,0);i.push([e,o,0])}catch(e){if(this.options.forgiving)continue;throw e}}if(i.length){let e=Math.min(...i.map(e=>e[1].index));for(let[t,n,r]of i)if(n.index===e)return a(t,n,r)}return null}};function y8(e){if([...e].length!==1)throw Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function v7e(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}var b8=new Set([`alnum`,`alpha`,`ascii`,`blank`,`cntrl`,`digit`,`graph`,`lower`,`print`,`punct`,`space`,`upper`,`word`,`xdigit`]),x8=String.raw;function S8(e,t){if(e==null)throw Error(t??`Value expected`);return e}var C8=x8`\[\^?`,w8=`c.? | C(?:-.?)?|${x8`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${x8`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${x8`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${x8`o\{[^\}]*\}?`}|${x8`\d{1,3}`}`,T8=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,E8=new RegExp(x8`
|
|
1043
1043
|
\\ (?:
|
|
1044
1044
|
${w8}
|
|
1045
1045
|
| [gk]<[^>]*>?
|
|
@@ -1070,8 +1070,8 @@ If init has been called in the preload and contextIsolation is disabled, is not
|
|
|
1070
1070
|
| ${C8}
|
|
1071
1071
|
| &&
|
|
1072
1072
|
| .
|
|
1073
|
-
`.replace(/\s+/g,``),`gsu`);function
|
|
1074
|
-
`,r);return{lastIndex:e===-1?t.length:e}}if(/^\s$/.test(n)){let e=/\s+/y;return e.lastIndex=r,{lastIndex:e.exec(t)?e.lastIndex:r}}}return n===`.`?{token:N8(`dot`,n)}:n===`^`||n===`$`?{token:k8(e.singleline?{"^":x8`\A`,$:x8`\Z`}[n]:n,n)}:n===`|`?{token:g7e(n)}:T8.test(n)?{tokens:P7e(n)}:{token:j8(y8(n),n)}}function m7e(e,t,n){let r=[M8(t[1]===`^`,t)],i=1,a;for(D8.lastIndex=n;a=D8.exec(e);){let e=a[0];if(e[0]===`[`&&e[1]!==`:`)i++,r.push(M8(e[1]===`^`,e));else if(e===`]`){if(r.at(-1).type===`CharacterClassOpen`)r.push(j8(93,e));else if(i--,r.push(_7e(e)),!i)break}else{let t=h7e(e);Array.isArray(t)?r.push(...t):r.push(t)}}return{tokens:r,lastIndex:D8.lastIndex||e.length}}function h7e(e){if(e[0]===`\\`)return O8(e,{inCharClass:!0});if(e[0]===`[`){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!b8.has(t.groups.name))throw Error(`Invalid POSIX class "${e}"`);return N8(`posix`,e,{value:t.groups.name,negate:!!t.groups.negate})}return e===`-`?v7e(e):e===`&&`?y7e(e):j8(y8(e),e)}function O8(e,{inCharClass:t}){let n=e[1];if(n===`c`||n===`C`)return E7e(e);if(`dDhHsSwW`.includes(n))return k7e(e);if(e.startsWith(x8`\o{`))throw Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw Error(`Incomplete or invalid Unicode property "${e}"`);return A7e(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let t=e.split(/\\x/).slice(1).map(e=>parseInt(e,16)),n=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(t)),r=new TextEncoder;return[...n].map(e=>{let t=[...r.encode(e)].map(e=>`\\x${e.toString(16)}`).join(``);return j8(y8(e),t)})}catch{throw Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n===`u`||n===`x`)return j8(M7e(e),e);if(I8.has(n))return j8(I8.get(n),e);if(/\d/.test(n))return b7e(t,e);if(e===`\\`)throw Error(x8`Incomplete escape "\"`);if(n===`M`)throw Error(`Unsupported meta "${e}"`);if([...e].length===2)return j8(e.codePointAt(1),e);throw Error(`Unexpected escape "${e}"`)}function g7e(e){return{type:`Alternator`,raw:e}}function k8(e,t){return{type:`Assertion`,kind:e,raw:t}}function A8(e){return{type:`Backreference`,raw:e}}function j8(e,t){return{type:`Character`,value:e,raw:t}}function _7e(e){return{type:`CharacterClassClose`,raw:e}}function v7e(e){return{type:`CharacterClassHyphen`,raw:e}}function y7e(e){return{type:`CharacterClassIntersector`,raw:e}}function M8(e,t){return{type:`CharacterClassOpen`,negate:e,raw:t}}function N8(e,t,n={}){return{type:`CharacterSet`,kind:e,...n,raw:t}}function P8(e,t,n={}){return e===`keep`?{type:`Directive`,kind:e,raw:t}:{type:`Directive`,kind:e,flags:S8(n.flags),raw:t}}function b7e(e,t){return{type:`EscapedNumber`,inCharClass:e,raw:t}}function x7e(e){return{type:`GroupClose`,raw:e}}function F8(e,t,n={}){return{type:`GroupOpen`,kind:e,...n,raw:t}}function S7e(e,t,n,r){return{type:`NamedCallout`,kind:e,tag:t,arguments:n,raw:r}}function C7e(e,t,n,r){return{type:`Quantifier`,kind:e,min:t,max:n,raw:r}}function w7e(e){return{type:`Subroutine`,raw:e}}var T7e=new Set([`COUNT`,`CMP`,`ERROR`,`FAIL`,`MAX`,`MISMATCH`,`SKIP`,`TOTAL_COUNT`]),I8=new Map([[`a`,7],[`b`,8],[`e`,27],[`f`,12],[`n`,10],[`r`,13],[`t`,9],[`v`,11]]);function E7e(e){let t=e[1]===`c`?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw Error(`Unsupported control character "${e}"`);return j8(y8(t.toUpperCase())-64,e)}function D7e(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??=``;let i=(t.getCurrentModX()||n.includes(`x`))&&!r.includes(`x`),a=R8(n),o=R8(r),s={};if(a&&(s.enable=a),o&&(s.disable=o),e.endsWith(`)`))return t.replaceCurrentModX(i),P8(`flags`,e,{flags:s});if(e.endsWith(`:`))return t.pushModX(i),t.numOpenGroups++,F8(`group`,e,{...(a||o)&&{flags:s}});throw Error(`Unexpected flag modifier "${e}"`)}function O7e(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw Error(`Incomplete or invalid named callout "${e}"`);let{name:n,tag:r,args:i}=t.groups;if(!n)throw Error(`Invalid named callout "${e}"`);if(r===``)throw Error(`Named callout tag with empty value not allowed "${e}"`);let a=i?i.split(`,`).filter(e=>e!==``).map(e=>/^[+-]?\d+$/.test(e)?+e:e):[],[o,s,c]=a,l=T7e.has(n)?n.toLowerCase():`custom`;switch(l){case`fail`:case`mismatch`:case`skip`:if(a.length>0)throw Error(`Named callout arguments not allowed "${a}"`);break;case`error`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(typeof o==`string`)throw Error(`Named callout argument must be a number "${o}"`);break;case`max`:if(!a.length||a.length>2)throw Error(`Named callout must have one or two arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(a.length===2&&(typeof s==`number`||!/^[<>X]$/.test(s)))throw Error(`Named callout optional argument two must be '<', '>', or 'X' "${s}"`);break;case`count`:case`total_count`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(a.length===1&&(typeof o==`number`||!/^[<>X]$/.test(o)))throw Error(`Named callout optional argument must be '<', '>', or 'X' "${o}"`);break;case`cmp`:if(a.length!==3)throw Error(`Named callout must have three arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(typeof s==`number`||!/^(?:[<>!=]=|[<>])$/.test(s))throw Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${s}"`);if(typeof c==`string`&&!/^[A-Za-z_]\w*$/.test(c))throw Error(`Named callout argument three must be a tag or number "${c}"`);break;case`custom`:throw Error(`Undefined callout name "${n}"`);default:throw Error(`Unexpected named callout kind "${l}"`)}return S7e(l,r??null,i?.split(`,`)??null,e)}function L8(e){let t=null,n,r;if(e[0]===`{`){let{minStr:i,maxStr:a}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,o=1e5;if(+i>o||a&&+a>o)throw Error(`Quantifier value unsupported in Oniguruma`);if(n=+i,r=a===void 0?+i:a===``?1/0:+a,n>r&&(t=`possessive`,[n,r]=[r,n]),e.endsWith(`?`)){if(t===`possessive`)throw Error(`Unsupported possessive interval quantifier chain with "?"`);t=`lazy`}else t||=`greedy`}else n=+(e[0]===`+`),r=e[0]===`?`?1:1/0,t=e[1]===`+`?`possessive`:e[1]===`?`?`lazy`:`greedy`;return C7e(t,n,r,e)}function k7e(e){let t=e[1].toLowerCase();return N8({d:`digit`,h:`hex`,s:`space`,w:`word`}[t],e,{negate:e[1]!==t})}function A7e(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return N8(`property`,e,{value:r,negate:t===`P`&&!n||t===`p`&&!!n})}function R8(e){let t={};return e.includes(`i`)&&(t.ignoreCase=!0),e.includes(`m`)&&(t.dotAll=!0),e.includes(`x`)&&(t.extended=!0),Object.keys(t).length?t:null}function j7e(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){let r=e[n];if(!`imxDPSWy`.includes(r))throw Error(`Invalid flag "${r}"`);if(r===`y`){if(!/^y{[gw]}/.test(e.slice(n)))throw Error(`Invalid or unspecified flag "y" mode`);t.textSegmentMode=e[n+2]===`g`?`grapheme`:`word`,n+=3;continue}t[{i:`ignoreCase`,m:`dotAll`,x:`extended`,D:`digitIsAscii`,P:`posixIsAscii`,S:`spaceIsAscii`,W:`wordIsAscii`}[r]]=!0}return t}function M7e(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw Error(`Incomplete or invalid escape "${e}"`);let t=e[2]===`{`?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function N7e(e,t){let{raw:n,inCharClass:r}=e,i=n.slice(1);if(!r&&(i!==`0`&&i.length===1||i[0]!==`0`&&+i<=t))return[A8(n)];let a=[],o=i.match(/^[0-7]+|\d/g);for(let e=0;e<o.length;e++){let t=o[e],r;if(e===0&&t!==`8`&&t!==`9`){if(r=parseInt(t,8),r>127)throw Error(x8`Octal encoded byte above 177 unsupported "${n}"`)}else r=y8(t);a.push(j8(r,(e===0?`\\`:``)+t))}return a}function P7e(e){let t=[],n=new RegExp(T8,`gy`),r;for(;r=n.exec(e);){let e=r[0];if(e[0]===`{`){let r=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(e);if(r){let{min:i,max:a}=r.groups;if(+i>+a&&e.endsWith(`?`)){n.lastIndex--,t.push(L8(e.slice(0,-1)));continue}}}t.push(L8(e))}return t}function z8(e,t){if(!Array.isArray(e.body))throw Error(`Expected node with body array`);if(e.body.length!==1)return!1;let n=e.body[0];return!t||Object.keys(t).every(e=>t[e]===n[e])}function F7e(e){return I7e.has(e.type)}var I7e=new Set([`AbsenceFunction`,`Backreference`,`CapturingGroup`,`Character`,`CharacterClass`,`CharacterSet`,`Group`,`Quantifier`,`Subroutine`]);function B8(e,t={}){let n={flags:``,normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=f7e(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),i=(e,t)=>{let n=r.tokens[a.nextIndex];switch(a.parent=e,a.nextIndex++,n.type){case`Alternator`:return V8();case`Assertion`:return L7e(n);case`Backreference`:return R7e(n,a);case`Character`:return G8(n.value,{useLastValid:!!t.isCheckingRangeEnd});case`CharacterClassHyphen`:return z7e(n,a,t);case`CharacterClassOpen`:return B7e(n,a,t);case`CharacterSet`:return V7e(n,a);case`Directive`:return q7e(n.kind,{flags:n.flags});case`GroupOpen`:return H7e(n,a,t);case`NamedCallout`:return Y7e(n.kind,n.tag,n.arguments);case`Quantifier`:return U7e(n,a);case`Subroutine`:return W7e(n,a);default:throw Error(`Unexpected token type "${n.type}"`)}},a={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:i},o=Z7e(J7e(r.flags)),s=o.body[0];for(;a.nextIndex<r.tokens.length;){let e=i(s,{});e.type===`Alternative`?(o.body.push(e),s=e):s.body.push(e)}let{capturingGroups:c,hasNumberedRef:l,namedGroupsByName:u,subroutines:d}=a;if(l&&u.size&&!n.rules.captureGroup)throw Error(`Numbered backref/subroutine not allowed when using named capture`);for(let{ref:e}of d)if(typeof e==`number`){if(e>c.length)throw Error(`Subroutine uses a group number that's not defined`);e&&(c[e-1].isSubroutined=!0)}else if(u.has(e)){if(u.get(e).length>1)throw Error(x8`Subroutine uses a duplicate group name "\g<${e}>"`);u.get(e)[0].isSubroutined=!0}else throw Error(x8`Subroutine uses a group name that's not defined "\g<${e}>"`);return o}function L7e({kind:e}){return H8(S8({"^":`line_start`,$:`line_end`,"\\A":`string_start`,"\\b":`word_boundary`,"\\B":`word_boundary`,"\\G":`search_start`,"\\y":`text_segment_boundary`,"\\Y":`text_segment_boundary`,"\\z":`string_end`,"\\Z":`string_end_newline`}[e],`Unexpected assertion kind "${e}"`),{negate:e===x8`\B`||e===x8`\Y`})}function R7e({raw:e},t){let n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),i=(n,r=!1)=>{let i=t.capturingGroups.length,a=!1;if(n>i)if(t.skipBackrefValidation)a=!0;else throw Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,U8(r?i+1-n:n,{orphan:a})};if(n){let n=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(n)return i(+n.groups.num,!!n.groups.sign);if(/[-+]/.test(r))throw Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw Error(`Group name not defined to the left "${e}"`);return U8(r)}return i(+r)}function z7e(e,t,n){let{tokens:r,walk:i}=t,a=t.parent,o=a.body.at(-1),s=r[t.nextIndex];if(!n.isCheckingRangeEnd&&o&&o.type!==`CharacterClass`&&o.type!==`CharacterClassRange`&&s&&s.type!==`CharacterClassOpen`&&s.type!==`CharacterClassClose`&&s.type!==`CharacterClassIntersector`){let e=i(a,{...n,isCheckingRangeEnd:!0});if(o.type===`Character`&&e.type===`Character`)return a.body.pop(),K7e(o,e);throw Error(`Invalid character class range`)}return G8(y8(`-`))}function B7e({negate:e},t,n){let{tokens:r,walk:i}=t,a=r[t.nextIndex],o=[K8()],s=i5(a);for(;s.type!==`CharacterClassClose`;){if(s.type===`CharacterClassIntersector`)o.push(K8()),t.nextIndex++;else{let e=o.at(-1);e.body.push(i(e,n))}s=i5(r[t.nextIndex],a)}let c=K8({negate:e});return o.length===1?c.body=o[0].body:(c.kind=`intersection`,c.body=o.map(e=>e.body.length===1?e.body[0]:e)),t.nextIndex++,c}function V7e({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o}=r;if(e===`property`){let r=r5(n);if(b8.has(r)&&!o?.has(r))e=`posix`,n=r;else return Q8(n,{negate:t,normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o})}return e===`posix`?X7e(n,{negate:t}):q8(e,{negate:t})}function H7e(e,t,n){let{tokens:r,capturingGroups:i,namedGroupsByName:a,skipLookbehindValidation:o,walk:s}=t,c=Q7e(e),l=c.type===`AbsenceFunction`,u=n5(c),d=u&&c.negate;if(c.type===`CapturingGroup`&&(i.push(c),c.name&&d7e(a,c.name,[]).push(c)),l&&n.isInAbsenceFunction)throw Error(`Nested absence function not supported by Oniguruma`);let f=a5(r[t.nextIndex]);for(;f.type!==`GroupClose`;){if(f.type===`Alternator`)c.body.push(V8()),t.nextIndex++;else{let e=c.body.at(-1),t=s(e,{...n,isInAbsenceFunction:n.isInAbsenceFunction||l,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||d});if(e.body.push(t),(u||n.isInLookbehind)&&!o){let e=`Lookbehind includes a pattern not allowed by Oniguruma`;if(d||n.isInNegLookbehind){if(t5(t)||t.type===`CapturingGroup`)throw Error(e)}else if(t5(t)||n5(t)&&t.negate)throw Error(e)}}f=a5(r[t.nextIndex])}return t.nextIndex++,c}function U7e({kind:e,min:t,max:n},r){let i=r.parent,a=i.body.at(-1);if(!a||!F7e(a))throw Error(`Quantifier requires a repeatable token`);let o=X8(e,t,n,a);return i.body.pop(),o}function W7e({raw:e},t){let{capturingGroups:n,subroutines:r}=t,i=e.slice(3,-1),a=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i);if(a){let e=+a.groups.num,r=n.length;if(t.hasNumberedRef=!0,i={"":e,"+":r+e,"-":r+1-e}[a.groups.sign],i<1)throw Error(`Invalid subroutine number`)}else i===`0`&&(i=0);let o=Z8(i);return r.push(o),o}function G7e(e,t){if(e!==`repeater`)throw Error(`Unexpected absence function kind "${e}"`);return{type:`AbsenceFunction`,kind:e,body:$8(t?.body)}}function V8(e){return{type:`Alternative`,body:e5(e?.body)}}function H8(e,t){let n={type:`Assertion`,kind:e};return(e===`word_boundary`||e===`text_segment_boundary`)&&(n.negate=!!t?.negate),n}function U8(e,t){let n=!!t?.orphan;return{type:`Backreference`,ref:e,...n&&{orphan:n}}}function W8(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!$7e(n.name))throw Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:`CapturingGroup`,number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:$8(t?.body)}}function G8(e,t){let n={useLastValid:!1,...t};if(e>1114111){let t=e.toString(16);if(n.useLastValid)e=1114111;else throw Error(e>1310719?`Invalid code point out of range "\\x{${t}}"`:`Invalid code point out of range in JS "\\x{${t}}"`)}return{type:`Character`,value:e}}function K8(e){let t={kind:`union`,negate:!1,...e};return{type:`CharacterClass`,kind:t.kind,negate:t.negate,body:e5(e?.body)}}function K7e(e,t){if(t.value<e.value)throw Error(`Character class range out of order`);return{type:`CharacterClassRange`,min:e,max:t}}function q8(e,t){let n=!!t?.negate,r={type:`CharacterSet`,kind:e};return(e===`digit`||e===`hex`||e===`newline`||e===`space`||e===`word`)&&(r.negate=n),(e===`text_segment`||e===`newline`&&!n)&&(r.variableLength=!0),r}function q7e(e,t={}){if(e===`keep`)return{type:`Directive`,kind:e};if(e===`flags`)return{type:`Directive`,kind:e,flags:S8(t.flags)};throw Error(`Unexpected directive kind "${e}"`)}function J7e(e){return{type:`Flags`,...e}}function J8(e){let t=e?.atomic,n=e?.flags;if(t&&n)throw Error(`Atomic group cannot have flags`);return{type:`Group`,...t&&{atomic:t},...n&&{flags:n},body:$8(e?.body)}}function Y8(e){let t={behind:!1,negate:!1,...e};return{type:`LookaroundAssertion`,kind:t.behind?`lookbehind`:`lookahead`,negate:t.negate,body:$8(e?.body)}}function Y7e(e,t,n){return{type:`NamedCallout`,kind:e,tag:t,arguments:n}}function X7e(e,t){let n=!!t?.negate;if(!b8.has(e))throw Error(`Invalid POSIX class "${e}"`);return{type:`CharacterSet`,kind:`posix`,value:e,negate:n}}function X8(e,t,n,r){if(t>n)throw Error(`Invalid reversed quantifier range`);return{type:`Quantifier`,kind:e,min:t,max:n,body:r}}function Z7e(e,t){return{type:`Regex`,body:$8(t?.body),flags:e}}function Z8(e){return{type:`Subroutine`,ref:e}}function Q8(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(r5(e));if(!r){if(n.normalizeUnknownPropertyNames)r=e9e(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw Error(x8`Invalid Unicode property "\p{${e}}"`)}return{type:`CharacterSet`,kind:`property`,value:r??e,negate:n.negate}}function Q7e({flags:e,kind:t,name:n,negate:r,number:i}){switch(t){case`absence_repeater`:return G7e(`repeater`);case`atomic`:return J8({atomic:!0});case`capturing`:return W8(i,{name:n});case`group`:return J8({flags:e});case`lookahead`:case`lookbehind`:return Y8({behind:t===`lookbehind`,negate:r});default:throw Error(`Unexpected group kind "${t}"`)}}function $8(e){if(e===void 0)e=[V8()];else if(!Array.isArray(e)||!e.length||!e.every(e=>e.type===`Alternative`))throw Error(`Invalid body; expected array of one or more Alternative nodes`);return e}function e5(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(e=>!!e.type))throw Error(`Invalid body; expected array of nodes`);return e}function t5(e){return e.type===`LookaroundAssertion`&&e.kind===`lookahead`}function n5(e){return e.type===`LookaroundAssertion`&&e.kind===`lookbehind`}function $7e(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function e9e(e){return e.trim().replace(/[- _]+/g,`_`).replace(/[A-Z][a-z]+(?=[A-Z])/g,`$&_`).replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}function r5(e){return e.replace(/[- _]+/g,``).toLowerCase()}function i5(e,t){return S8(e,`${t?.type===`Character`&&t.value===93?`Empty`:`Unclosed`} character class`)}function a5(e){return S8(e,`Unclosed group`)}function o5(e,t,n=null){function r(e,t){for(let n=0;n<e.length;n++){let r=i(e[n],t,n,e);n=Math.max(-1,n+r)}}function i(a,o=null,s=null,c=null){let l=0,u=!1,d={node:a,parent:o,key:s,container:c,root:e,remove(){s5(c).splice(Math.max(0,c5(s)+l),1),l--,u=!0},removeAllNextSiblings(){return s5(c).splice(c5(s)+1)},removeAllPrevSiblings(){let e=c5(s)+l;return l-=e,s5(c).splice(0,Math.max(0,e))},replaceWith(e,t={}){let n=!!t.traverse;c?c[Math.max(0,c5(s)+l)]=e:S8(o,`Can't replace root node`)[s]=e,n&&i(e,o,s,c),u=!0},replaceWithMultiple(e,t={}){let n=!!t.traverse;if(s5(c).splice(Math.max(0,c5(s)+l),1,...e),l+=e.length-1,n){let t=0;for(let n=0;n<e.length;n++)t+=i(e[n],o,c5(s)+n+t,c)}u=!0},skip(){u=!0}},{type:f}=a,p=t[`*`],m=t[f],h=typeof p==`function`?p:p?.enter,g=typeof m==`function`?m:m?.enter;if(h?.(d,n),g?.(d,n),!u)switch(f){case`AbsenceFunction`:case`CapturingGroup`:case`Group`:r(a.body,a);break;case`Alternative`:case`CharacterClass`:r(a.body,a);break;case`Assertion`:case`Backreference`:case`Character`:case`CharacterSet`:case`Directive`:case`Flags`:case`NamedCallout`:case`Subroutine`:break;case`CharacterClassRange`:i(a.min,a,`min`),i(a.max,a,`max`);break;case`LookaroundAssertion`:r(a.body,a);break;case`Quantifier`:i(a.body,a,`body`);break;case`Regex`:r(a.body,a),i(a.flags,a,`flags`);break;default:throw Error(`Unexpected node type "${f}"`)}return m?.exit?.(d,n),p?.exit?.(d,n),l}return i(e),e}function s5(e){if(!Array.isArray(e))throw Error(`Container expected`);return e}function c5(e){if(typeof e!=`number`)throw Error(`Numeric key expected`);return e}var t9e=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function n9e(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function r9e(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var l5=Object.freeze({DEFAULT:`DEFAULT`,CHAR_CLASS:`CHAR_CLASS`});function u5(e,t,n,r){let i=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,`gsu`),a=[!1],o=0,s=``;for(let t of e.matchAll(i)){let{0:e,groups:{$skip:i}}=t;if(!i&&(!r||r===l5.DEFAULT==!o)){n instanceof Function?s+=n(t,{context:o?l5.CHAR_CLASS:l5.DEFAULT,negated:a[a.length-1]}):s+=n;continue}e[0]===`[`?(o++,a.push(e[1]===`^`)):e===`]`&&o&&(o--,a.pop()),s+=e}return s}function d5(e,t,n,r){u5(e,t,n,r)}function i9e(e,t,n=0,r){if(!new RegExp(t,`su`).test(e))return null;let i=RegExp(`${t}|(?<$skip>\\\\?.)`,`gsu`);i.lastIndex=n;let a=0,o;for(;o=i.exec(e);){let{0:e,groups:{$skip:t}}=o;if(!t&&(!r||r===l5.DEFAULT==!a))return o;e===`[`?a++:e===`]`&&a&&a--,i.lastIndex==o.index&&i.lastIndex++}return null}function f5(e,t,n){return!!i9e(e,t,0,n)}function a9e(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,i=0,a=1,o;for(;o=n.exec(e);){let[e]=o;if(e===`[`)i++;else if(i)e===`]`&&i--;else if(e===`(`)a++;else if(e===`)`&&(a--,!a)){r=o.index;break}}return e.slice(t,r)}var p5=new RegExp(String.raw`(?<noncapturingStart>${t9e})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,`gsu`);function o9e(e,t){let n=t?.hiddenCaptures??[],r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};let i=[0],a=[],o=0,s=0,c=NaN,l;do{l=!1;let t=0,u=0,d=!1,f;for(p5.lastIndex=Number.isNaN(c)?0:c+7;f=p5.exec(e);){let{0:p,index:m,groups:{capturingStart:h,noncapturingStart:g}}=f;if(p===`[`)t++;else if(t)p===`]`&&t--;else if(p===`(?>`&&!d)c=m,d=!0;else if(d&&g)u++;else if(h)d?u++:(o++,i.push(o+s));else if(p===`)`&&d){if(!u){s++;let t=o+s;if(e=`${e.slice(0,c)}(?:(?=(${e.slice(c+3,m)}))<$$${t}>)${e.slice(m+1)}`,l=!0,a.push(t),n9e(n,t),r.size){let e=new Map;r.forEach((n,r)=>{e.set(r>=t?r+1:r,n.map(e=>e>=t?e+1:e))}),r=e}break}u--}}}while(l);return n.push(...a),e=u5(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:e,groups:{backrefNum:t,wrappedBackrefNum:n}})=>{if(t){let n=+t;if(n>i.length-1)throw Error(`Backref "${e}" greater than number of captures`);return`\\${i[n]}`}return`\\${n}`},l5.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var m5=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,h5=new RegExp(String.raw`
|
|
1073
|
+
`.replace(/\s+/g,``),`gsu`);function y7e(e,t={}){let n={flags:``,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!=`string`)throw Error(`String expected as pattern`);let r=R7e(n.flags),i=[r.extended],a={captureGroup:n.rules.captureGroup,getCurrentModX(){return i.at(-1)},numOpenGroups:0,popModX(){i.pop()},pushModX(e){i.push(e)},replaceCurrentModX(e){i[i.length-1]=e},singleline:n.rules.singleline},o=[],s;for(E8.lastIndex=0;s=E8.exec(e);){let t=b7e(a,e,s[0],E8.lastIndex);t.tokens?o.push(...t.tokens):t.token&&o.push(t.token),t.lastIndex!==void 0&&(E8.lastIndex=t.lastIndex)}let c=[],l=0;o.filter(e=>e.type===`GroupOpen`).forEach(e=>{e.kind===`capturing`?e.number=++l:e.raw===`(`&&c.push(e)}),l||c.forEach((e,t)=>{e.kind=`capturing`,e.number=t+1});let u=l||c.length;return{tokens:o.map(e=>e.type===`EscapedNumber`?B7e(e,u):e).flat(),flags:r}}function b7e(e,t,n,r){let[i,a]=n;if(n===`[`||n===`[^`){let e=x7e(t,n,r);return{tokens:e.tokens,lastIndex:e.lastIndex}}if(i===`\\`){if(`AbBGyYzZ`.includes(a))return{token:k8(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw Error(`Invalid group name "${n}"`);return{token:j7e(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw Error(`Invalid group name "${n}"`);return{token:A8(n)}}if(a===`K`)return{token:P8(`keep`,n)};if(a===`N`||a===`R`)return{token:N8(`newline`,n,{negate:a===`N`})};if(a===`O`)return{token:N8(`any`,n)};if(a===`X`)return{token:N8(`text_segment`,n)};let e=O8(n,{inCharClass:!1});return Array.isArray(e)?{tokens:e}:{token:e}}if(i===`(`){if(a===`*`)return{token:F7e(n)};if(n===`(?{`)throw Error(`Unsupported callout "${n}"`);if(n.startsWith(`(?#`)){if(t[r]!==`)`)throw Error(`Unclosed comment group "(?#"`);return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:P7e(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n===`(`&&!e.captureGroup||n===`(?:`)return{token:F8(`group`,n)};if(n===`(?>`)return{token:F8(`atomic`,n)};if(n===`(?=`||n===`(?!`||n===`(?<=`||n===`(?<!`)return{token:F8(n[2]===`<`?`lookbehind`:`lookahead`,n,{negate:n.endsWith(`!`)})};if(n===`(`&&e.captureGroup||n.startsWith(`(?<`)&&n.endsWith(`>`)||n.startsWith(`(?'`)&&n.endsWith(`'`))return{token:F8(`capturing`,n,{...n!==`(`&&{name:n.slice(3,-1)}})};if(n.startsWith(`(?~`)){if(n===`(?~|`)throw Error(`Unsupported absence function kind "${n}"`);return{token:F8(`absence_repeater`,n)}}throw Error(n===`(?(`?`Unsupported conditional "${n}"`:`Invalid or unsupported group option "${n}"`)}if(n===`)`){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw Error(`Unmatched ")"`);return{token:O7e(n)}}if(e.getCurrentModX()){if(n===`#`){let e=t.indexOf(`
|
|
1074
|
+
`,r);return{lastIndex:e===-1?t.length:e}}if(/^\s$/.test(n)){let e=/\s+/y;return e.lastIndex=r,{lastIndex:e.exec(t)?e.lastIndex:r}}}return n===`.`?{token:N8(`dot`,n)}:n===`^`||n===`$`?{token:k8(e.singleline?{"^":x8`\A`,$:x8`\Z`}[n]:n,n)}:n===`|`?{token:C7e(n)}:T8.test(n)?{tokens:V7e(n)}:{token:j8(y8(n),n)}}function x7e(e,t,n){let r=[M8(t[1]===`^`,t)],i=1,a;for(D8.lastIndex=n;a=D8.exec(e);){let e=a[0];if(e[0]===`[`&&e[1]!==`:`)i++,r.push(M8(e[1]===`^`,e));else if(e===`]`){if(r.at(-1).type===`CharacterClassOpen`)r.push(j8(93,e));else if(i--,r.push(w7e(e)),!i)break}else{let t=S7e(e);Array.isArray(t)?r.push(...t):r.push(t)}}return{tokens:r,lastIndex:D8.lastIndex||e.length}}function S7e(e){if(e[0]===`\\`)return O8(e,{inCharClass:!0});if(e[0]===`[`){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!b8.has(t.groups.name))throw Error(`Invalid POSIX class "${e}"`);return N8(`posix`,e,{value:t.groups.name,negate:!!t.groups.negate})}return e===`-`?T7e(e):e===`&&`?E7e(e):j8(y8(e),e)}function O8(e,{inCharClass:t}){let n=e[1];if(n===`c`||n===`C`)return N7e(e);if(`dDhHsSwW`.includes(n))return I7e(e);if(e.startsWith(x8`\o{`))throw Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw Error(`Incomplete or invalid Unicode property "${e}"`);return L7e(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let t=e.split(/\\x/).slice(1).map(e=>parseInt(e,16)),n=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(t)),r=new TextEncoder;return[...n].map(e=>{let t=[...r.encode(e)].map(e=>`\\x${e.toString(16)}`).join(``);return j8(y8(e),t)})}catch{throw Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n===`u`||n===`x`)return j8(z7e(e),e);if(I8.has(n))return j8(I8.get(n),e);if(/\d/.test(n))return D7e(t,e);if(e===`\\`)throw Error(x8`Incomplete escape "\"`);if(n===`M`)throw Error(`Unsupported meta "${e}"`);if([...e].length===2)return j8(e.codePointAt(1),e);throw Error(`Unexpected escape "${e}"`)}function C7e(e){return{type:`Alternator`,raw:e}}function k8(e,t){return{type:`Assertion`,kind:e,raw:t}}function A8(e){return{type:`Backreference`,raw:e}}function j8(e,t){return{type:`Character`,value:e,raw:t}}function w7e(e){return{type:`CharacterClassClose`,raw:e}}function T7e(e){return{type:`CharacterClassHyphen`,raw:e}}function E7e(e){return{type:`CharacterClassIntersector`,raw:e}}function M8(e,t){return{type:`CharacterClassOpen`,negate:e,raw:t}}function N8(e,t,n={}){return{type:`CharacterSet`,kind:e,...n,raw:t}}function P8(e,t,n={}){return e===`keep`?{type:`Directive`,kind:e,raw:t}:{type:`Directive`,kind:e,flags:S8(n.flags),raw:t}}function D7e(e,t){return{type:`EscapedNumber`,inCharClass:e,raw:t}}function O7e(e){return{type:`GroupClose`,raw:e}}function F8(e,t,n={}){return{type:`GroupOpen`,kind:e,...n,raw:t}}function k7e(e,t,n,r){return{type:`NamedCallout`,kind:e,tag:t,arguments:n,raw:r}}function A7e(e,t,n,r){return{type:`Quantifier`,kind:e,min:t,max:n,raw:r}}function j7e(e){return{type:`Subroutine`,raw:e}}var M7e=new Set([`COUNT`,`CMP`,`ERROR`,`FAIL`,`MAX`,`MISMATCH`,`SKIP`,`TOTAL_COUNT`]),I8=new Map([[`a`,7],[`b`,8],[`e`,27],[`f`,12],[`n`,10],[`r`,13],[`t`,9],[`v`,11]]);function N7e(e){let t=e[1]===`c`?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw Error(`Unsupported control character "${e}"`);return j8(y8(t.toUpperCase())-64,e)}function P7e(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??=``;let i=(t.getCurrentModX()||n.includes(`x`))&&!r.includes(`x`),a=R8(n),o=R8(r),s={};if(a&&(s.enable=a),o&&(s.disable=o),e.endsWith(`)`))return t.replaceCurrentModX(i),P8(`flags`,e,{flags:s});if(e.endsWith(`:`))return t.pushModX(i),t.numOpenGroups++,F8(`group`,e,{...(a||o)&&{flags:s}});throw Error(`Unexpected flag modifier "${e}"`)}function F7e(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw Error(`Incomplete or invalid named callout "${e}"`);let{name:n,tag:r,args:i}=t.groups;if(!n)throw Error(`Invalid named callout "${e}"`);if(r===``)throw Error(`Named callout tag with empty value not allowed "${e}"`);let a=i?i.split(`,`).filter(e=>e!==``).map(e=>/^[+-]?\d+$/.test(e)?+e:e):[],[o,s,c]=a,l=M7e.has(n)?n.toLowerCase():`custom`;switch(l){case`fail`:case`mismatch`:case`skip`:if(a.length>0)throw Error(`Named callout arguments not allowed "${a}"`);break;case`error`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(typeof o==`string`)throw Error(`Named callout argument must be a number "${o}"`);break;case`max`:if(!a.length||a.length>2)throw Error(`Named callout must have one or two arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(a.length===2&&(typeof s==`number`||!/^[<>X]$/.test(s)))throw Error(`Named callout optional argument two must be '<', '>', or 'X' "${s}"`);break;case`count`:case`total_count`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(a.length===1&&(typeof o==`number`||!/^[<>X]$/.test(o)))throw Error(`Named callout optional argument must be '<', '>', or 'X' "${o}"`);break;case`cmp`:if(a.length!==3)throw Error(`Named callout must have three arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(typeof s==`number`||!/^(?:[<>!=]=|[<>])$/.test(s))throw Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${s}"`);if(typeof c==`string`&&!/^[A-Za-z_]\w*$/.test(c))throw Error(`Named callout argument three must be a tag or number "${c}"`);break;case`custom`:throw Error(`Undefined callout name "${n}"`);default:throw Error(`Unexpected named callout kind "${l}"`)}return k7e(l,r??null,i?.split(`,`)??null,e)}function L8(e){let t=null,n,r;if(e[0]===`{`){let{minStr:i,maxStr:a}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,o=1e5;if(+i>o||a&&+a>o)throw Error(`Quantifier value unsupported in Oniguruma`);if(n=+i,r=a===void 0?+i:a===``?1/0:+a,n>r&&(t=`possessive`,[n,r]=[r,n]),e.endsWith(`?`)){if(t===`possessive`)throw Error(`Unsupported possessive interval quantifier chain with "?"`);t=`lazy`}else t||=`greedy`}else n=+(e[0]===`+`),r=e[0]===`?`?1:1/0,t=e[1]===`+`?`possessive`:e[1]===`?`?`lazy`:`greedy`;return A7e(t,n,r,e)}function I7e(e){let t=e[1].toLowerCase();return N8({d:`digit`,h:`hex`,s:`space`,w:`word`}[t],e,{negate:e[1]!==t})}function L7e(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return N8(`property`,e,{value:r,negate:t===`P`&&!n||t===`p`&&!!n})}function R8(e){let t={};return e.includes(`i`)&&(t.ignoreCase=!0),e.includes(`m`)&&(t.dotAll=!0),e.includes(`x`)&&(t.extended=!0),Object.keys(t).length?t:null}function R7e(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){let r=e[n];if(!`imxDPSWy`.includes(r))throw Error(`Invalid flag "${r}"`);if(r===`y`){if(!/^y{[gw]}/.test(e.slice(n)))throw Error(`Invalid or unspecified flag "y" mode`);t.textSegmentMode=e[n+2]===`g`?`grapheme`:`word`,n+=3;continue}t[{i:`ignoreCase`,m:`dotAll`,x:`extended`,D:`digitIsAscii`,P:`posixIsAscii`,S:`spaceIsAscii`,W:`wordIsAscii`}[r]]=!0}return t}function z7e(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw Error(`Incomplete or invalid escape "${e}"`);let t=e[2]===`{`?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function B7e(e,t){let{raw:n,inCharClass:r}=e,i=n.slice(1);if(!r&&(i!==`0`&&i.length===1||i[0]!==`0`&&+i<=t))return[A8(n)];let a=[],o=i.match(/^[0-7]+|\d/g);for(let e=0;e<o.length;e++){let t=o[e],r;if(e===0&&t!==`8`&&t!==`9`){if(r=parseInt(t,8),r>127)throw Error(x8`Octal encoded byte above 177 unsupported "${n}"`)}else r=y8(t);a.push(j8(r,(e===0?`\\`:``)+t))}return a}function V7e(e){let t=[],n=new RegExp(T8,`gy`),r;for(;r=n.exec(e);){let e=r[0];if(e[0]===`{`){let r=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(e);if(r){let{min:i,max:a}=r.groups;if(+i>+a&&e.endsWith(`?`)){n.lastIndex--,t.push(L8(e.slice(0,-1)));continue}}}t.push(L8(e))}return t}function z8(e,t){if(!Array.isArray(e.body))throw Error(`Expected node with body array`);if(e.body.length!==1)return!1;let n=e.body[0];return!t||Object.keys(t).every(e=>t[e]===n[e])}function H7e(e){return U7e.has(e.type)}var U7e=new Set([`AbsenceFunction`,`Backreference`,`CapturingGroup`,`Character`,`CharacterClass`,`CharacterSet`,`Group`,`Quantifier`,`Subroutine`]);function B8(e,t={}){let n={flags:``,normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=y7e(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),i=(e,t)=>{let n=r.tokens[a.nextIndex];switch(a.parent=e,a.nextIndex++,n.type){case`Alternator`:return V8();case`Assertion`:return W7e(n);case`Backreference`:return G7e(n,a);case`Character`:return G8(n.value,{useLastValid:!!t.isCheckingRangeEnd});case`CharacterClassHyphen`:return K7e(n,a,t);case`CharacterClassOpen`:return q7e(n,a,t);case`CharacterSet`:return J7e(n,a);case`Directive`:return e9e(n.kind,{flags:n.flags});case`GroupOpen`:return Y7e(n,a,t);case`NamedCallout`:return n9e(n.kind,n.tag,n.arguments);case`Quantifier`:return X7e(n,a);case`Subroutine`:return Z7e(n,a);default:throw Error(`Unexpected token type "${n.type}"`)}},a={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:i},o=i9e(t9e(r.flags)),s=o.body[0];for(;a.nextIndex<r.tokens.length;){let e=i(s,{});e.type===`Alternative`?(o.body.push(e),s=e):s.body.push(e)}let{capturingGroups:c,hasNumberedRef:l,namedGroupsByName:u,subroutines:d}=a;if(l&&u.size&&!n.rules.captureGroup)throw Error(`Numbered backref/subroutine not allowed when using named capture`);for(let{ref:e}of d)if(typeof e==`number`){if(e>c.length)throw Error(`Subroutine uses a group number that's not defined`);e&&(c[e-1].isSubroutined=!0)}else if(u.has(e)){if(u.get(e).length>1)throw Error(x8`Subroutine uses a duplicate group name "\g<${e}>"`);u.get(e)[0].isSubroutined=!0}else throw Error(x8`Subroutine uses a group name that's not defined "\g<${e}>"`);return o}function W7e({kind:e}){return H8(S8({"^":`line_start`,$:`line_end`,"\\A":`string_start`,"\\b":`word_boundary`,"\\B":`word_boundary`,"\\G":`search_start`,"\\y":`text_segment_boundary`,"\\Y":`text_segment_boundary`,"\\z":`string_end`,"\\Z":`string_end_newline`}[e],`Unexpected assertion kind "${e}"`),{negate:e===x8`\B`||e===x8`\Y`})}function G7e({raw:e},t){let n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),i=(n,r=!1)=>{let i=t.capturingGroups.length,a=!1;if(n>i)if(t.skipBackrefValidation)a=!0;else throw Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,U8(r?i+1-n:n,{orphan:a})};if(n){let n=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(n)return i(+n.groups.num,!!n.groups.sign);if(/[-+]/.test(r))throw Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw Error(`Group name not defined to the left "${e}"`);return U8(r)}return i(+r)}function K7e(e,t,n){let{tokens:r,walk:i}=t,a=t.parent,o=a.body.at(-1),s=r[t.nextIndex];if(!n.isCheckingRangeEnd&&o&&o.type!==`CharacterClass`&&o.type!==`CharacterClassRange`&&s&&s.type!==`CharacterClassOpen`&&s.type!==`CharacterClassClose`&&s.type!==`CharacterClassIntersector`){let e=i(a,{...n,isCheckingRangeEnd:!0});if(o.type===`Character`&&e.type===`Character`)return a.body.pop(),$7e(o,e);throw Error(`Invalid character class range`)}return G8(y8(`-`))}function q7e({negate:e},t,n){let{tokens:r,walk:i}=t,a=r[t.nextIndex],o=[K8()],s=i5(a);for(;s.type!==`CharacterClassClose`;){if(s.type===`CharacterClassIntersector`)o.push(K8()),t.nextIndex++;else{let e=o.at(-1);e.body.push(i(e,n))}s=i5(r[t.nextIndex],a)}let c=K8({negate:e});return o.length===1?c.body=o[0].body:(c.kind=`intersection`,c.body=o.map(e=>e.body.length===1?e.body[0]:e)),t.nextIndex++,c}function J7e({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o}=r;if(e===`property`){let r=r5(n);if(b8.has(r)&&!o?.has(r))e=`posix`,n=r;else return Q8(n,{negate:t,normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o})}return e===`posix`?r9e(n,{negate:t}):q8(e,{negate:t})}function Y7e(e,t,n){let{tokens:r,capturingGroups:i,namedGroupsByName:a,skipLookbehindValidation:o,walk:s}=t,c=a9e(e),l=c.type===`AbsenceFunction`,u=n5(c),d=u&&c.negate;if(c.type===`CapturingGroup`&&(i.push(c),c.name&&v7e(a,c.name,[]).push(c)),l&&n.isInAbsenceFunction)throw Error(`Nested absence function not supported by Oniguruma`);let f=a5(r[t.nextIndex]);for(;f.type!==`GroupClose`;){if(f.type===`Alternator`)c.body.push(V8()),t.nextIndex++;else{let e=c.body.at(-1),t=s(e,{...n,isInAbsenceFunction:n.isInAbsenceFunction||l,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||d});if(e.body.push(t),(u||n.isInLookbehind)&&!o){let e=`Lookbehind includes a pattern not allowed by Oniguruma`;if(d||n.isInNegLookbehind){if(t5(t)||t.type===`CapturingGroup`)throw Error(e)}else if(t5(t)||n5(t)&&t.negate)throw Error(e)}}f=a5(r[t.nextIndex])}return t.nextIndex++,c}function X7e({kind:e,min:t,max:n},r){let i=r.parent,a=i.body.at(-1);if(!a||!H7e(a))throw Error(`Quantifier requires a repeatable token`);let o=X8(e,t,n,a);return i.body.pop(),o}function Z7e({raw:e},t){let{capturingGroups:n,subroutines:r}=t,i=e.slice(3,-1),a=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i);if(a){let e=+a.groups.num,r=n.length;if(t.hasNumberedRef=!0,i={"":e,"+":r+e,"-":r+1-e}[a.groups.sign],i<1)throw Error(`Invalid subroutine number`)}else i===`0`&&(i=0);let o=Z8(i);return r.push(o),o}function Q7e(e,t){if(e!==`repeater`)throw Error(`Unexpected absence function kind "${e}"`);return{type:`AbsenceFunction`,kind:e,body:$8(t?.body)}}function V8(e){return{type:`Alternative`,body:e5(e?.body)}}function H8(e,t){let n={type:`Assertion`,kind:e};return(e===`word_boundary`||e===`text_segment_boundary`)&&(n.negate=!!t?.negate),n}function U8(e,t){let n=!!t?.orphan;return{type:`Backreference`,ref:e,...n&&{orphan:n}}}function W8(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!o9e(n.name))throw Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:`CapturingGroup`,number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:$8(t?.body)}}function G8(e,t){let n={useLastValid:!1,...t};if(e>1114111){let t=e.toString(16);if(n.useLastValid)e=1114111;else throw Error(e>1310719?`Invalid code point out of range "\\x{${t}}"`:`Invalid code point out of range in JS "\\x{${t}}"`)}return{type:`Character`,value:e}}function K8(e){let t={kind:`union`,negate:!1,...e};return{type:`CharacterClass`,kind:t.kind,negate:t.negate,body:e5(e?.body)}}function $7e(e,t){if(t.value<e.value)throw Error(`Character class range out of order`);return{type:`CharacterClassRange`,min:e,max:t}}function q8(e,t){let n=!!t?.negate,r={type:`CharacterSet`,kind:e};return(e===`digit`||e===`hex`||e===`newline`||e===`space`||e===`word`)&&(r.negate=n),(e===`text_segment`||e===`newline`&&!n)&&(r.variableLength=!0),r}function e9e(e,t={}){if(e===`keep`)return{type:`Directive`,kind:e};if(e===`flags`)return{type:`Directive`,kind:e,flags:S8(t.flags)};throw Error(`Unexpected directive kind "${e}"`)}function t9e(e){return{type:`Flags`,...e}}function J8(e){let t=e?.atomic,n=e?.flags;if(t&&n)throw Error(`Atomic group cannot have flags`);return{type:`Group`,...t&&{atomic:t},...n&&{flags:n},body:$8(e?.body)}}function Y8(e){let t={behind:!1,negate:!1,...e};return{type:`LookaroundAssertion`,kind:t.behind?`lookbehind`:`lookahead`,negate:t.negate,body:$8(e?.body)}}function n9e(e,t,n){return{type:`NamedCallout`,kind:e,tag:t,arguments:n}}function r9e(e,t){let n=!!t?.negate;if(!b8.has(e))throw Error(`Invalid POSIX class "${e}"`);return{type:`CharacterSet`,kind:`posix`,value:e,negate:n}}function X8(e,t,n,r){if(t>n)throw Error(`Invalid reversed quantifier range`);return{type:`Quantifier`,kind:e,min:t,max:n,body:r}}function i9e(e,t){return{type:`Regex`,body:$8(t?.body),flags:e}}function Z8(e){return{type:`Subroutine`,ref:e}}function Q8(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(r5(e));if(!r){if(n.normalizeUnknownPropertyNames)r=s9e(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw Error(x8`Invalid Unicode property "\p{${e}}"`)}return{type:`CharacterSet`,kind:`property`,value:r??e,negate:n.negate}}function a9e({flags:e,kind:t,name:n,negate:r,number:i}){switch(t){case`absence_repeater`:return Q7e(`repeater`);case`atomic`:return J8({atomic:!0});case`capturing`:return W8(i,{name:n});case`group`:return J8({flags:e});case`lookahead`:case`lookbehind`:return Y8({behind:t===`lookbehind`,negate:r});default:throw Error(`Unexpected group kind "${t}"`)}}function $8(e){if(e===void 0)e=[V8()];else if(!Array.isArray(e)||!e.length||!e.every(e=>e.type===`Alternative`))throw Error(`Invalid body; expected array of one or more Alternative nodes`);return e}function e5(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(e=>!!e.type))throw Error(`Invalid body; expected array of nodes`);return e}function t5(e){return e.type===`LookaroundAssertion`&&e.kind===`lookahead`}function n5(e){return e.type===`LookaroundAssertion`&&e.kind===`lookbehind`}function o9e(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function s9e(e){return e.trim().replace(/[- _]+/g,`_`).replace(/[A-Z][a-z]+(?=[A-Z])/g,`$&_`).replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}function r5(e){return e.replace(/[- _]+/g,``).toLowerCase()}function i5(e,t){return S8(e,`${t?.type===`Character`&&t.value===93?`Empty`:`Unclosed`} character class`)}function a5(e){return S8(e,`Unclosed group`)}function o5(e,t,n=null){function r(e,t){for(let n=0;n<e.length;n++){let r=i(e[n],t,n,e);n=Math.max(-1,n+r)}}function i(a,o=null,s=null,c=null){let l=0,u=!1,d={node:a,parent:o,key:s,container:c,root:e,remove(){s5(c).splice(Math.max(0,c5(s)+l),1),l--,u=!0},removeAllNextSiblings(){return s5(c).splice(c5(s)+1)},removeAllPrevSiblings(){let e=c5(s)+l;return l-=e,s5(c).splice(0,Math.max(0,e))},replaceWith(e,t={}){let n=!!t.traverse;c?c[Math.max(0,c5(s)+l)]=e:S8(o,`Can't replace root node`)[s]=e,n&&i(e,o,s,c),u=!0},replaceWithMultiple(e,t={}){let n=!!t.traverse;if(s5(c).splice(Math.max(0,c5(s)+l),1,...e),l+=e.length-1,n){let t=0;for(let n=0;n<e.length;n++)t+=i(e[n],o,c5(s)+n+t,c)}u=!0},skip(){u=!0}},{type:f}=a,p=t[`*`],m=t[f],h=typeof p==`function`?p:p?.enter,g=typeof m==`function`?m:m?.enter;if(h?.(d,n),g?.(d,n),!u)switch(f){case`AbsenceFunction`:case`CapturingGroup`:case`Group`:r(a.body,a);break;case`Alternative`:case`CharacterClass`:r(a.body,a);break;case`Assertion`:case`Backreference`:case`Character`:case`CharacterSet`:case`Directive`:case`Flags`:case`NamedCallout`:case`Subroutine`:break;case`CharacterClassRange`:i(a.min,a,`min`),i(a.max,a,`max`);break;case`LookaroundAssertion`:r(a.body,a);break;case`Quantifier`:i(a.body,a,`body`);break;case`Regex`:r(a.body,a),i(a.flags,a,`flags`);break;default:throw Error(`Unexpected node type "${f}"`)}return m?.exit?.(d,n),p?.exit?.(d,n),l}return i(e),e}function s5(e){if(!Array.isArray(e))throw Error(`Container expected`);return e}function c5(e){if(typeof e!=`number`)throw Error(`Numeric key expected`);return e}var c9e=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function l9e(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function u9e(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var l5=Object.freeze({DEFAULT:`DEFAULT`,CHAR_CLASS:`CHAR_CLASS`});function u5(e,t,n,r){let i=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,`gsu`),a=[!1],o=0,s=``;for(let t of e.matchAll(i)){let{0:e,groups:{$skip:i}}=t;if(!i&&(!r||r===l5.DEFAULT==!o)){n instanceof Function?s+=n(t,{context:o?l5.CHAR_CLASS:l5.DEFAULT,negated:a[a.length-1]}):s+=n;continue}e[0]===`[`?(o++,a.push(e[1]===`^`)):e===`]`&&o&&(o--,a.pop()),s+=e}return s}function d5(e,t,n,r){u5(e,t,n,r)}function d9e(e,t,n=0,r){if(!new RegExp(t,`su`).test(e))return null;let i=RegExp(`${t}|(?<$skip>\\\\?.)`,`gsu`);i.lastIndex=n;let a=0,o;for(;o=i.exec(e);){let{0:e,groups:{$skip:t}}=o;if(!t&&(!r||r===l5.DEFAULT==!a))return o;e===`[`?a++:e===`]`&&a&&a--,i.lastIndex==o.index&&i.lastIndex++}return null}function f5(e,t,n){return!!d9e(e,t,0,n)}function f9e(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,i=0,a=1,o;for(;o=n.exec(e);){let[e]=o;if(e===`[`)i++;else if(i)e===`]`&&i--;else if(e===`(`)a++;else if(e===`)`&&(a--,!a)){r=o.index;break}}return e.slice(t,r)}var p5=new RegExp(String.raw`(?<noncapturingStart>${c9e})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,`gsu`);function p9e(e,t){let n=t?.hiddenCaptures??[],r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};let i=[0],a=[],o=0,s=0,c=NaN,l;do{l=!1;let t=0,u=0,d=!1,f;for(p5.lastIndex=Number.isNaN(c)?0:c+7;f=p5.exec(e);){let{0:p,index:m,groups:{capturingStart:h,noncapturingStart:g}}=f;if(p===`[`)t++;else if(t)p===`]`&&t--;else if(p===`(?>`&&!d)c=m,d=!0;else if(d&&g)u++;else if(h)d?u++:(o++,i.push(o+s));else if(p===`)`&&d){if(!u){s++;let t=o+s;if(e=`${e.slice(0,c)}(?:(?=(${e.slice(c+3,m)}))<$$${t}>)${e.slice(m+1)}`,l=!0,a.push(t),l9e(n,t),r.size){let e=new Map;r.forEach((n,r)=>{e.set(r>=t?r+1:r,n.map(e=>e>=t?e+1:e))}),r=e}break}u--}}}while(l);return n.push(...a),e=u5(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:e,groups:{backrefNum:t,wrappedBackrefNum:n}})=>{if(t){let n=+t;if(n>i.length-1)throw Error(`Backref "${e}" greater than number of captures`);return`\\${i[n]}`}return`\\${n}`},l5.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var m5=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,h5=new RegExp(String.raw`
|
|
1075
1075
|
\\(?: \d+
|
|
1076
1076
|
| c[A-Za-z]
|
|
1077
1077
|
| [gk]<[^>]+>
|
|
@@ -1086,7 +1086,7 @@ If init has been called in the preload and contextIsolation is disabled, is not
|
|
|
1086
1086
|
))?
|
|
1087
1087
|
| (?<qBase>${m5})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
1088
1088
|
| \\?.
|
|
1089
|
-
`.replace(/\s+/g,``),`gsu`);function
|
|
1089
|
+
`.replace(/\s+/g,``),`gsu`);function m9e(e){if(!RegExp(`${m5}\\+`).test(e))return{pattern:e};let t=[],n=null,r=null,i=``,a=0,o;for(h5.lastIndex=0;o=h5.exec(e);){let{0:s,index:c,groups:{qBase:l,qMod:u,invalidQ:d}}=o;if(s===`[`)a||(r=c),a++;else if(s===`]`)a?a--:r=null;else if(!a)if(u===`+`&&i&&!i.startsWith(`(`)){if(d)throw Error(`Invalid quantifier "${s}"`);let t=-1;if(/^\{\d+\}$/.test(l))e=u9e(e,c+l.length,u,``);else{if(i===`)`||i===`]`){let t=i===`)`?n:r;if(t===null)throw Error(`Invalid unmatched "${i}"`);e=`${e.slice(0,t)}(?>${e.slice(t,c)}${l})${e.slice(c+s.length)}`}else e=`${e.slice(0,c-i.length)}(?>${i}${l})${e.slice(c+s.length)}`;t+=4}h5.lastIndex+=t}else s[0]===`(`?t.push(c):s===`)`&&(n=t.length?t.pop():null);i=s}return{pattern:e}}var g5=String.raw,_5=g5`\(\?R=(?<rDepth>[^\)]+)\)|${g5`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`}`,v5=g5`\(\?<(?![=!])(?<captureName>[^>]+)>`,y5=g5`${v5}|(?<unnamed>\()(?!\?)`,b5=new RegExp(g5`${v5}|${_5}|\(\?|\\?.`,`gsu`),x5=`Cannot use multiple overlapping recursions`;function h9e(e,t){let{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:`plugin`,...t},i=t?.captureTransfers??new Map;if(!new RegExp(_5,`su`).test(e))return{pattern:e,captureTransfers:i,hiddenCaptures:n};if(r===`plugin`&&f5(e,g5`\(\?\(DEFINE\)`,l5.DEFAULT))throw Error(`DEFINE groups cannot be used with recursion`);let a=[],o=f5(e,g5`\\[1-9]`,l5.DEFAULT),s=new Map,c=[],l=!1,u=0,d=0,f;for(b5.lastIndex=0;f=b5.exec(e);){let{0:t,groups:{captureName:p,rDepth:m,gRNameOrNum:h,gRDepth:g}}=f;if(t===`[`)u++;else if(u)t===`]`&&u--;else{if(m){if(S5(m),l)throw Error(x5);if(o)throw Error(`${r===`external`?`Backrefs`:`Numbered backrefs`} cannot be used with global recursion`);let t=e.slice(0,f.index),s=e.slice(b5.lastIndex);if(f5(s,_5,l5.DEFAULT))throw Error(x5);let c=m-1;e=C5(t,s,c,!1,n,a,d),i=T5(i,t,c,a.length,0,d);break}if(h){S5(g);let u=!1;for(let e of c)if(e.name===h||e.num===+h){if(u=!0,e.hasRecursedWithin)throw Error(x5);break}if(!u)throw Error(g5`Recursive \g cannot be used outside the referenced group "${r===`external`?h:g5`\g<${h}&R=${g}>`}"`);let p=s.get(h),m=f9e(e,p);if(o&&f5(m,g5`${v5}|\((?!\?)`,l5.DEFAULT))throw Error(`${r===`external`?`Backrefs`:`Numbered backrefs`} cannot be used with recursion of capturing groups`);let _=e.slice(p,f.index),v=m.slice(_.length+t.length),y=a.length,b=g-1,x=C5(_,v,b,!0,n,a,d);i=T5(i,_,b,a.length-y,y,d),e=`${e.slice(0,p)}${x}${e.slice(p+m.length)}`,b5.lastIndex+=x.length-t.length-_.length-v.length,c.forEach(e=>e.hasRecursedWithin=!0),l=!0}else if(p)d++,s.set(String(d),b5.lastIndex),s.set(p,b5.lastIndex),c.push({num:d,name:p});else if(t[0]===`(`){let e=t===`(`;e&&(d++,s.set(String(d),b5.lastIndex)),c.push(e?{num:d}:{})}else t===`)`&&c.pop()}}return n.push(...a),{pattern:e,captureTransfers:i,hiddenCaptures:n}}function S5(e){let t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e)||(e=+e,e<2||e>100))throw Error(t)}function C5(e,t,n,r,i,a,o){let s=new Set;r&&d5(e+t,v5,({groups:{captureName:e}})=>{s.add(e)},l5.DEFAULT);let c=[n,r?s:null,i,a,o];return`${e}${w5(`(?:${e}`,`forward`,...c)}(?:)${w5(`${t})`,`backward`,...c)}${t}`}function w5(e,t,n,r,i,a,o){let s=e=>t===`forward`?e+2:n-e+2-1,c=``;for(let t=0;t<n;t++){let n=s(t);c+=u5(e,g5`${y5}|\\k<(?<backref>[^>]+)>`,({0:e,groups:{captureName:t,unnamed:s,backref:c}})=>{if(c&&r&&!r.has(c))return e;let l=`_$${n}`;if(s||t){let n=o+a.length+1;return a.push(n),g9e(i,n),s?e:`(?<${t}${l}>`}return g5`\k<${c}${l}>`},l5.DEFAULT)}return c}function g9e(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function T5(e,t,n,r,i,a){if(e.size&&r){let o=0;d5(t,y5,()=>o++,l5.DEFAULT);let s=a-o+i,c=new Map;return e.forEach((e,t)=>{let i=(r-o*n)/n,a=o*n,l=t>s+o?t+r:t,u=[];for(let t of e)if(t<=s)u.push(t);else if(t>s+o+i)u.push(t+r);else if(t<=s+o)for(let e=0;e<=n;e++)u.push(t+o*e);else for(let e=0;e<=n;e++)u.push(t+a+i*e);c.set(l,u)}),c}return e}var E5=String.fromCodePoint,D5=String.raw,O5={},k5=globalThis.RegExp;O5.flagGroups=(()=>{try{new k5(`(?i:)`)}catch{return!1}return!0})(),O5.unicodeSets=(()=>{try{new k5(`[[]]`,`v`)}catch{return!1}return!0})(),O5.bugFlagVLiteralHyphenIsRange=O5.unicodeSets?(()=>{try{new k5(D5`[\d\-a]`,`v`)}catch{return!0}return!1})():!1,O5.bugNestedClassIgnoresNegation=O5.unicodeSets&&new k5(`[[^a]]`,`v`).test(`a`);function A5(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function j5(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function M5(e,t){return N5[e]>=N5[t]}function _9e(e,t){if(e==null)throw Error(t??`Value expected`);return e}var N5={ES2025:2025,ES2024:2024,ES2018:2018},v9e={auto:`auto`,ES2025:`ES2025`,ES2024:`ES2024`,ES2018:`ES2018`};function P5(e={}){if({}.toString.call(e)!==`[object Object]`)throw Error(`Unexpected options`);if(e.target!==void 0&&!v9e[e.target])throw Error(`Unexpected target "${e.target}"`);let t={accuracy:`default`,avoidSubclass:!1,flags:``,global:!1,hasIndices:!1,lazyCompileLength:1/0,target:`auto`,verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target===`auto`&&(t.target=O5.flagGroups?`ES2025`:O5.unicodeSets?`ES2024`:`ES2018`),t}var y9e=`[ -\r ]`,b9e=new Set([E5(304),E5(305)]),F5=D5`[\p{L}\p{M}\p{N}\p{Pc}]`;function I5(e){if(b9e.has(e))return[e];let t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),i=C9e.get(n),a=x9e.get(n),o=S9e.get(n);return[...r].length===1&&t.add(r),o&&t.add(o),i&&t.add(i),t.add(n),a&&t.add(a),[...t]}var L5=new Map(`C Other
|
|
1090
1090
|
Cc Control cntrl
|
|
1091
1091
|
Cf Format
|
|
1092
1092
|
Cn Unassigned
|
|
@@ -1176,18 +1176,18 @@ Uppercase Upper
|
|
|
1176
1176
|
Variation_Selector VS
|
|
1177
1177
|
White_Space space
|
|
1178
1178
|
XID_Continue XIDC
|
|
1179
|
-
XID_Start XIDS`.split(/\s/).map(e=>[r5(e),e])),
|
|
1179
|
+
XID_Start XIDS`.split(/\s/).map(e=>[r5(e),e])),x9e=new Map([[`s`,E5(383)],[E5(383),`s`]]),S9e=new Map([[E5(223),E5(7838)],[E5(107),E5(8490)],[E5(229),E5(8491)],[E5(969),E5(8486)]]),C9e=new Map([R5(453),R5(456),R5(459),R5(498),...z5(8072,8079),...z5(8088,8095),...z5(8104,8111),R5(8124),R5(8140),R5(8188)]),w9e=new Map([[`alnum`,D5`[\p{Alpha}\p{Nd}]`],[`alpha`,D5`\p{Alpha}`],[`ascii`,D5`\p{ASCII}`],[`blank`,D5`[\p{Zs}\t]`],[`cntrl`,D5`\p{Cc}`],[`digit`,D5`\p{Nd}`],[`graph`,D5`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],[`lower`,D5`\p{Lower}`],[`print`,D5`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],[`punct`,D5`[\p{P}\p{S}]`],[`space`,D5`\p{space}`],[`upper`,D5`\p{Upper}`],[`word`,D5`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],[`xdigit`,D5`\p{AHex}`]]);function T9e(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function R5(e){let t=E5(e);return[t.toLowerCase(),t]}function z5(e,t){return T9e(e,t).map(e=>R5(e))}var B5=new Set([`Lower`,`Lowercase`,`Upper`,`Uppercase`,`Ll`,`Lowercase_Letter`,`Lt`,`Titlecase_Letter`,`Lu`,`Uppercase_Letter`]);function E9e(e,t){let n={accuracy:`default`,asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:`ES2025`,...t};V5(e);let r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:M5(n.bestEffortTarget,`ES2024`),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};o5(e,D9e,r);let i={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},a={currentFlags:i,prevFlags:null,globalFlags:i,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};return o5(e,O9e,a),o5(e,k9e,{groupsByName:a.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:a.reffedNodesByReferencer}),e._originMap=a.groupOriginByCopy,e._strategy=r.strategy,e}var D9e={AbsenceFunction({node:e,parent:t,replaceWith:n}){let{body:r,kind:i}=e;if(i===`repeater`){let e=J8();e.body[0].body.push(Y8({negate:!0,body:r}),Q8(`Any`));let i=J8();i.body[0].body.push(X8(`greedy`,0,1/0,e)),n($5(i,t),{traverse:!0})}else throw Error(`Unsupported absence function "(?~|"`)},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){let i=e.body.filter(e=>e.kind===`flags`);for(let e=n+1;e<t.body.length;e++){let n=t.body[e];j5(r,n,[]).push(...i)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=G5(t.get(e));if(n){let t=J8({flags:n});t.body[0].body=e.body,e.body=[$5(t,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:i,remove:a,replaceWith:o},s){let{kind:c,negate:l}=e,{asciiWordBoundaries:u,avoidSubclass:d,supportedGNodes:f,wordIsAscii:p}=s;if(c===`text_segment_boundary`)throw Error(`Unsupported text segment boundary "\\${l?`Y`:`y`}"`);if(c===`line_end`)o($5(Y8({body:[V8({body:[H8(`string_end`)]}),V8({body:[G8(10)]})]}),t));else if(c===`line_start`)o($5(X5(D5`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(c===`search_start`)if(f.has(e))i.flags.sticky=!0,a();else{let e=r[n-1];if(e&&F9e(e))o($5(Y8({negate:!0}),t));else if(d)throw Error(D5`Uses "\G" in a way that requires a subclass`);else o(Q5(H8(`string_start`),t)),s.strategy=`clip_search`}else if(c!==`string_end`&&c!==`string_start`)if(c===`string_end_newline`)o($5(X5(D5`(?=\n?\z)`),t));else if(c===`word_boundary`){if(!p&&!u){let e=`(?:(?<=${F5})(?!${F5})|(?<!${F5})(?=${F5}))`,n=`(?:(?<=${F5})(?=${F5})|(?<!${F5})(?!${F5}))`;o($5(X5(l?n:e),t))}}else throw Error(`Unexpected assertion kind "${c}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!Y5(n)&&(n=W5(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Y5(r)&&(r=W5(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){t.kind===`intersection`&&n($5(K8({body:[e]}),t),{traverse:!0})},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:i,digitIsAscii:a,spaceIsAscii:o,wordIsAscii:s}){let{kind:c,negate:l,value:u}=e;if(a&&(c===`digit`||u===`digit`)){n(Q5(q8(`digit`,{negate:l}),t));return}if(o&&(c===`space`||u===`space`)){n($5(Z5(X5(y9e),l),t));return}if(s&&(c===`word`||u===`word`)){n(Q5(q8(`word`,{negate:l}),t));return}if(c===`any`)n(Q5(Q8(`Any`),t));else if(c===`digit`)n(Q5(Q8(`Nd`,{negate:l}),t));else if(c!==`dot`)if(c===`text_segment`){if(r===`strict`)throw Error(D5`Use of "\X" requires non-strict accuracy`);let e=`\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?`,a=D5`\p{RI}{2}|${e}(?:\u200D${e})*`;n($5(X5(D5`(?>\r\n|${i?D5`\p{RGI_Emoji}`:a}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(c===`hex`)n(Q5(Q8(`AHex`,{negate:l}),t));else if(c===`newline`)n($5(X5(l?`[^
|
|
1180
1180
|
]`:`(?>\r
|
|
1181
1181
|
?|[
|
|
1182
|
-
\v\f
\u2028\u2029])`),t));else if(c===`posix`)if(!i&&(u===`graph`||u===`print`)){if(r===`strict`)throw Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:`!-~`,print:` -~`}[u];l&&(e=`\0-${E5(e.codePointAt(0)-1)}${E5(e.codePointAt(2)+1)}-\u{10FFFF}`),n($5(X5(`[${e}]`),t))}else n($5(Z5(X5(_9e.get(u)),l),t));else if(c===`property`)L5.has(r5(u))||(e.key=`sc`);else if(c===`space`)n(Q5(Q8(`space`,{negate:l}),t));else if(c===`word`)n($5(Z5(X5(F5),l),t));else throw Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:o}){let{kind:s,flags:c}=e;if(s===`flags`)if(!c.enable&&!c.disable)r();else{let e=J8({flags:c});e.body[0].body=o(),i($5(e,t),{traverse:!0})}else if(s===`keep`){let e=n.body[0],r=n.body.length===1&&z8(e,{type:`Group`})&&e.body[0].body.length===1?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error(D5`Uses "\K" in a way that's unsupported`);let o=Y8({behind:!0});o.body[0].body=a(),i($5(o,t))}else throw Error(`Unexpected directive kind "${s}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error(`Unsupported flag "P"`);if(e.textSegmentMode===`word`)throw Error(`Unsupported flag "y{w}"`);[`digitIsAscii`,`extended`,`posixIsAscii`,`spaceIsAscii`,`wordIsAscii`,`textSegmentMode`].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n===`lookbehind`&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r===`fail`)n($5(Y8({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type===`Quantifier`){let t=J8();t.body[0].body.push(e.body),e.body=$5(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(t.body.length===1&&t.body[0].kind===`search_start`)t.body.pop();else{let e=q5(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t===`strict`&&n&&r)throw Error(D5`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!Y5(n)&&(n=W5(n,t),e.ref=n)}},x9e={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:o,openRefs:s,reffedNodesByReferencer:c}){let l=i.get(e);if(l&&s.has(e.number)){let r=Q5(U5(e.number),t);c.set(r,s.get(e.number)),n(r);return}s.set(e.number,e),o.set(e.number,[]),e.name&&j5(o,e.name,[]);let u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){let n=u[t];if(l===n.node||l&&l===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:l}),e.name&&o.get(e.name).push({node:e,origin:l}),e.name){let t=j5(a,e.name,new Map),n=!1;if(l)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=A5(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:a}=e;if(i){let n=t;for(;(n=n.parent)&&(n.type!==`CapturingGroup`||n.name!==a&&n.number!==a););r.reffedNodesByReferencer.set(e,n);return}let o=r.subroutineRefMap.get(a),s=a===0,c=s?U5(0):H5(o,r.groupOriginByCopy,null),l=c;if(!s){let e=G5(T9e(o,e=>e.type===`Group`&&!!e.flags)),t=e?A5(r.globalFlags,e):r.globalFlags;C9e(t,r.currentFlags)||(l=J8({flags:E9e(t)}),l.body[0].body.push(c))}n($5(l,t),{traverse:!s})}},S9e={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>w9e(t,e));i.length?i.length>1?n($5(J8({atomic:!0,body:i.reverse().map(e=>V8({body:[U8(e.number)]}))}),t)):e.ref=i[0].number:n($5(Y8({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=W8();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function V5(e){o5(e,{"*"({node:e,parent:t}){e.parent=t}})}function C9e(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function w9e(e,t){let n=t;do{if(n.type===`Regex`)return!1;if(n.type===`Alternative`)continue;if(n===e)return!1;let t=K5(n.parent);for(let r of t){if(r===n)break;if(r===e||J5(r,e))return!0}}while(n=n.parent);throw Error(`Unexpected path`)}function H5(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a===`parent`?i.parent=Array.isArray(n)?r:n:o&&typeof o==`object`?i[a]=H5(o,t,i,n):(a===`type`&&o===`CapturingGroup`&&t.set(i,t.get(e)??e),i[a]=o);return i}function U5(e){let t=Z8(e);return t.isRecursive=!0,t}function T9e(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function W5(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,`_`)}`;return t.set(e,n),n}function G5(e){let t=[`dotAll`,`ignoreCase`],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function E9e({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function K5(e){if(!e)throw Error(`Node expected`);let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function q5(e){let t=e.find(e=>e.kind===`search_start`||k9e(e,{negate:!1})||!D9e(e));if(!t)return null;if(t.kind===`search_start`)return t;if(t.type===`LookaroundAssertion`)return t.body[0].body[0];if(t.type===`CapturingGroup`||t.type===`Group`){let e=[];for(let n of t.body){let t=q5(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function J5(e,t){let n=K5(e)??[];for(let e of n)if(e===t||J5(e,t))return!0;return!1}function D9e({type:e}){return e===`Assertion`||e===`Directive`||e===`LookaroundAssertion`}function O9e(e){let t=[`Character`,`CharacterClass`,`CharacterSet`];return t.includes(e.type)||e.type===`Quantifier`&&e.min&&t.includes(e.body.type)}function k9e(e,t){let n={negate:null,...t};return e.type===`LookaroundAssertion`&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&z8(e.body[0],{type:`Assertion`,kind:`search_start`})}function Y5(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function X5(e,t){let n=B8(e,{...t,unicodePropertyMap:L5}).body;return n.length>1||n[0].body.length>1?J8({body:n}):n[0].body[0]}function Z5(e,t){return e.negate=t,e}function Q5(e,t){return e.parent=t,e}function $5(e,t){return V5(e),e.parent=t,e}function A9e(e,t){let n=P5(t),r=M5(n.target,`ES2024`),i=M5(n.target,`ES2025`),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error(`Invalid recursionLimit; use 2-20`);let o=null,s=null;if(!i){let t=[e.flags.ignoreCase];o5(e,j9e,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:s=!0}})}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!s)},l=e,u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&o&&s),useFlagMods:i,useFlagV:r,verbose:n.verbose};function d(e){return u.lastNode=l,l=e,u9e(M9e[e.type],`Unexpected node type "${e.type}"`)(e,u,d)}let f={pattern:e.body.map(d).join(`|`),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&f._hiddenCaptures.push(t),e.transferTo&&j5(f._captureTransfers,e.transferTo,[]).push(t)}),f}var j9e={"*":{enter({node:e},t){if(i7(e)){let n=t.getCurrentModI();t.pushModI(e.flags?A5({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){i7(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){t7(E5(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),n7(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===`property`&&B5.has(e.value)&&t.setHasCasedChar()}},M9e={Alternative({body:e},t,n){return e.map(n).join(``)},Assertion({kind:e,negate:t}){if(e===`string_end`)return`$`;if(e===`string_start`)return`^`;if(e===`word_boundary`)return t?D5`\B`:D5`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!=`number`)throw Error(`Unexpected named backref in transformed AST`);if(!t.useFlagMods&&t.accuracy===`strict`&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error(`Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy`);return`\\`+e},CapturingGroup(e,t,n){let{body:r,name:i,number:a}=e,o={ignoreCase:t.currentFlags.ignoreCase},s=t.originMap.get(e);return s&&(o.hidden=!0,a>s.number&&(o.transferTo=s.number)),t.captureMap.set(a,o),`(${i?`?<${i}>`:``}${r.map(n).join(`|`)})`},Character({value:e},t){let n=E5(e),r=r7(e,{escDigit:t.lastNode.type===`Backreference`,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&t7(n)){let e=I5(n);return t.inCharClass?e.join(``):e.length>1?`[${e.join(``)}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:a}=e,{body:o}=e;if(r===`intersection`&&!t.useFlagV)throw Error(`Use of character class intersection requires min target ES2024`);O5.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(a7)&&(o=[G8(45),...o.filter(e=>!a7(e))]);let s=()=>`[${i?`^`:``}${o.map(n).join(r===`intersection`?`&&`:``)}]`;if(!t.inCharClass){if((!t.useFlagV||O5.bugNestedClassIgnoresNegation)&&!i){let t=o.filter(e=>e.type===`CharacterClass`&&e.kind===`union`&&e.negate);if(t.length){let r=J8(),i=r.body[0];return r.parent=a,i.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=V8({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=s();return t.inCharClass=!1,r}let c=o[0];if(r===`union`&&!i&&c&&((!t.useFlagV||!t.verbose)&&a.kind===`union`&&!(O5.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind===`intersection`&&o.length===1&&c.type!==`CharacterClassRange`))return o.map(n).join(``);if(!t.useFlagV&&a.type===`CharacterClass`)throw Error(`Uses nested character class in a way that requires min target ES2024`);return s()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=r7(n,i),o=r7(r,i),s=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&L9e(n7(e)).forEach(e=>{s.add(Array.isArray(e)?`${r7(e[0],i)}-${r7(e[1],i)}`:r7(e,i))}),`${a}-${o}${[...s].join(``)}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e===`dot`)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?`.`:`[^]`:D5`[^\n]`;if(e===`digit`)return t?D5`\D`:D5`\d`;if(e===`property`){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&B5.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?D5`\P`:D5`\p`}{${r?`${r}=`:``}${n}}`}if(e===`word`)return t?D5`\W`:D5`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?`i`:``)+(e.dotAll?`s`:``)+(e.sticky?`y`:``)},Group({atomic:e,body:t,flags:n,parent:r},i,a){let o=i.currentFlags;n&&(i.currentFlags=A5(o,n));let s=t.map(a).join(`|`),c=!i.verbose&&t.length===1&&r.type!==`Quantifier`&&!e&&(!i.useFlagMods||!n)?s:`(?${R9e(e,n,i.useFlagMods)}${s})`;return i.currentFlags=o,c},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t===`lookahead`?``:`<`}${n?`!`:`=`}`}${e.map(i).join(`|`)})`},Quantifier(e,t,n){return n(e.body)+z9e(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error(`Unexpected non-recursive subroutine in transformed AST`);let r=n.recursionLimit;return t===0?`(?R=${r})`:D5`\g<${t}&R=${r}>`}},N9e=new Set([`$`,`(`,`)`,`*`,`+`,`.`,`?`,`[`,`\\`,`]`,`^`,`{`,`|`,`}`]),P9e=new Set([`-`,`\\`,`]`,`^`,`[`]),F9e=new Set("()-/[\\]^{|}!#$%&*+,.:;<=>?@`~".split(``)),e7=new Map([[9,D5`\t`],[10,D5`\n`],[11,D5`\v`],[12,D5`\f`],[13,D5`\r`],[8232,D5`\u2028`],[8233,D5`\u2029`],[65279,D5`\uFEFF`]]),I9e=/^\p{Cased}$/u;function t7(e){return I9e.test(e)}function n7(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let e=r;e<=i;e++){let t=E5(e);if(!t7(t))continue;let o=I5(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(o.length&&(a.push(...o),n))break}return a}function r7(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(e7.has(e))return e7.get(e);if(e<32||e>126&&e<160||e>262143||t&&B9e(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,`0`)}`;let i=n?r?F9e:P9e:N9e,a=E5(e);return(i.has(a)?`\\`:``)+a}function L9e(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:r===null?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}function R9e(e,t,n){if(e)return`>`;let r=``;if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?`i`:``)+(e?.dotAll?`s`:``)+(n?`-`:``)+(n?.ignoreCase?`i`:``)+(n?.dotAll?`s`:``)}return`${r}:`}function z9e({kind:e,max:t,min:n}){let r;return r=!n&&t===1?`?`:!n&&t===1/0?`*`:n===1&&t===1/0?`+`:n===t?`{${n}}`:`{${n},${t===1/0?``:t}}`,r+{greedy:``,lazy:`?`,possessive:`+`}[e]}function i7({type:e}){return e===`CapturingGroup`||e===`Group`||e===`LookaroundAssertion`}function B9e(e){return e>47&&e<58}function a7({type:e,value:t}){return e===`Character`&&t===45}var V9e=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||`(?:)`}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error(`Cannot provide options when copying a regexp`);let i=t;super(i,n),this.#n=i.source,i instanceof e&&(this.#e=i.#e,this.#r=i.#r,this.#i=i.#i,this.rawOptions=i.rawOptions)}else{let e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?``:t,n),this.#n=t,this.#e=U9e(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i===`clip_search`&&n&&r){this.lastIndex=0;let e=this.#a(t.slice(r));return e&&(H9e(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#a(t)}#a(e){this.#t.lastIndex=this.lastIndex;let t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;let n=[...t];t.length=1;let r;this.hasIndices&&(r=[...t.indices],t.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:o}=this.#e.get(e)??{};if(a?i.push(null):(i.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&n[e]!==void 0){let a=i[o];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(t[a]=n[e],this.hasIndices&&(t.indices[a]=r[e]),t.groups){this.#r||=W9e(this.source);let i=this.#r.get(o);i&&(t.groups[i]=n[e],this.hasIndices&&(t.indices.groups[i]=r[e]))}}}return t}};function H9e(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}function U9e(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)j5(n,t,{}).transferTo=e;return n}function W9e(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,a;for(;a=t.exec(e);){let{0:e,groups:{capture:t,name:o}}=a;e===`[`?r++:r?e===`]`&&r--:t&&(i++,o&&n.set(i,o))}return n}function G9e(e,t){let n=K9e(e,t);return n.options?new V9e(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function K9e(e,t){let n=P5(t),r=y9e(B8(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:L5}),{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=A9e(r,n),a=c9e(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:`external`}),o=o9e(s9e(a.pattern).pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),s={pattern:o.pattern,flags:`${n.hasIndices?`d`:``}${n.global?`g`:``}${i.flags}${i.options.disable.v?`u`:`v`}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error(`Lazy compilation requires subclass`)}else{let e=o.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(o.captureTransfers),i=r._strategy,a=s.pattern.length>=n.lazyCompileLength;(e.length||t.length||i||a)&&(s.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...i&&{strategy:i},...a&&{lazyCompile:a}})}return s}function q9e(e,t){return G9e(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function J9e(e={}){let t=Object.assign({target:`auto`,cache:new Map},e);return t.regexConstructor||=e=>q9e(e,{target:t.target}),{createScanner(e){return new u7e(e,t)},createString(e){return{content:e}}}}async function o7(e){if(C3())throw Error(`resolveLanguage("${e}") cannot be called from a worker context. Languages must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);let t=b3.get(e);if(t!=null)return t;try{let t=$6e.get(e);if(t==null&&Object.prototype.hasOwnProperty.call(D3,e)&&(t=D3[e]),t==null)throw Error(`resolveLanguage: "${e}" not found in bundled or custom languages`);let n=t().then(({default:t})=>{let n={name:e,data:t};return y3.has(e)||y3.set(e,n),n});return b3.set(e,n),await n}finally{b3.delete(e)}}function s7(e){return y3.get(e)??o7(e)}var c7=new Set;function l7(e){let t=[],n=new Set;for(let r of Y9e(e.themes)){let e=u7(r)?r.getThemes():[r];for(let r of e){if(n.has(r.name))throw Error(`Theme collection already contains theme "${r.name}"`);n.add(r.name),t.push(r)}}let r=Object.freeze([...t]),i=Object.freeze(r.filter(e=>e.colorScheme===`light`)),a=Object.freeze(r.filter(e=>e.colorScheme===`dark`)),o=new Map(r.map(e=>[e.name,e])),s=Object.freeze(r.map(e=>e.name)),c=Object.freeze(i.map(e=>e.name)),l=Object.freeze(a.map(e=>e.name));function u(e){if(e==null)return r;let{colorScheme:t,collection:n}=e;return n==null?t===`light`?i:t===`dark`?a:r:r.filter(e=>e.collection===n?t==null||e.colorScheme===t:!1)}return{getTheme(e){return o.get(e)},getThemes(e){return u(e)},getThemeNames(e){return e?.collection==null?e?.colorScheme===`light`?c:e?.colorScheme===`dark`?l:s:u(e).map(e=>e.name)},hasTheme(e){return o.has(e)},orderBy(e){return l7({themes:r.map((e,t)=>({descriptor:e,index:t})).sort((t,n)=>{let r=e(t.descriptor,n.descriptor);return r===0?t.index-n.index:r}).map(e=>e.descriptor)})},pick(e){let t=[],n=new Set;for(let r of e){if(n.has(r))throw Error(`Theme collection pick already includes theme "${r}"`);n.add(r);let e=o.get(r);if(e==null)throw Error(`Theme collection does not contain theme "${r}"`);t.push(e)}return l7({themes:t})},registerInto(e){for(let t of r)e.registerThemeIfAbsent(t.name,t.load)}}}function Y9e(e){return X9e(e)?[e]:e}function X9e(e){return u7(e)||Z9e(e)}function Z9e(e){return typeof e.name==`string`&&typeof e.load==`function`}function u7(e){return typeof e.getThemes==`function`}function d7(e){return typeof e==`object`&&e&&`default`in e?e.default:e}var Q9e=class extends Error{constructor(e){super(`Theme "${e}" is already registered`),this.name=`DuplicateThemeError`}},$9e=class extends Error{constructor(e){super(`No loader registered for theme "${e}"`),this.name=`UnregisteredThemeError`}},eet=class extends Error{constructor(e){super(`Theme "${e}" has not been resolved`),this.name=`UnresolvedThemeError`}};function tet(){let e=new Map,t=new Map,n=new Map,r=0;function i(t,n){if(e.has(t))throw new Q9e(t);e.set(t,n)}function a(t,n){return!e.has(t)&&(e.set(t,n),!0)}function o(t){return e.has(t)}function s(i){let a=t.get(i);if(a!==void 0)return Promise.resolve(a);let o=n.get(i);if(o!==void 0)return o;let s=e.get(i);if(s===void 0)return Promise.reject(new $9e(i));let c=r,l=s().then(e=>{let a=d7(e);return c===r&&t.set(i,a),n.get(i)===l&&n.delete(i),a}).catch(e=>{throw n.get(i)===l&&n.delete(i),e});return n.set(i,l),l}function c(e){return Promise.all(e.map(e=>s(e)))}function l(e,n){t.set(e,n)}function u(e){for(let[t,n]of e)l(t,n)}function d(e){return t.get(e)}function f(e){let n=[];for(let r of e){let e=t.get(r);if(e===void 0)throw new eet(r);n.push(e)}return n}function p(e){return t.has(e)}function m(e){for(let n of e)if(!t.has(n))return!1;return!0}function h(e){let n=t.get(e);return n===void 0?s(e):n}function g(){r++,t.clear(),n.clear()}return{clearResolvedThemes:g,getResolvedOrResolveTheme:h,getResolvedTheme:d,getResolvedThemes:f,hasRegisteredTheme:o,hasResolvedTheme:p,hasResolvedThemes:m,registerTheme:i,registerThemeIfAbsent:a,resolveTheme:s,resolveThemes:c,seedResolvedTheme:l,seedResolvedThemes:u}}var f7=tet();function p7(e,t){e=Array.isArray(e)?e:[e];for(let n of e){let e;if(typeof n==`string`){if(e=f7.getResolvedTheme(n),e==null)throw Error(`loadResolvedThemes: ${n} is not resolved, you must resolve it before calling loadResolvedThemes`)}else e=n,n=n.name,f7.getResolvedTheme(n)??f7.seedResolvedTheme(n,e);c7.has(n)||(c7.add(n),t.loadThemeSync(e))}}function m7({name:e,load:t,colorScheme:n,collection:r,displayName:i}){return{name:e,colorScheme:n,collection:r,displayName:i,load:net(t)}}function net(e){return async()=>G6(d7(await e()))}var ret=`pierre`,iet=[`pierre-dark`,`pierre-dark-soft`,`pierre-dark-vibrant`,`pierre-dark-protanopia-deuteranopia`,`pierre-dark-tritanopia`],h7=[`pierre-light`,`pierre-light-soft`,`pierre-light-vibrant`,`pierre-light-protanopia-deuteranopia`,`pierre-light-tritanopia`],aet=[...h7,...iet],oet=new Set(h7);function set(e){return oet.has(e)?`light`:`dark`}var cet={"pierre-dark":`Pierre Dark`,"pierre-dark-soft":`Pierre Dark Soft`,"pierre-dark-vibrant":`Pierre Dark Vibrant`,"pierre-dark-protanopia-deuteranopia":`Pierre Dark Protanopia & Deuteranopia`,"pierre-dark-tritanopia":`Pierre Dark Tritanopia`,"pierre-light":`Pierre Light`,"pierre-light-soft":`Pierre Light Soft`,"pierre-light-vibrant":`Pierre Light Vibrant`,"pierre-light-protanopia-deuteranopia":`Pierre Light Protanopia & Deuteranopia`,"pierre-light-tritanopia":`Pierre Light Tritanopia`},uet={"pierre-dark":()=>N(()=>import(`./pierre-dark-CpLgRqie.js`),[]),"pierre-dark-soft":()=>N(()=>import(`./pierre-dark-soft-kZQmAZld.js`),[]),"pierre-dark-vibrant":()=>N(()=>import(`./pierre-dark-vibrant-CpQYzh95.js`),[]),"pierre-dark-protanopia-deuteranopia":()=>N(()=>import(`./pierre-dark-protanopia-deuteranopia-B35FxJx-.js`),[]),"pierre-dark-tritanopia":()=>N(()=>import(`./pierre-dark-tritanopia-CpjhbsIL.js`),[]),"pierre-light":()=>N(()=>import(`./pierre-light-CoaEpmwp.js`),[]),"pierre-light-soft":()=>N(()=>import(`./pierre-light-soft-lWLdNTOI.js`),[]),"pierre-light-vibrant":()=>N(()=>import(`./pierre-light-vibrant-D80Fkn33.js`),[]),"pierre-light-protanopia-deuteranopia":()=>N(()=>import(`./pierre-light-protanopia-deuteranopia-0fSaH845.js`),[]),"pierre-light-tritanopia":()=>N(()=>import(`./pierre-light-tritanopia-CEbqgOJL.js`),[])};function det(e){return m7({name:e,collection:ret,colorScheme:set(e),displayName:cet[e],load:uet[e]})}var fet=l7({themes:aet.map(e=>det(e))}),pet=`shiki`,g7=[`ayu-light`,`catppuccin-latte`,`everforest-light`,`github-light`,`github-light-default`,`github-light-high-contrast`,`gruvbox-light-hard`,`gruvbox-light-medium`,`gruvbox-light-soft`,`horizon-bright`,`kanagawa-lotus`,`light-plus`,`material-theme-lighter`,`min-light`,`night-owl-light`,`one-light`,`rose-pine-dawn`,`slack-ochin`,`snazzy-light`,`solarized-light`,`vitesse-light`],met=`andromeeda.aurora-x.ayu-dark.ayu-mirage.catppuccin-frappe.catppuccin-macchiato.catppuccin-mocha.dark-plus.dracula.dracula-soft.everforest-dark.github-dark.github-dark-default.github-dark-dimmed.github-dark-high-contrast.gruvbox-dark-hard.gruvbox-dark-medium.gruvbox-dark-soft.horizon.houston.kanagawa-dragon.kanagawa-wave.laserwave.material-theme.material-theme-darker.material-theme-ocean.material-theme-palenight.min-dark.monokai.night-owl.nord.one-dark-pro.plastic.poimandres.red.rose-pine.rose-pine-moon.slack-dark.solarized-dark.synthwave-84.tokyo-night.vesper.vitesse-black.vitesse-dark`.split(`.`),het=new Set(g7);function get(e){return het.has(e)?`light`:`dark`}var _et={andromeeda:()=>N(()=>import(`./andromeeda-vGVdxbeo.js`),[]),"aurora-x":()=>N(()=>import(`./aurora-x-CDeNXAV0.js`),[]),"ayu-dark":()=>N(()=>import(`./ayu-dark-DluEY0Gj.js`),[]),"ayu-light":()=>N(()=>import(`./ayu-light-C3h-C4tm.js`),[]),"ayu-mirage":()=>N(()=>import(`./ayu-mirage-Bqwy1Gya.js`),[]),"catppuccin-frappe":()=>N(()=>import(`./catppuccin-frappe-3VR1Za6u.js`),[]),"catppuccin-latte":()=>N(()=>import(`./catppuccin-latte-DwIHMF0Q.js`),[]),"catppuccin-macchiato":()=>N(()=>import(`./catppuccin-macchiato-DYnBP6_5.js`),[]),"catppuccin-mocha":()=>N(()=>import(`./catppuccin-mocha-DYhrFGRu.js`),[]),"dark-plus":()=>N(()=>import(`./dark-plus-Cs2F2srj.js`),[]),dracula:()=>N(()=>import(`./dracula-BHWKrbxM.js`),[]),"dracula-soft":()=>N(()=>import(`./dracula-soft-5eyTD99u.js`),[]),"everforest-dark":()=>N(()=>import(`./everforest-dark-sB-x3p7T.js`),[]),"everforest-light":()=>N(()=>import(`./everforest-light-Df2xbC6M.js`),[]),"github-dark":()=>N(()=>import(`./github-dark-C-LZuMrd.js`),[]),"github-dark-default":()=>N(()=>import(`./github-dark-default-DXG-b-1a.js`),[]),"github-dark-dimmed":()=>N(()=>import(`./github-dark-dimmed-Bx1FflLF.js`),[]),"github-dark-high-contrast":()=>N(()=>import(`./github-dark-high-contrast-B_tTalzw.js`),[]),"github-light":()=>N(()=>import(`./github-light-EUqPIrTm.js`),[]),"github-light-default":()=>N(()=>import(`./github-light-default-BXViO-2h.js`),[]),"github-light-high-contrast":()=>N(()=>import(`./github-light-high-contrast-B68TUdTA.js`),[]),"gruvbox-dark-hard":()=>N(()=>import(`./gruvbox-dark-hard-C820rvS2.js`),[]),"gruvbox-dark-medium":()=>N(()=>import(`./gruvbox-dark-medium-BPjhmG05.js`),[]),"gruvbox-dark-soft":()=>N(()=>import(`./gruvbox-dark-soft-MrdJrrXF.js`),[]),"gruvbox-light-hard":()=>N(()=>import(`./gruvbox-light-hard-BC_s9l72.js`),[]),"gruvbox-light-medium":()=>N(()=>import(`./gruvbox-light-medium-BAWPOn9u.js`),[]),"gruvbox-light-soft":()=>N(()=>import(`./gruvbox-light-soft-BSMLrYjP.js`),[]),horizon:()=>N(()=>import(`./horizon-CE9ld1lL.js`),[]),"horizon-bright":()=>N(()=>import(`./horizon-bright-DSNQnXHK.js`),[]),houston:()=>N(()=>import(`./houston-CsvMBhTu.js`),[]),"kanagawa-dragon":()=>N(()=>import(`./kanagawa-dragon-CXtmUGW6.js`),[]),"kanagawa-lotus":()=>N(()=>import(`./kanagawa-lotus-BN08jTvb.js`),[]),"kanagawa-wave":()=>N(()=>import(`./kanagawa-wave-CTweb8Dz.js`),[]),laserwave:()=>N(()=>import(`./laserwave-C_8bwKvT.js`),[]),"light-plus":()=>N(()=>import(`./light-plus-DVQuIRkW.js`),[]),"material-theme":()=>N(()=>import(`./material-theme-Bm3Qr25_.js`),[]),"material-theme-darker":()=>N(()=>import(`./material-theme-darker-2IIEA8gg.js`),[]),"material-theme-lighter":()=>N(()=>import(`./material-theme-lighter-uhdI0v04.js`),[]),"material-theme-ocean":()=>N(()=>import(`./material-theme-ocean-CHQ94UKr.js`),[]),"material-theme-palenight":()=>N(()=>import(`./material-theme-palenight-B5W6OYN7.js`),[]),"min-dark":()=>N(()=>import(`./min-dark-BSWPekZh.js`),[]),"min-light":()=>N(()=>import(`./min-light-DDpmG2fV.js`),[]),monokai:()=>N(()=>import(`./monokai-CdkpiU2Y.js`),[]),"night-owl":()=>N(()=>import(`./night-owl-DhmEMT88.js`),[]),"night-owl-light":()=>N(()=>import(`./night-owl-light-eJ-hLW7d.js`),[]),nord:()=>N(()=>import(`./nord-Cb4Vim4T.js`),[]),"one-dark-pro":()=>N(()=>import(`./one-dark-pro-CLwyXe_n.js`),[]),"one-light":()=>N(()=>import(`./one-light-D7Lr4KcI.js`),[]),plastic:()=>N(()=>import(`./plastic-DQwYfKfQ.js`),[]),poimandres:()=>N(()=>import(`./poimandres-DRFjx7u4.js`),[]),red:()=>N(()=>import(`./red-CJ3rzSJv.js`),[]),"rose-pine":()=>N(()=>import(`./rose-pine-BthvhNj6.js`),[]),"rose-pine-dawn":()=>N(()=>import(`./rose-pine-dawn-Dg85fqjY.js`),[]),"rose-pine-moon":()=>N(()=>import(`./rose-pine-moon-hon4tzzS.js`),[]),"slack-dark":()=>N(()=>import(`./slack-dark-DnToyrRv.js`),[]),"slack-ochin":()=>N(()=>import(`./slack-ochin-B2OO5cIa.js`),[]),"snazzy-light":()=>N(()=>import(`./snazzy-light-4G7pJPwS.js`),[]),"solarized-dark":()=>N(()=>import(`./solarized-dark-DV17i1UV.js`),[]),"solarized-light":()=>N(()=>import(`./solarized-light-DSh2HLQt.js`),[]),"synthwave-84":()=>N(()=>import(`./synthwave-84-nFMaYfgc.js`),[]),"tokyo-night":()=>N(()=>import(`./tokyo-night-oM2G3aXe.js`),[]),vesper:()=>N(()=>import(`./vesper-DdrHHSXu.js`),[]),"vitesse-black":()=>N(()=>import(`./vitesse-black-fwtXNY1n.js`),[]),"vitesse-dark":()=>N(()=>import(`./vitesse-dark-BZCL-v6S.js`),[]),"vitesse-light":()=>N(()=>import(`./vitesse-light-VbXTXTou.js`),[])};function _7(e){return m7({name:e,collection:pet,colorScheme:get(e),load:_et[e]})}var vet=l7({themes:Object.freeze([...g7.map(e=>_7(e)),...met.map(e=>_7(e))])});function v7(e){if(C3())throw Error(`Theme "${e}" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);if(f7.hasRegisteredTheme(e))return;let t=vet.getTheme(e);if(t!=null){f7.registerThemeIfAbsent(t.name,t.load);return}throw Error(`No valid theme loader registered for "${e}"`)}function y7(e,t){if(t.name!==e)throw Error(`resolvedTheme: themeName: ${e} does not match theme.name: ${t.name}`)}async function yet(e){v7(e);let t=await f7.resolveTheme(e);return y7(e,t),t}function bet(e){return f7.getResolvedTheme(e)??yet(e)}var b7;async function x7({themes:e,langs:t,preferredHighlighter:n=`shiki-js`}){b7??=_8({themes:[],langs:[`text`],engine:n===`shiki-wasm`?R3(N(()=>import(`./wasm-BnjxR4X6.js`),[])):J9e()});let r=Cet(b7)?await b7:b7;b7=r;let i=[];for(let e of t){if(e===`text`||e===`ansi`)continue;let t=s7(e);`then`in t?i.push(t):S3(t,r)}let a=[];for(let t of e){let e=bet(t);`then`in e?a.push(e):p7(e,b7)}return(i.length>0||a.length>0)&&await Promise.all([Promise.all(i).then(e=>{S3(e,r)}),Promise.all(a).then(e=>{p7(e,r)})]),r}function xet(){if(b7!=null&&!(`then`in b7))return b7}function Cet(e=b7){return e!=null&&`then`in e}for(let e of fet.getThemes())f7.registerThemeIfAbsent(e.name,e.load);function S7(e=C2){let t=[];return typeof e==`string`?t.push(e):(t.push(e.dark),t.push(e.light)),t}function wet(e){for(let t of S7(e))if(!c7.has(t))return!1;return!0}function C7(e){return f7.hasResolvedThemes(e)}function w7(e,t){return M2(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}function Tet(e,t){return e==null||t==null?e===t:e.startingLine===t.startingLine&&e.totalLines===t.totalLines&&e.bufferBefore===t.bufferBefore&&e.bufferAfter===t.bufferAfter}function Eet(e){return s4({tagName:`div`,children:[s4({tagName:`div`,children:e.annotations?.map(e=>s4({tagName:`slot`,properties:{name:e}})),properties:{"data-annotation-content":``}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function Det(e){switch(e){case`file`:return`diffs-icon-file-code`;case`change`:return`diffs-icon-symbol-modified`;case`new`:return`diffs-icon-symbol-added`;case`deleted`:return`diffs-icon-symbol-deleted`;case`rename-pure`:case`rename-changed`:return`diffs-icon-symbol-moved`}}function Oet({fileOrDiff:e,mode:t,stickyHeader:n}){let r=`type`in e?e:void 0,i={"data-diffs-header":t,"data-change-type":r?.type,"data-sticky":n?``:void 0};return s4({tagName:`div`,children:[t===`custom`?s4({tagName:`slot`,properties:{name:S2}}):ket({name:e.name,prevName:`prevName`in e?e.prevName:void 0,iconType:r?.type??`file`}),...t===`custom`?[]:[Aet(r)]],properties:i})}function ket({name:e,prevName:t,iconType:n}){let r=[s4({tagName:`slot`,properties:{name:y2}}),c4({name:Det(n),properties:{"data-change-icon":n}})];return t!=null&&(r.push(s4({tagName:`div`,children:[s4({tagName:`bdi`,children:[o4(t)]})],properties:{"data-prev-name":``}})),r.push(c4({name:`diffs-icon-arrow-right-short`,properties:{"data-rename-icon":``}}))),r.push(s4({tagName:`div`,children:[s4({tagName:`bdi`,children:[o4(e)]})],properties:{"data-title":``}})),r.push(s4({tagName:`slot`,properties:{name:b2}})),s4({tagName:`div`,children:r,properties:{"data-header-content":``}})}function Aet(e){let t=[];if(e!=null){let n=0,r=0;for(let t of e.hunks)n+=t.additionLines,r+=t.deletionLines;(r>0||n===0)&&t.push(s4({tagName:`span`,children:[o4(`-${r}`)],properties:{"data-deletions-count":``}})),(n>0||r===0)&&t.push(s4({tagName:`span`,children:[o4(`+${n}`)],properties:{"data-additions-count":``}}))}return t.push(s4({tagName:`slot`,properties:{name:x2}})),s4({tagName:`div`,children:t,properties:{"data-metadata":``}})}function jet(e){return s4({tagName:`pre`,properties:Met(e)})}function Met({diffIndicators:e,disableBackground:t,disableLineNumbers:n,overflow:r,split:i,totalLines:a,type:o,customProperties:s}){return{...s,"data-diff":o===`diff`?``:void 0,"data-file":o===`file`?``:void 0,"data-diff-type":o===`diff`?i?`split`:`single`:void 0,"data-overflow":r,"data-disable-line-numbers":n?``:void 0,"data-background":t?void 0:``,"data-indicators":e===`bars`||e===`classic`?e:void 0,style:`--diffs-min-number-column-width-default:${`${a}`.length}ch;`}}var T7=new Map,Net=0,E7={"1c":`1c`,abap:`abap`,as:`actionscript-3`,ada:`ada`,adb:`ada`,ads:`ada`,adoc:`asciidoc`,asciidoc:`asciidoc`,"component.html":`angular-html`,"component.ts":`angular-ts`,conf:`nginx`,htaccess:`apache`,cls:`tex`,trigger:`apex`,apl:`apl`,applescript:`applescript`,scpt:`applescript`,ara:`ara`,asm:`asm`,s:`riscv`,astro:`astro`,awk:`awk`,bal:`ballerina`,sh:`zsh`,bash:`zsh`,bat:`cmd`,cmd:`cmd`,be:`berry`,beancount:`beancount`,bib:`bibtex`,bicep:`bicep`,"blade.php":`blade`,bsl:`bsl`,c:`c`,h:`objective-cpp`,cs:`csharp`,cpp:`cpp`,hpp:`cpp`,cc:`cpp`,cxx:`cpp`,hh:`cpp`,cdc:`cdc`,cairo:`cairo`,clar:`clarity`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,soy:`soy`,cmake:`cmake`,"CMakeLists.txt":`cmake`,cob:`cobol`,cbl:`cobol`,cobol:`cobol`,CODEOWNERS:`codeowners`,ql:`ql`,coffee:`coffeescript`,lisp:`lisp`,cl:`lisp`,lsp:`lisp`,log:`log`,v:`verilog`,cql:`cql`,cr:`crystal`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cypher`,cyp:`cypher`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,patch:`diff`,Dockerfile:`dockerfile`,dockerfile:`dockerfile`,env:`dotenv`,dm:`dream-maker`,edge:`edge`,el:`emacs-lisp`,ex:`elixir`,exs:`elixir`,elm:`elm`,erb:`erb`,erl:`erlang`,hrl:`erlang`,f:`fortran-fixed-form`,for:`fortran-fixed-form`,fs:`fsharp`,fsi:`fsharp`,fsx:`fsharp`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`fortran-free-form`,f95:`fortran-free-form`,fnl:`fennel`,fish:`fish`,ftl:`ftl`,tres:`gdresource`,res:`gdresource`,gd:`gdscript`,gdshader:`gdshader`,gs:`genie`,feature:`gherkin`,COMMIT_EDITMSG:`git-commit`,"git-rebase-todo":`git-rebase`,gjs:`glimmer-js`,gleam:`gleam`,gts:`glimmer-ts`,glsl:`glsl`,vert:`glsl`,frag:`glsl`,shader:`shaderlab`,gp:`gnuplot`,plt:`gnuplot`,gnuplot:`gnuplot`,go:`go`,graphql:`graphql`,gql:`graphql`,groovy:`groovy`,gvy:`groovy`,hack:`hack`,haml:`haml`,hbs:`handlebars`,handlebars:`handlebars`,hs:`haskell`,lhs:`haskell`,hx:`haxe`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,fx:`hlsl`,html:`html`,htm:`html`,http:`http`,rest:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,cfg:`ini`,jade:`pug`,pug:`pug`,java:`java`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jinja:`jinja`,jinja2:`jinja`,j2:`jinja`,jison:`jison`,jl:`julia`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,libsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,kt:`kotlin`,kts:`kts`,kql:`kusto`,tex:`tex`,ltx:`tex`,lean:`lean4`,less:`less`,liquid:`liquid`,lit:`lit`,ll:`llvm`,logo:`logo`,lua:`lua`,luau:`luau`,Makefile:`makefile`,mk:`makefile`,makefile:`makefile`,md:`markdown`,markdown:`markdown`,marko:`marko`,m:`wolfram`,mat:`matlab`,mdc:`mdc`,mdx:`mdx`,wiki:`wikitext`,mediawiki:`wikitext`,mmd:`mermaid`,mermaid:`mermaid`,mips:`mipsasm`,mojo:`mojo`,"🔥":`mojo`,move:`move`,nar:`narrat`,nf:`nextflow`,nim:`nim`,nims:`nim`,nimble:`nim`,nix:`nix`,nu:`nushell`,mm:`objective-cpp`,ml:`ocaml`,mli:`ocaml`,mll:`ocaml`,mly:`ocaml`,pas:`pascal`,p:`pascal`,pl:`prolog`,pm:`perl`,t:`perl`,raku:`raku`,p6:`raku`,pl6:`raku`,php:`php`,phtml:`php`,pls:`plsql`,sql:`sql`,po:`po`,polar:`polar`,pcss:`postcss`,pot:`pot`,potx:`potx`,pq:`powerquery`,pqm:`powerquery`,ps1:`powershell`,psm1:`powershell`,psd1:`powershell`,prisma:`prisma`,pro:`prolog`,P:`prolog`,properties:`properties`,proto:`protobuf`,pp:`puppet`,purs:`purescript`,py:`python`,pyw:`python`,pyi:`python`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,R:`r`,rkt:`racket`,rktl:`racket`,razor:`razor`,cshtml:`razor`,rb:`ruby`,rbw:`ruby`,reg:`reg`,regex:`regexp`,rel:`rel`,rs:`rust`,rst:`rst`,rake:`ruby`,gemspec:`ruby`,jbuilder:`ruby`,builder:`ruby`,rabl:`ruby`,arb:`ruby`,ru:`ruby`,podspec:`ruby`,Gemfile:`ruby`,Rakefile:`ruby`,Guardfile:`ruby`,Capfile:`ruby`,Berksfile:`ruby`,Brewfile:`ruby`,Vagrantfile:`ruby`,Thorfile:`ruby`,Appraisals:`ruby`,Dangerfile:`ruby`,sas:`sas`,sass:`sass`,scala:`scala`,sc:`scala`,scm:`scheme`,ss:`scheme`,sld:`scheme`,scss:`scss`,sdbl:`sdbl`,shadergraph:`shader`,st:`smalltalk`,sol:`solidity`,sparql:`sparql`,rq:`sparql`,spl:`splunk`,config:`ssh-config`,do:`stata`,ado:`stata`,dta:`stata`,styl:`stylus`,stylus:`stylus`,svelte:`svelte`,swift:`swift`,sv:`system-verilog`,svh:`system-verilog`,service:`systemd`,socket:`systemd`,device:`systemd`,timer:`systemd`,talon:`talonscript`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`typescript`,mts:`typescript`,cts:`typescript`,tsp:`typespec`,tsv:`tsv`,tsx:`tsx`,ttl:`turtle`,twig:`twig`,typ:`typst`,vv:`v`,vala:`vala`,vapi:`vala`,vb:`vb`,vbs:`vb`,bas:`vb`,vh:`verilog`,vhd:`vhdl`,vhdl:`vhdl`,vim:`vimscript`,vue:`vue`,"vine.ts":`vue-vine`,vy:`vyper`,wasm:`wasm`,wat:`wasm`,wy:`文言`,wgsl:`wgsl`,wit:`wit`,wl:`wolfram`,nb:`wolfram`,xml:`xml`,xsl:`xsl`,xslt:`xsl`,yaml:`yaml`,yml:`yml`,zs:`zenscript`,zig:`zig`,zsh:`zsh`,sty:`tex`};function D7(e){if(T7.has(e))return T7.get(e)??`text`;if(E7[e]!=null)return E7[e];let t=e.match(/\.([^/\\]+\.[^/\\]+)$/);if(t!=null){if(T7.has(t[1]))return T7.get(t[1])??`text`;if(E7[t[1]]!=null)return E7[t[1]]??`text`}let n=e.match(/\.([^.]+)$/)?.[1]??``;return T7.has(n)?T7.get(n)??`text`:E7[n]??`text`}function O7(){return Net}function k7(){return Object.fromEntries(T7)}function Pet(e,{theme:t,preferredHighlighter:n=`shiki-js`}){return{langs:[e??`text`],themes:S7(t),preferredHighlighter:n}}function Fet(e){return`annotation-${`side`in e?`${e.side}-`:``}${e.lineNumber}`}function Iet(e,t,n){let r=typeof n.lineInfo==`function`?n.lineInfo(t):n.lineInfo[t-1];if(r==null){let r=`processLine: line ${t}, contains no state.lineInfo`;throw console.error(r,{node:e,line:t,state:n}),Error(r)}return e.tagName=`div`,e.properties[`data-line`]=r.lineNumber,e.properties[`data-alt-line`]=r.altLineNumber,e.properties[`data-line-type`]=r.type,e.properties[`data-line-index`]=r.lineIndex,e.children.length===0&&e.children.push(o4(`
|
|
1183
|
-
`)),e}var A7=Symbol(`no-token`),j7=Symbol(`multiple-tokens`);function M7(e){let t=
|
|
1182
|
+
\v\f
\u2028\u2029])`),t));else if(c===`posix`)if(!i&&(u===`graph`||u===`print`)){if(r===`strict`)throw Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:`!-~`,print:` -~`}[u];l&&(e=`\0-${E5(e.codePointAt(0)-1)}${E5(e.codePointAt(2)+1)}-\u{10FFFF}`),n($5(X5(`[${e}]`),t))}else n($5(Z5(X5(w9e.get(u)),l),t));else if(c===`property`)L5.has(r5(u))||(e.key=`sc`);else if(c===`space`)n(Q5(Q8(`space`,{negate:l}),t));else if(c===`word`)n($5(Z5(X5(F5),l),t));else throw Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:o}){let{kind:s,flags:c}=e;if(s===`flags`)if(!c.enable&&!c.disable)r();else{let e=J8({flags:c});e.body[0].body=o(),i($5(e,t),{traverse:!0})}else if(s===`keep`){let e=n.body[0],r=n.body.length===1&&z8(e,{type:`Group`})&&e.body[0].body.length===1?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error(D5`Uses "\K" in a way that's unsupported`);let o=Y8({behind:!0});o.body[0].body=a(),i($5(o,t))}else throw Error(`Unexpected directive kind "${s}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error(`Unsupported flag "P"`);if(e.textSegmentMode===`word`)throw Error(`Unsupported flag "y{w}"`);[`digitIsAscii`,`extended`,`posixIsAscii`,`spaceIsAscii`,`wordIsAscii`,`textSegmentMode`].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n===`lookbehind`&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r===`fail`)n($5(Y8({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type===`Quantifier`){let t=J8();t.body[0].body.push(e.body),e.body=$5(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(t.body.length===1&&t.body[0].kind===`search_start`)t.body.pop();else{let e=q5(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t===`strict`&&n&&r)throw Error(D5`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!Y5(n)&&(n=W5(n,t),e.ref=n)}},O9e={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:o,openRefs:s,reffedNodesByReferencer:c}){let l=i.get(e);if(l&&s.has(e.number)){let r=Q5(U5(e.number),t);c.set(r,s.get(e.number)),n(r);return}s.set(e.number,e),o.set(e.number,[]),e.name&&j5(o,e.name,[]);let u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){let n=u[t];if(l===n.node||l&&l===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:l}),e.name&&o.get(e.name).push({node:e,origin:l}),e.name){let t=j5(a,e.name,new Map),n=!1;if(l)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=A5(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:a}=e;if(i){let n=t;for(;(n=n.parent)&&(n.type!==`CapturingGroup`||n.name!==a&&n.number!==a););r.reffedNodesByReferencer.set(e,n);return}let o=r.subroutineRefMap.get(a),s=a===0,c=s?U5(0):H5(o,r.groupOriginByCopy,null),l=c;if(!s){let e=G5(M9e(o,e=>e.type===`Group`&&!!e.flags)),t=e?A5(r.globalFlags,e):r.globalFlags;A9e(t,r.currentFlags)||(l=J8({flags:N9e(t)}),l.body[0].body.push(c))}n($5(l,t),{traverse:!s})}},k9e={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>j9e(t,e));i.length?i.length>1?n($5(J8({atomic:!0,body:i.reverse().map(e=>V8({body:[U8(e.number)]}))}),t)):e.ref=i[0].number:n($5(Y8({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=W8();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function V5(e){o5(e,{"*"({node:e,parent:t}){e.parent=t}})}function A9e(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function j9e(e,t){let n=t;do{if(n.type===`Regex`)return!1;if(n.type===`Alternative`)continue;if(n===e)return!1;let t=K5(n.parent);for(let r of t){if(r===n)break;if(r===e||J5(r,e))return!0}}while(n=n.parent);throw Error(`Unexpected path`)}function H5(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a===`parent`?i.parent=Array.isArray(n)?r:n:o&&typeof o==`object`?i[a]=H5(o,t,i,n):(a===`type`&&o===`CapturingGroup`&&t.set(i,t.get(e)??e),i[a]=o);return i}function U5(e){let t=Z8(e);return t.isRecursive=!0,t}function M9e(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function W5(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,`_`)}`;return t.set(e,n),n}function G5(e){let t=[`dotAll`,`ignoreCase`],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function N9e({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function K5(e){if(!e)throw Error(`Node expected`);let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function q5(e){let t=e.find(e=>e.kind===`search_start`||I9e(e,{negate:!1})||!P9e(e));if(!t)return null;if(t.kind===`search_start`)return t;if(t.type===`LookaroundAssertion`)return t.body[0].body[0];if(t.type===`CapturingGroup`||t.type===`Group`){let e=[];for(let n of t.body){let t=q5(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function J5(e,t){let n=K5(e)??[];for(let e of n)if(e===t||J5(e,t))return!0;return!1}function P9e({type:e}){return e===`Assertion`||e===`Directive`||e===`LookaroundAssertion`}function F9e(e){let t=[`Character`,`CharacterClass`,`CharacterSet`];return t.includes(e.type)||e.type===`Quantifier`&&e.min&&t.includes(e.body.type)}function I9e(e,t){let n={negate:null,...t};return e.type===`LookaroundAssertion`&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&z8(e.body[0],{type:`Assertion`,kind:`search_start`})}function Y5(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function X5(e,t){let n=B8(e,{...t,unicodePropertyMap:L5}).body;return n.length>1||n[0].body.length>1?J8({body:n}):n[0].body[0]}function Z5(e,t){return e.negate=t,e}function Q5(e,t){return e.parent=t,e}function $5(e,t){return V5(e),e.parent=t,e}function L9e(e,t){let n=P5(t),r=M5(n.target,`ES2024`),i=M5(n.target,`ES2025`),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error(`Invalid recursionLimit; use 2-20`);let o=null,s=null;if(!i){let t=[e.flags.ignoreCase];o5(e,R9e,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:s=!0}})}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!s)},l=e,u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&o&&s),useFlagMods:i,useFlagV:r,verbose:n.verbose};function d(e){return u.lastNode=l,l=e,_9e(z9e[e.type],`Unexpected node type "${e.type}"`)(e,u,d)}let f={pattern:e.body.map(d).join(`|`),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&f._hiddenCaptures.push(t),e.transferTo&&j5(f._captureTransfers,e.transferTo,[]).push(t)}),f}var R9e={"*":{enter({node:e},t){if(i7(e)){let n=t.getCurrentModI();t.pushModI(e.flags?A5({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){i7(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){t7(E5(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),n7(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===`property`&&B5.has(e.value)&&t.setHasCasedChar()}},z9e={Alternative({body:e},t,n){return e.map(n).join(``)},Assertion({kind:e,negate:t}){if(e===`string_end`)return`$`;if(e===`string_start`)return`^`;if(e===`word_boundary`)return t?D5`\B`:D5`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!=`number`)throw Error(`Unexpected named backref in transformed AST`);if(!t.useFlagMods&&t.accuracy===`strict`&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error(`Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy`);return`\\`+e},CapturingGroup(e,t,n){let{body:r,name:i,number:a}=e,o={ignoreCase:t.currentFlags.ignoreCase},s=t.originMap.get(e);return s&&(o.hidden=!0,a>s.number&&(o.transferTo=s.number)),t.captureMap.set(a,o),`(${i?`?<${i}>`:``}${r.map(n).join(`|`)})`},Character({value:e},t){let n=E5(e),r=r7(e,{escDigit:t.lastNode.type===`Backreference`,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&t7(n)){let e=I5(n);return t.inCharClass?e.join(``):e.length>1?`[${e.join(``)}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:a}=e,{body:o}=e;if(r===`intersection`&&!t.useFlagV)throw Error(`Use of character class intersection requires min target ES2024`);O5.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(a7)&&(o=[G8(45),...o.filter(e=>!a7(e))]);let s=()=>`[${i?`^`:``}${o.map(n).join(r===`intersection`?`&&`:``)}]`;if(!t.inCharClass){if((!t.useFlagV||O5.bugNestedClassIgnoresNegation)&&!i){let t=o.filter(e=>e.type===`CharacterClass`&&e.kind===`union`&&e.negate);if(t.length){let r=J8(),i=r.body[0];return r.parent=a,i.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=V8({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=s();return t.inCharClass=!1,r}let c=o[0];if(r===`union`&&!i&&c&&((!t.useFlagV||!t.verbose)&&a.kind===`union`&&!(O5.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind===`intersection`&&o.length===1&&c.type!==`CharacterClassRange`))return o.map(n).join(``);if(!t.useFlagV&&a.type===`CharacterClass`)throw Error(`Uses nested character class in a way that requires min target ES2024`);return s()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=r7(n,i),o=r7(r,i),s=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&W9e(n7(e)).forEach(e=>{s.add(Array.isArray(e)?`${r7(e[0],i)}-${r7(e[1],i)}`:r7(e,i))}),`${a}-${o}${[...s].join(``)}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e===`dot`)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?`.`:`[^]`:D5`[^\n]`;if(e===`digit`)return t?D5`\D`:D5`\d`;if(e===`property`){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&B5.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?D5`\P`:D5`\p`}{${r?`${r}=`:``}${n}}`}if(e===`word`)return t?D5`\W`:D5`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?`i`:``)+(e.dotAll?`s`:``)+(e.sticky?`y`:``)},Group({atomic:e,body:t,flags:n,parent:r},i,a){let o=i.currentFlags;n&&(i.currentFlags=A5(o,n));let s=t.map(a).join(`|`),c=!i.verbose&&t.length===1&&r.type!==`Quantifier`&&!e&&(!i.useFlagMods||!n)?s:`(?${G9e(e,n,i.useFlagMods)}${s})`;return i.currentFlags=o,c},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t===`lookahead`?``:`<`}${n?`!`:`=`}`}${e.map(i).join(`|`)})`},Quantifier(e,t,n){return n(e.body)+K9e(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error(`Unexpected non-recursive subroutine in transformed AST`);let r=n.recursionLimit;return t===0?`(?R=${r})`:D5`\g<${t}&R=${r}>`}},B9e=new Set([`$`,`(`,`)`,`*`,`+`,`.`,`?`,`[`,`\\`,`]`,`^`,`{`,`|`,`}`]),V9e=new Set([`-`,`\\`,`]`,`^`,`[`]),H9e=new Set("()-/[\\]^{|}!#$%&*+,.:;<=>?@`~".split(``)),e7=new Map([[9,D5`\t`],[10,D5`\n`],[11,D5`\v`],[12,D5`\f`],[13,D5`\r`],[8232,D5`\u2028`],[8233,D5`\u2029`],[65279,D5`\uFEFF`]]),U9e=/^\p{Cased}$/u;function t7(e){return U9e.test(e)}function n7(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let e=r;e<=i;e++){let t=E5(e);if(!t7(t))continue;let o=I5(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(o.length&&(a.push(...o),n))break}return a}function r7(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(e7.has(e))return e7.get(e);if(e<32||e>126&&e<160||e>262143||t&&q9e(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,`0`)}`;let i=n?r?H9e:V9e:B9e,a=E5(e);return(i.has(a)?`\\`:``)+a}function W9e(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:r===null?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}function G9e(e,t,n){if(e)return`>`;let r=``;if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?`i`:``)+(e?.dotAll?`s`:``)+(n?`-`:``)+(n?.ignoreCase?`i`:``)+(n?.dotAll?`s`:``)}return`${r}:`}function K9e({kind:e,max:t,min:n}){let r;return r=!n&&t===1?`?`:!n&&t===1/0?`*`:n===1&&t===1/0?`+`:n===t?`{${n}}`:`{${n},${t===1/0?``:t}}`,r+{greedy:``,lazy:`?`,possessive:`+`}[e]}function i7({type:e}){return e===`CapturingGroup`||e===`Group`||e===`LookaroundAssertion`}function q9e(e){return e>47&&e<58}function a7({type:e,value:t}){return e===`Character`&&t===45}var J9e=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||`(?:)`}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error(`Cannot provide options when copying a regexp`);let i=t;super(i,n),this.#n=i.source,i instanceof e&&(this.#e=i.#e,this.#r=i.#r,this.#i=i.#i,this.rawOptions=i.rawOptions)}else{let e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?``:t,n),this.#n=t,this.#e=X9e(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i===`clip_search`&&n&&r){this.lastIndex=0;let e=this.#a(t.slice(r));return e&&(Y9e(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#a(t)}#a(e){this.#t.lastIndex=this.lastIndex;let t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;let n=[...t];t.length=1;let r;this.hasIndices&&(r=[...t.indices],t.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:o}=this.#e.get(e)??{};if(a?i.push(null):(i.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&n[e]!==void 0){let a=i[o];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(t[a]=n[e],this.hasIndices&&(t.indices[a]=r[e]),t.groups){this.#r||=Z9e(this.source);let i=this.#r.get(o);i&&(t.groups[i]=n[e],this.hasIndices&&(t.indices.groups[i]=r[e]))}}}return t}};function Y9e(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}function X9e(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)j5(n,t,{}).transferTo=e;return n}function Z9e(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,a;for(;a=t.exec(e);){let{0:e,groups:{capture:t,name:o}}=a;e===`[`?r++:r?e===`]`&&r--:t&&(i++,o&&n.set(i,o))}return n}function Q9e(e,t){let n=$9e(e,t);return n.options?new J9e(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function $9e(e,t){let n=P5(t),r=E9e(B8(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:L5}),{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=L9e(r,n),a=h9e(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:`external`}),o=p9e(m9e(a.pattern).pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),s={pattern:o.pattern,flags:`${n.hasIndices?`d`:``}${n.global?`g`:``}${i.flags}${i.options.disable.v?`u`:`v`}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error(`Lazy compilation requires subclass`)}else{let e=o.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(o.captureTransfers),i=r._strategy,a=s.pattern.length>=n.lazyCompileLength;(e.length||t.length||i||a)&&(s.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...i&&{strategy:i},...a&&{lazyCompile:a}})}return s}function eet(e,t){return Q9e(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function tet(e={}){let t=Object.assign({target:`auto`,cache:new Map},e);return t.regexConstructor||=e=>eet(e,{target:t.target}),{createScanner(e){return new _7e(e,t)},createString(e){return{content:e}}}}async function o7(e){if(C3())throw Error(`resolveLanguage("${e}") cannot be called from a worker context. Languages must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);let t=b3.get(e);if(t!=null)return t;try{let t=o8e.get(e);if(t==null&&Object.prototype.hasOwnProperty.call(D3,e)&&(t=D3[e]),t==null)throw Error(`resolveLanguage: "${e}" not found in bundled or custom languages`);let n=t().then(({default:t})=>{let n={name:e,data:t};return y3.has(e)||y3.set(e,n),n});return b3.set(e,n),await n}finally{b3.delete(e)}}function s7(e){return y3.get(e)??o7(e)}var c7=new Set;function l7(e){let t=[],n=new Set;for(let r of net(e.themes)){let e=u7(r)?r.getThemes():[r];for(let r of e){if(n.has(r.name))throw Error(`Theme collection already contains theme "${r.name}"`);n.add(r.name),t.push(r)}}let r=Object.freeze([...t]),i=Object.freeze(r.filter(e=>e.colorScheme===`light`)),a=Object.freeze(r.filter(e=>e.colorScheme===`dark`)),o=new Map(r.map(e=>[e.name,e])),s=Object.freeze(r.map(e=>e.name)),c=Object.freeze(i.map(e=>e.name)),l=Object.freeze(a.map(e=>e.name));function u(e){if(e==null)return r;let{colorScheme:t,collection:n}=e;return n==null?t===`light`?i:t===`dark`?a:r:r.filter(e=>e.collection===n?t==null||e.colorScheme===t:!1)}return{getTheme(e){return o.get(e)},getThemes(e){return u(e)},getThemeNames(e){return e?.collection==null?e?.colorScheme===`light`?c:e?.colorScheme===`dark`?l:s:u(e).map(e=>e.name)},hasTheme(e){return o.has(e)},orderBy(e){return l7({themes:r.map((e,t)=>({descriptor:e,index:t})).sort((t,n)=>{let r=e(t.descriptor,n.descriptor);return r===0?t.index-n.index:r}).map(e=>e.descriptor)})},pick(e){let t=[],n=new Set;for(let r of e){if(n.has(r))throw Error(`Theme collection pick already includes theme "${r}"`);n.add(r);let e=o.get(r);if(e==null)throw Error(`Theme collection does not contain theme "${r}"`);t.push(e)}return l7({themes:t})},registerInto(e){for(let t of r)e.registerThemeIfAbsent(t.name,t.load)}}}function net(e){return ret(e)?[e]:e}function ret(e){return u7(e)||iet(e)}function iet(e){return typeof e.name==`string`&&typeof e.load==`function`}function u7(e){return typeof e.getThemes==`function`}function d7(e){return typeof e==`object`&&e&&`default`in e?e.default:e}var aet=class extends Error{constructor(e){super(`Theme "${e}" is already registered`),this.name=`DuplicateThemeError`}},oet=class extends Error{constructor(e){super(`No loader registered for theme "${e}"`),this.name=`UnregisteredThemeError`}},set=class extends Error{constructor(e){super(`Theme "${e}" has not been resolved`),this.name=`UnresolvedThemeError`}};function cet(){let e=new Map,t=new Map,n=new Map,r=0;function i(t,n){if(e.has(t))throw new aet(t);e.set(t,n)}function a(t,n){return!e.has(t)&&(e.set(t,n),!0)}function o(t){return e.has(t)}function s(i){let a=t.get(i);if(a!==void 0)return Promise.resolve(a);let o=n.get(i);if(o!==void 0)return o;let s=e.get(i);if(s===void 0)return Promise.reject(new oet(i));let c=r,l=s().then(e=>{let a=d7(e);return c===r&&t.set(i,a),n.get(i)===l&&n.delete(i),a}).catch(e=>{throw n.get(i)===l&&n.delete(i),e});return n.set(i,l),l}function c(e){return Promise.all(e.map(e=>s(e)))}function l(e,n){t.set(e,n)}function u(e){for(let[t,n]of e)l(t,n)}function d(e){return t.get(e)}function f(e){let n=[];for(let r of e){let e=t.get(r);if(e===void 0)throw new set(r);n.push(e)}return n}function p(e){return t.has(e)}function m(e){for(let n of e)if(!t.has(n))return!1;return!0}function h(e){let n=t.get(e);return n===void 0?s(e):n}function g(){r++,t.clear(),n.clear()}return{clearResolvedThemes:g,getResolvedOrResolveTheme:h,getResolvedTheme:d,getResolvedThemes:f,hasRegisteredTheme:o,hasResolvedTheme:p,hasResolvedThemes:m,registerTheme:i,registerThemeIfAbsent:a,resolveTheme:s,resolveThemes:c,seedResolvedTheme:l,seedResolvedThemes:u}}var f7=cet();function p7(e,t){e=Array.isArray(e)?e:[e];for(let n of e){let e;if(typeof n==`string`){if(e=f7.getResolvedTheme(n),e==null)throw Error(`loadResolvedThemes: ${n} is not resolved, you must resolve it before calling loadResolvedThemes`)}else e=n,n=n.name,f7.getResolvedTheme(n)??f7.seedResolvedTheme(n,e);c7.has(n)||(c7.add(n),t.loadThemeSync(e))}}function m7({name:e,load:t,colorScheme:n,collection:r,displayName:i}){return{name:e,colorScheme:n,collection:r,displayName:i,load:uet(t)}}function uet(e){return async()=>G6(d7(await e()))}var det=`pierre`,fet=[`pierre-dark`,`pierre-dark-soft`,`pierre-dark-vibrant`,`pierre-dark-protanopia-deuteranopia`,`pierre-dark-tritanopia`],h7=[`pierre-light`,`pierre-light-soft`,`pierre-light-vibrant`,`pierre-light-protanopia-deuteranopia`,`pierre-light-tritanopia`],pet=[...h7,...fet],met=new Set(h7);function het(e){return met.has(e)?`light`:`dark`}var get={"pierre-dark":`Pierre Dark`,"pierre-dark-soft":`Pierre Dark Soft`,"pierre-dark-vibrant":`Pierre Dark Vibrant`,"pierre-dark-protanopia-deuteranopia":`Pierre Dark Protanopia & Deuteranopia`,"pierre-dark-tritanopia":`Pierre Dark Tritanopia`,"pierre-light":`Pierre Light`,"pierre-light-soft":`Pierre Light Soft`,"pierre-light-vibrant":`Pierre Light Vibrant`,"pierre-light-protanopia-deuteranopia":`Pierre Light Protanopia & Deuteranopia`,"pierre-light-tritanopia":`Pierre Light Tritanopia`},_et={"pierre-dark":()=>N(()=>import(`./pierre-dark-CpLgRqie.js`),[]),"pierre-dark-soft":()=>N(()=>import(`./pierre-dark-soft-kZQmAZld.js`),[]),"pierre-dark-vibrant":()=>N(()=>import(`./pierre-dark-vibrant-CpQYzh95.js`),[]),"pierre-dark-protanopia-deuteranopia":()=>N(()=>import(`./pierre-dark-protanopia-deuteranopia-B35FxJx-.js`),[]),"pierre-dark-tritanopia":()=>N(()=>import(`./pierre-dark-tritanopia-CpjhbsIL.js`),[]),"pierre-light":()=>N(()=>import(`./pierre-light-CoaEpmwp.js`),[]),"pierre-light-soft":()=>N(()=>import(`./pierre-light-soft-lWLdNTOI.js`),[]),"pierre-light-vibrant":()=>N(()=>import(`./pierre-light-vibrant-D80Fkn33.js`),[]),"pierre-light-protanopia-deuteranopia":()=>N(()=>import(`./pierre-light-protanopia-deuteranopia-0fSaH845.js`),[]),"pierre-light-tritanopia":()=>N(()=>import(`./pierre-light-tritanopia-CEbqgOJL.js`),[])};function vet(e){return m7({name:e,collection:det,colorScheme:het(e),displayName:get[e],load:_et[e]})}var yet=l7({themes:pet.map(e=>vet(e))}),bet=`shiki`,g7=[`ayu-light`,`catppuccin-latte`,`everforest-light`,`github-light`,`github-light-default`,`github-light-high-contrast`,`gruvbox-light-hard`,`gruvbox-light-medium`,`gruvbox-light-soft`,`horizon-bright`,`kanagawa-lotus`,`light-plus`,`material-theme-lighter`,`min-light`,`night-owl-light`,`one-light`,`rose-pine-dawn`,`slack-ochin`,`snazzy-light`,`solarized-light`,`vitesse-light`],xet=`andromeeda.aurora-x.ayu-dark.ayu-mirage.catppuccin-frappe.catppuccin-macchiato.catppuccin-mocha.dark-plus.dracula.dracula-soft.everforest-dark.github-dark.github-dark-default.github-dark-dimmed.github-dark-high-contrast.gruvbox-dark-hard.gruvbox-dark-medium.gruvbox-dark-soft.horizon.houston.kanagawa-dragon.kanagawa-wave.laserwave.material-theme.material-theme-darker.material-theme-ocean.material-theme-palenight.min-dark.monokai.night-owl.nord.one-dark-pro.plastic.poimandres.red.rose-pine.rose-pine-moon.slack-dark.solarized-dark.synthwave-84.tokyo-night.vesper.vitesse-black.vitesse-dark`.split(`.`),Cet=new Set(g7);function wet(e){return Cet.has(e)?`light`:`dark`}var Tet={andromeeda:()=>N(()=>import(`./andromeeda-vGVdxbeo.js`),[]),"aurora-x":()=>N(()=>import(`./aurora-x-CDeNXAV0.js`),[]),"ayu-dark":()=>N(()=>import(`./ayu-dark-DluEY0Gj.js`),[]),"ayu-light":()=>N(()=>import(`./ayu-light-C3h-C4tm.js`),[]),"ayu-mirage":()=>N(()=>import(`./ayu-mirage-Bqwy1Gya.js`),[]),"catppuccin-frappe":()=>N(()=>import(`./catppuccin-frappe-3VR1Za6u.js`),[]),"catppuccin-latte":()=>N(()=>import(`./catppuccin-latte-DwIHMF0Q.js`),[]),"catppuccin-macchiato":()=>N(()=>import(`./catppuccin-macchiato-DYnBP6_5.js`),[]),"catppuccin-mocha":()=>N(()=>import(`./catppuccin-mocha-DYhrFGRu.js`),[]),"dark-plus":()=>N(()=>import(`./dark-plus-Cs2F2srj.js`),[]),dracula:()=>N(()=>import(`./dracula-BHWKrbxM.js`),[]),"dracula-soft":()=>N(()=>import(`./dracula-soft-5eyTD99u.js`),[]),"everforest-dark":()=>N(()=>import(`./everforest-dark-sB-x3p7T.js`),[]),"everforest-light":()=>N(()=>import(`./everforest-light-Df2xbC6M.js`),[]),"github-dark":()=>N(()=>import(`./github-dark-C-LZuMrd.js`),[]),"github-dark-default":()=>N(()=>import(`./github-dark-default-DXG-b-1a.js`),[]),"github-dark-dimmed":()=>N(()=>import(`./github-dark-dimmed-Bx1FflLF.js`),[]),"github-dark-high-contrast":()=>N(()=>import(`./github-dark-high-contrast-B_tTalzw.js`),[]),"github-light":()=>N(()=>import(`./github-light-EUqPIrTm.js`),[]),"github-light-default":()=>N(()=>import(`./github-light-default-BXViO-2h.js`),[]),"github-light-high-contrast":()=>N(()=>import(`./github-light-high-contrast-B68TUdTA.js`),[]),"gruvbox-dark-hard":()=>N(()=>import(`./gruvbox-dark-hard-C820rvS2.js`),[]),"gruvbox-dark-medium":()=>N(()=>import(`./gruvbox-dark-medium-BPjhmG05.js`),[]),"gruvbox-dark-soft":()=>N(()=>import(`./gruvbox-dark-soft-MrdJrrXF.js`),[]),"gruvbox-light-hard":()=>N(()=>import(`./gruvbox-light-hard-BC_s9l72.js`),[]),"gruvbox-light-medium":()=>N(()=>import(`./gruvbox-light-medium-BAWPOn9u.js`),[]),"gruvbox-light-soft":()=>N(()=>import(`./gruvbox-light-soft-BSMLrYjP.js`),[]),horizon:()=>N(()=>import(`./horizon-CE9ld1lL.js`),[]),"horizon-bright":()=>N(()=>import(`./horizon-bright-DSNQnXHK.js`),[]),houston:()=>N(()=>import(`./houston-CsvMBhTu.js`),[]),"kanagawa-dragon":()=>N(()=>import(`./kanagawa-dragon-CXtmUGW6.js`),[]),"kanagawa-lotus":()=>N(()=>import(`./kanagawa-lotus-BN08jTvb.js`),[]),"kanagawa-wave":()=>N(()=>import(`./kanagawa-wave-CTweb8Dz.js`),[]),laserwave:()=>N(()=>import(`./laserwave-C_8bwKvT.js`),[]),"light-plus":()=>N(()=>import(`./light-plus-DVQuIRkW.js`),[]),"material-theme":()=>N(()=>import(`./material-theme-Bm3Qr25_.js`),[]),"material-theme-darker":()=>N(()=>import(`./material-theme-darker-2IIEA8gg.js`),[]),"material-theme-lighter":()=>N(()=>import(`./material-theme-lighter-uhdI0v04.js`),[]),"material-theme-ocean":()=>N(()=>import(`./material-theme-ocean-CHQ94UKr.js`),[]),"material-theme-palenight":()=>N(()=>import(`./material-theme-palenight-B5W6OYN7.js`),[]),"min-dark":()=>N(()=>import(`./min-dark-BSWPekZh.js`),[]),"min-light":()=>N(()=>import(`./min-light-DDpmG2fV.js`),[]),monokai:()=>N(()=>import(`./monokai-CdkpiU2Y.js`),[]),"night-owl":()=>N(()=>import(`./night-owl-DhmEMT88.js`),[]),"night-owl-light":()=>N(()=>import(`./night-owl-light-eJ-hLW7d.js`),[]),nord:()=>N(()=>import(`./nord-Cb4Vim4T.js`),[]),"one-dark-pro":()=>N(()=>import(`./one-dark-pro-CLwyXe_n.js`),[]),"one-light":()=>N(()=>import(`./one-light-D7Lr4KcI.js`),[]),plastic:()=>N(()=>import(`./plastic-DQwYfKfQ.js`),[]),poimandres:()=>N(()=>import(`./poimandres-DRFjx7u4.js`),[]),red:()=>N(()=>import(`./red-CJ3rzSJv.js`),[]),"rose-pine":()=>N(()=>import(`./rose-pine-BthvhNj6.js`),[]),"rose-pine-dawn":()=>N(()=>import(`./rose-pine-dawn-Dg85fqjY.js`),[]),"rose-pine-moon":()=>N(()=>import(`./rose-pine-moon-hon4tzzS.js`),[]),"slack-dark":()=>N(()=>import(`./slack-dark-DnToyrRv.js`),[]),"slack-ochin":()=>N(()=>import(`./slack-ochin-B2OO5cIa.js`),[]),"snazzy-light":()=>N(()=>import(`./snazzy-light-4G7pJPwS.js`),[]),"solarized-dark":()=>N(()=>import(`./solarized-dark-DV17i1UV.js`),[]),"solarized-light":()=>N(()=>import(`./solarized-light-DSh2HLQt.js`),[]),"synthwave-84":()=>N(()=>import(`./synthwave-84-nFMaYfgc.js`),[]),"tokyo-night":()=>N(()=>import(`./tokyo-night-oM2G3aXe.js`),[]),vesper:()=>N(()=>import(`./vesper-DdrHHSXu.js`),[]),"vitesse-black":()=>N(()=>import(`./vitesse-black-fwtXNY1n.js`),[]),"vitesse-dark":()=>N(()=>import(`./vitesse-dark-BZCL-v6S.js`),[]),"vitesse-light":()=>N(()=>import(`./vitesse-light-VbXTXTou.js`),[])};function _7(e){return m7({name:e,collection:bet,colorScheme:wet(e),load:Tet[e]})}var Eet=l7({themes:Object.freeze([...g7.map(e=>_7(e)),...xet.map(e=>_7(e))])});function v7(e){if(C3())throw Error(`Theme "${e}" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);if(f7.hasRegisteredTheme(e))return;let t=Eet.getTheme(e);if(t!=null){f7.registerThemeIfAbsent(t.name,t.load);return}throw Error(`No valid theme loader registered for "${e}"`)}function y7(e,t){if(t.name!==e)throw Error(`resolvedTheme: themeName: ${e} does not match theme.name: ${t.name}`)}async function Det(e){v7(e);let t=await f7.resolveTheme(e);return y7(e,t),t}function Oet(e){return f7.getResolvedTheme(e)??Det(e)}var b7;async function x7({themes:e,langs:t,preferredHighlighter:n=`shiki-js`}){b7??=_8({themes:[],langs:[`text`],engine:n===`shiki-wasm`?R3(N(()=>import(`./wasm-BnjxR4X6.js`),[])):tet()});let r=Aet(b7)?await b7:b7;b7=r;let i=[];for(let e of t){if(e===`text`||e===`ansi`)continue;let t=s7(e);`then`in t?i.push(t):S3(t,r)}let a=[];for(let t of e){let e=Oet(t);`then`in e?a.push(e):p7(e,b7)}return(i.length>0||a.length>0)&&await Promise.all([Promise.all(i).then(e=>{S3(e,r)}),Promise.all(a).then(e=>{p7(e,r)})]),r}function ket(){if(b7!=null&&!(`then`in b7))return b7}function Aet(e=b7){return e!=null&&`then`in e}for(let e of yet.getThemes())f7.registerThemeIfAbsent(e.name,e.load);function S7(e=C2){let t=[];return typeof e==`string`?t.push(e):(t.push(e.dark),t.push(e.light)),t}function jet(e){for(let t of S7(e))if(!c7.has(t))return!1;return!0}function C7(e){return f7.hasResolvedThemes(e)}function w7(e,t){return M2(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}function Met(e,t){return e==null||t==null?e===t:e.startingLine===t.startingLine&&e.totalLines===t.totalLines&&e.bufferBefore===t.bufferBefore&&e.bufferAfter===t.bufferAfter}function Net(e){return s4({tagName:`div`,children:[s4({tagName:`div`,children:e.annotations?.map(e=>s4({tagName:`slot`,properties:{name:e}})),properties:{"data-annotation-content":``}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function Pet(e){switch(e){case`file`:return`diffs-icon-file-code`;case`change`:return`diffs-icon-symbol-modified`;case`new`:return`diffs-icon-symbol-added`;case`deleted`:return`diffs-icon-symbol-deleted`;case`rename-pure`:case`rename-changed`:return`diffs-icon-symbol-moved`}}function Fet({fileOrDiff:e,mode:t,stickyHeader:n}){let r=`type`in e?e:void 0,i={"data-diffs-header":t,"data-change-type":r?.type,"data-sticky":n?``:void 0};return s4({tagName:`div`,children:[t===`custom`?s4({tagName:`slot`,properties:{name:S2}}):Iet({name:e.name,prevName:`prevName`in e?e.prevName:void 0,iconType:r?.type??`file`}),...t===`custom`?[]:[Let(r)]],properties:i})}function Iet({name:e,prevName:t,iconType:n}){let r=[s4({tagName:`slot`,properties:{name:y2}}),c4({name:Pet(n),properties:{"data-change-icon":n}})];return t!=null&&(r.push(s4({tagName:`div`,children:[s4({tagName:`bdi`,children:[o4(t)]})],properties:{"data-prev-name":``}})),r.push(c4({name:`diffs-icon-arrow-right-short`,properties:{"data-rename-icon":``}}))),r.push(s4({tagName:`div`,children:[s4({tagName:`bdi`,children:[o4(e)]})],properties:{"data-title":``}})),r.push(s4({tagName:`slot`,properties:{name:b2}})),s4({tagName:`div`,children:r,properties:{"data-header-content":``}})}function Let(e){let t=[];if(e!=null){let n=0,r=0;for(let t of e.hunks)n+=t.additionLines,r+=t.deletionLines;(r>0||n===0)&&t.push(s4({tagName:`span`,children:[o4(`-${r}`)],properties:{"data-deletions-count":``}})),(n>0||r===0)&&t.push(s4({tagName:`span`,children:[o4(`+${n}`)],properties:{"data-additions-count":``}}))}return t.push(s4({tagName:`slot`,properties:{name:x2}})),s4({tagName:`div`,children:t,properties:{"data-metadata":``}})}function Ret(e){return s4({tagName:`pre`,properties:zet(e)})}function zet({diffIndicators:e,disableBackground:t,disableLineNumbers:n,overflow:r,split:i,totalLines:a,type:o,customProperties:s}){return{...s,"data-diff":o===`diff`?``:void 0,"data-file":o===`file`?``:void 0,"data-diff-type":o===`diff`?i?`split`:`single`:void 0,"data-overflow":r,"data-disable-line-numbers":n?``:void 0,"data-background":t?void 0:``,"data-indicators":e===`bars`||e===`classic`?e:void 0,style:`--diffs-min-number-column-width-default:${`${a}`.length}ch;`}}var T7=new Map,Bet=0,E7={"1c":`1c`,abap:`abap`,as:`actionscript-3`,ada:`ada`,adb:`ada`,ads:`ada`,adoc:`asciidoc`,asciidoc:`asciidoc`,"component.html":`angular-html`,"component.ts":`angular-ts`,conf:`nginx`,htaccess:`apache`,cls:`tex`,trigger:`apex`,apl:`apl`,applescript:`applescript`,scpt:`applescript`,ara:`ara`,asm:`asm`,s:`riscv`,astro:`astro`,awk:`awk`,bal:`ballerina`,sh:`zsh`,bash:`zsh`,bat:`cmd`,cmd:`cmd`,be:`berry`,beancount:`beancount`,bib:`bibtex`,bicep:`bicep`,"blade.php":`blade`,bsl:`bsl`,c:`c`,h:`objective-cpp`,cs:`csharp`,cpp:`cpp`,hpp:`cpp`,cc:`cpp`,cxx:`cpp`,hh:`cpp`,cdc:`cdc`,cairo:`cairo`,clar:`clarity`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,soy:`soy`,cmake:`cmake`,"CMakeLists.txt":`cmake`,cob:`cobol`,cbl:`cobol`,cobol:`cobol`,CODEOWNERS:`codeowners`,ql:`ql`,coffee:`coffeescript`,lisp:`lisp`,cl:`lisp`,lsp:`lisp`,log:`log`,v:`verilog`,cql:`cql`,cr:`crystal`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cypher`,cyp:`cypher`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,patch:`diff`,Dockerfile:`dockerfile`,dockerfile:`dockerfile`,env:`dotenv`,dm:`dream-maker`,edge:`edge`,el:`emacs-lisp`,ex:`elixir`,exs:`elixir`,elm:`elm`,erb:`erb`,erl:`erlang`,hrl:`erlang`,f:`fortran-fixed-form`,for:`fortran-fixed-form`,fs:`fsharp`,fsi:`fsharp`,fsx:`fsharp`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`fortran-free-form`,f95:`fortran-free-form`,fnl:`fennel`,fish:`fish`,ftl:`ftl`,tres:`gdresource`,res:`gdresource`,gd:`gdscript`,gdshader:`gdshader`,gs:`genie`,feature:`gherkin`,COMMIT_EDITMSG:`git-commit`,"git-rebase-todo":`git-rebase`,gjs:`glimmer-js`,gleam:`gleam`,gts:`glimmer-ts`,glsl:`glsl`,vert:`glsl`,frag:`glsl`,shader:`shaderlab`,gp:`gnuplot`,plt:`gnuplot`,gnuplot:`gnuplot`,go:`go`,graphql:`graphql`,gql:`graphql`,groovy:`groovy`,gvy:`groovy`,hack:`hack`,haml:`haml`,hbs:`handlebars`,handlebars:`handlebars`,hs:`haskell`,lhs:`haskell`,hx:`haxe`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,fx:`hlsl`,html:`html`,htm:`html`,http:`http`,rest:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,cfg:`ini`,jade:`pug`,pug:`pug`,java:`java`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jinja:`jinja`,jinja2:`jinja`,j2:`jinja`,jison:`jison`,jl:`julia`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,libsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,kt:`kotlin`,kts:`kts`,kql:`kusto`,tex:`tex`,ltx:`tex`,lean:`lean4`,less:`less`,liquid:`liquid`,lit:`lit`,ll:`llvm`,logo:`logo`,lua:`lua`,luau:`luau`,Makefile:`makefile`,mk:`makefile`,makefile:`makefile`,md:`markdown`,markdown:`markdown`,marko:`marko`,m:`wolfram`,mat:`matlab`,mdc:`mdc`,mdx:`mdx`,wiki:`wikitext`,mediawiki:`wikitext`,mmd:`mermaid`,mermaid:`mermaid`,mips:`mipsasm`,mojo:`mojo`,"🔥":`mojo`,move:`move`,nar:`narrat`,nf:`nextflow`,nim:`nim`,nims:`nim`,nimble:`nim`,nix:`nix`,nu:`nushell`,mm:`objective-cpp`,ml:`ocaml`,mli:`ocaml`,mll:`ocaml`,mly:`ocaml`,pas:`pascal`,p:`pascal`,pl:`prolog`,pm:`perl`,t:`perl`,raku:`raku`,p6:`raku`,pl6:`raku`,php:`php`,phtml:`php`,pls:`plsql`,sql:`sql`,po:`po`,polar:`polar`,pcss:`postcss`,pot:`pot`,potx:`potx`,pq:`powerquery`,pqm:`powerquery`,ps1:`powershell`,psm1:`powershell`,psd1:`powershell`,prisma:`prisma`,pro:`prolog`,P:`prolog`,properties:`properties`,proto:`protobuf`,pp:`puppet`,purs:`purescript`,py:`python`,pyw:`python`,pyi:`python`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,R:`r`,rkt:`racket`,rktl:`racket`,razor:`razor`,cshtml:`razor`,rb:`ruby`,rbw:`ruby`,reg:`reg`,regex:`regexp`,rel:`rel`,rs:`rust`,rst:`rst`,rake:`ruby`,gemspec:`ruby`,jbuilder:`ruby`,builder:`ruby`,rabl:`ruby`,arb:`ruby`,ru:`ruby`,podspec:`ruby`,Gemfile:`ruby`,Rakefile:`ruby`,Guardfile:`ruby`,Capfile:`ruby`,Berksfile:`ruby`,Brewfile:`ruby`,Vagrantfile:`ruby`,Thorfile:`ruby`,Appraisals:`ruby`,Dangerfile:`ruby`,sas:`sas`,sass:`sass`,scala:`scala`,sc:`scala`,scm:`scheme`,ss:`scheme`,sld:`scheme`,scss:`scss`,sdbl:`sdbl`,shadergraph:`shader`,st:`smalltalk`,sol:`solidity`,sparql:`sparql`,rq:`sparql`,spl:`splunk`,config:`ssh-config`,do:`stata`,ado:`stata`,dta:`stata`,styl:`stylus`,stylus:`stylus`,svelte:`svelte`,swift:`swift`,sv:`system-verilog`,svh:`system-verilog`,service:`systemd`,socket:`systemd`,device:`systemd`,timer:`systemd`,talon:`talonscript`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`typescript`,mts:`typescript`,cts:`typescript`,tsp:`typespec`,tsv:`tsv`,tsx:`tsx`,ttl:`turtle`,twig:`twig`,typ:`typst`,vv:`v`,vala:`vala`,vapi:`vala`,vb:`vb`,vbs:`vb`,bas:`vb`,vh:`verilog`,vhd:`vhdl`,vhdl:`vhdl`,vim:`vimscript`,vue:`vue`,"vine.ts":`vue-vine`,vy:`vyper`,wasm:`wasm`,wat:`wasm`,wy:`文言`,wgsl:`wgsl`,wit:`wit`,wl:`wolfram`,nb:`wolfram`,xml:`xml`,xsl:`xsl`,xslt:`xsl`,yaml:`yaml`,yml:`yml`,zs:`zenscript`,zig:`zig`,zsh:`zsh`,sty:`tex`};function D7(e){if(T7.has(e))return T7.get(e)??`text`;if(E7[e]!=null)return E7[e];let t=e.match(/\.([^/\\]+\.[^/\\]+)$/);if(t!=null){if(T7.has(t[1]))return T7.get(t[1])??`text`;if(E7[t[1]]!=null)return E7[t[1]]??`text`}let n=e.match(/\.([^.]+)$/)?.[1]??``;return T7.has(n)?T7.get(n)??`text`:E7[n]??`text`}function O7(){return Bet}function k7(){return Object.fromEntries(T7)}function Vet(e,{theme:t,preferredHighlighter:n=`shiki-js`}){return{langs:[e??`text`],themes:S7(t),preferredHighlighter:n}}function Het(e){return`annotation-${`side`in e?`${e.side}-`:``}${e.lineNumber}`}function Uet(e,t,n){let r=typeof n.lineInfo==`function`?n.lineInfo(t):n.lineInfo[t-1];if(r==null){let r=`processLine: line ${t}, contains no state.lineInfo`;throw console.error(r,{node:e,line:t,state:n}),Error(r)}return e.tagName=`div`,e.properties[`data-line`]=r.lineNumber,e.properties[`data-alt-line`]=r.altLineNumber,e.properties[`data-line-type`]=r.type,e.properties[`data-line-index`]=r.lineIndex,e.children.length===0&&e.children.push(o4(`
|
|
1183
|
+
`)),e}var A7=Symbol(`no-token`),j7=Symbol(`multiple-tokens`);function M7(e){let t=Wet(e);if(t!=null)return t;let n=A7,r=[],i=[],a,o=()=>{if(i.length===0||a==null){i=[],a=void 0;return}if(i.length===1){let e=i[0];if(e?.type===`element`){Get(e,a);for(let t of e.children)N7(t)}else N7(e);r.push(e),i=[],a=void 0;return}for(let e of i)N7(e);r.push(s4({tagName:`span`,properties:{"data-char":a},children:i})),i=[],a=void 0},s=e=>{if(e!==A7){if(e===j7){n=j7;return}if(n===A7){n=e;return}n!==e&&(n=j7)}};for(let t of e.children){let e=t.type===`element`?M7(t):A7;if(s(e),typeof e!=`number`){o(),r.push(t);continue}a!=null&&a!==e&&o(),a??=e,i.push(t)}return o(),e.children=r,n}function Wet(e){let t=e.properties[`data-char`];if(typeof t==`number`)return t}function N7(e){if(e.type===`element`){e.properties[`data-char`]=void 0;for(let t of e.children)N7(t)}}function Get(e,t){e.properties[`data-char`]=t}function Ket(e={}){let{classPrefix:t=`__shiki_`,classSuffix:n=``,classReplacer:r=e=>e}=e,i=new Map;function a(e){return Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function o(e){let o=typeof e==`string`?e:a(e),s=t+qet(o)+n;return s=r(s),i.has(s)||i.set(s,typeof e==`string`?e:{...e}),s}return{name:`@shikijs/transformers:style-to-class`,pre(e){if(!e.properties.style)return;let t=o(e.properties.style);delete e.properties.style,this.addClassToHast(e,t)},tokens(e){for(let t of e)for(let e of t){if(!e.htmlStyle)continue;let t=o(e.htmlStyle);e.htmlStyle={},e.htmlAttrs||={},e.htmlAttrs.class?e.htmlAttrs.class+=` ${t}`:e.htmlAttrs.class=t}},getClassRegistry(){return i},getCSS(){let e=``;for(let[t,n]of i.entries())e+=`.${t}{${typeof n==`string`?n:a(n)}}`;return e},clearRegistry(){i.clear()}}}function qet(e,t=0){let n=3735928559^t,r=1103547991^t;for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),(4294967296*(2097151&r)+(n>>>0)).toString(36).slice(0,6)}function P7(e=!1,t=!1){let n={lineInfo:[]},r=[{line(e){return delete e.properties.class,e},pre(t){let r=D3e(t),i=[];if(r!=null){let t=1;for(let a of r.children)a.type===`element`&&(e&&M7(a),i.push(Uet(a,t,n)),t++);r.children=i}return t},...e?{tokens(e){for(let t of e){let e=0;for(let n of t){let t=n;t.__lineChar??=e,e+=n.content.length}}},preprocess(e,t){t.mergeWhitespaces=`never`},span(e,t,n,r,i){if(i?.offset!=null&&i.content!=null){let t=i.__lineChar;return t!=null&&(e.properties[`data-char`]=t),e}return e}}:null}];return t&&r.push(Jet,F7),e&&r.push({line:e=>(e.type===`element`&&e.children.length===0&&e.children.push({type:`element`,tagName:`br`,properties:{},children:[]}),e)}),{state:n,transformers:r,toClass:F7}}var F7=Ket({classPrefix:`hl-`}),Jet={name:`token-style-normalizer`,tokens(e){for(let t of e)for(let e of t){if(e.htmlStyle!=null)continue;let t={};e.color!=null&&(t.color=e.color),e.bgColor!=null&&(t[`background-color`]=e.bgColor),e.fontStyle!=null&&e.fontStyle!==0&&(e.fontStyle&1&&(t[`font-style`]=`italic`),e.fontStyle&2&&(t[`font-weight`]=`bold`),e.fontStyle&4&&(t[`text-decoration`]=`underline`)),Object.keys(t).length>0&&(e.htmlStyle=t)}}};function I7(e){return`--${e===`token`?`diffs-token`:`diffs`}-`}var Yet=/^#(?:[0-9a-f]{3}0|[0-9a-f]{6}00)$/i,Xet=/^0(?:\.0+)?%?$/;function Zet(e){let t=e.indexOf(`(`);if(t<=0||!e.endsWith(`)`))return;let n=e.slice(0,t).trim();if(!/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)$/i.test(n))return;let r=e.slice(t+1,-1).trim();if(r.length===0)return;let i=r.lastIndexOf(`/`);if(i!==-1)return r.slice(i+1).trim();if(/^(?:rgba|hsla)$/i.test(n)){let e=r.split(`,`);if(e.length===4)return e[3]?.trim()}}function Qet(e){let t=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\b/i.exec(e.trim());if(t==null)return null;let n=t[1],r,i=1;return n.length===3?r=n.split(``).map(e=>e+e).join(``):n.length===6?r=n:(r=n.slice(0,6),i=parseInt(n.slice(6,8),16)/255),[parseInt(r.slice(0,2),16),parseInt(r.slice(2,4),16),parseInt(r.slice(4,6),16),i]}function L7(e){if(e==null)return null;let t=Qet(e);if(t==null)return null;let n=t[0]/255,r=t[1]/255,i=t[2]/255,a=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return .2126*a(n)+.7152*a(r)+.0722*a(i)}function R7(e){if(e==null)return!1;let t=e.trim().toLowerCase();if(t===`transparent`||Yet.test(t))return!0;let n=Zet(t);return n!=null&&Xet.test(n)}function $et(e,t,n){if(t==null||n==null)return!1;let r=L7(e),i=L7(t),a=L7(n);return r==null||i==null||a==null?!1:Math.abs(r-a)<Math.abs(r-i)}var z7=new WeakMap;function B7(e){let t=z7.get(e);if(t!=null)return t;let n=e.colors??{},r={...n},i=n[`editor.background`]??e.bg,a=n[`editor.foreground`]??e.fg,o=n[`sideBar.background`]??i,s=n[`sideBar.foreground`]??a;V7(r,`editor.background`,i),V7(r,`editor.foreground`,a),V7(r,`sideBar.background`,o),V7(r,`sideBar.foreground`,s),V7(r,`input.background`,n[`input.background`]??o),V7(r,`sideBarSectionHeader.foreground`,n[`sideBarSectionHeader.foreground`]??s),V7(r,`list.activeSelectionForeground`,n[`list.activeSelectionForeground`]??s),V7(r,`gitDecoration.addedResourceForeground`,H7(n[`gitDecoration.addedResourceForeground`],n[`terminal.ansiGreen`],n[`editorGutter.addedBackground`])),V7(r,`gitDecoration.modifiedResourceForeground`,H7(n[`gitDecoration.modifiedResourceForeground`],n[`terminal.ansiBlue`],n[`editorGutter.modifiedBackground`])),V7(r,`gitDecoration.deletedResourceForeground`,H7(n[`gitDecoration.deletedResourceForeground`],n[`terminal.ansiRed`],n[`editorGutter.deletedBackground`]));let c=(R7(n[`list.focusOutline`])?void 0:n[`list.focusOutline`])??(R7(n.focusBorder)?void 0:n.focusBorder);c==null?delete r[`list.focusOutline`]:r[`list.focusOutline`]=c;let l=n[`list.hoverBackground`];l!=null&&(ett(l,o)||$et(l,o,s))&&delete r[`list.hoverBackground`];let u=Object.freeze({...e,colors:Object.freeze(r)});return z7.set(e,u),u}function V7(e,t,n){n!=null&&n!==``&&(e[t]=n)}function H7(...e){for(let t of e)if(t!=null&&t!==``)return t}function ett(e,t){return t!=null&&e.toLowerCase()===t.toLowerCase()}function U7({theme:e=C2,highlighter:t,prefix:n}){let r=``;if(typeof e==`string`){let i=t.getTheme(e),a=B7(i);r+=`color:${a.fg};`,r+=`background-color:${a.bg};`,r+=`${I7(`global`)}fg:${a.fg};`,r+=`${I7(`global`)}bg:${a.bg};`,r+=W7(i,n)}else{let n=t.getTheme(e.dark),i=B7(n);r+=`${I7(`global`)}dark:${i.fg};`,r+=`${I7(`global`)}dark-bg:${i.bg};`,r+=W7(n,`dark`),n=t.getTheme(e.light),i=B7(n),r+=`${I7(`global`)}light:${i.fg};`,r+=`${I7(`global`)}light-bg:${i.bg};`,r+=W7(n,`light`)}return r}function W7(e,t){t=t==null?``:`${t}-`;let n=``,r=e.colors?.[`gitDecoration.addedResourceForeground`]??e.colors?.[`terminal.ansiGreen`];r!=null&&(n+=`${I7(`global`)}${t}addition-color:${r};`);let i=e.colors?.[`gitDecoration.deletedResourceForeground`]??e.colors?.[`terminal.ansiRed`];i!=null&&(n+=`${I7(`global`)}${t}deletion-color:${i};`);let a=e.colors?.[`gitDecoration.modifiedResourceForeground`]??e.colors?.[`terminal.ansiBlue`];return a!=null&&(n+=`${I7(`global`)}${t}modified-color:${a};`),n}function G7(e){let t=e.children[0];for(;t!=null;){if(t.type===`element`&&t.tagName===`code`)return t.children;t=`children`in t?t.children[0]:null}throw console.error(e),Error(`getLineNodes: Unable to find children`)}var K7=10,q7=13,ttt=4,ntt=40;function rtt(e){let t=[0],n=e.indexOf(`\r`),r=e.indexOf(`
|
|
1184
1184
|
`),i=0,a=0;for(;n!==-1||r!==-1;){let o;if(n!==-1&&(r===-1||n<r)?r===n+1?(o=r+1,n=e.indexOf(`\r`,o),r=e.indexOf(`
|
|
1185
1185
|
`,o)):(o=n+1,n=e.indexOf(`\r`,o)):(o=r+1,r=e.indexOf(`
|
|
1186
|
-
`,o)),t.push(o),++a===
|
|
1186
|
+
`,o)),t.push(o),++a===ttt){if(o-i<=ntt){for(let n=o;n<e.length;n++){let r=e.charCodeAt(n);(r===K7||r===q7)&&(r===q7&&n+1<e.length&&e.charCodeAt(n+1)===K7&&n++,t.push(n+1))}return t}i=o,a=0}}return t}function J7(e){let t=rtt(e);return Array.from({length:t.length},(n,r)=>{let i=t[r],a=t[r+1]??e.length;return e.slice(i,a)})}var itt={forcePlainText:!1};function Y7(e,t,{theme:n=C2,tokenizeMaxLineLength:r,useTokenTransformer:i},{forcePlainText:a,startingLine:o,totalLines:s,lines:c}=itt){a?(o??=0,s??=1/0):(o=0,s=1/0);let l=o>0||s<1/0,{state:u,transformers:d}=P7(i),f=a?`text`:e.lang??D7(e.name),p=typeof n==`string`?t.getTheme(n).type:void 0,m=U7({theme:n,highlighter:t});u.lineInfo=e=>({type:`context`,lineIndex:e-1+o,lineNumber:e+o});let h=typeof n==`string`?{lang:f,theme:n,transformers:d,defaultColor:!1,cssVariablePrefix:I7(`token`),tokenizeMaxLineLength:r,tokenizeTimeLimit:0}:{lang:f,themes:n,transformers:d,defaultColor:!1,cssVariablePrefix:I7(`token`),tokenizeMaxLineLength:r,tokenizeTimeLimit:0},g=G7(t.codeToHast(l?att(c??J7(e.contents),o,s):e.contents,h)),_=l?Array(o):g;return l&&_.push(...g),{code:_,themeStyles:m,baseThemeType:p}}function att(e,t,n){if(e.length===0)return``;let r=Math.min(t+n,e.length);return e.slice(t,r).join(``)}var ott=`-1,-1`;function stt(e){return e?.some(e=>e.lineNumber===0)??!1}function ctt(e){let t=e[0];return t!=null&&t.length>0?t:void 0}function ltt(e){return e.startingLine===0&&e.totalLines>0}function utt(e,t){return e.endsWith(`\r
|
|
1187
1187
|
`)?t+`\r
|
|
1188
1188
|
`:e.endsWith(`\r`)?t+`\r`:e.endsWith(`
|
|
1189
1189
|
`)?t+`
|
|
1190
|
-
`:t}function
|
|
1190
|
+
`:t}function dtt(e,t){return s4({tagName:`div`,children:e,properties:{"data-content":``,style:`grid-row: span ${t}`}})}function X7(e){return(e.lang??D7(e.name))===`text`}var ftt=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
1191
1191
|
<symbol id="diffs-icon-arrow-right-short" viewBox="0 0 16 16">
|
|
1192
1192
|
<path d="M8.47 4.22a.75.75 0 0 0 0 1.06l1.97 1.97H3.75a.75.75 0 0 0 0 1.5h6.69l-1.97 1.97a.75.75 0 1 0 1.06 1.06l3.25-3.25a.75.75 0 0 0 0-1.06L9.53 4.22a.75.75 0 0 0-1.06 0"/>
|
|
1193
1193
|
</symbol>
|
|
@@ -1239,7 +1239,7 @@ XID_Start XIDS`.split(/\s/).map(e=>[r5(e),e])),m9e=new Map([[`s`,E5(383)],[E5(38
|
|
|
1239
1239
|
<symbol id="diffs-icon-symbol-ref" viewBox="0 0 16 16">
|
|
1240
1240
|
<path d="M1.5 8c0 1.613.088 2.806.288 3.704.196.88.478 1.381.802 1.706.286.286.71.54 1.41.73V1.86c-.7.19-1.124.444-1.41.73-.324.325-.606.826-.802 1.706C1.588 5.194 1.5 6.387 1.5 8m4 6.397c.697.07 1.522.103 2.5.103 1.613 0 2.806-.088 3.704-.288.88-.195 1.381-.478 1.706-.802s.607-.826.802-1.706c.2-.898.288-2.091.288-3.704s-.088-2.806-.288-3.704c-.195-.88-.478-1.381-.802-1.706s-.826-.606-1.706-.802C10.806 1.588 9.613 1.5 8 1.5c-.978 0-1.803.033-2.5.103zM0 8c0-6.588 1.412-8 8-8s8 1.412 8 8-1.412 8-8 8-8-1.412-8-8m7-2a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z"/>
|
|
1241
1241
|
</symbol>
|
|
1242
|
-
</svg>`;function
|
|
1242
|
+
</svg>`;function ptt(e,t){return e==null||t==null?e===t:mtt(e.customProperties,t.customProperties)&&e.type===t.type&&e.diffIndicators===t.diffIndicators&&e.disableBackground===t.disableBackground&&e.disableLineNumbers===t.disableLineNumbers&&e.overflow===t.overflow&&e.split===t.split&&e.totalLines===t.totalLines}var Z7={};function mtt(e=Z7,t=Z7){if(e===t)return!0;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}function htt(e){let t=document.createElement(`div`);return t.dataset.annotationSlot=``,t.slot=e,t.style.whiteSpace=`normal`,t}function gtt(){let e=document.createElement(`div`);return e.slot=`gutter-utility-slot`,e.style.position=`absolute`,e.style.top=`0`,e.style.bottom=`0`,e.style.textAlign=`center`,e.style.whiteSpace=`normal`,e.style.touchAction=`none`,e}function _tt(){let e=document.createElement(`style`);return e.setAttribute(r3e,``),e}var vtt=`@layer base {
|
|
1243
1243
|
:host {
|
|
1244
1244
|
--diffs-font-fallback: "SF Mono", Monaco, Consolas, "Ubuntu Mono", "Liberation Mono",
|
|
1245
1245
|
"Courier New", monospace;
|
|
@@ -2517,15 +2517,15 @@ XID_Start XIDS`.split(/\s/).map(e=>[r5(e),e])),m9e=new Map([[`s`,E5(383)],[E5(38
|
|
|
2517
2517
|
}
|
|
2518
2518
|
|
|
2519
2519
|
@layer theme, rendered, unsafe;
|
|
2520
|
-
`,Q7;function $7(e){if(Q7!=null)return Q7;let t=e.host;if(typeof HTMLElement<`u`&&t instanceof HTMLElement&&!t.isConnected)return;let n=document.createElement(`div`);n.setAttribute(`data-code`,``),n.setAttribute(
|
|
2520
|
+
`,Q7;function $7(e){if(Q7!=null)return Q7;let t=e.host;if(typeof HTMLElement<`u`&&t instanceof HTMLElement&&!t.isConnected)return;let n=document.createElement(`div`);n.setAttribute(`data-code`,``),n.setAttribute(i3e,`true`);let r=document.createElement(`div`);return r.style.position=`relative`,r.style.width=`200%`,r.style.height=`200%`,n.appendChild(r),e.appendChild(n),Q7=Math.max(n.offsetHeight-n.clientHeight,0),n.remove(),Q7}function e9(e){return`${w2}: ${e==null?`var(--diffs-scrollbar-gutter-fallback)`:`${e}px`};`}var t9=`@layer base, theme, rendered, unsafe;`,ytt=RegExp(`${Ctt(w2)}\\s*:\\s*[^;]+;`);function btt(e){return`${t9}
|
|
2521
2521
|
@layer unsafe {
|
|
2522
2522
|
${e}
|
|
2523
|
-
}`}function
|
|
2523
|
+
}`}function xtt(e,t=`system`,n){return`${t9}
|
|
2524
2524
|
@layer rendered {
|
|
2525
2525
|
:host {${t===`system`?``:`
|
|
2526
2526
|
color-scheme: ${t};`}
|
|
2527
2527
|
${e9(n)}
|
|
2528
2528
|
${e}
|
|
2529
2529
|
}
|
|
2530
|
-
}`}function htt(e,t){let n=e9(t);return e.replace(ftt,n)}function gtt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function _tt({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 vtt(e,t){if(t==null)return;let n=e.shadowRoot??e.attachShadow({mode:`open`});n.innerHTML===``&&(n.innerHTML=t)}function ytt(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 btt(e){if(typeof HTMLStyleElement<`u`&&e instanceof HTMLStyleElement)return!0;let t=e.tagName??e.nodeName;return typeof t==`string`&&t.toLowerCase()===`style`}function xtt(e){return e?.useTokenTransformer===!0||e?.onTokenClick!=null||e?.onTokenEnter!=null||e?.onTokenLeave!=null}function Stt(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 Ctt({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===``){t?.remove();return}return t??=wtt(),t.textContent=n,t.parentNode!==e&&e.appendChild(t),t}function wtt(){let e=document.createElement(`style`);return e.setAttribute(Y4e,``),e}var Ttt=void 0;function Ett(){return Ttt??=`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(dtt)),t.adoptedStyleSheets=[e]}connectedCallback(){$7(this.shadowRoot??this.attachShadow({mode:`open`}))}}customElements.define(v2,t)}function Dtt(e){return{...T2,...e}}function Ott(e,t){let n=ktt(e,t);return t?n:e.diffHeaderHeight+n}function ktt(e,t){return e.paddingTop??(t?e.spacing:0)}function Att(e){return e.paddingBottom??e.spacing}function jtt(e){switch(e){case`simple`:return 4;case`metadata`:case`line-info`:case`line-info-basic`:case`custom`:return 32}}function n9(e,t){return e===t||e?.cacheKey!=null&&e.cacheKey===t?.cacheKey}function r9(e,t){return M2(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function i9({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 a9({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 o9(e){return[I2(e.additionStart,e.additionCount)+1,L2(e.additionStart,e.additionCount)+1]}function s9({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 Mtt(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-L2(t.additionStart,t.additionCount),r=e.deletionLines.length-L2(t.deletionStart,t.deletionCount);return n<=0&&r<=0?!1:n!==r}function c9({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-L2(n.additionStart,n.additionCount),i=e.deletionLines.length-L2(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 l9({fileDiff:e,hunkIndex:t,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:i}){if(t!==e.hunks.length-1)return;let a=c9({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 Ntt({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]=o9(a);if(t<o){let s=s9({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=l9({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]=o9(a);return t<o+i.fromStart||t>=o+i.rangeSize}function Ptt({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]=o9(n),l=s9({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=l9({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 u9({type:e,metrics:t}){return t.hunkSeparatorHeight??jtt(e)}function d9({type:e,metrics:t}){return e===`simple`||e===`metadata`||e===`line-info-basic`?0:t.spacing}function Ftt({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 Itt(e){return e!==`simple`&&e!==`metadata`}function Ltt({type:e,metrics:t,hunkIndex:n,hunkSpecs:r}){if(!Ftt({type:e,hunkIndex:n,hunkSpecs:r}))return;let i=u9({type:e,metrics:t}),a=d9({type:e,metrics:t}),o=n>0?a:0,s=a;return{height:i,gapBefore:o,gapAfter:s,totalHeight:o+i+s}}function Rtt({type:e,metrics:t}){if(!Itt(e))return;let n=u9({type:e,metrics:t}),r=d9({type:e,metrics:t});return{height:n,gapBefore:r,gapAfter:0,totalHeight:r+n}}function f9({diff:e,diffStyle:t,startingLine:n=0,totalLines:r=1/0,expandedHunks:i,collapsedContextThreshold:a=1,callback:o}){let s=ztt({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=I2(r.deletionStart,r.deletionCount),s=I2(r.additionStart,r.additionCount),l=!e.isPartial&&r.deletionCount===0?o:r.deletionLineIndex,u=!e.isPartial&&r.additionCount===0?s:r.additionLineIndex,d=s9({isPartial:e.isPartial,rangeSize:r.collapsedBefore,expandedHunks:i,hunkIndex:n,collapsedContextThreshold:a}),f=n===c.finalHunkIndex?l9({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(p9(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,p9(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(p9(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=Htt(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(Utt({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(p9(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 ztt({diff:e,diffStyle:t,startingLine:n,expandedHunks:r,collapsedContextThreshold:i}){if(n<=0||t===`both`)return{hunkIndex:0,splitCount:0,unifiedCount:0};let a=Btt({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 Btt({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=s9({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?l9({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 Vtt(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 p9(e,t,n,r,i,a){let[o,s]=Vtt(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 Htt(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 Utt({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 Wtt={forcePlainText:!1};function m9(e,t,n,{forcePlainText:r,startingLine:i,totalLines:a,expandedHunks:o,collapsedContextThreshold:s=1}=Wtt){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=U7({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)??Ktt();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)}f9({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&&Gtt({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}=qtt({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 Gtt({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:a,lineDiffType:o,maxLineDiffLength:s}){if(e==null||t==null||o===`none`||(e=F2(e),t=F2(t),e.length>s||t.length>s))return;let c=o===`char`?u3e(e,t):m3e(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?(a9({item:e,arr:l,enableJoin:d,isNeutral:!0,isLastItem:t}),a9({item:e,arr:u,enableJoin:d,isNeutral:!0,isLastItem:t})):e.removed?a9({item:e,arr:l,enableJoin:d,isLastItem:t}):a9({item:e,arr:u,enableJoin:d,isLastItem:t})}let p=0;for(let e of l)e[0]===1&&i.push(i9({line:n,spanStart:p,spanLength:e[1].length})),p+=e[1].length;p=0;for(let e of u)e[0]===1&&a.push(i9({line:r,spanStart:p,spanLength:e[1].length})),p+=e[1].length}function Ktt(){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 qtt({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:r,highlighter:i,deletionDecorations:a,additionDecorations:o,languageOverride:s,options:{theme:c=C2,...l}}){let u=s??D7(e.name),d=s??D7(t.name),{state:f,transformers:p}=P7(l.useTokenTransformer),m=typeof c==`string`?{...l,lang:`text`,theme:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:I7(`token`),tokenizeTimeLimit:0}:{...l,lang:`text`,themes:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:I7(`token`),tokenizeTimeLimit:0};return{deletionLines:e.contents===``?[]:(m.lang=u,f.lineInfo=n,m.decorations=a,G7(i.codeToHast(F2(e.contents),m))),additionLines:t.contents===``?[]:(m.lang=d,m.decorations=o,f.lineInfo=r,G7(i.codeToHast(F2(t.contents),m)))}}function h9(e){let t=e.lang??D7(e.name),n=e.lang??(e.prevName==null?`text`:D7(e.prevName));return t===`text`&&n===`text`}function g9(e){let t=[];for(let n of e){let e=y3.get(n);if(e==null)throw Error(`getResolvedLanguages: ${n} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(e)}return t}function _9(e){for(let t of Array.isArray(e)?e:[e])if(!y3.has(t))return!1;return!0}async function v9(e){let t=[],n=[];for(let r of e){if(r===`text`||r===`ansi`)continue;let e=s7(r)??o7(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 y9(e){return f7.getResolvedThemes(e)}async function b9(e){for(let t of e)v7(t);let t=await f7.resolveThemes(e);for(let n=0;n<e.length;n++)y7(e[n],t[n]);return t}var x9={light:`pierre-light`,dark:`pierre-dark`};function Jtt(e){return e===`dark`?x9.dark:x9.light}var S9=2166136261,C9=16777619,Ytt=2654435769,Xtt=2246822507;function w9(e,t=S9,n=C9){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 Ztt(e,t=`diff-panel`){let n=e.trim(),r=w9(n,S9,C9).toString(36),i=w9(n,Ytt,Xtt).toString(36);return`${t}:${n.length}:${r}:${i}`}var Qtt=`-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif`,$tt=`ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace`;function ent(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 tnt(e){let t=e.split(`,`).map(ent).filter(e=>e.length>0);return t.length>0?t.join(`, `):null}var T9={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 nnt(e,t){let n=[[T9.fontSans,t.fontFamilySans,Qtt],[T9.fontMono,t.fontFamilyCode,$tt],[T9.fontComposer,t.fontFamilyComposer,`var(--font-sans)`],[T9.fontTerminal,t.fontFamilyTerminal,`var(--font-mono)`]];for(let[t,r,i]of n){let n=tnt(r);if(n===null){e.style.removeProperty(t);continue}e.style.setProperty(t,`${n}, ${i}`)}e.style.setProperty(T9.promptFontSize,`${String(t.promptFontSize)}px`),e.style.setProperty(T9.terminalFontSize,`${String(t.terminalFontSize)}px`),e.style.setProperty(T9.glassOpacity,`${String(t.glassOpacity)}%`),t.fontSmoothing?e.style.setProperty(`-webkit-font-smoothing`,`antialiased`):e.style.removeProperty(`-webkit-font-smoothing`)}var E9=`themeId`,D9=`forge:theme-boot:v1`;function rnt(e,t){try{window.localStorage.setItem(D9,JSON.stringify({appearance:t,background:e}))}catch{}}function int(){try{window.localStorage.removeItem(D9)}catch{}}function O9(){return typeof document>`u`?null:document.documentElement}function k9(){let e=O9();if(e!==null){for(let t of vn)e.style.removeProperty(rn[t]);delete e.dataset[E9],int()}}function ant(e,t){let n=O9();if(n===null)return;let r=t===`dark`?e.dark:e.light;for(let e of vn){let t=r[e];if(t===void 0){n.style.removeProperty(rn[e]);continue}n.style.setProperty(rn[e],t)}n.dataset[E9]=e.id,r.background!==void 0&&rnt(r.background,t)}function ont(e,t){if(e===`forge`){k9();return}let n=jte(e);if(n===void 0){k9();return}ant(n,t)}var snt=`forge:theme`,A9=`theme-color`,cnt=`meta[name="${A9}"][data-dynamic-theme-color="true"]`,j9=`(prefers-color-scheme: dark)`,lnt={dark:`#0a0a0a`,light:`#ffffff`};function unt(){return typeof window<`u`&&typeof localStorage<`u`}function M9(e){return e===`system`||e===`light`||e===`dark`}function N9(e,t){return typeof e!=`number`||!Number.isFinite(e)?t:Math.min(20,Math.max(11,Math.round(e)))}function dnt(){if(!unt())return{theme:`system`,uiFontSize:16,codeFontSize:13};try{let e=window.localStorage.getItem(WY);if(e){let t=qY(JSON.parse(e));return{theme:M9(t.theme)?t.theme:`system`,uiFontSize:N9(t.uiFontSize,16),codeFontSize:N9(t.codeFontSize,13)}}let t=window.localStorage.getItem(snt);return{theme:M9(t)?t:`system`,uiFontSize:16,codeFontSize:13}}catch{return{theme:`system`,uiFontSize:16,codeFontSize:13}}}function fnt(){return typeof window>`u`||typeof window.matchMedia!=`function`||window.matchMedia(j9).matches?`dark`:`light`}function P9(e){return e===`system`?fnt():e}function pnt(){let e=document.querySelector(cnt);return e||(e=document.createElement(`meta`),e.name=A9,e.setAttribute(`data-dynamic-theme-color`,`true`),document.head.append(e),e)}function F9(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 mnt(){return document.querySelector(`main[data-slot='sidebar-inset']`)??document.querySelector(`[data-slot='sidebar-inner']`)??document.body}function hnt(){return document.documentElement.classList.contains(`dark`)?`dark`:`light`}function I9(e=hnt()){if(typeof document>`u`||typeof getComputedStyle>`u`)return;document.documentElement.style.backgroundColor=``,document.body.style.backgroundColor=``;let t=F9(getComputedStyle(mnt()).backgroundColor),n=F9(getComputedStyle(document.body).backgroundColor),r=t??n??lnt[e];document.documentElement.style.backgroundColor=r,document.body.style.backgroundColor=r,pnt().setAttribute(`content`,r)}function gnt(e){if(typeof window>`u`)return;let t=window.desktopBridge;t&&t.setTheme(e).catch(()=>{})}function L9(e,t=!1){let n=P9(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,I9(n),gnt(e),t&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove(`no-transitions`)})),n)}function R9(e){typeof document>`u`||document.documentElement.style.setProperty(`--forge-ui-font-size`,`${N9(e,16)}px`)}function z9(e){typeof document>`u`||document.documentElement.style.setProperty(`--forge-code-font-size`,`${N9(e,13)}px`)}function B9(e){R9(e.uiFontSize),z9(e.codeFontSize)}if(typeof document<`u`){let e=dnt();L9(e.theme),B9(e)}function _nt(){let e=(0,Cl.c)(34),t=S0(xnt),n=S0(bnt),r=S0(ynt),i=S0(vnt),{updateSettings:a}=C0(),o;e[0]===t?o=e[1]:(o=()=>P9(t),e[0]=t,e[1]=o);let[s,c]=(0,F.useState)(o),l;e[2]===a?l=e[3]:(l=e=>{a({theme:e}),c(L9(e,!0))},e[2]=a,e[3]=l);let u=l,d;e[4]===a?d=e[5]:(d=e=>{a({themeId:e})},e[4]=a,e[5]=d);let f=d,p;e[6]===a?p=e[7]:(p=e=>{let t=N9(e,16);a({uiFontSize:t}),R9(t)},e[6]=a,e[7]=p);let m=p,h;e[8]===a?h=e[9]:(h=e=>{let t=N9(e,13);a({codeFontSize:t}),z9(t)},e[8]=a,e[9]=h);let g=h,_,v;e[10]===t?(_=e[11],v=e[12]):(_=()=>{c(L9(t))},v=[t],e[10]=t,e[11]=_,e[12]=v),(0,F.useEffect)(_,v);let y,b;e[13]!==i||e[14]!==r?(y=()=>{B9({uiFontSize:r,codeFontSize:i})},b=[r,i],e[13]=i,e[14]=r,e[15]=y,e[16]=b):(y=e[15],b=e[16]),(0,F.useEffect)(y,b);let x,S;e[17]!==s||e[18]!==n?(S=()=>{ont(n,s===`dark`?`dark`:`light`)},x=[n,s],e[17]=s,e[18]=n,e[19]=x,e[20]=S):(x=e[19],S=e[20]),(0,F.useEffect)(S,x);let C,w;e[21]===t?(C=e[22],w=e[23]):(C=()=>{if(t!==`system`||typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(j9),n=()=>{c(L9(`system`,!0))};return e.addEventListener(`change`,n),()=>{e.removeEventListener(`change`,n)}},w=[t],e[21]=t,e[22]=C,e[23]=w),(0,F.useEffect)(C,w);let T;return e[24]!==i||e[25]!==s||e[26]!==g||e[27]!==u||e[28]!==f||e[29]!==m||e[30]!==t||e[31]!==n||e[32]!==r?(T={theme:t,setTheme:u,themeId:n,setThemeId:f,resolvedTheme:s,uiFontSize:r,codeFontSize:i,setUiFontSize:m,setCodeFontSize:g},e[24]=i,e[25]=s,e[26]=g,e[27]=u,e[28]=f,e[29]=m,e[30]=t,e[31]=n,e[32]=r,e[33]=T):T=e[33],T}function vnt(e){return e.codeFontSize}function ynt(e){return e.uiFontSize}function bnt(e){return e.themeId}function xnt(e){return e.theme}function Snt(){let e=(0,Cl.c)(10),t=S0(Ant),n=S0(knt),r=S0(Ont),i=S0(Dnt),a=S0(Ent),o=S0(Tnt),s=S0(wnt),c=S0(Cnt),l,u;e[0]!==n||e[1]!==r||e[2]!==t||e[3]!==i||e[4]!==s||e[5]!==c||e[6]!==a||e[7]!==o?(l=()=>{typeof document>`u`||nnt(document.documentElement,{fontFamilyCode:n,fontFamilyComposer:r,fontFamilySans:t,fontFamilyTerminal:i,fontSmoothing:s,glassOpacity:c,promptFontSize:a,terminalFontSize:o})},u=[n,r,t,i,s,c,a,o],e[0]=n,e[1]=r,e[2]=t,e[3]=i,e[4]=s,e[5]=c,e[6]=a,e[7]=o,e[8]=l,e[9]=u):(l=e[8],u=e[9]),(0,F.useEffect)(l,u)}function Cnt(e){return e.glassOpacity}function wnt(e){return e.fontSmoothing}function Tnt(e){return e.terminalFontSize}function Ent(e){return e.promptFontSize}function Dnt(e){return e.fontFamilyTerminal}function Ont(e){return e.fontFamilyComposer}function knt(e){return e.fontFamilyCode}function Ant(e){return e.fontFamilySans}function jnt(e){let t=(0,F.useRef)(e);return(0,F.useInsertionEffect)(()=>void(t.current=e)),(0,F.useCallback)((...e)=>t.current(...e),[])}var Mnt=(0,F.createContext)(void 0);function Nnt(){return(0,F.useContext)(Mnt)}var Pnt={position:`absolute`,top:0,bottom:0,textAlign:`center`,whiteSpace:`normal`,touchAction:`none`},Fnt={display:`contents`};function Int(){return null}var V9=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),H9=Symbol(`IGNORE_RESPONSE`),U9=class extends Error{constructor(){super(`WorkerPoolManager: operation canceled because the pool terminated`)}},W9=class extends Error{constructor(){super(`WorkerPoolManager: operation canceled before the task completed`)}},Lnt=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=C2,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 V9.default.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new V9.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??C2,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()||r9(a,this.renderOptions))return;let o=S7(e),c=[];if(M2(a.theme,this.renderOptions.theme)||(c=C7(o)?y9(o):await b9(o)),!s())return;if(this.highlighter!=null)p7(c,this.highlighter);else{let e=await x7({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 U9||!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);q9(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=S7(this.renderOptions.theme),i=[];if(i=C7(r)?y9(r):await b9(r),!this.isCurrentLifecycle(t)){n();return}let a=[];if(a=_9(e)?g9(e):await v9(e),!this.isCurrentLifecycle(t)){n();return}let[o]=await Promise.all([x7({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 U9||!this.isCurrentLifecycle(t)){n();return}this.initialized=!1,this.workersFailed=!0;for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,Y9(e));this.queueBroadcastStateChanges(),r(e)}})()}),this.queueBroadcastStateChanges()}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;let n=[],r=O7(),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=K9(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);X7(t)||n!=null&&w7(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||X7(e)||t!=null&&w7(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 Y7(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,lines:r})}highlightDiffAST(e,t){let n=this.getDiffResultCache(t);h9(t)||n!=null&&r9(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||h9(e)||t!=null&&r9(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:m9(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 U9;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 U9;for(let t of this.activeTaskById.values())`reject`in t?t.reject(e):q9(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&&(_9(r)?t.request.resolvedLanguages=g9(r):t.request.resolvedLanguages=await v9(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,Y9(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 H9;if(t.type===`error`){let e=Error(t.error);if(t.stack&&(e.stack=t.stack),`reject`in n)n.reject(e);else if(q9(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)||!w7(i,this.getFileRenderOptions()))throw H9;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)||!r9(i,this.getDiffRenderOptions()))throw H9;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!==H9&&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,q9(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&&(q9(t)&&(this.rejectRenderTaskCallbacks(t,new W9),this.clearInstanceRequests(t),this.clearHighlightKey(t)),this.activeTaskById.delete(t.id))}executeTask(e,t){G9(t.request)&&this.maybeAttachCustomExtensions(e,t.request),this.activeTaskById.has(t.id)||this.assignWorkerToTask(t,e);for(let n of K9(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),q9(t)?(this.notifyHighlightError(t,n),this.rejectRenderTaskCallbacks(t,Y9(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=O7();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 J9(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 W9),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new W9),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()))q9(e)&&e.renderOptionsVersion!==this.renderOptionsVersion&&this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(let t of J9(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 J9(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(let t of J9(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 J9(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)&&a4(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)&&n9(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())q9(e)&&(yield e)}generateRequestId(){return`req_${++this.nextRequestId}`}};function G9(e){return e.type===`initialize`||e.type===`file`||e.type===`diff`}function K9(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??D7(e.request.file.name));break;case`diff`:t.add(e.request.diff.lang??D7(e.request.diff.name)),t.add(e.request.diff.lang??D7(e.request.diff.prevName??`-`))}return t.delete(`text`),Array.from(t)}function q9(e){return e?.type===`file`||e?.type===`diff`}function J9(e){return e.instances}function Y9(e){return e instanceof Error?e:Error(String(e))}var X9;function Rnt({poolOptions:e,highlighterOptions:t}){return X9??=new Lnt(e,t),X9}function znt(){X9!=null&&(X9.terminate(),X9=void 0)}var Z9=(0,F.createContext)(void 0),Q9=0;function Bnt({children:e,poolOptions:t,highlighterOptions:n}){let[r]=(0,F.useState)(()=>{if(!(typeof window>`u`))return Rnt({poolOptions:t,highlighterOptions:n})});return(0,F.useInsertionEffect)(()=>{if(r!=null)return Q9++,()=>{Q9--}},[r]),(0,F.useEffect)(()=>()=>{Q9===0&&znt()},[]),(0,kr.jsx)(Z9.Provider,{value:r,children:e})}function Vnt(){return(0,F.useContext)(Z9)}function $9(e){return Xt(`flex items-center justify-between gap-2 px-4 wco:pr-[calc(100vw-env(titlebar-area-width)-env(titlebar-area-x)+1em)]`,Ar&&e!==`sheet`?`h-[52px] border-b border-border wco:h-[env(titlebar-area-height)]`:`h-12 wco:max-h-[env(titlebar-area-height)]`)}function Hnt(e){let t=(0,Cl.c)(10),n=Ar&&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=Xt(`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,kr.jsx)(`div`,{className:$9(e.mode),children:e.header}):(0,kr.jsx)(`div`,{className:`border-b border-border`,children:(0,kr.jsx)(`div`,{className:$9(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,kr.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 Unt(){let e=(0,Cl.c)(4),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,kr.jsx)(BY,{className:`absolute left-0 top-1/2 size-6 -translate-y-1/2 rounded-md border border-border/50`}),n=(0,kr.jsx)(BY,{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,kr.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[t,n,(0,kr.jsxs)(`div`,{className:`flex gap-1 overflow-hidden px-8 py-0.5`,children:[(0,kr.jsx)(BY,{className:`h-6 w-16 shrink-0 rounded-md`}),(0,kr.jsx)(BY,{className:`h-6 w-24 shrink-0 rounded-md`}),(0,kr.jsx)(BY,{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,kr.jsxs)(kr.Fragment,{children:[r,(0,kr.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,kr.jsx)(BY,{className:`size-7 rounded-md`}),(0,kr.jsx)(BY,{className:`size-7 rounded-md`})]})]}),e[3]=i):i=e[3],i}function Wnt(e){let t=(0,Cl.c)(7),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,kr.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,kr.jsx)(BY,{className:`h-4 w-32 rounded-full`}),(0,kr.jsx)(BY,{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,kr.jsxs)(`div`,{className:`space-y-2`,children:[(0,kr.jsx)(BY,{className:`h-3 w-full rounded-full`}),(0,kr.jsx)(BY,{className:`h-3 w-full rounded-full`}),(0,kr.jsx)(BY,{className:`h-3 w-10/12 rounded-full`}),(0,kr.jsx)(BY,{className:`h-3 w-11/12 rounded-full`}),(0,kr.jsx)(BY,{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,kr.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 px-3 py-4`,children:[r,(0,kr.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,kr.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col p-2`,children:(0,kr.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}export{itt as $,bJ as $a,_Z as $i,G2e as $n,FGe as $o,L1e as $r,fre as $s,k2 as $t,r9 as A,WJ as Aa,Kne as Ac,QXe as Ai,g2 as An,Lq as Ao,t0 as Ar,Di as As,G4 as At,ytt as B,dqe as Ba,kZ as Bi,x4e as Bn,Pq as Bo,u0 as Br,Tre as Bs,s4 as Bt,Ltt as C,RY as Ca,yr as Cc,SZe as Ci,J4e as Cn,cKe as Co,C0 as Cr,Wo as Cs,R6e as Ct,Rtt as D,qJ as Da,pr as Dc,rZe as Di,z4e as Dn,Rq as Do,p0 as Dr,Vo as Ds,q4 as Dt,l9 as E,zqe as Ea,Wne as Ec,yQ as Ei,F4e as En,Iq as Eo,k0e as Er,Bo as Es,t6e as Et,Ett as F,HJ as Fa,NZ as Fi,E4e as Fn,$Ge as Fo,w0e as Fr,bi as Fs,p4 as Ft,ptt as G,XKe as Ga,JYe as Gi,Y2e as Gn,PGe as Go,W1e as Gr,xre as Gs,L2 as Gt,_tt as H,iqe as Ha,CZ as Hi,Q0 as Hn,wq as Ho,Q1e as Hr,ui as Hs,o4 as Ht,Ctt as I,VJ as Ia,DXe as Ii,C4e as In,JGe as Io,y0e as Ir,Si as Is,u4 as It,ltt as J,WKe as Ja,fZ as Ji,K2e as Jn,zGe as Jo,K1e as Jr,ei as Js,c3e as Jt,$7 as K,BKe as Ka,dZ as Ki,J2e as Kn,LGe as Ko,R1e as Kr,ii as Ks,I2 as Kt,Stt as L,NJ as La,AZ as Li,w4e as Ln,KGe as Lo,x0e as Lr,xi as Ls,C3e as Lt,Dtt as M,zJ as Ma,$Xe as Mi,D4e as Mn,Hq as Mo,h0e as Mr,Ci as Ms,F4 as Mt,Ott as N,RJ as Na,uQ as Ni,d2 as Nn,sKe as No,b0e as Nr,Ti as Ns,I4 as Nt,Mtt as O,Bqe as Oa,Xne as Oc,pQ as Oi,B4e as On,Bq as Oo,r0 as Or,Fo as Os,e6e as Ot,Att as P,Rqe as Pa,fQ as Pi,S4e as Pn,Nq as Po,_0e as Pr,wi as Ps,P4 as Pt,X7 as Q,SJ as Qa,qYe as Qi,$0e as Qn,Oq as Qo,U1e as Qr,zr as Qs,j2 as Qt,xtt as R,Iqe as Ra,jXe as Ri,T4e as Rn,WGe as Ro,S0e as Rr,yi as Rs,S3e as Rt,o9 as S,wJe as Sa,Zne as Sc,PQ as Si,y2 as Sn,pKe as So,S0 as Sr,El as Ss,L6e as St,c9 as T,SJe as Ta,Hne as Tc,bZe as Ti,I4e as Tn,zq as To,M0e as Tr,Lo as Ts,J4 as Tt,htt as U,AJ as Ua,SZ as Ui,e2 as Un,kGe as Uo,$1e as Ur,Sre as Us,a4 as Ut,vtt as V,Sqe as Va,EZ as Vi,$0 as Vn,BGe as Vo,C0e as Vr,gi as Vs,c4 as Vt,mtt as W,OJ as Wa,xZ as Wi,n2 as Wn,AGe as Wo,H1e as Wr,bre as Ws,v3e as Wt,ott as X,EJ as Xa,KYe as Xi,d2e as Xn,_q as Xo,M1 as Xr,sre as Xs,s3e as Xt,ctt as Y,GKe as Ya,vZ as Yi,K0e as Yn,RGe as Yo,B1e as Yr,$r as Ys,P2 as Yt,att as Z,TJ as Za,gZ as Zi,f2e as Zn,EGe as Zo,j1 as Zr,Br as Zs,M2 as Zt,Jtt as _,kJe as _a,Cr as _c,o$ as _i,G4e as _n,Xq as _o,u2e as _r,Ice as _s,S7 as _t,Bnt as a,nYe as aa,Lr as ac,H$e as ai,S2 as an,aJ as ao,W2e as ar,LK as as,Y7 as at,f9 as b,DJe as ba,Yne as bc,gQe as bi,b2 as bn,Jq as bo,H0e as br,Fce as bs,e8e as bt,Fnt as c,_X as ca,Jr as cc,A$e as ci,i3e as cn,EKe as co,A0 as cr,EK as cs,Pet as ct,jnt as d,bX as da,Ar as dc,m$ as di,C2 as dn,tJ as do,F0 as dr,bWe as ds,Oet as dt,XYe as ea,lre as ec,h1e as ei,O2 as en,pJ as eo,e2e as er,cq as es,rtt as et,I9 as f,VY as fa,rre as fc,qQe as fi,e3e as fn,kKe as fo,n2e as fr,wK as fs,Eet as ft,w9 as g,BY as ga,wr as gc,a$ as gi,o3e as gn,Zq as go,L0 as gr,Hce as gs,wet as gt,Ztt as h,HY as ha,Tr as hc,XQe as hi,v2 as hn,AKe as ho,D0 as hr,Bce as hs,C7 as ht,Z9 as i,tYe as ia,Hr as ic,G$e as ii,H4e as in,dJ as io,Q0e as ir,zK as is,ntt as it,n9 as j,UJ as ja,mr as jc,eZe as ji,R4e as jn,Wq as jo,f0e as jr,Ei as js,R4 as jt,Ntt as k,GJ as ka,Vne as kc,ZXe as ki,L4e as kn,Vq as ko,i0 as kr,kre as ks,K4 as kt,Int as l,hX as la,Mr as lc,g$ as li,a3e as ln,_Ke as lo,t2e as lr,TK as ls,D7 as lt,_nt as m,UY as ma,Dr as mc,JQe as mi,V4e as mn,jKe as mo,U2e as mr,Vce as ms,w7 as mt,Wnt as n,WYe as na,Pr as nc,A1 as ni,$4e as nn,LKe as no,H2e as nr,iq as ns,ttt as nt,Vnt as o,SX as oa,Ur as oc,x$ as oi,t3e as on,sJ as oo,I2e as or,kK as os,J7 as ot,Snt as p,AJe as pa,Or as pc,n$e as pi,T2 as pn,gKe as po,F2e as pr,xWe as ps,Tet as pt,utt as q,HKe as qa,YYe as qi,X0 as qn,sGe as qo,G1e as qr,ri as qs,F2 as qt,Hnt as r,yZ as ra,Vr as rc,P$ as ri,Q4e as rn,yJ as ro,X0e as rr,WWe as rs,ett as rt,Pnt as s,mX as sa,Xr as sc,w$ as si,n3e as sn,CKe as so,r2e as sr,DK as ss,Fet as st,Unt as t,GYe as ta,cre as tc,q1e as ti,q4e as tn,vJ as to,Y0e as tr,aq as ts,$et as tt,Nnt as u,uX as ua,jr as uc,h$ as ui,r3e as un,nJ as uo,J0e as ur,CK as us,jet as ut,h9 as v,EJe as va,Sr as vc,SQe as vi,K4e as vn,Qq as vo,E0 as vr,Lce as vs,xet as vt,Ptt as w,bJe as wa,Qne as wc,wZe as wi,W4e as wn,Uq as wo,f0 as wr,Io as ws,o3 as wt,s9 as x,OJe as xa,$ne as xc,XZe as xi,x2 as xn,qq as xo,V0e as xr,Tl as xs,q6e as xt,m9 as y,TJe as ya,xr as yc,TQe as yi,U4e as yn,Kq as yo,U0e as yr,Rce as ys,x7 as yt,btt as z,mqe as za,MZ as zi,v4e as zn,XGe as zo,v0e as zr,vi as zs,x3e as zt};
|
|
2531
|
-
//# sourceMappingURL=DiffPanelShell-
|
|
2530
|
+
}`}function Stt(e,t){let n=e9(t);return e.replace(ytt,n)}function Ctt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function wtt({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 Ttt(e,t){if(t==null)return;let n=e.shadowRoot??e.attachShadow({mode:`open`});n.innerHTML===``&&(n.innerHTML=t)}function Ett(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 Dtt(e){if(typeof HTMLStyleElement<`u`&&e instanceof HTMLStyleElement)return!0;let t=e.tagName??e.nodeName;return typeof t==`string`&&t.toLowerCase()===`style`}function Ott(e){return e?.useTokenTransformer===!0||e?.onTokenClick!=null||e?.onTokenEnter!=null||e?.onTokenLeave!=null}function ktt(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 Att({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===``){t?.remove();return}return t??=jtt(),t.textContent=n,t.parentNode!==e&&e.appendChild(t),t}function jtt(){let e=document.createElement(`style`);return e.setAttribute(n3e,``),e}var Mtt=void 0;function Ntt(){return Mtt??=`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(vtt)),t.adoptedStyleSheets=[e]}connectedCallback(){$7(this.shadowRoot??this.attachShadow({mode:`open`}))}}customElements.define(v2,t)}function Ptt(e){return{...T2,...e}}function Ftt(e,t){let n=Itt(e,t);return t?n:e.diffHeaderHeight+n}function Itt(e,t){return e.paddingTop??(t?e.spacing:0)}function Ltt(e){return e.paddingBottom??e.spacing}function Rtt(e){switch(e){case`simple`:return 4;case`metadata`:case`line-info`:case`line-info-basic`:case`custom`:return 32}}function n9(e,t){return e===t||e?.cacheKey!=null&&e.cacheKey===t?.cacheKey}function r9(e,t){return M2(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function i9({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 a9({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 o9(e){return[I2(e.additionStart,e.additionCount)+1,L2(e.additionStart,e.additionCount)+1]}function s9({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 ztt(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-L2(t.additionStart,t.additionCount),r=e.deletionLines.length-L2(t.deletionStart,t.deletionCount);return n<=0&&r<=0?!1:n!==r}function c9({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-L2(n.additionStart,n.additionCount),i=e.deletionLines.length-L2(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 l9({fileDiff:e,hunkIndex:t,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:i}){if(t!==e.hunks.length-1)return;let a=c9({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 Btt({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]=o9(a);if(t<o){let s=s9({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=l9({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]=o9(a);return t<o+i.fromStart||t>=o+i.rangeSize}function Vtt({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]=o9(n),l=s9({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=l9({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 u9({type:e,metrics:t}){return t.hunkSeparatorHeight??Rtt(e)}function d9({type:e,metrics:t}){return e===`simple`||e===`metadata`||e===`line-info-basic`?0:t.spacing}function Htt({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 Utt(e){return e!==`simple`&&e!==`metadata`}function Wtt({type:e,metrics:t,hunkIndex:n,hunkSpecs:r}){if(!Htt({type:e,hunkIndex:n,hunkSpecs:r}))return;let i=u9({type:e,metrics:t}),a=d9({type:e,metrics:t}),o=n>0?a:0,s=a;return{height:i,gapBefore:o,gapAfter:s,totalHeight:o+i+s}}function Gtt({type:e,metrics:t}){if(!Utt(e))return;let n=u9({type:e,metrics:t}),r=d9({type:e,metrics:t});return{height:n,gapBefore:r,gapAfter:0,totalHeight:r+n}}function f9({diff:e,diffStyle:t,startingLine:n=0,totalLines:r=1/0,expandedHunks:i,collapsedContextThreshold:a=1,callback:o}){let s=Ktt({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=I2(r.deletionStart,r.deletionCount),s=I2(r.additionStart,r.additionCount),l=!e.isPartial&&r.deletionCount===0?o:r.deletionLineIndex,u=!e.isPartial&&r.additionCount===0?s:r.additionLineIndex,d=s9({isPartial:e.isPartial,rangeSize:r.collapsedBefore,expandedHunks:i,hunkIndex:n,collapsedContextThreshold:a}),f=n===c.finalHunkIndex?l9({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(p9(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,p9(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(p9(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=Ytt(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(Xtt({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(p9(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 Ktt({diff:e,diffStyle:t,startingLine:n,expandedHunks:r,collapsedContextThreshold:i}){if(n<=0||t===`both`)return{hunkIndex:0,splitCount:0,unifiedCount:0};let a=qtt({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 qtt({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=s9({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?l9({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 Jtt(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 p9(e,t,n,r,i,a){let[o,s]=Jtt(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 Ytt(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 Xtt({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 Ztt={forcePlainText:!1};function m9(e,t,n,{forcePlainText:r,startingLine:i,totalLines:a,expandedHunks:o,collapsedContextThreshold:s=1}=Ztt){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=U7({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)??$tt();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)}f9({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&&Qtt({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}=ent({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 Qtt({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:a,lineDiffType:o,maxLineDiffLength:s}){if(e==null||t==null||o===`none`||(e=F2(e),t=F2(t),e.length>s||t.length>s))return;let c=o===`char`?_3e(e,t):x3e(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?(a9({item:e,arr:l,enableJoin:d,isNeutral:!0,isLastItem:t}),a9({item:e,arr:u,enableJoin:d,isNeutral:!0,isLastItem:t})):e.removed?a9({item:e,arr:l,enableJoin:d,isLastItem:t}):a9({item:e,arr:u,enableJoin:d,isLastItem:t})}let p=0;for(let e of l)e[0]===1&&i.push(i9({line:n,spanStart:p,spanLength:e[1].length})),p+=e[1].length;p=0;for(let e of u)e[0]===1&&a.push(i9({line:r,spanStart:p,spanLength:e[1].length})),p+=e[1].length}function $tt(){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 ent({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:r,highlighter:i,deletionDecorations:a,additionDecorations:o,languageOverride:s,options:{theme:c=C2,...l}}){let u=s??D7(e.name),d=s??D7(t.name),{state:f,transformers:p}=P7(l.useTokenTransformer),m=typeof c==`string`?{...l,lang:`text`,theme:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:I7(`token`),tokenizeTimeLimit:0}:{...l,lang:`text`,themes:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:I7(`token`),tokenizeTimeLimit:0};return{deletionLines:e.contents===``?[]:(m.lang=u,f.lineInfo=n,m.decorations=a,G7(i.codeToHast(F2(e.contents),m))),additionLines:t.contents===``?[]:(m.lang=d,m.decorations=o,f.lineInfo=r,G7(i.codeToHast(F2(t.contents),m)))}}function h9(e){let t=e.lang??D7(e.name),n=e.lang??(e.prevName==null?`text`:D7(e.prevName));return t===`text`&&n===`text`}function g9(e){let t=[];for(let n of e){let e=y3.get(n);if(e==null)throw Error(`getResolvedLanguages: ${n} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(e)}return t}function _9(e){for(let t of Array.isArray(e)?e:[e])if(!y3.has(t))return!1;return!0}async function v9(e){let t=[],n=[];for(let r of e){if(r===`text`||r===`ansi`)continue;let e=s7(r)??o7(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 y9(e){return f7.getResolvedThemes(e)}async function b9(e){for(let t of e)v7(t);let t=await f7.resolveThemes(e);for(let n=0;n<e.length;n++)y7(e[n],t[n]);return t}var x9={light:`pierre-light`,dark:`pierre-dark`};function tnt(e){return e===`dark`?x9.dark:x9.light}var S9=2166136261,C9=16777619,nnt=2654435769,rnt=2246822507;function w9(e,t=S9,n=C9){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 int(e,t=`diff-panel`){let n=e.trim(),r=w9(n,S9,C9).toString(36),i=w9(n,nnt,rnt).toString(36);return`${t}:${n.length}:${r}:${i}`}var ant=`-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif`,ont=`ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace`;function snt(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 cnt(e){let t=e.split(`,`).map(snt).filter(e=>e.length>0);return t.length>0?t.join(`, `):null}var T9={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 lnt(e,t){let n=[[T9.fontSans,t.fontFamilySans,ant],[T9.fontMono,t.fontFamilyCode,ont],[T9.fontComposer,t.fontFamilyComposer,`var(--font-sans)`],[T9.fontTerminal,t.fontFamilyTerminal,`var(--font-mono)`]];for(let[t,r,i]of n){let n=cnt(r);if(n===null){e.style.removeProperty(t);continue}e.style.setProperty(t,`${n}, ${i}`)}e.style.setProperty(T9.promptFontSize,`${String(t.promptFontSize)}px`),e.style.setProperty(T9.terminalFontSize,`${String(t.terminalFontSize)}px`),e.style.setProperty(T9.glassOpacity,`${String(t.glassOpacity)}%`),t.fontSmoothing?e.style.setProperty(`-webkit-font-smoothing`,`antialiased`):e.style.removeProperty(`-webkit-font-smoothing`)}var E9=`themeId`,D9=`forge:theme-boot:v1`;function unt(e,t){try{window.localStorage.setItem(D9,JSON.stringify({appearance:t,background:e}))}catch{}}function dnt(){try{window.localStorage.removeItem(D9)}catch{}}function O9(){return typeof document>`u`?null:document.documentElement}function k9(){let e=O9();if(e!==null){for(let t of vn)e.style.removeProperty(rn[t]);delete e.dataset[E9],dnt()}}function fnt(e,t){let n=O9();if(n===null)return;let r=t===`dark`?e.dark:e.light;for(let e of vn){let t=r[e];if(t===void 0){n.style.removeProperty(rn[e]);continue}n.style.setProperty(rn[e],t)}n.dataset[E9]=e.id,r.background!==void 0&&unt(r.background,t)}function pnt(e,t){if(e===`forge`){k9();return}let n=jte(e);if(n===void 0){k9();return}fnt(n,t)}var mnt=`forge:theme`,A9=`theme-color`,hnt=`meta[name="${A9}"][data-dynamic-theme-color="true"]`,j9=`(prefers-color-scheme: dark)`,gnt={dark:`#0a0a0a`,light:`#ffffff`};function _nt(){return typeof window<`u`&&typeof localStorage<`u`}function M9(e){return e===`system`||e===`light`||e===`dark`}function N9(e,t){return typeof e!=`number`||!Number.isFinite(e)?t:Math.min(20,Math.max(11,Math.round(e)))}function vnt(){if(!_nt())return{theme:`system`,uiFontSize:16,codeFontSize:13};try{let e=window.localStorage.getItem(WY);if(e){let t=qY(JSON.parse(e));return{theme:M9(t.theme)?t.theme:`system`,uiFontSize:N9(t.uiFontSize,16),codeFontSize:N9(t.codeFontSize,13)}}let t=window.localStorage.getItem(mnt);return{theme:M9(t)?t:`system`,uiFontSize:16,codeFontSize:13}}catch{return{theme:`system`,uiFontSize:16,codeFontSize:13}}}function ynt(){return typeof window>`u`||typeof window.matchMedia!=`function`||window.matchMedia(j9).matches?`dark`:`light`}function P9(e){return e===`system`?ynt():e}function bnt(){let e=document.querySelector(hnt);return e||(e=document.createElement(`meta`),e.name=A9,e.setAttribute(`data-dynamic-theme-color`,`true`),document.head.append(e),e)}function F9(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 xnt(){return document.querySelector(`main[data-slot='sidebar-inset']`)??document.querySelector(`[data-slot='sidebar-inner']`)??document.body}function Snt(){return document.documentElement.classList.contains(`dark`)?`dark`:`light`}function I9(e=Snt()){if(typeof document>`u`||typeof getComputedStyle>`u`)return;document.documentElement.style.backgroundColor=``,document.body.style.backgroundColor=``;let t=F9(getComputedStyle(xnt()).backgroundColor),n=F9(getComputedStyle(document.body).backgroundColor),r=t??n??gnt[e];document.documentElement.style.backgroundColor=r,document.body.style.backgroundColor=r,bnt().setAttribute(`content`,r)}function Cnt(e){if(typeof window>`u`)return;let t=window.desktopBridge;t&&t.setTheme(e).catch(()=>{})}function L9(e,t=!1){let n=P9(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,I9(n),Cnt(e),t&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove(`no-transitions`)})),n)}function R9(e){typeof document>`u`||document.documentElement.style.setProperty(`--forge-ui-font-size`,`${N9(e,16)}px`)}function z9(e){typeof document>`u`||document.documentElement.style.setProperty(`--forge-code-font-size`,`${N9(e,13)}px`)}function B9(e){R9(e.uiFontSize),z9(e.codeFontSize)}if(typeof document<`u`){let e=vnt();L9(e.theme),B9(e)}function wnt(){let e=(0,Cl.c)(34),t=S0(Ont),n=S0(Dnt),r=S0(Ent),i=S0(Tnt),{updateSettings:a}=C0(),o;e[0]===t?o=e[1]:(o=()=>P9(t),e[0]=t,e[1]=o);let[s,c]=(0,F.useState)(o),l;e[2]===a?l=e[3]:(l=e=>{a({theme:e}),c(L9(e,!0))},e[2]=a,e[3]=l);let u=l,d;e[4]===a?d=e[5]:(d=e=>{a({themeId:e})},e[4]=a,e[5]=d);let f=d,p;e[6]===a?p=e[7]:(p=e=>{let t=N9(e,16);a({uiFontSize:t}),R9(t)},e[6]=a,e[7]=p);let m=p,h;e[8]===a?h=e[9]:(h=e=>{let t=N9(e,13);a({codeFontSize:t}),z9(t)},e[8]=a,e[9]=h);let g=h,_,v;e[10]===t?(_=e[11],v=e[12]):(_=()=>{c(L9(t))},v=[t],e[10]=t,e[11]=_,e[12]=v),(0,F.useEffect)(_,v);let y,b;e[13]!==i||e[14]!==r?(y=()=>{B9({uiFontSize:r,codeFontSize:i})},b=[r,i],e[13]=i,e[14]=r,e[15]=y,e[16]=b):(y=e[15],b=e[16]),(0,F.useEffect)(y,b);let x,S;e[17]!==s||e[18]!==n?(S=()=>{pnt(n,s===`dark`?`dark`:`light`)},x=[n,s],e[17]=s,e[18]=n,e[19]=x,e[20]=S):(x=e[19],S=e[20]),(0,F.useEffect)(S,x);let C,w;e[21]===t?(C=e[22],w=e[23]):(C=()=>{if(t!==`system`||typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(j9),n=()=>{c(L9(`system`,!0))};return e.addEventListener(`change`,n),()=>{e.removeEventListener(`change`,n)}},w=[t],e[21]=t,e[22]=C,e[23]=w),(0,F.useEffect)(C,w);let T;return e[24]!==i||e[25]!==s||e[26]!==g||e[27]!==u||e[28]!==f||e[29]!==m||e[30]!==t||e[31]!==n||e[32]!==r?(T={theme:t,setTheme:u,themeId:n,setThemeId:f,resolvedTheme:s,uiFontSize:r,codeFontSize:i,setUiFontSize:m,setCodeFontSize:g},e[24]=i,e[25]=s,e[26]=g,e[27]=u,e[28]=f,e[29]=m,e[30]=t,e[31]=n,e[32]=r,e[33]=T):T=e[33],T}function Tnt(e){return e.codeFontSize}function Ent(e){return e.uiFontSize}function Dnt(e){return e.themeId}function Ont(e){return e.theme}function knt(){let e=(0,Cl.c)(10),t=S0(Lnt),n=S0(Int),r=S0(Fnt),i=S0(Pnt),a=S0(Nnt),o=S0(Mnt),s=S0(jnt),c=S0(Ant),l,u;e[0]!==n||e[1]!==r||e[2]!==t||e[3]!==i||e[4]!==s||e[5]!==c||e[6]!==a||e[7]!==o?(l=()=>{typeof document>`u`||lnt(document.documentElement,{fontFamilyCode:n,fontFamilyComposer:r,fontFamilySans:t,fontFamilyTerminal:i,fontSmoothing:s,glassOpacity:c,promptFontSize:a,terminalFontSize:o})},u=[n,r,t,i,s,c,a,o],e[0]=n,e[1]=r,e[2]=t,e[3]=i,e[4]=s,e[5]=c,e[6]=a,e[7]=o,e[8]=l,e[9]=u):(l=e[8],u=e[9]),(0,F.useEffect)(l,u)}function Ant(e){return e.glassOpacity}function jnt(e){return e.fontSmoothing}function Mnt(e){return e.terminalFontSize}function Nnt(e){return e.promptFontSize}function Pnt(e){return e.fontFamilyTerminal}function Fnt(e){return e.fontFamilyComposer}function Int(e){return e.fontFamilyCode}function Lnt(e){return e.fontFamilySans}function Rnt(e){let t=(0,F.useRef)(e);return(0,F.useInsertionEffect)(()=>void(t.current=e)),(0,F.useCallback)((...e)=>t.current(...e),[])}var znt=(0,F.createContext)(void 0);function Bnt(){return(0,F.useContext)(znt)}var Vnt={position:`absolute`,top:0,bottom:0,textAlign:`center`,whiteSpace:`normal`,touchAction:`none`},Hnt={display:`contents`};function Unt(){return null}var V9=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),H9=Symbol(`IGNORE_RESPONSE`),U9=class extends Error{constructor(){super(`WorkerPoolManager: operation canceled because the pool terminated`)}},W9=class extends Error{constructor(){super(`WorkerPoolManager: operation canceled before the task completed`)}},Wnt=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=C2,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 V9.default.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new V9.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??C2,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()||r9(a,this.renderOptions))return;let o=S7(e),c=[];if(M2(a.theme,this.renderOptions.theme)||(c=C7(o)?y9(o):await b9(o)),!s())return;if(this.highlighter!=null)p7(c,this.highlighter);else{let e=await x7({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 U9||!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);q9(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=S7(this.renderOptions.theme),i=[];if(i=C7(r)?y9(r):await b9(r),!this.isCurrentLifecycle(t)){n();return}let a=[];if(a=_9(e)?g9(e):await v9(e),!this.isCurrentLifecycle(t)){n();return}let[o]=await Promise.all([x7({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 U9||!this.isCurrentLifecycle(t)){n();return}this.initialized=!1,this.workersFailed=!0;for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,Y9(e));this.queueBroadcastStateChanges(),r(e)}})()}),this.queueBroadcastStateChanges()}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;let n=[],r=O7(),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=K9(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);X7(t)||n!=null&&w7(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||X7(e)||t!=null&&w7(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 Y7(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,lines:r})}highlightDiffAST(e,t){let n=this.getDiffResultCache(t);h9(t)||n!=null&&r9(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||h9(e)||t!=null&&r9(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:m9(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 U9;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 U9;for(let t of this.activeTaskById.values())`reject`in t?t.reject(e):q9(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&&(_9(r)?t.request.resolvedLanguages=g9(r):t.request.resolvedLanguages=await v9(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,Y9(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 H9;if(t.type===`error`){let e=Error(t.error);if(t.stack&&(e.stack=t.stack),`reject`in n)n.reject(e);else if(q9(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)||!w7(i,this.getFileRenderOptions()))throw H9;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)||!r9(i,this.getDiffRenderOptions()))throw H9;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!==H9&&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,q9(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&&(q9(t)&&(this.rejectRenderTaskCallbacks(t,new W9),this.clearInstanceRequests(t),this.clearHighlightKey(t)),this.activeTaskById.delete(t.id))}executeTask(e,t){G9(t.request)&&this.maybeAttachCustomExtensions(e,t.request),this.activeTaskById.has(t.id)||this.assignWorkerToTask(t,e);for(let n of K9(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),q9(t)?(this.notifyHighlightError(t,n),this.rejectRenderTaskCallbacks(t,Y9(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=O7();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 J9(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 W9),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new W9),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()))q9(e)&&e.renderOptionsVersion!==this.renderOptionsVersion&&this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(let t of J9(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 J9(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(let t of J9(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 J9(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)&&a4(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)&&n9(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())q9(e)&&(yield e)}generateRequestId(){return`req_${++this.nextRequestId}`}};function G9(e){return e.type===`initialize`||e.type===`file`||e.type===`diff`}function K9(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??D7(e.request.file.name));break;case`diff`:t.add(e.request.diff.lang??D7(e.request.diff.name)),t.add(e.request.diff.lang??D7(e.request.diff.prevName??`-`))}return t.delete(`text`),Array.from(t)}function q9(e){return e?.type===`file`||e?.type===`diff`}function J9(e){return e.instances}function Y9(e){return e instanceof Error?e:Error(String(e))}var X9;function Gnt({poolOptions:e,highlighterOptions:t}){return X9??=new Wnt(e,t),X9}function Knt(){X9!=null&&(X9.terminate(),X9=void 0)}var Z9=(0,F.createContext)(void 0),Q9=0;function qnt({children:e,poolOptions:t,highlighterOptions:n}){let[r]=(0,F.useState)(()=>{if(!(typeof window>`u`))return Gnt({poolOptions:t,highlighterOptions:n})});return(0,F.useInsertionEffect)(()=>{if(r!=null)return Q9++,()=>{Q9--}},[r]),(0,F.useEffect)(()=>()=>{Q9===0&&Knt()},[]),(0,kr.jsx)(Z9.Provider,{value:r,children:e})}function Jnt(){return(0,F.useContext)(Z9)}function $9(e){return Xt(`flex items-center justify-between gap-2 px-4 wco:pr-[calc(100vw-env(titlebar-area-width)-env(titlebar-area-x)+1em)]`,Ar&&e!==`sheet`?`h-[52px] border-b border-border wco:h-[env(titlebar-area-height)]`:`h-12 wco:max-h-[env(titlebar-area-height)]`)}function Ynt(e){let t=(0,Cl.c)(10),n=Ar&&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=Xt(`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,kr.jsx)(`div`,{className:$9(e.mode),children:e.header}):(0,kr.jsx)(`div`,{className:`border-b border-border`,children:(0,kr.jsx)(`div`,{className:$9(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,kr.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 Xnt(){let e=(0,Cl.c)(4),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,kr.jsx)(BY,{className:`absolute left-0 top-1/2 size-6 -translate-y-1/2 rounded-md border border-border/50`}),n=(0,kr.jsx)(BY,{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,kr.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[t,n,(0,kr.jsxs)(`div`,{className:`flex gap-1 overflow-hidden px-8 py-0.5`,children:[(0,kr.jsx)(BY,{className:`h-6 w-16 shrink-0 rounded-md`}),(0,kr.jsx)(BY,{className:`h-6 w-24 shrink-0 rounded-md`}),(0,kr.jsx)(BY,{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,kr.jsxs)(kr.Fragment,{children:[r,(0,kr.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,kr.jsx)(BY,{className:`size-7 rounded-md`}),(0,kr.jsx)(BY,{className:`size-7 rounded-md`})]})]}),e[3]=i):i=e[3],i}function Znt(e){let t=(0,Cl.c)(7),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,kr.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,kr.jsx)(BY,{className:`h-4 w-32 rounded-full`}),(0,kr.jsx)(BY,{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,kr.jsxs)(`div`,{className:`space-y-2`,children:[(0,kr.jsx)(BY,{className:`h-3 w-full rounded-full`}),(0,kr.jsx)(BY,{className:`h-3 w-full rounded-full`}),(0,kr.jsx)(BY,{className:`h-3 w-10/12 rounded-full`}),(0,kr.jsx)(BY,{className:`h-3 w-11/12 rounded-full`}),(0,kr.jsx)(BY,{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,kr.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 px-3 py-4`,children:[r,(0,kr.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,kr.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col p-2`,children:(0,kr.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}export{dtt as $,bJ as $a,_Z as $i,Q2e as $n,EGe as $o,H1e as $r,Br as $s,k2 as $t,r9 as A,WJ as Aa,Xne as Ac,rZe as Ai,g2 as An,Lq as Ao,t0 as Ar,Fo as As,G4 as At,Ett as B,gqe as Ba,kZ as Bi,O4e as Bn,WGe as Bo,u0 as Br,yi as Bs,s4 as Bt,Wtt as C,RY as Ca,$ne as Cc,DZe as Ci,t3e as Cn,dKe as Co,C0 as Cr,Tl as Cs,G6e as Ct,Gtt as D,qJ as Da,Hne as Dc,cZe as Di,K4e as Dn,Rq as Do,p0 as Dr,Lo as Ds,q4 as Dt,l9 as E,Wqe as Ea,Qne as Ec,yQ as Ei,H4e as En,Iq as Eo,P0e as Er,Io as Es,c6e as Et,Ntt as F,HJ as Fa,NZ as Fi,N4e as Fn,XGe as Fo,k0e as Fr,Ti as Fs,p4 as Ft,btt as G,$Ke as Ga,$Ye as Gi,n4e as Gn,kGe as Go,Y1e as Gr,Sre as Gs,L2 as Gt,wtt as H,lqe as Ha,CZ as Hi,Q0 as Hn,Pq as Ho,r0e as Hr,Tre as Hs,o4 as Ht,Att as I,VJ as Ia,MXe as Ii,A4e as In,nKe as Io,w0e as Ir,wi as Is,u4 as It,gtt as J,qKe as Ja,fZ as Ji,$2e as Jn,LGe as Jo,Z1e as Jr,ii as Js,h3e as Jt,$7 as K,UKe as Ka,dZ as Ki,t4e as Kn,AGe as Ko,U1e as Kr,bre as Ks,I2 as Kt,ktt as L,NJ as La,AZ as Li,j4e as Ln,ZGe as Lo,E0e as Lr,bi as Ls,A3e as Lt,Ptt as M,zJ as Ma,Kne as Mc,iZe as Mi,P4e as Mn,Hq as Mo,b0e as Mr,Di as Ms,F4 as Mt,Ftt as N,RJ as Na,mr as Nc,uQ as Ni,d2 as Nn,uKe as No,T0e as Nr,Ei as Ns,I4 as Nt,ztt as O,Gqe as Oa,Wne as Oc,pQ as Oi,q4e as On,Bq as Oo,r0 as Or,Bo as Os,s6e as Ot,Ltt as P,Uqe as Pa,fQ as Pi,k4e as Pn,Nq as Po,S0e as Pr,Ci as Ps,P4 as Pt,X7 as Q,SJ as Qa,QYe as Qi,s2e as Qn,_q as Qo,J1e as Qr,sre as Qs,j2 as Qt,Ott as R,Vqe as Ra,IXe as Ri,M4e as Rn,KGe as Ro,D0e as Rr,Si as Rs,k3e as Rt,o9 as S,kJe as Sa,Yne as Sc,PQ as Si,y2 as Sn,gKe as So,S0 as Sr,Fce as Ss,W6e as St,c9 as T,DJe as Ta,yr as Tc,TZe as Ti,U4e as Tn,zq as To,L0e as Tr,Wo as Ts,J4 as Tt,Stt as U,AJ as Ua,SZ as Ui,e2 as Un,BGe as Uo,i0e as Ur,gi as Us,a4 as Ut,Ttt as V,Dqe as Va,EZ as Vi,$0 as Vn,$Ge as Vo,O0e as Vr,vi as Vs,c4 as Vt,xtt as W,OJ as Wa,xZ as Wi,n2 as Wn,wq as Wo,q1e as Wr,ui as Ws,T3e as Wt,ptt as X,EJ as Xa,ZYe as Xi,v2e as Xn,zGe as Xo,M1 as Xr,ei as Xs,m3e as Xt,htt as Y,JKe as Ya,vZ as Yi,e2e as Yn,sGe as Yo,G1e as Yr,ri as Ys,P2 as Yt,ftt as Z,TJ as Za,gZ as Zi,y2e as Zn,RGe as Zo,j1 as Zr,$r as Zs,M2 as Zt,tnt as _,PJe as _a,Tr as _c,o$ as _i,Q4e as _n,Xq as _o,_2e as _r,Bce as _s,S7 as _t,qnt as a,sYe as aa,Vr as ac,q$e as ai,S2 as an,aJ as ao,Z2e as ar,WWe as as,Y7 as at,f9 as b,MJe as ba,Sr as bc,xQe as bi,b2 as bn,Jq as bo,q0e as br,Lce as bs,s8e as bt,Hnt as c,_X as ca,Ur as cc,F$e as ci,d3e as cn,kKe as co,A0 as cr,kK as cs,Vet as ct,Rnt as d,bX as da,Mr as dc,m$ as di,C2 as dn,tJ as do,F0 as dr,TK as ds,Fet as dt,tXe as ea,zr as ec,b1e as ei,O2 as en,pJ as eo,c2e as er,Oq as es,utt as et,I9 as f,VY as fa,jr as fc,QQe as fi,s3e as fn,MKe as fo,u2e as fr,CK as fs,Net as ft,w9 as g,BY as ga,Dr as gc,a$ as gi,p3e as gn,Zq as go,L0 as gr,Vce as gs,jet as gt,int as h,HY as ha,Or as hc,t$e as hi,v2 as hn,NKe as ho,D0 as hr,xWe as hs,C7 as ht,Z9 as i,oYe as ia,Pr as ic,X$e as ii,Y4e as in,dJ as io,o2e as ir,iq as is,ltt as it,n9 as j,UJ as ja,Vne as jc,aZe as ji,G4e as jn,Wq as jo,_0e as jr,kre as js,R4 as jt,Btt as k,GJ as ka,pr as kc,nZe as ki,W4e as kn,Vq as ko,i0 as kr,Vo as ks,K4 as kt,Unt as l,hX as la,Xr as lc,g$ as li,f3e as ln,bKe as lo,l2e as lr,DK as ls,D7 as lt,wnt as m,UY as ma,rre as mc,$Qe as mi,J4e as mn,PKe as mo,X2e as mr,wK as ms,w7 as mt,Znt as n,YYe as na,lre as nc,A1 as ni,o3e as nn,BKe as no,Y2e as nr,cq as ns,ctt as nt,Jnt as o,SX as oa,Hr as oc,x$ as oi,c3e as on,sJ as oo,U2e as or,zK as os,J7 as ot,knt as p,FJe as pa,Ar as pc,s$e as pi,T2 as pn,yKe as po,H2e as pr,bWe as ps,Met as pt,_tt as q,GKe as qa,eXe as qi,X0 as qn,PGe as qo,X1e as qr,xre as qs,F2 as qt,Ynt as r,yZ as ra,cre as rc,P$ as ri,a3e as rn,yJ as ro,i2e as rr,aq as rs,stt as rt,Vnt as s,mX as sa,Lr as sc,w$ as si,l3e as sn,EKe as so,d2e as sr,LK as ss,Het as st,Xnt as t,XYe as ta,fre as tc,Q1e as ti,e3e as tn,vJ as to,r2e as tr,FGe as ts,ott as tt,Bnt as u,uX as ua,Jr as uc,h$ as ui,u3e as un,nJ as uo,n2e as ur,EK as us,Ret as ut,h9 as v,jJe as va,wr as vc,DQe as vi,$4e as vn,Qq as vo,E0 as vr,Hce as vs,ket as vt,Vtt as w,TJe as wa,Zne as wc,kZe as wi,Z4e as wn,Uq as wo,f0 as wr,El as ws,o3 as wt,s9 as x,NJe as xa,xr as xc,tQe as xi,x2 as xn,qq as xo,K0e as xr,Rce as xs,e8e as xt,m9 as y,AJe as ya,Cr as yc,AQe as yi,X4e as yn,Kq as yo,J0e as yr,Ice as ys,x7 as yt,Dtt as z,yqe as za,MZ as zi,T4e as zn,JGe as zo,C0e as zr,xi as zs,O3e as zt};
|
|
2531
|
+
//# sourceMappingURL=DiffPanelShell-AKUK0L-g.js.map
|