@fungi.computer/prints 0.20.17 → 0.20.19

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 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,C as n,Dn as r,En as i,Et as a,F as o,Gt as s,H as c,Ht as l,I as u,J as d,K as ee,Lt as te,M as ne,Mt as re,N as f,O as p,Ot as ie,Q as ae,R as oe,Rt as se,S as ce,Sn as m,T as h,Tn as le,V as g,Vn as ue,Vt as de,W as _,X as fe,_n as v,at as pe,bn as y,cn as b,ct as x,dn as S,et as me,fn as he,gn as C,hn as ge,it as w,j as _e,jt as ve,k as T,ln as ye,lt as E,mn as be,nt as xe,ot as D,q as Se,qt as Ce,st as O,tt as we,un as Te,w as k,wn as A,xn as Ee,yn as j,z as De,zt as Oe}from"./button-oE2Hrd5D.js";var M=e(ue(),1),ke=ge(),Ae=C(()=>be(`status`,[y({status:v(`available`)}).strict(),y({status:v(`unavailable`),reason:A()}).strict()])),je=ke,Me=C(()=>m(A(),je)),N=e=>je.parse(e),Ne=C(()=>y({code:A().min(1).max(160),message:A().min(1).max(512),details:je.optional()}).strict()),Pe=e=>Ne.parse(e),P=Me,F=C(()=>A().refine(e=>e.trim().length>0)),Fe=Ae,Ie=C(()=>le([y({type:v(`action`)}).strict(),y({type:v(`custom`),data:Me}).strict(),y({type:v(`choice`),options:S(y({value:je,label:F,description:F.optional()}))}).strict(),y({type:v(`form`),submitLabel:F.optional()}).strict(),y({type:v(`confirmation`),message:F,confirmLabel:F.optional(),cancelLabel:F.optional()}).strict()])),Le=C(()=>y({inputSchema:P.optional(),outputSchema:P.optional(),presentation:Ie.optional()}).strict()),Re=C(()=>j().int().refine(e=>Number.isSafeInteger(e))),ze=C(()=>y({hint:F.pipe(A().max(120)),words:S(y({word:A().regex(/^\S{1,64}$/u),description:F.pipe(A().max(512)).optional(),arguments:Me}).strict()).max(32).optional(),text:y({field:F.pipe(A().max(120)),arguments:Me,requestIdField:F.pipe(A().max(120)).optional()}).strict().optional()}).strict().refine(e=>e.words!==void 0||e.text!==void 0,`slash arguments need words or text`)),Be=C(()=>y({order:Re.optional()}).strict()),Ve=C(()=>y({bindings:y({order:Re.optional(),values:S(F).max(16)}).strict().optional(),agent:y({keybind:F.optional(),order:Re.optional()}).strict().optional(),help:Be.optional(),menu:Be.optional(),palette:Be.optional(),slash:y({aliases:S(F).max(16),consumesDraft:he().optional(),order:Re.optional(),arguments:ze.optional()}).strict().optional()}).strict()),He=C(()=>y({id:F.refine(e=>!e.includes(`:`)),title:F,category:F,description:F.optional(),projections:Ve.optional(),action:Le.optional(),availability:Fe.optional()}).strict()),Ue=e=>He.parse(e),We=C(()=>y({inputSchema:P.optional(),outputSchema:P.optional()}).strict()),Ge=A().min(1).brand(),Ke=C(()=>y({commandId:Ge,command:y({namespace:A(),id:A()}).strict(),sourceId:A(),scope:A().optional(),title:A(),category:A(),description:A().optional(),order:j(),availability:Ae,action:We.optional(),keybind:A().optional()}).strict());S(Ke);var qe=8192,I=F.pipe(A().max(qe)),Je=F.pipe(A().max(60)),Ye=r({protocol:/^https?$/u}),Xe=y({label:I,value:I}).strict(),Ze={summary:I.optional(),facts:S(Xe).max(4).optional(),body:I.optional(),bodyLabel:I.optional(),details:S(Xe).max(24).optional()};be(`type`,[y({type:v(`choice`),message:Je,...Ze,current:I.optional(),collapsedGroup:I.optional(),options:S(y({value:I,label:I,description:I.optional(),group:I.optional(),destructive:v(!0).optional()}).strict()).min(1).max(256)}).strict(),y({type:v(`text`),message:Je,...Ze,placeholder:I.optional(),secret:he().optional()}).strict(),y({type:v(`confirmation`),message:Je,...Ze,confirmLabel:I.optional(),cancelLabel:I.optional(),destructive:v(!0).optional()}).strict(),y({type:v(`decision`),message:Je,...Ze,options:S(y({value:I,label:I,description:I.optional(),destructive:v(!0).optional()}).strict()).min(1).max(8).refine(e=>new Set(e.map(e=>e.value)).size===e.length,`Decision option values must be unique`),multiple:he().optional(),other:y({label:I,placeholder:I.optional(),maxLength:j().int().min(1).max(qe),blank:I.optional()}).strict().optional(),escape:I.optional()}).strict().refine(e=>[e.escape,e.other?.blank].every(t=>t===void 0||e.options.some(e=>e.value===t)),`A decision's escape and blank answers must be offered options`)]),C(()=>be(`type`,[y({type:v(`info`),message:I,links:S(y({url:Ye,label:I.optional()}).strict()).max(16).optional()}).strict(),y({type:v(`progress`),message:I}).strict(),y({type:v(`handoff`),url:Ye,code:I.optional(),message:I.optional()}).strict(),y({type:v(`success`),message:I}).strict()]));var Qe=new WeakMap,$e=`~effect/Redacted`,et=e=>l(e,$e),tt=(e,t)=>{let n=Object.create(nt);return t?.label&&(n.label=t.label),Qe.set(n,e),n},nt={[$e]:{_A:e=>e},label:void 0,...te,toJSON(){return this.toString()},toString(){return`<redacted${s(this.label)?`:`+this.label:``}>`},[de](){return t(Qe.get(this))},[Oe](e){return et(e)&&se(Qe.get(this),Qe.get(e))}},rt=o.pipe(_(pe(1)),_(w(80))),it=[`CANCELLED`,`CAPABILITY_DENIED`,`CAPABILITY_REVOKED`,`COMMAND_NOT_DECLARED`,`CONFLICT`,`DAILY_LIMIT_REACHED`,`DELIVERY_PENDING`,`DISCONNECTED`,`FILE_TOO_LARGE`,`HOST_FAILURE`,`IDENTITY`,`INSUFFICIENT_CREDIT`,`INVALID_ARGUMENT`,`MEDIA_PROVIDER_FAILURE`,`MEDIA_PROVIDER_FAILURE_UNCHARGED`,`PROTOCOL`,`SAFETY_FILTER_REFUSED`,`SELECTION_CHANGED`,`SETUP_REQUIRED`,`TIMEOUT`],at=u({name:p(`AppError`),code:T(it),retryable:h,need:x(o)}),L=class extends Error{code;retryable;need;constructor(e,t){super(e,{cause:t.cause}),this.name=`AppError`,this.code=t.code,this.retryable=t.retryable,this.need=t.need}};function ot(e){return ve(ee(rt)(e))}function st(e){return`This needs ${e??`setup`} first.`}var ct={CANCELLED:{title:`Request cancelled`,message:`It stopped before it finished. Start it again if you still want it.`},CAPABILITY_DENIED:{title:`Access needed`,message:`This App needs permission to do that.`,action:`grant`},CAPABILITY_REVOKED:{title:`Access changed`,message:`This App no longer has permission to do that.`,action:`grant`},COMMAND_NOT_DECLARED:{title:`Action unavailable`,message:`This App doesn't include that action. It may need an update.`},CONFLICT:{title:`File changed`,message:`This file changed elsewhere. Review it before saving again.`},DAILY_LIMIT_REACHED:{title:`Daily limit reached`,message:`Today's spending limit for this Oyster is used up. It resets at 00:00 UTC.`},DELIVERY_PENDING:{title:`App delivery pending`,message:`The App hasn't finished getting ready. Try opening it again.`},DISCONNECTED:{title:`Connection lost`,message:`Reopen the App to connect again.`,action:`reconnect`},HOST_FAILURE:{title:`Couldn't complete the request`,message:`The host stopped answering. Reopen the App or reload the workspace.`},FILE_TOO_LARGE:{title:`File too large`,message:`Choose a file within the supported size limit.`},IDENTITY:{title:`Couldn't connect`,message:`Reopen the App to connect again.`,action:`reconnect`},INSUFFICIENT_CREDIT:{title:`Something went wrong`,message:`The App couldn't complete this request.`,action:`billing`},INVALID_ARGUMENT:{title:`Request not accepted`,message:`Some of the details weren't usable. Check them and try again.`},MEDIA_PROVIDER_FAILURE:{title:`Generation failed`,message:`The model couldn't complete this generation. Change the prompt or model and send again.`},MEDIA_PROVIDER_FAILURE_UNCHARGED:{title:`Generation failed`,message:`The model couldn't complete this generation. You weren't charged. Change the prompt or model and send again.`},PROTOCOL:{title:`Couldn't read the response`,message:`The host sent something this App doesn't understand. Reload the workspace; if it keeps happening, the App may need an update.`},SAFETY_FILTER_REFUSED:{title:`Generation refused`,message:`The model refused this generation. Change the prompt or reference image and send again.`},SELECTION_CHANGED:{title:`Selection changed`,message:`The selection changed during this request. Reopen the App to continue.`,action:`reconnect`},SETUP_REQUIRED:{title:`Setup needed`,message:st(void 0),action:`setup`},TIMEOUT:{title:`Still waiting`,message:`The request didn't respond in time. Its outcome isn't known yet.`},UNKNOWN:{title:`Something went wrong`,message:`The App couldn't complete this request.`}};function lt(e,t){let n=ee(at)(e);if(re(n))return{...ct.UNKNOWN,retryable:!1};let r=n.value,i=ct[r.code],a=t?.[r.code]??(r.code===`SETUP_REQUIRED`?{title:i.title,message:st(ot(r.need))}:i),o=i.action??(r.retryable?`retry`:void 0),s={title:a.title,message:a.message,retryable:r.retryable};return o?{...s,action:o}:s}var ut=n(),dt=M.createContext(void 0),ft=e=>{let t=M.useContext(dt);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},pt=({client:e,children:t})=>(M.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,ut.jsx)(dt.Provider,{value:e,children:t})),mt={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},ht=new class{#e=mt;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 gt(e){setTimeout(e,0)}var _t=typeof window>`u`||`Deno`in globalThis;function vt(){}function yt(e,t){return typeof e==`function`?e(t):e}function bt(e){return typeof e==`number`&&e>=0&&e!==1/0}function xt(e,t){return Math.max(e+(t||0)-Date.now(),0)}function St(e,t){return typeof e==`function`?e(t):e}function Ct(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Tt(o,t.options))return!1}else if(!Dt(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 wt(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Et(t.options.mutationKey)!==Et(a))return!1}else if(!Dt(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Tt(e,t){return(t?.queryKeyHashFn||Et)(e)}function Et(e){return JSON.stringify(e,(e,t)=>Mt(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Dt(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(!Dt(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Dt(e[r],t[r]))return!1;return!0}return!1}var Ot=Object.prototype.hasOwnProperty;function kt(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=jt(e)&&jt(t);if(!r&&!(Mt(e)&&Mt(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:Ot.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let ee=kt(u,d,n+1);s[o]=ee,ee===u&&c++}return i===o&&c===i?e:s}function At(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 jt(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Mt(e){if(!Nt(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Nt(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Nt(e){return Object.prototype.toString.call(e)===`[object Object]`}function Pt(e){return new Promise(t=>{ht.setTimeout(t,e)})}function Ft(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:kt(e,t)}function It(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Lt(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Rt=Symbol();function zt(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Rt?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Bt(e,t){return typeof e==`function`?e(...t):!!e}function Vt(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 Ht=()=>_t,Ut=()=>Ht(),Wt=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(){}},Gt=new class extends Wt{#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`}},Kt=gt;function qt(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Kt,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 Jt=qt(),Yt=new class extends Wt{#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 Xt(e){return Math.min(1e3*2**e,3e4)}function Zt(e){return(e??`online`)!==`online`||Yt.isOnline()}var Qt=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function $t(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(vt);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new Qt(t);re(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},ee=()=>Gt.isFocused()&&(e.networkMode===`always`||Yt.isOnline())&&e.canRun(),te=()=>Zt(e.networkMode)&&e.canRun(),ne=e=>{c()||(r?.(),i=`resolved`,a(e))},re=e=>{c()||(r?.(),i=`rejected`,o(e))},f=()=>new Promise(t=>{r=e=>{(c()||ee())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),p=()=>{if(c())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(ne).catch(r=>{if(c())return;let i=e.retry??(Ut()?0:3),a=e.retryDelay??Xt,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!s){re(r);return}n++,e.onFail?.(n,r),Pt(o).then(()=>ee()?void 0:f()).then(()=>{t?re(r):p()})})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:te,start:()=>(te()?p():f().then(p),s)}}var en=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),bt(this.gcTime)&&(this.#e=ht.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ut()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(ht.clearTimeout(this.#e),this.#e=void 0)}},tn=class extends en{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||nn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=$t({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),Jt.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function nn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var rn=Symbol(`workers-module`);Symbol.dispose||(Symbol.dispose=Symbol.for(`dispose`)),Symbol.asyncDispose||(Symbol.asyncDispose=Symbol.for(`asyncDispose`)),Promise.withResolvers||(Promise.withResolvers=function(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}});var an=globalThis[rn],on=an?an.RpcTarget:class{},sn=async function(){}.constructor,cn=typeof Buffer<`u`?Buffer.prototype:void 0;function ln(e){switch(typeof e){case`boolean`:case`number`:case`string`:return`primitive`;case`undefined`:return`undefined`;case`object`:case`function`:break;case`bigint`:return`bigint`;default:return`unsupported`}if(e===null)return`primitive`;let t=Object.getPrototypeOf(e);switch(t){case Object.prototype:return`object`;case Function.prototype:case sn.prototype:return`function`;case Array.prototype:return`array`;case Date.prototype:return`date`;case Uint8Array.prototype:case cn:case ArrayBuffer.prototype:case DataView.prototype:case Int8Array.prototype:case Uint8ClampedArray.prototype:case Int16Array.prototype:case Uint16Array.prototype:case Int32Array.prototype:case Uint32Array.prototype:case BigInt64Array.prototype:case BigUint64Array.prototype:case Float32Array.prototype:case Float64Array.prototype:return`bytes`;case WritableStream.prototype:return`writable`;case ReadableStream.prototype:return`readable`;case URL.prototype:return`url`;case Headers.prototype:return`headers`;case Request.prototype:return`request`;case Response.prototype:return`response`;case Blob.prototype:return`blob`;case H.prototype:return`stub`;case U.prototype:return`rpc-promise`;default:if(an){if(t==an.RpcStub.prototype||e instanceof an.ServiceStub)return`rpc-target`;if(t==an.RpcPromise.prototype||t==an.RpcProperty.prototype)return`rpc-thenable`}return e instanceof on?`rpc-target`:e instanceof Error?`error`:`unsupported`}}function un(){throw Error(`RPC map() implementation was not loaded.`)}var dn={applyMap:un,sendMap:un};function fn(){throw Error(`Stream implementation was not loaded.`)}var R={createWritableStreamHook:fn,createWritableStreamFromHook:fn,createReadableStreamHook:fn},z=class{stream(e,t){let n=this.call(e,t),r;try{r=n.pull()}catch(e){throw n.dispose(),e}let i;return r instanceof Promise?i=r.then(e=>{e.dispose()}):(r.dispose(),i=Promise.resolve()),{promise:i}}},B=class extends z{error;constructor(e){super(),this.error=e}call(e,t){return t.dispose(),this}map(e,t,n){for(let e of t)e.dispose();return this}get(e){return this}dup(){return this}pull(){return Promise.reject(this.error)}ignoreUnhandledRejections(){}dispose(){}onBroken(e){try{e(this.error)}catch(e){Promise.resolve(e)}}},pn=new B(Error(`Attempted to use RPC stub after it has been disposed.`)),mn=(e,t,n)=>e.call(t,n);function hn(e,t){let n=mn;mn=e;try{return t()}finally{mn=n}}var V=Symbol(`realStub`),gn={apply(e,t,n){let r=e.raw;return new U(mn(r.hook,r.pathIfPromise||[],W.fromAppParams(n)),[])},get(e,t,n){let r=e.raw;if(t===V)return r;if(t in U.prototype)return r[t];if(typeof t==`string`)return new U(r.hook,r.pathIfPromise?[...r.pathIfPromise,t]:[t]);if(t===Symbol.dispose&&(!r.pathIfPromise||r.pathIfPromise.length==0))return()=>{r.hook.dispose(),r.hook=pn}},has(e,t){let n=e.raw;return t===V?!0:t in U.prototype?t in n:typeof t==`string`||t===Symbol.dispose&&(!n.pathIfPromise||n.pathIfPromise.length==0)},construct(e,t){throw Error(`An RPC stub cannot be used as a constructor.`)},defineProperty(e,t,n){throw Error(`Can't define properties on RPC stubs.`)},deleteProperty(e,t){throw Error(`Can't delete properties on RPC stubs.`)},getOwnPropertyDescriptor(e,t){},getPrototypeOf(e){return Object.getPrototypeOf(e.raw)},isExtensible(e){return!1},ownKeys(e){return[]},preventExtensions(e){return!0},set(e,t,n,r){throw Error(`Can't assign properties on RPC stubs.`)},setPrototypeOf(e,t){throw Error(`Can't override prototype of RPC stubs.`)}},H=class e extends on{constructor(e,t){if(super(),!(e instanceof z)){let n=e;if(e=n instanceof on||n instanceof Function?En.create(n,void 0):new G(W.fromAppReturn(n)),t)throw TypeError(`RpcStub constructor expected one argument, received two.`)}this.hook=e,this.pathIfPromise=t;let n=()=>{};return n.raw=this,new Proxy(n,gn)}hook;pathIfPromise;dup(){let t=this[V];return t.pathIfPromise?new e(t.hook.get(t.pathIfPromise)):new e(t.hook.dup())}onRpcBroken(e){this[V].hook.onBroken(e)}map(e){let{hook:t,pathIfPromise:n}=this[V];return dn.sendMap(t,n||[],e)}toString(){return`[object RpcStub]`}},U=class extends H{constructor(e,t){if(e instanceof z)super(e,t??[]);else{if(t!==void 0)throw TypeError(`RpcPromise constructor expected one argument, received two.`);let n=ln(e);if(n===`rpc-promise`){let t=xn(e);if(t.pathIfPromise.length>0)super(t.hook,t.pathIfPromise);else{let e=t.hook;t.hook=pn,super(e,[])}}else if(n===`rpc-thenable`)super(En.create(e,void 0),[]);else{let t=new Dn(Promise.resolve(e).then(e=>new G(W.fromAppReturn(e))));t.ignoreUnhandledRejections(),super(t,[])}}}then(e,t){return Sn(this).then(...arguments)}catch(e){return Sn(this).catch(...arguments)}finally(e){return Sn(this).finally(...arguments)}toString(){return`[object RpcPromise]`}};function _n(e){let{hook:t,pathIfPromise:n}=e[V];return n&&n.length>0?t.get(n):t}function vn(e){let{hook:t,pathIfPromise:n}=e[V];return n?t.get(n):t.dup()}function yn(e){let{hook:t,pathIfPromise:n}=e[V];if(!(n&&n.length>0))return t}function bn(e){return e[V].hook}function xn(e){return e[V]}async function Sn(e){let{hook:t,pathIfPromise:n}=e[V];return n.length>0&&(t=t.get(n)),(await t.pull()).deliverResolve()}var W=class e{value;source;hooks;promises;static fromAppParams(t){return new e(t,`params`)}static fromAppReturn(t){return new e(t,`return`)}static fromArray(t){let n=[],r=[],i=[];for(let e of t){e.ensureDeepCopied();for(let t of e.hooks)n.push(t);for(let t of e.promises)t.parent===e&&(t={parent:i,property:i.length,promise:t.promise}),r.push(t);i.push(e.value)}return new e(i,`owned`,n,r)}static forEvaluate(t,n){return new e(null,`owned`,t,n)}static deepCopyFrom(t,n,r){let i=new e(null,`owned`,[],[]);return i.value=i.deepCopy(t,n,`value`,i,!0,r),i}constructor(e,t,n,r){this.value=e,this.source=t,this.hooks=n,this.promises=r}rpcTargets;getHookForRpcTarget(e,t,n=!0){if(this.source===`params`){if(n){let t=e;typeof t.dup==`function`&&(e=t.dup())}return En.create(e,t)}if(this.source===`return`){let r=this.rpcTargets?.get(e);return r?n?r.dup():(this.rpcTargets?.delete(e),r):(r=En.create(e,t),n?(this.rpcTargets||=new Map,this.rpcTargets.set(e,r),r.dup()):r)}throw Error(`owned payload shouldn't contain raw RpcTargets`)}getHookForWritableStream(e,t,n=!0){if(this.source===`params`)return R.createWritableStreamHook(e);if(this.source===`return`){let t=this.rpcTargets?.get(e);return t?n?t.dup():(this.rpcTargets?.delete(e),t):(t=R.createWritableStreamHook(e),n?(this.rpcTargets||=new Map,this.rpcTargets.set(e,t),t.dup()):t)}throw Error(`owned payload shouldn't contain raw WritableStreams`)}getHookForReadableStream(e,t,n=!0){if(this.source===`params`)return R.createReadableStreamHook(e);if(this.source===`return`){let t=this.rpcTargets?.get(e);return t?n?t.dup():(this.rpcTargets?.delete(e),t):(t=R.createReadableStreamHook(e),n?(this.rpcTargets||=new Map,this.rpcTargets.set(e,t),t.dup()):t)}throw Error(`owned payload shouldn't contain raw ReadableStreams`)}deepCopy(e,t,n,r,i,a){switch(ln(e)){case`unsupported`:return e;case`primitive`:case`bigint`:case`date`:case`bytes`:case`blob`:case`url`:case`error`:case`undefined`:return e;case`array`:{let t=e,n=t.length,r=Array(n);for(let e=0;e<n;e++)r[e]=this.deepCopy(t[e],t,e,r,i,a);return r}case`object`:{let t={},n=e;for(let e in n)t[e]=this.deepCopy(n[e],n,e,t,i,a);return t}case`stub`:case`rpc-promise`:{let t=e,a;if(a=i?vn(t):_n(t),t instanceof U){let e=new U(a,[]);return this.promises.push({parent:r,property:n,promise:e}),e}return this.hooks.push(a),new H(a)}case`function`:case`rpc-target`:{let n=e,r;return r=a?a.getHookForRpcTarget(n,t,i):En.create(n,t),this.hooks.push(r),new H(r)}case`rpc-thenable`:{let o=e,s;return s=a?new U(a.getHookForRpcTarget(o,t,i),[]):new U(En.create(o,t),[]),this.promises.push({parent:r,property:n,promise:s}),s}case`writable`:{let n=e,r;return r=a?a.getHookForWritableStream(n,t,i):R.createWritableStreamHook(n),this.hooks.push(r),n}case`readable`:{let n=e,r;return r=a?a.getHookForReadableStream(n,t,i):R.createReadableStreamHook(n),this.hooks.push(r),n}case`headers`:return new Headers(e);case`request`:{let t=e;return t.body&&this.deepCopy(t.body,t,`body`,t,i,a),new Request(t)}case`response`:{let t=e;return t.body&&this.deepCopy(t.body,t,`body`,t,i,a),new Response(t.body,t)}default:throw Error(`unreachable`)}}ensureDeepCopied(){if(this.source!==`owned`){let e=this.source===`params`;this.hooks=[],this.promises=[];try{this.value=this.deepCopy(this.value,void 0,`value`,this,e,this)}catch(e){throw this.hooks=void 0,this.promises=void 0,e}if(this.source=`owned`,this.rpcTargets&&this.rpcTargets.size>0)throw Error(`Not all rpcTargets were accounted for in deep-copy?`);this.rpcTargets=void 0}}deliverTo(t,n,r){if(this.ensureDeepCopied(),this.value instanceof U)e.deliverRpcPromiseTo(this.value,t,n,r);else{t[n]=this.value;for(let t of this.promises)e.deliverRpcPromiseTo(t.promise,t.parent,t.property,r)}}static deliverRpcPromiseTo(t,n,r,i){let a=yn(t);if(!a)throw Error(`property promises should have been resolved earlier`);let o=a.pull();o instanceof e?o.deliverTo(n,r,i):i.push(o.then(e=>{let t=[];if(e.deliverTo(n,r,t),t.length>0)return Promise.all(t)}))}async deliverCall(t,n){try{let r=[];this.deliverTo(this,`value`,r),r.length>0&&await Promise.all(r);let i=Function.prototype.apply.call(t,n,this.value);return i instanceof U?e.fromAppReturn(i):e.fromAppReturn(await i)}finally{this.dispose()}}async deliverStreamWrite(t){try{let n=[];this.deliverTo(this,`value`,n),n.length>0&&await Promise.all(n);let r=this.value[0];return(this.hooks.length>0||this.promises.length>0)&&r instanceof Object?(Symbol.dispose in r||Object.defineProperty(r,Symbol.dispose,{value:()=>this.dispose(),writable:!0,enumerable:!1,configurable:!0}),await t.write(r),e.fromAppReturn(void 0)):(await t.write(r),this.dispose(),e.fromAppReturn(void 0))}catch(e){throw this.dispose(),e}}async deliverResolve(){try{let e=[];this.deliverTo(this,`value`,e),e.length>0&&await Promise.all(e);let t=this.value;return t instanceof Object&&(Symbol.dispose in t||Object.defineProperty(t,Symbol.dispose,{value:()=>this.dispose(),writable:!0,enumerable:!1,configurable:!0})),t}catch(e){throw this.dispose(),e}}dispose(){if(this.source===`owned`)this.hooks.forEach(e=>e.dispose()),this.promises.forEach(e=>e.promise[Symbol.dispose]());else if(this.source===`return`&&(this.disposeImpl(this.value,void 0),this.rpcTargets&&this.rpcTargets.size>0))throw Error(`Not all rpcTargets were accounted for in disposeImpl()?`);this.source=`owned`,this.hooks=[],this.promises=[]}disposeImpl(e,t){switch(ln(e)){case`unsupported`:case`primitive`:case`bigint`:case`bytes`:case`blob`:case`date`:case`url`:case`error`:case`undefined`:return;case`array`:{let t=e,n=t.length;for(let e=0;e<n;e++)this.disposeImpl(t[e],t);return}case`object`:{let t=e;for(let e in t)this.disposeImpl(t[e],t);return}case`stub`:case`rpc-promise`:{let t=yn(e);t&&t.dispose();return}case`function`:case`rpc-target`:{let t=e,n=this.rpcTargets?.get(t);n?(n.dispose(),this.rpcTargets.delete(t)):Tn(t);return}case`rpc-thenable`:return;case`headers`:return;case`request`:{let t=e;t.body&&this.disposeImpl(t.body,t);return}case`response`:{let t=e;t.body&&this.disposeImpl(t.body,t);return}case`writable`:{let t=e,n=this.rpcTargets?.get(t);n?this.rpcTargets.delete(t):n=R.createWritableStreamHook(t),n.dispose();return}case`readable`:{let t=e,n=this.rpcTargets?.get(t);n?this.rpcTargets.delete(t):n=R.createReadableStreamHook(t),n.dispose();return}default:return}}ignoreUnhandledRejections(){this.hooks?(this.hooks.forEach(e=>{e.ignoreUnhandledRejections()}),this.promises.forEach(e=>bn(e.promise).ignoreUnhandledRejections())):this.ignoreUnhandledRejectionsImpl(this.value)}ignoreUnhandledRejectionsImpl(e){switch(ln(e)){case`unsupported`:case`primitive`:case`bigint`:case`bytes`:case`blob`:case`date`:case`error`:case`undefined`:case`function`:case`rpc-target`:case`writable`:case`readable`:case`url`:case`headers`:case`request`:case`response`:return;case`array`:{let t=e,n=t.length;for(let e=0;e<n;e++)this.ignoreUnhandledRejectionsImpl(t[e]);return}case`object`:{let t=e;for(let e in t)this.ignoreUnhandledRejectionsImpl(t[e]);return}case`stub`:case`rpc-promise`:bn(e).ignoreUnhandledRejections();return;case`rpc-thenable`:e.then(e=>{},e=>{});return;default:return}}};function Cn(e,t,n,r){for(let i=0;i<n.length;i++){t=e;let a=n[i];if(a in Object.prototype){e=void 0;continue}switch(ln(e)){case`object`:case`function`:e=Object.hasOwn(e,a)?e[a]:void 0;break;case`array`:e=Number.isInteger(a)&&a>=0?e[a]:void 0;break;case`rpc-target`:case`rpc-thenable`:if(Object.hasOwn(e,a))throw TypeError(`Attempted to access property '${a}', which is an instance property of the RpcTarget. To avoid leaking private internals, instance properties cannot be accessed over RPC. If you want to make this property available over RPC, define it as a method or getter on the class, instead of an instance property.`);e=e[a],r=null;break;case`stub`:case`rpc-promise`:{let{hook:t,pathIfPromise:r}=xn(e);return{hook:t,remainingPath:r?r.concat(n.slice(i)):n.slice(i)}}case`writable`:e=void 0;break;case`readable`:e=void 0;break;case`primitive`:case`bigint`:case`bytes`:case`blob`:case`date`:case`error`:case`url`:case`headers`:case`request`:case`response`:e=void 0;break;case`undefined`:e=e[a];break;case`unsupported`:if(i===0)throw TypeError(`RPC stub points at a non-serializable type.`);{let e=n.slice(0,i).join(`.`),t=n.slice(0,i).join(`.`);throw TypeError(`'${e}' is not a serializable type, so property ${t} cannot be accessed.`)}default:throw TypeError(`unreachable`)}}if(e instanceof U){let{hook:t,pathIfPromise:n}=xn(e);return{hook:t,remainingPath:n||[]}}return{value:e,parent:t,owner:r}}var wn=class extends z{call(e,t){let n;try{let{value:t,owner:r}=this.getValue();n=Cn(t,void 0,e,r)}catch(e){return t.dispose(),new B(e)}return n.hook?n.hook.call(n.remainingPath,t):typeof n.value==`function`?new Dn(t.deliverCall(n.value,n.parent).then(e=>new G(e))):(t.dispose(),new B(TypeError(`'${e.join(`.`)}' is not a function.`)))}map(e,t,n){try{let r;try{let{value:t,owner:n}=this.getValue();r=Cn(t,void 0,e,n)}catch(e){for(let e of t)e.dispose();throw e}return r.hook?r.hook.map(r.remainingPath,t,n):dn.applyMap(r.value,r.parent,r.owner,t,n)}catch(e){return new B(e)}}get(e){try{let{value:t,owner:n}=this.getValue();if(e.length===0&&n===null){if(t instanceof Object&&`then`in t)return this.dup();throw Error(`Can't dup an RpcTarget stub as a promise.`)}let r=Cn(t,void 0,e,n);return r.hook?r.hook.get(r.remainingPath):new G(W.deepCopyFrom(r.value,r.parent,r.owner))}catch(e){return new B(e)}}},G=class e extends wn{constructor(e){super(),this.payload=e}payload;getPayload(){if(this.payload)return this.payload;throw Error(`Attempted to use an RPC StubHook after it was disposed.`)}getValue(){let e=this.getPayload();return{value:e.value,owner:e}}dup(){let t=this.getPayload();return new e(W.deepCopyFrom(t.value,void 0,t))}pull(){return this.getPayload()}ignoreUnhandledRejections(){this.payload&&this.payload.ignoreUnhandledRejections()}dispose(){this.payload&&=(this.payload.dispose(),void 0)}onBroken(e){this.payload&&this.payload.value instanceof H&&this.payload.value.onRpcBroken(e)}};function Tn(e){if(Symbol.dispose in e)try{e[Symbol.dispose]()}catch(e){Promise.reject(e)}}var En=class e extends wn{static create(t,n){return typeof t!=`function`&&(n=void 0),new e(t,n)}constructor(e,t,n){super(),this.target=e,this.parent=t,n?n.refcount&&(this.refcount=n.refcount,++this.refcount.count):Symbol.dispose in e&&(this.refcount={count:1})}target;parent;refcount;getTarget(){if(this.target)return this.target;throw Error(`Attempted to use an RPC StubHook after it was disposed.`)}getValue(){return{value:this.getTarget(),owner:null}}dup(){return new e(this.getTarget(),this.parent,this)}pull(){let e=this.getTarget();return`then`in e?Promise.resolve(e).then(e=>W.fromAppReturn(e)):Promise.reject(Error(`Tried to resolve a non-promise stub.`))}ignoreUnhandledRejections(){}dispose(){this.target&&=(this.refcount&&--this.refcount.count==0&&Tn(this.target),void 0)}onBroken(e){let t=this.target;t&&`then`in t&&Promise.resolve(t).then(()=>{},e)}},Dn=class e extends z{promise;resolution;constructor(e){super(),this.promise=e.then(e=>(this.resolution=e,e))}call(t,n){return n.ensureDeepCopied(),new e(this.promise.then(e=>e.call(t,n),e=>{throw n.dispose(),e}))}stream(e,t){return t.ensureDeepCopied(),{promise:this.promise.then(n=>n.stream(e,t).promise,e=>{throw t.dispose(),e})}}map(t,n,r){return new e(this.promise.then(e=>e.map(t,n,r),e=>{for(let e of n)e.dispose();throw e}))}get(t){return new e(this.promise.then(e=>e.get(t)))}dup(){return this.resolution?this.resolution.dup():new e(this.promise.then(e=>e.dup()))}pull(){return this.resolution?this.resolution.pull():this.promise.then(e=>e.pull())}ignoreUnhandledRejections(){this.resolution?this.resolution.ignoreUnhandledRejections():this.promise.then(e=>{e.ignoreUnhandledRejections()},e=>{})}dispose(){this.promise.then(e=>e.dispose(),()=>{})}onBroken(e){this.resolution?this.resolution.onBroken(e):this.promise.then(t=>{t.onBroken(e)},e)}},On={maxBigIntDigits:16384,maxDepth:256,maxMessageSize:33554432},kn=new Uint8Array(new Uint16Array([1]).buffer)[0]===1,An=[`ArrayBuffer`,`DataView`,`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`BigInt64Array`,`BigUint64Array`,`Float32Array`,`Float64Array`];function jn(e){return An.includes(e)}var Mn={ArrayBuffer:void 0,DataView:void 0,Int8Array:void 0,Uint8Array:void 0,Uint8ClampedArray:void 0,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,BigInt64Array:8,BigUint64Array:8,Float32Array:4,Float64Array:8},Nn={ArrayBuffer:ArrayBuffer.prototype,DataView:DataView.prototype,Int8Array:Int8Array.prototype,Uint8ClampedArray:Uint8ClampedArray.prototype,Int16Array:Int16Array.prototype,Uint16Array:Uint16Array.prototype,Int32Array:Int32Array.prototype,Uint32Array:Uint32Array.prototype,BigInt64Array:BigInt64Array.prototype,BigUint64Array:BigUint64Array.prototype,Float32Array:Float32Array.prototype,Float64Array:Float64Array.prototype},Pn=new Map;for(let e of Object.keys(Nn))Pn.set(Nn[e],e);function Fn(e,t){if(t!==2&&t!==4&&t!==8)throw RangeError(`Unsupported element size: ${t}`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let r=0;r<e.byteLength;r+=t)switch(t){case 2:n.setUint16(r,n.getUint16(r,!1),!0);break;case 4:n.setUint32(r,n.getUint32(r,!1),!0);break;case 8:n.setBigUint64(r,n.getBigUint64(r,!1),!0)}}var In=new class{exportStub(e){throw Error(`Cannot serialize RPC stubs without an RPC session.`)}exportPromise(e){throw Error(`Cannot serialize RPC stubs without an RPC session.`)}getImport(e){}unexport(e){}createPipe(e){throw Error(`Cannot create pipes without an RPC session.`)}onSendError(e){}};async function Ln(e,t){let n=await new Response(e).blob();return n.type===t?n:n.slice(0,n.size,t)}var Rn={__proto__:null,Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError},K=class e{exporter;source;encodingLevel;constructor(e,t,n){this.exporter=e,this.source=t,this.encodingLevel=n}static devaluate(t,n,r=In,i,a=`string`){let o=new e(r,i,a);try{return o.devaluateImpl(t,n,0)}catch(e){if(o.exports)try{r.unexport(o.exports)}catch{}throw e}}exports;devaluateImpl(e,t,n){if(n>=256)throw Error(`Serialization exceeded maximum allowed depth. (Does the message contain cycles?)`);switch(ln(e)){case`unsupported`:{let t;try{t=`Cannot serialize value: ${e}`}catch{t=`Cannot serialize value: (couldn't stringify value)`}throw TypeError(t)}case`primitive`:return typeof e==`number`&&!isFinite(e)?this.encodingLevel===`structuredClonable`?e:e===1/0?[`inf`]:e===-1/0?[`-inf`]:[`nan`]:e;case`object`:{let t=e,r={};for(let e in t)r[e]=this.devaluateImpl(t[e],t,n+1);return r}case`array`:{let t=e,r=t.length,i=Array(r);for(let e=0;e<r;e++)i[e]=this.devaluateImpl(t[e],t,n+1);return[i]}case`bigint`:return this.encodingLevel===`structuredClonable`?e:[`bigint`,e.toString()];case`date`:{if(this.encodingLevel===`structuredClonable`)return e;let t=e.getTime();return[`date`,Number.isNaN(t)?null:t]}case`bytes`:{let t=Pn.get(Object.getPrototypeOf(e)),n;if(t===`ArrayBuffer`)n=new Uint8Array(e);else if(t===void 0)n=e;else{let r=e;n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);let i=Mn[t];!kn&&i&&(n=n.slice(),Fn(n,i))}if(this.encodingLevel===`structuredClonable`||this.encodingLevel===`jsonCompatibleWithBytes`)return t===void 0?[`bytes`,n]:[`bytes`,n,t];let r;if(n.toBase64)r=n.toBase64({omitPadding:!0});else if(typeof Buffer<`u`)r=(n instanceof Buffer?n:Buffer.from(n.buffer,n.byteOffset,n.byteLength)).toString(`base64`);else{let e=``;for(let t=0;t<n.length;t++)e+=String.fromCharCode(n[t]);r=btoa(e)}return r=r.replace(/=+$/,``),t===void 0?[`bytes`,r]:[`bytes`,r,t]}case`url`:return[`url`,e.href];case`headers`:return[`headers`,[...e]];case`request`:{let t=e,r={};t.method!==`GET`&&(r.method=t.method);let i=[...t.headers];if(i.length>0&&(r.headers=i),t.body)r.body=this.devaluateImpl(t.body,t,n+1),r.duplex=t.duplex||`half`;else if(t.body===void 0&&![`GET`,`HEAD`,`OPTIONS`,`TRACE`,`DELETE`].includes(t.method)){let e=t.arrayBuffer(),n=new ReadableStream({async start(t){try{t.enqueue(new Uint8Array(await e)),t.close()}catch(e){t.error(e)}}}),i=R.createReadableStreamHook(n);r.body=[`readable`,this.exporter.createPipe(n,i)],r.duplex=t.duplex||`half`}t.cache&&t.cache!=="default"&&(r.cache=t.cache),t.redirect!==`follow`&&(r.redirect=t.redirect),t.integrity&&(r.integrity=t.integrity),t.mode&&t.mode!==`cors`&&(r.mode=t.mode),t.credentials&&t.credentials!==`same-origin`&&(r.credentials=t.credentials),t.referrer&&t.referrer!==`about:client`&&(r.referrer=t.referrer),t.referrerPolicy&&(r.referrerPolicy=t.referrerPolicy),t.keepalive&&(r.keepalive=t.keepalive);let a=t;return a.cf&&(r.cf=a.cf),a.encodeResponseBody&&a.encodeResponseBody!==`automatic`&&(r.encodeResponseBody=a.encodeResponseBody),[`request`,t.url,r]}case`response`:{let t=e,r=this.devaluateImpl(t.body,t,n+1),i={};t.status!==200&&(i.status=t.status),t.statusText&&(i.statusText=t.statusText);let a=[...t.headers];a.length>0&&(i.headers=a);let o=t;if(o.cf&&(i.cf=o.cf),o.encodeBody&&o.encodeBody!==`automatic`&&(i.encodeBody=o.encodeBody),o.webSocket)throw TypeError(`Can't serialize a Response containing a webSocket.`);return[`response`,r,i]}case`blob`:{let t=e,n=t.stream(),r=R.createReadableStreamHook(n),i=this.exporter.createPipe(n,r);return[`blob`,t.type,[`readable`,i]]}case`error`:{let t=e,r=this.exporter.onSendError(t);r&&(t=r);let i=t,a,o=(e,r)=>{let i=this.exports?.length??0;try{let i=this.devaluateImpl(r,t,n+1);a||={},a[e]=i}catch{if(this.exports&&this.exports.length>i){let e=this.exports.splice(i);try{this.exporter.unexport(e)}catch{}}}};for(let e of Object.keys(t))e!==`name`&&e!==`message`&&e!==`stack`&&o(e,i[e]);`cause`in t&&o(`cause`,i.cause),t instanceof AggregateError&&o(`errors`,t.errors);let s=[`error`,t.name,t.message];return a?(s.push(r&&r.stack?r.stack:null),s.push(a)):r&&r.stack&&s.push(r.stack),s}case`undefined`:return this.encodingLevel===`structuredClonable`?void 0:[`undefined`];case`stub`:case`rpc-promise`:{if(!this.source)throw Error(`Can't serialize RPC stubs in this context.`);let{hook:t,pathIfPromise:n}=xn(e),r=this.exporter.getImport(t);return r===void 0?(t=n?t.get(n):t.dup(),this.devaluateHook(n?`promise`:`export`,t)):n?n.length>0?[`pipeline`,r,n]:[`pipeline`,r]:[`import`,r]}case`function`:case`rpc-target`:{if(!this.source)throw Error(`Can't serialize RPC stubs in this context.`);let n=this.source.getHookForRpcTarget(e,t);return this.devaluateHook(`export`,n)}case`rpc-thenable`:{if(!this.source)throw Error(`Can't serialize RPC stubs in this context.`);let n=this.source.getHookForRpcTarget(e,t);return this.devaluateHook(`promise`,n)}case`writable`:{if(!this.source)throw Error(`Can't serialize WritableStream in this context.`);let n=this.source.getHookForWritableStream(e,t);return this.devaluateHook(`writable`,n)}case`readable`:{if(!this.source)throw Error(`Can't serialize ReadableStream in this context.`);let n=e,r=this.source.getHookForReadableStream(n,t);return[`readable`,this.exporter.createPipe(n,r)]}default:throw Error(`unreachable`)}}devaluateHook(e,t){this.exports||=[];let n=e===`promise`?this.exporter.exportPromise(t):this.exporter.exportStub(t);return this.exports.push(n),[e,n]}};new class{importStub(e){throw Error(`Cannot deserialize RPC stubs without an RPC session.`)}importPromise(e){throw Error(`Cannot deserialize RPC stubs without an RPC session.`)}getExport(e){}getPipeReadable(e){throw Error(`Cannot retrieve pipe readable without an RPC session.`)}getLimits(){return On}};function zn(e,t){return new U(new Dn(new Response(t).arrayBuffer().then(t=>{let n=new Uint8Array(t),r=new Request(e,{body:n});return new G(W.fromAppReturn(r))})),[])}function Bn(e,t){return new U(new Dn(Ln(e,t).then(e=>new G(W.fromAppReturn(e)))),[])}var Vn=class e{importer;encodingLevel;limits;constructor(e,t=`string`){this.importer=e,this.encodingLevel=t,this.limits=e.getLimits()}hooks=[];promises=[];evaluate(e){return this.evaluateWithDepth(e,0)}evaluateWithDepth(e,t){let n=W.forEvaluate(this.hooks,this.promises);try{return n.value=this.evaluateImpl(e,n,`value`,t),n}catch(e){throw n.dispose(),e}}evaluateCopy(e){return this.evaluate(structuredClone(e))}evaluateImpl(t,n,r,i){let a=this.limits.maxDepth;if(i>=a)throw TypeError(`Deserialization exceeded maximum allowed message depth of ${a}.`);if(this.encodingLevel===`structuredClonable`&&(t instanceof Date||typeof t==`bigint`))return t;if(t instanceof Array){if(t.length==1&&t[0]instanceof Array){let e=t[0];for(let t=0;t<e.length;t++)e[t]=this.evaluateImpl(e[t],e,t,i+1);return e}switch(t[0]){case`bigint`:if(typeof t[1]==`string`){let e=t[1],n=this.limits.maxBigIntDigits;if(e.length>n)throw TypeError(`Deserialized bigint exceeds maximum length of ${n} digits.`);return BigInt(e)}break;case`date`:if(t[1]===null)return new Date(NaN);if(typeof t[1]==`number`)return new Date(t[1]);break;case`bytes`:{let e;if(t[1]instanceof Uint8Array)e=t[1];else if(typeof t[1]==`string`){if(typeof Buffer<`u`)e=Buffer.from(t[1],`base64`);else if(Uint8Array.fromBase64)e=Uint8Array.fromBase64(t[1]);else{let n=atob(t[1]),r=n.length;e=new Uint8Array(r);for(let t=0;t<r;t++)e[t]=n.charCodeAt(t)}}else break;if(t.length===2)return e;if(typeof t[2]!=`string`)throw TypeError(`Unknown bytes type marker type: ${typeof t[2]}`);if(!jn(t[2])){let e=t[2].slice(0,64);throw TypeError(`Unknown bytes type marker: ${e}`)}let n=t[2],r=Mn[n];if(r!==void 0&&e.byteLength%r!==0)throw TypeError(`Invalid byte length ${e.byteLength} for ${n}; expected a multiple of ${r}`);let i=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);switch(!kn&&r!==void 0&&Fn(new Uint8Array(i),r),n){case`ArrayBuffer`:return i;case`DataView`:return new DataView(i);case`Int8Array`:return new Int8Array(i);case`Uint8Array`:return new Uint8Array(i);case`Uint8ClampedArray`:return new Uint8ClampedArray(i);case`Int16Array`:return new Int16Array(i);case`Uint16Array`:return new Uint16Array(i);case`Int32Array`:return new Int32Array(i);case`Uint32Array`:return new Uint32Array(i);case`BigInt64Array`:return new BigInt64Array(i);case`BigUint64Array`:return new BigUint64Array(i);case`Float32Array`:return new Float32Array(i);case`Float64Array`:return new Float64Array(i)}}case`error`:if(t.length>=3&&typeof t[1]==`string`&&typeof t[2]==`string`){let e=Rn[t[1]]||Error,n=e===AggregateError?new e([],t[2]):new e(t[2]);if(typeof t[3]==`string`&&(n.stack=t[3]),t.length>=5){let e=t[4];if(!e||typeof e!=`object`||Array.isArray(e))break;let r=n,a=e;for(let e of Object.keys(a))if(e!==`name`&&e!==`message`&&e!==`stack`){if(e in Object.prototype||e===`toJSON`){this.evaluateImpl(a[e],n,e,i+1);continue}r[e]=this.evaluateImpl(a[e],n,e,i+1)}}return n}break;case`undefined`:if(t.length===1)return;break;case`inf`:return 1/0;case`-inf`:return-1/0;case`nan`:return NaN;case`url`:if(t.length===2&&typeof t[1]==`string`)return new URL(t[1]);break;case`headers`:if(t.length===2&&t[1]instanceof Array)return new Headers(t[1]);break;case`request`:{if(t.length!==3||typeof t[1]!=`string`)break;let e=t[1],a=t[2];if(typeof a!=`object`||!a)break;if(a.body&&(a.body=this.evaluateImpl(a.body,a,`body`,i+1),!(a.body===null||typeof a.body==`string`||a.body instanceof Uint8Array||a.body instanceof ReadableStream)))throw TypeError(`Request body must be of type ReadableStream.`);if(a.signal&&(a.signal=this.evaluateImpl(a.signal,a,`signal`,i+1),!(a.signal instanceof AbortSignal)))throw TypeError(`Request siganl must be of type AbortSignal.`);if(a.headers&&!(a.headers instanceof Array))throw TypeError(`Request headers must be serialized as an array of pairs.`);let o=new Request(e,a);if(a.body instanceof ReadableStream&&o.body===void 0){let e=zn(o,a.body);return this.promises.push({promise:e,parent:n,property:r}),e}return o}case`response`:{if(t.length!==3)break;let e=this.evaluateImpl(t[1],n,r,i+1);if(!(e===null||typeof e==`string`||e instanceof Uint8Array||e instanceof ReadableStream))throw TypeError(`Response body must be of type ReadableStream.`);let a=t[2];if(typeof a!=`object`||!a)break;if(a.webSocket)throw TypeError(`Can't deserialize a Response containing a webSocket.`);if(a.headers&&!(a.headers instanceof Array))throw TypeError(`Request headers must be serialized as an array of pairs.`);return new Response(e,a)}case`blob`:{if(t.length!==3||typeof t[1]!=`string`)break;let e=t[1],a=this.evaluateImpl(t[2],n,r,i+1);if(!(a instanceof ReadableStream))throw TypeError(`Blob content must be serialized as a ReadableStream.`);let o=Bn(a,e);return this.promises.push({promise:o,parent:n,property:r}),o}case`import`:case`pipeline`:{if(t.length<2||t.length>4||typeof t[1]!=`number`)break;let a=this.importer.getExport(t[1]);if(!a)throw Error(`no such entry on exports table: ${t[1]}`);let o=t[0]==`pipeline`,s=e=>{if(o){let t=new U(e,[]);return this.promises.push({promise:t,parent:n,property:r}),t}return this.hooks.push(e),new U(e,[])};if(t.length==2)return s(o?a.get([]):a.dup());let c=t[2];if(!(c instanceof Array)||!c.every(e=>typeof e==`string`||typeof e==`number`))break;if(t.length==3)return s(a.get(c));let l=t[3];if(!(l instanceof Array))break;return l=new e(this.importer).evaluateWithDepth([l],i),s(a.call(c,l))}case`remap`:{if(t.length!==5||typeof t[1]!=`number`||!(t[2]instanceof Array)||!(t[3]instanceof Array)||!(t[4]instanceof Array))break;let e=this.importer.getExport(t[1]);if(!e)throw Error(`no such entry on exports table: ${t[1]}`);let i=t[2];if(!i.every(e=>typeof e==`string`||typeof e==`number`))break;let a=t[3].map(e=>{if(!(e instanceof Array)||e.length!==2||e[0]!==`import`&&e[0]!==`export`||typeof e[1]!=`number`)throw TypeError(`unknown map capture: ${JSON.stringify(e)}`);if(e[0]===`export`)return this.importer.importStub(e[1]);{let t=this.importer.getExport(e[1]);if(!t)throw Error(`no such entry on exports table: ${e[1]}`);return t.dup()}}),o=t[4],s=new U(e.map(i,a,o),[]);return this.promises.push({promise:s,parent:n,property:r}),s}case`export`:case`promise`:if(typeof t[1]==`number`){if(t[0]==`promise`){let e=new U(this.importer.importPromise(t[1]),[]);return this.promises.push({parent:n,property:r,promise:e}),e}{let e=this.importer.importStub(t[1]);return this.hooks.push(e),new H(e)}}break;case`writable`:if(typeof t[1]==`number`){let e=this.importer.importStub(t[1]),n=R.createWritableStreamFromHook(e);return this.hooks.push(e),n}break;case`readable`:if(typeof t[1]==`number`){let e=this.importer.getPipeReadable(t[1]),n=R.createReadableStreamHook(e);return this.hooks.push(n),e}}throw TypeError(`unknown special value: ${JSON.stringify(t)}`)}if(t instanceof Object){let e=t;for(let t in e)t in Object.prototype||t===`toJSON`?(this.evaluateImpl(e[t],e,t,i+1),delete e[t]):e[t]=this.evaluateImpl(e[t],e,t,i+1);return e}return t}},Hn=16,Un=8,Wn=16,Gn=64;function Kn(e){return 2+e.length*3}function qn(e,t,n=0){if(n>=Gn)return Un;switch(typeof e){case`string`:return Kn(e);case`number`:return 16;case`bigint`:return 16;case`boolean`:return 8;case`undefined`:return 16;case`object`:{if(e===null)return 8;if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return Wn+e.byteLength;if(typeof Blob<`u`&&e instanceof Blob)return Wn+e.size;if(e instanceof Date)return 16;if(t??=new WeakSet,t.has(e))return Un;if(t.add(e),e instanceof Array){let r=Hn;for(let i of e)r+=Un+qn(i,t,n+1);return r}if(e instanceof Error){let r=Hn+Kn(e.name)+Kn(e.message)+Kn(e.stack??``);for(let i of Object.keys(e))r+=Un+Kn(i)+qn(e[i],t,n+1);return r}let r=Hn;for(let i of Object.keys(e))r+=Un+Kn(i)+qn(e[i],t,n+1);return r}default:return 16}}var Jn=class{session;importId;constructor(e,t,n){this.session=e,this.importId=t,n&&(this.activePull=Promise.withResolvers())}localRefcount=0;remoteRefcount=1;activePull;resolution;onBrokenRegistrations;resolve(e){if(this.localRefcount==0){e.dispose();return}if(this.resolution=e,this.sendRelease(),this.onBrokenRegistrations){for(let t of this.onBrokenRegistrations){let n=this.session.onBrokenCallbacks[t],r=this.session.onBrokenCallbacks.length;e.onBroken(n),this.session.onBrokenCallbacks[r]===n?delete this.session.onBrokenCallbacks[r]:delete this.session.onBrokenCallbacks[t]}this.onBrokenRegistrations=void 0}this.activePull&&=(this.activePull.resolve(),void 0)}async awaitResolution(){return this.activePull||=(this.session.sendPull(this.importId),Promise.withResolvers()),await this.activePull.promise,this.resolution.pull()}dispose(){this.resolution?this.resolution.dispose():(this.abort(Error(`RPC was canceled because the RpcPromise was disposed.`)),this.sendRelease())}abort(e){if(!this.resolution){if(this.resolution=new B(e),this.activePull&&=(this.activePull.reject(e),void 0),this.onBrokenRegistrations)for(let e of this.onBrokenRegistrations)delete this.session.onBrokenCallbacks[e];this.onBrokenRegistrations=void 0}}onBroken(e){if(this.resolution)this.resolution.onBroken(e);else{let t=this.session.onBrokenCallbacks.length;this.session.onBrokenCallbacks.push(e),this.onBrokenRegistrations||=[],this.onBrokenRegistrations.push(t)}}sendRelease(){this.remoteRefcount>0&&(this.session.sendRelease(this.importId,this.remoteRefcount),this.remoteRefcount=0)}},Yn=class e extends z{isPromise;entry;constructor(e,t){super(),this.isPromise=e,++t.localRefcount,this.entry=t}collectPath(e){return this}getEntry(){if(this.entry)return this.entry;throw Error(`This RpcImportHook was already disposed.`)}getEntryTakingOwnership(e){try{return this.getEntry()}catch(t){throw e(),t}}call(e,t){let n=this.getEntryTakingOwnership(()=>t.dispose());return n.resolution?n.resolution.call(e,t):n.session.sendCall(n.importId,e,t)}stream(e,t){let n=this.getEntryTakingOwnership(()=>t.dispose());return n.resolution?n.resolution.stream(e,t):n.session.sendStream(n.importId,e,t)}map(e,t,n){let r=this.getEntryTakingOwnership(()=>{for(let e of t)e.dispose()});return r.resolution?r.resolution.map(e,t,n):r.session.sendMap(r.importId,e,t,n)}get(e){let t=this.getEntry();return t.resolution?t.resolution.get(e):t.session.sendCall(t.importId,e)}dup(){return new e(!1,this.getEntry())}pull(){let e=this.getEntry();if(!this.isPromise)throw Error(`Can't pull this hook because it's not a promise hook.`);return e.resolution?e.resolution.pull():e.awaitResolution()}ignoreUnhandledRejections(){}dispose(){let e=this.entry;this.entry=void 0,e&&--e.localRefcount===0&&e.dispose()}onBroken(e){this.entry&&this.entry.onBroken(e)}},Xn=class extends Yn{session;constructor(e){super(!1,e),this.session=e.session}dispose(){if(this.session){let e=this.session;this.session=void 0,e.shutdown()}}},Zn=class{transport;options;exports=[];reverseExports=new Map;imports=[];abortReason;cancelReadLoop;nextExportId=-1;onBatchDone;pullCount=0;onBrokenCallbacks=[];encodingLevel;limits;constructor(e,t,n){this.transport=e,this.options=n;let r=`string`;if(`encodingLevel`in e){let t=e.encodingLevel;if(t!==void 0){if(t!==`string`&&t!==`jsonCompatible`&&t!==`jsonCompatibleWithBytes`&&t!==`structuredClonable`)throw TypeError(`Unknown transport encodingLevel: ${String(t)}`);r=t}}this.encodingLevel=r,this.limits={...On,...n.limits},this.exports.push({hook:t,refcount:1}),this.imports.push(new Jn(this,0,!1)),this.readLoop().catch(e=>this.abort(e))}getMainImport(){return new Xn(this.imports[0])}shutdown(){this.abort(Error(`RPC session was shut down by disposing the main stub`),!1)}exportStub(e){if(this.abortReason)throw this.abortReason;let t=this.reverseExports.get(e);if(t!==void 0)return++this.exports[t].refcount,t;{let t=this.nextExportId--;return this.exports[t]={hook:e,refcount:1},this.reverseExports.set(e,t),this.watchExport(t,e),t}}exportPromise(e){if(this.abortReason)throw this.abortReason;let t=this.nextExportId--;return this.exports[t]={hook:e,refcount:1},this.reverseExports.set(e,t),this.ensureResolvingExport(t),t}unexport(e){for(let t of e)this.releaseExport(t,1)}watchExport(e,t){t.onBroken(n=>{queueMicrotask(()=>{if(this.abortReason===void 0&&this.exports[e]?.hook===t)try{this.send([`reject`,e,K.devaluate(n,void 0,this,void 0,this.encodingLevel)])}catch(e){this.abort(e)}})})}releaseExport(e,t){let n=this.exports[e];if(!n)throw Error(`no such export ID: ${e}`);if(n.refcount<t)throw Error(`refcount would go negative: ${n.refcount} < ${t}`);n.refcount-=t,n.refcount===0&&(delete this.exports[e],this.reverseExports.delete(n.hook),n.hook.dispose())}onSendError(e){if(this.options.onSendError)return this.options.onSendError(e)}ensureResolvingExport(e){let t=this.exports[e];if(!t)throw Error(`no such export ID: ${e}`);if(!t.pull){let n=async()=>{let e=t.hook;for(;;){let t=await e.pull();if(t.value instanceof H){let{hook:n,pathIfPromise:r}=xn(t.value);if(r&&r.length==0&&this.getImport(e)===void 0){e=n;continue}}return t}},r=t.autoRelease;++this.pullCount,t.pull=n().then(t=>{let n=K.devaluate(t.value,void 0,this,t,this.encodingLevel);this.send([`resolve`,e,n]),r&&this.releaseExport(e,1)},t=>{this.send([`reject`,e,K.devaluate(t,void 0,this,void 0,this.encodingLevel)]),r&&this.releaseExport(e,1)}).catch(t=>{try{this.send([`reject`,e,K.devaluate(t,void 0,this,void 0,this.encodingLevel)]),r&&this.releaseExport(e,1)}catch(e){this.abort(e)}}).finally(()=>{--this.pullCount===0&&this.onBatchDone&&this.onBatchDone.resolve()})}}getImport(e){if(e instanceof Yn&&e.entry&&e.entry.session===this)return e.entry.importId}importStub(e){if(this.abortReason)throw this.abortReason;let t=this.imports[e];return t||(t=new Jn(this,e,!1),this.imports[e]=t),new Yn(!1,t)}importPromise(e){if(this.abortReason)throw this.abortReason;if(this.imports[e])return new B(Error(`Bug in RPC system: The peer sent a promise reusing an existing export ID.`));let t=new Jn(this,e,!0);return this.imports[e]=t,new Yn(!0,t)}getExport(e){return this.exports[e]?.hook}getPipeReadable(e){let t=this.exports[e];if(!t||!t.pipeReadable)throw Error(`Export ${e} is not a pipe or its readable end was already consumed.`);let n=t.pipeReadable;return t.pipeReadable=void 0,n}getLimits(){return this.limits}createPipe(e,t){if(this.abortReason)throw this.abortReason;this.send([`pipe`]);let n=this.imports.length,r=new Jn(this,n,!1);this.imports.push(r);let i=new Yn(!1,r),a=R.createWritableStreamFromHook(i);return e.pipeTo(a).catch(()=>{}).finally(()=>t.dispose()),n}send(e){if(this.abortReason!==void 0)return 0;if(this.encodingLevel===`string`){let t;try{t=JSON.stringify(e)}catch(e){try{this.abort(e)}catch{}throw e}try{let e=this.transport.send(t);e!==void 0&&typeof e.catch==`function`&&e.catch(e=>this.abort(e,!1))}catch(e){queueMicrotask(()=>this.abort(e,!1))}return t.length}try{let t=this.transport.send(e);if(typeof t==`number`)return t;let n=t;n&&typeof n.then==`function`&&Promise.resolve(n).catch(e=>this.abort(e,!1));return}catch(e){queueMicrotask(()=>this.abort(e,!1));return}}sendCall(e,t,n){if(this.abortReason)throw n?.dispose(),this.abortReason;let r=[`pipeline`,e,t];if(n){let e;try{e=K.devaluate(n.value,void 0,this,n,this.encodingLevel)}catch(e){throw n.dispose(),e}r.push(e[0])}this.send([`push`,r]);let i=new Jn(this,this.imports.length,!1);return this.imports.push(i),new Yn(!0,i)}sendStream(e,t,n){if(this.abortReason)throw n.dispose(),this.abortReason;let r=[`pipeline`,e,t],i;try{i=K.devaluate(n.value,void 0,this,n,this.encodingLevel)}catch(e){throw n.dispose(),e}r.push(i[0]);let a=[`stream`,r],o=this.send(a);o===void 0&&(o=qn(a));let s=this.imports.length,c=new Jn(this,s,!0);return c.remoteRefcount=0,c.localRefcount=1,this.imports.push(c),{promise:c.awaitResolution().then(e=>{e.dispose(),delete this.imports[s]},e=>{throw delete this.imports[s],e}),size:o}}sendMap(e,t,n,r){if(this.abortReason){for(let e of n)e.dispose();throw this.abortReason}let i=[`remap`,e,t,n.map(e=>{let t=this.getImport(e);return t===void 0?[`export`,this.exportStub(e)]:[`import`,t]}),r];this.send([`push`,i]);let a=new Jn(this,this.imports.length,!1);return this.imports.push(a),new Yn(!0,a)}sendPull(e){if(this.abortReason)throw this.abortReason;this.send([`pull`,e])}sendRelease(e,t){this.abortReason||(this.send([`release`,e,t]),delete this.imports[e])}abort(e,t=!0){if(this.abortReason===void 0){if(this.cancelReadLoop?.(e),this.cancelReadLoop=void 0,t)try{let t=[`abort`,K.devaluate(e,void 0,this,void 0,this.encodingLevel)];if(this.encodingLevel===`string`){let e=this.transport.send(JSON.stringify(t));e!==void 0&&typeof e.catch==`function`&&e.catch(e=>{})}else{let e=this.transport.send(t);e&&typeof e.then==`function`&&Promise.resolve(e).catch(e=>{})}}catch{}if(e===void 0&&(e=`undefined`),this.abortReason=e,this.onBatchDone&&this.onBatchDone.reject(e),this.transport.abort)try{this.transport.abort(e)}catch(e){Promise.resolve(e)}for(let t of Object.values(this.onBrokenCallbacks))try{t(e)}catch(e){Promise.resolve(e)}for(let t in this.imports)this.imports[t].abort(e);for(let e in this.exports)this.exports[e].hook.dispose()}}async readLoop(){for(;!this.abortReason;){let e=Promise.withResolvers();this.cancelReadLoop=e.reject;let t;try{t=await Promise.race([this.transport.receive(),e.promise])}finally{this.cancelReadLoop===e.reject&&(this.cancelReadLoop=void 0)}if(this.encodingLevel===`string`&&t.length>this.limits.maxMessageSize)throw TypeError(`Incoming message exceeds maximum size of ${this.limits.maxMessageSize} UTF-16 code units.`);if(this.abortReason)break;let n=this.encodingLevel===`string`?JSON.parse(t):t;if(n instanceof Array)switch(n[0]){case`push`:if(n.length>1){let e=new G(new Vn(this,this.encodingLevel).evaluate(n[1]));e.ignoreUnhandledRejections(),this.exports.push({hook:e,refcount:1});continue}break;case`stream`:if(n.length>1){let e=new G(new Vn(this,this.encodingLevel).evaluate(n[1]));e.ignoreUnhandledRejections();let t=this.exports.length;this.exports.push({hook:e,refcount:1,autoRelease:!0}),this.ensureResolvingExport(t);continue}break;case`pipe`:{let{readable:e,writable:t}=new TransformStream,n=R.createWritableStreamHook(t),r=this.exports.length;this.exports.push({hook:n,refcount:1,pipeReadable:e}),this.watchExport(r,n);continue}case`pull`:{let e=n[1];if(typeof e==`number`){this.ensureResolvingExport(e);continue}break}case`resolve`:case`reject`:{let e=n[1];if(typeof e==`number`&&n.length>2){let t=this.imports[e];if(t){if(n[0]==`resolve`)t.resolve(new G(new Vn(this,this.encodingLevel).evaluate(n[2])));else{let e=new Vn(this,this.encodingLevel).evaluate(n[2]);e.dispose(),t.resolve(new B(e.value))}}else n[0]==`resolve`&&new Vn(this,this.encodingLevel).evaluate(n[2]).dispose();continue}break}case`release`:{let e=n[1],t=n[2];if(typeof e==`number`&&typeof t==`number`){this.releaseExport(e,t);continue}break}case`abort`:{let e=new Vn(this,this.encodingLevel).evaluate(n[1]);e.dispose(),this.abort(e.value,!1);break}}throw Error(`bad RPC message: ${JSON.stringify(n)}`)}}async drain(){if(this.abortReason)throw this.abortReason;if(this.pullCount>0){let{promise:e,resolve:t,reject:n}=Promise.withResolvers();this.onBatchDone={resolve:t,reject:n},await e}}getStats(){let e={imports:0,exports:0};for(let t in this.imports)++e.imports;for(let t in this.exports)++e.exports;return e}},Qn=class{#e;#t;constructor(e,t,n={}){let r;r=t?new G(W.fromAppReturn(t)):new B(Error(`This connection has no main object.`)),this.#e=new Zn(e,r,n),this.#t=new H(this.#e.getMainImport())}getRemoteMain(){return this.#t}getStats(){return this.#e.getStats()}drain(){return this.#e.drain()}};function $n(e,t,n){return new Qn(new er(e),t,n).getRemoteMain()}var er=class{encodingLevel=`structuredClonable`;constructor(e){this.#e=e,e.start(),e.addEventListener(`message`,e=>{this.#i||(e.data===null?this.#a(Error(`Peer closed MessagePort connection.`)):this.#t?(this.#t(e.data),this.#t=void 0,this.#n=void 0):this.#r.push(e.data))}),e.addEventListener(`messageerror`,e=>{this.#a(Error(`MessagePort message error.`))})}#e;#t;#n;#r=[];#i;send(e){if(this.#i)throw this.#i;this.#e.postMessage(e)}async receive(){if(this.#r.length>0)return this.#r.shift();if(this.#i)throw this.#i;return new Promise((e,t)=>{this.#t=e,this.#n=t})}abort(e){try{this.#e.postMessage(null)}catch{}this.#e.close(),this.#i||=e}#a(e){this.#i||(this.#i=e,this.#n&&=(this.#n(e),this.#t=void 0,void 0))}},tr,nr=class{context;captureMap=new Map;instructions=[];constructor(e,t){this.context=tr?{parent:tr,captures:[],subject:tr.capture(e),path:t}:{parent:void 0,captures:[],subject:e,path:t},tr=this}unregister(){tr=this.context.parent}makeInput(){return new ir(this,0)}makeOutput(e){let t;try{t=K.devaluate(e.value,void 0,this,e)}finally{e.dispose()}return this.instructions.push(t),this.context.parent?(this.context.parent.instructions.push([`remap`,this.context.subject,this.context.path,this.context.captures.map(e=>[`import`,e]),this.instructions]),new ir(this.context.parent,this.context.parent.instructions.length)):this.context.subject.map(this.context.path,this.context.captures,this.instructions)}pushCall(e,t,n){let r=K.devaluate(n.value,void 0,this,n);r=r[0];let i=this.capture(e.dup());return this.instructions.push([`pipeline`,i,t,r]),new ir(this,this.instructions.length)}pushGet(e,t){let n=this.capture(e.dup());return this.instructions.push([`pipeline`,n,t]),new ir(this,this.instructions.length)}capture(e){if(e instanceof ir&&e.mapper===this)return e.idx;let t=this.captureMap.get(e);if(t===void 0){if(this.context.parent){let t=this.context.parent.capture(e);this.context.captures.push(t)}else this.context.captures.push(e);t=-this.context.captures.length,this.captureMap.set(e,t)}return t}exportStub(e){throw Error(`Can't construct an RpcTarget or RPC callback inside a mapper function. Try creating a new RpcStub outside the callback first, then using it inside the callback.`)}exportPromise(e){return this.exportStub(e)}getImport(e){return this.capture(e)}unexport(e){}createPipe(e){throw Error(`Cannot send ReadableStream inside a mapper function.`)}onSendError(e){}};dn.sendMap=(e,t,n)=>{let r=new nr(e,t),i;try{i=W.fromAppReturn(hn(r.pushCall.bind(r),()=>n(new U(r.makeInput(),[]))))}finally{r.unregister()}if(i instanceof Promise)throw i.catch(e=>{}),Error(`RPC map() callbacks cannot be async.`);return new U(r.makeOutput(i),[])};function rr(){throw Error(`Attempted to use an abstract placeholder from a mapper function. Please make sure your map function has no side effects.`)}var ir=class extends z{mapper;idx;constructor(e,t){super(),this.mapper=e,this.idx=t}dup(){return this}dispose(){}get(e){if(e.length==0)return this;if(tr)return tr.pushGet(this,e);rr()}call(e,t){t.dispose(),rr()}map(e,t,n){for(let e of t)e.dispose();rr()}pull(){rr()}ignoreUnhandledRejections(){}onBroken(e){rr()}},ar=class{captures;variables;constructor(e,t){this.captures=e,this.variables=[t]}dispose(){for(let e of this.variables)e.dispose()}apply(e){try{if(e.length<1)throw Error(`Invalid empty mapper function.`);for(let t of e.slice(0,-1)){let e=new Vn(this).evaluateCopy(t);if(e.value instanceof H){let t=yn(e.value);if(t){this.variables.push(t);continue}}this.variables.push(new G(e))}return new Vn(this).evaluateCopy(e[e.length-1])}finally{for(let e of this.variables)e.dispose()}}importStub(e){throw Error(`A mapper function cannot refer to exports.`)}importPromise(e){return this.importStub(e)}getExport(e){return e<0?this.captures[-e-1]:this.variables[e]}getPipeReadable(e){throw Error(`A mapper function cannot use pipe readables.`)}getLimits(){return On}};function or(e,t,n,r,i){let a=new ar(r,new G(W.deepCopyFrom(e,t,n)));try{return a.apply(i)}finally{a.dispose()}}dn.applyMap=(e,t,n,r,i)=>{try{let a;if(e instanceof U)throw Error(`applyMap() can't be called on RpcPromise`);if(e instanceof Array){let t=[];try{for(let a of e)t.push(or(a,e,n,r,i))}catch(e){for(let e of t)e.dispose();throw e}a=W.fromArray(t)}else a=e==null?W.fromAppReturn(e):or(e,t,n,r,i);return new G(a)}finally{for(let e of r)e.dispose()}};var sr=class e extends z{state;static create(t){let n=t.getWriter();return new e({refcount:1,writer:n,closed:!1})}constructor(e,t){super(),this.state=e,t&&++e.refcount}getState(){if(this.state)return this.state;throw Error(`Attempted to use a WritableStreamStubHook after it was disposed.`)}call(e,t){try{let n=this.getState();if(e.length!==1||typeof e[0]!=`string`)throw Error(`WritableStream stub only supports direct method calls`);let r=e[0];if(r!==`write`&&r!==`close`&&r!==`abort`)throw Error(`Unknown WritableStream method: ${r}`);return(r===`close`||r===`abort`)&&(n.closed=!0),new Dn((r===`write`?t.deliverStreamWrite(n.writer):t.deliverCall(n.writer[r],n.writer)).then(e=>new G(e)))}catch(e){return t.dispose(),new B(e)}}map(e,t,n){for(let e of t)e.dispose();return new B(Error(`Cannot use map() on a WritableStream`))}get(e){return new B(Error(`Cannot access properties on a WritableStream stub`))}dup(){let t=this.getState();return new e(t,this)}pull(){return Promise.reject(Error(`Cannot pull a WritableStream stub`))}ignoreUnhandledRejections(){}dispose(){let e=this.state;this.state=void 0,e&&--e.refcount===0&&(e.closed||e.writer.abort(Error(`WritableStream RPC stub was disposed without calling close()`)).catch(()=>{}),e.writer.releaseLock())}onBroken(e){this.getState().writer.closed.then(void 0,e)}},cr=262144,lr=1073741824,ur=65536,dr=2,fr=1.25,pr=.9,mr=3,hr=class{now;window=cr;bytesInFlight=0;inStartupPhase=!0;delivered=0;deliveredTime=0;firstAckTime=0;firstAckDelivered=0;minRtt=1/0;roundsWithoutIncrease=0;lastRoundWindow=0;roundStartTime=0;constructor(e){this.now=e}onSend(e){this.bytesInFlight+=e;let t={sentTime:this.now(),size:e,deliveredAtSend:this.delivered,deliveredTimeAtSend:this.deliveredTime,windowAtSend:this.window,windowFullAtSend:this.bytesInFlight>=this.window};return{token:t,shouldBlock:t.windowFullAtSend}}onError(e){this.bytesInFlight-=e.size}onAck(e){let t=this.now();this.delivered+=e.size,this.deliveredTime=t,this.bytesInFlight-=e.size;let n=t-e.sentTime;if(this.minRtt=Math.min(this.minRtt,n),this.firstAckTime===0)this.firstAckTime=t,this.firstAckDelivered=this.delivered;else{let n,r;e.deliveredTimeAtSend===0?(n=this.firstAckTime,r=this.firstAckDelivered):(n=e.deliveredTimeAtSend,r=e.deliveredAtSend);let i=t-n,a=(this.delivered-r)/i,o=this.inStartupPhase?dr:fr,s=a*this.minRtt*o;s=Math.min(s,e.windowAtSend*o),s=e.windowFullAtSend?Math.max(s,e.windowAtSend*pr):Math.max(s,this.window),this.window=Math.max(Math.min(s,lr),ur),this.inStartupPhase&&e.sentTime>=this.roundStartTime&&(this.window>this.lastRoundWindow*fr?this.roundsWithoutIncrease=0:++this.roundsWithoutIncrease>=mr&&(this.inStartupPhase=!1),this.roundStartTime=t,this.lastRoundWindow=this.window)}return this.bytesInFlight<this.window}};function gr(e){let t,n=!1,r=new hr(()=>performance.now()),i,a,o=()=>{n||(n=!0,e.dispose())};return new WritableStream({start(n){e.onBroken(e=>{t===void 0&&(t=e,n.error(e),o()),a&&=(a(e),i=void 0,void 0)})},write(n,s){if(t!==void 0)throw t;let c=W.fromAppParams([n]),{promise:l,size:u}=e.stream([`write`],c);if(u===void 0)return l.catch(e=>{throw t===void 0&&(t=e),e});{let{token:e,shouldBlock:n}=r.onSend(u);if(l.then(()=>{r.onAck(e)&&i&&(i(),i=void 0,a=void 0)},n=>{r.onError(e),t===void 0&&(t=n,s.error(n),o()),a&&=(a(n),i=void 0,void 0)}),n)return new Promise((e,t)=>{i=e,a=t})}},async close(){if(t!==void 0)throw o(),t;let{promise:n}=e.stream([`close`],W.fromAppParams([]));try{await n}catch(e){throw t??e}finally{o()}},abort(n){if(t!==void 0)return;t=n??Error(`WritableStream was aborted`),a&&=(a(t),i=void 0,void 0);let{promise:r}=e.stream([`abort`],W.fromAppParams([n]));r.then(()=>o(),()=>o())}})}var _r=class e extends z{state;static create(t){return new e({refcount:1,stream:t,canceled:!1})}constructor(e,t){super(),this.state=e,t&&++e.refcount}call(e,t){return t.dispose(),new B(Error(`Cannot call methods on a ReadableStream stub`))}map(e,t,n){for(let e of t)e.dispose();return new B(Error(`Cannot use map() on a ReadableStream`))}get(e){return new B(Error(`Cannot access properties on a ReadableStream stub`))}dup(){let t=this.state;if(!t)throw Error(`Attempted to dup a ReadableStreamStubHook after it was disposed.`);return new e(t,this)}pull(){return Promise.reject(Error(`Cannot pull a ReadableStream stub`))}ignoreUnhandledRejections(){}dispose(){let e=this.state;this.state=void 0,e&&--e.refcount===0&&(e.canceled||(e.canceled=!0,e.stream.locked||e.stream.cancel(Error(`ReadableStream RPC stub was disposed without being consumed`)).catch(()=>{})))}onBroken(e){}};R.createWritableStreamHook=sr.create,R.createWritableStreamFromHook=gr,R.createReadableStreamHook=_r.create;var vr=H,yr=on,br=$n;function xr(e){return e<32||e>=127&&e<=159||e===1564||e>=8203&&e<=8207||e===8232||e===8233||e>=8234&&e<=8238||e>=8294&&e<=8297||e===65279}function Sr(e,t=80){let n=``;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);n+=xr(r)?` `:e.charAt(t)}return n=n.replace(/\s+/gu,` `).trim(),n.length<=t?n:`${n.slice(0,Math.max(0,t-1)).trimEnd()}…`}function Cr(e,t){let n=e.find(e=>e.id===t.itemId);if(n===void 0||n.kind===`text`)return!1;if(n.kind===`menu`){let e=n.options.find(e=>e.id===t.optionId);return e!==void 0&&e.disabled!==!0}return t.optionId===void 0?n.kind!==`button`||n.disabled!==!0:!1}Object.freeze({publish:()=>Promise.resolve(),onBack:()=>()=>void 0,onForward:()=>()=>void 0,onActivate:()=>()=>void 0});function wr(e,t){if(t.kind===`action`){let n=[...e.primary??[],...e.menu??[]].find(e=>e.id===t.actionId);return n!==void 0&&n.disabled!==!0}let n=e.crumbs?.find(e=>e.id===t.crumbId);return n===void 0?!1:t.siblingId===void 0||n.siblings?.some(e=>e.id===t.siblingId)===!0}var Tr=[2,3],Er=`fungi.app.ready.v3`,Dr=`fungi.app.ready`,Or=`fungi.app.connect`,q=e=>o.pipe(_(pe(1)),_(w(e))),kr=e=>x(q(e)),Ar=f.pipe(_(xe()),_(O(Number.isSafeInteger,{message:`Expected a safe integer`}))),jr=Ar.pipe(_(we(0))),Mr=Ar.pipe(_(me(0))),Nr=u({appId:q(160),releaseId:q(160),surfaceId:q(160)}),Pr=u({editing:h,surface:g([q(160),_e])}),Fr=g([u({kind:p(`compose`),requestId:q(160),text:q(2e3)}),u({kind:p(`navigate`),requestId:q(160),params:k(u({key:q(64),value:q(4096)})).pipe(_(w(16)))})]),J=E(T([`granted`,`missing`])),Ir=u({"agent.list":J,"agent.manage":J,"agent.read":J,"agent.send":J,"computer.list":J,"computer.readFile":J,"computer.writeFile":J,"computer.execute":J,"git.repository":J,"workflow.publish":J,"workflow.arm":J,"workflow.run":J,"app.events.emit":J,"llm.generation":J,"media.generation":J,"media.share":J}),Lr=T([`ready`,`missing`,`unknown`]),Rr=u({models:Lr,media:Lr,git:Lr,terminal:T([`ready`,`exec-only`,`missing`,`unknown`]),terminalReason:x(o)}),zr=T([`model`,`media`,`git`,`computer`]),Br=T([`opened`,`unavailable`]),Vr=u({computerId:g([q(256),_e]),computerName:x(ne(o)),teamHasComputers:x(ne(h)),computerAccessGranted:x(h),setup:x(Rr),permissions:x(Ir),focus:Pr,openRequest:g([_e,Fr]),visibility:T([`visible`,`hidden`])}),Hr=T([`connecting`,`connected`,`suspended`,`disconnected`,`disposing`,`disposed`]),Ur=u({altKey:h,ctrlKey:h,id:q(160),key:q(64),metaKey:h,shiftKey:h}),Wr=u({action:x(c),availability:x(c),category:q(160),description:kr(512),id:q(160),projections:x(c),title:q(160)}),Gr=u({arguments:x(c),commandId:q(321),origin:T([`agent`,`browser`,`keyboard`,`menu`,`palette`,`programmatic`,`slash`,`terminal`]),requestId:q(160)}),Kr=g([u({result:x(c),status:p(`handled`)}),u({error:c,status:p(`failed`)})]),qr=e=>q(e).pipe(_(O(e=>{for(let t=0;t<e.length;t+=1)if(xr(e.charCodeAt(t)))return!1;return!0},{message:`Expected one line of plain text`}))),Jr={id:q(64),text:qr(80),end:E(h),priority:E(p(`low`))},Yr=E(f.pipe(_(xe()),_(ae({minimum:0,maximum:9999})))),Xr=k(g([u({...Jr,kind:p(`text`),tone:E(T([`neutral`,`success`,`warning`,`error`]))}),u({...Jr,kind:p(`button`),icon:E(T([`folder`,`ports`,`processes`,`access`])),count:Yr,tone:E(T([`neutral`,`success`,`warning`,`error`])),busy:E(h),title:E(qr(1024)),disabled:E(h),opens:E(p(`dialog`)),expanded:E(h)}),u({...Jr,kind:p(`toggle`),pressed:h}),u({...Jr,kind:p(`menu`),count:Yr,title:E(qr(1024)),options:k(u({id:q(64),text:qr(80),checked:E(h),disabled:E(h)})).pipe(_(w(16)),_(O(e=>new Set(e.map(e=>e.id)).size===e.length,{message:`Expected unique status option ids`})))})])).pipe(_(w(6)),_(O(e=>new Set(e.map(e=>e.id)).size===e.length,{message:`Expected unique status item ids`}))),Zr=u({computerId:q(256),path:q(1024)}),Qr=q(80).pipe(_(O(e=>e.trim()===e,{message:`Expected a trimmed title`}))),$r=q(64),ei=q(80),ti=e=>new Set(e.map(e=>e.id)).size===e.length,ni=u({id:$r,label:ei,siblings:x(k(u({id:$r,label:ei})).pipe(_(w(16)),_(O(ti,{message:`Expected unique crumb sibling ids`}))))}),ri=u({id:$r,label:ei,icon:x(p(`play`)),variant:x(T([`primary`,`outline`,`ghost`])),tone:x(p(`destructive`)),disabled:x(h)}),ii=e=>k(ri).pipe(_(w(e)),_(O(ti,{message:`Expected unique header command ids`}))),ai=u({id:$r,label:ei,presentation:x(p(`bead`)),tone:x(T([`neutral`,`info`,`warning`,`success`,`error`]))}),oi={status:x(k(ai).pipe(_(w(4)),_(O(ti,{message:`Expected unique header status ids`})))),crumbs:x(k(ni).pipe(_(w(8)),_(O(ti,{message:`Expected unique crumb ids`})))),primary:x(ii(3)),menu:x(ii(12))},si=u({contractVersion:p(2),canGoBack:h,canGoForward:h,title:x(Qr),...oi}),ci=u({canGoBack:h,canGoForward:h,title:x(o),...oi}),li=g([u({kind:p(`crumb`),crumbId:$r,siblingId:x($r)}),u({kind:p(`action`),actionId:$r})]),ui=ne(u({agentId:q(256),sessionId:q(256)})),di=e=>x(k(T(e)).pipe(_(w(e.length)))),fi=u({agents:x(k(T([`agent.list`,`agent.manage`,`agent.read`,`agent.send`])).pipe(_(w(4)))),computers:x(k(T([`computer.list`,`computer.readFile`,`computer.writeFile`,`computer.execute`])).pipe(_(w(4)))),git:di([`git.repository`]),workflows:di([`workflow.publish`,`workflow.arm`,`workflow.run`]),events:di([`app.events.emit`]),generation:di([`llm.generation`,`media.generation`,`media.share`])}),pi=T([`granted`,`declined`,`customize`]),mi=u({message:q(512),tone:x(T([`info`,`success`,`warning`,`error`]))}),hi=T(it);u({code:hi.pick([`DELIVERY_PENDING`])});var gi=u({code:hi,message:q(512),retryable:h,need:E(rt)}),_i=g([u({protocolVersion:p(3),type:p(Er)}),u({protocolVersion:p(2),type:p(Dr)})]),vi=u({epoch:q(160),protocolVersion:T(Tr),type:p(Or)}),yi=u({epoch:q(160),protocolVersion:T(Tr)}),bi={[Symbol.dispose]:x(c)},xi=g([u({...bi,ok:p(!0),value:c}),u({...bi,error:gi,ok:p(!1)})]);function Y(e,t,n=`PROTOCOL`){return Ce(Se(e,{onExcessProperty:`error`}),ie({onFailure:e=>{throw new L(`The peer sent malformed protocol data`,{cause:e,code:n,retryable:!1})},onSuccess:t}))}function X(e){return Object.freeze(e)}function Si(e,t){let n=e.arguments===void 0?void 0:N(e.arguments),r={origin:e.origin,signal:t};return n!==void 0&&Object.assign(r,{arguments:n}),X(r)}var Ci=Y(Wr,e=>{let t={category:e.category,id:e.id,title:e.title};return e.action!==void 0&&Object.assign(t,{action:e.action}),e.availability!==void 0&&Object.assign(t,{availability:e.availability}),e.description!==void 0&&Object.assign(t,{description:e.description}),e.projections!==void 0&&Object.assign(t,{projections:e.projections}),X(pa(()=>Ue(t)))},`INVALID_ARGUMENT`),wi=Y(q(321),e=>e),Ti=Y(Gr,e=>{let t=e.arguments===void 0?void 0:N(e.arguments),n={commandId:e.commandId,origin:e.origin,requestId:e.requestId};return t!==void 0&&Object.assign(n,{arguments:t}),X(n)}),Ei=Y(g([De,c]),e=>e===void 0?void 0:N(e)),Di=Y(vi,e=>X(e));Y(yi,e=>X(e));var Oi=Y(Vr,e=>{let t={computerId:e.computerId,focus:X({...e.focus}),openRequest:e.openRequest===null?null:X({...e.openRequest}),visibility:e.visibility};return e.teamHasComputers!==void 0&&(t.teamHasComputers=e.teamHasComputers),e.computerName!==void 0&&(t.computerName=e.computerName),e.computerAccessGranted!==void 0&&(t.computerAccessGranted=e.computerAccessGranted),e.setup!==void 0&&(t.setup=X({...e.setup})),e.permissions!==void 0&&(t.permissions=X({...e.permissions})),X(t)}),ki=Y(gi,e=>X({...e})),Ai=Y(Pr,e=>X({...e}),`INVALID_ARGUMENT`),ji=Y(Nr,e=>X({...e})),Mi=Y(Hr,e=>e),Ni=Y(Xr,e=>X(e.map(e=>e.kind===`menu`?X({...e,options:X(e.options.map(e=>X(e)))}):X(e))),`INVALID_ARGUMENT`),Pi=Y(u({itemId:q(64),optionId:E(q(64)),anchor:E(u({start:f.pipe(_(ae({minimum:0,maximum:1e5}))),width:f.pipe(_(ae({minimum:0,maximum:1e5})))}))}),e=>X(e.anchor===void 0?{...e}:{...e,anchor:X({...e.anchor})}),`INVALID_ARGUMENT`),Fi=Y(Zr,e=>X({...e}),`INVALID_ARGUMENT`);function Ii(e){let t={id:e.id,label:e.label};return e.presentation!==void 0&&(t={...t,presentation:e.presentation}),e.tone!==void 0&&(t={...t,tone:e.tone}),X(t)}function Li(e){let t={id:e.id,label:e.label};return e.siblings===void 0?X(t):X({...t,siblings:X(e.siblings.map(e=>X({...e})))})}function Ri(e){let t={id:e.id,label:e.label};return e.icon!==void 0&&(t={...t,icon:e.icon}),e.variant!==void 0&&(t={...t,variant:e.variant}),e.tone!==void 0&&(t={...t,tone:e.tone}),e.disabled!==void 0&&(t={...t,disabled:e.disabled}),X(t)}function zi(e){let t={canGoBack:e.canGoBack,canGoForward:e.canGoForward};return e.title!==void 0&&(t={...t,title:e.title}),e.crumbs!==void 0&&(t={...t,crumbs:X(e.crumbs.map(Li))}),e.primary!==void 0&&(t={...t,primary:X(e.primary.map(Ri))}),e.menu!==void 0&&(t={...t,menu:X(e.menu.map(Ri))}),e.status!==void 0&&(t={...t,status:X(e.status.map(Ii))}),X(t)}var Bi=Y(si,zi,`INVALID_ARGUMENT`),Vi=Y(ci,e=>{let t=e.title?.trim();return Hi({...zi({...e,title:t===void 0||t.length===0?void 0:t}),contractVersion:2})},`INVALID_ARGUMENT`),Hi=Y(si,e=>X({...zi(e),contractVersion:2}),`INVALID_ARGUMENT`),Ui=Y(li,e=>e.kind===`action`?X({...e}):X(e.siblingId===void 0?{kind:e.kind,crumbId:e.crumbId}:e),`INVALID_ARGUMENT`),Wi=Y(ui,e=>e===null?null:X({...e}),`INVALID_ARGUMENT`),Gi=Y(fi,e=>X({agents:X([...new Set(e.agents??[])]),computers:X([...new Set(e.computers??[])]),...e.git&&{git:X([...new Set(e.git)])},...e.workflows&&{workflows:X([...new Set(e.workflows)])},...e.events&&{events:X([...new Set(e.events)])},...e.generation&&{generation:X([...new Set(e.generation)])}}),`INVALID_ARGUMENT`),Ki=Y(zr,e=>e,`INVALID_ARGUMENT`);Y(_i,e=>X(e));var qi=Y(q(512),e=>e),Ji=Y(mi,e=>X({...e}),`INVALID_ARGUMENT`);Y(u({id:q(160),repeat:h}),e=>X(e));var Yi=Y(k(Ur).pipe(_(w(64))),e=>{if(new Set(e.map(e=>e.id)).size!==e.length)throw new L(`Reserved chords are invalid`,{code:`PROTOCOL`,retryable:!1});return X(e.map(e=>X({...e})))});function Xi(e){return Y(u({value:c,version:jr}),t=>X({value:e(t.value),version:t.version}))}var Zi=Xi(Oi),Qi=Y(u({capabilities:k(c).pipe(_(w(128))),context:c}),e=>X({capabilities:X(e.capabilities.map(e=>ia(e))),context:Zi(e.context)})),$i=Xi(Mi),ea=Xi(Yi),ta=Xi(qi),na=Ce($i,e=>{if(e.value!==`connected`&&e.value!==`suspended`)throw new L(`The host lifecycle is invalid`,{code:`PROTOCOL`,retryable:!1});return X({value:e.value,version:e.version})});function ra(e){return Y(u({handle:c,id:q(160),version:Mr}),t=>{if(!(t.handle instanceof vr)&&!(e&&t.handle instanceof yr))throw new L(`A capability handle is invalid`,{code:`PROTOCOL`,retryable:!1});return X({handle:t.handle,id:t.id,version:t.version})})}var ia=ra(!1),aa=ra(!0);function oa(e){let t=e?aa:ia;return Y(u({capabilities:k(c).pipe(_(w(128))),context:c,identity:c,lifecycle:c,reservedChords:c,theme:c}),e=>X({capabilities:X(e.capabilities.map(e=>t(e))),context:Zi(e.context),identity:ji(e.identity),lifecycle:na(e.lifecycle),reservedChords:ea(e.reservedChords),theme:ta(e.theme)}))}var sa=oa(!1);oa(!0);function Z(e){return Y(xi,t=>t.ok?X({ok:!0,value:e(t.value)}):X({ok:!1,error:ki(t.error)}))}var ca=Z(sa),la=Z(Y(u({commandId:q(321)}),e=>X(e)));Z(Y(Kr,e=>{if(e.status===`failed`)return X({status:`failed`,error:pa(()=>Pe(e.error))});let t=e.result===void 0?void 0:N(e.result);return X(t===void 0?{status:`handled`}:{status:`handled`,result:t})}));var ua=Z(Y(De,()=>void 0)),da=Z(Y(pi,e=>e)),fa=Z(Y(Br,e=>e));Z(Y(h,e=>e)),Z(Y(h,e=>e));function pa(e){try{return e()}catch(e){throw new L(`The command metadata is invalid`,{cause:e,code:`INVALID_ARGUMENT`,retryable:!1})}}var ma=g([u({kind:p(`saveFile`),name:q(255).pipe(_(D(/^[^\p{Cc}/\\]+$/u))),mime:q(255),bytes:oe}),u({kind:p(`copyText`),text:o})]);function ha(e){let t=Se(ma,{onExcessProperty:`error`})(e);if(a(t))return{kind:`refused`,reason:`invalid-request`};let n=t.success;return n.kind===`saveFile`?n.name===`.`||n.name===`..`?{kind:`refused`,reason:`invalid-request`}:n.bytes.byteLength>33554432?{kind:`refused`,reason:`too-large`}:{...n,bytes:new Uint8Array(n.bytes)}:n.text.length>1048576||new TextEncoder().encode(n.text).byteLength>1048576?{kind:`refused`,reason:`too-large`}:n}var ga=Z(Y(g([u({kind:p(`saved`)}),u({kind:p(`copied`)}),u({kind:p(`refused`),reason:T([`no-user-gesture`,`too-large`,`invalid-request`,`unavailable`,`denied`,`busy`])})]),e=>X(e)));function _a(e){let t=e,n=new Set;return{get:()=>t,subscribe(e){n.add(e);let t=!0;return()=>{t&&(t=!1,n.delete(e))}},update(e){if(!Object.is(t,e)){t=e;for(let e of Array.from(n))try{e(t)}catch(e){console.warn(`App store subscriber failed`,e)}}}}}function va(e){let t=new Map,n=_a(0),r=!1,i=e=>{let t=new Map;try{for(let n of e){let e=ia(n),r=Ca(e.id,e.version);if(t.has(r))throw ba(e.handle),new L(`Duplicate capability grant`,{code:`PROTOCOL`,retryable:!1});t.set(r,e.handle)}}catch(e){for(let e of t.values())ba(e);throw e}return t};for(let[n,r]of i(e))t.set(n,r);let a=e=>{for(let t of e)ba(t)},o=e=>{if(r)throw new L(`The app connection is disposed`,{code:`DISCONNECTED`,retryable:!0});let n=Ca(e.id,e.version);return t.get(n)};return{directory:Object.freeze({get version(){return n.get()},subscribe:e=>n.subscribe(e),has(e){return!!o(e)},require(e){let t=o(e);if(!t)throw new L(`The capability is not granted`,{code:`CAPABILITY_DENIED`,retryable:!1});try{return e.schema.parse(t)}catch(e){throw new L(`The capability interface is malformed`,{cause:e,code:`PROTOCOL`,retryable:!1})}}}),replace(e){if(r)throw new L(`The app connection is disposed`,{code:`DISCONNECTED`,retryable:!0});let o=i(e),s=[...t.values()];t.clear();for(let[e,n]of o)t.set(e,n);a(s.filter(e=>![...o.values()].includes(e))),n.update(n.get()+1)},disconnect(){r||(r=!0,a(t.values()),t.clear(),n.update(n.get()+1))}}}var ya=i().transform(e=>{let t=ye(Object).safeParse(e);if(!t.success)return;let n=Object.create(t.data),r=d(u({[Symbol.dispose]:x(fe(Function))}))(n);return{owner:t.data,dispose:r[Symbol.dispose]}});function ba(e){try{let t=ya.parse(e);if(t===void 0||Sa.has(t.owner))return;Sa.add(t.owner),t.dispose?.call(t.owner)}catch(e){console.warn(`RPC value disposal failed`,e)}}function xa(e){return{value:e,[Symbol.dispose](){ba(e)}}}var Sa=new WeakSet;function Ca(e,t){return`${e}@${String(t)}`}var wa=class{id;version;#e;constructor(e,t,n){this.id=e,this.version=t,this.#e=n,Object.freeze(this)}get schema(){return this.#e}};function Ta(e,t,n){return new wa(e,t,n)}function Ea(e){let t=y(e),n=ye(Object),r=y(Object.fromEntries(Object.keys(e).map(e=>[e,i().optional()])));return i().transform(e=>{let i=n.parse(e),a=Object.create(i),o=r.parse(a),s=Object.fromEntries(Object.entries(o).flatMap(([e,t])=>t===void 0?[]:[[e,b().parse(t).bind(i)]]));return{...t.parse(s),[Symbol.dispose](){ba(e)}}})}function Da(e){return i().transform(t=>{try{return e.parse(t)}catch(e){throw e instanceof L?e:new L(`The capability returned malformed data`,{cause:e,code:`PROTOCOL`,retryable:!1})}finally{ba(t)}})}function Oa(e){return b({output:Ee(i().transform(t=>{try{return e.parse(t)}catch(e){throw ba(t),e instanceof L?e:new L(`The capability returned a malformed result`,{cause:e,code:`PROTOCOL`,retryable:!1})}}))})}var ka=Oa(Da(Te()));Ea({fetch:Oa(ye(Response)),close:ka});var Aa=e(ce(),1);function ja(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var Ma=e=>{switch(e){case`success`:return Fa;case`info`:return La;case`warning`:return Ia;case`error`:return Ra;default:return null}},Na=Array(12).fill(0),Pa=({visible:e,className:t})=>M.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},M.createElement(`div`,{className:`sonner-spinner`},Na.map((e,t)=>M.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),Fa=M.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},M.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),Ia=M.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},M.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),La=M.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},M.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),Ra=M.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},M.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),za=M.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`},M.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),M.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),Ba=()=>{let[e,t]=M.useState(document.hidden);return M.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e},Va=1,Ha=100,Ua=e=>typeof e?.id==`number`||e?.id?.length>0?e.id:Va++,Q=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),this.getActiveToasts().forEach(t=>e(t)),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e],this.trimHistory()},this.trimHistory=()=>{let e=this.toasts.length-Ha;e<=0||(this.toasts=this.toasts.filter(t=>e>0&&this.dismissedToasts.has(t.id)?(this.dismissedToasts.delete(t.id),e--,!1):!0))},this.create=e=>{let{message:t,...n}=e,r=Ua(e),i=this.pendingDismissals.get(r);i!==void 0&&(cancelAnimationFrame(i),this.pendingDismissals.delete(r),this.dismissedToasts.delete(r));let a=this.dismissedToasts.has(r),o=e.dismissible===void 0||e.dismissible;return a&&(this.dismissedToasts.delete(r),this.toasts=this.toasts.filter(e=>e.id!==r)),!a&&this.toasts.find(e=>e.id===r)?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:o,title:t}):n):this.addToast({title:t,...n,dismissible:o,id:r}),r},this.dismiss=e=>{if(e==null)return this.getActiveToasts().forEach(e=>{this.dismissedToasts.add(e.id),this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e;this.dismissedToasts.add(e);let t=this.pendingDismissals.get(e);return t!==void 0&&cancelAnimationFrame(t),this.pendingDismissals.set(e,requestAnimationFrame(()=>{this.pendingDismissals.delete(e),this.subscribers.forEach(t=>t({id:e,dismiss:!0}))})),e},this.message=(e,t)=>this.create({...t,message:e,type:void 0}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],M.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(Ga(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!M.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!M.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!M.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!M.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=Ua(t);return this.create({...t,jsx:e(n),id:n,type:void 0}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}},Wa=(e,t)=>Q.message(e,t),Ga=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,Ka=Object.assign(Wa,{success:Q.success,info:Q.info,warning:Q.warning,error:Q.error,custom:Q.custom,message:Q.message,promise:Q.promise,dismiss:Q.dismiss,loading:Q.loading},{getHistory:()=>Q.toasts,getToasts:()=>Q.getActiveToasts()});ja(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function qa(e){return e.label!==void 0}var Ja=3,Ya=`24px`,Xa=`16px`,Za=4e3,Qa=356,$a=14,eo=45,to=200;function $(...e){return e.filter(Boolean).join(` `)}function no(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var ro=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:ee,closeButton:te,style:ne,cancelButtonStyle:re,actionButtonStyle:f,className:p=``,descriptionClassName:ie=``,duration:ae,position:oe,gap:se,expandByDefault:ce,classNames:m,icons:h,closeButtonAriaLabel:le=`Close toast`}=e,[g,ue]=M.useState(null),[de,_]=M.useState(null),[fe,v]=M.useState(!1),[pe,y]=M.useState(!1),[b,x]=M.useState(!1),[S,me]=M.useState(!1),[he,C]=M.useState(!1),[ge,w]=M.useState(0),[_e,ve]=M.useState(0),T=M.useRef(n.duration||ae||Za),ye=M.useRef(null),E=M.useRef(null),be=c===0,xe=c+1<=o,D=n.type,Se=D??`default`,Ce=n.dismissible!==!1,O=n.className||``,we=n.descriptionClassName||``,Te=M.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),k=M.useMemo(()=>n.closeButton??te,[n.closeButton,te]),A=M.useMemo(()=>n.duration||ae||Za,[n.duration,ae]),Ee=M.useRef(0),j=M.useRef(0),De=M.useRef(0),Oe=M.useRef(null),[ke,Ae]=oe.split(`-`),je=M.useMemo(()=>s.reduce((e,t,n)=>n>=Te?e:e+t.height,0),[s,Te]),Me=Ba(),N=M.useMemo(()=>e.swipeDirections??no(oe),[e.swipeDirections,oe]),Ne=n.invert||t,Pe=D===`loading`;j.current=M.useMemo(()=>Te*se+je,[Te,je]),M.useEffect(()=>{T.current=A},[A]),M.useEffect(()=>{v(!0)},[]),M.useEffect(()=>{let e=E.current;if(e){let t=e.getBoundingClientRect().height;return ve(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),M.useLayoutEffect(()=>{if(!fe)return;let e=E.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,ve(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[fe,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let P=M.useCallback(()=>{y(!0),w(j.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},to)},[n,d,a,j]);M.useEffect(()=>{if(n.promise&&D===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||Me?(()=>{if(De.current<Ee.current){let e=new Date().getTime()-Ee.current;T.current-=e}De.current=new Date().getTime()})():T.current!==1/0&&(Ee.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),P()},T.current)),()=>clearTimeout(e)},[u,i,n,D,Me,P]),M.useEffect(()=>{n.delete&&(P(),n.onDismiss==null||n.onDismiss.call(n,n))},[P,n.delete]);function F(){return h?.loading?M.createElement(`div`,{className:$(m?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":D===`loading`},h.loading):M.createElement(Pa,{className:$(m?.loader,n?.classNames?.loader),visible:D===`loading`})}let Fe=n.icon||h?.[D]||Ma(D);return M.createElement(`li`,{tabIndex:0,ref:E,className:$(p,O,m?.toast,n?.classNames?.toast,m?.[Se],n?.classNames?.[Se]),"data-sonner-toast":``,"data-rich-colors":n.richColors??ee,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":fe,"data-promise":!!n.promise,"data-swiped":he,"data-removed":pe,"data-visible":xe,"data-y-position":ke,"data-x-position":Ae,"data-index":c,"data-front":be,"data-swiping":b,"data-dismissible":Ce,"data-type":D,"data-invert":Ne,"data-swipe-out":S,"data-swipe-direction":de,"data-expanded":!!(u||ce&&fe),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${pe?ge:j.current}px`,"--initial-height":ce?`auto`:`${_e}px`,...ne,...n.style},onDragEnd:()=>{x(!1),ue(null),Oe.current=null},onPointerDown:e=>{e.button!==2&&(Pe||!Ce||(ye.current=new Date,w(j.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(x(!0),Oe.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(S||!Ce)return;Oe.current=null;let e=Number(E.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(E.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-ye.current?.getTime(),i=g===`x`?e:t,a=Math.abs(i)/r;if((g===`x`?N.includes(e>0?`right`:`left`):N.includes(t>0?`bottom`:`top`))&&(Math.abs(i)>=eo||a>.11)){w(j.current),n.onDismiss==null||n.onDismiss.call(n,n),_(g===`x`?e>0?`right`:`left`:t>0?`down`:`up`),P(),me(!0);return}var o,s;(o=E.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=E.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`),C(!1),x(!1),ue(null)},onPointerMove:e=>{var t,n;if(!Oe.current||!Ce||window.getSelection()?.toString().length>0)return;let r=e.clientY-Oe.current.y,i=e.clientX-Oe.current.x;!g&&(Math.abs(i)>1||Math.abs(r)>1)&&ue(Math.abs(i)>Math.abs(r)?`x`:`y`);let a={x:0,y:0},o=e=>1/(1.5+Math.abs(e)/20);if(g===`y`){if(N.includes(`top`)||N.includes(`bottom`)){if(N.includes(`top`)&&r<0||N.includes(`bottom`)&&r>0)a.y=r;else{let e=r*o(r);a.y=Math.abs(e)<Math.abs(r)?e:r}}}else if(g===`x`&&(N.includes(`left`)||N.includes(`right`))){if(N.includes(`left`)&&i<0||N.includes(`right`)&&i>0)a.x=i;else{let e=i*o(i);a.x=Math.abs(e)<Math.abs(i)?e:i}}(Math.abs(a.x)>0||Math.abs(a.y)>0)&&C(!0),(t=E.current)==null||t.style.setProperty(`--swipe-amount-x`,`${a.x}px`),(n=E.current)==null||n.style.setProperty(`--swipe-amount-y`,`${a.y}px`)}},k&&!n.jsx&&D!==`loading`?M.createElement(`button`,{"aria-label":le,"data-disabled":Pe,"data-close-button":!0,onClick:Pe||!Ce?()=>{}:()=>{P(),n.onDismiss==null||n.onDismiss.call(n,n)},className:$(m?.closeButton,n?.classNames?.closeButton)},h?.close??za):null,(D||n.icon||n.promise)&&n.icon!==null&&(h?.[D]!==null||n.icon)?M.createElement(`div`,{"data-icon":``,className:$(m?.icon,n?.classNames?.icon)},D===`loading`?n.icon||F():n.promise?F():null,D===`loading`?null:Fe):null,M.createElement(`div`,{"data-content":``,className:$(m?.content,n?.classNames?.content)},M.createElement(`div`,{"data-title":``,className:$(m?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?M.createElement(`div`,{"data-description":``,className:$(ie,we,m?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),M.isValidElement(n.cancel)?n.cancel:n.cancel&&qa(n.cancel)?M.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||re,onClick:e=>{qa(n.cancel)&&Ce&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),P())},className:$(m?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,M.isValidElement(n.action)?n.action:n.action&&qa(n.action)?M.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||f,onClick:e=>{qa(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&P())},className:$(m?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function io(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function ao(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?Xa:Ya;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var oo=M.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:ee,duration:te,style:ne,visibleToasts:re=Ja,toastOptions:f,dir:p=io(),gap:ie=$a,icons:ae,customAriaLabel:oe,containerAriaLabel:se=`Notifications`}=e,[ce,m]=M.useState([]),h=M.useMemo(()=>n?ce.filter(e=>e.toasterId===n):ce.filter(e=>!e.toasterId),[ce,n]),le=M.useMemo(()=>Array.from(new Set([i].concat(h.filter(e=>e.position).map(e=>e.position)))),[h,i]),[g,ue]=M.useState([]),[de,_]=M.useState(!1),[fe,v]=M.useState(!1),[pe,y]=M.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),b=M.useRef(null),x=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),S=M.useRef(null),me=M.useRef(!1),he=M.useCallback(e=>{m(t=>(t.find(t=>t.id===e.id)?.delete||Q.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return M.useEffect(()=>Q.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{m(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{Aa.flushSync(()=>{m(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[]),M.useEffect(()=>{if(d!==`system`){y(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?y(`dark`):y(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{y(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{y(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),M.useEffect(()=>{ce.length<=1&&_(!1)},[ce]),M.useEffect(()=>{let e=e=>{if(a.length>0&&a.every(t=>e[t]||e.code===t)){var t;_(!0),(t=b.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===b.current||b.current?.contains(document.activeElement))&&_(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),M.useEffect(()=>{if(b.current)return()=>{S.current&&(S.current.focus({preventScroll:!0}),S.current=null,me.current=!1)}},[b.current]),M.createElement(`section`,{ref:t,"aria-label":oe??`${se} ${x}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},le.map((t,n)=>{let[i,a]=t.split(`-`);return h.length?M.createElement(`ol`,{key:t,dir:p===`auto`?io():p,tabIndex:-1,ref:b,className:c,"data-sonner-toaster":!0,"data-sonner-theme":pe,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${g[0]?.height||0}px`,"--width":`${Qa}px`,"--gap":`${ie}px`,...ne,...ao(l,u)},onBlur:e=>{me.current&&!e.currentTarget.contains(e.relatedTarget)&&(me.current=!1,S.current&&=(S.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||me.current||(me.current=!0,S.current=e.relatedTarget)},onMouseEnter:()=>_(!0),onMouseMove:()=>_(!0),onMouseLeave:()=>{fe||_(!1)},onDragEnd:()=>_(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||v(!0)},onPointerUp:()=>v(!1)},h.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>M.createElement(ro,{key:n.id,icons:ae,index:i,toast:n,defaultRichColors:ee,duration:f?.duration??te,className:f?.className,descriptionClassName:f?.descriptionClassName,invert:r,visibleToasts:re,closeButton:f?.closeButton??s,interacting:fe,position:t,style:f?.style,unstyled:f?.unstyled,classNames:f?.classNames,cancelButtonStyle:f?.cancelButtonStyle,actionButtonStyle:f?.actionButtonStyle,closeButtonAriaLabel:f?.closeButtonAriaLabel,removeToast:he,toasts:h.filter(e=>e.position==n.position),heights:g.filter(e=>e.position==n.position),setHeights:ue,expandByDefault:o,gap:ie,expanded:de,swipeDirections:e.swipeDirections}))):null}))});export{tn as $,Ui as A,pt as At,Ni as B,ki as C,kt as Ct,ji as D,Rt as Dt,Qi as E,Bt as Et,la as F,rt as Ft,Er as G,Ji as H,Yi as I,tt as It,Cr as J,Dr as K,Ki as L,Ge as Lt,Vi as M,L as Mt,da as N,it as Nt,Mi as O,xt as Ot,Gi as P,lt as Pt,br as Q,fa as R,Pe as Rt,Oi as S,Ft as St,Ai as T,At as Tt,ua as U,qi as V,Or as W,vr as X,Sr as Y,yr as Z,Ci as _,bt as _t,Oa as a,Yt as at,Ei as b,vt as bt,va as c,Wt as ct,_a as d,It as dt,nn as et,Si as f,Lt as ft,ga as g,Tt as gt,ha as h,Et as ht,Ea as i,$t as it,Bi as j,ft as jt,Fi as k,ht as kt,ba as l,Ut as lt,ca as m,yt as mt,Ka as n,Qt as nt,ka as o,Jt as ot,Wi as p,zt as pt,wr as q,Da as r,Zt as rt,Ta as s,Gt as st,oo as t,en as tt,xa as u,Vt as ut,wi as v,wt as vt,Xi as w,St as wt,Di as x,Dt as xt,Ti as y,Ct as yt,Pi as z,N as zt};