@gjermundgaraba/clankerauth-dev 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -0
- package/dist/THIRD_PARTY_NOTICES.txt +1 -1
- package/dist/edge.d.ts +84 -0
- package/dist/edge.mjs +2 -0
- package/dist/index.d.ts +50 -2
- package/dist/index.mjs +38 -38
- package/dist/web/assets/{index-BtTQ7_kn.js → index-TYt-q9U4.js} +14 -14
- package/dist/web/index.html +1 -1
- package/package.json +7 -3
|
@@ -6,21 +6,21 @@
|
|
|
6
6
|
`);e.splice(1,3),t.stack=e.join(`
|
|
7
7
|
`)}return t},rs=S(2,(e,t)=>{let n=Ro(e,t.key);return n===Lo?Uo(t)?Sa(ts(t)):xa():Sa(n)}),is=S(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:Io(e,e=>t.mapUnsafe.forEach((t,n)=>e.set(n,t)))),as=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((e,n)=>{t.set(n,e)});return zo(t)},os=(...e)=>t=>Io(t,t=>{for(let n=0;n<e.length;n++)t.delete(e[n].key)}),M=j,ss=`~effect/Duration`,cs=BigInt(0),ls=BigInt(1),us=BigInt(2),ds=BigInt(10),fs=BigInt(1e3),ps=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),ms=e=>ps(e*1e6),hs=(e,t)=>{let n=e.indexOf(`.`);if(n===-1)return BigInt(e)*t;let r=e[0]===`-`,i=e.slice(n+1),a=ds**BigInt(i.length),o=(BigInt(e.slice(+!!r,n))*a+BigInt(i))*t,s=o/a+(o%a*us>=a?ls:cs);return r?-s:s},gs=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,_s=e=>{switch(typeof e){case`number`:return ks(e);case`bigint`:return Os(e);case`string`:{if(e===`Infinity`)return Es;if(e===`-Infinity`)return Ds;let t=gs.exec(e);if(!t)break;let[n,r,i]=t;if(i===`nano`||i===`nanos`)return Os(hs(r,ls));if(i===`micro`||i===`micros`)return Os(hs(r,fs));let a=Number(r);switch(i){case`milli`:case`millis`:return ks(a);case`second`:case`seconds`:return As(a);case`minute`:case`minutes`:return js(a);case`hour`:case`hours`:return Ms(a);case`day`:case`days`:return Ns(a);case`week`:case`weeks`:return Ps(a)}break}case`object`:{if(e===null)break;if(ss in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(Nn)?vs(e):Number.isNaN(e[0])||Number.isNaN(e[1])?Ts:e[0]===-1/0||e[1]===-1/0?Ds:e[0]===1/0||e[1]===1/0?Es:Cs(ps(e[0]*1e9+e[1]));let t=e,n=0;return t.weeks&&(n+=t.weeks*6048e5),t.days&&(n+=t.days*864e5),t.hours&&(n+=t.hours*36e5),t.minutes&&(n+=t.minutes*6e4),t.seconds&&(n+=t.seconds*1e3),t.milliseconds&&(n+=t.milliseconds),!t.microseconds&&!t.nanoseconds?Cs(n):Cs(ps(n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0)))}}return vs(e)},vs=e=>{throw Error(`Invalid Input: ${e}`)},ys={_tag:`Millis`,millis:0},bs={_tag:`Infinity`},xs={_tag:`NegativeInfinity`},Ss={[ss]:ss,[Gn](){switch(this.value._tag){case`Millis`:{let e=this.value.millis*1e6;return Number.isFinite(e)?T(ps(e)):Xn(this.value.millis)}case`Nanos`:return T(this.value.nanos);default:return $n(this.value)}},[cr](e){return ws(e)&&Bs(this,e)},toString(){switch(this.value._tag){case`Infinity`:return`Infinity`;case`NegativeInfinity`:return`-Infinity`;case`Nanos`:return`${this.value.nanos} nanos`;case`Millis`:return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case`Millis`:return{_id:`Duration`,_tag:`Millis`,millis:this.value.millis};case`Nanos`:return{_id:`Duration`,_tag:`Nanos`,nanos:String(this.value.nanos)};case`Infinity`:return{_id:`Duration`,_tag:`Infinity`};case`NegativeInfinity`:return{_id:`Duration`,_tag:`NegativeInfinity`}}},[qr](){return this.toJSON()},pipe(){return x(this,arguments)}},Cs=e=>{let t=Object.create(Ss);return t.value=typeof e==`number`?isNaN(e)||e===0||Object.is(e,-0)?ys:Number.isFinite(e)?Number.isInteger(e)?{_tag:`Millis`,millis:e}:{_tag:`Nanos`,nanos:ms(e)}:e>0?bs:xs:e===cs?ys:{_tag:`Nanos`,nanos:e},t},ws=e=>w(e,ss),Ts=Cs(0),Es=Cs(1/0),Ds=Cs(-1/0),Os=e=>Cs(e),ks=e=>Cs(e),As=e=>Cs(e*1e3),js=e=>Cs(e*6e4),Ms=e=>Cs(e*36e5),Ns=e=>Cs(e*864e5),Ps=e=>Cs(e*6048e5),Fs=e=>Ls(_s(e),{onMillis:C,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),Is=e=>{let t=_s(e);switch(t.value._tag){case`Infinity`:case`NegativeInfinity`:throw Error(`Cannot convert infinite duration to nanos`);case`Nanos`:return t.value.nanos;case`Millis`:return ms(t.value.millis)}},Ls=S(2,(e,t)=>{switch(e.value._tag){case`Millis`:return t.onMillis(e.value.millis);case`Nanos`:return t.onNanos(e.value.nanos);case`Infinity`:return t.onInfinity();case`NegativeInfinity`:return(t.onNegativeInfinity??t.onInfinity)()}}),Rs=S(3,(e,t,n)=>e.value._tag===`Infinity`||e.value._tag===`NegativeInfinity`||t.value._tag===`Infinity`||t.value._tag===`NegativeInfinity`?n.onInfinity(e,t):e.value._tag===`Millis`?t.value._tag===`Millis`?n.onMillis(e.value.millis,t.value.millis):n.onNanos(Is(e),t.value.nanos):n.onNanos(e.value.nanos,Is(t))),zs=(e,t)=>Rs(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),Bs=S(2,(e,t)=>zs(e,t)),Vs=M(`effect/Scheduler`,{fiberCached:!0,defaultValue:()=>new Ks}),Hs=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},Us=`setImmediate`in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},Ws=e=>{try{return Us(e)}catch{return Hs(e)}},Gs=class{buckets=[];scheduleTask(e,t){let n=this.buckets,r=n.length,i,a=0;for(;a<r&&!(n[a][0]>t);a++)i=n[a];i&&i[0]===t?i[1].push(e):a===r?n.push([t,[e]]):n.splice(a,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}},Ks=class{executionMode;setImmediate;constructor(e=`async`,t){this.executionMode=e,this.setImmediate=t??(e===`sync`?Hs:Ws)}shouldYield(e){return e.currentOpCount>=e.cache.maxOpsBeforeYield}makeDispatcher(){return new qs(this.setImmediate)}},qs=class{tasks=new Gs;running=void 0;setImmediate;constructor(e=Ws){this.setImmediate=e}scheduleTask(e,t){this.tasks.scheduleTask(e,t),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let n=e[t][1];for(let e=0;e<n.length;e++)n[e]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}},Js=M(`effect/Scheduler/MaxOpsBeforeYield`,{fiberCached:!0,defaultValue:()=>2048}),Ys=M(`effect/Scheduler/PreventSchedulerYield`,{fiberCached:!0,defaultValue:()=>!1}),Xs=class extends Sn{constructor(e){super(),e&&jr(this,e)}},Zs=e=>class extends Xs{_tag=e},Qs=Hi,$s=`~effect/Encoding/EncodingError`,ec=class extends Qs(`EncodingError`){[$s]=$s},tc=e=>fc(typeof e==`string`?lc.encode(e):e),nc=e=>{let t=dc(e),n=t.length;if(n%4!=0)return ja(new ec({kind:`Decode`,module:`Base64`,input:t,message:`Length must be a multiple of 4, but is ${n}`}));let r=t.indexOf(`=`);if(r!==-1&&(r<n-2||r===n-2&&t[n-1]!==`=`))return ja(new ec({kind:`Decode`,module:`Base64`,input:t,message:`Found a '=' character, but it is not at the end`}));try{let e=t.endsWith(`==`)?2:+!!t.endsWith(`=`),r=new Uint8Array(n/4*3-e);for(let e=0,i=0;e<n;e+=4,i+=3){let n=pc(t.charCodeAt(e))<<18|pc(t.charCodeAt(e+1))<<12|pc(t.charCodeAt(e+2))<<6|pc(t.charCodeAt(e+3));r[i]=n>>16,r[i+1]=n>>8&255,r[i+2]=n&255}return Aa(r)}catch(e){return ja(new ec({kind:`Decode`,module:`Base64`,input:t,message:e instanceof Error?e.message:`Invalid input`}))}},rc=e=>Fa(nc(e),e=>uc.decode(e)),ic=e=>{switch(e){case 16:return sc();case 32:return cc();default:{let t=``;for(let n=e>>>3;n>0;n--)t+=oc();return t}}},N=Uint8Array.from(`0123456789abcdef`,e=>e.charCodeAt(0)),ac=()=>Math.random()*4294967296>>>0,oc=()=>{let e=ac();return String.fromCharCode(N[e>>>28],N[e>>>24&15],N[e>>>20&15],N[e>>>16&15],N[e>>>12&15],N[e>>>8&15],N[e>>>4&15],N[e&15])},sc=()=>{let e=ac(),t=ac();return String.fromCharCode(N[e>>>28],N[e>>>24&15],N[e>>>20&15],N[e>>>16&15],N[e>>>12&15],N[e>>>8&15],N[e>>>4&15],N[e&15],N[t>>>28],N[t>>>24&15],N[t>>>20&15],N[t>>>16&15],N[t>>>12&15],N[t>>>8&15],N[t>>>4&15],N[t&15])},cc=()=>{let e=ac(),t=ac(),n=ac(),r=ac();return String.fromCharCode(N[e>>>28],N[e>>>24&15],N[e>>>20&15],N[e>>>16&15],N[e>>>12&15],N[e>>>8&15],N[e>>>4&15],N[e&15],N[t>>>28],N[t>>>24&15],N[t>>>20&15],N[t>>>16&15],N[t>>>12&15],N[t>>>8&15],N[t>>>4&15],N[t&15],N[n>>>28],N[n>>>24&15],N[n>>>20&15],N[n>>>16&15],N[n>>>12&15],N[n>>>8&15],N[n>>>4&15],N[n&15],N[r>>>28],N[r>>>24&15],N[r>>>20&15],N[r>>>16&15],N[r>>>12&15],N[r>>>8&15],N[r>>>4&15],N[r&15])},lc=new TextEncoder,uc=new TextDecoder,dc=e=>e.replace(/[\n\r]/g,``),fc=e=>{let t=e.length,n=``,r=2;for(;r<t;r+=3)n+=mc[e[r-2]>>2],n+=mc[(e[r-2]&3)<<4|e[r-1]>>4],n+=mc[(e[r-1]&15)<<2|e[r]>>6],n+=mc[e[r]&63];return r===t+1&&(n+=mc[e[r-2]>>2],n+=mc[(e[r-2]&3)<<4],n+=`==`),r===t&&(n+=mc[e[r-2]>>2],n+=mc[(e[r-2]&3)<<4|e[r-1]>>4],n+=mc[(e[r-1]&15)<<2],n+=`=`),n};function pc(e){if(e>=hc.length)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);let t=hc[e];if(t===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return t}var mc=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``),hc=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],gc=`effect/Tracer/ParentSpan`,_c=class extends j()(gc,{fiberCached:!0}){},vc=e=>e,yc=M(`effect/Tracer/DisablePropagation`,{defaultValue:Tn}),bc=M(`effect/Tracer/CurrentTraceLevel`,{defaultValue:()=>`Info`}),xc=M(`effect/Tracer/MinimumTraceLevel`,{defaultValue:()=>`All`}),Sc=`effect/Tracer`,Cc=M(Sc,{fiberCached:!0,defaultValue:()=>wc}),wc=vc({span:e=>new Tc(e)}),Tc=class{_tag=`Span`;sampled;name;parent;annotations;links;startTime;kind;status;_traceId=void 0;_spanId=void 0;_attributes=void 0;_events=void 0;constructor(e){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.startTime=e.startTime,this.kind=e.kind,this.sampled=e.sampled,this.status={_tag:`Started`,startTime:e.startTime}}get traceId(){return this._traceId??=Oa(this.parent)?.traceId??ic(32)}get spanId(){return this._spanId??=ic(16)}get attributes(){return this._attributes??=new Map}get events(){return this._events??=[]}end(e,t){this.status={_tag:`Ended`,endTime:e,exit:t,startTime:this.status.startTime}}attribute(e,t){this.attributes.set(e,t)}event(e,t,n){this.events.push([e,t,n??{}])}addLinks(e){this.links.push(...e)}},Ec=`effect/Metric/FiberRuntimeMetrics`,Dc=M(`effect/ErrorReporter/CurrentErrorReporters`,{defaultValue:()=>new Set}),Oc=M(`effect/References/CurrentStackFrame`,{fiberCached:!0,defaultValue:En}),kc=M(`effect/References/TracerEnabled`,{fiberCached:!0,defaultValue:wn}),Ac=M(`effect/References/TracerTimingEnabled`,{defaultValue:wn}),jc=M(`effect/References/TracerSpanAnnotations`,{defaultValue:()=>({})}),Mc=M(`effect/References/TracerSpanLinks`,{defaultValue:()=>[]}),Nc=M(`effect/References/CurrentLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),Pc=M(`effect/References/MinimumLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),Fc=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!=`boolean`)return e;let t=Qr();if(t===0&&e?.captureStackTrace!==!0)return{...e,captureStackTrace:!1};$r(3);let n=Error();return $r(t),{...e,captureStackTrace:Ic(()=>n.stack)}},Ic=(e=>t=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let i=r.split(`
|
|
8
8
|
`);if(i[e]!==void 0)return n=i[e].trim(),n}})(3),Lc=class extends bi{constructor(e,t=xi){super(`Interrupt`,t,`Interrupted`),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:`Interrupt`,fiberId:this.fiberId}}[cr](e){return Ai(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[Gn](){return qn(Zn(`${this._tag}:${this.fiberId}`))(Kn(this.annotations))}},Rc=e=>new Lc(e),zc=e=>new vi([new Lc(e)]),Bc=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag===`Fail`)return Aa(n.error)}return ja(e)},Vc=e=>e.reasons.some(ki),Hc=e=>e.reasons.some(Ai),Uc=e=>{let t;for(let n=0;n<e.reasons.length;n++){let r=e.reasons[n];r._tag===`Interrupt`&&(t??=new Set,r.fiberId!==void 0&&t.add(r.fiberId))}return t?Aa(t):ja(e)},Wc=(e,t)=>{let n=new Map,r=[];for(let i of e.concat(t)){let e=T(i),t=n.get(e);if(t===void 0)n.set(e,[i]);else if(t.some(e=>lr(e,i)))continue;else t.push(i);r.push(i)}return r},Gc=S(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new vi(Wc(e.reasons,t.reasons));return lr(e,n)?e:n}),Kc=S(2,(e,t)=>{let n=!1,r=e.reasons.map(e=>Oi(e)?(n=!0,new Si(t(e.error),e.annotations)):e);return n?Ci(r):e}),qc=e=>{let t={Fail:[],Die:[],Interrupt:[]};for(let n=0;n<e.reasons.length;n++)t[e.reasons[n]._tag].push(e.reasons[n]);return t},Jc=e=>{let t=qc(e);return t.Fail.length>0?t.Fail[0].error:t.Die.length>0?t.Die[0].defect:t.Interrupt.length>0?new globalThis.Error(`All fibers interrupted without error`):new globalThis.Error(`Empty cause`)},Yc=`~effect/Fiber`,Xc={_A:C,_E:C},Zc={id:0},Qc=()=>globalThis[Ir],$c=class{constructor(e,t=!0){this[Yc]=Xc,this.setContext(e),this.id=++Zc.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}[Yc];id;interruptible;currentOpCount;_stack;_observers;_exit;_children;_interruptedCause;_yielded;_running;_deferredInterrupt;_parent;context;cache;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return $o(this.context,e)}addObserver(e){return this._exit?(e(this._exit),Dn):(this._observers===void 0?this._observers=[e]:this._observers.push(e),()=>{if(this._exit||this._observers===void 0)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)})}interruptUnsafe(e,t){if(this._exit)return;let n=zc(e);this.cache.stackFrame&&(n=Di(n,Ko(Fi,this.cache.stackFrame))),t&&(n=Di(n,t)),this._interruptedCause=this._interruptedCause?Gc(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(ul(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===li)return;let n=nl.interruptChildren&&nl.interruptChildren(this);if(n!==void 0)return this.evaluate(R(n,()=>t));if(this._exit=t,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&=(this._parent._children?.delete(this),void 0),this._observers!==void 0){let e=this._observers;this._observers=void 0;for(let n=0;n<e.length;n++)e[n](t)}this._stack.length=0,this._children=void 0,this.context=Wo()}runLoop(e){let t=globalThis[Ir];globalThis[Ir]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;){this._deferredInterrupt&&(this._deferredInterrupt=!1,i=ul(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!r&&!e.preventYield&&e.scheduler.shouldYield(this)){r=!0;let e=i;i=R(pl,()=>e)}if(i=e.tracerContext?e.tracerContext(i,this):i[O](this),i===li){let e=this._yielded;if(ri in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return li}}}catch(e){return w(i,O)?this.runLoop(zi(e)):zi(`Fiber.runLoop: Not a valid effect: ${String(i)}`)}finally{this._running=n,globalThis[Ir]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,tl;for(;;){let t=this._stack.pop();if(!t)return;let n=t[ci];if(n!==void 0){let r=n.call(t,this);if(r)return r[e]=r,r}if(t[e])return t}}yieldWith(e){return this._yielded=e,li}children(){return this._children??=new Set}pipe(){return x(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&Vo(t,e))return;let n=e.cacheRoot,r=n._fiberCache??=el(e);this.cache!==void 0&&this.cache.scheduler!==r.scheduler&&(this._dispatcher=void 0),this.cache=r}get currentSpanLocal(){let e=this.cache.span;return e?._tag===`Span`?e:void 0}},el=e=>{let t=Zo(e,Sc);return{scheduler:$o(e,Vs),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:$o(e,kc),span:Zo(e,gc),logLevel:$o(e,Nc),minimumLogLevel:$o(e,Pc),stackFrame:$o(e,Oc),runtimeMetrics:Zo(e,Ec),maxOpsBeforeYield:$o(e,Js),preventYield:$o(e,Ys)}},tl={[oi](e,t){return ul(t._interruptedCause)},[si](e,t){return ul(t._interruptedCause)}},nl={interruptChildren:void 0},rl=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(Ii.key,e.cache.stackFrame),zo(t)},il=e=>{let t=e;return t._exit?P(t._exit):wl(n=>t._exit?n(P(t._exit)):F(e.addObserver(e=>n(P(e)))))},al=e=>wl(t=>{let n=e[Symbol.iterator](),r=[],i;function a(){let e=n.next();for(;!e.done;){if(e.value._exit){r.push(e.value._exit),e=n.next();continue}i=e.value.addObserver(e=>{r.push(e),a()});return}t(P(r))}return a(),F(()=>i?.())}),ol=e=>{let t=e;return t._exit?t._exit:wl(n=>t._exit?n(t._exit):F(e.addObserver(n)))},sl=e=>A(t=>cl(e,t.id)),cl=S(e=>w(e[0],Yc),(e,t,n)=>A(r=>{let i=rl(r);return i=i&&n?is(i,n):i??n,e.interruptUnsafe(t,i),Gl(il(e))})),ll=e=>A(t=>{let n=rl(t),r=Za();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return Gl(al(r))}),P=k,ul=Li,dl=Ri,F=Ni({op:`Sync`,[O](e){let t=this[D](),n=e.getCont(oi);return n?n[oi](t,e):e.yieldWith(k(t))}}),I=Ni({op:`Suspend`,[O](e){return this[D]()}}),fl=Ia({onFailure:dl,onSuccess:P}),pl=Ni({op:`Yield`,[O](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(tu)},this[D]??0),e.yieldWith(()=>{t=!0})}})(0),ml=P(xa()),hl=e=>I(()=>ul(ti(e))),gl=e=>zi(e),_l=e=>I(()=>dl(ti(e))),L=P(void 0),vl=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new $d(e,`An error occurred in Effect.try`):e.catch;return I(()=>{try{return P(ti(t))}catch(e){return dl(ti(()=>n(e)))}})},yl=e=>Sl(function(t,n){ti(()=>e(n)).then(e=>t(P(e)),e=>t(gl(e)))},e.length!==0),bl=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new $d(e,`An error occurred in Effect.tryPromise`):e.catch;return Sl(function(e,r){let i=t=>{try{e(dl(ti(()=>n(t))))}catch(t){e(gl(t))}};try{ti(()=>t(r)).then(t=>e(P(t)),i)}catch(e){i(e)}},t.length!==0)},xl=e=>A(t=>e(t.id)),Sl=function(){let e=Mi({op:`Async`,[O](e){let t=ti(()=>this.register.bind(e.cache.scheduler)),n=!1,r=!1,i=this.withSignal?new AbortController:void 0,a=t(t=>{n||(n=!0,r?e.evaluate(t):r=t)},i?.signal);return r===!1?(r=!0,e._yielded=()=>{n=!0},i===void 0&&a===void 0||e._stack.push(Cl(()=>(n=!0,i?.abort(),a??tu))),li):r}}),t=function(e,t){this.register=e,this.withSignal=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),Cl=Ni({op:`AsyncFinalizer`,[ci](e){e.interruptible&&(e.interruptible=!1,e._stack.push(od))},[si](e,t){return Hc(e)?R(this[D](),()=>ul(e)):ul(e)}}),wl=e=>Sl(e,e.length>=2),Tl=wl(Dn),El=(...e)=>{if(e.length===1){let t=e[0];return I(()=>jl(t()))}let[t,n]=e;return I(()=>jl(n.call(t.self)))},Dl=(e,...t)=>{let n=t.length===0?function(){return I(()=>jl(e.apply(this,arguments)))}:function(){let n=I(()=>jl(e.apply(this,arguments)));for(let e=0;e<t.length;e++)n=t[e](n,...arguments);return n};return Ol(e.length,n)},Ol=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),kl=(e,...t)=>Ol(e.length,t.length===0?function(){return Al(()=>e.apply(this,arguments))}:function(){let n=Al(()=>e.apply(this,arguments));for(let e of t)n=e(n,...arguments);return n}),Al=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return P(r.value);let i=r.value;if(i&&i._tag===`Success`){n=i.value;continue}if(i&&i._tag===`Failure`)return r.value;{let n=!0;return I(()=>n?(n=!1,R(r.value,e=>jl(t,e))):I(()=>jl(e())))}}}catch(e){return gl(e)}},jl=function(){let e=Mi({op:`Iterator`,[oi](e,t){let n=this.iterator;for(;;){let r=n.next(e);if(r.done)return P(r.value);if(!z(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[O](e){return this[oi](this.initial,e)}}),t=function(e,t){this.iterator=e,this.initial=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),Ml=S(2,(e,t)=>new Il(e,Ll,P(t))),Nl=function(e){return e._stack.push(this),this[D]},Pl=Mi({op:`OnSuccess`,[O]:Nl}),Fl=function(e,t){this[D]=e,this[oi]=t};Fl.prototype=Pl;var Il=function(e,t,n){this[D]=e,this[oi]=t,this.payload=n};Il.prototype=Pl;var Ll=function(){return this.payload},Rl=function(e){let t=this.payload;return P(ti(()=>t(e)))},zl=function(e){let t=this.payload;return ti(()=>t(e))},Bl=function(e){let t=this.payload;return new Il(ti(()=>t(e)),Ll,k(e))},Vl=function(e){return new Il(this.payload,Ll,k(e))},Hl=e=>Jl(e,Sa),Ul=S(2,(e,t)=>new Il(e,fi(t)?Ll:zl,t)),Wl=S(2,(e,t)=>new Il(e,fi(t)?Vl:Bl,t)),Gl=e=>new Il(e,Ll,tu),R=S(2,(e,t)=>new Fl(e,t.length===1?t:e=>t(e))),z=e=>e[ri]!==void 0,Kl=S(2,(e,t)=>z(e)?e._tag===`Success`?t(e.value):e:R(e,t)),ql=e=>R(e,C),Jl=S(2,(e,t)=>new Il(e,Rl,t)),Yl=S(2,(e,t)=>z(e)?nu(e,t):Jl(e,t)),Xl=S(2,(e,t)=>z(e)?ru(e,t):Cu(e,t)),Zl=S(2,(e,t)=>z(e)?iu(e,t):wu(e,t)),Ql=e=>Li(zc(e)),$l=e=>e._tag===`Success`,eu=e=>e._tag===`Failure`?Aa(e.cause):ja(e),tu=k(void 0),nu=S(2,(e,t)=>e._tag===`Success`?k(t(e.value)):e),ru=S(2,(e,t)=>{if(e._tag===`Success`)return e;let n=Bc(e.cause);return Na(n)?e:Ri(t(n.success))}),iu=S(2,(e,t)=>{if(e._tag===`Success`)return k(t.onSuccess(e.value));let n=Bc(e.cause);return Na(n)?e:Ri(t.onFailure(n.success))}),au=S(2,(e,t)=>$l(e)?t:e),ou=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?tu:Li(Ci(t))},su=S(2,(e,t)=>A(n=>{let r=n.context,i=t(r);return r===i?e:(n.setContext(i),Zu(e,()=>{n.setContext(r)}))})),cu=S(3,(e,t,n)=>su(e,e=>{let r=Qo(e,t),i=n(r);return r===i?e:qo(e,t,i)})),lu=()=>uu,uu=A(e=>P(e.context)),du=e=>A(t=>e(t.context)),fu=S(2,(e,t)=>z(e)?e:su(e,is(t))),pu=function(){return arguments.length===1?S(2,(e,t)=>mu(e,arguments[0],t)):S(3,(e,t,n)=>mu(e,t,n)).apply(this,arguments)},mu=(e,t,n)=>su(e,qo(t,n)),hu=S(e=>fi(e[0]),(e,t)=>dd({while:wn,body:Cn(t?.disableYield?e:R(e,e=>pl)),step:Dn})),gu=S(2,(e,t)=>new vu(e,t.length===1?t:e=>t(e))),_u=Mi({op:`OnFailure`,[O]:Nl}),vu=function(e,t){this[D]=e,this[si]=t};vu.prototype=_u;var yu=S(3,(e,t,n)=>gu(e,e=>{let r=t(e);return Na(r)?ul(r.failure):ti(()=>n(r.success,e))})),bu=S(2,(e,t)=>yu(e,Bc,e=>t(e))),xu=S(e=>fi(e[0]),(e,t,n,r)=>gu(e,e=>{let i=Bc(e);return Na(i)?ul(i.failure):t(i.success)?ti(()=>n(i.success)):r?ti(()=>r(i.success)):ul(e)})),Su=S(e=>fi(e[0]),(e,t,n,r)=>xu(e,Array.isArray(t)?e=>w(e,`_tag`)&&t.includes(e._tag):Un(t),n,r)),Cu=S(2,(e,t)=>bu(e,e=>_l(()=>t(e)))),wu=S(2,(e,t)=>Au(e,{onFailure:e=>_l(()=>t.onFailure(e)),onSuccess:e=>F(()=>t.onSuccess(e))})),Tu=e=>bu(e,gl),Eu=e=>Mu(e,{onFailure:ja,onSuccess:Aa}),Du=S(2,(e,t)=>new ku(e,t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),t.onFailure.length===1?t.onFailure:e=>t.onFailure(e))),Ou=Mi({op:`OnSuccessAndFailure`,[O]:Nl}),ku=function(e,t,n){this[D]=e,this[oi]=t,this[si]=n};ku.prototype=Ou;var Au=S(2,(e,t)=>Du(e,{onFailure:e=>{let n=e.reasons.find(Oi);return n?ti(()=>t.onFailure(n.error)):ul(e)},onSuccess:t.onSuccess})),ju=S(2,(e,t)=>Au(e,{onFailure:e=>F(()=>t.onFailure(e)),onSuccess:e=>F(()=>t.onSuccess(e))})),Mu=S(2,(e,t)=>{if(z(e)){if(e._tag===`Success`)return k(t.onSuccess(e.value));let n=Bc(e.cause);return Na(n)?e:k(t.onFailure(n.success))}return ju(e,t)}),Nu=e=>z(e)?k(e):Pu(e),Pu=Ni({op:`Exit`,[O](e){return e._stack.push(this),this[D]},[oi](e,t,n){return P(n??k(e))},[si](e,t,n){return P(n??Li(e))}}),Fu=`~effect/Scope`,Iu=`~effect/Scope/Closeable`,Lu=j(`effect/Scope`),Ru=(e,t)=>I(()=>zu(e,t)??L),zu=(e,t)=>{if(e.state._tag===`Closed`)return;let n={_tag:`Closed`,exit:t};if(e.state._tag===`Empty`){e.state=n;return}let r=e.state;if(e.state=n,r.finalizer!==void 0)return r.finalizer(t);let i=r.finalizers;if(i!==void 0&&i.size!==0)return i.size===1?i.values().next().value(t):Vu(e,i,t)},Bu=(e,t)=>$l(e)?t:gu(t,t=>ul(Gc(e.cause,t))),Vu=Dl(function*(e,t,n){let r=[],i=[],a=Array.from(t.values()),o=Qc();for(let t=a.length-1;t>=0;t--){let s=a[t];e.strategy===`sequential`?r.push(yield*Nu(s(n))):i.push(yd(o,s(n),!0,!0,`inherit`))}return i.length>0&&(r=yield*al(i)),yield*ou(r)}),Hu=(e,t)=>{let n=qu(t);if(e.state._tag===`Closed`)return n.state=e.state,n;let r={};return Gu(e,r,e=>Ru(n,e)),Gu(n,r,t=>F(()=>Ku(e,r))),n},Uu=(e,t)=>I(()=>e.state._tag===`Closed`?t(e.state.exit):(Gu(e,{},t),L)),Wu=(e,t)=>Uu(e,Cn(t)),Gu=(e,t,n)=>{if(e.state._tag===`Empty`)e.state={_tag:`Open`,finalizerKey:t,finalizer:n,finalizers:void 0};else if(e.state._tag===`Open`){let r=e.state;r.finalizer===void 0?r.finalizers===void 0?(r.finalizerKey=t,r.finalizer=n):r.finalizers.set(t,n):(r.finalizers=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0,r.finalizers.set(t,n))}},Ku=(e,t)=>{if(e.state._tag===`Open`){let n=e.state;n.finalizerKey===t?(n.finalizerKey=void 0,n.finalizer=void 0):n.finalizers!==void 0&&n.finalizers.delete(t)}},qu=(e=`sequential`)=>({[Iu]:Iu,[Fu]:Fu,strategy:e,state:Ju}),Ju={_tag:`Empty`},Yu=pu(Lu),Xu=e=>I(()=>{let t=qu();return Qu(e(t),e=>I(()=>zu(t,e)??L))}),Zu=function(){let e=Mi({op:`OnExit`,[O](e){return e._stack.push(this),this.effect},[ci](e){e.interruptible&&this.interruptible!==!0&&(e._stack.push(od),e.interruptible=!1)},[oi](e,t,n){n??=k(e);let r=this.onExit(n);return r?R(r,e=>n):n},[si](e,t,n){n??=Li(e);let r=this.onExit(n);return r?R(Bu(n,r),e=>n):n}}),t=function(e,t,n){this.effect=e,this.onExit=t,this.interruptible=n};return t.prototype=e,function(e,n,r){return new t(e,n,r)}}(),Qu=S(2,Zu),$u=S(3,(e,t,n)=>Qu(e,e=>{let r=t(e);return Na(r)?L:n(r.success,e)})),ed=S(2,(e,t)=>$u(e,eu,t)),td=S(3,(e,t,n)=>Qu(e,e=>{if(e._tag!==`Failure`)return L;let r=t(e.cause);return Na(r)?L:n(r.success,e.cause)})),nd=S(2,(e,t)=>td(Uc,t)(e)),rd=e=>F(()=>{let t=Md(!1),n=!1,r,i=R(t.await,()=>r);return I(()=>r===void 0?n?i:(n=!0,Qu(e,e=>F(()=>{r=e,t.openUnsafe()}))):r)}),id=e=>A(t=>t.interruptible?(t.interruptible=!1,t._stack.push(od),e):e),ad=Ni({op:`SetInterruptible`,[ci](e){if(e.interruptible=this[D],e._interruptedCause&&e.interruptible)return()=>ul(e._interruptedCause)}}),od=ad(!0),sd=ad(!1),cd=e=>{if(e.interruptible=!0,e._stack.push(sd),e._interruptedCause)return ul(e._interruptedCause)},ld=e=>A(t=>t.interruptible?e:cd(t)??e),ud=e=>A(t=>t.interruptible?(t.interruptible=!1,t._stack.push(od),e(ld)):e(C)),dd=Ni({op:`While`,[oi](e,t){return this[D].step(e),this[D].while()?(t._stack.push(this),this[D].body()):tu},[O](e){return this[D].while()?(e._stack.push(this),this[D].body()):tu}}),fd=S(e=>typeof e[1]==`function`,(e,t,n)=>I(()=>{let r=md(n?.concurrency);if(r===1)return pd(e,t,n);let i=Ga(e),a=i.length;if(a===0)return n?.discard?L:P([]);let o=n?.discard?void 0:Array(a),s=vd({f:t,out:o},i,{concurrency:r});return s?Ml(s,o):P(o)})),pd=(e,t,n)=>I(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return Ml(dd({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),md=e=>e===`unbounded`?1/0:Math.max(1,e??1),hd=()=>e=>{let t=e.onItem,n=e.step,r=(e,i,a=0,o=i.length)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!z(c))return R(Nu(c),t=>n(e,s,t,a)??r(e,i,a+1,o)??L);let l=n(e,s,c,a);if(l)return l._tag===`Failure`?l:void 0}};return r},gd=e=>{let t=e.onItem,n=e.step;return(e,r,i)=>{let a=0,o=i.end??r.length,s=i.concurrency,c=!1,l,u,d,f=!1,p,m,h=e=>{let t=zi(e);return p=t,c=!0,f=!0,u&&u.size>0?R(id(ll(Array.from(u))),()=>t):t},g=()=>{let i=!1;for(;!p&&a<o;a++){let o=r[a],_=m??t(e,o,a);if(z(_)){if(p=n(e,o,_,a),p)break}else if(l){m=void 0;let t=yd(l,_,!0,!0,`inherit`);if(t._exit){if(p=n(e,o,t._exit,a),p)break;continue}u.add(t);let r=a;if(t.addObserver(a=>{u.delete(t);try{if(p){if(!f&&a._tag===`Failure`)for(let e of a.cause.reasons)if(e._tag===`Interrupt`)continue;else p._tag===`Failure`?p.cause.reasons.push(e):p=Li(Ci([e]))}else{let t=n(e,o,a,r);t&&(p=t._tag===`Failure`?Li(Ci(t.cause.reasons.slice())):t,g())}if(i){let e=g();e&&d(e)}else c&&u.size===0&&d(p??L)}catch(e){d(h(e))}}),u.size<s)continue;i=!0,a++;return}else return wl(e=>{l=Qc(),u=new Set,m=_,d=e;let t;try{t=g()}catch(t){return e(h(t))}return t?e(t):I(()=>(p=tu,f=!0,u?ll(u):L))})}if(c=!0,p){if(u&&u.size>0){let e=rl(l);u.forEach(t=>t.interruptUnsafe(l.id,e));return}if(d||p._tag===`Failure`)return p}else if(d){if(u)u.size===0&&d(L);else return tu}};return g()}},_d=()=>e=>gd(e),vd=gd({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag===`Failure`)return n;e.out&&(e.out[r]=n.value)}}),yd=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new $c(a.context,o);return n?s.evaluate(t):a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0),!r&&!s._exit&&(a.children().add(s),s._parent=a),s},bd=S(e=>fi(e[0]),(e,t,n)=>A(r=>{let i=yd(r,e,n?.startImmediately,!0,n?.uninterruptible);if(!i._exit){if(t.state._tag!==`Closed`){let e={};Gu(t,e,()=>xl(e=>e===i.id?L:sl(i))),i.addObserver(()=>Ku(t,e))}else i.interruptUnsafe(r.id,rl(r))}return P(i)})),xd=e=>(t,n)=>{let r=new $c(n?.scheduler?qo(e,Vs,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal){if(n.signal.aborted)r.interruptUnsafe();else{let e=()=>r.interruptUnsafe();n.signal.addEventListener(`abort`,e,{once:!0}),r.addObserver(()=>n.signal.removeEventListener(`abort`,e))}}return n?.onFiberStart&&n.onFiberStart(r),r},Sd=S(2,(e,t)=>{if(e._exit)return e;if(t.state._tag===`Closed`)return e.interruptUnsafe(e.id),e;let n={};return Gu(t,n,()=>sl(e)),e.addObserver(()=>Ku(t,n)),e}),Cd=xd(Wo()),wd=e=>{let t=xd(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},Td=(e=>{let t=wd(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw Jc(e.cause);return e.value})})(Wo()),Ed=e=>{let t=xd(e);return e=>{if(z(e))return e;let n=new Ks(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??zi(new Zd(r))}},Dd=Ed(Wo()),Od=(e=>{let t=Ed(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw Jc(n.cause);return n.value}})(Wo()),kd=P(!0),Ad=P(!1),jd=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return kd;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let e=0;e<this.waiters.length;e++)this.scheduled.push(this.waiters[e]);return this.waiters=[],kd}flushScheduled=()=>{if(this.scheduled===void 0)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](tu)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](tu)}open=A(e=>this._isOpen?Ad:(this._isOpen=!0,this.scheduleUnsafe(e)));release=A(e=>this._isOpen?Ad:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=wl(e=>this._isOpen?e(L):(this.waiters.push(e),F(()=>{let t=this.waiters.indexOf(e);t===-1?this.scheduled!==void 0&&(t=this.scheduled.indexOf(e),t!==-1&&this.scheduled.splice(t,1)):this.waiters.splice(t,1)})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=F(()=>this.closeUnsafe());whenOpen=e=>R(this.await,()=>e);isOpen(){return this._isOpen}},Md=e=>new jd(e??!1),Nd=BigInt(0),Pd={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:Nd,endTime:Nd,exit:tu},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},Fd=e=>Object.assign(Object.create(Pd),e),Id=e=>e?$o(e.annotations,yc)?e._tag===`Span`?Id(Oa(e.parent)):xa():Sa(e):xa(),Ld=(e,t,n)=>{let r=!e.getRef(kc)||n?.annotations&&$o(n.annotations,yc),i=n?.parent===void 0?n?.root?xa():Id(e.cache.span):Sa(n.parent),a;if(r)a=Fd({name:t,parent:i,annotations:qo(n?.annotations??Wo(),yc,!0)});else{let r=e.getRef(Cc),o=e.getRef(Wd),s=e.getRef(Ac),c=e.getRef(jc),l=e.getRef(Mc),u=n?.level??e.getRef(bc),d=n?.links===void 0?l.length===0?[]:l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??Wo(),links:d,startTime:s?o.currentTimeNanosUnsafe():Nd,kind:n?.kind??`internal`,root:n?.root??Ca(i),sampled:n?.sampled??(wa(i)&&i.value.sampled===!1?!1:!ef(e.getRef(xc),u))});for(let e in c)a.attribute(e,c[e]);if(n?.attributes!==void 0)for(let e in n.attributes)a.attribute(e,n.attributes[e])}return a},Rd=(e,t)=>(t=typeof t==`function`?t:En,cu(Oc,n=>({name:e,stack:t,parent:n}))),zd=(e,t,n,r)=>F(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():Nd,t)}),Bd=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return A(t=>{let i=Ld(t,e,n),a=t.getRef(Wd),o=t.getRef(Ac);return Qu(I(()=>ti(()=>r(i))),e=>zd(i,e,a,o))})},Vd=pu(_c),Hd=function(){let e=fi(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=C;return t._tag===`Span`&&(n=Fc(n),r=Rd(t.name,n?.captureStackTrace)),e?Vd(r(arguments[0]),t):e=>Vd(r(e),t)},Ud=function(){let e=typeof arguments[0]!=`string`,t=e?arguments[1]:arguments[0],n=Fc(arguments[2]);if(e){let e=arguments[0];return Bd(t,arguments[2],t=>Hd(e,t,n))}let r=typeof arguments[1]==`function`?arguments[1]:void 0,i=r?void 0:arguments[1];return(e,...a)=>Bd(t,r?r(...a):i,t=>Hd(e,t,n))},Wd=M(`effect/Clock`,{defaultValue:()=>new Kd}),Gd=2**31-1,Kd=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=F(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return Yd()}currentTimeNanos=F(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return Jd()}monotonicTimeNanos=F(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(Fs(e))}sleepMillis(e){return e<=0?pl:Number.isFinite(e)?wl(t=>{let n=e>Gd?this.sleepMillis(e-Gd):L,r=setTimeout(()=>t(n),Math.min(e,Gd));return F(()=>clearTimeout(r))}):Tl}},qd=BigInt(1e6),Jd=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==`function`)return()=>e.bigint();if(typeof performance<`u`&&typeof performance.now==`function`)return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*qd;return e>t&&(t=e),t}}(),Yd=function(){let e=BigInt(1e9),t;return()=>{let n=Jd(),r=BigInt(Date.now())*qd;if(t===void 0)t=r-n;else{let i=t+n;(r>i?r-i:i-r)>e&&(t=r-n)}return t+n}}(),Xd=`~effect/Cause/AsyncFiberError`,Zd=class extends Hi(`AsyncFiberError`){[Xd]=Xd;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},Qd=`~effect/Cause/UnknownError`,$d=class extends Hi(`UnknownError`){[Qd]=Qd;constructor(e,t){super({message:t,cause:e})}},ef=ba(ya(va,e=>{switch(e){case`All`:return-(2**53-1);case`Fatal`:return 5e4;case`Error`:return 4e4;case`Warn`:return 3e4;case`Info`:return 2e4;case`Debug`:return 1e4;case`Trace`:return 0;case`None`:return 2**53-1}})),tf={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};tf.gray,tf.blue,tf.green,tf.yellow,tf.red,tf.bgBrightRed,tf.black;var nf=S(e=>fi(e[0]),(e,t)=>ed(e,e=>A(n=>(rf(n,e,t?.defectsOnly),L)))),rf=(e,t,n)=>{let r=e.getRef(Dc);if(r.size===0||n&&!Vc(t))return;let i={cause:t,fiber:e,timestamp:e.getRef(Wd).currentTimeNanosUnsafe()};r.forEach(e=>e.report(i))},af=gi,of=_i,sf=Oi,cf=Ci,lf=wi,uf=Ei,df=e=>new Si(e),ff=e=>new Ti(e),pf=Rc,mf=Kc,hf=Gc,gf=Jc,_f=Hc,vf=Wi,yf=Ji,bf=k,xf=Li,Sf=Ri,Cf=tu,wf=$l,Tf={"~effect/Deferred":{_A:C,_E:C},pipe(){return x(this,arguments)}},Ef=function(){this.resumes=void 0,this.effect=void 0};Ef.prototype=Tf;var Df=()=>new Ef,Of=e=>wl(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),F(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),kf=S(2,(e,t)=>F(()=>Af(e,t))),Af=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let e=0;e<n.length;e++)n[e](t)}return!0},jf=Lu,Mf=qu,Nf=Yu,Pf=Uu,Ff=Wu,If=Hu,Lf=Ru,Rf=`~effect/Layer`,zf=`~effect/Layer/MemoMap`,Bf=(e,t)=>(e.observers++,Ul(Uu(t,t=>e.finalizer(t)),e.effect)),Vf={[Rf]:{_ROut:C,_E:C,_RIn:C},pipe(){return x(this,arguments)}},Hf=e=>{let t=Object.create(Vf);return t.build=e,t},Uf=e=>Hf((t,n)=>{let r=If(n);return Qu(e(t,r),e=>e._tag===`Failure`?Lf(r,e):L)}),Wf=e=>{let t=Uf((n,r)=>n.getOrElseMemoize(t,r,e));return t},Gf=(e,t,n,r)=>{let i=Mf(),a=Df(),o={observers:1,effect:Of(a),finalizer:n=>I(()=>(o.observers--,o.observers===0?(e.map.delete(t),Lf(i,n)):L))};return e.map.set(t,o),Uu(n,o.finalizer).pipe(R(()=>r(e,i)),Qu(e=>(o.effect=e,kf(a,e))))},Kf=class{get[zf](){return zf}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?Bf(n,t):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return I(()=>this.get(e,t)||Gf(this,e,t,n))}},qf=()=>new Kf,Jf=e=>new Kf(e),Yf=class e extends j()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=Xo(t,e);return n?Jf(n):qf()}},Xf=S(3,(e,t,n)=>pu(Jl(e.build(t,n),qo(Yf,t)),Yf,t)),Zf=S(2,(e,t)=>A(n=>Xf(e,Yf.forkOrCreate(n.context),t))),Qf=function(){return arguments.length===1?e=>$f(Ko(arguments[0],e)):$f(Ko(arguments[0],arguments[1]))},$f=e=>Hf(Cn(P(e))),ep=$f(Wo()),tp=function(){return arguments.length===1?e=>np(arguments[0],e):np(arguments[0],arguments[1])},np=(e,t)=>rp(Jl(t,t=>Ko(e,t))),rp=e=>Wf((t,n)=>Nf(e,n)),ip=e=>rp(Ml(e,Wo())),ap=j(`effect/Layer/unwrap`),op=e=>fp(tp(ap)(e),$o(ap)),sp=(e,t,n)=>{let r=If(n,`parallel`);return fd(e,e=>e.build(t,If(r,`sequential`)),{concurrency:e.length}).pipe(Jl(e=>as(...e)))},cp=(...e)=>Uf((t,n)=>sp(e,t,n)),lp=(e,t,n)=>Uf((r,i)=>R(Array.isArray(t)?sp(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(fu(t),Jl(e=>n(e,t))))),up=S(2,(e,t)=>lp(e,t,C)),dp=S(2,(e,t)=>lp(e,t,(e,t)=>is(t,e))),fp=S(2,(e,t)=>Uf((n,r)=>R(e.build(n,r),e=>t(e).build(n,r)))),pp=`~effect/DateTime`,mp=`~effect/DateTime/TimeZone`,hp={[pp]:pp,pipe(){return x(this,arguments)},[qr](){return this.toString()},toJSON(){return _p(this).toJSON()}};({...hp}),{...hp};var gp={[mp]:mp,[qr](){return this.toString()}};({...gp}),{...gp};var _p=e=>new Date(e.epochMilliseconds),vp=S(2,(e,t)=>yu(e,Sp,e=>t(e))),yp=e=>e.reasons.some(bp),bp=e=>e._tag===`Fail`&&vf(e.error),xp=e=>{let t,n=!1;for(let r of e.reasons)bp(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?ja(e):n?ja(cf(e.reasons.filter(e=>!bp(e)))):Aa(t)},Sp=e=>{let t=xp(e);return Na(t)?t:Aa(t.success.value)},Cp=e=>{let t=xp(e);return Na(t)?xf(t.failure):bf(t.success.value)},wp=(e,t,n)=>Xu(r=>R(n?.local?Xf(t,qf(),r):Zf(t,r),t=>fu(e,t))),Tp=S(e=>fi(e[0]),(e,t,n)=>Ho(t)?fu(e,t):wp(e,Array.isArray(t)?cp(...t):t,n)),Ep=fi,Dp=yl,Op=bl,B=P,kp=I,Ap=F,jp=L,Mp=El,V=dl,Np=ul,Pp=hl,Fp=gl,Ip=vl,Lp=A,Rp=fl,H=R,zp=ql,Bp=Ul,Vp=Wl,Hp=Eu,Up=Nu,U=Jl,Wp=Ml,Gp=Gl,Kp=bu,qp=Su,Jp=gu,Yp=Cu,Xp=Tu,Zp=nf,Qp=ju,$p=Du,em=lu,tm=du,nm=Tp,rm=fu,im=su,am=ed,om=Qu,sm=rd,cm=nd,lm=ud,um=hu,dm=Bd,fm=Ud,pm=Hd,mm=bd,hm=Cd,gm=xd,_m=Td,vm=Od,ym=Dd,bm=Dl,xm=Yl,Sm=Xl,Cm=Zl,wm=Kl,Tm=kl;function Em(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function Dm(e){return t=>Em(t)?.[e]}var Om=`~structural`,km=`~identifier`,Am=`~sentinels`,jm=`~constructor`,Mm=[`title`,`description`,`default`,`examples`,`readOnly`,`writeOnly`,`format`,`contentEncoding`,`contentMediaType`,`contentSchema`],Nm=Dm(`identifier`),Pm=Dm(km),Fm=Dm(`description`),Im=On(e=>{let t=Em(e)?.identifier;return typeof t==`string`?t:e.getExpected(Im)}),Lm=new Set([Am,Om,`representation`,`arbitraryConstraint`,`brands`,`toJsonSchema`,`toCode`,`toEquivalence`,`toFormatter`,`toCodec`,`toCodecJson`,`toCodecStringTree`,`toCodecIso`,`toCodecArbitrary`]),W=Symbol(),Rm=bf,zm=Rm(W),G=Rm(W),Bm=e=>e===W?xa():Sa(e),Vm=e=>e._tag===`None`?zm:Rm(e.value),Hm=`~effect/SchemaIssue/Issue`;function Um(e){return w(e,Hm)&&e[Hm]===Hm}function Wm(e){return Object.hasOwn(e,`input`)}var Gm=class{[Hm]=Hm;constructor(e,t){t?.reportInput===!0&&e!==W&&(this.input=e)}},Km=class extends Gm{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},qm=class extends Gm{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},Jm=class extends Gm{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},Ym=class extends Gm{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},Xm=class extends Gm{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},Zm=class extends Gm{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},Qm=class extends Gm{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},$m=class extends Gm{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}};function eh(e,t,n,r,i){return new Zm(e,[new Jm([t],n)],r,i)}var th=class extends Gm{_tag=`Forbidden`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},nh=class extends Gm{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},rh=class extends Gm{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function ih(e,t,n){if(Um(e))return e;if(typeof e==`string`)return new $m({message:e},t,n);let r=typeof e.issue==`string`?new $m({message:e.issue},t,n):e.issue;return new Jm(e.path,r)}function ah(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new $m(void 0,t,n):ih(e,t,n)}function oh(e,t,n,r){return Array.isArray(t)?Xa(t)?t.length===1?ih(t[0],n,r):new Zm(e,$a(t,e=>ih(e,n,r)),n,r):void 0:ah(t,n,r)}var sh=e=>{let t=gh(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return dh(Im(e.ast),e);case`InvalidValue`:{let t=uh(e);if(t!==void 0)return dh(t,e);let n=lh(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=lh(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=lh(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},ch=e=>gh(e.issue)??gh(e);function lh(e){return Wm(e)?zr(e.input):void 0}function uh(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function dh(e,t){let n=lh(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function fh(e){let t=e.annotations?.expected;if(typeof t==`string`)return t;switch(e._tag){case`Filter`:return`<filter>`;case`FilterGroup`:return e.checks.map(e=>fh(e)).join(` & `)}}function ph(){return e=>hh(e,``)}var mh=ph();function hh(e,t){let n;switch(e._tag){case`Filter`:{let r=ch(e);if(r!==void 0)n=r;else{if(e.issue._tag!==`InvalidValue`)return hh(e.issue,t);let r=uh(e.issue);n=r===void 0?dh(fh(e.filter),e):dh(r,e.issue)}break}case`Encoding`:return hh(e.issue,t);case`Pointer`:return hh(e.issue,t+Hr(e.path));case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>hh(e,t)).join(`
|
|
9
|
-
`);n=gh(e)??dh(Im(e.ast),e);break;default:n=sh(e)}return t?`${n}\n at ${t}`:n}function gh(e){if(e._tag===`Pointer`)return;if(e._tag===`Encoding`)return gh(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function _h(e){let t;for(let n of e.reasons){if(!sf(n)||!Um(n.error))return;t??=n.error}return t}function vh(e,t){let n=_h(e);if(n===void 0)throw Error(t,{cause:e});return n}var yh=e=>Object.assign(Object.create(xn),e),bh=yh({_tag:`Passthrough`});function xh(){return bh}function Sh(e){return yh({_tag:`Transform`,transform:e})}function Ch(e){return yh({_tag:`TransformEffect`,transform:e})}function wh(){return Sh(globalThis.String)}function Th(){return Sh(globalThis.Number)}function Eh(e){return Ch((t,n)=>Ip({try:()=>JSON.parse(t,e?.reviver),catch:()=>new $m({expected:`a valid JSON string`},t,n)}))}function Dh(e){return Ch((t,n)=>Ip({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return n},catch:()=>new $m({expected:`a JSON-serializable value`},t,n)}))}function Oh(){return Sh(tc)}function kh(){return Ch((e,t)=>Sm(Rp(nc(e)),()=>new $m({expected:`a valid Base64 string`},e,t)))}var Ah=BigInt(0),jh=BigInt(1),Mh=BigInt(1e3),Nh=BigInt(1024),Ph=[{symbol:`B`,factor:jh,names:[`B`,`byte`,`bytes`]},{symbol:`kB`,factor:Mh,names:[`kB`,`kilobyte`,`kilobytes`]},{symbol:`MB`,factor:Mh**BigInt(2),names:[`MB`,`megabyte`,`megabytes`]},{symbol:`GB`,factor:Mh**BigInt(3),names:[`GB`,`gigabyte`,`gigabytes`]},{symbol:`TB`,factor:Mh**BigInt(4),names:[`TB`,`terabyte`,`terabytes`]},{symbol:`PB`,factor:Mh**BigInt(5),names:[`PB`,`petabyte`,`petabytes`]},{symbol:`EB`,factor:Mh**BigInt(6),names:[`EB`,`exabyte`,`exabytes`]},{symbol:`ZB`,factor:Mh**BigInt(7),names:[`ZB`,`zettabyte`,`zettabytes`]},{symbol:`YB`,factor:Mh**BigInt(8),names:[`YB`,`yottabyte`,`yottabytes`]},{symbol:`RB`,factor:Mh**BigInt(9),names:[`RB`,`ronnabyte`,`ronnabytes`]},{symbol:`QB`,factor:Mh**BigInt(10),names:[`QB`,`quettabyte`,`quettabytes`]}],Fh=[Ph[0],{symbol:`KiB`,factor:Nh,names:[`KiB`,`kibibyte`,`kibibytes`]},{symbol:`MiB`,factor:Nh**BigInt(2),names:[`MiB`,`mebibyte`,`mebibytes`]},{symbol:`GiB`,factor:Nh**BigInt(3),names:[`GiB`,`gibibyte`,`gibibytes`]},{symbol:`TiB`,factor:Nh**BigInt(4),names:[`TiB`,`tebibyte`,`tebibytes`]},{symbol:`PiB`,factor:Nh**BigInt(5),names:[`PiB`,`pebibyte`,`pebibytes`]},{symbol:`EiB`,factor:Nh**BigInt(6),names:[`EiB`,`exbibyte`,`exbibytes`]},{symbol:`ZiB`,factor:Nh**BigInt(7),names:[`ZiB`,`zebibyte`,`zebibytes`]},{symbol:`YiB`,factor:Nh**BigInt(8),names:[`YiB`,`yobibyte`,`yobibytes`]}],Ih=[...Ph,...Fh.slice(1)],Lh=new Map(Ih.flatMap(e=>e.names.map(t=>[t,e]))),Rh=new Map(Ih.map(e=>[e.symbol,e])),zh=e=>e,Bh=e=>{throw Error(`Invalid ByteSize: ${e}`)},Vh=e=>!Number.isSafeInteger(e)||e<0?Bh(`expected a non-negative safe integer, received ${e}`):zh(BigInt(e)),Hh=(e,t)=>{if(typeof e==`bigint`)return e<Ah?Bh(`expected a non-negative quantity, received ${e}`):zh(e*t.factor);let n=e*Number(t.factor);return!Number.isSafeInteger(n)||n<0?Bh(`expected an exact non-negative safe-integer byte result, received ${e} ${t.symbol}`):zh(BigInt(n))},Uh=e=>{let t=/^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(e);if(t===null)return Bh(`unsupported syntax ${JSON.stringify(e)}`);let n=Lh.get(t[3]);if(n===void 0)return Bh(`unsupported unit ${JSON.stringify(t[3])}`);let r=t[2]??``,i=BigInt(10)**BigInt(r.length),a=BigInt(t[1]+r)*n.factor;return a%i===Ah?zh(a/i):Bh(`${JSON.stringify(e)} does not represent an integral number of bytes`)},Wh=e=>{switch(typeof e){case`bigint`:return e<Ah?Bh(`expected a non-negative bigint, received ${e}`):zh(e);case`number`:return Vh(e);case`string`:return Uh(e)}return Bh(`unsupported input ${e}`)},Gh=(e=>t=>Hh(t,Rh.get(e)))(`MiB`),Kh=class extends Sn{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Kh(this.encode,this.decode)}},qh=`~effect/SchemaTransformation/Transformation`,Jh=class extends Sn{[qh]=qh;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Jh(this.encode,this.decode)}};function Yh(e){return w(e,qh)&&e[qh]===qh}var Xh=e=>Yh(e)?e:new Jh(e.decode,e.encode);function Zh(e){return new Jh(Ch(e.decode),Ch(e.encode))}function Qh(e){return new Jh(Sh(e.decode),Sh(e.encode))}var $h=new Jh(xh(),xh());function eg(){return $h}var tg=new Jh(Th(),wh()),ng=e=>Vn(e)&&typeof e.message==`string`,rg=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:sg(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},ig=e=>{try{let t=Kr(e);return t===void 0?zr(e):JSON.parse(t)}catch{return zr(e)}},ag=(e,t,n)=>{let r={name:e.name,message:typeof e.message==`string`?e.message:``};return t?.includeStack&&typeof e.stack==`string`&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},og=e=>{let t=new WeakSet,n=r=>{if(Wn(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=ag(r,e,n);return t.delete(r),i}return ig(r)};return n},sg=e=>ng(e)?rg(e):e,cg=e=>Qh({decode:sg,encode:og(e)}),lg=new Jh(kh(),Oh());function ug(e){return new Jh(Eh(e??{}),Dh(e))}function dg(e){return t=>t._tag===e}var fg=dg(`Declaration`),pg=dg(`Null`),mg=dg(`Void`),hg=dg(`Never`),gg=dg(`Literal`),_g=dg(`UniqueSymbol`),vg=dg(`Arrays`),yg=dg(`Objects`),bg=dg(`Union`),xg=dg(`Suspend`),Sg=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},Cg={},wg=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},Tg=`~effect/Schema`,Eg=class{[Tg]=Tg;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},Dg=class extends Eg{_tag=`Declaration`;typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,i,a,o,s){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o,this.encodingRun=s}getParser(){let e;return(t,n)=>t===W?zm:(e??=this.run(this.typeParameters))(t,this,n)}_rebuild(e,t,n,r,i){let a=q_(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new Dg(a,r,this.annotations,t,void 0,this.context,n,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},Og=new class extends Eg{_tag=`Null`;getParser(){return dv(this,null)}getExpected(){return`null`}},kg=class extends Eg{_tag=`Undefined`;getParser(){return dv(this,void 0)}toCodecJson(){return K(this,[Ag])}getExpected(){return`undefined`}},Ag=new Sg(Og,new Jh(Sh(()=>void 0),Sh(()=>null))),jg=new kg,Mg=new class extends Eg{_tag=`Void`;getParser(){let e=Rm(void 0);return t=>t===W?zm:e}toCodecJson(){return K(this,[Ag])}getExpected(){return`void`}},Ng=new class extends Eg{_tag=`Never`;getParser(){return fv(this,zn)}getExpected(){return`never`}},Pg=new class extends Eg{_tag=`Unknown`;getParser(){return fv(this,Bn)}getExpected(){return`unknown`}},Fg=class extends Eg{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${zr(e)}`);this.literal=e}getParser(){return dv(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?Ig(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:Ig(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function Ig(e){let t=globalThis.String(e.literal);return K(e,[new Sg(new Fg(t),new Jh(Sh(()=>e.literal),Sh(()=>t)))])}var Lg=new class extends Eg{_tag=`String`;getParser(){return fv(this,Mn)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&Sv(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},Rg=class extends Eg{_tag=`Number`;getParser(){return fv(this,Nn)}matchKey(e,t){return this._match(_v,e,t)}matchPart(e,t){return this._match(gv,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:Sv(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(zg(this.checks,`effect/schema/isFinite`)||zg(this.checks,`effect/schema/isInt`))?this:K(this,[j_])}toCodecStringTree(){return this.toCodecJson()===this?K(this,[bv]):K(this,[xv])}getExpected(){return`number`}};function zg(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&zg(e.checks,t))}var Bg=new Rg,Vg=new class extends Eg{_tag=`Boolean`;getParser(){return fv(this,Pn)}getExpected(){return`boolean`}},Hg=class extends Eg{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(nv(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(nv(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}return Tm(function*(e,c){if(e===W)return W;if(!Array.isArray(e))return yield*V(new Qm(n,e,c));r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)})));let l=e.length,u={ast:n,getParser:s,input:e,len:l,tailThreshold:Math.max(a,l-o),output:new globalThis.Array(l),issues:void 0,options:c},d=n.rest.length===0?a:Math.max(l,a+o),f=c.concurrency===void 0?1:md(c.concurrency),p=f===1?Gg(u,e,0,d):Kg(u,e,{concurrency:f,end:d});if(p&&(yield*p),n.rest.length===0&&l>a)for(let t=a;t<=l-1;t++){let r=new Xm(n,e[t],c),i=new Jm([t],r);if(c.errors===`all`)u.issues?u.issues.push(i):u.issues=[i];else return yield*V(new Zm(n,[i],e,c))}return u.issues?yield*V(new Zm(n,u.issues,e,c)):u.output})}_rebuild(e,t,n){let r=q_(this.elements,e),i=q_(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new Hg(this.isMutable,r,i,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}};function Ug(e,t,n,r){if(n._tag===`Failure`)return qg(e,e.ast,r,n);let i=n===G?t:n[D];if(i!==W)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(nv(t.ast))return;let n=new Jm([r],new Ym(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return Sf(new Zm(e.ast,[n],e.input,e.options))}}var Wg={onItem(e,t,n){let r=n<e.len?t:W;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:Ug},Gg=hd()(Wg),Kg=_d()(Wg),qg=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=_h(r.cause);if(i===void 0)return xf(mf(r.cause,r=>new Zm(t,[new Jm([n],r)],e.input,e.options)));let a=new Jm([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return Sf(new Zm(t,[a],e.input,e.options))},Jg=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;function Yg(e,t,n=Cg){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(pv(sv(t)))}var Xg=class{name;type;constructor(e,t){this.name=e,this.type=t}};function Zg(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(Zg);default:return!1}}function Qg(e){let t=L_(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(Qg);default:return!1}}function $g(e){return Zg(e)&&Qg(e)}var e_=class{parameter;type;constructor(e,t){if(!$g(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,nv(t)&&!uv(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},t_=class extends Eg{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o;let s=new Set,c=[];for(let t of e){let e=t.name;s.has(e)?c.push(e):s.add(e)}if(c.length>0)throw Error(`Duplicate identifiers: ${JSON.stringify(c)}. ts(2300)`)}getParser(e,t=e){let n=this,r=[];for(let e of n.propertySignatures)r.push(typeof e.name==`number`?globalThis.String(e.name):e.name);let i=r.length,a=n.indexSignatures.length,o=i&&a?new Set(r):void 0;if(!i&&!a)return fv(n,Rn);let s,c,l=(e,t,r,a,s)=>{if(s._tag===`Failure`)return qg(e,n,t,s)??Cf;let c=s===G?a:s[D];if(r!==W&&c!==W){if(i&&(o.has(t)||o.has(typeof r==`number`?globalThis.String(r):r)))return Cf;E(e.out,r,c)}return Cf},u=(e,t,r,i)=>{if(!i){let n=r.parserKey(t,e.options);if(!z(n))return H(Up(n),n=>u(e,t,r,n));i=n}if(i._tag===`Failure`)return qg(e,n,t,i)??Cf;let a=i===G?t:i[D],o=e.input[t],s=r.parserValue(o,e.options);return z(s)?l(e,t,a,o,s):H(Up(s),n=>l(e,t,a,o,n))},d=(e,t,n)=>{let r=e.input[t],i=n.parserValue(r,e.options);return z(i)?l(e,t,t,r,i):H(Up(i),n=>l(e,t,t,r,n))},f=a?_d()({onItem:(e,[t,n])=>n.is.parameter===Lg?d(e,t,n):u(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0,p=()=>(s||(s=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),c=a?n.indexSignatures.map(n=>({is:n,parserKey:e(pv(n.parameter)),parserValue:t(n.type)})):void 0),s),m=Tm(function*(e,t){if(e===W)return W;if(typeof e!=`object`||!e||Array.isArray(e))return yield*V(new Qm(n,e,t));p();let l=e,m={},h={ast:n,input:l,out:m,issues:void 0,options:t},g=t.errors===`all`,_=t.onExcessProperty===`error`,ee=t.concurrency===void 0?1:md(t.concurrency),v=a&&_?n.indexSignatures.map(e=>Yg(l,e.parameter,t)):void 0;if(_){o??=new Set(r);let i=v?new Set(o):o;if(v)for(let e of v)for(let t of e)i.add(t);let a=Reflect.ownKeys(l);for(let r=0;r<a.length;r++){let o=a[r];if(!i.has(o)){let r=new Xm(n,l[o],t),i=new Jm([o],r);if(g){h.issues?h.issues.push(i):h.issues=[i];continue}return yield*V(new Zm(n,[i],e,t))}}}if(i){let e=ee===1?i_(h,s):a_(h,s,{concurrency:ee});e&&(yield*e)}if(a&&ee===1)for(let e=0;e<a;e++){let n=c[e],r=n.is.parameter===Lg?d:u,i=v?.[e]??(n.is.parameter===Lg?Object.keys(l):Yg(l,n.is.parameter,t));for(let e=0;e<i.length;e++){let t=r(h,i[e],n);if(!z(t))yield*t;else if(t._tag===`Failure`)return yield*t}}else if(f){let e=Za();for(let n=0;n<a;n++){let r=c[n],i=v?.[n]??(r.is.parameter===Lg?Object.keys(l):Yg(l,r.is.parameter,t));for(let t=0;t<i.length;t++)e.push([i[t],r])}let n=f(h,e,{concurrency:ee});n&&(yield*n)}return h.issues?yield*V(new Zm(n,h.issues,e,t)):m});if(a)return m;let h=(e,t,n)=>{let r=s[t];return H(Up(n),n=>{let i=n_(e,r,n);if(i)return i;let a=()=>Rm(e.out),o=i_(e,s.slice(t+1));return o?wm(o,a):a()})};return(e,t)=>{if(e===W)return zm;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&md(t.concurrency)!==1)return m(e,t);if(typeof e!=`object`||!e||Array.isArray(e))return V(new Qm(n,e,t));let r=p(),i=e,a={},o={ast:n,input:i,out:a,issues:void 0,options:t};try{for(let e=0;e<r.length;e++){let n=r[e],s=n.name,c=g_(i,s),l=c?i[s]:W,u=n.parser(l,t);if(!z(u))return h(o,e,u);if(u===G){c&&E(a,s,l);continue}let d=n_(o,n,u);if(d)return d}}catch(e){return Fp(e)}return Rm(a)}}_rebuild(e,t,n,r){let i=q_(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new Xg(t.name,n)}),a=q_(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new e_(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new t_(i,a,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function n_(e,t,n){if(n._tag===`Failure`)return qg(e,e.ast,t.name,n);if(n===G)return;let r=n[D];if(r!==W){E(e.out,t.name,r);return}if(delete e.out[t.name],!nv(t.type)){let n=new Jm([t.name],new Ym(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return Sf(new Zm(e.ast,[n],e.input,e.options))}}var r_={onItem(e,t){if(!g_(e.input,t.name))return t.parser(W,e.options);let n=e.input[t.name];return E(e.out,t.name,n),t.parser(n,e.options)},step:n_},i_=hd()(r_),a_=_d()(r_);function o_(e,t){return e?t?[...e,...t]:e:t}function s_(e,t,n){return new t_(Reflect.ownKeys(e).map(t=>new Xg(t,e[t].ast)),[],n,t)}function c_(e){return e.ast}function l_(e,t=void 0){return new Hg(!1,e.map(e=>e.ast),[],void 0,t)}function u_(e,t,n){return new b_(e.map(c_),t,void 0,n)}var d_=kn(e=>{for(;;){if(xg(e))return Pg;let t=e.encoding;if(!t)return e.recur?.(d_,C)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==C))return Pg;e=t[t.length-1].to}});function f_(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(f_)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function p_(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[Am];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!nv(t)){if(gg(t))return[{key:e.name,literal:t.literal}];if(_g(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!nv(e)){if(gg(e))return[{key:t,literal:e.literal}];if(_g(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>p_(d_(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return p_(e.thunk())}}var m_=new WeakMap,h_=Object.freeze([]),g_=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function __(e){let t=m_.get(e);if(t)return t;let n,r=0,i,a,o=!0;for(let t=0;t<e.length;t++){let s=e[t],c=d_(s);if(hg(c))continue;if(o){if(gg(c)||_g(c)){a??=new Map;let e=gg(c)?c.literal:c.symbol,t=a.get(e);t||a.set(e,t=[]),t.push(s)}else o=!1}let l=p_(c);if(l.length){n??=new Map,r++;for(let{key:e,literal:r}of l){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=f_(c);for(let n of e)(i[n]??=[]).push(t)}}if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??h_;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=i;for(let[t,n]of i)a.set(t,Object.freeze(Array.from(n,t=>e[t])));t=(t,n)=>{if(Hn(t)){let i=g_(t,r)?t[r]:void 0;if(i!==void 0)return a.get(i)??h_;if(n)return e}return h_}}else if(n){let a;for(let e of n)(!a||e[1][0].size>a[1][0].size)&&e[1][1].size===r&&(a=e);t=(t,r)=>{let o=i?.[t===null?`null`:Array.isArray(t)?`array`:typeof t]??h_;if(!Hn(t))return o.map(t=>e[t]);let s=new Set(o),c;if(a){let[n,[i]]=a,l=g_(t,n),u=l?t[n]:void 0;if(l&&(!r||u!==void 0)){let t=i.get(u);if(!t)return o.map(t=>e[t]);for(let e of t)s.add(e);c=n}}if(c===void 0)for(let[e,[i,a]]of n){let n=g_(t,e),o=n?t[e]:void 0;if(n&&(!r||o!==void 0)){let e=i.get(o);if(e)for(let t of e)s.add(t)}else if(r)for(let e of a)s.add(e)}for(let[e,[i,a]]of n){if(e===c)continue;let n=g_(t,e),o=n?t[e]:void 0;if(n&&(!r||o!==void 0)){let e=i.get(o);for(let t of s)a.has(t)&&!e?.has(t)&&s.delete(t)}}return Array.from(s).sort((e,t)=>e-t).map(t=>e[t])}}else t=t=>(i?.[t===null?`null`:Array.isArray(t)?`array`:typeof t]??h_).map(t=>e[t]).filter(v_(t));return m_.set(e,t),t}function v_(e){return t=>{let n=d_(t);return n._tag===`Literal`?n.literal===e:n._tag!==`UniqueSymbol`||n.symbol===e}}function y_(e,t,n=!1){return __(t)(e,n)}var b_=class extends Eg{_tag=`Union`;types;options;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.options=t,this.encodingChecks=o}getParser(e,t){let n=this;return(r,i)=>{if(r===W)return zm;let a=y_(r,n.types,t!==void 0);if(a.length===0)return V(new nh(n,[],r,i));if(a.length===1){let t=e(a[0])(r,i);return t._tag===`Success`?t:z(t)?x_(n,t.cause,r,i):Jp(t,e=>x_(n,e,r,i))}let o={ast:n,compile:e,input:r,out:void 0,successes:n.options?.mode===`oneOf`?[]:void 0,issues:void 0,options:i},s=S_(o,a);return s?wm(s,e=>o.out===G?B(r):o.out?o.out:V(new nh(n,o.issues??[],r,i))):o.out?o.out:V(new nh(n,o.issues??[],r,i))}}_rebuild(e,t,n){let r=q_(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new b_(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=sv(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(gg);if(t.length>0)return`${w_(n.isMutable)}[ ${t.map(t=>e(t)+T_(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>gg(e.type));if(t.length>0)return`{ ${t.map(t=>`${w_(t.type.context?.isMutable)}${Vr(t.name)}${T_(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function x_(e,t,n,r){let i=_h(t);return i?Sf(new nh(e,[i],n,r)):xf(t)}var S_=hd()({onItem(e,t){return e.compile(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=_h(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(t),Sf(new rh(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(t);else return Cf}}}),C_=new b_([new Fg(`Infinity`),new Fg(`-Infinity`),new Fg(`NaN`)]);function w_(e){return e?``:`readonly `}function T_(e){return e?`?`:``}var E_=class extends Sn{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new E_(this.run,{...this.annotations,...e},this.aborted)}abort(){return new E_(this.run,this.annotations,!0)}and(e,t){return new D_([this,e],t)}},D_=class extends Sn{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new D_(this.checks,{...this.annotations,...e})}and(e,t){return new D_([this,e],t)}};function O_(e,t,n=!1){return new E_((t,n,r)=>oh(n,e(t,n,r),t,r),t,n)}function k_(e){return O_(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitraryConstraint:{number:`finite`},...e})}var A_=B_(Bg,[k_()]),j_=new Sg(new b_([A_,C_]),new Jh(Th(),Sh(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function M_(e,t){let n=e.source,r=new globalThis.RegExp(n,e.flags);return O_(e=>(r.lastIndex=0,r.test(e)),{expected:`a string matching the RegExp ${n}`,representation:{id:`effect/schema/isPattern`,payload:{source:n,flags:e.flags}},toJsonSchema:()=>({pattern:n}),arbitraryConstraint:{patterns:[{source:e.source,flags:e.flags}]},...t})}function N_(e,t){let n=Object.getOwnPropertyDescriptors(e);return t(n),Object.create(Object.getPrototypeOf(e),n)}var P_=new WeakMap;function F_(e){return P_.get(e)??e}function K(e,t){return e.encoding===t?e:N_(e,e=>{e.encoding.value=t})}function I_(e,t){if(e.context===t)return e;let n=F_(e);if(n.context===t)return n;let r=N_(e,e=>{e.context.value=t});return P_.set(r,n),r}function L_(e){return e.encoding?L_(e.encoding[e.encoding.length-1].to):e}function R_(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return z_(e,qa(e.checks.slice(0,-1),n.annotate(t)))}return N_(e,e=>{e.annotations.value={...e.annotations.value,...t}})}function z_(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:N_(e,e=>{e.checks.value=t})}function B_(e,t){return z_(e,o_(e.checks,t))}function V_(e,t){let n=t(e.to);return n===e.to?e:new Sg(n,e.transformation)}function H_(e,t){let n=e,r=n[n.length-1],i=V_(r,t);return i===r?e:qa(e.slice(0,e.length-1),i)}function U_(e){return t=>t.encoding?K(t,H_(t.encoding,e)):t}function W_(e,t){return U_(e=>I_(e,t))(e)}function G_(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:K(r,H_(r.encoding,n))}return e(r)}return kn(n)}function K_(e,t,n){let r=new Sg(e,t);return K(n,n.encoding?[...n.encoding,r]:[r])}function q_(e,t){let n=!1,r=Array(e.length);for(let i=0;i<e.length;i++){let a=e[i],o=t(a);o!==a&&(n=!0),r[i]=o}return n?r:e}function J_(e,t){return I_(e,e.context?new wg(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new wg(!1,!1,void 0,t))}var Y_=kn(e=>X_(I_(e,e.context?e.context.isOptional===!1?new wg(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new wg(!0,!1)))),X_=U_(Y_),Z_=On(e=>Y_(new b_([e,jg])));function Q_(e,t){return I_(e,e.context?new wg(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new wg(!1,!1,t))}function $_(e,t,n){return K_(e,n,t)}function ev(e){let t=[],n=[];function r(e){switch(e._tag){case`Literal`:In(e.literal)&&t.push(e.literal);return;case`UniqueSymbol`:t.push(e.symbol);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)r(e.types[t]);return;default:n.push(e)}}return r(e),{literals:t,parameters:n}}function tv(e,t){let{literals:n,parameters:r}=ev(e);return new t_(n.map(e=>new Xg(e,t)),r.map(e=>new e_(e,t)))}function nv(e){return e.context?.isOptional??!1}function rv(e){return e.context?.isMutable??!1}function iv(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(iv)}function av(e){function t(e){return iv(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return Ya(n)?n:void 0}var ov=kn(e=>{if(e.encoding)return ov(K(e,void 0));let t=e,n=t.recur?.(ov)??t,r=n.encodingChecks;if(r){let t=n===e?r:vg(n)||yg(n)||fg(n)&&n.typeParameters.length>0?av(r):void 0;return N_(n,e=>{e.encodingChecks.value=void 0,e.checks.value=o_(n.checks,t)})}return n}),sv=kn(e=>ov(lv(e)));function cv(e,t){let n=t,r=n.length,i=n[r-1],a=[new Sg(lv(K(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new Sg(lv(n[e-1].to),n[e].transformation.flip()));let o=lv(i.to);return o.encoding?K(o,[...o.encoding,...a]):K(o,a)}var lv=On(e=>{if(e.encoding)return cv(e,e.encoding);let t=e;return t.flip?.(lv)??t.recur?.(lv)??t});function uv(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(uv);default:return!1}}function dv(e,t){let n=t===0?G:Rm(t);return(r,i)=>r===W?zm:r===t?n:V(new Qm(e,r,i))}function fv(e,t){return(n,r)=>n===W?zm:t(n)?G:V(new Qm(e,n,r))}var pv=G_(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(pv)}}),mv=G_(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(mv)}}),hv=`[\\s\\S]*?`,gv=new globalThis.RegExp(`^${Jg}$`),_v=new globalThis.RegExp(`^(?:${Jg}|Infinity|-Infinity|NaN)$`);function vv(e){return M_(gv,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:gv.source}),...e})}var yv=B_(Lg,[vv()]),bv=new Sg(yv,tg),xv=new Sg(new b_([yv,C_]),tg);function Sv(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=Sv(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new Km(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function Cv(e){if(!fg(e))return;let t=e.annotations?.[jm];return Ln(t)?t(e.typeParameters):void 0}var wv=Dm,Tv=Nm,Ev=Fm;function Dv(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function Ov(e){return e===void 0||typeof e==`string`}function kv(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function Av(e){return kv(e,Dv)}var jv=new Dg([],()=>(e,t,n)=>Av(e)?G:V(new Qm(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>Fv}),Mv=new Sg(jv,eg()),Nv=new Sg(new b_([new Hg(!1,[],[jv]),new t_([],[new e_(Lg,jv)])]),eg());function Pv(e){return kv(e,Ov)}var Fv=new Sg(new Dg([],()=>(e,t,n)=>Pv(e)?G:V(new Qm(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),eg()),Iv=ol,Lv=sl,Rv=Qc,zv=Sd,Bv=Md,Vv=`~effect/MutableRef`,Hv={[Vv]:Vv,...ui,toJSON(){return{_id:`MutableRef`,current:Jr(this.current)}}},Uv=e=>{let t=Object.create(Hv);return t.current=e,t},Wv=Symbol.for(`effect/MutableList/Empty`),Gv=()=>({head:void 0,tail:void 0,length:0}),Kv=()=>({array:[],mutable:!0,offset:0,next:void 0}),qv=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=Kv(),e.tail=e.tail.next):e.head=e.tail=Kv(),e.tail.array.push(t),e.length++},Jv=e=>{e.head=e.tail=void 0,e.length=0},Yv=e=>{if(!e.head)return Wv;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:Jv(e)),t},Xv=`~effect/Queue`,Zv=`~effect/Queue/Enqueue`,Qv=`~effect/Queue/Dequeue`,$v={_A:C,_E:C},ey={[Xv]:$v,[Zv]:$v,[Qv]:$v,...ui,toJSON(){return{_id:`effect/Queue`,state:this.state._tag,size:ly(this)}}},ty=e=>A(t=>{let n=Object.create(ey);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??1/0,n.strategy=e?.strategy??`suspend`,n.messages=Gv(),n.scheduleRunning=!1,n.state={_tag:`Open`,takers:new Set,offers:new Set,awaiters:new Set},P(n)}),ny=e=>ty({capacity:e}),ry=(e,t)=>I(()=>{if(e.state._tag!==`Open`)return uy;if(e.messages.length>=e.capacity)switch(e.strategy){case`dropping`:return uy;case`suspend`:return e.capacity<=0&&e.state.takers.size>0?(qv(e.messages,t),my(e),dy):gy(e,t);case`sliding`:return Yv(e.messages),qv(e.messages,t),dy}return qv(e.messages,t),hy(e),dy}),iy=S(2,(e,t)=>F(()=>ay(e,t))),ay=(e,t)=>{if(e.state._tag!==`Open`)return!1;let n=au(Li(t),fy);return e.state.offers.size===0&&e.messages.length===0?(by(e,n),!0):(e.state={...e.state,_tag:`Closing`,exit:n},!0)},oy=e=>F(()=>{if(e.state._tag===`Done`)return!0;Jv(e.messages);let t=e.state.offers;if(by(e,e.state._tag===`Open`?py:e.state.exit),t.size>0){for(let e of t)e._tag===`Single`?e.resume(uy):e.resume(k(e.remaining.slice(e.offset)));t.clear()}return!0}),sy=e=>I(()=>cy(e)??Ul(yy(e),sy(e))),cy=e=>{if(e.state._tag===`Done`)return e.state.exit;if(e.messages.length>0){let t=Yv(e.messages);return vy(e),k(t)}if(e.capacity<=0&&e.state.offers.size>0){let t=_y(e.state.offers);return vy(e),k(t)}},ly=e=>e.state._tag===`Done`?0:e.messages.length,uy=k(!1),dy=k(!0),fy=Ri(Ki()),py=Ql(),my=e=>{if(e.state._tag!==`Done`&&e.state.takers.size!==0){for(let t of e.state.takers)if(e.state.takers.delete(t),t(tu),e.messages.length===0)break}},hy=e=>{e.scheduleRunning||e.state._tag===`Done`||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,my(e)},0))},gy=(e,t)=>wl(n=>{if(e.state._tag!==`Open`)return n(uy);let r={_tag:`Single`,message:t,resume:n};return e.state.offers.add(r),F(()=>{e.state._tag===`Open`&&e.state.offers.delete(r)})}),_y=e=>{let t=e.values().next().value;if(t._tag===`Single`)return e.delete(t),t.resume(dy),t.message;let n=t.remaining[t.offset++];return t.offset===t.remaining.length&&(e.delete(t),t.resume(k([]))),n},vy=e=>{if(e.state._tag===`Done`)return yp(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag===`Closing`&&e.messages.length===0&&(by(e,e.state.exit),yp(e.state.exit.cause));for(let t of e.state.offers){let n=e.capacity-e.messages.length;if(n<=0)break;if(t._tag===`Single`)qv(e.messages,t.message),e.state.offers.delete(t),t.resume(dy);else{for(;t.offset<t.remaining.length;t.offset++){if(n===0)return!1;qv(e.messages,t.remaining[t.offset]),n--}e.state.offers.delete(t),t.resume(k([]))}}return!1},yy=e=>wl(t=>e.state._tag===`Done`?t(e.state.exit):(e.state.takers.add(t),F(()=>{e.state._tag!==`Done`&&e.state.takers.delete(t)}))),by=(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()},xy=e=>new Cy(e),Sy=(e,t,n)=>wl(r=>{if(e.free>=t)return r(n);let i=()=>{e.free<t||(e.waiters.delete(i),r(n))};return e.waiters.add(i),F(()=>{e.waiters.delete(i)})}),Cy=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=I(()=>this.free<e?Sy(this,e,t):(this.taken+=e,P(e)));return t}takeIfAvailable(e){return I(()=>this.free<e?P(!1):(this.taken+=e,P(!0)))}releaseUnsafe(e,t){return this.taken-=t,this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{for(let e of this.waiters){if(this.free<=0)break;e()}},0),this.free}resize(e){return A(t=>(this.permits=e,this.free<0||this.releaseUnsafe(t,0),L))}release(e){return A(t=>P(this.releaseUnsafe(t,e)))}get releaseAll(){return A(e=>P(this.releaseUnsafe(e,this.taken)))}withPermits(e){return t=>ud(n=>{let r=I(()=>this.free<e?R(n(Sy(this,e,L)),()=>r):(this.taken+=e,Zu(n(t),()=>{this.releaseUnsafe(Qc(),e)},!0)));return r})}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>ud(n=>this.free<e?ml:(this.taken+=e,Zu(n(Hl(t)),()=>{this.releaseUnsafe(Qc(),e)},!0)))}},wy=`~effect/Channel`,Ty=e=>w(e,wy),Ey={[wy]:{_Env:C,_InErr:C,_InElem:C,_OutErr:C,_OutElem:C},pipe(){return x(this,arguments)}},Dy=e=>{let t=Object.create(Ey);return t.transform=(t,n)=>Jp(e(t,n),e=>B(Np(e))),t},Oy=(e,t)=>Dy((n,r)=>H(jy(e)(n,r),e=>t(e,r))),ky=e=>Dy((t,n)=>e),Ay=e=>Dy(bm(function*(t,n){let r=If(n),i=e=>Lf(r,Cp(e));return am(yield*am(e(t,n,r),i),i)})),jy=e=>e.transform,My=e=>Dy((t,n)=>kp(()=>jy(e())(t,n))),Ny=e=>ky(B(V(e))),Py=e=>ky(Ap(()=>{let t=!1;return kp(()=>t?yf():(t=!0,e))})),Fy=e=>Dy((t,n)=>Iy({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),Iy=e=>{let t=e.readable.getReader(),n=e.exit??Uv(void 0),r=kp(()=>n.current?n.current:$p(Op({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??Np(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?yf():B(Qa(t))}));return Wp(Ff(e.scope,e.releaseLockOnEnd?Ap(()=>t.releaseLock()):Dp(()=>t.cancel().catch(Dn))),r)},Ly=S(2,(e,t)=>Oy(e,e=>Ap(()=>{let n=0;return U(e,e=>t(e,n++))}))),Ry=e=>e===void 0||e!==`unbounded`&&e<=1,zy=S(e=>Ty(e[0]),(e,t,n)=>Ry(n?.concurrency)?By(e,t):Vy(e,t,n)),By=(e,t)=>Dy((n,r)=>{let i=0;return U(jy(e)(n,r),H(e=>t(e,i++)))}),Vy=(e,t,n)=>Ay(bm(function*(r,i,a){let o=0,s=yield*jy(e)(r,i),c=n.concurrency===`unbounded`?2**53-1:n.concurrency,l=yield*ny(0);yield*Ff(a,oy(l));let u=gm(yield*em()),d=zv(a);if(n.unordered){let e=xy(c),n=Cn(e.release(1)),r=$p({onFailure:e=>H(iy(l,e),n),onSuccess:e=>H(ry(l,e),n)});yield*e.take(1).pipe(H(()=>s),H(e=>(d(u(r(t(e,o++)))),jp)),um({disableYield:!0}),Jp(t=>e.withPermits(c-1)(iy(l,t))),mm(a))}else{let e=yield*ny(c-2);yield*Ff(a,oy(e)),yield*sy(e).pipe(zp,H(e=>ry(l,e)),um({disableYield:!0}),Jp(e=>iy(l,e)),mm(a));let n,r=e=>{e._tag!==`Success`&&(n=e.cause,ay(l,e.cause))};yield*s.pipe(H(i=>{if(n)return Np(n);let a=u(t(i,o++));return d(a),a.addObserver(r),ry(e,Iv(a))}),um({disableYield:!0}),Jp(t=>ry(e,xf(t)).pipe(Bp(iy(e,t)))),mm(a))}return sy(l)})),Hy=S(2,(e,t)=>Dy((n,r)=>{let i=If(r);return U(jy(e)(n,i),e=>{let a=e.pipe(Jp(e=>{if(yp(e))return Np(e);let o=i;return i=If(r),Lf(o,xf(e)).pipe(Bp(jy(t(e))(n,i)),H(e=>(a=e,e)))}));return kp(()=>a)})})),Uy=S(2,(e,t)=>Dy((n,r)=>H(jy(e)(n,r),e=>jy(t)(e,r)))),Wy=S(2,(e,t)=>Ay((n,r,i)=>Pf(i,t).pipe(Bp(jy(e)(n,r))))),Gy=S(2,(e,t)=>Wy(e,e=>t)),Ky=(e,t,n)=>kp(()=>{let r=Mf();return vp(H(jy(e)(yf(),r),t),n||B).pipe(om(e=>Lf(r,e)))}),qy=S(2,(e,t)=>Dy((n,r)=>U(rm(jy(e)(n,r),t),rm(t)))),Jy=S(2,(e,t)=>Ky(e,e=>um(H(e,t),{disableYield:!0}))),Yy=(e,t)=>jy(e)(yf(),t),Xy=(e,t,n)=>e===G?n(t):wm(e,n);function Zy(e){if(e._tag===`Middleware`)return(t,n,r)=>Qy(t===G?e.decode(Rm(Bm(n)),r):e.decode(xm(t,Bm),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===G?Rm(t):e;case`Transform`:{let e=e=>e===W?zm:Rm(t.transform(e));return(t,n)=>Xy(t,n,e)}case`TransformOptional`:{let e=e=>Vm(t.transform(Bm(e)));return(t,n)=>Xy(t,n,e)}case`TransformEffect`:return(e,n,r)=>Xy(e,n,e=>e===W?zm:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>Xy(e,n,e=>Qy(t.transform(Bm(e),r)))}}var Qy=e=>wm(e,Vm),$y=(e,t,n,r)=>Jp(r,r=>Pp(()=>mf(r,r=>new qm(e,r,t,n))));function eb(e,t){let n=Zy(e.link.transformation),r;return(i,a)=>{if(i===W)return zm;if(e.isConstructed(i))return G;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function tb(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==W&&r!==void 0)return t(r,i);let a=n;if(z(a)&&a._tag===`Success`){let e=t(a[D],i);return e===G?a:e}return wm($y(e,r,i,a),e=>{let n=t(e,i);return n===G?Rm(e):n})}}function nb(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:tb(e,n)}function rb(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?Cv(e):void 0,o=a?eb(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>Zy(e.transformation)),u=e.encodingChecks;if(!c&&!s&&!u)return o;let d,f=(t,n)=>{let r=o(t,n);if(u&&!n.disableChecks){if(z(r)){if(r._tag===`Success`){let i=r===G?t:r[D];if(t!==W&&i!==W){let i=Sv(u,t,void 0,e,n);i&&(r=V(new Zm(e,i,t,n)))}}}else r=H(r,r=>{if(t!==W&&r!==W){let r=Sv(u,t,void 0,e,n);if(r)return V(new Zm(e,r,t,n))}return B(r)})}if(s&&!n.disableChecks){if(z(r)){if(r._tag===`Success`){let i=r===G?t:r[D];if(i===W)return r;let a=Sv(s,i,void 0,e,n);a&&(r=V(new Zm(e,a,i,n)))}}else r=H(r,t=>{if(t!==W){let r=Sv(s,t,void 0,e,n);if(r)return V(new Zm(e,r,t,n))}return B(t)})}return r},p=i===void 0?f:i(f);return c?(n,r)=>{let i=d??=c.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=c.length-1;e>=0;e--)if(o=l[e](o,a,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[D],o=t(a,r)):o=wm(o,e=>{let n=t(e,r);return n===G?Rm(e):n})}if(o._tag===`Success`){let e=o[D],t=p(e,r);return t===G?o:t}return o=$y(e,n,r,o),wm(o,e=>{let t=p(e,r);return t===G?Rm(e):t})}:p}var ib=Symbol(),ab=new WeakMap,ob=e=>ub(e).parser,sb=e=>ub(e).makeEffect,cb=e=>nb(e,sb),lb=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=rb(this.ast,ob)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=rb(this.ast,sb,cb)}};function ub(e){let t=ab.get(e);if(t!==void 0)return t;let n=new lb(e);return ab.set(e,n),n}function db(e){let t=e.ast,n;return(e,r)=>(n??=xb(Db,ov(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function fb(e){let t=db(e);return(e,n)=>{let r=ym(t(e,n));return wf(r)?Sa(r.value):(vh(r.cause,`Option adapter can only return none for schema issues`),xa())}}function pb(e){return Tb(ov(e.ast))}function mb(e,t){let n=yb(e.ast);return t===void 0?n:(e,r)=>n(e,_b(t,r))}function hb(e,t){return Cb(mb(e,t))}function gb(e,t){let n=yb(lv(e.ast));return t===void 0?n:(e,r)=>n(e,_b(t,r))}var _b=(e,t)=>t?{...e,...t}:e,vb=e=>e===W?V(new $m):B(e);function yb(e){return xb(Eb,e)}function bb(e,t){return e===G?B(t):z(e)?e[D]===W?vb(W):e:wm(e,vb)}function xb(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??Cg);return a===G?B(r):z(a)?a[D]===W?vb(W):a:wm(a,vb)}}function Sb(e){return(t,n)=>ym(e(t,n))}function Cb(e){let t=Sb(e);return(e,n)=>{let r=t(e,n);return wf(r)?Sa(r.value):(vh(r.cause,`Option adapter can only return none for schema issues`),xa())}}function wb(e,t){let n=ym(e);if(wf(n))return n.value;let r=vh(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}function Tb(e){let t,n;return(r,i)=>{t??=ub(e);let a=i?.disableChecks?i.parseOptions?{...i.parseOptions,disableChecks:!0}:{disableChecks:!0}:i?.parseOptions??Cg,o=t.make;if(o!==void 0&&r!==W){let e;try{e=o(r,a)}catch(e){throw vh(uf(e),`Constructor adapter can only throw schema issues`),e}if(e!==ib&&e!==W)return e}return wb(bb((n??=t.makeEffect)(r,a),r),`Constructor adapter can only throw schema issues`)}}var Eb=e=>ub(e).parser,Db=e=>ub(e).makeEffect,Ob=`~effect/Schema/Schema`,kb={[Ob]:Ob,pipe(){return x(this,arguments)},annotate(e){return this.rebuild(R_(this.ast,e))},annotateKey(e){return this.rebuild(J_(this.ast,e))},check(...e){return this.rebuild(B_(this.ast,e))}};function Ab(e,t){function n(){}let r=Object.setPrototypeOf(n,kb);return t&&(Object.hasOwn(t,`name`)||Object.hasOwn(t,`length`)||Object.hasOwn(t,`__proto__`))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r.ast=e,r.rebuild=e=>Ab(e,t),r.makeEffect=db(r),r.make=pb(r),r.makeOption=fb(r),r}function jb(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Mb(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function Nb(e){return encodeURI(jb(e)).replace(/#/g,`%23`)}function Pb(e){if(e.length===0||e===`#`)return``;if(!e.startsWith(`#`))return;let t=e.slice(1);try{if(encodeURI(t).replace(/%25/g,`%`).replace(/#/g,`%23`)!==t)return;let e=decodeURIComponent(t);return e.startsWith(`/`)&&!/~(?:[^01]|$)/.test(e)?e:void 0}catch{return}}function Fb(e){let t=Pb(e);return t===void 0?void 0:t.length===0?[]:t.slice(1).split(`/`).map(Mb)}function Ib(e){return e.reduce((e,t)=>`${e}/${Nb(t)}`,`#`)}var Lb=[`example`,`discriminator`,`xml`,`externalDocs`];function Rb(e){let t=Object.keys(e.definitions),n=new Map,r=new Set(t.filter(e=>zb.test(e))),i=t.filter(e=>!zb.test(e)).sort().map(e=>[e,Bb(e)]);for(let[e,t]of i)r.has(t)||(r.add(t),n.set(e,t));for(let[e,t]of i){if(n.has(e))continue;let i,a=0;do i=`${t}_${++a}`;while(r.has(i));r.add(i),n.set(e,i)}function a(t,r=!1){let i=Gb(t.$id),a=Vn(t.$defs)?t.$defs:void 0;return Vb(t,(t,o)=>{Jb(t,Lb,`OpenAPI 3.1`,`Draft 2020-12`),Ub(t,(t,s)=>{let c=t.startsWith(`#`)?Fb(t):void 0;if(c===void 0||c[0]!==`$defs`||c.length<2)return t;let l=c[1];return i?(r&&!o&&Object.hasOwn(e.definitions,l)&&(a===void 0||!Object.hasOwn(a,l))&&qb(s,`OpenAPI 3.1`,`a schema resource cannot reference the shared definitions pool`),t):o?t:Ib([`components`,`schemas`,n.get(l)??l,...c.slice(2)])})})}let o=e.schemas.map(e=>a(e,!0)),s={};for(let r of t)E(s,n.get(r)??r,a(e.definitions[r]));return{dialect:`openapi-3.1`,schemas:o,definitions:s}}var zb=/^[a-zA-Z0-9.\-_]+$/;function Bb(e){return e.length===0?`_`:e.replace(/[^a-zA-Z0-9._-]/gu,`_`)}function Vb(e,t){return n(e,!1,!0);function n(e,r,i=!1){if(!Vn(e))return e;let a=r||!i&&Gb(e.$id),o={};for(let t of Object.keys(e)){let r=e[t],i=r;switch(t){case`$defs`:case`properties`:case`patternProperties`:case`dependentSchemas`:i=Wb(r,e=>n(e,a))??r;break;case`allOf`:case`anyOf`:case`oneOf`:case`prefixItems`:i=Array.isArray(r)?r.map(e=>n(e,a)):r;break;case`not`:case`additionalProperties`:case`propertyNames`:case`unevaluatedProperties`:case`items`:case`contains`:case`unevaluatedItems`:case`if`:case`then`:case`else`:case`contentSchema`:i=n(r,a)}E(o,t,i)}return t(o,a),o}}function Hb(e,t){return Vb(e,e=>{Ub(e,t)})}function Ub(e,t){typeof e.$ref==`string`&&E(e,`$ref`,t(e.$ref,`$ref`)),typeof e.$dynamicRef==`string`&&E(e,`$dynamicRef`,t(e.$dynamicRef,`$dynamicRef`))}function Wb(e,t){if(!Vn(e))return;let n={};for(let r of Object.keys(e))E(n,r,t(e[r],r));return n}function Gb(e){return typeof e==`string`&&e.length>0&&e[0]!==`#`}var Kb=[`$anchor`,`$defs`,`$dynamicAnchor`,`$dynamicRef`,`$vocabulary`,`contentSchema`,`dependentRequired`,`dependentSchemas`,`maxContains`,`minContains`,`prefixItems`,`unevaluatedItems`,`unevaluatedProperties`];[...Kb],[...Kb];function qb(e,t,n){throw Error(`Cannot convert JSON Schema keyword "${e}" to ${t}: ${n}`)}function Jb(e,t,n,r){for(let i of t)Object.hasOwn(e,i)&&qb(i,n,`it is not active in ${r} but would become active in the target`)}function Yb(e){return Ab(Xb(e.ast),{schema:e})}var Xb=G_(e=>{let t=tx(e,Xb),n=e.context;return t===e||n===void 0?t:W_(t,Zb(n))});function Zb(e){return e.constructorDefault===void 0?e:new wg(e.isOptional,e.isMutable,void 0,e.annotations)}function Qb(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function $b(e){return t=>{let n=new Map;for(let e=0;e<t.length;e++)n.set(sv(t[e]),e);let r=[...t].sort((t,r)=>{t=sv(t),r=sv(r);let i=e(t),a=e(r);return i===a?n.get(t)-n.get(r):i-a});return r.some((e,n)=>e!==t[n])?r:t}}var ex=$b(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function tx(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!Ln(n))return K(e,[Mv]);let r=n(e.typeParameters.map(e=>Ab(sv(e))));return r===void 0?e:K(e,[V_(r,t)])}case`Unknown`:return K(e,[Mv]);case`ObjectKeyword`:return K(e,[Nv]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return Qb(e),e.recur(t,mv);case`Union`:{let n=ex(e.types);return n===e.types?e.recur(t):new b_(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}function nx(e){return Ab(ux(e.ast),{schema:e})}function rx(e){return Ab(fx(e.ast))}var ix=$b(e=>{switch(e._tag){case`Null`:case`Boolean`:case`Number`:case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function ax(e,t,n){switch(e._tag){case`Declaration`:{let r=e.typeParameters.map(e=>Ab(t(sv(e)))),i=e.annotations?.toCodecStringTree;if(Ln(i)){let n=i(r);return n===void 0?e:K(e,[V_(n,t)])}let a=e.annotations?.toCodecJson,o=Ln(a)?a(r):void 0,s=o===void 0?e.annotations?.toCodec:void 0,c=o??(Ln(s)?s(r):void 0);return c===void 0?n(e):K(e,[V_(c,t)])}case`Null`:return K(e,[ox]);case`Boolean`:return K(e,[sx]);case`Unknown`:case`ObjectKeyword`:return K(e,[Fv]);case`Enum`:case`Number`:case`Literal`:case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return Qb(e),e.recur(t,mv);case`Union`:{let n=ix(e.types);return n===e.types?e.recur(t):new b_(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}var ox=new Sg(new Fg(`null`),new Jh(Sh(()=>null),Sh(()=>`null`))),sx=new Sg(new b_([new Fg(`true`),new Fg(`false`)]),new Jh(Sh(e=>e===`true`),wh())),cx=new Jh(Sh(e=>typeof e==`string`?[e]:e),xh()),lx=e=>e.transformation===cx,ux=G_(e=>{let t=ax(e,ux,e=>{throw new globalThis.Error(`Missing structural codec for StringTree`,{cause:e})});return t!==e&&e.context!==void 0?W_(t,Zb(e.context)):t},{stopAt:lx}),dx=e=>nv(e)?Y_(Pg):Pg,fx=G_(e=>{let t=px(e);if(vg(t)){let n=$_(new b_([new Hg(t.isMutable,t.elements.map(dx),t.rest.map(dx)),Lg],{mode:`anyOf`}),t,cx);return nv(e)?Y_(n):n}return t},{stopAt:lx});function px(e){return e._tag===`Declaration`||e._tag===`Arrays`||e._tag===`Objects`||e._tag===`Union`||e._tag===`Suspend`?e.recur(fx):e}globalThis.RegExp;var mx=e=>e.replace(/[/\\^$*+?.()|[\]{}]/g,`\\$&`);function hx(e,t){return t.length>0&&(e+=`\n at ${Hr(t)}`),Error(e)}function gx(e){return`#/$defs/${Nb(e)}`}var _x=new Set([...Lm,km,...Mm]);function vx(e,t){if(e===void 0)return;let n={},r=e.title;typeof r==`string`&&(n.title=r);let i=e.description,a=e.expected;typeof i==`string`?n.description=i:t?.generateDescriptions===!0&&typeof a==`string`&&(n.description=a);let o=e.default;Av(o)&&(n.default=o);let s=e.examples;Array.isArray(s)&&Av(s)&&(n.examples=s);let c=e.readOnly;typeof c==`boolean`&&(n.readOnly=c);let l=e.writeOnly;typeof l==`boolean`&&(n.writeOnly=l);let u=e.format;typeof u==`string`&&(n.format=u);let d=e.contentEncoding;typeof d==`string`&&(n.contentEncoding=d);let f=e.contentMediaType;typeof f==`string`&&(n.contentMediaType=f);let p=e.contentSchema;if(Av(p)&&(n.contentSchema=p),t?.includeAnnotationKey!==void 0)for(let[r,i]of Object.entries(e))!_x.has(r)&&t.includeAnnotationKey(r)&&Av(i)&&E(n,r,i);return Object.keys(n).length===0?void 0:n}function yx(e){let t=e.type===`number`||e.type===`integer`?e.type:void 0,n=e;if(t!==void 0&&(n={...e},delete n.type),Array.isArray(n.allOf)){let e=[],r=!1;for(let i of n.allOf){let n=yx(i);n.type!==void 0&&(r=!0,(t===void 0||n.type===`integer`)&&(t=n.type)),Object.keys(n.schema).length>0&&e.push(n.schema)}if(r){let{allOf:t,...r}=n;n=e.length===0?r:{...r,allOf:e}}}return{type:t,schema:n}}function bx(e){if(!Array.isArray(e.anyOf)||e.anyOf.length!==2||e.anyOf[0]?.type!==`number`)return!1;let t=e.anyOf[1];return t?.type===`string`&&Array.isArray(t.enum)&&t.enum.length===3&&t.enum.includes(`NaN`)&&t.enum.includes(`Infinity`)&&t.enum.includes(`-Infinity`)}var xx=`|type|format|pattern|multipleOf|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minProperties|maxProperties|propertyNames|`;function Sx(e,t){return Object.keys(e).every(e=>t.includes(`|${e}|`))}function Cx(e,t){return typeof e.$ref!=`string`&&t.every(t=>!Object.hasOwn(e,t))}var wx=`|title|description|default|examples|readOnly|writeOnly|`,Tx=xx+wx;function Ex(e,t,n){if(Object.keys(e).length===0)return t;let r=Object.keys(t);if(r.length===0)return e;let i=e.type===`number`||e.type===`integer`?e.type:void 0,a=bx(e);if(i!==void 0||a){let r=yx(t);if(r.type!==void 0){let t=i===`integer`||r.type===`integer`?`integer`:`number`,o={...e,type:t};a&&delete o.anyOf;let s=Object.keys(r.schema);return s.length===0?o:Sx(r.schema,wx)&&Cx(o,s)?{...o,...r.schema}:Ex(o,r.schema,n)}}if(n&&Cx(e,r))return{...e,...t};let o=Array.isArray(t.allOf)&&r.length===1?t.allOf:[t];return Array.isArray(e.allOf)?{...e,allOf:[...e.allOf,...o]}:typeof e.$ref==`string`?{allOf:[e,...o]}:{...e,allOf:o}}function Dx(e,t,n,r){let i=new Map,a=new WeakMap,o=new Map,s=Object.keys(n);for(let e of s)u(e,[`references`,e]);let c=$a(e,(e,n)=>d(h(e,t[n]))),l={};for(let e of s){let t=i.get(e);typeof t!=`string`&&E(l,e,d(t))}return{dialect:`draft-2020-12`,schemas:c,definitions:l};function u(e,t){let r=i.get(e);if(r!==void 0)return typeof r==`string`?r:e;if(!Object.hasOwn(n,e))throw hx(`Invalid reference ${e}`,[...t,`$ref`]);i.set(e,null);let a=n[e],s=h(a,[`references`,e]),c=f(a);if(c!==void 0){let t=o.get(c),n=t?.find(e=>lr(i.get(e),s));if(n===void 0)t===void 0?o.set(c,[e]):t.push(e);else return i.set(e,n),n}return i.set(e,s),e}function d(e){return Hb(e,e=>{let t=Pb(e);if(t===void 0){if(/^#(?:\/|%2f)/i.test(e))throw Error(`Invalid JSON Pointer URI fragment ${JSON.stringify(e)}`);return e}if(!t.startsWith(`/$defs/`))return e;let n=t.indexOf(`/`,7),r=i.get(Mb(t.slice(7,n<0?void 0:n)));return typeof r==`string`?e.replace(/^#(?:\/|%2f).*?(?:\/|%2f).*?(?=\/|%2f|$)/i,gx(r)):e})}function f(e){if(e._tag===`Reference`)return;let t=e.checks.length===0?e.annotations:e.checks[e.checks.length-1].annotations;return typeof t?.identifier!=`string`&&typeof t?.[`~identifier`]==`string`?t[km]:void 0}function p(e,t){return e?.schemas?.map((e,n)=>h(e,[...t,`schemas`,n]))??[]}function m(e,t,n){let i=e.annotations,a=i?.toJsonSchema;if(a!==void 0){let o=a({type:t,schemas:p(e.representation,[...n,`representation`])}),s=vx(i,r),c=s===void 0?o:{...o,...s},l=s===void 0?xx:Tx;return e._tag===`Filter`&&Sx(c,l)&&(s===void 0||Sx(s,wx))?[c,!0]:[c]}if(e._tag===`Filter`)return;let o=e.checks.map((e,r)=>m(e,t,[...n,`checks`,r])).filter(e=>e!==void 0);if(o.length===0)return;let s=vx(i,r),c=o.map(([e])=>e);return[s===void 0?{allOf:c}:{allOf:c,...s}]}function h(e,t){if(e._tag===`Reference`)return{$ref:gx(u(e.$ref,t))};let n=a.get(e);if(n!==void 0)return n;let i=g(e,t),o=vx(e.annotations,r);o!==void 0&&(i={...i,...o});for(let n=0;n<e.checks.length;n++){let r=typeof i.type==`string`&&Ox(i.type)?i.type:void 0,a=m(e.checks[n],r,[...t,`checks`,n]);a!==void 0&&(i=Ex(i,...a))}return a.set(e,i),i}function g(e,t){switch(e._tag){case`Any`:case`Unknown`:return{};case`ObjectKeyword`:return{anyOf:[{type:`object`},{type:`array`}]};case`Void`:case`Undefined`:case`Null`:return{type:`null`};case`BigInt`:return{type:`string`,allOf:[{pattern:`^-?\\d+$`}]};case`Symbol`:return{type:`string`,allOf:[{pattern:`^Symbol\\(([\\s\\S]*)\\)$`}]};case`UniqueSymbol`:return globalThis.Symbol.keyFor(e.symbol)===void 0?{not:{}}:{type:`string`,enum:[globalThis.String(e.symbol)]};case`Declaration`:return{};case`Suspend`:return h(e.thunk,[...t,`thunk`]);case`Never`:return{not:{}};case`String`:return{type:`string`};case`Number`:return{anyOf:[{type:`number`},{type:`string`,enum:[`NaN`,`Infinity`,`-Infinity`]}]};case`Boolean`:return{type:`boolean`};case`Literal`:{let t=e.literal;return typeof t==`bigint`?{type:`string`,enum:[globalThis.String(t)]}:{type:typeof t,enum:[t]}}case`Enum`:{let n=e.enums.map(([e,n],r)=>{if(typeof n==`number`&&!globalThis.Number.isFinite(n))throw hx(`Invalid numeric enum value ${globalThis.String(n)}`,[...t,`enums`,r,1]);return{type:typeof n,enum:[n],title:e}});return n.length===0?{not:{}}:{anyOf:n}}case`TemplateLiteral`:return{type:`string`,pattern:`^${e.parts.map(Ax).join(``)}$`};case`Arrays`:{if(e.rest.length>1)throw hx(`Invalid schema representation document`,[...t,`rest`]);let n={type:`array`},i=e.elements.length,a=e.elements.map((e,n)=>{e.isOptional&&i--;let a=h(e.type,[...t,`elements`,n,`type`]),o=vx(e.annotations,r);return o===void 0?a:Ex(a,o)});if(a.length>0?(n.prefixItems=a,n.maxItems=e.elements.length,i>0&&(n.minItems=i)):n.items=!1,e.rest.length===1){delete n.maxItems;let r=h(e.rest[0],[...t,`rest`,0]);Object.keys(r).length>0?n.items=r:delete n.items}return n}case`Objects`:{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return{not:{type:`null`}};let n={type:`object`},i={},a=[];for(let n=0;n<e.propertySignatures.length;n++){let o=e.propertySignatures[n];if(typeof o.name!=`string`)throw hx(`Invalid schema representation document`,[...t,`propertySignatures`,n,`name`]);let s=o.name,c=h(o.type,[...t,`propertySignatures`,n,`type`]),l=vx(o.annotations,r);E(i,s,l===void 0?c:Ex(c,l)),o.isOptional||a.push(s)}e.propertySignatures.length>0&&(n.properties=i),a.length>0&&(n.required=a);let o={},s=[],c=[],l=!1;for(let n=0;n<e.indexSignatures.length;n++){let r=e.indexSignatures[n],i=h(r.type,[...t,`indexSignatures`,n,`type`]);lr(i,{not:{}})&&(i=!1),c.push(i);let a=_(r.parameter,[...t,`indexSignatures`,n,`parameter`],new Set);if(a===void 0){l=!0;continue}if(a.length===0)s.push(i);else for(let e of a){let t=o[e];E(o,e,t===void 0?i:t===!1||i===!1?!1:Ex(t,i))}}let u=Object.keys(o).length>0;if(u&&(n.patternProperties=o),l&&r?.onExcessProperty===`error`){let r=[];e.propertySignatures.length>0&&r.push({enum:Object.keys(i)});for(let n=0;n<e.indexSignatures.length;n++)r.push(h(e.indexSignatures[n].parameter,[...t,`indexSignatures`,n,`parameter`]));n.propertyNames=r.length===1?r[0]:{anyOf:r},n.additionalProperties=c.length===1?c[0]:{anyOf:c},s.length>0&&(n.allOf=s.map(e=>({type:`object`,additionalProperties:e})))}else s.length===0?n.additionalProperties=l||r?.onExcessProperty!==`error`:s.length===1&&e.propertySignatures.length===0&&!u?n.additionalProperties=s[0]:s.length>0&&(n.allOf=s.map(e=>({type:`object`,additionalProperties:e})));return typeof n.additionalProperties==`object`&&n.additionalProperties!==null&&Object.keys(n.additionalProperties).length===0&&delete n.additionalProperties,n}case`Union`:{let n=e.types.map((e,n)=>h(e,[...t,`types`,n]));if(n.length===0)return{not:{}};let r=e.options?.mode??`anyOf`;if(r===`anyOf`&&n.length>1){let e=kx(n);if(e!==void 0)return e}return r===`anyOf`?{anyOf:n}:{oneOf:n}}}}function _(e,t,r){switch(e._tag){case`Reference`:{if(!Object.hasOwn(n,e.$ref))throw hx(`Invalid reference ${e.$ref}`,[...t,`$ref`]);if(u(e.$ref,t),r.has(e.$ref))return;let i=new Set(r).add(e.$ref);return _(n[e.$ref],[`references`,e.$ref],i)}case`String`:{if(e.checks.length===0)return[];if(e.checks.length!==1||e.checks[0]._tag!==`Filter`||e.checks[0].annotations?.toJsonSchema===void 0)return;let n=h(e,t);return n.type===`string`&&typeof n.pattern==`string`&&Sx(n,`|type|pattern|title|description|default|examples|readOnly|writeOnly|`)?[n.pattern]:void 0}case`TemplateLiteral`:return e.checks.length===0?[`^${e.parts.map(Ax).join(``)}$`]:void 0;case`Union`:{if(e.types.length===0||e.checks.length>0||e.options?.mode===`oneOf`)return;let n=[];for(let i=0;i<e.types.length;i++){let a=_(e.types[i],[...t,`types`,i],r);if(a===void 0)return;if(a.length===0)return[];n.push(...a)}return n}default:throw hx(`Invalid schema representation document`,t)}}}function Ox(e){return e===`string`||e===`number`||e===`boolean`||e===`array`||e===`object`||e===`null`||e===`integer`}function kx(e){let t,n=[];for(let r of e){if(Object.keys(r).length!==2||r.type===void 0||!Array.isArray(r.enum)||r.enum.length===0)return;if(t===void 0)t=r.type;else if(r.type!==t)return;for(let e of r.enum){if(n.includes(e))return;n.push(e)}}return{type:t,enum:n}}function Ax(e){switch(e._tag){case`Literal`:return mx(globalThis.String(e.literal));case`String`:return hv;case`Number`:return Jg;case`TemplateLiteral`:return e.parts.map(Ax).join(``);case`Union`:return`(?:${e.types.map(Ax).join(`|`)})`;default:throw hx(`Invalid schema representation document`,[])}}function jx(e,t){return Dx(e.representations,e.representations.map((e,t)=>[`representations`,t]),e.references,t)}var Mx=({identifier:e})=>e;function Nx(e){return e===void 0?void 0:{annotations:e}}function Px(e,t){let n={},r=new Map,i=new Set,a=new Map,o=new Set;for(let t of e)f(t);let s=t?.referencePolicy??Mx;for(let e of a.values())for(let t of e.values()){let e=s({ast:t.ast,occurrences:t.occurrences,identifier:t.identifier});e===void 0?t.isRecursive&&(t.reference=c(`${t.ast._tag}_`,t,``)):t.reference=c(e,t,e===t.identifier||!e.endsWith(`_`)?`_`:``)}return{representations:$a(e,e=>m(e)),references:n};function c(e,t,n=`_`){let i=e,a=0;for(;r.has(i);){if(r.get(i)===t)return i;i=`${e}${n}${++a}`}return r.set(i,t),i}function l(e,t,n){let r=t.fallback;return r===void 0?n===t.identifier?e:R_(e,{identifier:n}):Pm(e)===r?e:R_(e,{[km]:r})}function u(e,t){if(!Object.hasOwn(n,e)&&!i.has(e)){i.add(e);let r=h(t);i.delete(e),E(n,e,r)}return{_tag:`Reference`,$ref:e}}function d(e){let t=L_(e),n=F_(t),r=Nm(t),i=r===void 0?(t===e?void 0:Nm(e))??Pm(t):void 0;i!==void 0&&(r=`${i}Encoded`);let o=a.get(n);o===void 0&&(o=new Map,a.set(n,o));let s=o.get(r);return s===void 0&&(s={ast:n,identifier:r,fallback:i,occurrences:0,isRecursive:!1,reference:void 0},o.set(r,s)),s}function f(e){let t=d(e),n=t.ast;if(t.occurrences++,o.has(t)){t.isRecursive=!0;return}if(!(t.occurrences>1)){switch(o.add(t),p(n.checks),n._tag){case`Declaration`:case`Arrays`:case`Objects`:case`Union`:n.recur(e=>(f(e),e));break;case`TemplateLiteral`:n.parts.forEach(f);break;case`Suspend`:f(n.thunk())}o.delete(t)}}function p(e){e?.forEach(e=>{e.annotations?.representation?.schemas?.forEach(e=>f(ov(e))),e._tag===`FilterGroup`&&p(e.checks)})}function m(e){let t=d(e),n=t.ast,r=t.reference;return r===void 0?h(n):u(r,t.identifier===void 0?n:l(n,t,r))}function h(e){let t=g(e.checks);switch(e._tag){case`Declaration`:return{_tag:`Declaration`,typeParameters:e.typeParameters.map(e=>m(e)),checks:t,...ee(e.annotations)};case`Null`:case`Undefined`:case`Void`:case`Never`:case`Unknown`:case`Any`:case`String`:case`Boolean`:case`Number`:case`BigInt`:case`Symbol`:case`ObjectKeyword`:return{_tag:e._tag,checks:t,...Nx(e.annotations)};case`Literal`:return{_tag:`Literal`,literal:e.literal,checks:t,...Nx(e.annotations)};case`UniqueSymbol`:return{_tag:`UniqueSymbol`,symbol:e.symbol,checks:t,...Nx(e.annotations)};case`Enum`:return{_tag:`Enum`,enums:e.enums,checks:t,...Nx(e.annotations)};case`TemplateLiteral`:return{_tag:`TemplateLiteral`,parts:e.parts.map(e=>m(e)),checks:t,...Nx(e.annotations)};case`Arrays`:return{_tag:`Arrays`,elements:e.elements.map(e=>{let t=L_(e),n=t.context?.annotations;return{isOptional:nv(t),type:m(e),...Nx(n)}}),rest:e.rest.map(e=>m(e)),checks:t,...Nx(e.annotations)};case`Objects`:return{_tag:`Objects`,propertySignatures:e.propertySignatures.map(e=>{let t=L_(e.type),n=t.context?.annotations;return{name:e.name,type:m(e.type),isOptional:nv(t),isMutable:rv(t),...Nx(n)}}),indexSignatures:e.indexSignatures.map(e=>({parameter:m(e.parameter),type:m(e.type)})),checks:t,...Nx(e.annotations)};case`Union`:return{_tag:`Union`,types:e.types.map(e=>m(e)),...e.options===void 0?{}:{options:e.options},checks:t,...Nx(e.annotations)};case`Suspend`:return{_tag:`Suspend`,checks:[],thunk:m(e.thunk()),...Nx(e.annotations)}}}function g(e){return e?.map(_)??[]}function _(e){switch(e._tag){case`Filter`:return{_tag:`Filter`,aborted:e.aborted,...v(e.annotations)};case`FilterGroup`:return{_tag:`FilterGroup`,checks:$a(e.checks,_),...v(e.annotations)}}}function ee(e){if(e===void 0)return;let{representation:t,...n}=e;return{...t===void 0?void 0:{representation:t},...Object.keys(n).length===0?void 0:{annotations:n}}}function v(e){if(e===void 0)return;let{representation:t,...n}=e,r=t===void 0?void 0:t.schemas===void 0?t:{...t,schemas:t.schemas.map(e=>m(ov(e)))};return{...r===void 0?void 0:{representation:r},...Object.keys(n).length===0?void 0:{annotations:n}}}}function Fx(e,t){let n=t;for(let t of e)n=zx(n,t);return n}function Ix(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Lx(e){if(e===``)return[];if(e.charCodeAt(0)!==47)throw Error(`Invalid JSON Pointer, it must start with "/": ${JSON.stringify(e)}`);return e.split(`/`).slice(1).map(Mb)}function Rx(e){if(!/^(0|[1-9]\d*)$/.test(e))throw Error(`Invalid array index: "${e}"`);return Number(e)}function zx(e,t){if(t.path===``){if(t.op===`remove`)throw Error(`Unsupported operation at the root`);return t.value}let n=Bx(e,t.path);if(n===null)throw Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`);let{lastToken:r,parent:i,stack:a}=n;if(Array.isArray(i)){if(r===`-`&&t.op!==`add`)throw Error(`"-" is not valid for ${t.op} at "${t.path}".`);let e=r===`-`?i.length:Rx(r);if(e>(t.op===`add`?i.length:i.length-1))throw Error(`Array index out of bounds at "${t.path}".`);let n=i.slice();return t.op===`add`?n.splice(e,0,t.value):t.op===`remove`?n.splice(e,1):n[e]=t.value,Vx(a,n)}if(Ix(i)){if(t.op!==`add`&&!Object.hasOwn(i,r))throw Error(`Property "${r}" does not exist at "${t.path}".`);let e={...i};return t.op===`remove`?delete e[r]:E(e,r,t.value),Vx(a,e)}throw Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`)}function Bx(e,t){let n=Lx(t);if(n.length===0)return null;let r=n[n.length-1],i=[],a=e;for(let e=0;e<n.length-1;e++){let t=n[e];if(Array.isArray(a)){let e=Rx(t);if(e>=a.length)return null;i.push({container:a,token:e}),a=a[e];continue}if(Ix(a)){if(!Object.hasOwn(a,t))return null;i.push({container:a,token:t}),a=a[t];continue}return null}return{stack:i,parent:a,lastToken:r}}function Vx(e,t){let n=t;for(let t=e.length-1;t>=0;t--){let{container:r,token:i}=e[t];if(Array.isArray(r)){let e=r.slice();e[i]=n,n=e}else{let e={...r};E(e,i,n),n=e}}return n}var Hx=S(2,(e,t)=>({...e,...t})),Ux=e=>e,Wx=`~effect/Schema/SchemaError`;function Gx(e){return w(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}var Kx=new WeakMap,qx=`~effect/Redacted`,Jx=e=>w(e,qx),Yx=(e,t)=>{let n=Object.create(Xx);return t?.label&&(n.label=t.label),Kx.set(n,e),n},Xx={[qx]:{_A:e=>e},label:void 0,...ui,toJSON(){return this.toString()},toString(){return`<redacted${Mn(this.label)?`:`+this.label:``}>`},[Gn](){return T(Kx.get(this))},[cr](e){return Jx(e)&&lr(Kx.get(this),Kx.get(e))}},Zx=`~effect/http/Cookies`,Qx=`~effect/http/Cookies/Cookie`,$x={[Zx]:Zx,...Yr,toJSON(){return{_id:`effect/Cookies`,cookies:Ba(this.cookies,e=>e.toJSON())}},pipe(){return x(this,arguments)}},eS=e=>{let t=Object.create($x);return t.cookies=e,t},tS=e=>{let t={};for(let n of e)E(t,n.name,n);return eS(t)},nS=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=rS(e.trim());t&&n.push(t)}return tS(n)};function rS(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(!aS.test(r))return;let i=t[0].slice(n+1),a=sS(i);if(t.length===1)return Object.assign(Object.create(oS),{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=As(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;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`}}}return Object.assign(Object.create(oS),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var iS=tS([]),aS=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,oS={[Qx]:Qx,...Yr,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},sS=e=>{try{return decodeURIComponent(e)}catch{return e}},cS=Symbol.for(`~effect/http/Headers`),lS=Object.defineProperties(Object.create(null),{[cS]:{value:cS},[Mr]:{value(e){return yS(this,$o(e,xS))}},toJSON:{value(){return Pr(this)}},[cr]:{value(e){return dS(this,e)}},[Gn]:{value(){return $n(this)}},toString:{value:Yr.toString},[qr]:{value:Yr[qr]}}),uS=e=>Object.assign(Object.create(lS),e),dS=Ua(Dr()),fS=Object.create(lS),pS=e=>{if(e===void 0)return fS;if(Symbol.iterator in e){let t=Object.create(lS);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(lS);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},mS=e=>Object.setPrototypeOf(e,lS),hS=S(3,(e,t,n)=>{let r=uS(e);return r[t.toLowerCase()]=n,r}),gS=S(2,(e,t)=>uS({...e,...pS(t)})),_S=S(2,(e,t)=>{let n=uS(e);return Object.assign(n,t),n}),vS=S(2,(e,t)=>{let n=uS(e);return delete n[t.toLowerCase()],n}),yS=S(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=Yx(e[r]))}else for(let r in e)r.search(t)!==-1&&(n[r]=Yx(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),bS=(e,t)=>{for(let n=0;n<t.length;n++){let r=t[n];if(typeof r==`string`){if(r.toLowerCase()===e.toLowerCase())return!0}else if(e.search(r)!==-1)return!0}return!1},xS=M(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),SS=`~effect/http/UrlParams`,CS=e=>w(e,SS),wS={...ui,[SS]:SS,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:`UrlParams`,params:Object.fromEntries(this.params)}},[cr](e){return OS(this,e)},[Gn](){return tr(this.params.flat())}},TS=e=>{let t=Object.create(wS);return t.params=e,t},ES=e=>{if(CS(e))return e;let t=DS(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 TS(n)},DS=e=>{let t=typeof e[Symbol.iterator]==`function`?Ga(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`&&r){let t=DS(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},OS=Tr((e,t)=>kS(e.params,t.params)),kS=eo(Ra([Dr(),Dr()])),AS=TS([]),jS=S(2,(e,t)=>TS(t(e.params))),MS=S(2,(e,t)=>{let n=ES(t).params.slice(),r=new Set;for(let e=0;e<n.length;e++)r.add(n[e][0]);for(let t=0;t<e.params.length;t++)r.has(e.params[t][0])||n.push(e.params[t]);return TS(n)}),NS=S(2,(e,t)=>jS(e,Ja(ES(t).params))),PS=e=>new URLSearchParams(ES(e).params).toString(),FS=e=>{let t={};for(let[n,r]of e.params)if(!Object.hasOwn(t,n))E(t,n,r);else{let e=t[n];typeof e==`string`?E(t,n,[e,r]):e.push(r)}return t},IS=FS,LS=Ob;function RS(){return(e,t,n)=>q(new Dg(e.map(c_),e=>t(e.map(e=>q(e))),n))}function zS(e,t){return RS()([],()=>(t,n,r)=>e(t)?B(t):V(new Qm(n,t,r)),t)}var BS=class extends Qs(`SchemaError`){[Wx]=Wx;constructor(e){let t=Qr();$r(0);try{super({issue:e})}finally{$r(t)}}get message(){return mh(this.issue)}toString(){return`SchemaError(${this.message})`}};function VS(e){return Gx(e)}function HS(e){return z(e)?US(e):Jp(e,e=>Pp(()=>mf(e,e=>new BS(e))))}function US(e){return wf(e)?e:xf(mf(e.cause,e=>new BS(e)))}function WS(e,t){let n;for(let r of e.reasons){if(!sf(r)||!VS(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function GS(e){let t=ym(e);if(wf(t))return t.value;throw WS(t.cause,`Sync adapter can only throw schema errors`)}function KS(e,t){let n=mb(e,t);return(e,t)=>HS(n(e,t))}var qS=KS,JS=hb;function YS(e,t){let n=KS(e,t);return(e,t)=>GS(n(e,t))}function XS(e,t){let n=gb(e,t);return(e,t)=>HS(n(e,t))}var q=Ab;function ZS(e){return w(e,LS)&&e[LS]===LS}var QS=Ux(e=>{let t=bC(e);return q(Z_(e.ast),{schema:t})}),$S=Ux(e=>q(ov(e.ast),{schema:e})),eC=Ux(e=>q(sv(e.ast),{schema:e}));function tC(e){let t=q(new Fg(e),{literal:e,transform(n){return t.pipe(X(tC(n),{decode:Sh(()=>n),encode:Sh(()=>e)}))}});return t}var nC=q(Ng),rC=q(Pg),iC=q(Og),aC=q(jg),J=q(Lg),oC=q(Bg),sC=q(Vg),cC=q(Mg);function lC(e,t){return q(e,{fields:t,mapFields(e,t){let n=e(this.fields);return lC(s_(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function Y(e){return lC(s_(e,void 0),e)}function uC(e){return Ux(t=>t.mapFields(Hx(e)))}function dC(e,t){return q(tv(e.ast,t.ast),{key:e,value:t})}function fC(e,t){return q(e,{elements:t,mapElements(e,t){let n=e(this.elements);return fC(l_(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function pC(e){return fC(l_(e),e)}var mC=Ux(e=>q(new Hg(!1,[],[e.ast]),{value:e})),hC=Ux(e=>q(new Hg(!1,[e.ast],[e.ast]),{value:e}));function gC(e,t){return q(e,{members:t,mapMembers(e,t){let n=e(this.members);return gC(u_(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function _C(e,t){return gC(u_(e,t,void 0),e)}function vC(e){let t=e.map(tC);return q(u_(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return _C(e(this.members))},pick(e){return vC(e)},transform(e){return _C(t.map((t,n)=>t.transform(e[n])))}})}var yC=Ux(e=>_C([e,iC])),bC=Ux(e=>_C([e,aC]));function X(e,t){return n=>q($_(n.ast,e.ast,t?Xh(t):eg()),{from:n,to:e})}function xC(e){return t=>q(Q_(t.ast,e),{schema:t})}function SC(e){return tC(e).pipe(xC(B(e)))}function CC(e,t){return Y({_tag:SC(e),...t})}function wC(e,t){return zS(t=>t instanceof e,t)}function TC(){return(e,t)=>new Sg(e.ast,Xh(t))}var EC=q(A_),DC=e=>+(e?.includeStack===!0)|(e?.excludeCause===!0?2:0),OC=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},kC=[];function AC(e){let t=DC(e),n=kC[t];if(n!==void 0)return n;let r=ZC.pipe(X(rC,cg(OC(t))));return kC[t]=r,r}globalThis.RegExp,globalThis.URL;var jC=J.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`});function MC(e,t){return jC.pipe(X(e,ug(t)))}var NC=MC(rC);globalThis.File,globalThis.FormData,globalThis.URLSearchParams;var PC=J.annotate({expected:`a base64 encoded string that will be decoded as Uint8Array`,format:`byte`,contentEncoding:`base64`}),FC=wC(globalThis.Uint8Array,{representation:{id:`effect/schema/Uint8Array`,payload:null},toCode:()=>({runtime:`Schema.Uint8Array`,Type:`globalThis.Uint8Array`}),expected:`Uint8Array`,toCodecJson:()=>TC()(PC,lg)});function IC(e,t){return q(RS()([e,t],([e,t])=>(n,r,i)=>{if(!of(n))return V(new Qm(r,n,i));switch(n._tag){case`Fail`:return Cm(mb(e)(n.error,i),{onSuccess:df,onFailure:e=>eh(r,`error`,e,n,i)});case`Die`:return Cm(mb(t)(n.defect,i),{onSuccess:ff,onFailure:e=>eh(r,`defect`,e,n,i)});case`Interrupt`:return B(n)}},{representation:{id:`effect/schema/CauseReason`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.CauseReason(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Failure<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause.Failure`,toCodec:([e,t])=>TC()(_C([Y({_tag:tC(`Fail`),error:e}),Y({_tag:tC(`Die`),defect:t}),Y({_tag:tC(`Interrupt`),fiberId:bC(EC)})]),Qh({decode:e=>{switch(e._tag){case`Fail`:return df(e.error);case`Die`:return ff(e.defect);case`Interrupt`:return pf(e.fiberId)}},encode:e=>{switch(e._tag){case`Fail`:return{_tag:`Fail`,error:e.error};case`Die`:return{_tag:`Die`,defect:e.defect};case`Interrupt`:return{_tag:`Interrupt`,fiberId:e.fiberId}}}}))}).ast,{error:e,defect:t})}function LC(e,t){return q(RS()([e,t],([e,t])=>{let n=mC(IC(e,t));return(e,t,r)=>af(e)?Cm(mb(n)(e.reasons,r),{onSuccess:cf,onFailure:n=>eh(t,`failures`,n,e,r)}):V(new Qm(t,e,r))},{representation:{id:`effect/schema/Cause`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Cause(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Cause<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause`,toCodec:([e,t])=>TC()(mC(IC(e,t)),Qh({decode:cf,encode:({reasons:e})=>e}))}).ast,{error:e,defect:t})}var RC=zS(CS,{representation:{id:`effect/http/UrlParams`,payload:null},toCode:()=>({runtime:`Schema.UrlParams`,Type:`UrlParams.UrlParams`,importDeclarations:[`import * as UrlParams from "effect/unstable/http/UrlParams"`]}),expected:`UrlParams`,toEquivalence:()=>OS,toCodec:()=>TC()(mC(pC([J,J])),Qh({decode:TS,encode:e=>e.params}))}).pipe(X(dC(J,_C([J,hC(J)])),Qh({decode:IS,encode:ES}))),zC=globalThis.Symbol.for(`immer-draftable`),BC={};function VC(e,t,n,r,i){let a=WC(n,t,r),o=UC(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===BC?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:BC,value:i}})}static[LS]=LS;get[o](){return o}static[zC]=!0;static identifier=t;static fields=n.fields;static get ast(){return a(this).ast}static pipe(){return x(this,arguments)}static rebuild(e){return a(this).rebuild(e)}static make(e,t){return pb(a(this))(e??{},t)}static makeOption(e,t){return fb(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(R_(this.ast,e))}static annotateKey(e){return this.rebuild(J_(this.ast,e))}static check(...e){return this.rebuild(B_(this.ast,e))}static extend(e){return(t,r)=>{let a=GC(t)?t:Y(t),o={...n.fields,...a.fields},s=s_(o,n.ast.checks,{identifier:e});return VC(this,e,lC(B_(s,a.ast.checks),o),r,i)}}static mapFields(e,t){return n.mapFields(e,t)}};return i!==void 0&&Object.assign(s.prototype,i(t)),s}function HC(e){return new Jh(Sh(t=>new e(t,{"~payload":{token:BC,value:t}})),xh())}function UC(e){return`~effect/Schema/Class/${e}`}function WC(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=UC(t),o=e=>e instanceof i||w(e,a),s=HC(i);return r=X(q(new Dg([e.ast],()=>(e,t,n)=>o(e)?B(e):V(new Qm(t,e,n)),{identifier:t,[jm]:([e])=>({isConstructed:o,link:new Sg(e,s)}),toCodec:([e])=>new Sg(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[Am]:p_(e.ast),...n})),s)(e)}}function GC(e){return ZS(e)}var KC=e=>(t,n)=>VC(Vi,e,GC(t)?t:Y(t),n,e=>({name:e})),qC=e=>(t,n,r)=>{let i=GC(n)?n.mapFields(e=>({_tag:SC(t),...e}),{unsafePreserveChecks:!0}):CC(t,n);return KC(e??t)(i,r)},JC=Yb,YC=nx,XC=rx,ZC=q(R_(jv,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),QC=(e,t)=>()=>{let n=qS(hC(e),t);return Dy((e,t)=>B(H(e,e=>n(e))))},$C=`~effect/Stream`,ew={_R:C,_E:C,_A:C},tw=function(e){this.channel=e};tw.prototype={[$C]:ew,pipe(){return x(this,arguments)}};var nw=e=>new tw(e),rw=`~effect/Stream`,iw=e=>w(e,rw),aw=nw,ow=e=>aw(Py(U(e,Qa))),sw=(e,t)=>aw(Dy((n,r)=>H(Yy(e.channel,r),e=>t(e,r)))),cw=e=>aw(My(()=>e().channel)),lw=e=>aw(Ny(e)),uw=e=>aw(Fy(e)),dw=S(2,(e,t)=>cw(()=>{let n=0;return aw(Ly(e.channel,$a(e=>t(e,n++))))})),fw=S(2,(e,t)=>aw(zy(e.channel,t))),pw=S(2,(e,t)=>e.channel.pipe(Hy(e=>t(e).channel),aw)),mw=S(2,(e,t)=>aw(Uy(e.channel,t))),hw=S(e=>iw(e[0]),(e,t)=>cw(()=>{let n=new TextDecoder(t?.encoding);return dw(e,e=>n.decode(e,{stream:!0}))})),gw=e=>cw(()=>{let t=new TextEncoder;return dw(e,e=>t.encode(e))}),_w=S(2,(e,t)=>aw(Gy(e.channel,t))),vw=S(2,(e,t)=>aw(qy(e.channel,t))),yw=S(2,(e,t)=>Jy(e.channel,t)),bw=S(e=>iw(e[0]),(e,t,n)=>{let r,i,a=Bv(!1);return new ReadableStream({start(n){i=hm(rm(yw(e,e=>a.whenOpen(Ap(()=>{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(gf(e.cause)):n.close()})},pull(){return new Promise(e=>{r=e,a.openUnsafe()})},cancel(){if(i)return _m(Gp(Lv(i)))}},n?.strategy)}),xw=S(e=>iw(e[0]),(e,t)=>U(em(),n=>bw(e,n,t))),Sw=`~effect/ErrorReporter/ignore`,Cw=S(2,(e,t)=>e===void 0?void 0:t(e)),ww=/^[A-Za-z0-9_-]+$/,Tw=(e,t)=>{if(!ww.test(t)||t===`then`)throw Error(`Invalid ${e}: ${t}`)},Ew=(e,t)=>{let n=new Set;for(let r of t){if(n.has(r))throw Error(`Duplicate ${e}: ${r}`);n.add(r)}},Dw=dC(J,nC);function Ow(e,t){Tw(`action name`,e);let n=t.mcp===!1?!1:t.mcp?.readOnly??!1,r=t.mcp!==!1&&{name:t.mcp?.name??e,readOnly:n,destructive:t.mcp?.destructive??!n,idempotent:t.mcp?.idempotent??!1,openWorld:t.mcp?.openWorld??!0};if(r!==!1&&r.name.length>128)throw Error(`Invalid MCP name: ${r.name}`);return r!==!1&&Tw(`MCP name`,r.name),{name:e,description:t.description,input:t.input??Dw,success:t.success,errors:t.errors??[],http:t.http!==!1,mcp:r}}var kw=class e{group;#e;constructor(e,t){this.group=e,this.#e=t}get build(){return this.#e}static make(t,n){return new e(t,n)}},Aw=(e,t,n)=>{let r=n[t.name];if(r===void 0)throw Error(`Missing handler: ${t.name}`);return n=>fm(kp(()=>r(n)),`${e.name}.${t.name}`,{captureStackTrace:!1})};function jw(e,...t){let{name:n}=e;Tw(`action group name`,n);let r=t.map(t=>({...t,errors:[...t.errors,...e.errors??[]]}));Ew(`action`,r.map(e=>e.name)),Ew(`MCP tool`,r.flatMap(e=>e.mcp===!1?[]:[e.mcp.name]));let i={name:n,actions:r,schemaError:e.schemaError,implement:e=>{let t=Ep(e)?e:B(e);return kw.make(i,t)}};return i}var Mw=`~effect/http/HttpBody`,Nw=e=>w(e,Mw),Pw=class{[Mw];constructor(){this[Mw]=Mw}[qr](){return this.toJSON()}toString(){return zr(this,{ignoreToString:!0})}},Fw=new class extends Pw{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},Iw=class extends Pw{_tag=`Uint8Array`;contentType;contentLength;text;_body;constructor(e,t,n,r){super(),this._body=e,this.text=r,this.contentType=t,this.contentLength=n}get body(){return this._body??=Bw(this.text)}toJSON(){return{_id:`effect/HttpBody`,_tag:`Uint8Array`,body:this.contentType.startsWith(`text/`)||this.contentType.endsWith(`json`)?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},Lw=(e,t)=>new Iw(e,t??`application/octet-stream`,e.length),Rw=new TextEncoder,zw=globalThis.Buffer,Bw=zw===void 0?e=>Rw.encode(e):e=>zw.from(e,`utf8`),Vw=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),zw!==void 0)return new Iw(void 0,t??`text/plain`,zw.byteLength(e,`utf8`),e);let n=Rw.encode(e);return new Iw(n,t??`text/plain`,n.length,e)},Hw=(e,t)=>Vw(JSON.stringify(e),t??`application/json`),Uw=(e,t)=>Vw(PS(ES(e)),t??`application/x-www-form-urlencoded`),Ww=class extends Pw{_tag=`FormData`;contentType=void 0;contentLength=void 0;formData;constructor(e){super(),this.formData=e}toJSON(){return{_id:`effect/HttpBody`,_tag:`FormData`,formData:this.formData}}},Gw=e=>new Ww(e),Kw=class extends Pw{_tag=`Stream`;stream;contentType;contentLength;constructor(e,t,n){super(),this.stream=e,this.contentType=t,this.contentLength=n}toJSON(){return{_id:`effect/HttpBody`,_tag:`Stream`,contentType:this.contentType,contentLength:this.contentLength}}},qw=(e,t,n)=>new Kw(e,t??`application/octet-stream`,n),Jw=`~effect/http/HttpClientError`,Yw=class extends Qs(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[Jw]=Jw;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},Xw=e=>e.endsWith(`Error`)?e.slice(0,-5):e,Zw=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,Qw=class extends Qs(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return Zw(Xw(this._tag),this.description,this.methodAndUrl)}},$w=class extends Qs(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return Zw(Xw(this._tag),this.description,this.methodAndUrl)}},eT=class extends Qs(`StatusCodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return Zw(Xw(this._tag),this.description,e)}},tT=class extends Qs(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return Zw(Xw(this._tag),this.description,e)}},nT=class extends Qs(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return Zw(Xw(this._tag),this.description,e)}},rT=e=>e!==`GET`&&e!==`HEAD`&&e!==`OPTIONS`&&e!==`TRACE`,iT=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],aT=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?vS(vS(e,`content-type`),`content-length`):(e=t.contentType===void 0?vS(e,`content-type`):hS(e,`content-type`,t.contentType),t.contentLength===void 0?vS(e,`content-length`):hS(e,`content-length`,t.contentLength.toString())),oT=class extends Qs(`UrlError`){},sT=(e,t,n)=>Ma({try:()=>{let r=new URL(e,cT());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),r},catch:e=>new oT({cause:e})}),cT=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},lT=`~effect/http/HttpClientRequest`,uT={[lT]:lT,...Yr,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Pr(this.headers),body:this.body.toJSON()}},pipe(){return x(this,arguments)}};function dT(e,t,n,r,i,a){let o=Object.create(uT);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var fT=dT(`GET`,``,AS,xa(),fS,Fw),pT=e=>(t,n)=>mT(fT,{method:e,url:t,...n??void 0}),mT=S(2,(e,t)=>{let n=e;return t.method&&(n=hT(n,t.method)),t.url&&(n=bT(n,t.url)),t.headers&&(n=_T(n,t.headers)),t.urlParams&&(n=CT(n,t.urlParams)),t.hash&&(n=TT(n,t.hash)),t.body&&(n=ET(n,t.body)),t.accept&&(n=vT(n,t.accept)),t.acceptJson&&(n=yT(n)),n}),hT=S(2,(e,t)=>dT(t,e.url,e.urlParams,e.hash,e.headers,e.body)),gT=S(3,(e,t,n)=>dT(e.method,e.url,e.urlParams,e.hash,hS(e.headers,t,n),e.body)),_T=S(2,(e,t)=>dT(e.method,e.url,e.urlParams,e.hash,gS(e.headers,t),e.body)),vT=S(2,(e,t)=>gT(e,`Accept`,t)),yT=vT(`application/json`),bT=S(2,(e,t)=>{if(typeof t==`string`)return dT(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=ES(n.searchParams),i=Da(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,dT(e.method,n.toString(),r,i,e.headers,e.body)}),xT=S(2,(e,t)=>t===``?e:dT(e.method,ST(t,e.url),e.urlParams,e.hash,e.headers,e.body)),ST=(e,t)=>{let n=e.endsWith(`/`),r=t.startsWith(`/`);return n&&r?e+t.slice(1):!n&&!r?e+`/`+t:e+t},CT=S(2,(e,t)=>dT(e.method,e.url,MS(e.urlParams,t),e.hash,e.headers,e.body)),wT=S(2,(e,t)=>dT(e.method,e.url,NS(e.urlParams,t),e.hash,e.headers,e.body)),TT=S(2,(e,t)=>dT(e.method,e.url,e.urlParams,Sa(t),e.headers,e.body)),ET=S(2,(e,t)=>dT(e.method,e.url,e.urlParams,e.hash,aT(e.headers,t),t)),DT=S(2,(e,t)=>ET(e,Gw(t)));function OT(e){let t=sT(e.url,e.urlParams,Oa(e.hash));return Pa(t)?Sa(t.success):xa()}var kT=`~effect/http/HttpIncomingMessage`,AT=M(`effect/http/HttpIncomingMessage/MaxBodySize`,{defaultValue:()=>void 0}),jT=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=vm(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=vm(e.text)}catch{}let i={...t,headers:Pr(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},MT=`~effect/http/HttpClientResponse`,NT=(e,t)=>new PT(e,t),PT=class extends Xr{[kT];[MT];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[kT]=kT,this[MT]=MT}toJSON(){return jT(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split(`#`)[0];let e=OT(this.request);return Ca(e)?``:(e.value.hash=``,e.value.href)}get headers(){return pS(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=nS(this.source.headers.getSetCookie())}get remoteAddress(){return xa()}get stream(){return this.source.body?uw({evaluate:()=>this.source.body,onError:e=>new Yw({reason:new tT({request:this.request,response:this,cause:e})})}):lw(new Yw({reason:new nT({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return H(this.text,e=>Ip({try:()=>e===``?null:JSON.parse(e),catch:e=>new Yw({reason:new tT({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=U(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return H(this.text,e=>Ip({try:()=>ES(new URLSearchParams(e)),catch:e=>new Yw({reason:new tT({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=Op({try:()=>this.source.formData(),catch:e=>new Yw({reason:new tT({request:this.request,response:this,cause:e})})}).pipe(sm,vm)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=Op({try:()=>this.source.arrayBuffer(),catch:e=>new Yw({reason:new tT({request:this.request,response:this,cause:e})})}).pipe(sm,vm),this.arrayBufferBody}pipe(){return x(this,arguments)}},FT=Object.getPrototypeOf(fS),IT=()=>Object.create(FT),LT=`~effect/http/HttpServerResponse`,RT=e=>w(e,LT),zT=e=>YT({status:e?.status??204,statusText:e?.statusText,headers:e?.headers?pS(e.headers):void 0,cookies:e?.cookies}),BT=(e,t)=>{let n=t?.headers?pS(t.headers):fS;return YT({status:t?.status??200,statusText:t?.statusText,headers:n,cookies:t?.cookies??iS,body:Lw(e,VT(t,n))})},VT=(e,t)=>{if(e?.contentType)return e.contentType;if(e?.headers)return t[`content-type`]},HT=(e,t)=>{let n=t?.headers?pS(t.headers):fS;return YT({status:t?.status??200,statusText:t?.statusText,headers:n,cookies:t?.cookies??iS,body:Vw(e,VT(t,n))})},UT=(e,t)=>{let n=t?.headers?pS(t.headers):fS;return YT({status:t?.status??200,statusText:t?.statusText,headers:n,cookies:t?.cookies,body:Hw(e,VT(t,n))})},WT=(e,t)=>{let n=t?.headers?pS(t.headers):fS;return YT({status:t?.status??200,statusText:t?.statusText,headers:n,cookies:t?.cookies,body:Vw(PS(ES(e)),VT(t,n)??`application/x-www-form-urlencoded`)})},GT=(e,t)=>{let n=t?.headers?pS(t.headers):fS;return YT({status:t?.status??200,statusText:t?.statusText,headers:n,cookies:t?.cookies,body:qw(e,VT(t,n),t?.contentLength)})},KT=S(3,(e,t,n)=>YT(e,hS(e.headers,t,n))),qT=S(2,(e,t)=>YT(e,gS(e.headers,t))),JT={...ui,[LT]:LT,[Sw]:!0,toJSON(){return{_id:`HttpServerResponse`,status:this.status,statusText:this.statusText,headers:Pr(this.headers),cookies:this.cookies.toJSON(),body:this.body.toJSON()}}},YT=(e,t)=>{let n=Object.create(JT);if(n.status=e.status,n.statusText=e.statusText,n.cookies=e.cookies??iS,n.body=e.body??Fw,n.body._tag!==`Empty`&&(n.body.contentType||n.body.contentLength!==void 0)){let r=t!==void 0,i=r?t:e.headers===void 0||e.headers===fS?IT():mS({...e.headers});n.body.contentType&&(!r||i[`content-type`]===void 0)&&(i[`content-type`]=n.body.contentType),n.body.contentLength!==void 0&&(!r||i[`content-length`]===void 0)&&(i[`content-length`]=n.body.contentLength.toString()),n.headers=i}else n.headers=t??e.headers??fS;return n},XT=`~effect/http/HttpServerRespondable`,ZT=new Uint8Array(256);for(let e of"!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")ZT[e.charCodeAt(0)]=1;var QT=new Uint8Array(256);QT[9]=1;for(let e=32;e<=126;e++)QT[e]=1;for(let e=128;e<=255;e++)QT[e]=1;var $T=e=>{let t=new Map;return e.maxParts!==void 0&&t.set(eE.key,e.maxParts),e.maxFieldSize!==void 0&&t.set(tE.key,Wh(e.maxFieldSize)),e.maxFileSize!==void 0&&t.set(nE.key,Wh(e.maxFileSize)),e.maxTotalSize!==void 0&&t.set(AT.key,Wh(e.maxTotalSize)),e.fieldMimeTypes!==void 0&&t.set(rE.key,e.fieldMimeTypes),zo(t)},eE=M(`effect/http/Multipart/MaxParts`,{defaultValue:()=>void 0}),tE=M(`effect/http/Multipart/MaxFieldSize`,{defaultValue:Cn(Gh(10))}),nE=M(`effect/http/Multipart/MaxFileSize`,{defaultValue:()=>void 0}),rE=M(`effect/http/Multipart/FieldMimeTypes`,{defaultValue:Cn([`application/json`])}),iE=j(`effect/http/HttpServerRequest`),aE=class extends j()(`effect/http/ParsedSearchParams`){},oE=(e,t)=>{let n=KS(e);return H(iE,e=>n(e.cookies,t))},sE=(e,t)=>{let n=KS(e);return H(iE,e=>n(e.headers,t))},cE=(e,t)=>{let n=KS(e);return H(aE,e=>n(e,t))},lE=e=>mS({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${Ta(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),uE=new WeakSet,dE=e=>Lp(t=>{let n=Qo(t.context,iE);return uE.add(n.source),e}),fE=`~effect/http/HttpClient`,pE=j(`effect/HttpClient`),mE=S(2,(e,t)=>hE(n=>t(e.postprocess(n)),e.preprocess)),hE=(e,t)=>{let n=Object.create(gE);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},gE={[fE]:fE,pipe(){return x(this,arguments)},...Yr,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(iT.map(([e,t])=>[t,function(t,n){return this.execute(pT(e)(t,n))}]))},_E=e=>hE(t=>H(t,t=>Lp(n=>{let r=TE.get(t),i=r??new AbortController,a=sT(t.url,t.urlParams,Oa(t.hash));if(Na(a))return V(new Yw({reason:new $w({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(yc)||n.getRef(yE)(t)){let a=e(t,o,i.signal,n);return r?a:lm(e=>$p(e(a),{onSuccess(e){return wE.register(e,i),B(new EE(e,i))},onFailure(e){return _f(e)&&i.abort(),Np(e)}}))}return dm(n.getRef(SE)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method),a.attribute(`server.address`,o.origin),o.port!==``&&a.attribute(`server.port`,+o.port),a.attribute(`url.full`,o.toString()),a.attribute(`url.path`,o.pathname),a.attribute(`url.scheme`,o.protocol.slice(0,-1));let s=o.search.slice(1);s!==``&&a.attribute(`url.query`,s);let c=n.getRef(xS),l=n.getRef(bE);for(let e in t.headers)l(e,`request`)&&a.attribute(`http.request.header.${e}`,bS(e,c)?`<redacted>`:t.headers[e]);return t=n.getRef(xE)?_T(t,lE(a)):t,lm(s=>s(e(t,o,i.signal,n)).pipe(pm(a,{captureStackTrace:!1}),$p({onSuccess:e=>{a.attribute(`http.response.status_code`,e.status);for(let t in e.headers)l(t,`response`)&&a.attribute(`http.response.header.${t}`,bS(t,c)?`<redacted>`:e.headers[t]);return r?B(e):(wE.register(e,i),B(new EE(e,i)))},onFailure(e){return!r&&_f(e)&&i.abort(),Np(e)}})))})})),B),vE=S(2,(e,t)=>hE(e.postprocess,n=>U(e.preprocess(n),t))),yE=M(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>Tn}),bE=M(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>wn}),xE=M(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:wn}),SE=M(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),CE=e=>tp(pE)(tm(t=>U(e,e=>mE(e,im(e=>is(t,e)))))),wE=(()=>{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))}}})(),TE=new WeakMap,EE=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[MT]=MT;[kT]=kT;applyInterrupt(e){return kp(()=>(wE.unregister(this.original),cm(e,()=>Ap(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}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 cw(()=>(wE.unregister(this.original),_w(this.original.stream,Ap(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[qr](){return this.original[qr]()}pipe(){return x(this,arguments)}},DE=j(`effect/http/HttpRouter`),OE=class extends j()(`effect/http/HttpRouter/RouteContext`){},kE=e=>ip(H(DE,e)),AE=`~effect/http/HttpRouter/Route`,jE=e=>({...e,uninterruptible:e.uninterruptible??!1,prefix:typeof e.prefix==`string`?Sa(e.prefix):e.prefix??xa(),[AE]:AE}),ME=(e,t,n,r)=>jE({...r,method:e,path:t,handler:RT(n)?B(n):Ep(n)?n:H(iE,n),uninterruptible:r?.uninterruptible??!1}),NE=e=>e.endsWith(`/`)?e.slice(0,-1):e,PE=S(2,(e,t)=>(t=NE(t),e===`*`?`${t}/*`:e===`/`?t:t+e)),FE=`~effect/http/HttpRouter/Middleware`,IE=function(){return arguments.length===0?LE:LE(arguments[0],arguments[1])},LE=(e,t)=>t?.global?ip(Mp(function*(){let t=yield*DE,n=Ep(e)?yield*e:e;yield*t.addGlobalMiddleware(n)})):new BE(Ep(e)?rp(U(e,e=>zo(new Map([[zE,e]])))):$f(zo(new Map([[zE,e]])))),RE=0,zE=`effect/http/HttpRouter/MiddlewareFn`,BE=class e{[FE]={};layerFn;dependencies;constructor(e,t){this.layerFn=e,this.dependencies=t;let n=`effect/http/HttpRouter/Middleware-${++RE}`;this.layer=rp(Mp({self:this},function*(){let e=yield*em(),t=[Zo(e,zE)];if(this.dependencies){let n=yield*Yf,r=$o(e,jf),i=yield*Xf(this.dependencies,n,r);t.push(...HE(i))}return zo(new Map([[n,t]]))})).pipe(up(this.layerFn))}layer;combine(t){return new e(this.layerFn,this.dependencies?dp(this.dependencies,t.layer):t.layer)}},VE=new WeakMap,HE=e=>{let t=VE.get(e);if(t)return t;let n=Za(),r=0;for(let[t,i]of e.mapUnsafe)t.startsWith(`effect/http/HttpRouter/Middleware-`)&&(n.push(i),i.length>r&&(r=i.length));if(n.length===0)t=[];else{let e=new Set;for(let t=r-1;t>=0;t--)for(let r of n)t<r.length&&e.add(r[t]);t=Ga(e).reverse()}return VE.set(e,t),t};IE(dE).layer;var UE=`~effect/encoding/Sse/SseError`,WE=class extends Qs(`EventTooLarge`){get message(){return`Pending SSE event exceeded the maximum size of ${this.maxEventSize}`}},GE=class extends Qs(`SseError`){[UE]=UE;get message(){return this.reason.message}},KE=10485760,qE=e=>Dy((t,n)=>Ap(()=>{let n=[],r,i=YE(e=>{e._tag===`Retry`?r=e:n.push(e)},e),a=H(t,e=>{for(let t=0;t<e.length;t++){let n=i.feed(e[t]);if(n!==void 0)return V(n)}return jp});return kp(function e(){if(Ya(n)){let e=n;return n=[],B(e)}return r?V(r):H(a,e)})})),JE=(e,t,n)=>Uy(qE(t),QC(ZE.pipe(X(e,QE)),n)());function YE(e,t){let n=t?.maxEventSize??KE,r,i,a,o,s,c,l,u;return d(),{feed:f,reset:d};function d(){r=!0,i=``,a=0,o=-1,s=!1,c=void 0,l=void 0,u=``}function f(e){i=i?i+e:e,r&&i.startsWith(XE)&&(i=i.slice(XE.length)),r=!1;let t=i.length,c=0;for(;c<t;){s&&=(i[c]===`
|
|
9
|
+
`);n=gh(e)??dh(Im(e.ast),e);break;default:n=sh(e)}return t?`${n}\n at ${t}`:n}function gh(e){if(e._tag===`Pointer`)return;if(e._tag===`Encoding`)return gh(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function _h(e){let t;for(let n of e.reasons){if(!sf(n)||!Um(n.error))return;t??=n.error}return t}function vh(e,t){let n=_h(e);if(n===void 0)throw Error(t,{cause:e});return n}var yh=e=>Object.assign(Object.create(xn),e),bh=yh({_tag:`Passthrough`});function xh(){return bh}function Sh(e){return yh({_tag:`Transform`,transform:e})}function Ch(e){return yh({_tag:`TransformEffect`,transform:e})}function wh(){return Sh(globalThis.String)}function Th(){return Sh(globalThis.Number)}function Eh(e){return Ch((t,n)=>Ip({try:()=>JSON.parse(t,e?.reviver),catch:()=>new $m({expected:`a valid JSON string`},t,n)}))}function Dh(e){return Ch((t,n)=>Ip({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return n},catch:()=>new $m({expected:`a JSON-serializable value`},t,n)}))}function Oh(){return Sh(tc)}function kh(){return Ch((e,t)=>Sm(Rp(nc(e)),()=>new $m({expected:`a valid Base64 string`},e,t)))}var Ah=BigInt(0),jh=BigInt(1),Mh=BigInt(1e3),Nh=BigInt(1024),Ph=[{symbol:`B`,factor:jh,names:[`B`,`byte`,`bytes`]},{symbol:`kB`,factor:Mh,names:[`kB`,`kilobyte`,`kilobytes`]},{symbol:`MB`,factor:Mh**BigInt(2),names:[`MB`,`megabyte`,`megabytes`]},{symbol:`GB`,factor:Mh**BigInt(3),names:[`GB`,`gigabyte`,`gigabytes`]},{symbol:`TB`,factor:Mh**BigInt(4),names:[`TB`,`terabyte`,`terabytes`]},{symbol:`PB`,factor:Mh**BigInt(5),names:[`PB`,`petabyte`,`petabytes`]},{symbol:`EB`,factor:Mh**BigInt(6),names:[`EB`,`exabyte`,`exabytes`]},{symbol:`ZB`,factor:Mh**BigInt(7),names:[`ZB`,`zettabyte`,`zettabytes`]},{symbol:`YB`,factor:Mh**BigInt(8),names:[`YB`,`yottabyte`,`yottabytes`]},{symbol:`RB`,factor:Mh**BigInt(9),names:[`RB`,`ronnabyte`,`ronnabytes`]},{symbol:`QB`,factor:Mh**BigInt(10),names:[`QB`,`quettabyte`,`quettabytes`]}],Fh=[Ph[0],{symbol:`KiB`,factor:Nh,names:[`KiB`,`kibibyte`,`kibibytes`]},{symbol:`MiB`,factor:Nh**BigInt(2),names:[`MiB`,`mebibyte`,`mebibytes`]},{symbol:`GiB`,factor:Nh**BigInt(3),names:[`GiB`,`gibibyte`,`gibibytes`]},{symbol:`TiB`,factor:Nh**BigInt(4),names:[`TiB`,`tebibyte`,`tebibytes`]},{symbol:`PiB`,factor:Nh**BigInt(5),names:[`PiB`,`pebibyte`,`pebibytes`]},{symbol:`EiB`,factor:Nh**BigInt(6),names:[`EiB`,`exbibyte`,`exbibytes`]},{symbol:`ZiB`,factor:Nh**BigInt(7),names:[`ZiB`,`zebibyte`,`zebibytes`]},{symbol:`YiB`,factor:Nh**BigInt(8),names:[`YiB`,`yobibyte`,`yobibytes`]}],Ih=[...Ph,...Fh.slice(1)],Lh=new Map(Ih.flatMap(e=>e.names.map(t=>[t,e]))),Rh=new Map(Ih.map(e=>[e.symbol,e])),zh=e=>e,Bh=e=>{throw Error(`Invalid ByteSize: ${e}`)},Vh=e=>!Number.isSafeInteger(e)||e<0?Bh(`expected a non-negative safe integer, received ${e}`):zh(BigInt(e)),Hh=(e,t)=>{if(typeof e==`bigint`)return e<Ah?Bh(`expected a non-negative quantity, received ${e}`):zh(e*t.factor);let n=e*Number(t.factor);return!Number.isSafeInteger(n)||n<0?Bh(`expected an exact non-negative safe-integer byte result, received ${e} ${t.symbol}`):zh(BigInt(n))},Uh=e=>{let t=/^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(e);if(t===null)return Bh(`unsupported syntax ${JSON.stringify(e)}`);let n=Lh.get(t[3]);if(n===void 0)return Bh(`unsupported unit ${JSON.stringify(t[3])}`);let r=t[2]??``,i=BigInt(10)**BigInt(r.length),a=BigInt(t[1]+r)*n.factor;return a%i===Ah?zh(a/i):Bh(`${JSON.stringify(e)} does not represent an integral number of bytes`)},Wh=e=>{switch(typeof e){case`bigint`:return e<Ah?Bh(`expected a non-negative bigint, received ${e}`):zh(e);case`number`:return Vh(e);case`string`:return Uh(e)}return Bh(`unsupported input ${e}`)},Gh=(e=>t=>Hh(t,Rh.get(e)))(`MiB`),Kh=class extends Sn{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Kh(this.encode,this.decode)}},qh=`~effect/SchemaTransformation/Transformation`,Jh=class extends Sn{[qh]=qh;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Jh(this.encode,this.decode)}};function Yh(e){return w(e,qh)&&e[qh]===qh}var Xh=e=>Yh(e)?e:new Jh(e.decode,e.encode);function Zh(e){return new Jh(Ch(e.decode),Ch(e.encode))}function Qh(e){return new Jh(Sh(e.decode),Sh(e.encode))}var $h=new Jh(xh(),xh());function eg(){return $h}var tg=new Jh(Th(),wh()),ng=e=>Vn(e)&&typeof e.message==`string`,rg=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:sg(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},ig=e=>{try{let t=Kr(e);return t===void 0?zr(e):JSON.parse(t)}catch{return zr(e)}},ag=(e,t,n)=>{let r={name:e.name,message:typeof e.message==`string`?e.message:``};return t?.includeStack&&typeof e.stack==`string`&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},og=e=>{let t=new WeakSet,n=r=>{if(Wn(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=ag(r,e,n);return t.delete(r),i}return ig(r)};return n},sg=e=>ng(e)?rg(e):e,cg=e=>Qh({decode:sg,encode:og(e)}),lg=new Jh(kh(),Oh());function ug(e){return new Jh(Eh(e??{}),Dh(e))}function dg(e){return t=>t._tag===e}var fg=dg(`Declaration`),pg=dg(`Null`),mg=dg(`Void`),hg=dg(`Never`),gg=dg(`Literal`),_g=dg(`UniqueSymbol`),vg=dg(`Arrays`),yg=dg(`Objects`),bg=dg(`Union`),xg=dg(`Suspend`),Sg=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},Cg={},wg=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},Tg=`~effect/Schema`,Eg=class{[Tg]=Tg;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},Dg=class extends Eg{_tag=`Declaration`;typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,i,a,o,s){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o,this.encodingRun=s}getParser(){let e;return(t,n)=>t===W?zm:(e??=this.run(this.typeParameters))(t,this,n)}_rebuild(e,t,n,r,i){let a=q_(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new Dg(a,r,this.annotations,t,void 0,this.context,n,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},Og=new class extends Eg{_tag=`Null`;getParser(){return dv(this,null)}getExpected(){return`null`}},kg=class extends Eg{_tag=`Undefined`;getParser(){return dv(this,void 0)}toCodecJson(){return K(this,[Ag])}getExpected(){return`undefined`}},Ag=new Sg(Og,new Jh(Sh(()=>void 0),Sh(()=>null))),jg=new kg,Mg=new class extends Eg{_tag=`Void`;getParser(){let e=Rm(void 0);return t=>t===W?zm:e}toCodecJson(){return K(this,[Ag])}getExpected(){return`void`}},Ng=new class extends Eg{_tag=`Never`;getParser(){return fv(this,zn)}getExpected(){return`never`}},Pg=new class extends Eg{_tag=`Unknown`;getParser(){return fv(this,Bn)}getExpected(){return`unknown`}},Fg=class extends Eg{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${zr(e)}`);this.literal=e}getParser(){return dv(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?Ig(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:Ig(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function Ig(e){let t=globalThis.String(e.literal);return K(e,[new Sg(new Fg(t),new Jh(Sh(()=>e.literal),Sh(()=>t)))])}var Lg=new class extends Eg{_tag=`String`;getParser(){return fv(this,Mn)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&Sv(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},Rg=class extends Eg{_tag=`Number`;getParser(){return fv(this,Nn)}matchKey(e,t){return this._match(_v,e,t)}matchPart(e,t){return this._match(gv,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:Sv(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(zg(this.checks,`effect/schema/isFinite`)||zg(this.checks,`effect/schema/isInt`))?this:K(this,[j_])}toCodecStringTree(){return this.toCodecJson()===this?K(this,[bv]):K(this,[xv])}getExpected(){return`number`}};function zg(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&zg(e.checks,t))}var Bg=new Rg,Vg=new class extends Eg{_tag=`Boolean`;getParser(){return fv(this,Pn)}getExpected(){return`boolean`}},Hg=class extends Eg{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(nv(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(nv(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}return Tm(function*(e,c){if(e===W)return W;if(!Array.isArray(e))return yield*V(new Qm(n,e,c));r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)})));let l=e.length,u={ast:n,getParser:s,input:e,len:l,tailThreshold:Math.max(a,l-o),output:new globalThis.Array(l),issues:void 0,options:c},d=n.rest.length===0?a:Math.max(l,a+o),f=c.concurrency===void 0?1:md(c.concurrency),p=f===1?Gg(u,e,0,d):Kg(u,e,{concurrency:f,end:d});if(p&&(yield*p),n.rest.length===0&&l>a)for(let t=a;t<=l-1;t++){let r=new Xm(n,e[t],c),i=new Jm([t],r);if(c.errors===`all`)u.issues?u.issues.push(i):u.issues=[i];else return yield*V(new Zm(n,[i],e,c))}return u.issues?yield*V(new Zm(n,u.issues,e,c)):u.output})}_rebuild(e,t,n){let r=q_(this.elements,e),i=q_(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new Hg(this.isMutable,r,i,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}};function Ug(e,t,n,r){if(n._tag===`Failure`)return qg(e,e.ast,r,n);let i=n===G?t:n[D];if(i!==W)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(nv(t.ast))return;let n=new Jm([r],new Ym(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return Sf(new Zm(e.ast,[n],e.input,e.options))}}var Wg={onItem(e,t,n){let r=n<e.len?t:W;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:Ug},Gg=hd()(Wg),Kg=_d()(Wg),qg=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=_h(r.cause);if(i===void 0)return xf(mf(r.cause,r=>new Zm(t,[new Jm([n],r)],e.input,e.options)));let a=new Jm([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return Sf(new Zm(t,[a],e.input,e.options))},Jg=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;function Yg(e,t,n=Cg){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(pv(sv(t)))}var Xg=class{name;type;constructor(e,t){this.name=e,this.type=t}};function Zg(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(Zg);default:return!1}}function Qg(e){let t=L_(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(Qg);default:return!1}}function $g(e){return Zg(e)&&Qg(e)}var e_=class{parameter;type;constructor(e,t){if(!$g(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,nv(t)&&!uv(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},t_=class extends Eg{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o;let s=new Set,c=[];for(let t of e){let e=t.name;s.has(e)?c.push(e):s.add(e)}if(c.length>0)throw Error(`Duplicate identifiers: ${JSON.stringify(c)}. ts(2300)`)}getParser(e,t=e){let n=this,r=[];for(let e of n.propertySignatures)r.push(typeof e.name==`number`?globalThis.String(e.name):e.name);let i=r.length,a=n.indexSignatures.length,o=i&&a?new Set(r):void 0;if(!i&&!a)return fv(n,Rn);let s,c,l=(e,t,r,a,s)=>{if(s._tag===`Failure`)return qg(e,n,t,s)??Cf;let c=s===G?a:s[D];if(r!==W&&c!==W){if(i&&(o.has(t)||o.has(typeof r==`number`?globalThis.String(r):r)))return Cf;E(e.out,r,c)}return Cf},u=(e,t,r,i)=>{if(!i){let n=r.parserKey(t,e.options);if(!z(n))return H(Up(n),n=>u(e,t,r,n));i=n}if(i._tag===`Failure`)return qg(e,n,t,i)??Cf;let a=i===G?t:i[D],o=e.input[t],s=r.parserValue(o,e.options);return z(s)?l(e,t,a,o,s):H(Up(s),n=>l(e,t,a,o,n))},d=(e,t,n)=>{let r=e.input[t],i=n.parserValue(r,e.options);return z(i)?l(e,t,t,r,i):H(Up(i),n=>l(e,t,t,r,n))},f=a?_d()({onItem:(e,[t,n])=>n.is.parameter===Lg?d(e,t,n):u(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0,p=()=>(s||(s=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),c=a?n.indexSignatures.map(n=>({is:n,parserKey:e(pv(n.parameter)),parserValue:t(n.type)})):void 0),s),m=Tm(function*(e,t){if(e===W)return W;if(typeof e!=`object`||!e||Array.isArray(e))return yield*V(new Qm(n,e,t));p();let l=e,m={},h={ast:n,input:l,out:m,issues:void 0,options:t},g=t.errors===`all`,_=t.onExcessProperty===`error`,ee=t.concurrency===void 0?1:md(t.concurrency),v=a&&_?n.indexSignatures.map(e=>Yg(l,e.parameter,t)):void 0;if(_){o??=new Set(r);let i=v?new Set(o):o;if(v)for(let e of v)for(let t of e)i.add(t);let a=Reflect.ownKeys(l);for(let r=0;r<a.length;r++){let o=a[r];if(!i.has(o)){let r=new Xm(n,l[o],t),i=new Jm([o],r);if(g){h.issues?h.issues.push(i):h.issues=[i];continue}return yield*V(new Zm(n,[i],e,t))}}}if(i){let e=ee===1?i_(h,s):a_(h,s,{concurrency:ee});e&&(yield*e)}if(a&&ee===1)for(let e=0;e<a;e++){let n=c[e],r=n.is.parameter===Lg?d:u,i=v?.[e]??(n.is.parameter===Lg?Object.keys(l):Yg(l,n.is.parameter,t));for(let e=0;e<i.length;e++){let t=r(h,i[e],n);if(!z(t))yield*t;else if(t._tag===`Failure`)return yield*t}}else if(f){let e=Za();for(let n=0;n<a;n++){let r=c[n],i=v?.[n]??(r.is.parameter===Lg?Object.keys(l):Yg(l,r.is.parameter,t));for(let t=0;t<i.length;t++)e.push([i[t],r])}let n=f(h,e,{concurrency:ee});n&&(yield*n)}return h.issues?yield*V(new Zm(n,h.issues,e,t)):m});if(a)return m;let h=(e,t,n)=>{let r=s[t];return H(Up(n),n=>{let i=n_(e,r,n);if(i)return i;let a=()=>Rm(e.out),o=i_(e,s.slice(t+1));return o?wm(o,a):a()})};return(e,t)=>{if(e===W)return zm;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&md(t.concurrency)!==1)return m(e,t);if(typeof e!=`object`||!e||Array.isArray(e))return V(new Qm(n,e,t));let r=p(),i=e,a={},o={ast:n,input:i,out:a,issues:void 0,options:t};try{for(let e=0;e<r.length;e++){let n=r[e],s=n.name,c=g_(i,s),l=c?i[s]:W,u=n.parser(l,t);if(!z(u))return h(o,e,u);if(u===G){c&&E(a,s,l);continue}let d=n_(o,n,u);if(d)return d}}catch(e){return Fp(e)}return Rm(a)}}_rebuild(e,t,n,r){let i=q_(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new Xg(t.name,n)}),a=q_(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new e_(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new t_(i,a,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function n_(e,t,n){if(n._tag===`Failure`)return qg(e,e.ast,t.name,n);if(n===G)return;let r=n[D];if(r!==W){E(e.out,t.name,r);return}if(delete e.out[t.name],!nv(t.type)){let n=new Jm([t.name],new Ym(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return Sf(new Zm(e.ast,[n],e.input,e.options))}}var r_={onItem(e,t){if(!g_(e.input,t.name))return t.parser(W,e.options);let n=e.input[t.name];return E(e.out,t.name,n),t.parser(n,e.options)},step:n_},i_=hd()(r_),a_=_d()(r_);function o_(e,t){return e?t?[...e,...t]:e:t}function s_(e,t,n){return new t_(Reflect.ownKeys(e).map(t=>new Xg(t,e[t].ast)),[],n,t)}function c_(e){return e.ast}function l_(e,t=void 0){return new Hg(!1,e.map(e=>e.ast),[],void 0,t)}function u_(e,t,n){return new b_(e.map(c_),t,void 0,n)}var d_=kn(e=>{for(;;){if(xg(e))return Pg;let t=e.encoding;if(!t)return e.recur?.(d_,C)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==C))return Pg;e=t[t.length-1].to}});function f_(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(f_)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function p_(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[Am];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!nv(t)){if(gg(t))return[{key:e.name,literal:t.literal}];if(_g(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!nv(e)){if(gg(e))return[{key:t,literal:e.literal}];if(_g(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>p_(d_(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return p_(e.thunk())}}var m_=new WeakMap,h_=Object.freeze([]),g_=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function __(e){let t=m_.get(e);if(t)return t;let n,r=0,i,a,o=!0;for(let t=0;t<e.length;t++){let s=e[t],c=d_(s);if(hg(c))continue;if(o){if(gg(c)||_g(c)){a??=new Map;let e=gg(c)?c.literal:c.symbol,t=a.get(e);t||a.set(e,t=[]),t.push(s)}else o=!1}let l=p_(c);if(l.length){n??=new Map,r++;for(let{key:e,literal:r}of l){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=f_(c);for(let n of e)(i[n]??=[]).push(t)}}if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??h_;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=i;for(let[t,n]of i)a.set(t,Object.freeze(Array.from(n,t=>e[t])));t=(t,n)=>{if(Hn(t)){let i=g_(t,r)?t[r]:void 0;if(i!==void 0)return a.get(i)??h_;if(n)return e}return h_}}else if(n){let a;for(let e of n)(!a||e[1][0].size>a[1][0].size)&&e[1][1].size===r&&(a=e);t=(t,r)=>{let o=i?.[t===null?`null`:Array.isArray(t)?`array`:typeof t]??h_;if(!Hn(t))return o.map(t=>e[t]);let s=new Set(o),c;if(a){let[n,[i]]=a,l=g_(t,n),u=l?t[n]:void 0;if(l&&(!r||u!==void 0)){let t=i.get(u);if(!t)return o.map(t=>e[t]);for(let e of t)s.add(e);c=n}}if(c===void 0)for(let[e,[i,a]]of n){let n=g_(t,e),o=n?t[e]:void 0;if(n&&(!r||o!==void 0)){let e=i.get(o);if(e)for(let t of e)s.add(t)}else if(r)for(let e of a)s.add(e)}for(let[e,[i,a]]of n){if(e===c)continue;let n=g_(t,e),o=n?t[e]:void 0;if(n&&(!r||o!==void 0)){let e=i.get(o);for(let t of s)a.has(t)&&!e?.has(t)&&s.delete(t)}}return Array.from(s).sort((e,t)=>e-t).map(t=>e[t])}}else t=t=>(i?.[t===null?`null`:Array.isArray(t)?`array`:typeof t]??h_).map(t=>e[t]).filter(v_(t));return m_.set(e,t),t}function v_(e){return t=>{let n=d_(t);return n._tag===`Literal`?n.literal===e:n._tag!==`UniqueSymbol`||n.symbol===e}}function y_(e,t,n=!1){return __(t)(e,n)}var b_=class extends Eg{_tag=`Union`;types;options;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.options=t,this.encodingChecks=o}getParser(e,t){let n=this;return(r,i)=>{if(r===W)return zm;let a=y_(r,n.types,t!==void 0);if(a.length===0)return V(new nh(n,[],r,i));if(a.length===1){let t=e(a[0])(r,i);return t._tag===`Success`?t:z(t)?x_(n,t.cause,r,i):Jp(t,e=>x_(n,e,r,i))}let o={ast:n,compile:e,input:r,out:void 0,successes:n.options?.mode===`oneOf`?[]:void 0,issues:void 0,options:i},s=S_(o,a);return s?wm(s,e=>o.out===G?B(r):o.out?o.out:V(new nh(n,o.issues??[],r,i))):o.out?o.out:V(new nh(n,o.issues??[],r,i))}}_rebuild(e,t,n){let r=q_(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new b_(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=sv(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(gg);if(t.length>0)return`${w_(n.isMutable)}[ ${t.map(t=>e(t)+T_(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>gg(e.type));if(t.length>0)return`{ ${t.map(t=>`${w_(t.type.context?.isMutable)}${Vr(t.name)}${T_(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function x_(e,t,n,r){let i=_h(t);return i?Sf(new nh(e,[i],n,r)):xf(t)}var S_=hd()({onItem(e,t){return e.compile(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=_h(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(t),Sf(new rh(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(t);else return Cf}}}),C_=new b_([new Fg(`Infinity`),new Fg(`-Infinity`),new Fg(`NaN`)]);function w_(e){return e?``:`readonly `}function T_(e){return e?`?`:``}var E_=class extends Sn{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new E_(this.run,{...this.annotations,...e},this.aborted)}abort(){return new E_(this.run,this.annotations,!0)}and(e,t){return new D_([this,e],t)}},D_=class extends Sn{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new D_(this.checks,{...this.annotations,...e})}and(e,t){return new D_([this,e],t)}};function O_(e,t,n=!1){return new E_((t,n,r)=>oh(n,e(t,n,r),t,r),t,n)}function k_(e){return O_(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitraryConstraint:{number:`finite`},...e})}var A_=B_(Bg,[k_()]),j_=new Sg(new b_([A_,C_]),new Jh(Th(),Sh(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function M_(e,t){let n=e.source,r=new globalThis.RegExp(n,e.flags);return O_(e=>(r.lastIndex=0,r.test(e)),{expected:`a string matching the RegExp ${n}`,representation:{id:`effect/schema/isPattern`,payload:{source:n,flags:e.flags}},toJsonSchema:()=>({pattern:n}),arbitraryConstraint:{patterns:[{source:e.source,flags:e.flags}]},...t})}function N_(e,t){let n=Object.getOwnPropertyDescriptors(e);return t(n),Object.create(Object.getPrototypeOf(e),n)}var P_=new WeakMap;function F_(e){return P_.get(e)??e}function K(e,t){return e.encoding===t?e:N_(e,e=>{e.encoding.value=t})}function I_(e,t){if(e.context===t)return e;let n=F_(e);if(n.context===t)return n;let r=N_(e,e=>{e.context.value=t});return P_.set(r,n),r}function L_(e){return e.encoding?L_(e.encoding[e.encoding.length-1].to):e}function R_(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return z_(e,qa(e.checks.slice(0,-1),n.annotate(t)))}return N_(e,e=>{e.annotations.value={...e.annotations.value,...t}})}function z_(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:N_(e,e=>{e.checks.value=t})}function B_(e,t){return z_(e,o_(e.checks,t))}function V_(e,t){let n=t(e.to);return n===e.to?e:new Sg(n,e.transformation)}function H_(e,t){let n=e,r=n[n.length-1],i=V_(r,t);return i===r?e:qa(e.slice(0,e.length-1),i)}function U_(e){return t=>t.encoding?K(t,H_(t.encoding,e)):t}function W_(e,t){return U_(e=>I_(e,t))(e)}function G_(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:K(r,H_(r.encoding,n))}return e(r)}return kn(n)}function K_(e,t,n){let r=new Sg(e,t);return K(n,n.encoding?[...n.encoding,r]:[r])}function q_(e,t){let n=!1,r=Array(e.length);for(let i=0;i<e.length;i++){let a=e[i],o=t(a);o!==a&&(n=!0),r[i]=o}return n?r:e}function J_(e,t){return I_(e,e.context?new wg(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new wg(!1,!1,void 0,t))}var Y_=kn(e=>X_(I_(e,e.context?e.context.isOptional===!1?new wg(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new wg(!0,!1)))),X_=U_(Y_),Z_=On(e=>Y_(new b_([e,jg])));function Q_(e,t){return I_(e,e.context?new wg(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new wg(!1,!1,t))}function $_(e,t,n){return K_(e,n,t)}function ev(e){let t=[],n=[];function r(e){switch(e._tag){case`Literal`:In(e.literal)&&t.push(e.literal);return;case`UniqueSymbol`:t.push(e.symbol);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)r(e.types[t]);return;default:n.push(e)}}return r(e),{literals:t,parameters:n}}function tv(e,t){let{literals:n,parameters:r}=ev(e);return new t_(n.map(e=>new Xg(e,t)),r.map(e=>new e_(e,t)))}function nv(e){return e.context?.isOptional??!1}function rv(e){return e.context?.isMutable??!1}function iv(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(iv)}function av(e){function t(e){return iv(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return Ya(n)?n:void 0}var ov=kn(e=>{if(e.encoding)return ov(K(e,void 0));let t=e,n=t.recur?.(ov)??t,r=n.encodingChecks;if(r){let t=n===e?r:vg(n)||yg(n)||fg(n)&&n.typeParameters.length>0?av(r):void 0;return N_(n,e=>{e.encodingChecks.value=void 0,e.checks.value=o_(n.checks,t)})}return n}),sv=kn(e=>ov(lv(e)));function cv(e,t){let n=t,r=n.length,i=n[r-1],a=[new Sg(lv(K(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new Sg(lv(n[e-1].to),n[e].transformation.flip()));let o=lv(i.to);return o.encoding?K(o,[...o.encoding,...a]):K(o,a)}var lv=On(e=>{if(e.encoding)return cv(e,e.encoding);let t=e;return t.flip?.(lv)??t.recur?.(lv)??t});function uv(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(uv);default:return!1}}function dv(e,t){let n=t===0?G:Rm(t);return(r,i)=>r===W?zm:r===t?n:V(new Qm(e,r,i))}function fv(e,t){return(n,r)=>n===W?zm:t(n)?G:V(new Qm(e,n,r))}var pv=G_(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(pv)}}),mv=G_(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(mv)}}),hv=`[\\s\\S]*?`,gv=new globalThis.RegExp(`^${Jg}$`),_v=new globalThis.RegExp(`^(?:${Jg}|Infinity|-Infinity|NaN)$`);function vv(e){return M_(gv,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:gv.source}),...e})}var yv=B_(Lg,[vv()]),bv=new Sg(yv,tg),xv=new Sg(new b_([yv,C_]),tg);function Sv(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=Sv(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new Km(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function Cv(e){if(!fg(e))return;let t=e.annotations?.[jm];return Ln(t)?t(e.typeParameters):void 0}var wv=Dm,Tv=Nm,Ev=Fm;function Dv(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function Ov(e){return e===void 0||typeof e==`string`}function kv(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function Av(e){return kv(e,Dv)}var jv=new Dg([],()=>(e,t,n)=>Av(e)?G:V(new Qm(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>Fv}),Mv=new Sg(jv,eg()),Nv=new Sg(new b_([new Hg(!1,[],[jv]),new t_([],[new e_(Lg,jv)])]),eg());function Pv(e){return kv(e,Ov)}var Fv=new Sg(new Dg([],()=>(e,t,n)=>Pv(e)?G:V(new Qm(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),eg()),Iv=ol,Lv=sl,Rv=Qc,zv=Sd,Bv=Md,Vv=`~effect/MutableRef`,Hv={[Vv]:Vv,...ui,toJSON(){return{_id:`MutableRef`,current:Jr(this.current)}}},Uv=e=>{let t=Object.create(Hv);return t.current=e,t},Wv=Symbol.for(`effect/MutableList/Empty`),Gv=()=>({head:void 0,tail:void 0,length:0}),Kv=()=>({array:[],mutable:!0,offset:0,next:void 0}),qv=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=Kv(),e.tail=e.tail.next):e.head=e.tail=Kv(),e.tail.array.push(t),e.length++},Jv=e=>{e.head=e.tail=void 0,e.length=0},Yv=e=>{if(!e.head)return Wv;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:Jv(e)),t},Xv=`~effect/Queue`,Zv=`~effect/Queue/Enqueue`,Qv=`~effect/Queue/Dequeue`,$v={_A:C,_E:C},ey={[Xv]:$v,[Zv]:$v,[Qv]:$v,...ui,toJSON(){return{_id:`effect/Queue`,state:this.state._tag,size:ly(this)}}},ty=e=>A(t=>{let n=Object.create(ey);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??1/0,n.strategy=e?.strategy??`suspend`,n.messages=Gv(),n.scheduleRunning=!1,n.state={_tag:`Open`,takers:new Set,offers:new Set,awaiters:new Set},P(n)}),ny=e=>ty({capacity:e}),ry=(e,t)=>I(()=>{if(e.state._tag!==`Open`)return uy;if(e.messages.length>=e.capacity)switch(e.strategy){case`dropping`:return uy;case`suspend`:return e.capacity<=0&&e.state.takers.size>0?(qv(e.messages,t),my(e),dy):gy(e,t);case`sliding`:return Yv(e.messages),qv(e.messages,t),dy}return qv(e.messages,t),hy(e),dy}),iy=S(2,(e,t)=>F(()=>ay(e,t))),ay=(e,t)=>{if(e.state._tag!==`Open`)return!1;let n=au(Li(t),fy);return e.state.offers.size===0&&e.messages.length===0?(by(e,n),!0):(e.state={...e.state,_tag:`Closing`,exit:n},!0)},oy=e=>F(()=>{if(e.state._tag===`Done`)return!0;Jv(e.messages);let t=e.state.offers;if(by(e,e.state._tag===`Open`?py:e.state.exit),t.size>0){for(let e of t)e._tag===`Single`?e.resume(uy):e.resume(k(e.remaining.slice(e.offset)));t.clear()}return!0}),sy=e=>I(()=>cy(e)??Ul(yy(e),sy(e))),cy=e=>{if(e.state._tag===`Done`)return e.state.exit;if(e.messages.length>0){let t=Yv(e.messages);return vy(e),k(t)}if(e.capacity<=0&&e.state.offers.size>0){let t=_y(e.state.offers);return vy(e),k(t)}},ly=e=>e.state._tag===`Done`?0:e.messages.length,uy=k(!1),dy=k(!0),fy=Ri(Ki()),py=Ql(),my=e=>{if(e.state._tag!==`Done`&&e.state.takers.size!==0){for(let t of e.state.takers)if(e.state.takers.delete(t),t(tu),e.messages.length===0)break}},hy=e=>{e.scheduleRunning||e.state._tag===`Done`||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,my(e)},0))},gy=(e,t)=>wl(n=>{if(e.state._tag!==`Open`)return n(uy);let r={_tag:`Single`,message:t,resume:n};return e.state.offers.add(r),F(()=>{e.state._tag===`Open`&&e.state.offers.delete(r)})}),_y=e=>{let t=e.values().next().value;if(t._tag===`Single`)return e.delete(t),t.resume(dy),t.message;let n=t.remaining[t.offset++];return t.offset===t.remaining.length&&(e.delete(t),t.resume(k([]))),n},vy=e=>{if(e.state._tag===`Done`)return yp(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag===`Closing`&&e.messages.length===0&&(by(e,e.state.exit),yp(e.state.exit.cause));for(let t of e.state.offers){let n=e.capacity-e.messages.length;if(n<=0)break;if(t._tag===`Single`)qv(e.messages,t.message),e.state.offers.delete(t),t.resume(dy);else{for(;t.offset<t.remaining.length;t.offset++){if(n===0)return!1;qv(e.messages,t.remaining[t.offset]),n--}e.state.offers.delete(t),t.resume(k([]))}}return!1},yy=e=>wl(t=>e.state._tag===`Done`?t(e.state.exit):(e.state.takers.add(t),F(()=>{e.state._tag!==`Done`&&e.state.takers.delete(t)}))),by=(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()},xy=e=>new Cy(e),Sy=(e,t,n)=>wl(r=>{if(e.free>=t)return r(n);let i=()=>{e.free<t||(e.waiters.delete(i),r(n))};return e.waiters.add(i),F(()=>{e.waiters.delete(i)})}),Cy=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=I(()=>this.free<e?Sy(this,e,t):(this.taken+=e,P(e)));return t}takeIfAvailable(e){return I(()=>this.free<e?P(!1):(this.taken+=e,P(!0)))}releaseUnsafe(e,t){return this.taken-=t,this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{for(let e of this.waiters){if(this.free<=0)break;e()}},0),this.free}resize(e){return A(t=>(this.permits=e,this.free<0||this.releaseUnsafe(t,0),L))}release(e){return A(t=>P(this.releaseUnsafe(t,e)))}get releaseAll(){return A(e=>P(this.releaseUnsafe(e,this.taken)))}withPermits(e){return t=>ud(n=>{let r=I(()=>this.free<e?R(n(Sy(this,e,L)),()=>r):(this.taken+=e,Zu(n(t),()=>{this.releaseUnsafe(Qc(),e)},!0)));return r})}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>ud(n=>this.free<e?ml:(this.taken+=e,Zu(n(Hl(t)),()=>{this.releaseUnsafe(Qc(),e)},!0)))}},wy=`~effect/Channel`,Ty=e=>w(e,wy),Ey={[wy]:{_Env:C,_InErr:C,_InElem:C,_OutErr:C,_OutElem:C},pipe(){return x(this,arguments)}},Dy=e=>{let t=Object.create(Ey);return t.transform=(t,n)=>Jp(e(t,n),e=>B(Np(e))),t},Oy=(e,t)=>Dy((n,r)=>H(jy(e)(n,r),e=>t(e,r))),ky=e=>Dy((t,n)=>e),Ay=e=>Dy(bm(function*(t,n){let r=If(n),i=e=>Lf(r,Cp(e));return am(yield*am(e(t,n,r),i),i)})),jy=e=>e.transform,My=e=>Dy((t,n)=>kp(()=>jy(e())(t,n))),Ny=e=>ky(B(V(e))),Py=e=>ky(Ap(()=>{let t=!1;return kp(()=>t?yf():(t=!0,e))})),Fy=e=>Dy((t,n)=>Iy({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),Iy=e=>{let t=e.readable.getReader(),n=e.exit??Uv(void 0),r=kp(()=>n.current?n.current:$p(Op({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??Np(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?yf():B(Qa(t))}));return Wp(Ff(e.scope,e.releaseLockOnEnd?Ap(()=>t.releaseLock()):Dp(()=>t.cancel().catch(Dn))),r)},Ly=S(2,(e,t)=>Oy(e,e=>Ap(()=>{let n=0;return U(e,e=>t(e,n++))}))),Ry=e=>e===void 0||e!==`unbounded`&&e<=1,zy=S(e=>Ty(e[0]),(e,t,n)=>Ry(n?.concurrency)?By(e,t):Vy(e,t,n)),By=(e,t)=>Dy((n,r)=>{let i=0;return U(jy(e)(n,r),H(e=>t(e,i++)))}),Vy=(e,t,n)=>Ay(bm(function*(r,i,a){let o=0,s=yield*jy(e)(r,i),c=n.concurrency===`unbounded`?2**53-1:n.concurrency,l=yield*ny(0);yield*Ff(a,oy(l));let u=gm(yield*em()),d=zv(a);if(n.unordered){let e=xy(c),n=Cn(e.release(1)),r=$p({onFailure:e=>H(iy(l,e),n),onSuccess:e=>H(ry(l,e),n)});yield*e.take(1).pipe(H(()=>s),H(e=>(d(u(r(t(e,o++)))),jp)),um({disableYield:!0}),Jp(t=>e.withPermits(c-1)(iy(l,t))),mm(a))}else{let e=yield*ny(c-2);yield*Ff(a,oy(e)),yield*sy(e).pipe(zp,H(e=>ry(l,e)),um({disableYield:!0}),Jp(e=>iy(l,e)),mm(a));let n,r=e=>{e._tag!==`Success`&&(n=e.cause,ay(l,e.cause))};yield*s.pipe(H(i=>{if(n)return Np(n);let a=u(t(i,o++));return d(a),a.addObserver(r),ry(e,Iv(a))}),um({disableYield:!0}),Jp(t=>ry(e,xf(t)).pipe(Bp(iy(e,t)))),mm(a))}return sy(l)})),Hy=S(2,(e,t)=>Dy((n,r)=>{let i=If(r);return U(jy(e)(n,i),e=>{let a=e.pipe(Jp(e=>{if(yp(e))return Np(e);let o=i;return i=If(r),Lf(o,xf(e)).pipe(Bp(jy(t(e))(n,i)),H(e=>(a=e,e)))}));return kp(()=>a)})})),Uy=S(2,(e,t)=>Dy((n,r)=>H(jy(e)(n,r),e=>jy(t)(e,r)))),Wy=S(2,(e,t)=>Ay((n,r,i)=>Pf(i,t).pipe(Bp(jy(e)(n,r))))),Gy=S(2,(e,t)=>Wy(e,e=>t)),Ky=(e,t,n)=>kp(()=>{let r=Mf();return vp(H(jy(e)(yf(),r),t),n||B).pipe(om(e=>Lf(r,e)))}),qy=S(2,(e,t)=>Dy((n,r)=>U(rm(jy(e)(n,r),t),rm(t)))),Jy=S(2,(e,t)=>Ky(e,e=>um(H(e,t),{disableYield:!0}))),Yy=(e,t)=>jy(e)(yf(),t),Xy=(e,t,n)=>e===G?n(t):wm(e,n);function Zy(e){if(e._tag===`Middleware`)return(t,n,r)=>Qy(t===G?e.decode(Rm(Bm(n)),r):e.decode(xm(t,Bm),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===G?Rm(t):e;case`Transform`:{let e=e=>e===W?zm:Rm(t.transform(e));return(t,n)=>Xy(t,n,e)}case`TransformOptional`:{let e=e=>Vm(t.transform(Bm(e)));return(t,n)=>Xy(t,n,e)}case`TransformEffect`:return(e,n,r)=>Xy(e,n,e=>e===W?zm:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>Xy(e,n,e=>Qy(t.transform(Bm(e),r)))}}var Qy=e=>wm(e,Vm),$y=(e,t,n,r)=>Jp(r,r=>Pp(()=>mf(r,r=>new qm(e,r,t,n))));function eb(e,t){let n=Zy(e.link.transformation),r;return(i,a)=>{if(i===W)return zm;if(e.isConstructed(i))return G;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function tb(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==W&&r!==void 0)return t(r,i);let a=n;if(z(a)&&a._tag===`Success`){let e=t(a[D],i);return e===G?a:e}return wm($y(e,r,i,a),e=>{let n=t(e,i);return n===G?Rm(e):n})}}function nb(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:tb(e,n)}function rb(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?Cv(e):void 0,o=a?eb(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>Zy(e.transformation)),u=e.encodingChecks;if(!c&&!s&&!u)return o;let d,f=(t,n)=>{let r=o(t,n);if(u&&!n.disableChecks){if(z(r)){if(r._tag===`Success`){let i=r===G?t:r[D];if(t!==W&&i!==W){let i=Sv(u,t,void 0,e,n);i&&(r=V(new Zm(e,i,t,n)))}}}else r=H(r,r=>{if(t!==W&&r!==W){let r=Sv(u,t,void 0,e,n);if(r)return V(new Zm(e,r,t,n))}return B(r)})}if(s&&!n.disableChecks){if(z(r)){if(r._tag===`Success`){let i=r===G?t:r[D];if(i===W)return r;let a=Sv(s,i,void 0,e,n);a&&(r=V(new Zm(e,a,i,n)))}}else r=H(r,t=>{if(t!==W){let r=Sv(s,t,void 0,e,n);if(r)return V(new Zm(e,r,t,n))}return B(t)})}return r},p=i===void 0?f:i(f);return c?(n,r)=>{let i=d??=c.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=c.length-1;e>=0;e--)if(o=l[e](o,a,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[D],o=t(a,r)):o=wm(o,e=>{let n=t(e,r);return n===G?Rm(e):n})}if(o._tag===`Success`){let e=o[D],t=p(e,r);return t===G?o:t}return o=$y(e,n,r,o),wm(o,e=>{let t=p(e,r);return t===G?Rm(e):t})}:p}var ib=Symbol(),ab=new WeakMap,ob=e=>ub(e).parser,sb=e=>ub(e).makeEffect,cb=e=>nb(e,sb),lb=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=rb(this.ast,ob)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=rb(this.ast,sb,cb)}};function ub(e){let t=ab.get(e);if(t!==void 0)return t;let n=new lb(e);return ab.set(e,n),n}function db(e){let t=e.ast,n;return(e,r)=>(n??=xb(Db,ov(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function fb(e){let t=db(e);return(e,n)=>{let r=ym(t(e,n));return wf(r)?Sa(r.value):(vh(r.cause,`Option adapter can only return none for schema issues`),xa())}}function pb(e){return Tb(ov(e.ast))}function mb(e,t){let n=yb(e.ast);return t===void 0?n:(e,r)=>n(e,_b(t,r))}function hb(e,t){return Cb(mb(e,t))}function gb(e,t){let n=yb(lv(e.ast));return t===void 0?n:(e,r)=>n(e,_b(t,r))}var _b=(e,t)=>t?{...e,...t}:e,vb=e=>e===W?V(new $m):B(e);function yb(e){return xb(Eb,e)}function bb(e,t){return e===G?B(t):z(e)?e[D]===W?vb(W):e:wm(e,vb)}function xb(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??Cg);return a===G?B(r):z(a)?a[D]===W?vb(W):a:wm(a,vb)}}function Sb(e){return(t,n)=>ym(e(t,n))}function Cb(e){let t=Sb(e);return(e,n)=>{let r=t(e,n);return wf(r)?Sa(r.value):(vh(r.cause,`Option adapter can only return none for schema issues`),xa())}}function wb(e,t){let n=ym(e);if(wf(n))return n.value;let r=vh(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}function Tb(e){let t,n;return(r,i)=>{t??=ub(e);let a=i?.disableChecks?i.parseOptions?{...i.parseOptions,disableChecks:!0}:{disableChecks:!0}:i?.parseOptions??Cg,o=t.make;if(o!==void 0&&r!==W){let e;try{e=o(r,a)}catch(e){throw vh(uf(e),`Constructor adapter can only throw schema issues`),e}if(e!==ib&&e!==W)return e}return wb(bb((n??=t.makeEffect)(r,a),r),`Constructor adapter can only throw schema issues`)}}var Eb=e=>ub(e).parser,Db=e=>ub(e).makeEffect,Ob=`~effect/Schema/Schema`,kb={[Ob]:Ob,pipe(){return x(this,arguments)},annotate(e){return this.rebuild(R_(this.ast,e))},annotateKey(e){return this.rebuild(J_(this.ast,e))},check(...e){return this.rebuild(B_(this.ast,e))}};function Ab(e,t){function n(){}let r=Object.setPrototypeOf(n,kb);return t&&(Object.hasOwn(t,`name`)||Object.hasOwn(t,`length`)||Object.hasOwn(t,`__proto__`))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r.ast=e,r.rebuild=e=>Ab(e,t),r.makeEffect=db(r),r.make=pb(r),r.makeOption=fb(r),r}function jb(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Mb(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function Nb(e){return encodeURI(jb(e)).replace(/#/g,`%23`)}function Pb(e){if(e.length===0||e===`#`)return``;if(!e.startsWith(`#`))return;let t=e.slice(1);try{if(encodeURI(t).replace(/%25/g,`%`).replace(/#/g,`%23`)!==t)return;let e=decodeURIComponent(t);return e.startsWith(`/`)&&!/~(?:[^01]|$)/.test(e)?e:void 0}catch{return}}function Fb(e){let t=Pb(e);return t===void 0?void 0:t.length===0?[]:t.slice(1).split(`/`).map(Mb)}function Ib(e){return e.reduce((e,t)=>`${e}/${Nb(t)}`,`#`)}var Lb=[`example`,`discriminator`,`xml`,`externalDocs`];function Rb(e){let t=Object.keys(e.definitions),n=new Map,r=new Set(t.filter(e=>zb.test(e))),i=t.filter(e=>!zb.test(e)).sort().map(e=>[e,Bb(e)]);for(let[e,t]of i)r.has(t)||(r.add(t),n.set(e,t));for(let[e,t]of i){if(n.has(e))continue;let i,a=0;do i=`${t}_${++a}`;while(r.has(i));r.add(i),n.set(e,i)}function a(t,r=!1){let i=Gb(t.$id),a=Vn(t.$defs)?t.$defs:void 0;return Vb(t,(t,o)=>{Jb(t,Lb,`OpenAPI 3.1`,`Draft 2020-12`),Ub(t,(t,s)=>{let c=t.startsWith(`#`)?Fb(t):void 0;if(c===void 0||c[0]!==`$defs`||c.length<2)return t;let l=c[1];return i?(r&&!o&&Object.hasOwn(e.definitions,l)&&(a===void 0||!Object.hasOwn(a,l))&&qb(s,`OpenAPI 3.1`,`a schema resource cannot reference the shared definitions pool`),t):o?t:Ib([`components`,`schemas`,n.get(l)??l,...c.slice(2)])})})}let o=e.schemas.map(e=>a(e,!0)),s={};for(let r of t)E(s,n.get(r)??r,a(e.definitions[r]));return{dialect:`openapi-3.1`,schemas:o,definitions:s}}var zb=/^[a-zA-Z0-9.\-_]+$/;function Bb(e){return e.length===0?`_`:e.replace(/[^a-zA-Z0-9._-]/gu,`_`)}function Vb(e,t){return n(e,!1,!0);function n(e,r,i=!1){if(!Vn(e))return e;let a=r||!i&&Gb(e.$id),o={};for(let t of Object.keys(e)){let r=e[t],i=r;switch(t){case`$defs`:case`properties`:case`patternProperties`:case`dependentSchemas`:i=Wb(r,e=>n(e,a))??r;break;case`allOf`:case`anyOf`:case`oneOf`:case`prefixItems`:i=Array.isArray(r)?r.map(e=>n(e,a)):r;break;case`not`:case`additionalProperties`:case`propertyNames`:case`unevaluatedProperties`:case`items`:case`contains`:case`unevaluatedItems`:case`if`:case`then`:case`else`:case`contentSchema`:i=n(r,a)}E(o,t,i)}return t(o,a),o}}function Hb(e,t){return Vb(e,e=>{Ub(e,t)})}function Ub(e,t){typeof e.$ref==`string`&&E(e,`$ref`,t(e.$ref,`$ref`)),typeof e.$dynamicRef==`string`&&E(e,`$dynamicRef`,t(e.$dynamicRef,`$dynamicRef`))}function Wb(e,t){if(!Vn(e))return;let n={};for(let r of Object.keys(e))E(n,r,t(e[r],r));return n}function Gb(e){return typeof e==`string`&&e.length>0&&e[0]!==`#`}var Kb=[`$anchor`,`$defs`,`$dynamicAnchor`,`$dynamicRef`,`$vocabulary`,`contentSchema`,`dependentRequired`,`dependentSchemas`,`maxContains`,`minContains`,`prefixItems`,`unevaluatedItems`,`unevaluatedProperties`];[...Kb],[...Kb];function qb(e,t,n){throw Error(`Cannot convert JSON Schema keyword "${e}" to ${t}: ${n}`)}function Jb(e,t,n,r){for(let i of t)Object.hasOwn(e,i)&&qb(i,n,`it is not active in ${r} but would become active in the target`)}function Yb(e){return Ab(Xb(e.ast),{schema:e})}var Xb=G_(e=>{let t=tx(e,Xb),n=e.context;return t===e||n===void 0?t:W_(t,Zb(n))});function Zb(e){return e.constructorDefault===void 0?e:new wg(e.isOptional,e.isMutable,void 0,e.annotations)}function Qb(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function $b(e){return t=>{let n=new Map;for(let e=0;e<t.length;e++)n.set(sv(t[e]),e);let r=[...t].sort((t,r)=>{t=sv(t),r=sv(r);let i=e(t),a=e(r);return i===a?n.get(t)-n.get(r):i-a});return r.some((e,n)=>e!==t[n])?r:t}}var ex=$b(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function tx(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!Ln(n))return K(e,[Mv]);let r=n(e.typeParameters.map(e=>Ab(sv(e))));return r===void 0?e:K(e,[V_(r,t)])}case`Unknown`:return K(e,[Mv]);case`ObjectKeyword`:return K(e,[Nv]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return Qb(e),e.recur(t,mv);case`Union`:{let n=ex(e.types);return n===e.types?e.recur(t):new b_(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}function nx(e){return Ab(ux(e.ast),{schema:e})}function rx(e){return Ab(fx(e.ast))}var ix=$b(e=>{switch(e._tag){case`Null`:case`Boolean`:case`Number`:case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function ax(e,t,n){switch(e._tag){case`Declaration`:{let r=e.typeParameters.map(e=>Ab(t(sv(e)))),i=e.annotations?.toCodecStringTree;if(Ln(i)){let n=i(r);return n===void 0?e:K(e,[V_(n,t)])}let a=e.annotations?.toCodecJson,o=Ln(a)?a(r):void 0,s=o===void 0?e.annotations?.toCodec:void 0,c=o??(Ln(s)?s(r):void 0);return c===void 0?n(e):K(e,[V_(c,t)])}case`Null`:return K(e,[ox]);case`Boolean`:return K(e,[sx]);case`Unknown`:case`ObjectKeyword`:return K(e,[Fv]);case`Enum`:case`Number`:case`Literal`:case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return Qb(e),e.recur(t,mv);case`Union`:{let n=ix(e.types);return n===e.types?e.recur(t):new b_(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}var ox=new Sg(new Fg(`null`),new Jh(Sh(()=>null),Sh(()=>`null`))),sx=new Sg(new b_([new Fg(`true`),new Fg(`false`)]),new Jh(Sh(e=>e===`true`),wh())),cx=new Jh(Sh(e=>typeof e==`string`?[e]:e),xh()),lx=e=>e.transformation===cx,ux=G_(e=>{let t=ax(e,ux,e=>{throw new globalThis.Error(`Missing structural codec for StringTree`,{cause:e})});return t!==e&&e.context!==void 0?W_(t,Zb(e.context)):t},{stopAt:lx}),dx=e=>nv(e)?Y_(Pg):Pg,fx=G_(e=>{let t=px(e);if(vg(t)){let n=$_(new b_([new Hg(t.isMutable,t.elements.map(dx),t.rest.map(dx)),Lg],{mode:`anyOf`}),t,cx);return nv(e)?Y_(n):n}return t},{stopAt:lx});function px(e){return e._tag===`Declaration`||e._tag===`Arrays`||e._tag===`Objects`||e._tag===`Union`||e._tag===`Suspend`?e.recur(fx):e}globalThis.RegExp;var mx=e=>e.replace(/[/\\^$*+?.()|[\]{}]/g,`\\$&`);function hx(e,t){return t.length>0&&(e+=`\n at ${Hr(t)}`),Error(e)}function gx(e){return`#/$defs/${Nb(e)}`}var _x=new Set([...Lm,km,...Mm]);function vx(e,t){if(e===void 0)return;let n={},r=e.title;typeof r==`string`&&(n.title=r);let i=e.description,a=e.expected;typeof i==`string`?n.description=i:t?.generateDescriptions===!0&&typeof a==`string`&&(n.description=a);let o=e.default;Av(o)&&(n.default=o);let s=e.examples;Array.isArray(s)&&Av(s)&&(n.examples=s);let c=e.readOnly;typeof c==`boolean`&&(n.readOnly=c);let l=e.writeOnly;typeof l==`boolean`&&(n.writeOnly=l);let u=e.format;typeof u==`string`&&(n.format=u);let d=e.contentEncoding;typeof d==`string`&&(n.contentEncoding=d);let f=e.contentMediaType;typeof f==`string`&&(n.contentMediaType=f);let p=e.contentSchema;if(Av(p)&&(n.contentSchema=p),t?.includeAnnotationKey!==void 0)for(let[r,i]of Object.entries(e))!_x.has(r)&&t.includeAnnotationKey(r)&&Av(i)&&E(n,r,i);return Object.keys(n).length===0?void 0:n}function yx(e){let t=e.type===`number`||e.type===`integer`?e.type:void 0,n=e;if(t!==void 0&&(n={...e},delete n.type),Array.isArray(n.allOf)){let e=[],r=!1;for(let i of n.allOf){let n=yx(i);n.type!==void 0&&(r=!0,(t===void 0||n.type===`integer`)&&(t=n.type)),Object.keys(n.schema).length>0&&e.push(n.schema)}if(r){let{allOf:t,...r}=n;n=e.length===0?r:{...r,allOf:e}}}return{type:t,schema:n}}function bx(e){if(!Array.isArray(e.anyOf)||e.anyOf.length!==2||e.anyOf[0]?.type!==`number`)return!1;let t=e.anyOf[1];return t?.type===`string`&&Array.isArray(t.enum)&&t.enum.length===3&&t.enum.includes(`NaN`)&&t.enum.includes(`Infinity`)&&t.enum.includes(`-Infinity`)}var xx=`|type|format|pattern|multipleOf|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minProperties|maxProperties|propertyNames|`;function Sx(e,t){return Object.keys(e).every(e=>t.includes(`|${e}|`))}function Cx(e,t){return typeof e.$ref!=`string`&&t.every(t=>!Object.hasOwn(e,t))}var wx=`|title|description|default|examples|readOnly|writeOnly|`,Tx=xx+wx;function Ex(e,t,n){if(Object.keys(e).length===0)return t;let r=Object.keys(t);if(r.length===0)return e;let i=e.type===`number`||e.type===`integer`?e.type:void 0,a=bx(e);if(i!==void 0||a){let r=yx(t);if(r.type!==void 0){let t=i===`integer`||r.type===`integer`?`integer`:`number`,o={...e,type:t};a&&delete o.anyOf;let s=Object.keys(r.schema);return s.length===0?o:Sx(r.schema,wx)&&Cx(o,s)?{...o,...r.schema}:Ex(o,r.schema,n)}}if(n&&Cx(e,r))return{...e,...t};let o=Array.isArray(t.allOf)&&r.length===1?t.allOf:[t];return Array.isArray(e.allOf)?{...e,allOf:[...e.allOf,...o]}:typeof e.$ref==`string`?{allOf:[e,...o]}:{...e,allOf:o}}function Dx(e,t,n,r){let i=new Map,a=new WeakMap,o=new Map,s=Object.keys(n);for(let e of s)u(e,[`references`,e]);let c=$a(e,(e,n)=>d(h(e,t[n]))),l={};for(let e of s){let t=i.get(e);typeof t!=`string`&&E(l,e,d(t))}return{dialect:`draft-2020-12`,schemas:c,definitions:l};function u(e,t){let r=i.get(e);if(r!==void 0)return typeof r==`string`?r:e;if(!Object.hasOwn(n,e))throw hx(`Invalid reference ${e}`,[...t,`$ref`]);i.set(e,null);let a=n[e],s=h(a,[`references`,e]),c=f(a);if(c!==void 0){let t=o.get(c),n=t?.find(e=>lr(i.get(e),s));if(n===void 0)t===void 0?o.set(c,[e]):t.push(e);else return i.set(e,n),n}return i.set(e,s),e}function d(e){return Hb(e,e=>{let t=Pb(e);if(t===void 0){if(/^#(?:\/|%2f)/i.test(e))throw Error(`Invalid JSON Pointer URI fragment ${JSON.stringify(e)}`);return e}if(!t.startsWith(`/$defs/`))return e;let n=t.indexOf(`/`,7),r=i.get(Mb(t.slice(7,n<0?void 0:n)));return typeof r==`string`?e.replace(/^#(?:\/|%2f).*?(?:\/|%2f).*?(?=\/|%2f|$)/i,gx(r)):e})}function f(e){if(e._tag===`Reference`)return;let t=e.checks.length===0?e.annotations:e.checks[e.checks.length-1].annotations;return typeof t?.identifier!=`string`&&typeof t?.[`~identifier`]==`string`?t[km]:void 0}function p(e,t){return e?.schemas?.map((e,n)=>h(e,[...t,`schemas`,n]))??[]}function m(e,t,n){let i=e.annotations,a=i?.toJsonSchema;if(a!==void 0){let o=a({type:t,schemas:p(e.representation,[...n,`representation`])}),s=vx(i,r),c=s===void 0?o:{...o,...s},l=s===void 0?xx:Tx;return e._tag===`Filter`&&Sx(c,l)&&(s===void 0||Sx(s,wx))?[c,!0]:[c]}if(e._tag===`Filter`)return;let o=e.checks.map((e,r)=>m(e,t,[...n,`checks`,r])).filter(e=>e!==void 0);if(o.length===0)return;let s=vx(i,r),c=o.map(([e])=>e);return[s===void 0?{allOf:c}:{allOf:c,...s}]}function h(e,t){if(e._tag===`Reference`)return{$ref:gx(u(e.$ref,t))};let n=a.get(e);if(n!==void 0)return n;let i=g(e,t),o=vx(e.annotations,r);o!==void 0&&(i={...i,...o});for(let n=0;n<e.checks.length;n++){let r=typeof i.type==`string`&&Ox(i.type)?i.type:void 0,a=m(e.checks[n],r,[...t,`checks`,n]);a!==void 0&&(i=Ex(i,...a))}return a.set(e,i),i}function g(e,t){switch(e._tag){case`Any`:case`Unknown`:return{};case`ObjectKeyword`:return{anyOf:[{type:`object`},{type:`array`}]};case`Void`:case`Undefined`:case`Null`:return{type:`null`};case`BigInt`:return{type:`string`,allOf:[{pattern:`^-?\\d+$`}]};case`Symbol`:return{type:`string`,allOf:[{pattern:`^Symbol\\(([\\s\\S]*)\\)$`}]};case`UniqueSymbol`:return globalThis.Symbol.keyFor(e.symbol)===void 0?{not:{}}:{type:`string`,enum:[globalThis.String(e.symbol)]};case`Declaration`:return{};case`Suspend`:return h(e.thunk,[...t,`thunk`]);case`Never`:return{not:{}};case`String`:return{type:`string`};case`Number`:return{anyOf:[{type:`number`},{type:`string`,enum:[`NaN`,`Infinity`,`-Infinity`]}]};case`Boolean`:return{type:`boolean`};case`Literal`:{let t=e.literal;return typeof t==`bigint`?{type:`string`,enum:[globalThis.String(t)]}:{type:typeof t,enum:[t]}}case`Enum`:{let n=e.enums.map(([e,n],r)=>{if(typeof n==`number`&&!globalThis.Number.isFinite(n))throw hx(`Invalid numeric enum value ${globalThis.String(n)}`,[...t,`enums`,r,1]);return{type:typeof n,enum:[n],title:e}});return n.length===0?{not:{}}:{anyOf:n}}case`TemplateLiteral`:return{type:`string`,pattern:`^${e.parts.map(Ax).join(``)}$`};case`Arrays`:{if(e.rest.length>1)throw hx(`Invalid schema representation document`,[...t,`rest`]);let n={type:`array`},i=e.elements.length,a=e.elements.map((e,n)=>{e.isOptional&&i--;let a=h(e.type,[...t,`elements`,n,`type`]),o=vx(e.annotations,r);return o===void 0?a:Ex(a,o)});if(a.length>0?(n.prefixItems=a,n.maxItems=e.elements.length,i>0&&(n.minItems=i)):n.items=!1,e.rest.length===1){delete n.maxItems;let r=h(e.rest[0],[...t,`rest`,0]);Object.keys(r).length>0?n.items=r:delete n.items}return n}case`Objects`:{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return{not:{type:`null`}};let n={type:`object`},i={},a=[];for(let n=0;n<e.propertySignatures.length;n++){let o=e.propertySignatures[n];if(typeof o.name!=`string`)throw hx(`Invalid schema representation document`,[...t,`propertySignatures`,n,`name`]);let s=o.name,c=h(o.type,[...t,`propertySignatures`,n,`type`]),l=vx(o.annotations,r);E(i,s,l===void 0?c:Ex(c,l)),o.isOptional||a.push(s)}e.propertySignatures.length>0&&(n.properties=i),a.length>0&&(n.required=a);let o={},s=[],c=[],l=!1;for(let n=0;n<e.indexSignatures.length;n++){let r=e.indexSignatures[n],i=h(r.type,[...t,`indexSignatures`,n,`type`]);lr(i,{not:{}})&&(i=!1),c.push(i);let a=_(r.parameter,[...t,`indexSignatures`,n,`parameter`],new Set);if(a===void 0){l=!0;continue}if(a.length===0)s.push(i);else for(let e of a){let t=o[e];E(o,e,t===void 0?i:t===!1||i===!1?!1:Ex(t,i))}}let u=Object.keys(o).length>0;if(u&&(n.patternProperties=o),l&&r?.onExcessProperty===`error`){let r=[];e.propertySignatures.length>0&&r.push({enum:Object.keys(i)});for(let n=0;n<e.indexSignatures.length;n++)r.push(h(e.indexSignatures[n].parameter,[...t,`indexSignatures`,n,`parameter`]));n.propertyNames=r.length===1?r[0]:{anyOf:r},n.additionalProperties=c.length===1?c[0]:{anyOf:c},s.length>0&&(n.allOf=s.map(e=>({type:`object`,additionalProperties:e})))}else s.length===0?n.additionalProperties=l||r?.onExcessProperty!==`error`:s.length===1&&e.propertySignatures.length===0&&!u?n.additionalProperties=s[0]:s.length>0&&(n.allOf=s.map(e=>({type:`object`,additionalProperties:e})));return typeof n.additionalProperties==`object`&&n.additionalProperties!==null&&Object.keys(n.additionalProperties).length===0&&delete n.additionalProperties,n}case`Union`:{let n=e.types.map((e,n)=>h(e,[...t,`types`,n]));if(n.length===0)return{not:{}};let r=e.options?.mode??`anyOf`;if(r===`anyOf`&&n.length>1){let e=kx(n);if(e!==void 0)return e}return r===`anyOf`?{anyOf:n}:{oneOf:n}}}}function _(e,t,r){switch(e._tag){case`Reference`:{if(!Object.hasOwn(n,e.$ref))throw hx(`Invalid reference ${e.$ref}`,[...t,`$ref`]);if(u(e.$ref,t),r.has(e.$ref))return;let i=new Set(r).add(e.$ref);return _(n[e.$ref],[`references`,e.$ref],i)}case`String`:{if(e.checks.length===0)return[];if(e.checks.length!==1||e.checks[0]._tag!==`Filter`||e.checks[0].annotations?.toJsonSchema===void 0)return;let n=h(e,t);return n.type===`string`&&typeof n.pattern==`string`&&Sx(n,`|type|pattern|title|description|default|examples|readOnly|writeOnly|`)?[n.pattern]:void 0}case`TemplateLiteral`:return e.checks.length===0?[`^${e.parts.map(Ax).join(``)}$`]:void 0;case`Union`:{if(e.types.length===0||e.checks.length>0||e.options?.mode===`oneOf`)return;let n=[];for(let i=0;i<e.types.length;i++){let a=_(e.types[i],[...t,`types`,i],r);if(a===void 0)return;if(a.length===0)return[];n.push(...a)}return n}default:throw hx(`Invalid schema representation document`,t)}}}function Ox(e){return e===`string`||e===`number`||e===`boolean`||e===`array`||e===`object`||e===`null`||e===`integer`}function kx(e){let t,n=[];for(let r of e){if(Object.keys(r).length!==2||r.type===void 0||!Array.isArray(r.enum)||r.enum.length===0)return;if(t===void 0)t=r.type;else if(r.type!==t)return;for(let e of r.enum){if(n.includes(e))return;n.push(e)}}return{type:t,enum:n}}function Ax(e){switch(e._tag){case`Literal`:return mx(globalThis.String(e.literal));case`String`:return hv;case`Number`:return Jg;case`TemplateLiteral`:return e.parts.map(Ax).join(``);case`Union`:return`(?:${e.types.map(Ax).join(`|`)})`;default:throw hx(`Invalid schema representation document`,[])}}function jx(e,t){return Dx(e.representations,e.representations.map((e,t)=>[`representations`,t]),e.references,t)}var Mx=({identifier:e})=>e;function Nx(e){return e===void 0?void 0:{annotations:e}}function Px(e,t){let n={},r=new Map,i=new Set,a=new Map,o=new Set;for(let t of e)f(t);let s=t?.referencePolicy??Mx;for(let e of a.values())for(let t of e.values()){let e=s({ast:t.ast,occurrences:t.occurrences,identifier:t.identifier});e===void 0?t.isRecursive&&(t.reference=c(`${t.ast._tag}_`,t,``)):t.reference=c(e,t,e===t.identifier||!e.endsWith(`_`)?`_`:``)}return{representations:$a(e,e=>m(e)),references:n};function c(e,t,n=`_`){let i=e,a=0;for(;r.has(i);){if(r.get(i)===t)return i;i=`${e}${n}${++a}`}return r.set(i,t),i}function l(e,t,n){let r=t.fallback;return r===void 0?n===t.identifier?e:R_(e,{identifier:n}):Pm(e)===r?e:R_(e,{[km]:r})}function u(e,t){if(!Object.hasOwn(n,e)&&!i.has(e)){i.add(e);let r=h(t);i.delete(e),E(n,e,r)}return{_tag:`Reference`,$ref:e}}function d(e){let t=L_(e),n=F_(t),r=Nm(t),i=r===void 0?(t===e?void 0:Nm(e))??Pm(t):void 0;i!==void 0&&(r=`${i}Encoded`);let o=a.get(n);o===void 0&&(o=new Map,a.set(n,o));let s=o.get(r);return s===void 0&&(s={ast:n,identifier:r,fallback:i,occurrences:0,isRecursive:!1,reference:void 0},o.set(r,s)),s}function f(e){let t=d(e),n=t.ast;if(t.occurrences++,o.has(t)){t.isRecursive=!0;return}if(!(t.occurrences>1)){switch(o.add(t),p(n.checks),n._tag){case`Declaration`:case`Arrays`:case`Objects`:case`Union`:n.recur(e=>(f(e),e));break;case`TemplateLiteral`:n.parts.forEach(f);break;case`Suspend`:f(n.thunk())}o.delete(t)}}function p(e){e?.forEach(e=>{e.annotations?.representation?.schemas?.forEach(e=>f(ov(e))),e._tag===`FilterGroup`&&p(e.checks)})}function m(e){let t=d(e),n=t.ast,r=t.reference;return r===void 0?h(n):u(r,t.identifier===void 0?n:l(n,t,r))}function h(e){let t=g(e.checks);switch(e._tag){case`Declaration`:return{_tag:`Declaration`,typeParameters:e.typeParameters.map(e=>m(e)),checks:t,...ee(e.annotations)};case`Null`:case`Undefined`:case`Void`:case`Never`:case`Unknown`:case`Any`:case`String`:case`Boolean`:case`Number`:case`BigInt`:case`Symbol`:case`ObjectKeyword`:return{_tag:e._tag,checks:t,...Nx(e.annotations)};case`Literal`:return{_tag:`Literal`,literal:e.literal,checks:t,...Nx(e.annotations)};case`UniqueSymbol`:return{_tag:`UniqueSymbol`,symbol:e.symbol,checks:t,...Nx(e.annotations)};case`Enum`:return{_tag:`Enum`,enums:e.enums,checks:t,...Nx(e.annotations)};case`TemplateLiteral`:return{_tag:`TemplateLiteral`,parts:e.parts.map(e=>m(e)),checks:t,...Nx(e.annotations)};case`Arrays`:return{_tag:`Arrays`,elements:e.elements.map(e=>{let t=L_(e),n=t.context?.annotations;return{isOptional:nv(t),type:m(e),...Nx(n)}}),rest:e.rest.map(e=>m(e)),checks:t,...Nx(e.annotations)};case`Objects`:return{_tag:`Objects`,propertySignatures:e.propertySignatures.map(e=>{let t=L_(e.type),n=t.context?.annotations;return{name:e.name,type:m(e.type),isOptional:nv(t),isMutable:rv(t),...Nx(n)}}),indexSignatures:e.indexSignatures.map(e=>({parameter:m(e.parameter),type:m(e.type)})),checks:t,...Nx(e.annotations)};case`Union`:return{_tag:`Union`,types:e.types.map(e=>m(e)),...e.options===void 0?{}:{options:e.options},checks:t,...Nx(e.annotations)};case`Suspend`:return{_tag:`Suspend`,checks:[],thunk:m(e.thunk()),...Nx(e.annotations)}}}function g(e){return e?.map(_)??[]}function _(e){switch(e._tag){case`Filter`:return{_tag:`Filter`,aborted:e.aborted,...v(e.annotations)};case`FilterGroup`:return{_tag:`FilterGroup`,checks:$a(e.checks,_),...v(e.annotations)}}}function ee(e){if(e===void 0)return;let{representation:t,...n}=e;return{...t===void 0?void 0:{representation:t},...Object.keys(n).length===0?void 0:{annotations:n}}}function v(e){if(e===void 0)return;let{representation:t,...n}=e,r=t===void 0?void 0:t.schemas===void 0?t:{...t,schemas:t.schemas.map(e=>m(ov(e)))};return{...r===void 0?void 0:{representation:r},...Object.keys(n).length===0?void 0:{annotations:n}}}}function Fx(e,t){let n=t;for(let t of e)n=zx(n,t);return n}function Ix(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Lx(e){if(e===``)return[];if(e.charCodeAt(0)!==47)throw Error(`Invalid JSON Pointer, it must start with "/": ${JSON.stringify(e)}`);return e.split(`/`).slice(1).map(Mb)}function Rx(e){if(!/^(0|[1-9]\d*)$/.test(e))throw Error(`Invalid array index: "${e}"`);return Number(e)}function zx(e,t){if(t.path===``){if(t.op===`remove`)throw Error(`Unsupported operation at the root`);return t.value}let n=Bx(e,t.path);if(n===null)throw Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`);let{lastToken:r,parent:i,stack:a}=n;if(Array.isArray(i)){if(r===`-`&&t.op!==`add`)throw Error(`"-" is not valid for ${t.op} at "${t.path}".`);let e=r===`-`?i.length:Rx(r);if(e>(t.op===`add`?i.length:i.length-1))throw Error(`Array index out of bounds at "${t.path}".`);let n=i.slice();return t.op===`add`?n.splice(e,0,t.value):t.op===`remove`?n.splice(e,1):n[e]=t.value,Vx(a,n)}if(Ix(i)){if(t.op!==`add`&&!Object.hasOwn(i,r))throw Error(`Property "${r}" does not exist at "${t.path}".`);let e={...i};return t.op===`remove`?delete e[r]:E(e,r,t.value),Vx(a,e)}throw Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`)}function Bx(e,t){let n=Lx(t);if(n.length===0)return null;let r=n[n.length-1],i=[],a=e;for(let e=0;e<n.length-1;e++){let t=n[e];if(Array.isArray(a)){let e=Rx(t);if(e>=a.length)return null;i.push({container:a,token:e}),a=a[e];continue}if(Ix(a)){if(!Object.hasOwn(a,t))return null;i.push({container:a,token:t}),a=a[t];continue}return null}return{stack:i,parent:a,lastToken:r}}function Vx(e,t){let n=t;for(let t=e.length-1;t>=0;t--){let{container:r,token:i}=e[t];if(Array.isArray(r)){let e=r.slice();e[i]=n,n=e}else{let e={...r};E(e,i,n),n=e}}return n}var Hx=S(2,(e,t)=>({...e,...t})),Ux=e=>e,Wx=`~effect/Schema/SchemaError`;function Gx(e){return w(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}var Kx=new WeakMap,qx=`~effect/Redacted`,Jx=e=>w(e,qx),Yx=(e,t)=>{let n=Object.create(Xx);return t?.label&&(n.label=t.label),Kx.set(n,e),n},Xx={[qx]:{_A:e=>e},label:void 0,...ui,toJSON(){return this.toString()},toString(){return`<redacted${Mn(this.label)?`:`+this.label:``}>`},[Gn](){return T(Kx.get(this))},[cr](e){return Jx(e)&&lr(Kx.get(this),Kx.get(e))}},Zx=`~effect/http/Cookies`,Qx=`~effect/http/Cookies/Cookie`,$x={[Zx]:Zx,...Yr,toJSON(){return{_id:`effect/Cookies`,cookies:Ba(this.cookies,e=>e.toJSON())}},pipe(){return x(this,arguments)}},eS=e=>{let t=Object.create($x);return t.cookies=e,t},tS=e=>{let t={};for(let n of e)E(t,n.name,n);return eS(t)},nS=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=rS(e.trim());t&&n.push(t)}return tS(n)};function rS(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(!aS.test(r))return;let i=t[0].slice(n+1),a=sS(i);if(t.length===1)return Object.assign(Object.create(oS),{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=As(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;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`}}}return Object.assign(Object.create(oS),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var iS=tS([]),aS=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,oS={[Qx]:Qx,...Yr,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},sS=e=>{try{return decodeURIComponent(e)}catch{return e}},cS=Symbol.for(`~effect/http/Headers`),lS=Object.defineProperties(Object.create(null),{[cS]:{value:cS},[Mr]:{value(e){return yS(this,$o(e,xS))}},toJSON:{value(){return Pr(this)}},[cr]:{value(e){return dS(this,e)}},[Gn]:{value(){return $n(this)}},toString:{value:Yr.toString},[qr]:{value:Yr[qr]}}),uS=e=>Object.assign(Object.create(lS),e),dS=Ua(Dr()),fS=Object.create(lS),pS=e=>{if(e===void 0)return fS;if(Symbol.iterator in e){let t=Object.create(lS);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(lS);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},mS=e=>Object.setPrototypeOf(e,lS),hS=S(3,(e,t,n)=>{let r=uS(e);return r[t.toLowerCase()]=n,r}),gS=S(2,(e,t)=>uS({...e,...pS(t)})),_S=S(2,(e,t)=>{let n=uS(e);return Object.assign(n,t),n}),vS=S(2,(e,t)=>{let n=uS(e);return delete n[t.toLowerCase()],n}),yS=S(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=Yx(e[r]))}else for(let r in e)r.search(t)!==-1&&(n[r]=Yx(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),bS=(e,t)=>{for(let n=0;n<t.length;n++){let r=t[n];if(typeof r==`string`){if(r.toLowerCase()===e.toLowerCase())return!0}else if(e.search(r)!==-1)return!0}return!1},xS=M(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),SS=`~effect/http/UrlParams`,CS=e=>w(e,SS),wS={...ui,[SS]:SS,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:`UrlParams`,params:Object.fromEntries(this.params)}},[cr](e){return OS(this,e)},[Gn](){return tr(this.params.flat())}},TS=e=>{let t=Object.create(wS);return t.params=e,t},ES=e=>{if(CS(e))return e;let t=DS(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 TS(n)},DS=e=>{let t=typeof e[Symbol.iterator]==`function`?Ga(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`&&r){let t=DS(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},OS=Tr((e,t)=>kS(e.params,t.params)),kS=eo(Ra([Dr(),Dr()])),AS=TS([]),jS=S(2,(e,t)=>TS(t(e.params))),MS=S(2,(e,t)=>{let n=ES(t).params.slice(),r=new Set;for(let e=0;e<n.length;e++)r.add(n[e][0]);for(let t=0;t<e.params.length;t++)r.has(e.params[t][0])||n.push(e.params[t]);return TS(n)}),NS=S(2,(e,t)=>jS(e,Ja(ES(t).params))),PS=e=>new URLSearchParams(ES(e).params).toString(),FS=e=>{let t={};for(let[n,r]of e.params)if(!Object.hasOwn(t,n))E(t,n,r);else{let e=t[n];typeof e==`string`?E(t,n,[e,r]):e.push(r)}return t},IS=FS,LS=Ob;function RS(){return(e,t,n)=>q(new Dg(e.map(c_),e=>t(e.map(e=>q(e))),n))}function zS(e,t){return RS()([],()=>(t,n,r)=>e(t)?B(t):V(new Qm(n,t,r)),t)}var BS=class extends Qs(`SchemaError`){[Wx]=Wx;constructor(e){let t=Qr();$r(0);try{super({issue:e})}finally{$r(t)}}get message(){return mh(this.issue)}toString(){return`SchemaError(${this.message})`}};function VS(e){return Gx(e)}function HS(e){return z(e)?US(e):Jp(e,e=>Pp(()=>mf(e,e=>new BS(e))))}function US(e){return wf(e)?e:xf(mf(e.cause,e=>new BS(e)))}function WS(e,t){let n;for(let r of e.reasons){if(!sf(r)||!VS(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function GS(e){let t=ym(e);if(wf(t))return t.value;throw WS(t.cause,`Sync adapter can only throw schema errors`)}function KS(e,t){let n=mb(e,t);return(e,t)=>HS(n(e,t))}var qS=KS,JS=hb;function YS(e,t){let n=KS(e,t);return(e,t)=>GS(n(e,t))}function XS(e,t){let n=gb(e,t);return(e,t)=>HS(n(e,t))}var q=Ab;function ZS(e){return w(e,LS)&&e[LS]===LS}var QS=Ux(e=>{let t=bC(e);return q(Z_(e.ast),{schema:t})}),$S=Ux(e=>q(ov(e.ast),{schema:e})),eC=Ux(e=>q(sv(e.ast),{schema:e}));function tC(e){let t=q(new Fg(e),{literal:e,transform(n){return t.pipe(X(tC(n),{decode:Sh(()=>n),encode:Sh(()=>e)}))}});return t}var nC=q(Ng),rC=q(Pg),iC=q(Og),aC=q(jg),J=q(Lg),oC=q(Bg),sC=q(Vg),cC=q(Mg);function lC(e,t){return q(e,{fields:t,mapFields(e,t){let n=e(this.fields);return lC(s_(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function Y(e){return lC(s_(e,void 0),e)}function uC(e){return Ux(t=>t.mapFields(Hx(e)))}function dC(e,t){return q(tv(e.ast,t.ast),{key:e,value:t})}function fC(e,t){return q(e,{elements:t,mapElements(e,t){let n=e(this.elements);return fC(l_(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function pC(e){return fC(l_(e),e)}var mC=Ux(e=>q(new Hg(!1,[],[e.ast]),{value:e})),hC=Ux(e=>q(new Hg(!1,[e.ast],[e.ast]),{value:e}));function gC(e,t){return q(e,{members:t,mapMembers(e,t){let n=e(this.members);return gC(u_(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function _C(e,t){return gC(u_(e,t,void 0),e)}function vC(e){let t=e.map(tC);return q(u_(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return _C(e(this.members))},pick(e){return vC(e)},transform(e){return _C(t.map((t,n)=>t.transform(e[n])))}})}var yC=Ux(e=>_C([e,iC])),bC=Ux(e=>_C([e,aC]));function X(e,t){return n=>q($_(n.ast,e.ast,t?Xh(t):eg()),{from:n,to:e})}function xC(e){return t=>q(Q_(t.ast,e),{schema:t})}function SC(e){return tC(e).pipe(xC(B(e)))}function CC(e,t){return Y({_tag:SC(e),...t})}function wC(e,t){return zS(t=>t instanceof e,t)}function TC(){return(e,t)=>new Sg(e.ast,Xh(t))}var EC=q(A_),DC=e=>+(e?.includeStack===!0)|(e?.excludeCause===!0?2:0),OC=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},kC=[];function AC(e){let t=DC(e),n=kC[t];if(n!==void 0)return n;let r=ZC.pipe(X(rC,cg(OC(t))));return kC[t]=r,r}globalThis.RegExp,globalThis.URL;var jC=J.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`});function MC(e,t){return jC.pipe(X(e,ug(t)))}var NC=MC(rC);globalThis.File,globalThis.FormData,globalThis.URLSearchParams;var PC=J.annotate({expected:`a base64 encoded string that will be decoded as Uint8Array`,format:`byte`,contentEncoding:`base64`}),FC=wC(globalThis.Uint8Array,{representation:{id:`effect/schema/Uint8Array`,payload:null},toCode:()=>({runtime:`Schema.Uint8Array`,Type:`globalThis.Uint8Array`}),expected:`Uint8Array`,toCodecJson:()=>TC()(PC,lg)});function IC(e,t){return q(RS()([e,t],([e,t])=>(n,r,i)=>{if(!of(n))return V(new Qm(r,n,i));switch(n._tag){case`Fail`:return Cm(mb(e)(n.error,i),{onSuccess:df,onFailure:e=>eh(r,`error`,e,n,i)});case`Die`:return Cm(mb(t)(n.defect,i),{onSuccess:ff,onFailure:e=>eh(r,`defect`,e,n,i)});case`Interrupt`:return B(n)}},{representation:{id:`effect/schema/CauseReason`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.CauseReason(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Failure<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause.Failure`,toCodec:([e,t])=>TC()(_C([Y({_tag:tC(`Fail`),error:e}),Y({_tag:tC(`Die`),defect:t}),Y({_tag:tC(`Interrupt`),fiberId:bC(EC)})]),Qh({decode:e=>{switch(e._tag){case`Fail`:return df(e.error);case`Die`:return ff(e.defect);case`Interrupt`:return pf(e.fiberId)}},encode:e=>{switch(e._tag){case`Fail`:return{_tag:`Fail`,error:e.error};case`Die`:return{_tag:`Die`,defect:e.defect};case`Interrupt`:return{_tag:`Interrupt`,fiberId:e.fiberId}}}}))}).ast,{error:e,defect:t})}function LC(e,t){return q(RS()([e,t],([e,t])=>{let n=mC(IC(e,t));return(e,t,r)=>af(e)?Cm(mb(n)(e.reasons,r),{onSuccess:cf,onFailure:n=>eh(t,`failures`,n,e,r)}):V(new Qm(t,e,r))},{representation:{id:`effect/schema/Cause`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Cause(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Cause<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause`,toCodec:([e,t])=>TC()(mC(IC(e,t)),Qh({decode:cf,encode:({reasons:e})=>e}))}).ast,{error:e,defect:t})}var RC=zS(CS,{representation:{id:`effect/http/UrlParams`,payload:null},toCode:()=>({runtime:`Schema.UrlParams`,Type:`UrlParams.UrlParams`,importDeclarations:[`import * as UrlParams from "effect/unstable/http/UrlParams"`]}),expected:`UrlParams`,toEquivalence:()=>OS,toCodec:()=>TC()(mC(pC([J,J])),Qh({decode:TS,encode:e=>e.params}))}).pipe(X(dC(J,_C([J,hC(J)])),Qh({decode:IS,encode:ES}))),zC=globalThis.Symbol.for(`immer-draftable`),BC={};function VC(e,t,n,r,i){let a=WC(n,t,r),o=UC(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===BC?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:BC,value:i}})}static[LS]=LS;get[o](){return o}static[zC]=!0;static identifier=t;static fields=n.fields;static get ast(){return a(this).ast}static pipe(){return x(this,arguments)}static rebuild(e){return a(this).rebuild(e)}static make(e,t){return pb(a(this))(e??{},t)}static makeOption(e,t){return fb(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(R_(this.ast,e))}static annotateKey(e){return this.rebuild(J_(this.ast,e))}static check(...e){return this.rebuild(B_(this.ast,e))}static extend(e){return(t,r)=>{let a=GC(t)?t:Y(t),o={...n.fields,...a.fields},s=s_(o,n.ast.checks,{identifier:e});return VC(this,e,lC(B_(s,a.ast.checks),o),r,i)}}static mapFields(e,t){return n.mapFields(e,t)}};return i!==void 0&&Object.assign(s.prototype,i(t)),s}function HC(e){return new Jh(Sh(t=>new e(t,{"~payload":{token:BC,value:t}})),xh())}function UC(e){return`~effect/Schema/Class/${e}`}function WC(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=UC(t),o=e=>e instanceof i||w(e,a),s=HC(i);return r=X(q(new Dg([e.ast],()=>(e,t,n)=>o(e)?B(e):V(new Qm(t,e,n)),{identifier:t,[jm]:([e])=>({isConstructed:o,link:new Sg(e,s)}),toCodec:([e])=>new Sg(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[Am]:p_(e.ast),...n})),s)(e)}}function GC(e){return ZS(e)}var KC=e=>(t,n)=>VC(Vi,e,GC(t)?t:Y(t),n,e=>({name:e})),qC=e=>(t,n,r)=>{let i=GC(n)?n.mapFields(e=>({_tag:SC(t),...e}),{unsafePreserveChecks:!0}):CC(t,n);return KC(e??t)(i,r)},JC=Yb,YC=nx,XC=rx,ZC=q(R_(jv,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),QC=(e,t)=>()=>{let n=qS(hC(e),t);return Dy((e,t)=>B(H(e,e=>n(e))))},$C=`~effect/Stream`,ew={_R:C,_E:C,_A:C},tw=function(e){this.channel=e};tw.prototype={[$C]:ew,pipe(){return x(this,arguments)}};var nw=e=>new tw(e),rw=`~effect/Stream`,iw=e=>w(e,rw),aw=nw,ow=e=>aw(Py(U(e,Qa))),sw=(e,t)=>aw(Dy((n,r)=>H(Yy(e.channel,r),e=>t(e,r)))),cw=e=>aw(My(()=>e().channel)),lw=e=>aw(Ny(e)),uw=e=>aw(Fy(e)),dw=S(2,(e,t)=>cw(()=>{let n=0;return aw(Ly(e.channel,$a(e=>t(e,n++))))})),fw=S(2,(e,t)=>aw(zy(e.channel,t))),pw=S(2,(e,t)=>e.channel.pipe(Hy(e=>t(e).channel),aw)),mw=S(2,(e,t)=>aw(Uy(e.channel,t))),hw=S(e=>iw(e[0]),(e,t)=>cw(()=>{let n=new TextDecoder(t?.encoding);return dw(e,e=>n.decode(e,{stream:!0}))})),gw=e=>cw(()=>{let t=new TextEncoder;return dw(e,e=>t.encode(e))}),_w=S(2,(e,t)=>aw(Gy(e.channel,t))),vw=S(2,(e,t)=>aw(qy(e.channel,t))),yw=S(2,(e,t)=>Jy(e.channel,t)),bw=S(e=>iw(e[0]),(e,t,n)=>{let r,i,a=Bv(!1);return new ReadableStream({start(n){i=hm(rm(yw(e,e=>a.whenOpen(Ap(()=>{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(gf(e.cause)):n.close()})},pull(){return new Promise(e=>{r=e,a.openUnsafe()})},cancel(){if(i)return _m(Gp(Lv(i)))}},n?.strategy)}),xw=S(e=>iw(e[0]),(e,t)=>U(em(),n=>bw(e,n,t))),Sw=`~effect/ErrorReporter/ignore`,Cw=S(2,(e,t)=>e===void 0?void 0:t(e)),ww=/^[A-Za-z0-9_-]+$/,Tw=(e,t)=>{if(!ww.test(t)||t===`then`)throw Error(`Invalid ${e}: ${t}`)},Ew=(e,t)=>{let n=new Set;for(let r of t){if(n.has(r))throw Error(`Duplicate ${e}: ${r}`);n.add(r)}},Dw=dC(J,nC);function Ow(e,t){Tw(`action name`,e);let n=t.access??`write`,r=t.mcp===!1?!1:t.mcp?.readOnly??n===`read`,i=t.mcp!==!1&&{name:t.mcp?.name??e,readOnly:r,destructive:t.mcp?.destructive??!r,idempotent:t.mcp?.idempotent??!1,openWorld:t.mcp?.openWorld??!0};if(i!==!1&&i.name.length>128)throw Error(`Invalid MCP name: ${i.name}`);return i!==!1&&Tw(`MCP name`,i.name),{name:e,description:t.description,input:t.input??Dw,success:t.success,errors:t.errors??[],access:n,http:t.http!==!1,mcp:i}}var kw=class e{group;#e;#t;constructor(e,t,n){this.group=e,this.#e=t,this.#t=n}get build(){return this.#e}get before(){return this.#t}static make(t,n,r){return new e(t,n,r)}},Aw=(e,t,n,r)=>{let i=n[t.name];if(i===void 0)throw Error(`Missing handler: ${t.name}`);return n=>fm(kp(()=>r===void 0?i(n):H(r(t),()=>i(n))),`${e.name}.${t.name}`,{captureStackTrace:!1})};function jw(e,...t){let{name:n}=e;Tw(`action group name`,n);let r=t.map(t=>({...t,errors:[...t.errors,...e.errors??[]]}));Ew(`action`,r.map(e=>e.name)),Ew(`MCP tool`,r.flatMap(e=>e.mcp===!1?[]:[e.mcp.name]));let i={name:n,actions:r,schemaError:e.schemaError,implement:(e,t)=>{let n=Ep(e)?e:B(e),r=t?.before;return kw.make(i,n,r)}};return i}var Mw=`~effect/http/HttpBody`,Nw=e=>w(e,Mw),Pw=class{[Mw];constructor(){this[Mw]=Mw}[qr](){return this.toJSON()}toString(){return zr(this,{ignoreToString:!0})}},Fw=new class extends Pw{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},Iw=class extends Pw{_tag=`Uint8Array`;contentType;contentLength;text;_body;constructor(e,t,n,r){super(),this._body=e,this.text=r,this.contentType=t,this.contentLength=n}get body(){return this._body??=Bw(this.text)}toJSON(){return{_id:`effect/HttpBody`,_tag:`Uint8Array`,body:this.contentType.startsWith(`text/`)||this.contentType.endsWith(`json`)?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},Lw=(e,t)=>new Iw(e,t??`application/octet-stream`,e.length),Rw=new TextEncoder,zw=globalThis.Buffer,Bw=zw===void 0?e=>Rw.encode(e):e=>zw.from(e,`utf8`),Vw=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),zw!==void 0)return new Iw(void 0,t??`text/plain`,zw.byteLength(e,`utf8`),e);let n=Rw.encode(e);return new Iw(n,t??`text/plain`,n.length,e)},Hw=(e,t)=>Vw(JSON.stringify(e),t??`application/json`),Uw=(e,t)=>Vw(PS(ES(e)),t??`application/x-www-form-urlencoded`),Ww=class extends Pw{_tag=`FormData`;contentType=void 0;contentLength=void 0;formData;constructor(e){super(),this.formData=e}toJSON(){return{_id:`effect/HttpBody`,_tag:`FormData`,formData:this.formData}}},Gw=e=>new Ww(e),Kw=class extends Pw{_tag=`Stream`;stream;contentType;contentLength;constructor(e,t,n){super(),this.stream=e,this.contentType=t,this.contentLength=n}toJSON(){return{_id:`effect/HttpBody`,_tag:`Stream`,contentType:this.contentType,contentLength:this.contentLength}}},qw=(e,t,n)=>new Kw(e,t??`application/octet-stream`,n),Jw=`~effect/http/HttpClientError`,Yw=class extends Qs(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[Jw]=Jw;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},Xw=e=>e.endsWith(`Error`)?e.slice(0,-5):e,Zw=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,Qw=class extends Qs(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return Zw(Xw(this._tag),this.description,this.methodAndUrl)}},$w=class extends Qs(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return Zw(Xw(this._tag),this.description,this.methodAndUrl)}},eT=class extends Qs(`StatusCodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return Zw(Xw(this._tag),this.description,e)}},tT=class extends Qs(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return Zw(Xw(this._tag),this.description,e)}},nT=class extends Qs(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return Zw(Xw(this._tag),this.description,e)}},rT=e=>e!==`GET`&&e!==`HEAD`&&e!==`OPTIONS`&&e!==`TRACE`,iT=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],aT=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?vS(vS(e,`content-type`),`content-length`):(e=t.contentType===void 0?vS(e,`content-type`):hS(e,`content-type`,t.contentType),t.contentLength===void 0?vS(e,`content-length`):hS(e,`content-length`,t.contentLength.toString())),oT=class extends Qs(`UrlError`){},sT=(e,t,n)=>Ma({try:()=>{let r=new URL(e,cT());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),r},catch:e=>new oT({cause:e})}),cT=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},lT=`~effect/http/HttpClientRequest`,uT={[lT]:lT,...Yr,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Pr(this.headers),body:this.body.toJSON()}},pipe(){return x(this,arguments)}};function dT(e,t,n,r,i,a){let o=Object.create(uT);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var fT=dT(`GET`,``,AS,xa(),fS,Fw),pT=e=>(t,n)=>mT(fT,{method:e,url:t,...n??void 0}),mT=S(2,(e,t)=>{let n=e;return t.method&&(n=hT(n,t.method)),t.url&&(n=bT(n,t.url)),t.headers&&(n=_T(n,t.headers)),t.urlParams&&(n=CT(n,t.urlParams)),t.hash&&(n=TT(n,t.hash)),t.body&&(n=ET(n,t.body)),t.accept&&(n=vT(n,t.accept)),t.acceptJson&&(n=yT(n)),n}),hT=S(2,(e,t)=>dT(t,e.url,e.urlParams,e.hash,e.headers,e.body)),gT=S(3,(e,t,n)=>dT(e.method,e.url,e.urlParams,e.hash,hS(e.headers,t,n),e.body)),_T=S(2,(e,t)=>dT(e.method,e.url,e.urlParams,e.hash,gS(e.headers,t),e.body)),vT=S(2,(e,t)=>gT(e,`Accept`,t)),yT=vT(`application/json`),bT=S(2,(e,t)=>{if(typeof t==`string`)return dT(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=ES(n.searchParams),i=Da(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,dT(e.method,n.toString(),r,i,e.headers,e.body)}),xT=S(2,(e,t)=>t===``?e:dT(e.method,ST(t,e.url),e.urlParams,e.hash,e.headers,e.body)),ST=(e,t)=>{let n=e.endsWith(`/`),r=t.startsWith(`/`);return n&&r?e+t.slice(1):!n&&!r?e+`/`+t:e+t},CT=S(2,(e,t)=>dT(e.method,e.url,MS(e.urlParams,t),e.hash,e.headers,e.body)),wT=S(2,(e,t)=>dT(e.method,e.url,NS(e.urlParams,t),e.hash,e.headers,e.body)),TT=S(2,(e,t)=>dT(e.method,e.url,e.urlParams,Sa(t),e.headers,e.body)),ET=S(2,(e,t)=>dT(e.method,e.url,e.urlParams,e.hash,aT(e.headers,t),t)),DT=S(2,(e,t)=>ET(e,Gw(t)));function OT(e){let t=sT(e.url,e.urlParams,Oa(e.hash));return Pa(t)?Sa(t.success):xa()}var kT=`~effect/http/HttpIncomingMessage`,AT=M(`effect/http/HttpIncomingMessage/MaxBodySize`,{defaultValue:()=>void 0}),jT=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=vm(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=vm(e.text)}catch{}let i={...t,headers:Pr(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},MT=`~effect/http/HttpClientResponse`,NT=(e,t)=>new PT(e,t),PT=class extends Xr{[kT];[MT];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[kT]=kT,this[MT]=MT}toJSON(){return jT(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split(`#`)[0];let e=OT(this.request);return Ca(e)?``:(e.value.hash=``,e.value.href)}get headers(){return pS(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=nS(this.source.headers.getSetCookie())}get remoteAddress(){return xa()}get stream(){return this.source.body?uw({evaluate:()=>this.source.body,onError:e=>new Yw({reason:new tT({request:this.request,response:this,cause:e})})}):lw(new Yw({reason:new nT({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return H(this.text,e=>Ip({try:()=>e===``?null:JSON.parse(e),catch:e=>new Yw({reason:new tT({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=U(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return H(this.text,e=>Ip({try:()=>ES(new URLSearchParams(e)),catch:e=>new Yw({reason:new tT({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=Op({try:()=>this.source.formData(),catch:e=>new Yw({reason:new tT({request:this.request,response:this,cause:e})})}).pipe(sm,vm)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=Op({try:()=>this.source.arrayBuffer(),catch:e=>new Yw({reason:new tT({request:this.request,response:this,cause:e})})}).pipe(sm,vm),this.arrayBufferBody}pipe(){return x(this,arguments)}},FT=Object.getPrototypeOf(fS),IT=()=>Object.create(FT),LT=`~effect/http/HttpServerResponse`,RT=e=>w(e,LT),zT=e=>YT({status:e?.status??204,statusText:e?.statusText,headers:e?.headers?pS(e.headers):void 0,cookies:e?.cookies}),BT=(e,t)=>{let n=t?.headers?pS(t.headers):fS;return YT({status:t?.status??200,statusText:t?.statusText,headers:n,cookies:t?.cookies??iS,body:Lw(e,VT(t,n))})},VT=(e,t)=>{if(e?.contentType)return e.contentType;if(e?.headers)return t[`content-type`]},HT=(e,t)=>{let n=t?.headers?pS(t.headers):fS;return YT({status:t?.status??200,statusText:t?.statusText,headers:n,cookies:t?.cookies??iS,body:Vw(e,VT(t,n))})},UT=(e,t)=>{let n=t?.headers?pS(t.headers):fS;return YT({status:t?.status??200,statusText:t?.statusText,headers:n,cookies:t?.cookies,body:Hw(e,VT(t,n))})},WT=(e,t)=>{let n=t?.headers?pS(t.headers):fS;return YT({status:t?.status??200,statusText:t?.statusText,headers:n,cookies:t?.cookies,body:Vw(PS(ES(e)),VT(t,n)??`application/x-www-form-urlencoded`)})},GT=(e,t)=>{let n=t?.headers?pS(t.headers):fS;return YT({status:t?.status??200,statusText:t?.statusText,headers:n,cookies:t?.cookies,body:qw(e,VT(t,n),t?.contentLength)})},KT=S(3,(e,t,n)=>YT(e,hS(e.headers,t,n))),qT=S(2,(e,t)=>YT(e,gS(e.headers,t))),JT={...ui,[LT]:LT,[Sw]:!0,toJSON(){return{_id:`HttpServerResponse`,status:this.status,statusText:this.statusText,headers:Pr(this.headers),cookies:this.cookies.toJSON(),body:this.body.toJSON()}}},YT=(e,t)=>{let n=Object.create(JT);if(n.status=e.status,n.statusText=e.statusText,n.cookies=e.cookies??iS,n.body=e.body??Fw,n.body._tag!==`Empty`&&(n.body.contentType||n.body.contentLength!==void 0)){let r=t!==void 0,i=r?t:e.headers===void 0||e.headers===fS?IT():mS({...e.headers});n.body.contentType&&(!r||i[`content-type`]===void 0)&&(i[`content-type`]=n.body.contentType),n.body.contentLength!==void 0&&(!r||i[`content-length`]===void 0)&&(i[`content-length`]=n.body.contentLength.toString()),n.headers=i}else n.headers=t??e.headers??fS;return n},XT=`~effect/http/HttpServerRespondable`,ZT=new Uint8Array(256);for(let e of"!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")ZT[e.charCodeAt(0)]=1;var QT=new Uint8Array(256);QT[9]=1;for(let e=32;e<=126;e++)QT[e]=1;for(let e=128;e<=255;e++)QT[e]=1;var $T=e=>{let t=new Map;return e.maxParts!==void 0&&t.set(eE.key,e.maxParts),e.maxFieldSize!==void 0&&t.set(tE.key,Wh(e.maxFieldSize)),e.maxFileSize!==void 0&&t.set(nE.key,Wh(e.maxFileSize)),e.maxTotalSize!==void 0&&t.set(AT.key,Wh(e.maxTotalSize)),e.fieldMimeTypes!==void 0&&t.set(rE.key,e.fieldMimeTypes),zo(t)},eE=M(`effect/http/Multipart/MaxParts`,{defaultValue:()=>void 0}),tE=M(`effect/http/Multipart/MaxFieldSize`,{defaultValue:Cn(Gh(10))}),nE=M(`effect/http/Multipart/MaxFileSize`,{defaultValue:()=>void 0}),rE=M(`effect/http/Multipart/FieldMimeTypes`,{defaultValue:Cn([`application/json`])}),iE=j(`effect/http/HttpServerRequest`),aE=class extends j()(`effect/http/ParsedSearchParams`){},oE=(e,t)=>{let n=KS(e);return H(iE,e=>n(e.cookies,t))},sE=(e,t)=>{let n=KS(e);return H(iE,e=>n(e.headers,t))},cE=(e,t)=>{let n=KS(e);return H(aE,e=>n(e,t))},lE=e=>mS({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${Ta(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),uE=new WeakSet,dE=e=>Lp(t=>{let n=Qo(t.context,iE);return uE.add(n.source),e}),fE=`~effect/http/HttpClient`,pE=j(`effect/HttpClient`),mE=S(2,(e,t)=>hE(n=>t(e.postprocess(n)),e.preprocess)),hE=(e,t)=>{let n=Object.create(gE);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},gE={[fE]:fE,pipe(){return x(this,arguments)},...Yr,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(iT.map(([e,t])=>[t,function(t,n){return this.execute(pT(e)(t,n))}]))},_E=e=>hE(t=>H(t,t=>Lp(n=>{let r=TE.get(t),i=r??new AbortController,a=sT(t.url,t.urlParams,Oa(t.hash));if(Na(a))return V(new Yw({reason:new $w({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(yc)||n.getRef(yE)(t)){let a=e(t,o,i.signal,n);return r?a:lm(e=>$p(e(a),{onSuccess(e){return wE.register(e,i),B(new EE(e,i))},onFailure(e){return _f(e)&&i.abort(),Np(e)}}))}return dm(n.getRef(SE)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method),a.attribute(`server.address`,o.origin),o.port!==``&&a.attribute(`server.port`,+o.port),a.attribute(`url.full`,o.toString()),a.attribute(`url.path`,o.pathname),a.attribute(`url.scheme`,o.protocol.slice(0,-1));let s=o.search.slice(1);s!==``&&a.attribute(`url.query`,s);let c=n.getRef(xS),l=n.getRef(bE);for(let e in t.headers)l(e,`request`)&&a.attribute(`http.request.header.${e}`,bS(e,c)?`<redacted>`:t.headers[e]);return t=n.getRef(xE)?_T(t,lE(a)):t,lm(s=>s(e(t,o,i.signal,n)).pipe(pm(a,{captureStackTrace:!1}),$p({onSuccess:e=>{a.attribute(`http.response.status_code`,e.status);for(let t in e.headers)l(t,`response`)&&a.attribute(`http.response.header.${t}`,bS(t,c)?`<redacted>`:e.headers[t]);return r?B(e):(wE.register(e,i),B(new EE(e,i)))},onFailure(e){return!r&&_f(e)&&i.abort(),Np(e)}})))})})),B),vE=S(2,(e,t)=>hE(e.postprocess,n=>U(e.preprocess(n),t))),yE=M(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>Tn}),bE=M(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>wn}),xE=M(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:wn}),SE=M(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),CE=e=>tp(pE)(tm(t=>U(e,e=>mE(e,im(e=>is(t,e)))))),wE=(()=>{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))}}})(),TE=new WeakMap,EE=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[MT]=MT;[kT]=kT;applyInterrupt(e){return kp(()=>(wE.unregister(this.original),cm(e,()=>Ap(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}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 cw(()=>(wE.unregister(this.original),_w(this.original.stream,Ap(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[qr](){return this.original[qr]()}pipe(){return x(this,arguments)}},DE=j(`effect/http/HttpRouter`),OE=class extends j()(`effect/http/HttpRouter/RouteContext`){},kE=e=>ip(H(DE,e)),AE=`~effect/http/HttpRouter/Route`,jE=e=>({...e,uninterruptible:e.uninterruptible??!1,prefix:typeof e.prefix==`string`?Sa(e.prefix):e.prefix??xa(),[AE]:AE}),ME=(e,t,n,r)=>jE({...r,method:e,path:t,handler:RT(n)?B(n):Ep(n)?n:H(iE,n),uninterruptible:r?.uninterruptible??!1}),NE=e=>e.endsWith(`/`)?e.slice(0,-1):e,PE=S(2,(e,t)=>(t=NE(t),e===`*`?`${t}/*`:e===`/`?t:t+e)),FE=`~effect/http/HttpRouter/Middleware`,IE=function(){return arguments.length===0?LE:LE(arguments[0],arguments[1])},LE=(e,t)=>t?.global?ip(Mp(function*(){let t=yield*DE,n=Ep(e)?yield*e:e;yield*t.addGlobalMiddleware(n)})):new BE(Ep(e)?rp(U(e,e=>zo(new Map([[zE,e]])))):$f(zo(new Map([[zE,e]])))),RE=0,zE=`effect/http/HttpRouter/MiddlewareFn`,BE=class e{[FE]={};layerFn;dependencies;constructor(e,t){this.layerFn=e,this.dependencies=t;let n=`effect/http/HttpRouter/Middleware-${++RE}`;this.layer=rp(Mp({self:this},function*(){let e=yield*em(),t=[Zo(e,zE)];if(this.dependencies){let n=yield*Yf,r=$o(e,jf),i=yield*Xf(this.dependencies,n,r);t.push(...HE(i))}return zo(new Map([[n,t]]))})).pipe(up(this.layerFn))}layer;combine(t){return new e(this.layerFn,this.dependencies?dp(this.dependencies,t.layer):t.layer)}},VE=new WeakMap,HE=e=>{let t=VE.get(e);if(t)return t;let n=Za(),r=0;for(let[t,i]of e.mapUnsafe)t.startsWith(`effect/http/HttpRouter/Middleware-`)&&(n.push(i),i.length>r&&(r=i.length));if(n.length===0)t=[];else{let e=new Set;for(let t=r-1;t>=0;t--)for(let r of n)t<r.length&&e.add(r[t]);t=Ga(e).reverse()}return VE.set(e,t),t};IE(dE).layer;var UE=`~effect/encoding/Sse/SseError`,WE=class extends Qs(`EventTooLarge`){get message(){return`Pending SSE event exceeded the maximum size of ${this.maxEventSize}`}},GE=class extends Qs(`SseError`){[UE]=UE;get message(){return this.reason.message}},KE=10485760,qE=e=>Dy((t,n)=>Ap(()=>{let n=[],r,i=YE(e=>{e._tag===`Retry`?r=e:n.push(e)},e),a=H(t,e=>{for(let t=0;t<e.length;t++){let n=i.feed(e[t]);if(n!==void 0)return V(n)}return jp});return kp(function e(){if(Ya(n)){let e=n;return n=[],B(e)}return r?V(r):H(a,e)})})),JE=(e,t,n)=>Uy(qE(t),QC(ZE.pipe(X(e,QE)),n)());function YE(e,t){let n=t?.maxEventSize??KE,r,i,a,o,s,c,l,u;return d(),{feed:f,reset:d};function d(){r=!0,i=``,a=0,o=-1,s=!1,c=void 0,l=void 0,u=``}function f(e){i=i?i+e:e,r&&i.startsWith(XE)&&(i=i.slice(XE.length)),r=!1;let t=i.length,c=0;for(;c<t;){s&&=(i[c]===`
|
|
10
10
|
`&&++c,!1);let e=-1,n=o,r;for(let o=c+a;e<0&&o<t;++o)r=i[o],r===`:`&&n<0?n=o-c:r===`\r`?(s=!0,e=o-c):r===`
|
|
11
11
|
`&&(e=o-c);if(e<0){a=t-c,o=n;break}a=0,o=-1,p(i,c,n,e),c+=e+1}if(c===t?i=``:c>0&&(i=i.slice(c)),i.length+u.length>n){let e=new GE({reason:new WE({maxEventSize:n})});return d(),e}}function p(t,n,r,i){if(i===0){u.length>0&&(e({_tag:`Event`,id:c,event:l||`message`,data:u.slice(0,-1)}),u=``),l=void 0;return}let a=r<0,o=t.slice(n,n+(a?i:r)),s=0;s=a?i:t[n+r+1]===` `?r+2:r+1;let d=n+s,f=i-s,p=t.slice(d,d+f).toString();o===`data`?u+=p?`${p}\n`:`
|
|
12
12
|
`:o===`event`?l=p:o===`id`&&!p.includes(`\0`)?c=p:o===`retry`&&/^\d+$/.test(p)&&e(new eD({duration:ks(parseInt(p,10)),lastEventId:c}))}}var XE=``,ZE=Y({_tag:SC(`Event`),id:bC(J),event:J,data:J}),QE=Qh({decode:e=>e.id===void 0?{event:e.event,data:e.data}:{id:e.id,event:e.event,data:e.data},encode:e=>({_tag:`Event`,id:e.id,event:e.event??`message`,data:e.data})}),$E=`~effect/encoding/Sse/Retry`,eD=class e extends Zs(`Retry`){[$E]=$E;static is(e){return w(e,$E)}static filter(t){return e.is(t)?Aa(t):ja(t)}},tD={write(e){switch(e._tag){case`Event`:{let t=``;return e.id!==void 0&&(t+=`id: ${e.id}\n`),e.event!==`message`&&(t+=`event: ${e.event}\n`),t+=`data: ${e.data.replace(/\n/g,`
|
|
13
13
|
data: `)}\n`,t+`
|
|
14
|
-
`}case`Retry`:return`retry: ${Fs(e.duration)}\n\n`}}},nD={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,OK:200,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511},rD=e=>nD[e],iD=`~effect/httpapi/HttpApiSchema/Stream`;function aD(e){let t=typeof e==`string`?rD(e):e;return e=>e.annotate({httpApiStatus:t})}var oD=(e=>cC.pipe(aD(e)))(204),sD=e=>ZS(e)&&w(e,iD),cD=e=>sD(e)&&e._tag===`StreamSse`,lD=e=>sD(e)&&e._tag===`StreamUint8Array`,uD=`~effect/httpapi/HttpApiSchema/WithHeaders`,dD=`~effect/httpapi/HttpApiSchema/WithHeadersValue`,fD=e=>w(e,dD),pD=e=>({[dD]:dD,body:e.body,headers:e.headers}),Z=e=>ZS(e)&&w(e,`~effect/httpapi/HttpApiSchema/WithHeaders`);function mD(e,t,n){return q(e.ast,{[uD]:uD,schema:t,headers:n})}function hD(e,t){return e.annotate({"~httpApiEncoding":{_tag:t._tag,contentType:t.contentType??gD(t._tag)}})}function gD(e){switch(e){case`Multipart`:return`multipart/form-data`;case`Json`:return`application/json`;case`FormUrlEncoded`:return`application/x-www-form-urlencoded`;case`Uint8Array`:return`application/octet-stream`;case`Text`:return`text/plain`}}function _D(e){return t=>hD(t,{_tag:`FormUrlEncoded`,...e})}var vD=e=>{if(mg(e)||mg(sv(e)))return!0;let t=e.encoding?.[0].to;return t!==void 0&&mg(t)},yD=wv(`~httpApiEncoding`),bD=wv(`~httpApiWithHeaders`),xD=wv(`httpApiStatus`),SD={_tag:`Json`,contentType:`application/json`},CD={_tag:`FormUrlEncoded`,contentType:`application/x-www-form-urlencoded`};function wD(e){return yD(e)??SD}function TD(e,t){return yD(e)||(rT(t)?SD:CD)}function ED(e){let t=wD(e);if(t._tag===`Multipart`)throw Error(`Multipart is not supported in response`);return t}function DD(e){return xD(e)??200}function OD(e){return Z(e)?xD(e.ast)??DD(e.schema.ast):DD(e.ast)}function kD(e){return Z(e)&&yD(e.ast)===void 0?ED(e.schema.ast):ED(e.ast)}function AD(e){return xD(e)??500}function jD(e){return Z(e)?xD(e.ast)??AD(e.schema.ast):AD(e.ast)}function MD(e){let t=e.toLowerCase().trim(),n=t.indexOf(`;`);return n===-1?t:t.slice(0,n).trim()}var ND=`~effect/httpapi/HttpApiEndpoint`;function PD(e){let t=[];for(let{schemas:n}of e.payload.values())t.push(...n);return t}function FD(e){let t=Array.from(e.success);return Ya(t)?t:[oD]}function ID(e){let t=new Set(e.error),n=e.disableCodecs?C:GD;for(let r of e.middlewares){let e=r;for(let r of e.error)t.add(n(r))}return Array.from(t)}var LD={[ND]:ND,pipe(){return x(this,arguments)},prefix(e){return zD({...RD(this),path:PE(this.path,e)})},middleware(e){return zD({...RD(this),middlewares:new Set([...this.middlewares,e])})},annotate(e,t){return zD({...RD(this),annotations:qo(this.annotations,e,t)})},annotateMerge(e){return zD({...RD(this),annotations:is(this.annotations,e)})}},RD=e=>({identifier:e.identifier,path:e.path,method:e.method,params:e.params,query:e.query,headers:e.headers,payload:e.payload,success:e.success,error:e.error,annotations:e.annotations,middlewares:e.middlewares,disableCodecs:e.disableCodecs});function zD(e){function t(){}return Object.setPrototypeOf(t,LD),Object.assign(t,e)}var BD=e=>(t,n,r)=>{let i=r?.disableCodecs??!1,a=i?C:YC;return zD({identifier:t,path:n,method:e,params:VD(r?.params,a),query:VD(r?.query,a),headers:VD(r?.headers,a),payload:HD(r?.payload,e,i),success:WD(r?.success,e,i),error:KD(r?.error,i),annotations:Wo(),middlewares:new Set,disableCodecs:i})};function VD(e,t){if(e!==void 0)return ZS(e)?t(e):t(Y(e))}function HD(e,t,n){let r=new Map;if(e===void 0)return r;let i=Array.isArray(e)?e:ZS(e)?[e]:[Y(e).pipe(_D())],a=n?C:nO;for(let e of i){let n=TD(e.ast,t),i=MD(n.contentType),o=r.get(i);if(o){if(o.encoding._tag!==n._tag)throw Error(`Multiple payload encodings for content-type: ${n.contentType}`);if(o.encoding._tag===`Multipart`)throw Error(`Multiple multipart payloads for content-type: ${n.contentType}`);o.schemas.push(a(e,t))}else r.set(i,{encoding:n,schemas:[a(e,t)]})}return r}var UD=`effect/httpapi/stream/failure`;function WD(e,t,n){if(e===void 0)return new Set;let r=Ka(e);return qD(r,t),new Set(n?r:r.map(GD))}var GD=On(e=>sD(e)?e:Z(e)?mD(e,sD(e.schema)?e.schema:tO(e.schema,kD(e)),YC(e.headers)):eO(e));function KD(e,t){if(e===void 0)return new Set;let n=Ka(e);for(let e of n)if(sD(Z(e)?e.schema:e))throw Error(`Streaming schemas are not supported in error responses`);return YD(n,jD),new Set(t?n:n.map(GD))}function qD(e,t){let n=!1,r=new Map;for(let i of e){let e=Z(i)?i.schema:i,a=OD(i);if(sD(e)){if(XD(e,t),n)throw Error(`Multiple streaming success responses are not supported`);n=!0;let i=JD(r,a);if(i.noContent)throw Error(`Cannot combine no-content and streaming success responses for status: ${a}`);if(i.bufferedContentTypes.has(MD(e.contentType)))throw Error(`Cannot combine buffered and streaming success responses for status ${a} and content-type: ${e.contentType}`);r.set(a,{...i,stream:e})}else{let t=JD(r,a),n=vD(e.ast);if(t.stream!==void 0){if(n)throw Error(`Cannot combine no-content and streaming success responses for status: ${a}`);let e=kD(i);if(MD(e.contentType)===MD(t.stream.contentType))throw Error(`Cannot combine buffered and streaming success responses for status ${a} and content-type: ${e.contentType}`)}n||t.bufferedContentTypes.add(MD(kD(i).contentType)),t.noContent=t.noContent||n}}YD(e,OD)}function JD(e,t){let n=e.get(t);return n===void 0&&(n={bufferedContentTypes:new Set,noContent:!1},e.set(t,n)),n}function YD(e,t){let n=new Map;for(let r of e){let e=t(r),i=bD(r.ast),a=Z(r)?r.schema:i?.body??r,o=vD(a.ast)?``:MD(sD(a)?a.contentType:kD(r).contentType),s=n.get(e);s===void 0&&(s={headerContentType:void 0,plainContentTypes:new Set},n.set(e,s));let c=()=>Error(`Cannot combine a response with headers with another response for status ${e} and content-type: ${o||`<no content>`}`);if(Z(r)||i!==void 0){if(s.headerContentType!==void 0)throw Error(`Cannot declare multiple responses with headers for status ${e}`);if(s.plainContentTypes.has(o))throw c();s.headerContentType=o}else{if(s.headerContentType===o)throw c();s.plainContentTypes.add(o)}}}function XD(e,t){if(t===`HEAD`)throw Error(`HEAD endpoints cannot declare streaming success responses`);if(cD(e)&&ZD(e.events.ast))throw Error(`SSE event name is reserved: ${UD}`)}function ZD(e){return QD(sv(e),new Set)}function QD(e,t){if(t.has(e))return!1;if(t.add(e),bg(e))return e.types.some(e=>QD(e,t));if(xg(e))return QD(e.thunk(),t);if(!yg(e))return!1;let n=e.propertySignatures.find(e=>e.name===`event`);return n!==void 0&&$D(n.type,t)}function $D(e,t){if(t.has(e))return!1;t.add(e);let n=sv(e);return n===e?gg(e)?e.literal===UD:bg(e)?e.types.some(e=>$D(e,t)):xg(e)?$D(e.thunk(),t):!1:$D(n,t)}function eO(e){let t=ED(e.ast),n=bD(e.ast);if(n===void 0)return tO(e,t);let r=eC(n.headers);return Y({body:tO(eC(n.body),t),headers:r}).pipe(X(e)).annotate({"~httpApiWithHeaders":{...n,headersCodec:YC(r)}})}function tO(e,t){switch(t._tag){case`Json`:return JC(e);case`FormUrlEncoded`:return YC(e);case`Text`:case`Uint8Array`:return e}}function nO(e,t){switch(TD(e.ast,t)._tag){case`Json`:return JC(e);case`FormUrlEncoded`:return YC(e);case`Text`:case`Uint8Array`:case`Multipart`:return e}}var rO=BD(`POST`),iO=`~effect/httpapi/HttpApi`,aO={[iO]:iO,pipe(){return x(this,arguments)},add(...e){let t={...this.groups};for(let n of e)E(t,n.identifier,n);return sO({...oO(this),groups:t})},addHttpApi(e){let t={...this.groups};for(let n of Object.keys(e.groups)){let r=e.groups[n];E(t,n,r.annotateMerge(is(e.annotations,r.annotations)))}return sO({...oO(this),groups:t})},prefix(e){return sO({...oO(this),groups:Ba(this.groups,t=>t.prefix(e))})},middleware(e){return sO({...oO(this),groups:Ba(this.groups,t=>t.middleware(e))})},annotate(e,t){return sO({...oO(this),annotations:qo(this.annotations,e,t)})},annotateMerge(e){return sO({...oO(this),annotations:is(this.annotations,e)})}},oO=e=>({identifier:e.identifier,groups:e.groups,annotations:e.annotations}),sO=e=>{function t(){}return Object.setPrototypeOf(t,aO),Object.assign(t,e)},cO=e=>sO({identifier:e,groups:{},annotations:Wo()}),lO=(e,t)=>{let n=Object.values(e.groups);for(let r of n){let n=is(e.annotations,r.annotations);t.onGroup({group:r,mergedAnnotations:n});let i=Object.values(r.endpoints);for(let e of i)(!t.predicate||t.predicate({endpoint:e,group:r}))&&t.onEndpoint({group:r,endpoint:e,middleware:e.middlewares,mergedAnnotations:is(n,e.annotations),successes:uO(FD(e),OD),errors:uO(ID(e),jD)})}},uO=(e,t)=>{let n=new Map;return e.forEach(r),n;function r(e){if(sD(Z(e)?e.schema:e))return;let r=t(e),i=n.get(r);i===void 0?n.set(r,[e]):i.push(e)}},dO=class extends j()(`effect/httpapi/HttpApi/AdditionalSchemas`){},fO=class extends j()(`effect/httpapi/HttpApi/ParseOptions`){},pO=zT({status:400}),mO=`~effect/httpapi/HttpApiError/HttpApiSchemaError`,hO=class e extends Zs(`HttpApiSchemaError`){[mO]=mO;static is(e){return w(e,mO)}static wrap(t,n){return Sm(n,n=>new e({kind:t,cause:n}))}name=`HttpApiSchemaError`;message=this.kind;[XT](){return B(pO)}},gO=`~effect/httpapi/HttpApiMiddleware`,_O=`~effect/httpapi/HttpApiMiddleware/Security`,vO=e=>w(e,_O),yO=()=>(e,t)=>{let n=Qr(),r;n!==0&&($r(2),r=new globalThis.Error,$r(n));class i extends j()(e){}let a=i;if(Object.defineProperty(i,"stack",{get(){return r?.stack}}),a[gO]=gO,a.error=bO(t?.error),a.requiredForClient=t?.requiredForClient??!1,t?.security!==void 0){if(Object.keys(t.security).length===0)throw Error(`HttpApiMiddleware.Service: security object must not be empty`);a[_O]=_O,a.security=t.security}return a};function bO(e){return e===void 0?new Set:new Set(Array.isArray(e)?e:[e])}var xO=(e,t)=>Qf(e,(e,n)=>Kp(e,e=>hO.is(e)?t(e,n):V(e))),SO=new Set;function CO(e){if(e===void 0)return SO;let t=L_(e.ast);return yg(t)&&t.indexSignatures.length===0?new Set(t.propertySignatures.map(e=>String(e.name))):void 0}function wO(e,t){if(t===void 0||!e.includes(`:`))return e;let n=CO(t);if(n===void 0)return e;let r=``,i=0,a=-1;for(let t=0;t<e.length;t++){let o=e[t];if(i>0||t===a){r+=o,o===`\\`?r+=e[++t]??``:o===`(`?i++:o===`)`&&i--;continue}if(o!==`:`){r+=o;continue}if(e[t+1]===`:`){r+=`::`,t++;continue}let s=/^:(\w+)/.exec(e.slice(t));if(s!==null&&n.has(s[1])){r+=s[0],t+=s[0].length-1;let n=e[t+1];n===`(`?a=t+1:n!==void 0&&!`/.-?`.includes(n)&&(r+=`(.*?)`)}else r+=`::`}return r}var TO=class extends j()(`effect/httpapi/OpenApi/Identifier`){},EO=class extends j()(`effect/httpapi/OpenApi/Title`){},DO=class extends j()(`effect/httpapi/OpenApi/Version`){},OO=class extends j()(`effect/httpapi/OpenApi/Description`){},kO=class extends j()(`effect/httpapi/OpenApi/License`){},AO=class extends j()(`effect/httpapi/OpenApi/ExternalDocs`){},jO=class extends j()(`effect/httpapi/OpenApi/Servers`){},MO=class extends j()(`effect/httpapi/OpenApi/Format`){},NO=class extends j()(`effect/httpapi/OpenApi/Summary`){},PO=class extends j()(`effect/httpapi/OpenApi/Deprecated`){},FO=class extends j()(`effect/httpapi/OpenApi/Override`){},IO=M(`effect/httpapi/OpenApi/Exclude`,{defaultValue:Tn}),LO=class extends j()(`effect/httpapi/OpenApi/Transform`){},RO={},zO=new WeakMap,BO=e=>{if(Array.isArray(e))return e.map(BO);if(typeof e==`object`&&e&&!Object.isFrozen(e)){let t={};for(let n of Object.keys(e))E(t,n,BO(e[n]));return t}return e};function Q(e,t,n){let r=rs(e,t);wa(r)&&n(r.value)}function VO(e,t){let n=t??RO,r=zO.get(n);r===void 0&&(r=new WeakMap,zO.set(n,r));let i=r.get(e);if(i!==void 0)return BO(i);let a=HO(e,n);return r.set(e,BO(a)),a}function HO(e,t){let n={openapi:`3.1.0`,info:{title:`Api`,version:`0.0.1`},paths:{},components:{schemas:{},securitySchemes:{}},security:[],tags:[]},r=[],i=new Set,a=new Set,o=[];Q(e.annotations,EO,e=>{n.info.title=e}),Q(e.annotations,DO,e=>{n.info.version=e}),Q(e.annotations,OO,e=>{n.info.description=e}),Q(e.annotations,kO,e=>{n.info.license=e}),Q(e.annotations,NO,e=>{n.info.summary=e}),Q(e.annotations,jO,e=>{n.servers=[...e]}),lO(e,{onGroup({group:e}){if($o(e.annotations,IO))return;let t={name:Yo(e.annotations,EO,()=>e.identifier)};Q(e.annotations,OO,e=>{t.description=e}),Q(e.annotations,AO,e=>{t.externalDocs=e}),Q(e.annotations,FO,e=>{for(let[n,r]of Object.entries(e))E(t,n,r)}),Q(e.annotations,LO,e=>{t=e(t)}),n.tags.push(t)},onEndpoint({endpoint:e,group:t,mergedAnnotations:s,middleware:c}){if($o(s,IO))return;let l={tags:[Yo(t.annotations,EO,()=>t.identifier)],operationId:Yo(e.annotations,TO,()=>t.topLevel?e.identifier:`${t.identifier}.${e.identifier}`),parameters:[],security:[],responses:{}},u=CO(e.params),d=e.path.replace(/:(\w+)\??/g,(e,t)=>u===void 0||u.has(t)?`{${t}}`:e),f=e.method.toLowerCase(),p=f===`query`,m=p?`QUERY`:f,h=p?[`paths`,d,`x-oai-additionalOperations`,m]:[`paths`,d,m];function g(e,t){for(let[n,{content:i,descriptions:a,headers:o,streamContent:s}]of e){let e=a.size>0?Array.from(a).join(` | `):t();E(l.responses,n,{description:e});for(let e of o){let t=L_(e.ast);if(yg(t))for(let e of t.propertySignatures){let t=String(e.name).toLowerCase();t!==`content-type`&&(l.responses[n].headers??={},E(l.responses[n].headers,t,{schema:{},required:!nv(e.type)}),r.push({_tag:`parameter`,ast:e.type,path:[...h,`responses`,String(n),`headers`,t,`schema`]}))}}i!==void 0&&i.forEach((e,t)=>{e.forEach((e,i)=>{let a=Array.from(e,c_),o=a.length===1?a[0]:new b_(a);r.push({_tag:`schema`,ast:JO(o,t),path:[...h,`responses`,String(n),`content`,i,`schema`]}),l.responses[n].content??={},E(l.responses[n].content,i,{schema:{}})})}),s!==void 0&&s.forEach((e,t)=>{l.responses[n].content??={},cD(e)?(r.push({_tag:`schema`,ast:c_(e.events),path:[...h,`responses`,String(n),`content`,t,`schema`]}),r.push({_tag:`schema`,ast:c_(JC(LC(e.error,AC()))),path:[...h,`responses`,String(n),`content`,t,`x-effect-stream`,`causeSchema`]}),r.push({_tag:`schema`,ast:c_(e.error),path:[...h,`responses`,String(n),`content`,t,`x-effect-stream`,`errorSchema`]}),E(l.responses[n].content,t,{schema:{},"x-effect-stream":{encoding:`sse`,causeSchema:{},errorSchema:{},failureEvent:UO}})):E(l.responses[n].content,t,{schema:{type:`string`,format:`binary`},"x-effect-stream":{encoding:`uint8array`}})})}}function _(e,t){if(e){let n=L_(e.ast);if(yg(n))for(let e of n.propertySignatures)l.parameters.push({name:String(e.name),in:t,schema:{},required:t===`path`||!nv(e.type)}),r.push({_tag:`parameter`,ast:e.type,path:[...h,`parameters`,String(l.parameters.length-1),`schema`]})}}Q(e.annotations,OO,e=>{l.description=e}),Q(e.annotations,NO,e=>{l.summary=e}),Q(e.annotations,PO,e=>{l.deprecated=e}),Q(e.annotations,AO,e=>{l.externalDocs=e}),c.forEach(e=>{if(vO(e))for(let[t,n]of Object.entries(e.security))ee(t,n),l.security.push({[t]:[]})});function ee(e,t){let r=XO(t);if(!Object.hasOwn(n.components.securitySchemes,e)){E(n.components.securitySchemes,e,r);return}if(!lr(ZO(n.components.securitySchemes[e]),ZO(r)))throw new globalThis.Error(`Conflicting OpenAPI security scheme: ${e}`)}let v=rT(e.method);if(v){let t=new Map;for(let n of PD(e)){if(vD(n.ast))continue;let r=TD(n.ast,e.method),i=t.get(r.contentType);i===void 0?t.set(r.contentType,{encoding:r,schemas:[n]}):i.schemas.push(n)}if(t.size>0){let e={};for(let[n,{encoding:i,schemas:a}]of t){let t=a.map(c_),o=t.length===1?t[0]:new b_(t);r.push({_tag:`schema`,ast:JO(o,i._tag),path:[...h,`requestBody`,`content`,n,`schema`]}),E(e,n,{schema:{}})}l.requestBody={content:e,required:!0}}}if(_(e.params,`path`),!v&&e.payload.size===1){let t=e.payload.values().next().value;_(t.schemas[0],`query`)}_(e.headers,`header`),_(e.query,`query`),g(WO(e),()=>`Success`),g(GO(ID(e),jD,KO),()=>`Error`);let te=`${f} ${d.replace(/\{[^}]+\}/g,`{}`)}`;if(i.has(te))throw new globalThis.Error(`Duplicate OpenAPI operation for ${e.method} ${d}`);i.add(te),Object.hasOwn(n.paths,d)||E(n.paths,d,{});let ne=()=>{let e=n.paths[d];return p?e[`x-oai-additionalOperations`]??={}:e};ne()[m]=l,o.push(()=>{let t=ne(),n=t[m];Q(e.annotations,FO,e=>{for(let[t,r]of Object.entries(e))E(n,t,r)}),Q(e.annotations,LO,e=>{n=e(n)});let r=n.operationId;if(r!==void 0){if(a.has(r))throw new globalThis.Error(`Duplicate OpenAPI operationId: ${r}`);a.add(r)}t[m]=n})}}),Q(e.annotations,dO,e=>{e.forEach(e=>{let t=Tv(e.ast);if(t!==void 0){if(Object.hasOwn(n.components.schemas,t))throw new globalThis.Error(`Duplicate component schema identifier: ${t}`);E(n.components.schemas,t,{}),r.push({_tag:`schema`,ast:e.ast,path:[`components`,`schemas`,t]})}})});function s(e){return`/`+e.map(jb).join(`/`)}if(Ya(r)){let e=Rb(jx(Px($a(r,e=>Xb(e.ast)),t),{onExcessProperty:`error`})),i=r.map((t,n)=>({op:`replace`,path:s(t.path),value:e.schemas[n]}));Object.entries(e.definitions).forEach(([e,t])=>{i.push({op:`add`,path:s([`components`,`schemas`,e]),value:t})}),n=Fx(i,n)}for(let e of o)e();return Object.keys(n.components.schemas).forEach(e=>{if(!zb.test(e))throw new globalThis.Error(`Invalid component schema key: ${e}`)}),Q(e.annotations,FO,e=>{for(let[t,r]of Object.entries(e))E(n,t,r)}),Q(e.annotations,LO,e=>{n=e(n)}),n}var UO=`effect/httpapi/stream/failure`;function WO(e){return GO(FD(e),OD,KO)}function GO(e,t,n){let r=new Map;return e.forEach(i),r;function i(e){let i=bD(e.ast),c=Z(e)?e.schema:i?.body??e,l=Z(e)?e.headers:i?.headersCodec,u=t(e),d=c.ast;sD(c)?s(c,u):vD(d)?a(u,n(e.ast)??n(d)??`<No Content>`):o(c,u,kD(e),n(e.ast)??n(d)),l!==void 0&&r.get(u).headers.push(l)}function a(e,t){let n=r.get(e);n===void 0?r.set(e,{descriptions:new Set([t]),content:void 0,headers:[],streamContent:void 0}):t!==void 0&&n.descriptions.add(t)}function o(e,t,n,i){let a=r.get(t),{_tag:o,contentType:s}=n;if(a===void 0)r.set(t,{descriptions:new Set(i===void 0?[]:[i]),content:new Map([[o,new Map([[s,new Set([e])]])]]),headers:[],streamContent:void 0});else if(i!==void 0&&a.descriptions.add(i),a.content===void 0)a.content=new Map([[o,new Map([[s,new Set([e])]])]]);else{let t=a.content.get(o);if(t===void 0)a.content.set(o,new Map([[s,new Set([e])]]));else{let n=t.get(s);n===void 0?t.set(s,new Set([e])):n.add(e)}}}function s(e,t){let n=r.get(t);n===void 0?r.set(t,{descriptions:new Set,content:void 0,headers:[],streamContent:new Map([[e.contentType,e]])}):n.streamContent===void 0?n.streamContent=new Map([[e.contentType,e]]):n.streamContent.set(e.contentType,e)}}function KO(e){return Ev(e)??Tv(e)}var qO=J.annotate({format:`binary`});function JO(e,t){switch(t){case`Uint8Array`:return qO.ast;case`Text`:return J.ast;case`FormUrlEncoded`:case`Json`:return e;case`Multipart`:return YO(e)}}function YO(e){return fg(e)&&e.annotations?.representation?.id===`effect/http/PersistedFile`?qO.ast:typeof e?.recur==`function`?e.recur(YO):e}var XO=e=>{let t={};switch(Q(e.annotations,OO,e=>{t.description=e}),e._tag){case`Basic`:return{...t,type:`http`,scheme:`basic`};case`Http`:{let n=rs(e.annotations,MO).pipe(ka(e=>({bearerFormat:e})),Oa);return{...t,type:`http`,scheme:e.scheme,...n}}case`ApiKey`:return{...t,type:`apiKey`,name:e.key,in:e.in}}},ZO=e=>e.type===`http`?{...e,scheme:e.scheme.toLowerCase()}:e.in===`header`?{...e,name:e.name.toLowerCase()}:e,QO=(e,t)=>kE(bm(function*(n){let r=yield*em(),i=[],a=Array.from(r.mapUnsafe.keys()).filter(e=>e.startsWith(`effect/httpapi/HttpApiGroup/`)),o=Object.values(e.groups);for(let e of o){let t=r.mapUnsafe.get(e.key)?.routes;if(t===void 0){let t=a.length===0?`none`:a.join(`, `);return yield*Fp(`HttpApiGroup "${e.identifier}" not found (key: "${e.key}"). Did you forget to provide HttpApiBuilder.group(api, "${e.identifier}", ...)? Available groups: ${t}`)}i.push(...t)}if(yield*n.addAll(i),t?.openapiPath){let r=On(e=>UT(VO(e)));yield*n.add(`GET`,t.openapiPath,Ap(()=>r(e)))}})),$O=(e,t,n)=>rp(Mp(function*(){let r=(yield*em()).pipe(os(jf)),i=e.groups[t],a=n(ok(i)),o=Ep(a)?yield*a:a,s=[];for(let t of o.handlers.values())s.push(uk(e,i,t,r));return zo(new Map([[i.key,{routes:s,handlers:o.handlers}]]))})),ek=`~effect/httpapi/HttpApiBuilder/Handlers`,tk=e=>{switch(e._tag){case`Http`:return U(iE,t=>Yx(rk(t.headers.authorization,e.scheme)??``));case`ApiKey`:{let t=e.in===`header`?e.key.toLowerCase():e.key,n=Y({[t]:J});return Qp(e.in===`query`?cE(n):e.in===`cookie`?oE(n):sE(n),{onFailure:()=>Yx(``),onSuccess:e=>Yx(e[t])})}case`Basic`:{let e={username:``,password:Yx(``)};return U(iE,t=>{let n=rk(t.headers.authorization,nk);if(n===void 0)return e;let r=La(rc(n));if(r===void 0)return e;let i=r.indexOf(`:`);return i===-1?e:{username:r.slice(0,i),password:Yx(r.slice(i+1))}})}}},nk=`Basic`;function rk(e,t){let n=t.length;if(e===void 0||e.length<=n||e.charCodeAt(n)!==32||e.slice(0,n).toLowerCase()!==t.toLowerCase())return;let r=n+1;for(;e.charCodeAt(r)===32;)r++;return r===e.length?void 0:e.slice(r)}var ik=(e,t,n,r,i)=>{if(!Object.hasOwn(e.group.endpoints,t))throw Error(`HttpApiEndpoint "${t}" not found in HttpApiGroup "${e.group.identifier}"`);if(e.handlers.has(t))throw Error(`Handler for HttpApiEndpoint "${t}" is already registered in HttpApiGroup "${e.group.identifier}"`);let a=e.group.endpoints[t];return e.handlers.set(t,{endpoint:a,handler:n,isRaw:r,uninterruptible:i?.uninterruptible??!1}),e},ak={[ek]:ek,pipe(){return x(this,arguments)},handle(e,t,n){return ik(this,e,t,!1,n)},handleAll(e){for(let[t,n]of Object.entries(e)){let e=typeof n==`function`?n:n.handler,r=typeof n==`function`?void 0:n.options;ik(this,t,e,!1,r)}return this},handleRaw(e,t,n){return ik(this,e,t,!0,n)}},ok=e=>{let t=Object.create(ak);return t.group=e,t.handlers=new Map,t};function sk(e,t){let n=new Map;return e.forEach(({encoding:e,schemas:r},i)=>{let a=KS(_C(r),t);e._tag===`Multipart`?n.set(i,{_tag:`Multipart`,mode:e.mode,limits:e.limits,decode:a}):n.set(i,{_tag:e._tag,decode:a,nullOnEmpty:r.some(e=>pg(sv(e.ast)))})}),n}function ck(e,t,n){let r=rT(t.method),i=r?MD(t.headers[`content-type`]??`application/json`):`application/x-www-form-urlencoded`,a=e.get(i);if(!a)return HT(`Unsupported content-type: ${i}`,{status:415});let{_tag:o,decode:s}=a;switch(o){case`Multipart`:if(a.mode===`buffered`){let e=Xp(t.multipart);return a.limits&&(e=rm(e,$T(a.limits))),H(e,s)}return B(a.limits?vw(t.multipartStream,$T(a.limits)):t.multipartStream);case`Json`:return H(Xp(t.text),e=>{if(e===``)return s(a.nullOnEmpty?null:void 0);try{return s(JSON.parse(e))}catch{return V(new BS(new $m({message:`Expected a valid JSON body`})))}});case`Text`:return H(Xp(t.text),s);case`FormUrlEncoded`:return H(r?U(Xp(t.urlParamsBody),FS):B(n),s);case`Uint8Array`:return H(U(Xp(t.arrayBuffer),e=>new Uint8Array(e)),s)}}function lk(e,t,n,r,i,a){let o=Xo(is(is(e.annotations,t.annotations),n.annotations),fO),s=e=>KS(e,o),c=XS(Ak(n),o),l=XS(jk(n),o),u=Cw(n.params,s),d=Cw(n.headers,s),f=Cw(n.query,e=>s(XC(e))),p=yk(n,o),m=vk(n,o),h=n.payload.size>0&&!a?sk(n.payload,o):void 0;return dk(t,n,r,Mp(function*(){let e=Rv().context,r=Qo(e,iE),a=Qo(e,OE),o=Qo(e,aE),s={request:r,endpoint:n,group:t};if(u&&(s.params=yield*hO.wrap(`Params`,u(a.params))),d&&(s.headers=yield*hO.wrap(`Headers`,d(r.headers))),f&&(s.query=yield*hO.wrap(`Query`,f(o))),h){let e=ck(h,r,o);if(RT(e))return e;e!==void 0&&(s.payload=yield*hO.wrap(`Payload`,e))}let l=yield*i(s);if(RT(l))return l;let g;m!==void 0&&fD(l)&&(g=l.headers,l=l.body);let _=yield*hO.wrap(`Body`,p?.(l,e)??(g===void 0?c(l):m.encodeBody(l)));return m===void 0||g===void 0?_:qT(_,yield*hO.wrap(`ResponseHeaders`,m.encodeHeaders.get(_.status)(g)))})).pipe(Zp,Kp(e=>hO.is(e)?Fp(e):Xp(l(e))),rm(r))}function uk(e,t,n,r){let i=n.endpoint;return ME(i.method,wO(i.path,i.params),lk(e,t,i,r,n.handler,n.isRaw),{uninterruptible:n.uninterruptible})}var dk=(e,t,n,r)=>{let i={group:e,endpoint:t};for(let e of t.middlewares){let t=e,a=Qo(n,t);r=(vO(t)?pk(t,a):a)(r,i)}return r},fk=new WeakMap,pk=(e,t)=>{let n=fk.get(t);if(n!==void 0)return n;let r=Object.entries(e.security).map(([e,n])=>({decode:tk(n),middleware:t[e]}));if(r.length===0)return C;let i=bm(function*(e,t){e=Yp(e,e=>new hk(e));let n;for(let i=0;i<r.length;i++){let{decode:a,middleware:o}=r[i],s=yield*Hp(H(a,n=>o(e,{credential:n,endpoint:t.endpoint,group:t.group})));if(Na(s)){if(gk(s.failure))return yield*V(s.failure.error);n=s;continue}return s.success}return yield*Rp(n)});return fk.set(t,i),i},mk=`~effect/httpapi/HttpApiBuilder/HandlerError`,hk=class{[mk]=mk;error;constructor(e){this.error=e}},gk=e=>w(e,mk),_k=zS(RT);function vk(e,t){let n=new Map,r=[];for(let i of e.success)Z(i)&&(n.set(OD(i),XS(i.headers,t)),sD(i.schema)||r.push(Dk(i)));return n.size===0?void 0:{encodeBody:XS(r.length===0?nC:r.length===1?r[0]:_C(r),t),encodeHeaders:n}}function yk(e,t){let n=bk(e);if(n===void 0)return;let r=n.body,i=xk(e),a=OD(n.schema),o=r.contentType;if(lD(r))return(e,t)=>iw(e)?B(GT(vw(e,t),{status:a,contentType:o})):i?void 0:new BS(new $m({message:`Expected a streaming response`}));let s=Sk(r,t);return(e,t)=>iw(e)?B(GT(vw(Ck(e,s),t),{status:a,contentType:o})):i?void 0:new BS(new $m({message:`Expected a streaming response`}))}function bk(e){for(let t of e.success){let e=Z(t)?t.schema:t;if(sD(e))return{schema:t,body:e}}}function xk(e){for(let t of e.success){let e=Z(t)?t.schema:t;if(ZS(e)&&!sD(e))return!0}return e.success.size===0}function Sk(e,t){let n=JC(LC(e.error,AC()));return{sseMode:e.sseMode,encodeEvents:XS(mC(e.events),t),encodeCause:XS(MC(n),t)}}function Ck(e,t){return e.pipe(t.sseMode===`data`?dw(e=>({id:void 0,event:`message`,data:e})):C,fw(e=>Xp(t.encodeEvents(e))),pw(e=>ow(wk(e,t))),dw(Ek),gw)}function wk(e,t){return t.encodeCause(e).pipe(Xp,U(e=>({id:void 0,event:Tk,data:e})))}var Tk=`effect/httpapi/stream/failure`;function Ek(e){return tD.write({_tag:`Event`,event:e.event,id:e.id,data:e.data})}var Dk=Mk(OD),Ok=Mk(jD);function kk(e){if(!Z(e))return Ok(e);let t=XS(e.schema),n=XS(e.headers),r=Fk(jD(e),kD(e),vD(e.schema.ast)),i=Pk((e,n)=>t(e,n).pipe(Yp(e=>e.issue),H(e=>r(e,n))),n);return _k.pipe(X(e,i))}function Ak(e){let t=FD(e).map(Dk);return t.length===1?t[0]:_C(t)}function jk(e){let t=ID(e).map(kk);return t.length===0?nC:t.length===1?t[0]:_C(t)}function Mk(e){let t=new WeakMap;return n=>{let r=Z(n)?n:n.ast,i=t.get(r);if(i!==void 0)return i;let a=Z(n)?n.schema:n,o=_k.pipe(X(a,Nk(e,n)));return t.set(r,o),o}}function Nk(e,t){let n=bD(t.ast);if(n!==void 0)return Pk(Fk(e(n.body),ED(n.body.ast),vD(n.body.ast)),XS(n.headersCodec));let r=Z(t)?t.schema:t;return Zh({decode:(e,t)=>V(new th({message:`Encode only schema`},e,t)),encode:Fk(e(t),kD(t),vD(r.ast))})}function Pk(e,t){return Zh({decode:(e,t)=>V(new th({message:`Encode only schema`},e,t)),encode:(n,r)=>{let i=n;return H(e(i.body,r),e=>U(t(i.headers,r).pipe(Yp(e=>e.issue)),t=>qT(e,t)))}})}function Fk(e,t,n){switch(t._tag){case`Json`:return(r,i)=>{if(r===void 0||n)return B(zT({status:e}));try{return B(HT(JSON.stringify(r),{status:e,contentType:t.contentType}))}catch{return V(new $m({expected:`a JSON-serializable response body`},r,i))}};case`Text`:return n=>B(HT(n,{status:e,contentType:t.contentType}));case`Uint8Array`:return n=>B(BT(n,{status:e,contentType:t.contentType}));case`FormUrlEncoded`:return n=>B(WT(n,{status:e}).pipe(KT(`content-type`,t.contentType)))}}var Ik=(e,t)=>Mp(function*(){let n=yield*em(),r=t.httpClient.pipe(t?.baseUrl===void 0?C:vE(xT(t.baseUrl.toString())));function i(e,t,a,o,s){if(s===-1)return r.execute(a);let c=n.mapUnsafe.get(o[s]);return c===void 0?i(e,t,a,o,s-1):c({endpoint:t,group:e,request:a,next(n){return i(e,t,n,o,s-1)}})}lO(e,{predicate:t?.predicate,onGroup(e){t.onGroup?.(e)},onEndpoint(e){let{group:n,endpoint:r,errors:a,successes:o,mergedAnnotations:s}=e,c=Xo(s,fO),l=Bk(r.path,r.params),u={orElse:aA},d=new Map;for(let[e,t]of a.entries()){let n=Gk(t);for(let[t,r]of n.entries())Uk(d,e,t,Vk(r,c))}for(let[e,t]of d.entries()){let n=Wk(t);u[e]=e=>H(Jp(n(e),t=>Np(hf(lf(new Yw({reason:new eT({request:e.request,response:e})})),t))),V)}let f=new Map;for(let[e,t]of o.entries()){let n=Gk(t);for(let[t,r]of n.entries())Uk(f,e,t,Vk(r,c))}for(let e of Yk(r)){let t=Jk(e)?e.schema:e;Uk(f,OD(e),t.contentType,Xk(e,c))}for(let[e,t]of f.entries())u[e]=Wk(t);let p=e=>XS(e,c),m=Cw(r.params,p),h=PD(r),g=Ya(h)?rT(r.method)?p(sA(h,r.method)):p(_C(h)):void 0,_=Cw(r.headers,p),ee=Cw(r.query,p),v=Array.from(e.middleware,e=>`${e.key}/Client`),te=bm(function*(e){let a=pT(r.method)(r.path);if(e!==void 0){if(m!==void 0){let t=yield*m(e.params);a=bT(a,l(t))}if(g!==void 0){if(rT(r.method)){if(e.payload instanceof FormData)a=DT(a,e.payload);else{let t=yield*g(e.payload);a=ET(a,t)}}else{let t=yield*g(e.payload);a=wT(a,t)}}if(_!==void 0){let t=yield*_(e.headers);a=_T(a,t)}if(ee!==void 0){let t=yield*ee(e.query);a=wT(a,t)}}let o=yield*i(n,r,a,v,v.length-1);if(e?.responseMode===`response-only`)return o;let s=(u[o.status]??u.orElse)(o,e?.sseOptions),c=yield*t.transformResponse===void 0?s:t.transformResponse(s);return e?.responseMode===`decoded-and-response`?[c,o]:c});t.onEndpoint({...e,endpointFn:te})}})}),Lk=(e,t)=>H(pE,n=>Rk(e,{...t,httpClient:t?.transformClient?t.transformClient(n):n})),Rk=(e,t)=>{let n={};return Ik(e,{...t,onGroup({group:e}){e.topLevel||E(n,e.identifier,{})},onEndpoint({endpoint:e,endpointFn:t,group:r}){E(r.topLevel?n:n[r.identifier],e.identifier,t)}}).pipe(Wp(n))},zk=/(\/?):(\w+)(\?)?/g,Bk=(e,t)=>{if(t===void 0||!e.includes(`:`))return t=>e;let n=CO(t);return t=>e.replace(zk,(e,r,i,a)=>{if(n!==void 0&&!n.has(i))return e;let o=t[i];if(o===void 0){if(a!==void 0)return``;throw Error(`Missing path parameter: ${i}`)}return`${r}${encodeURIComponent(o)}`})};function Vk(e,t){let n=e.some(e=>Z(e)||bD(e.ast)!==void 0),r=qS(n?_C(e.map(Hk)):rA(e),t);return e=>H(e.arrayBuffer,n?t=>r({body:t,headers:e.headers}):r)}function Hk(e){let t=Z(e),n=bD(e.ast);if(n!==void 0)return Y({body:iA(n.body),headers:n.headersCodec}).pipe(X(e));let r=t?e.schema:e;return Y({body:iA(r).pipe(X(r)),headers:t?e.headers:rC}).pipe(X(t?e:$S(e),Qh({decode:e=>t?pD(e):e.body,encode:e=>t?e:{body:e,headers:void 0}})))}function Uk(e,t,n,r){let i=MD(n),a=e.get(t);a===void 0?e.set(t,[{contentType:i,decode:r}]):a.push({contentType:i,decode:r})}function Wk(e){let t=e[0];return e.length===1&&t!==void 0?t.decode:(t,n)=>{let r=MD(t.headers[`content-type`]??``),i=e.find(e=>e.contentType===r);return i===void 0?Kk(t,r,e):i.decode(t,n)}}function Gk(e){let t=new Map;for(let n of e){let e=vD((Z(n)?n.schema:n).ast)?``:MD(kD(n).contentType),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return t}function Kk(e,t,n){let r=Array.from(new Set(n.map(e=>e.contentType))).join(`, `);return V(new Yw({reason:new tT({request:e.request,response:e,description:`Unsupported response content-type for status ${e.status}: ${t||`<missing>`}. Expected one of: ${r}`})}))}var qk=`effect/httpapi/stream/failure`,Jk=e=>Z(e);function Yk(e){let t=[];for(let n of e.success)sD(Z(n)?n.schema:n)&&t.push(n);return t}function Xk(e,t){let n=Jk(e),r=n?e.schema:e,i=lD(r)?void 0:{declaration:r,decoder:Zk(r,t)},a=(e,t)=>U(em(),n=>vw(i===void 0?e.stream:Qk(e.stream,i.declaration,i.decoder(t)),n));if(!n)return a;let o=KS(e.headers,t);return(e,t)=>H(o(e.headers),n=>U(a(e,t),e=>pD({body:e,headers:n})))}function Zk(e,t){let n=_C([Y({id:QS(J),event:tC(qk),data:MC(JC(LC(e.error,AC())))}),e.events]),r=JE(n,void 0,t);return e=>e===void 0?r:JE(n,e,t)}function Qk(e,t,n){let r=sw(e.pipe(hw,mw(n)),e=>Ap(()=>{let t;return kp(()=>t===void 0?H(e,e=>{for(let n=0;n<e.length;n++){let r=e[n];if(r.event===qk&&af(r.data)){if(n===0)return Np(r.data);t=r.data,e=e.slice(0,n);break}}return B(e)}):Np(t))}));return t.sseMode===`data`?dw(r,e=>e.data):r}var $k=wC(globalThis.ArrayBuffer,{expected:`ArrayBuffer`}),eA=$k.pipe(X(FC,Qh({decode(e){return new Uint8Array(e)},encode(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}}))),tA=$k.pipe(X(J,Qh({decode(e){return new TextDecoder().decode(e)},encode(e){let t=new TextEncoder().encode(e);return t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}}))),nA=tA.pipe(X(_C([tC(``).pipe(X(aC,Qh({decode:()=>void 0,encode:()=>``}))),NC])));function rA(e){return _C(e.map(t));function t(e){return iA(e).pipe(X(e))}}function iA(e){switch(ED(e.ast)._tag){case`Json`:return pg(sv(e.ast))?nA.pipe(X(rC,Qh({decode:e=>e===void 0?null:e,encode:e=>e===null?void 0:e}))):nA;case`FormUrlEncoded`:return tA.pipe(X(RC,Qh({decode:e=>ES(new URLSearchParams(e)),encode:PS})));case`Uint8Array`:return eA;case`Text`:return tA}}var aA=e=>V(new Yw({reason:new tT({request:e.request,response:e})})),oA=zS(Nw);function sA(e,t){return _C(e.map(e=>lA(e,t)))}var cA=new WeakMap;function lA(e,t){let n=e.ast,r=cA.get(n);if(r!==void 0)return r;let i=TD(n,t),a=oA.pipe(X(e,Zh({decode(e,t){return V(new th({message:`Encode only schema`},e,t))},encode(e,t){switch(i._tag){case`Multipart`:return V(new th({message:`Payload must be a FormData`},e,t));case`Json`:try{return B(Vw(JSON.stringify(e),i.contentType))}catch{return V(new $m({expected:`a JSON-serializable request body`},e,t))}case`Text`:return typeof e==`string`?B(Vw(e,i.contentType)):V(new $m({message:`Expected a string`},e,t));case`FormUrlEncoded`:return Vn(e)?B(Uw(ES(e),i.contentType)):V(new $m({message:`Expected a record`},e,t));case`Uint8Array`:return e instanceof Uint8Array?B(Lw(e,i.contentType)):V(new $m({message:`Expected a Uint8Array`},e,t))}}})));return cA.set(n,a),a}var uA=`~effect/httpapi/HttpApiGroup`,dA={[uA]:uA,add(...e){let t={...this.endpoints};for(let n of e)E(t,n.identifier,n);return pA({...fA(this),endpoints:t})},prefix(e){return pA({...fA(this),endpoints:Ba(this.endpoints,t=>t.prefix(e))})},middleware(e){return pA({...fA(this),endpoints:Ba(this.endpoints,t=>t.middleware(e))})},annotateMerge(e){return pA({...fA(this),annotations:is(this.annotations,e)})},annotate(e,t){return pA({...fA(this),annotations:qo(this.annotations,e,t)})},annotateEndpointsMerge(e){return pA({...fA(this),endpoints:Ba(this.endpoints,t=>t.annotateMerge(e))})},annotateEndpoints(e,t){return pA({...fA(this),endpoints:Ba(this.endpoints,n=>n.annotate(e,t))})},pipe(){return x(this,arguments)}},fA=e=>({identifier:e.identifier,topLevel:e.topLevel,endpoints:e.endpoints,annotations:e.annotations}),pA=e=>{function t(){}return Object.setPrototypeOf(t,dA),t.key=`effect/httpapi/HttpApiGroup/${e.identifier}`,Object.assign(t,e)},mA=(e,t)=>pA({identifier:e,topLevel:t?.topLevel??!1,endpoints:{},annotations:Wo()}),hA=e=>e.actions.filter(e=>e.http),gA=(e,t,n)=>rO(n.name,`${e}/${t.name}/${n.name}`,{payload:n.input,success:n.success,error:n.errors}).annotate(OO,n.description),_A=(e,t)=>{class n extends yO()(`effect-actions/http/SchemaErrors/${e}`,{error:t.errors}){}return{SchemaErrors:n,layer:xO(n,e=>V(t.map(e)))}};function vA(e,t){let[n,...r]=hA(t).map(n=>gA(e.apiPath,t,n));if(n===void 0)return;let i=mA(t.name).add(n,...r);if(t.schemaError===void 0)return{native:i,policy:ep};let a=_A(t.name,t.schemaError);return{native:i.middleware(a.SchemaErrors),policy:a.layer}}function yA(e){let[t,...n]=e,r=cO(`actions`).annotate(fO,{errors:`all`});return t===void 0?r:r.add(t,...n)}var bA=e=>e,xA=(e,t,n)=>{let r=e=>Object.fromEntries(hA(t.group).map(n=>[n.name,r=>Aw(t.group,n,e)(r.payload)]));return op(U(t.build,n=>$O(e,t.group.name,e=>e.handleAll(r(bA(n)))))).pipe(up(n))};function SA(e,...t){Ew(`action group`,t.map(e=>e.name));let n=new Map(t.flatMap(t=>{let n=vA(e,t);return n===void 0?[]:[[t,n]]})),r=(...e)=>{Ew(`implementation group`,e.map(e=>e.group.name));for(let n of e)if(!t.includes(n.group))throw Error(`Implementation of group "${n.group.name}" is not served by this adapter`);let r=e.flatMap(e=>{let t=n.get(e.group);return t===void 0?[]:[{app:e,...t}]}),i=yA(r.map(({native:e})=>e));return r.reduce((e,{app:t,policy:n})=>e.pipe(up(xA(i,t,n))),QO(i))};return{groups:t,api:yA([...n.values()].map(({native:e})=>e)),layer:r}}var CA=class extends qC()(`BadRequest`,{error:J},{httpApiStatus:400}){},wA=class extends qC()(`Unauthorized`,{error:J},{httpApiStatus:401}){},TA=class extends qC()(`Forbidden`,{error:J},{httpApiStatus:403}){},EA=class extends qC()(`NotFound`,{error:J},{httpApiStatus:404}){},DA=class extends qC()(`Conflict`,{error:J},{httpApiStatus:409}){},OA=class extends qC()(`TooManyRequests`,{error:J},{httpApiStatus:429}){},kA=class extends qC()(`InternalServerError`,{error:J},{httpApiStatus:500}){},AA=[CA,wA,TA,EA,DA,OA,kA,class extends qC()(`ServiceUnavailable`,{error:J},{httpApiStatus:503}){}],jA=Y({email:J,password:J}),MA=vC([`none`,`client_secret_basic`,`client_secret_post`]),NA=vC([`web`,`native`]),PA=Y({client_name:J,redirect_uris:mC(J),resources:mC(J),token_endpoint_auth_method:MA,application_type:NA}),FA=Y({client_id:J,client_name:J,redirect_uris:mC(J),application_type:NA}),IA=Y({client_id:J}),LA=Y({client_id:J,blocked:sC}),RA=Y({onboarding:QS(vC([`managed`,`dcr`,`cimd`])),blocked:QS(sC),client_id:J,client_name:QS(J),redirect_uris:mC(J),token_endpoint_auth_method:QS(J),application_type:QS(yC(J)),scope:QS(J),grant_types:QS(mC(J))}),zA=RA.pipe(uC({client_secret:QS(J),client_secret_expires_at:QS(oC)})),BA=Y({identifier:J,name:J,scopes:mC(J)}),VA=BA.pipe(uC({builtIn:sC})),HA=Y({identifier:J}),UA=Y({client_id:J,resource:J}),WA=Y({client_id:J,resources:mC(J)}),GA=Y({clientAccess:mC(UA)}),KA=dC(J,mC(J)),qA=Y({name:J,permissions:KA,expiresAt:yC(J)}),JA=Y({keyId:J}),YA=Y({keyId:J,name:QS(J),permissions:QS(KA),enabled:QS(sC)}),XA=Y({keyId:J,name:J,enabled:sC,permissions:KA,expiresAt:yC(J),createdAt:J}),ZA={errors:[CA,kA],map:e=>e.kind===`Body`||e.kind===`ResponseHeaders`?new kA({error:`Request could not be completed`}):new CA({error:`Invalid request`})},QA=jw({name:`issuer`,errors:AA,schemaError:ZA},Ow(`setupStatus`,{description:`Check whether the issuer needs its first owner account.`,success:Y({required:sC}),mcp:!1}),Ow(`setupOwner`,{description:`Create the first owner account.`,input:jA,success:Y({created:sC}).pipe(aD(201)),mcp:!1}),Ow(`verifyApiKey`,{description:`Verify the bearer API key against one resource and return its granted scopes.`,input:Y({resource:J}),success:Y({keyId:J,ownerId:J,resource:J,scopes:mC(J),expiresAt:yC(J)}),mcp:!1})),$A=Y({clients:mC(RA),resources:mC(VA),clientAccess:mC(UA),email:J,issuer:J}),ej=SA({apiPath:`/api`},jw({name:`administration`,errors:AA,schemaError:ZA},Ow(`listClients`,{description:`List clients, resources and access grants.`,success:$A,mcp:{readOnly:!0}}),Ow(`createClient`,{description:`Register a first-party OAuth client. Returns its secret once when confidential.`,input:PA,success:zA.pipe(aD(201))}),Ow(`updateClient`,{description:`Rename a first-party client or change its redirect URIs and application type.`,input:FA,success:RA}),Ow(`deleteClient`,{description:`Delete a first-party OAuth client.`,input:IA,success:Y({deleted:sC})}),Ow(`revokeClient`,{description:`Revoke a client’s authorization grants.`,input:IA,success:Y({revoked:sC})}),Ow(`blockClient`,{description:`Block or unblock OAuth authorization for a client.`,input:LA,success:Y({blocked:sC})}),Ow(`rotateClientSecret`,{description:`Rotate a confidential client secret. Returns the new secret once.`,input:IA,success:zA}),Ow(`setClientAccess`,{description:`Set the resources a client may request.`,input:WA,success:GA}),Ow(`createResource`,{description:`Create an OAuth resource and its scopes.`,input:BA,success:BA.pipe(aD(201))}),Ow(`updateResource`,{description:`Update an OAuth resource and its scopes.`,input:BA,success:BA}),Ow(`deleteResource`,{description:`Delete a resource and its client-resource links. Stored authorization grants and API-key permissions are retained; recreating the resource can restore access.`,input:HA,success:Y({deleted:sC})}),Ow(`listApiKeys`,{description:`List API key metadata without secret values.`,success:Y({keys:mC(XA)}),mcp:{readOnly:!0}}),Ow(`createApiKey`,{description:`Create a scoped API key. Returns its secret once.`,input:qA,success:XA.pipe(uC({key:J}),aD(201))}),Ow(`updateApiKey`,{description:`Update an API key’s name, permissions or enabled state.`,input:YA,success:XA}),Ow(`deleteApiKey`,{description:`Delete an API key.`,input:JA,success:Y({deleted:sC})})),QA);ej.api;var tj=M(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),nj=class extends j()(`effect/http/FetchHttpClient/RequestInit`){},rj=CE(B(_E((e,t,n,r)=>{let i=r.getRef(tj),a=Xo(r.context,nj)??{},o=a.headers?_S(pS(a.headers),e.headers):e.headers;o[`content-length`]&&(o=vS(o,`content-length`));let s=r=>U(Op({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:typeof ReadableStream<`u`&&r instanceof ReadableStream?`half`:void 0,signal:n}),catch:t=>new Yw({reason:new Qw({request:e,cause:t})})}),t=>NT(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 H(xw(e.body.stream),s)}return s(void 0)}))),ij=Y({error:J}),aj=await _m(Lk(ej.api,{baseUrl:location.origin}).pipe(nm(rj)));function oj(e){return _m(e.pipe(Yp(e=>Error(Ea(ka(JS(ij)(e),e=>e.error),()=>`Request could not be completed. Please try again.`)))))}var sj=dn({plugins:[bn()]}),cj=document.querySelector(`#app`);cj.innerHTML=`<header><a href="/" class="brand"><span class="mark">c.</span> clanker<span class="muted">auth</span></a><span class="tag">PRIVATE IDENTITY</span></header><main id="main"></main><footer>Local accounts. Explicit access.<span>Self-hosted authorization server</span></footer>`;var lj=document.querySelector(`#main`),$=e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]);function uj(e){let t=document.querySelector(`#message`);t.textContent=e,e&&t.hasAttribute(`tabindex`)&&(t.focus(),t.scrollIntoView({behavior:`smooth`,block:`center`}))}var dj=!1;async function fj(e){if(dj)return;dj=!0;let t=Array.from(lj.querySelectorAll(`button`),e=>({button:e,disabled:e.disabled}));t.forEach(({button:e})=>e.disabled=!0),uj(``);try{await e()}catch(e){uj(e instanceof Error?e.message:`Request failed`)}finally{t.forEach(({button:e,disabled:t})=>e.disabled=t),dj=!1}}function pj(e,t){!dj&&confirm(e)&&fj(t)}function mj(){lj.innerHTML=`<section class="intro"><p class="eyebrow">YOUR NETWORK, YOUR IDENTITY</p><h1>Your identity.<br>Starts here.</h1><p>Create the owner account for your private applications.<br>Your account stays on your infrastructure.</p><div class="note"><span class="dot"></span> One owner · Explicit access</div></section>
|
|
14
|
+
`}case`Retry`:return`retry: ${Fs(e.duration)}\n\n`}}},nD={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,OK:200,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511},rD=e=>nD[e],iD=`~effect/httpapi/HttpApiSchema/Stream`;function aD(e){let t=typeof e==`string`?rD(e):e;return e=>e.annotate({httpApiStatus:t})}var oD=(e=>cC.pipe(aD(e)))(204),sD=e=>ZS(e)&&w(e,iD),cD=e=>sD(e)&&e._tag===`StreamSse`,lD=e=>sD(e)&&e._tag===`StreamUint8Array`,uD=`~effect/httpapi/HttpApiSchema/WithHeaders`,dD=`~effect/httpapi/HttpApiSchema/WithHeadersValue`,fD=e=>w(e,dD),pD=e=>({[dD]:dD,body:e.body,headers:e.headers}),Z=e=>ZS(e)&&w(e,`~effect/httpapi/HttpApiSchema/WithHeaders`);function mD(e,t,n){return q(e.ast,{[uD]:uD,schema:t,headers:n})}function hD(e,t){return e.annotate({"~httpApiEncoding":{_tag:t._tag,contentType:t.contentType??gD(t._tag)}})}function gD(e){switch(e){case`Multipart`:return`multipart/form-data`;case`Json`:return`application/json`;case`FormUrlEncoded`:return`application/x-www-form-urlencoded`;case`Uint8Array`:return`application/octet-stream`;case`Text`:return`text/plain`}}function _D(e){return t=>hD(t,{_tag:`FormUrlEncoded`,...e})}var vD=e=>{if(mg(e)||mg(sv(e)))return!0;let t=e.encoding?.[0].to;return t!==void 0&&mg(t)},yD=wv(`~httpApiEncoding`),bD=wv(`~httpApiWithHeaders`),xD=wv(`httpApiStatus`),SD={_tag:`Json`,contentType:`application/json`},CD={_tag:`FormUrlEncoded`,contentType:`application/x-www-form-urlencoded`};function wD(e){return yD(e)??SD}function TD(e,t){return yD(e)||(rT(t)?SD:CD)}function ED(e){let t=wD(e);if(t._tag===`Multipart`)throw Error(`Multipart is not supported in response`);return t}function DD(e){return xD(e)??200}function OD(e){return Z(e)?xD(e.ast)??DD(e.schema.ast):DD(e.ast)}function kD(e){return Z(e)&&yD(e.ast)===void 0?ED(e.schema.ast):ED(e.ast)}function AD(e){return xD(e)??500}function jD(e){return Z(e)?xD(e.ast)??AD(e.schema.ast):AD(e.ast)}function MD(e){let t=e.toLowerCase().trim(),n=t.indexOf(`;`);return n===-1?t:t.slice(0,n).trim()}var ND=`~effect/httpapi/HttpApiEndpoint`;function PD(e){let t=[];for(let{schemas:n}of e.payload.values())t.push(...n);return t}function FD(e){let t=Array.from(e.success);return Ya(t)?t:[oD]}function ID(e){let t=new Set(e.error),n=e.disableCodecs?C:GD;for(let r of e.middlewares){let e=r;for(let r of e.error)t.add(n(r))}return Array.from(t)}var LD={[ND]:ND,pipe(){return x(this,arguments)},prefix(e){return zD({...RD(this),path:PE(this.path,e)})},middleware(e){return zD({...RD(this),middlewares:new Set([...this.middlewares,e])})},annotate(e,t){return zD({...RD(this),annotations:qo(this.annotations,e,t)})},annotateMerge(e){return zD({...RD(this),annotations:is(this.annotations,e)})}},RD=e=>({identifier:e.identifier,path:e.path,method:e.method,params:e.params,query:e.query,headers:e.headers,payload:e.payload,success:e.success,error:e.error,annotations:e.annotations,middlewares:e.middlewares,disableCodecs:e.disableCodecs});function zD(e){function t(){}return Object.setPrototypeOf(t,LD),Object.assign(t,e)}var BD=e=>(t,n,r)=>{let i=r?.disableCodecs??!1,a=i?C:YC;return zD({identifier:t,path:n,method:e,params:VD(r?.params,a),query:VD(r?.query,a),headers:VD(r?.headers,a),payload:HD(r?.payload,e,i),success:WD(r?.success,e,i),error:KD(r?.error,i),annotations:Wo(),middlewares:new Set,disableCodecs:i})};function VD(e,t){if(e!==void 0)return ZS(e)?t(e):t(Y(e))}function HD(e,t,n){let r=new Map;if(e===void 0)return r;let i=Array.isArray(e)?e:ZS(e)?[e]:[Y(e).pipe(_D())],a=n?C:nO;for(let e of i){let n=TD(e.ast,t),i=MD(n.contentType),o=r.get(i);if(o){if(o.encoding._tag!==n._tag)throw Error(`Multiple payload encodings for content-type: ${n.contentType}`);if(o.encoding._tag===`Multipart`)throw Error(`Multiple multipart payloads for content-type: ${n.contentType}`);o.schemas.push(a(e,t))}else r.set(i,{encoding:n,schemas:[a(e,t)]})}return r}var UD=`effect/httpapi/stream/failure`;function WD(e,t,n){if(e===void 0)return new Set;let r=Ka(e);return qD(r,t),new Set(n?r:r.map(GD))}var GD=On(e=>sD(e)?e:Z(e)?mD(e,sD(e.schema)?e.schema:tO(e.schema,kD(e)),YC(e.headers)):eO(e));function KD(e,t){if(e===void 0)return new Set;let n=Ka(e);for(let e of n)if(sD(Z(e)?e.schema:e))throw Error(`Streaming schemas are not supported in error responses`);return YD(n,jD),new Set(t?n:n.map(GD))}function qD(e,t){let n=!1,r=new Map;for(let i of e){let e=Z(i)?i.schema:i,a=OD(i);if(sD(e)){if(XD(e,t),n)throw Error(`Multiple streaming success responses are not supported`);n=!0;let i=JD(r,a);if(i.noContent)throw Error(`Cannot combine no-content and streaming success responses for status: ${a}`);if(i.bufferedContentTypes.has(MD(e.contentType)))throw Error(`Cannot combine buffered and streaming success responses for status ${a} and content-type: ${e.contentType}`);r.set(a,{...i,stream:e})}else{let t=JD(r,a),n=vD(e.ast);if(t.stream!==void 0){if(n)throw Error(`Cannot combine no-content and streaming success responses for status: ${a}`);let e=kD(i);if(MD(e.contentType)===MD(t.stream.contentType))throw Error(`Cannot combine buffered and streaming success responses for status ${a} and content-type: ${e.contentType}`)}n||t.bufferedContentTypes.add(MD(kD(i).contentType)),t.noContent=t.noContent||n}}YD(e,OD)}function JD(e,t){let n=e.get(t);return n===void 0&&(n={bufferedContentTypes:new Set,noContent:!1},e.set(t,n)),n}function YD(e,t){let n=new Map;for(let r of e){let e=t(r),i=bD(r.ast),a=Z(r)?r.schema:i?.body??r,o=vD(a.ast)?``:MD(sD(a)?a.contentType:kD(r).contentType),s=n.get(e);s===void 0&&(s={headerContentType:void 0,plainContentTypes:new Set},n.set(e,s));let c=()=>Error(`Cannot combine a response with headers with another response for status ${e} and content-type: ${o||`<no content>`}`);if(Z(r)||i!==void 0){if(s.headerContentType!==void 0)throw Error(`Cannot declare multiple responses with headers for status ${e}`);if(s.plainContentTypes.has(o))throw c();s.headerContentType=o}else{if(s.headerContentType===o)throw c();s.plainContentTypes.add(o)}}}function XD(e,t){if(t===`HEAD`)throw Error(`HEAD endpoints cannot declare streaming success responses`);if(cD(e)&&ZD(e.events.ast))throw Error(`SSE event name is reserved: ${UD}`)}function ZD(e){return QD(sv(e),new Set)}function QD(e,t){if(t.has(e))return!1;if(t.add(e),bg(e))return e.types.some(e=>QD(e,t));if(xg(e))return QD(e.thunk(),t);if(!yg(e))return!1;let n=e.propertySignatures.find(e=>e.name===`event`);return n!==void 0&&$D(n.type,t)}function $D(e,t){if(t.has(e))return!1;t.add(e);let n=sv(e);return n===e?gg(e)?e.literal===UD:bg(e)?e.types.some(e=>$D(e,t)):xg(e)?$D(e.thunk(),t):!1:$D(n,t)}function eO(e){let t=ED(e.ast),n=bD(e.ast);if(n===void 0)return tO(e,t);let r=eC(n.headers);return Y({body:tO(eC(n.body),t),headers:r}).pipe(X(e)).annotate({"~httpApiWithHeaders":{...n,headersCodec:YC(r)}})}function tO(e,t){switch(t._tag){case`Json`:return JC(e);case`FormUrlEncoded`:return YC(e);case`Text`:case`Uint8Array`:return e}}function nO(e,t){switch(TD(e.ast,t)._tag){case`Json`:return JC(e);case`FormUrlEncoded`:return YC(e);case`Text`:case`Uint8Array`:case`Multipart`:return e}}var rO=BD(`POST`),iO=`~effect/httpapi/HttpApi`,aO={[iO]:iO,pipe(){return x(this,arguments)},add(...e){let t={...this.groups};for(let n of e)E(t,n.identifier,n);return sO({...oO(this),groups:t})},addHttpApi(e){let t={...this.groups};for(let n of Object.keys(e.groups)){let r=e.groups[n];E(t,n,r.annotateMerge(is(e.annotations,r.annotations)))}return sO({...oO(this),groups:t})},prefix(e){return sO({...oO(this),groups:Ba(this.groups,t=>t.prefix(e))})},middleware(e){return sO({...oO(this),groups:Ba(this.groups,t=>t.middleware(e))})},annotate(e,t){return sO({...oO(this),annotations:qo(this.annotations,e,t)})},annotateMerge(e){return sO({...oO(this),annotations:is(this.annotations,e)})}},oO=e=>({identifier:e.identifier,groups:e.groups,annotations:e.annotations}),sO=e=>{function t(){}return Object.setPrototypeOf(t,aO),Object.assign(t,e)},cO=e=>sO({identifier:e,groups:{},annotations:Wo()}),lO=(e,t)=>{let n=Object.values(e.groups);for(let r of n){let n=is(e.annotations,r.annotations);t.onGroup({group:r,mergedAnnotations:n});let i=Object.values(r.endpoints);for(let e of i)(!t.predicate||t.predicate({endpoint:e,group:r}))&&t.onEndpoint({group:r,endpoint:e,middleware:e.middlewares,mergedAnnotations:is(n,e.annotations),successes:uO(FD(e),OD),errors:uO(ID(e),jD)})}},uO=(e,t)=>{let n=new Map;return e.forEach(r),n;function r(e){if(sD(Z(e)?e.schema:e))return;let r=t(e),i=n.get(r);i===void 0?n.set(r,[e]):i.push(e)}},dO=class extends j()(`effect/httpapi/HttpApi/AdditionalSchemas`){},fO=class extends j()(`effect/httpapi/HttpApi/ParseOptions`){},pO=zT({status:400}),mO=`~effect/httpapi/HttpApiError/HttpApiSchemaError`,hO=class e extends Zs(`HttpApiSchemaError`){[mO]=mO;static is(e){return w(e,mO)}static wrap(t,n){return Sm(n,n=>new e({kind:t,cause:n}))}name=`HttpApiSchemaError`;message=this.kind;[XT](){return B(pO)}},gO=`~effect/httpapi/HttpApiMiddleware`,_O=`~effect/httpapi/HttpApiMiddleware/Security`,vO=e=>w(e,_O),yO=()=>(e,t)=>{let n=Qr(),r;n!==0&&($r(2),r=new globalThis.Error,$r(n));class i extends j()(e){}let a=i;if(Object.defineProperty(i,"stack",{get(){return r?.stack}}),a[gO]=gO,a.error=bO(t?.error),a.requiredForClient=t?.requiredForClient??!1,t?.security!==void 0){if(Object.keys(t.security).length===0)throw Error(`HttpApiMiddleware.Service: security object must not be empty`);a[_O]=_O,a.security=t.security}return a};function bO(e){return e===void 0?new Set:new Set(Array.isArray(e)?e:[e])}var xO=(e,t)=>Qf(e,(e,n)=>Kp(e,e=>hO.is(e)?t(e,n):V(e))),SO=new Set;function CO(e){if(e===void 0)return SO;let t=L_(e.ast);return yg(t)&&t.indexSignatures.length===0?new Set(t.propertySignatures.map(e=>String(e.name))):void 0}function wO(e,t){if(t===void 0||!e.includes(`:`))return e;let n=CO(t);if(n===void 0)return e;let r=``,i=0,a=-1;for(let t=0;t<e.length;t++){let o=e[t];if(i>0||t===a){r+=o,o===`\\`?r+=e[++t]??``:o===`(`?i++:o===`)`&&i--;continue}if(o!==`:`){r+=o;continue}if(e[t+1]===`:`){r+=`::`,t++;continue}let s=/^:(\w+)/.exec(e.slice(t));if(s!==null&&n.has(s[1])){r+=s[0],t+=s[0].length-1;let n=e[t+1];n===`(`?a=t+1:n!==void 0&&!`/.-?`.includes(n)&&(r+=`(.*?)`)}else r+=`::`}return r}var TO=class extends j()(`effect/httpapi/OpenApi/Identifier`){},EO=class extends j()(`effect/httpapi/OpenApi/Title`){},DO=class extends j()(`effect/httpapi/OpenApi/Version`){},OO=class extends j()(`effect/httpapi/OpenApi/Description`){},kO=class extends j()(`effect/httpapi/OpenApi/License`){},AO=class extends j()(`effect/httpapi/OpenApi/ExternalDocs`){},jO=class extends j()(`effect/httpapi/OpenApi/Servers`){},MO=class extends j()(`effect/httpapi/OpenApi/Format`){},NO=class extends j()(`effect/httpapi/OpenApi/Summary`){},PO=class extends j()(`effect/httpapi/OpenApi/Deprecated`){},FO=class extends j()(`effect/httpapi/OpenApi/Override`){},IO=M(`effect/httpapi/OpenApi/Exclude`,{defaultValue:Tn}),LO=class extends j()(`effect/httpapi/OpenApi/Transform`){},RO={},zO=new WeakMap,BO=e=>{if(Array.isArray(e))return e.map(BO);if(typeof e==`object`&&e&&!Object.isFrozen(e)){let t={};for(let n of Object.keys(e))E(t,n,BO(e[n]));return t}return e};function Q(e,t,n){let r=rs(e,t);wa(r)&&n(r.value)}function VO(e,t){let n=t??RO,r=zO.get(n);r===void 0&&(r=new WeakMap,zO.set(n,r));let i=r.get(e);if(i!==void 0)return BO(i);let a=HO(e,n);return r.set(e,BO(a)),a}function HO(e,t){let n={openapi:`3.1.0`,info:{title:`Api`,version:`0.0.1`},paths:{},components:{schemas:{},securitySchemes:{}},security:[],tags:[]},r=[],i=new Set,a=new Set,o=[];Q(e.annotations,EO,e=>{n.info.title=e}),Q(e.annotations,DO,e=>{n.info.version=e}),Q(e.annotations,OO,e=>{n.info.description=e}),Q(e.annotations,kO,e=>{n.info.license=e}),Q(e.annotations,NO,e=>{n.info.summary=e}),Q(e.annotations,jO,e=>{n.servers=[...e]}),lO(e,{onGroup({group:e}){if($o(e.annotations,IO))return;let t={name:Yo(e.annotations,EO,()=>e.identifier)};Q(e.annotations,OO,e=>{t.description=e}),Q(e.annotations,AO,e=>{t.externalDocs=e}),Q(e.annotations,FO,e=>{for(let[n,r]of Object.entries(e))E(t,n,r)}),Q(e.annotations,LO,e=>{t=e(t)}),n.tags.push(t)},onEndpoint({endpoint:e,group:t,mergedAnnotations:s,middleware:c}){if($o(s,IO))return;let l={tags:[Yo(t.annotations,EO,()=>t.identifier)],operationId:Yo(e.annotations,TO,()=>t.topLevel?e.identifier:`${t.identifier}.${e.identifier}`),parameters:[],security:[],responses:{}},u=CO(e.params),d=e.path.replace(/:(\w+)\??/g,(e,t)=>u===void 0||u.has(t)?`{${t}}`:e),f=e.method.toLowerCase(),p=f===`query`,m=p?`QUERY`:f,h=p?[`paths`,d,`x-oai-additionalOperations`,m]:[`paths`,d,m];function g(e,t){for(let[n,{content:i,descriptions:a,headers:o,streamContent:s}]of e){let e=a.size>0?Array.from(a).join(` | `):t();E(l.responses,n,{description:e});for(let e of o){let t=L_(e.ast);if(yg(t))for(let e of t.propertySignatures){let t=String(e.name).toLowerCase();t!==`content-type`&&(l.responses[n].headers??={},E(l.responses[n].headers,t,{schema:{},required:!nv(e.type)}),r.push({_tag:`parameter`,ast:e.type,path:[...h,`responses`,String(n),`headers`,t,`schema`]}))}}i!==void 0&&i.forEach((e,t)=>{e.forEach((e,i)=>{let a=Array.from(e,c_),o=a.length===1?a[0]:new b_(a);r.push({_tag:`schema`,ast:JO(o,t),path:[...h,`responses`,String(n),`content`,i,`schema`]}),l.responses[n].content??={},E(l.responses[n].content,i,{schema:{}})})}),s!==void 0&&s.forEach((e,t)=>{l.responses[n].content??={},cD(e)?(r.push({_tag:`schema`,ast:c_(e.events),path:[...h,`responses`,String(n),`content`,t,`schema`]}),r.push({_tag:`schema`,ast:c_(JC(LC(e.error,AC()))),path:[...h,`responses`,String(n),`content`,t,`x-effect-stream`,`causeSchema`]}),r.push({_tag:`schema`,ast:c_(e.error),path:[...h,`responses`,String(n),`content`,t,`x-effect-stream`,`errorSchema`]}),E(l.responses[n].content,t,{schema:{},"x-effect-stream":{encoding:`sse`,causeSchema:{},errorSchema:{},failureEvent:UO}})):E(l.responses[n].content,t,{schema:{type:`string`,format:`binary`},"x-effect-stream":{encoding:`uint8array`}})})}}function _(e,t){if(e){let n=L_(e.ast);if(yg(n))for(let e of n.propertySignatures)l.parameters.push({name:String(e.name),in:t,schema:{},required:t===`path`||!nv(e.type)}),r.push({_tag:`parameter`,ast:e.type,path:[...h,`parameters`,String(l.parameters.length-1),`schema`]})}}Q(e.annotations,OO,e=>{l.description=e}),Q(e.annotations,NO,e=>{l.summary=e}),Q(e.annotations,PO,e=>{l.deprecated=e}),Q(e.annotations,AO,e=>{l.externalDocs=e}),c.forEach(e=>{if(vO(e))for(let[t,n]of Object.entries(e.security))ee(t,n),l.security.push({[t]:[]})});function ee(e,t){let r=XO(t);if(!Object.hasOwn(n.components.securitySchemes,e)){E(n.components.securitySchemes,e,r);return}if(!lr(ZO(n.components.securitySchemes[e]),ZO(r)))throw new globalThis.Error(`Conflicting OpenAPI security scheme: ${e}`)}let v=rT(e.method);if(v){let t=new Map;for(let n of PD(e)){if(vD(n.ast))continue;let r=TD(n.ast,e.method),i=t.get(r.contentType);i===void 0?t.set(r.contentType,{encoding:r,schemas:[n]}):i.schemas.push(n)}if(t.size>0){let e={};for(let[n,{encoding:i,schemas:a}]of t){let t=a.map(c_),o=t.length===1?t[0]:new b_(t);r.push({_tag:`schema`,ast:JO(o,i._tag),path:[...h,`requestBody`,`content`,n,`schema`]}),E(e,n,{schema:{}})}l.requestBody={content:e,required:!0}}}if(_(e.params,`path`),!v&&e.payload.size===1){let t=e.payload.values().next().value;_(t.schemas[0],`query`)}_(e.headers,`header`),_(e.query,`query`),g(WO(e),()=>`Success`),g(GO(ID(e),jD,KO),()=>`Error`);let te=`${f} ${d.replace(/\{[^}]+\}/g,`{}`)}`;if(i.has(te))throw new globalThis.Error(`Duplicate OpenAPI operation for ${e.method} ${d}`);i.add(te),Object.hasOwn(n.paths,d)||E(n.paths,d,{});let ne=()=>{let e=n.paths[d];return p?e[`x-oai-additionalOperations`]??={}:e};ne()[m]=l,o.push(()=>{let t=ne(),n=t[m];Q(e.annotations,FO,e=>{for(let[t,r]of Object.entries(e))E(n,t,r)}),Q(e.annotations,LO,e=>{n=e(n)});let r=n.operationId;if(r!==void 0){if(a.has(r))throw new globalThis.Error(`Duplicate OpenAPI operationId: ${r}`);a.add(r)}t[m]=n})}}),Q(e.annotations,dO,e=>{e.forEach(e=>{let t=Tv(e.ast);if(t!==void 0){if(Object.hasOwn(n.components.schemas,t))throw new globalThis.Error(`Duplicate component schema identifier: ${t}`);E(n.components.schemas,t,{}),r.push({_tag:`schema`,ast:e.ast,path:[`components`,`schemas`,t]})}})});function s(e){return`/`+e.map(jb).join(`/`)}if(Ya(r)){let e=Rb(jx(Px($a(r,e=>Xb(e.ast)),t),{onExcessProperty:`error`})),i=r.map((t,n)=>({op:`replace`,path:s(t.path),value:e.schemas[n]}));Object.entries(e.definitions).forEach(([e,t])=>{i.push({op:`add`,path:s([`components`,`schemas`,e]),value:t})}),n=Fx(i,n)}for(let e of o)e();return Object.keys(n.components.schemas).forEach(e=>{if(!zb.test(e))throw new globalThis.Error(`Invalid component schema key: ${e}`)}),Q(e.annotations,FO,e=>{for(let[t,r]of Object.entries(e))E(n,t,r)}),Q(e.annotations,LO,e=>{n=e(n)}),n}var UO=`effect/httpapi/stream/failure`;function WO(e){return GO(FD(e),OD,KO)}function GO(e,t,n){let r=new Map;return e.forEach(i),r;function i(e){let i=bD(e.ast),c=Z(e)?e.schema:i?.body??e,l=Z(e)?e.headers:i?.headersCodec,u=t(e),d=c.ast;sD(c)?s(c,u):vD(d)?a(u,n(e.ast)??n(d)??`<No Content>`):o(c,u,kD(e),n(e.ast)??n(d)),l!==void 0&&r.get(u).headers.push(l)}function a(e,t){let n=r.get(e);n===void 0?r.set(e,{descriptions:new Set([t]),content:void 0,headers:[],streamContent:void 0}):t!==void 0&&n.descriptions.add(t)}function o(e,t,n,i){let a=r.get(t),{_tag:o,contentType:s}=n;if(a===void 0)r.set(t,{descriptions:new Set(i===void 0?[]:[i]),content:new Map([[o,new Map([[s,new Set([e])]])]]),headers:[],streamContent:void 0});else if(i!==void 0&&a.descriptions.add(i),a.content===void 0)a.content=new Map([[o,new Map([[s,new Set([e])]])]]);else{let t=a.content.get(o);if(t===void 0)a.content.set(o,new Map([[s,new Set([e])]]));else{let n=t.get(s);n===void 0?t.set(s,new Set([e])):n.add(e)}}}function s(e,t){let n=r.get(t);n===void 0?r.set(t,{descriptions:new Set,content:void 0,headers:[],streamContent:new Map([[e.contentType,e]])}):n.streamContent===void 0?n.streamContent=new Map([[e.contentType,e]]):n.streamContent.set(e.contentType,e)}}function KO(e){return Ev(e)??Tv(e)}var qO=J.annotate({format:`binary`});function JO(e,t){switch(t){case`Uint8Array`:return qO.ast;case`Text`:return J.ast;case`FormUrlEncoded`:case`Json`:return e;case`Multipart`:return YO(e)}}function YO(e){return fg(e)&&e.annotations?.representation?.id===`effect/http/PersistedFile`?qO.ast:typeof e?.recur==`function`?e.recur(YO):e}var XO=e=>{let t={};switch(Q(e.annotations,OO,e=>{t.description=e}),e._tag){case`Basic`:return{...t,type:`http`,scheme:`basic`};case`Http`:{let n=rs(e.annotations,MO).pipe(ka(e=>({bearerFormat:e})),Oa);return{...t,type:`http`,scheme:e.scheme,...n}}case`ApiKey`:return{...t,type:`apiKey`,name:e.key,in:e.in}}},ZO=e=>e.type===`http`?{...e,scheme:e.scheme.toLowerCase()}:e.in===`header`?{...e,name:e.name.toLowerCase()}:e,QO=(e,t)=>kE(bm(function*(n){let r=yield*em(),i=[],a=Array.from(r.mapUnsafe.keys()).filter(e=>e.startsWith(`effect/httpapi/HttpApiGroup/`)),o=Object.values(e.groups);for(let e of o){let t=r.mapUnsafe.get(e.key)?.routes;if(t===void 0){let t=a.length===0?`none`:a.join(`, `);return yield*Fp(`HttpApiGroup "${e.identifier}" not found (key: "${e.key}"). Did you forget to provide HttpApiBuilder.group(api, "${e.identifier}", ...)? Available groups: ${t}`)}i.push(...t)}if(yield*n.addAll(i),t?.openapiPath){let r=On(e=>UT(VO(e)));yield*n.add(`GET`,t.openapiPath,Ap(()=>r(e)))}})),$O=(e,t,n)=>rp(Mp(function*(){let r=(yield*em()).pipe(os(jf)),i=e.groups[t],a=n(ok(i)),o=Ep(a)?yield*a:a,s=[];for(let t of o.handlers.values())s.push(uk(e,i,t,r));return zo(new Map([[i.key,{routes:s,handlers:o.handlers}]]))})),ek=`~effect/httpapi/HttpApiBuilder/Handlers`,tk=e=>{switch(e._tag){case`Http`:return U(iE,t=>Yx(rk(t.headers.authorization,e.scheme)??``));case`ApiKey`:{let t=e.in===`header`?e.key.toLowerCase():e.key,n=Y({[t]:J});return Qp(e.in===`query`?cE(n):e.in===`cookie`?oE(n):sE(n),{onFailure:()=>Yx(``),onSuccess:e=>Yx(e[t])})}case`Basic`:{let e={username:``,password:Yx(``)};return U(iE,t=>{let n=rk(t.headers.authorization,nk);if(n===void 0)return e;let r=La(rc(n));if(r===void 0)return e;let i=r.indexOf(`:`);return i===-1?e:{username:r.slice(0,i),password:Yx(r.slice(i+1))}})}}},nk=`Basic`;function rk(e,t){let n=t.length;if(e===void 0||e.length<=n||e.charCodeAt(n)!==32||e.slice(0,n).toLowerCase()!==t.toLowerCase())return;let r=n+1;for(;e.charCodeAt(r)===32;)r++;return r===e.length?void 0:e.slice(r)}var ik=(e,t,n,r,i)=>{if(!Object.hasOwn(e.group.endpoints,t))throw Error(`HttpApiEndpoint "${t}" not found in HttpApiGroup "${e.group.identifier}"`);if(e.handlers.has(t))throw Error(`Handler for HttpApiEndpoint "${t}" is already registered in HttpApiGroup "${e.group.identifier}"`);let a=e.group.endpoints[t];return e.handlers.set(t,{endpoint:a,handler:n,isRaw:r,uninterruptible:i?.uninterruptible??!1}),e},ak={[ek]:ek,pipe(){return x(this,arguments)},handle(e,t,n){return ik(this,e,t,!1,n)},handleAll(e){for(let[t,n]of Object.entries(e)){let e=typeof n==`function`?n:n.handler,r=typeof n==`function`?void 0:n.options;ik(this,t,e,!1,r)}return this},handleRaw(e,t,n){return ik(this,e,t,!0,n)}},ok=e=>{let t=Object.create(ak);return t.group=e,t.handlers=new Map,t};function sk(e,t){let n=new Map;return e.forEach(({encoding:e,schemas:r},i)=>{let a=KS(_C(r),t);e._tag===`Multipart`?n.set(i,{_tag:`Multipart`,mode:e.mode,limits:e.limits,decode:a}):n.set(i,{_tag:e._tag,decode:a,nullOnEmpty:r.some(e=>pg(sv(e.ast)))})}),n}function ck(e,t,n){let r=rT(t.method),i=r?MD(t.headers[`content-type`]??`application/json`):`application/x-www-form-urlencoded`,a=e.get(i);if(!a)return HT(`Unsupported content-type: ${i}`,{status:415});let{_tag:o,decode:s}=a;switch(o){case`Multipart`:if(a.mode===`buffered`){let e=Xp(t.multipart);return a.limits&&(e=rm(e,$T(a.limits))),H(e,s)}return B(a.limits?vw(t.multipartStream,$T(a.limits)):t.multipartStream);case`Json`:return H(Xp(t.text),e=>{if(e===``)return s(a.nullOnEmpty?null:void 0);try{return s(JSON.parse(e))}catch{return V(new BS(new $m({message:`Expected a valid JSON body`})))}});case`Text`:return H(Xp(t.text),s);case`FormUrlEncoded`:return H(r?U(Xp(t.urlParamsBody),FS):B(n),s);case`Uint8Array`:return H(U(Xp(t.arrayBuffer),e=>new Uint8Array(e)),s)}}function lk(e,t,n,r,i,a){let o=Xo(is(is(e.annotations,t.annotations),n.annotations),fO),s=e=>KS(e,o),c=XS(Ak(n),o),l=XS(jk(n),o),u=Cw(n.params,s),d=Cw(n.headers,s),f=Cw(n.query,e=>s(XC(e))),p=yk(n,o),m=vk(n,o),h=n.payload.size>0&&!a?sk(n.payload,o):void 0;return dk(t,n,r,Mp(function*(){let e=Rv().context,r=Qo(e,iE),a=Qo(e,OE),o=Qo(e,aE),s={request:r,endpoint:n,group:t};if(u&&(s.params=yield*hO.wrap(`Params`,u(a.params))),d&&(s.headers=yield*hO.wrap(`Headers`,d(r.headers))),f&&(s.query=yield*hO.wrap(`Query`,f(o))),h){let e=ck(h,r,o);if(RT(e))return e;e!==void 0&&(s.payload=yield*hO.wrap(`Payload`,e))}let l=yield*i(s);if(RT(l))return l;let g;m!==void 0&&fD(l)&&(g=l.headers,l=l.body);let _=yield*hO.wrap(`Body`,p?.(l,e)??(g===void 0?c(l):m.encodeBody(l)));return m===void 0||g===void 0?_:qT(_,yield*hO.wrap(`ResponseHeaders`,m.encodeHeaders.get(_.status)(g)))})).pipe(Zp,Kp(e=>hO.is(e)?Fp(e):Xp(l(e))),rm(r))}function uk(e,t,n,r){let i=n.endpoint;return ME(i.method,wO(i.path,i.params),lk(e,t,i,r,n.handler,n.isRaw),{uninterruptible:n.uninterruptible})}var dk=(e,t,n,r)=>{let i={group:e,endpoint:t};for(let e of t.middlewares){let t=e,a=Qo(n,t);r=(vO(t)?pk(t,a):a)(r,i)}return r},fk=new WeakMap,pk=(e,t)=>{let n=fk.get(t);if(n!==void 0)return n;let r=Object.entries(e.security).map(([e,n])=>({decode:tk(n),middleware:t[e]}));if(r.length===0)return C;let i=bm(function*(e,t){e=Yp(e,e=>new hk(e));let n;for(let i=0;i<r.length;i++){let{decode:a,middleware:o}=r[i],s=yield*Hp(H(a,n=>o(e,{credential:n,endpoint:t.endpoint,group:t.group})));if(Na(s)){if(gk(s.failure))return yield*V(s.failure.error);n=s;continue}return s.success}return yield*Rp(n)});return fk.set(t,i),i},mk=`~effect/httpapi/HttpApiBuilder/HandlerError`,hk=class{[mk]=mk;error;constructor(e){this.error=e}},gk=e=>w(e,mk),_k=zS(RT);function vk(e,t){let n=new Map,r=[];for(let i of e.success)Z(i)&&(n.set(OD(i),XS(i.headers,t)),sD(i.schema)||r.push(Dk(i)));return n.size===0?void 0:{encodeBody:XS(r.length===0?nC:r.length===1?r[0]:_C(r),t),encodeHeaders:n}}function yk(e,t){let n=bk(e);if(n===void 0)return;let r=n.body,i=xk(e),a=OD(n.schema),o=r.contentType;if(lD(r))return(e,t)=>iw(e)?B(GT(vw(e,t),{status:a,contentType:o})):i?void 0:new BS(new $m({message:`Expected a streaming response`}));let s=Sk(r,t);return(e,t)=>iw(e)?B(GT(vw(Ck(e,s),t),{status:a,contentType:o})):i?void 0:new BS(new $m({message:`Expected a streaming response`}))}function bk(e){for(let t of e.success){let e=Z(t)?t.schema:t;if(sD(e))return{schema:t,body:e}}}function xk(e){for(let t of e.success){let e=Z(t)?t.schema:t;if(ZS(e)&&!sD(e))return!0}return e.success.size===0}function Sk(e,t){let n=JC(LC(e.error,AC()));return{sseMode:e.sseMode,encodeEvents:XS(mC(e.events),t),encodeCause:XS(MC(n),t)}}function Ck(e,t){return e.pipe(t.sseMode===`data`?dw(e=>({id:void 0,event:`message`,data:e})):C,fw(e=>Xp(t.encodeEvents(e))),pw(e=>ow(wk(e,t))),dw(Ek),gw)}function wk(e,t){return t.encodeCause(e).pipe(Xp,U(e=>({id:void 0,event:Tk,data:e})))}var Tk=`effect/httpapi/stream/failure`;function Ek(e){return tD.write({_tag:`Event`,event:e.event,id:e.id,data:e.data})}var Dk=Mk(OD),Ok=Mk(jD);function kk(e){if(!Z(e))return Ok(e);let t=XS(e.schema),n=XS(e.headers),r=Fk(jD(e),kD(e),vD(e.schema.ast)),i=Pk((e,n)=>t(e,n).pipe(Yp(e=>e.issue),H(e=>r(e,n))),n);return _k.pipe(X(e,i))}function Ak(e){let t=FD(e).map(Dk);return t.length===1?t[0]:_C(t)}function jk(e){let t=ID(e).map(kk);return t.length===0?nC:t.length===1?t[0]:_C(t)}function Mk(e){let t=new WeakMap;return n=>{let r=Z(n)?n:n.ast,i=t.get(r);if(i!==void 0)return i;let a=Z(n)?n.schema:n,o=_k.pipe(X(a,Nk(e,n)));return t.set(r,o),o}}function Nk(e,t){let n=bD(t.ast);if(n!==void 0)return Pk(Fk(e(n.body),ED(n.body.ast),vD(n.body.ast)),XS(n.headersCodec));let r=Z(t)?t.schema:t;return Zh({decode:(e,t)=>V(new th({message:`Encode only schema`},e,t)),encode:Fk(e(t),kD(t),vD(r.ast))})}function Pk(e,t){return Zh({decode:(e,t)=>V(new th({message:`Encode only schema`},e,t)),encode:(n,r)=>{let i=n;return H(e(i.body,r),e=>U(t(i.headers,r).pipe(Yp(e=>e.issue)),t=>qT(e,t)))}})}function Fk(e,t,n){switch(t._tag){case`Json`:return(r,i)=>{if(r===void 0||n)return B(zT({status:e}));try{return B(HT(JSON.stringify(r),{status:e,contentType:t.contentType}))}catch{return V(new $m({expected:`a JSON-serializable response body`},r,i))}};case`Text`:return n=>B(HT(n,{status:e,contentType:t.contentType}));case`Uint8Array`:return n=>B(BT(n,{status:e,contentType:t.contentType}));case`FormUrlEncoded`:return n=>B(WT(n,{status:e}).pipe(KT(`content-type`,t.contentType)))}}var Ik=(e,t)=>Mp(function*(){let n=yield*em(),r=t.httpClient.pipe(t?.baseUrl===void 0?C:vE(xT(t.baseUrl.toString())));function i(e,t,a,o,s){if(s===-1)return r.execute(a);let c=n.mapUnsafe.get(o[s]);return c===void 0?i(e,t,a,o,s-1):c({endpoint:t,group:e,request:a,next(n){return i(e,t,n,o,s-1)}})}lO(e,{predicate:t?.predicate,onGroup(e){t.onGroup?.(e)},onEndpoint(e){let{group:n,endpoint:r,errors:a,successes:o,mergedAnnotations:s}=e,c=Xo(s,fO),l=Bk(r.path,r.params),u={orElse:aA},d=new Map;for(let[e,t]of a.entries()){let n=Gk(t);for(let[t,r]of n.entries())Uk(d,e,t,Vk(r,c))}for(let[e,t]of d.entries()){let n=Wk(t);u[e]=e=>H(Jp(n(e),t=>Np(hf(lf(new Yw({reason:new eT({request:e.request,response:e})})),t))),V)}let f=new Map;for(let[e,t]of o.entries()){let n=Gk(t);for(let[t,r]of n.entries())Uk(f,e,t,Vk(r,c))}for(let e of Yk(r)){let t=Jk(e)?e.schema:e;Uk(f,OD(e),t.contentType,Xk(e,c))}for(let[e,t]of f.entries())u[e]=Wk(t);let p=e=>XS(e,c),m=Cw(r.params,p),h=PD(r),g=Ya(h)?rT(r.method)?p(sA(h,r.method)):p(_C(h)):void 0,_=Cw(r.headers,p),ee=Cw(r.query,p),v=Array.from(e.middleware,e=>`${e.key}/Client`),te=bm(function*(e){let a=pT(r.method)(r.path);if(e!==void 0){if(m!==void 0){let t=yield*m(e.params);a=bT(a,l(t))}if(g!==void 0){if(rT(r.method)){if(e.payload instanceof FormData)a=DT(a,e.payload);else{let t=yield*g(e.payload);a=ET(a,t)}}else{let t=yield*g(e.payload);a=wT(a,t)}}if(_!==void 0){let t=yield*_(e.headers);a=_T(a,t)}if(ee!==void 0){let t=yield*ee(e.query);a=wT(a,t)}}let o=yield*i(n,r,a,v,v.length-1);if(e?.responseMode===`response-only`)return o;let s=(u[o.status]??u.orElse)(o,e?.sseOptions),c=yield*t.transformResponse===void 0?s:t.transformResponse(s);return e?.responseMode===`decoded-and-response`?[c,o]:c});t.onEndpoint({...e,endpointFn:te})}})}),Lk=(e,t)=>H(pE,n=>Rk(e,{...t,httpClient:t?.transformClient?t.transformClient(n):n})),Rk=(e,t)=>{let n={};return Ik(e,{...t,onGroup({group:e}){e.topLevel||E(n,e.identifier,{})},onEndpoint({endpoint:e,endpointFn:t,group:r}){E(r.topLevel?n:n[r.identifier],e.identifier,t)}}).pipe(Wp(n))},zk=/(\/?):(\w+)(\?)?/g,Bk=(e,t)=>{if(t===void 0||!e.includes(`:`))return t=>e;let n=CO(t);return t=>e.replace(zk,(e,r,i,a)=>{if(n!==void 0&&!n.has(i))return e;let o=t[i];if(o===void 0){if(a!==void 0)return``;throw Error(`Missing path parameter: ${i}`)}return`${r}${encodeURIComponent(o)}`})};function Vk(e,t){let n=e.some(e=>Z(e)||bD(e.ast)!==void 0),r=qS(n?_C(e.map(Hk)):rA(e),t);return e=>H(e.arrayBuffer,n?t=>r({body:t,headers:e.headers}):r)}function Hk(e){let t=Z(e),n=bD(e.ast);if(n!==void 0)return Y({body:iA(n.body),headers:n.headersCodec}).pipe(X(e));let r=t?e.schema:e;return Y({body:iA(r).pipe(X(r)),headers:t?e.headers:rC}).pipe(X(t?e:$S(e),Qh({decode:e=>t?pD(e):e.body,encode:e=>t?e:{body:e,headers:void 0}})))}function Uk(e,t,n,r){let i=MD(n),a=e.get(t);a===void 0?e.set(t,[{contentType:i,decode:r}]):a.push({contentType:i,decode:r})}function Wk(e){let t=e[0];return e.length===1&&t!==void 0?t.decode:(t,n)=>{let r=MD(t.headers[`content-type`]??``),i=e.find(e=>e.contentType===r);return i===void 0?Kk(t,r,e):i.decode(t,n)}}function Gk(e){let t=new Map;for(let n of e){let e=vD((Z(n)?n.schema:n).ast)?``:MD(kD(n).contentType),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return t}function Kk(e,t,n){let r=Array.from(new Set(n.map(e=>e.contentType))).join(`, `);return V(new Yw({reason:new tT({request:e.request,response:e,description:`Unsupported response content-type for status ${e.status}: ${t||`<missing>`}. Expected one of: ${r}`})}))}var qk=`effect/httpapi/stream/failure`,Jk=e=>Z(e);function Yk(e){let t=[];for(let n of e.success)sD(Z(n)?n.schema:n)&&t.push(n);return t}function Xk(e,t){let n=Jk(e),r=n?e.schema:e,i=lD(r)?void 0:{declaration:r,decoder:Zk(r,t)},a=(e,t)=>U(em(),n=>vw(i===void 0?e.stream:Qk(e.stream,i.declaration,i.decoder(t)),n));if(!n)return a;let o=KS(e.headers,t);return(e,t)=>H(o(e.headers),n=>U(a(e,t),e=>pD({body:e,headers:n})))}function Zk(e,t){let n=_C([Y({id:QS(J),event:tC(qk),data:MC(JC(LC(e.error,AC())))}),e.events]),r=JE(n,void 0,t);return e=>e===void 0?r:JE(n,e,t)}function Qk(e,t,n){let r=sw(e.pipe(hw,mw(n)),e=>Ap(()=>{let t;return kp(()=>t===void 0?H(e,e=>{for(let n=0;n<e.length;n++){let r=e[n];if(r.event===qk&&af(r.data)){if(n===0)return Np(r.data);t=r.data,e=e.slice(0,n);break}}return B(e)}):Np(t))}));return t.sseMode===`data`?dw(r,e=>e.data):r}var $k=wC(globalThis.ArrayBuffer,{expected:`ArrayBuffer`}),eA=$k.pipe(X(FC,Qh({decode(e){return new Uint8Array(e)},encode(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}}))),tA=$k.pipe(X(J,Qh({decode(e){return new TextDecoder().decode(e)},encode(e){let t=new TextEncoder().encode(e);return t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}}))),nA=tA.pipe(X(_C([tC(``).pipe(X(aC,Qh({decode:()=>void 0,encode:()=>``}))),NC])));function rA(e){return _C(e.map(t));function t(e){return iA(e).pipe(X(e))}}function iA(e){switch(ED(e.ast)._tag){case`Json`:return pg(sv(e.ast))?nA.pipe(X(rC,Qh({decode:e=>e===void 0?null:e,encode:e=>e===null?void 0:e}))):nA;case`FormUrlEncoded`:return tA.pipe(X(RC,Qh({decode:e=>ES(new URLSearchParams(e)),encode:PS})));case`Uint8Array`:return eA;case`Text`:return tA}}var aA=e=>V(new Yw({reason:new tT({request:e.request,response:e})})),oA=zS(Nw);function sA(e,t){return _C(e.map(e=>lA(e,t)))}var cA=new WeakMap;function lA(e,t){let n=e.ast,r=cA.get(n);if(r!==void 0)return r;let i=TD(n,t),a=oA.pipe(X(e,Zh({decode(e,t){return V(new th({message:`Encode only schema`},e,t))},encode(e,t){switch(i._tag){case`Multipart`:return V(new th({message:`Payload must be a FormData`},e,t));case`Json`:try{return B(Vw(JSON.stringify(e),i.contentType))}catch{return V(new $m({expected:`a JSON-serializable request body`},e,t))}case`Text`:return typeof e==`string`?B(Vw(e,i.contentType)):V(new $m({message:`Expected a string`},e,t));case`FormUrlEncoded`:return Vn(e)?B(Uw(ES(e),i.contentType)):V(new $m({message:`Expected a record`},e,t));case`Uint8Array`:return e instanceof Uint8Array?B(Lw(e,i.contentType)):V(new $m({message:`Expected a Uint8Array`},e,t))}}})));return cA.set(n,a),a}var uA=`~effect/httpapi/HttpApiGroup`,dA={[uA]:uA,add(...e){let t={...this.endpoints};for(let n of e)E(t,n.identifier,n);return pA({...fA(this),endpoints:t})},prefix(e){return pA({...fA(this),endpoints:Ba(this.endpoints,t=>t.prefix(e))})},middleware(e){return pA({...fA(this),endpoints:Ba(this.endpoints,t=>t.middleware(e))})},annotateMerge(e){return pA({...fA(this),annotations:is(this.annotations,e)})},annotate(e,t){return pA({...fA(this),annotations:qo(this.annotations,e,t)})},annotateEndpointsMerge(e){return pA({...fA(this),endpoints:Ba(this.endpoints,t=>t.annotateMerge(e))})},annotateEndpoints(e,t){return pA({...fA(this),endpoints:Ba(this.endpoints,n=>n.annotate(e,t))})},pipe(){return x(this,arguments)}},fA=e=>({identifier:e.identifier,topLevel:e.topLevel,endpoints:e.endpoints,annotations:e.annotations}),pA=e=>{function t(){}return Object.setPrototypeOf(t,dA),t.key=`effect/httpapi/HttpApiGroup/${e.identifier}`,Object.assign(t,e)},mA=(e,t)=>pA({identifier:e,topLevel:t?.topLevel??!1,endpoints:{},annotations:Wo()}),hA=e=>e.actions.filter(e=>e.http),gA=(e,t)=>[...t.errors,...(e.errors??[]).filter(e=>!t.errors.includes(e))],_A=(e,t,n)=>rO(n.name,`${e.apiPath}/${t.name}/${n.name}`,{payload:n.input,success:n.success,error:gA(e,n)}).annotate(OO,n.description),vA=(e,t)=>{class n extends yO()(`effect-actions/http/SchemaErrors/${e}`,{error:t.errors}){}return{SchemaErrors:n,layer:xO(n,e=>V(t.map(e)))}};function yA(e,t){let[n,...r]=hA(t).map(n=>_A(e,t,n));if(n===void 0)return;let i=mA(t.name).add(n,...r);if(t.schemaError===void 0)return{native:i,policy:ep};let a=vA(t.name,t.schemaError);return{native:i.middleware(a.SchemaErrors),policy:a.layer}}function bA(e){let[t,...n]=e,r=cO(`actions`).annotate(fO,{errors:`all`});return t===void 0?r:r.add(t,...n)}var xA=e=>e,SA=(e,t,n)=>{let r=e=>Object.fromEntries(hA(t.group).map(n=>[n.name,r=>Aw(t.group,n,e,t.before)(r.payload)]));return op(U(t.build,n=>$O(e,t.group.name,e=>e.handleAll(r(xA(n)))))).pipe(up(n))};function CA(e,...t){Ew(`action group`,t.map(e=>e.name));let n=new Map(t.flatMap(t=>{let n=yA(e,t);return n===void 0?[]:[[t,n]]})),r=(...e)=>{Ew(`implementation group`,e.map(e=>e.group.name));for(let n of e)if(!t.includes(n.group))throw Error(`Implementation of group "${n.group.name}" is not served by this adapter`);let r=e.flatMap(e=>{let t=n.get(e.group);return t===void 0?[]:[{app:e,...t}]}),i=bA(r.map(({native:e})=>e));return r.reduce((e,{app:t,policy:n})=>e.pipe(up(SA(i,t,n))),QO(i))};return{groups:t,api:bA([...n.values()].map(({native:e})=>e)),layer:r}}var wA=class extends qC()(`BadRequest`,{error:J},{httpApiStatus:400}){},TA=class extends qC()(`Unauthorized`,{error:J},{httpApiStatus:401}){},EA=class extends qC()(`Forbidden`,{error:J},{httpApiStatus:403}){},DA=class extends qC()(`NotFound`,{error:J},{httpApiStatus:404}){},OA=class extends qC()(`Conflict`,{error:J},{httpApiStatus:409}){},kA=class extends qC()(`TooManyRequests`,{error:J},{httpApiStatus:429}){},AA=class extends qC()(`InternalServerError`,{error:J},{httpApiStatus:500}){},jA=[wA,TA,EA,DA,OA,kA,AA,class extends qC()(`ServiceUnavailable`,{error:J},{httpApiStatus:503}){}],MA=Y({email:J,password:J}),NA=vC([`none`,`client_secret_basic`,`client_secret_post`]),PA=vC([`web`,`native`]),FA=Y({client_name:J,redirect_uris:mC(J),resources:mC(J),token_endpoint_auth_method:NA,application_type:PA}),IA=Y({client_id:J,client_name:J,redirect_uris:mC(J),application_type:PA}),LA=Y({client_id:J}),RA=Y({client_id:J,blocked:sC}),zA=Y({onboarding:QS(vC([`managed`,`dcr`,`cimd`])),blocked:QS(sC),client_id:J,client_name:QS(J),redirect_uris:mC(J),token_endpoint_auth_method:QS(J),application_type:QS(yC(J)),scope:QS(J),grant_types:QS(mC(J))}),BA=zA.pipe(uC({client_secret:QS(J),client_secret_expires_at:QS(oC)})),VA=Y({identifier:J,name:J,scopes:mC(J)}),HA=VA.pipe(uC({builtIn:sC})),UA=Y({identifier:J}),WA=Y({client_id:J,resource:J}),GA=Y({client_id:J,resources:mC(J)}),KA=Y({clientAccess:mC(WA)}),qA=dC(J,mC(J)),JA=Y({name:J,permissions:qA,expiresAt:yC(J)}),YA=Y({keyId:J}),XA=Y({keyId:J,name:QS(J),permissions:QS(qA),enabled:QS(sC)}),ZA=Y({keyId:J,name:J,enabled:sC,permissions:qA,expiresAt:yC(J),createdAt:J}),QA={errors:[wA,AA],map:e=>e.kind===`Body`||e.kind===`ResponseHeaders`?new AA({error:`Request could not be completed`}):new wA({error:`Invalid request`})},$A=jw({name:`issuer`,errors:jA,schemaError:QA},Ow(`setupStatus`,{description:`Check whether the issuer needs its first owner account.`,access:`read`,success:Y({required:sC}),mcp:!1}),Ow(`setupOwner`,{description:`Create the first owner account.`,input:MA,success:Y({created:sC}).pipe(aD(201)),mcp:!1}),Ow(`verifyApiKey`,{description:`Verify the bearer API key against one resource and return its granted scopes.`,access:`read`,input:Y({resource:J}),success:Y({keyId:J,ownerId:J,resource:J,scopes:mC(J),expiresAt:yC(J)}),mcp:!1})),ej=Y({clients:mC(zA),resources:mC(HA),clientAccess:mC(WA),email:J,issuer:J}),tj=CA({apiPath:`/api`},jw({name:`administration`,errors:jA,schemaError:QA},Ow(`listClients`,{description:`List clients, resources and access grants.`,access:`read`,success:ej}),Ow(`createClient`,{description:`Register a first-party OAuth client. Returns its secret once when confidential.`,input:FA,success:BA.pipe(aD(201))}),Ow(`updateClient`,{description:`Rename a first-party client or change its redirect URIs and application type.`,input:IA,success:zA}),Ow(`deleteClient`,{description:`Delete a first-party OAuth client.`,input:LA,success:Y({deleted:sC})}),Ow(`revokeClient`,{description:`Revoke a client’s authorization grants.`,input:LA,success:Y({revoked:sC})}),Ow(`blockClient`,{description:`Block or unblock OAuth authorization for a client.`,input:RA,success:Y({blocked:sC})}),Ow(`rotateClientSecret`,{description:`Rotate a confidential client secret. Returns the new secret once.`,input:LA,success:BA}),Ow(`setClientAccess`,{description:`Set the resources a client may request.`,input:GA,success:KA}),Ow(`createResource`,{description:`Create an OAuth resource and its scopes.`,input:VA,success:VA.pipe(aD(201))}),Ow(`updateResource`,{description:`Update an OAuth resource and its scopes.`,input:VA,success:VA}),Ow(`deleteResource`,{description:`Delete a resource and its client-resource links. Stored authorization grants and API-key permissions are retained; recreating the resource can restore access.`,input:UA,success:Y({deleted:sC})}),Ow(`listApiKeys`,{description:`List API key metadata without secret values.`,access:`read`,success:Y({keys:mC(ZA)})}),Ow(`createApiKey`,{description:`Create a scoped API key. Returns its secret once.`,input:JA,success:ZA.pipe(uC({key:J}),aD(201))}),Ow(`updateApiKey`,{description:`Update an API key’s name, permissions or enabled state.`,input:XA,success:ZA}),Ow(`deleteApiKey`,{description:`Delete an API key.`,input:YA,success:Y({deleted:sC})})),$A);tj.api;var nj=M(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),rj=class extends j()(`effect/http/FetchHttpClient/RequestInit`){},ij=CE(B(_E((e,t,n,r)=>{let i=r.getRef(nj),a=Xo(r.context,rj)??{},o=a.headers?_S(pS(a.headers),e.headers):e.headers;o[`content-length`]&&(o=vS(o,`content-length`));let s=r=>U(Op({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:typeof ReadableStream<`u`&&r instanceof ReadableStream?`half`:void 0,signal:n}),catch:t=>new Yw({reason:new Qw({request:e,cause:t})})}),t=>NT(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 H(xw(e.body.stream),s)}return s(void 0)}))),aj=Y({error:J}),oj=await _m(Lk(tj.api,{baseUrl:location.origin}).pipe(nm(ij)));function sj(e){return _m(e.pipe(Yp(e=>Error(Ea(ka(JS(aj)(e),e=>e.error),()=>`Request could not be completed. Please try again.`)))))}var cj=dn({plugins:[bn()]}),lj=document.querySelector(`#app`);lj.innerHTML=`<header><a href="/" class="brand"><span class="mark">c.</span> clanker<span class="muted">auth</span></a><span class="tag">PRIVATE IDENTITY</span></header><main id="main"></main><footer>Local accounts. Explicit access.<span>Self-hosted authorization server</span></footer>`;var uj=document.querySelector(`#main`),$=e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]);function dj(e){let t=document.querySelector(`#message`);t.textContent=e,e&&t.hasAttribute(`tabindex`)&&(t.focus(),t.scrollIntoView({behavior:`smooth`,block:`center`}))}var fj=!1;async function pj(e){if(fj)return;fj=!0;let t=Array.from(uj.querySelectorAll(`button`),e=>({button:e,disabled:e.disabled}));t.forEach(({button:e})=>e.disabled=!0),dj(``);try{await e()}catch(e){dj(e instanceof Error?e.message:`Request failed`)}finally{t.forEach(({button:e,disabled:t})=>e.disabled=t),fj=!1}}function mj(e,t){!fj&&confirm(e)&&pj(t)}function hj(){uj.innerHTML=`<section class="intro"><p class="eyebrow">YOUR NETWORK, YOUR IDENTITY</p><h1>Your identity.<br>Starts here.</h1><p>Create the owner account for your private applications.<br>Your account stays on your infrastructure.</p><div class="note"><span class="dot"></span> One owner · Explicit access</div></section>
|
|
15
15
|
<section class="card login"><p class="eyebrow">FIRST-TIME SETUP</p><h2>Create your account</h2><p class="muted">This account manages Clients and Resources and approves access.</p>
|
|
16
16
|
<form id="setup"><label>Email<input name="email" type="email" autocomplete="username" required placeholder="owner@example.internal"></label>
|
|
17
17
|
<label>Password<input name="password" type="password" autocomplete="new-password" required minlength="8" maxlength="128" aria-describedby="password-help"></label><p id="password-help" class="help">Use 8–128 characters. Save your password somewhere safe.</p>
|
|
18
18
|
<label>Confirm password<input name="confirmation" type="password" autocomplete="new-password" required minlength="8" maxlength="128"></label>
|
|
19
|
-
<p id="message" role="alert"></p><button>Create account <span>→</span></button></form></section>`;let e=document.querySelector(`#setup`);e.addEventListener(`submit`,t=>{t.preventDefault(),
|
|
19
|
+
<p id="message" role="alert"></p><button>Create account <span>→</span></button></form></section>`;let e=document.querySelector(`#setup`);e.addEventListener(`submit`,t=>{t.preventDefault(),pj(async()=>{let t=e.querySelector(`[name="password"]`).value,n=e.querySelector(`[name="confirmation"]`).value;if(t.length<8||t.length>128)throw Error(`Use a password between 8 and 128 characters.`);if(t!==n)throw Error(`Passwords do not match.`);await sj(oj.issuer.setupOwner({payload:{email:e.querySelector(`[name="email"]`).value,password:t}}).pipe(Vp(()=>Ap(()=>location.replace(`/`))),qp(`Conflict`,()=>Ap(()=>location.replace(`/login`)))))})})}function gj(){uj.innerHTML=`<section class="intro"><p class="eyebrow">YOUR NETWORK, YOUR IDENTITY</p><h1>One identity.<br>Deliberate access.</h1><p>Sign in to authorize your private applications.<br>Your account stays on your infrastructure.</p><div class="note"><span class="dot"></span> Password login · No external identity provider</div></section>
|
|
20
20
|
<section class="card login"><p class="eyebrow">OWNER ACCESS</p><h2>Welcome back</h2><p class="muted">Use your local account to continue.</p>
|
|
21
21
|
<form id="login"><label>Email<input name="email" type="email" autocomplete="username" required placeholder="owner@example.internal"></label>
|
|
22
22
|
<label>Password<input name="password" type="password" autocomplete="current-password" required></label>
|
|
23
|
-
<p id="message" role="alert"></p><button>Sign in <span>→</span></button></form></section>`;let e=document.querySelector(`#login`);e.addEventListener(`submit`,t=>{t.preventDefault(),
|
|
23
|
+
<p id="message" role="alert"></p><button>Sign in <span>→</span></button></form></section>`;let e=document.querySelector(`#login`);e.addEventListener(`submit`,t=>{t.preventDefault(),pj(async()=>{if((await cj.signIn.email({email:e.querySelector(`[name="email"]`).value,password:e.querySelector(`[name="password"]`).value})).error)throw Error(`Sign-in failed. Check your credentials or try again later.`);let t=new URLSearchParams(location.search),n=t.get(`rd`)??`/`;t.has(`sig`)||location.assign(new URL(n,location.origin).origin===location.origin?n:`/`)})})}async function _j(){let e=new URLSearchParams(location.search),t=e.get(`client_id`);if(!t||!e.has(`sig`))throw Error(`Start authorization from your application; this consent link is incomplete.`);let n=await cj.oauth2.publicClient({query:{client_id:t}});if(n.error||!n.data)throw Error(`Sign in through your application to continue authorization.`);let r=(e.get(`scope`)??``).split(` `).filter(Boolean),i=e.getAll(`resource`),a;try{let e=new URL(t);e.protocol===`https:`&&(a=e.hostname)}catch{}let o=e.get(`redirect_uri`);uj.className=`center`,uj.innerHTML=`<section class="card consent"><p class="eyebrow">PERMISSION REQUEST</p><h1>Allow this connection?</h1>
|
|
24
24
|
<p><strong>${$(n.data.client_name??t)}</strong> wants to act on your behalf.</p>
|
|
25
25
|
${a?`<p>Client metadata host: <strong>${$(a)}</strong></p>`:``}
|
|
26
26
|
<label>Client ID<code>${$(t)}</code></label>
|
|
@@ -30,24 +30,24 @@ data: `)}\n`,t+`
|
|
|
30
30
|
<h3>Requested access</h3><ul class="scopes">${r.map(e=>`<li><span>✓</span><code>${$(e)}</code></li>`).join(``)}</ul>
|
|
31
31
|
${e.has(`claims`)?`<h3>Additional identity claims</h3><pre>${$(e.get(`claims`))}</pre>`:``}
|
|
32
32
|
<p class="help">Access tokens expire after fifteen minutes. Offline access lets the Client renew them until you revoke its authorization.</p>
|
|
33
|
-
<p id="message" role="alert"></p><form id="consent"><div class="actions"><button type="submit" name="decision" value="deny" class="secondary">Deny</button><button type="submit" name="decision" value="allow">Allow access →</button></div></form></section>`,document.querySelector(`#consent`).addEventListener(`submit`,e=>{e.preventDefault();let t=e.submitter;if(!(t instanceof HTMLButtonElement))throw Error(`Consent must be decided with the Allow or Deny button.`);let n=t.value===`allow`;
|
|
33
|
+
<p id="message" role="alert"></p><form id="consent"><div class="actions"><button type="submit" name="decision" value="deny" class="secondary">Deny</button><button type="submit" name="decision" value="allow">Allow access →</button></div></form></section>`,document.querySelector(`#consent`).addEventListener(`submit`,e=>{e.preventDefault();let t=e.submitter;if(!(t instanceof HTMLButtonElement))throw Error(`Consent must be decided with the Allow or Deny button.`);let n=t.value===`allow`;pj(async()=>{if((await cj.oauth2.consent({accept:n})).error)throw Error(`Authorization could not be completed. Restart from your application.`)})})}function vj(e,t){let n=e.get(t);if(n===null||n instanceof File)throw Error(`Missing form field: ${t}`);return n.trim()}function yj(e){return Array.from(e.querySelectorAll(`input[name="resources"]:checked`),e=>e.value)}function bj(e){let t=[...new Set(vj(e,`scopes`).split(/\s+/).filter(Boolean))];return{name:vj(e,`name`),scopes:t}}function xj(e){let t=[...new Set(vj(e,`redirect_uris`).split(/\s+/).filter(Boolean))];if(!t.length)throw Error(`Add at least one redirect URI.`);return t}var Sj={none:`Public client (PKCE only)`,client_secret_basic:`Confidential client · HTTP Basic secret`,client_secret_post:`Confidential client · secret in request body`},Cj=e=>YS(NA)(vj(e,`token_endpoint_auth_method`)),wj=e=>YS(PA)(e.has(`native`)?`native`:`web`);function Tj(e){let t={};for(let n of e.querySelectorAll(`input[name="key-scope"]:checked`))(t[n.dataset.resource]??=[]).push(n.value);return t}var Ej=new Map,Dj=new Map;function Oj(){let e=document.querySelector(`#credentials`);if(e.classList.toggle(`hidden`,Dj.size===0&&Ej.size===0),e.replaceChildren(),!Dj.size&&!Ej.size)return;e.innerHTML=`<h2>Save these credentials now</h2><p>API keys and client secrets are shown only once.</p><button class="secondary">Saved — dismiss credentials</button>`;let t=e.querySelector(`button`);for(let e of Dj.values()){let n=document.createElement(`pre`);n.textContent=JSON.stringify(e,null,2),t.before(n)}for(let e of Ej.values()){let n=document.createElement(`pre`);n.textContent=e,t.before(n)}t.addEventListener(`click`,()=>{Ej.clear(),Dj.clear(),Oj()})}function kj(){Oj(),document.querySelector(`#credentials`).scrollIntoView({behavior:`smooth`})}async function Aj(){try{await Gj()}catch{document.querySelector(`#dashboard-mutations`).disabled=!0,dj(`Saved, but the dashboard could not refresh.`);let e=document.createElement(`button`);e.type=`button`,e.className=`secondary`,e.textContent=`Retry refresh`,e.addEventListener(`click`,()=>{pj(Aj)}),document.querySelector(`#message`).append(` `,e)}}var jj=`Optional. Separate scopes with spaces. offline_access is reserved.`,Mj={managed:`Managed registration · first party, no consent screen`,dcr:`Dynamic registration`,cimd:`Client ID Metadata Document`},Nj=e=>!e.onboarding||e.onboarding===`managed`,Pj=(e,t,n,r,i)=>`<div class="columns dashboard-section"><section><h2>${e} <span class="count">${t}</span></h2><p class="muted">${n}</p>${r}</section><section class="card registration">${i}</section></div>`,Fj=(e,t)=>`<div class="empty"><h3>${e}</h3><p>${t}</p></div>`,Ij=e=>`<code>${$(e.identifier)}</code><span class="muted">${$(e.scopes.join(` · `))}</span>`,Lj=(e,t)=>e.map(e=>`<label class="checkbox resource-choice"><input type="checkbox" name="resources" value="${$(e.identifier)}" ${t.includes(e.identifier)?`checked`:``}><span>${$(e.name)}${Ij(e)}</span></label>`).join(``),Rj=(e,t)=>e.map(e=>`<fieldset><legend>${$(e.name)}</legend><code>${$(e.identifier)}</code>${e.scopes.map(n=>`<label class="checkbox"><input type="checkbox" name="key-scope" data-resource="${$(e.identifier)}" value="${$(n)}" ${t[e.identifier]?.includes(n)?`checked`:``}><code>${$(n)}</code></label>`).join(``)}</fieldset>`).join(``)||`<p class="help">Add a Resource to grant access.</p>`,zj=(e,t)=>`<article class="resource"><h3>${$(e.name)}</h3>${Ij(e)}
|
|
34
34
|
<p class="help dependencies">Managed Clients with access: ${t.length?t.map(e=>$(e.client_name??e.client_id)).join(`, `):`None`}</p>
|
|
35
35
|
${e.builtIn?`<p class="help">Built-in administration resource. OAuth access tokens are required; its scopes and identifier are fixed.</p>`:``}
|
|
36
36
|
<details><summary>Edit resource</summary><form data-resource-edit="${$(e.identifier)}"><label>Name<input name="name" value="${$(e.name)}" required maxlength="100"></label>
|
|
37
37
|
${e.builtIn?``:`<label>Scopes<input name="scopes" value="${$(e.scopes.join(` `))}"></label><p class="help">Added scopes need new consent. Removed scopes are no longer issued, but stored grants are kept and work again if the scope is restored.</p>`}
|
|
38
38
|
<button>Save resource</button></form></details>
|
|
39
|
-
${e.builtIn?``:`<button class="danger" data-resource-delete="${$(e.identifier)}">Delete resource</button>`}</article>`,
|
|
39
|
+
${e.builtIn?``:`<button class="danger" data-resource-delete="${$(e.identifier)}">Delete resource</button>`}</article>`,Bj=()=>`<h2>Add resource</h2><form id="resource-create"><label>Name<input name="name" required maxlength="100" placeholder="Notes MCP"></label><label>HTTP or HTTPS identifier<input name="identifier" type="url" required placeholder="https://notes.internal/mcp"></label><p class="help">The identifier is the token audience and cannot be changed later.</p><label>Scopes<input name="scopes" placeholder="notes:read notes:write"></label><p class="help">${jj}</p><button>Add resource +</button></form>`,Vj=(e,t)=>`<article class="resource"><h3>${$(e.name)}</h3><p>${e.enabled?`Enabled`:`Disabled`} · ${e.expiresAt?`Expires ${$(new Date(e.expiresAt).toLocaleString())}`:`Valid until revoked`}</p>${Object.entries(e.permissions).map(([e,t])=>`<code>${$(e)}</code><p class="help">${$(t.join(` · `))}</p>`).join(``)}
|
|
40
40
|
<details><summary>Rename key</summary><form data-key-rename="${$(e.keyId)}"><label>Name<input name="name" required maxlength="100" value="${$(e.name)}"></label><button>Save name</button></form></details>
|
|
41
|
-
<details><summary>Edit grants</summary><form data-key-grants="${$(e.keyId)}">${
|
|
42
|
-
<div class="actions"><button class="secondary" data-key-toggle="${$(e.keyId)}" data-enabled="${e.enabled}">${e.enabled?`Disable key`:`Enable key`}</button><button class="danger" data-key-delete="${$(e.keyId)}">Delete key</button></div></article>`,
|
|
43
|
-
`))}</textarea></label><label class="checkbox"><input type="checkbox" name="native" ${e.application_type===`native`?`checked`:``}>Native / desktop client (loopback redirect)</label><p class="help">The authentication method is fixed at registration.</p><button>Save client</button></form></details>`:``,c=[`<button class="secondary" data-revoke="${i}">Revoke authorization</button>`,`<button class="secondary" data-block="${i}" data-blocked="${e.blocked?`true`:`false`}">${e.blocked?`Unblock client`:`Block client`}</button>`,r&&e.token_endpoint_auth_method!==`none`?`<button class="secondary" data-rotate="${i}">Rotate secret</button>`:``,r?`<button class="danger" data-delete="${i}">Delete client</button>`:``].join(``);return`<article class="card client"><div class="client-heading"><h3>${$(e.client_name??`Unnamed client`)}</h3><span class="tag">${e.token_endpoint_auth_method===`none`?`PUBLIC · PKCE`:`CONFIDENTIAL · PKCE`}</span></div><p class="help">${
|
|
44
|
-
<h3>${r?`Allowed Resources`:`Resources eligible for consent`}</h3>${a}${o}${s}<div class="actions">${c}</div></article>`},
|
|
41
|
+
<details><summary>Edit grants</summary><form data-key-grants="${$(e.keyId)}">${Rj(t,e.permissions)}<p class="help">Saving replaces all grants, including any not currently available, with the selected scopes.</p><button>Save grants</button></form></details>
|
|
42
|
+
<div class="actions"><button class="secondary" data-key-toggle="${$(e.keyId)}" data-enabled="${e.enabled}">${e.enabled?`Disable key`:`Enable key`}</button><button class="danger" data-key-delete="${$(e.keyId)}">Delete key</button></div></article>`,Hj=e=>`<h2>Create API key</h2><form id="key-create"><label>Name<input name="name" required maxlength="100" placeholder="Backup script"></label>${Rj(e,{})}<label>Expiry (optional)<input name="expiry" type="datetime-local"></label><p class="help">Blank means valid until revoked. The key is shown once.</p><button ${e.length?``:`disabled`}>Create API key</button></form>`,Uj=(e,t,n)=>{let r=Nj(e),i=$(e.client_id),a=t.flatMap(e=>n.includes(e.identifier)?[`<div class="allowed-resource"><strong>${$(e.name)}</strong>${Ij(e)}</div>`]:[]).join(``)||`<p class="help">No Resource access configured.</p>`,o=`<details><summary>Manage access</summary><form data-client-access="${i}"><fieldset><legend>Allowed Resources</legend>${Lj(t,n)||`<p class="help">Add a Resource above to configure access.</p>`}</fieldset><p class="help">${r?``:`Automatic Clients receive access to new Resources; each still needs your consent. `}Removing access stops new authorization and refresh; use Revoke authorization to clear issued grants.</p><button>Save access</button></form></details>`,s=r?`<details><summary>Edit client</summary><form data-client-edit="${i}"><label>Client name<input name="name" required maxlength="100" value="${$(e.client_name??``)}"></label><label>Redirect URIs (one per line)<textarea name="redirect_uris" required rows="3">${$(e.redirect_uris.join(`
|
|
43
|
+
`))}</textarea></label><label class="checkbox"><input type="checkbox" name="native" ${e.application_type===`native`?`checked`:``}>Native / desktop client (loopback redirect)</label><p class="help">The authentication method is fixed at registration.</p><button>Save client</button></form></details>`:``,c=[`<button class="secondary" data-revoke="${i}">Revoke authorization</button>`,`<button class="secondary" data-block="${i}" data-blocked="${e.blocked?`true`:`false`}">${e.blocked?`Unblock client`:`Block client`}</button>`,r&&e.token_endpoint_auth_method!==`none`?`<button class="secondary" data-rotate="${i}">Rotate secret</button>`:``,r?`<button class="danger" data-delete="${i}">Delete client</button>`:``].join(``);return`<article class="card client"><div class="client-heading"><h3>${$(e.client_name??`Unnamed client`)}</h3><span class="tag">${e.token_endpoint_auth_method===`none`?`PUBLIC · PKCE`:`CONFIDENTIAL · PKCE`}</span></div><p class="help">${Mj[e.onboarding??`managed`]}${e.blocked?` · BLOCKED`:``}</p><label>Client ID<code>${i}</code></label><label>Redirect URIs${e.redirect_uris.map(e=>`<code>${$(e)}</code>`).join(``)}</label>
|
|
44
|
+
<h3>${r?`Allowed Resources`:`Resources eligible for consent`}</h3>${a}${o}${s}<div class="actions">${c}</div></article>`},Wj=e=>`<p class="eyebrow">MANAGED REGISTRATION</p><h2>Register client</h2><form id="register"><fieldset><label>Client name<input name="name" required maxlength="100" placeholder="My MCP client"></label><label>Redirect URIs (one per line)<textarea name="redirect_uris" required rows="3" placeholder="https://app.internal/callback"></textarea></label><fieldset><legend>Allowed Resources (optional)</legend>${Lj(e,[])||`<p class="help">You can configure Resource access after registration.</p>`}</fieldset><label class="checkbox"><input type="checkbox" name="native">Native / desktop client (loopback redirect)</label><label>Client authentication<select name="token_endpoint_auth_method">${Object.entries(Sj).map(([e,t])=>`<option value="${e}">${t}</option>`).join(``)}</select></label><button>Register client +</button></fieldset><p class="help">S256 PKCE is always required. Clients you register here are first party and skip the consent screen.</p></form>`;async function Gj(){let[e,t]=await Promise.all([sj(oj.administration.listClients({payload:{}})),sj(oj.administration.listApiKeys({payload:{}}))]),{resources:n}=e,r=n.filter(e=>!e.builtIn),i=t=>e.clientAccess.filter(e=>e.client_id===t).map(e=>e.resource);uj.className=`dashboard`,uj.innerHTML=`
|
|
45
45
|
<div class="page-title"><div><p class="eyebrow">CONTROL PLANE</p><h1>Clients and Resources</h1><p class="muted">Signed in as ${$(e.email)}</p></div><button id="logout" class="secondary">Sign out</button></div>
|
|
46
46
|
<div class="issuer"><span class="dot"></span><span>Canonical issuer</span><code>${$(e.issuer)}</code></div>
|
|
47
47
|
<p id="message" role="alert" tabindex="-1"></p>
|
|
48
48
|
<section id="credentials" class="card hidden" aria-live="polite"></section>
|
|
49
49
|
<fieldset id="dashboard-mutations" aria-label="Clients and Resources">
|
|
50
|
-
${
|
|
51
|
-
${
|
|
52
|
-
${
|
|
53
|
-
</fieldset>`,
|
|
50
|
+
${Pj(`Resources`,n.length,`Protected APIs and MCP servers, and the scopes they define.`,n.map(t=>zj(t,e.clients.filter(e=>Nj(e)&&i(e.client_id).includes(t.identifier)))).join(``)||Fj(`Add your first Resource`,`Define a protected API or MCP server. Compatible MCP clients onboard automatically when you connect.`),Bj())}
|
|
51
|
+
${Pj(`API keys`,t.keys.length,`Direct access for CLIs and automation. Keys carry only the scopes you select, filtered by current Resource policy. Policy changes do not revoke stored grants; restoring policy restores access.`,t.keys.map(e=>Vj(e,r)).join(``)||Fj(`No API keys`,`Create a key for a CLI or automation that needs direct access.`),Hj(r))}
|
|
52
|
+
${Pj(`Clients`,e.clients.length,`Compatible MCP clients register themselves when they connect; registration alone grants no access. Revoking or blocking stops new authorization and refresh at once; already-issued access tokens stay valid until they expire, at most fifteen minutes.`,e.clients.map(e=>Uj(e,n,i(e.client_id))).join(``)||Fj(`No Clients registered`,`Connect your MCP client to a configured server to onboard automatically, or register a managed Client here.`),Wj(n))}
|
|
53
|
+
</fieldset>`,Oj();let a=e=>document.querySelector(e),o=(e,t)=>e.addEventListener(`submit`,n=>{n.preventDefault(),pj(()=>t(e))}),s=(e,t)=>{for(let n of uj.querySelectorAll(e))n.addEventListener(`click`,()=>t(n))};document.querySelector(`#logout`).addEventListener(`click`,()=>{pj(async()=>{await cj.signOut(),location.assign(`/login`)})}),o(a(`#register`),async e=>{let t=new FormData(e),n=await sj(oj.administration.createClient({payload:{client_name:vj(t,`name`),redirect_uris:xj(t),resources:yj(e),application_type:wj(t),token_endpoint_auth_method:Cj(t)}}));e.reset(),Dj.set(n.client_id,n),kj(),await Aj()}),o(a(`#key-create`),async e=>{let t=new FormData(e),n=vj(t,`expiry`),r=await sj(oj.administration.createApiKey({payload:{name:vj(t,`name`),permissions:Tj(e),expiresAt:n?new Date(n).toISOString():null}}));Ej.set(r.keyId,`${r.name}\n${r.key}`),e.reset(),kj(),await Aj()}),o(a(`#resource-create`),async e=>{let t=new FormData(e);await sj(oj.administration.createResource({payload:{identifier:vj(t,`identifier`),...bj(t)}})),e.reset(),await Aj()});for(let e of uj.querySelectorAll(`[data-key-rename]`))o(e,async e=>{await sj(oj.administration.updateApiKey({payload:{keyId:e.dataset.keyRename,name:vj(new FormData(e),`name`)}})),await Aj()});for(let e of uj.querySelectorAll(`[data-key-grants]`))o(e,async e=>{await sj(oj.administration.updateApiKey({payload:{keyId:e.dataset.keyGrants,permissions:Tj(e)}})),await Aj()});for(let e of uj.querySelectorAll(`[data-resource-edit]`))o(e,async e=>{let t=n.find(t=>t.identifier===e.dataset.resourceEdit);await sj(oj.administration.updateResource({payload:{identifier:e.dataset.resourceEdit,name:vj(new FormData(e),`name`),scopes:t.builtIn?t.scopes:bj(new FormData(e)).scopes}})),await Aj()});for(let e of uj.querySelectorAll(`[data-client-edit]`))o(e,async e=>{let t=new FormData(e);await sj(oj.administration.updateClient({payload:{client_id:e.dataset.clientEdit,client_name:vj(t,`name`),redirect_uris:xj(t),application_type:wj(t)}})),await Aj()});for(let e of uj.querySelectorAll(`[data-client-access]`))e.addEventListener(`submit`,t=>{t.preventDefault();let n=e.dataset.clientAccess,r=yj(e),a=i(n).filter(e=>!r.includes(e)),o=async()=>{await sj(oj.administration.setClientAccess({payload:{client_id:n,resources:r}})),await Aj()};a.length?mj(`Remove access to ${a.join(`, `)}? Stored consent remains until revoked.`,o):pj(o)});s(`[data-key-toggle]`,e=>{pj(async()=>{await sj(oj.administration.updateApiKey({payload:{keyId:e.dataset.keyToggle,enabled:e.dataset.enabled!==`true`}})),await Aj()})}),s(`[data-key-delete]`,e=>{let t=e.dataset.keyDelete;mj(`Delete this API key?`,async()=>{await sj(oj.administration.deleteApiKey({payload:{keyId:t}})),Ej.delete(t),Oj(),await Aj()})}),s(`[data-revoke]`,e=>{let t=e.dataset.revoke;mj(`Revoke this Client’s authorization? It can request consent again.`,async()=>{await sj(oj.administration.revokeClient({payload:{client_id:t}})),await Aj()})}),s(`[data-block]`,e=>{let t=e.dataset.block,n=e.dataset.blocked!==`true`;mj(n?`Block this Client and revoke its authorization?`:`Unblock this Client?`,async()=>{await sj(oj.administration.blockClient({payload:{client_id:t,blocked:n}})),await Aj()})}),s(`[data-rotate]`,e=>{let t=e.dataset.rotate;mj(`Rotate the secret? The old one stops working immediately.`,async()=>{let e=await sj(oj.administration.rotateClientSecret({payload:{client_id:t}}));Dj.set(e.client_id,e),kj()})}),s(`[data-delete]`,e=>{let t=e.dataset.delete;mj(`Delete this Client and its grants?`,async()=>{await sj(oj.administration.deleteClient({payload:{client_id:t}})),Dj.delete(t),Oj(),await Aj()})}),s(`[data-resource-delete]`,e=>{let t=e.dataset.resourceDelete;mj(`Delete Resource ${t}? Stored grants are kept and may become usable again if it is recreated.`,async()=>{await sj(oj.administration.deleteResource({payload:{identifier:t}})),await Aj()})})}try{if((await sj(oj.issuer.setupStatus({payload:{}}))).required)location.pathname===`/setup`?hj():location.replace(`/setup`);else if(location.pathname===`/setup`){let e=await cj.getSession();location.replace(e.data?`/`:`/login`)}else location.pathname===`/consent`?await _j():!(await cj.getSession()).data||location.pathname===`/login`?gj():await Gj()}catch(e){uj.innerHTML=`<section class="card"><h1>Unable to continue</h1><p>${$(e instanceof Error?e.message:`Please try again`)}</p><a href="/login">Return to sign in</a></section>`}
|