@deslop/workbench 0.0.344 → 0.0.357

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.
Files changed (39) hide show
  1. package/dist/client/assets/-workbench-terminal-DyfxJcjD.js +145 -0
  2. package/dist/client/assets/agent-CA1IdfRT.js +1 -0
  3. package/dist/client/assets/agent-COvRE6oy.js +2 -0
  4. package/dist/client/assets/button-Dz6Az3h_.js +16 -0
  5. package/dist/client/assets/{diff-BwOj6t_o.js → diff-BqnMP7Ys.js} +44 -44
  6. package/dist/client/assets/{diff-COOvYjfB.js → diff-CLnQZZVT.js} +2 -2
  7. package/dist/client/assets/{external-link-DR7_wu3r.js → external-link-DPI4TAq4.js} +1 -1
  8. package/dist/client/assets/{fallbacks-D-9MltuA.js → fallbacks-uU4M5NOw.js} +1 -1
  9. package/dist/client/assets/{index-DCRiD9Nz.js → index-Mo4bEjHb.js} +3 -3
  10. package/dist/client/assets/input-group-1-P7Y_75.js +153 -0
  11. package/dist/client/assets/loader-circle-BxillczB.js +1 -0
  12. package/dist/client/assets/{portless-nerboxiJ.js → portless-ClPWjTC4.js} +1 -1
  13. package/dist/client/assets/portless-QJD7ZmA9.js +2 -0
  14. package/dist/client/assets/{resizable-ChkQg6Mj.js → resizable-BaJ5ba6-.js} +1 -1
  15. package/dist/client/assets/route-C-L2dkin.js +45 -0
  16. package/dist/client/assets/route-b5JXfzPO.js +2 -0
  17. package/dist/client/assets/run-C0ukWbxF.js +2 -0
  18. package/dist/client/assets/run-cjBxZ3gl.js +1 -0
  19. package/dist/client/assets/state-CVjPP5QG.js +2 -0
  20. package/dist/client/assets/terminal-B5ko1jIG.js +2 -0
  21. package/dist/client/assets/terminal-CA1dMT3m.js +1 -0
  22. package/dist/client/assets/{triangle-alert-CQsOhrGn.js → triangle-alert-CTEZG9zF.js} +1 -1
  23. package/dist/client/index.html +11 -11
  24. package/dist/server.js +519 -1553
  25. package/package.json +2 -4
  26. package/dist/client/assets/agent-BATV5D0O.js +0 -1
  27. package/dist/client/assets/agent-K-v27T1K.js +0 -2
  28. package/dist/client/assets/button-f42ZKq6E.js +0 -16
  29. package/dist/client/assets/input-group-mMwtG03E.js +0 -153
  30. package/dist/client/assets/loader-circle-DEYAvEPU.js +0 -1
  31. package/dist/client/assets/portless-C8dLcQQw.js +0 -2
  32. package/dist/client/assets/route-DAz8IJkt.js +0 -2
  33. package/dist/client/assets/route-GFqYSDK4.js +0 -45
  34. package/dist/client/assets/run-B16WQaws.js +0 -2
  35. package/dist/client/assets/run-BHEbhvk3.js +0 -1
  36. package/dist/client/assets/state-BOj5tZ-Q.js +0 -2
  37. package/dist/client/assets/terminal-B410vkZ0.js +0 -1
  38. package/dist/client/assets/terminal-BQ9AR6VK.js +0 -145
  39. package/dist/client/assets/terminal-Br297Oa8.js +0 -2
