@cmmd-center/forge 0.13.126 → 0.13.127

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/workspaceReadinessAtom-D6bgTvKb.js","assets/rolldown-runtime-hePW80VL.js","assets/atomRegistry-C1yW8tyM.js","assets/Stream-mUTFnSY9.js","assets/angular-html-B8mrqUL5.js","assets/html-XwrE-1r6.js","assets/javascript-obGGvMPs.js","assets/css-CNuuLpMC.js","assets/angular-ts-Bzix210W.js","assets/scss-YesllqfO.js","assets/apl-Dhin1L29.js","assets/xml-BlnrEAEy.js","assets/java-DdHNQ9hk.js","assets/json-DAgxKhMr.js","assets/astro-B-4NNgOP.js","assets/typescript-BydbNFcO.js","assets/postcss-BXeXVLqQ.js","assets/tsx-CUOciP0b.js","assets/blade-Wr94ul2N.js","assets/html-derivative-i4STDFnl.js","assets/sql-ClgswhA6.js","assets/bsl-BkkzgIyY.js","assets/sdbl-bTVj8UrX.js","assets/c-iCihek07.js","assets/cairo-DLTphjLi.js","assets/python-gzcpVVnB.js","assets/cobol-Cw2-KvLW.js","assets/coffee-CiiSLhB6.js","assets/cpp-DjoE5qBx.js","assets/regexp-DR20uMnK.js","assets/glsl-D5MA2a_X.js","assets/crystal-wCJpIkgB.js","assets/shellscript-Da78Ox-3.js","assets/edge-DCY0a-ow.js","assets/elixir-DP304Xio.js","assets/elm-o4NJxfws.js","assets/erb-BcNYoZVd.js","assets/ruby-2bd251b9.js","assets/haml-CwEpbK1d.js","assets/graphql-Ctjuxyvl.js","assets/jsx-gTgmArGx.js","assets/lua-FONpmTUP.js","assets/yaml-Du_6cdrH.js","assets/erlang-Cphh6RMH.js","assets/markdown-BYOwaDjH.js","assets/fortran-fixed-form-DEKoE2YW.js","assets/fortran-free-form-CYNrtFtB.js","assets/fsharp-D13ZGOAj.js","assets/gdresource-C0sCabJj.js","assets/gdshader-CBce3t8t.js","assets/gdscript-Cp2uCuqX.js","assets/git-commit-BSykSTBG.js","assets/diff-woXpYk--.js","assets/git-rebase-BDPpS8w6.js","assets/glimmer-js-BONyzAsu.js","assets/glimmer-ts-f9c0GCOe.js","assets/hack-7ztQ7Up-.js","assets/handlebars-ryMP1rBR.js","assets/http-kmH8AyfE.js","assets/hurl-DCZHXKU4.js","assets/csv-Dx-8-gkx.js","assets/hxml-B0Qn7Nwc.js","assets/haxe-OTjmBuCE.js","assets/jinja-B-tLrNsM.js","assets/jison-CBjhYtSs.js","assets/julia-CjHxn3vf.js","assets/r-D6UWEOL2.js","assets/just-CZ9bduw9.js","assets/perl-BAov3eih.js","assets/latex-D9bvcAJr.js","assets/tex-0w6-Dtgt.js","assets/liquid-G0MH4h_m.js","assets/marko-DV5GrDmo.js","assets/less-DVTAwKKz.js","assets/mdc-cg1lnqpW.js","assets/nextflow-BJtWHP5T.js","assets/nextflow-groovy-DJMQeKeT.js","assets/nginx-BTMw9COX.js","assets/nim-B6yJ_yaC.js","assets/php-Cg76ANFt.js","assets/pug-DkgDHZci.js","assets/qml-_a-QhfPD.js","assets/razor-D3EoCAik.js","assets/csharp-Ct8U2NOr.js","assets/rst-YTmaoyaq.js","assets/cmake-Bj61d0ZC.js","assets/sas-B6p8-ynO.js","assets/shaderlab-TOUzSsQk.js","assets/hlsl-Cvrh5tZx.js","assets/shellsession-CVsQGYfZ.js","assets/soy-DEd-qcad.js","assets/sparql-D_iOobhT.js","assets/turtle-ByJddavk.js","assets/stata-RoaAgbqU.js","assets/surrealql-DIn4NJsS.js","assets/svelte-Bj3Hmc9F.js","assets/templ-TjxbArHn.js","assets/go-rLFTqkRN.js","assets/ts-tags-DFwAVxhO.js","assets/twig-BbcH-NR0.js","assets/vue-BNi0qJZP.js","assets/vue-html-DkKkQnZL.js","assets/vue-vine-DFaKYU4X.js","assets/stylus-B6D30XZt.js","assets/xsl-BOPS8gLt.js"])))=>i.map(i=>d[i]);
2
- import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{$ as r,$t as i,Aa as a,An as o,Ar as s,At as c,B as l,Br as u,Bt as d,Ci as f,Dn as p,Ei as m,En as h,Er as g,Fa as _,Fi as v,Fn as y,Gn as b,Gt as x,Ha as ee,Hn as te,Hr as ne,Ht as re,Ia as ie,It as ae,J as oe,Jt as se,Kt as ce,L as le,La as ue,Ln as de,Lt as fe,M as pe,Ma as me,Mr as he,Ni as ge,Nn as _e,Nt as ve,Pi as ye,Pn as be,Pt as xe,Qi as Se,Rn as Ce,Rr as we,Rt as Te,Si as Ee,Ta as De,Tn as Oe,Tr as ke,Tt as Ae,Ua as je,Un as Me,Ur as Ne,Ut as Pe,V as Fe,Va as Ie,Vn as Le,Vr as Re,Vt as ze,W as Be,Wa as Ve,Wn as He,Wr as Ue,Wt as We,X as Ge,Yi as Ke,Yt as qe,Z as Je,Zi as Ye,_ as Xe,_t as Ze,an as Qe,at as $e,bn as et,br as tt,bt as nt,ca as rt,ci as it,ct as at,dn as ot,ea as st,en as ct,et as lt,fi as ut,gi as dt,gn as ft,hn as pt,hr as mt,ht,in as gt,it as _t,ja as vt,jn as yt,jr as bt,jt as xt,ki as St,kr as Ct,kt as wt,li as Tt,ln as Et,m as Dt,mn as Ot,mr as kt,na as At,ni as jt,nt as Mt,oa as Nt,or as Pt,pn as Ft,pt as It,q as Lt,qt as Rt,r as zt,rn as Bt,rr as Vt,rt as Ht,sn as Ut,un as Wt,ut as Gt,vn as Kt,vr as qt,wn as Jt,wr as Yt,wt as Xt,xi as Zt,xn as Qt,y as $t,yi as en,yn as tn,z as nn,zn as rn,zt as an}from"./Stream-mUTFnSY9.js";import{i as on,l as sn,n as cn,o as ln,s as un}from"./atomRegistry-C1yW8tyM.js";import{_n as dn,on as fn}from"./CompositeItem-BxPZ_9BJ.js";import{$ as pn,A as mn,B as hn,Bn as gn,C as _n,D as vn,Dt as yn,G as bn,H as S,Hn as C,Jn as xn,Kn as Sn,L as Cn,Ln as wn,M as Tn,N as En,O as Dn,Q as On,Qt as kn,Rt as An,S as jn,Sn as Mn,T as Nn,Tn as Pn,U as Fn,Un as In,Vn as Ln,Wn as Rn,Wt as zn,X as Bn,Y as Vn,Yt as Hn,Z as Un,_n as Wn,at as Gn,ct as Kn,dn as qn,dt as Jn,fn as Yn,gn as Xn,gt as Zn,hn as Qn,ht as $n,in as er,it as tr,ln as nr,lt as rr,mn as ir,mt as ar,ot as or,pn as sr,qn as cr,rn as lr,st as ur,t as dr,tn as fr,tt as pr,un as mr,ut as hr,vt as gr,w as _r,wn as vr,yn as yr,yt as br,zn as xr}from"./cmmdForgeRuntimeListResource-CRVF6pin.js";import{$t as Sr,A as Cr,At as wr,Bt as Tr,C as Er,Ct as Dr,Dt as Or,En as kr,Et as Ar,G as jr,Gn as Mr,Gt as Nr,Hn as Pr,Ht as Fr,In as w,Jt as Ir,Kn as Lr,Kt as Rr,Lt as zr,Mt as Br,Nn as Vr,Nt as Hr,Ot as Ur,Q as Wr,Qt as Gr,R as Kr,Rt as qr,Sn as Jr,U as Yr,Un as Xr,Ut as Zr,Vn as Qr,Vt as $r,W as ei,Wn as ti,Wt as ni,Xt as ri,Yn as ii,Yt as ai,Zt as oi,_n as si,_t as ci,an as li,b as ui,c as di,cn as fi,dt as pi,en as mi,er as hi,ft as gi,gn as _i,gt as vi,hn as yi,in as bi,j as xi,jt as Si,kn as Ci,l as wi,mt as Ti,nn as Ei,nt as Di,on as Oi,pn as ki,qt as Ai,rt as ji,s as T,sn as Mi,tn as Ni,tt as Pi,ut as Fi,vn as E,vt as Ii,w as Li,x as Ri,xn as zi,yn as Bi,zn as Vi,zt as Hi}from"./src-BAHvoNAY.js";import{$ as Ui,A as Wi,B as Gi,C as Ki,D as qi,E as Ji,F as Yi,G as Xi,H as Zi,I as Qi,J as $i,K as ea,L as ta,N as na,O as ra,P as ia,Q as aa,R as oa,T as sa,U as ca,W as la,X as ua,Y as da,Z as fa,_ as pa,et as ma,it as ha,nt as ga,q as _a,rt as va,tt as ya,w as ba}from"./cmmdAuthRedirect-BYBGztDm.js";import{d as xa,f as Sa,n as Ca,t as wa}from"./utils-B4G-Q0s7.js";import{t as D}from"./preload-helper-Czpn1I53.js";import{a as Ta,i as Ea,n as Da,o as Oa,r as ka,t as Aa}from"./debouncer-BmyJL8Gi.js";import{t as ja}from"./transport-CgH8pQK3.js";import{n as Ma,t as Na}from"./workspaceReadinessAtom-D6bgTvKb.js";import{a as Pa,c as Fa,n as Ia,r as La,s as Ra,u as za}from"./themePalette-gr6ZYaOx.js";function Ba(e){return e[e.length-1]}function Va(e,t){return typeof e==`function`?e(t):e}var Ha=Object.prototype.hasOwnProperty,Ua=Object.prototype.propertyIsEnumerable;function Wa(e){for(let t in e)if(Ha.call(e,t))return!0;return!1}var Ga=()=>Object.create(null),Ka=(e,t)=>qa(e,t,Ga);function qa(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=Za(e)&&Za(i);if(!a&&!(Ya(e)&&Ya(i)))return i;let o=a?e:Ja(e);if(!o)return i;let s=a?i:Ja(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:Ha.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=qa(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function Ja(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(!Ua.call(e,r))return!1;t.push(r)}return t}function Ya(e){if(!Xa(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Xa(n)||!n.hasOwnProperty(`isPrototypeOf`))}function Xa(e){return Object.prototype.toString.call(e)===`[object Object]`}function Za(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Qa(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(!Qa(e[r],t[r],n))return!1;return!0}if(Ya(e)&&Ya(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!Qa(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||!Qa(e[o],t[o],n)))return!1;return i===a}return!1}var $a=/[\x00-\x1f\x7f"<>`{}]/g;function eo(e){return e.replace($a,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function to(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 eo(t)}var no=[`http:`,`https:`,`mailto:`,`tel:`];function ro(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function io(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+=to(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=to(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function ao(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function oo(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 so(){throw Error(`Invariant failed`)}var O=t(Ve(),1),co=O.createContext(null);function lo(e){return O.useContext(co)}var uo=O.createContext(void 0),fo=O.createContext(void 0),po=dn();function mo(e,t){return e===t}function ho(e,t,n=mo){let r=(0,O.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,O.useCallback)(()=>e?.get(),[e]);return(0,po.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var go={};function _o(e,t){let n=O.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=qa(n.current,i):i}}function vo(e){let t=lo(),n=O.useContext(e.from?fo:uo),r=e.from??n,i=t.stores.getMatchStore(r),a=_o(e,t),o=ho(i,e=>e?a(e):go);if(o!==go)return o;(e.shouldThrow??!0)&&so()}function yo(e){return vo({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 bo=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(){}},xo=new class extends bo{#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`}},So={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Co=new class{#e=So;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 wo(e){setTimeout(e,0)}var To=typeof window>`u`||`Deno`in globalThis;function Eo(){}function Do(e,t){return typeof e==`function`?e(t):e}function Oo(e){return typeof e==`number`&&e>=0&&e!==1/0}function ko(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Ao(e,t){return typeof e==`function`?e(t):e}function jo(e,t){return typeof e==`function`?e(t):e}function Mo(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Po(o,t.options))return!1}else if(!Io(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 No(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Fo(t.options.mutationKey)!==Fo(a))return!1}else if(!Io(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Po(e,t){return(t?.queryKeyHashFn||Fo)(e)}function Fo(e){return JSON.stringify(e,(e,t)=>Vo(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Io(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(!Io(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Io(e[r],t[r]))return!1;return!0}return!1}var Lo=Object.prototype.hasOwnProperty;function Ro(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Bo(e)&&Bo(t);if(!r&&!(Vo(e)&&Vo(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:Lo.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Ro(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function zo(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 Bo(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Vo(e){if(!Ho(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Ho(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Ho(e){return Object.prototype.toString.call(e)===`[object Object]`}function Uo(e){return new Promise(t=>{Co.setTimeout(t,e)})}function Wo(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Ro(e,t)}function Go(e){return e}function Ko(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function qo(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Jo=Symbol();function Yo(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Jo?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Xo(e,t){return typeof e==`function`?e(...t):!!e}function Zo(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 Qo=(()=>{let e=()=>To;return{isServer(){return e()},setIsServer(t){e=t}}})();function $o(){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 es=wo;function ts(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=es,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 ns=ts(),rs=new class extends bo{#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 is(e){return Math.min(1e3*2**e,3e4)}function as(e){return(e??`online`)!==`online`||rs.isOnline()}var os=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function ss(e){let t=!1,n=0,r,i=$o(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new os(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>xo.isFocused()&&(e.networkMode===`always`||rs.isOnline())&&e.canRun(),u=()=>as(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??(Qo.isServer()?0:3),o=e.retryDelay??is,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),Uo(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 cs=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Oo(this.gcTime)&&(this.#e=Co.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Qo.isServer()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(Co.clearTimeout(this.#e),this.#e=void 0)}};function ls(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=>{Zo(e,()=>t.signal,()=>n=!0)},u=Yo(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?qo:Ko;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?ds:us,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:us(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 us(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 ds(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function fs(e,t){return t?us(e,t)!=null:!1}function ps(e,t){return!t||!e.getPreviousPageParam?!1:ds(e,t)!=null}var ms=class extends cs{#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=_s(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=_s(this.options);e.data!==void 0&&(this.setState(gs(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Wo(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(Eo).catch(Eo):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=>jo(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Jo||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Ao(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:!ko(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=Yo(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`?ls(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=ss({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof os&&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 os){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,...hs(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...gs(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),ns.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function hs(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:as(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function gs(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function _s(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 vs=class extends bo{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=$o(),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),bs(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return xs(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return xs(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 jo(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&&!zo(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Ss(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||jo(this.options.enabled,this.#t)!==jo(t.enabled,this.#t)||Ao(this.options.staleTime,this.#t)!==Ao(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||jo(this.options.enabled,this.#t)!==jo(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 ws(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(Eo)),t}#g(){this.#b();let e=Ao(this.options.staleTime,this.#t);if(Qo.isServer()||this.#r.isStale||!Oo(e))return;let t=ko(this.#r.dataUpdatedAt,e)+1;this.#d=Co.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,!(Qo.isServer()||jo(this.options.enabled,this.#t)===!1||!Oo(this.#p)||this.#p===0)&&(this.#f=Co.setInterval(()=>{(this.options.refetchIntervalInBackground||xo.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(Co.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(Co.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&&bs(e,t),o=i&&Ss(e,n,t,r);(a||o)&&(l={...l,...hs(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=Wo(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=Wo(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:Cs(e,t),refetch:this.refetch,promise:this.#o,isEnabled:jo(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=$o();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),!zo(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){ns.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function ys(e,t){return jo(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||jo(t.retryOnMount,e)!==!1)}function bs(e,t){return ys(e,t)||e.state.data!==void 0&&xs(e,t,t.refetchOnMount)}function xs(e,t,n){if(jo(t.enabled,e)!==!1&&Ao(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Cs(e,t)}return!1}function Ss(e,t,n,r){return(e!==t||jo(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Cs(e,n)}function Cs(e,t){return jo(t.enabled,e)!==!1&&e.isStaleByTime(Ao(t.staleTime,e))}function ws(e,t){return!zo(e.getCurrentResult(),t)}var k=je(),Ts=O.createContext(void 0),Es=e=>{let t=O.useContext(Ts);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Ds=({client:e,children:t})=>(O.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,k.jsx)(Ts.Provider,{value:e,children:t})),Os=O.createContext(!1),ks=()=>O.useContext(Os);Os.Provider;function As(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var js=O.createContext(As()),Ms=()=>O.useContext(js),Ns=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Xo(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Ps=e=>{O.useEffect(()=>{e.clearReset()},[e])},Fs=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Xo(n,[e.error,r])),Is=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))}},Ls=(e,t)=>e.isLoading&&e.isFetching&&!t,Rs=(e,t)=>e?.suspense&&t.isPending,zs=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Bs(e,t,n){let r=ks(),i=Ms(),a=Es(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,Is(o),Ns(o,i,s),Ps(i);let l=!a.getQueryCache().get(o.queryHash),[u]=O.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(O.useSyncExternalStore(O.useCallback(e=>{let t=f?u.subscribe(ns.batchCalls(e)):Eo;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),O.useEffect(()=>{u.setOptions(o)},[o,u]),Rs(o,d))throw zs(o,u,i);if(Fs({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&&!Qo.isServer()&&Ls(d,r)&&(l?zs(o,u,i):s?.promise)?.catch(Eo).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function Vs(e,t){return Bs(e,vs,t)}function Hs(e){return e}var Us=g,Ws=globalThis.Number,Gs=e=>{if(e===`NaN`)return v(NaN);if(e===`Infinity`)return v(1/0);if(e===`-Infinity`)return v(-1/0);if(e.trim()===``)return ye();let t=Ws(e);return Ws.isNaN(t)?ye():v(t)},Ks=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`]],qs=`~effect/http/HttpClientRequest`,Js={[qs]:qs,...Se,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Nt(this.headers),body:this.body.toJSON()}},pipe(){return Ie(this,arguments)}};function Ys(e,t,n,r,i,a){let o=Object.create(Js);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var Xs=Ys(`GET`,``,Gr,ye(),Fr,ri),Zs=e=>(t,n)=>$s(Xs,{method:e,url:t,...n??void 0}),Qs=Zs(`POST`),$s=_(2,(e,t)=>{let n=e;return t.method&&(n=ec(n,t.method)),t.url&&(n=ac(n,t.url)),t.headers&&(n=nc(n,t.headers)),t.urlParams&&(n=oc(n,t.urlParams)),t.hash&&(n=sc(n,t.hash)),t.body&&(n=cc(n,t.body)),t.accept&&(n=rc(n,t.accept)),t.acceptJson&&(n=ic(n)),n}),ec=_(2,(e,t)=>Ys(t,e.url,e.urlParams,e.hash,e.headers,e.body)),tc=_(3,(e,t,n)=>Ys(e.method,e.url,e.urlParams,e.hash,Ir(e.headers,t,n),e.body)),nc=_(2,(e,t)=>Ys(e.method,e.url,e.urlParams,e.hash,ai(e.headers,t),e.body)),rc=_(2,(e,t)=>tc(e,`Accept`,t)),ic=rc(`application/json`),ac=_(2,(e,t)=>{if(typeof t==`string`)return Ys(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Sr(n.searchParams),i=Zt(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,Ys(e.method,n.toString(),r,i,e.headers,e.body)}),oc=_(2,(e,t)=>Ys(e.method,e.url,Ni(e.urlParams,t),e.hash,e.headers,e.body)),sc=_(2,(e,t)=>Ys(e.method,e.url,e.urlParams,v(t),e.headers,e.body)),cc=_(2,(e,t)=>{let n=e.headers;return t._tag===`Empty`||t._tag===`FormData`?n=Ai(Ai(n,`Content-Type`),`Content-length`):(t.contentType&&(n=Ir(n,`content-type`,t.contentType)),t.contentLength!==void 0&&(n=Ir(n,`content-length`,t.contentLength.toString()))),Ys(e.method,e.url,e.urlParams,e.hash,n,t)}),lc=e=>ni({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${ge(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),uc=`~effect/http/HttpClient`,dc=Tt(`effect/HttpClient`),fc=_(2,(e,t)=>mc(n=>t(e.postprocess(n)),e.preprocess)),pc=fc(Mt(qr)),mc=(e,t)=>{let n=Object.create(hc);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},hc={[uc]:uc,pipe(){return Ie(this,arguments)},...Se,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(Ks.map(([e,t])=>[t,function(t,n){return this.execute(Zs(e)(t,n))}]))},gc=e=>mc(t=>Mt(t,t=>Kt(n=>{let i=Cc.get(t),a=i??new AbortController,o=mi(t.url,t.urlParams,m(t.hash));if(jt(o))return r(new Ei({reason:new bi({request:t,cause:o.failure})}));let s=o.success;if(n.getRef(Ct)||n.getRef(vc)(t)){let r=e(t,s,a.signal,n);return i?r:Ft(e=>Ae(e(r),{onSuccess(e){return Sc.register(e,a),ct(new wc(e,a))},onFailure(e){return kt(e)&&a.abort(),lt(e)}}))}return pt(n.getRef(bc)(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($r),l=Rr(t.headers,c);for(let e in l)r.attribute(`http.request.header.${e}`,String(l[e]));return t=n.getRef(yc)?nc(t,lc(r)):t,Ft(o=>o(e(t,s,a.signal,n)).pipe(tn(r,{captureStackTrace:!1}),Ae({onSuccess:e=>{r.attribute(`http.response.status_code`,e.status);let t=Rr(e.headers,c);for(let e in t)r.attribute(`http.response.header.${e}`,String(t[e]));return i?ct(e):(Sc.register(e,a),ct(new wc(e,a)))},onFailure(e){return!i&&kt(e)&&a.abort(),lt(e)}})))})})),ct),_c=_(2,(e,t)=>{let n=Oe(t),r=n?`errors-and-responses`:t.retryOn??`errors-and-responses`,i=n?t:t.schedule,o=i&&h(i),s=n?void 0:t.times;return fc(e,ie(r===`errors-only`?ue:ae({schedule:o,times:s,while:Dc}),r===`response-only`?ue:fe({while:n||t.while===void 0?Tc:a(Tc,t.while),schedule:i,times:s})))}),vc=it(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>vt}),yc=it(`effect/HttpClient/TracerPropagationEnabled`,{defaultValue:me}),bc=it(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),xc=e=>yt(dc)(oe(t=>nt(e,e=>fc(e,Ot(e=>dt(t,e)))))),Sc=(()=>{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))}}})(),Cc=new WeakMap,wc=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[zr]=zr;[Tr]=Tr;applyInterrupt(e){return Bt(()=>(Sc.unregister(this.original),wt(e,()=>gt(()=>{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 Xe(()=>(Sc.unregister(this.original),zt(this.original.stream,gt(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[st](){return this.original[st]()}pipe(){return Ie(this,arguments)}},Tc=e=>tt(e)||Ec(e),Ec=e=>Oi(e)&&(e.reason._tag===`TransportError`||e.reason._tag===`StatusCodeError`&&Dc(e.reason.response)),Dc=e=>e.status===408||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504,Oc=`~effect/ManagedRuntime`,kc=(e,t)=>{let n=t?.memoMap??_e(),r=He(`parallel`),i=te(r,`sequential`),a={onFiberStart:le(r)},s=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,c,l=Kt(t=>(c||=d(Qe(o(e,n,i),e=>gt(()=>{u.cachedContext=e})),{...a,scheduler:t.currentScheduler}),_t(pe(c)))),u={[Oc]:Oc,memoMap:n,scope:r,contextEffect:l,cachedContext:void 0,context(){return u.cachedContext===void 0?re(u.contextEffect):Promise.resolve(u.cachedContext)},dispose(){return re(u.disposeEffect)},disposeEffect:Bt(()=>(u.contextEffect=Ge(`ManagedRuntime disposed`),u.cachedContext=void 0,Le(u.scope,Pt))),runFork(e,t){return u.cachedContext===void 0?d(Ac(u,e),s(t)):ze(u.cachedContext)(e,s(t))},runCallback(e,t){return u.cachedContext===void 0?Te(Ac(u,e),s(t)):an(u.cachedContext)(e,s(t))},runSyncExit(e){return u.cachedContext===void 0?Rt(Ac(u,e)):se(u.cachedContext)(e)},runSync(e){return u.cachedContext===void 0?ce(Ac(u,e)):qe(u.cachedContext)(e)},runPromiseExit(e,t){return u.cachedContext===void 0?Pe(Ac(u,e),s(t)):We(u.cachedContext)(e,s(t))},runPromise(e,t){return u.cachedContext===void 0?re(Ac(u,e),s(t)):x(u.cachedContext)(e,s(t))}};return u};function Ac(e,t){return Mt(e.contextEffect,e=>ve(t,e))}var jc={accept:!1,observe:!1,missingFrameCount:0,startsNewStream:!1};function Mc(e){let t=e===!0;return{accept:t,observe:t,missingFrameCount:0,startsNewStream:t}}function Nc(e,t){let n=e.streamGeneration===void 0&&e.streamId===void 0,r=t.streamGeneration!==void 0||t.streamId!==void 0;return n&&r?Mc(t.keyframe):null}function Pc(e,t){return e.streamGeneration===void 0||t.streamGeneration===void 0?null:t.streamGeneration<e.streamGeneration?jc:t.streamGeneration>e.streamGeneration?Mc(t.keyframe):null}function Fc(e,t){if(!e.streamId||!t.streamId)return null;if(e.streamId!==t.streamId)return Mc(t.keyframe);if(t.sequence<=e.observedSequence)return jc;let n=Math.max(0,t.sequence-e.observedSequence-1);return{accept:n===0||t.keyframe===!0,observe:!0,missingFrameCount:n,startsNewStream:!1}}function Ic(e,t){if(t.sequence>e.acceptedSequence)return{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1};if(!e.acceptedCapturedAt)return jc;let n=Date.parse(e.acceptedCapturedAt),r=Date.parse(t.capturedAt);return Number.isNaN(n)||Number.isNaN(r)||r<=n?jc:{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1}}function Lc(e,t){return Nc(e,t)??Pc(e,t)??Fc(e,t)??Ic(e,t)}function Rc(e,t){let n=Lc(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}}function zc(e){return{_tag:`Value`,value:e}}function Bc(e,t){return{_tag:`Record`,keys:e,value:t}}function Vc(e,t){return{_tag:`Array`,length:e,value:t}}hi(`SourceError`);var Hc=it(`effect/ConfigProvider`,{defaultValue:()=>Gc()}),Uc={...Ke,toJSON(){return{_id:`ConfigProvider`}}};function Wc(e,t,n){let r=Object.create(Uc);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 Gc(e){let t=e?.env??{APP_VERSION:`0.13.4`,BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`,VITE_COMMIT_SHA:``,VITE_HOSTED_APP_CHANNEL:``,VITE_HTTP_URL:``,VITE_SENTRY_COMMIT_SHA:`8a4057a4a58eeb014b73143ffbb1bb091089d750`,VITE_SENTRY_DEBUG:``,VITE_SENTRY_DSN:``,VITE_SENTRY_ENABLED:``,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_PROFILES_SAMPLE_RATE:``,VITE_SENTRY_RELEASE:`forge-web@0.13.4+8a4057a4a58eeb014b73143ffbb1bb091089d750`,VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE:``,VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE:``,VITE_SENTRY_TRACES_SAMPLE_RATE:``,VITE_WS_URL:``},n=Kc(t);return Wc(e=>ct(Jc(n,t,e)))}function Kc(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 qc=/^(0|[1-9][0-9]*)$/;function Jc(e,t,n){let r=t[n.map(String).join(`_`)],i=Yc(e,n),a=i?.children?Object.keys(i.children):[];return a.length===0?r===void 0?void 0:zc(r):a.every(e=>qc.test(e))?Vc(Math.max(...a.map(e=>parseInt(e,10)))+1,r):Bc(new Set(a),r)}function Yc(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 Xc=`~effect/Config`,Zc=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},Qc={...Ke,...Ye,[Xc]:Xc,asEffect(){return Mt(Hc.asEffect(),e=>this.parse(e))},toJSON(){return{_id:`Config`}}};function $c(e){let t=Object.create(Qc);return t.parse=e,t}var el=$e(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*el(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*el(e,[...t,i]));return r}}}),tl=$e(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*tl(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=Pr(a.parameter);for(let o of i.keys)if(!Object.hasOwn(r,o)&&e(o)){let e=yield*tl(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*tl(e.elements[r],t,[...n,r]));return i}case`Union`:return yield*el(t,n);case`Suspend`:return yield*tl(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 nl(e,t){let n=Vi(e),r=Xr(n),i=Mr(n.ast),a=typeof t==`string`?[t]:t??[];return $c(e=>{let t=e.prefix?[...e.prefix,...a]:a;return tl(i,e,a).pipe(Ht(e=>r(e).pipe(Xt(e=>new Qr(t.length>0?new ii(t,e):e)))),Xt(e=>new Zc(e)))})}var rl=(e,t,n)=>{let r=si(e,t),i=E.pipe(kr(si(E,E),Lr(n)),kr(r));return Jr([r,i])},A=ee();function il(e){return new Promise(t=>globalThis.setTimeout(t,e))}function al(){let e=Error(`The environment connection attempt was cancelled.`);return e.name=`AbortError`,e}function ol(e){if(e?.aborted)throw al()}function sl(e,t){return t?t.aborted?Promise.reject(al()):new Promise((n,r)=>{let i=()=>r(al());t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>{t.removeEventListener(`abort`,i)})}):e}function cl(e,t){return t?t.aborted?Promise.reject(al()):new Promise((n,r)=>{let i=globalThis.setTimeout(()=>{t.removeEventListener(`abort`,a),n()},e),a=()=>{globalThis.clearTimeout(i),r(al())};t.addEventListener(`abort`,a,{once:!0})}):il(e)}var ll=Object.freeze({connectionState:`disconnected`,authState:`unknown`,lastError:null,lastErrorAt:null,role:null,descriptor:null,serverConfig:null,connectedAt:null,disconnectedAt:null,providerAuthority:null}),ul=()=>({...ll}),j=Oa()(e=>({byId:{},ensure:t=>e(e=>e.byId[t]?e:{byId:{...e.byId,[t]:ul()}}),patch:(t,n)=>e(e=>({byId:{...e.byId,[t]:{...e.byId[t]??ul(),...n}}})),clear:t=>e(e=>{let{[t]:n,...r}=e.byId;return{byId:r}}),reset:()=>e({byId:{}})}));function dl(e){let t=tr(e.environmentId);if(t?.lastAuthenticatedPullRequestCapability!==void 0)return{...e,lastAuthenticatedPullRequestCapability:t.lastAuthenticatedPullRequestCapability};let n=j.getState().byId?.[e.environmentId];return n?.authState===`authenticated`&&n.descriptor?{...e,lastAuthenticatedPullRequestCapability:n.descriptor.capabilities.pullRequests===!0}:e}function fl(e){return!!e.runtimeId?.trim()||yr(e.environmentId).isCloud}function pl(e,t){return e.environmentId===t.environmentId&&e.httpBaseUrl===t.httpBaseUrl&&e.wsBaseUrl===t.wsBaseUrl&&e.runtimeId===t.runtimeId&&e.cmmdOrganizationId===t.cmmdOrganizationId}function ml(e){return e.replacedRecord===null&&e.existing!==null&&pl(e.existing,e.record)}function hl(e){let t=e.replacesEnvironmentId?Ur.make(e.replacesEnvironmentId):null,n=t&&t!==e.environmentId?tr(t):null;return{existing:tr(e.environmentId)??n,replacedRecord:n}}async function gl(e){return{records:ur(),bearerToken:e?await rr(e.environmentId):null}}async function _l(e){let t=e.replacedRecord?.environmentId??e.record.environmentId;await ir(e.rollback.records),await hr(e.record.environmentId).catch(()=>void 0),e.rollback.bearerToken&&await Zn(t,e.rollback.bearerToken)}async function vl(e){try{e.replacedRecord?await Jn(e.replacedRecord.environmentId,e.record):await Kn(e.record),ol(e.signal),await hr(e.record.environmentId),e.replacedRecord&&await hr(e.replacedRecord.environmentId),ol(e.signal)}catch(t){try{await _l(e)}catch(e){let n=AggregateError([t,e],`Cloud Environment rollback failed.`);throw n.cause=t,n}throw t}}function yl(e){return{lastError:e instanceof Error?e.message:String(e),lastErrorAt:new Date().toISOString()}}var bl=new Map;function xl(e,t){return e.acquire(t?{signal:t}:{})}function Sl(e,t){bl.set(e,t)}function Cl(e){return bl.has(e)}function wl(e,t){let n=bl.get(e);if(t&&n!==t){t.dispose();return}n?.dispose(),bl.delete(e)}async function Tl(e){let t=bl.get(e);if(t)return(await t.acquire()).bearerToken;let n=tr(e);return n&&fl(n)?null:rr(e)}function El(){return{executionCount:0,isPending:!1,lastArgs:void 0,lastExecutionTime:0,nextExecutionTime:0,status:`idle`,maybeExecuteCount:0}}var Dl={enabled:!0,leading:!0,trailing:!0,wait:0},Ol=class{#e;constructor(e,t){this.fn=e,this.store=new Ea(El()),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`}}),Da(`Throttler`,this)},this.#n=()=>!!Ta(this.options.enabled,this),this.#r=()=>Ta(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(El())},this.key=t.key,this.options={...Dl,...t},this.#t(this.options.initialState??{}),this.key&&ka.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},kl={all:[`projects`],searchContents:(e,t,n,r,i,a,o)=>[`projects`,`search-contents`,e??null,t,n,r,i,a,o],searchEntries:(e,t,n,r)=>[`projects`,`search-entries`,e??null,t,n,r]},Al={all:[`providers`],checkpointDiff:e=>[`providers`,`checkpointDiff`,e.environmentId??null,e.threadId,e.fromTurnCount,e.toTurnCount,e.cacheScope??null]};function jl(e){let t=null,n=!1;function r(){return t}function i(){n=!0,t?.queryInvalidationThrottler.maybeExecute()}function a(){t?.stop(),t=null}function o(r){if(t?.queryClient===r)return t.refCount+=1,()=>{!t||t.queryClient!==r||(--t.refCount,t.refCount===0&&a())};a(),n=!1;let i=new Ol(()=>{n&&(n=!1,r.invalidateQueries({queryKey:Al.all}),r.invalidateQueries({queryKey:kl.all}))},{wait:100,leading:!1,trailing:!0});e.createPrimaryEnvironmentConnection(),ta().catch(()=>void 0);let o=ar.subscribe(()=>{Gn()&&e.syncSavedEnvironmentConnections(ur())});return $n().then(()=>e.syncSavedEnvironmentConnections(ur())).catch(()=>void 0),t={queryClient:r,queryInvalidationThrottler:i,refCount:1,stop:()=>{o(),i.cancel()}},()=>{!t||t.queryClient!==r||(--t.refCount,t.refCount===0&&a())}}return{readActiveService:r,notifyProviderInvalidation:i,stopActiveService:a,start:o}}var Ml=class extends Error{status;constructor(e,t){super(e),this.name=`RemoteEnvironmentAuthHttpError`,this.status=t}};function Nl(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 Pl(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 Fl(e){let t=Nl(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 Ml(await Pl(n,`Remote auth request failed (${n.status}).`),n.status);return await n.json()}async function Il(e){return Fl({httpBaseUrl:e.httpBaseUrl,pathname:`/api/auth/session`,bearerToken:e.bearerToken,...e.signal?{signal:e.signal}:{}})}async function Ll(e){return Fl({httpBaseUrl:e.httpBaseUrl,pathname:`/.well-known/forge/environment`,...e.bearerToken?{bearerToken:e.bearerToken}:{}})}async function Rl(e){return Fl({httpBaseUrl:e.httpBaseUrl,pathname:`/api/auth/ws-token`,method:`POST`,bearerToken:e.bearerToken})}async function zl(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 Rl({httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken});return t.searchParams.set(`wsToken`,n.token),t.toString()}function Bl(e,t){if(t){Ma(t,e);return}Na(e)}function Vl(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(`
2
+ import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{$ as r,$t as i,Aa as a,An as o,Ar as s,At as c,B as l,Br as u,Bt as d,Ci as f,Dn as p,Ei as m,En as h,Er as g,Fa as _,Fi as v,Fn as y,Gn as b,Gt as x,Ha as ee,Hn as te,Hr as ne,Ht as re,Ia as ie,It as ae,J as oe,Jt as se,Kt as ce,L as le,La as ue,Ln as de,Lt as fe,M as pe,Ma as me,Mr as he,Ni as ge,Nn as _e,Nt as ve,Pi as ye,Pn as be,Pt as xe,Qi as Se,Rn as Ce,Rr as we,Rt as Te,Si as Ee,Ta as De,Tn as Oe,Tr as ke,Tt as Ae,Ua as je,Un as Me,Ur as Ne,Ut as Pe,V as Fe,Va as Ie,Vn as Le,Vr as Re,Vt as ze,W as Be,Wa as Ve,Wn as He,Wr as Ue,Wt as We,X as Ge,Yi as Ke,Yt as qe,Z as Je,Zi as Ye,_ as Xe,_t as Ze,an as Qe,at as $e,bn as et,br as tt,bt as nt,ca as rt,ci as it,ct as at,dn as ot,ea as st,en as ct,et as lt,fi as ut,gi as dt,gn as ft,hn as pt,hr as mt,ht,in as gt,it as _t,ja as vt,jn as yt,jr as bt,jt as xt,ki as St,kr as Ct,kt as wt,li as Tt,ln as Et,m as Dt,mn as Ot,mr as kt,na as At,ni as jt,nt as Mt,oa as Nt,or as Pt,pn as Ft,pt as It,q as Lt,qt as Rt,r as zt,rn as Bt,rr as Vt,rt as Ht,sn as Ut,un as Wt,ut as Gt,vn as Kt,vr as qt,wn as Jt,wr as Yt,wt as Xt,xi as Zt,xn as Qt,y as $t,yi as en,yn as tn,z as nn,zn as rn,zt as an}from"./Stream-mUTFnSY9.js";import{i as on,l as sn,n as cn,o as ln,s as un}from"./atomRegistry-C1yW8tyM.js";import{_n as dn,on as fn}from"./CompositeItem-BxPZ_9BJ.js";import{$ as pn,A as mn,B as hn,Bn as gn,C as _n,D as vn,Dt as yn,G as bn,H as S,Hn as C,Jn as xn,Kn as Sn,L as Cn,Ln as wn,M as Tn,N as En,O as Dn,Q as On,Qt as kn,Rt as An,S as jn,Sn as Mn,T as Nn,Tn as Pn,U as Fn,Un as In,Vn as Ln,Wn as Rn,Wt as zn,X as Bn,Y as Vn,Yt as Hn,Z as Un,_n as Wn,at as Gn,ct as Kn,dn as qn,dt as Jn,fn as Yn,gn as Xn,gt as Zn,hn as Qn,ht as $n,in as er,it as tr,ln as nr,lt as rr,mn as ir,mt as ar,ot as or,pn as sr,qn as cr,rn as lr,st as ur,t as dr,tn as fr,tt as pr,un as mr,ut as hr,vt as gr,w as _r,wn as vr,yn as yr,yt as br,zn as xr}from"./cmmdForgeRuntimeListResource-lbV63vQg.js";import{$t as Sr,A as Cr,At as wr,Bt as Tr,C as Er,Ct as Dr,Dt as Or,En as kr,Et as Ar,G as jr,Gn as Mr,Gt as Nr,Hn as Pr,Ht as Fr,In as w,Jt as Ir,Kn as Lr,Kt as Rr,Lt as zr,Mt as Br,Nn as Vr,Nt as Hr,Ot as Ur,Q as Wr,Qt as Gr,R as Kr,Rt as qr,Sn as Jr,U as Yr,Un as Xr,Ut as Zr,Vn as Qr,Vt as $r,W as ei,Wn as ti,Wt as ni,Xt as ri,Yn as ii,Yt as ai,Zt as oi,_n as si,_t as ci,an as li,b as ui,c as di,cn as fi,dt as pi,en as mi,er as hi,ft as gi,gn as _i,gt as vi,hn as yi,in as bi,j as xi,jt as Si,kn as Ci,l as wi,mt as Ti,nn as Ei,nt as Di,on as Oi,pn as ki,qt as Ai,rt as ji,s as T,sn as Mi,tn as Ni,tt as Pi,ut as Fi,vn as E,vt as Ii,w as Li,x as Ri,xn as zi,yn as Bi,zn as Vi,zt as Hi}from"./src-BAHvoNAY.js";import{$ as Ui,A as Wi,B as Gi,C as Ki,D as qi,E as Ji,F as Yi,G as Xi,H as Zi,I as Qi,J as $i,K as ea,L as ta,N as na,O as ra,P as ia,Q as aa,R as oa,T as sa,U as ca,W as la,X as ua,Y as da,Z as fa,_ as pa,et as ma,it as ha,nt as ga,q as _a,rt as va,tt as ya,w as ba}from"./cmmdAuthRedirect-BYBGztDm.js";import{d as xa,f as Sa,n as Ca,t as wa}from"./utils-B4G-Q0s7.js";import{t as D}from"./preload-helper-Czpn1I53.js";import{a as Ta,i as Ea,n as Da,o as Oa,r as ka,t as Aa}from"./debouncer-BmyJL8Gi.js";import{t as ja}from"./transport-CgH8pQK3.js";import{n as Ma,t as Na}from"./workspaceReadinessAtom-D6bgTvKb.js";import{a as Pa,c as Fa,n as Ia,r as La,s as Ra,u as za}from"./themePalette-gr6ZYaOx.js";function Ba(e){return e[e.length-1]}function Va(e,t){return typeof e==`function`?e(t):e}var Ha=Object.prototype.hasOwnProperty,Ua=Object.prototype.propertyIsEnumerable;function Wa(e){for(let t in e)if(Ha.call(e,t))return!0;return!1}var Ga=()=>Object.create(null),Ka=(e,t)=>qa(e,t,Ga);function qa(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=Za(e)&&Za(i);if(!a&&!(Ya(e)&&Ya(i)))return i;let o=a?e:Ja(e);if(!o)return i;let s=a?i:Ja(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:Ha.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=qa(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function Ja(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(!Ua.call(e,r))return!1;t.push(r)}return t}function Ya(e){if(!Xa(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Xa(n)||!n.hasOwnProperty(`isPrototypeOf`))}function Xa(e){return Object.prototype.toString.call(e)===`[object Object]`}function Za(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Qa(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(!Qa(e[r],t[r],n))return!1;return!0}if(Ya(e)&&Ya(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!Qa(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||!Qa(e[o],t[o],n)))return!1;return i===a}return!1}var $a=/[\x00-\x1f\x7f"<>`{}]/g;function eo(e){return e.replace($a,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function to(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 eo(t)}var no=[`http:`,`https:`,`mailto:`,`tel:`];function ro(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function io(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+=to(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=to(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function ao(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function oo(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 so(){throw Error(`Invariant failed`)}var O=t(Ve(),1),co=O.createContext(null);function lo(e){return O.useContext(co)}var uo=O.createContext(void 0),fo=O.createContext(void 0),po=dn();function mo(e,t){return e===t}function ho(e,t,n=mo){let r=(0,O.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,O.useCallback)(()=>e?.get(),[e]);return(0,po.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var go={};function _o(e,t){let n=O.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=qa(n.current,i):i}}function vo(e){let t=lo(),n=O.useContext(e.from?fo:uo),r=e.from??n,i=t.stores.getMatchStore(r),a=_o(e,t),o=ho(i,e=>e?a(e):go);if(o!==go)return o;(e.shouldThrow??!0)&&so()}function yo(e){return vo({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 bo=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(){}},xo=new class extends bo{#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`}},So={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Co=new class{#e=So;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 wo(e){setTimeout(e,0)}var To=typeof window>`u`||`Deno`in globalThis;function Eo(){}function Do(e,t){return typeof e==`function`?e(t):e}function Oo(e){return typeof e==`number`&&e>=0&&e!==1/0}function ko(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Ao(e,t){return typeof e==`function`?e(t):e}function jo(e,t){return typeof e==`function`?e(t):e}function Mo(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Po(o,t.options))return!1}else if(!Io(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 No(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Fo(t.options.mutationKey)!==Fo(a))return!1}else if(!Io(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Po(e,t){return(t?.queryKeyHashFn||Fo)(e)}function Fo(e){return JSON.stringify(e,(e,t)=>Vo(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Io(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(!Io(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Io(e[r],t[r]))return!1;return!0}return!1}var Lo=Object.prototype.hasOwnProperty;function Ro(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Bo(e)&&Bo(t);if(!r&&!(Vo(e)&&Vo(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:Lo.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Ro(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function zo(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 Bo(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Vo(e){if(!Ho(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Ho(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Ho(e){return Object.prototype.toString.call(e)===`[object Object]`}function Uo(e){return new Promise(t=>{Co.setTimeout(t,e)})}function Wo(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Ro(e,t)}function Go(e){return e}function Ko(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function qo(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Jo=Symbol();function Yo(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Jo?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Xo(e,t){return typeof e==`function`?e(...t):!!e}function Zo(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 Qo=(()=>{let e=()=>To;return{isServer(){return e()},setIsServer(t){e=t}}})();function $o(){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 es=wo;function ts(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=es,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 ns=ts(),rs=new class extends bo{#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 is(e){return Math.min(1e3*2**e,3e4)}function as(e){return(e??`online`)!==`online`||rs.isOnline()}var os=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function ss(e){let t=!1,n=0,r,i=$o(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new os(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>xo.isFocused()&&(e.networkMode===`always`||rs.isOnline())&&e.canRun(),u=()=>as(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??(Qo.isServer()?0:3),o=e.retryDelay??is,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),Uo(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 cs=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Oo(this.gcTime)&&(this.#e=Co.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Qo.isServer()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(Co.clearTimeout(this.#e),this.#e=void 0)}};function ls(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=>{Zo(e,()=>t.signal,()=>n=!0)},u=Yo(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?qo:Ko;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?ds:us,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:us(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 us(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 ds(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function fs(e,t){return t?us(e,t)!=null:!1}function ps(e,t){return!t||!e.getPreviousPageParam?!1:ds(e,t)!=null}var ms=class extends cs{#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=_s(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=_s(this.options);e.data!==void 0&&(this.setState(gs(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Wo(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(Eo).catch(Eo):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=>jo(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Jo||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Ao(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:!ko(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=Yo(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`?ls(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=ss({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof os&&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 os){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,...hs(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...gs(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),ns.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function hs(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:as(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function gs(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function _s(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 vs=class extends bo{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=$o(),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),bs(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return xs(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return xs(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 jo(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&&!zo(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Ss(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||jo(this.options.enabled,this.#t)!==jo(t.enabled,this.#t)||Ao(this.options.staleTime,this.#t)!==Ao(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||jo(this.options.enabled,this.#t)!==jo(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 ws(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(Eo)),t}#g(){this.#b();let e=Ao(this.options.staleTime,this.#t);if(Qo.isServer()||this.#r.isStale||!Oo(e))return;let t=ko(this.#r.dataUpdatedAt,e)+1;this.#d=Co.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,!(Qo.isServer()||jo(this.options.enabled,this.#t)===!1||!Oo(this.#p)||this.#p===0)&&(this.#f=Co.setInterval(()=>{(this.options.refetchIntervalInBackground||xo.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(Co.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(Co.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&&bs(e,t),o=i&&Ss(e,n,t,r);(a||o)&&(l={...l,...hs(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=Wo(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=Wo(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:Cs(e,t),refetch:this.refetch,promise:this.#o,isEnabled:jo(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=$o();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),!zo(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){ns.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function ys(e,t){return jo(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||jo(t.retryOnMount,e)!==!1)}function bs(e,t){return ys(e,t)||e.state.data!==void 0&&xs(e,t,t.refetchOnMount)}function xs(e,t,n){if(jo(t.enabled,e)!==!1&&Ao(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Cs(e,t)}return!1}function Ss(e,t,n,r){return(e!==t||jo(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Cs(e,n)}function Cs(e,t){return jo(t.enabled,e)!==!1&&e.isStaleByTime(Ao(t.staleTime,e))}function ws(e,t){return!zo(e.getCurrentResult(),t)}var k=je(),Ts=O.createContext(void 0),Es=e=>{let t=O.useContext(Ts);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Ds=({client:e,children:t})=>(O.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,k.jsx)(Ts.Provider,{value:e,children:t})),Os=O.createContext(!1),ks=()=>O.useContext(Os);Os.Provider;function As(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var js=O.createContext(As()),Ms=()=>O.useContext(js),Ns=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Xo(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Ps=e=>{O.useEffect(()=>{e.clearReset()},[e])},Fs=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Xo(n,[e.error,r])),Is=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))}},Ls=(e,t)=>e.isLoading&&e.isFetching&&!t,Rs=(e,t)=>e?.suspense&&t.isPending,zs=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Bs(e,t,n){let r=ks(),i=Ms(),a=Es(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,Is(o),Ns(o,i,s),Ps(i);let l=!a.getQueryCache().get(o.queryHash),[u]=O.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(O.useSyncExternalStore(O.useCallback(e=>{let t=f?u.subscribe(ns.batchCalls(e)):Eo;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),O.useEffect(()=>{u.setOptions(o)},[o,u]),Rs(o,d))throw zs(o,u,i);if(Fs({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&&!Qo.isServer()&&Ls(d,r)&&(l?zs(o,u,i):s?.promise)?.catch(Eo).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function Vs(e,t){return Bs(e,vs,t)}function Hs(e){return e}var Us=g,Ws=globalThis.Number,Gs=e=>{if(e===`NaN`)return v(NaN);if(e===`Infinity`)return v(1/0);if(e===`-Infinity`)return v(-1/0);if(e.trim()===``)return ye();let t=Ws(e);return Ws.isNaN(t)?ye():v(t)},Ks=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`]],qs=`~effect/http/HttpClientRequest`,Js={[qs]:qs,...Se,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Nt(this.headers),body:this.body.toJSON()}},pipe(){return Ie(this,arguments)}};function Ys(e,t,n,r,i,a){let o=Object.create(Js);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var Xs=Ys(`GET`,``,Gr,ye(),Fr,ri),Zs=e=>(t,n)=>$s(Xs,{method:e,url:t,...n??void 0}),Qs=Zs(`POST`),$s=_(2,(e,t)=>{let n=e;return t.method&&(n=ec(n,t.method)),t.url&&(n=ac(n,t.url)),t.headers&&(n=nc(n,t.headers)),t.urlParams&&(n=oc(n,t.urlParams)),t.hash&&(n=sc(n,t.hash)),t.body&&(n=cc(n,t.body)),t.accept&&(n=rc(n,t.accept)),t.acceptJson&&(n=ic(n)),n}),ec=_(2,(e,t)=>Ys(t,e.url,e.urlParams,e.hash,e.headers,e.body)),tc=_(3,(e,t,n)=>Ys(e.method,e.url,e.urlParams,e.hash,Ir(e.headers,t,n),e.body)),nc=_(2,(e,t)=>Ys(e.method,e.url,e.urlParams,e.hash,ai(e.headers,t),e.body)),rc=_(2,(e,t)=>tc(e,`Accept`,t)),ic=rc(`application/json`),ac=_(2,(e,t)=>{if(typeof t==`string`)return Ys(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Sr(n.searchParams),i=Zt(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,Ys(e.method,n.toString(),r,i,e.headers,e.body)}),oc=_(2,(e,t)=>Ys(e.method,e.url,Ni(e.urlParams,t),e.hash,e.headers,e.body)),sc=_(2,(e,t)=>Ys(e.method,e.url,e.urlParams,v(t),e.headers,e.body)),cc=_(2,(e,t)=>{let n=e.headers;return t._tag===`Empty`||t._tag===`FormData`?n=Ai(Ai(n,`Content-Type`),`Content-length`):(t.contentType&&(n=Ir(n,`content-type`,t.contentType)),t.contentLength!==void 0&&(n=Ir(n,`content-length`,t.contentLength.toString()))),Ys(e.method,e.url,e.urlParams,e.hash,n,t)}),lc=e=>ni({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${ge(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),uc=`~effect/http/HttpClient`,dc=Tt(`effect/HttpClient`),fc=_(2,(e,t)=>mc(n=>t(e.postprocess(n)),e.preprocess)),pc=fc(Mt(qr)),mc=(e,t)=>{let n=Object.create(hc);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},hc={[uc]:uc,pipe(){return Ie(this,arguments)},...Se,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(Ks.map(([e,t])=>[t,function(t,n){return this.execute(Zs(e)(t,n))}]))},gc=e=>mc(t=>Mt(t,t=>Kt(n=>{let i=Cc.get(t),a=i??new AbortController,o=mi(t.url,t.urlParams,m(t.hash));if(jt(o))return r(new Ei({reason:new bi({request:t,cause:o.failure})}));let s=o.success;if(n.getRef(Ct)||n.getRef(vc)(t)){let r=e(t,s,a.signal,n);return i?r:Ft(e=>Ae(e(r),{onSuccess(e){return Sc.register(e,a),ct(new wc(e,a))},onFailure(e){return kt(e)&&a.abort(),lt(e)}}))}return pt(n.getRef(bc)(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($r),l=Rr(t.headers,c);for(let e in l)r.attribute(`http.request.header.${e}`,String(l[e]));return t=n.getRef(yc)?nc(t,lc(r)):t,Ft(o=>o(e(t,s,a.signal,n)).pipe(tn(r,{captureStackTrace:!1}),Ae({onSuccess:e=>{r.attribute(`http.response.status_code`,e.status);let t=Rr(e.headers,c);for(let e in t)r.attribute(`http.response.header.${e}`,String(t[e]));return i?ct(e):(Sc.register(e,a),ct(new wc(e,a)))},onFailure(e){return!i&&kt(e)&&a.abort(),lt(e)}})))})})),ct),_c=_(2,(e,t)=>{let n=Oe(t),r=n?`errors-and-responses`:t.retryOn??`errors-and-responses`,i=n?t:t.schedule,o=i&&h(i),s=n?void 0:t.times;return fc(e,ie(r===`errors-only`?ue:ae({schedule:o,times:s,while:Dc}),r===`response-only`?ue:fe({while:n||t.while===void 0?Tc:a(Tc,t.while),schedule:i,times:s})))}),vc=it(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>vt}),yc=it(`effect/HttpClient/TracerPropagationEnabled`,{defaultValue:me}),bc=it(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),xc=e=>yt(dc)(oe(t=>nt(e,e=>fc(e,Ot(e=>dt(t,e)))))),Sc=(()=>{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))}}})(),Cc=new WeakMap,wc=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[zr]=zr;[Tr]=Tr;applyInterrupt(e){return Bt(()=>(Sc.unregister(this.original),wt(e,()=>gt(()=>{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 Xe(()=>(Sc.unregister(this.original),zt(this.original.stream,gt(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[st](){return this.original[st]()}pipe(){return Ie(this,arguments)}},Tc=e=>tt(e)||Ec(e),Ec=e=>Oi(e)&&(e.reason._tag===`TransportError`||e.reason._tag===`StatusCodeError`&&Dc(e.reason.response)),Dc=e=>e.status===408||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504,Oc=`~effect/ManagedRuntime`,kc=(e,t)=>{let n=t?.memoMap??_e(),r=He(`parallel`),i=te(r,`sequential`),a={onFiberStart:le(r)},s=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,c,l=Kt(t=>(c||=d(Qe(o(e,n,i),e=>gt(()=>{u.cachedContext=e})),{...a,scheduler:t.currentScheduler}),_t(pe(c)))),u={[Oc]:Oc,memoMap:n,scope:r,contextEffect:l,cachedContext:void 0,context(){return u.cachedContext===void 0?re(u.contextEffect):Promise.resolve(u.cachedContext)},dispose(){return re(u.disposeEffect)},disposeEffect:Bt(()=>(u.contextEffect=Ge(`ManagedRuntime disposed`),u.cachedContext=void 0,Le(u.scope,Pt))),runFork(e,t){return u.cachedContext===void 0?d(Ac(u,e),s(t)):ze(u.cachedContext)(e,s(t))},runCallback(e,t){return u.cachedContext===void 0?Te(Ac(u,e),s(t)):an(u.cachedContext)(e,s(t))},runSyncExit(e){return u.cachedContext===void 0?Rt(Ac(u,e)):se(u.cachedContext)(e)},runSync(e){return u.cachedContext===void 0?ce(Ac(u,e)):qe(u.cachedContext)(e)},runPromiseExit(e,t){return u.cachedContext===void 0?Pe(Ac(u,e),s(t)):We(u.cachedContext)(e,s(t))},runPromise(e,t){return u.cachedContext===void 0?re(Ac(u,e),s(t)):x(u.cachedContext)(e,s(t))}};return u};function Ac(e,t){return Mt(e.contextEffect,e=>ve(t,e))}var jc={accept:!1,observe:!1,missingFrameCount:0,startsNewStream:!1};function Mc(e){let t=e===!0;return{accept:t,observe:t,missingFrameCount:0,startsNewStream:t}}function Nc(e,t){let n=e.streamGeneration===void 0&&e.streamId===void 0,r=t.streamGeneration!==void 0||t.streamId!==void 0;return n&&r?Mc(t.keyframe):null}function Pc(e,t){return e.streamGeneration===void 0||t.streamGeneration===void 0?null:t.streamGeneration<e.streamGeneration?jc:t.streamGeneration>e.streamGeneration?Mc(t.keyframe):null}function Fc(e,t){if(!e.streamId||!t.streamId)return null;if(e.streamId!==t.streamId)return Mc(t.keyframe);if(t.sequence<=e.observedSequence)return jc;let n=Math.max(0,t.sequence-e.observedSequence-1);return{accept:n===0||t.keyframe===!0,observe:!0,missingFrameCount:n,startsNewStream:!1}}function Ic(e,t){if(t.sequence>e.acceptedSequence)return{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1};if(!e.acceptedCapturedAt)return jc;let n=Date.parse(e.acceptedCapturedAt),r=Date.parse(t.capturedAt);return Number.isNaN(n)||Number.isNaN(r)||r<=n?jc:{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1}}function Lc(e,t){return Nc(e,t)??Pc(e,t)??Fc(e,t)??Ic(e,t)}function Rc(e,t){let n=Lc(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}}function zc(e){return{_tag:`Value`,value:e}}function Bc(e,t){return{_tag:`Record`,keys:e,value:t}}function Vc(e,t){return{_tag:`Array`,length:e,value:t}}hi(`SourceError`);var Hc=it(`effect/ConfigProvider`,{defaultValue:()=>Gc()}),Uc={...Ke,toJSON(){return{_id:`ConfigProvider`}}};function Wc(e,t,n){let r=Object.create(Uc);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 Gc(e){let t=e?.env??{APP_VERSION:`0.13.4`,BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`,VITE_COMMIT_SHA:``,VITE_HOSTED_APP_CHANNEL:``,VITE_HTTP_URL:``,VITE_SENTRY_COMMIT_SHA:`c7fe2d96f51605b303a42c585157e3bc4d4af889`,VITE_SENTRY_DEBUG:``,VITE_SENTRY_DSN:``,VITE_SENTRY_ENABLED:``,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_PROFILES_SAMPLE_RATE:``,VITE_SENTRY_RELEASE:`forge-web@0.13.4+c7fe2d96f51605b303a42c585157e3bc4d4af889`,VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE:``,VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE:``,VITE_SENTRY_TRACES_SAMPLE_RATE:``,VITE_WS_URL:``},n=Kc(t);return Wc(e=>ct(Jc(n,t,e)))}function Kc(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 qc=/^(0|[1-9][0-9]*)$/;function Jc(e,t,n){let r=t[n.map(String).join(`_`)],i=Yc(e,n),a=i?.children?Object.keys(i.children):[];return a.length===0?r===void 0?void 0:zc(r):a.every(e=>qc.test(e))?Vc(Math.max(...a.map(e=>parseInt(e,10)))+1,r):Bc(new Set(a),r)}function Yc(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 Xc=`~effect/Config`,Zc=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},Qc={...Ke,...Ye,[Xc]:Xc,asEffect(){return Mt(Hc.asEffect(),e=>this.parse(e))},toJSON(){return{_id:`Config`}}};function $c(e){let t=Object.create(Qc);return t.parse=e,t}var el=$e(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*el(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*el(e,[...t,i]));return r}}}),tl=$e(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*tl(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=Pr(a.parameter);for(let o of i.keys)if(!Object.hasOwn(r,o)&&e(o)){let e=yield*tl(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*tl(e.elements[r],t,[...n,r]));return i}case`Union`:return yield*el(t,n);case`Suspend`:return yield*tl(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 nl(e,t){let n=Vi(e),r=Xr(n),i=Mr(n.ast),a=typeof t==`string`?[t]:t??[];return $c(e=>{let t=e.prefix?[...e.prefix,...a]:a;return tl(i,e,a).pipe(Ht(e=>r(e).pipe(Xt(e=>new Qr(t.length>0?new ii(t,e):e)))),Xt(e=>new Zc(e)))})}var rl=(e,t,n)=>{let r=si(e,t),i=E.pipe(kr(si(E,E),Lr(n)),kr(r));return Jr([r,i])},A=ee();function il(e){return new Promise(t=>globalThis.setTimeout(t,e))}function al(){let e=Error(`The environment connection attempt was cancelled.`);return e.name=`AbortError`,e}function ol(e){if(e?.aborted)throw al()}function sl(e,t){return t?t.aborted?Promise.reject(al()):new Promise((n,r)=>{let i=()=>r(al());t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>{t.removeEventListener(`abort`,i)})}):e}function cl(e,t){return t?t.aborted?Promise.reject(al()):new Promise((n,r)=>{let i=globalThis.setTimeout(()=>{t.removeEventListener(`abort`,a),n()},e),a=()=>{globalThis.clearTimeout(i),r(al())};t.addEventListener(`abort`,a,{once:!0})}):il(e)}var ll=Object.freeze({connectionState:`disconnected`,authState:`unknown`,lastError:null,lastErrorAt:null,role:null,descriptor:null,serverConfig:null,connectedAt:null,disconnectedAt:null,providerAuthority:null}),ul=()=>({...ll}),j=Oa()(e=>({byId:{},ensure:t=>e(e=>e.byId[t]?e:{byId:{...e.byId,[t]:ul()}}),patch:(t,n)=>e(e=>({byId:{...e.byId,[t]:{...e.byId[t]??ul(),...n}}})),clear:t=>e(e=>{let{[t]:n,...r}=e.byId;return{byId:r}}),reset:()=>e({byId:{}})}));function dl(e){let t=tr(e.environmentId);if(t?.lastAuthenticatedPullRequestCapability!==void 0)return{...e,lastAuthenticatedPullRequestCapability:t.lastAuthenticatedPullRequestCapability};let n=j.getState().byId?.[e.environmentId];return n?.authState===`authenticated`&&n.descriptor?{...e,lastAuthenticatedPullRequestCapability:n.descriptor.capabilities.pullRequests===!0}:e}function fl(e){return!!e.runtimeId?.trim()||yr(e.environmentId).isCloud}function pl(e,t){return e.environmentId===t.environmentId&&e.httpBaseUrl===t.httpBaseUrl&&e.wsBaseUrl===t.wsBaseUrl&&e.runtimeId===t.runtimeId&&e.cmmdOrganizationId===t.cmmdOrganizationId}function ml(e){return e.replacedRecord===null&&e.existing!==null&&pl(e.existing,e.record)}function hl(e){let t=e.replacesEnvironmentId?Ur.make(e.replacesEnvironmentId):null,n=t&&t!==e.environmentId?tr(t):null;return{existing:tr(e.environmentId)??n,replacedRecord:n}}async function gl(e){return{records:ur(),bearerToken:e?await rr(e.environmentId):null}}async function _l(e){let t=e.replacedRecord?.environmentId??e.record.environmentId;await ir(e.rollback.records),await hr(e.record.environmentId).catch(()=>void 0),e.rollback.bearerToken&&await Zn(t,e.rollback.bearerToken)}async function vl(e){try{e.replacedRecord?await Jn(e.replacedRecord.environmentId,e.record):await Kn(e.record),ol(e.signal),await hr(e.record.environmentId),e.replacedRecord&&await hr(e.replacedRecord.environmentId),ol(e.signal)}catch(t){try{await _l(e)}catch(e){let n=AggregateError([t,e],`Cloud Environment rollback failed.`);throw n.cause=t,n}throw t}}function yl(e){return{lastError:e instanceof Error?e.message:String(e),lastErrorAt:new Date().toISOString()}}var bl=new Map;function xl(e,t){return e.acquire(t?{signal:t}:{})}function Sl(e,t){bl.set(e,t)}function Cl(e){return bl.has(e)}function wl(e,t){let n=bl.get(e);if(t&&n!==t){t.dispose();return}n?.dispose(),bl.delete(e)}async function Tl(e){let t=bl.get(e);if(t)return(await t.acquire()).bearerToken;let n=tr(e);return n&&fl(n)?null:rr(e)}function El(){return{executionCount:0,isPending:!1,lastArgs:void 0,lastExecutionTime:0,nextExecutionTime:0,status:`idle`,maybeExecuteCount:0}}var Dl={enabled:!0,leading:!0,trailing:!0,wait:0},Ol=class{#e;constructor(e,t){this.fn=e,this.store=new Ea(El()),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`}}),Da(`Throttler`,this)},this.#n=()=>!!Ta(this.options.enabled,this),this.#r=()=>Ta(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(El())},this.key=t.key,this.options={...Dl,...t},this.#t(this.options.initialState??{}),this.key&&ka.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},kl={all:[`projects`],searchContents:(e,t,n,r,i,a,o)=>[`projects`,`search-contents`,e??null,t,n,r,i,a,o],searchEntries:(e,t,n,r)=>[`projects`,`search-entries`,e??null,t,n,r]},Al={all:[`providers`],checkpointDiff:e=>[`providers`,`checkpointDiff`,e.environmentId??null,e.threadId,e.fromTurnCount,e.toTurnCount,e.cacheScope??null]};function jl(e){let t=null,n=!1;function r(){return t}function i(){n=!0,t?.queryInvalidationThrottler.maybeExecute()}function a(){t?.stop(),t=null}function o(r){if(t?.queryClient===r)return t.refCount+=1,()=>{!t||t.queryClient!==r||(--t.refCount,t.refCount===0&&a())};a(),n=!1;let i=new Ol(()=>{n&&(n=!1,r.invalidateQueries({queryKey:Al.all}),r.invalidateQueries({queryKey:kl.all}))},{wait:100,leading:!1,trailing:!0});e.createPrimaryEnvironmentConnection(),ta().catch(()=>void 0);let o=ar.subscribe(()=>{Gn()&&e.syncSavedEnvironmentConnections(ur())});return $n().then(()=>e.syncSavedEnvironmentConnections(ur())).catch(()=>void 0),t={queryClient:r,queryInvalidationThrottler:i,refCount:1,stop:()=>{o(),i.cancel()}},()=>{!t||t.queryClient!==r||(--t.refCount,t.refCount===0&&a())}}return{readActiveService:r,notifyProviderInvalidation:i,stopActiveService:a,start:o}}var Ml=class extends Error{status;constructor(e,t){super(e),this.name=`RemoteEnvironmentAuthHttpError`,this.status=t}};function Nl(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 Pl(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 Fl(e){let t=Nl(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 Ml(await Pl(n,`Remote auth request failed (${n.status}).`),n.status);return await n.json()}async function Il(e){return Fl({httpBaseUrl:e.httpBaseUrl,pathname:`/api/auth/session`,bearerToken:e.bearerToken,...e.signal?{signal:e.signal}:{}})}async function Ll(e){return Fl({httpBaseUrl:e.httpBaseUrl,pathname:`/.well-known/forge/environment`,...e.bearerToken?{bearerToken:e.bearerToken}:{}})}async function Rl(e){return Fl({httpBaseUrl:e.httpBaseUrl,pathname:`/api/auth/ws-token`,method:`POST`,bearerToken:e.bearerToken})}async function zl(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 Rl({httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken});return t.searchParams.set(`wsToken`,n.token),t.toString()}function Bl(e,t){if(t){Ma(t,e);return}Na(e)}function Vl(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(`
3
3
  `)}}function Hl(e,t){let n=Vl(e);if(n.eventName!==`phase`||!n.data)return!1;try{let e=JSON.parse(n.data);return Bl(e,t),e.phase===`app-ready`||e.phase===`error`}catch{return!1}}async function Ul(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(`
4
4
 
5
5
  `);for(;o!==-1;){let e=a.slice(0,o);if(a=a.slice(o+2),Hl(e,t))return;o=a.indexOf(`
@@ -1530,4 +1530,4 @@ XID_Start XIDS`.split(/\s/).map(e=>[EV(e),e])),vH=new Map([[`s`,Z(383)],[Z(383),
1530
1530
  ${e}
1531
1531
  }
1532
1532
  }`}function PG(e,t){let n=kG(t);return e.replace(jG,n)}function FG(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function IG({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 LG(e,t){if(t==null)return;let n=e.shadowRoot??e.attachShadow({mode:`open`});n.innerHTML===``&&(n.innerHTML=t)}function RG(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 zG(e){if(typeof HTMLStyleElement<`u`&&e instanceof HTMLStyleElement)return!0;let t=e.tagName??e.nodeName;return typeof t==`string`&&t.toLowerCase()===`style`}function BG(e){return e?.useTokenTransformer===!0||e?.onTokenClick!=null||e?.onTokenEnter!=null||e?.onTokenLeave!=null}function VG(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 HG({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===``){t?.remove();return}return t??=UG(),t.textContent=n,t.parentNode!==e&&e.appendChild(t),t}function UG(){let e=document.createElement(`style`);return e.setAttribute(Zj,``),e}var WG=void 0;function GG(){return WG??=`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(EG)),t.adoptedStyleSheets=[e]}connectedCallback(){OG(this.shadowRoot??this.attachShadow({mode:`open`}))}}customElements.define(Lj,t)}function KG(e){return{...iM,...e}}function qG(e,t){let n=JG(e,t);return t?n:e.diffHeaderHeight+n}function JG(e,t){return e.paddingTop??(t?e.spacing:0)}function YG(e){return e.paddingBottom??e.spacing}function XG(e){switch(e){case`simple`:return 4;case`metadata`:case`line-info`:case`line-info-basic`:case`custom`:return 32}}function ZG(e,t){return e===t||e?.cacheKey!=null&&e.cacheKey===t?.cacheKey}function QG(e,t){return _M(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function $G({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 eK({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 tK(e){return[CM(e.additionStart,e.additionCount)+1,wM(e.additionStart,e.additionCount)+1]}function nK({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 rK(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-wM(t.additionStart,t.additionCount),r=e.deletionLines.length-wM(t.deletionStart,t.deletionCount);return n<=0&&r<=0?!1:n!==r}function iK({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-wM(n.additionStart,n.additionCount),i=e.deletionLines.length-wM(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 aK({fileDiff:e,hunkIndex:t,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:i}){if(t!==e.hunks.length-1)return;let a=iK({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 oK({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]=tK(a);if(t<o){let s=nK({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=aK({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]=tK(a);return t<o+i.fromStart||t>=o+i.rangeSize}function sK({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]=tK(n),l=nK({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=aK({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 cK({type:e,metrics:t}){return t.hunkSeparatorHeight??XG(e)}function lK({type:e,metrics:t}){return e===`simple`||e===`metadata`||e===`line-info-basic`?0:t.spacing}function uK({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 dK(e){return e!==`simple`&&e!==`metadata`}function fK({type:e,metrics:t,hunkIndex:n,hunkSpecs:r}){if(!uK({type:e,hunkIndex:n,hunkSpecs:r}))return;let i=cK({type:e,metrics:t}),a=lK({type:e,metrics:t}),o=n>0?a:0,s=a;return{height:i,gapBefore:o,gapAfter:s,totalHeight:o+i+s}}function pK({type:e,metrics:t}){if(!dK(e))return;let n=cK({type:e,metrics:t}),r=lK({type:e,metrics:t});return{height:n,gapBefore:r,gapAfter:0,totalHeight:r+n}}function mK({diff:e,diffStyle:t,startingLine:n=0,totalLines:r=1/0,expandedHunks:i,collapsedContextThreshold:a=1,callback:o}){let s=hK({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=CM(r.deletionStart,r.deletionCount),s=CM(r.additionStart,r.additionCount),l=!e.isPartial&&r.deletionCount===0?o:r.deletionLineIndex,u=!e.isPartial&&r.additionCount===0?s:r.additionLineIndex,d=nK({isPartial:e.isPartial,rangeSize:r.collapsedBefore,expandedHunks:i,hunkIndex:n,collapsedContextThreshold:a}),f=n===c.finalHunkIndex?aK({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(vK(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,vK(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,ee=s+1,te=r.hunkContent.at(-1);for(let e of r.hunkContent){if(c.shouldBreak())break hunkIterator;let i=e===te;if(e.type===`context`){if(c.shouldSkip(e.lines,e.lines))c.incrementCounts(e.lines,e.lines),g();else if(vK(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:ee+t,noEOFCR:a&&r.noEOFCRAdditions}})},()=>{g()}))break hunkIterator;_+=e.lines,v+=e.lines,y+=e.lines,b+=e.lines,x+=e.lines,ee+=e.lines}else{let a=Math.max(e.deletions,e.additions),o=e.deletions+e.additions;if(!c.shouldSkip(o,a)){let s=yK(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(bK({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:l,diffStyle:t,index:s,unifiedLineIndex:_,splitLineIndex:v,additionLineIndex:b,deletionLineIndex:y,additionLineNumber:ee,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,ee+=e.additions}}if(f!=null){let{collapsedLines:n,fromStart:r,fromEnd:i}=f,a=r+i;if(vK(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:ee+t,noEOFCR:!1}})},void 0,()=>c.shouldBreak()))break hunkIterator}}}function hK({diff:e,diffStyle:t,startingLine:n,expandedHunks:r,collapsedContextThreshold:i}){if(n<=0||t===`both`)return{hunkIndex:0,splitCount:0,unifiedCount:0};let a=gK({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 gK({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=nK({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?aK({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 _K(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 vK(e,t,n,r,i,a){let[o,s]=_K(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 yK(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 bK({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,ee=i===`unified`?a>=f.deletions?u+(a-f.deletions):void 0:a<f.additions?u+a:void 0,te=i===`unified`?p&&a===f.deletions-1&&t.noEOFCRDeletions:p&&a===h-1&&t.noEOFCRDeletions,ne=i===`unified`?p&&a===m-1&&t.noEOFCRAdditions:p&&a===h-1&&t.noEOFCRAdditions,re=y!=null&&b!=null&&g!=null?{lineNumber:b,lineIndex:y,noEOFCR:te,unifiedLineIndex:g,splitLineIndex:v}:void 0,ie=x!=null&&ee!=null&&_!=null?{unifiedLineIndex:_,splitLineIndex:v,lineIndex:x,lineNumber:ee,noEOFCR:ne}:void 0;if(re==null&&ie!=null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:void 0,additionLine:ie};if(re!=null&&ie==null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:re,additionLine:void 0};if(re==null||ie==null)throw Error(`iterateOverDiff: missing change line data`);return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:re,additionLine:ie}}var xK={forcePlainText:!1};function SK(e,t,n,{forcePlainText:r,startingLine:i,totalLines:a,expandedHunks:o,collapsedContextThreshold:s=1}=xK){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=eG({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)??wK();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)}mK({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&&CK({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}=TK({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 CK({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:a,lineDiffType:o,maxLineDiffLength:s}){if(e==null||t==null||o===`none`||(e=SM(e),t=SM(t),e.length>s||t.length>s))return;let c=o===`char`?DM(e,t):WM(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?(eK({item:e,arr:l,enableJoin:d,isNeutral:!0,isLastItem:t}),eK({item:e,arr:u,enableJoin:d,isNeutral:!0,isLastItem:t})):e.removed?eK({item:e,arr:l,enableJoin:d,isLastItem:t}):eK({item:e,arr:u,enableJoin:d,isLastItem:t})}let p=0;for(let e of l)e[0]===1&&i.push($G({line:n,spanStart:p,spanLength:e[1].length})),p+=e[1].length;p=0;for(let e of u)e[0]===1&&a.push($G({line:r,spanStart:p,spanLength:e[1].length})),p+=e[1].length}function wK(){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 TK({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:r,highlighter:i,deletionDecorations:a,additionDecorations:o,languageOverride:s,options:{theme:c=Xj,...l}}){let u=s??wW(e.name),d=s??wW(t.name),{state:f,transformers:p}=RW(l.useTokenTransformer),m=typeof c==`string`?{...l,lang:`text`,theme:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:VW(`token`),tokenizeTimeLimit:0}:{...l,lang:`text`,themes:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:VW(`token`),tokenizeTimeLimit:0};return{deletionLines:e.contents===``?[]:(m.lang=u,f.lineInfo=n,m.decorations=a,nG(i.codeToHast(SM(e.contents),m))),additionLines:t.contents===``?[]:(m.lang=d,m.decorations=o,f.lineInfo=r,nG(i.codeToHast(SM(t.contents),m)))}}function EK(e){let t=e.lang??wW(e.name),n=e.lang??(e.prevName==null?`text`:wW(e.prevName));return t===`text`&&n===`text`}function DK(e){let t=[];for(let n of e){let e=GF.get(n);if(e==null)throw Error(`getResolvedLanguages: ${n} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(e)}return t}function OK(e){for(let t of Array.isArray(e)?e:[e])if(!GF.has(t))return!1;return!0}async function kK(e){let t=[],n=[];for(let r of e){if(r===`text`||r===`ansi`)continue;let e=xU(r)??bU(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 AK(e){return NU.getResolvedThemes(e)}async function jK(e){for(let t of e)tW(t);let t=await NU.resolveThemes(e);for(let n=0;n<e.length;n++)nW(e[n],t[n]);return t}var MK={light:`pierre-light`,dark:`pierre-dark`};function NK(e){return e===`dark`?MK.dark:MK.light}var PK=2166136261,FK=16777619,IK=2654435769,LK=2246822507;function RK(e,t=PK,n=FK){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 zK(e,t=`diff-panel`){let n=e.trim(),r=RK(n,PK,FK).toString(36),i=RK(n,IK,LK).toString(36);return`${t}:${n.length}:${r}:${i}`}function BK(e){return wa(`flex items-center justify-between gap-2 px-4 wco:pr-[calc(100vw-env(titlebar-area-width)-env(titlebar-area-x)+1em)]`,xn&&e!==`sheet`?`h-[52px] border-b border-border wco:h-[env(titlebar-area-height)]`:`h-12 wco:max-h-[env(titlebar-area-height)]`)}function VK(e){let t=(0,A.c)(10),n=xn&&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=wa(`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,k.jsx)(`div`,{className:BK(e.mode),children:e.header}):(0,k.jsx)(`div`,{className:`border-b border-border`,children:(0,k.jsx)(`div`,{className:BK(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,k.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 HK(){let e=(0,A.c)(4),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,k.jsx)(I,{className:`absolute left-0 top-1/2 size-6 -translate-y-1/2 rounded-md border border-border/50`}),n=(0,k.jsx)(I,{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,k.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[t,n,(0,k.jsxs)(`div`,{className:`flex gap-1 overflow-hidden px-8 py-0.5`,children:[(0,k.jsx)(I,{className:`h-6 w-16 shrink-0 rounded-md`}),(0,k.jsx)(I,{className:`h-6 w-24 shrink-0 rounded-md`}),(0,k.jsx)(I,{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,k.jsxs)(k.Fragment,{children:[r,(0,k.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,k.jsx)(I,{className:`size-7 rounded-md`}),(0,k.jsx)(I,{className:`size-7 rounded-md`})]})]}),e[3]=i):i=e[3],i}function UK(e){let t=(0,A.c)(7),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,k.jsx)(I,{className:`h-4 w-32 rounded-full`}),(0,k.jsx)(I,{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,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(I,{className:`h-3 w-full rounded-full`}),(0,k.jsx)(I,{className:`h-3 w-full rounded-full`}),(0,k.jsx)(I,{className:`h-3 w-10/12 rounded-full`}),(0,k.jsx)(I,{className:`h-3 w-11/12 rounded-full`}),(0,k.jsx)(I,{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,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 px-3 py-4`,children:[r,(0,k.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,k.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col p-2`,children:(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border border-border/60 bg-card/25`,role:`status`,"aria-live":`polite`,"aria-label":e.label,children:[n,i]})}),t[4]=e.label,t[5]=i,t[6]=a):a=t[6],a}function WK(e){let t=(0,O.useRef)(e);return(0,O.useInsertionEffect)(()=>void(t.current=e)),(0,O.useCallback)((...e)=>t.current(...e),[])}var GK=(0,O.createContext)(void 0);function KK(){return(0,O.useContext)(GK)}var qK={position:`absolute`,top:0,bottom:0,textAlign:`center`,whiteSpace:`normal`,touchAction:`none`},JK={display:`contents`};function YK(){return null}var XK=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),ZK=Symbol(`IGNORE_RESPONSE`),QK=class extends Error{constructor(){super(`WorkerPoolManager: operation canceled because the pool terminated`)}},$K=class extends Error{constructor(){super(`WorkerPoolManager: operation canceled before the task completed`)}},eq=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=Xj,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 XK.default.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new XK.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??Xj,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()||QG(a,this.renderOptions))return;let o=lW(e),c=[];if(_M(a.theme,this.renderOptions.theme)||(c=dW(o)?AK(o):await jK(o)),!s())return;if(this.highlighter!=null)PU(c,this.highlighter);else{let e=await oW({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 QK||!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);rq(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=lW(this.renderOptions.theme),i=[];if(i=dW(r)?AK(r):await jK(r),!this.isCurrentLifecycle(t)){n();return}let a=[];if(a=OK(e)?DK(e):await kK(e),!this.isCurrentLifecycle(t)){n();return}let[o]=await Promise.all([oW({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 QK||!this.isCurrentLifecycle(t)){n();return}this.initialized=!1,this.workersFailed=!0;for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,aq(e));this.queueBroadcastStateChanges(),r(e)}})()}),this.queueBroadcastStateChanges()}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;let n=[],r=TW(),i=r>0?EW():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=nq(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);vG(t)||n!=null&&fW(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||vG(e)||t!=null&&fW(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 uG(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,lines:r})}highlightDiffAST(e,t){let n=this.getDiffResultCache(t);EK(t)||n!=null&&QG(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||EK(e)||t!=null&&QG(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:SK(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 QK;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 QK;for(let t of this.activeTaskById.values())`reject`in t?t.reject(e):rq(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&&(OK(r)?t.request.resolvedLanguages=DK(r):t.request.resolvedLanguages=await kK(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,aq(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 ZK;if(t.type===`error`){let e=Error(t.error);if(t.stack&&(e.stack=t.stack),`reject`in n)n.reject(e);else if(rq(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)||!fW(i,this.getFileRenderOptions()))throw ZK;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)||!QG(i,this.getDiffRenderOptions()))throw ZK;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!==ZK&&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,rq(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&&(rq(t)&&(this.rejectRenderTaskCallbacks(t,new $K),this.clearInstanceRequests(t),this.clearHighlightKey(t)),this.activeTaskById.delete(t.id))}executeTask(e,t){tq(t.request)&&this.maybeAttachCustomExtensions(e,t.request),this.activeTaskById.has(t.id)||this.assignWorkerToTask(t,e);for(let n of nq(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),rq(t)?(this.notifyHighlightError(t,n),this.rejectRenderTaskCallbacks(t,aq(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=TW();e.customExtensionsVersion>=n||(t.customExtensionsVersion=n,t.customExtensionMap=EW())}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 iq(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 $K),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new $K),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()))rq(e)&&e.renderOptionsVersion!==this.renderOptionsVersion&&this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(let t of iq(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 iq(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(let t of iq(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 iq(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)&&rN(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)&&ZG(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())rq(e)&&(yield e)}generateRequestId(){return`req_${++this.nextRequestId}`}};function tq(e){return e.type===`initialize`||e.type===`file`||e.type===`diff`}function nq(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??wW(e.request.file.name));break;case`diff`:t.add(e.request.diff.lang??wW(e.request.diff.name)),t.add(e.request.diff.lang??wW(e.request.diff.prevName??`-`))}return t.delete(`text`),Array.from(t)}function rq(e){return e?.type===`file`||e?.type===`diff`}function iq(e){return e.instances}function aq(e){return e instanceof Error?e:Error(String(e))}var oq;function sq({poolOptions:e,highlighterOptions:t}){return oq??=new eq(e,t),oq}function cq(){oq!=null&&(oq.terminate(),oq=void 0)}var lq=(0,O.createContext)(void 0),uq=0;function dq({children:e,poolOptions:t,highlighterOptions:n}){let[r]=(0,O.useState)(()=>{if(!(typeof window>`u`))return sq({poolOptions:t,highlighterOptions:n})});return(0,O.useInsertionEffect)(()=>{if(r!=null)return uq++,()=>{uq--}},[r]),(0,O.useEffect)(()=>()=>{uq===0&&cq()},[]),(0,k.jsx)(lq.Provider,{value:r,children:e})}function fq(){return(0,O.useContext)(lq)}export{mG as $,Sh as $a,Cb as $i,gk as $n,sl as $o,UT as $r,Ba as $s,tM as $t,qG as A,c_ as Aa,sC as Ai,gj as An,Bf as Ao,uD as Ar,Ao as As,UN as At,PG as B,Cg as Ba,$S as Bi,$k as Bn,Cd as Bo,OD as Br,uo as Bs,rN as Bt,aK as C,__ as Ca,dw as Ci,Aj as Cn,Xf as Co,PD as Cr,Po as Cs,SP as Ct,QG as D,i_ as Da,SC as Di,kj as Dn,Yf as Do,AD as Dr,Eo as Ds,yP as Dt,oK as E,u_ as Ea,tw as Ei,Nj as En,$f as Eo,pD as Er,Mo as Es,xP as Et,BG as F,Wg as Fa,nC as Fi,gA as Fn,pf as Fo,gD as Fr,bo as Fs,cN as Ft,wG as G,hg as Ga,wS as Gi,Pk as Gn,Wu as Go,jE as Gr,oo as Gs,xM as Gt,MG as H,Tg as Ha,US as Hi,Ik as Hn,nd as Ho,tD as Hr,co as Hs,wM as Ht,zG as I,Zg as Ia,aC as Ii,dA as In,ff as Io,aD as Ir,yo as Is,sN as It,yG as J,_h as Ja,uS as Ji,Ek as Jn,Al as Jo,oE as Jr,ao as Js,_M as Jt,CG as K,ng as Ka,CS as Ki,wk as Kn,Tu as Ko,aE as Kr,io as Ks,bM as Kt,RG as L,Rg as La,tC as Li,hA as Ln,af as Lo,oD as Lr,vo as Ls,B as Lt,GG as M,o_ as Ma,cC as Mi,ij as Mn,Rf as Mo,kD as Mr,Xo as Ms,gN as Mt,HG as N,Yg as Na,ZS as Ni,$A as Nn,Ff as No,xD as Nr,Jo as Ns,pN as Nt,ZG as O,r_ as Oa,mC as Oi,Pj as On,Hf as Oo,mD as Or,Io as Os,GN as Ot,VG as P,Jg as Pa,eC as Pi,BA as Pn,Pf as Po,hD as Pr,xo as Ps,lN as Pt,fG as Q,Ch as Qa,dx as Qi,vk as Qn,j as Qo,HT as Qr,ro as Qs,Wj as Qt,LG as R,Hg as Ra,QS as Ri,uA as Rn,Sd as Ro,_D as Rr,_o as Rs,aN as Rt,iK as S,m_ as Sa,lw as Si,jj as Sn,rp as So,MD as Sr,Fo as Ss,TP as St,rK as T,d_ as Ta,gw as Ti,Ij as Tn,ip as To,iD as Tr,No as Ts,bP as Tt,OG as U,xg as Ua,HS as Ui,Lk as Un,ud as Uo,UE as Ur,so as Us,CM as Ut,NG as V,Lg as Va,qS as Vi,eA as Vn,Td as Vo,sD as Vr,lo as Vs,tN as Vt,TG as W,kg as Wa,VS as Wi,Fk as Wn,zu as Wo,PE as Wr,no as Ws,SM as Wt,_G as X,Eh as Xa,Xx as Xi,Ok as Xn,Tl as Xo,mE as Xr,Wa as Xs,mM as Xt,vG as Y,xh as Ya,Kx as Yi,Dk as Yn,kl as Yo,pE as Yr,Va as Ys,gM as Yt,gG as Z,Dh as Za,Yx as Zi,pk as Zn,fl as Zo,lE as Zr,Ha as Zs,pM as Zt,mK as _,C_ as _a,mw as _i,qj as _n,rm as _o,ZO as _r,cs as _s,YF as _t,JK as a,Ay as aa,Ew as ai,cM as an,Vm as ao,DO as ar,Rs as as,DW as at,fK as b,x_ as ba,aw as bi,Gj as bn,op as bo,uO as br,ns as bs,vF as bt,WK as c,Ov as ca,I as ci,Xj as cn,Nm as co,IO as cr,Ps as cs,gW as ct,VK as d,gy as da,bw as di,Rj as dn,Jm as do,QO as dr,Ds as ds,fW as dt,wb as ea,Ka as ec,kT as ei,eM as en,hh as eo,_k as er,Hs as es,pG as et,zK as f,_y as fa,xw as fi,Lj as fn,qm as fo,KO as fr,Es as fs,dW as ft,SK as g,q_ as ga,ow as gi,Bj as gn,sm as go,WO as gr,ps as gs,oW as gt,EK as h,ev as ha,fw as hi,Uj as hn,cm as ho,GO as hr,fs as hs,sW as ht,qK as i,Oy as ia,OT as ii,oM as in,Rm as io,MO as ir,zs as is,OW as it,YG as j,s_ as ja,oC as ji,hj as jn,Vf as jo,fD as jr,zo as js,zN as jt,KG as k,l_ as ka,fC as ki,_j as kn,Wf as ko,cD as kr,Ro as ks,HN as kt,HK as l,Dv as la,yw as li,rM as ln,Km as lo,qO as lr,Ms as ls,mW as lt,NK as m,J_ as ma,uw as mi,Hj as mn,om as mo,YO as mr,ms,lW as mt,dq as n,_b as na,TT as ni,Yj as nn,eh as no,bk as nr,Bs as ns,uG as nt,YK as o,mv as oa,Cw as oi,lM as on,Am as oo,OO as or,Ns as os,wW as ot,RK as p,tv as pa,_w as pi,uM as pn,am as po,JO as pr,vs as ps,uW as pt,bG as q,ig as qa,pS as qi,Ak as qn,zl as qo,tE as qr,Qa as qs,vM as qt,fq as r,gb as ra,DT as ri,aM as rn,$m as ro,jO as rr,Is as rs,cG as rt,KK as s,xy as sa,ww as si,sM as sn,Pm as so,FO as sr,Fs as ss,yW as st,lq as t,Tb as ta,qa as tc,AT as ti,zj as tn,ph as to,yk as tr,Vs as ts,hG as tt,UK as u,vy as ua,vw as ui,iM as un,km as uo,UO as ur,ks as us,pW as ut,nK as v,S_ as va,hw as vi,Jj as vn,lm as vo,XO as vr,ss as vs,LF as vt,pK as w,f_ as wa,iw as wi,Fj as wn,Zf as wo,LD as wr,Go as ws,CP as wt,sK as x,g_ as xa,nw as xi,Vj as xn,cp as xo,ND as xr,Do as xs,mF as xt,tK as y,w_ as ya,rw as yi,Kj as yn,sp as yo,aO as yr,rs as ys,_F as yt,IG as z,Ug as za,iC as zi,mA as zn,Md as zo,vD as zr,ho as zs,iN as zt};
1533
- //# sourceMappingURL=WorkerPoolContext-CaivT_VA.js.map
1533
+ //# sourceMappingURL=WorkerPoolContext-CD9L3Rin.js.map