@@ -0,0 +1,2 @@
1
+ import{r as e}from"./chunk-QTnfLwEv.js";import{r as t}from"./compiler-runtime-rGeCHUuX.js";import{$a as n,$i as r,$n as i,$r as a,$t as o,Aa as s,Ai as c,An as l,Ao as u,Ar as d,At as f,B as p,Ba as m,Bi as ee,Bn as te,Bo as ne,Br as re,Bt as h,Ci as ie,Cn as ae,Co as oe,Cr as se,Ct as ce,Da as le,Di as ue,Dn as de,Do as fe,Dr as pe,Dt as me,Ea as he,Ei as ge,En as _e,Eo as ve,Er as ye,Et as be,F as xe,Fa as Se,Fi as Ce,Fn as we,Fo as Te,Fr as Ee,Ft as De,G as Oe,Ga as ke,Gi as Ae,Gn as je,Go as Me,Gr as Ne,Gt as Pe,H as Fe,Ha as Ie,Hi as Le,Hn as Re,Ho as ze,Hr as Be,Ht as Ve,I as He,Ia as Ue,Ii as We,In as g,Io as Ge,Ir as Ke,It as qe,J as Je,Ja as Ye,Ji as Xe,Jn as Ze,Jo as _,Jr as Qe,Jt as $e,K as et,Ka as tt,Ki as nt,Kn as rt,Ko as v,Kr as it,Kt as y,L as b,La as at,Li as ot,Ln as st,Lr as ct,Lt as lt,Ma as ut,Mi as dt,Mn as ft,Mo as pt,Mr as mt,Mt as ht,Na as gt,Ni as _t,Nn as vt,No as yt,Nr as bt,Nt as xt,Oi as St,On as Ct,Oo as wt,Or as Tt,P as x,Pa as Et,Pi as Dt,Pn as Ot,Po as kt,Pr as At,Pt as jt,Q as Mt,Qa as Nt,Qi as Pt,Qn as Ft,Qo as It,Qr as Lt,Qt as Rt,R as S,Ri as zt,Rn as Bt,Ro as Vt,Rr as Ht,Rt as Ut,Sa as Wt,Si as Gt,Sn as Kt,So as qt,Sr as Jt,St as Yt,Ta as Xt,Ti as Zt,Tn as Qt,To as $t,Tr as en,Tt as tn,U as nn,Ua as rn,Ui as an,Un as on,Ur as sn,Ut as cn,V as ln,Va as un,Vi as dn,Vn as fn,Vo as pn,Vr as mn,Vt as hn,W as gn,Wa as _n,Wi as vn,Wn as yn,Wo as bn,Wr as xn,Wt as Sn,X as C,Xa as Cn,Xi as wn,Xn as Tn,Xo as En,Xr as Dn,Xt as w,Y as T,Ya as On,Yi as kn,Yn as An,Yo as jn,Yr as Mn,Z as Nn,Za as Pn,Zi as Fn,Zn as E,Zr as In,Zt as Ln,_i as Rn,_n as zn,_o as Bn,_t as Vn,aa as Hn,ai as Un,an as Wn,ao as Gn,ar as Kn,ba as qn,bi as Jn,bn as Yn,bo as Xn,br as Zn,bt as Qn,ca as $n,ci as er,cn as tr,co as nr,cr as rr,ct as ir,da as ar,di as or,dn as sr,do as cr,dr as lr,dt as ur,ea as dr,ei as fr,en as pr,eo as mr,er as hr,et as gr,fi as _r,fn as vr,fo as yr,ft as br,gi as xr,gn as Sr,go as Cr,gt as wr,ha as Tr,hi as Er,hn as Dr,ho as Or,ht as kr,ia as Ar,in as jr,io as D,ir as Mr,it as Nr,ja as Pr,ji as Fr,jn as Ir,jo as Lr,jr as Rr,jt as zr,ki as Br,kn as Vr,ko as Hr,kr as Ur,kt as Wr,la as Gr,li as Kr,ln as O,lo as qr,lt as Jr,mi as Yr,mn as Xr,mo as Zr,mt as k,na as Qr,ni as $r,nn as ei,no as ti,nr as ni,nt as ri,oa as ii,oi as ai,on as oi,oo as A,or as si,ot as ci,pa as li,pi as ui,pn as di,po as fi,pt as pi,q as mi,qa as hi,qi as gi,qn as _i,qo as vi,qr as yi,qt as bi,ra as xi,ri as Si,rn as Ci,ro as wi,rr as Ti,rt as Ei,sa as Di,si as Oi,sn as ki,so as Ai,sr as ji,ta as j,tn as Mi,to as Ni,tr as Pi,tt as Fi,ua as Ii,ui as Li,un as Ri,uo as zi,ut as Bi,va as Vi,vi as Hi,vn as Ui,vo as Wi,vr as Gi,wa as Ki,wi as qi,wn as Ji,wo as Yi,wr as Xi,wt as Zi,xa as Qi,xi as $i,xn as ea,xo as ta,xr as na,xt as ra,ya as ia,yi as aa,yn as oa,yo as sa,yr as ca,yt as la,z as ua,za as da,zi as fa,zn as M,zr as pa,zt as ma}from"./button-Dz6Az3h_.js";var ha=Zt,ga=ge,_a=ie,va=qi,ya=c,ba=ue,xa=dt,Sa=Symbol.for(`effect/MutableList/Empty`),Ca=()=>({head:void 0,tail:void 0,length:0}),wa=()=>({array:[],mutable:!0,offset:0,next:void 0}),Ta=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=wa(),e.tail=e.tail.next):e.head=e.tail=wa(),e.tail.array.push(t),e.length++},Ea=(e,t)=>Da(e,Ki(t),!Array.isArray(t)),Da=(e,t,n=!1)=>{if(t.length===0)return 0;let r={array:t,mutable:n,offset:0,next:void 0};return e.head?e.tail=e.tail.next=r:e.head=e.tail=r,e.length+=t.length,t.length},Oa=e=>{e.head=e.tail=void 0,e.length=0},ka=(e,t)=>{if(t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let t=e.head.array;return Oa(e),t}let n=Array(t),r=0,i=e.head;for(;i;){for(;i.offset<i.array.length;)if(n[r++]=i.array[i.offset],i.mutable&&(i.array[i.offset]=void 0),i.offset++,r===t)return e.head=i,e.length-=t,e.length===0&&Oa(e),n;i=i.next}return Oa(e),n},Aa=e=>ka(e,e.length),ja=e=>{if(!e.head)return Sa;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length&&(e.head.next?e.head=e.head.next:Oa(e)),t},Ma=(e,t)=>{let n=[],r=e.head;for(;r;){for(let e=r.offset;e<r.array.length;e++)t(r.array[e],e)&&n.push(r.array[e]);r=r.next}e.head=e.tail={array:n,mutable:!0,offset:0,next:void 0},e.length=n.length},Na=(e,t)=>Ma(e,e=>e!==t),Pa=`~effect/MutableRef`,Fa={[Pa]:Pa,...qr,toJSON(){return{_id:`MutableRef`,current:sa(this.current)}}},Ia=e=>{let t=Object.create(Fa);return t.current=e,t},La=v(2,(e,t)=>(e.current=t,e)),Ra=`~effect/PubSub/Subscription`,za=v(2,(e,t)=>e.shutdownFlag.current?!1:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),!0):!1),Ba=e=>_i(hn(t=>{let n=Ar(t,Rr),r=Ee(e.scope),i=Wa(e.pubsub,e.subscribers,e.strategy);return mt(r,Va(i)).pipe(zr(bt(n,e=>At(r,e))),xt(i))})),Va=e=>_i(hr(t=>(La(e.shutdownFlag,!0),Ln(Aa(e.pollers),e=>Be(e,t.id),{discard:!0,concurrency:`unbounded`}).pipe(te(()=>M(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),Ft(e.shutdownHook.open),jt)))),Ha=e=>Bt(function t(n){if(e.shutdownFlag.current)return jr;let r=e.pollers.length===0?e.subscription.pollUpTo(1/0):[];return n&&(r=n.concat(r)),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),e.replayWindow.remaining>0?g(e.replayWindow.takeAll().concat(r)):Xt(r)?g(r):y(Ua(e),e=>t([e]))}),Ua=e=>{let t=xn(),n=e.subscribers.get(e.subscription);return n||(n=new Set,e.subscribers.set(e.subscription,n)),n.add(e.pollers),Ta(e.pollers,t),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),zn(re(t),()=>(Na(e.pollers,t),E))},Wa=(e,t,n)=>new Ga(e,t,e.subscribe(),Ca(),xa(!1),Ia(!1),n,e.replayWindow()),Ga=class{[Ra]={_A:_};pubsub;subscribers;subscription;pollers;shutdownHook;shutdownFlag;strategy;replayWindow;constructor(e,t,n,r,i,a,o,s){this.pubsub=e,this.subscribers=t,this.subscription=n,this.pollers=r,this.shutdownHook=i,this.shutdownFlag=a,this.strategy=o,this.replayWindow=s}pipe(){return En(this,arguments)}},Ka=`~effect/Queue`,qa=`~effect/Queue/Enqueue`,Ja=`~effect/Queue/Dequeue`,Ya={_A:_,_E:_},Xa={[Ka]:Ya,[qa]:Ya,[Ja]:Ya,...qr,toJSON(){return{_id:`effect/Queue`,state:this.state._tag,size:fo(this)}}},Za=e=>Or(t=>{let n=Object.create(Xa);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??1/0,n.strategy=e?.strategy??`suspend`,n.messages=Ca(),n.scheduleRunning=!1,n.state={_tag:`Open`,takers:new Set,offers:new Set,awaiters:new Set},Dt(n)}),Qa=e=>Za({capacity:e}),$a=(e,t)=>We(()=>{if(e.state._tag!==`Open`)return po;if(e.messages.length>=e.capacity)switch(e.strategy){case`dropping`:return po;case`suspend`:return e.capacity<=0&&e.state.takers.size>0?(Ta(e.messages,t),_o(e),mo):bo(e,t);case`sliding`:return ja(e.messages),Ta(e.messages,t),mo}return Ta(e.messages,t),vo(e),mo}),eo=(e,t)=>e.state._tag===`Open`?e.messages.length>=e.capacity?e.strategy===`sliding`?(ja(e.messages),Ta(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0?(Ta(e.messages,t),_o(e),!0):!1:(Ta(e.messages,t),vo(e),!0):!1,to=(e,t)=>We(()=>{if(e.state._tag!==`Open`)return Dt(Ki(t));let n=no(e,t);return n.length===0?fi([]):e.strategy===`dropping`?Dt(n):xo(e,n)}),no=(e,t)=>{if(e.state._tag!==`Open`)return Ki(t);if(e.capacity===1/0||e.strategy===`sliding`)return Ea(e.messages,t),e.strategy===`sliding`&&ka(e.messages,e.messages.length-e.capacity),vo(e),[];let n=e.capacity<=0?e.state.takers.size:e.capacity-e.messages.length;if(n===0)return Ki(t);let r=[],i=0;for(let a of t)i<n?Ta(e.messages,a):r.push(a),i++;return vo(e),r},ro=v(2,(e,t)=>ot(()=>io(e,t))),io=(e,t)=>{if(e.state._tag!==`Open`)return!1;let n=Gt(yr(t),ho);return e.state.offers.size===0&&e.messages.length===0?(wo(e,n),!0):(e.state={...e.state,_tag:`Closing`,exit:n},!0)},ao=e=>ro(e,zi(nr())),oo=e=>ot(()=>{if(e.state._tag===`Done`)return!0;Oa(e.messages);let t=e.state.offers;if(wo(e,e.state._tag===`Open`?go:e.state.exit),t.size>0){for(let e of t)e._tag===`Single`?e.resume(po):e.resume(fi(e.remaining.slice(e.offset)));t.clear()}return!0}),so=e=>co(e,1,1/0),co=(e,t,n)=>We(()=>yo(e,t,n)??Rn(Co(e),co(e,1,n))),lo=e=>We(()=>uo(e)??Rn(Co(e),lo(e))),uo=e=>{if(e.state._tag===`Done`)return e.state.exit;if(e.messages.length>0){let t=ja(e.messages);return So(e),fi(t)}else if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,So(e),e.capacity=0;let t=ja(e.messages);return So(e),fi(t)}},fo=e=>e.state._tag===`Done`?0:e.messages.length,po=fi(!1),mo=fi(!0),ho=cr(nr()),go=Jn(),_o=e=>{if(e.scheduleRunning=!1,!(e.state._tag===`Done`||e.state.takers.size===0)){for(let t of e.state.takers)if(e.state.takers.delete(t),t($i),e.messages.length===0)break}},vo=e=>{e.scheduleRunning||e.state._tag===`Done`||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>_o(e),0))},yo=(e,t,n)=>{if(e.state._tag===`Done`)return e.state.exit;if(n<=0||t<=0)return fi([]);if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,So(e),e.capacity=0;let t=[ja(e.messages)];return So(e),fi(t)}if(t=Math.min(t,e.capacity||1),t<=e.messages.length){let t=ka(e.messages,n);return So(e),fi(t)}},bo=(e,t)=>aa(n=>{if(e.state._tag!==`Open`)return n(po);let r={_tag:`Single`,message:t,resume:n};return e.state.offers.add(r),ot(()=>{e.state._tag===`Open`&&e.state.offers.delete(r)})}),xo=(e,t)=>aa(n=>{if(e.state._tag!==`Open`)return n(fi(t));let r={_tag:`Array`,remaining:t,offset:0,resume:n};return e.state.offers.add(r),ot(()=>{e.state._tag===`Open`&&e.state.offers.delete(r)})}),So=e=>{if(e.state._tag===`Done`)return rr(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag===`Closing`&&e.messages.length===0?(wo(e,e.state.exit),rr(e.state.exit.cause)):!1;let t=e.capacity-e.messages.length;for(let n of e.state.offers)if(t===0)break;else if(n._tag===`Single`)Ta(e.messages,n.message),t--,n.resume(mo),e.state.offers.delete(n);else{for(;n.offset<n.remaining.length;n.offset++){if(t===0)return!1;Ta(e.messages,n.remaining[n.offset]),t--}n.resume(fi([])),e.state.offers.delete(n)}return!1},Co=e=>aa(t=>e.state._tag===`Done`?t(e.state.exit):(e.state.takers.add(t),ot(()=>{e.state._tag!==`Done`&&e.state.takers.delete(t)}))),wo=(e,t)=>{if(e.state._tag===`Done`)return;let n=e.state;e.state={_tag:`Done`,exit:t};for(let e of n.takers)e(t);n.takers.clear();for(let e of n.awaiters)e(t);n.awaiters.clear()},To=e=>new Eo(e),Eo=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=We(()=>this.free<e?aa(n=>{if(this.free>=e)return n(t);let r=()=>{this.free<e||(this.waiters.delete(r),n(t))};return this.waiters.add(r),ot(()=>{this.waiters.delete(r)})}):(this.taken+=e,Dt(e)));return t}updateTakenUnsafe(e,t){return this.taken=t(this.taken),this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{let e=this.waiters.values(),t=e.next();for(;t.done===!1&&this.free>0;)t.value(),t=e.next()},0),this.free}updateTaken(e){return Or(t=>Dt(this.updateTakenUnsafe(t,e)))}resize(e){return Or(t=>(this.permits=e,this.free<0||this.updateTakenUnsafe(t,e=>e),fa))}release(e){return this.updateTaken(t=>t-e)}get releaseAll(){return this.updateTaken(e=>0)}withPermits(e){return t=>zt(n=>St(n(this.take(e)),e=>_t(n(t),()=>{this.updateTakenUnsafe(c(),t=>t-e)},!0)))}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>zt(n=>this.free<e?Ce:(this.taken+=e,_t(n(Hi(t)),()=>{this.updateTakenUnsafe(c(),t=>t-e)},!0)))}},Do=`~effect/Channel`,Oo=e=>Te(e,Do),ko={[Do]:{_Env:_,_InErr:_,_InElem:_,_OutErr:_,_OutElem:_},pipe(){return En(this,arguments)}},Ao=e=>{let t=Object.create(ko);return t.transform=(t,n)=>lt(e(t,n),e=>g(Pe(e))),t},jo=(e,t)=>Ao((n,r)=>y(Po(e)(n,r),e=>t(e,r))),Mo=e=>Ao((t,n)=>e),No=e=>Ao(w(function*(t,n){let r=Ee(n),i=e=>At(r,ji(e));return Dr(yield*Dr(e(t,n,r),i),i)})),Po=e=>e.transform,Fo=(e,t,n)=>Za({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(te(t=>mt(e,oo(t))),te(n=>pr(ct(t(n),e),e))),Io=(e,t)=>Ao((n,r)=>O(Fo(r,e,t),so)),Lo=e=>Ao((t,n)=>Bt(()=>Po(e())(t,n))),Ro=Mo(g(Un())),zo=e=>Mo(g(Sn(e))),Bo=e=>Mo(g(so(e))),Vo=e=>Mo(g(zn(Ha(e),()=>Un()))),Ho=e=>Xo(O(Ba(e),Vo)),Uo=v(2,(e,t)=>jo(e,e=>M(()=>{let n=0;return O(e,e=>t(e,n++))}))),Wo=e=>e===void 0||e!==`unbounded`&&e<=1,Go=v(e=>Oo(e[0]),(e,t,n)=>Wo(n?.concurrency)?Ko(e,t):qo(e,t,n)),Ko=(e,t)=>Ao((n,r)=>{let i=0;return O(Po(e)(n,r),y(e=>t(e,i++)))}),qo=(e,t,n)=>No(w(function*(r,i,a){let o=0,s=yield*Po(e)(r,i),c=n.concurrency===`unbounded`?2**53-1:n.concurrency,l=yield*Qa(0);yield*mt(a,oo(l));let u=de(yield*h()),d=ba(a);if(n.unordered){let e=To(c),n=Me(e.release(1)),r=di({onFailure:e=>y(ro(l,e),n),onSuccess:e=>y($a(l,e),n)});yield*e.take(1).pipe(y(()=>s),y(e=>(d(u(r(t(e,o++)))),E)),Rt({disableYield:!0}),lt(t=>e.withPermits(c-1)(ro(l,t))),pr(a))}else{let e=yield*Qa(c-2);yield*mt(a,oo(l)),yield*lo(e).pipe($e,y(e=>$a(l,e)),Rt({disableYield:!0}),lt(e=>ro(l,e)),pr(a));let n,r=e=>{e._tag!==`Success`&&(n=e.cause,io(l,e.cause))};yield*s.pipe(y(i=>{if(n)return Pe(n);let a=u(t(i,o++));return d(a),a.addObserver(r),$a(e,ha(a))}),Rt({disableYield:!0}),lt(t=>$a(e,yi(t)).pipe(zr(ro(e,t)))),pr(a))}return lo(l)})),Jo=e=>jo(e,e=>{let t,n=0;return g(Bt(function r(){if(t===void 0)return y(e,e=>{switch(e.length){case 0:return r();case 1:return g(e[0]);default:return t=e,g(e[n++])}});let i=t[n++];return n>=t.length&&(t=void 0,n=0),g(i)}))}),Yo=v(2,(e,t)=>jo(e,e=>g(y(e,function n(r){let i=[];for(let e=0;e<r.length;e++)t(r[e])&&i.push(r[e]);return le(i)?g(i):y(e,n)})))),Xo=e=>Ao((t,n)=>{let r;return g(Bt(()=>r||e.pipe(ct(n),y(e=>Po(e)(t,n)),y(e=>r=e))))}),Zo=v(2,(e,t)=>No((n,r,i)=>bt(i,t).pipe(zr(Po(e)(n,r))))),Qo=v(2,(e,t)=>Zo(e,e=>t)),$o=(e,t,n)=>Bt(()=>{let r=Ke();return si(y(Po(e)(Un(),r),t),n||g).pipe(Sr(e=>At(r,e)))}),es=v(2,(e,t)=>Ao((n,r)=>O(ea(Po(e)(n,r),t),ea(t)))),ts=v(2,(e,t)=>$o(e,e=>Rt(y(e,t),{disableYield:!0}))),ns=w(function*(e){let t=To(1),n=yield*h(),r=Ar(n,Rr);return(yield*Po(e)(Un(),r)).pipe(ea(n),t.withPermits(1))},lt(e=>g(Pe(e)))),rs=(e,t)=>Po(e)(Un(),t),is=`~effect/Stream`,as={_R:_,_E:_,_A:_},os={[is]:as,pipe(){return En(this,arguments)}},ss=e=>{let t=Object.create(os);return t.channel=e,t},cs=`~effect/collections/MutableHashMap`,ls={[cs]:cs,[Symbol.iterator](){return this.backing[Symbol.iterator]()},toString(){return`MutableHashMap(${ta(Array.from(this))})`},toJSON(){return{_id:`MutableHashMap`,values:sa(Array.from(this))}},[Wi](){return this.toJSON()},pipe(){return En(this,arguments)}},us=()=>{let e=Object.create(ls);return e.backing=new Map,e.buckets=new Map,e},ds=v(2,(e,t)=>{if(e.backing.has(t))return A(e.backing.get(t));if(ps(t))return D();let n=fs.get(e);if(n!==void 0)return e.backing.has(n)?A(e.backing.get(n)):D();let r=Lr(t),i=e.buckets.get(r);return i===void 0?D():ms(e,i,t)}),fs=new WeakMap,ps=e=>typeof e!=`object`&&typeof e!=`function`,ms=(e,t,n)=>{for(let r=0,i=t.length;r<i;r++)if(fe(n,t[r])){let i=t[r];return fs.set(n,i),A(e.backing.get(i))}return D()},hs=v(3,(e,t,n)=>{if(e.backing.has(t)||ps(t))return e.backing.set(t,n),e;let r=fs.get(e);if(r!==void 0&&e.backing.has(r))return e.backing.set(r,n),e;let i=Lr(t),a=e.buckets.get(i);return a===void 0?(e.buckets.set(i,[t]),e.backing.set(t,n),e):(r=gs(a,t),r===void 0&&(a.push(t),r=t),e.backing.set(r,n),e)}),gs=(e,t)=>{for(let n=0,r=e.length;n<r;n++)if(fe(t,e[n]))return fs.set(t,e[n]),e[n]},_s=v(2,(e,t)=>{if(ps(t))return e.backing.delete(t),e;let n=fs.get(e)??t,r=Lr(n),i=e.buckets.get(r);if(i===void 0)return e;for(let t=0,r=i.length;t<r;t++){let r=i[t];if(r===n||fe(n,r)){e.backing.delete(r),i.splice(t,1);break}}return i.length===0&&e.buckets.delete(r),e}),vs=`~effect/Stream`,ys=e=>Te(e,vs),bs=ss,xs=e=>e.channel,Ss=(e,t)=>bs(Io(e,t)),Cs=bs(Ro),ws=e=>bs(Lo(()=>e().channel)),Ts=e=>bs(zo(e)),Es=e=>bs(Bo(e)),Ds=e=>bs(Ho(e)),Os=e=>bs(Ao(w(function*(t,n){let r=e.evaluate().getReader();return yield*mt(n,e.releaseLockOnEnd?M(()=>r.releaseLock()):oa(()=>r.cancel())),y(je({try:()=>r.read(),catch:t=>e.onError(t)}),({done:e,value:t})=>e?Un():g(Et(t)))}))),ks=e=>bs(Xo(O(e,xs))),As=v(e=>ys(e[0]),(e,t,n)=>e.channel.pipe(Jo,Go(t,n),Uo(Et),bs)),js=v(2,(e,t)=>bs(Yo(xs(e),t))),Ms=v(2,(e,t)=>bs(Qo(e.channel,t))),Ns=v(2,(e,t)=>bs(es(e.channel,t))),Ps=v(2,(e,t)=>ts(e.channel,t)),Fs=e=>ns(e.channel),Is=v(e=>ys(e[0]),(e,t,n)=>{let r,i,a=xa(!1);return new ReadableStream({start(n){i=_e(ea(Ps(e,e=>a.whenOpen(M(()=>{a.closeUnsafe();for(let t=0;t<e.length;t++)n.enqueue(e[t]);r(),r=void 0}))),t)),i.addObserver(e=>{e._tag===`Failure`?n.error(Er(e.cause)):n.close()})},pull(){return new Promise(e=>{r=e,a.openUnsafe()})},cancel(){if(i)return Ct(jt(_a(i)))}},n?.strategy)}),Ls=v(e=>ys(e[0]),(e,t)=>O(h(),n=>Is(e,n,t))),Rs=e(t(),1),zs=e(It(),1);function Bs(e){return{_tag:`Value`,value:e}}function Vs(e,t){return{_tag:`Record`,keys:e,value:t}}function Hs(e,t){return{_tag:`Array`,length:e,value:t}}$r(`SourceError`);var Us=dr(`effect/ConfigProvider`,{defaultValue:()=>Xs()}),Ws={...qr,toJSON(){return{_id:`ConfigProvider`}}};function Gs(e,t,n){let r=Object.create(Ws);return r.get=e,r.mapInput=t,r.prefix=n,r.load=r=>(t&&(r=t(r)),n&&(r=[...n,...r]),e(r)),r}var Ks=e=>oi(e)?Zn(Us)(e):Ur(Us)(e);function qs(e){return Gs(t=>g(Js(e,t)))}function Js(e,t){let n=e;for(let e of t){if(n==null)return;if(Array.isArray(n)){if(typeof e!=`number`||!Number.isInteger(e)||e<0||e>=n.length)return;n=n[e];continue}if(Vt(n)){if(typeof e!=`string`||!Object.hasOwn(n,e))return;n=n[e];continue}return}return Ys(n)}function Ys(e){if(e!=null)return typeof e==`string`?Bs(e):typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`?Bs(String(e)):Array.isArray(e)?Hs(e.length):Vt(e)?Vs(new Set(Object.keys(e))):Bs(ta(e))}function Xs(e){let t=e?.env??{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`},n=Zs(t);return Gs(e=>g($s(n,t,e)))}function Zs(e){let t={};for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let e=n.split(`_`),i=t;for(let t of e)i.children??={},i=i.children[t]??={};i.value=r}return t}var Qs=/^(0|[1-9][0-9]*)$/;function $s(e,t,n){let r=t[n.map(String).join(`_`)],i=ec(e,n),a=i?.children?Object.keys(i.children):[];return a.length===0?r===void 0?void 0:Bs(r):a.every(e=>Qs.test(e))?Hs(Math.max(...a.map(e=>parseInt(e,10)))+1,r):Vs(new Set(a),r)}function ec(e,t){if(t.length===0)return e;let n=e;for(let e of t)if(n=n?.children?.[String(e)],!n)return;return n}var tc=`~effect/Config`,nc=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},rc={...Ii({label:`Config`,evaluate(e){return this.parse(e.getRef(Us))}}),[tc]:tc,toJSON(){return{_id:`Config`}}};function ic(e){let t=Object.create(rc);return t.parse=e,t}var ac=v(2,(e,t)=>ic(n=>O(e.parse(n),t))),oc=v(2,(e,t)=>ic(n=>ma(e.parse(n),e=>t(e).parse(n))));function sc(e){switch(e._tag){case`MissingKey`:return!0;case`InvalidType`:case`InvalidValue`:return mr(e.actual)||Ni(e.actual)&&e.actual.value===void 0;case`OneOf`:return e.actual===void 0;case`Encoding`:return mr(e.actual)||Ni(e.actual)&&e.actual.value===void 0?!0:sc(e.issue);case`Pointer`:case`Filter`:return sc(e.issue);case`UnexpectedKey`:return!1;case`Forbidden`:return!1;case`Composite`:case`AnyOf`:return e.issues.every(sc)}}var cc=v(2,(e,t)=>oc(e,e=>{if(ur(e.cause)){let n=e.cause.issue;if(sc(n))return mc(t)}return pc(e.cause)})),lc=e=>e.pipe(ac(A),cc(D())),uc=w(function*(e,t){let n=yield*e.load(t);if(n!==void 0)switch(n._tag){case`Value`:return n.value;case`Record`:{if(n.value!==void 0)return n.value;let r={};for(let i of n.keys){let n=yield*uc(e,[...t,i]);n!==void 0&&(r[i]=n)}return r}case`Array`:{if(n.value!==void 0)return n.value;let r=[];for(let i=0;i<n.length;i++)r.push(yield*uc(e,[...t,i]));return r}}}),dc=w(function*(e,t,n){switch(e._tag){case`Objects`:{let r={};for(let i of e.propertySignatures){let e=i.name;if(typeof e==`string`){let a=yield*dc(i.type,t,[...n,e]);a!==void 0&&(r[e]=a)}}if(e.indexSignatures.length>0){let i=yield*t.load(n);if(i&&i._tag===`Record`)for(let a of e.indexSignatures){let e=Qn(a.parameter);for(let o of i.keys)if(!Object.hasOwn(r,o)&&e(o)){let e=yield*dc(a.type,t,[...n,o]);e!==void 0&&(r[o]=e)}}}return r}case`Arrays`:{let r=yield*t.load(n);if(r&&r._tag===`Value`)return r.value;let i=[];for(let r=0;r<e.elements.length;r++)i.push(yield*dc(e.elements[r],t,[...n,r]));return i}case`Union`:return yield*uc(t,n);case`Suspend`:return yield*dc(e.thunk(),t,n);default:{let e=yield*t.load(n);return e===void 0?void 0:e._tag===`Value`||e._tag===`Record`&&e.value!==void 0||e._tag===`Array`&&e.value!==void 0?e.value:void 0}}});function fc(e,t){let n=Vn(e),r=ra(n),i=Yt(n.ast),a=typeof t==`string`?[t]:t??[];return ic(e=>{let t=e.prefix?[...e.prefix,...a]:a;return dc(i,e,a).pipe(bi(e=>r(e).pipe(vr(e=>new la(t.length>0?new be(t,e):e)))),vr(e=>new nc(e)))})}function pc(e){return ic(()=>Sn(new nc(e)))}function mc(e){return ic(()=>g(e))}function hc(e){return fc(T,e)}var gc=`~effect/SubscriptionRef`,_c=e=>Te(e,gc);({...qr});var vc=e=>Ds(e.pubsub),yc=e=>M(()=>e.value),bc=(e,t)=>{e.value=t,za(e.pubsub,t)},xc=v(2,(e,t)=>e.semaphore.withPermit(M(()=>bc(e,t)))),Sc=class extends j()(`effect/reactivity/Reactivity`){},Cc=M(()=>{let e=new Map,t=t=>{kc(t,t=>{let n=e.get(t);n!==void 0&&n.forEach(e=>e())})},n=e=>hn(n=>{let r=n.mapUnsafe.get(wc.key);return r?kc(e,e=>{r.add(e)}):t(e),E}),r=(e,t)=>te(t,n(e)),i=(t,n)=>{let r=[];return kc(t,t=>{r.push(t);let i=e.get(t);i===void 0&&(i=new Set,e.set(t,i)),i.add(n)}),()=>{for(let t=0;t<r.length;t++){let i=e.get(r[t]);i.delete(n),i.size===0&&e.delete(r[t])}}},a=(e,t)=>ei(function*(){let n=yield*h(),r=Ar(n,Rr),a=yield*Za(),o=vi(de(n),ba(r)),s=!1,c=!1,l=e=>{e._tag===`Failure`?io(a,e.cause):eo(a,e.value),c?(c=!1,o(t).addObserver(l)):s=!1};function u(){if(s){c=!0;return}s=!0,o(t).addObserver(l)}return yield*mt(r,M(i(e,u))),u(),a});return Sc.of({mutation:r,query:a,stream:(e,t)=>a(e,t).pipe(O(Es),ks),invalidateUnsafe:t,invalidate:n,registerUnsafe:i,withBatch:t=>Bt(()=>{let n=new Set;return t.pipe(Kt(wc,n),Sr(t=>M(()=>{n.forEach(t=>{let n=e.get(t);n!==void 0&&n.forEach(e=>e())})})))})})}),wc=class extends j()(`effect/reactivity/Reactivity/PendingInvalidation`){},Tc=v(2,(e,t)=>Sc.use(n=>n.mutation(t,e))),Ec=e=>Sc.use(t=>t.invalidate(e)),Dc=Zn(Sc)(Cc);function Oc(e){switch(typeof e){case`string`:case`number`:case`bigint`:case`boolean`:return String(e);default:return Lr(e)}}var kc=(e,t)=>{if(Array.isArray(e)){for(let n=0;n<e.length;n++)t(Oc(e[n]));return}for(let n in e){t(n);let r=e[n];for(let e=0;e<r.length;e++)t(`${n}:${Oc(r[e])}`)}},Ac=`~effect/reactivity/AsyncResult`,jc=e=>Te(e,Ac),Mc={[Ac]:{E:_,A:_},pipe(){return En(this,arguments)},[wt](e){if(this._tag!==e._tag||this.waiting!==e.waiting)return!1;switch(this._tag){case`Initial`:return!0;case`Success`:return fe(this.value,e.value);case`Failure`:return fe(this.cause,e.cause)}},[kt](){let e=pt(`${this._tag}:${this.waiting}`);return this._tag===`Initial`?e:u(e)(this._tag===`Success`?Lr(this.value):Lr(this.cause))}},Nc=e=>e.waiting,Pc=(e,t)=>e._tag===`Success`?N(e.value):Hc(e.cause,{previous:t}),Fc=e=>e._tag===`None`?Rc(!0):Wc(e.value),Ic=e=>e._tag===`Initial`,Lc=e=>e._tag!==`Initial`,Rc=(e=!1)=>{let t=Object.create(Mc);return t._tag=`Initial`,t.waiting=e,t},zc=e=>e._tag===`Success`,N=(e,t)=>{let n=Object.create(Mc);return n._tag=`Success`,n.value=e,n.waiting=t?.waiting??!1,n.timestamp=t?.timestamp??Date.now(),n},Bc=e=>e._tag===`Failure`,Vc=(e,t)=>{let n=Object.create(Mc);return n._tag=`Failure`,n.cause=e,n.previousSuccess=t?.previousSuccess??D(),n.waiting=t?.waiting??!1,n},Hc=(e,t)=>Vc(e,{previousSuccess:Ye(t.previous,e=>zc(e)?A(e):Bc(e)?e.previousSuccess:D()),waiting:t.waiting}),Uc=(e,t)=>Hc(ai(e),t),Wc=(e,t)=>{if(e.waiting)return t?.touch?Gc(e):e;let n=Object.assign(Object.create(Mc),e);return n.waiting=!0,t?.touch&&zc(n)&&(n.timestamp=Date.now()),n},Gc=e=>zc(e)?N(e.value,{waiting:e.waiting}):e,Kc=(e,t)=>e._tag===`Failure`?Hc(e.cause,{previous:t,waiting:e.waiting}):e,qc=e=>e._tag===`Success`?A(e.value):e._tag===`Failure`?ti(e.previousSuccess,e=>e.value):D(),Jc=e=>Nt(qc(e),()=>new Si(`AsyncResult.getOrThrow: no value found`)),Yc=e=>{switch(e._tag){case`Success`:return Lt(e.value);case`Failure`:return yi(e.cause);default:return it(new Si)}},Xc=v(2,(e,t)=>{switch(e._tag){case`Initial`:return e;case`Failure`:return Vc(e.cause,{previousSuccess:ti(e.previousSuccess,e=>N(t(e.value),e)),waiting:e.waiting});case`Success`:return N(t(e.value),e)}}),Zc=e=>{let t=e.success??nn,n=e.error??nn,r=Ei()([t,He(n,S)],([e,t])=>(n,r,i)=>{if(!jc(n))return Sn(new tn(r,A(n)));switch(n._tag){case`Initial`:return g(n);case`Success`:return Ri(ra(e)(n.value,i),{onSuccess:e=>N(e,n),onFailure:e=>new Zi(r,A(n),[new be([`value`],e)])});case`Failure`:{let a=n.previousSuccess.pipe(ti(t=>Ri(ra(e)(t.value,i),{onSuccess:e=>A(N(e,t)),onFailure:e=>new Zi(r,A(n),[new be([`previousSuccess`,`value`],e)])})),Pn(()=>st)),o=vr(ra(t)(n.cause,i),e=>new Zi(r,A(n),[new be([`cause`],e)]));return bi(a,e=>sr(o,t=>Vc(t,{previousSuccess:e,waiting:n.waiting})))}}},{expected:`AsyncResult`,toCodec([e,t]){let n=Mt(`Success`,{value:e,waiting:xe,timestamp:et});return br()(gr([Mt(`Initial`,{waiting:xe}),n,Mt(`Failure`,{cause:t,previousSuccess:mi(n),waiting:xe})]),ce({decode:e=>{switch(e._tag){case`Initial`:return Rc(e.waiting);case`Success`:return N(e.value,{waiting:e.waiting,timestamp:e.timestamp});case`Failure`:return Vc(e.cause,{previousSuccess:ti(e.previousSuccess,e=>N(e.value,e)),waiting:e.waiting})}},encode(e){switch(e._tag){case`Initial`:return{_tag:`Initial`,waiting:e.waiting};case`Success`:return{_tag:`Success`,value:e.value,waiting:e.waiting,timestamp:e.timestamp};case`Failure`:return{_tag:`Failure`,cause:e.cause,previousSuccess:e.previousSuccess,waiting:e.waiting}}}}))},toEquivalence:ve,toFormatter:([e,t])=>n=>{switch(n._tag){case`Success`:return`AsyncResult.Success(${e(n.value)}, ${n.waiting}, ${n.timestamp})`;case`Failure`:return`AsyncResult.Failure(${t(n.cause)}, ${n.waiting})`;case`Initial`:return`AsyncResult.Initial(${n.waiting}, ${n.waiting})`}}});return Object.assign(r,{success:t,error:n})},Qc=`~effect/reactivity/AtomRegistry`,$c=e=>Te(e,Qc),el=e=>new sl(e?.initialValues,e?.scheduleTask,e?.timeoutResolution,e?.defaultIdleTTL),tl=j(Qc),nl=v(e=>$c(e[0]),(e,t,n)=>{let r=n?.suspendOnWaiting??!1;return qe(n=>{let i=e.get(t);if(i._tag!==`Initial`&&!(r&&i.waiting))return n(Yc(i));let a=e.subscribe(t,e=>{e._tag!==`Initial`&&!(r&&e.waiting)&&(n(Yc(e)),a())});return M(a)})}),rl={immediate:!0},il=e=>{e()},al=`~effect-atom/atom/Atom/Serializable`,ol=e=>al in e?e[al].key:e,sl=class{[Qc];timeoutResolution;defaultIdleTTL;scheduler;schedulerAsync;dispatcher;onNodeAdded;onNodeRemoved;constructor(e,t,n,r){if(this[Qc]=Qc,this.scheduler=new Ae(`sync`,t),this.schedulerAsync=new Ae(`async`,t),this.dispatcher=this.schedulerAsync.makeDispatcher(),this.defaultIdleTTL=r,n===void 0&&r!==void 0?this.timeoutResolution=Math.round(r/2):this.timeoutResolution=n??1e3,e!==void 0)for(let[t,n]of e){let e=t;for(;e.initialValueTarget;)e=e.initialValueTarget;this.ensureNode(e).setInitialValue(n)}}nodes=new Map;preloadedSerializable=new Map;timeoutBuckets=new Map;nodeTimeoutBucket=new Map;disposed=!1;getNodes(){return this.nodes}get(e){return this.ensureNode(e).value()}set(e,t){e.write(this.ensureNode(e).writeContext,t)}setSerializable(e,t){this.preloadedSerializable.set(e,t)}modify(e,t){let n=this.ensureNode(e),r=t(n.value());return e.write(n.writeContext,r[1]),r[0]}update(e,t){let n=this.ensureNode(e);e.write(n.writeContext,t(n.value()))}refresh=e=>{e.refresh===void 0?this.invalidateAtom(e):e.refresh(this.refresh)};subscribe(e,t,n){let r=this.ensureNode(e);n?.immediate&&t(r.value());let i=r.subscribe(function(){t(r._value)});return()=>{i(),r.canBeRemoved&&this.scheduleNodeRemoval(r)}}mount(e){return this.subscribe(e,bn,rl)}atomHasTtl(e){return!e.keepAlive&&e.idleTTL!==0&&(e.idleTTL!==void 0||this.defaultIdleTTL!==void 0)}ensureNode(e){let t=ol(e),n=this.nodes.get(t);if(n===void 0?(n=this.createNode(e),this.nodes.set(t,n),this.onNodeAdded?.(n)):this.atomHasTtl(e)&&this.removeNodeTimeout(n),typeof t==`string`&&this.preloadedSerializable.has(t)){let r=this.preloadedSerializable.get(t);this.preloadedSerializable.delete(t);let i=e[al].decode(r);n.setValue(i)}return n}createNode(e){if(this.disposed)throw Error(`Cannot access Atom ${e}: registry is disposed`);return e.keepAlive||this.scheduleAtomRemoval(e),new ll(this,e)}invalidateAtom=e=>{this.ensureNode(e).invalidate()};scheduleAtomRemoval(e){this.dispatcher.scheduleTask(()=>{let t=this.nodes.get(ol(e));t!==void 0&&t.canBeRemoved&&this.removeNode(t)},0)}scheduleNodeRemoval(e){this.dispatcher.scheduleTask(()=>{e.canBeRemoved&&this.removeNode(e)},0)}removeNode(e){this.atomHasTtl(e.atom)?this.setNodeTimeout(e):(this.nodes.delete(ol(e.atom)),e.remove(),this.onNodeRemoved?.(e))}setNodeTimeout(e){if(this.nodeTimeoutBucket.has(e))return;let t=e.atom.idleTTL??this.defaultIdleTTL;if(this.#e!==null&&(t-=this.#e,t<=0)){this.nodes.delete(ol(e.atom)),e.remove(),this.onNodeRemoved?.(e);return}let n=Math.ceil(t/this.timeoutResolution)*this.timeoutResolution,r=Date.now()+n,i=r-r%this.timeoutResolution+this.timeoutResolution,a=this.timeoutBuckets.get(i);a===void 0&&(a=[new Set,setTimeout(()=>this.sweepBucket(i),i-Date.now())],this.timeoutBuckets.set(i,a)),a[0].add(e),this.nodeTimeoutBucket.set(e,i)}removeNodeTimeout(e){let t=this.nodeTimeoutBucket.get(e);if(t===void 0)return;this.nodeTimeoutBucket.delete(e),this.scheduleNodeRemoval(e);let[n,r]=this.timeoutBuckets.get(t);n.delete(e),n.size===0&&(clearTimeout(r),this.timeoutBuckets.delete(t))}#e=null;sweepBucket(e){let t=this.timeoutBuckets.get(e)[0];this.timeoutBuckets.delete(e),t.forEach(e=>{this.nodeTimeoutBucket.delete(e),e.canBeRemoved&&(this.nodes.delete(ol(e.atom)),this.onNodeRemoved?.(e),this.#e=e.atom.idleTTL??this.defaultIdleTTL,e.remove(),this.#e=null)})}reset(){this.timeoutBuckets.forEach(([,e])=>clearTimeout(e)),this.timeoutBuckets.clear(),this.nodeTimeoutBucket.clear(),this.nodes.forEach(e=>{e.remove(),this.onNodeRemoved?.(e)}),this.nodes.clear()}dispose(){this.disposed=!0,this.reset()}},cl={alive:1,initialized:2,waitingForValue:4},P={uninitialized:cl.alive|cl.waitingForValue,stale:cl.alive|cl.initialized|cl.waitingForValue,valid:cl.alive|cl.initialized,removed:0},ll=class{constructor(e,t){this.registry=e,this.atom=t,this.writeContext=new pl(e,this)}registry;atom;state=P.uninitialized;lifetime;writeContext;preserveInitialValueOnBuild=!1;parents=[];previousParents;children=[];listeners=new Set;skipInvalidation=!1;currentState(){switch(this.state){case P.uninitialized:return`uninitialized`;case P.stale:return`stale`;case P.valid:return`valid`;default:return`removed`}}get canBeRemoved(){return!this.atom.keepAlive&&this.listeners.size===0&&this.children.length===0&&this.state!==0}_value=void 0;value(){if((this.state&cl.waitingForValue)!==0){this.lifetime=fl(this);let e=this.atom.read(this.lifetime);if((this.state&cl.waitingForValue)!==0&&(this.preserveInitialValueOnBuild?(this.preserveInitialValueOnBuild=!1,this.state=P.valid):this.setValue(e)),this.previousParents){let e=this.previousParents;this.previousParents=void 0;for(let t=0;t<e.length;t++)e[t].removeChild(this),e[t].canBeRemoved&&this.registry.scheduleNodeRemoval(e[t])}}return this._value}valueOption(){return(this.state&cl.initialized)===0?D():A(this._value)}setInitialValue(e){if((this.state&cl.initialized)===0){this.preserveInitialValueOnBuild=!0,this.state=P.stale,this._value=e,F.phase===ml.collect?F.notify.add(this):this.notify();return}this.setValue(e)}setValue(e){if((this.state&cl.initialized)===0){this.state=P.valid,this._value=e,F.phase===ml.collect?F.notify.add(this):this.notify();return}this.state=P.valid,!Object.is(this._value,e)&&(this._value=e,this.skipInvalidation?this.skipInvalidation=!1:this.invalidateChildren(),this.listeners.size>0&&(F.phase===ml.collect?F.notify.add(this):this.notify()))}addParent(e){if(this.parents.push(e),this.previousParents!==void 0){let t=this.previousParents.indexOf(e);t!==-1&&(this.previousParents[t]=this.previousParents[this.previousParents.length-1],this.previousParents.pop()===void 0&&(this.previousParents=void 0))}e.children.indexOf(this)===-1&&(e.children.push(this),e.skipInvalidation&&=!1)}removeChild(e){let t=this.children.indexOf(e);t!==-1&&(this.children[t]=this.children[this.children.length-1],this.children.pop())}invalidate(){this.state===P.valid&&(this.state=P.stale,this.disposeLifetime()),F.phase===ml.collect?F.stale.push(this):this.atom.lazy&&this.listeners.size===0&&!ul(this.children)?(this.invalidateChildren(),this.skipInvalidation=!0):this.value()}invalidateChildren(){if(this.children.length===0)return;let e=this.children;this.children=[];for(let t=0;t<e.length;t++)e[t].invalidate()}notify(){this.listeners.forEach(il),F.phase===ml.commit&&F.notify.delete(this)}disposeLifetime(){this.lifetime!==void 0&&(this.lifetime.dispose(),this.lifetime=void 0),this.parents.length!==0&&(this.previousParents=this.parents,this.parents=[])}remove(){if(this.state=P.removed,this.listeners.clear(),this.lifetime===void 0||(this.disposeLifetime(),this.previousParents===void 0))return;let e=this.previousParents;this.previousParents=void 0;for(let t=0;t<e.length;t++)e[t].removeChild(this),e[t].canBeRemoved&&this.registry.removeNode(e[t])}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}};function ul(e){if(e.length===0)return!1;let t=e,n,r=0;for(;t!==void 0;){for(let e=0,r=t.length;e<r;e++){let r=t[e];if(!r.atom.lazy||r.listeners.size>0)return!0;r.children.length>0&&(n===void 0?n=[r.children]:n.push(r.children))}t=n?.[r++]}return!1}var dl={get registry(){return this.node.registry},addFinalizer(e){if(this.disposed)return e();this.finalizers??=[],this.finalizers.push(e)},get(e){if(this.disposed)return this.node.registry.get(e);let t=this.node.registry.ensureNode(e);return this.node.addParent(t),t.value()},result(e,t){if(this.disposed||this.isFn)return this.resultOnce(e,t);let n=this.get(e);if(t?.suspendOnWaiting&&n.waiting)return Xr;switch(n._tag){case`Initial`:return Xr;case`Failure`:return yi(n.cause);case`Success`:return g(n.value)}},resultOnce(e,t){return qe(n=>{let r=this.once(e);if(r._tag!==`Initial`&&!(t?.suspendOnWaiting&&r.waiting))return n(Yc(r));let i=this.node.registry.subscribe(e,e=>{e._tag===`Initial`||t?.suspendOnWaiting&&e.waiting||(i(),n(Yc(e)))},{immediate:!1});return M(i)})},setResult(e,t){return this.disposed?Xr:(this.node.registry.set(e,t),this.resultOnce(e,{suspendOnWaiting:!0}))},some(e){if(this.disposed||this.isFn)return this.someOnce(e);let t=this.get(e);return t._tag===`None`?Xr:g(t.value)},someOnce(e){return qe(t=>{let n=this.once(e);if(Ni(n))return t(g(n.value));let r=this.node.registry.subscribe(e,e=>{mr(e)||(r(),t(g(e.value)))},{immediate:!1});return M(r)})},once(e){return this.node.registry.get(e)},self(){return this.disposed?D():this.node.valueOption()},refresh(e){this.disposed||this.node.registry.refresh(e)},refreshSelf(){this.disposed||this.node.invalidate()},mount(e){this.disposed||this.addFinalizer(this.node.registry.mount(e))},subscribe(e,t,n){this.disposed||this.addFinalizer(this.node.registry.subscribe(e,t,n))},setSelf(e){this.disposed||this.node.setValue(e)},set(e,t){this.disposed||this.node.registry.set(e,t)},stream(e,t){return this.disposed?Cs:Ss(n=>M(()=>{this.subscribe(e,e=>eo(n,e),{immediate:!t?.withoutInitialValue})}))},streamResult(e,t){return this.stream(e,t).pipe(js(Lc),As(e=>e._tag===`Success`?g(e.value):Pe(e.cause)))},dispose(){if(this.disposed=!0,this.finalizers===void 0)return;let e=this.finalizers;this.finalizers=void 0;for(let t=e.length-1;t>=0;t--)e[t]()}},fl=e=>{function t(n){if(t.disposed||t.isFn)return e.registry.get(n);let r=e.registry.ensureNode(n),i=r.value();return e.addParent(r),i}return Object.setPrototypeOf(t,dl),t.isFn=!1,t.disposed=!1,t.finalizers=void 0,t.node=e,t},pl=class{constructor(e,t){this.registry=e,this.node=t}registry;node;get(e){return this.registry.get(e)}set(e,t){return this.registry.set(e,t)}setSelf(e){return this.node.setValue(e)}refreshSelf(){return this.node.invalidate()}},ml={disabled:0,collect:1,commit:2},F={phase:ml.disabled,depth:0,stale:[],notify:new Set};function hl(e){F.phase=ml.collect,F.depth++;try{if(e(),F.depth===1){for(let e=0;e<F.stale.length;e++)gl(F.stale[e]);F.phase=ml.commit;for(let e of F.notify)e.notify();F.notify.clear()}}finally{F.depth--,F.depth===0&&(F.phase=ml.disabled,F.stale=[])}}function gl(e){if(e.state!==P.valid){for(let t=0;t<e.parents.length;t++){let n=e.parents[t];n.state!==P.valid&&gl(n)}e.state!==P.valid&&e.value()}}var _l=`~effect/reactivity/Atom`,vl=e=>Te(e,_l),yl=`~effect/reactivity/Atom/Writable`,bl=v(2,(e,t)=>{let n=wn(t),i=Fn(n);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!i,idleTTL:i?r(n):void 0})}),xl=bl(0),Sl={[_l]:_l,...qr,toJSON(){return{_id:`Atom`,keepAlive:this.keepAlive,lazy:this.lazy,label:this.label}}},Cl={...Sl,atom(e,t){let n=jl(e,t);return Dl(e=>{let t=e.self(),r=e(this);return r._tag===`Success`?n(e,r.value):Kc(r,t)})},fn(e,t){return arguments.length===0?(e,t)=>wl(this,e,t):wl(this,e,t)},pull(e,t){let n=xl(Pl(0));return Yl(n,Dl(r=>{let i=r.self(),a=r(this);return a._tag===`Success`?Il(r,Jl(r,n,e,t),Rc(!0),a.value):Kc(a,i)}))},subscriptionRef(e){return Hl(xl(Dl(t=>{let n=t.self(),r=t(this);if(r._tag!==`Success`)return Kc(r,n);let i=typeof e==`function`?e(t):e;return _c(i)?i:Il(t,i,Rc(!0),r.value)})),(e,t)=>Vl(e,t,Jc(e(this))))}},wl=(e,t,n)=>{let[r,i,a]=ql(n?.reactivityKeys?(e,r)=>{let i=t(e,r);return oi(i)?Tc(i,n.reactivityKeys):Ms(i,Ec(n.reactivityKeys))}:t,n);return Ol(t=>{t.get(a);let n=t.self(),i=t.get(e);return i._tag===`Success`?r(t,i.value):Kc(i,n)},i)},Tl={...Sl,[yl]:yl},El=e=>yl in e,Dl=(e,t)=>{let n=Object.create(Sl);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.refresh=t,n},Ol=(e,t,n)=>{let r=Object.create(Tl);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.write=t,r.refresh=n,r};function kl(e,t){e.setSelf(t)}var Al=(e,t)=>{let n=jl(e,t);return`~effect/reactivity/Atom`in n?n:Dl(n)},jl=(e,t)=>{if(typeof e==`function`&&!oi(e)&&!ys(e)){let n=e;return function(e,r){let i=n(e);switch(typeof i){case`function`:case`object`:return i===null?i:Ml in i?Fl(e,i,t,r):Nl in i?zl(e,i,t,r):i;default:return i}}}else if(oi(e))return function(n,r){return Fl(n,e,t,r)};else if(ys(e))return function(n,r){return zl(n,e,t,r)};return Pl(e)},Ml=`~effect/Effect`,Nl=`~effect/Stream`,Pl=e=>Ol(function(t){return e},kl),Fl=(e,t,n,r)=>Il(e,t,n?.initialValue===void 0?Rc():N(n.initialValue),r,n?.uninterruptible);function Il(e,t,n,r=xi(),i=!1){let o=e.self(),s=Ke();e.addFinalizer(()=>{de(r)(At(s,a))});let c=new Map(r.mapUnsafe);c.set(Rr.key,s),c.set(tl.key,e.registry),c.set(nt.key,e.registry.scheduler);let l,u=!1,d=Ll($n(c),t,function(t){l=Pc(t,o),u&&e.setSelf(l)},i);return u=!0,d!==void 0&&e.addFinalizer(d),l===void 0?o._tag===`Some`?Fc(o):Wc(n):l}function Ll(e,t,n,r=!1){if(Mn(t)){n(t);return}let i=de(e)(t);i.currentDispatcher?.flush();let a=i.pollUnsafe();if(a){n(a);return}let o=i.addObserver(n);function s(){o(),r||i.interruptUnsafe()}return s}var Rl=(e=>{let t=Dc;function n(r){let i=Object.create(Cl);i.keepAlive=!1,i.lazy=!0,i.refresh=void 0,i.factory=n;let a=Zl(Dl(typeof r==`function`?e=>Tt(r(e),t):()=>Tt(r,t)));return i.layer=a,i.read=function(t){let n=t(a);return Fl(t,y(ft,t=>ca(n,e.memoMap,t)),{uninterruptible:!0})},i}n.memoMap=e.memoMap,n.addGlobalLayer=e=>{t=Tt(t,pe(e,Dc))};let r=xl(Al(hn(t=>ca(Dc,e.memoMap,Ar(t,Rr))).pipe(O(Ar(Sc)))));return n.withReactivity=e=>t=>$l(t,n=>{let i=Jc(n(r));return n.addFinalizer(i.registerUnsafe(e,()=>{n.refresh(t)})),n.subscribe(t,e=>n.setSelf(e)),n.once(t)},{initialValueTarget:t}),n})({memoMap:Xi()});Rl.withReactivity;var zl=(e,t,n,r)=>Bl(e,t,n?.initialValue===void 0?Rc():N(n.initialValue),r);function Bl(e,t,n,r=xi()){let a=e.self();r=Qr(r,tl,e.registry);let o=vt(n=>y(rs(t.channel,n),t=>i({while:ze,body:()=>t,step(t){e.setSelf(N(s(t),{waiting:!0}))}}))).pipe(lt(t=>(rr(t)?jn(e.self(),Ye(qc),wi({onNone:()=>e.setSelf(Uc(new Si,{previous:e.self()})),onSome:t=>e.setSelf(N(t))})):e.setSelf(Hc(t,{previous:e.self()})),E))),c=new Map(r.mapUnsafe);c.set(tl.key,e.registry),c.set(nt.key,e.registry.scheduler);let l=Ll($n(c),o,bn,!1);return l!==void 0&&e.addFinalizer(l),a._tag===`Some`?Fc(a):Wc(n)}var Vl=(e,t,n=xi())=>_c(t)?(e.addFinalizer(vc(t).pipe(Ps(t=>{for(let n=0;n<t.length;n++)e.setSelf(t[n]);return E}),Qt(n))),Ir(n)(yc(t))):t._tag===`Success`?Bl(e,vc(t.value),Rc(!0),n):t,Hl=(e,t)=>{function n(t,n){let r=t.get(e);_c(r)?l(xc(r,n)):zc(r)&&l(xc(r.value,n))}return Ol(n=>{let r=n(e);return _c(r)||zc(r)?t(n,r):r},n)},Ul=Symbol.for(`effect/reactivity/atom/Atom/Reset`),Wl=Symbol.for(`effect/reactivity/atom/Atom/Interrupt`),Gl=function(...e){return e.length===0?Kl:Kl(...e)},Kl=(e,t)=>{let[n,r]=ql(e,t);return Ol(n,r)};function ql(e,t){let n=xl(Pl([0,void 0])),r=t?.initialValue===void 0?Rc():N(t.initialValue),i=t?.concurrent?xl(Dl(e=>{let t=new Set;return e.addFinalizer(()=>t.forEach(e=>e.interruptUnsafe())),t})):void 0;function a(t,a){let s=i?t(i):void 0;t.isFn=!0;let[c,l]=t.get(n);if(c===0)return r;if(l===Wl)return Hc(or(),{previous:t.self()});let u=e(l,t);return Ml in u?(s&&(u=y(o(u,{startImmediately:!0}),e=>(s.add(e),e.addObserver(()=>s.delete(e)),O(ga(s),e=>e[0])))),Il(t,u,r,a,!1)):Bl(t,u,r,a)}function s(e,t){iu(()=>{t===Ul?e.set(n,[0,void 0]):t===Wl?e.set(n,[e.get(n)[0]+1,Wl]):e.set(n,[e.get(n)[0]+1,t]),e.refreshSelf()})}return[a,s,n]}var Jl=(e,t,n,r)=>y(Fs(typeof n==`function`?n(e):n),n=>{let i=ya().context,a=Vi(),o=di(n,{onFailure(e){return rr(e)?le(a)?g({done:!0,items:a}):Sn(new Si(`Atom.pull: no items`)):Pe(e)},onSuccess(e){let t;return r?.disableAccumulation?t=e:(t=li(a,e),a=t),g({done:!1,items:t})}}),s=new Set;return e.addFinalizer(()=>{for(let e of s)e()}),e.once(t),e.subscribe(t,()=>{e.setSelf(Fc(e.self()));let t;t=Ll(i,o,n=>{t&&s.delete(t);let r=Pc(n,e.self()),i=s.size>0;e.setSelf(i?Wc(r):r)}),t&&s.add(t)}),o}),Yl=(e,t)=>Ol(t.read,function(t,n){t.set(e,t.get(e)+1)}),Xl=typeof WeakRef>`u`||typeof FinalizationRegistry>`u`?e=>{let t=us();return function(n){let r=ds(t,n);if(r._tag===`Some`)return r.value;let i=e(n);return hs(t,n,i),i}}:e=>{let t=us(),n=new FinalizationRegistry(e=>{_s(t,e)});return function(r){let i=ds(t,r).pipe(On(e=>e.deref()));if(i._tag===`Some`)return i.value;let a=e(r);return hs(t,r,new WeakRef(a)),n.register(a,r),a}},Zl=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0}),Ql=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!1}),$l=v(e=>vl(e[0]),(e,t,n)=>{let r=xl(El(e)?Ol(n=>t(n,e),function(t,n){t.set(e,n)},e.refresh??function(t){t(e)}):Dl(n=>t(n,e),e.refresh??function(t){t(e)}));return n?.initialValueTarget&&(r.initialValueTarget=eu(n.initialValueTarget)),r}),eu=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t},tu=v(2,(e,t)=>$l(e,n=>t(n(e)))),nu=e=>{let t=0,r=xl(Pl([t,void 0]));return Ol(t=>{let i=t.once(e),a=!1;t.subscribe(e,e=>{if(i=e,o.size>0)return;if(a=!1,!jc(e))return t.setSelf(e);let r=n(t.self());switch(e._tag){case`Initial`:Ic(r)&&t.setSelf(e);return;case`Success`:zc(r)?!e.waiting&&e.timestamp>=r.timestamp&&t.setSelf(e):t.setSelf(e);return;case`Failure`:return t.setSelf(e)}});let o=new Set,s=new Set;return t.subscribe(r,([,n])=>{if(o.has(n))return;o.add(n);let r;r=t.registry.subscribe(n,c=>{if(zc(c)&&c.waiting)return t.setSelf(c.value);o.delete(n),r&&(s.delete(r),r()),!a&&!Bc(c)&&(a=!0),o.size===0&&(a?(a=!1,t.refresh(e)):t.setSelf(i))},{immediate:!0}),o.has(n)?s.add(r):r()}),t.addFinalizer(()=>{for(let e of s)e();o.clear(),s.clear()}),i},(e,n)=>e.set(r,[++t,n]),t=>t(e))},ru=v(2,(e,t)=>{let n=xl(Pl(Rc()));return Gl((r,i)=>{let a=t.reducer(i(e),r);jc(a)&&(a=Wc(a,{touch:!0})),i.set(n,N(a,{waiting:!0})),i.set(e,n);let o=typeof t.fn==`function`?Ql(t.fn(e=>i.set(n,N(jc(e)?Wc(e):e,{waiting:!0})))):t.fn;return i.set(o,r),qe(e=>{i.subscribe(o,t=>{t._tag===`Initial`||t.waiting||(i.set(n,Xc(t,()=>a)),e(Yc(t)))},{immediate:!0})})})}),iu=hl,au=`~effect-atom/atom/Atom/Serializable`,ou=v(2,(e,t)=>{let n=wr(t.schema);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:e.label??[t.key,Error().stack?.split(`
2
+ `)[5]??``],[au]:{key:t.key,encode:Jr(n),decode:Nr(n)}})}),su=`~effect-atom/atom/Atom/ServerValue`,cu=v(2,(e,t)=>`~effect-atom/atom/Atom/ServerValue`in e?e[su](e=>t.get(e)):t.get(e));function lu(e){let t=zs.unstable_scheduleCallback(4,e);return()=>zs.unstable_cancelCallback(t)}var uu=Rs.createContext(el({scheduleTask:lu,defaultIdleTTL:400})),du=new WeakMap;function fu(e,t){let n=du.get(e);n===void 0&&(n=new WeakMap,du.set(e,n));let r=n.get(t);if(r!==void 0)return r;let i={subscribe(n){return e.subscribe(t,n)},snapshot(){return e.get(t)},getServerSnapshot(){return cu(t,e)}};return n.set(t,i),i}function pu(e,t){let n=fu(e,t);return Rs.useSyncExternalStore(n.subscribe,n.snapshot,n.getServerSnapshot)}var mu=(e,t)=>{let n=Rs.useContext(uu);return t?pu(n,Rs.useMemo(()=>tu(e,t),[e,t])):pu(n,e)};function hu(e,t){Rs.useEffect(()=>e.mount(t),[t,e])}function gu(e,t,n){return n?.mode===`promise`||n?.mode===`promiseExit`?Rs.useCallback(r=>{e.set(t,r);let i=Vr(nl(e,t,{suspendOnWaiting:!0}));return n.mode===`promise`?i.then(_u):i},[e,t,n.mode]):Rs.useCallback(n=>{e.set(t,typeof n==`function`?n(e.get(t)):n)},[e,t])}var _u=e=>{if(In(e))return e.value;throw Er(e.cause)},vu=(e,t)=>{let n=Rs.useContext(uu);return hu(n,e),gu(n,e,t)},yu=e=>{let t=Rs.useContext(uu);return hu(t,e),Rs.useCallback(()=>{t.refresh(e)},[t,e])},bu=(e,t)=>{let n=Rs.useContext(uu);return[pu(n,e),gu(n,e,t)]},xu={suspendOnWaiting:new Map,default:new Map};function Su(e,t,n){let r=n?xu.suspendOnWaiting:xu.default,i=r.get(t);return i===void 0?(i=new Promise(i=>{let a=e.subscribe(t,e=>{e._tag===`Initial`||n&&e.waiting||(setTimeout(a,1e3),i(),r.delete(t))})}),r.set(t,i),i):i}function Cu(e,t,n){let r=pu(e,t);if(r._tag===`Initial`||n&&r.waiting)throw Su(e,t,n);return r}var wu=(e,t)=>{let n=Cu(Rs.useContext(uu),e,t?.suspendOnWaiting??!1);if(n._tag===`Failure`&&!t?.includeFailure)throw Er(n.cause);return n},Tu=Symbol.for(`~effect/http/Headers`),Eu=Object.create(null);Object.defineProperties(Eu,{[Tu]:{value:Tu},[oe]:{value(e){return Iu(this,Ar(e,Lu))}},toJSON:{value(){return qt(this)}},[wt]:{value(e){return Ou(this,e)}},[kt]:{value(){return yt(this)}},toString:{value:Cr.toString},[Wi]:{value:Cr[Wi]}});var Du=e=>Object.assign(Object.create(Eu),e),Ou=da($t()),ku=Object.create(Eu),Au=e=>{if(e===void 0)return ku;if(Symbol.iterator in e){let t=Object.create(Eu);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(Eu);for(let[n,r]of Object.entries(e))Array.isArray(r)?t[n.toLowerCase()]=r.join(`, `):r!==void 0&&(t[n.toLowerCase()]=r);return t},ju=e=>Object.setPrototypeOf(e,Eu),Mu=v(3,(e,t,n)=>{let r=Du(e);return r[t.toLowerCase()]=n,r}),Nu=v(2,(e,t)=>Du({...e,...Au(t)})),Pu=v(2,(e,t)=>{let n=Du(e);return Object.assign(n,t),n}),Fu=v(2,(e,t)=>{let n=Du(e);return delete n[t.toLowerCase()],n}),Iu=v(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=me(e[r]))}else for(let r in e)t.test(r)&&(n[r]=me(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),Lu=dr(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),Ru=`~effect/http/UrlParams`,zu={...qr,[Ru]:Ru,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:`UrlParams`,params:Object.fromEntries(this.params)}},[wt](e){return Uu(this,e)},[kt](){return Hr(this.params.flat())}},Bu=e=>{let t=Object.create(zu);return t.params=e,t},Vu=e=>{let t=Hu(e),n=[];for(let e=0;e<t.length;e++)if(Array.isArray(t[e][0])){let[r,i]=t[e];n.push([`${r[0]}[${r.slice(1).join(`][`)}]`,i])}else n.push(t[e]);return Bu(n)},Hu=e=>{let t=typeof e[Symbol.iterator]==`function`?Ki(e):Object.entries(e),n=[];for(let[e,r]of t)if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]!==void 0&&n.push([e,String(r[t])]);else if(typeof r==`object`){let t=Hu(r);for(let[r,i]of t)n.push([[e,...typeof r==`string`?[r]:r],i])}else r!==void 0&&n.push([e,String(r)]);return n},Uu=Yi((e,t)=>Wu(e.params,t.params)),Wu=ut(Ie([$t(),$t()])),Gu=Bu([]),Ku=v(2,(e,t)=>{let n=Vu(t),r=n.params,i=new Set;for(let e=0;e<r.length;e++)i.add(r[e][0]);for(let t=0;t<e.params.length;t++)i.has(e.params[t][0])||r.push(e.params[t]);return n}),qu=class extends $r(`UrlParamsError`){},Ju=(e,t,n)=>{try{let r=new URL(e,Yu());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,i)}return n!==void 0&&(r.hash=n),hi(r)}catch(e){return rn(new qu({cause:e}))}},Yu=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},Xu=`~effect/http/HttpBody`;$r(`HttpBodyError`);var Zu=class{[Xu];constructor(){this[Xu]=Xu}[Wi](){return this.toJSON()}toString(){return ta(this,{ignoreToString:!0})}},Qu=new class extends Zu{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},$u=`~effect/http/Cookies`,ed=`~effect/http/Cookies/Cookie`;$r(`CookieError`);var td={[$u]:$u,...Cr,toJSON(){return{_id:`effect/Cookies`,cookies:m(this.cookies,e=>e.toJSON())}},pipe(){return En(this,arguments)}},nd=e=>{let t=Object.create(td);return t.cookies=e,t},rd=e=>{let t={};for(let n of e)t[n.name]=n;return nd(t)},id=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=ad(e.trim());t&&n.push(t)}return rd(n)};function ad(e){let t=e.split(`;`).map(e=>e.trim()).filter(e=>e!==``);if(t.length===0)return;let n=t[0].indexOf(`=`);if(n===-1)return;let r=t[0].slice(0,n);if(!od.test(r))return;let i=t[0].slice(n+1),a=cd(i);if(t.length===1)return Object.assign(Object.create(sd),{name:r,value:a,valueEncoded:i});let o={};for(let e=1;e<t.length;e++){let n=t[e],r=n.indexOf(`=`),i=r===-1?n:n.slice(0,r).trim(),a=r===-1?void 0:n.slice(r+1).trim();switch(i.toLowerCase()){case`domain`:{if(a===void 0)break;let e=a.trim().replace(/^\./,``);e&&(o.domain=e);break}case`expires`:{if(a===void 0)break;let e=new Date(a);isNaN(e.getTime())||(o.expires=e);break}case`max-age`:{if(a===void 0)break;let e=parseInt(a,10);isNaN(e)||(o.maxAge=Pt(e));break}case`path`:if(a===void 0)break;a[0]===`/`&&(o.path=a);break;case`priority`:if(a===void 0)break;switch(a.toLowerCase()){case`low`:o.priority=`low`;break;case`medium`:o.priority=`medium`;break;case`high`:o.priority=`high`;break}break;case`httponly`:o.httpOnly=!0;break;case`secure`:o.secure=!0;break;case`partitioned`:o.partitioned=!0;break;case`samesite`:if(a===void 0)break;switch(a.toLowerCase()){case`lax`:o.sameSite=`lax`;break;case`strict`:o.sameSite=`strict`;break;case`none`:o.sameSite=`none`;break}break}}return Object.assign(Object.create(sd),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var od=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,sd={[ed]:ed,...Cr,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},cd=e=>{try{return decodeURIComponent(e)}catch{return e}},ld=`~effect/http/HttpClientError`,ud=class extends $r(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[ld]=ld;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},dd=e=>e.endsWith(`Error`)?e.slice(0,-5):e,fd=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,pd=class extends $r(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return fd(dd(this._tag),this.description,this.methodAndUrl)}};$r(`EncodeError`);var md=class extends $r(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return fd(dd(this._tag),this.description,this.methodAndUrl)}};$r(`StatusCodeError`);var hd=class extends $r(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return fd(dd(this._tag),this.description,e)}},gd=class extends $r(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return fd(dd(this._tag),this.description,e)}},_d=class e extends ua(ld)({_tag:kr(`HttpError`),kind:Fe([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:k(S)}){static fromHttpClientError(t){return new e({_tag:`HttpError`,kind:t.reason._tag,cause:t.reason})}},vd=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`]],yd=`~effect/http/HttpClientRequest`,bd={[yd]:yd,...Cr,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:qt(this.headers),body:this.body.toJSON()}},pipe(){return En(this,arguments)}};function xd(e,t,n,r,i,a){let o=Object.create(bd);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var Sd=xd(`GET`,``,Gu,D(),ku,Qu),Cd=e=>(t,n)=>wd(Sd,{method:e,url:t,...n??void 0}),wd=v(2,(e,t)=>{let n=e;return t.method&&(n=Td(n,t.method)),t.url&&(n=Ad(n,t.url)),t.headers&&(n=Dd(n,t.headers)),t.urlParams&&(n=jd(n,t.urlParams)),t.hash&&(n=Md(n,t.hash)),t.body&&(n=Nd(n,t.body)),t.accept&&(n=Od(n,t.accept)),t.acceptJson&&(n=kd(n)),n}),Td=v(2,(e,t)=>xd(t,e.url,e.urlParams,e.hash,e.headers,e.body)),Ed=v(3,(e,t,n)=>xd(e.method,e.url,e.urlParams,e.hash,Mu(e.headers,t,n),e.body)),Dd=v(2,(e,t)=>xd(e.method,e.url,e.urlParams,e.hash,Nu(e.headers,t),e.body)),Od=v(2,(e,t)=>Ed(e,`Accept`,t)),kd=Od(`application/json`),Ad=v(2,(e,t)=>{if(typeof t==`string`)return xd(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Vu(n.searchParams),i=Cn(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,xd(e.method,n.toString(),r,i,e.headers,e.body)}),jd=v(2,(e,t)=>xd(e.method,e.url,Ku(e.urlParams,t),e.hash,e.headers,e.body)),Md=v(2,(e,t)=>xd(e.method,e.url,e.urlParams,A(t),e.headers,e.body)),Nd=v(2,(e,t)=>{let n=e.headers;return t._tag===`Empty`||t._tag===`FormData`?n=Fu(Fu(n,`Content-Type`),`Content-length`):(t.contentType&&(n=Mu(n,`content-type`,t.contentType)),t.contentLength!==void 0&&(n=Mu(n,`content-length`,t.contentLength.toString()))),xd(e.method,e.url,e.urlParams,e.hash,n,t)}),Pd=`~effect/http/HttpIncomingMessage`,Fd=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=l(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=l(e.text)}catch{}let i={...t,headers:qt(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},Id=`~effect/http/HttpClientResponse`,Ld=(e,t)=>new Rd(e,t),Rd=class extends Bn{[Pd];[Id];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[Pd]=Pd,this[Id]=Id}toJSON(){return Fd(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get headers(){return Au(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=id(this.source.headers.getSetCookie())}get remoteAddress(){return D()}get stream(){return this.source.body?Os({evaluate:()=>this.source.body,onError:e=>new ud({reason:new hd({request:this.request,response:this,cause:e})})}):Ts(new ud({reason:new gd({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return y(this.text,e=>rt({try:()=>e===``?null:JSON.parse(e),catch:e=>new ud({reason:new hd({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody?this.textBody:(this.textBody=je({try:()=>this.source.text(),catch:e=>new ud({reason:new hd({request:this.request,response:this,cause:e})})}).pipe(De,l),this.arrayBufferBody=O(this.textBody,e=>new TextEncoder().encode(e).buffer),this.textBody)}get urlParamsBody(){return y(this.text,e=>rt({try:()=>Vu(new URLSearchParams(e)),catch:e=>new ud({reason:new hd({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=je({try:()=>this.source.formData(),catch:e=>new ud({reason:new hd({request:this.request,response:this,cause:e})})}).pipe(De,l)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody?this.arrayBufferBody:(this.arrayBufferBody=je({try:()=>this.source.arrayBuffer(),catch:e=>new ud({reason:new hd({request:this.request,response:this,cause:e})})}).pipe(De,l),this.textBody=O(this.arrayBufferBody,e=>new TextDecoder().decode(e)),this.arrayBufferBody)}pipe(){return En(this,arguments)}},zd=e=>ju({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${wi(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),Bd=`~effect/http/HttpClient`,Vd=j(`effect/HttpClient`),Hd=v(2,(e,t)=>Ud(n=>t(e.postprocess(n)),e.preprocess)),Ud=(e,t)=>{let n=Object.create(Wd);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},Wd={[Bd]:Bd,pipe(){return En(this,arguments)},...Cr,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(vd.map(([e,t])=>[t,function(t,n){return this.execute(Cd(e)(t,n))}]))},Gd=e=>Ud(t=>y(t,t=>hr(r=>{let i=Zd.get(t),a=i??new AbortController,o=Ju(t.url,t.urlParams,n(t.hash));if(ke(o))return Sn(new ud({reason:new md({request:t,cause:o.failure})}));let s=o.success;if(r.getRef(ee)||r.getRef(Kd)(t)){let n=e(t,s,a.signal,r);return i?n:Ze(e=>di(e(n),{onSuccess(e){return Xd.register(e,a),g(new Qd(e,a))},onFailure(e){return Kr(e)&&a.abort(),Pe(e)}}))}return Tn(r.getRef(Jd)(t),{kind:`client`},n=>{n.attribute(`http.request.method`,t.method),n.attribute(`server.address`,s.origin),s.port!==``&&n.attribute(`server.port`,+s.port),n.attribute(`url.full`,s.toString()),n.attribute(`url.path`,s.pathname),n.attribute(`url.scheme`,s.protocol.slice(0,-1));let o=s.search.slice(1);o!==``&&n.attribute(`url.query`,o);let c=r.getRef(Lu),l=Iu(t.headers,c);for(let e in l)n.attribute(`http.request.header.${e}`,String(l[e]));return t=r.getRef(qd)?Dd(t,zd(n)):t,Ze(o=>o(e(t,s,a.signal,r)).pipe(Pi(n,{captureStackTrace:!1}),di({onSuccess:e=>{n.attribute(`http.response.status_code`,e.status);let t=Iu(e.headers,c);for(let e in t)n.attribute(`http.response.header.${e}`,String(t[e]));return i?g(e):(Xd.register(e,a),g(new Qd(e,a)))},onFailure(e){return!i&&Kr(e)&&a.abort(),Pe(e)}})))})})),g),Kd=dr(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>pn}),qd=dr(`effect/HttpClient/TracerPropagationEnabled`,{defaultValue:ze}),Jd=dr(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),Yd=e=>Zn(Vd)(hn(t=>O(e,e=>Hd(e,An(e=>Gr(t,e)))))),Xd=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),Zd=new WeakMap,Qd=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[Id]=Id;[Pd]=Pd;applyInterrupt(e){return Bt(()=>(Xd.unregister(this.original),zn(e,()=>M(()=>{this.controller.abort()}))))}get request(){return this.original.request}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return ws(()=>(Xd.unregister(this.original),Ms(this.original.stream,M(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Wi](){return this.original[Wi]()}pipe(){return En(this,arguments)}},$d=`~effect/FiberSet`,ef=e=>Te(e,$d),tf={[$d]:$d,[Symbol.iterator](){return this.state._tag===`Closed`?un():this.state.backing[Symbol.iterator]()},...qr,toJSON(){return{_id:`FiberMap`,state:this.state}}},nf=(e,t)=>{let n=Object.create(tf);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},rf=()=>Wr(M(()=>nf(new Set,xn())),e=>Bt(()=>{let t=e.state;if(t._tag===`Closed`)return E;e.state={_tag:`Closed`};let n=t.backing;return va(n).pipe(sn(e.deferred))})),af=-1,of=kn(gi(Oi,Xe(af))),sf=v(e=>ef(e[0]),(e,t,n)=>{if(e.state._tag===`Closed`){t.interruptUnsafe(af);return}else if(e.state.backing.has(t))return;e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),Dn(r)&&(n?.propagateInterruption===!0?!of(r.cause):!Li(r.cause))&&mn(e.deferred,r))})}),cf=function(){let e;return()=>(e===void 0&&(e=_e(jr)),e)}(),lf=e=>()=>O(h(),t=>{let n=de(t);return(t,r)=>{if(e.state._tag===`Closed`)return cf();let i=n(t,r);return sf(e,i),i}}),uf=e=>re(e.deferred),df=`~effect/socket/Socket`,ff=j(`effect/socket/Socket`),pf=e=>ff.of({[df]:df,runRaw:e.runRaw,run:e.run??((t,n)=>e.runRaw(e=>typeof e==`string`?t(mf.encode(e)):e instanceof Uint8Array?t(e):t(new Uint8Array(e)),n)),runString:e.runString??(e.run?(t,n)=>e.run(e=>t(hf.decode(e)),n):(t,n)=>e.runRaw(e=>typeof e==`string`?t(e):e instanceof Uint8Array?t(hf.decode(e)):t(hf.decode(new Uint8Array(e))),n)),writer:e.writer}),mf=new TextEncoder,hf=new TextDecoder,gf=`~effect/socket/Socket/CloseEvent`,_f=e=>Te(e,gf),vf=`~effect/socket/Socket/SocketError`,yf=e=>Te(e,vf),bf=class extends ua(`effect/socket/Socket/SocketReadError`)({_tag:kr(`SocketReadError`),cause:S}){message=`An error occurred during Read`},xf=class extends ua(`effect/socket/Socket/SocketWriteError`)({_tag:kr(`SocketWriteError`),cause:S}){message=`An error occurred during Write`},Sf=class extends ua(`effect/socket/Socket/SocketOpenError`)({_tag:kr(`SocketOpenError`),kind:Fe([`Unknown`,`Timeout`]),cause:S}){get message(){return this.kind===`Timeout`?`timeout waiting for "open"`:`An error occurred during Open`}},Cf=class extends ua(`effect/socket/Socket/SocketCloseError`)({_tag:kr(`SocketCloseError`),code:et,closeReason:k(T)}){static filterClean(e){return function(t){return Tf.is(t)&&t.reason._tag===`SocketCloseError`&&e(t.reason.code)?hi(t.reason):rn(t)}}get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},wf=gr([bf,xf,Sf,Cf]),Tf=class extends Nn(vf)(`SocketError`,{_tag:kr(`SocketError`),reason:wf}){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[vf]=vf;static is(e){return yf(e)}message=this.reason.message},Ef=e=>!0,Df=class extends j()(`~effect/socket/Socket/WebSocket`){},Of=class extends j()(`@effect/platform/Socket/WebSocketConstructor`){},kf=Ur(Of)((e,t)=>new globalThis.WebSocket(e,t)),Af=(e,t)=>Of.use(n=>jf(Wr((typeof e==`string`?g(e):e).pipe(O(e=>n(e,t?.protocols))),e=>M(()=>e.close(1e3))),t)),jf=(e,t)=>hr(n=>{let r,i=xa(!1),a=n.context,o=t?.closeCodeIsError??Ef;return g(pf({runRaw:(n,s)=>vt(w(function*(a){let c=yield*rf().pipe(ct(a)),l=yield*ct(e,a),u=yield*Kt(lf(c)(),Df,l),d=!1;function f(e){if(e.data instanceof Blob)return u(y(oa(()=>e.data.arrayBuffer()),e=>{let t=n(new Uint8Array(e));return oi(t)?t:E}));let t=n(e.data);oi(t)&&u(t)}function p(e){l.removeEventListener(`message`,f),l.removeEventListener(`close`,m),mn(c.deferred,Sn(new Tf({reason:d?new bf({cause:e}):new Sf({kind:`Unknown`,cause:e})})))}function m(e){let t=typeof e.code==`number`?e.code:1001;l.removeEventListener(`message`,f),l.removeEventListener(`error`,p),mn(c.deferred,Sn(new Tf({reason:new Cf({code:t,closeReason:e.reason})})))}if(l.addEventListener(`close`,m,{once:!0}),l.addEventListener(`error`,p,{once:!0}),l.addEventListener(`message`,f),l.readyState!==1){let e=xn();l.addEventListener(`open`,()=>{d=!0,mn(e,E)},{once:!0}),yield*re(e).pipe(yn({duration:t?.openTimeout??1e4,orElse:()=>Sn(new Tf({reason:new Sf({kind:`Timeout`,cause:Error(`timeout waiting for "open"`)})}))}),ae(uf(c)))}return d=!0,r=l,i.openUnsafe(),s?.onOpen&&(yield*s.onOpen),yield*Ut(uf(c),Cf.filterClean(e=>!o(e)),()=>E)})).pipe(An(e=>Gr(a,e)),cn(M(()=>{i.closeUnsafe(),r=void 0}))),writer:g(e=>i.whenOpen(M(()=>{let t=r;_f(e)?t.close(e.code,e.reason):t.send(e)})))}))}),Mf=vi(Af,Zn(ff)),Nf=class extends j()(`effect/workers/Transferable/Collector`){},Pf=()=>{let e=[],t=t=>{e.push(...t)},n=()=>e,r=()=>{let t=e;return e=[],t};return Nf.of({addAllUnsafe:t,addAll:e=>M(()=>t(e)),readUnsafe:n,read:M(n),clearUnsafe:r,clear:M(r)})},Ff=`~effect/workers/WorkerError`,If=gr([class extends ua(`effect/workers/WorkerError/WorkerSpawnError`)({_tag:kr(`WorkerSpawnError`),message:T,cause:k(S)}){},class extends ua(`effect/workers/WorkerError/WorkerSendError`)({_tag:kr(`WorkerSendError`),message:T,cause:k(S)}){},class extends ua(`effect/workers/WorkerError/WorkerReceiveError`)({_tag:kr(`WorkerReceiveError`),message:T,cause:k(S)}){},class extends ua(`effect/workers/WorkerError/WorkerUnknownError`)({_tag:kr(`WorkerUnknownError`),message:T,cause:k(S)}){}]);ua(Ff)({_tag:kr(`WorkerError`),reason:If});var Lf=`~effect/interfaces/PrimaryKey`,Rf=`~effect/rpc/RpcSchema/StreamSchema`;function zf(e){return Te(e,Rf)}function Bf(e){return zf(e)?A({success:e.success,error:e.error}):D()}var Vf=ri(ys);function Hf(e,t){return pi(Vf.ast,{[Rf]:Rf,success:e,error:t})}j()(`effect/rpc/RpcSchema/ClientAbort`);var Uf=`~effect/rpc/Rpc`,Wf={[Uf]:Uf,pipe(){return En(this,arguments)},setSuccess(e){return Gf({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return Gf({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return Gf({_tag:this._tag,payloadSchema:Bi(e)?e:C(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return Gf({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},prefix(e){return Gf({_tag:`${e}${this._tag}`,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},annotate(e,t){return Gf({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:Qr(this.annotations,e,t)})},annotateMerge(e){return Gf({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:Gr(this.annotations,e)})}},Gf=e=>{function t(){}return Object.setPrototypeOf(t,Wf),Object.assign(t,e),t.key=`effect/rpc/Rpc/${e._tag}`,t},I=(e,t)=>{let n=t?.success??Fi,r=t?.error??nn,i=t?.defect??S,a;return a=t?.primaryKey?class extends b(`effect/rpc/Rpc/${e}`)(t.payload){[Lf](){return t.primaryKey(this)}}:Bi(t?.payload)?t?.payload:t?.payload?C(t?.payload):Fi,Gf({_tag:e,payloadSchema:a,successSchema:t?.stream?Hf(n,r):n,errorSchema:t?.stream?nn:r,defectSchema:i,annotations:xi(),middlewares:new Set})},Kf=new WeakMap,qf=e=>{if(Kf.has(e))return Kf.get(e);let t=e,n=new Set([t.errorSchema]),r=Bf(t.successSchema);Ni(r)&&n.add(r.value.error);for(let e of t.middlewares)n.add(e.error);let i=p(Ni(r)?Fi:t.successSchema,gr([...n]),t.defectSchema);return Kf.set(e,i),i},Jf=`~effect/rpc/Rpc/Wrapper`,Yf=e=>Jf in e,Xf=`~effect/rpc/RpcClientError`,Zf=class extends ua(`effect/rpc/RpcClientError/RpcClientDefect`)({_tag:kr(`RpcClientDefect`),message:T,cause:S}){},Qf=class extends ua(Xf)({_tag:kr(`RpcClientError`),reason:gr([If,wf,_d,Zf])}){[Xf]=Xf;get message(){return`${this.reason._tag}: ${this.reason.message}`}},$f=e=>typeof e==`bigint`?e:BigInt(e),ep={_tag:`Ping`},tp;try{tp=new TextDecoder}catch{}var L,np,R=0,rp=[],ip=rp,ap=0,z={},B,op,sp=0,cp=0,V,lp,H=[],U,up={useRecords:!1,mapsAsObjects:!0},dp=class{},fp=new dp;fp.name=`MessagePack 0xC1`;var pp=!1,mp=2,hp=class e{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=0&&(e.structures=[],e.maxSharedStructures||=0)),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType=`number`)),Object.assign(this,e)}unpack(t,n){if(L)return Hp(()=>(Up(),this?this.unpack(t,n):e.prototype.unpack.call(up,t,n)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<`u`?Buffer.from(t):new Uint8Array(t)),typeof n==`object`?(np=n.end||t.length,R=n.start||0):(R=0,np=n>-1?n:t.length),ap=0,cp=0,op=null,ip=rp,V=null,L=t;try{U=t.dataView||=new DataView(t.buffer,t.byteOffset,t.byteLength)}catch(e){throw L=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(z=this,this.structures)return B=this.structures,gp(n);(!B||B.length>0)&&(B=[])}else z=up,(!B||B.length>0)&&(B=[]);return gp(n)}unpackMultiple(e,t){let n,r=0;try{pp=!0;let i=e.length,a=this?this.unpack(e,i):Gp.unpack(e,i);if(t){if(t(a,r,R)===!1)return;for(;R<i;)if(r=R,t(gp(),r,R)===!1)return}else{for(n=[a];R<i;)r=R,n.push(gp());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{pp=!1,Up()}}_mergeStructures(e,t){this._onLoadedStructures&&(e=this._onLoadedStructures(e)),e||=[],Object.isFrozen(e)&&(e=e.map(e=>e.slice(0)));for(let t=0,n=e.length;t<n;t++){let n=e[t];n&&(n.isShared=!0,t>=32&&(n.highByte=t-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let r=e[n],i=t[n];i&&(r&&((e.restoreStructures||=[])[n]=r),e[n]=i)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function gp(e){try{if(!z.trusted&&!pp){let e=B.sharedLength||0;e<B.length&&(B.length=e)}let t;if(z._readStruct&&L[R]<64&&L[R]>=32?(t=z._readStruct(L,R,np),L=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),R=np):t=W(),V&&=(R=V.postBundlePosition,null),pp&&(B.restoreStructures=null),R==np)B&&B.restoreStructures&&_p(),B=null,L=null,lp&&=null;else if(R>np)throw Error(`Unexpected end of MessagePack data`);else if(!pp){let e;try{e=JSON.stringify(t,(e,t)=>typeof t==`bigint`?`${t}n`:t).slice(0,100)}catch(t){e=`(JSON view not available `+t+`)`}throw Error(`Data read, but end of buffer not reached `+e)}return t}catch(e){throw B&&B.restoreStructures&&_p(),Up(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`)||R>np)&&(e.incomplete=!0),e}}function _p(){for(let e in B.restoreStructures)B[e]=B.restoreStructures[e];B.restoreStructures=null}function W(){let e=L[R++];if(e<160)if(e<128){if(e<64)return e;{let t=B[e&63]||z.getStructures&&xp()[e&63];return t?(t.read||=yp(t,e&63),t.read()):e}}else if(e<144)if(e-=128,z.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=Fp();e===`__proto__`&&(e=`__proto_`),t[e]=W()}return t}else{let t=new Map;for(let n=0;n<e;n++)t.set(W(),W());return t}else{e-=144;let t=Array(e);for(let n=0;n<e;n++)t[n]=W();return z.freezeData?Object.freeze(t):t}else if(e<192){let t=e-160;if(cp>=R)return op.slice(R-sp,(R+=t)-sp);if(cp==0&&np<140){let e=t<16?Ap(t):kp(t);if(e!=null)return e}return Sp(t)}else{let t;switch(e){case 192:return null;case 193:return V?(t=W(),t>0?V[1].slice(V.position1,V.position1+=t):V[0].slice(V.position0,V.position0-=t)):fp;case 194:return!1;case 195:return!0;case 196:if(t=L[R++],t===void 0)throw Error(`Unexpected end of buffer`);return Mp(t);case 197:return t=U.getUint16(R),R+=2,Mp(t);case 198:return t=U.getUint32(R),R+=4,Mp(t);case 199:return Np(L[R++]);case 200:return t=U.getUint16(R),R+=2,Np(t);case 201:return t=U.getUint32(R),R+=4,Np(t);case 202:if(t=U.getFloat32(R),z.useFloat32>2){let e=Wp[(L[R]&127)<<1|L[R+1]>>7];return R+=4,(e*t+(t>0?.5:-.5)>>0)/e}return R+=4,t;case 203:return t=U.getFloat64(R),R+=8,t;case 204:return L[R++];case 205:return t=U.getUint16(R),R+=2,t;case 206:return t=U.getUint32(R),R+=4,t;case 207:return z.int64AsType===`number`?(t=U.getUint32(R)*4294967296,t+=U.getUint32(R+4)):z.int64AsType===`string`?t=U.getBigUint64(R).toString():z.int64AsType===`auto`?(t=U.getBigUint64(R),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=U.getBigUint64(R),R+=8,t;case 208:return U.getInt8(R++);case 209:return t=U.getInt16(R),R+=2,t;case 210:return t=U.getInt32(R),R+=4,t;case 211:return z.int64AsType===`number`?(t=U.getInt32(R)*4294967296,t+=U.getUint32(R+4)):z.int64AsType===`string`?t=U.getBigInt64(R).toString():z.int64AsType===`auto`?(t=U.getBigInt64(R),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=U.getBigInt64(R),R+=8,t;case 212:if(t=L[R++],t==114)return Lp(L[R++]&63);{let e=H[t];if(e)return e.read?(R++,e.read(W())):e.noBuffer?(R++,e()):e(L.subarray(R,++R));throw Error(`Unknown extension `+t)}case 213:return t=L[R],t==114?(R++,Lp(L[R++]&63,L[R++])):Np(2);case 214:return Np(4);case 215:return Np(8);case 216:return Np(16);case 217:return t=L[R++],cp>=R?op.slice(R-sp,(R+=t)-sp):Cp(t);case 218:return t=U.getUint16(R),R+=2,cp>=R?op.slice(R-sp,(R+=t)-sp):wp(t);case 219:return t=U.getUint32(R),R+=4,cp>=R?op.slice(R-sp,(R+=t)-sp):Tp(t);case 220:return t=U.getUint16(R),R+=2,Dp(t);case 221:return t=U.getUint32(R),R+=4,Dp(t);case 222:return t=U.getUint16(R),R+=2,Op(t);case 223:return t=U.getUint32(R),R+=4,Op(t);default:if(e>=224)return e-256;if(e===void 0){let e=Error(`Unexpected end of MessagePack data`);throw e.incomplete=!0,e}throw Error(`Unknown MessagePack token `+e)}}}var vp=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function yp(e,t){function n(){if(n.count++>mp){let r;try{r=e.read=Function(`r`,`return function(){return `+(z.freezeData?`Object.freeze`:``)+`({`+e.map(e=>e===`__proto__`?`__proto_:r()`:vp.test(e)?e+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`})}`)(W)}catch{return mp=1/0,n()}return e.highByte===0&&(e.read=bp(t,e.read)),r()}let r={};for(let t=0,n=e.length;t<n;t++){let n=e[t];n===`__proto__`&&(n=`__proto_`),r[n]=W()}return z.freezeData?Object.freeze(r):r}return n.count=0,e.highByte===0?bp(t,n):n}var bp=(e,t)=>function(){let n=L[R++];if(n===0)return t();let r=e<32?-(e+(n<<5)):e+(n<<5),i=B[r]||xp()[r];if(!i)throw Error(`Record id is not defined for `+r);return i.read||=yp(i,e),i.read()};function xp(){let e=Hp(()=>(L=null,z.getStructures()));return B=z._mergeStructures(e,B)}var Sp=Ep,Cp=Ep,wp=Ep,Tp=Ep;function Ep(e){let t;if(e<16&&(t=Ap(e)))return t;if(e>64&&tp)return tp.decode(L.subarray(R,R+=e));let n=R+e,r=[];for(t=``;R<n;){let e=L[R++];if(!(e&128))r.push(e);else if((e&224)==192){let t=L[R++]&63,n=(e&31)<<6|t;n<128?r.push(65533):r.push(n)}else if((e&240)==224){let t=L[R++]&63,n=L[R++]&63,i=(e&31)<<12|t<<6|n;i<2048||i>=55296&&i<=57343?r.push(65533):r.push(i)}else if((e&248)==240){let t=L[R++]&63,n=L[R++]&63,i=L[R++]&63,a=(e&7)<<18|t<<12|n<<6|i;a<65536||a>1114111?r.push(65533):a>65535?(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023,r.push(a)):r.push(a)}else r.push(65533);r.length>=4096&&(t+=G.apply(String,r),r.length=0)}return r.length>0&&(t+=G.apply(String,r)),t}function Dp(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=W();return z.freezeData?Object.freeze(t):t}function Op(e){if(z.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=Fp();e===`__proto__`&&(e=`__proto_`),t[e]=W()}return t}else{let t=new Map;for(let n=0;n<e;n++)t.set(W(),W());return t}}var G=String.fromCharCode;function kp(e){let t=R,n=Array(e);for(let r=0;r<e;r++){let e=L[R++];if((e&128)>0){R=t;return}n[r]=e}return G.apply(String,n)}function Ap(e){if(e<4)if(e<2){if(e===0)return``;{let e=L[R++];if((e&128)>1){--R;return}return G(e)}}else{let t=L[R++],n=L[R++];if((t&128)>0||(n&128)>0){R-=2;return}if(e<3)return G(t,n);let r=L[R++];if((r&128)>0){R-=3;return}return G(t,n,r)}else{let t=L[R++],n=L[R++],r=L[R++],i=L[R++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){R-=4;return}if(e<6){if(e===4)return G(t,n,r,i);{let e=L[R++];if((e&128)>0){R-=5;return}return G(t,n,r,i,e)}}else if(e<8){let a=L[R++],o=L[R++];if((a&128)>0||(o&128)>0){R-=6;return}if(e<7)return G(t,n,r,i,a,o);let s=L[R++];if((s&128)>0){R-=7;return}return G(t,n,r,i,a,o,s)}else{let a=L[R++],o=L[R++],s=L[R++],c=L[R++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){R-=8;return}if(e<10){if(e===8)return G(t,n,r,i,a,o,s,c);{let e=L[R++];if((e&128)>0){R-=9;return}return G(t,n,r,i,a,o,s,c,e)}}else if(e<12){let l=L[R++],u=L[R++];if((l&128)>0||(u&128)>0){R-=10;return}if(e<11)return G(t,n,r,i,a,o,s,c,l,u);let d=L[R++];if((d&128)>0){R-=11;return}return G(t,n,r,i,a,o,s,c,l,u,d)}else{let l=L[R++],u=L[R++],d=L[R++],f=L[R++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){R-=12;return}if(e<14){if(e===12)return G(t,n,r,i,a,o,s,c,l,u,d,f);{let e=L[R++];if((e&128)>0){R-=13;return}return G(t,n,r,i,a,o,s,c,l,u,d,f,e)}}else{let p=L[R++],m=L[R++];if((p&128)>0||(m&128)>0){R-=14;return}if(e<15)return G(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let ee=L[R++];if((ee&128)>0){R-=15;return}return G(t,n,r,i,a,o,s,c,l,u,d,f,p,m,ee)}}}}}function jp(){let e=L[R++],t;if(e<192)t=e-160;else switch(e){case 217:t=L[R++];break;case 218:t=U.getUint16(R),R+=2;break;case 219:t=U.getUint32(R),R+=4;break;default:throw Error(`Expected string`)}return Ep(t)}function Mp(e){return z.copyBuffers?Uint8Array.prototype.slice.call(L,R,R+=e):L.subarray(R,R+=e)}function Np(e){let t=L[R++];if(H[t]){let n;return H[t](L.subarray(R,n=R+=e),e=>{R=e;try{return W()}finally{R=n}})}else throw Error(`Unknown extension type `+t)}var Pp=Array(4096);function Fp(){let e=L[R++];if(e>=160&&e<192){if(e-=160,cp>=R)return op.slice(R-sp,(R+=e)-sp);if(!(cp==0&&np<180))return Sp(e)}else return R--,Ip(W());let t=(e<<5^(e>1?U.getUint16(R):e>0?L[R]:0))&4095,n=Pp[t],r=R,i=R+e-3,a,o=0;if(n&&n.bytes==e){for(;r<i;){if(a=U.getUint32(r),a!=n[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(a=L[r++],a!=n[o++]){r=1879048192;break}if(r===i)return R=r,n.string;i-=3,r=R}for(n=[],Pp[t]=n,n.bytes=e;r<i;)a=U.getUint32(r),n.push(a),r+=4;for(i+=3;r<i;)a=L[r++],n.push(a);let s=e<16?Ap(e):kp(e);return s==null?n.string=Sp(e):n.string=s}function Ip(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;if(z.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(e=>[`string`,`number`,`boolean`,`bigint`].includes(typeof e)))return e.flat().toString();throw Error(`Invalid property type for record: ${typeof e}`)}var Lp=(e,t)=>{let n=W().map(Ip),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,n.highByte=t);let i=B[e];return i&&(i.isShared||pp)&&((B.restoreStructures||=[])[e]=i),B[e]=n,n.read=yp(n,r),n.read()};H[0]=()=>{},H[0].noBuffer=!0,H[66]=e=>{let t=e.byteLength%8||8,n=BigInt(e[0]&128?e[0]-256:e[0]);for(let r=1;r<t;r++)n<<=BigInt(8),n+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=(e,t)=>{let n=t-e;if(n<=40){let n=r.getBigUint64(e);for(let i=e+8;i<t;i+=8)n<<=BigInt(64),n|=r.getBigUint64(i);return n}let a=e+(n>>4<<3),o=i(e,a),s=i(a,t);return o<<BigInt((t-a)*8)|s};n=n<<BigInt((r.byteLength-t)*8)|i(t,r.byteLength)}return n};var Rp={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError==`function`?AggregateError:null};H[101]=()=>{let e=W();if(!Rp[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return Rp[e[0]](e[1],{cause:e[2]})},H[105]=e=>{if(z.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=U.getUint32(R-4);lp||=new Map;let n=L[R],r;r=n>=144&&n<160||n==220||n==221?[]:n>=128&&n<144||n==222||n==223?new Map:(n>=199&&n<=201||n>=212&&n<=216)&&L[R+1]===115?new Set:{};let i={target:r};lp.set(t,i);let a=W();if(i.used)Object.assign(r,a);else return i.target=a;if(r instanceof Map)for(let[e,t]of a.entries())r.set(e,t);if(r instanceof Set)for(let e of Array.from(a))r.add(e);return r},H[112]=e=>{if(z.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=U.getUint32(R-4),n=lp.get(t);return n.used=!0,n.target},H[115]=()=>new Set(W());var zp=[`Int8`,`Uint8`,`Uint8Clamped`,`Int16`,`Uint16`,`Int32`,`Uint32`,`Float32`,`Float64`,`BigInt64`,`BigUint64`].map(e=>e+`Array`),Bp=typeof globalThis==`object`?globalThis:window;H[116]=e=>{let t=e[0],n=Uint8Array.prototype.slice.call(e,1).buffer,r=zp[t];if(!r){if(t===16)return n;if(t===17)return new DataView(n);throw Error(`Could not find typed array for code `+t)}return new Bp[r](n)},H[120]=()=>{let e=W();return new RegExp(e[0],e[1])};var Vp=[];H[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],n=R;return R+=t-e.length,V=Vp,V=[jp(),jp()],V.position0=0,V.position1=0,V.postBundlePosition=R,R=n,W()},H[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date(`invalid`);function Hp(e){z&&z._onSaveState&&z._onSaveState();let t=np,n=R,r=ap,i=sp,a=cp,o=op,s=ip,c=lp,l=V,u=new Uint8Array(L.slice(0,np)),d=B,f=B.slice(0,B.length),p=z,m=pp,ee=e();return np=t,R=n,ap=r,sp=i,cp=a,op=o,ip=s,lp=c,V=l,L=u,pp=m,B=d,B.splice(0,B.length,...f),z=p,U=new DataView(L.buffer,L.byteOffset,L.byteLength),ee}function Up(){L=null,lp=null,B=null}var Wp=Array(147);for(let e=0;e<256;e++)Wp[e]=+(`1e`+Math.floor(45.15-e*.30103));var Gp=new hp({useRecords:!1});Gp.unpack,Gp.unpackMultiple,Gp.unpack;var Kp={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};new Uint8Array(new Float32Array(1).buffer,0,4),hp.SUPPORTS_STRUCT_HOOKS=!0;var qp;try{qp=new TextEncoder}catch{}var Jp,Yp,Xp=typeof Buffer<`u`,Zp=Xp?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,Qp=Xp?Buffer:Uint8Array,$p=Xp?4294967296:2144337920,K,em,q,J=0,Y,X=null,tm=21760,nm=/[\u0080-\uFFFF]/,rm=Symbol(`record-id`),im=class extends hp{constructor(e){super(e),this.offset=0;let t,n,r,i,a=Qp.prototype.utf8Write?function(e,t){return K.utf8Write(e,t,K.byteLength-t)}:qp&&qp.encodeInto?function(e,t){return qp.encodeInto(e,K.subarray(t)).written}:!1,o=this;e||={};let s=e&&e.sequential,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?32:0,l>8160)throw Error(`Maximum maxSharedStructure is 8160`);e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let u=e.maxOwnStructures;u??=c?32:64,!this.structures&&e.useRecords!=0&&(this.structures=[]);let d=l>32||u+l>64,f=l+64,p=l+u+64;if(p>8256)throw Error(`Maximum maxSharedStructure + maxOwnStructure is 8192`);let m=[],ee=0,te=0;this.pack=this.encode=function(e,a){if(K||(K=new Zp(8192),q=K.dataView||=new DataView(K.buffer,0,8192),J=0),Y=K.length-10,Y-J<2048?(K=new Zp(K.length),q=K.dataView||=new DataView(K.buffer,0,K.length),Y=K.length-10,J=0):J=J+7&2147483640,t=J,a&2048&&(J+=a&255),i=o.structuredClone?new Map:null,o.bundleStrings&&typeof e!=`string`?(X=[],X.size=1/0):X=null,r=o.structures,r){r.uninitialized&&(r=o._mergeStructures(o.getStructures()));let e=r.sharedLength||0;if(e>l)throw Error(`Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to `+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let t=0;t<e;t++){let e=r[t];if(!e)continue;let n,i=r.transitions;for(let t=0,r=e.length;t<r;t++){let r=e[t];n=i[r],n||=i[r]=Object.create(null),i=n}i[rm]=t+64}this.lastNamedStructuresLength=e}s||(r.nextId=e+64)}n&&=!1;let c;try{o._writeStruct&&e&&typeof e==`object`?e.constructor===Object?ce(e):e.constructor!==Map&&!Array.isArray(e)&&!Yp.some(t=>e instanceof t)?ce(e.toJSON?e.toJSON():e):h(e):h(e);let n=X;if(X&&lm(t,h,0),i&&i.idsToInsert){let e=i.idsToInsert.sort((e,t)=>e.offset>t.offset?1:-1),r=e.length,a=-1;for(;n&&r>0;){let i=e[--r].offset+t;i<n.stringsPosition+t&&a===-1&&(a=0),i>n.position+t?a>=0&&(a+=6):(a>=0&&(q.setUint32(n.position+t,q.getUint32(n.position+t)+a),a=-1),n=n.previous,r++)}a>=0&&n&&q.setUint32(n.position+t,q.getUint32(n.position+t)+a),J+=e.length*6,J>Y&&le(J),o.offset=J;let s=cm(K.subarray(t,J),e);return i=null,s}return o.offset=J,a&512?(K.start=t,K.end=J,K):K.subarray(t,J)}catch(e){throw c=e,e}finally{if(r&&(ne(),n&&o.saveStructures)){let n=r.sharedLength||0,i=K.subarray(t,J),s=(o._prepareStructures||um)(r,o);if(!c)return o.saveStructures(s,s.isCompatible)===!1?o.pack(e,a):(o.lastNamedStructuresLength=n,K.length>1073741824&&(K=null),i)}K.length>1073741824&&(K=null),a&1024&&(J=t)}};let ne=()=>{te<10&&te++;let e=r.sharedLength||0;if(r.length>e&&!s&&(r.length=e),ee>1e4)r.transitions=null,te=0,ee=0,m.length>0&&(m=[]);else if(m.length>0&&!s){for(let e=0,t=m.length;e<t;e++)m[e][rm]=0;m=[]}},re=e=>{var t=e.length;t<16?K[J++]=144|t:t<65536?(K[J++]=220,K[J++]=t>>8,K[J++]=t&255):(K[J++]=221,q.setUint32(J,t),J+=4);for(let n=0;n<t;n++)h(e[n])},h=e=>{J>Y&&(K=le(J));var n=typeof e,r;if(n===`string`){let n=e.length;if(X&&n>=4&&n<4096){if((X.size+=n)>tm){let e,n=(X[0]?X[0].length*3+X[1].length:0)+10;J+n>Y&&(K=le(J+n));let r;X.position?(r=X,K[J]=200,J+=3,K[J++]=98,e=J-t,J+=4,lm(t,h,0),q.setUint16(e+t-3,J-t-e)):(K[J++]=214,K[J++]=98,e=J-t,J+=4),X=[``,``],X.previous=r,X.size=0,X.position=e}let r=nm.test(e);X[+!r]+=e,K[J++]=193,h(r?-n:n);return}let i;i=n<32?1:n<256?2:n<65536?3:5;let o=n*3;if(J+o>Y&&(K=le(J+o)),n<64||!a){let t,a,o,s=J+i;for(t=0;t<n;t++)a=e.charCodeAt(t),a<128?K[s++]=a:a<2048?(K[s++]=a>>6|192,K[s++]=a&63|128):(a&64512)==55296&&((o=e.charCodeAt(t+1))&64512)==56320?(a=65536+((a&1023)<<10)+(o&1023),t++,K[s++]=a>>18|240,K[s++]=a>>12&63|128,K[s++]=a>>6&63|128,K[s++]=a&63|128):(K[s++]=a>>12|224,K[s++]=a>>6&63|128,K[s++]=a&63|128);r=s-J-i}else r=a(e,J+i);r<32?K[J++]=160|r:r<256?(i<2&&K.copyWithin(J+2,J+1,J+1+r),K[J++]=217,K[J++]=r):r<65536?(i<3&&K.copyWithin(J+3,J+2,J+2+r),K[J++]=218,K[J++]=r>>8,K[J++]=r&255):(i<5&&K.copyWithin(J+5,J+3,J+3+r),K[J++]=219,q.setUint32(J,r),J+=4),J+=r}else if(n===`number`)if(e>>>0===e)e<32||e<128&&this.useRecords===!1||e<64&&!this._writeStruct?K[J++]=e:e<256?(K[J++]=204,K[J++]=e):e<65536?(K[J++]=205,K[J++]=e>>8,K[J++]=e&255):(K[J++]=206,q.setUint32(J,e),J+=4);else if(e>>0===e)e>=-32?K[J++]=256+e:e>=-128?(K[J++]=208,K[J++]=e+256):e>=-32768?(K[J++]=209,q.setInt16(J,e),J+=2):(K[J++]=210,q.setInt32(J,e),J+=4);else{let t;if((t=this.useFloat32)>0&&e<4294967296&&e>=-2147483648){K[J++]=202,q.setFloat32(J,e);let n;if(t<4||(n=e*Wp[(K[J]&127)<<1|K[J+1]>>7])>>0===n){J+=4;return}else J--}K[J++]=203,q.setFloat64(J,e),J+=8}else if(n===`object`||n===`function`)if(!e)K[J++]=192;else{if(i){let n=i.get(e);if(n){n.id||=(i.idsToInsert||=[]).push(n),K[J++]=214,K[J++]=112,q.setUint32(J,n.id),J+=4;return}else i.set(e,{offset:J-t})}let a=e.constructor;if(a===Object)se(e);else if(a===Array)re(e);else if(a===Map)if(this.mapAsEmptyObject)K[J++]=128;else{r=e.size,r<16?K[J++]=128|r:r<65536?(K[J++]=222,K[J++]=r>>8,K[J++]=r&255):(K[J++]=223,q.setUint32(J,r),J+=4);for(let[t,n]of e)h(t),h(n)}else{for(let t=0,n=Jp.length;t<n;t++){let n=Yp[t];if(e instanceof n){let n=Jp[t];if(n.write){n.type&&(K[J++]=212,K[J++]=n.type,K[J++]=0);let t=n.write.call(this,e);t===e?Array.isArray(e)?re(e):se(e):h(t);return}let r=K,i=q,a=J;K=null;let o;try{o=n.pack.call(this,e,e=>(K=r,r=null,J+=e,J>Y&&le(J),{target:K,targetView:q,position:J-e}),h)}finally{r&&(K=r,q=i,J=a,Y=K.length-10)}o&&(o.length+J>Y&&le(o.length+J),J=sm(o,K,J,n.type));return}}if(Array.isArray(e))re(e);else{if(e.toJSON){let t=e.toJSON();if(t!==e)return h(t)}if(n===`function`)return h(this.writeFunction&&this.writeFunction(e));se(e)}}}else if(n===`boolean`)K[J++]=e?195:194;else if(n===`bigint`){if(e<0x8000000000000000&&e>=-0x8000000000000000)K[J++]=211,q.setBigInt64(J,e);else if(e<0x10000000000000000&&e>0)K[J++]=207,q.setBigUint64(J,e);else if(this.largeBigIntToFloat)K[J++]=203,q.setFloat64(J,Number(e));else if(this.largeBigIntToString)return h(e.toString());else if(this.useBigIntExtension||this.moreTypes){let t=BigInt(e<0?-1:0),n;if(e>>BigInt(65536)===t){let r=BigInt(0x10000000000000000)-BigInt(1),i=[];for(;i.push(e&r),e>>BigInt(63)!==t;)e>>=BigInt(64);n=new Uint8Array(new BigUint64Array(i).buffer),n.reverse()}else{let t=e<0,r=(t?~e:e).toString(16);if(r.length%2?r=`0`+r:parseInt(r.charAt(0),16)>=8&&(r=`00`+r),Xp)n=Buffer.from(r,`hex`);else{n=new Uint8Array(r.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(r.slice(e*2,e*2+2),16)}if(t)for(let e=0;e<n.length;e++)n[e]=~n[e]}n.length+J>Y&&le(n.length+J),J=sm(n,K,J,66);return}else throw RangeError(e+` was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string`);J+=8}else if(n===`undefined`)this.encodeUndefinedAsNil?K[J++]=192:(K[J++]=212,K[J++]=0,K[J++]=0);else throw Error(`Unknown type: `+n)},ie=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?e=>{let t;if(this.skipValues){t=[];for(let n in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(n))&&!this.skipValues.includes(e[n])&&t.push(n)}else t=Object.keys(e);let n=t.length;n<16?K[J++]=128|n:n<65536?(K[J++]=222,K[J++]=n>>8,K[J++]=n&255):(K[J++]=223,q.setUint32(J,n),J+=4);let r;if(this.coercibleKeyAsNumber)for(let i=0;i<n;i++){r=t[i];let n=Number(r);h(isNaN(n)?r:n),h(e[r])}else for(let i=0;i<n;i++)h(r=t[i]),h(e[r])}:e=>{K[J++]=222;let n=J-t;J+=2;let r=0;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(h(t),h(e[t]),r++);if(r>65535)throw Error(`Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object`);K[n+++t]=r>>8,K[n+t]=r&255},ae=this.useRecords===!1?ie:e.progressiveRecords&&!d?e=>{let n,i=r.transitions||=Object.create(null),a=J++-t,o;for(let s in e)if(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(s)){if(n=i[s],n)i=n;else{let c=Object.keys(e),l=i;i=r.transitions;let u=0;for(let e=0,t=c.length;e<t;e++){let t=c[e];n=i[t],n||(n=i[t]=Object.create(null),u++),i=n}a+t+1==J?(J--,ue(i,c,u)):de(i,c,a,u),o=!0,i=l[s]}h(e[s])}if(!o){let n=i[rm];n?K[a+t]=n:de(i,Object.keys(e),a,0)}}:e=>{let t,n=r.transitions||=Object.create(null),i=0;for(let r in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(r))&&(t=n[r],t||(t=n[r]=Object.create(null),i++),n=t);let a=n[rm];a?a>=96&&d?(K[J++]=((a-=96)&31)+96,K[J++]=a>>5):K[J++]=a:ue(n,n.__keys__||Object.keys(e),i);for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&h(e[t])},oe=typeof this.useRecords==`function`&&this.useRecords,se=oe?e=>{oe(e)?ae(e):ie(e)}:ae,ce=e=>{let i=o._writeStruct(e,K,t,J,r,le,(e,t,r)=>{if(r)return n=!0;J=t;let i=K;return h(e),ne(),i===K?J:{position:J,targetView:q,target:K}});if(i===0)return se(e);J=i},le=e=>{let n;if(e>16777216){if(e-t>$p)throw Error(`Packed buffer would be larger than maximum buffer size`);n=Math.min($p,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,K.length-1)>>12)+1<<12;let r=new Zp(n);return q=r.dataView||=new DataView(r.buffer,0,n),e=Math.min(e,K.length),K.copy?K.copy(r,0,t,e):r.set(K.slice(t,e)),J-=t,t=0,Y=r.length-10,K=r},ue=(e,t,i)=>{let a=r.nextId;a||=64,a<f&&this.shouldShareStructure&&!this.shouldShareStructure(t)?(a=r.nextOwnId,a<p||(a=f),r.nextOwnId=a+1):(a>=p&&(a=f),r.nextId=a+1);let o=t.highByte=a>=96&&d?a-96>>5:-1;e[rm]=a,e.__keys__=t,r[a-64]=t,a<f?(t.isShared=!0,r.sharedLength=a-63,n=!0,o>=0?(K[J++]=(a&31)+96,K[J++]=o):K[J++]=a):(o>=0?(K[J++]=213,K[J++]=114,K[J++]=(a&31)+96,K[J++]=o):(K[J++]=212,K[J++]=114,K[J++]=a),i&&(ee+=te*i),m.length>=u&&(m.shift()[rm]=0),m.push(e),h(t))},de=(e,n,r,i)=>{let a=K,o=J,s=Y,c=t;K=em,J=0,t=0,K||(em=K=new Zp(8192)),Y=K.length-10,ue(e,n,i),em=K;let l=J;if(K=a,J=o,Y=s,t=c,l>1){let e=J+l-1;e>Y&&le(e);let n=r+t;K.copyWithin(n+l,n+1,J),K.set(em.slice(0,l),n),J=e}else K[r+t]=em[0]}}useBuffer(e){K=e,K.dataView||=new DataView(K.buffer,K.byteOffset,K.byteLength),q=K.dataView,J=0}set position(e){J=e}get position(){return J}clearSharedData(){this.structures&&=[],this.typedStructs&&=[]}};Yp=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,dp],Jp=[{pack(e,t,n){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:e,targetView:n,position:i}=t(6);e[i++]=214,e[i++]=255,n.setUint32(i,r)}else if(r>0&&r<4294967296){let{target:n,targetView:i,position:a}=t(10);n[a++]=215,n[a++]=255,i.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),n(this.onInvalidDate());let{target:e,targetView:r,position:i}=t(3);e[i++]=212,e[i++]=255,e[i++]=255}else{let{target:n,targetView:i,position:a}=t(15);n[a++]=199,n[a++]=12,n[a++]=255,i.setUint32(a,e.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,n){if(this.setAsEmptyObject)return t(0),n({});let r=Array.from(e),{target:i,position:a}=t(this.moreTypes?3:0);this.moreTypes&&(i[a++]=212,i[a++]=115,i[a++]=0),n(r)}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=101,r[i++]=0),n([e.name,e.message,e.cause])}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=120,r[i++]=0),n([e.source,e.flags])}},{pack(e,t){this.moreTypes?am(e,16,t):om(Xp?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let n=e.constructor;n!==Qp&&this.moreTypes?am(e,zp.indexOf(n.name),t):om(e,t)}},{pack(e,t){this.moreTypes?am(e,17,t):om(Xp?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:n,position:r}=t(1);n[r]=193}}];function am(e,t,n,r){let i=e.byteLength;if(i+1<256){var{target:a,position:o}=n(4+i);a[o++]=199,a[o++]=i+1}else if(i+1<65536){var{target:a,position:o}=n(5+i);a[o++]=200,a[o++]=i+1>>8,a[o++]=i+1&255}else{var{target:a,position:o,targetView:s}=n(7+i);a[o++]=201,s.setUint32(o,i+1),o+=4}a[o++]=116,a[o++]=t,e.buffer||(e=new Uint8Array(e)),a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),o)}function om(e,t){let n=e.byteLength;var r,i;if(n<256){var{target:r,position:i}=t(n+2);r[i++]=196,r[i++]=n}else if(n<65536){var{target:r,position:i}=t(n+3);r[i++]=197,r[i++]=n>>8,r[i++]=n&255}else{var{target:r,position:i,targetView:a}=t(n+5);r[i++]=198,a.setUint32(i,n),i+=4}r.set(e,i)}function sm(e,t,n,r){let i=e.length;switch(i){case 1:t[n++]=212;break;case 2:t[n++]=213;break;case 4:t[n++]=214;break;case 8:t[n++]=215;break;case 16:t[n++]=216;break;default:i<256?(t[n++]=199,t[n++]=i):i<65536?(t[n++]=200,t[n++]=i>>8,t[n++]=i&255):(t[n++]=201,t[n++]=i>>24,t[n++]=i>>16&255,t[n++]=i>>8&255,t[n++]=i&255)}return t[n++]=r,t.set(e,n),n+=i,n}function cm(e,t){let n,r=t.length*6,i=e.length-r;for(;n=t.pop();){let t=n.offset,a=n.id;e.copyWithin(t+r,t,i),r-=6;let o=t+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,i=t}return e}function lm(e,t,n){if(X.length>0){q.setUint32(X.position+e,J+n-X.position-e),X.stringsPosition=J-e;let r=X;X=null,t(r[0]),t(r[1])}}function um(e,t){return e.isCompatible=e=>{let n=!e||(t.lastNamedStructuresLength||0)===e.length;return n||t._mergeStructures(e),n},e}im.SUPPORTS_STRUCT_HOOKS=!0;var dm=new im({useRecords:!1});dm.pack,dm.pack;var{NEVER:fm,ALWAYS:pm,DECIMAL_ROUND:mm,DECIMAL_FIT:hm}=Kp,gm=class extends j()(`effect/rpc/RpcSerialization`){},_m=(e=>gm.of({contentType:`application/msgpack`,includesFraming:!0,makeUnsafe:()=>{let t=new hp(e),n=new im(e),r=new TextEncoder,i;return{decode(e){let n=typeof e==`string`?r.encode(e):e;if(i!==void 0){let t=n;e=new Uint8Array(i.length+n.length),e.set(i),e.set(t,i.length),n=e,i=void 0}try{return t.unpackMultiple(n)}catch(e){let t=e;if(t.incomplete)return i=n.subarray(t.lastPosition),t.values??[];throw e}},encode:e=>n.pack(e)}}}))({useRecords:!0}),vm=Ur(gm)(_m),ym=e=>Bt(()=>{let t=new Set,n=new Map,r=new Map,i=(e,t)=>hn(r=>{let i=n.get(e);return i||(i=[],n.set(e,i)),i.push([t,r]),E});return O(e((e,t)=>{let n=r.get(e);return n?n(t):i(e,t)},t),e=>({...e,run(e,i){return ei(function*(){t.add(e),r.set(e,i);let a=n.get(e);if(a){n.delete(e);for(let[e,t]of a)yield*ea(Bt(()=>i(e)),t)}return yield*Sr(Xr,()=>(t.delete(e),r.delete(e),E))})}}))}),bm=BigInt(0),xm=w(function*(e,t){let n=t?.spanPrefix??`RpcClient`,r=t?.supportsAck??!0,i=t?.disableTracing??!1,a=t?.generateRequestId??(()=>bm++),o=yield*h(),s=Ar(o,Rr),c=new Map,l=!1;yield*mt(s,hr(e=>(l=!0,u(Qe(e.id)))));let u=w(function*(e){for(let[t,n]of c)c.delete(t),n._tag===`Queue`?yield*e._tag===`Success`?ao(n.queue):ro(n.queue,e.cause):n.resume(e)}),d=e=>{let r=zf(e.successSchema),a=m(e);return(o,s)=>{let c=s?.headers?Au(s.headers):ku,l=s?.context??xi();if(!r){let r=t=>f(e,a,t,e.payloadSchema.make(o),c,l,s?.discard??!1);return i?r(void 0):Tn(`${n}.${e._tag}`,{attributes:t.spanAttributes},r)}let u=p(e,a,e.payloadSchema.make(o),c,s?.streamBufferSize??16,l);return s?.asQueue?u:ks(O(u,Es))}},f=(e,n,r,i,o,s,u)=>hr(d=>{if(l)return jr;let f=a(),p=n(e=>t.onFromClient({message:e,context:s,discard:u}),{_tag:`Request`,id:f,tag:e._tag,payload:i,...r?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{},headers:Pu(d.getRef(Em),o)});if(u)return p;let m;return zn(qe(t=>{let n={_tag:`Effect`,rpc:e,context:s,resume(e){t(e),m&&!m.pollUnsafe()&&d.currentDispatcher.scheduleTask(()=>{m.interruptUnsafe(d.id)},0)}};c.set(f,n),m=p.pipe(r?Pi(r,{captureStackTrace:!1}):_,de(d.context)),m.addObserver(e=>{if(e._tag===`Failure`)return t(e)})}),e=>(c.delete(f),zr(_a(m),ee(f,Array.from(e),s))))}),p=w(function*(e,r,o,s,u,d){if(l)return yield*jr;let f=i?void 0:yield*tr(`${n}.${e._tag}`,{attributes:t.spanAttributes}),p=ya(),m=a(),te=ii(p.context,Rr);yield*bt(te,e=>c.has(m)?(c.delete(m),ee(m,Dn(e)?Array.from(_r(e.cause)):[],d)):E);let ne=yield*Qa(u);return c.set(m,{_tag:`Queue`,rpc:e,queue:ne,scope:te,context:d}),yield*r(e=>t.onFromClient({message:e,context:d,discard:!1}),{_tag:`Request`,id:m,tag:e._tag,payload:o,...f?{traceId:f.traceId,spanId:f.spanId,sampled:f.sampled}:{},headers:Pu(p.getRef(Em),s)}).pipe(f?Pi(f,{captureStackTrace:!1}):_,lt(e=>ro(ne,e)),Wn,pr(te,{startImmediately:!0})),ne}),m=e=>{let t=[];for(let n of e.middlewares.values()){let e=o.mapUnsafe.get(`${n.key}/Client`);e&&t.push(e)}return t.length===0?(e,t)=>e(t):function n(r,i,a=t.length-1){return a===-1?r(i):t[a]({rpc:e,request:i,next(e){return n(r,e,a-1)}})}},ee=(e,n,r)=>qe(i=>{let a=ya();t.onFromClient({message:{_tag:`Interrupt`,requestId:e,interruptors:n},context:r,discard:!1}).pipe(Re(1e3),de(a.context)).addObserver(()=>{i(E)})}),te=e=>{switch(e._tag){case`Chunk`:{let n=e.requestId,i=c.get(n);return!i||i._tag!==`Queue`?E:to(i.queue,e.values).pipe(r?y(()=>t.onFromClient({message:{_tag:`Ack`,requestId:e.requestId},context:i.context,discard:!1})):_,lt(e=>ro(i.queue,e)))}case`Exit`:{let t=e.requestId,n=c.get(t);return n?(c.delete(t),n._tag===`Effect`?(n.resume(e.exit),E):e.exit._tag===`Success`?ao(n.queue):ro(n.queue,e.exit.cause)):E}case`Defect`:return u(Ne(e.defect));case`ClientEnd`:return E}},ne;if(t.flatten){let t=new Map;ne=function(n,r,i){let a=t.get(n);return a||(a=d(e.requests.get(n)),t.set(n,a)),a(r,i)}}else ne={},e.requests.forEach(e=>{ne[e._tag]=d(e)});return{client:ne,write:te}}),Sm=0,Cm=w(function*(e,t){let n=Sm++,{run:r,send:i,supportsAck:a,supportsTransferables:o}=yield*Dm,s=new Map,{client:c,write:l}=yield*xm(e,{...t,supportsAck:a,onFromClient({message:t}){switch(t._tag){case`Request`:{let r=e.requests.get(t.tag),a=o?Pf():void 0,c=ya(),l={rpc:r,context:a?Qr(c.context,Nf,a):c.context,schemas:Tm(r)};return s.set(t.id,l),l.schemas.encodePayload(t.payload).pipe(ea(l.context),Ui,y(e=>i(n,{...t,id:String(t.id),payload:e,headers:Object.entries(t.headers)},a&&a.readUnsafe())))}case`Ack`:return s.get(t.requestId)?i(n,{_tag:`Ack`,requestId:String(t.requestId)}):E;case`Interrupt`:return s.get(t.requestId)?(s.delete(t.requestId),i(n,{_tag:`Interrupt`,requestId:String(t.requestId)})):E;case`Eof`:return E}}});return yield*r(n,e=>{switch(e._tag){case`Chunk`:{let t=$f(e.requestId),n=s.get(t);return!n||mr(n.schemas.decodeChunk)?E:n.schemas.decodeChunk.value(e.values).pipe(ea(n.context),Ui,y(t=>l({_tag:`Chunk`,clientId:0,requestId:$f(e.requestId),values:t})),Dr(t=>l({_tag:`Exit`,clientId:0,requestId:$f(e.requestId),exit:yi(t)})))}case`Exit`:{let t=$f(e.requestId),n=s.get(t);return n?(s.delete(t),n.schemas.decodeExit(e.exit).pipe(ea(n.context),Ui,di({onSuccess:e=>l({_tag:`Exit`,clientId:0,requestId:t,exit:e}),onFailure:e=>l({_tag:`Exit`,clientId:0,requestId:t,exit:yi(e)})}))):E}case`Defect`:return l({_tag:`Defect`,clientId:0,defect:Nm(e.defect)});case`ClientProtocolError`:{let t=it(e.error);return Ln(s.keys(),e=>l({_tag:`Exit`,clientId:0,requestId:e,exit:t}))}default:return E}}).pipe(lt(ki),Wn,Mi),c}),wm=new WeakMap,Tm=e=>{let t=wm.get(e);return t===void 0?(t={decodeChunk:ti(Bf(e.successSchema),e=>ci(wr(gn(e.success)))),encodePayload:ir(wr(e.payloadSchema)),decodeExit:ci(wr(qf(e)))},wm.set(e,t),t):t},Em=dr(`effect/rpc/RpcClient/CurrentHeaders`,{defaultValue:()=>ku}),Dm=class extends j()(`effect/rpc/RpcClient/Protocol`){static make=ym},Om=e=>Dm.make(w(function*(t,n){let r=yield*ff,a=yield*gm,o=yield*we(Mm),s=new Map,c=yield*r.writer,l=a.makeUnsafe(),u=yield*Am(c(l.encode(ep))),d,f=Bt(()=>(d=void 0,Ni(o)?o.value.onConnect:E)),p=e=>Ln(n,n=>t(n,e));return yield*Bt(()=>(l=a.makeUnsafe(),u.reset(),r.runRaw(e=>{try{let n=l.decode(e);if(n.length===0)return;let r=0;return i({while:()=>r<n.length,body:()=>{let e=n[r++];if(e._tag===`Pong`)return u.onPong(),E;if(`requestId`in e){let n=s.get(e.requestId);if(n!==void 0)return e._tag===`Exit`&&s.delete(e.requestId),t(n,e)}return p(e)},step:bn})}catch(e){return p({_tag:`ClientProtocolError`,error:new Qf({reason:new Zf({message:`Error decoding message`,cause:e})})})}},{onOpen:f}).pipe(ae(y(u.timeout,()=>Sn(new Tf({reason:new Sf({kind:`Timeout`,cause:Error(`ping timeout`)})}))))))).pipe(y(()=>Sn(new Tf({reason:new Cf({code:1e3})}))),Ni(o)?cn(o.value.onDisconnect):_,fn(t=>{let n=er(t),r=tt(n);return e?.retryTransientErrors&&r&&n.success.reason._tag===`SocketOpenError`?E:(d=new Qf({reason:r?n.success.reason:new Zf({message:`Unknown socket error`,cause:Er(t)})}),p({_tag:`ClientProtocolError`,error:d}))}),Ji(e?.retryPolicy??km),ht({module:`RpcClient`,method:`makeProtocolSocket`}),Mi),{send(e,t){if(d)return Sn(d);t._tag===`Request`&&s.set(t.id,e);let n=l.encode(t);return n===void 0?E:Ui(c(n))},supportsAck:!0,supportsTransferables:!1}})),km=Mr(500,1.5).pipe(Ti(Kn(5e3))),Am=w(function*(e){let t=!0,n=xa();return yield*Bt(()=>t?(t=!1,e):n.open).pipe(Ve(`5 seconds`),Ci,Rt,Wn,Mi),{timeout:n.await,reset:()=>{t=!0,n.closeUnsafe()},onPong:()=>{t=!0}}}),jm=e=>Zn(Dm)(Om(e)),Mm=class extends j()(`effect/rpc/RpcClient/ConnectionHooks`){},Nm=Nr(S),Pm=()=>(e,t)=>{let n=j()(e),r=Zn(n,t.makeEffect??Cm(t.group,{...t,flatten:!0}));n.runtime=(t.runtime??Rl)(typeof t.protocol==`function`?e=>pe(r,ye(t.protocol(e))):pe(r,ye(t.protocol))),n.mutation=Xl(e=>{let r=t.group.requests.get(e);return n.runtime.fn()(w(function*({headers:t,payload:r,reactivityKeys:i}){let a=(yield*n)(e,r,{headers:t});return yield*i?Tc(a,i):a})).pipe(ou({key:`AtomRpc:mutation:${e}`,schema:Zc({success:r.successSchema,error:Fm(r)})}))});let i=Xl(e=>{let{headers:r,payload:i,reactivityKeys:a,tag:o,timeToLive:s}=e,c=t.group.requests.get(o),l=zf(c.successSchema),u=l?n.runtime.pull(ks(n.use(e=>g(e(o,i,{headers:r}))))):n.runtime.atom(n.use(e=>e(o,i,{headers:r})));return!l&&e.serializationKey&&(u=ou(u,{key:`AtomRpc:${e.tag}:${e.serializationKey}`,schema:Zc({success:c.successSchema,error:Fm(c)})})),s&&(u=Fn(s)?bl(u,s):Zl(u)),a?n.runtime.factory.withReactivity(a)(u):u});return n.query=(e,t,n)=>i({tag:e,payload:t,headers:n?.headers?Au(n.headers):void 0,reactivityKeys:n?.reactivityKeys,timeToLive:n?.timeToLive?wn(n.timeToLive):void 0,serializationKey:n?.serializationKey}),n},Fm=e=>gr([e.errorSchema,...Array.from(e.middlewares,e=>e.error),Qf]),Im=dr(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),Lm=class extends j()(`effect/http/FetchHttpClient/RequestInit`){},Rm=Yd(g(Gd((e,t,n,r)=>{let i=r.getRef(Im),a=r.context.mapUnsafe.get(Lm.key)??{},o=a.headers?Pu(Au(a.headers),e.headers):e.headers;o[`content-length`]&&(o=Fu(o,`content-length`));let s=r=>O(je({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:e.body._tag===`Stream`?`half`:void 0,signal:n}),catch:t=>new ud({reason:new pd({request:e,cause:t})})}),t=>Ld(e,t));switch(e.body._tag){case`Raw`:case`Uint8Array`:return s(e.body.body);case`FormData`:return s(e.body.formData);case`Stream`:return y(Ls(e.body.stream),s)}return s(void 0)}))),zm={add(...e){let t=new Map(this.requests);for(let n of e)t.set(n._tag,n);return Bm({requests:t,annotations:this.annotations})},merge(...e){let t=new Map(this.requests),n=new Map(this.annotations.mapUnsafe);for(let r of e){for(let[e,n]of r.requests)t.set(e,n);for(let[e,t]of r.annotations.mapUnsafe)n.set(e,t)}return Bm({requests:t,annotations:$n(n)})},omit(...e){let t=new Map(this.requests);for(let n of e)t.delete(n);return Bm({requests:t,annotations:this.annotations})},middleware(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.middleware(e));return Bm({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return ei(function*(){let n=yield*h(),r=oi(e)?yield*e:e,i=new Map;for(let[e,a]of Object.entries(r)){let r=t.requests.get(e);i.set(r.key,{tag:r._tag,handler:a,context:n})}return $n(i)})},prefix(e){let t=new Map;for(let n of this.requests.values()){let r=n.prefix(e);t.set(r._tag,r)}return Bm({requests:t,annotations:this.annotations})},toLayer(e){return na(this.toHandlers(e))},of:_,toLayerHandler(e,t){let n=this;return na(ei(function*(){let r=yield*h(),i=oi(t)?yield*t:t,a=new Map,o=n.requests.get(e);return a.set(o.key,{handler:i,context:r}),$n(a)}))},accessHandler(e){return hn(t=>{let n=this.requests.get(e),{handler:r,context:i}=t.mapUnsafe.get(n.key);return g((e,t)=>{t.rpc=n;let a=r(e,t),o=Yf(a)?a.value:a;return oi(o)?Yn(o,i):Ns(o,i)})})},annotate(e,t){return Bm({requests:this.requests,annotations:Qr(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(Di(e,t))},annotateMerge(e){return Bm({requests:this.requests,annotations:Gr(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.annotateMerge(Gr(e,r.annotations)));return Bm({requests:t,annotations:this.annotations})}},Bm=e=>Object.assign(function(){},zm,{requests:e.requests,annotations:e.annotations}),Vm=(...e)=>Bm({requests:new Map(e.map(e=>[e._tag,e])),annotations:xi()}),Z=class extends Nn()(`GitError`,{cause:k(S),message:k(T)}){},Hm=Fe([`added`,`deleted`,`modified`,`renamed`]),Um=class extends b(`GitDiffSegment`)({filePath:T,fingerprint:T,id:T,type:Fe([`commit`,`worktree`])}){},Wm=class extends b(`GitDiff`)({fileContent:k(T),filePath:T,patch:T,segments:x(Um),status:Hm}){},Gm=gr([C({_tag:ln(`changes`)}),C({_tag:ln(`local`)}),C({_tag:ln(`branch`)}),C({_tag:ln(`commit`),hash:T})]),Km=class extends b(`GitCommit`)({hash:T,shortHash:T,subject:T}){},qm=class extends b(`GitReviewMetadata`)({branchCommits:x(Km),dirty:xe,localCommits:x(Km),prUrl:k(T),unpushedCommits:xe}){},Jm=class extends b(`GitReviewMark`)({filePath:T,fingerprint:T,segmentId:T}){},Ym=class extends b(`GitReviewComment`)({body:T,filePath:T,lineNumber:et,resolved:xe,side:k(Fe([`additions`,`deletions`]))}){},Xm=class extends b(`GitReviewState`)({comments:x(Ym),marks:x(Jm)}){},Zm=class extends b(`GitHubReviewThread`)({body:T,filePath:T,id:T,lineNumber:et,resolved:xe,side:k(Fe([`additions`,`deletions`])),url:k(T)}){};C({name:T,owner:C({login:T})}),C({data:k(C({repository:k(C({pullRequest:k(C({reviewThreads:k(C({nodes:x(C({comments:C({nodes:x(C({body:T,line:k(Oe(et)),originalLine:k(Oe(et)),path:T,url:k(T)}))}),diffSide:k(T),id:T,isResolved:xe}))}))}))}))}))});var Qm=class extends b(`GitRepository`)({gitDirectory:T,root:T}){},$m=class extends b(`GitBranch`)({name:T,remote:k(T),type:Fe([`local`,`remote`])}){},eh=class extends b(`GitBranchesSnapshot`)({branches:x($m),defaultBranch:T}){},th=class extends b(`GitWorktreeStatus`)({ahead:et,behind:et,dirtyTracked:xe,unpushedCommits:xe,untracked:xe}){},nh=class extends b(`GitWorktree`)({branch:k(T),root:T,status:k(th)}){},rh=class extends b(`GitProject`)({repository:Qm,worktrees:x(nh)}){};function ih(e){return`${e.filePath}:${e.side??`additions`}:${e.lineNumber}`}function ah(e){return`${e.filePath}:${e.fingerprint}`}function oh(e){return gt(e.segments,e=>({filePath:e.filePath,fingerprint:e.fingerprint,segmentId:e.id}))}function sh(e,t){let n=qn(e,e=>t.has(ah(e)));return he(e)||he(n)?`unchecked`:Pr(n)===Pr(e)?`checked`:`indeterminate`}var ch=class extends Nn()(`TerminalError`,{cause:k(S),message:k(T)}){},lh=C({state:Fe([`idle`,`starting`,`running`,`waiting`,`stopped`,`exited`,`failed`]),title:T});function uh(e){return e===`idle`||e===`starting`||e===`running`||e===`waiting`}var dh=gr([C({data:T,type:ln(`snapshot`)}),C({data:T,type:ln(`data`)}),C({status:lh,type:ln(`status`)})]),fh=gr([C({_tag:ln(`local`)}),C({_tag:ln(`remote`),remote:T}),C({_tag:ln(`new`)})]),ph=C({args:k(x(T)),command:k(T),cwd:T,env:k(Je(T,T)),sessionId:k(T)}),mh=C({baseOrigin:k(T),command:T,cwd:T,env:k(Je(T,T)),name:T,origin:k(T),packageFolder:T,packagePath:T,portless:k(xe),service:k(T),sessionId:T}),hh=C({args:x(T),command:T,cwd:T,icon:Fe([`opencode`,`codex`,`pi`]),label:T,state:lh,uuid:T}),gh=class extends Vm(I(`agents.create`,{error:ch,payload:C({args:x(T),command:T,cwd:T,icon:Fe([`opencode`,`codex`,`pi`]),label:T}),success:hh}),I(`agents.remove`,{error:ch,payload:C({cwd:T,uuid:T})}),I(`agents.watch`,{error:ch,payload:C({cwd:T}),stream:!0,success:x(hh)}),I(`projects.watch`,{stream:!0,success:x(rh)}),I(`projects.branches`,{error:Z,payload:C({cwd:T}),success:eh}),I(`review.metadata`,{error:Z,payload:C({cwd:T}),success:qm}),I(`review.diffs`,{error:Z,payload:C({cwd:T,target:Gm}),stream:!0,success:x(Wm)}),I(`review.state.watch`,{error:Z,payload:C({cwd:T}),stream:!0,success:Xm}),I(`review.state.mark`,{error:Z,payload:C({cwd:T,marks:x(Jm)})}),I(`review.state.unmark`,{error:Z,payload:C({cwd:T,marks:x(Jm)})}),I(`review.comments.save`,{error:Z,payload:C({comment:Ym,cwd:T})}),I(`review.comments.resolve`,{error:Z,payload:C({cwd:T,filePath:T,lineNumber:et,side:k(Fe([`additions`,`deletions`]))})}),I(`review.commit`,{error:Z,payload:C({cwd:T,message:T})}),I(`review.push`,{error:Z,payload:C({cwd:T})}),I(`review.githubThreads`,{error:Z,payload:C({cwd:T}),success:x(Zm)}),I(`review.githubThreads.resolve`,{error:Z,payload:C({cwd:T,threadId:T})}),I(`projects.createWorktree`,{error:Z,payload:C({branch:T,cwd:T,source:fh}),success:T}),I(`projects.deleteWorktree`,{error:Z,payload:C({cwd:T})}),I(`projects.cleanup`,{error:Z,payload:C({cwd:T})}),I(`runs.portless`,{error:ch,payload:C({cwd:T}),success:x(mh)}),I(`terminal.write`,{error:ch,payload:C({args:k(x(T)),command:k(T),cwd:T,data:T,env:k(Je(T,T)),sessionId:k(T)})}),I(`terminal.resize`,{error:ch,payload:C({args:k(x(T)),cols:et,command:k(T),cwd:T,env:k(Je(T,T)),rows:et,sessionId:k(T)})}),I(`terminal.restart`,{error:ch,payload:ph,success:lh}),I(`terminal.status.watch`,{error:ch,payload:ph,stream:!0,success:lh}),I(`terminal.stop`,{error:ch,payload:ph,success:lh}),I(`terminal.attach`,{error:ch,payload:ph,stream:!0,success:dh})){},_h=`1.9.1`,vh=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function yh(e){let t=new Set([e]),n=new Set,r=e.match(vh);if(!r)return()=>!1;let i={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(i.prerelease!=null)return function(t){return t===e};function a(e){return n.add(e),!1}function o(e){return t.add(e),!0}return function(e){if(t.has(e))return!0;if(n.has(e))return!1;let r=e.match(vh);if(!r)return a(e);let s={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};return s.prerelease!=null||i.major!==s.major?a(e):i.major===0?i.minor===s.minor&&i.patch<=s.patch?o(e):a(e):i.minor<=s.minor?o(e):a(e)}}var bh=yh(_h),xh=_h.split(`.`)[0],Sh=Symbol.for(`opentelemetry.js.api.${xh}`),Ch=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{};function wh(e,t,n,r=!1){let i=Ch[Sh]=Ch[Sh]??{version:_h};if(!r&&i[e]){let t=Error(`@opentelemetry/api: Attempted duplicate registration of API: ${e}`);return n.error(t.stack||t.message),!1}if(i.version!==`1.9.1`){let t=Error(`@opentelemetry/api: Registration of version v${i.version} for ${e} does not match previously registered API v${_h}`);return n.error(t.stack||t.message),!1}return i[e]=t,n.debug(`@opentelemetry/api: Registered a global for ${e} v${_h}.`),!0}function Th(e){let t=Ch[Sh]?.version;if(!(!t||!bh(t)))return Ch[Sh]?.[e]}function Eh(e,t){t.debug(`@opentelemetry/api: Unregistering a global for ${e} v${_h}.`);let n=Ch[Sh];n&&delete n[e]}var Dh=class{constructor(e){this._namespace=e.namespace||`DiagComponentLogger`}debug(...e){return Oh(`debug`,this._namespace,e)}error(...e){return Oh(`error`,this._namespace,e)}info(...e){return Oh(`info`,this._namespace,e)}warn(...e){return Oh(`warn`,this._namespace,e)}verbose(...e){return Oh(`verbose`,this._namespace,e)}};function Oh(e,t,n){let r=Th(`diag`);if(r)return r[e](t,...n)}var kh;(function(e){e[e.NONE=0]=`NONE`,e[e.ERROR=30]=`ERROR`,e[e.WARN=50]=`WARN`,e[e.INFO=60]=`INFO`,e[e.DEBUG=70]=`DEBUG`,e[e.VERBOSE=80]=`VERBOSE`,e[e.ALL=9999]=`ALL`})(kh||={});function Ah(e,t){e<kh.NONE?e=kh.NONE:e>kh.ALL&&(e=kh.ALL),t||={};function n(n,r){let i=t[n];return typeof i==`function`&&e>=r?i.bind(t):function(){}}return{error:n(`error`,kh.ERROR),warn:n(`warn`,kh.WARN),info:n(`info`,kh.INFO),debug:n(`debug`,kh.DEBUG),verbose:n(`verbose`,kh.VERBOSE)}}var jh=`diag`,Mh=class e{static instance(){return this._instance||=new e,this._instance}constructor(){function e(e){return function(...t){let n=Th(`diag`);if(n)return n[e](...t)}}let t=this;t.setLogger=(e,n={logLevel:kh.INFO})=>{if(e===t){let e=Error(`Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation`);return t.error(e.stack??e.message),!1}typeof n==`number`&&(n={logLevel:n});let r=Th(`diag`),i=Ah(n.logLevel??kh.INFO,e);if(r&&!n.suppressOverrideMessage){let e=Error().stack??`<failed to generate stacktrace>`;r.warn(`Current logger will be overwritten from ${e}`),i.warn(`Current logger will overwrite one already registered from ${e}`)}return wh(`diag`,i,t,!0)},t.disable=()=>{Eh(jh,t)},t.createComponentLogger=e=>new Dh(e),t.verbose=e(`verbose`),t.debug=e(`debug`),t.info=e(`info`),t.warn=e(`warn`),t.error=e(`error`)}},Nh=class e{constructor(e){this._entries=e?new Map(e):new Map}getEntry(e){let t=this._entries.get(e);if(t)return Object.assign({},t)}getAllEntries(){return Array.from(this._entries.entries())}setEntry(t,n){let r=new e(this._entries);return r._entries.set(t,n),r}removeEntry(t){let n=new e(this._entries);return n._entries.delete(t),n}removeEntries(...t){let n=new e(this._entries);for(let e of t)n._entries.delete(e);return n}clear(){return new e}},Ph=Symbol(`BaggageEntryMetadata`),Fh=Mh.instance();function Ih(e={}){return new Nh(new Map(Object.entries(e)))}function Lh(e){return typeof e!=`string`&&(Fh.error(`Cannot create baggage metadata from unknown type: ${typeof e}`),e=``),{__TYPE__:Ph,toString(){return e}}}function Rh(e){return Symbol.for(e)}var zh=new class e{constructor(t){let n=this;n._currentContext=t?new Map(t):new Map,n.getValue=e=>n._currentContext.get(e),n.setValue=(t,r)=>{let i=new e(n._currentContext);return i._currentContext.set(t,r),i},n.deleteValue=t=>{let r=new e(n._currentContext);return r._currentContext.delete(t),r}}},Bh=class{constructor(){}createGauge(e,t){return Qh}createHistogram(e,t){return $h}createCounter(e,t){return Zh}createUpDownCounter(e,t){return eg}createObservableGauge(e,t){return ng}createObservableCounter(e,t){return tg}createObservableUpDownCounter(e,t){return rg}addBatchObservableCallback(e,t){}removeBatchObservableCallback(e){}},Vh=class{},Hh=class extends Vh{add(e,t){}},Uh=class extends Vh{add(e,t){}},Wh=class extends Vh{record(e,t){}},Gh=class extends Vh{record(e,t){}},Kh=class{addCallback(e){}removeCallback(e){}},qh=class extends Kh{},Jh=class extends Kh{},Yh=class extends Kh{},Xh=new Bh,Zh=new Hh,Qh=new Wh,$h=new Gh,eg=new Uh,tg=new qh,ng=new Jh,rg=new Yh;function ig(){return Xh}var ag;(function(e){e[e.INT=0]=`INT`,e[e.DOUBLE=1]=`DOUBLE`})(ag||={});var og={get(e,t){if(e!=null)return e[t]},keys(e){return e==null?[]:Object.keys(e)}},sg={set(e,t,n){e!=null&&(e[t]=n)}},cg=class{active(){return zh}with(e,t,n,...r){return t.call(n,...r)}bind(e,t){return t}enable(){return this}disable(){return this}},lg=`context`,ug=new cg,dg=class e{constructor(){}static getInstance(){return this._instance||=new e,this._instance}setGlobalContextManager(e){return wh(lg,e,Mh.instance())}active(){return this._getContextManager().active()}with(e,t,n,...r){return this._getContextManager().with(e,t,n,...r)}bind(e,t){return this._getContextManager().bind(e,t)}_getContextManager(){return Th(lg)||ug}disable(){this._getContextManager().disable(),Eh(lg,Mh.instance())}},fg;(function(e){e[e.NONE=0]=`NONE`,e[e.SAMPLED=1]=`SAMPLED`})(fg||={});var pg={traceId:`00000000000000000000000000000000`,spanId:`0000000000000000`,traceFlags:fg.NONE},mg=class{constructor(e=pg){this._spanContext=e}spanContext(){return this._spanContext}setAttribute(e,t){return this}setAttributes(e){return this}addEvent(e,t){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,t){}},hg=Rh(`OpenTelemetry Context Key SPAN`);function gg(e){return e.getValue(hg)||void 0}function _g(){return gg(dg.getInstance().active())}function vg(e,t){return e.setValue(hg,t)}function yg(e){return e.deleteValue(hg)}function bg(e,t){return vg(e,new mg(t))}function xg(e){return gg(e)?.spanContext()}var Sg=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function Cg(e,t){if(typeof e!=`string`||e.length!==t)return!1;let n=0;for(let t=0;t<e.length;t+=4)n+=(Sg[e.charCodeAt(t)]|0)+(Sg[e.charCodeAt(t+1)]|0)+(Sg[e.charCodeAt(t+2)]|0)+(Sg[e.charCodeAt(t+3)]|0);return n===t}function wg(e){return Cg(e,32)&&e!==`00000000000000000000000000000000`}function Tg(e){return Cg(e,16)&&e!==`0000000000000000`}function Eg(e){return wg(e.traceId)&&Tg(e.spanId)}function Dg(e){return new mg(e)}var Og=dg.getInstance(),kg=class{startSpan(e,t,n=Og.active()){if(t?.root)return new mg;let r=n&&xg(n);return Ag(r)&&Eg(r)?new mg(r):new mg}startActiveSpan(e,t,n,r){let i,a,o;if(arguments.length<2)return;arguments.length===2?o=t:arguments.length===3?(i=t,o=n):(i=t,a=n,o=r);let s=a??Og.active(),c=this.startSpan(e,i,s),l=vg(s,c);return Og.with(l,o,void 0,c)}};function Ag(e){return typeof e==`object`&&!!e&&`spanId`in e&&typeof e.spanId==`string`&&`traceId`in e&&typeof e.traceId==`string`&&`traceFlags`in e&&typeof e.traceFlags==`number`}var jg=new kg,Mg=class{constructor(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}startSpan(e,t,n){return this._getTracer().startSpan(e,t,n)}startActiveSpan(e,t,n,r){let i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)}_getTracer(){if(this._delegate)return this._delegate;let e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):jg}},Ng=new class{getTracer(e,t,n){return new kg}},Pg=class{getTracer(e,t,n){return this.getDelegateTracer(e,t,n)??new Mg(this,e,t,n)}getDelegate(){return this._delegate??Ng}setDelegate(e){this._delegate=e}getDelegateTracer(e,t,n){return this._delegate?.getTracer(e,t,n)}},Fg;(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(Fg||={});var Ig;(function(e){e[e.INTERNAL=0]=`INTERNAL`,e[e.SERVER=1]=`SERVER`,e[e.CLIENT=2]=`CLIENT`,e[e.PRODUCER=3]=`PRODUCER`,e[e.CONSUMER=4]=`CONSUMER`})(Ig||={});var Lg;(function(e){e[e.UNSET=0]=`UNSET`,e[e.OK=1]=`OK`,e[e.ERROR=2]=`ERROR`})(Lg||={});var Rg=dg.getInstance(),Q=Mh.instance(),zg=class{inject(e,t){}extract(e,t){return e}fields(){return[]}},Bg=Rh(`OpenTelemetry Baggage Key`);function Vg(e){return e.getValue(Bg)||void 0}function Hg(){return Vg(dg.getInstance().active())}function Ug(e,t){return e.setValue(Bg,t)}function Wg(e){return e.deleteValue(Bg)}var Gg=`propagation`,Kg=new zg,qg=class e{constructor(){this.createBaggage=Ih,this.getBaggage=Vg,this.getActiveBaggage=Hg,this.setBaggage=Ug,this.deleteBaggage=Wg}static getInstance(){return this._instance||=new e,this._instance}setGlobalPropagator(e){return wh(Gg,e,Mh.instance())}inject(e,t,n=sg){return this._getGlobalPropagator().inject(e,t,n)}extract(e,t,n=og){return this._getGlobalPropagator().extract(e,t,n)}fields(){return this._getGlobalPropagator().fields()}disable(){Eh(Gg,Mh.instance())}_getGlobalPropagator(){return Th(Gg)||Kg}}.getInstance(),Jg=`trace`,$=class e{constructor(){this._proxyTracerProvider=new Pg,this.wrapSpanContext=Dg,this.isSpanContextValid=Eg,this.deleteSpan=yg,this.getSpan=gg,this.getActiveSpan=_g,this.getSpanContext=xg,this.setSpan=vg,this.setSpanContext=bg}static getInstance(){return this._instance||=new e,this._instance}setGlobalTracerProvider(e){let t=wh(Jg,this._proxyTracerProvider,Mh.instance());return t&&this._proxyTracerProvider.setDelegate(e),t}getTracerProvider(){return Th(Jg)||this._proxyTracerProvider}getTracer(e,t){return this.getTracerProvider().getTracer(e,t)}disable(){Eh(Jg,Mh.instance()),this._proxyTracerProvider=new Pg}}.getInstance(),Yg=Rh(`OpenTelemetry SDK Context Key SUPPRESS_TRACING`);function Xg(e){return e.setValue(Yg,!0)}function Zg(e){return e.getValue(Yg)===!0}var Qg=`baggage`,$g=4096;function e_(e){return e.reduce((e,t)=>{let n=`${e}${e===``?``:`,`}${t}`;return n.length>8192?e:n},``)}function t_(e){return e.getAllEntries().map(([e,t])=>{let n=`${encodeURIComponent(e)}=${encodeURIComponent(t.value)}`;return t.metadata!==void 0&&(n+=`;`+t.metadata.toString()),n})}function n_(e){if(!e)return;let t=e.indexOf(`;`),n=t===-1?e:e.substring(0,t),r=n.indexOf(`=`);if(r<=0)return;let i=n.substring(0,r).trim(),a=n.substring(r+1).trim();if(!i||!a)return;let o,s;try{o=decodeURIComponent(i),s=decodeURIComponent(a)}catch{return}let c;return t!==-1&&t<e.length-1&&(c=Lh(e.substring(t+1))),{key:o,value:s,metadata:c}}var r_=class{inject(e,t,n){let r=qg.getBaggage(e);if(!r||Zg(e))return;let i=e_(t_(r).filter(e=>e.length<=$g).slice(0,180));i.length>0&&n.set(t,Qg,i)}extract(e,t,n){let r=n.get(t,Qg),i=Array.isArray(r)?r.join(`,`):r;if(!i)return e;let a={};return i.length===0||(i.split(`,`).forEach(e=>{let t=n_(e);if(t){let e={value:t.value};t.metadata&&(e.metadata=t.metadata),a[t.key]=e}}),Object.entries(a).length===0)?e:qg.setBaggage(e,qg.createBaggage(a))}fields(){return[Qg]}};function i_(e){let t={};if(typeof e!=`object`||!e)return t;for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;if(!a_(n)){Q.warn(`Invalid attribute key: ${n}`);continue}let r=e[n];if(!o_(r)){Q.warn(`Invalid attribute value set for key: ${n}`);continue}Array.isArray(r)?t[n]=r.slice():t[n]=r}return t}function a_(e){return typeof e==`string`&&e!==``}function o_(e){return e==null?!0:Array.isArray(e)?s_(e):c_(typeof e)}function s_(e){let t;for(let n of e){if(n==null)continue;let e=typeof n;if(e!==t){if(!t){if(c_(e)){t=e;continue}return!1}return!1}}return!0}function c_(e){switch(e){case`number`:case`boolean`:case`string`:return!0}return!1}function l_(){return e=>{Q.error(u_(e))}}function u_(e){return typeof e==`string`?e:JSON.stringify(d_(e))}function d_(e){let t={},n=e;for(;n!==null;)Object.getOwnPropertyNames(n).forEach(e=>{if(t[e])return;let r=n[e];r&&(t[e]=String(r))}),n=Object.getPrototypeOf(n);return t}var f_=l_();function p_(e){try{f_(e)}catch{}}var m_=`2.7.1`,h_=`exception.message`,g_=`exception.stacktrace`,__=`exception.type`,v_=`service.name`,y_=`service.version`,b_=`telemetry.sdk.language`,x_=`nodejs`,S_=`webjs`,C_=`telemetry.sdk.name`,w_=`telemetry.sdk.version`,T_=`process.runtime.name`,E_={[C_]:`opentelemetry`,[T_]:`browser`,[b_]:S_,[w_]:m_},D_=performance,O_=9,k_=10**6,A_=10**O_;function j_(e){let t=e/1e3;return[Math.trunc(t),Math.round(e%1e3*k_)]}function M_(e){return R_(j_(D_.timeOrigin),j_(typeof e==`number`?e:D_.now()))}function N_(e){if(I_(e))return e;if(typeof e==`number`)return e<D_.timeOrigin?M_(e):j_(e);if(e instanceof Date)return j_(e.getTime());throw TypeError(`Invalid input type`)}function P_(e,t){let n=t[0]-e[0],r=t[1]-e[1];return r<0&&(--n,r+=A_),[n,r]}function F_(e){return e[0]*A_+e[1]}function I_(e){return Array.isArray(e)&&e.length===2&&typeof e[0]==`number`&&typeof e[1]==`number`}function L_(e){return I_(e)||typeof e==`number`||e instanceof Date}function R_(e,t){let n=[e[0]+t[0],e[1]+t[1]];return n[1]>=A_&&(n[1]-=A_,n[0]+=1),n}var z_;(function(e){e[e.SUCCESS=0]=`SUCCESS`,e[e.FAILED=1]=`FAILED`})(z_||={});var B_=class{_propagators;_fields;constructor(e={}){this._propagators=e.propagators??[];let t=new Set;for(let e of this._propagators){let n=typeof e.fields==`function`?e.fields():[];for(let e of n)t.add(e)}this._fields=Array.from(t)}inject(e,t,n){for(let r of this._propagators)try{r.inject(e,t,n)}catch(e){Q.warn(`Failed to inject with ${r.constructor.name}. Err: ${e.message}`)}}extract(e,t,n){return this._propagators.reduce((e,r)=>{try{return r.extract(e,t,n)}catch(e){Q.warn(`Failed to extract with ${r.constructor.name}. Err: ${e.message}`)}return e},e)}fields(){return this._fields.slice()}},V_=`[_0-9a-z-*/]`,H_=RegExp(`^(?:${`[a-z]${V_}{0,255}`}|${`[a-z0-9]${V_}{0,240}@[a-z]${V_}{0,13}`})$`),U_=/^[ -~]{0,255}[!-~]$/,W_=/,|=/;function G_(e){return H_.test(e)}function K_(e){return U_.test(e)&&!W_.test(e)}var q_=32,J_=512,Y_=`,`,X_=`=`,Z_=class e{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e==`string`?e:``,this._length=this._rawTraceState.length}set(e,t){if(!G_(e)||!K_(t))return this;let n=this._getState(),r=n.get(e),i=this._length;if(typeof r==`string`?i+=t.length-r.length:i+=e.length+t.length+(n.size>0?2:1),i>J_)return this;let a=new Map(n);return a.delete(e),a.set(e,t),this._fromState(a,i)}unset(e){let t=this._getState(),n=t.get(e);if(typeof n!=`string`)return this;let r=this._length-(e.length+n.length+1);t.size>1&&--r;let i=new Map(t);return i.delete(e),this._fromState(i,r)}get(e){return this._getState().get(e)}serialize(){let e=``,t=0;for(let n of this._getState())t>0&&(e=Y_+e),e=`${n[0]}${X_}${n[1]}`+e,t++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(Y_),t=new Map,n=0;for(let r of e){let e=r.trim(),i=e.indexOf(X_);if(i===-1)continue;let a=e.slice(0,i),o=e.slice(i+1);if(!G_(a)||!K_(o))continue;let s=n+e.length+ +(t.size>0);if(!(s>J_)&&(t.set(a,o),n=s,t.size>=q_))break}return this._length=n,this._internalState=new Map(Array.from(t.entries()).reverse()),this._internalState}_fromState(t,n){let r=Object.create(e.prototype);return r._internalState=t,r._length=n,r}},Q_=`traceparent`,$_=`tracestate`,ev=`00`,tv=RegExp(`^\\s?((?!ff)[\\da-f]{2})-((?![0]{32})[\\da-f]{32})-((?![0]{16})[\\da-f]{16})-([\\da-f]{2})(-.*)?\\s?$`);function nv(e){let t=tv.exec(e);return!t||t[1]===`00`&&t[5]?null:{traceId:t[2],spanId:t[3],traceFlags:parseInt(t[4],16)}}var rv=class{inject(e,t,n){let r=$.getSpanContext(e);if(!r||Zg(e)||!Eg(r))return;let i=`${ev}-${r.traceId}-${r.spanId}-0${Number(r.traceFlags||fg.NONE).toString(16)}`;n.set(t,Q_,i),r.traceState&&n.set(t,$_,r.traceState.serialize())}extract(e,t,n){let r=n.get(t,Q_);if(!r)return e;let i=Array.isArray(r)?r[0]:r;if(typeof i!=`string`)return e;let a=nv(i);if(!a)return e;a.isRemote=!0;let o=n.get(t,$_);if(o){let e=Array.isArray(o)?o.join(`,`):o;a.traceState=new Z_(typeof e==`string`?e:void 0)}return $.setSpanContext(e,a)}fields(){return[Q_,$_]}},iv=`[object Object]`,av=`[object Null]`,ov=`[object Undefined]`,sv=Function.prototype.toString,cv=sv.call(Object),lv=Object.getPrototypeOf,uv=Object.prototype,dv=uv.hasOwnProperty,fv=Symbol?Symbol.toStringTag:void 0,pv=uv.toString;function mv(e){if(!hv(e)||gv(e)!==iv)return!1;let t=lv(e);if(t===null)return!0;let n=dv.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&sv.call(n)===cv}function hv(e){return typeof e==`object`&&!!e}function gv(e){return e==null?e===void 0?ov:av:fv&&fv in Object(e)?_v(e):vv(e)}function _v(e){let t=dv.call(e,fv),n=e[fv],r=!1;try{e[fv]=void 0,r=!0}catch{}let i=pv.call(e);return r&&(t?e[fv]=n:delete e[fv]),i}function vv(e){return pv.call(e)}var yv=20;function bv(...e){let t=e.shift(),n=new WeakMap;for(;e.length>0;)t=Sv(t,e.shift(),0,n);return t}function xv(e){return wv(e)?e.slice():e}function Sv(e,t,n=0,r){let i;if(!(n>yv)){if(n++,Dv(e)||Dv(t)||Tv(t))i=xv(t);else if(wv(e)){if(i=e.slice(),wv(t))for(let e=0,n=t.length;e<n;e++)i.push(xv(t[e]));else if(Ev(t)){let e=Object.keys(t);for(let n=0,r=e.length;n<r;n++){let r=e[n];r===`__proto__`||r===`constructor`||r===`prototype`||(i[r]=xv(t[r]))}}}else if(Ev(e))if(Ev(t)){if(!Ov(e,t))return t;i=Object.assign({},e);let a=Object.keys(t);for(let o=0,s=a.length;o<s;o++){let s=a[o];if(s===`__proto__`||s===`constructor`||s===`prototype`)continue;let c=t[s];if(Dv(c))c===void 0?delete i[s]:i[s]=c;else{let a=i[s],o=c;if(Cv(e,s,r)||Cv(t,s,r))delete i[s];else{if(Ev(a)&&Ev(o)){let n=r.get(a)||[],i=r.get(o)||[];n.push({obj:e,key:s}),i.push({obj:t,key:s}),r.set(a,n),r.set(o,i)}i[s]=Sv(i[s],c,n,r)}}}}else i=t;return i}}function Cv(e,t,n){let r=n.get(e[t])||[];for(let n=0,i=r.length;n<i;n++){let i=r[n];if(i.key===t&&i.obj===e)return!0}return!1}function wv(e){return Array.isArray(e)}function Tv(e){return typeof e==`function`}function Ev(e){return!Dv(e)&&!wv(e)&&!Tv(e)&&typeof e==`object`}function Dv(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e===void 0||e instanceof Date||e instanceof RegExp||e===null}function Ov(e,t){return!(!mv(e)||!mv(t))}var kv=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function Av(e,t){let n,r=new Promise(function(e,r){n=setTimeout(function(){r(new kv(`Operation timed out.`))},t)});return Promise.race([e,r]).then(e=>(clearTimeout(n),e),e=>{throw clearTimeout(n),e})}var jv=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}},Mv=class{_isCalled=!1;_deferred=new jv;_callback;_that;constructor(e,t){this._callback=e,this._that=t}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(e=>this._deferred.resolve(e),e=>this._deferred.reject(e))}catch(e){this._deferred.reject(e)}}return this._deferred.promise}};function Nv(e,t){return new Promise(n=>{Rg.with(Xg(Rg.active()),()=>{e.export(t,n)})})}var Pv={_export:Nv},Fv;function Iv(){if(Fv===void 0)try{let e=globalThis.process.argv0;Fv=e?`unknown_service:${e}`:`unknown_service`}catch{Fv=`unknown_service`}return Fv}var Lv=e=>typeof e==`object`&&!!e&&typeof e.then==`function`,Rv=class e{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(t,n){let r=new e({},n);return r._rawAttributes=Vv(t),r._asyncAttributesPending=t.filter(([e,t])=>Lv(t)).length>0,r}constructor(e,t){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([e,t])=>(Lv(t)&&(this._asyncAttributesPending=!0),[e,t])),this._rawAttributes=Vv(this._rawAttributes),this._schemaUrl=Hv(t?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[t,n]=this._rawAttributes[e];this._rawAttributes[e]=[t,Lv(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&Q.error(`Accessing resource attributes before async attributes settled`),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[t,n]of this._rawAttributes){if(Lv(n)){Q.debug(`Unsettled resource attribute ${t} skipped`);continue}n!=null&&(e[t]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(t){if(t==null)return this;let n=Uv(this,t),r=n?{schemaUrl:n}:void 0;return e.FromAttributeList([...t.getRawAttributes(),...this.getRawAttributes()],r)}};function zv(e,t){return Rv.FromAttributeList(Object.entries(e),t)}function Bv(){return zv({[v_]:Iv(),[b_]:E_[b_],[C_]:E_[C_],[w_]:E_[w_]})}function Vv(e){return e.map(([e,t])=>Lv(t)?[e,t.catch(t=>{Q.debug(`promise rejection for resource attribute: %s - %s`,e,t)})]:[e,t])}function Hv(e){if(typeof e==`string`||e===void 0)return e;Q.warn(`Schema URL must be string or undefined, got %s. Schema URL will be ignored.`,e)}function Uv(e,t){let n=e?.schemaUrl,r=t?.schemaUrl,i=n===void 0||n===``,a=r===void 0||r===``;if(i)return r;if(a||n===r)return n;Q.warn(`Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.`,n,r)}var Wv=`exception`,Gv=class{_spanContext;kind;parentSpanContext;attributes={};links=[];events=[];startTime;resource;instrumentationScope;_droppedAttributesCount=0;_droppedEventsCount=0;_droppedLinksCount=0;_attributesCount=0;name;status={code:Lg.UNSET};endTime=[0,0];_ended=!1;_duration=[-1,-1];_spanProcessor;_spanLimits;_attributeValueLengthLimit;_recordEndMetrics;_performanceStartTime;_performanceOffset;_startTimeProvided;constructor(e){let t=Date.now();if(this._spanContext=e.spanContext,this._performanceStartTime=D_.now(),this._performanceOffset=t-(this._performanceStartTime+D_.timeOrigin),this._startTimeProvided=e.startTime!=null,this._spanLimits=e.spanLimits,this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit??0,this._spanProcessor=e.spanProcessor,this.name=e.name,this.parentSpanContext=e.parentSpanContext,this.kind=e.kind,e.links)for(let t of e.links)this.addLink(t);this.startTime=this._getTime(e.startTime??t),this.resource=e.resource,this.instrumentationScope=e.scope,this._recordEndMetrics=e.recordEndMetrics,e.attributes!=null&&this.setAttributes(e.attributes),this._spanProcessor.onStart(this,e.context)}spanContext(){return this._spanContext}setAttribute(e,t){if(t==null||this._isSpanEnded())return this;if(e.length===0)return Q.warn(`Invalid attribute key: ${e}`),this;if(!o_(t))return Q.warn(`Invalid attribute value set for key: ${e}`),this;let{attributeCountLimit:n}=this._spanLimits,r=!Object.prototype.hasOwnProperty.call(this.attributes,e);return n!==void 0&&this._attributesCount>=n&&r?(this._droppedAttributesCount++,this):(this.attributes[e]=this._truncateToSize(t),r&&this._attributesCount++,this)}setAttributes(e){for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.setAttribute(t,e[t]);return this}addEvent(e,t,n){if(this._isSpanEnded())return this;let{eventCountLimit:r}=this._spanLimits;if(r===0)return Q.warn(`No events allowed.`),this._droppedEventsCount++,this;r!==void 0&&this.events.length>=r&&(this._droppedEventsCount===0&&Q.debug(`Dropping extra events.`),this.events.shift(),this._droppedEventsCount++),L_(t)&&(L_(n)||(n=t),t=void 0);let i=i_(t),{attributePerEventCountLimit:a}=this._spanLimits,o={},s=0,c=0;for(let e in i){if(!Object.prototype.hasOwnProperty.call(i,e))continue;let t=i[e];if(a!==void 0&&c>=a){s++;continue}o[e]=this._truncateToSize(t),c++}return this.events.push({name:e,attributes:o,time:this._getTime(n),droppedAttributesCount:s}),this}addLink(e){if(this._isSpanEnded())return this;let{linkCountLimit:t}=this._spanLimits;if(t===0)return this._droppedLinksCount++,this;t!==void 0&&this.links.length>=t&&(this._droppedLinksCount===0&&Q.debug(`Dropping extra links.`),this.links.shift(),this._droppedLinksCount++);let{attributePerLinkCountLimit:n}=this._spanLimits,r=i_(e.attributes),i={},a=0,o=0;for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e))continue;let t=r[e];if(n!==void 0&&o>=n){a++;continue}i[e]=this._truncateToSize(t),o++}let s={context:e.context};return o>0&&(s.attributes=i),a>0&&(s.droppedAttributesCount=a),this.links.push(s),this}addLinks(e){for(let t of e)this.addLink(t);return this}setStatus(e){if(this._isSpanEnded()||e.code===Lg.UNSET||this.status.code===Lg.OK)return this;let t={code:e.code};return e.code===Lg.ERROR&&(typeof e.message==`string`?t.message=e.message:e.message!=null&&Q.warn(`Dropping invalid status.message of type '${typeof e.message}', expected 'string'`)),this.status=t,this}updateName(e){return this._isSpanEnded()||(this.name=e),this}end(e){if(this._isSpanEnded()){Q.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`);return}this.endTime=this._getTime(e),this._duration=P_(this.startTime,this.endTime),this._duration[0]<0&&(Q.warn(`Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.`,this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0]),this._droppedEventsCount>0&&Q.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._droppedLinksCount>0&&Q.warn(`Dropped ${this._droppedLinksCount} links because linkCountLimit reached`),this._spanProcessor.onEnding&&this._spanProcessor.onEnding(this),this._recordEndMetrics?.(),this._ended=!0,this._spanProcessor.onEnd(this)}_getTime(e){if(typeof e==`number`&&e<=D_.now())return M_(e+this._performanceOffset);if(typeof e==`number`)return j_(e);if(e instanceof Date)return j_(e.getTime());if(I_(e))return e;if(this._startTimeProvided)return j_(Date.now());let t=D_.now()-this._performanceStartTime;return R_(this.startTime,j_(t))}isRecording(){return this._ended===!1}recordException(e,t){let n={};typeof e==`string`?n[h_]=e:e&&(e.code?n[__]=e.code.toString():e.name&&(n[__]=e.name),e.message&&(n[h_]=e.message),e.stack&&(n[g_]=e.stack)),n[`exception.type`]||n[`exception.message`]?this.addEvent(Wv,n,t):Q.warn(`Failed to record an exception ${e}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){let e=Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);Q.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,e)}return this._ended}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_truncateToSize(e){let t=this._attributeValueLengthLimit;return t<=0?(Q.warn(`Attribute value limit must be positive, got ${t}`),e):typeof e==`string`?this._truncateToLimitUtil(e,t):Array.isArray(e)?e.map(e=>typeof e==`string`?this._truncateToLimitUtil(e,t):e):e}},Kv;(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(Kv||={});var qv=class{shouldSample(){return{decision:Kv.NOT_RECORD}}toString(){return`AlwaysOffSampler`}},Jv=class{shouldSample(){return{decision:Kv.RECORD_AND_SAMPLED}}toString(){return`AlwaysOnSampler`}},Yv=class{_root;_remoteParentSampled;_remoteParentNotSampled;_localParentSampled;_localParentNotSampled;constructor(e){this._root=e.root,this._root||=(p_(Error(`ParentBasedSampler must have a root sampler configured`)),new Jv),this._remoteParentSampled=e.remoteParentSampled??new Jv,this._remoteParentNotSampled=e.remoteParentNotSampled??new qv,this._localParentSampled=e.localParentSampled??new Jv,this._localParentNotSampled=e.localParentNotSampled??new qv}shouldSample(e,t,n,r,i,a){let o=$.getSpanContext(e);return!o||!Eg(o)?this._root.shouldSample(e,t,n,r,i,a):o.isRemote?o.traceFlags&fg.SAMPLED?this._remoteParentSampled.shouldSample(e,t,n,r,i,a):this._remoteParentNotSampled.shouldSample(e,t,n,r,i,a):o.traceFlags&fg.SAMPLED?this._localParentSampled.shouldSample(e,t,n,r,i,a):this._localParentNotSampled.shouldSample(e,t,n,r,i,a)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}},Xv=class{_ratio;_upperBound;constructor(e=0){this._ratio=this._normalize(e),this._upperBound=Math.floor(this._ratio*4294967295)}shouldSample(e,t){return{decision:wg(t)&&this._accumulate(t)<this._upperBound?Kv.RECORD_AND_SAMPLED:Kv.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(e){return typeof e!=`number`||isNaN(e)?0:e>=1?1:e<=0?0:e}_accumulate(e){let t=0;for(let n=0;n<32;n+=8){let r=0;for(let t=0;t<8;t++){let i=e.charCodeAt(n+t),a=i<58?i-48:i<71?i-55:i-87;r=r<<4|a}t=(t^r)>>>0}return t}},Zv;(function(e){e.AlwaysOff=`always_off`,e.AlwaysOn=`always_on`,e.ParentBasedAlwaysOff=`parentbased_always_off`,e.ParentBasedAlwaysOn=`parentbased_always_on`,e.ParentBasedTraceIdRatio=`parentbased_traceidratio`,e.TraceIdRatio=`traceidratio`})(Zv||={});var Qv=1;function $v(){return{sampler:ey(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128},spanLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128,linkCountLimit:128,eventCountLimit:128,attributePerEventCountLimit:128,attributePerLinkCountLimit:128}}}function ey(){let e=Zv.ParentBasedAlwaysOn;switch(e){case Zv.AlwaysOn:return new Jv;case Zv.AlwaysOff:return new qv;case Zv.ParentBasedAlwaysOn:return new Yv({root:new Jv});case Zv.ParentBasedAlwaysOff:return new Yv({root:new qv});case Zv.TraceIdRatio:return new Xv(ty());case Zv.ParentBasedTraceIdRatio:return new Yv({root:new Xv(ty())});default:return Q.error(`OTEL_TRACES_SAMPLER value "${e}" invalid, defaulting to "${Zv.ParentBasedAlwaysOn}".`),new Yv({root:new Jv})}}function ty(){return Q.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${Qv}.`),Qv}function ny(e){let t={sampler:ey()},n=$v(),r=Object.assign({},n,t,e);return r.generalLimits=Object.assign({},n.generalLimits,e.generalLimits||{}),r.spanLimits=Object.assign({},n.spanLimits,e.spanLimits||{}),r}function ry(e){let t=Object.assign({},e.spanLimits);return t.attributeCountLimit=e.spanLimits?.attributeCountLimit??e.generalLimits?.attributeCountLimit??void 0??void 0??128,t.attributeValueLengthLimit=e.spanLimits?.attributeValueLengthLimit??e.generalLimits?.attributeValueLengthLimit??void 0??void 0??1/0,Object.assign({},e,{spanLimits:t})}var iy=16,ay=8,oy=new Uint8Array(iy),sy=new Uint8Array(ay),cy=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function ly(e){for(let t=0;t<e.length;t++)e[t]=Math.random()*256>>>0;for(let t=0;t<e.length;t++)if(e[t]>0)return;e[e.length-1]=1}function uy(e){let t=``;for(let n=0;n<e.length;n++)t+=cy[e[n]];return t}var dy=class{generateTraceId(){return ly(oy),uy(oy)}generateSpanId(){return ly(sy),uy(sy)}},fy=`otel.span.parent.origin`,py=`otel.span.sampling_result`,my=`otel.sdk.span.live`,hy=`otel.sdk.span.started`,gy=class{startedSpans;liveSpans;constructor(e){this.startedSpans=e.createCounter(hy,{unit:`{span}`,description:`The number of created spans.`}),this.liveSpans=e.createUpDownCounter(my,{unit:`{span}`,description:`The number of currently live spans.`})}startSpan(e,t){let n=vy(t);if(this.startedSpans.add(1,{[fy]:_y(e),[py]:n}),t===Kv.NOT_RECORD)return()=>{};let r={[py]:n};return this.liveSpans.add(1,r),()=>{this.liveSpans.add(-1,r)}}};function _y(e){return e?e.isRemote?`remote`:`local`:`none`}function vy(e){switch(e){case Kv.RECORD_AND_SAMPLED:return`RECORD_AND_SAMPLE`;case Kv.RECORD:return`RECORD_ONLY`;case Kv.NOT_RECORD:return`DROP`}}var yy=`2.7.1`,by=class{_sampler;_generalLimits;_spanLimits;_idGenerator;instrumentationScope;_resource;_spanProcessor;_tracerMetrics;constructor(e,t,n,r){let i=ny(t);this._sampler=i.sampler,this._generalLimits=i.generalLimits,this._spanLimits=i.spanLimits,this._idGenerator=t.idGenerator||new dy,this._resource=n,this._spanProcessor=r,this.instrumentationScope=e;let a=i.meterProvider?i.meterProvider.getMeter(`@opentelemetry/sdk-trace`,yy):ig();this._tracerMetrics=new gy(a)}startSpan(e,t={},n=Rg.active()){t.root&&(n=$.deleteSpan(n));let r=$.getSpan(n);if(Zg(n))return Q.debug(`Instrumentation suppressed, returning Noop Span`),$.wrapSpanContext(pg);let i=r?.spanContext(),a=this._idGenerator.generateSpanId(),o,s,c;!i||!$.isSpanContextValid(i)?s=this._idGenerator.generateTraceId():(s=i.traceId,c=i.traceState,o=i);let l=t.kind??Ig.INTERNAL,u=(t.links??[]).map(e=>({context:e.context,attributes:i_(e.attributes)})),d=i_(t.attributes),f=this._sampler.shouldSample(n,s,e,l,d,u),p=this._tracerMetrics.startSpan(i,f.decision);c=f.traceState??c;let m=f.decision===Fg.RECORD_AND_SAMPLED?fg.SAMPLED:fg.NONE,ee={traceId:s,spanId:a,traceFlags:m,traceState:c};if(f.decision===Fg.NOT_RECORD)return Q.debug(`Recording is off, propagating context in a non-recording span`),$.wrapSpanContext(ee);let te=i_(Object.assign(d,f.attributes));return new Gv({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:ee,name:e,kind:l,links:u,parentSpanContext:o,attributes:te,startTime:t.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits,recordEndMetrics:p})}startActiveSpan(e,t,n,r){let i,a,o;if(arguments.length<2)return;arguments.length===2?o=t:arguments.length===3?(i=t,o=n):(i=t,a=n,o=r);let s=a??Rg.active(),c=this.startSpan(e,i,s),l=$.setSpan(s,c);return Rg.with(l,o,void 0,c)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}},xy=class{_spanProcessors;constructor(e){this._spanProcessors=e}forceFlush(){let e=[];for(let t of this._spanProcessors)e.push(t.forceFlush());return new Promise(t=>{Promise.all(e).then(()=>{t()}).catch(e=>{p_(e||Error(`MultiSpanProcessor: forceFlush failed`)),t()})})}onStart(e,t){for(let n of this._spanProcessors)n.onStart(e,t)}onEnding(e){for(let t of this._spanProcessors)t.onEnding&&t.onEnding(e)}onEnd(e){for(let t of this._spanProcessors)t.onEnd(e)}shutdown(){let e=[];for(let t of this._spanProcessors)e.push(t.shutdown());return new Promise((t,n)=>{Promise.all(e).then(()=>{t()},n)})}},Sy;(function(e){e[e.resolved=0]=`resolved`,e[e.timeout=1]=`timeout`,e[e.error=2]=`error`,e[e.unresolved=3]=`unresolved`})(Sy||={});var Cy=class{_config;_tracers=new Map;_resource;_activeSpanProcessor;constructor(e={}){let t=bv({},$v(),ry(e));this._resource=t.resource??Bv(),this._config=Object.assign({},t,{resource:this._resource});let n=[];e.spanProcessors?.length&&n.push(...e.spanProcessors),this._activeSpanProcessor=new xy(n)}getTracer(e,t,n){let r=`${e}@${t||``}:${n?.schemaUrl||``}`;return this._tracers.has(r)||this._tracers.set(r,new by({name:e,version:t,schemaUrl:n?.schemaUrl},this._config,this._resource,this._activeSpanProcessor)),this._tracers.get(r)}forceFlush(){let e=this._config.forceFlushTimeoutMillis,t=this._activeSpanProcessor._spanProcessors.map(t=>new Promise(n=>{let r,i=setTimeout(()=>{n(Error(`Span processor did not completed within timeout period of ${e} ms`)),r=Sy.timeout},e);t.forceFlush().then(()=>{clearTimeout(i),r!==Sy.timeout&&(r=Sy.resolved,n(r))}).catch(e=>{clearTimeout(i),r=Sy.error,n(e)})}));return new Promise((e,n)=>{Promise.all(t).then(t=>{let r=t.filter(e=>e!==Sy.resolved);r.length>0?n(r):e()}).catch(e=>n([e]))})}shutdown(){return this._activeSpanProcessor.shutdown()}},wy=class{_exporter;_shutdownOnce;_pendingExports;constructor(e){this._exporter=e,this._shutdownOnce=new Mv(this._shutdown,this),this._pendingExports=new Set}async forceFlush(){await Promise.all(Array.from(this._pendingExports)),this._exporter.forceFlush&&await this._exporter.forceFlush()}onStart(e,t){}onEnd(e){if(this._shutdownOnce.isCalled||(e.spanContext().traceFlags&fg.SAMPLED)===0)return;let t=this._doExport(e).catch(e=>p_(e));this._pendingExports.add(t),t.finally(()=>this._pendingExports.delete(t))}async _doExport(e){e.resource.asyncAttributesPending&&await e.resource.waitForAsyncAttributes?.();let t=await Pv._export(this._exporter,[e]);if(t.code!==z_.SUCCESS)throw t.error??Error(`SimpleSpanProcessor: span export failed (status ${t})`)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return this._exporter.shutdown()}},Ty=class{_enabled=!1;_currentContext=zh;_bindFunction(e=zh,t){let n=this,r=function(...r){return n.with(e,()=>t.apply(this,r))};return Object.defineProperty(r,"length",{enumerable:!1,configurable:!0,writable:!1,value:t.length}),r}active(){return this._currentContext}bind(e,t){return e===void 0&&(e=this.active()),typeof t==`function`?this._bindFunction(e,t):t}disable(){return this._currentContext=zh,this._enabled=!1,this}enable(){return this._enabled?this:(this._enabled=!0,this._currentContext=zh,this)}with(e,t,n,...r){let i=this._currentContext;this._currentContext=e||zh;try{return t.call(n,...r)}finally{this._currentContext=i}}};function Ey(e){if(e!==null){if(e===void 0){let e=new Ty;e.enable(),Rg.setGlobalContextManager(e);return}e.enable(),Rg.setGlobalContextManager(e)}}function Dy(e){if(e!==null){if(e===void 0){qg.setGlobalPropagator(new B_({propagators:[new rv,new r_]}));return}qg.setGlobalPropagator(e)}}var Oy=class extends Cy{constructor(e={}){super(e)}register(e={}){$.setGlobalTracerProvider(this),Dy(e.propagator),Ey(e.contextManager)}},ky=e=>e!==void 0&&!(Array.isArray(e)&&e.length===0),Ay;(function(e){e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TRACE=1]=`TRACE`,e[e.TRACE2=2]=`TRACE2`,e[e.TRACE3=3]=`TRACE3`,e[e.TRACE4=4]=`TRACE4`,e[e.DEBUG=5]=`DEBUG`,e[e.DEBUG2=6]=`DEBUG2`,e[e.DEBUG3=7]=`DEBUG3`,e[e.DEBUG4=8]=`DEBUG4`,e[e.INFO=9]=`INFO`,e[e.INFO2=10]=`INFO2`,e[e.INFO3=11]=`INFO3`,e[e.INFO4=12]=`INFO4`,e[e.WARN=13]=`WARN`,e[e.WARN2=14]=`WARN2`,e[e.WARN3=15]=`WARN3`,e[e.WARN4=16]=`WARN4`,e[e.ERROR=17]=`ERROR`,e[e.ERROR2=18]=`ERROR2`,e[e.ERROR3=19]=`ERROR3`,e[e.ERROR4=20]=`ERROR4`,e[e.FATAL=21]=`FATAL`,e[e.FATAL2=22]=`FATAL2`,e[e.FATAL3=23]=`FATAL3`,e[e.FATAL4=24]=`FATAL4`})(Ay||={});var jy=new class{emit(e){}enabled(){return!1}};function My(e){return Ny(e,new WeakSet)}function Ny(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e instanceof Uint8Array)return!0;if(typeof e==`object`){if(t.has(e))return!1;if(t.add(e),Array.isArray(e))return e.every(e=>Ny(e,t));let n=e;return n.constructor!==Object&&n.constructor!==void 0?!1:Object.values(n).every(e=>Ny(e,t))}return!1}var Py=class{hrTime;hrTimeObserved;spanContext;resource;instrumentationScope;attributes={};_severityText;_severityNumber;_body;_eventName;_attributesCount=0;_droppedAttributesCount=0;_isReadonly=!1;_logRecordLimits;set severityText(e){this._isLogRecordReadonly()||(this._severityText=e)}get severityText(){return this._severityText}set severityNumber(e){this._isLogRecordReadonly()||(this._severityNumber=e)}get severityNumber(){return this._severityNumber}set body(e){this._isLogRecordReadonly()||(this._body=e)}get body(){return this._body}get eventName(){return this._eventName}set eventName(e){this._isLogRecordReadonly()||(this._eventName=e)}get droppedAttributesCount(){return this._droppedAttributesCount}constructor(e,t,n){let{timestamp:r,observedTimestamp:i,eventName:a,severityNumber:o,severityText:s,body:c,attributes:l={},exception:u,context:d}=n,f=Date.now();if(this.hrTime=N_(r??f),this.hrTimeObserved=N_(i??f),d){let e=$.getSpanContext(d);e&&Eg(e)&&(this.spanContext=e)}this.severityNumber=o,this.severityText=s,this.body=c,this.resource=e.resource,this.instrumentationScope=t,this._logRecordLimits=e.logRecordLimits,this._eventName=a,this.setAttributes(l),u!=null&&this._setException(u)}setAttribute(e,t){if(this._isLogRecordReadonly())return this;if(e.length===0)return Q.warn(`Invalid attribute key: ${e}`),this;if(!My(t))return Q.warn(`Invalid attribute value set for key: ${e}`),this;let n=!Object.prototype.hasOwnProperty.call(this.attributes,e);return n&&this._attributesCount>=this._logRecordLimits.attributeCountLimit?(this._droppedAttributesCount++,this._droppedAttributesCount===1&&Q.warn(`Dropping extra attributes.`),this):(this.attributes[e]=this._truncateToSize(t),n&&this._attributesCount++,this)}setAttributes(e){for(let[t,n]of Object.entries(e))this.setAttribute(t,n);return this}setBody(e){return this.body=e,this}setEventName(e){return this.eventName=e,this}setSeverityNumber(e){return this.severityNumber=e,this}setSeverityText(e){return this.severityText=e,this}_makeReadonly(){this._isReadonly=!0}_truncateToSize(e){let t=this._logRecordLimits.attributeValueLengthLimit;if(t<=0)return Q.warn(`Attribute value limit must be positive, got ${t}`),e;if(e==null)return e;if(typeof e==`string`)return this._truncateToLimitUtil(e,t);if(e instanceof Uint8Array)return e;if(Array.isArray(e))return e.map(e=>this._truncateToSize(e));if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=this._truncateToSize(r);return t}return e}_setException(e){let t=!1;if(typeof e==`string`||typeof e==`number`)Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(h_,String(e)),t=!0;else if(e&&typeof e==`object`){let n=e;n.code?(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(__,n.code.toString()),t=!0):n.name&&(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(__,n.name),t=!0),n.message&&(Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(h_,n.message),t=!0),n.stack&&(Object.hasOwn(this.attributes,`exception.stacktrace`)||this.setAttribute(g_,n.stack),t=!0)}t||Q.warn(`Failed to record an exception ${e}`)}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_isLogRecordReadonly(){return this._isReadonly&&Q.warn(`Can not execute the operation on emitted log record`),this._isReadonly}},Fy=class{instrumentationScope;_sharedState;_loggerConfig;constructor(e,t){this.instrumentationScope=e,this._sharedState=t,this._loggerConfig=this._sharedState.getLoggerConfig(this.instrumentationScope)}emit(e){let t=e.context||Rg.active();if(!this.enabled(e))return;let n=new Py(this._sharedState,this.instrumentationScope,{context:t,...e});this._sharedState.loggerMetrics.emitLog(),this._sharedState.activeProcessor.onEmit(n,t),n._makeReadonly()}enabled(e){let t=this._loggerConfig;if(t.disabled)return!1;let n=e?.severityNumber;if(typeof n==`number`&&n!==Ay.UNSPECIFIED&&n<t.minimumSeverity)return!1;let r=e?.context||Rg.active();if(t.traceBased){let e=$.getSpanContext(r);if(e&&Eg(e)&&(e.traceFlags&fg.SAMPLED)!==fg.SAMPLED)return!1}let i={context:r,instrumentationScope:this.instrumentationScope,severityNumber:e?.severityNumber,eventName:e?.eventName};for(let e of this._sharedState.processors)if(!e.enabled||e.enabled(i))return!0;return!1}},Iy=class{forceFlush(){return Promise.resolve()}onEmit(e,t){}shutdown(){return Promise.resolve()}enabled(e){return!1}},Ly=class{processors;forceFlushTimeoutMillis;constructor(e,t){this.processors=e,this.forceFlushTimeoutMillis=t}async forceFlush(){let e=this.forceFlushTimeoutMillis;await Promise.all(this.processors.map(t=>Av(t.forceFlush(),e)))}onEmit(e,t){this.processors.forEach(n=>n.onEmit(e,t))}async shutdown(){await Promise.all(this.processors.map(e=>e.shutdown()))}enabled(e){for(let t of this.processors)if(!t.enabled||t.enabled(e))return!0;return!1}};function Ry(e){return`${e.name}@${e.version||``}:${e.schemaUrl||``}`}var zy=`otel.sdk.log.created`,By=class{createdLogs;constructor(e){this.createdLogs=e.createCounter(zy,{unit:`{log_record}`,description:`The number of logs submitted to enabled SDK Loggers.`})}emitLog(){this.createdLogs.add(1)}},Vy=`0.218.0`,Hy={disabled:!1,minimumSeverity:Ay.UNSPECIFIED,traceBased:!1},Uy=()=>({...Hy}),Wy=class{loggers=new Map;activeProcessor;registeredLogRecordProcessors=[];resource;forceFlushTimeoutMillis;logRecordLimits;processors;loggerMetrics;_loggerConfigurator;_loggerConfigs=new Map;constructor(e,t,n,r,i,a){this.resource=e,this.forceFlushTimeoutMillis=t,this.logRecordLimits=n,this.processors=r,r.length>0?(this.registeredLogRecordProcessors=r,this.activeProcessor=new Ly(this.registeredLogRecordProcessors,this.forceFlushTimeoutMillis)):this.activeProcessor=new Iy,this._loggerConfigurator=i??Uy;let o=a?a.getMeter(`@opentelemetry/sdk-logs`,Vy):ig();this.loggerMetrics=new By(o)}getLoggerConfig(e){let t=Ry(e),n=this._loggerConfigs.get(t);return n||(n=this._loggerConfigurator(e),this._loggerConfigs.set(t,n),n)}},Gy=class{_shutdownOnce;_sharedState;constructor(e={}){let t={resource:e.resource??Bv(),forceFlushTimeoutMillis:e.forceFlushTimeoutMillis??3e4,logRecordLimits:{attributeCountLimit:e.logRecordLimits?.attributeCountLimit??128,attributeValueLengthLimit:e.logRecordLimits?.attributeValueLengthLimit??1/0},loggerConfigurator:e.loggerConfigurator??Uy,processors:e.processors??[],meterProvider:e.meterProvider};this._sharedState=new Wy(t.resource,t.forceFlushTimeoutMillis,t.logRecordLimits,t.processors,t.loggerConfigurator,t.meterProvider),this._shutdownOnce=new Mv(this._shutdown,this)}getLogger(e,t,n){if(this._shutdownOnce.isCalled)return Q.warn(`A shutdown LoggerProvider cannot provide a Logger`),jy;e||Q.warn(`Logger requested without instrumentation scope name.`);let r=e||`unknown`,i=`${r}@${t||``}:${n?.schemaUrl||``}`;return this._sharedState.loggers.has(i)||this._sharedState.loggers.set(i,new Fy({name:r,version:t,schemaUrl:n?.schemaUrl},this._sharedState)),this._sharedState.loggers.get(i)}forceFlush(){return this._shutdownOnce.isCalled?(Q.warn(`invalid attempt to force flush after LoggerProvider shutdown`),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush()}shutdown(){return this._shutdownOnce.isCalled?(Q.warn(`shutdown may only be called once per LoggerProvider`),this._shutdownOnce.promise):this._shutdownOnce.call()}_shutdown(){return this._sharedState.activeProcessor.shutdown()}},Ky=xr,qy=Fr,Jy=(e,t)=>Zn(Ky,Or(Br(function*(n){let r=new Set(t?.mergeWithExisting===!0?n.getRef(xr):[]);for(let t of e)r.add(Zr(t)?yield*t:t);return r}))),Yy=BigInt(1e9),Xy=e=>[Number(e/Yy),Number(e%Yy)],Zy=e=>{let t={};for(let[n,r]of Object.entries(e))t[n]=Qy(r);return t},Qy=e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:typeof e==`bigint`?e.toString():Xn(e),$y=class extends j()(`@effect/opentelemetry/Resource`){},eb=e=>Ur($y,zv(tb(e))),tb=e=>{let t={...e.attributes??void 0,[v_]:e.serviceName,[C_]:`@effect/opentelemetry`,[b_]:globalThis.document===void 0?x_:S_};return e.serviceVersion&&(t[y_]=e.serviceVersion),t},nb=class extends j()(`@effect/opentelemetry/Logger/OtelLoggerProvider`){},rb=e=>{switch(e){case`Trace`:return Ay.TRACE;case`Debug`:return Ay.DEBUG;case`Info`:return Ay.INFO;case`Warn`:return Ay.WARN;case`Error`:return Ay.ERROR;case`Fatal`:return Ay.FATAL;default:return Ay.UNSPECIFIED}},ib=ei(function*(){let e=yield*nb,t=yield*Gi,n=e.getLogger(`@effect/opentelemetry`);return qy(e=>{let r={fiberId:e.fiber.id},i=Hn(e.fiber.context,dn);Ge(i)&&(r.spanId=i.spanId,r.traceId=i.traceId);for(let[t,n]of Object.entries(e.fiber.getRef(Ht)))r[t]=Qy(n);let a=e.date.getTime();for(let[t,n]of e.fiber.getRef(pa))r[`logSpan.${t}`]=`${a-n}ms`;let o=ia(e.message).map(Qy),s=Xy(t.currentTimeNanosUnsafe());n.emit({body:o.length===1?o[0]:o,severityText:e.logLevel,severityNumber:rb(e.logLevel),timestamp:s,observedTimestamp:s,attributes:r})})}),ab=e=>Jy([ib],{mergeWithExisting:e.mergeWithExisting??!0}),ob=(e,t)=>Zn(nb,ei(function*(){let n=yield*$y;return yield*Wr(M(()=>new Gy({...t??void 0,processors:ia(e),resource:n})),e=>oa(()=>e.forceFlush().then(()=>e.shutdown())).pipe(Ci,Wn,on(t?.shutdownTimeout??3e3)))})),sb;(function(e){e[e.DELTA=0]=`DELTA`,e[e.CUMULATIVE=1]=`CUMULATIVE`})(sb||={});var cb;(function(e){e.COUNTER=`COUNTER`,e.GAUGE=`GAUGE`,e.HISTOGRAM=`HISTOGRAM`,e.UP_DOWN_COUNTER=`UP_DOWN_COUNTER`,e.OBSERVABLE_COUNTER=`OBSERVABLE_COUNTER`,e.OBSERVABLE_GAUGE=`OBSERVABLE_GAUGE`,e.OBSERVABLE_UP_DOWN_COUNTER=`OBSERVABLE_UP_DOWN_COUNTER`})(cb||={});var lb;(function(e){e[e.HISTOGRAM=0]=`HISTOGRAM`,e[e.EXPONENTIAL_HISTOGRAM=1]=`EXPONENTIAL_HISTOGRAM`,e[e.GAUGE=2]=`GAUGE`,e[e.SUM=3]=`SUM`})(lb||={});var ub=`@effect/opentelemetry/Metrics`,db=class{resource;context;temporality;startTimes;startTimeNanos;previousExportTimeNanos;previousCounterState;previousHistogramState;previousFrequencyState;previousSummaryState;constructor(e,t,n=`cumulative`){this.resource=e,this.context=t,this.temporality=n,this.startTimes=new Map,this.startTimeNanos=pb(),this.previousExportTimeNanos=this.startTimeNanos,this.previousCounterState=new Map,this.previousHistogramState=new Map,this.previousFrequencyState=new Map,this.previousSummaryState=new Map}startTimeFor(e,t){return this.startTimes.has(e)?this.startTimes.get(e):(this.startTimes.set(e,t),t)}collect(e){let t=ni(this.context),n=pb(),r=[],i=new Map,a=e=>{r.push(e),i.set(e.descriptor.name,e)},o=this.temporality===`delta`,s=o?sb.DELTA:sb.CUMULATIVE,c=o?this.previousExportTimeNanos:this.startTimeNanos;for(let e=0,r=t.length;e<r;e++){let r=t[e],l=r.attributes?Se(Object.entries(r.attributes),{},(e,[t,n])=>(e[t]=String(n),e)):{},u=fb(r.id,r.attributes);switch(r.type){case`Counter`:{let e=r.state.count,t=e;if(o){let n=this.previousCounterState.get(u);if(n!==void 0)if(typeof e==`bigint`&&typeof n==`bigint`)t=e-n,t<BigInt(0)&&(t=e);else{let r=Number(e);t=r-Number(n),t<0&&(t=r)}this.previousCounterState.set(u,e)}let d=mb(r,l),f={startTime:this.startTimeFor(d.name,c),endTime:n,attributes:l,value:Number(t)};i.has(r.id)?i.get(r.id).dataPoints.push(f):a({dataPointType:lb.SUM,descriptor:d,isMonotonic:r.state.incremental,aggregationTemporality:s,dataPoints:[f]});break}case`Gauge`:{let e=mb(r,l),t={startTime:this.startTimeFor(e.name,this.startTimeNanos),endTime:n,attributes:l,value:Number(r.state.value)};i.has(r.id)?i.get(r.id).dataPoints.push(t):a({dataPointType:lb.GAUGE,descriptor:e,aggregationTemporality:sb.CUMULATIVE,dataPoints:[t]});break}case`Histogram`:{let e=r.state.buckets.length,t={boundaries:ar(e-1),counts:ar(e)},d=0,f=0;for(let[n,i]of r.state.buckets)d<e-1&&(t.boundaries[d]=n),t.counts[d]=i-f,f=i,d++;let p=r.state.count,m=r.state.sum,ee=t.counts,te=r.state.min,ne=r.state.max;if(o){let e=this.previousHistogramState.get(u);e!==void 0&&(p=r.state.count-e.count,m=r.state.sum-e.sum,ee=t.counts.map((t,n)=>Math.max(0,t-(e.bucketCounts[n]??0)))),this.previousHistogramState.set(u,{count:r.state.count,sum:r.state.sum,bucketCounts:t.counts.slice(),min:r.state.min,max:r.state.max})}let re=mb(r,l),h={startTime:this.startTimeFor(re.name,c),endTime:n,attributes:l,value:{buckets:{boundaries:t.boundaries,counts:ee},count:p,min:te,max:ne,sum:m}};i.has(r.id)?i.get(r.id).dataPoints.push(h):a({dataPointType:lb.HISTOGRAM,descriptor:re,aggregationTemporality:s,dataPoints:[h]});break}case`Frequency`:{let e=[],t=new Map;for(let[i,a]of r.state.occurrences){t.set(i,a);let s=a;if(o){let e=this.previousFrequencyState.get(u);if(e!==void 0){let t=e.get(i)??0;s=Math.max(0,a-t)}}let d=mb(r,l),f=this.startTimeFor(d.name,c);e.push({startTime:f,endTime:n,attributes:{...l,key:i},value:s})}if(o&&this.previousFrequencyState.set(u,t),i.has(r.id))i.get(r.id).dataPoints.push(...e);else{let t=mb(r,l);a({dataPointType:lb.SUM,descriptor:t,aggregationTemporality:s,isMonotonic:!0,dataPoints:e})}break}case`Summary`:{let e=[{startTime:c,endTime:n,attributes:{...l,quantile:`min`},value:r.state.min}];for(let[t,i]of r.state.quantiles)e.push({startTime:c,endTime:n,attributes:{...l,quantile:t.toString()},value:i??0});e.push({startTime:c,endTime:n,attributes:{...l,quantile:`max`},value:r.state.max});let t=r.state.count,d=r.state.sum;if(o){let e=this.previousSummaryState.get(u);e!==void 0&&(t=r.state.count-e.count,d=r.state.sum-e.sum),this.previousSummaryState.set(u,{count:r.state.count,sum:r.state.sum})}let f={startTime:c,endTime:n,attributes:l,value:t},p={startTime:c,endTime:n,attributes:l,value:d};if(i.has(`${r.id}_quantiles`))i.get(`${r.id}_quantiles`).dataPoints.push(...e),i.get(`${r.id}_count`).dataPoints.push(f),i.get(`${r.id}_sum`).dataPoints.push(p);else{let t=mb(r,l);a({dataPointType:lb.SUM,descriptor:{...t,name:`${t.name}_quantiles`},aggregationTemporality:s,isMonotonic:!1,dataPoints:e}),a({dataPointType:lb.SUM,descriptor:{name:`${r.id}_count`,description:r.description??``,unit:`1`,type:cb.COUNTER,valueType:ag.INT,advice:{}},aggregationTemporality:s,isMonotonic:!0,dataPoints:[f]}),a({dataPointType:lb.SUM,descriptor:{name:`${r.id}_sum`,description:r.description??``,unit:`1`,type:cb.COUNTER,valueType:ag.DOUBLE,advice:{}},aggregationTemporality:s,isMonotonic:!0,dataPoints:[p]})}break}}}return o&&(this.previousExportTimeNanos=n),Promise.resolve({resourceMetrics:{resource:this.resource,scopeMetrics:[{scope:{name:ub},metrics:r}]},errors:[]})}},fb=(e,t)=>{if(t===void 0||Object.keys(t).length===0)return e;let n=Object.entries(t).sort((e,t)=>e[0].localeCompare(t[0]));return`${e}:${JSON.stringify(n)}`},pb=()=>{let e=Date.now();return[Math.floor(e/1e3),e%1e3*1e6]},mb=(e,t)=>{let n=t.unit??t.time_unit??`1`;return{name:e.id,description:e.description??``,unit:n,type:hb(e),valueType:gb(e),advice:{}}},hb=e=>{switch(e.type){case`Histogram`:return cb.HISTOGRAM;case`Gauge`:return cb.OBSERVABLE_GAUGE;case`Frequency`:return cb.COUNTER;case`Counter`:return e.state.incremental?cb.COUNTER:cb.UP_DOWN_COUNTER;case`Summary`:return cb.COUNTER}},gb=e=>e.type===`Counter`?typeof e.state.count==`bigint`?ag.INT:ag.DOUBLE:e.type===`Gauge`&&typeof e.state.value==`bigint`?ag.INT:ag.DOUBLE,_b=e=>ei(function*(){return new db(yield*$y,yield*h(),e)}),vb=(e,t,n)=>Wr(M(()=>{let n=t(),r=Array.isArray(n)?n:[n];return r.forEach(t=>t.setMetricProducer(e)),r}),e=>oa(()=>Promise.all(e.map(e=>e.shutdown()))).pipe(Ci,Wn,on(n?.shutdownTimeout??3e3))),yb=(e,t)=>Jt(y(_b(t?.temporality),n=>vb(n,e,t))),bb=class extends j()(`@effect/opentelemetry/Tracer`){},xb=class extends j()(`@effect/opentelemetry/Tracer/OtelTracerProvider`){},Sb=class extends j()(`@effect/opentelemetry/Tracer/OtelTraceFlags`){},Cb=class extends j()(`@effect/opentelemetry/Tracer/OtelTraceState`){},wb=O(Ot(bb),e=>vn({span(t){return new kb(Rg,$,e,t)},context(e,t){let n=t.currentSpan;return n===void 0?e[`~effect/Effect/evaluate`](t):Rg.with(Ib(Rg.active(),n),()=>e[`~effect/Effect/evaluate`](t))}})),Tb=Zn(bb,ei(function*(){let e=yield*$y;return(yield*xb).getTracer(e.attributes[v_],e.attributes[y_])})),Eb=Zn(Le,wb).pipe(Tt(Tb)),Db=`~@effect/opentelemetry/Tracer/OtelSpan`,Ob={internal:Ig.INTERNAL,client:Ig.CLIENT,server:Ig.SERVER,producer:Ig.PRODUCER,consumer:Ig.CONSUMER},kb=class{[Db];_tag=`Span`;name;kind;annotations;links;span;spanId;traceId;attributes=new Map;sampled;parent;status;constructor(e,t,n,r){this[Db]=Db,this.name=r.name,this.annotations=r.annotations,this.links=r.links,this.kind=r.kind;let i=e.active();this.parent=r.root===!0?r.parent:Gn(r.parent,()=>jb(t,i,r.annotations)),this.span=n.startSpan(r.name,{startTime:Xy(r.startTime),links:r.links.length>0?r.links.map(e=>({context:Mb(e.span),attributes:Zy(e.attributes)})):void 0,kind:Ob[this.kind]},Ni(this.parent)?Ib(i,this.parent.value,r.annotations):$.deleteSpan(i));let a=this.span.spanContext();this.spanId=a.spanId,this.traceId=a.traceId,this.status={_tag:`Started`,startTime:r.startTime},this.sampled=Ab(a.traceFlags)}attribute(e,t){this.span.setAttribute(e,Qy(t)),this.attributes.set(e,t)}addLinks(e){this.links.push(...e),this.span.addLinks(e.map(e=>({context:Mb(e.span),attributes:Zy(e.attributes)})))}end(e,t){let n=Xy(e);if(this.status={_tag:`Ended`,endTime:e,exit:t,startTime:this.status.startTime},t._tag===`Success`)this.span.setStatus({code:Lg.OK});else if(Li(t.cause))this.span.setStatus({code:Lg.OK,message:ui(t.cause)}),this.span.setAttribute(`span.label`,`⚠︎ Interrupted`),this.span.setAttribute(`status.interrupted`,!0);else{let e=Yr(t.cause);if(e.length>0){for(let t of e)this.span.recordException(t,n);this.span.setStatus({code:Lg.ERROR,message:e[0].message})}else this.span.setStatus({code:Lg.OK})}this.span.end(n)}event(e,t,n){this.span.addEvent(e,n?Zy(n):void 0,Xy(t))}},Ab=e=>(e&fg.SAMPLED)===fg.SAMPLED,jb=(e,t,n)=>{let r=e.getSpan(t)?.spanContext();return r?A(an({spanId:r.spanId,traceId:r.traceId,sampled:(r.traceFlags&1)==1,annotations:n})):D()},Mb=(e,t)=>{let n=Nb(e,t),r=Pb(e,t);return{spanId:e.spanId,traceId:e.traceId,isRemote:e._tag===`ExternalSpan`,traceFlags:n,traceState:r}},Nb=(e,t)=>{let n;return Ge(t)&&(n=Fb(e,t,Sb),ne(n)&&(n=Hn(e.annotations,Sb))),n??fg.SAMPLED},Pb=(e,t)=>{let n;return Ge(t)&&(n=Fb(e,t,Cb),ne(n)&&(n=Hn(e.annotations,Cb))),n},Fb=(e,t,n)=>{let r=Hn(t,n);return Ge(r)?r:Hn(e.annotations,n)},Ib=(e,t,n)=>t instanceof kb?$.setSpan(e,t.span):$.setSpanContext(e,Mb(t,n)),Lb=(e,t)=>Zn(xb,ei(function*(){let n=yield*$y;return yield*Wr(M(()=>new Oy({...t??void 0,resource:n,spanProcessors:Array.isArray(e)?e:[e]})),e=>Ci(oa(()=>e.forceFlush().then(()=>e.shutdown()))))})),Rb=e=>d(ei(function*(){let t=yield*oi(e)?e:M(e),n=eb(t.resource),r=ky(t.spanProcessor)?pe(Eb,Lb(t.spanProcessor,t.tracerConfig)):se,i=ky(t.logRecordProcessor)?pe(ab({mergeWithExisting:t.loggerMergeWithExisting}),ob(t.logRecordProcessor,t.loggerProviderConfig)):se;return en(r,ky(t.metricReader)?yb(Me(t.metricReader),{temporality:t.metricTemporality}):se,i).pipe(Tt(n))})),zb=class{_delegate;constructor(e){this._delegate=e}export(e,t){this._delegate.export(e,t)}forceFlush(){return this._delegate.forceFlush()}shutdown(){return this._delegate.shutdown()}};function Bb(e,t){let n={attributes:Hb(e.attributes,t),droppedAttributesCount:0},r=e.schemaUrl;return r&&r!==``&&(n.schemaUrl=r),n}function Vb(e){return{name:e.name,version:e.version}}function Hb(e,t){return Object.keys(e).map(n=>Ub(n,e[n],t))}function Ub(e,t,n){return{key:e,value:Wb(t,n)}}function Wb(e,t){let n=typeof e;if(n===`string`)return{stringValue:e};if(n===`number`)return Number.isInteger(e)?{intValue:e}:{doubleValue:e};if(n===`boolean`)return{boolValue:e};if(e instanceof Uint8Array)return{bytesValue:t.encodeUint8Array(e)};if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=Wb(e[r],t);return{arrayValue:{values:n}}}if(n===`object`&&e!=null){let n=Object.keys(e),r=Array(n.length);for(let i=0;i<n.length;i++)r[i]={key:n[i],value:Wb(e[n[i]],t)};return{kvlistValue:{values:r}}}return{}}var Gb=256,Kb=512;function qb(e,t){let n=e&255|Gb;return t&&(n|=Kb),n}function Jb(e,t){let n=e.spanContext(),r=e.status,i=e.parentSpanContext?.spanId?t.encodeSpanContext(e.parentSpanContext?.spanId):void 0;return{traceId:t.encodeSpanContext(n.traceId),spanId:t.encodeSpanContext(n.spanId),parentSpanId:i,traceState:n.traceState?.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:Hb(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(e=>Xb(e,t)),droppedEventsCount:e.droppedEventsCount,status:{code:r.code,message:r.message},links:e.links.map(e=>Yb(e,t)),droppedLinksCount:e.droppedLinksCount,flags:qb(n.traceFlags,e.parentSpanContext?.isRemote)}}function Yb(e,t){return{attributes:e.attributes?Hb(e.attributes,t):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:e.context.traceState?.serialize(),droppedAttributesCount:e.droppedAttributesCount||0,flags:qb(e.context.traceFlags,e.context.isRemote)}}function Xb(e,t){return{attributes:e.attributes?Hb(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function Zb(e,t){return{resourceSpans:$b(e,t)}}function Qb(e){let t=new Map;for(let n of e){let e=t.get(n.resource);e||(e=new Map,t.set(n.resource,e));let r=`${n.instrumentationScope.name}@${n.instrumentationScope.version||``}:${n.instrumentationScope.schemaUrl||``}`,i=e.get(r);i||(i=[],e.set(r,i)),i.push(n)}return t}function $b(e,t){let n=Qb(e),r=[],i=n.entries(),a=i.next();for(;!a.done;){let[e,n]=a.value,o=[],s=n.values(),c=s.next();for(;!c.done;){let e=c.value;if(e.length>0){let n=e.map(e=>Jb(e,t));o.push({scope:Vb(e[0].instrumentationScope),spans:n,schemaUrl:e[0].instrumentationScope.schemaUrl})}c=s.next()}let l=Bb(e,t),u={resource:l,scopeSpans:o,schemaUrl:l.schemaUrl};r.push(u),a=i.next()}return r}function ex(e){let t=BigInt(1e9);return BigInt(Math.trunc(e[0]))*t+BigInt(Math.trunc(e[1]))}function tx(e){return ex(e).toString()}var nx=typeof BigInt<`u`?tx:F_;function rx(e){return e}var ix={encodeHrTime:nx,encodeSpanContext:rx,encodeOptionalSpanContext:rx,encodeUint8Array:e=>{if(typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=String.fromCharCode(e[n]);return btoa(t.join(``))}},ax={serializeRequest:e=>{let t=Zb(e,ix);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return Q.warn(`Failed to parse trace export response: ${e.message}. Returning empty response`),{}}}},ox=5,sx=1e3,cx=5e3,lx=1.5,ux=.2;function dx(){return 2*ux*Math.random()-ux}var fx=class{_transport;constructor(e){this._transport=e}retry(e,t,n){return new Promise((r,i)=>{setTimeout(()=>{this._transport.send(e,t).then(r,i)},n)})}async send(e,t){let n=ox,r=sx,i=Date.now()+t,a=await this._transport.send(e,t);for(;a.status===`retryable`&&n>0;){n--;let t=Math.max(Math.min(r*(1+dx()),cx),0);r*=lx;let o=a.retryInMillis??t,s=i-Date.now();if(o>s)return Q.info(`Export retry time ${Math.round(o)}ms exceeds remaining timeout ${Math.round(s)}ms, not retrying further.`),a;Q.verbose(`Scheduling export retry in ${Math.round(o)}ms`),a=await this.retry(e,s,o)}return a.status===`success`?Q.verbose(`Export succeeded after ${ox-n} retry attempts.`):a.status===`retryable`?Q.info(`Export failed after maximum retry attempts (${ox}).`):Q.info(`Export failed with non-retryable error: ${a.error}`),a}shutdown(){return this._transport.shutdown()}};function px(e){return new fx(e.transport)}var mx=class{_concurrencyLimit;_sendingPromises=[];constructor(e){this._concurrencyLimit=e}pushPromise(e){if(this.hasReachedLimit())throw Error(`Concurrency Limit reached`);this._sendingPromises.push(e);let t=()=>{let t=this._sendingPromises.indexOf(e);this._sendingPromises.splice(t,1)};e.then(t,t)}hasReachedLimit(){return this._sendingPromises.length>=this._concurrencyLimit}async awaitAll(){await Promise.all(this._sendingPromises)}};function hx(e){return new mx(e.concurrencyLimit)}var gx=class extends Error{code;name=`OTLPExporterError`;data;constructor(e,t,n){super(e),this.data=n,this.code=t}};function _x(e){return Object.prototype.hasOwnProperty.call(e,`partialSuccess`)}function vx(){return{handleResponse(e){e==null||!_x(e)||e.partialSuccess==null||Object.keys(e.partialSuccess).length===0||Q.warn(`Received Partial Success response:`,JSON.stringify(e.partialSuccess))}}}var yx=class{_diagLogger;_transport;_serializer;_responseHandler;_promiseQueue;_timeout;constructor(e,t,n,r,i){this._transport=e,this._serializer=t,this._responseHandler=n,this._promiseQueue=r,this._timeout=i,this._diagLogger=Q.createComponentLogger({namespace:`OTLPExportDelegate`})}export(e,t){if(this._diagLogger.debug(`items to be sent`,e),this._promiseQueue.hasReachedLimit()){t({code:z_.FAILED,error:Error(`Concurrent export limit reached`)});return}let n=this._serializer.serializeRequest(e);if(n==null){t({code:z_.FAILED,error:Error(`Nothing to send`)});return}this._promiseQueue.pushPromise(this._transport.send(n,this._timeout).then(e=>{if(e.status===`success`){if(e.data!=null)try{this._responseHandler.handleResponse(this._serializer.deserializeResponse(e.data))}catch(t){this._diagLogger.warn(`Export succeeded but could not deserialize response - is the response specification compliant?`,t,e.data)}t({code:z_.SUCCESS});return}else if(e.status===`failure`&&e.error){t({code:z_.FAILED,error:e.error});return}else e.status===`retryable`?t({code:z_.FAILED,error:e.error??new gx(`Export failed with retryable status`)}):t({code:z_.FAILED,error:new gx(`Export failed with unknown error`)})},e=>t({code:z_.FAILED,error:e})))}forceFlush(){return this._promiseQueue.awaitAll()}async shutdown(){this._diagLogger.debug(`shutdown started`),await this.forceFlush(),this._transport.shutdown()}};function bx(e,t){return new yx(e.transport,e.serializer,vx(),e.promiseHandler,t.timeout)}function xx(e,t,n){return bx({transport:n,serializer:t,promiseHandler:hx(e)},{timeout:e.timeoutMillis})}function Sx(e){return e===429||e===502||e===503||e===504}function Cx(e){if(e==null)return;let t=Number.parseInt(e,10);if(Number.isInteger(t))return t>0?t*1e3:-1;let n=new Date(e).getTime()-Date.now();return n>=0?n:0}var wx=60*1024,Tx=9,Ex=0,Dx=0,Ox=class{_parameters;constructor(e){this._parameters=e}async send(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),t),i=globalThis.fetch;typeof i.__original==`function`&&(i=i.__original);let a=e.byteLength,o=Ex+a>wx,s=!o&&!(Dx>=Tx);if(s)Ex+=a,Dx++;else{let e=o?`size limit`:`count limit`;Q.debug(`keepalive disabled: ${(a/1024).toFixed(1)}KB payload, ${Dx} pending (${e})`)}try{let t=new URL(this._parameters.url),r=await i(t.href,{method:`POST`,headers:await this._parameters.headers(),body:e,signal:n.signal,keepalive:s,mode:globalThis.location?globalThis.location.origin===t.origin?`same-origin`:`cors`:`no-cors`});return r.status>=200&&r.status<=299?(Q.debug(`export response success (status: ${r.status})`),{status:`success`}):Sx(r.status)?(Q.warn(`export response retryable (status: ${r.status})`),{status:`retryable`,retryInMillis:Cx(r.headers.get(`Retry-After`))}):(Q.error(`export response failure (status: ${r.status})`),{status:`failure`,error:Error(`Fetch request failed with non-retryable status ${r.status}`)})}catch(e){return Ax(e)?(Q.warn(`export request retryable (network error: ${e})`),{status:`retryable`,error:Error(`Fetch request encountered a network error`,{cause:e})}):(Q.error(`export request failure (error: ${e})`),{status:`failure`,error:Error(`Fetch request errored`,{cause:e})})}finally{clearTimeout(r),s&&(Ex-=a,Dx--)}}shutdown(){}};function kx(e){return new Ox(e)}function Ax(e){return e instanceof TypeError&&!e.cause}function jx(e,t){return xx(e,t,px({transport:kx(e)}))}function Mx(e){if(Number.isFinite(e)&&e>0)return e;throw Error(`Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${e}')`)}function Nx(e){if(e!=null)return async()=>e}function Px(e,t,n){return{timeoutMillis:Mx(e.timeoutMillis??t.timeoutMillis??n.timeoutMillis),concurrencyLimit:e.concurrencyLimit??t.concurrencyLimit??n.concurrencyLimit,compression:e.compression??t.compression??n.compression}}function Fx(){return{timeoutMillis:1e4,concurrencyLimit:30,compression:`none`}}function Ix(e){let t={};return Object.entries(e??{}).forEach(([e,n])=>{n===void 0?Q.warn(`Header "${e}" has invalid value (${n}) and will be ignored`):t[e]=String(n)}),t}function Lx(e,t,n){return async()=>{let r={...await n()},i={};return t!=null&&Object.assign(i,await t()),e!=null&&Object.assign(i,Ix(await e())),Object.assign(i,r)}}function Rx(e){if(e!=null)try{let t=globalThis.location?.href;return new URL(e,t).href}catch{throw Error(`Configuration: Could not parse user-provided export URL: '${e}'`)}}function zx(e,t,n){return{...Px(e,t,n),headers:Lx(e.headers,t.headers,n.headers),url:Rx(e.url)??t.url??n.url}}function Bx(e,t){return{...Fx(),headers:async()=>e,url:`http://localhost:4318/`+t}}function Vx(e){return typeof e.headers==`function`?e.headers:Nx(e.headers)}function Hx(e,t,n){return zx({url:e.url,timeoutMillis:e.timeoutMillis,headers:Vx(e),concurrencyLimit:e.concurrencyLimit},{},Bx(n,t))}function Ux(e,t,n,r){return jx(Hx(e,n,r),t)}var Wx=class extends zb{constructor(e={}){super(Ux(e,ax,`v1/traces`,{"Content-Type":`application/json`}))}};function Gx(e){return d(O(lc(hc(`VITE_OTEL_URL`)),wi({onNone:()=>se,onSome:t=>Rb(()=>({resource:{serviceName:e},spanProcessor:new wy(new Wx({url:t}))}))})))}var Kx=jn(se,Tt(Gx(`workbench-client`)),Tt(Rm),Tt(vm),Tt(Ks(qs({VITE_OTEL_URL:{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`}.VITE_OTEL_URL,VITE_PORTLESS_BASE_ORIGIN:{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`}.VITE_PORTLESS_BASE_ORIGIN,VITE_PORTLESS_ORIGIN:{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`}.VITE_PORTLESS_ORIGIN})))),qx=class extends Pm()(`ApiClient`,{group:gh,protocol:jn(jm({retryTransientErrors:!0}),Tt(Mf(jn(f({base:lc(hc(`VITE_PORTLESS_BASE_ORIGIN`)),origin:lc(hc(`VITE_PORTLESS_ORIGIN`))}),O(e=>jn(e.base,ti(e=>{let t=new URL(e);return t.hostname=`server.${t.hostname}`,t.origin}),Gn(()=>ti(e.origin,e=>{let t=new URL(e);return t.hostname=[`server`,...t.hostname.split(`.`).slice(1)].join(`.`),t.origin})),wi({onNone:()=>`${location.origin}/api/rpc`,onSome:e=>`${e}/api/rpc`}))),Ui))),Tt(kf),Tt(Kx))}){},Jx=class extends fr{};function Yx(e){return{...e.args===void 0?{}:{args:[...e.args]},...e.command===void 0?{}:{command:e.command},cwd:e.cwd,...e.env===void 0?{}:{env:{...e.env}},...e.sessionId===void 0?{}:{sessionId:e.sessionId}}}function Xx(e){return Math.abs(pt(e)).toString(36)}function Zx(e){return{state:e.command===void 0&&e.sessionId===void 0?`starting`:`idle`,title:``}}var Qx=Xl(e=>qx.runtime.atom(jn(qx,y(t=>t(`terminal.attach`,Yx(e),{asQueue:!0})))));function $x(e){return Qx(new Jx(Yx(e)))}var eS=Xl(e=>qx.runtime.atom(jn(qx,O(t=>t(`terminal.status.watch`,Yx(e))),ks),{initialValue:Zx(e)}));function tS(e){return eS(new Jx(Yx(e)))}var nS=Xl(e=>Zl(qx.runtime.atom(y(qx,t=>lr(e)?t(`runs.portless`,{cwd:e}):g([])),{initialValue:[]}))),rS=Xl(e=>Al(t=>jn(t.result(nS(e)),O(e=>jn(e,Qi(e=>e.origin===void 0?_n:hi(e.origin)),Tr,at(e=>e,Ai)))))),iS=Zl(qx.runtime.atom(jn(qx,O(e=>e(`projects.watch`,void 0)),ks))),aS=Xl(e=>Zl(Al(t=>jn(t.result(iS),O(t=>{let r=Wt(t,t=>Ue(t.worktrees,t=>Xx(t.root)===e)),i=jn(r,Ye(t=>Wt(t.worktrees,t=>Xx(t.root)===e)));return{activeProject:n(r),activeWorktree:n(i),projects:t}}))))),oS=Xl(e=>qx.runtime.atom(jn(qx,O(t=>t(`agents.watch`,{cwd:e})),ks)));export{Nc as A,Xl as C,nu as D,tu as E,lo as M,_a as N,ru as O,mu as S,Al as T,sh as _,iS as a,vu as b,tS as c,uh as d,eh as f,oh as g,ah as h,nS as i,ks as j,Bc as k,Xx as l,ih as m,oS as n,$x as o,Xm as p,rS as r,Zx as s,aS as t,qx as u,bu as v,Zl as w,wu as x,yu as y};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/terminal-CA1dMT3m.js","assets/state-CVjPP5QG.js","assets/chunk-QTnfLwEv.js","assets/button-Dz6Az3h_.js","assets/compiler-runtime-rGeCHUuX.js","assets/-workbench-terminal-DyfxJcjD.js","assets/fallbacks-uU4M5NOw.js"])))=>i.map(i=>d[i]);
2
+ import{$o as e,es as t}from"./button-Dz6Az3h_.js";import{t as n}from"./preload-helper-CjdClQve.js";var r=t(`/(home)/$worktree/terminal`)({component:e(()=>n(()=>import(`./terminal-CA1dMT3m.js`),__vite__mapDeps([0,1,2,3,4,5,6])),`component`)});export{r as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./compiler-runtime-rGeCHUuX.js";import{Hs as n}from"./button-Dz6Az3h_.js";import{t as r,x as i}from"./state-CVjPP5QG.js";import{t as a}from"./terminal-B5ko1jIG.js";import{t as o}from"./-workbench-terminal-DyfxJcjD.js";var s=t(),c=e();function l(){let e=(0,s.c)(5),t=a.useParams(),o;e[0]===t.worktree?o=e[1]:(o=r(t.worktree),e[0]=t.worktree,e[1]=o);let l=i(o);if(!l.value.activeWorktree){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,c.jsx)(n,{to:`/`,replace:!0}),e[2]=t):t=e[2],t}let d;return e[3]===l.value.activeWorktree.root?d=e[4]:(d=(0,c.jsx)(u,{cwd:l.value.activeWorktree.root},l.value.activeWorktree.root),e[3]=l.value.activeWorktree.root,e[4]=d),d}function u(e){let t=(0,s.c)(2),n;return t[0]===e.cwd?n=t[1]:(n=(0,c.jsx)(`div`,{className:`bg-background h-full min-h-0 min-w-0`,children:(0,c.jsx)(o,{className:`h-full min-h-0 w-full min-w-0 overflow-hidden`,session:{cwd:e.cwd}})}),t[0]=e.cwd,t[1]=n),n}export{l as component};
@@ -1 +1 @@
1
- import{$o as e}from"./button-f42ZKq6E.js";var t=e(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]);export{t};
1
+ import{Zo as e}from"./button-Dz6Az3h_.js";var t=e(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]);export{t};
@@ -6,20 +6,20 @@
6
6
 
7
7
  <title>@deslop/workbench</title>
8
8
  <link rel="icon" href="/assets/icon-CNwYPYVD.png" />
9
- <script type="module" crossorigin src="/assets/index-DCRiD9Nz.js"></script>
9
+ <script type="module" crossorigin src="/assets/index-Mo4bEjHb.js"></script>
10
10
  <link rel="modulepreload" crossorigin href="/assets/chunk-QTnfLwEv.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-CjdClQve.js">
12
12
  <link rel="modulepreload" crossorigin href="/assets/compiler-runtime-rGeCHUuX.js">
13
- <link rel="modulepreload" crossorigin href="/assets/button-f42ZKq6E.js">
14
- <link rel="modulepreload" crossorigin href="/assets/agent-K-v27T1K.js">
15
- <link rel="modulepreload" crossorigin href="/assets/fallbacks-D-9MltuA.js">
16
- <link rel="modulepreload" crossorigin href="/assets/loader-circle-DEYAvEPU.js">
17
- <link rel="modulepreload" crossorigin href="/assets/triangle-alert-CQsOhrGn.js">
18
- <link rel="modulepreload" crossorigin href="/assets/diff-COOvYjfB.js">
19
- <link rel="modulepreload" crossorigin href="/assets/portless-C8dLcQQw.js">
20
- <link rel="modulepreload" crossorigin href="/assets/run-B16WQaws.js">
21
- <link rel="modulepreload" crossorigin href="/assets/terminal-Br297Oa8.js">
22
- <link rel="modulepreload" crossorigin href="/assets/route-DAz8IJkt.js">
13
+ <link rel="modulepreload" crossorigin href="/assets/button-Dz6Az3h_.js">
14
+ <link rel="modulepreload" crossorigin href="/assets/agent-COvRE6oy.js">
15
+ <link rel="modulepreload" crossorigin href="/assets/fallbacks-uU4M5NOw.js">
16
+ <link rel="modulepreload" crossorigin href="/assets/loader-circle-BxillczB.js">
17
+ <link rel="modulepreload" crossorigin href="/assets/triangle-alert-CTEZG9zF.js">
18
+ <link rel="modulepreload" crossorigin href="/assets/diff-CLnQZZVT.js">
19
+ <link rel="modulepreload" crossorigin href="/assets/portless-QJD7ZmA9.js">
20
+ <link rel="modulepreload" crossorigin href="/assets/run-C0ukWbxF.js">
21
+ <link rel="modulepreload" crossorigin href="/assets/terminal-B5ko1jIG.js">
22
+ <link rel="modulepreload" crossorigin href="/assets/route-b5JXfzPO.js">
23
23
  <link rel="stylesheet" crossorigin href="/assets/index-DNWcrdqu.css">
24
24
  </head>
25
25
  <body>