@shivaedev/work-board 0.7.2 → 0.8.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/CHANGELOG.md +24 -0
- package/README.md +93 -2
- package/assets/agent.js +37 -0
- package/assets/native.js +32 -25
- package/dist/board.d.ts +1 -0
- package/dist/board.d.ts.map +1 -1
- package/dist/board.js +15 -2
- package/dist/board.js.map +1 -1
- package/dist/browser/client.d.ts +19 -79
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/client.js +12 -1
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/entry.d.ts +3 -0
- package/dist/browser/entry.d.ts.map +1 -0
- package/dist/browser/entry.js +7 -0
- package/dist/browser/entry.js.map +1 -0
- package/dist/browser/responses/draftSession.d.ts +8 -0
- package/dist/browser/responses/draftSession.d.ts.map +1 -0
- package/dist/browser/responses/draftSession.js +92 -0
- package/dist/browser/responses/draftSession.js.map +1 -0
- package/dist/browser/responses/drafts.d.ts +16 -0
- package/dist/browser/responses/drafts.d.ts.map +1 -0
- package/dist/browser/responses/drafts.js +49 -0
- package/dist/browser/responses/drafts.js.map +1 -0
- package/dist/browser/responses/preview.d.ts +3 -0
- package/dist/browser/responses/preview.d.ts.map +1 -0
- package/dist/browser/responses/preview.js +4 -0
- package/dist/browser/responses/preview.js.map +1 -0
- package/dist/browser/responses/schema.d.ts +127 -0
- package/dist/browser/responses/schema.d.ts.map +1 -0
- package/dist/browser/responses/schema.js +47 -0
- package/dist/browser/responses/schema.js.map +1 -0
- package/dist/browser/responses/setup.d.ts +2 -0
- package/dist/browser/responses/setup.d.ts.map +1 -0
- package/dist/browser/responses/setup.js +99 -0
- package/dist/browser/responses/setup.js.map +1 -0
- package/dist/browser/responses/submit.d.ts +4 -0
- package/dist/browser/responses/submit.d.ts.map +1 -0
- package/dist/browser/responses/submit.js +36 -0
- package/dist/browser/responses/submit.js.map +1 -0
- package/dist/browser/session.d.ts +1 -79
- package/dist/browser/session.d.ts.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +24 -15
- package/dist/cli.js.map +1 -1
- package/dist/files/changes.d.ts +1 -0
- package/dist/files/changes.d.ts.map +1 -1
- package/dist/files/changes.js +1 -1
- package/dist/files/changes.js.map +1 -1
- package/dist/http/respond.d.ts.map +1 -1
- package/dist/http/respond.js +2 -0
- package/dist/http/respond.js.map +1 -1
- package/dist/metadata/backlinks.d.ts.map +1 -1
- package/dist/metadata/backlinks.js +2 -0
- package/dist/metadata/backlinks.js.map +1 -1
- package/dist/metadata/fields.d.ts +17 -1
- package/dist/metadata/fields.d.ts.map +1 -1
- package/dist/metadata/problems.d.ts.map +1 -1
- package/dist/metadata/problems.js +2 -0
- package/dist/metadata/problems.js.map +1 -1
- package/dist/metadata/schema.d.ts +17 -1
- package/dist/metadata/schema.d.ts.map +1 -1
- package/dist/metadata/schema.js +6 -2
- package/dist/metadata/schema.js.map +1 -1
- package/dist/page/attentionDetails.d.ts.map +1 -1
- package/dist/page/attentionDetails.js +2 -1
- package/dist/page/attentionDetails.js.map +1 -1
- package/dist/page/metadataDetails.d.ts.map +1 -1
- package/dist/page/metadataDetails.js +6 -0
- package/dist/page/metadataDetails.js.map +1 -1
- package/dist/page/navigationScript.js +1 -1
- package/dist/page/shell.d.ts +1 -1
- package/dist/page/shell.d.ts.map +1 -1
- package/dist/page/shell.js.map +1 -1
- package/dist/page/style.d.ts.map +1 -1
- package/dist/page/style.js +2 -1
- package/dist/page/style.js.map +1 -1
- package/dist/page/swap.d.ts +1 -1
- package/dist/page/swap.d.ts.map +1 -1
- package/dist/page/swap.js +3 -0
- package/dist/page/swap.js.map +1 -1
- package/dist/path/Identity.d.ts +3 -0
- package/dist/path/Identity.d.ts.map +1 -0
- package/dist/path/Identity.js +3 -0
- package/dist/path/Identity.js.map +1 -0
- package/dist/responses/agent-cli.d.ts +2 -0
- package/dist/responses/agent-cli.d.ts.map +1 -0
- package/dist/responses/agent-cli.js +31 -0
- package/dist/responses/agent-cli.js.map +1 -0
- package/dist/responses/agent.d.ts +68 -0
- package/dist/responses/agent.d.ts.map +1 -0
- package/dist/responses/agent.js +49 -0
- package/dist/responses/agent.js.map +1 -0
- package/dist/responses/await.d.ts +33 -0
- package/dist/responses/await.d.ts.map +1 -0
- package/dist/responses/await.js +21 -0
- package/dist/responses/await.js.map +1 -0
- package/dist/responses/flags.d.ts +6 -0
- package/dist/responses/flags.d.ts.map +1 -0
- package/dist/responses/flags.js +23 -0
- package/dist/responses/flags.js.map +1 -0
- package/dist/responses/locate.d.ts +13 -0
- package/dist/responses/locate.d.ts.map +1 -0
- package/dist/responses/locate.js +50 -0
- package/dist/responses/locate.js.map +1 -0
- package/dist/responses/outcome.d.ts +65 -0
- package/dist/responses/outcome.d.ts.map +1 -0
- package/dist/responses/outcome.js +14 -0
- package/dist/responses/outcome.js.map +1 -0
- package/dist/responses/page.d.ts +6 -0
- package/dist/responses/page.d.ts.map +1 -0
- package/dist/responses/page.js +25 -0
- package/dist/responses/page.js.map +1 -0
- package/dist/responses/publish.d.ts +4 -0
- package/dist/responses/publish.d.ts.map +1 -0
- package/dist/responses/publish.js +56 -0
- package/dist/responses/publish.js.map +1 -0
- package/dist/responses/publishIn.d.ts +3 -0
- package/dist/responses/publishIn.d.ts.map +1 -0
- package/dist/responses/publishIn.js +69 -0
- package/dist/responses/publishIn.js.map +1 -0
- package/dist/responses/read.d.ts +30 -0
- package/dist/responses/read.d.ts.map +1 -0
- package/dist/responses/read.js +43 -0
- package/dist/responses/read.js.map +1 -0
- package/dist/responses/records.d.ts +12 -0
- package/dist/responses/records.d.ts.map +1 -0
- package/dist/responses/records.js +47 -0
- package/dist/responses/records.js.map +1 -0
- package/dist/responses/retry.d.ts +22 -0
- package/dist/responses/retry.d.ts.map +1 -0
- package/dist/responses/retry.js +14 -0
- package/dist/responses/retry.js.map +1 -0
- package/dist/responses/service.d.ts +106 -0
- package/dist/responses/service.d.ts.map +1 -0
- package/dist/responses/service.js +90 -0
- package/dist/responses/service.js.map +1 -0
- package/dist/responses/waitFor.d.ts +31 -0
- package/dist/responses/waitFor.d.ts.map +1 -0
- package/dist/responses/waitFor.js +47 -0
- package/dist/responses/waitFor.js.map +1 -0
- package/dist/rpc/contract.d.ts +101 -2
- package/dist/rpc/contract.d.ts.map +1 -1
- package/dist/rpc/contract.js +3 -2
- package/dist/rpc/contract.js.map +1 -1
- package/dist/rpc/responseContract.d.ts +212 -0
- package/dist/rpc/responseContract.d.ts.map +1 -0
- package/dist/rpc/responseContract.js +37 -0
- package/dist/rpc/responseContract.js.map +1 -0
- package/dist/rpc/server.d.ts +3 -1
- package/dist/rpc/server.d.ts.map +1 -1
- package/dist/rpc/server.js +6 -1
- package/dist/rpc/server.js.map +1 -1
- package/dist/serve-cli.d.ts +3 -0
- package/dist/serve-cli.d.ts.map +1 -0
- package/dist/serve-cli.js +20 -0
- package/dist/serve-cli.js.map +1 -0
- package/package.json +2 -2
- package/src/board.ts +16 -2
- package/src/browser/client.ts +30 -4
- package/src/browser/entry.ts +9 -0
- package/src/browser/responses/draftSession.ts +88 -0
- package/src/browser/responses/drafts.ts +58 -0
- package/src/browser/responses/preview.ts +5 -0
- package/src/browser/responses/schema.ts +52 -0
- package/src/browser/responses/setup.ts +102 -0
- package/src/browser/responses/submit.ts +41 -0
- package/src/cli.ts +14 -22
- package/src/files/changes.ts +2 -1
- package/src/http/respond.ts +2 -0
- package/src/metadata/backlinks.ts +2 -0
- package/src/metadata/problems.ts +2 -0
- package/src/metadata/schema.ts +6 -2
- package/src/page/attentionDetails.ts +2 -1
- package/src/page/metadataDetails.ts +6 -0
- package/src/page/navigationScript.ts +1 -1
- package/src/page/shell.ts +1 -1
- package/src/page/style.ts +2 -1
- package/src/page/swap.ts +3 -0
- package/src/path/Identity.ts +3 -0
- package/src/responses/agent-cli.ts +35 -0
- package/src/responses/agent.ts +59 -0
- package/src/responses/await.ts +21 -0
- package/src/responses/flags.ts +22 -0
- package/src/responses/locate.ts +55 -0
- package/src/responses/outcome.ts +15 -0
- package/src/responses/page.ts +41 -0
- package/src/responses/publish.ts +53 -0
- package/src/responses/publishIn.ts +64 -0
- package/src/responses/read.ts +45 -0
- package/src/responses/records.ts +53 -0
- package/src/responses/retry.ts +23 -0
- package/src/responses/service.ts +106 -0
- package/src/responses/waitFor.ts +58 -0
- package/src/rpc/contract.ts +3 -2
- package/src/rpc/responseContract.ts +46 -0
- package/src/rpc/server.ts +8 -1
- package/src/serve-cli.ts +37 -0
package/assets/native.js
CHANGED
|
@@ -1,36 +1,43 @@
|
|
|
1
|
-
var kH=Object.defineProperty;var Hs=(e,t)=>{for(var n in t)kH(e,n,{get:t[n],enumerable:!0})};var ie=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let r=0,o=t.length;r<o;r++)n=t[r](n);return n}}},CH={pipe(){return ie(this,arguments)}},Mc=(function(){function e(){}return e.prototype=CH,e})();var d=function(e,t){if(typeof e=="function")return function(){return e(arguments)?t.apply(this,arguments):n=>t(n,...arguments)};switch(e){case 0:case 1:throw new RangeError(`Invalid arity ${e}`);case 2:return function(n,r){return arguments.length>=2?t(n,r):function(o){return t(o,n)}};case 3:return function(n,r,o){return arguments.length>=3?t(n,r,o):function(s){return t(s,n,r)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(r){return t(r,...n)}}}};var L=e=>e;var Qe=e=>()=>e,Xt=Qe(!0),Pc=Qe(!1),kE=Qe(null),es=Qe(void 0),bn=es;function of(e,...t){return ie(e,t)}function Fc(e,t,n,r,o,s,i,a,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return o(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(o(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return i(s(o(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return a(i(s(o(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return c(a(i(s(o(r(n(t(e.apply(this,arguments)))))))))}}}function wn(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let o=e(n);return t.set(n,o),o}}function Uc(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let o=e(n);return t.set(n,o),t.set(o,o),o}}var cd=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete("stack");let n=Object.getPrototypeOf(e),r=n;for(;r!==null&&r!==Object.prototype;){let o=Reflect.ownKeys(r);for(let s=0;s<o.length;s++)t.add(o[s]);r=Object.getPrototypeOf(r)}return t.has("constructor")&&typeof e.constructor=="function"&&n===e.constructor.prototype&&t.delete("constructor"),t},sf=new WeakSet;function oo(e){return typeof e=="string"}function ud(e){return typeof e=="number"}function EA(e){return typeof e=="boolean"}function bA(e){return typeof e=="bigint"}function CE(e){return typeof e=="symbol"}function dh(e){return oo(e)||ud(e)||CE(e)}function cn(e){return typeof e=="function"}function wA(e){return e===void 0}function Kn(e){return e!==void 0}function IA(e){return e==null}function ph(e){return e!=null}function vA(e){return!1}function AE(e){return!0}function fd(e){return typeof e=="object"&&e!==null}function en(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ld(e){return typeof e=="object"&&e!==null||cn(e)}var B=d(2,(e,t)=>ld(e)&&t in e),yr=d(2,(e,t)=>B(e,"_tag")&&e._tag===t);function TA(e){return e instanceof Error}function Ws(e){return B(e,Symbol.iterator)||oo(e)}var Re="~effect/interfaces/Hash",ce=e=>{switch(typeof e){case"number":return Dr(e);case"bigint":return it(e.toString(10));case"boolean":return it(String(e));case"symbol":return it(String(e));case"string":return it(e);case"undefined":return it("undefined");case"function":case"object":{if(e===null)return it("null");if(e instanceof Date)return Number.isNaN(e.getTime())?it("Invalid Date"):it(e.toISOString());if(e instanceof RegExp)return it(e.toString());{if(sf.has(e))return mh(e);if(RE.has(e))return RE.get(e);let t=_H(e,()=>AH(e)?e[Re]():typeof e=="function"?mh(e):e instanceof DataView?Aa(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):Array.isArray(e)||ArrayBuffer.isView(e)?Aa(e):e instanceof Map?OH(e):e instanceof Set?RH(e):dd(e));return RE.set(e,t),t}}default:throw new Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},mh=e=>(OE.has(e)||OE.set(e,Dr(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),OE.get(e)),Nt=d(2,(e,t)=>e*53^t),Oa=e=>e&3221225471|e>>>1&1073741824,AH=e=>B(e,Re),Dr=e=>{if(e!==e)return it("NaN");if(e===1/0)return it("Infinity");if(e===-1/0)return it("-Infinity");let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return Oa(t)},it=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return Oa(t)},ME=(e,t)=>{let n=12289;for(let r of t)n^=Nt(ce(r),ce(e[r]));return Oa(n)},dd=e=>ME(e,cd(e)),PE=(e,t)=>n=>{let r=e;for(let o of n)r^=t(o);return Oa(r)},Aa=PE(6151,ce),OH=PE(it("Map"),([e,t])=>Nt(ce(e),ce(t))),RH=PE(it("Set"),ce),OE=new WeakMap,RE=new WeakMap,_E=new WeakSet;function _H(e,t){if(_E.has(e))return it("[Circular]");_E.add(e);let n=t();return _E.delete(e),n}var _e="~effect/interfaces/Equal";function ae(){return arguments.length===1?e=>Dc(e,arguments[0]):Dc(arguments[0],arguments[1])}function Dc(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n!==typeof t?!1:n==="number"&&e!==e&&t!==t?!0:n!=="object"&&n!=="function"||sf.has(e)||sf.has(t)?!1:FH(e,t,PH)}function MH(e,t,n){let r=FE.has(e),o=UE.has(t);if(r&&o)return!0;if(r||o)return!1;FE.add(e),UE.add(t);let s=n();return FE.delete(e),UE.delete(t),s}var FE=new WeakSet,UE=new WeakSet;function PH(e,t){if(ce(e)!==ce(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let s=e.getTime(),i=t.getTime();return s===i||Number.isNaN(s)&&Number.isNaN(i)}else if(e instanceof RegExp)return t instanceof RegExp?e.toString()===t.toString():!1;let n=CA(e),r=CA(t);if(n!==r)return!1;let o=n&&r;return typeof e=="function"&&!o?!1:MH(e,t,()=>{if(o)return e[_e](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:UH(e,t);if(ArrayBuffer.isView(e)){let s=e instanceof DataView;if(!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||s!==t instanceof DataView)return!1;if(s){let i=t;return kA(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(i.buffer,i.byteOffset,i.byteLength))}return kA(e,t)}else{if(e instanceof Map)return!(t instanceof Map)||e.size!==t.size?!1:NH(e,t);if(e instanceof Set)return!(t instanceof Set)||e.size!==t.size?!1:LH(e,t)}return DH(e,t)})}function FH(e,t,n){let r=hh.get(e);if(!r)r=new WeakMap,hh.set(e,r);else if(r.has(t))return r.get(t);let o=n(e,t);r.set(t,o);let s=hh.get(t);return s||(s=new WeakMap,hh.set(t,s)),s.set(e,o),o}var hh=new WeakMap;function UH(e,t){for(let n=0;n<e.length;n++)if(!Dc(e[n],t[n]))return!1;return!0}function kA(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function DH(e,t){let n=cd(e),r=cd(t);if(n.size!==r.size)return!1;for(let o of n)if(!r.has(o)||!Dc(e[o],t[o]))return!1;return!0}function gh(e,t){return function(r,o){let s=Array.from(o);for(let[i,a]of r){let c=!1;for(let u=0;u<s.length;u++){let[f,l]=s[u];if(e(i,f)&&t(a,l)){s[u]=s[s.length-1],s.pop(),c=!0;break}}if(!c)return!1}return!0}}var NH=gh(Dc,Dc);function xh(e){return function(n,r){let o=Array.from(r);for(let s of n){let i=!1;for(let a=0;a<o.length;a++){let c=o[a];if(e(s,c)){o[a]=o[o.length-1],o.pop(),i=!0;break}}if(!i)return!1}return!0}}var LH=xh(Dc),CA=e=>B(e,_e),pd=()=>ae;var DE=e=>(sf.add(e),e);function wo(e,t,n){return{combine:e,initialValue:t,combineAll:n??(r=>{let o=t;for(let s of r)o=e(o,s);return o})}}var un=e=>(t,n)=>t===n||e(t,n),BH=(e,t)=>e===t,Nc=()=>BH;function AA(e){return un((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e[r](t[r],n[r]))return!1;return!0})}function yh(e){return un((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0})}var NE=e=>e.length>0;var Sh=e=>d(3,(t,n,r)=>e(t,o=>({...o,[n]:r(o)}))),Eh=e=>d(2,(t,n)=>e(t,r=>({[n]:r}))),bh=(e,t)=>d(3,(n,r,o)=>t(n,s=>e(o(s),i=>({...s,[r]:i}))));function W(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function wh(e,t){for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&W(e,n,t[n])}var Le={};Hs(Le,{Do:()=>_W,all:()=>SW,andThen:()=>hW,as:()=>KA,asVoid:()=>pW,bind:()=>RW,bindTo:()=>AW,composeK:()=>xW,contains:()=>kW,containsWith:()=>YA,exists:()=>CW,filter:()=>Na,filterMap:()=>wW,firstSomeOf:()=>lW,flatMap:()=>rs,flatMapNullishOr:()=>YE,flatten:()=>Vc,fromIterable:()=>sW,fromNullOr:()=>ZE,fromNullishOr:()=>Kc,fromUndefinedOr:()=>GE,gen:()=>MW,getFailure:()=>aW,getOrElse:()=>Ua,getOrNull:()=>Td,getOrThrow:()=>QE,getOrThrowWith:()=>kd,getOrUndefined:()=>Ao,getSuccess:()=>iW,isNone:()=>ge,isOption:()=>Gs,isSome:()=>Te,let:()=>OW,lift2:()=>vW,liftNullishOr:()=>dW,liftPredicate:()=>TW,liftThrowable:()=>Da,makeCombinerFailFast:()=>XA,makeEquivalence:()=>XE,makeOrder:()=>IW,makeReducer:()=>PW,makeReducerFailFast:()=>FW,map:()=>Lt,match:()=>rr,none:()=>U,orElse:()=>cW,orElseResult:()=>fW,orElseSome:()=>uW,partitionMap:()=>bW,product:()=>GA,productMany:()=>yW,reduceCompact:()=>EW,some:()=>N,tap:()=>JA,toArray:()=>QA,toRefinement:()=>oW,void:()=>mW,zipLeft:()=>gW,zipRight:()=>VA,zipWith:()=>ZA});function Ih(e){return{combine:e}}var Lc=Symbol.for("~effect/Redactable"),$H=e=>B(e,Lc);function Io(e){return $H(e)?BE(e):e}function BE(e){return e[Lc](globalThis[cf]?.context??qH)}var cf="~effect/Fiber/currentFiber",RA=new Map,qH={"~effect/Context":{},base:RA,depth:0,mapUnsafe:RA,pipe(){return ie(this,arguments)}};function X(e,t){let n=t?.space??0,r=new WeakSet,o=n?typeof n=="number"?" ".repeat(n):n:"",s=u=>o.repeat(u),i=(u,f)=>{let l=u?.constructor;return l&&l!==Object.prototype.constructor&&l.name?`${l.name}(${f})`:f},a=u=>{try{return Reflect.ownKeys(u)}catch{return["[ownKeys threw]"]}};function c(u,f=0){if(typeof u=="string")return JSON.stringify(u);if(typeof u=="number"||u==null||typeof u=="boolean"||typeof u=="symbol")return String(u);if(typeof u=="bigint")return String(u)+"n";if(typeof u=="object"||typeof u=="function"){if(r.has(u))return zH;r.add(u);let l;if(Lc in u)l=c(BE(u),f);else if(Array.isArray(u))l=!o||u.length<=1?`[${u.map(p=>c(p,f)).join(",")}]`:`[
|
|
1
|
+
var YH=Object.defineProperty;var ns=(e,t)=>{for(var n in t)YH(e,n,{get:t[n],enumerable:!0})};var ie=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let r=0,o=t.length;r<o;r++)n=t[r](n);return n}}},XH={pipe(){return ie(this,arguments)}},Bc=(function(){function e(){}return e.prototype=XH,e})();var d=function(e,t){if(typeof e=="function")return function(){return e(arguments)?t.apply(this,arguments):n=>t(n,...arguments)};switch(e){case 0:case 1:throw new RangeError(`Invalid arity ${e}`);case 2:return function(n,r){return arguments.length>=2?t(n,r):function(o){return t(o,n)}};case 3:return function(n,r,o){return arguments.length>=3?t(n,r,o):function(s){return t(s,n,r)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(r){return t(r,...n)}}}};var B=e=>e;var Qe=e=>()=>e,Xt=Qe(!0),jc=Qe(!1),jb=Qe(null),rs=Qe(void 0),En=rs;function lf(e,...t){return ie(e,t)}function qc(e,t,n,r,o,s,i,a,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return o(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(o(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return i(s(o(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return a(i(s(o(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return c(a(i(s(o(r(n(t(e.apply(this,arguments)))))))))}}}function wn(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let o=e(n);return t.set(n,o),o}}function $c(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let o=e(n);return t.set(n,o),t.set(o,o),o}}var pd=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete("stack");let n=Object.getPrototypeOf(e),r=n;for(;r!==null&&r!==Object.prototype;){let o=Reflect.ownKeys(r);for(let s=0;s<o.length;s++)t.add(o[s]);r=Object.getPrototypeOf(r)}return t.has("constructor")&&typeof e.constructor=="function"&&n===e.constructor.prototype&&t.delete("constructor"),t},df=new WeakSet;function io(e){return typeof e=="string"}function md(e){return typeof e=="number"}function DA(e){return typeof e=="boolean"}function NA(e){return typeof e=="bigint"}function qb(e){return typeof e=="symbol"}function yh(e){return io(e)||md(e)||qb(e)}function cn(e){return typeof e=="function"}function LA(e){return e===void 0}function Kn(e){return e!==void 0}function BA(e){return e==null}function Sh(e){return e!=null}function jA(e){return!1}function $b(e){return!0}function hd(e){return typeof e=="object"&&e!==null}function en(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function gd(e){return typeof e=="object"&&e!==null||cn(e)}var j=d(2,(e,t)=>gd(e)&&t in e),yr=d(2,(e,t)=>j(e,"_tag")&&e._tag===t);function qA(e){return e instanceof Error}function Js(e){return j(e,Symbol.iterator)||io(e)}var Oe="~effect/interfaces/Hash",ce=e=>{switch(typeof e){case"number":return Nr(e);case"bigint":return it(e.toString(10));case"boolean":return it(String(e));case"symbol":return it(String(e));case"string":return it(e);case"undefined":return it("undefined");case"function":case"object":{if(e===null)return it("null");if(e instanceof Date)return Number.isNaN(e.getTime())?it("Invalid Date"):it(e.toISOString());if(e instanceof RegExp)return it(e.toString());{if(df.has(e))return bh(e);if(Hb.has(e))return Hb.get(e);let t=rW(e,()=>eW(e)?e[Oe]():typeof e=="function"?bh(e):e instanceof DataView?Fa(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):Array.isArray(e)||ArrayBuffer.isView(e)?Fa(e):e instanceof Map?tW(e):e instanceof Set?nW(e):xd(e));return Hb.set(e,t),t}}default:throw new Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},bh=e=>(zb.has(e)||zb.set(e,Nr(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),zb.get(e)),Nt=d(2,(e,t)=>e*53^t),Ua=e=>e&3221225471|e>>>1&1073741824,eW=e=>j(e,Oe),Nr=e=>{if(e!==e)return it("NaN");if(e===1/0)return it("Infinity");if(e===-1/0)return it("-Infinity");let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return Ua(t)},it=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return Ua(t)},Kb=(e,t)=>{let n=12289;for(let r of t)n^=Nt(ce(r),ce(e[r]));return Ua(n)},xd=e=>Kb(e,pd(e)),Vb=(e,t)=>n=>{let r=e;for(let o of n)r^=t(o);return Ua(r)},Fa=Vb(6151,ce),tW=Vb(it("Map"),([e,t])=>Nt(ce(e),ce(t))),nW=Vb(it("Set"),ce),zb=new WeakMap,Hb=new WeakMap,Wb=new WeakSet;function rW(e,t){if(Wb.has(e))return it("[Circular]");Wb.add(e);let n=t();return Wb.delete(e),n}var _e="~effect/interfaces/Equal";function ae(){return arguments.length===1?e=>zc(e,arguments[0]):zc(arguments[0],arguments[1])}function zc(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n!==typeof t?!1:n==="number"&&e!==e&&t!==t?!0:n!=="object"&&n!=="function"||df.has(e)||df.has(t)?!1:iW(e,t,sW)}function oW(e,t,n){let r=Jb.has(e),o=Gb.has(t);if(r&&o)return!0;if(r||o)return!1;Jb.add(e),Gb.add(t);let s=n();return Jb.delete(e),Gb.delete(t),s}var Jb=new WeakSet,Gb=new WeakSet;function sW(e,t){if(ce(e)!==ce(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let s=e.getTime(),i=t.getTime();return s===i||Number.isNaN(s)&&Number.isNaN(i)}else if(e instanceof RegExp)return t instanceof RegExp?e.toString()===t.toString():!1;let n=zA(e),r=zA(t);if(n!==r)return!1;let o=n&&r;return typeof e=="function"&&!o?!1:oW(e,t,()=>{if(o)return e[_e](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:aW(e,t);if(ArrayBuffer.isView(e)){let s=e instanceof DataView;if(!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||s!==t instanceof DataView)return!1;if(s){let i=t;return $A(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(i.buffer,i.byteOffset,i.byteLength))}return $A(e,t)}else{if(e instanceof Map)return!(t instanceof Map)||e.size!==t.size?!1:uW(e,t);if(e instanceof Set)return!(t instanceof Set)||e.size!==t.size?!1:fW(e,t)}return cW(e,t)})}function iW(e,t,n){let r=Eh.get(e);if(!r)r=new WeakMap,Eh.set(e,r);else if(r.has(t))return r.get(t);let o=n(e,t);r.set(t,o);let s=Eh.get(t);return s||(s=new WeakMap,Eh.set(t,s)),s.set(e,o),o}var Eh=new WeakMap;function aW(e,t){for(let n=0;n<e.length;n++)if(!zc(e[n],t[n]))return!1;return!0}function $A(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function cW(e,t){let n=pd(e),r=pd(t);if(n.size!==r.size)return!1;for(let o of n)if(!r.has(o)||!zc(e[o],t[o]))return!1;return!0}function wh(e,t){return function(r,o){let s=Array.from(o);for(let[i,a]of r){let c=!1;for(let u=0;u<s.length;u++){let[f,l]=s[u];if(e(i,f)&&t(a,l)){s[u]=s[s.length-1],s.pop(),c=!0;break}}if(!c)return!1}return!0}}var uW=wh(zc,zc);function Ih(e){return function(n,r){let o=Array.from(r);for(let s of n){let i=!1;for(let a=0;a<o.length;a++){let c=o[a];if(e(s,c)){o[a]=o[o.length-1],o.pop(),i=!0;break}}if(!i)return!1}return!0}}var fW=Ih(zc),zA=e=>j(e,_e),yd=()=>ae;var Zb=e=>(df.add(e),e);function vo(e,t,n){return{combine:e,initialValue:t,combineAll:n??(r=>{let o=t;for(let s of r)o=e(o,s);return o})}}var un=e=>(t,n)=>t===n||e(t,n),lW=(e,t)=>e===t,Hc=()=>lW;function HA(e){return un((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e[r](t[r],n[r]))return!1;return!0})}function vh(e){return un((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0})}var Qb=e=>e.length>0;var Th=e=>d(3,(t,n,r)=>e(t,o=>({...o,[n]:r(o)}))),kh=e=>d(2,(t,n)=>e(t,r=>({[n]:r}))),Ch=(e,t)=>d(3,(n,r,o)=>t(n,s=>e(o(s),i=>({...s,[r]:i}))));function W(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function Ah(e,t){for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&W(e,n,t[n])}var Le={};ns(Le,{Do:()=>r3,all:()=>WW,andThen:()=>qW,as:()=>cR,asVoid:()=>BW,bind:()=>n3,bindTo:()=>e3,composeK:()=>zW,contains:()=>YW,containsWith:()=>mR,exists:()=>XW,filter:()=>za,filterMap:()=>JW,firstSomeOf:()=>NW,flatMap:()=>is,flatMapNullishOr:()=>dE,flatten:()=>eu,fromIterable:()=>_W,fromNullOr:()=>fE,fromNullishOr:()=>Xc,fromUndefinedOr:()=>uE,gen:()=>o3,getFailure:()=>PW,getOrElse:()=>qa,getOrNull:()=>Od,getOrThrow:()=>lE,getOrThrowWith:()=>_d,getOrUndefined:()=>Oo,getSuccess:()=>MW,isNone:()=>xe,isOption:()=>Ys,isSome:()=>Te,let:()=>t3,lift2:()=>ZW,liftNullishOr:()=>LW,liftPredicate:()=>QW,liftThrowable:()=>$a,makeCombinerFailFast:()=>hR,makeEquivalence:()=>pE,makeOrder:()=>GW,makeReducer:()=>s3,makeReducerFailFast:()=>i3,map:()=>Lt,match:()=>rr,none:()=>D,orElse:()=>FW,orElseResult:()=>DW,orElseSome:()=>UW,partitionMap:()=>VW,product:()=>lR,productMany:()=>HW,reduceCompact:()=>KW,some:()=>L,tap:()=>fR,toArray:()=>pR,toRefinement:()=>OW,void:()=>jW,zipLeft:()=>$W,zipRight:()=>uR,zipWith:()=>dR});function Rh(e){return{combine:e}}var Wc=Symbol.for("~effect/Redactable"),pW=e=>j(e,Wc);function To(e){return pW(e)?Xb(e):e}function Xb(e){return e[Wc](globalThis[mf]?.context??mW)}var mf="~effect/Fiber/currentFiber",KA=new Map,mW={"~effect/Context":{},base:KA,depth:0,mapUnsafe:KA,pipe(){return ie(this,arguments)}};function X(e,t){let n=t?.space??0,r=new WeakSet,o=n?typeof n=="number"?" ".repeat(n):n:"",s=u=>o.repeat(u),i=(u,f)=>{let l=u?.constructor;return l&&l!==Object.prototype.constructor&&l.name?`${l.name}(${f})`:f},a=u=>{try{return Reflect.ownKeys(u)}catch{return["[ownKeys threw]"]}};function c(u,f=0){if(typeof u=="string")return JSON.stringify(u);if(typeof u=="number"||u==null||typeof u=="boolean"||typeof u=="symbol")return String(u);if(typeof u=="bigint")return String(u)+"n";if(typeof u=="object"||typeof u=="function"){if(r.has(u))return hW;r.add(u);let l;if(Wc in u)l=c(Xb(u),f);else if(Array.isArray(u))l=!o||u.length<=1?`[${u.map(p=>c(p,f)).join(",")}]`:`[
|
|
2
2
|
${s(f+1)}${u.map(p=>c(p,f+1)).join(`,
|
|
3
3
|
`+s(f+1))}
|
|
4
|
-
${s(f)}]`;else if(u instanceof Date)l=
|
|
5
|
-
${p.map(h=>`${s(f+1)}${
|
|
4
|
+
${s(f)}]`;else if(u instanceof Date)l=eE(u);else if(!t?.ignoreToString&&j(u,"toString")&&typeof u.toString=="function"&&u.toString!==Object.prototype.toString&&u.toString!==Array.prototype.toString){let p=gW(u);l=u instanceof Error&&u.cause?`${p} (cause: ${c(u.cause,f)})`:p}else if(Symbol.iterator in u)l=`${u.constructor.name}(${c(Array.from(u),f)})`;else{let p=a(u);if(!o||p.length<=1){let m=`{${p.map(h=>`${qi(h)}:${c(u[h],f)}`).join(",")}}`;l=i(u,m)}else{let m=`{
|
|
5
|
+
${p.map(h=>`${s(f+1)}${qi(h)}: ${c(u[h],f+1)}`).join(`,
|
|
6
6
|
`)}
|
|
7
|
-
${s(f)}}`;l=i(u,m)}}return r.delete(u),l}return String(u)}return c(e,0)}var zH="[Circular]";function Ui(e){return typeof e=="string"?JSON.stringify(e):String(e)}function vh(e){return e.map(t=>`[${Ui(t)}]`).join("")}function jE(e){try{return e.toISOString()}catch{return"Invalid Date"}}function HH(e){try{let t=e.toString();return typeof t=="string"?t:String(t)}catch{return"[toString threw]"}}function Bc(e,t){let n=[];return JSON.stringify(e,function(r,o){let s=Object.getOwnPropertyDescriptor(this,r)?.value,i=B(s,Lc)?Io(s):Io(o);if(typeof i=="bigint")return X(i);if(typeof i!="object"||i===null)return i;for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(!n.includes(i))return n.push(i),i},t?.space)??"null"}var at=Symbol.for("nodejs.util.inspect.custom"),hn=e=>{try{return e=Io(e),B(e,"toJSON")&&cn(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(hn):e}catch{return"[toJSON threw]"}},MA=(e,t=2)=>{if(typeof e=="string")return e;try{return typeof e=="object"?Bc(e,{space:t}):X(e,{space:t})}catch{return String(e)}},Ks={toJSON(){return hn(this)},[at](){return this.toJSON()},toString(){return X(this.toJSON())}},Th=class{[at](){return this.toJSON()}toString(){return X(this.toJSON())}};var _a=class e{called=!1;self;constructor(t){this.self=t}next(t){return this.called?{value:t,done:!0}:(this.called=!0,{value:this.self,done:!1})}[Symbol.iterator](){return new e(this.self)}},KH=()=>{let e="~effect/Utils/internal",t={[e]:o=>o()},n={[e]:o=>o()};return t[e](()=>new Error().stack)?.includes(e)===!0?t[e]:n[e]},je=KH();var Js="~effect/Effect",jc="~effect/Exit",JH={_A:L,_E:L,_R:L},FA=`${Js}/identifier`,xe=`${Js}/args`,nn=`${Js}/evaluate`,Sr=`${Js}/successCont`,vo=`${Js}/failureCont`,Ma=`${Js}/ensureCont`,qc=Symbol.for("effect/Effect/Yield"),vn={pipe(){return ie(this,arguments)},toJSON(){return{...this}},toString(){return X(this.toJSON(),{ignoreToString:!0,space:2})},[at](){return this.toJSON()}},UA={[Re](){return ME(this,Object.keys(this))},[_e](e){let t=Object.keys(this),n=Object.keys(e);if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==n[r]||!ae(this[t[r]],e[t[r]]))return!1;return!0}},GH={[Js]:JH,...vn,[Symbol.iterator](){return new _a(this)},toJSON(){return{_id:"Effect",op:this[FA],...xe in this?{args:this[xe]}:void 0}}},ve=e=>B(e,Js),$E=e=>B(e,jc),md="~effect/Cause",hd="~effect/Cause/Reason",lf=e=>B(e,md),DA=e=>B(e,hd),Vs=class{[md];reasons;constructor(t){this[md]=md,this.reasons=t}pipe(){return ie(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map(t=>t.toJSON())}}toString(){return`Cause(${X(this.reasons)})`}[at](){return this.toJSON()}[_e](t){return lf(t)&&this.reasons.length===t.reasons.length&&this.reasons.every((n,r)=>ae(n,t.reasons[r]))}[Re](){return Aa(this.reasons)}},PA=new WeakMap,uf=class{[hd];annotations;_tag;constructor(t,n,r){if(this[hd]=hd,this._tag=t,n!==xd&&typeof r=="object"&&r!==null&&n.size>0){let o=PA.get(r);o&&(n=new Map([...o,...n])),PA.set(r,n)}this.annotations=n}annotate(t,n){if(t.mapUnsafe.size===0)return this;let r=new Map(this.annotations);t.mapUnsafe.forEach((s,i)=>{n?.overwrite!==!0&&r.has(i)||r.set(i,s)});let o=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return o.annotations=r,o}pipe(){return ie(this,arguments)}toString(){return X(this)}[at](){return this.toString()}},xd=new Map,$c=class extends uf{error;constructor(t,n=xd){super("Fail",n,t),this.error=t}toString(){return`Fail(${X(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[_e](t){return Pa(t)&&ae(this.error,t.error)&&ae(this.annotations,t.annotations)}[Re](){return Nt(it(this._tag))(Nt(ce(this.error))(ce(this.annotations)))}},Di=e=>new Vs(e),Ch=new Vs([]),df=e=>new Vs([new $c(e)]),gd=class extends uf{defect;constructor(t,n=xd){super("Die",n,t),this.defect=t}toString(){return`Die(${X(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[_e](t){return Sd(t)&&ae(this.defect,t.defect)&&ae(this.annotations,t.annotations)}[Re](){return Nt(it(this._tag))(Nt(ce(this.defect))(ce(this.annotations)))}},qE=e=>new Vs([new gd(e)]),yd=d(e=>lf(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new Vs(e.reasons.map(r=>r.annotate(t,n)))),Pa=e=>e._tag==="Fail",Sd=e=>e._tag==="Die",Ed=e=>e._tag==="Interrupt";function ZH(e){return ao("Effect.evaluate: Not implemented")}var Ni=e=>({...GH,[FA]:e.op,[nn]:e[nn]??ZH,[Sr]:e[Sr],[vo]:e[vo],[Ma]:e[Ma]}),To=e=>{let t=Ni(e);return function(){let n=Object.create(t);return n[xe]=e.single===!1?arguments:arguments[0],n}},NA=e=>{let t={[jc]:jc,_tag:e.op,get[e.prop](){return this[xe]},...Ni(e),toString(){return`${e.op}(${X(this[xe])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[xe]}},[_e](n){return $E(n)&&n._tag===this._tag&&ae(this[xe],n[xe])},[Re](){return Nt(it(e.op),ce(this[xe]))}};return function(n){let r=Object.create(t);return r[xe]=n,r}},rt=NA({op:"Success",prop:"value",[nn](e){let t=e.getCont(Sr);return t?t[Sr](this[xe],e,this):e.yieldWith(this)}}),Ah={key:"effect/Cause/StackTrace"},zE={key:"effect/Cause/InterruptorStackTrace"},Rn=NA({op:"Failure",prop:"cause",[nn](e){let t=this[xe],n=!1;e.currentStackFrame&&(t=yd(t,{mapUnsafe:new Map([[Ah.key,e.currentStackFrame]])}),n=!0);let r=e.getCont(vo);for(;e.interruptible&&e._interruptedCause&&r;)r=e.getCont(vo);return r?r[vo](t,e,n?void 0:this):e.yieldWith(n?Rn(t):this)}}),io=e=>Rn(df(e)),ao=e=>Rn(qE(e)),de=To({op:"WithFiber",[nn](e){return this[xe](e)}}),QH=(function(){class e extends globalThis.Error{}let t=Ni({op:"YieldableError",[nn](){return io(this)}});return delete t.toString,Object.assign(e.prototype,t),e})(),bd=(function(){let e=Symbol.for("effect/Data/Error/plainArgs");return class extends QH{constructor(n){super(n?.message,n?.cause?{cause:n.cause}:void 0),n&&(wh(this,n),Object.defineProperty(this,e,{value:n,enumerable:!1}))}toJSON(){return{...this[e],...this}}}})(),Li=e=>{class t extends bd{_tag=e}return t.prototype.name=e,t},kh="~effect/Cause/NoSuchElementError",HE=e=>B(e,kh),ts=class extends Li("NoSuchElementError"){[kh]=kh;constructor(t){super({message:t})}},ff="~effect/Cause/Done",wd=e=>B(e,ff),LA={[ff]:ff,_tag:"Done",value:void 0},zc=e=>e===void 0?LA:{[ff]:ff,_tag:"Done",value:e},YH=io(LA),BA=e=>e===void 0?YH:io(zc(e));var jA="~effect/data/Option",$A={[jA]:{_A:e=>e},...vn,[Symbol.iterator](){return new _a(this)}},XH=Object.defineProperty(Object.assign(Object.create($A),{_tag:"Some",_op:"Some",[_e](e){return Oh(e)&&WE(e)&&ae(this.value,e.value)},[Re](){return Nt(ce(this._tag))(ce(this.value))},toString(){return`some(${X(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:hn(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),eW=ce("None"),tW=Object.assign(Object.create($A),{_tag:"None",_op:"None",valueOrUndefined:void 0,[_e](e){return Oh(e)&&Rh(e)},[Re](){return eW},toString(){return"none()"},toJSON(){return{_id:"Option",_tag:this._tag}}}),Oh=e=>B(e,jA),Rh=e=>e._tag==="None",WE=e=>e._tag==="Some",Id=Object.create(tW),vd=e=>{let t=Object.create(XH);return t.value=e,t};var zA="~effect/data/Result",HA={[zA]:{_A:e=>e,_E:e=>e},...vn,[Symbol.iterator](){return new _a(this)}},nW=Object.assign(Object.create(HA),{_tag:"Success",_op:"Success",[_e](e){return _h(e)&&mf(e)&&ae(this.success,e.success)},[Re](){return Nt(ce(this._tag))(ce(this.success))},toString(){return`success(${X(this.success)})`},toJSON(){return{_id:"Result",_tag:this._tag,value:hn(this.success)}}}),rW=Object.assign(Object.create(HA),{_tag:"Failure",_op:"Failure",[_e](e){return _h(e)&&pf(e)&&ae(this.failure,e.failure)},[Re](){return Nt(ce(this._tag))(ce(this.failure))},toString(){return`failure(${X(this.failure)})`},toJSON(){return{_id:"Result",_tag:this._tag,failure:hn(this.failure)}}}),_h=e=>B(e,zA),pf=e=>e._tag==="Failure",mf=e=>e._tag==="Success",Mh=e=>{let t=Object.create(rW);return t.failure=e,t},Ph=e=>{let t=Object.create(nW);return t.success=e,t},KE=e=>mf(e)?Id:vd(e.failure),VE=e=>pf(e)?Id:vd(e.success);function ns(e){return(t,n)=>t===n?0:e(t,n)}var co=ns((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1);var Co=ns((e,t)=>e<t?-1:1);var JE=d(2,(e,t)=>ns((n,r)=>e(t(n),t(r)))),Hc=JE(co,e=>e.getTime());var Wc=e=>d(2,(t,n)=>e(t,n)===-1),Bi=e=>d(2,(t,n)=>e(t,n)===1),hf=e=>d(2,(t,n)=>e(t,n)!==1),gf=e=>d(2,(t,n)=>e(t,n)!==-1),Fh=e=>d(2,(t,n)=>t===n||e(t,n)<1?t:n);var U=()=>Id,N=vd,Gs=Oh,ge=Rh,Te=WE,rr=d(2,(e,{onNone:t,onSome:n})=>ge(e)?t():n(e.value)),oW=e=>t=>Te(e(t)),sW=e=>{for(let t of e)return N(t);return U()},iW=VE,aW=KE,Ua=d(2,(e,t)=>ge(e)?t():e.value),cW=d(2,(e,t)=>ge(e)?t():e),uW=d(2,(e,t)=>ge(e)?N(t()):e),fW=d(2,(e,t)=>ge(e)?Lt(t(),Ph):Lt(e,Mh)),lW=e=>{let t=U();for(t of e)if(Te(t))return t;return t},Kc=e=>e==null?U():N(e),GE=e=>e===void 0?U():N(e),ZE=e=>e===null?U():N(e),dW=e=>(...t)=>Kc(e(...t)),Td=Ua(kE),Ao=Ua(es),Da=e=>(...t)=>{try{return N(e(...t))}catch{return U()}},kd=d(2,(e,t)=>{if(Te(e))return e.value;throw t()}),QE=kd(()=>new Error("getOrThrow called on a None")),Lt=d(2,(e,t)=>ge(e)?U():N(t(e.value))),KA=d(2,(e,t)=>Lt(e,()=>t)),pW=KA(void 0),mW=N(void 0);var rs=d(2,(e,t)=>ge(e)?U():t(e.value)),hW=d(2,(e,t)=>rs(e,n=>{let r=cn(t)?t(n):t;return Gs(r)?r:N(r)})),YE=d(2,(e,t)=>ge(e)?U():Kc(t(e.value))),Vc=rs(L),VA=d(2,(e,t)=>rs(e,()=>t)),gW=d(2,(e,t)=>JA(e,()=>t)),xW=d(2,(e,t)=>n=>rs(e(n),t)),JA=d(2,(e,t)=>rs(e,n=>Lt(t(n),()=>n))),GA=(e,t)=>Te(e)&&Te(t)?N([e.value,t.value]):U(),yW=(e,t)=>{if(ge(e))return U();let n=[e.value];for(let r of t){if(ge(r))return U();n.push(r.value)}return N(n)},SW=e=>{if(Symbol.iterator in e){let n=[];for(let r of e){if(ge(r))return U();n.push(r.value)}return N(n)}let t={};for(let n of Object.keys(e)){let r=e[n];if(ge(r))return U();W(t,n,r.value)}return N(t)},ZA=d(3,(e,t,n)=>Lt(GA(e,t),([r,o])=>n(r,o))),EW=d(3,(e,t,n)=>{let r=t;for(let o of e)Te(o)&&(r=n(r,o.value));return r}),QA=e=>ge(e)?[]:[e.value],bW=d(2,(e,t)=>{if(ge(e))return[U(),U()];let n=t(e.value);return pf(n)?[N(n.failure),U()]:[U(),N(n.success)]}),wW=d(2,(e,t)=>{if(ge(e))return U();let n=t(e.value);return mf(n)?N(n.success):U()}),Na=d(2,(e,t)=>ge(e)?U():t(e.value)?N(e.value):U()),XE=e=>un((t,n)=>ge(t)?ge(n):ge(n)?!1:e(t.value,n.value)),IW=e=>ns((t,n)=>Te(t)?Te(n)?e(t.value,n.value):1:-1),vW=e=>d(2,(t,n)=>ZA(t,n,e)),TW=d(2,(e,t)=>t(e)?N(e):U()),YA=e=>d(2,(t,n)=>ge(t)?!1:e(t.value,n)),kW=YA(pd()),CW=d(2,(e,t)=>ge(e)?!1:t(e.value)),AW=Eh(Lt),OW=Sh(Lt);var RW=bh(Lt,rs),_W=N({}),MW=(...e)=>{let n=(e.length===1?e[0]:e[1].bind(e[0]))(),r=n.next();for(;!r.done;){let o=r.value;if(ge(o))return o;r=n.next(o.value)}return N(r.value)};function PW(e){return wo((t,n)=>ge(t)?n:ge(n)?t:N(e.combine(t.value,n.value)),U())}function XA(e){return Ih((t,n)=>ge(t)||ge(n)?U():N(e.combine(t.value,n.value)))}function FW(e){let t=XA(e).combine,n=N(e.initialValue);return wo(t,n,r=>{let o=n;for(let s of r)if(o=t(o,s),ge(o))return o;return o})}var Ce=Ph,Ae=Mh;var Uh=e=>{if(cn(e))try{return Ce(e())}catch(t){return Ae(t)}else try{return Ce(e.try())}catch(t){return Ae(e.catch(t))}};var xf=_h,Fe=pf,Kt=mf;var eO=(e,t)=>un((n,r)=>Fe(n)?Fe(r)&&t(n.failure,r.failure):Kt(r)&&e(n.success,r.success));var eb=d(2,(e,t)=>Fe(e)?Ae(t(e.failure)):e),Jc=d(2,(e,t)=>Kt(e)?Ce(t(e.success)):e),Oo=d(2,(e,{onFailure:t,onSuccess:n})=>Fe(e)?t(e.failure):n(e.success));var Cd=d(2,(e,t)=>Fe(e)?t(e.failure):e.success);var Dh=d(2,(e,t)=>Fe(e)?Ae(e.failure):t(e.success));var tO=AA;var UW=(e,t)=>{let n=t?.length!==void 0?Math.max(1,Math.floor(t.length)):1/0;return{[Symbol.iterator](){let r=0;return{next(){return r<n?{value:e(r++),done:!1}:{done:!0,value:void 0}}}}}};var DW=d(2,(e,t)=>NW(UW(()=>e,{length:t}))),rO=e=>DW(e,1/0);var oO=e=>{let n=e[Symbol.iterator]().next();return n.done?U():N(n.value)},sO=e=>{let n=e[Symbol.iterator]().next();if(n.done)throw new Error("headUnsafe: empty iterable");return n.value};var NW=e=>({[Symbol.iterator](){let t=e[Symbol.iterator](),n;function r(){for(;;){if(n===void 0){let s=t.next();if(s.done)return s;n=s.value[Symbol.iterator]()}let o=n.next();if(!o.done)return o;n=void 0}}return{next:r}}});var Nh=d(2,(e,t)=>({[Symbol.iterator](){let n=e[Symbol.iterator](),r=0;return{next(){let o=n.next();for(;!o.done;){if(t(o.value,r++))return{done:!1,value:o.value};o=n.next()}return{done:!0,value:void 0}}}}}));var LW=d(2,(e,t)=>Object.hasOwn(e,t));var Lh=d(2,(e,t)=>{let n={...e};for(let r of iO(e))W(n,r,t(e[r],r));return n});var iO=e=>Object.keys(e);var BW=e=>d(2,(t,n)=>{for(let r of iO(t))if(!LW(n,r)||!e(t[r],n[r]))return!1;return!0});var aO=e=>{let t=BW(e);return(n,r)=>t(n,r)&&t(r,n)};var Od=globalThis.Array;var cO=d(2,(e,t)=>{let n=Math.max(1,Math.floor(e)),r=new Od(n);for(let o=0;o<n;o++)r[o]=t(o);return r}),tb=(e,t)=>e<=t?cO(t-e+1,n=>e+n):[e];var ht=e=>Od.isArray(e)?e:Od.from(e),uO=e=>Od.isArray(e)?e:[e];var jh=d(2,(e,t)=>[...e,t]),yf=d(2,(e,t)=>ht(e).concat(ht(t)));var fO=Od.isArray;var Vn=NE,Ye=NE;function jW(e,t){return!Number.isFinite(e)||e<0||e>=t.length}var lO=d(2,(e,t)=>{let n=Math.floor(t);if(jW(n,e))throw new Error(`Index out of bounds: ${n}`);return e[n]});var Sf=e=>e[e.length-1];var dO=d(2,(e,t)=>{let n=0,r=[];for(let o of e){if(!t(o,n))break;r.push(o),n++}return r});var $W=(e,t)=>{let n=ce(t),r=e.get(n);if(r===void 0)return e.set(n,[t]),!0;for(let o of r)if(ae(o,t))return!1;return r.push(t),!0};var nb=d(2,(e,t)=>{let n=ht(e),r=ht(t);return Ye(n)?Ye(r)?qh(yf(n,r)):n:r});var rn=()=>[],Ne=e=>[e],os=d(2,(e,t)=>e.map(t));var rb=e=>{let t=[];for(let n of e)Te(n)&&t.push(n.value);return t};var $h=d(2,(e,t)=>{let n=ht(e),r=[];for(let o=0;o<n.length;o++)t(n[o],o)&&r.push(n[o]);return r}),ob=d(2,(e,t)=>{let n=[],r=[],o=0;for(let s of e){let i=t(s,o++);Kt(i)?r.push(i.success):n.push(i.failure)}return[n,r]});var pO=yh;var qh=e=>{let t=ht(e);if(t.length<2)return[...t];let n=new Map,r=[];for(let o of t)$W(n,o)&&r.push(o);return r};var qW=wo((e,t)=>e.concat(t),[]);function mO(){return qW}var hO=/^[+-]?\d+$/,sb="~effect/BigDecimal",zW={[sb]:sb,[Re](){let e=Rd(this);return Nt(ce(e.value),Dr(e.scale))},[_e](e){return Ba(e)&&GW(this,e)},toString(){return`BigDecimal(${Zs(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[at](){return this.toJSON()},pipe(){return ie(this,arguments)}},Ba=e=>B(e,sb),sr=(e,t)=>{let n=Object.create(zW);return n.value=e,n.scale=t,n},EO=(e,t)=>{if(e!==uo&&e%zh===uo)throw new RangeError("Value must be normalized");let n=sr(e,t);return n.normalized=n,n},uo=BigInt(0),HW=BigInt(1),WW=BigInt(-1);var zh=BigInt(10),bO=EO(uo,0);var Rd=e=>{if(e.normalized===void 0)if(e.value===uo)e.normalized=bO;else{let t=`${e.value}`,n=0;for(let s=t.length-1;s>=0&&t[s]==="0";s--)n++;n===0&&(e.normalized=e);let r=BigInt(t.substring(0,t.length-n)),o=e.scale-n;e.normalized=EO(r,o)}return e.normalized},La=d(2,(e,t)=>t>e.scale?sr(e.value*zh**BigInt(t-e.scale),t):t<e.scale?sr(e.value/zh**BigInt(e.scale-t),t):e),wO=d(2,(e,t)=>t.value===uo?e:e.value===uo?t:e.scale>t.scale?sr(La(t,e.scale).value+e.value,e.scale):e.scale<t.scale?sr(La(e,t.scale).value+t.value,t.scale):sr(e.value+t.value,e.scale));var ji=ns((e,t)=>{let n=co(gO(e),gO(t));return n!==0?n:e.scale>t.scale?Co(e.value,La(t,e.scale).value):e.scale<t.scale?Co(La(e,t.scale).value,t.value):Co(e.value,t.value)}),KW=Wc(ji);var VW=Bi(ji);var gO=e=>e.value===uo?0:e.value<uo?-1:1,JW=e=>e.value<uo?sr(-e.value,e.scale):e;var ib=un((e,t)=>e.scale>t.scale?La(t,e.scale).value===e.value:e.scale<t.scale?La(e,t.scale).value===t.value:e.value===t.value),GW=d(2,(e,t)=>ib(e,t));var IO=e=>{if(e==="")return N(bO);let t,n,r=e.search(/[eE]/);if(r!==-1){let c=e.slice(r+1);if(t=e.slice(0,r),n=Number(c),t===""||!Number.isSafeInteger(n)||!hO.test(c))return U()}else t=e,n=0;let o,s,i=t.search(/\./);if(i!==-1){let c=t.slice(0,i),u=t.slice(i+1);o=`${c}${u}`,s=u.length}else o=t,s=0;if(!hO.test(o))return U();let a=s-n;return Number.isSafeInteger(a)?N(sr(BigInt(o),a)):U()};var Zs=e=>{let t=Rd(e);if(Math.abs(t.scale)>=16)return ZW(t);let n=t.value<uo,r=n?`${t.value}`.substring(1):`${t.value}`,o,s;if(t.scale>=r.length)o="0",s="0".repeat(t.scale-r.length)+r;else{let a=r.length-t.scale;if(a>r.length){let c=a-r.length;o=`${r}${"0".repeat(c)}`,s=""}else s=r.slice(a),o=r.slice(0,a)}let i=s===""?o:`${o}.${s}`;return n?`-${i}`:i},ZW=e=>{if(QW(e))return"0e+0";let t=Rd(e),n=`${JW(t).value}`,r=n.slice(0,1),o=n.slice(1),s=`${vO(t)?"-":""}${r}`;o!==""&&(s+=`.${o}`);let i=o.length-t.scale;return`${s}e${i>=0?"+":""}${i}`};var QW=e=>e.value===uo,vO=e=>e.value<uo,YW=e=>e.value>uo,ab=e=>Ba(e[0]);var TO=d(ab,(e,t=0)=>e.scale<=t?e:sr(e.value/zh**BigInt(e.scale-t),t)),cb=d(ab,(e,t=0)=>{let n=TO(e,t);return YW(e)&&KW(n,e)?wO(n,sr(HW,t)):n});var ub=d(ab,(e,t=0)=>{let n=TO(e,t);return vO(e)&&VW(n,e)?wO(n,sr(WW,t)):n});var Joe=globalThis.Boolean;var kO=wo((e,t)=>e||t,!1);var AO=e=>Ni({op:e.label,[nn]:e.evaluate});var RO="~effect/Context/Service",Ke=function(){function e(){}let t=e;Object.setPrototypeOf(t,XW);let n=(r,o)=>(t.key=r,o?.defaultValue&&(t[lb]=lb,t.defaultValue=o.defaultValue),o?.make&&(t.make=o.make),o?.fiberCached&&_O.add(r),t);return arguments.length>0?n(arguments[0],arguments[1]):n},XW={[RO]:RO,...AO({label:"Service",evaluate(e){return rt(qe(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key}},of(e){return e},context(e){return ss(this,e)},use(e){return de(t=>e(qe(t.context,this)))},useSync(e){return de(t=>rt(e(qe(t.context,this))))}},_O=new Set,lb="~effect/Context/Reference",MO="~effect/Context",e3=8,t3=8,db=(e,t,n,r)=>{let o=Object.create(r3);return o.cacheRoot=e??o,o.base=t,o.overlay=n,o.depth=r,o._flat=void 0,o.baseHits=0,o},PO=(e,t)=>{t&&(PO(e,t.parent),e.set(t.key,t.value))},FO=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return PO(t,e.overlay),e._flat=t},n3=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),Ro(n)},Wh=Symbol(),pb=(e,t)=>{let n=e;for(let o=n.overlay;o;o=o.parent)if(o.key===t)return o.value;let r=n.base.get(t);return r===void 0&&!n.base.has(t)?Wh:(n.overlay&&++n.baseHits>=t3&&(n.base=FO(n),n.overlay=void 0,n.depth=0),r)},Ro=e=>db(void 0,e,void 0,0),r3={get mapUnsafe(){return FO(this)},...vn,[MO]:{_Services:e=>e},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[_e](e){if(!_d(e))return!1;let t=this.mapUnsafe,n=e.mapUnsafe;if(t.size!==n.size)return!1;for(let[r,o]of t)if(!n.has(r)||!ae(o,n.get(r)))return!1;return!0},[Re](){return Dr(this.mapUnsafe.size)}},UO=(e,t)=>e.cacheRoot===t.cacheRoot,_d=e=>B(e,MO);var DO=e=>!!e[lb],bt=()=>o3,o3=Ro(new Map),ss=(e,t)=>Ro(new Map([[e.key,t]])),Ve=d(3,(e,t,n)=>s3(e,t.key,n)),s3=(e,t,n)=>{let r=e,o=_O.has(t)?void 0:r.cacheRoot;if(r.depth>=e3){let s=new Map(r.mapUnsafe);return s.set(t,n),db(o,s,void 0,0)}return db(o,r.base,{key:t,value:n,parent:r.overlay},r.depth+1)};var $i=d(2,(e,t)=>qi(e,t.key)),qi=(e,t)=>{let n=pb(e,t);return n===Wh?void 0:n},Jn=d(2,(e,t)=>{let n=pb(e,t.key);if(n===Wh){if(DO(t))return NO(t);throw i3(t)}return n}),qe=Jn,fb="~effect/Context/defaultValue",NO=e=>fb in e?e[fb]:e[fb]=e.defaultValue(),i3=e=>{let t=new Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(t.stack){let n=t.stack.split(`
|
|
7
|
+
${s(f)}}`;l=i(u,m)}}return r.delete(u),l}return String(u)}return c(e,0)}var hW="[Circular]";function qi(e){return typeof e=="string"?JSON.stringify(e):String(e)}function Oh(e){return e.map(t=>`[${qi(t)}]`).join("")}function eE(e){try{return e.toISOString()}catch{return"Invalid Date"}}function gW(e){try{let t=e.toString();return typeof t=="string"?t:String(t)}catch{return"[toString threw]"}}function Kc(e,t){let n=[];return JSON.stringify(e,function(r,o){let s=Object.getOwnPropertyDescriptor(this,r)?.value,i=j(s,Wc)?To(s):To(o);if(typeof i=="bigint")return X(i);if(typeof i!="object"||i===null)return i;for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(!n.includes(i))return n.push(i),i},t?.space)??"null"}var at=Symbol.for("nodejs.util.inspect.custom"),hn=e=>{try{return e=To(e),j(e,"toJSON")&&cn(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(hn):e}catch{return"[toJSON threw]"}},JA=(e,t=2)=>{if(typeof e=="string")return e;try{return typeof e=="object"?Kc(e,{space:t}):X(e,{space:t})}catch{return String(e)}},Gs={toJSON(){return hn(this)},[at](){return this.toJSON()},toString(){return X(this.toJSON())}},_h=class{[at](){return this.toJSON()}toString(){return X(this.toJSON())}};var Na=class e{called=!1;self;constructor(t){this.self=t}next(t){return this.called?{value:t,done:!0}:(this.called=!0,{value:this.self,done:!1})}[Symbol.iterator](){return new e(this.self)}},yW=()=>{let e="~effect/Utils/internal",t={[e]:o=>o()},n={[e]:o=>o()};return t[e](()=>new Error().stack)?.includes(e)===!0?t[e]:n[e]},je=yW();var Qs="~effect/Effect",Vc="~effect/Exit",bW={_A:B,_E:B,_R:B},ZA=`${Qs}/identifier`,ye=`${Qs}/args`,nn=`${Qs}/evaluate`,Sr=`${Qs}/successCont`,ko=`${Qs}/failureCont`,La=`${Qs}/ensureCont`,Gc=Symbol.for("effect/Effect/Yield"),vn={pipe(){return ie(this,arguments)},toJSON(){return{...this}},toString(){return X(this.toJSON(),{ignoreToString:!0,space:2})},[at](){return this.toJSON()}},QA={[Oe](){return Kb(this,Object.keys(this))},[_e](e){let t=Object.keys(this),n=Object.keys(e);if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==n[r]||!ae(this[t[r]],e[t[r]]))return!1;return!0}},EW={[Qs]:bW,...vn,[Symbol.iterator](){return new Na(this)},toJSON(){return{_id:"Effect",op:this[ZA],...ye in this?{args:this[ye]}:void 0}}},ve=e=>j(e,Qs),tE=e=>j(e,Vc),Sd="~effect/Cause",bd="~effect/Cause/Reason",xf=e=>j(e,Sd),YA=e=>j(e,bd),Zs=class{[Sd];reasons;constructor(t){this[Sd]=Sd,this.reasons=t}pipe(){return ie(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map(t=>t.toJSON())}}toString(){return`Cause(${X(this.reasons)})`}[at](){return this.toJSON()}[_e](t){return xf(t)&&this.reasons.length===t.reasons.length&&this.reasons.every((n,r)=>ae(n,t.reasons[r]))}[Oe](){return Fa(this.reasons)}},GA=new WeakMap,hf=class{[bd];annotations;_tag;constructor(t,n,r){if(this[bd]=bd,this._tag=t,n!==wd&&typeof r=="object"&&r!==null&&n.size>0){let o=GA.get(r);o&&(n=new Map([...o,...n])),GA.set(r,n)}this.annotations=n}annotate(t,n){if(t.mapUnsafe.size===0)return this;let r=new Map(this.annotations);t.mapUnsafe.forEach((s,i)=>{n?.overwrite!==!0&&r.has(i)||r.set(i,s)});let o=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return o.annotations=r,o}pipe(){return ie(this,arguments)}toString(){return X(this)}[at](){return this.toString()}},wd=new Map,Jc=class extends hf{error;constructor(t,n=wd){super("Fail",n,t),this.error=t}toString(){return`Fail(${X(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[_e](t){return Ba(t)&&ae(this.error,t.error)&&ae(this.annotations,t.annotations)}[Oe](){return Nt(it(this._tag))(Nt(ce(this.error))(ce(this.annotations)))}},$i=e=>new Zs(e),Ph=new Zs([]),yf=e=>new Zs([new Jc(e)]),Ed=class extends hf{defect;constructor(t,n=wd){super("Die",n,t),this.defect=t}toString(){return`Die(${X(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[_e](t){return vd(t)&&ae(this.defect,t.defect)&&ae(this.annotations,t.annotations)}[Oe](){return Nt(it(this._tag))(Nt(ce(this.defect))(ce(this.annotations)))}},nE=e=>new Zs([new Ed(e)]),Id=d(e=>xf(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new Zs(e.reasons.map(r=>r.annotate(t,n)))),Ba=e=>e._tag==="Fail",vd=e=>e._tag==="Die",Td=e=>e._tag==="Interrupt";function wW(e){return uo("Effect.evaluate: Not implemented")}var zi=e=>({...EW,[ZA]:e.op,[nn]:e[nn]??wW,[Sr]:e[Sr],[ko]:e[ko],[La]:e[La]}),Co=e=>{let t=zi(e);return function(){let n=Object.create(t);return n[ye]=e.single===!1?arguments:arguments[0],n}},XA=e=>{let t={[Vc]:Vc,_tag:e.op,get[e.prop](){return this[ye]},...zi(e),toString(){return`${e.op}(${X(this[ye])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[ye]}},[_e](n){return tE(n)&&n._tag===this._tag&&ae(this[ye],n[ye])},[Oe](){return Nt(it(e.op),ce(this[ye]))}};return function(n){let r=Object.create(t);return r[ye]=n,r}},rt=XA({op:"Success",prop:"value",[nn](e){let t=e.getCont(Sr);return t?t[Sr](this[ye],e,this):e.yieldWith(this)}}),Fh={key:"effect/Cause/StackTrace"},rE={key:"effect/Cause/InterruptorStackTrace"},On=XA({op:"Failure",prop:"cause",[nn](e){let t=this[ye],n=!1;e.currentStackFrame&&(t=Id(t,{mapUnsafe:new Map([[Fh.key,e.currentStackFrame]])}),n=!0);let r=e.getCont(ko);for(;e.interruptible&&e._interruptedCause&&r;)r=e.getCont(ko);return r?r[ko](t,e,n?void 0:this):e.yieldWith(n?On(t):this)}}),co=e=>On(yf(e)),uo=e=>On(nE(e)),pe=Co({op:"WithFiber",[nn](e){return this[ye](e)}}),IW=(function(){class e extends globalThis.Error{}let t=zi({op:"YieldableError",[nn](){return co(this)}});return delete t.toString,Object.assign(e.prototype,t),e})(),kd=(function(){let e=Symbol.for("effect/Data/Error/plainArgs");return class extends IW{constructor(n){super(n?.message,n?.cause?{cause:n.cause}:void 0),n&&(Ah(this,n),Object.defineProperty(this,e,{value:n,enumerable:!1}))}toJSON(){return{...this[e],...this}}}})(),Hi=e=>{class t extends kd{_tag=e}return t.prototype.name=e,t},Mh="~effect/Cause/NoSuchElementError",oE=e=>j(e,Mh),os=class extends Hi("NoSuchElementError"){[Mh]=Mh;constructor(t){super({message:t})}},gf="~effect/Cause/Done",Cd=e=>j(e,gf),eR={[gf]:gf,_tag:"Done",value:void 0},Zc=e=>e===void 0?eR:{[gf]:gf,_tag:"Done",value:e},vW=co(eR),tR=e=>e===void 0?vW:co(Zc(e));var nR="~effect/data/Option",rR={[nR]:{_A:e=>e},...vn,[Symbol.iterator](){return new Na(this)}},TW=Object.defineProperty(Object.assign(Object.create(rR),{_tag:"Some",_op:"Some",[_e](e){return Uh(e)&&sE(e)&&ae(this.value,e.value)},[Oe](){return Nt(ce(this._tag))(ce(this.value))},toString(){return`some(${X(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:hn(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),kW=ce("None"),CW=Object.assign(Object.create(rR),{_tag:"None",_op:"None",valueOrUndefined:void 0,[_e](e){return Uh(e)&&Dh(e)},[Oe](){return kW},toString(){return"none()"},toJSON(){return{_id:"Option",_tag:this._tag}}}),Uh=e=>j(e,nR),Dh=e=>e._tag==="None",sE=e=>e._tag==="Some",Ad=Object.create(CW),Rd=e=>{let t=Object.create(TW);return t.value=e,t};var sR="~effect/data/Result",iR={[sR]:{_A:e=>e,_E:e=>e},...vn,[Symbol.iterator](){return new Na(this)}},AW=Object.assign(Object.create(iR),{_tag:"Success",_op:"Success",[_e](e){return Nh(e)&&bf(e)&&ae(this.success,e.success)},[Oe](){return Nt(ce(this._tag))(ce(this.success))},toString(){return`success(${X(this.success)})`},toJSON(){return{_id:"Result",_tag:this._tag,value:hn(this.success)}}}),RW=Object.assign(Object.create(iR),{_tag:"Failure",_op:"Failure",[_e](e){return Nh(e)&&Sf(e)&&ae(this.failure,e.failure)},[Oe](){return Nt(ce(this._tag))(ce(this.failure))},toString(){return`failure(${X(this.failure)})`},toJSON(){return{_id:"Result",_tag:this._tag,failure:hn(this.failure)}}}),Nh=e=>j(e,sR),Sf=e=>e._tag==="Failure",bf=e=>e._tag==="Success",Lh=e=>{let t=Object.create(RW);return t.failure=e,t},Bh=e=>{let t=Object.create(AW);return t.success=e,t},iE=e=>bf(e)?Ad:Rd(e.failure),aE=e=>Sf(e)?Ad:Rd(e.success);function ss(e){return(t,n)=>t===n?0:e(t,n)}var fo=ss((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1);var Ro=ss((e,t)=>e<t?-1:1);var cE=d(2,(e,t)=>ss((n,r)=>e(t(n),t(r)))),Qc=cE(fo,e=>e.getTime());var Yc=e=>d(2,(t,n)=>e(t,n)===-1),Wi=e=>d(2,(t,n)=>e(t,n)===1),Ef=e=>d(2,(t,n)=>e(t,n)!==1),wf=e=>d(2,(t,n)=>e(t,n)!==-1),jh=e=>d(2,(t,n)=>t===n||e(t,n)<1?t:n);var D=()=>Ad,L=Rd,Ys=Uh,xe=Dh,Te=sE,rr=d(2,(e,{onNone:t,onSome:n})=>xe(e)?t():n(e.value)),OW=e=>t=>Te(e(t)),_W=e=>{for(let t of e)return L(t);return D()},MW=aE,PW=iE,qa=d(2,(e,t)=>xe(e)?t():e.value),FW=d(2,(e,t)=>xe(e)?t():e),UW=d(2,(e,t)=>xe(e)?L(t()):e),DW=d(2,(e,t)=>xe(e)?Lt(t(),Bh):Lt(e,Lh)),NW=e=>{let t=D();for(t of e)if(Te(t))return t;return t},Xc=e=>e==null?D():L(e),uE=e=>e===void 0?D():L(e),fE=e=>e===null?D():L(e),LW=e=>(...t)=>Xc(e(...t)),Od=qa(jb),Oo=qa(rs),$a=e=>(...t)=>{try{return L(e(...t))}catch{return D()}},_d=d(2,(e,t)=>{if(Te(e))return e.value;throw t()}),lE=_d(()=>new Error("getOrThrow called on a None")),Lt=d(2,(e,t)=>xe(e)?D():L(t(e.value))),cR=d(2,(e,t)=>Lt(e,()=>t)),BW=cR(void 0),jW=L(void 0);var is=d(2,(e,t)=>xe(e)?D():t(e.value)),qW=d(2,(e,t)=>is(e,n=>{let r=cn(t)?t(n):t;return Ys(r)?r:L(r)})),dE=d(2,(e,t)=>xe(e)?D():Xc(t(e.value))),eu=is(B),uR=d(2,(e,t)=>is(e,()=>t)),$W=d(2,(e,t)=>fR(e,()=>t)),zW=d(2,(e,t)=>n=>is(e(n),t)),fR=d(2,(e,t)=>is(e,n=>Lt(t(n),()=>n))),lR=(e,t)=>Te(e)&&Te(t)?L([e.value,t.value]):D(),HW=(e,t)=>{if(xe(e))return D();let n=[e.value];for(let r of t){if(xe(r))return D();n.push(r.value)}return L(n)},WW=e=>{if(Symbol.iterator in e){let n=[];for(let r of e){if(xe(r))return D();n.push(r.value)}return L(n)}let t={};for(let n of Object.keys(e)){let r=e[n];if(xe(r))return D();W(t,n,r.value)}return L(t)},dR=d(3,(e,t,n)=>Lt(lR(e,t),([r,o])=>n(r,o))),KW=d(3,(e,t,n)=>{let r=t;for(let o of e)Te(o)&&(r=n(r,o.value));return r}),pR=e=>xe(e)?[]:[e.value],VW=d(2,(e,t)=>{if(xe(e))return[D(),D()];let n=t(e.value);return Sf(n)?[L(n.failure),D()]:[D(),L(n.success)]}),JW=d(2,(e,t)=>{if(xe(e))return D();let n=t(e.value);return bf(n)?L(n.success):D()}),za=d(2,(e,t)=>xe(e)?D():t(e.value)?L(e.value):D()),pE=e=>un((t,n)=>xe(t)?xe(n):xe(n)?!1:e(t.value,n.value)),GW=e=>ss((t,n)=>Te(t)?Te(n)?e(t.value,n.value):1:-1),ZW=e=>d(2,(t,n)=>dR(t,n,e)),QW=d(2,(e,t)=>t(e)?L(e):D()),mR=e=>d(2,(t,n)=>xe(t)?!1:e(t.value,n)),YW=mR(yd()),XW=d(2,(e,t)=>xe(e)?!1:t(e.value)),e3=kh(Lt),t3=Th(Lt);var n3=Ch(Lt,is),r3=L({}),o3=(...e)=>{let n=(e.length===1?e[0]:e[1].bind(e[0]))(),r=n.next();for(;!r.done;){let o=r.value;if(xe(o))return o;r=n.next(o.value)}return L(r.value)};function s3(e){return vo((t,n)=>xe(t)?n:xe(n)?t:L(e.combine(t.value,n.value)),D())}function hR(e){return Rh((t,n)=>xe(t)||xe(n)?D():L(e.combine(t.value,n.value)))}function i3(e){let t=hR(e).combine,n=L(e.initialValue);return vo(t,n,r=>{let o=n;for(let s of r)if(o=t(o,s),xe(o))return o;return o})}var Ce=Bh,Ae=Lh;var qh=e=>{if(cn(e))try{return Ce(e())}catch(t){return Ae(t)}else try{return Ce(e.try())}catch(t){return Ae(e.catch(t))}};var If=Nh,Fe=Sf,Kt=bf;var gR=(e,t)=>un((n,r)=>Fe(n)?Fe(r)&&t(n.failure,r.failure):Kt(r)&&e(n.success,r.success));var mE=d(2,(e,t)=>Fe(e)?Ae(t(e.failure)):e),tu=d(2,(e,t)=>Kt(e)?Ce(t(e.success)):e),_o=d(2,(e,{onFailure:t,onSuccess:n})=>Fe(e)?t(e.failure):n(e.success));var Md=d(2,(e,t)=>Fe(e)?t(e.failure):e.success);var $h=d(2,(e,t)=>Fe(e)?Ae(e.failure):t(e.success));var xR=HA;var a3=(e,t)=>{let n=t?.length!==void 0?Math.max(1,Math.floor(t.length)):1/0;return{[Symbol.iterator](){let r=0;return{next(){return r<n?{value:e(r++),done:!1}:{done:!0,value:void 0}}}}}};var c3=d(2,(e,t)=>u3(a3(()=>e,{length:t}))),SR=e=>c3(e,1/0);var bR=e=>{let n=e[Symbol.iterator]().next();return n.done?D():L(n.value)},ER=e=>{let n=e[Symbol.iterator]().next();if(n.done)throw new Error("headUnsafe: empty iterable");return n.value};var u3=e=>({[Symbol.iterator](){let t=e[Symbol.iterator](),n;function r(){for(;;){if(n===void 0){let s=t.next();if(s.done)return s;n=s.value[Symbol.iterator]()}let o=n.next();if(!o.done)return o;n=void 0}}return{next:r}}});var zh=d(2,(e,t)=>({[Symbol.iterator](){let n=e[Symbol.iterator](),r=0;return{next(){let o=n.next();for(;!o.done;){if(t(o.value,r++))return{done:!1,value:o.value};o=n.next()}return{done:!0,value:void 0}}}}}));var f3=d(2,(e,t)=>Object.hasOwn(e,t));var Hh=d(2,(e,t)=>{let n={...e};for(let r of wR(e))W(n,r,t(e[r],r));return n});var wR=e=>Object.keys(e);var l3=e=>d(2,(t,n)=>{for(let r of wR(t))if(!f3(n,r)||!e(t[r],n[r]))return!1;return!0});var IR=e=>{let t=l3(e);return(n,r)=>t(n,r)&&t(r,n)};var Fd=globalThis.Array;var vR=d(2,(e,t)=>{let n=Math.max(1,Math.floor(e)),r=new Fd(n);for(let o=0;o<n;o++)r[o]=t(o);return r}),hE=(e,t)=>e<=t?vR(t-e+1,n=>e+n):[e];var ht=e=>Fd.isArray(e)?e:Fd.from(e),TR=e=>Fd.isArray(e)?e:[e];var Kh=d(2,(e,t)=>[...e,t]),vf=d(2,(e,t)=>ht(e).concat(ht(t)));var kR=Fd.isArray;var Vn=Qb,Ye=Qb;function d3(e,t){return!Number.isFinite(e)||e<0||e>=t.length}var CR=d(2,(e,t)=>{let n=Math.floor(t);if(d3(n,e))throw new Error(`Index out of bounds: ${n}`);return e[n]});var Tf=e=>e[e.length-1];var AR=d(2,(e,t)=>{let n=0,r=[];for(let o of e){if(!t(o,n))break;r.push(o),n++}return r});var p3=(e,t)=>{let n=ce(t),r=e.get(n);if(r===void 0)return e.set(n,[t]),!0;for(let o of r)if(ae(o,t))return!1;return r.push(t),!0};var gE=d(2,(e,t)=>{let n=ht(e),r=ht(t);return Ye(n)?Ye(r)?Jh(vf(n,r)):n:r});var rn=()=>[],Ne=e=>[e],as=d(2,(e,t)=>e.map(t));var xE=e=>{let t=[];for(let n of e)Te(n)&&t.push(n.value);return t};var Vh=d(2,(e,t)=>{let n=ht(e),r=[];for(let o=0;o<n.length;o++)t(n[o],o)&&r.push(n[o]);return r}),yE=d(2,(e,t)=>{let n=[],r=[],o=0;for(let s of e){let i=t(s,o++);Kt(i)?r.push(i.success):n.push(i.failure)}return[n,r]});var RR=vh;var Jh=e=>{let t=ht(e);if(t.length<2)return[...t];let n=new Map,r=[];for(let o of t)p3(n,o)&&r.push(o);return r};var m3=vo((e,t)=>e.concat(t),[]);function OR(){return m3}var _R=/^[+-]?\d+$/,SE="~effect/BigDecimal",h3={[SE]:SE,[Oe](){let e=Ud(this);return Nt(ce(e.value),Nr(e.scale))},[_e](e){return Wa(e)&&E3(this,e)},toString(){return`BigDecimal(${Xs(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[at](){return this.toJSON()},pipe(){return ie(this,arguments)}},Wa=e=>j(e,SE),sr=(e,t)=>{let n=Object.create(h3);return n.value=e,n.scale=t,n},DR=(e,t)=>{if(e!==lo&&e%Gh===lo)throw new RangeError("Value must be normalized");let n=sr(e,t);return n.normalized=n,n},lo=BigInt(0),g3=BigInt(1),x3=BigInt(-1);var Gh=BigInt(10),NR=DR(lo,0);var Ud=e=>{if(e.normalized===void 0)if(e.value===lo)e.normalized=NR;else{let t=`${e.value}`,n=0;for(let s=t.length-1;s>=0&&t[s]==="0";s--)n++;n===0&&(e.normalized=e);let r=BigInt(t.substring(0,t.length-n)),o=e.scale-n;e.normalized=DR(r,o)}return e.normalized},Ha=d(2,(e,t)=>t>e.scale?sr(e.value*Gh**BigInt(t-e.scale),t):t<e.scale?sr(e.value/Gh**BigInt(e.scale-t),t):e),LR=d(2,(e,t)=>t.value===lo?e:e.value===lo?t:e.scale>t.scale?sr(Ha(t,e.scale).value+e.value,e.scale):e.scale<t.scale?sr(Ha(e,t.scale).value+t.value,t.scale):sr(e.value+t.value,e.scale));var Ki=ss((e,t)=>{let n=fo(MR(e),MR(t));return n!==0?n:e.scale>t.scale?Ro(e.value,Ha(t,e.scale).value):e.scale<t.scale?Ro(Ha(e,t.scale).value,t.value):Ro(e.value,t.value)}),y3=Yc(Ki);var S3=Wi(Ki);var MR=e=>e.value===lo?0:e.value<lo?-1:1,b3=e=>e.value<lo?sr(-e.value,e.scale):e;var bE=un((e,t)=>e.scale>t.scale?Ha(t,e.scale).value===e.value:e.scale<t.scale?Ha(e,t.scale).value===t.value:e.value===t.value),E3=d(2,(e,t)=>bE(e,t));var BR=e=>{if(e==="")return L(NR);let t,n,r=e.search(/[eE]/);if(r!==-1){let c=e.slice(r+1);if(t=e.slice(0,r),n=Number(c),t===""||!Number.isSafeInteger(n)||!_R.test(c))return D()}else t=e,n=0;let o,s,i=t.search(/\./);if(i!==-1){let c=t.slice(0,i),u=t.slice(i+1);o=`${c}${u}`,s=u.length}else o=t,s=0;if(!_R.test(o))return D();let a=s-n;return Number.isSafeInteger(a)?L(sr(BigInt(o),a)):D()};var Xs=e=>{let t=Ud(e);if(Math.abs(t.scale)>=16)return w3(t);let n=t.value<lo,r=n?`${t.value}`.substring(1):`${t.value}`,o,s;if(t.scale>=r.length)o="0",s="0".repeat(t.scale-r.length)+r;else{let a=r.length-t.scale;if(a>r.length){let c=a-r.length;o=`${r}${"0".repeat(c)}`,s=""}else s=r.slice(a),o=r.slice(0,a)}let i=s===""?o:`${o}.${s}`;return n?`-${i}`:i},w3=e=>{if(I3(e))return"0e+0";let t=Ud(e),n=`${b3(t).value}`,r=n.slice(0,1),o=n.slice(1),s=`${jR(t)?"-":""}${r}`;o!==""&&(s+=`.${o}`);let i=o.length-t.scale;return`${s}e${i>=0?"+":""}${i}`};var I3=e=>e.value===lo,jR=e=>e.value<lo,v3=e=>e.value>lo,EE=e=>Wa(e[0]);var qR=d(EE,(e,t=0)=>e.scale<=t?e:sr(e.value/Gh**BigInt(e.scale-t),t)),wE=d(EE,(e,t=0)=>{let n=qR(e,t);return v3(e)&&y3(n,e)?LR(n,sr(g3,t)):n});var IE=d(EE,(e,t=0)=>{let n=qR(e,t);return jR(e)&&S3(n,e)?LR(n,sr(x3,t)):n});var Rse=globalThis.Boolean;var $R=vo((e,t)=>e||t,!1);var HR=e=>zi({op:e.label,[nn]:e.evaluate});var KR="~effect/Context/Service",Ke=function(){function e(){}let t=e;Object.setPrototypeOf(t,T3);let n=(r,o)=>(t.key=r,o?.defaultValue&&(t[TE]=TE,t.defaultValue=o.defaultValue),o?.make&&(t.make=o.make),o?.fiberCached&&VR.add(r),t);return arguments.length>0?n(arguments[0],arguments[1]):n},T3={[KR]:KR,...HR({label:"Service",evaluate(e){return rt($e(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key}},of(e){return e},context(e){return cs(this,e)},use(e){return pe(t=>e($e(t.context,this)))},useSync(e){return pe(t=>rt(e($e(t.context,this))))}},VR=new Set,TE="~effect/Context/Reference",JR="~effect/Context",k3=8,C3=8,kE=(e,t,n,r)=>{let o=Object.create(R3);return o.cacheRoot=e??o,o.base=t,o.overlay=n,o.depth=r,o._flat=void 0,o.baseHits=0,o},GR=(e,t)=>{t&&(GR(e,t.parent),e.set(t.key,t.value))},ZR=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return GR(t,e.overlay),e._flat=t},A3=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),Mo(n)},Qh=Symbol(),CE=(e,t)=>{let n=e;for(let o=n.overlay;o;o=o.parent)if(o.key===t)return o.value;let r=n.base.get(t);return r===void 0&&!n.base.has(t)?Qh:(n.overlay&&++n.baseHits>=C3&&(n.base=ZR(n),n.overlay=void 0,n.depth=0),r)},Mo=e=>kE(void 0,e,void 0,0),R3={get mapUnsafe(){return ZR(this)},...vn,[JR]:{_Services:e=>e},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[_e](e){if(!Dd(e))return!1;let t=this.mapUnsafe,n=e.mapUnsafe;if(t.size!==n.size)return!1;for(let[r,o]of t)if(!n.has(r)||!ae(o,n.get(r)))return!1;return!0},[Oe](){return Nr(this.mapUnsafe.size)}},QR=(e,t)=>e.cacheRoot===t.cacheRoot,Dd=e=>j(e,JR);var YR=e=>!!e[TE],Et=()=>O3,O3=Mo(new Map),cs=(e,t)=>Mo(new Map([[e.key,t]])),Ve=d(3,(e,t,n)=>_3(e,t.key,n)),_3=(e,t,n)=>{let r=e,o=VR.has(t)?void 0:r.cacheRoot;if(r.depth>=k3){let s=new Map(r.mapUnsafe);return s.set(t,n),kE(o,s,void 0,0)}return kE(o,r.base,{key:t,value:n,parent:r.overlay},r.depth+1)};var Vi=d(2,(e,t)=>Ji(e,t.key)),Ji=(e,t)=>{let n=CE(e,t);return n===Qh?void 0:n},Jn=d(2,(e,t)=>{let n=CE(e,t.key);if(n===Qh){if(YR(t))return XR(t);throw M3(t)}return n}),$e=Jn,vE="~effect/Context/defaultValue",XR=e=>vE in e?e[vE]:e[vE]=e.defaultValue(),M3=e=>{let t=new Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(t.stack){let n=t.stack.split(`
|
|
8
8
|
`);n.splice(1,3),t.stack=n.join(`
|
|
9
|
-
`)}return t},mb=d(2,(e,t)=>{let n=pb(e,t.key);return n!==Wh?N(n):DO(t)?N(NO(t)):U()}),Er=d(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:n3(e,n=>t.mapUnsafe.forEach((r,o)=>n.set(o,r)))),LO=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((r,o)=>{t.set(o,r)});return Ro(t)};var Me=Ke;var Kh="~effect/time/Duration",gb=BigInt(0),qO=BigInt(1),a3=BigInt(2),c3=BigInt(10);var u3=BigInt(1e3);var Vh=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),zO=e=>Vh(e*1e6),BO=(e,t)=>{let n=e.indexOf(".");if(n===-1)return BigInt(e)*t;let r=e[0]==="-",o=e.slice(n+1),s=c3**BigInt(o.length),i=(BigInt(e.slice(r?1:0,n))*s+BigInt(o))*t,a=i/s+(i%s*a3>=s?qO:gb);return r?-a:a};var f3=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,gt=e=>{switch(typeof e){case"number":return is(e);case"bigint":return Nr(e);case"string":{if(e==="Infinity")return fo;if(e==="-Infinity")return Hi;let t=f3.exec(e);if(!t)break;let[n,r,o]=t;if(o==="nano"||o==="nanos")return Nr(BO(r,qO));if(o==="micro"||o==="micros")return Nr(BO(r,u3));let s=Number(r);switch(o){case"milli":case"millis":return is(s);case"second":case"seconds":return xb(s);case"minute":case"minutes":return m3(s);case"hour":case"hours":return h3(s);case"day":case"days":return g3(s);case"week":case"weeks":return x3(s)}break}case"object":{if(e===null)break;if(Kh in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(ud)?jO(e):Number.isNaN(e[0])||Number.isNaN(e[1])?zi:e[0]===-1/0||e[1]===-1/0?Hi:e[0]===1/0||e[1]===1/0?fo:br(Vh(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?br(n):br(Vh(n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0)))}}return jO(e)},jO=e=>{throw new Error(`Invalid Input: ${e}`)},HO=Da(gt),$O={_tag:"Millis",millis:0},l3={_tag:"Infinity"},d3={_tag:"NegativeInfinity"},p3={[Kh]:Kh,[Re](){switch(this.value._tag){case"Millis":{let e=this.value.millis*1e6;return Number.isFinite(e)?ce(Vh(e)):Dr(this.value.millis)}case"Nanos":return ce(this.value.nanos);default:return dd(this.value)}},[_e](e){return Gc(e)&&E3(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"}}},[at](){return this.toJSON()},pipe(){return ie(this,arguments)}},br=e=>{let t=Object.create(p3);return typeof e=="number"?isNaN(e)||e===0||Object.is(e,-0)?t.value=$O:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:zO(e)}:t.value=e>0?l3:d3:e===gb?t.value=$O:t.value={_tag:"Nanos",nanos:e},t},Gc=e=>B(e,Kh),as=e=>e.value._tag!=="Infinity"&&e.value._tag!=="NegativeInfinity",Md=e=>{switch(e.value._tag){case"Millis":return e.value.millis===0;case"Nanos":return e.value.nanos===gb;case"Infinity":case"NegativeInfinity":return!1}};var zi=br(0),fo=br(1/0),Hi=br(-1/0),Nr=e=>br(e);var is=e=>br(e),xb=e=>br(e*1e3),m3=e=>br(e*6e4),h3=e=>br(e*36e5),g3=e=>br(e*864e5),x3=e=>br(e*6048e5),Tn=e=>y3(gt(e),{onMillis:L,onNanos:t=>Number(t)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0});var hb=e=>{let t=gt(e);switch(t.value._tag){case"Infinity":case"NegativeInfinity":throw new Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return zO(t.value.millis)}},WO=Da(hb);var y3=d(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)()}}),yb=d(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(hb(e),t.value.nanos):n.onNanos(e.value.nanos,hb(t))),S3=ns((e,t)=>yb(e,t,{onMillis:(n,r)=>n<r?-1:n>r?1:0,onNanos:(n,r)=>n<r?-1:n>r?1:0,onInfinity:(n,r)=>n.value._tag===r.value._tag?0:n.value._tag==="Infinity"?1:n.value._tag==="NegativeInfinity"||r.value._tag==="Infinity"?-1:1}));var Sb=(e,t)=>yb(e,t,{onMillis:(n,r)=>n===r,onNanos:(n,r)=>n===r,onInfinity:(n,r)=>n.value._tag===r.value._tag}),KO=Fh(S3);var VO=d(2,(e,t)=>yb(e,t,{onMillis:(n,r)=>br(n-r),onNanos:(n,r)=>br(n-r),onInfinity:(n,r)=>{let o=n.value._tag,s=r.value._tag;return o==="Infinity"?s==="Infinity"?zi:fo:o==="NegativeInfinity"?s==="NegativeInfinity"?zi:Hi:s==="Infinity"?Hi:fo}}));var E3=d(2,(e,t)=>Sb(e,t));var ja=Me("effect/Scheduler",{fiberCached:!0,defaultValue:()=>new Qs}),JO="setImmediate"in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},b3=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},Eb=class{buckets=[];scheduleTask(t,n){let r=this.buckets,o=r.length,s,i=0;for(;i<o&&!(r[i][0]>n);i++)s=r[i];s&&s[0]===n?s[1].push(t):i===o?r.push([n,[t]]):r.splice(i,0,[n,[t]])}drain(){let t=this.buckets;return this.buckets=[],t}},Qs=class{executionMode;setImmediate;constructor(t="async",n){this.executionMode=t,this.setImmediate=n??(t==="sync"?b3:JO)}shouldYield(t){return t.currentOpCount>=t.maxOpsBeforeYield}makeDispatcher(){return new bb(this.setImmediate)}},bb=class{tasks=new Eb;running=void 0;setImmediate;constructor(t=JO){this.setImmediate=t}scheduleTask(t,n){this.tasks.scheduleTask(t,n),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let t=this.tasks.drain();for(let n=0;n<t.length;n++){let r=t[n][1];for(let o=0;o<r.length;o++)r[o]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}},GO=Me("effect/Scheduler/MaxOpsBeforeYield",{fiberCached:!0,defaultValue:()=>2048}),ZO=Me("effect/Scheduler/PreventSchedulerYield",{fiberCached:!0,defaultValue:()=>!1});var QO=class extends Mc{constructor(e){super(),e&&wh(this,e)}};var YO=bd,Mn=Li;var XO="~effect/encoding/EncodingError",Ki=class extends Mn("EncodingError"){[XO]=XO};var Zh=e=>wb(typeof e=="string"?kb.encode(e):e),bf=e=>{let t=uR(e),n=t.length;if(n%4!==0)return Ae(new Ki({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 Ae(new Ki({kind:"Decode",module:"Base64",input:t,message:"Found a '=' character, but it is not at the end"}));try{let o=t.endsWith("==")?2:t.endsWith("=")?1:0,s=new Uint8Array(3*(n/4)-o);for(let i=0,a=0;i<n;i+=4,a+=3){let c=Gh(t.charCodeAt(i))<<18|Gh(t.charCodeAt(i+1))<<12|Gh(t.charCodeAt(i+2))<<6|Gh(t.charCodeAt(i+3));s[a]=c>>16,s[a+1]=c>>8&255,s[a+2]=c&255}return Ce(s)}catch(o){return Ae(new Ki({kind:"Decode",module:"Base64",input:t,message:o instanceof Error?o.message:"Invalid input"}))}},oR=e=>Jc(bf(e),t=>Cb.decode(t)),sR=e=>tR(typeof e=="string"?kb.encode(e):e),Ib=e=>{let t=uR(e),n=t.length;if(n%4===1)return Ae(new Ki({module:"Base64Url",kind:"Decode",input:t,message:`Length should be a multiple of 4, but is ${n}`}));if(!/^[-_A-Z0-9]*?={0,2}$/i.test(t))return Ae(new Ki({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let r=n%4===2?`${t}==`:n%4===3?`${t}=`:t;return r=r.replace(/-/g,"+").replace(/_/g,"/"),bf(r)},iR=e=>Jc(Ib(e),t=>Cb.decode(t)),aR=e=>nR(typeof e=="string"?kb.encode(e):e),vb=e=>{let t="";for(let n=e>>>3;n>0;n--){let r=Math.random()*4294967296>>>0;t+=Ef[r>>>24]+Ef[r>>>16&255]+Ef[r>>>8&255]+Ef[r&255]}return t},Tb=e=>{let t=new TextEncoder().encode(e);if(t.length%2!==0)return Ae(new Ki({module:"Hex",kind:"Decode",input:e,message:`Length must be a multiple of 2, but is ${t.length}`}));try{let n=t.length/2,r=new Uint8Array(n);for(let o=0;o<n;o++){let s=rR(t[o*2]),i=rR(t[o*2+1]);r[o]=s<<4|i}return Ce(r)}catch(n){return Ae(new Ki({module:"Hex",kind:"Decode",input:e,message:n instanceof Error?n.message:"Invalid input"}))}},cR=e=>Jc(Tb(e),t=>Cb.decode(t)),kb=new TextEncoder,Cb=new TextDecoder,uR=e=>e.replace(/[\n\r]/g,""),wb=e=>{let t=e.length,n="",r;for(r=2;r<t;r+=3)n+=Wi[e[r-2]>>2],n+=Wi[(e[r-2]&3)<<4|e[r-1]>>4],n+=Wi[(e[r-1]&15)<<2|e[r]>>6],n+=Wi[e[r]&63];return r===t+1&&(n+=Wi[e[r-2]>>2],n+=Wi[(e[r-2]&3)<<4],n+="=="),r===t&&(n+=Wi[e[r-2]>>2],n+=Wi[(e[r-2]&3)<<4|e[r-1]>>4],n+=Wi[(e[r-1]&15)<<2],n+="="),n};function Gh(e){if(e>=eR.length)throw new TypeError(`Invalid character ${String.fromCharCode(e)}`);let t=eR[e];if(t===255)throw new TypeError(`Invalid character ${String.fromCharCode(e)}`);return t}var Wi=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"],eR=[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],tR=e=>wb(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),Ef=[];for(let e=0;e<256;e++)Ef.push(e.toString(16).padStart(2,"0"));var nR=e=>{let t="";for(let n=0;n<e.length;n++)t+=Ef[e[n]];return t},rR=e=>{if(48<=e&&e<=57)return e-48;if(97<=e&&e<=102)return e-97+10;if(65<=e&&e<=70)return e-65+10;throw new TypeError("Invalid input")};var Ob="effect/Tracer/ParentSpan",Ys=class extends Ke()(Ob,{fiberCached:!0}){},w3=e=>e;var wf=Me("effect/Tracer/DisablePropagation",{defaultValue:Pc}),fR=Me("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),lR=Me("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),Rb="effect/Tracer",Yh=Me(Rb,{fiberCached:!0,defaultValue:()=>w3({span:e=>new Ab(e)})}),Ab=class{_tag="Span";spanId;traceId="native";sampled;name;parent;annotations;links;startTime;kind;status;attributes;events=[];constructor(t){this.name=t.name,this.parent=t.parent,this.annotations=t.annotations,this.links=t.links,this.startTime=t.startTime,this.kind=t.kind,this.sampled=t.sampled,this.status={_tag:"Started",startTime:t.startTime},this.attributes=new Map,this.traceId=Ao(t.parent)?.traceId??vb(32),this.spanId=vb(16)}end(t,n){this.status={_tag:"Ended",endTime:t,exit:n,startTime:this.status.startTime}}attribute(t,n){this.attributes.set(t,n)}event(t,n,r){this.events.push([t,n,r??{}])}addLinks(t){this.links.push(...t)}};var dR="effect/observability/Metric/FiberRuntimeMetricsKey";var pR=Me("effect/ErrorReporter/CurrentErrorReporters",{defaultValue:()=>new Set}),If=Me("effect/References/CurrentStackFrame",{fiberCached:!0,defaultValue:es}),eg=Me("effect/References/TracerEnabled",{defaultValue:Xt}),Zc=Me("effect/References/TracerTimingEnabled",{defaultValue:Xt}),Pd=Me("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),Fd=Me("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),Vi=Me("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})}),_b=Me("effect/References/CurrentLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),Mb=Me("effect/References/MinimumLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),mR=Me("effect/References/UnhandledLogLevel",{defaultValue:()=>"Error"}),tg=Me("effect/References/CurrentLogSpans",{defaultValue:()=>[]});var T3=()=>{let e=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit");return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,"writable")?e.writable===!0:e.set!==void 0},k3=T3(),Xs=()=>Error.stackTraceLimit,ir=e=>{k3&&(Error.stackTraceLimit=e)};var _o=e=>{if(e?.captureStackTrace===!1)return e;if(e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!="boolean")return e;let t=Xs();ir(3);let n=new Error;return ir(t),{...e,captureStackTrace:C3(()=>n.stack)}},Pb=e=>t=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let o=r.split(`
|
|
10
|
-
`);if(o[e]!==void 0)return n=o[e].trim(),n}},
|
|
11
|
-
`),s=[r];for(let i=1;i<o.length&&!/(?:Generator\.next|~effect\/Effect)/.test(o[i]);i++)s.push(o[i]);return n?
|
|
9
|
+
`)}return t},AE=d(2,(e,t)=>{let n=CE(e,t.key);return n!==Qh?L(n):YR(t)?L(XR(t)):D()}),br=d(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:A3(e,n=>t.mapUnsafe.forEach((r,o)=>n.set(o,r)))),eO=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((r,o)=>{t.set(o,r)});return Mo(t)};var Me=Ke;var Yh="~effect/time/Duration",OE=BigInt(0),oO=BigInt(1),P3=BigInt(2),F3=BigInt(10);var U3=BigInt(1e3);var Xh=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),sO=e=>Xh(e*1e6),tO=(e,t)=>{let n=e.indexOf(".");if(n===-1)return BigInt(e)*t;let r=e[0]==="-",o=e.slice(n+1),s=F3**BigInt(o.length),i=(BigInt(e.slice(r?1:0,n))*s+BigInt(o))*t,a=i/s+(i%s*P3>=s?oO:OE);return r?-a:a};var D3=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,gt=e=>{switch(typeof e){case"number":return us(e);case"bigint":return Lr(e);case"string":{if(e==="Infinity")return po;if(e==="-Infinity")return Zi;let t=D3.exec(e);if(!t)break;let[n,r,o]=t;if(o==="nano"||o==="nanos")return Lr(tO(r,oO));if(o==="micro"||o==="micros")return Lr(tO(r,U3));let s=Number(r);switch(o){case"milli":case"millis":return us(s);case"second":case"seconds":return _E(s);case"minute":case"minutes":return j3(s);case"hour":case"hours":return q3(s);case"day":case"days":return $3(s);case"week":case"weeks":return z3(s)}break}case"object":{if(e===null)break;if(Yh in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(md)?nO(e):Number.isNaN(e[0])||Number.isNaN(e[1])?Gi:e[0]===-1/0||e[1]===-1/0?Zi:e[0]===1/0||e[1]===1/0?po:Er(Xh(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?Er(n):Er(Xh(n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0)))}}return nO(e)},nO=e=>{throw new Error(`Invalid Input: ${e}`)},iO=$a(gt),rO={_tag:"Millis",millis:0},N3={_tag:"Infinity"},L3={_tag:"NegativeInfinity"},B3={[Yh]:Yh,[Oe](){switch(this.value._tag){case"Millis":{let e=this.value.millis*1e6;return Number.isFinite(e)?ce(Xh(e)):Nr(this.value.millis)}case"Nanos":return ce(this.value.nanos);default:return xd(this.value)}},[_e](e){return nu(e)&&K3(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"}}},[at](){return this.toJSON()},pipe(){return ie(this,arguments)}},Er=e=>{let t=Object.create(B3);return typeof e=="number"?isNaN(e)||e===0||Object.is(e,-0)?t.value=rO:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:sO(e)}:t.value=e>0?N3:L3:e===OE?t.value=rO:t.value={_tag:"Nanos",nanos:e},t},nu=e=>j(e,Yh),fs=e=>e.value._tag!=="Infinity"&&e.value._tag!=="NegativeInfinity",Nd=e=>{switch(e.value._tag){case"Millis":return e.value.millis===0;case"Nanos":return e.value.nanos===OE;case"Infinity":case"NegativeInfinity":return!1}};var Gi=Er(0),po=Er(1/0),Zi=Er(-1/0),Lr=e=>Er(e);var us=e=>Er(e),_E=e=>Er(e*1e3),j3=e=>Er(e*6e4),q3=e=>Er(e*36e5),$3=e=>Er(e*864e5),z3=e=>Er(e*6048e5),Tn=e=>H3(gt(e),{onMillis:B,onNanos:t=>Number(t)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0});var RE=e=>{let t=gt(e);switch(t.value._tag){case"Infinity":case"NegativeInfinity":throw new Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return sO(t.value.millis)}},aO=$a(RE);var H3=d(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)()}}),ME=d(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(RE(e),t.value.nanos):n.onNanos(e.value.nanos,RE(t))),W3=ss((e,t)=>ME(e,t,{onMillis:(n,r)=>n<r?-1:n>r?1:0,onNanos:(n,r)=>n<r?-1:n>r?1:0,onInfinity:(n,r)=>n.value._tag===r.value._tag?0:n.value._tag==="Infinity"?1:n.value._tag==="NegativeInfinity"||r.value._tag==="Infinity"?-1:1}));var PE=(e,t)=>ME(e,t,{onMillis:(n,r)=>n===r,onNanos:(n,r)=>n===r,onInfinity:(n,r)=>n.value._tag===r.value._tag}),cO=jh(W3);var uO=d(2,(e,t)=>ME(e,t,{onMillis:(n,r)=>Er(n-r),onNanos:(n,r)=>Er(n-r),onInfinity:(n,r)=>{let o=n.value._tag,s=r.value._tag;return o==="Infinity"?s==="Infinity"?Gi:po:o==="NegativeInfinity"?s==="NegativeInfinity"?Gi:Zi:s==="Infinity"?Zi:po}}));var K3=d(2,(e,t)=>PE(e,t));var Ka=Me("effect/Scheduler",{fiberCached:!0,defaultValue:()=>new ei}),fO="setImmediate"in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},V3=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},FE=class{buckets=[];scheduleTask(t,n){let r=this.buckets,o=r.length,s,i=0;for(;i<o&&!(r[i][0]>n);i++)s=r[i];s&&s[0]===n?s[1].push(t):i===o?r.push([n,[t]]):r.splice(i,0,[n,[t]])}drain(){let t=this.buckets;return this.buckets=[],t}},ei=class{executionMode;setImmediate;constructor(t="async",n){this.executionMode=t,this.setImmediate=n??(t==="sync"?V3:fO)}shouldYield(t){return t.currentOpCount>=t.maxOpsBeforeYield}makeDispatcher(){return new UE(this.setImmediate)}},UE=class{tasks=new FE;running=void 0;setImmediate;constructor(t=fO){this.setImmediate=t}scheduleTask(t,n){this.tasks.scheduleTask(t,n),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let t=this.tasks.drain();for(let n=0;n<t.length;n++){let r=t[n][1];for(let o=0;o<r.length;o++)r[o]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}},lO=Me("effect/Scheduler/MaxOpsBeforeYield",{fiberCached:!0,defaultValue:()=>2048}),dO=Me("effect/Scheduler/PreventSchedulerYield",{fiberCached:!0,defaultValue:()=>!1});var pO=class extends Bc{constructor(e){super(),e&&Ah(this,e)}};var mO=kd,Mn=Hi;var hO="~effect/encoding/EncodingError",Yi=class extends Mn("EncodingError"){[hO]=hO};var ng=e=>DE(typeof e=="string"?jE.encode(e):e),Cf=e=>{let t=TO(e),n=t.length;if(n%4!==0)return Ae(new Yi({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 Ae(new Yi({kind:"Decode",module:"Base64",input:t,message:"Found a '=' character, but it is not at the end"}));try{let o=t.endsWith("==")?2:t.endsWith("=")?1:0,s=new Uint8Array(3*(n/4)-o);for(let i=0,a=0;i<n;i+=4,a+=3){let c=tg(t.charCodeAt(i))<<18|tg(t.charCodeAt(i+1))<<12|tg(t.charCodeAt(i+2))<<6|tg(t.charCodeAt(i+3));s[a]=c>>16,s[a+1]=c>>8&255,s[a+2]=c&255}return Ce(s)}catch(o){return Ae(new Yi({kind:"Decode",module:"Base64",input:t,message:o instanceof Error?o.message:"Invalid input"}))}},bO=e=>tu(Cf(e),t=>qE.decode(t)),EO=e=>xO(typeof e=="string"?jE.encode(e):e),NE=e=>{let t=TO(e),n=t.length;if(n%4===1)return Ae(new Yi({module:"Base64Url",kind:"Decode",input:t,message:`Length should be a multiple of 4, but is ${n}`}));if(!/^[-_A-Z0-9]*?={0,2}$/i.test(t))return Ae(new Yi({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let r=n%4===2?`${t}==`:n%4===3?`${t}=`:t;return r=r.replace(/-/g,"+").replace(/_/g,"/"),Cf(r)},wO=e=>tu(NE(e),t=>qE.decode(t)),IO=e=>yO(typeof e=="string"?jE.encode(e):e),LE=e=>{let t="";for(let n=e>>>3;n>0;n--){let r=Math.random()*4294967296>>>0;t+=kf[r>>>24]+kf[r>>>16&255]+kf[r>>>8&255]+kf[r&255]}return t},BE=e=>{let t=new TextEncoder().encode(e);if(t.length%2!==0)return Ae(new Yi({module:"Hex",kind:"Decode",input:e,message:`Length must be a multiple of 2, but is ${t.length}`}));try{let n=t.length/2,r=new Uint8Array(n);for(let o=0;o<n;o++){let s=SO(t[o*2]),i=SO(t[o*2+1]);r[o]=s<<4|i}return Ce(r)}catch(n){return Ae(new Yi({module:"Hex",kind:"Decode",input:e,message:n instanceof Error?n.message:"Invalid input"}))}},vO=e=>tu(BE(e),t=>qE.decode(t)),jE=new TextEncoder,qE=new TextDecoder,TO=e=>e.replace(/[\n\r]/g,""),DE=e=>{let t=e.length,n="",r;for(r=2;r<t;r+=3)n+=Qi[e[r-2]>>2],n+=Qi[(e[r-2]&3)<<4|e[r-1]>>4],n+=Qi[(e[r-1]&15)<<2|e[r]>>6],n+=Qi[e[r]&63];return r===t+1&&(n+=Qi[e[r-2]>>2],n+=Qi[(e[r-2]&3)<<4],n+="=="),r===t&&(n+=Qi[e[r-2]>>2],n+=Qi[(e[r-2]&3)<<4|e[r-1]>>4],n+=Qi[(e[r-1]&15)<<2],n+="="),n};function tg(e){if(e>=gO.length)throw new TypeError(`Invalid character ${String.fromCharCode(e)}`);let t=gO[e];if(t===255)throw new TypeError(`Invalid character ${String.fromCharCode(e)}`);return t}var Qi=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"],gO=[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],xO=e=>DE(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),kf=[];for(let e=0;e<256;e++)kf.push(e.toString(16).padStart(2,"0"));var yO=e=>{let t="";for(let n=0;n<e.length;n++)t+=kf[e[n]];return t},SO=e=>{if(48<=e&&e<=57)return e-48;if(97<=e&&e<=102)return e-97+10;if(65<=e&&e<=70)return e-65+10;throw new TypeError("Invalid input")};var zE="effect/Tracer/ParentSpan",ti=class extends Ke()(zE,{fiberCached:!0}){},J3=e=>e;var Af=Me("effect/Tracer/DisablePropagation",{defaultValue:jc}),kO=Me("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),CO=Me("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),HE="effect/Tracer",og=Me(HE,{fiberCached:!0,defaultValue:()=>J3({span:e=>new $E(e)})}),$E=class{_tag="Span";spanId;traceId="native";sampled;name;parent;annotations;links;startTime;kind;status;attributes;events=[];constructor(t){this.name=t.name,this.parent=t.parent,this.annotations=t.annotations,this.links=t.links,this.startTime=t.startTime,this.kind=t.kind,this.sampled=t.sampled,this.status={_tag:"Started",startTime:t.startTime},this.attributes=new Map,this.traceId=Oo(t.parent)?.traceId??LE(32),this.spanId=LE(16)}end(t,n){this.status={_tag:"Ended",endTime:t,exit:n,startTime:this.status.startTime}}attribute(t,n){this.attributes.set(t,n)}event(t,n,r){this.events.push([t,n,r??{}])}addLinks(t){this.links.push(...t)}};var AO="effect/observability/Metric/FiberRuntimeMetricsKey";var RO=Me("effect/ErrorReporter/CurrentErrorReporters",{defaultValue:()=>new Set}),Rf=Me("effect/References/CurrentStackFrame",{fiberCached:!0,defaultValue:rs}),ig=Me("effect/References/TracerEnabled",{defaultValue:Xt}),ru=Me("effect/References/TracerTimingEnabled",{defaultValue:Xt}),Ld=Me("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),Bd=Me("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),Xi=Me("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})}),WE=Me("effect/References/CurrentLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),KE=Me("effect/References/MinimumLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),OO=Me("effect/References/UnhandledLogLevel",{defaultValue:()=>"Error"}),ag=Me("effect/References/CurrentLogSpans",{defaultValue:()=>[]});var Q3=()=>{let e=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit");return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,"writable")?e.writable===!0:e.set!==void 0},Y3=Q3(),ni=()=>Error.stackTraceLimit,ir=e=>{Y3&&(Error.stackTraceLimit=e)};var Po=e=>{if(e?.captureStackTrace===!1)return e;if(e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!="boolean")return e;let t=ni();ir(3);let n=new Error;return ir(t),{...e,captureStackTrace:X3(()=>n.stack)}},VE=e=>t=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let o=r.split(`
|
|
10
|
+
`);if(o[e]!==void 0)return n=o[e].trim(),n}},X3=VE(3);var cg=class extends hf{fiberId;constructor(t,n=wd){super("Interrupt",n,"Interrupted"),this.fiberId=t}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[_e](t){return Td(t)&&this.fiberId===t.fiberId&&this.annotations===t.annotations}[Oe](){return Nt(it(`${this._tag}:${this.fiberId}`))(bh(this.annotations))}},NO=e=>new cg(e),Za=e=>new Zs([new cg(e)]),LO=e=>e.reasons.some(Ba),BO=e=>{let t=e.reasons.find(Ba);return t?Ce(t):Ae(e)},ri=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag==="Fail")return Ce(n.error)}return Ae(e)};var jO=e=>e.reasons.some(vd);var c0=e=>{let t=e.reasons.find(vd);return t?Ce(t.defect):Ae(e)},u0=e=>e.reasons.some(Td);var f0=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?Ce(t):Ae(e)},qO=e=>{let t=f0(e);return Fe(t)?t4:t.success},t4=new Set,$O=e=>e.reasons.length>0&&e.reasons.every(Td);var l0=d(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new Zs(gE(e.reasons,t.reasons));return ae(e,n)?e:n}),zO=d(2,(e,t)=>{let n=!1,r=e.reasons.map(o=>Ba(o)?(n=!0,new Jc(t(o.error),o.annotations)):o);return n?$i(r):e}),n4=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},hg=e=>{let t=n4(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")},HO=(e,t)=>{let n=[],r=[];if(e.reasons.length===0)return n;let o=ni();ir(1);for(let s of e.reasons){if(s._tag==="Interrupt"){r.push(s);continue}n.push(GE(s._tag==="Die"?s.defect:s.error,s.annotations,t))}if(n.length===0){let s=new Error("The fiber was interrupted by:");s.name="InterruptCause",s.stack=i4(s,r);let i=new globalThis.Error("All fibers interrupted without error",{cause:s});i.name="InterruptError",i.stack=`${i.name}: ${i.message}`,n.push(GE(i,r[0].annotations,t))}return ir(o),n},GE=(e,t,n)=>{let r=typeof e,o;if(e&&r==="object"){if(o=new globalThis.Error(r4(e),{cause:e.cause?GE(e.cause):void 0}),typeof e.name=="string"&&(o.name=e.name),typeof e.stack=="string")o.stack=s4(e.stack,o,t);else{let s=`${o.name}: ${o.message}`;o.stack=t?WO(s,t):s}n?.includeCauseInStack&&(o.stack=VO(o));for(let s of Object.keys(e))s in o||(o[s]=e[s])}else o=new globalThis.Error(e?r==="string"?e:Kc(e):`Unknown error: ${e}`);return o},r4=e=>{if(typeof e.message=="string")return e.message;if(typeof e.toString=="function"&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return Kc(e)},o4=/\((.*)\)/g,s4=(e,t,n)=>{let r=`${t.name}: ${t.message}`,o=(e.startsWith(r)?e.slice(r.length):e).split(`
|
|
11
|
+
`),s=[r];for(let i=1;i<o.length&&!/(?:Generator\.next|~effect\/Effect)/.test(o[i]);i++)s.push(o[i]);return n?WO(s.join(`
|
|
12
12
|
`),n):s.join(`
|
|
13
|
-
`)},
|
|
14
|
-
${
|
|
15
|
-
`)},
|
|
16
|
-
`)},
|
|
17
|
-
`),
|
|
18
|
-
${
|
|
19
|
-
}`:e.stack,
|
|
13
|
+
`)},WO=(e,t)=>{let n=t?.get(Fh.key);return n&&(e=`${e}
|
|
14
|
+
${KO(n)}`),e},i4=(e,t)=>{let n=[`${e.name}: ${e.message}`];for(let r of t){let o=r.fiberId!==void 0?`#${r.fiberId}`:"unknown",s=r.annotations.get(rE.key);n.push(` at fiber (${o})`),s&&n.push(KO(s))}return n.join(`
|
|
15
|
+
`)},KO=e=>{let t=[],n=e,r=0;for(;n&&r<10;){let o=n.stack();if(o){let s=o.matchAll(o4),i=!1;for(let[,a]of s)i=!0,t.push(` at ${n.name} (${a})`);i||t.push(` at ${n.name} (${o.replace(/^at /,"")})`)}else t.push(` at ${n.name}`);n=n.parent,r++}return t.join(`
|
|
16
|
+
`)},gg=e=>HO(e).map(VO).join(`
|
|
17
|
+
`),VO=e=>e.cause?`${e.stack} {
|
|
18
|
+
${JO(e.cause," ")}
|
|
19
|
+
}`:e.stack,JO=(e,t)=>{let n=e.stack.split(`
|
|
20
20
|
`),r=`${t}[cause]: ${n[0]}`;for(let o=1,s=n.length;o<s;o++)r+=`
|
|
21
21
|
${t}${n[o]}`;return e.cause&&(r+=` {
|
|
22
|
-
${
|
|
23
|
-
${t}}`),r},rg="~effect/Fiber",U3={_A:L,_E:L},D3={id:0},Ji=()=>globalThis[cf],og=class{constructor(t,n=!0){this[rg]=U3,this.setContext(t),this.id=++D3.id,this.currentOpCount=0,this.interruptible=n,this._stack=[],this._observers=[],this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this.runtimeMetrics?.recordFiberStart(this.context)}[rg];id;interruptible;currentOpCount;_stack;_observers;_exit;_children;_interruptedCause;_yielded;_running;_deferredInterrupt;context;currentScheduler;currentTracerContext;currentSpan;currentLogLevel;minimumLogLevel;currentStackFrame;runtimeMetrics;maxOpsBeforeYield;currentPreventYield;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.currentScheduler.makeDispatcher()}getRef(t){return qe(this.context,t)}addObserver(t){return this._exit?(t(this._exit),bn):(this._observers.push(t),()=>{if(this._exit)return;let n=this._observers.indexOf(t);n>=0&&this._observers.splice(n,1)})}interruptUnsafe(t,n){if(this._exit)return;let r=Ha(t);this.currentStackFrame&&(r=yd(r,ss(Ah,this.currentStackFrame))),n&&(r=yd(r,n)),this._interruptedCause=this._interruptedCause?Qb(this._interruptedCause,r):r,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(ot(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(t){if(this._exit)return;if(this._yielded!==void 0){let o=this._yielded;this._yielded=void 0,o()}let n=this.runLoop(t);if(n===qc)return;let r=Db.interruptChildren&&Db.interruptChildren(this);if(r!==void 0)return this.evaluate(ne(r,()=>n));this._exit=n,this.runtimeMetrics?.recordFiberEnd(this.context,this._exit);for(let o=0;o<this._observers.length;o++)this._observers[o](n);this._observers.length=0,this._stack.length=0,this._children=void 0,this.context=bt()}runLoop(t){let n=globalThis[cf];globalThis[cf]=this;let r=this._running;this._running=!0;let o=!1,s=t;this.currentOpCount=0;try{for(;;){if(this._deferredInterrupt&&(this._deferredInterrupt=!1,s=ot(this._interruptedCause)),this.currentOpCount++,!o&&!this.currentPreventYield&&this.currentScheduler.shouldYield(this)){o=!0;let i=s;s=ne(Cf,()=>i)}if(s=this.currentTracerContext?this.currentTracerContext(s,this):s[nn](this),s===qc){let i=this._yielded;if(jc in i)return this._deferredInterrupt=!1,this._yielded=void 0,i;if(this._deferredInterrupt){this._yielded=void 0,i();continue}return qc}}}catch(i){return B(s,nn)?this.runLoop(ao(i)):ao(`Fiber.runLoop: Not a valid effect: ${String(s)}`)}finally{this._running=r,globalThis[cf]=n}}getCont(t){if(this._deferredInterrupt)return this._deferredInterrupt=!1,N3;for(;;){let n=this._stack.pop();if(!n)return;let r=n[Ma]&&n[Ma](this);if(r)return r[t]=r,r;if(n[t])return n}}yieldWith(t){return this._yielded=t,qc}children(){return this._children??=new Set}pipe(){return ie(this,arguments)}setContext(t){let n=this.context;if(this.context=t,n!==void 0&&UO(n,t))return;let r=this.getRef(ja);r!==this.currentScheduler&&(this.currentScheduler=r,this._dispatcher=void 0),this.currentSpan=qi(t,Ob),this.currentLogLevel=this.getRef(_b),this.minimumLogLevel=this.getRef(Mb),this.currentStackFrame=this.getRef(If),this.maxOpsBeforeYield=this.getRef(GO),this.currentPreventYield=this.getRef(ZO),this.runtimeMetrics=qi(t,dR);let o=qi(t,Rb);this.currentTracerContext=o?o.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag==="Span"?this.currentSpan:void 0}},N3={[Sr](e,t){return ot(t._interruptedCause)},[vo](e,t){return ot(t._interruptedCause)}},Db={interruptChildren:void 0},lg=e=>{if(!e.currentStackFrame)return;let t=new Map;return t.set(zE.key,e.currentStackFrame),Ro(t)},L3=e=>{if(!(e._children===void 0||e._children.size===0))return za(e._children)},Yb=e=>{let t=e;return t._exit?J(t._exit):Bt(n=>t._exit?n(J(t._exit)):he(e.addObserver(r=>n(J(r)))))},dg=e=>Bt(t=>{let n=e[Symbol.iterator](),r=[],o;function s(){let i=n.next();for(;!i.done;){if(i.value._exit){r.push(i.value._exit),i=n.next();continue}o=i.value.addObserver(a=>{r.push(a),s()});return}t(J(r))}return s(),he(()=>o?.())}),PR=e=>{let t=e;return t._exit?t._exit:Bt(n=>t._exit?n(t._exit):he(e.addObserver(n)))},FR=e=>Bt(t=>{let n=Array.from(e);if(n.length===0)return t(J(rn()));let r=new Array(n.length),o=rn(),s=0,i=!1;for(let a=0;a<n.length&&!i;a++)o.push(n[a].addObserver(c=>{if(s++,c._tag==="Failure")return i=!0,o.forEach(u=>u()),t(c);r[a]=c.value,s===n.length&&t(J(r))}));return he(()=>{i=!0,o.forEach(a=>a())})}),pg=e=>de(t=>UR(e,t.id)),UR=d(e=>B(e[0],rg),(e,t,n)=>de(r=>{let o=lg(r);return o=o&&n?Er(o,n):o??n,e.interruptUnsafe(t,o),Ld(Yb(e))})),za=e=>de(t=>{let n=lg(t),r=rn();for(let o of e)o.interruptUnsafe(t.id,n),r.push(o);return Ld(dg(r))});var J=rt,ot=Rn,wt=io,he=To({op:"Sync",[nn](e){let t=this[xe](),n=e.getCont(Sr);return n?n[Sr](t,e):e.yieldWith(rt(t))}}),me=To({op:"Suspend",[nn](e){return this[xe]()}}),Xb=d(e=>e.length>=2||Gs(e[0]),(e,t)=>ge(e)?wt(t?t():new ts("Effect.fromOption: Option.none")):J(e.value)),kf=Oo({onFailure:wt,onSuccess:J}),DR=e=>e==null?wt(new ts):J(e),e0=To({op:"Yield",[nn](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(Ir)},this[xe]??0),e.yieldWith(()=>{t=!0})}}),Cf=e0(0),t0=e=>J(N(e)),Xc=J(U()),NR=e=>ge(e)?Xc:Be(e.value,N),LR=e=>me(()=>ot(je(e))),Gi=e=>ao(e),mg=e=>me(()=>wt(je(e))),we=J(void 0);var BR=e=>{let t=typeof e=="function"?e:e.try,n=typeof e=="function"?r=>new Dd(r,"An error occurred in Effect.try"):e.catch;return me(()=>{try{return J(je(t))}catch(r){return wt(je(()=>n(r)))}})};var n0=e=>r0(function(t,n){je(()=>e(n)).then(r=>t(J(r)),r=>t(Gi(r)))},e.length!==0),jR=e=>{let t=typeof e=="function"?e:e.try,n=typeof e=="function"?r=>new Dd(r,"An error occurred in Effect.tryPromise"):e.catch;return r0(function(r,o){let s=i=>{try{r(wt(je(()=>n(i))))}catch(a){r(Gi(a))}};try{je(()=>t(o)).then(i=>r(J(i)),s)}catch(i){s(i)}},t.length!==0)},$R=e=>de(t=>e(t.id)),qR=de(J),zR=$R(J),r0=To({op:"Async",single:!1,[nn](e){let t=je(()=>this[xe][0].bind(e.currentScheduler)),n=!1,r=!1,o=this[xe][1]?new AbortController:void 0,s=t(i=>{n||(n=!0,r?e.evaluate(i):r=i)},o?.signal);return r!==!1?r:(r=!0,e._yielded=()=>{n=!0},o===void 0&&s===void 0?qc:(e._stack.push(B3(()=>(n=!0,o?.abort(),s??Ir))),qc))}}),B3=To({op:"AsyncFinalizer",[Ma](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Og))},[vo](e,t){return Gb(e)?ne(this[xe](),()=>ot(e)):ot(e)}}),Bt=e=>r0(e,e.length>=2),Nd=Bt(bn),HR=(...e)=>me(()=>vf(e.length===1?e[0]():e[1].call(e[0].self))),o0=(e,...t)=>{let n=t.length===0?function(){return me(()=>vf(e.apply(this,arguments)))}:function(){let r=me(()=>vf(e.apply(this,arguments)));for(let o=0;o<t.length;o++)r=t[o](r,...arguments);return r};return s0(e.length,n)},s0=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),hR=Pb(2),WR=function(){let e=typeof arguments[0]=="string",t=e?arguments[0]:"Effect.fn",n=e?arguments[1]:void 0,r=Xs();ir(2);let o=new globalThis.Error;return ir(r),e?(s,...i)=>gR(t,s,o,i,e,n):gR(t,arguments[0],o,Array.prototype.slice.call(arguments,1),e,n)},gR=(e,t,n,r,o,s)=>{let i=typeof t=="function"?t:r.shift().bind(t.self);return s0(i.length,function(...a){let c=me(()=>{let l=i.apply(this,arguments);return ve(l)?l:vf(l)});for(let l=0;l<r.length;l++)c=r[l](c,...a);if(!ve(c))return c;let u=Xs();ir(2);let f=new globalThis.Error;return ir(u),Zi(o?Ud(e,s,l=>$b(c,l)):c,If,l=>({name:e,stack:hR(()=>f.stack),parent:{name:`${e} (definition)`,stack:hR(()=>n.stack),parent:l}}))})},KR=(e,...t)=>s0(e.length,t.length===0?function(){return xR(()=>e.apply(this,arguments))}:function(){let n=xR(()=>e.apply(this,arguments));for(let r of t)n=r(n);return n}),xR=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return J(r.value);let o=r.value;if(o&&o._tag==="Success"){n=o.value;continue}else{if(o&&o._tag==="Failure")return r.value;{let s=!0;return me(()=>s?(s=!1,ne(r.value,i=>vf(t,i))):me(()=>vf(e())))}}}}catch(t){return Gi(t)}},vf=To({op:"Iterator",single:!1,[Sr](e,t){let n=this[xe][0];for(;;){let r=n.next(e);if(r.done)return J(r.value);if(xt(r.value)){if(r.value._tag==="Failure")return r.value}else return t._stack.push(this),r.value;e=r.value.value}},[nn](e){return this[Sr](this[xe][1],e)}}),Pn=d(2,(e,t)=>{let n=J(t);return ne(e,r=>n)}),Af=e=>Be(e,N),VR=e=>eu(e,{onFailure:J,onSuccess:wt}),Br=d(2,(e,t)=>ne(e,n=>ve(t)?t:je(()=>t(n)))),ti=d(2,(e,t)=>ne(e,n=>Pn(ve(t)?t:je(()=>t(n)),n))),Ld=e=>ne(e,t=>Ir),JR=e=>Tr(e,wt),i0=(e,t)=>de(n=>Bt(r=>{let o=ht(e),s=o.length,i=0,a=!1,c=new Set,u=[],f=(l,p,m)=>{if(i++,l._tag==="Failure"){u.push(...l.cause.reasons),i>=s&&r(ot(Di(u)));return}let h=!a;a=!0,r(c.size===0?l:ne(Yi(za(c)),()=>l)),h&&t?.onWinner&&t.onWinner({fiber:p,index:m,parentFiber:n})};for(let l=0;l<s;l++){let p=nu(n,o[l],!0,!0,!1);if(c.add(p),p.addObserver(m=>{c.delete(p),f(m,p,l)}),a)break}return za(c)})),a0=(e,t)=>de(n=>Bt(r=>{let o=!1,s=new Set,i=c=>{o=!0,r(s.size===0?c:ne(Yi(za(s)),()=>c))},a=0;for(let c of e){if(o)break;let u=a++,f=nu(n,c,!0,!0,!1);s.add(f),f.addObserver(l=>{s.delete(f);let p=!o;i(l),p&&t?.onWinner&&t.onWinner({fiber:f,index:u,parentFiber:n})})}return za(s)})),GR=d(e=>ve(e[1]),(e,t,n)=>i0([e,t],n)),hg=d(e=>ve(e[1]),(e,t,n)=>a0([e,t],n)),ne=d(2,(e,t)=>{let n=Object.create(j3);return n[xe]=e,n[Sr]=t.length!==1?r=>t(r):t,n}),j3=Ni({op:"OnSuccess",[nn](e){return e._stack.push(this),this[xe]}}),ZR=d(2,(e,t)=>xt(e)?e._tag==="Success"?t.onSuccess(e.value):t.onFailure(e.cause):cs(e,t)),xt=e=>jc in e,QR=d(2,(e,t)=>xt(e)?e._tag==="Success"?t(e.value):e:ne(e,t)),YR=e=>ne(e,L),Be=d(2,(e,t)=>ne(e,n=>J(je(()=>t(n))))),XR=d(2,(e,t)=>xt(e)?s_(e,t):Be(e,t)),e_=d(2,(e,t)=>xt(e)?i_(e,t):p0(e,t)),t_=d(2,(e,t)=>xt(e)?a_(e,t):m0(e,t)),n_=d(2,(e,t)=>{if(xt(e)){if(e._tag==="Success")return e;let n=ei(e.cause);return Fe(n)?e:t(n.success)}return kr(e,t)}),gg=e=>Rn(Ha(e)),Of=e=>e._tag==="Success";var r_=e=>e._tag==="Failure";var o_=e=>e._tag==="Failure"?Ce(e.cause):Ae(e);var Ir=rt(void 0),s_=d(2,(e,t)=>e._tag==="Success"?rt(t(e.value)):e),i_=d(2,(e,t)=>{if(e._tag==="Success")return e;let n=ei(e.cause);return Fe(n)?e:io(t(n.success))}),a_=d(2,(e,t)=>{if(e._tag==="Success")return rt(t.onSuccess(e.value));let n=ei(e.cause);return Fe(n)?e:io(t.onFailure(n.success))});var c_=d(2,(e,t)=>Of(e)?t:e),u_=d(2,(e,t)=>Of(e)?t.onSuccess(e.value):t.onFailure(e.cause));var f_=e=>{let t=[];for(let n of e)n._tag==="Failure"&&t.push(...n.cause.reasons);return t.length===0?Ir:Rn(Di(t))};var l_=e=>e,d_=e=>de(t=>J(mb(t.context,e))),$3=e=>de(t=>Xb(mb(t.context,e))),Rf=d(2,(e,t)=>de(n=>{let r=n.context,o=t(r);return r===o?e:(n.setContext(o),ls(e,()=>{n.setContext(r)}))})),Zi=d(3,(e,t,n)=>Rf(e,r=>{let o=Jn(r,t),s=n(o);return o===s?r:Ve(r,t,s)})),p_=(e,t,n)=>Yi(de(r=>{let o=Jn(r.context,e),s=t(o);return r.setContext(Ve(r.context,e,s)),fs(Jn(r.context,Ka),i=>{let a=Jn(r.context,e),c;if(n?.reset===void 0){if(a!==s)return we;c=o}else c=n.reset(o,s,a);return r.setContext(Ve(r.context,e,c)),we})})),c0=()=>q3,q3=de(e=>J(e.context)),Wa=e=>de(t=>e(t.context)),m_=d(2,(e,t)=>Rf(e,Qe(t))),Qi=d(2,(e,t)=>xt(e)?e:Rf(e,Er(t))),vr=function(){return arguments.length===1?d(2,(e,t)=>yR(e,arguments[0],t)):d(3,(e,t,n)=>yR(e,t,n)).apply(this,arguments)},yR=(e,t,n)=>Rf(e,Ve(t,n)),xg=d(3,(e,t,n)=>ne(n,r=>vr(e,t,r))),h_=d(e=>ve(e[1]),(e,t,n)=>u0(e,t,(r,o)=>[r,o],n)),u0=d(e=>ve(e[1]),(e,t,n,r)=>r?.concurrent?Be(Uf([e,t],{concurrency:2}),([o,s])=>je(()=>n(o,s))):ne(e,o=>Be(t,s=>je(()=>n(o,s))))),g_=d(e=>ve(e[0]),(e,t,n)=>A0(e,t,n?r=>wt(n(r)):()=>wt(new ts))),x_=d(2,(e,t)=>ne(t,n=>n?Af(e):Xc)),f0=d(2,(e,t)=>Array.from({length:t},()=>e)),y_=d(e=>ve(e[0]),(e,t,n)=>Uf(f0(e,t),n)),yg=d(e=>ve(e[0]),(e,t)=>ni({while:Xt,body:Qe(t?.disableYield?e:ne(e,n=>Cf)),step:bn})),Tr=d(2,(e,t)=>{let n=Object.create(z3);return n[xe]=e,n[vo]=t.length!==1?r=>t(r):t,n}),z3=Ni({op:"OnFailure",[nn](e){return e._stack.push(this),this[xe]}}),l0=d(3,(e,t,n)=>Tr(e,r=>t(r)?je(()=>n(r)):ot(r))),_f=d(3,(e,t,n)=>Tr(e,r=>{let o=t(r);return Fe(o)?ot(o.failure):je(()=>n(o.success,r))})),kr=d(2,(e,t)=>_f(e,ei,n=>t(n))),S_=e=>eu(e,{onFailure:t=>HE(t)?Xc:wt(t),onSuccess:t0}),E_=d(2,(e,t)=>_f(e,Jb,t)),b_=d(2,(e,t)=>Tr(e,n=>Br(je(()=>t(n)),ot(n)))),w_=d(3,(e,t,n)=>l0(e,t,r=>Br(je(()=>n(r)),ot(r)))),Sg=d(3,(e,t,n)=>Tr(e,r=>{let o=t(r);return Fe(o)?ot(r):Br(je(()=>n(o.success,r)),ot(r))})),d0=d(2,(e,t)=>Sg(e,ei,n=>t(n))),I_=d(3,(e,t,n)=>{let r=Array.isArray(t)?o=>B(o,"_tag")&&t.includes(o._tag):yr(t);return d0(e,o=>r(o)?n(o):we)}),v_=d(2,(e,t)=>Sg(e,Jb,n=>t(n))),Bd=d(e=>ve(e[0]),(e,t,n,r)=>Tr(e,o=>{let s=ei(o);return Fe(s)?ot(s.failure):t(s.success)?je(()=>n(s.success)):r?je(()=>r(s.success)):ot(o)})),Eg=d(e=>ve(e[0]),(e,t,n,r)=>Tr(e,o=>{let s=ei(o);if(Fe(s))return ot(s.failure);let i=t(s.success);return Fe(i)?r?je(()=>r(i.failure)):ot(o):je(()=>n(i.success))})),bg=d(e=>ve(e[0]),(e,t,n,r)=>{let o=Array.isArray(t)?s=>B(s,"_tag")&&t.includes(s._tag):yr(t);return Bd(e,o,n,r)}),T_=d(e=>ve(e[0]),(e,t,n)=>{let r;return Eg(e,o=>(r??=Object.keys(t),B(o,"_tag")&&oo(o._tag)&&r.includes(o._tag)?Ce(o):Ae(o)),o=>je(()=>t[o._tag](o)),n)}),k_=d(e=>ve(e[0]),(e,t,n,r,o)=>Bd(e,s=>yr(s,t)&&B(s,"reason"),s=>{let i=s.reason;return yr(i,n)?r(i,s):o?je(()=>o(i,s)):wt(s)})),C_=d(e=>ve(e[0]),(e,t,n,r)=>{let o;return Bd(e,s=>yr(s,t)&&B(s,"reason")&&B(s.reason,"_tag")&&oo(s.reason._tag),s=>{let i=s.reason;return o??=Object.keys(n),o.includes(i._tag)?je(()=>n[i._tag](i,s)):r?je(()=>r(i,s)):wt(s)})}),A_=d(2,(e,t)=>Eg(e,n=>yr(n,t)&&B(n,"reason")?Ce(n.reason):Ae(n),wt)),p0=d(2,(e,t)=>kr(e,n=>mg(()=>t(n)))),m0=d(2,(e,t)=>eu(e,{onFailure:n=>mg(()=>t.onFailure(n)),onSuccess:n=>he(()=>t.onSuccess(n))})),wg=e=>kr(e,Gi),O_=d(2,(e,t)=>kr(e,n=>he(t))),R_=e=>me(()=>{let t=e[Symbol.iterator](),n=t.next();if(n.done)return Gi(new Error("Received an empty collection of effects"));function r(o){let s=t.next();return s.done?o.value:kr(o.value,i=>r(s))}return r(n)}),h0=e=>kr(e,t=>ne(Cf,()=>h0(e))),__=d(e=>ve(e[0]),(e,t)=>{if(!t?.log)return eu(e,{onFailure:r=>we,onSuccess:r=>we});let n=ps(t.log===!0?void 0:t.log);return cs(e,{onFailure(r){let o=IR(r);return Fe(o)?ot(o.failure):t.message===void 0?n(r):n(t.message,r)},onSuccess:r=>we})}),Ig=d(e=>ve(e[0]),(e,t)=>{if(!t?.log)return cs(e,{onFailure:r=>we,onSuccess:r=>we});let n=ps(t.log===!0?void 0:t.log);return cs(e,{onFailure:r=>t.message===void 0?n(r):n(t.message,r),onSuccess:r=>we})}),M_=e=>vg(e,{onFailure:U,onSuccess:N}),qa=e=>jd(e,{onFailure:Ae,onSuccess:Ce}),cs=d(2,(e,t)=>{let n=Object.create(H3);return n[xe]=e,n[Sr]=t.onSuccess.length!==1?r=>t.onSuccess(r):t.onSuccess,n[vo]=t.onFailure.length!==1?r=>t.onFailure(r):t.onFailure,n}),H3=Ni({op:"OnSuccessAndFailure",[nn](e){return e._stack.push(this),this[xe]}}),g0=d(2,(e,t)=>cs(e,{onFailure:n=>he(()=>t.onFailure(n)),onSuccess:n=>he(()=>t.onSuccess(n))})),eu=d(2,(e,t)=>cs(e,{onFailure:n=>{let r=n.reasons.find(Pa);return r?je(()=>t.onFailure(r.error)):ot(n)},onSuccess:t.onSuccess})),vg=d(2,(e,t)=>eu(e,{onFailure:n=>he(()=>t.onFailure(n)),onSuccess:n=>he(()=>t.onSuccess(n))})),jd=d(2,(e,t)=>{if(xt(e)){if(e._tag==="Success")return rt(t.onSuccess(e.value));let n=ei(e.cause);return Fe(n)?e:rt(t.onFailure(n.success))}return vg(e,t)}),P_=d(2,(e,t)=>xt(e)?e._tag==="Success"?rt(t.onSuccess(e.value)):rt(t.onFailure(e.cause)):g0(e,t)),$d=e=>xt(e)?rt(e):W3(e),W3=To({op:"Exit",[nn](e){return e._stack.push(this),this[xe]},[Sr](e,t,n){return J(n??rt(e))},[vo](e,t,n){return J(n??Rn(e))}}),F_=jd({onFailure:()=>!0,onSuccess:()=>!1}),U_=jd({onFailure:()=>!1,onSuccess:()=>!0}),D_=d(2,(e,t)=>Br(ru(t),e)),x0=d(2,(e,t)=>hg(e,ne(ru(t.duration),t.orElse))),N_=d(2,(e,t)=>x0(e,{duration:t,orElse:()=>wt(new sg)})),L_=d(2,(e,t)=>hg(Af(e),Pn(ru(t),U()))),B_=e=>ds(t=>{let n=t.monotonicTimeNanosUnsafe();return Be(e,r=>[Nr(t.monotonicTimeNanosUnsafe()-n),r])}),Nb="~effect/Scope",Lb="~effect/Scope/Closeable",Ka=Ke("effect/Scope"),y0=(e,t)=>me(()=>Mf(e,t)??we),Mf=(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 o=r.finalizers;if(!(o===void 0||o.size===0))return o.size===1?o.values().next().value(t):V3(e,o,t)},K3=(e,t)=>Of(e)?t:Tr(t,n=>ot(Qb(e.cause,n))),V3=o0(function*(e,t,n){let r=[],o=[],s=Array.from(t.values()),i=Ji();for(let a=s.length-1;a>=0;a--){let c=s[a];e.strategy==="sequential"?r.push(yield*$d(c(n))):o.push(nu(i,c(n),!0,!0,"inherit"))}return o.length>0&&(r=yield*dg(o)),yield*f_(r)});var j_=(e,t)=>{let n=tu(t);if(e.state._tag==="Closed")return n.state=e.state,n;let r={};return Yc(e,r,o=>y0(n,o)),Yc(n,r,o=>he(()=>S0(e,r))),n},fs=(e,t)=>me(()=>e.state._tag==="Closed"?t(e.state.exit):(Yc(e,{},t),we)),$_=(e,t)=>fs(e,Qe(t)),Yc=(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=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0,r.finalizers.set(t,n)):r.finalizers===void 0?(r.finalizerKey=t,r.finalizer=n):r.finalizers.set(t,n)}},S0=(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)}},q_=e=>e.state._tag!=="Open"?0:e.state.finalizer!==void 0?1:e.state.finalizers?.size??0,tu=(e="sequential")=>({[Lb]:Lb,[Nb]:Nb,strategy:e,state:J3}),J3={_tag:"Empty"};var qd=Ka,z_=vr(Ka),Tg=e=>de(t=>{let n=t.context,r=tu();return t.setContext(Ve(t.context,Ka,r)),ls(e,o=>(t.setContext(n),Mf(r,o)))});var kg=e=>me(()=>{let t=tu();return Gn(e(t),n=>me(()=>Mf(t,n)??we))}),Cg=(e,t,n)=>Wa(r=>jr(o=>ne(qd,s=>ti(n?.interruptible?o(e):e,i=>fs(s,a=>Qi(t(i,a),r)))))),Pf=e=>ne(qd,t=>Wa(n=>fs(t,r=>Qi(e(r),n)))),ls=To({op:"OnExit",single:!1,[nn](e){return e._stack.push(this),this[xe][0]},[Ma](e){e.interruptible&&this[xe][2]!==!0&&(e._stack.push(Og),e.interruptible=!1)},[Sr](e,t,n){n??=rt(e);let r=this[xe][1](n);return r?ne(r,o=>n):n},[vo](e,t,n){n??=Rn(e);let r=this[xe][1](n);return r?ne(K3(n,r),o=>n):n}}),Gn=d(2,ls),H_=d(2,(e,t)=>Gn(e,n=>t)),E0=d(3,(e,t,n)=>Gn(e,r=>t(r)?n(r):we)),b0=d(3,(e,t,n)=>Gn(e,r=>{let o=t(r);return Fe(o)?we:n(o.success,r)})),w0=d(2,(e,t)=>b0(e,o_,t)),W_=d(3,(e,t,n)=>E0(e,r=>r._tag!=="Failure"?!1:t(r.cause),r=>n(r.cause))),I0=d(3,(e,t,n)=>Gn(e,r=>{if(r._tag!=="Failure")return we;let o=t(r.cause);return Fe(o)?we:n(o.success,r.cause)})),Ag=d(2,(e,t)=>I0(Zb,t)(e)),K_=(e,t,n)=>jr(r=>ne(e,o=>ls(r(t(o)),s=>n(o,s),!0))),V_=e=>Cg(e,t=>B(t,Symbol.asyncDispose)?n0(()=>t[Symbol.asyncDispose]()):he(()=>t[Symbol.dispose]())),v0=d(2,(e,t)=>he(()=>{let n=Tn(gt(t)),r=Number.isFinite(n),o=Mg(!1),s=0,i=!1,a,c=ne(o.await,()=>a);return[de(u=>{let f=u.getRef(lo),l=r?f.currentTimeMillisUnsafe():0;return i||l<s?a??c:(i=!0,o.closeUnsafe(),a=void 0,Gn(e,p=>he(()=>{i=!1,s=f.currentTimeMillisUnsafe()+n,a=p,o.openUnsafe()})))}),he(()=>{s=0,o.closeUnsafe(),a=void 0})]})),T0=d(2,(e,t)=>Be(v0(e,t),n=>n[0])),J_=e=>T0(e,fo),Ff=de(e=>ot(Ha(e.id))),Yi=e=>de(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(Og)),e)),G_=To({op:"SetInterruptible",[Ma](e){if(e.interruptible=this[xe],e._interruptedCause&&e.interruptible)return()=>ot(e._interruptedCause)}}),Og=G_(!0),G3=G_(!1),Z_=e=>{if(e.interruptible=!0,e._stack.push(G3),e._interruptedCause)return ot(e._interruptedCause)},k0=e=>de(t=>t.interruptible?e:Z_(t)??e),jr=e=>de(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Og),e(k0)):e(L)),Q_=e=>de(t=>{if(t.interruptible)return e(L);let n=Z_(t),r=e(Yi);return n??r}),Y_=Be(Cg(he(()=>new AbortController),e=>he(()=>e.abort())),e=>e.signal),Uf=(e,t)=>Ws(e)?t?.mode==="result"?Lr(e,qa,t):Lr(e,L,t):t?.discard?t.mode==="result"?Lr(Object.values(e),qa,t):Lr(Object.values(e),L,t):me(()=>{let n={};return Pn(Lr(Object.entries(e),([r,o])=>Be(t?.mode==="result"?qa(o):o,s=>{W(n,r,s)}),{discard:!0,concurrency:t?.concurrency}),n)}),C0=d(e=>Ws(e[0])&&!ve(e[0]),(e,t,n)=>Be(Lr(e,(r,o)=>qa(t(r,o)),n),r=>ob(r,L))),X_=d(3,(e,t,n)=>{let r=ht(e);return r.length===0?he(t):me(()=>{let o=0,s=t();return Be(ni({while:()=>o<r.length,body:()=>n(s,r[o],o),step(i){s=i,o++}}),()=>s)})}),eM=d(e=>Ws(e[0])&&!ve(e[0]),(e,t,n)=>ne(C0(e,t,{concurrency:n?.concurrency}),([r,o])=>Vn(r)?wt(r):n?.discard?we:J(o))),tM=d(e=>Ws(e[0])&&!ve(e[0]),(e,t)=>me(()=>{let n=e[Symbol.iterator](),r=n.next();return r.done?J(U()):nM(n,0,t,r.value)})),nM=(e,t,n,r)=>ne(n(r,t),o=>{if(o)return J(N(r));let s=e.next();return s.done?J(U()):nM(e,t+1,n,s.value)}),rM=d(e=>Ws(e[0])&&!ve(e[0]),(e,t)=>me(()=>{let n=e[Symbol.iterator](),r=n.next();return r.done?J(U()):oM(n,0,t,r.value)})),oM=(e,t,n,r)=>ne(n(r,t),o=>{if(Kt(o))return J(N(o.success));let s=e.next();return s.done?J(U()):oM(e,t+1,n,s.value)}),ni=To({op:"While",[Sr](e,t){return this[xe].step(e),this[xe].while()?(t._stack.push(this),this[xe].body()):Ir},[nn](e){return this[xe].while()?(e._stack.push(this),this[xe].body()):Ir}}),Lr=d(e=>typeof e[1]=="function",(e,t,n)=>me(()=>{let r=n?.concurrency??1,o=r==="unbounded"?Number.POSITIVE_INFINITY:Math.max(1,r);if(o===1)return Z3(e,t,n);let s=ht(e),i=s.length;if(i===0)return n?.discard?we:J([]);let a=n?.discard?void 0:new Array(i),c=Q3({f:t,out:a},s,{concurrency:o});return c?Pn(c,a):J(a)})),sM=e=>ne(e,t=>{let n=t[Symbol.iterator]().next();return n.done?wt(new ts):J(n.value)}),Z3=(e,t,n)=>me(()=>{let r=n?.discard?void 0:[],o=e[Symbol.iterator](),s=o.next(),i=0;return Pn(ni({while:()=>!s.done,body:()=>t(s.value,i++),step:a=>{r&&r.push(a),s=o.next()}}),r)}),iM=e=>{let t=e.onItem,n=e.step,r=(o,s,i,a)=>{for(;i<a;i++){let c=s[i],u=t(o,c,i);if(!xt(u))return ne($d(u),l=>n(o,c,l,i)??r(o,s,i+1,a)??we);let f=n(o,c,u,i);if(f)return f._tag==="Failure"?f:void 0}};return(o,s,i)=>{let a=0,c=i?.end??s.length,u=i?.concurrency??1;if(u===1)return r(o,s,0,c);let f=i?.orderedStep===!0,l=!1,p,m,h,g=!1,x,b,E=a,y=f?new Array(c):void 0,w=_=>{let R=ao(_);return x=R,l=!0,g=!0,m&&m.size>0?ne(Yi(za(Array.from(m))),()=>R):R},S=(_,R,M)=>{if(!f)return n(o,_,R,M);if(x)return x;for(y[M]=R;E<c;){let q=y[E];if(q===void 0)return;y[E]=void 0;let P=E++,te=n(o,s[P],q,P);if(te)return te}},C=()=>{let _=!1;for(;!x&&a<c;a++){let R=s[a],M=b??t(o,R,a);if(xt(M)){if(x=S(R,M,a),x)break}else if(p){b=void 0;let q=nu(p,M,!0,!0,"inherit");if(q._exit){if(x=S(R,q._exit,a),x)break;continue}m.add(q);let P=a;if(q.addObserver(te=>{m.delete(q);try{if(x){if(!g&&te._tag==="Failure")for(let ee of te.cause.reasons)ee._tag!=="Interrupt"&&(x._tag==="Failure"?x.cause.reasons.push(ee):x=Rn(Di([ee])))}else{let ee=S(R,te,P);ee&&(x=ee._tag==="Failure"?Rn(Di(ee.cause.reasons.slice())):ee,C())}if(_){let ee=C();ee&&h(ee)}else l&&m.size===0&&h(x??we)}catch(ee){h(w(ee))}}),m.size<u)continue;_=!0,a++;return}else return Bt(q=>{p=Ji(),m=new Set,b=M,h=q;let P;try{P=C()}catch(te){return q(w(te))}return P?q(P):me(()=>(x=Ir,g=!0,m?za(m):we))})}if(l=!0,x){if(m&&m.size>0){let R=lg(p);m.forEach(M=>M.interruptUnsafe(p.id,R));return}if(h||x._tag==="Failure")return x}else if(h)if(m)m.size===0&&h(we);else return Ir};return C()}},zd=()=>iM,Q3=iM({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)}}),A0=d(3,(e,t,n)=>ne(e,r=>t(r)?J(r):n(r))),O0=d(3,(e,t,n)=>ne(e,r=>{let o=t(r);return Fe(o)?n(o.failure):J(o.success)})),aM=d(e=>ve(e[0]),(e,t,n)=>O0(e,t,n?r=>wt(n(r)):()=>wt(new ts))),cM=d(e=>Ws(e[0])&&!ve(e[0]),(e,t,n)=>me(()=>{let r=[];return Pn(Lr(e,(o,s)=>{let i=t(o,s);return typeof i=="boolean"?(i&&r.push(o),we):Be(i,a=>{a&&r.push(o)})},{discard:!0,concurrency:n?.concurrency}),r)})),uM=d(e=>Ws(e[0])&&!ve(e[0]),(e,t)=>me(()=>{let n=[];for(let r of e){let o=t(r);Kt(o)&&n.push(o.success)}return J(n)})),fM=d(e=>Ws(e[0])&&!ve(e[0]),(e,t,n)=>me(()=>{let r=[];return Pn(Lr(e,o=>Be(t(o),s=>{Kt(s)&&r.push(s.success)}),{discard:!0,concurrency:n?.concurrency}),r)})),lM=J({}),dM=Eh(Be),pM=bh(Be,ne),mM=Sh(Be);var hM=d(e=>ve(e[0]),(e,t)=>de(n=>(p4(),J(nu(n,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),nu=(e,t,n=!1,r=!1,o=!1)=>{let s=e,i=o==="inherit"?s.interruptible:!o,a=new og(s.context,i);return n?a.evaluate(t):s.currentDispatcher.scheduleTask(()=>a.evaluate(t),0),!r&&!a._exit&&(s.children().add(a),a.addObserver(()=>s._children.delete(a))),a},gM=d(e=>ve(e[0]),(e,t)=>de(n=>J(nu(n,e,t?.startImmediately,!0,t?.uninterruptible)))),xM=e=>de(t=>{let n=t._children&&new Set(t._children);return Gn(e,r=>{let o=t._children;return o===void 0||o.size===0?we:(n&&(o=Nh(o,s=>!n.has(s))),Ld(dg(o)))})}),R0=d(e=>ve(e[0]),(e,t,n)=>de(r=>{let o=nu(r,e,n?.startImmediately,!0,n?.uninterruptible);if(!o._exit)if(t.state._tag!=="Closed"){let s={};Yc(t,s,()=>$R(a=>a===o.id?we:pg(o))),o.addObserver(()=>S0(t,s))}else o.interruptUnsafe(r.id,lg(r));return J(o)})),yM=d(e=>ve(e[0]),(e,t)=>ne(qd,n=>R0(e,n,t))),Xi=e=>(t,n)=>{let r=new og(n?.scheduler?Ve(e,ja,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 o=()=>r.interruptUnsafe();n.signal.addEventListener("abort",o,{once:!0}),r.addObserver(()=>n.signal.removeEventListener("abort",o))}return n?.onFiberStart&&n.onFiberStart(r),r},SM=d(2,(e,t)=>{if(e._exit)return e;if(t.state._tag==="Closed")return e.interruptUnsafe(e.id),e;let n={};return Yc(t,n,()=>pg(e)),e.addObserver(()=>S0(t,n)),e}),EM=Xi(bt()),_0=e=>{let t=Xi(e);return(n,r)=>{let o=t(n,r);return r?.onExit&&o.addObserver(r.onExit),s=>o.interruptUnsafe(s)}},bM=_0(bt()),Rg=e=>{let t=Xi(e);return(n,r)=>{let o=t(n,r);return new Promise(s=>{o.addObserver(i=>s(i))})}},wM=Rg(bt()),M0=e=>{let t=Rg(e);return(n,r)=>t(n,r).then(o=>{if(o._tag==="Failure")throw ug(o.cause);return o.value})},IM=M0(bt()),_g=e=>{let t=Xi(e);return n=>{if(xt(n))return n;let r=new Qs("sync"),o=t(n,{scheduler:r});return o._dispatcher?.flush(),o._exit??ao(new cg(o))}},vM=_g(bt()),P0=e=>{let t=_g(e);return n=>{let r=t(n);if(r._tag==="Failure")throw ug(r.cause);return r.value}},TM=P0(bt()),SR=J(!0),ER=J(!1),Bb=class{waiters=[];scheduled=void 0;_isOpen;constructor(t){this._isOpen=t}scheduleUnsafe(t){if(this.waiters.length===0)return SR;if(this.scheduled===void 0)this.scheduled=this.waiters,t.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let n=0;n<this.waiters.length;n++)this.scheduled.push(this.waiters[n]);return this.waiters=[],SR}flushScheduled=()=>{if(this.scheduled===void 0)return;let t=this.scheduled;this.scheduled=void 0;for(let n=0;n<t.length;n++)t[n](Ir)};flushWaiters(){let t=this.waiters;this.waiters=[],this.flushScheduled();for(let n=0;n<t.length;n++)t[n](Ir)}open=de(t=>this._isOpen?ER:(this._isOpen=!0,this.scheduleUnsafe(t)));release=de(t=>this._isOpen?ER:this.scheduleUnsafe(t));openUnsafe(){return this._isOpen?!1:(this._isOpen=!0,this.flushWaiters(),!0)}await=Bt(t=>this._isOpen?t(we):(this.waiters.push(t),he(()=>{let n=this.waiters.indexOf(t);n!==-1?this.waiters.splice(n,1):this.scheduled!==void 0&&(n=this.scheduled.indexOf(t),n!==-1&&this.scheduled.splice(n,1))})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=he(()=>this.closeUnsafe());whenOpen=t=>ne(this.await,()=>t);isOpen(){return this._isOpen}},Mg=e=>new Bb(e??!1),kM=e=>he(()=>Mg(e)),CM=de(e=>J(e.getRef(Yh))),AM=d(2,(e,t)=>vr(e,Yh,t)),OM=vr(eg),RM=vr(Zc),jb=BigInt(0),Y3={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:jb,endTime:jb,exit:Ir},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},X3=e=>Object.assign(Object.create(Y3),e),_M=e=>e?qe(e.annotations,wf)?e._tag==="Span"?_M(Ao(e.parent)):U():N(e):U(),F0=(e,t,n)=>{let r=!e.getRef(eg)||n?.annotations&&qe(n.annotations,wf),o=n?.parent!==void 0?N(n.parent):n?.root?U():_M(e.currentSpan),s;if(r)s=X3({name:t,parent:o,annotations:Ve(n?.annotations??bt(),wf,!0)});else{let i=e.getRef(Yh),a=e.getRef(lo),c=e.getRef(Zc),u=e.getRef(Pd),f=e.getRef(Fd),l=n?.level??e.getRef(fR),p=n?.links!==void 0?[...f,...n.links]:f.length===0?[]:f.slice();s=i.span({name:t,parent:o,annotations:n?.annotations??bt(),links:p,startTime:c?a.currentTimeNanosUnsafe():BigInt(0),kind:n?.kind??"internal",root:n?.root??ge(o),sampled:n?.sampled??(Te(o)&&o.value.sampled===!1?!1:!HM(e.getRef(lR),l))});for(let m in u)s.attribute(m,u[m]);if(n?.attributes!==void 0)for(let m in n.attributes)s.attribute(m,n.attributes[m])}return s},MM=(e,t)=>de(n=>J(F0(n,e,t))),us=(e,t)=>Yi(de(n=>{let r=Jn(n.context,Ka),o=F0(n,e,t??{}),s=n.getRef(lo),i=n.getRef(Zc);return Pn(fs(r,a=>Pg(o,a,s,i)),o)})),PM=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],n=_o(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return ne(us(t,n),o=>Tf(r,o,n))}return r=>ne(us(t,n),o=>Tf(r,o,n))},e4=(e,t)=>(t=typeof t=="function"?t:es,Zi(If,n=>({name:e,stack:t,parent:n}))),FM=Pd,UM=Fd,DM=d(e=>ve(e[0]),(e,t,n={})=>{let o=(Array.isArray(t)?t:[t]).map(s=>({span:s,attributes:n}));return Zi(e,Fd,s=>[...s,...o])}),Pg=(e,t,n,r)=>he(()=>{e.status._tag!=="Ended"&&e.end(r?n.currentTimeNanosUnsafe():jb,t)}),Ud=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return de(o=>{let s=F0(o,e,n),i=o.getRef(lo),a=o.getRef(Zc);return Gn(je(()=>r(s)),c=>Pg(s,c,i,a))})},$b=vr(Ys),Tf=function(){let e=ve(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=L;return t._tag==="Span"&&(n=_o(n),r=e4(t.name,n?.captureStackTrace)),e?$b(r(arguments[0]),t):o=>$b(r(o),t)},NM=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],n=_o(arguments[2]);if(e){let s=arguments[0];return Ud(t,arguments[2],i=>Tf(s,i,n))}let r=typeof arguments[1]=="function"?arguments[1]:void 0,o=r?void 0:arguments[1];return(s,...i)=>Ud(t,r?r(...i):o,a=>Tf(s,a,n))},LM=d(e=>ve(e[0]),(e,...t)=>Zi(e,Pd,n=>{let r=t.length===1?{...n,...t[0]}:{...n};return t.length===1||W(r,t[0],t[1]),r})),BM=(...e)=>de(t=>{let n=t.currentSpanLocal;if(n)if(e.length===1)for(let[r,o]of Object.entries(e[0]))n.attribute(r,o);else n.attribute(e[0],e[1]);return we}),jM=de(e=>{let t=e.currentSpanLocal;return t?J(t):wt(new ts)}),$M=$3(Ys),lo=Me("effect/Clock",{defaultValue:()=>new qb}),Fb=2**31-1,qb=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=he(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return t4()}currentTimeNanos=he(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return zM()}monotonicTimeNanos=he(()=>this.monotonicTimeNanosUnsafe());sleep(t){return this.sleepMillis(Tn(t))}sleepMillis(t){return t<=0?Cf:Number.isFinite(t)?Bt(n=>{let r=t>Fb?this.sleepMillis(t-Fb):we,o=setTimeout(()=>n(r),Math.min(t,Fb));return he(()=>clearTimeout(o))}):Nd}},qM=BigInt(1e6),zM=(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 n=BigInt(Date.now())*qM;return n>t&&(t=n),t}})(),t4=(function(){let e=BigInt(1e9),t;return()=>{let n=zM(),r=BigInt(Date.now())*qM;if(t===void 0)t=r-n;else{let o=t+n;(r>o?r-o:o-r)>e&&(t=r-n)}return t+n}})(),ds=e=>de(t=>e(t.getRef(lo))),ru=e=>ds(t=>t.sleep(gt(e))),U0=ds(e=>e.currentTimeMillis);var zb="~effect/Cause/TimeoutError";var sg=class extends Li("TimeoutError"){[zb]=zb;constructor(t){super({message:t})}},Hb="~effect/Cause/IllegalArgumentError";var ig=class extends Li("IllegalArgumentError"){[Hb]=Hb;constructor(t){super({message:t})}},Wb="~effect/Cause/ExceededCapacityError";var ag=class extends Li("ExceededCapacityError"){[Wb]=Wb;constructor(t){super({message:t})}},Kb="~effect/Cause/AsyncFiberError";var cg=class extends Li("AsyncFiberError"){[Kb]=Kb;constructor(t){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:t})}},Vb="~effect/Cause/UnknownError";var Dd=class extends Li("UnknownError"){[Vb]=Vb;constructor(t,n){super({message:n,cause:t})}},n4=Me("effect/Console/CurrentConsole",{defaultValue:()=>globalThis.console}),r4=e=>{switch(e){case"All":return Number.MIN_SAFE_INTEGER;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 Number.MAX_SAFE_INTEGER}},o4=JE(co,r4),HM=Bi(o4),D0=Me("effect/Loggers/CurrentLoggers",{defaultValue:()=>new Set([l4,d4])}),s4=Me("effect/Logger/LogToStderr",{defaultValue:Pc}),WM=function(){let e=typeof arguments[0]=="string"?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return Yi(de(t=>{let n=t.getRef(Vi),r={...n};for(let o=0;o<e.length;o++){let[s,i]=e[o];W(r,s,i)}return t.setContext(Ve(t.context,Vi,r)),fs(Jn(t.context,Ka),o=>{let s=t.getRef(Vi),i={...s};for(let a=0;a<e.length;a++){let[c,u]=e[a];s[c]===u&&(Object.hasOwn(n,c)?W(i,c,n[c]):delete i[c])}return t.setContext(Ve(t.context,Vi,i)),we})}))},i4="~effect/Logger",a4={[i4]:{_Message:L,_Output:L},pipe(){return ie(this,arguments)}},KM=e=>{let t=Object.create(a4);return t.log=e,t},c4=e=>e.replace(/[\s="]/g,"_"),u4=(e,t)=>`${c4(e[0])}=${t-e[1]}ms`;var ps=e=>(...t)=>{let n;for(let r=0,o=t.length;r<o;r++){let s=t[r];lf(s)&&(n?t.splice(r,1):t=t.slice(0,r).concat(t.slice(r+1)),n=n?Di(n.reasons.concat(s.reasons)):s,r--)}return n===void 0&&(n=Ch),de(r=>{let o=e??r.currentLogLevel;if(HM(r.minimumLogLevel,o))return we;let s=r.getRef(lo),i=r.getRef(D0);if(i.size>0){let a=new Date(s.currentTimeMillisUnsafe());for(let c of i)c.log({cause:n,fiber:r,date:a,logLevel:o,message:t})}return we})};var Qc={bold:"1",red:"31",green:"32",yellow:"33",blue:"34",cyan:"36",white:"37",gray:"90",black:"30",bgBrightRed:"101"},Sse={None:[],All:[],Trace:[Qc.gray],Debug:[Qc.blue],Info:[Qc.green],Warn:[Qc.yellow],Error:[Qc.red],Fatal:[Qc.bgBrightRed,Qc.black]};var f4=e=>`${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}.${e.getMilliseconds().toString().padStart(3,"0")}`;var l4=KM(({cause:e,date:t,fiber:n,logLevel:r,message:o})=>{let s=Array.isArray(o)?o.slice():[o];e.reasons.length>0&&s.push(fg(e));let i=t.getTime(),a=n.getRef(tg),c="";for(let p of a)c+=` ${u4(p,i)}`;let u=n.getRef(Vi);Object.keys(u).length>0&&s.push(u);let f=n.getRef(n4);(n.getRef(s4)?f.error:f.log)(`[${f4(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...s)}),d4=KM(({cause:e,fiber:t,logLevel:n,message:r})=>{let o=t.getRef(lo),s=t.getRef(Vi),i=t.currentSpan;if(i===void 0||i._tag==="ExternalSpan")return;let a={};for(let[c,u]of Object.entries(s))W(a,c,u);a["effect.fiberId"]=t.id,a["effect.logLevel"]=n.toUpperCase(),e.reasons.length>0&&(a["effect.cause"]=fg(e)),i.event(MA(Array.isArray(r)&&r.length===1?r[0]:r),o.currentTimeNanosUnsafe(),a)});function p4(){Db.interruptChildren??=L3}var Fg=J(void 0);var VM=d(e=>ve(e[0]),(e,t)=>w0(e,n=>de(r=>(m4(r,n,t?.defectsOnly),we)))),m4=(e,t,n)=>{let r=e.getRef(pR);if(r.size===0||n&&!vR(t))return;let o={cause:t,fiber:e,timestamp:e.getRef(lo).currentTimeNanosUnsafe()};r.forEach(s=>s.report(o))};var Df=lf,Nf=DA,Ug=Pa;var Va=Di,JM=Ch,GM=df,ZM=qE,QM=Ha,Lf=e=>new $c(e),Bf=e=>new gd(e),ou=bR,N0=kR,Ja=CR;var su=ug,YM=wR;var jf=ei;var L0=Gb;var XM=TR;var eP=fg;var $f=ts,Hd=wd;var tP=zc,pe=BA;var Dg=ig;var nP=ag;var Se={};Hs(Se,{Do:()=>D8,Transaction:()=>Zf,TypeId:()=>A8,abortSignal:()=>D6,acquireDisposable:()=>O6,acquireRelease:()=>Xa,acquireUseRelease:()=>gF,addFinalizer:()=>xF,all:()=>O8,andThen:()=>Dn,annotateCurrentSpan:()=>W6,annotateLogs:()=>fx,annotateLogsScoped:()=>hK,annotateSpans:()=>H6,as:()=>zt,asSome:()=>sx,asVoid:()=>Lo,awaitAllChildren:()=>tK,bind:()=>B8,bindTo:()=>N8,cached:()=>cx,cachedInvalidateWithTTL:()=>U6,cachedWithTTL:()=>F6,callback:()=>Es,catch:()=>mu,catchCause:()=>ft,catchCauseFilter:()=>t6,catchCauseIf:()=>e6,catchDefect:()=>Sw,catchEager:()=>lx,catchFilter:()=>Y8,catchIf:()=>Q8,catchNoSuchElement:()=>X8,catchReason:()=>J8,catchReasons:()=>G8,catchTag:()=>fF,catchTags:()=>lF,clockWith:()=>xu,context:()=>ar,contextWith:()=>cr,currentParentSpan:()=>V6,currentSpan:()=>K6,delay:()=>ta,die:()=>po,effectify:()=>CK,ensuring:()=>na,eventually:()=>i6,exit:()=>Wr,fail:()=>G,failCause:()=>ct,failCauseSync:()=>ea,failSync:()=>ox,fiber:()=>nK,fiberId:()=>rK,filter:()=>Tw,filterMap:()=>x6,filterMapEffect:()=>kw,filterMapOrElse:()=>y6,filterMapOrFail:()=>S6,filterOrElse:()=>pF,filterOrFail:()=>mF,findFirst:()=>P8,findFirstFilter:()=>F8,firstSuccessOf:()=>l6,flatMap:()=>A,flatMapEager:()=>Bn,flatten:()=>xw,flip:()=>K8,fn:()=>aK,fnUntraced:()=>ye,fnUntracedEager:()=>dx,forEach:()=>Do,forever:()=>Ht,forkChild:()=>el,forkDetach:()=>tl,forkIn:()=>Ut,forkScoped:()=>bs,fromNullishOr:()=>z8,fromOption:()=>$8,fromResult:()=>gw,gen:()=>qt,head:()=>U8,ignore:()=>bw,ignoreCause:()=>ww,interrupt:()=>ho,interruptible:()=>ra,interruptibleMask:()=>Mw,isEffect:()=>Cr,isFailure:()=>v6,isSuccess:()=>T6,let:()=>L8,linkSpans:()=>Z6,log:()=>cK,logDebug:()=>dK,logError:()=>fp,logFatal:()=>uK,logInfo:()=>lK,logTrace:()=>pK,logWarning:()=>fK,logWithLevel:()=>nl,makeSpan:()=>Fw,makeSpanScoped:()=>Uw,map:()=>Y,mapBoth:()=>n6,mapBothEager:()=>fn,mapEager:()=>oa,mapError:()=>Yf,mapErrorEager:()=>yu,match:()=>Cw,matchCause:()=>b6,matchCauseEager:()=>w6,matchCauseEffect:()=>Kr,matchCauseEffectEager:()=>I6,matchEager:()=>E6,matchEffect:()=>hF,never:()=>Hr,onError:()=>mo,onErrorFilter:()=>_6,onErrorIf:()=>R6,onExit:()=>ur,onExitFilter:()=>P6,onExitIf:()=>M6,onExitPrimitive:()=>_w,onInterrupt:()=>ui,option:()=>W8,orDie:()=>ci,orElseSucceed:()=>f6,partition:()=>R8,promise:()=>nx,provide:()=>Aw,provideContext:()=>Nn,provideService:()=>Bo,provideServiceEffect:()=>A6,race:()=>g6,raceAll:()=>vw,raceAllFirst:()=>h6,raceFirst:()=>Ya,reduce:()=>_8,repeat:()=>yF,repeatOrElse:()=>N6,replicate:()=>L6,replicateEffect:()=>Pw,request:()=>X6,requestUnsafe:()=>eK,result:()=>H8,retry:()=>ix,retryOrElse:()=>Ew,runCallback:()=>oK,runCallbackWith:()=>Dw,runFork:()=>up,runForkWith:()=>Ln,runPromise:()=>Nw,runPromiseExit:()=>ux,runPromiseExitWith:()=>sK,runPromiseWith:()=>Lw,runSync:()=>li,runSyncExit:()=>ec,runSyncExitWith:()=>iK,runSyncWith:()=>Bw,sandbox:()=>a6,satisfiesErrorType:()=>OK,satisfiesServicesType:()=>RK,satisfiesSuccessType:()=>AK,schedule:()=>B6,scheduleFrom:()=>SF,scope:()=>jo,scoped:()=>gu,scopedWith:()=>ap,service:()=>Ow,serviceOption:()=>hu,setContext:()=>k6,sleep:()=>Qa,spanAnnotations:()=>J6,spanLinks:()=>G6,succeed:()=>v,succeedNone:()=>Ss,succeedSome:()=>rx,suspend:()=>K,sync:()=>se,tap:()=>Mt,tapCause:()=>sp,tapCauseFilter:()=>s6,tapCauseIf:()=>o6,tapDefect:()=>dF,tapError:()=>op,tapErrorTag:()=>r6,timed:()=>m6,timeout:()=>Iw,timeoutOption:()=>d6,timeoutOrElse:()=>p6,tracer:()=>j6,track:()=>xK,trackDefects:()=>EK,trackDuration:()=>bK,trackErrors:()=>SK,trackSuccesses:()=>yK,transposeOption:()=>q8,try:()=>No,tryPromise:()=>ys,tx:()=>wK,txRetry:()=>kK,undefined:()=>Qf,uninterruptible:()=>fi,uninterruptibleMask:()=>go,unwrapReason:()=>Z8,updateContext:()=>ip,updateService:()=>Rw,updateServiceScoped:()=>C6,useSpan:()=>cp,validate:()=>M8,void:()=>H,when:()=>ax,whileLoop:()=>Qn,withErrorReporting:()=>u6,withExecutionPlan:()=>c6,withFiber:()=>xn,withLogSpan:()=>gK,withLogger:()=>mK,withParentSpan:()=>Xf,withSpan:()=>Q6,withSpanScoped:()=>Y6,withTracer:()=>$6,withTracerEnabled:()=>q6,withTracerTiming:()=>z6,yieldNow:()=>rp,yieldNowWith:()=>j8,zip:()=>yw,zipWith:()=>V8});var ms=$E,kn=rt,jt=Rn,Mo=io,Ng=ao,Lg=gg,Vt=Ir;var Ft=Of,ri=r_;var rP=u_;var zr={};Hs(zr,{CurrentMemoMap:()=>cu,build:()=>mP,buildWithMemoMap:()=>si,buildWithScope:()=>Wd,catch:()=>M4,catchCause:()=>F4,catchTag:()=>P4,effect:()=>qr,effectContext:()=>zf,effectDiscard:()=>k4,empty:()=>T4,flatMap:()=>xP,forkMemoMap:()=>v4,forkMemoMapUnsafe:()=>H0,fresh:()=>U4,fromBuild:()=>Ga,fromBuildMemo:()=>zg,isLayer:()=>qg,launch:()=>D4,makeMemoMap:()=>I4,makeMemoMapUnsafe:()=>oi,merge:()=>A4,mergeAll:()=>Hg,mock:()=>N4,orDie:()=>Wg,parentSpan:()=>SP,provide:()=>gs,provideMerge:()=>Kd,satisfiesErrorType:()=>j4,satisfiesServicesType:()=>$4,satisfiesSuccessType:()=>B4,span:()=>q4,succeed:()=>ii,succeedContext:()=>uu,suspend:()=>C4,sync:()=>W0,syncContext:()=>$0,tap:()=>O4,tapCause:()=>_4,tapError:()=>R4,unwrap:()=>q0,updateService:()=>yP,withParentSpan:()=>z0,withSpan:()=>z4});var h4="~effect/Deferred";var g4={[h4]:{_A:L,_E:L},pipe(){return ie(this,arguments)}},iu=()=>{let e=Object.create(g4);return e.resumes=void 0,e.effect=void 0,e};var au=e=>Bt(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),he(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)})));var x4=d(2,(e,t)=>he(()=>qf(e,t))),B0=x4;var y4=d(2,(e,t)=>B0(e,Rn(t)));var j0=d(2,(e,t)=>y4(e,Ha(t)));var qf=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let r=0;r<n.length;r++)n[r](t)}return!0};var oP=Vi;var sP=tg,iP=If;var aP=Zc,cP=mR;var It=Ka;var $r=tu,Po=z_,Fo=fs,_t=$_;var Cn=j_,Je=y0;var pP="~effect/Layer",uP="~effect/Layer/MemoMap",E4=(e,t)=>(e.observers++,Br(fs(t,n=>e.finalizer(n)),e.effect)),qg=e=>B(e,pP),b4={[pP]:{_ROut:L,_E:L,_RIn:L},pipe(){return ie(this,arguments)}},fu=e=>{let t=Object.create(b4);return t.build=e,t},Ga=e=>fu((t,n)=>{let r=Cn(n);return Gn(e(t,r),o=>o._tag==="Failure"?Je(r,o):we)}),zg=e=>{let t=Ga((n,r)=>n.getOrElseMemoize(t,r,e));return t},w4=(e,t,n,r)=>{let o=$r(),s=iu(),i={observers:1,effect:au(s),finalizer:a=>me(()=>(i.observers--,i.observers===0?(e.map.delete(t),Je(o,a)):we))};return e.map.set(t,i),fs(n,i.finalizer).pipe(ne(()=>r(e,o)),Gn(a=>(i.effect=a,B0(s,a))))},$g=class{get[uP](){return uP}parent;constructor(t){this.parent=t}map=new Map;get(t,n){let r=this.map.get(t);return r?E4(r,n):this.parent?.get(t,n)}getOrElseMemoize(t,n,r){return me(()=>{let o=this.get(t,n);return o||w4(this,t,n,r)})}},oi=()=>new $g,H0=e=>new $g(e),I4=he(oi),v4=e=>he(()=>H0(e)),cu=class e extends Ke()("effect/Layer/CurrentMemoMap"){static forkOrCreate(t){let n=$i(t,e);return n?H0(n):oi()}},si=d(3,(e,t,n)=>vr(Be(e.build(t,n),Ve(cu,t)),cu,t)),mP=e=>de(t=>si(e,cu.forkOrCreate(t.context),Jn(t.context,It))),Wd=d(2,(e,t)=>de(n=>si(e,cu.forkOrCreate(n.context),t))),ii=function(){return arguments.length===1?e=>uu(ss(arguments[0],e)):uu(ss(arguments[0],arguments[1]))},uu=e=>fu(Qe(J(e))),T4=uu(bt()),W0=function(){return arguments.length===1?e=>$0(()=>ss(arguments[0],e())):$0(()=>ss(arguments[0],arguments[1]()))},$0=e=>zg(Qe(he(e))),qr=function(){return arguments.length===1?e=>fP(arguments[0],e):fP(arguments[0],arguments[1])},fP=(e,t)=>zf(Be(t,n=>ss(e,n))),zf=e=>zg((t,n)=>Po(e,n)),k4=e=>zf(Pn(e,bt())),C4=e=>zg((t,n)=>me(()=>e().build(t,n))),q0=e=>{let t=Ke("effect/Layer/unwrap");return xP(qr(t)(e),qe(t))},hP=(e,t,n)=>{let r=Cn(n,"parallel");return Lr(e,o=>o.build(t,Cn(r,"sequential")),{concurrency:e.length}).pipe(Be(o=>LO(...o)))},Hg=(...e)=>Ga((t,n)=>hP(e,t,n)),A4=d(2,(e,t)=>Hg(e,...Array.isArray(t)?t:[t])),gP=(e,t,n)=>Ga((r,o)=>ne(Array.isArray(t)?hP(t,r,o):t.build(r,o),s=>e.build(r,o).pipe(Qi(s),Be(i=>n(i,s))))),gs=d(2,(e,t)=>gP(e,t,L)),Kd=d(2,(e,t)=>gP(e,t,(n,r)=>Er(r,n))),xP=d(2,(e,t)=>Ga((n,r)=>ne(e.build(n,r),o=>t(o).build(n,r)))),O4=d(2,(e,t)=>Ga((n,r)=>ne(e.build(n,r),o=>Po(Pn(t(o),o),r)))),R4=d(2,(e,t)=>Ga((n,r)=>kr(e.build(n,r),o=>Po(Br(t(o),wt(o)),r)))),_4=d(2,(e,t)=>Ga((n,r)=>Tr(e.build(n,r),o=>Po(Br(t(o),ot(o)),r)))),Wg=e=>fu((t,n)=>wg(e.build(t,n))),M4=d(2,(e,t)=>fu((n,r)=>kr(e.build(n,r),o=>t(o).build(n,r))));var P4=d(3,(e,t,n)=>fu((r,o)=>bg(e.build(r,o),t,s=>n(s).build(r,o)))),F4=d(2,(e,t)=>fu((n,r)=>Tr(e.build(n,r),o=>t(o).build(n,r)))),yP=d(3,(e,t,n)=>gs(e,qr(t,Be(t,n)))),U4=e=>fu((t,n)=>e.build(oi(),n)),D4=e=>Tg(Br(mP(e),Nd)),N4=function(){return arguments.length===1?e=>lP(arguments[0],e):lP(arguments[0],arguments[1])},lP=(e,t)=>ii(e)(new Proxy({...t},{get(n,r,o){if(r in n)return n[r];let s=Xs();ir(2);let i=new Error(`${e.key}: Unimplemented method "${r.toString()}"`);return ir(s),i.name="UnimplementedError",L4(i)},has:Xt})),L4=e=>{let t=Object.assign(Gi(e),{[dP]:dP,channel:{[jg]:jg,transform:()=>J(t),pipe(){return ie(this,arguments)}},[jg]:jg,transform:()=>J(t)});function n(){return t}return Object.assign(n,t),Object.setPrototypeOf(n,Object.getPrototypeOf(t)),n},dP="~effect/Stream",jg="~effect/Channel",B4=()=>e=>e,j4=()=>e=>e,$4=()=>e=>e,q4=(e,t)=>(t=_o(t),qr(Ys,t?.onEnd?ti(us(e,t),n=>Pf(r=>t.onEnd(n,r))):us(e,t))),SP=e=>uu(Ys.context(e)),z4=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],n=_o(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return q0(Be(n?.onEnd!==void 0?ti(us(t,n),o=>Pf(s=>n.onEnd(o,s))):us(t,n),o=>z0(r,o)))}return r=>q0(Be(n?.onEnd!==void 0?ti(us(t,n),o=>Pf(s=>n.onEnd(o,s))):us(t,n),o=>z0(r,o)))},z0=function(){let e=qg(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=L;t._tag==="Span"&&(n=_o(n),r=H4(t.name,n?.captureStackTrace));let o=SP(t);return e?gs(r(arguments[0]),o):s=>gs(r(s),o)},H4=(e,t)=>(t=typeof t=="function"?t:es,yP(iP,n=>({name:e,stack:t,parent:n})));var EP="~effect/ExecutionPlan";var W4={[EP]:EP,get captureRequirements(){let e=this;return Wa(t=>J(K4(e.steps.map(n=>({...n,provide:qg(n.provide)?gs(n.provide,uu(t)):n.provide})))))},pipe(){return ie(this,arguments)}},K4=e=>{let t=Object.create(W4);return t.steps=e,t};var Kg=Me("effect/ExecutionPlan/CurrentMetadata",{defaultValue:Qe({attempt:0,stepIndex:0})});var lu=lo;var Vg="~effect/time/DateTime",Jg="~effect/time/DateTime/TimeZone",wP={[Vg]:Vg,pipe(){return ie(this,arguments)},[at](){return this.toString()},toJSON(){return Zd(this).toJSON()}},J4={...wP,_tag:"Utc",[Re](){return Dr(this.epochMilliseconds)},[_e](e){return Hf(e)&&e._tag==="Utc"&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Zd(this).toJSON()})`}},G4={...wP,_tag:"Zoned",[Re](){return Nt(Dr(this.epochMilliseconds))(ce(this.zone))},[_e](e){return Hf(e)&&e._tag==="Zoned"&&this.epochMilliseconds===e.epochMilliseconds&&ae(this.zone,e.zone)},toString(){return`DateTime.Zoned(${ow(this)})`}},IP={[Jg]:Jg,[at](){return this.toString()}},Z4={...IP,_tag:"Named",[Re](){return it(`Named:${this.id}`)},[_e](e){return pu(e)&&e._tag==="Named"&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},Q4={...IP,_tag:"Offset",[Re](){return it(`Offset:${this.offset}`)},[_e](e){return pu(e)&&e._tag==="Offset"&&this.offset===e.offset},toString(){return`TimeZone.Offset(${tw(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},ai=(e,t,n)=>{let r=Object.create(G4);return r.epochMilliseconds=e,r.zone=t,Object.defineProperty(r,"partsUtc",{value:n,enumerable:!1,writable:!0}),Object.defineProperty(r,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(r,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),r},Hf=e=>B(e,Vg);var pu=e=>B(e,Jg),vP=e=>pu(e)&&e._tag==="Offset",TP=e=>pu(e)&&e._tag==="Named",kP=e=>e._tag==="Utc",G0=e=>e._tag==="Zoned",CP=un((e,t)=>e.epochMilliseconds===t.epochMilliseconds),AP=ns((e,t)=>e.epochMilliseconds<t.epochMilliseconds?-1:e.epochMilliseconds>t.epochMilliseconds?1:0);var OP=e=>{let t=Object.create(J4);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},du=e=>{let t=e.getTime();if(Number.isNaN(t))throw new Dg("Invalid date");return OP(t)},Gg=e=>{if(Hf(e))return e;if(e instanceof Date)return du(e);if(typeof e=="object"){if("epochMilliseconds"in e)return du(new Date(e.epochMilliseconds));let t=new Date(0);return s8(t,e),du(t)}else if(typeof e=="string"&&!Y4(e))return du(new Date(e+"Z"));return du(new Date(e))},Y4=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),X4=-864e13+720*60*1e3,e8=864e13-840*60*1e3,Z0=(e,t)=>{let n=t?.timeZone;if(n===void 0&&Hf(e)&&G0(e))return e;let r=Gg(e);if(r.epochMilliseconds<X4||r.epochMilliseconds>e8)throw new RangeError(`Epoch millis out of range: ${r.epochMilliseconds}`);n===void 0&&typeof e=="object"&&"timeZoneId"in e&&(n=e.timeZoneId);let o;if(n===void 0){let s=new Date(r.epochMilliseconds).getTimezoneOffset()*-60*1e3;o=Gd(s)}else if(pu(n))o=n;else if(typeof n=="number")o=Gd(n);else{let s=X0(n);if(ge(s))throw new Dg(`Invalid time zone: ${n}`);o=s.value}return t?.adjustForTimeZone!==!0?ai(r.epochMilliseconds,o,r.partsUtc):i8(r.epochMilliseconds,o,t?.disambiguation??"compatible")},V0=Da(Z0),RP=Da(Gg),t8=/^(.{17,35})\[(.+)\]$/,_P=e=>{let t=t8.exec(e);if(t===null){let o=rw(e);return o!==null?V0(e,{timeZone:o}):U()}let[,n,r]=t;return V0(n,{timeZone:r})};var MP=e=>OP(e.epochMilliseconds);var Jd=new Map,n8={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},r8=e=>{let t=e.resolvedOptions().timeZone;if(Jd.has(t))return Jd.get(t);let n=Object.create(Z4);return n.id=t,n.format=e,Jd.set(t,n),n},Q0=e=>{if(Jd.has(e))return Jd.get(e);try{return r8(new Intl.DateTimeFormat("en-US",{...n8,timeZone:e}))}catch{throw new Dg(`Invalid time zone: ${e}`)}},Gd=e=>{let t=Object.create(Q4);return t.offset=e,t},Y0=Da(Q0);var o8=/^(?:GMT|[+-])/,X0=e=>{if(o8.test(e)){let t=rw(e);return t===null?U():N(Gd(t))}return Y0(e)},PP=e=>e._tag==="Offset"?tw(e.offset):e.id;var Zd=e=>new Date(e.epochMilliseconds),Zg=e=>{if(e._tag==="Utc")return new Date(e.epochMilliseconds);if(e.zone._tag==="Offset")return new Date(e.epochMilliseconds+e.zone.offset);if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=e.zone.format.formatToParts(e.epochMilliseconds).filter(r=>r.type!=="literal"),n=new Date(0);return n.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),n.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),Number(t[6].value)),e.adjustedEpochMilliseconds=n.getTime(),n},ew=e=>Zg(e).getTime()-nw(e),tw=e=>{let t=Math.abs(e),n=Math.floor(t/(3600*1e3)),r=Math.round(t%(3600*1e3)/(60*1e3));return r===60&&(n+=1,r=0),`${e<0?"-":"+"}${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`},FP=e=>tw(ew(e)),nw=e=>e.epochMilliseconds;var s8=(e,t)=>{if(t.year!==void 0&&e.setUTCFullYear(t.year),t.month!==void 0&&e.setUTCMonth(t.month-1),t.day!==void 0&&e.setUTCDate(t.day),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond)};var bP=1440*60*1e3,i8=(e,t,n)=>{if(t._tag==="Offset")return ai(e-t.offset,t);let r=Vd(e-bP,e,t),o=Vd(e+bP,e,t);if(r===o)return ai(e-r,t);let s=r<o,i=r-o;if(s){if(Vd(e-o,e,t)===o)return ai(e-o,t);let u=ai(e-r,t),f=Zg(u).getTime();if(e!==f)switch(n){case"reject":{let l=new Date(e).toISOString();throw new RangeError(`Gap time: ${l} does not exist in time zone ${t.id}`)}case"earlier":return ai(e-o,t);case"compatible":case"later":return u}return u}if(Vd(e-r,e,t)===r){if(n==="earlier"||n==="compatible"||Vd(e-r+i,e+i,t)===r)return ai(e-r,t);if(n==="reject"){let u=new Date(e).toISOString();throw new RangeError(`Ambiguous time: ${u} occurs twice in time zone ${t.id}`)}}return ai(e-o,t)},a8=/([+-])(\d{2}):(\d{2})$/,rw=e=>{let t=a8.exec(e);if(t===null)return null;let[,n,r,o]=t;return(n==="+"?1:-1)*(Number(r)*60+Number(o))*60*1e3},Vd=(e,t,n)=>{let r=n.format.formatToParts(e).find(s=>s.type==="timeZoneName")?.value??"";if(r==="GMT")return 0;let o=rw(r);return o===null?ew(ai(t,n)):o};var UP=e=>Zd(e).toISOString();var J0=e=>{let t=Zg(e);return e._tag==="Utc"?t.toISOString():`${t.toISOString().slice(0,-1)}${FP(e)}`},ow=e=>e.zone._tag==="Offset"?J0(e):`${J0(e)}[${e.zone.id}]`;var sie=globalThis.Number;var NP=d(2,(e,t)=>{let n=e.toString(),r=t.toString();if(n.includes("e")||r.includes("e"))return!globalThis.Number.isFinite(e)||!globalThis.Number.isFinite(t)||t===0?NaN:u8(e,t);let o=(n.split(".")[1]||"").length,s=(r.split(".")[1]||"").length,i=o>s?o:s,a=parseInt(e.toFixed(i).replace(".","")),c=parseInt(t.toFixed(i).replace(".",""));return a%c/Math.pow(10,i)});function u8(e,t){let[n,r]=DP(e),[o,s]=DP(t),i=Math.min(r,s),a=n*BigInt(10)**BigInt(r-i),c=o*BigInt(10)**BigInt(s-i),u=a%c;if(u===BigInt(0))return e<0||Object.is(e,-0)?-0:0;let f=globalThis.Number(`${u}e${i}`);return f===0?Math.sign(e)*globalThis.Number.MIN_VALUE:f}function DP(e){let t=Math.abs(e).toExponential(),n=t.indexOf("e"),r=t.slice(0,n).replace(".","");return[BigInt(r)*(e<0?-BigInt(1):BigInt(1)),globalThis.Number(t.slice(n+1))-r.length+1]}var LP=e=>{let t=Math.ceil(Math.log(e)/Math.log(2));return Math.max(Math.pow(2,t),2)};var BP=wo((e,t)=>Math.max(e,t),-1/0),jP=wo((e,t)=>Math.min(e,t),1/0);var aie=globalThis.String,Qg=oo;var qP=e=>e.trim();var $t=d(2,(e,t)=>_f(e,f8,n=>t(n))),Uo=e=>e.reasons.some(iw),iw=e=>e._tag==="Fail"&&Hd(e.error),Wf=e=>{let t,n=!1;for(let r of e.reasons)iw(r)?t??=r.error:r._tag!=="Interrupt"&&(n=!0);return t===void 0?Ae(e):n?Ae(Va(e.reasons.filter(r=>!iw(r)))):Ce(t)};var f8=e=>{let t=Wf(e);return Fe(t)?t:Ce(t.success.value)},aw=e=>{let t=Wf(e);return Fe(t)?jt(t.failure):kn(t.success.value)},Qd=d(2,(e,t)=>cs(e,{onSuccess:t.onSuccess,onFailure:n=>{let r=Wf(n);return Fe(r)?t.onFailure(r.failure):t.onDone(r.success.value)}}));var zP="~effect/Schedule";var Un=Me("effect/Schedule/CurrentMetadata",{defaultValue:Qe({input:void 0,output:void 0,duration:zi,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),l8={[zP]:{_Out:L,_In:L,_Env:L},pipe(){return ie(this,arguments)}},cw=e=>B(e,zP),Yg=e=>{let t=Object.create(l8);return t.step=e,t},uw=()=>{let e=0,t,n;return(r,o)=>{n===void 0&&(n=r);let s=r-n,i=t===void 0?0:r-t;return t=r,{input:o,attempt:++e,start:n,now:r,elapsed:s,elapsedSincePrevious:i}}},HP=e=>Yg(Be(e,t=>{let n=uw();return(r,o)=>t(n(r,o))})),Xg=e=>Tr(e.step,t=>J(()=>ot(t))),xs=e=>ds(t=>Be(Xg(e),n=>{let r=uw();return o=>me(()=>{let s=t.currentTimeMillisUnsafe();return ne(n(s,o),([i,a])=>{let c=r(s,o);return c.output=i,c.duration=a,Pn(ru(a),c)})})})),Kf=e=>Be(xs(e),t=>n=>Be(t(n),r=>r.output));var WP=e=>Yg(Be(Uf(e.map(Xg)),t=>(n,r)=>ne(Lr(t,o=>Qd(o(n,r),{onSuccess:s=>J(s[1]),onDone:()=>Fg,onFailure:ot})),o=>{let s=d8(o);return s===void 0?pe(zi):J([s,s])}))),d8=e=>{let t;for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(t=t===void 0?r:KO(t,r))}return t},KP=(e,t=2)=>{let n=Tn(gt(e));return HP(J(r=>{let o=is(n*Math.pow(t,r.attempt-1));return J([o,o])}))};var fw=e=>Yg(Be(Xg(e),t=>(n,r)=>Qd(t(n,r),{onSuccess:o=>J([r,o[1]]),onFailure:ot,onDone:()=>pe(r)}))),VP=e=>Yd(Xd,({attempt:t})=>J(t<=e)),Vf=e=>{let t=gt(e);return HP(J(n=>J([n.attempt-1,t])))};var Yd=d(2,(e,t)=>Yg(Be(Xg(e),n=>{let r=uw();return(o,s)=>ne(n(o,s),i=>{let[a,c]=i,u=t({...r(o,s),output:a,duration:c});return ne(ve(u)?u:J(u),f=>f?J(i):pe(a))})})));var Xd=Vf(zi);var p8=(e,t,n)=>kg(r=>ne(n?.local?si(t,oi(),r):Wd(t,r),o=>Qi(e,o))),ex=d(e=>ve(e[0]),(e,t,n)=>_d(t)?Qi(e,t):p8(e,Array.isArray(t)?Hg(...t):t,n));var lw=d(3,(e,t,n)=>ne(xs(t),r=>{let o=Un.defaultValue();return kr(yg(ti(ne(me(()=>vr(e,Un,o)),r),s=>he(()=>{o=s})),{disableYield:!0}),s=>wd(s)?J(s.value):n(s,o.attempt===0?U():N(o)))})),dw=d(3,(e,t,n)=>ne(xs(t),r=>{let o=Un.defaultValue(),s,i=kr(me(()=>vr(e,Un,o)),a=>(s=a,ne(r(a),c=>(o=c,i))));return $t(i,a=>je(()=>n(s,a)))})),GP=d(2,(e,t)=>{let n=typeof t=="function"?t(L):cw(t)?t:tp(t);return lw(e,n,wt)}),ep=d(2,(e,t)=>{let n=typeof t=="function"?t(L):cw(t)?t:tp(t);return dw(e,n,wt)}),ZP=d(3,(e,t,n)=>ne(xs(n),r=>{let o=Un.defaultValue(),s=me(()=>vr(e,Un,o));return kr(ne(r(t),i=>{o=i;let a=Qe(ne(s,r));return ni({while:Xt,body:a,step(c){o=c}})}),i=>wd(i)?J(i.value):wt(i))})),m8=fw(Xd),tp=e=>{let t=e.schedule?fw(e.schedule):m8;return e.while&&(t=Yd(t,({input:n})=>{let r=e.while(n);return ve(r)?r:J(r)})),e.until&&(t=Yd(t,({input:n})=>{let r=e.until(n);return ve(r)?Be(r,o=>!o):J(!r)})),e.times!==void 0&&(t=Yd(t,({attempt:n})=>J(n<=e.times))),t};var pw=(e,t)=>{let n=-1,r=0,o=s=>Ig(e(s));return{begin:ds(s=>me(()=>{let i=t();i.stepIndex!==n&&(n=i.stepIndex,r=0),r++;let a={attempt:i.attempt,stepAttempt:r,stepIndex:i.stepIndex,startNanos:s.monotonicTimeNanosUnsafe()};return Pn(o({_tag:"AttemptStart",attempt:a.attempt,stepAttempt:a.stepAttempt,stepIndex:a.stepIndex}),a)})),end:(s,i)=>ds(a=>{let c=Nr(a.monotonicTimeNanosUnsafe()-s.startNanos);return o(i._tag==="Success"?{_tag:"AttemptSuccess",attempt:s.attempt,stepAttempt:s.stepAttempt,stepIndex:s.stepIndex,duration:c}:{_tag:"AttemptFailure",attempt:s.attempt,stepAttempt:s.stepAttempt,stepIndex:s.stepIndex,duration:c,cause:i.cause})})}},YP=d(e=>ve(e[0]),(e,t,n)=>me(()=>{let r=0,o={attempt:0,stepIndex:0},s=xg(Kg,he(()=>(o={attempt:o.attempt+1,stepIndex:r},o))),i=n?.onEvent===void 0?void 0:pw(n.onEvent,()=>o),a=i===void 0?L:u=>jr(f=>ne(i.begin,l=>Gn(f(u),p=>i.end(l,p)))),c;return ne(ni({while:()=>r<t.steps.length&&(c===void 0||Fe(c)),body(){let u=t.steps[r],f=s(a(ex(e,u.provide)));if(c){let l=!1,p=f;f=me(()=>l?p:(l=!0,kf(c))),f=ep(f,np(u,!1))}else{let l=np(u,!0);f=l?ep(f,l):f}return qa(f)},step(u){c=u,r++}}),()=>kf(c))})),np=(e,t)=>{if(t){if(e.attempts===1||!(e.schedule||e.attempts))return}else return tp({schedule:e.schedule?e.schedule:e.attempts?void 0:h8,times:e.attempts,while:e.while});return tp({schedule:e.schedule,while:e.while,times:e.attempts?e.attempts-1:void 0})},h8=VP(1);var g8="~effect/Request",x8=DE({_E:e=>e,_A:e=>e,_R:e=>e}),wie={...UA,[g8]:x8};var eF=e=>e;var nF=d(2,(e,t)=>{let n=r=>Bt(o=>{let s=oF(r,e,o,Ji());return S8(r,s)});return ve(t)?ne(t,n):n(t)}),rF=(e,t)=>{let n=oF(t.resolver,e,t.onExit,{context:t.context,currentScheduler:qe(t.context,ja)});return()=>sF(t.resolver,n)},tx=[],mw=new WeakMap,oF=(e,t,n,r)=>{let o=mw.get(e);o||(o=new Map,mw.set(e,o));let s,i=!1,a=eF({request:t,context:r.context,uninterruptible:!1,completeUnsafe(u){i||(i=!0,n(u),s?.entrySet.delete(a))}});if(e.preCheck!==void 0&&!e.preCheck(a))return a;let c=e.batchKey(a);if(s=o.get(c),!s){if(tx.length>0)s=tx.pop(),s.key=c,s.resolver=e,s.map=o;else{let u={key:c,resolver:e,map:o,entrySet:new Set,entries:new Set,delayEffect:ne(me(()=>u.resolver.delay),f=>tF(u)),run:Gn(me(()=>u.resolver.runAll(Array.from(u.entries),u.key)),f=>{for(let l of u.entrySet)l.completeUnsafe(f._tag==="Success"?ao(new Error("Effect.request: RequestResolver did not complete request",{cause:l.request})):f);return u.entries.clear(),tx.length<128&&(u.entrySet.clear(),u.key=void 0,u.fiber=void 0,u.resolver=void 0,u.map=void 0,tx.push(u)),we})};s=u}o.set(c,s),s.fiber=Xi(r.context)(s.delayEffect,{scheduler:r.currentScheduler})}return s.entrySet.add(a),s.entries.add(a),s.resolver.collectWhile(s.entries)||(s.fiber.interruptUnsafe(r.id),s.fiber=Xi(r.context)(tF(s),{scheduler:r.currentScheduler})),a},sF=(e,t)=>{if(t.uninterruptible)return;let n=mw.get(e);if(!n)return;let r=e.batchKey(t),o=n.get(r);o&&(o.entries.delete(t),o.entrySet.delete(t),o.entries.size===0&&(n.delete(r),o.fiber?.interruptUnsafe()))},S8=(e,t)=>he(()=>sF(e,t));function tF(e){return e.map.has(e.key)?(e.map.delete(e.key),e.run):we}var b8="effect/Metric/CurrentMetricAttributes",w8=Me(b8,{defaultValue:()=>({})}),I8="~effect/observability/Metric/MetricRegistryKey",v8=Me(I8,{defaultValue:()=>new Map}),iF="~effect/observability/Metric",aF=class{[iF]=iF;#e=new WeakMap;#t;id;description;attributes;constructor(t,n,r){this.id=t,this.description=n,this.attributes=r}valueUnsafe(t){return this.hook(t).get(t)}modifyUnsafe(t,n){return this.hook(n).modify(t,n)}updateUnsafe(t,n){return this.hook(n).update(t,n)}hook(t){let n=qe(t,w8);if(Object.keys(n).length===0)return Kn(this.#t)?this.#t.hooks:(this.#t=this.getOrCreate(t,this.attributes),this.#t.hooks);let r=C8(this.attributes,n),o=this.#e.get(r);return Kn(o)||(o=this.getOrCreate(t,r),this.#e.set(r,o)),o.hooks}getOrCreate(t,n){let r=T8(this,n),o=qe(t,v8);if(o.has(r))return o.get(r);let s=this.createHooks(),i={id:this.id,type:this.type,description:this.description,attributes:hw(n),hooks:s};return o.set(r,i),i}pipe(){return ie(this,arguments)}};var Gf=d(2,(e,t)=>Wa(n=>he(()=>e.updateUnsafe(t,n))));function T8(e,t){let n=`${e.type}:${e.id}`;return Kn(e.description)&&(n+=`:${e.description}`),Kn(t)&&(n+=`:${k8(t)}`),n}function k8(e){return JSON.stringify(Array.isArray(e)?e:Object.entries(e))}function C8(e,t){return{...hw(e),...hw(t)}}function hw(e){return Kn(e)&&Array.isArray(e)?e.reduce((t,[n,r])=>(W(t,n,r),t),{}):e}var A8=Js,Cr=ve,O8=Uf,R8=C0,_8=X_,M8=eM,P8=tM,F8=rM,Do=Lr,U8=sM,Qn=ni,nx=n0,ys=jR,v=J,Ss=Xc,rx=t0,K=me,se=he,H=we;var Qf=Fg;var Es=Bt,Hr=Nd,D8=lM,N8=dM,L8=mM;var B8=pM,qt=HR,G=wt,ox=mg,ct=ot,ea=LR,po=Gi,No=BR;var rp=Cf,j8=e0,xn=de,gw=kf,$8=Xb,q8=NR,z8=DR,A=ne,xw=YR,Dn=Br,Mt=ti,H8=qa,W8=M_,Wr=$d,Y=Be,zt=Pn,sx=Af,Lo=Ld,K8=VR,yw=h_,V8=u0,mu=kr;var fF=bg,lF=T_,J8=k_,G8=C_,Z8=A_,ft=Tr,Sw=E_,Q8=Bd,Y8=Eg,X8=S_,e6=l0,t6=_f,Yf=p0,n6=m0,ci=wg,op=d0,r6=I_,sp=b_,o6=w_,s6=Sg,dF=v_,i6=h0,ix=ep,Ew=dw,a6=JR,bw=__,ww=Ig,c6=YP,u6=VM,f6=O_,l6=R_,Iw=N_,d6=L_,p6=x0,ta=D_,Qa=ru,m6=B_,vw=i0,h6=a0,g6=GR,Ya=hg,Tw=cM,x6=uM,kw=fM,pF=A0,y6=O0,mF=g_,S6=aM,ax=x_,Cw=vg,E6=jd,b6=g0,w6=P_,I6=ZR,Kr=cs,hF=eu,v6=F_,T6=U_,ar=c0,cr=Wa,Aw=ex,Nn=Qi,k6=m_,Ow=l_,hu=d_,ip=Rf,Rw=Zi,C6=p_,Bo=vr,A6=xg,jo=qd,gu=Tg,ap=kg,Xa=Cg,O6=V_,gF=K_,xF=Pf,na=H_,mo=w0,R6=W_,_6=I0,_w=ls,ur=Gn,M6=E0,P6=b0,cx=J_,F6=T0,U6=v0,ho=Ff,ra=k0,ui=Ag,fi=Yi,go=jr,Mw=Q_,D6=Y_,Ht=yg,yF=GP,N6=lw,L6=f0,Pw=y_,B6=d(2,(e,t)=>SF(e,void 0,t)),SF=ZP,j6=CM,$6=AM,q6=OM,z6=RM,H6=LM,W6=BM,K6=jM,V6=$M,J6=FM,G6=UM,Z6=DM,Fw=MM,Uw=us,cp=Ud,Q6=NM,Y6=PM,Xf=Tf,X6=nF,eK=rF,el=hM,Ut=R0,bs=yM,tl=gM,tK=xM,nK=qR,rK=zR,up=EM,Ln=Xi,Dw=_0,oK=bM,Nw=IM,Lw=M0,ux=wM,sK=Rg,li=TM,Bw=P0,ec=vM,iK=_g,ye=o0,aK=WR,xu=ds,nl=ps,cK=ps(),uK=ps("Fatal"),fK=ps("Warn"),fp=ps("Error"),lK=ps("Info"),dK=ps("Debug"),pK=ps("Trace"),mK=d(2,(e,t)=>Zi(e,D0,n=>new Set([...n,t]))),fx=d(e=>Cr(e[0]),(e,...t)=>Zi(e,oP,n=>{let r=t.length===1?{...n,...t[0]}:{...n};return t.length===1||W(r,t[0],t[1]),r})),hK=WM,gK=d(2,(e,t)=>ne(U0,n=>Zi(e,sP,r=>[[t,n],...r]))),xK=d(e=>Cr(e[0]),(e,t,n)=>ur(e,r=>{let o=n===void 0?r:je(()=>n(r));return Gf(t,o)})),yK=d(e=>Cr(e[0]),(e,t,n)=>Mt(e,r=>{let o=n===void 0?r:n(r);return Gf(t,o)})),SK=d(e=>Cr(e[0]),(e,t,n)=>op(e,r=>{let o=n===void 0?r:je(()=>n(r));return Gf(t,o)})),EK=d(e=>Cr(e[0]),(e,t,n)=>dF(e,r=>{let o=n===void 0?r:je(()=>n(r));return Gf(t,o)})),bK=d(e=>Cr(e[0]),(e,t,n)=>xu(r=>{let o=r.monotonicTimeNanosUnsafe();return ur(e,()=>{let s=r.monotonicTimeNanosUnsafe(),i=VO(gt(s),gt(o)),a=n===void 0?i:je(()=>n(i));return Gf(t,a)})})),Zf=class extends Ke()("effect/Effect/Transaction"){},wK=e=>xn(t=>{let n=$i(t.context,Zf);if(n)return e;n={journal:new Map,retry:!1};let r;return go(o=>A(Qn({while:()=>!r,body:Qe(o(e).pipe(Bo(Zf,n),sp(()=>n.retry?o(vK(n)):H),Wr)),step(s){if(n.retry||!IK(n))return uF(n);Ft(s)?TK(t,n):uF(n),r=s}}),()=>r))}),IK=e=>{for(let[t,{version:n}]of e.journal)if(t.version!==n)return!1;return!0},vK=e=>K(()=>{let t={},n=Array.from(e.journal.keys()),r=()=>{for(let o of n)o.pending.delete(t)};return Es(o=>{let s=()=>{r(),o(H)};for(let i of n)i.pending.set(t,s);return se(r)})});function TK(e,t){for(let[n,{value:r}]of t.journal){r!==n.value&&(n.version=n.version+1,n.value=r);for(let o of n.pending.values())e.currentDispatcher.scheduleTask(o,0);n.pending.clear()}}function uF(e){e.retry=!1,e.journal.clear()}var kK=A(Zf,e=>(e.retry=!0,ho)),CK=(e,t,n)=>(...r)=>Es(o=>{try{e(...r,(s,i)=>{o(s?G(t?t(s,r):s):v(i))})}catch(s){o(n?G(n(s,r)):po(s))}}),AK=()=>e=>e,OK=()=>e=>e,RK=()=>e=>e,oa=XR,yu=e_,fn=t_,Bn=QR,lx=n_,dx=KR;function di(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function lp(e){return t=>di(t)?.[e]}var Vr="~structural",Su="~identifier",dp="~sentinels",px="~constructor",EF=["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"],rl=lp("identifier"),jw=lp(Su),$w=lp("title");var bF=lp("brands"),pp=wn(e=>{let t=di(e)?.identifier;return typeof t=="string"?t:e.getExpected(pp)});var wF=new Set([dp,Vr,"representation","arbitrary","brands","toJsonSchema","toCode","toArbitrary","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecStringTree","toCodecIso"]);var ze=Symbol();var $o=kn,ws=$o(ze),on=$o(ze),mx=e=>e===ze?U():N(e),qw=e=>e._tag==="None"?ws:$o(e.value);var hp="~effect/SchemaIssue/Issue";function Hw(e){return B(e,hp)&&e[hp]===hp}function _K(e){return Object.hasOwn(e,"input")}var xo=class{[hp]=hp;constructor(t,n){n?.reportInput===!0&&t!==ze&&(this.input=t)}},xx=class extends xo{_tag="Filter";filter;issue;constructor(t,n,r,o){super(r,o),this.filter=t,this.issue=n}},yx=class extends xo{_tag="Encoding";ast;issue;constructor(t,n,r,o){super(r,o),this.ast=t,this.issue=n}},Ct=class extends xo{_tag="Pointer";path;issue;constructor(t,n){super(),this.path=t,this.issue=n}},sn=class extends xo{_tag="MissingKey";annotations;constructor(t){super(),this.annotations=t}},sa=class extends xo{_tag="UnexpectedKey";ast;constructor(t,n,r){super(n,r),this.ast=t}},At=class extends xo{_tag="Composite";ast;issues;constructor(t,n,r,o){super(r,o),this.ast=t,this.issues=n}},st=class extends xo{_tag="InvalidType";ast;constructor(t,n,r){super(n,r),this.ast=t}},ke=class extends xo{_tag="InvalidValue";annotations;constructor(t,n,r){super(n,r),this.annotations=t}};function Yn(e,t,n,r,o){return new At(e,[new Ct([t],n)],r,o)}var bu=class extends xo{_tag="Forbidden";annotations;constructor(t,n,r){super(n,r),this.annotations=t}},sl=class extends xo{_tag="AnyOf";ast;issues;constructor(t,n,r,o){super(r,o),this.ast=t,this.issues=n}},Sx=class extends xo{_tag="OneOf";ast;successes;constructor(t,n,r,o){super(r,o),this.ast=t,this.successes=n}};function zw(e,t,n){if(Hw(e))return e;if(typeof e=="string")return new ke({message:e},t,n);let r=typeof e.issue=="string"?new ke({message:e.issue},t,n):e.issue;return new Ct(e.path,r)}function IF(e,t,n){if(e!==void 0)return typeof e=="boolean"?e?void 0:new ke(void 0,t,n):zw(e,t,n)}function vF(e,t,n,r){return Array.isArray(t)?Ye(t)?t.length===1?zw(t[0],n,r):new At(e,os(t,o=>zw(o,n,r)),n,r):void 0:IF(t,n,r)}var TF=e=>{let t=il(e);if(t!==void 0)return t;switch(e._tag){case"InvalidType":return tc(pp(e.ast),e);case"InvalidValue":{let n=Ww(e);if(n!==void 0)return tc(n,e);let r=gx(e);return r===void 0?"Expected a valid value":`Invalid data ${r}`}case"MissingKey":return"Missing key";case"UnexpectedKey":{let n=gx(e);return n===void 0?"Expected no excess property":`Unexpected key with value ${n}`}case"Forbidden":return"Forbidden operation";case"OneOf":{let n=gx(e);return n===void 0?"Expected exactly one member to match":`Expected exactly one member to match the input ${n}`}}},kF=e=>il(e.issue)??il(e);function CF(e){return t=>({issues:ol(t,[],e?.leafHook??TF,e?.checkHook??kF)})}function gx(e){return _K(e)?X(e.input):void 0}function Ww(e){let t=e.annotations?.expected;return typeof t=="string"?t:void 0}function tc(e,t){let n=gx(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function ol(e,t,n,r){switch(e._tag){case"Filter":{let o=r(e);if(o!==void 0)return[{path:t,message:o}];if(e.issue._tag!=="InvalidValue")return ol(e.issue,t,n,r);let s=Ww(e.issue);return[{path:t,message:s===void 0?tc(Kw(e.filter),e):tc(s,e.issue)}]}case"Encoding":return ol(e.issue,t,n,r);case"Pointer":return ol(e.issue,[...t,...e.path],n,r);case"Composite":return e.issues.flatMap(o=>ol(o,t,n,r));case"AnyOf":return e.issues.length===0?[{path:t,message:il(e)??tc(pp(e.ast),e)}]:e.issues.flatMap(o=>ol(o,t,n,r));default:return[{path:t,message:n(e)}]}}function Kw(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(n=>Kw(n)).join(" & ")}}function MK(){return e=>mp(e,"")}var AF=MK();function mp(e,t){let n;switch(e._tag){case"Filter":{let r=kF(e);if(r!==void 0)n=r;else{if(e.issue._tag!=="InvalidValue")return mp(e.issue,t);let o=Ww(e.issue);n=o===void 0?tc(Kw(e.filter),e):tc(o,e.issue)}break}case"Encoding":return mp(e.issue,t);case"Pointer":return mp(e.issue,t+vh(e.path));case"Composite":case"AnyOf":{if(e._tag==="Composite"||e.issues.length>0)return e.issues.map(r=>mp(r,t)).join(`
|
|
24
|
-
`);n=
|
|
25
|
-
at ${t}`:n}function il(e){if(e._tag==="Pointer")return;if(e._tag==="Encoding")return il(e.issue);let n=(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 n=="string")return n}function gp(e){let t;for(let n of e.reasons){if(!Ug(n)||!Hw(n.error))return;t??=n.error}return t}function ia(e,t){let n=gp(e);if(n===void 0)throw new Error(t,{cause:e});return n}var wu=Hf,RF=pu,_F=vP,MF=TP,PF=kP,FF=G0,Vw=CP,Jw=AP;var UF=du,DF=Gg;var Ex=Z0;var bx=RP,NF=_P;var wx=MP;var Gw=Q0,xp=Gd,LF=Y0;var BF=X0,nc=PP;var Ix=Zd;var jF=nw;var $F=UP;var vx=ow;var rc=class e extends Mc{run;constructor(t){super(),this.run=t}map(t){return new e((n,r)=>this.run(n,r).pipe(oa(Lt(t))))}compose(t){return qF(this)?t:qF(t)?this:new e((n,r)=>this.run(n,r).pipe(Bn(o=>t.run(o,r))))}};function PK(e){return new rc((t,n)=>G(e(t,n)))}function Zw(e){return PK((t,n)=>{let r={message:e(t)};return Te(t)?new bu(r,t.value,n):new bu(r)})}var zF=new rc(v);function qF(e){return e.run===zF.run}function Is(){return zF}function Qw(e){return new rc((t,n)=>ge(t)?Ss:e(t.value,n))}function De(e){return Tx(Lt(e))}function Jr(e){return Qw((t,n)=>e(t,n).pipe(oa(N)))}function Tx(e){return new rc(t=>v(e(t)))}function Yw(){return new rc(()=>Ss)}function Sp(e){return new rc(t=>{let n=Na(t,Kn);return Te(n)?v(n):oa(e,N)})}function Iu(){return De(globalThis.String)}function kx(){return De(globalThis.Number)}function HF(){return De(globalThis.BigInt)}function Xw(){return De(e=>new globalThis.Date(e))}function WF(){return De(qP)}function KF(e){return Qw((t,n)=>No({try:()=>N(JSON.parse(t,e?.reviver)),catch:()=>new ke({expected:"a valid JSON string"},t,n)}))}function VF(e){return Qw((t,n)=>No({try:()=>{let r=JSON.stringify(t,e?.replacer,e?.space);if(r===void 0)throw new TypeError("Value cannot be represented as JSON");return N(r)},catch:()=>new ke({expected:"a JSON-serializable value"},t,n)}))}function eI(){return De(Zh)}function Cx(){return De(sR)}function Ax(){return De(aR)}function JF(){return Jr((e,t)=>yu(gw(bf(e)),()=>new ke({expected:"a valid Base64 string"},e,t)))}function GF(){return Jr((e,t)=>Oo(oR(e),{onFailure:()=>G(new ke({expected:"a valid Base64 string"},e,t)),onSuccess:v}))}function ZF(){return Jr((e,t)=>Oo(Ib(e),{onFailure:()=>G(new ke({expected:"a valid Base64Url string"},e,t)),onSuccess:v}))}function QF(){return Jr((e,t)=>Oo(iR(e),{onFailure:()=>G(new ke({expected:"a valid Base64Url string"},e,t)),onSuccess:v}))}function YF(){return Jr((e,t)=>Oo(Tb(e),{onFailure:()=>G(new ke({expected:"a valid hexadecimal string"},e,t)),onSuccess:v}))}function XF(){return Jr((e,t)=>Oo(cR(e),{onFailure:()=>G(new ke({expected:"a valid hexadecimal string"},e,t)),onSuccess:v}))}function eU(){return De(encodeURIComponent)}function tU(){return Jr((e,t)=>{try{return v(globalThis.decodeURIComponent(e))}catch{return G(new ke({expected:"a valid URI component"},e,t))}})}function tI(){return Jr((e,t)=>rr(bx(e),{onNone:()=>G(new ke({message:"Invalid DateTime input"},e,t)),onSome:n=>v(wx(n))}))}function nU(){return De(e=>iU(Array.from(e.entries())))}var FK=aU(e=>typeof e=="string"||typeof Blob<"u"&&e instanceof Blob);function rU(){return De(e=>{let t=new FormData;return typeof e=="object"&&e!==null&&FK(e).forEach(([r,o])=>{t.append(r,o)}),t})}function oU(){return De(e=>iU(Array.from(e.entries())))}var UK=aU(oo);function sU(){return De(e=>typeof e=="object"&&e!==null?new URLSearchParams(UK(e)):new URLSearchParams)}var DK=/^\d+$/;function NK(e){if(e==="")return[""];let t=e.replace(/\[(.*?)\]/g,".$1"),n=t.split("."),r=t.startsWith(".")?1:0;return n.slice(r).map(o=>DK.test(o)?globalThis.Number(o):o)}function iU(e){let t={},n=new WeakSet;function r(o,s,i){let a=Object.hasOwn(o,s)?o[s]:void 0;if(n.has(a)&&Array.isArray(a)===i)return a;let c=i?[]:{};return n.add(c),W(o,s,c),c}return e.forEach(([o,s])=>{let i=NK(o),a=t;i.forEach((c,u)=>{let f=u===i.length-1;if(Array.isArray(a)&&c==="")if(f)a.push(s);else{let l=i[u+1],p=typeof l=="number"||l==="",m=a.length;a=r(a,m,p)}else if(f){let l=Object.hasOwn(a,c);l&&Array.isArray(a[c])?a[c].push(s):l?W(a,c,[a[c],s]):W(a,c,s)}else{let l=i[u+1];a=r(a,c,typeof l=="number"||l==="")}})}),t}function aU(e){return t=>{let n=[];function r(o,s){if(e(s))n.push([o,s]);else if(Array.isArray(s))s.every(e)?s.forEach(a=>{n.push([o,a])}):s.forEach((a,c)=>{r(`${o}[${c}]`,a)});else if(typeof s=="object"&&s!==null)for(let[i,a]of Object.entries(s))r(`${o}[${i}]`,a)}for(let[o,s]of Object.entries(t))r(o,s);return n}}var bp=class e{_tag="Middleware";decode;encode;constructor(t,n){this.decode=t,this.encode=n}flip(){return new e(this.encode,this.decode)}},Ep="~effect/SchemaTransformation/Transformation",et=class e{[Ep]=Ep;_tag="Transformation";decode;encode;constructor(t,n){this.decode=t,this.encode=n}flip(){return new e(this.encode,this.decode)}compose(t){return new e(this.decode.compose(t.decode),t.encode.compose(this.encode))}};function LK(e){return B(e,Ep)&&e[Ep]===Ep}var Rx=e=>LK(e)?e:new et(e.decode,e.encode);function Ar(e){return new et(Jr(e.decode),Jr(e.encode))}function vt(e){return new et(De(e.decode),De(e.encode))}function _x(e){return new et(Tx(e.decode),Tx(e.encode))}function cU(){return new et(WF(),Is())}var BK=new et(Is(),Is());function al(){return BK}var cl=new et(kx(),Iu()),Mx=new et(HF(),Iu()),nI=new et(Xw(),De(jE)),uU=new et(Xw(),De(e=>e.getTime())),fU=Ar({decode:(e,t)=>rr(HO(e),{onNone:()=>G(new ke({expected:"a valid Duration string"},e,t)),onSome:v}),encode:e=>v(globalThis.String(e))}),lU=Ar({decode:e=>v(Nr(e)),encode:(e,t)=>rr(WO(e),{onNone:()=>G(new ke({expected:"a Duration representable as a bigint"},e,t)),onSome:n=>v(n)})}),dU=vt({decode:e=>is(e),encode:e=>Tn(e)}),jK=e=>en(e)&&typeof e.message=="string",pU=e=>{let n=Object.hasOwn(e,"cause")?new Error(e.message,{cause:hU(e.cause)}):new Error(e.message);return typeof e.name=="string"&&e.name!=="Error"&&(n.name=e.name),typeof e.stack=="string"&&(n.stack=e.stack),n},$K=e=>{try{let t=Bc(e);return t===void 0?X(e):JSON.parse(t)}catch{return X(e)}},qK=(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},mU=e=>{let t=new WeakSet,n=r=>{if(TA(r)){if(t.has(r))return"[Circular]";t.add(r);let o=qK(r,e,n);return t.delete(r),o}return $K(r)};return n},hU=e=>jK(e)?pU(e):e,gU=e=>vt({decode:pU,encode:t=>mU(e)(t)}),xU=e=>vt({decode:hU,encode:mU(e)});function yU(){return vt({decode:ZE,encode:Td})}function SU(){return vt({decode:GE,encode:Ao})}function EU(e){return vt({decode:Kc,encode:e?.onNoneEncoding===null?Td:Ao})}function bU(){return _x({decode:N,encode:Vc})}function wU(){return _x({decode:e=>e.pipe(Na(Kn),N),encode:Vc})}var rI=Ar({decode:(e,t)=>URL.canParse(e)?v(new URL(e)):G(new ke({expected:"a valid URL string"},e,t)),encode:e=>v(e.href)}),oI=Ar({decode:(e,t)=>{let n=IO(e);return ge(n)?G(new ke({expected:"a valid BigDecimal string"},e,t)):v(n.value)},encode:e=>v(Zs(e))}),sI=new et(JF(),eI()),IU=new et(GF(),eI()),vU=new et(QF(),Cx()),TU=new et(XF(),Ax()),kU=new et(tU(),eU());function CU(e){return new et(KF(e??{}),VF(e))}var AU=new et(nU(),rU()),OU=new et(oU(),sU()),RU=vt({decode:e=>xp(e),encode:e=>e.offset}),iI=Ar({decode:(e,t)=>rr(LF(e),{onNone:()=>G(new ke({expected:"a valid IANA time zone"},e,t)),onSome:v}),encode:e=>v(e.id)}),aI=Ar({decode:(e,t)=>rr(BF(e),{onNone:()=>G(new ke({expected:"a valid time zone"},e,t)),onSome:v}),encode:e=>v(nc(e))}),cI=Ar({decode:(e,t)=>rr(bx(e),{onNone:()=>G(new ke({expected:"a valid UTC DateTime string"},e,t)),onSome:n=>v(wx(n))}),encode:e=>v($F(e))}),uI=Ar({decode:(e,t)=>rr(NF(e),{onNone:()=>G(new ke({expected:"a valid Zoned DateTime string"},e,t)),onSome:v}),encode:e=>v(vx(e))});function sc(e){return t=>t._tag===e}var ic=sc("Declaration");var zK=sc("Never");var ul=sc("Literal"),fI=sc("UniqueSymbol");var OI=sc("Arrays"),HK=sc("Objects"),BU=sc("Union"),WK=sc("Suspend"),Dt=class{to;transformation;constructor(t,n){this.to=t,this.transformation=n}},Qr={},Zr=class{isOptional;isMutable;constructorDefault;annotations;constructor(t,n,r=void 0,o=void 0){this.isOptional=t,this.isMutable=n,this.constructorDefault=r,this.annotations=o}},_U="~effect/Schema",Jt=class{[_U]=_U;annotations;checks;encoding;context;constructor(t=void 0,n=void 0,r=void 0,o=void 0){this.annotations=t,this.checks=n,this.encoding=r,this.context=o}toString(){return`<${this._tag}>`}},aa=class e extends Jt{_tag="Declaration";typeParameters;run;encodingChecks;encodingRun;constructor(t,n,r,o,s,i,a,c){super(r,o,s,i),this.typeParameters=t,this.run=n,this.encodingChecks=a,this.encodingRun=c}getParser(){let t;return(n,r)=>n===ze?ws:(t??=this.run(this.typeParameters))(n,this,r)}_rebuild(t,n,r,o,s){let i=ll(this.typeParameters,t);return i===this.typeParameters&&n===this.checks&&r===this.encodingChecks&&o===this.run&&s===this.encodingRun?this:new e(i,o,this.annotations,n,void 0,this.context,r,s)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let t=this.annotations?.expected;return typeof t=="string"?t:"<Declaration>"}},lI=class extends Jt{_tag="Null";getParser(){return Jx(this,null)}getExpected(){return"null"}},RI=new lI;var dI=class extends Jt{_tag="Undefined";getParser(){return Jx(this,void 0)}toCodecJson(){return lt(this,[jU])}getExpected(){return"undefined"}},jU=new Dt(RI,new et(De(()=>{}),De(()=>null))),_I=new dI;var pI=class extends Jt{_tag="Void";getParser(){let t=$o(void 0);return n=>n===ze?ws:t}toCodecJson(){return lt(this,[jU])}getExpected(){return"void"}},$U=new pI;var mI=class extends Jt{_tag="Never";getParser(){return ks(this,vA)}getExpected(){return"never"}},qU=new mI,hI=class extends Jt{_tag="Any";getParser(){return ks(this,AE)}getExpected(){return"any"}},zU=new hI,gI=class extends Jt{_tag="Unknown";getParser(){return ks(this,AE)}getExpected(){return"unknown"}},ca=new gI,xI=class extends Jt{_tag="ObjectKeyword";getParser(){return ks(this,ld)}getExpected(){return"object | array | function"}},HU=new xI,Px=class extends Jt{_tag="Enum";enums;constructor(t,n,r,o,s){super(n,r,o,s),this.enums=t}getParser(){let t=new Set(this.enums.map(([,n])=>n));return ks(this,n=>t.has(n))}toCodecStringTree(){if(this.enums.some(([t,n])=>typeof n=="number")){let t=Object.fromEntries(this.enums.map(([n,r])=>[globalThis.String(r),r]));return lt(this,[new Dt(new Or(Object.keys(t).map(n=>new Gr(n)),"anyOf"),new et(De(n=>t[n]),Iu()))])}return this}getExpected(){return this.enums.map(([t,n])=>JSON.stringify(n)).join(" | ")}};function WU(e){switch(e._tag){case"String":case"Number":case"BigInt":return!0;case"Literal":case"TemplateLiteral":return!e.checks;case"Union":return!e.checks&&e.types.every(WU);default:return!1}}var Fx=class extends Jt{_tag="TemplateLiteral";parts;encodedParts;literals;suffixLengths;constructor(t,n,r,o,s){super(n,r,o,s);let i=[],a=[];for(let u of t){let f=jn(u);if(WU(f))i.push(f),a.push(f._tag==="Literal"?globalThis.String(f.literal):void 0);else throw new Error(`Invalid TemplateLiteral part ${f._tag}`)}let c=new Array(i.length+1);c[i.length]=0;for(let u=i.length-1;u>=0;u--)c[u]=c[u+1]+(a[u]?.length??0);this.parts=t,this.encodedParts=i,this.literals=a,this.suffixLengths=c}getParser(t){let n=t(this.asTemplateLiteralParser());return(r,o)=>{if(r===ze)return ws;let s=n(r,o);return s._tag==="Success"?on:fn(s,{onSuccess:()=>r,onFailure:i=>new At(this,[i],r,o)})}}getExpected(){return"string"}matchPart(t,n){return LU(this,t,n)===void 0?void 0:t}asTemplateLiteralParser(){let t=new Ts(!1,this.parts.map(f1),[]);return Vx(mi,t,new et(Jr((n,r)=>{let o=LU(this,n,r);return o?v(o):G(new ke({expected:"a string matching template literal parts"},n,r))}),De(n=>n.join(""))))}},Ux=class extends Jt{_tag="UniqueSymbol";symbol;constructor(t,n,r,o,s){super(n,r,o,s),this.symbol=t}getParser(){return Jx(this,this.symbol)}toCodecStringTree(){return lt(this,[p1])}getExpected(){return globalThis.String(this.symbol)}},Gr=class extends Jt{_tag="Literal";literal;constructor(t,n,r,o,s){if(super(n,r,o,s),typeof t=="number"&&!globalThis.Number.isFinite(t))throw new Error(`A numeric literal must be finite, got ${X(t)}`);this.literal=t}getParser(){return Jx(this,this.literal)}matchPart(t,n){return t===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal=="bigint"?MU(this):this}toCodecStringTree(){return typeof this.literal=="string"?this:MU(this)}getExpected(){return typeof this.literal=="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};function MU(e){let t=globalThis.String(e.literal);return lt(e,[new Dt(new Gr(t),new et(De(()=>e.literal),De(()=>t)))])}var yI=class extends Jt{_tag="String";getParser(){return ks(this,oo)}matchPart(t,n){let r=this.checks;return r&&!n.disableChecks&&Cs(r,t,void 0,this,n)?void 0:t}getExpected(){return"string"}},mi=new yI,SI=class extends Jt{_tag="Number";getParser(){return ks(this,ud)}matchKey(t,n){return this._match(rV,t,n)}matchPart(t,n){return this._match(kI,t,n)}_match(t,n,r){if(!t.test(n))return;let o=globalThis.Number(n);return r.disableChecks||!this.checks?o:Cs(this.checks,o,void 0,this,r)?void 0:o}toCodecJson(){return this.checks&&(EI(this.checks,"effect/schema/isFinite")||EI(this.checks,"effect/schema/isInt"))?this:lt(this,[QK])}toCodecStringTree(){return this.toCodecJson()===this?lt(this,[oV]):lt(this,[sV])}getExpected(){return"number"}};function EI(e,t){return e.some(n=>n.annotations?.representation?.id===t||n._tag==="FilterGroup"&&EI(n.checks,t))}var MI=new SI,bI=class extends Jt{_tag="Boolean";getParser(){return ks(this,EA)}getExpected(){return"boolean"}},KU=new bI,wI=class extends Jt{_tag="Symbol";getParser(){return ks(this,CE)}matchKey(t,n){return n.disableChecks||!this.checks?t:Cs(this.checks,t,void 0,this,n)?void 0:t}toCodecStringTree(){return lt(this,[p1])}getExpected(){return"symbol"}},VU=new wI,II=class extends Jt{_tag="BigInt";getParser(){return ks(this,bA)}matchPart(t,n){if(!CI.test(t))return;let r=globalThis.BigInt(t);return n.disableChecks||!this.checks?r:Cs(this.checks,r,void 0,this,n)?void 0:r}toCodecStringTree(){return lt(this,[aV])}getExpected(){return"bigint"}},JU=new II,Ts=class e extends Jt{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(t,n,r,o,s,i,a,c){super(o,s,i,a),this.isMutable=t,this.elements=n,this.rest=r,this.encodingChecks=c;let u=!1;for(let f=0;f<n.length;f++)if(an(n[f]))u=!0;else if(u)throw new Error("A required element cannot follow an optional element. ts(1257)");if(u&&r.length>1)throw new Error("A required element cannot follow an optional element. ts(1257)");for(let f=1;f<r.length;f++)if(an(r[f]))throw new Error("An optional element cannot follow a rest element. ts(1266)")}getParser(t,n=t){let r=this,o,s,i=r.elements.length,a=Math.max(0,r.rest.length-1);function c(u,f){return f<i?o[f]:f>=u?s[f-u+1]:s[0]}return dx(function*(u,f){if(u===ze)return ze;if(!Array.isArray(u))return yield*G(new st(r,u,f));o||(o=r.elements.map(g=>({ast:g,parser:n(g)})),s=r.rest.map(g=>({ast:g,parser:n(g)})));let l=u.length,p={ast:r,getParser:c,input:u,len:l,tailThreshold:Math.max(i,l-a),output:new globalThis.Array(l),issues:void 0,options:f},m=PI(f?.concurrency),h=KK(p,u,{concurrency:m?.concurrency,end:r.rest.length===0?i:Math.max(l,i+a)});if(h&&(yield*h),r.rest.length===0&&l>i)for(let g=i;g<=l-1;g++){let x=new sa(r,u[g],f),b=new Ct([g],x);if(f.errors==="all")p.issues?p.issues.push(b):p.issues=[b];else return yield*G(new At(r,[b],u,f))}return p.issues?yield*G(new At(r,p.issues,u,f)):p.output})}_rebuild(t,n,r){let o=ll(this.elements,t),s=ll(this.rest,t);return o===this.elements&&s===this.rest&&n===this.checks&&r===this.encodingChecks?this:new e(this.isMutable,o,s,this.annotations,n,void 0,this.context,r)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks)}getExpected(){return"array"}},KK=zd()({onItem(e,t,n){let r=n<e.len?t:ze;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step(e,t,n,r){if(n._tag==="Failure")return Dx(e,e.ast,r,n);let o=n===on?t:n[xe];if(o!==ze)e.output[r]=o;else{let s=e.getParser(e.tailThreshold,r);if(an(s.ast))return;let i=new Ct([r],new sn(s.ast.context?.annotations));if(e.options.errors==="all")e.issues?e.issues.push(i):e.issues=[i];else return Mo(new At(e.ast,[i],e.input,e.options))}}}),PI=e=>(e=e==="unbounded"?1/0:e??1,e>1?{concurrency:e}:void 0),Dx=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let o=gp(r.cause);if(o===void 0)return jt(Ja(r.cause,i=>new At(t,[new Ct([n],i)],e.input,e.options)));let s=new Ct([n],o);if(e.options.errors==="all")e.issues?e.issues.push(s):e.issues=[s];else return Mo(new At(t,[s],e.input,e.options))},Bx="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";function ua(e,t,n=Qr){let r,o;function s(i){switch(i._tag){case"String":case"TemplateLiteral":return(r??=Object.keys(e)).filter(a=>i.matchPart(a,n)!==void 0);case"Number":return(r??=Object.keys(e)).filter(a=>i.matchKey(a,n)!==void 0);case"Symbol":return(o??=Object.getOwnPropertySymbols(e)).filter(a=>i.matchKey(a,n)!==void 0);case"Union":return[...new Set(i.types.flatMap(s))];default:return[]}}return s($I(jn(t)))}var vp=class{name;type;constructor(t,n){this.name=t,this.type=n}};function vI(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(vI);default:return!1}}function VK(e){return vI(e)&&vI(jn(e))}var Tp=class{parameter;type;constructor(t,n){if(!VK(t))throw new Error(`Invalid index signature parameter ${t._tag}`);if(this.parameter=t,this.type=n,an(n)&&!u1(n))throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},fl=class e extends Jt{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(t,n,r,o,s,i,a){super(r,o,s,i),this.propertySignatures=t,this.indexSignatures=n,this.encodingChecks=a;let c=t.map(u=>u.name).filter((u,f,l)=>l.indexOf(u)!==f);if(c.length>0)throw new Error(`Duplicate identifiers: ${JSON.stringify(c)}. ts(2300)`)}getParser(t,n=t){let r=this,o=[];for(let b of r.propertySignatures)o.push(b.name);let s=o.length,i=r.indexSignatures.length,a=s&&i?new Set(o):void 0;if(!s&&!i)return ks(r,ph);let c,u,f=(b,E,y,w,S)=>{if(S._tag==="Failure")return Dx(b,r,E,S)??Vt;let C=S===on?w:S[xe];if(y!==ze&&C!==ze){if(s&&(a.has(E)||a.has(y)))return Vt;W(b.out,y,C)}return Vt},l=(b,E,y,w)=>{if(!w){let R=y.parserKey(E,b.options);if(!xt(R))return A(Wr(R),M=>l(b,E,y,M));w=R}if(w._tag==="Failure")return Dx(b,r,E,w)??Vt;let S=w===on?E:w[xe],C=b.input[E],_=y.parserValue(C,b.options);return xt(_)?f(b,E,S,C,_):A(Wr(_),R=>f(b,E,S,C,R))},p=(b,E,y)=>{let w=b.input[E],S=y.parserValue(w,b.options);return xt(S)?f(b,E,E,w,S):A(Wr(S),C=>f(b,E,E,w,C))},m=i?zd()({onItem:(b,[E,y])=>l(b,E,y),step:(b,E,y)=>y._tag==="Failure"?y:void 0}):void 0,h=()=>(c||(c=r.propertySignatures.map(b=>({parser:n(b.type),name:b.name,type:b.type})),u=i?r.indexSignatures.map(b=>({is:b,parserKey:t($I(b.parameter)),parserValue:n(b.type)})):void 0),c),g=dx(function*(b,E){if(b===ze)return ze;if(!(typeof b=="object"&&b!==null&&!Array.isArray(b)))return yield*G(new st(r,b,E));h();let y=b,w={},S={ast:r,input:y,out:w,issues:void 0,options:E},C=E.errors==="all",_=E.onExcessProperty==="error",R=E.onExcessProperty==="preserve",M;if(!i&&(_||R)){a??=new Set(o),M=Reflect.ownKeys(y);for(let P=0;P<M.length;P++){let te=M[P];if(!a.has(te))if(_){let ee=new sa(r,y[te],E),T=new Ct([te],ee);if(C){S.issues?S.issues.push(T):S.issues=[T];continue}else return yield*G(new At(r,[T],b,E))}else W(w,te,y[te])}}let q=PI(E?.concurrency);if(s){let P=PU(S,c,q);P&&(yield*P)}if(i&&!q)for(let P=0;P<i;P++){let te=u[P],ee=te.is.parameter===mi?p:l,T=te.is.parameter===mi?Object.keys(y):ua(y,te.is.parameter,E);for(let z=0;z<T.length;z++){let F=ee(S,T[z],te);if(!xt(F))yield*F;else if(F._tag==="Failure")return yield*F}}else if(m){let P=rn();for(let ee=0;ee<i;ee++){let T=u[ee],z=ua(y,T.is.parameter,E);for(let F=0;F<z.length;F++)P.push([z[F],T])}let te=m(S,P,q);te&&(yield*te)}if(S.issues)return yield*G(new At(r,S.issues,b,E));if(E.propertyOrder==="original"){let P=(M??Reflect.ownKeys(y)).concat(o),te={};for(let ee of P)Object.hasOwn(w,ee)&&W(te,ee,w[ee]);return te}return w});if(i)return g;let x=(b,E,y)=>{let w=c[E];return A(Wr(y),S=>{let C=TI(b,w,S);if(C)return C;let _=()=>$o(b.out),R=PU(b,c.slice(E+1));return R?Bn(R,_):_()})};return(b,E)=>{if(b===ze)return ws;if(E.errors==="all"||E.onExcessProperty!==void 0||E.propertyOrder==="original"||E.concurrency!==void 0)return g(b,E);if(!(typeof b=="object"&&b!==null&&!Array.isArray(b)))return G(new st(r,b,E));let y=h(),w=b,S={},C={ast:r,input:w,out:S,issues:void 0,options:E};try{for(let _=0;_<y.length;_++){let R=y[_],M=R.name,q=Object.hasOwn(w,M),P=q?w[M]:ze,te=R.parser(P,E);if(!xt(te))return x(C,_,te);if(te===on){q&&W(S,M,P);continue}let ee=TI(C,R,te);if(ee)return ee}}catch(_){return po(_)}return $o(S)}}_rebuild(t,n,r,o){let s=ll(this.propertySignatures,a=>{let c=t(a.type);return c===a.type?a:new vp(a.name,c)}),i=ll(this.indexSignatures,a=>{let c=n(a.parameter),u=t(a.type);return c===a.parameter&&u===a.type?a:new Tp(c,u)});return s===this.propertySignatures&&i===this.indexSignatures&&r===this.checks&&o===this.encodingChecks?this:new e(s,i,this.annotations,r,void 0,this.context,o)}flip(t){return this._rebuild(t,t,this.encodingChecks,this.checks)}recur(t,n=t){return this._rebuild(t,n,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?"object | array":"object"}};function TI(e,t,n){if(n._tag==="Failure")return Dx(e,e.ast,t.name,n);if(n===on)return;let r=n[xe];if(r!==ze){W(e.out,t.name,r);return}if(delete e.out[t.name],!an(t.type)){let o=new Ct([t.name],new sn(t.type.context?.annotations));if(e.options.errors==="all"){e.issues?e.issues.push(o):e.issues=[o];return}else return Mo(new At(e.ast,[o],e.input,e.options))}}var PU=zd()({onItem(e,t){if(!Object.hasOwn(e.input,t.name))return t.parser(ze,e.options);let n=e.input[t.name];return W(e.out,t.name,n),t.parser(n,e.options)},step:TI});function FI(e,t){return e?t?[...e,...t]:e:t}function jx(e,t,n){return new fl(Reflect.ownKeys(e).map(r=>new vp(r,e[r].ast)),[],n,t)}function kp(e){return e.ast}function UI(e,t=void 0){return new Ts(!1,e.map(n=>n.ast),[],void 0,t)}function $x(e,t,n){return new Or(e.map(kp),t,void 0,n)}function GU(e,t){if(e.encoding||t.some(s=>s.encoding))throw new Error("StructWithRest does not support encodings");let n=e.propertySignatures,r=e.indexSignatures,o=e.checks;for(let s of t)n=n.concat(s.propertySignatures),r=r.concat(s.indexSignatures),o=FI(o,s.checks);return new fl(n,r,void 0,o)}function ZU(e,t){if(e.encoding)throw new Error("TupleWithRest does not support encodings");return new Ts(e.isMutable,e.elements,t,void 0,e.checks)}var qx=Uc(e=>{for(;;){if(WK(e))return ca;let t=e.encoding;if(!t)return e.recur?.(qx,L)??e;if(t.some(n=>n.transformation._tag==="Middleware"&&n.transformation.decode!==L))return ca;e=t[t.length-1].to}});function QU(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(([,t])=>typeof t)));case"Literal":return[typeof e.literal];case"Union":return Array.from(new Set(e.types.flatMap(QU)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}function oc(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[dp];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap(t=>{let n=t.type;if(!an(n)){if(ul(n))return[{key:t.name,literal:n.literal}];if(fI(n))return[{key:t.name,literal:n.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,n)=>{if(!an(t)){if(ul(t))return[{key:n,literal:t.literal}];if(fI(t))return[{key:n,literal:t.symbol}]}return[]});case"Union":{if(e.types.length===0)return[];let t=e.types.map(n=>oc(qx(n)));return t[0].filter(n=>t.every(r=>r.some(o=>o.key===n.key&&o.literal===n.literal)))}case"Suspend":return oc(e.thunk())}}var FU=new WeakMap,Ip=Object.freeze([]);function JK(e){let t=FU.get(e);if(t)return t;let n,r=0,o,s,i=!0;for(let a=0;a<e.length;a++){let c=e[a],u=qx(c);if(zK(u))continue;if(i)if(ul(u)||fI(u)){s??=new Map;let l=ul(u)?u.literal:u.symbol,p=s.get(l);p||s.set(l,p=[]),p.push(c)}else i=!1;let f=oc(u);if(f.length){n??=new Map,r++;for(let{key:l,literal:p}of f){let m=n.get(l);m||n.set(l,m=[new Map,new Set]),m[1].add(a);let h=m[0].get(p);h||m[0].set(p,h=new Set),h.add(a)}}else{o??={};let l=QU(u);for(let p of l)(o[p]??=[]).push(a)}}if(i&&s)s.forEach(Object.freeze),t=a=>s.get(a)??Ip;else if(n?.size===1&&!o){let[a,[c]]=n.entries().next().value,u=c;for(let[f,l]of c)u.set(f,Object.freeze(Array.from(l,p=>e[p])));t=(f,l)=>{if(ld(f)){let p=Object.hasOwn(f,a)?f[a]:void 0;if(p!==void 0)return u.get(p)??Ip;if(l)return e}return Ip}}else if(n){let a;for(let c of n)(!a||c[1][0].size>a[1][0].size)&&c[1][1].size===r&&(a=c);t=(c,u)=>{let f=c===null?"null":Array.isArray(c)?"array":typeof c,l=o?.[f]??Ip;if(!ld(c))return l.map(h=>e[h]);let p=new Set(l),m;if(a){let[h,[g]]=a,x=Object.hasOwn(c,h),b=x?c[h]:void 0;if(x&&(!u||b!==void 0)){let E=g.get(b);if(!E)return l.map(y=>e[y]);for(let y of E)p.add(y);m=h}}if(m===void 0)for(let[h,[g,x]]of n){let b=Object.hasOwn(c,h),E=b?c[h]:void 0;if(b&&(!u||E!==void 0)){let y=g.get(E);if(y)for(let w of y)p.add(w)}else if(u)for(let y of x)p.add(y)}for(let[h,[g,x]]of n){if(h===m)continue;let b=Object.hasOwn(c,h),E=b?c[h]:void 0;if(b&&(!u||E!==void 0)){let y=g.get(E);for(let w of p)x.has(w)&&!y?.has(w)&&p.delete(w)}}return Array.from(p).sort((h,g)=>h-g).map(h=>e[h])}}else t=a=>{let c=a===null?"null":Array.isArray(a)?"array":typeof a;return(o?.[c]??Ip).map(u=>e[u]).filter(GK(a))};return FU.set(e,t),t}function GK(e){return t=>{let n=qx(t);return n._tag==="Literal"?n.literal===e:n._tag==="UniqueSymbol"?n.symbol===e:!0}}function Cp(e,t,n=!1){return JK(t)(e,n)}var Or=class e extends Jt{_tag="Union";types;mode;encodingChecks;constructor(t,n,r,o,s,i,a){super(r,o,s,i),this.types=t,this.mode=n,this.encodingChecks=a}getParser(t,n){let r=this;return(o,s)=>{if(o===ze)return ws;let i=Cp(o,r.types,n!==void 0);if(i.length===1){let f=t(i[0])(o,s);return f._tag==="Success"?f:xt(f)?UU(r,f.cause,o,s):ft(f,l=>UU(r,l,o,s))}let a={ast:r,compile:t,input:o,out:void 0,successes:r.mode==="oneOf"?[]:void 0,issues:void 0,options:s},c=PI(s?.concurrency),u=ZK(a,i,c?{...c,orderedStep:!0}:void 0);return u?Bn(u,f=>a.out===on?v(o):a.out?a.out:G(new sl(r,a.issues??[],o,s))):a.out?a.out:G(new sl(r,a.issues??[],o,s))}}_rebuild(t,n,r){let o=ll(this.types,t);return o===this.types&&n===this.checks&&r===this.encodingChecks?this:new e(o,this.mode,this.annotations,n,void 0,this.context,r)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks)}matchPart(t,n){for(let r of this.types){let o=r.matchPart(t,n);if(o!==void 0)return o}}getExpected(t){let n=this.annotations?.expected;if(typeof n=="string")return n;if(this.types.length===0)return"never";let r=this.types.map(o=>{let s=jn(o);switch(s._tag){case"Arrays":{let i=s.elements.filter(ul);if(i.length>0)return`${DU(s.isMutable)}[ ${i.map(a=>t(a)+NU(a.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{let i=s.propertySignatures.filter(a=>ul(a.type));if(i.length>0)return`{ ${i.map(a=>`${DU(a.type.context?.isMutable)}${Ui(a.name)}${NU(a.type.context?.isOptional)}: ${t(a.type)}`).join(", ")}, ... }`;break}}return t(s)});return Array.from(new Set(r)).join(" | ")}};function UU(e,t,n,r){let o=gp(t);return o?Mo(new sl(e,[o],n,r)):jt(t)}var ZK=zd()({onItem(e,t){return e.compile(t)(e.input,e.options)},step(e,t,n){if(n._tag==="Failure"){let r=gp(n.cause);if(r===void 0)return n;e.issues?e.issues.push(r):e.issues=[r]}else{if(e.out&&e.successes)return e.successes.push(t),Mo(new Sx(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(t);else return Vt}}}),YU=new Or([new Gr("Infinity"),new Gr("-Infinity"),new Gr("NaN")],"anyOf");function DU(e){return e?"":"readonly "}function NU(e){return e?"?":""}function Tu(e){let t=!1,n;return()=>(t||(n=e(),t=!0),n)}var Nx=class e extends Jt{_tag="Suspend";thunk;constructor(t,n,r,o,s){if(r)throw new Error("Cannot add checks to Suspend");super(n,void 0,o,s),this.thunk=Tu(t)}getParser(t){let n;return(r,o)=>(n??=t(this.thunk()))(r,o)}recur(t){return new e(()=>t(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(t){return t(this.thunk())}},Lx=class e extends Mc{_tag="Filter";run;annotations;aborted;constructor(t,n=void 0,r=!1){super(),this.run=t,this.annotations=n,this.aborted=r}annotate(t){return new e(this.run,{...this.annotations,...t},this.aborted)}abort(){return new e(this.run,this.annotations,!0)}and(t,n){return new vu([this,t],n)}},vu=class e extends Mc{_tag="FilterGroup";checks;annotations;constructor(t,n=void 0){super(),this.checks=t,this.annotations=n}annotate(t){return new e(this.checks,{...this.annotations,...t})}and(t,n){return new e([this,t],n)}};function zx(e,t,n=!1){return new Lx((r,o,s)=>vF(o,e(r,o,s),r,s),t,n)}function Hx(e,t){return new Lx((n,r,o)=>e(n)?void 0:new ke(void 0,n,o),t,!0)}function DI(e){return zx(t=>globalThis.Number.isFinite(t),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:()=>({type:"number"}),toCode:()=>({runtime:"Schema.isFinite()"}),arbitrary:{constraint:{noInfinity:!0,noNaN:!0}},...e})}var NI=hi(MI,[DI()]),QK=new Dt(new Or([NI,YU],"anyOf"),new et(kx(),De(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function Ap(e,t){let n=e.source,r=new globalThis.RegExp(n,e.flags);return zx(o=>(r.lastIndex=0,r.test(o)),{expected:`a string matching the RegExp ${n}`,representation:{id:"effect/schema/isPattern",payload:{source:n,flags:e.flags}},toJsonSchema:()=>({pattern:n}),arbitrary:{constraint:{patterns:[e.source]}},...t})}function Op(e,t){let n=Object.getOwnPropertyDescriptors(e);return t(n),Object.create(Object.getPrototypeOf(e),n)}var XU=new WeakMap;function LI(e){return XU.get(e)??e}function lt(e,t){return e.encoding===t?e:Op(e,n=>{n.encoding.value=t})}function Rp(e,t){if(e.context===t)return e;let n=LI(e);if(n.context===t)return n;let r=Op(e,o=>{o.context.value=t});return XU.set(r,n),r}function _p(e){return e.encoding?_p(e.encoding[e.encoding.length-1].to):e}function qo(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Wx(e,jh(e.checks.slice(0,-1),n.annotate(t)))}return Op(e,n=>{n.annotations.value={...n.annotations.value,...t}})}function Wx(e,t){if(e._tag==="Suspend"&&t)throw new Error("Cannot add checks to Suspend");return e.checks===t?e:Op(e,n=>{n.checks.value=t})}function hi(e,t){return Wx(e,FI(e.checks,t))}function ac(e,t){let n=t(e.to);return n===e.to?e:new Dt(n,e.transformation)}function e1(e,t){let n=e,r=n[n.length-1],o=ac(r,t);return o===r?e:jh(e.slice(0,e.length-1),o)}function Kx(e){return t=>t.encoding?lt(t,e1(t.encoding,e)):t}function pl(e,t){return Kx(n=>Rp(n,t))(e)}function fa(e,t){function n(r){if(r.encoding){let o=r.encoding[r.encoding.length-1];return t?.stopAt?.(o)?r:lt(r,e1(r.encoding,n))}return e(r)}return Uc(n)}function t1(e,t){return BI(e,t,yn(e))}function n1(e,t){return BI(jn(e),t,e)}function BI(e,t,n){let r=new Dt(e,t);return lt(n,n.encoding?[...n.encoding,r]:[r])}function r1(e,t){let n=bF(e),r=n?[...n,t]:[t];return qo(e,{brands:r})}function ll(e,t){let n=!1,r=new Array(e.length);for(let o=0;o<e.length;o++){let s=e[o],i=t(s);i!==s&&(n=!0),r[o]=i}return n?r:e}function ml(e,t){let n=e.context?new Zr(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new Zr(!1,!1,void 0,t);return Rp(e,n)}var hl=Uc(e=>{let t=e.context?e.context.isOptional===!1?new Zr(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new Zr(!0,!1);return YK(Rp(e,t))}),YK=Kx(hl),o1=wn(e=>hl(new Or([e,_I],"anyOf"))),jI=Uc(e=>{let t=e.context?e.context.isMutable===!1?new Zr(e.context.isOptional,!0,e.context.constructorDefault,e.context.annotations):e.context:new Zr(!1,!0);return XK(Rp(e,t))}),XK=Kx(jI);function s1(e,t){let n=new et(Sp(t),Is()),r=new Dt(ca,n),o=e.context?new Zr(e.context.isOptional,e.context.isMutable,r,e.context.annotations):new Zr(!1,!1,r);return Rp(e,o)}function Vx(e,t,n){return BI(e,n,t)}function eV(e){let t=[],n=[];function r(o){switch(o._tag){case"Literal":dh(o.literal)&&t.push(o.literal);return;case"UniqueSymbol":t.push(o.symbol);return;case"Never":return;case"Union":for(let s=0;s<o.types.length;s++)r(o.types[s]);return;default:n.push(o)}}return r(e),{literals:t,parameters:n}}function i1(e,t){let{literals:n,parameters:r}=eV(e);return new fl(n.map(o=>new vp(o,t)),r.map(o=>new Tp(o,t)))}function an(e){return e.context?.isOptional??!1}function a1(e){return e.context?.isMutable??!1}function c1(e){return e.annotations?.[Vr]===!0||e._tag==="FilterGroup"&&e.checks.every(c1)}function tV(e){function t(r){return c1(r)?[r]:r._tag==="FilterGroup"?r.checks.flatMap(t):[]}let n=e.flatMap(t);return Vn(n)?n:void 0}var yn=Uc(e=>{if(e.encoding)return yn(lt(e,void 0));let t=e,n=t.recur?.(yn)??t,r=n.encodingChecks;if(r){let o=n===e?r:OI(n)||HK(n)||ic(n)&&n.typeParameters.length>0?tV(r):void 0;return Op(n,s=>{s.encodingChecks.value=void 0,s.checks.value=FI(n.checks,o)})}return n}),jn=Uc(e=>yn(vs(e)));function nV(e,t){let n=t,r=n.length,o=n[r-1],s=[new Dt(vs(lt(e,void 0)),n[0].transformation.flip())];for(let a=1;a<r;a++)s.unshift(new Dt(vs(n[a-1].to),n[a].transformation.flip()));let i=vs(o.to);return i.encoding?lt(i,[...i.encoding,...s]):lt(i,s)}var vs=wn(e=>{if(e.encoding)return nV(e,e.encoding);let t=e;return t.flip?.(vs)??t.recur?.(vs)??t});function u1(e){switch(e._tag){case"Undefined":return!0;case"Union":return e.types.some(u1);default:return!1}}function Jx(e,t){let n=$o(t);return(r,o)=>r===ze?ws:r===t?n:G(new st(e,r,o))}function ks(e,t){return(n,r)=>n===ze?ws:t(n)?on:G(new st(e,n,r))}function LU(e,t,n){let r=e.encodedParts,o=e.literals,s=t.length;for(let u=0;u<o.length;u++){let f=o[u];if(f&&!t.includes(f))return}if(e.suffixLengths[0]>s)return;let i=new Array(r.length),a;function c(u,f){if(u===r.length)return f===s;if(a?.has(u*(s+1)+f))return!1;let l=r[u];if(u===r.length-1){let p=t.slice(f);if(l.matchPart(p,n)!==void 0)return i[u]=p,!0}else if(l._tag==="Literal"){let p=o[u];if(t.startsWith(p,f)&&c(u+1,f+p.length))return i[u]=p,!0}else{let p=s-e.suffixLengths[u+1],m=o[u+1],h=m===void 0?p:t.lastIndexOf(m,p);for(;h>=f;){let g=t.slice(f,h);if(l.matchPart(g,n)!==void 0&&c(u+1,h))return i[u]=g,!0;if(h===0)break;h=m===void 0?h-1:t.lastIndexOf(m,h-1)}}return a??=new Set,a.add(u*(s+1)+f),!1}return c(0,0)?i:void 0}var Mp=wn(e=>new Or(e.enums.map(t=>new Gr(t[1],{title:t[0]})),"anyOf")),$I=fa(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur($I)}}),Gx=fa(e=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(Gx)}}),f1=fa(e=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(f1)}}),l1="[\\s\\S]*?",kI=new globalThis.RegExp(`^${Bx}$`),rV=new globalThis.RegExp(`^(?:${Bx}|Infinity|-Infinity|NaN)$`);function qI(e){return Ap(kI,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:()=>({pattern:kI.source}),...e})}var d1=hi(mi,[qI()]),oV=new Dt(d1,cl),sV=new Dt(new Or([d1,YU],"anyOf"),cl),iV="-?\\d+",CI=new globalThis.RegExp(`^${iV}$`);function zI(e){return Ap(CI,{expected:"a string representing a bigint",representation:{id:"effect/schema/isStringBigInt",payload:null},toJsonSchema:()=>({pattern:CI.source}),...e})}var HI=hi(mi,[zI({expected:"a string representing a bigint"})]),aV=new Dt(HI,Mx),cV="Symbol\\((.*)\\)",AI=new globalThis.RegExp(`^${cV}$`),uV=hi(mi,[WI()]),p1=new Dt(uV,new et(De(e=>globalThis.Symbol.for(AI.exec(e)[1])),Jr((e,t)=>globalThis.Symbol.keyFor(e)!==void 0?v(globalThis.String(e)):G(new bu({message:"cannot serialize to string, Symbol is not registered"},e,t)))));function WI(e){return Ap(AI,{expected:"a string representing a symbol",representation:{id:"effect/schema/isStringSymbol",payload:null},toJsonSchema:()=>({pattern:AI.source}),...e})}function Cs(e,t,n,r,o){for(let s=0;s<e.length;s++){let i=e[s];if(i._tag==="FilterGroup"){if(n=Cs(i.checks,t,n,r,o),n&&(o.errors!=="all"||n[n.length-1].filter.aborted))return n}else{let a=i.run(t,r,o);if(a){let c=new xx(i,a,t,o);if(n?n.push(c):n=[c],o.errors!=="all"||i.aborted)return n}}}return n}function m1(e,t){let n=Cs(e,t,void 0,ca,{errors:"all"});if(n){let r=new At(ca,n);return Ae(r)}return Ce(t)}function h1(e){if(!ic(e))return;let t=e.annotations?.[px];return cn(t)?t(e.typeParameters):void 0}function fV(e){return e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&globalThis.Number.isFinite(e)}function lV(e){return e===void 0||typeof e=="string"}function g1(e,t){let n=new WeakMap,r=[];e:for(;;){if(typeof e!="object"||e===null){if(!t(e))return!1}else{let o=e,s=n.get(o);if(s===!1)return!1;if(s===void 0){let i=Array.isArray(o);if(!i){let a=Object.getPrototypeOf(o);if(a!==null&&a!==Object.prototype&&Object.getPrototypeOf(a)!==null)return!1}n.set(o,!1),r.push({value:o,keys:i?o.length:Object.keys(o),index:0})}}for(;r.length>0;){let o=r[r.length-1],s=o.keys;if(typeof s=="number"){if(o.index<s){e=o.value[o.index++];continue e}}else if(o.index<s.length){e=o.value[s[o.index++]];continue e}n.set(o.value,!0),r.pop()}return!0}}function gl(e){return g1(e,fV)}var dl=new aa([],()=>(e,t,n)=>gl(e)?on:G(new st(t,e,n)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:()=>{},toCodecStringTree:()=>VI,toArbitrary:()=>e=>e.jsonValue()}),x1=qo(dl,{representation:{id:"effect/schema/MutableJson",payload:null}}),KI=new Dt(dl,al()),y1=new Dt(new Or([new Ts(!1,[],[dl]),new fl([],[new Tp(mi,dl)])],"anyOf"),al());function dV(e){return g1(e,lV)}var pV=new aa([],()=>(e,t,n)=>dV(e)?on:G(new st(t,e,n)),{expected:"StringTree",toCodecStringTree:()=>{}}),VI=new Dt(pV,al());var S1="~effect/collections/MutableHashMap";var mV={[S1]:S1,[Symbol.iterator](){return this.backing[Symbol.iterator]()},toString(){return`MutableHashMap(${X(Array.from(this))})`},toJSON(){return{_id:"MutableHashMap",values:hn(Array.from(this))}},[at](){return this.toJSON()},pipe(){return ie(this,arguments)}},cc=()=>{let e=Object.create(mV);return e.backing=new Map,e.buckets=new Map,e};var As=d(2,(e,t)=>{if(e.backing.has(t))return N(e.backing.get(t));if(JI(t))return U();let n=Pp.get(e);if(n!==void 0)return e.backing.has(n)?N(e.backing.get(n)):U();let r=ce(t),o=e.buckets.get(r);return o===void 0?U():hV(e,o,t)}),Pp=new WeakMap,JI=e=>typeof e!="object"&&typeof e!="function";var hV=(e,t,n)=>{for(let r=0,o=t.length;r<o;r++)if(ae(n,t[r])){let s=t[r];return Pp.set(n,s),N(e.backing.get(s))}return U()},E1=d(2,(e,t)=>Te(As(e,t))),uc=d(3,(e,t,n)=>{if(e.backing.has(t)||JI(t))return e.backing.set(t,n),e;let r=Pp.get(e);if(r!==void 0&&e.backing.has(r))return e.backing.set(r,n),e;let o=ce(t),s=e.buckets.get(o);return s===void 0?(e.buckets.set(o,[t]),e.backing.set(t,n),e):(r=gV(s,t),r===void 0&&(s.push(t),r=t),e.backing.set(r,n),e)}),gV=(e,t)=>{for(let n=0,r=e.length;n<r;n++)if(ae(t,e[n]))return Pp.set(t,e[n]),e[n]};var ku=d(2,(e,t)=>{if(JI(t))return e.backing.delete(t),e;let n=Pp.get(e)??t,r=ce(n),o=e.buckets.get(r);if(o===void 0)return e;for(let s=0,i=o.length;s<i;s++){let a=o[s];if(a===n||ae(n,a)){e.backing.delete(a),o.splice(s,1);break}}return o.length===0&&e.buckets.delete(r),e}),Zx=e=>(e.backing.clear(),e.buckets.clear(),e),b1=e=>e.backing.size;var w1="~effect/collections/Chunk";function EV(e,t,n,r,o){for(let s=t;s<Math.min(e.length,t+o);s++)n[r+s-t]=e[s];return n}var I1=[],ZI=e=>un((t,n)=>t.length===n.length&&Fp(t).every((r,o)=>e(r,Up(n,o)))),bV=ZI(ae),wV={[w1]:{_A:e=>e},toString(){return`Chunk(${X(Fp(this))})`},toJSON(){return{_id:"Chunk",values:hn(Fp(this))}},[at](){return this.toJSON()},[_e](e){return xl(e)&&bV(this,e)},[Re](){return Aa(Fp(this))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return I1[Symbol.iterator]();default:return Fp(this)[Symbol.iterator]()}},pipe(){return ie(this,arguments)}},QI=e=>{let t=Object.create(wV);switch(t.backing=e,e._tag){case"IEmpty":{t.length=0,t.depth=0,t.left=t,t.right=t;break}case"IConcat":{t.length=e.left.length+e.right.length,t.depth=1+Math.max(e.left.depth,e.right.depth),t.left=e.left,t.right=e.right;break}case"IArray":{t.length=e.array.length,t.depth=0,t.left=la,t.right=la;break}case"ISingleton":{t.length=1,t.depth=0,t.left=la,t.right=la;break}case"ISlice":{t.length=e.length,t.depth=e.chunk.depth+1,t.left=la,t.right=la;break}}return t},xl=e=>B(e,w1),la=QI({_tag:"IEmpty"}),IV=()=>la;var vV=e=>QI({_tag:"ISingleton",a:e}),Yx=e=>xl(e)?e:kV(ht(e)),GI=(e,t,n)=>{switch(e.backing._tag){case"IArray":{EV(e.backing.array,0,t,n,e.length);break}case"IConcat":{GI(e.left,t,n),GI(e.right,t,n+e.left.length);break}case"ISingleton":{t[n]=e.backing.a;break}case"ISlice":{let r=0,o=n;for(;r<e.length;)t[o]=Up(e,r),r+=1,o+=1;break}}};var TV=e=>{switch(e.backing._tag){case"IEmpty":return I1;case"IArray":return e.backing.array;default:{let t=new Array(e.length);return GI(e,t,0),e.backing={_tag:"IArray",array:t},e.left=la,e.right=la,e.depth=0,t}}},Fp=TV;var kV=e=>e.length===0?IV():e.length===1?vV(e[0]):QI({_tag:"IArray",array:e});var Up=d(2,(e,t)=>{let n=Math.floor(t);switch(e.backing._tag){case"IEmpty":throw new Error(`Index out of bounds: ${n}`);case"ISingleton":{if(t!==0)throw new Error(`Index out of bounds: ${n}`);return e.backing.a}case"IArray":{if(n>=e.length||n<0)throw new Error(`Index out of bounds: ${n}`);return e.backing.array[n]}case"IConcat":return n<e.left.length?Up(e.left,n):Up(e.right,n-e.left.length);case"ISlice":return Up(e.backing.chunk,n+e.backing.offset)}});var v1=e=>e.length;var T1=Yb;var yl=PR,Xx=FR,yo=pg;var xi=Ji,da=SM;var fr=Mg,k1=kM;var C1="~effect/MutableRef",CV={[C1]:C1,...vn,toJSON(){return{_id:"MutableRef",current:hn(this.current)}}},Np=e=>{let t=Object.create(CV);return t.current=e,t};var A1=e=>e.current;var XI=d(2,(e,t)=>(e.current=t,e));var Rr=Symbol.for("effect/MutableList/Empty"),ha=()=>({head:void 0,tail:void 0,length:0}),O1=()=>({array:[],mutable:!0,offset:0,next:void 0}),Yr=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=O1(),e.tail=e.tail.next):e.head=e.tail=O1(),e.tail.array.push(t),e.length++},tv=(e,t)=>{e.head={array:[t],mutable:!0,offset:0,next:e.head},e.tail||(e.tail=e.head),e.length++};var ey=(e,t)=>ty(e,ht(t),!Array.isArray(t)),ty=(e,t,n=!1)=>{if(t.length===0)return 0;let r={array:t,mutable:n,offset:0,next:void 0};return e.head?e.tail=e.tail.next=r:e.head=e.tail=r,e.length+=t.length,t.length},ma=e=>{e.head=e.tail=void 0,e.length=0},Cu=(e,t)=>{if(t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let s=e.head.array;return ma(e),s}let n=new Array(t),r=0,o=e.head;for(;o;){for(;o.offset<o.array.length;)if(n[r++]=o.array[o.offset],o.mutable&&(o.array[o.offset]=void 0),o.offset++,r===t)return e.head=o,e.length-=t,e.length===0&&ma(e),n;o=o.next}return ma(e),n},Lp=(e,t)=>{if(t<=0||!e.head)return;if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){ma(e);return}let n=0,r=e.head;for(;r;){let o=r.array.length-r.offset;if(n+o>t){r.offset+=t-n,e.head=r,e.length-=t;return}n+=o,r=r.next}ma(e)},Au=e=>Cu(e,e.length),Os=e=>{if(!e.head)return Rr;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:ma(e)),t},R1=(e,t)=>{if(t<=0)return[];let n=Math.min(t,e.length),r=new Array(n),o=0,s=e.head;for(;s;){for(let i=s.offset;i<s.array.length;i++)if(r[o++]=s.array[i],o===n)return r;s=s.next}return r};var nv=(e,t)=>{let n=[],r=e.head;for(;r;){for(let o=r.offset;o<r.array.length;o++)t(r.array[o],o)&&n.push(r.array[o]);r=r.next}if(n.length===0){ma(e);return}e.head=e.tail={array:n,mutable:!0,offset:0,next:void 0},e.length=n.length},_1=(e,t)=>nv(e,n=>n!==t);var AV="~effect/PubSub",OV="~effect/PubSub/Subscription",sy=e=>se(()=>UV(e.atomicPubSub(),new Map,$r(),fr(!1),Np(!1),e.strategy())),iy=e=>sy({atomicPubSub:()=>hv(e),strategy:()=>new pv}),ay=e=>sy({atomicPubSub:()=>hv(e),strategy:()=>new ry}),cy=e=>sy({atomicPubSub:()=>hv(e),strategy:()=>new mv}),Bp=e=>sy({atomicPubSub:()=>RV(e),strategy:()=>new ry}),hv=e=>{let t=typeof e=="number"?{capacity:e}:e;DV(t.capacity);let n=t.replay&&t.replay>0?new oy(Math.ceil(t.replay)):void 0;return t.capacity===1?new av(n):LP(t.capacity)===t.capacity?new sv(t.capacity,n):new rv(t.capacity,n)},RV=e=>{let t=e?.replay;return new uv(t&&t>0?new oy(Math.ceil(t)):void 0)};var jp=e=>fi(xn(t=>(XI(e.shutdownFlag,!0),Je(e.scope,Lg(t.id)).pipe(Dn(e.strategy.shutdown),ax(e.shutdownHook.open),Lo))));var El=d(2,(e,t)=>K(()=>e.shutdownFlag.current?v(!1):e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),v(!0)):e.strategy.handleSurplus(e.pubsub,e.subscribers,[t],e.shutdownFlag))),M1=d(2,(e,t)=>e.shutdownFlag.current?!1:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),!0):!1),P1=d(2,(e,t)=>K(()=>{if(e.shutdownFlag.current)return v(!1);let n=e.pubsub.publishAll(t);return e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),n.length===0?v(!0):e.strategy.handleSurplus(e.pubsub,e.subscribers,n,e.shutdownFlag)})),$p=e=>fi(cr(t=>{let n=qe(t,It),r=Cn(e.scope),o=FV(e.pubsub,e.subscribers,e.strategy);return _t(r,_V(o)).pipe(Dn(Fo(n,s=>Je(r,s))),zt(o))})),_V=e=>fi(xn(t=>(XI(e.shutdownFlag,!0),Do(Au(e.pollers),n=>j0(n,t.id),{discard:!0,concurrency:"unbounded"}).pipe(Mt(()=>se(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.replayWindow.close(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),ax(e.shutdownHook.open),Lo)))),uy=e=>K(()=>{if(e.shutdownFlag.current)return ho;if(e.replayWindow.remaining>0){let n=e.replayWindow.take();return v(n)}let t=e.pollers.length===0?e.subscription.poll():Rr;return t===Rr?U1(e):(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),v(t))}),F1=e=>K(function t(n){if(e.shutdownFlag.current)return ho;let r=e.pollers.length===0?e.subscription.pollUpTo(Number.POSITIVE_INFINITY):[];return n&&(r=n.concat(r)),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),e.replayWindow.remaining>0?v(e.replayWindow.takeAll().concat(r)):Vn(r)?v(r):A(U1(e),o=>t([o]))}),U1=e=>{let t=iu(),n=e.subscribers.get(e.subscription);return n||(n=new Set,e.subscribers.set(e.subscription,n)),n.add(e.pollers),Yr(e.pollers,t),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),ui(au(t),()=>(_1(e.pollers,t),H))};var Gt=Symbol.for("effect/PubSub/AbsentValue"),MV=(e,t,n)=>{e.has(t)||e.set(t,new Set),e.get(t).add(n)},PV=(e,t,n)=>{if(!e.has(t))return;let r=e.get(t);r.delete(n),r.size===0&&e.delete(t)},FV=(e,t,n)=>new lv(e,t,e.subscribe(),ha(),fr(!1),Np(!1),n,e.replayWindow()),rv=class{array;replayIndices;publisherIndex=0;subscribers;subscriberCount=0;subscribersIndex=0;capacity;replayBuffer;constructor(t,n){this.capacity=t,this.replayBuffer=n,this.array=Array.from({length:t}),this.replayIndices=n?Array.from({length:t}):[],this.subscribers=Array.from({length:t})}replayWindow(){return this.replayBuffer?new Sl(this.replayBuffer):fy}isEmpty(){return this.publisherIndex===this.subscribersIndex}isFull(){return this.publisherIndex===this.subscribersIndex+this.capacity}size(){return this.publisherIndex-this.subscribersIndex}publish(t){if(this.isFull())return!1;let n=this.replayBuffer?.offer(t);if(this.subscriberCount!==0){let r=this.publisherIndex%this.capacity;this.array[r]=t,n!==void 0&&(this.replayIndices[r]=n),this.subscribers[r]=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let n=ht(t),r=n.length,o=this.publisherIndex-this.subscribersIndex,s=this.capacity-o,i=Math.min(r,s);if(i===0)return n;let a=0,c=this.publisherIndex+i;for(;this.publisherIndex!==c;){let u=n[a++],f=this.publisherIndex%this.capacity;this.array[f]=u;let l=this.replayBuffer?.offer(u);l!==void 0&&(this.replayIndices[f]=l),this.subscribers[f]=this.subscriberCount,this.publisherIndex+=1}return n.slice(a)}slide(){if(this.subscribersIndex!==this.publisherIndex){let t=this.subscribersIndex%this.capacity,n=this.array[t];this.array[t]=Gt,this.subscribers[t]=0,this.subscribersIndex+=1,this.replayBuffer?.slide(n,this.replayIndices[t])}}subscribe(){return this.subscriberCount+=1,new ov(this,this.publisherIndex,!1)}},ov=class{self;subscriberIndex;unsubscribed;constructor(t,n,r){this.self=t,this.subscriberIndex=n,this.unsubscribed=r}isEmpty(){return this.unsubscribed||this.self.publisherIndex===this.subscriberIndex||this.self.publisherIndex===this.self.subscribersIndex}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Rr;if(this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex),this.subscriberIndex!==this.self.publisherIndex){let t=this.subscriberIndex%this.self.capacity,n=this.self.array[t];return this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=Gt,this.self.subscribersIndex+=1),this.subscriberIndex+=1,n}return Rr}pollUpTo(t){if(this.unsubscribed)return[];this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);let n=this.self.publisherIndex-this.subscriberIndex,r=Math.min(t,n);if(r<=0)return[];let o=[],s=this.subscriberIndex+r;for(;this.subscriberIndex!==s;){let i=this.subscriberIndex%this.self.capacity,a=this.self.array[i];this.self.subscribers[i]-=1,this.self.subscribers[i]===0&&(this.self.array[i]=Gt,this.self.subscribersIndex+=1),o.push(a),this.subscriberIndex+=1}return o}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);this.subscriberIndex!==this.self.publisherIndex;){let t=this.subscriberIndex%this.self.capacity;this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=Gt,this.self.subscribersIndex+=1),this.subscriberIndex+=1}}},sv=class{array;replayIndices;mask;publisherIndex=0;subscribers;subscriberCount=0;subscribersIndex=0;capacity;replayBuffer;constructor(t,n){this.capacity=t,this.replayBuffer=n,this.array=Array.from({length:t}),this.replayIndices=n?Array.from({length:t}):[],this.mask=t-1,this.subscribers=Array.from({length:t})}replayWindow(){return this.replayBuffer?new Sl(this.replayBuffer):fy}isEmpty(){return this.publisherIndex===this.subscribersIndex}isFull(){return this.publisherIndex===this.subscribersIndex+this.capacity}size(){return this.publisherIndex-this.subscribersIndex}publish(t){if(this.isFull())return!1;let n=this.replayBuffer?.offer(t);if(this.subscriberCount!==0){let r=this.publisherIndex&this.mask;this.array[r]=t,n!==void 0&&(this.replayIndices[r]=n),this.subscribers[r]=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let n=ht(t),r=n.length,o=this.publisherIndex-this.subscribersIndex,s=this.capacity-o,i=Math.min(r,s);if(i===0)return n;let a=0,c=this.publisherIndex+i;for(;this.publisherIndex!==c;){let u=n[a++],f=this.publisherIndex&this.mask;this.array[f]=u;let l=this.replayBuffer?.offer(u);l!==void 0&&(this.replayIndices[f]=l),this.subscribers[f]=this.subscriberCount,this.publisherIndex+=1}return n.slice(a)}slide(){if(this.subscribersIndex!==this.publisherIndex){let t=this.subscribersIndex&this.mask,n=this.array[t];this.array[t]=Gt,this.subscribers[t]=0,this.subscribersIndex+=1,this.replayBuffer?.slide(n,this.replayIndices[t])}}subscribe(){return this.subscriberCount+=1,new iv(this,this.publisherIndex,!1)}},iv=class{self;subscriberIndex;unsubscribed;constructor(t,n,r){this.self=t,this.subscriberIndex=n,this.unsubscribed=r}isEmpty(){return this.unsubscribed||this.self.publisherIndex===this.subscriberIndex||this.self.publisherIndex===this.self.subscribersIndex}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Rr;if(this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex),this.subscriberIndex!==this.self.publisherIndex){let t=this.subscriberIndex&this.self.mask,n=this.self.array[t];return this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=Gt,this.self.subscribersIndex+=1),this.subscriberIndex+=1,n}return Rr}pollUpTo(t){if(this.unsubscribed)return[];this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);let n=this.self.publisherIndex-this.subscriberIndex,r=Math.min(t,n);if(r<=0)return[];let o=[],s=this.subscriberIndex+r;for(;this.subscriberIndex!==s;){let i=this.subscriberIndex&this.self.mask,a=this.self.array[i];this.self.subscribers[i]-=1,this.self.subscribers[i]===0&&(this.self.array[i]=Gt,this.self.subscribersIndex+=1),o.push(a),this.subscriberIndex+=1}return o}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);this.subscriberIndex!==this.self.publisherIndex;){let t=this.subscriberIndex&this.self.mask;this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=Gt,this.self.subscribersIndex+=1),this.subscriberIndex+=1}}},av=class{publisherIndex=0;subscriberCount=0;subscribers=0;value=Gt;replayIndex=0;capacity=1;replayBuffer;constructor(t){this.replayBuffer=t}replayWindow(){return this.replayBuffer?new Sl(this.replayBuffer):fy}pipe(){return ie(this,arguments)}isEmpty(){return this.subscribers===0}isFull(){return!this.isEmpty()}size(){return this.isEmpty()?0:1}publish(t){if(this.isFull())return!1;let n=this.replayBuffer?.offer(t);return this.subscriberCount!==0&&(this.value=t,n!==void 0&&(this.replayIndex=n),this.subscribers=this.subscriberCount,this.publisherIndex+=1),!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let n=ht(t);return n.length===0?n:this.publish(n[0])?n.slice(1):n}slide(){if(this.isFull()){let t=this.value;this.subscribers=0,this.value=Gt,this.replayBuffer?.slide(t,this.replayIndex)}}subscribe(){return this.subscriberCount+=1,new cv(this,this.publisherIndex,!1)}},cv=class{self;subscriberIndex;unsubscribed;constructor(t,n,r){this.self=t,this.subscriberIndex=n,this.unsubscribed=r}isEmpty(){return this.unsubscribed||this.self.subscribers===0||this.subscriberIndex===this.self.publisherIndex}size(){return this.isEmpty()?0:1}poll(){if(this.isEmpty())return Rr;let t=this.self.value;return this.self.subscribers-=1,this.self.subscribers===0&&(this.self.value=Gt),this.subscriberIndex+=1,t}pollUpTo(t){if(this.isEmpty()||t<1)return[];let n=this.self.value;return this.self.subscribers-=1,this.self.subscribers===0&&(this.self.value=Gt),this.subscriberIndex+=1,[n]}unsubscribe(){this.unsubscribed||(this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex!==this.self.publisherIndex&&(this.self.subscribers-=1,this.self.subscribers===0&&(this.self.value=Gt)))}},uv=class{publisherHead={value:Gt,replayIndex:void 0,subscribers:0,next:null};publisherTail=this.publisherHead;publisherIndex=0;subscribersIndex=0;capacity=Number.MAX_SAFE_INTEGER;replayBuffer;constructor(t){this.replayBuffer=t}replayWindow(){return this.replayBuffer?new Sl(this.replayBuffer):fy}isEmpty(){return this.publisherHead===this.publisherTail}isFull(){return!1}size(){return this.publisherIndex-this.subscribersIndex}publish(t){let n=this.replayBuffer?.offer(t),r=this.publisherTail.subscribers;if(r!==0){let o={value:t,replayIndex:n,subscribers:r,next:null};this.publisherTail.next=o,this.publisherTail=this.publisherTail.next,this.publisherIndex+=1}return!0}publishAll(t){if(this.publisherTail.subscribers!==0)for(let n of t)this.publish(n);else this.replayBuffer&&this.replayBuffer.offerAll(t);return[]}slide(){if(this.publisherHead!==this.publisherTail){let t=this.publisherHead.next,n=t.value;this.publisherHead=this.publisherHead.next,this.publisherHead.value=Gt,this.subscribersIndex+=1,this.replayBuffer?.slide(n,t.replayIndex)}}subscribe(){return this.publisherTail.subscribers+=1,new fv(this,this.publisherTail,this.publisherIndex,!1)}},fv=class{self;subscriberHead;subscriberIndex;unsubscribed;constructor(t,n,r,o){this.self=t,this.subscriberHead=n,this.subscriberIndex=r,this.unsubscribed=o}isEmpty(){if(this.unsubscribed)return!0;let t=!0,n=!0;for(;n;)this.subscriberHead===this.self.publisherTail?n=!1:this.subscriberHead.next.value!==Gt?(t=!1,n=!1):(this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1);return t}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Rr;let t=!0,n=Rr;for(;t;)if(this.subscriberHead===this.self.publisherTail)t=!1;else{let r=this.subscriberHead.next.value;r!==Gt&&(n=r,this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=Gt,this.self.subscribersIndex+=1),t=!1),this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1}return n}pollUpTo(t){let n=[],r=0;for(;r!==t;){let o=this.poll();o===Rr?r=t:(n.push(o),r+=1)}return n}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.publisherTail.subscribers-=1;this.subscriberHead!==this.self.publisherTail;)this.subscriberHead.next.value!==Gt&&(this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=Gt,this.self.subscribersIndex+=1)),this.subscriberHead=this.subscriberHead.next}},lv=class{[OV]={_A:L};pubsub;subscribers;subscription;pollers;shutdownHook;shutdownFlag;strategy;replayWindow;constructor(t,n,r,o,s,i,a,c){this.pubsub=t,this.subscribers=n,this.subscription=r,this.pollers=o,this.shutdownHook=s,this.shutdownFlag=i,this.strategy=a,this.replayWindow=c}pipe(){return ie(this,arguments)}},dv=class{[AV]={_A:L};pubsub;subscribers;scope;shutdownHook;shutdownFlag;strategy;constructor(t,n,r,o,s,i){this.pubsub=t,this.subscribers=n,this.scope=r,this.shutdownHook=o,this.shutdownFlag=s,this.strategy=i}pipe(){return ie(this,arguments)}},UV=(e,t,n,r,o,s)=>new dv(e,t,n,r,o,s),DV=e=>{if(e<=0)throw new Error(`Cannot construct PubSub with capacity of ${e}`)},pv=class{publishers=ha();get shutdown(){return xn(t=>Do(Au(this.publishers),([n,r,o])=>o?j0(r,t.id):H,{concurrency:"unbounded",discard:!0}))}handleSurplus(t,n,r,o){return K(()=>{let s=iu();return this.offerUnsafe(r,s),this.onPubSubEmptySpaceUnsafe(t,n),this.completeSubscribersUnsafe(t,n),(A1(o)?ho:au(s)).pipe(ui(()=>(this.removeUnsafe(s),H)))})}onPubSubEmptySpaceUnsafe(t,n){let r=!0;for(;r&&!t.isFull();){let o=Os(this.publishers);if(o===Rr)r=!1;else{let[s,i]=o,a=t.publish(s);a&&o[2]?qf(i,kn(!0)):a||tv(this.publishers,o),this.completeSubscribersUnsafe(t,n)}}}completePollersUnsafe(t,n,r,o){return gv(this,t,n,r,o)}completeSubscribersUnsafe(t,n){return xv(this,t,n)}offerUnsafe(t,n){let r=t[Symbol.iterator](),o=r.next();if(!o.done)for(;;){let s=o.value;if(o=r.next(),o.done){Yr(this.publishers,[s,n,!0]);break}Yr(this.publishers,[s,n,!1])}}removeUnsafe(t){nv(this.publishers,([n,r])=>r!==t)}},ry=class{get shutdown(){return H}handleSurplus(t,n,r,o){return v(!1)}onPubSubEmptySpaceUnsafe(t,n){}completePollersUnsafe(t,n,r,o){return gv(this,t,n,r,o)}completeSubscribersUnsafe(t,n){return xv(this,t,n)}},mv=class{get shutdown(){return H}handleSurplus(t,n,r,o){return se(()=>(this.slidingPublishUnsafe(t,r),this.completeSubscribersUnsafe(t,n),!0))}onPubSubEmptySpaceUnsafe(t,n){}completePollersUnsafe(t,n,r,o){return gv(this,t,n,r,o)}completeSubscribersUnsafe(t,n){return xv(this,t,n)}slidingPublishUnsafe(t,n){let r=n[Symbol.iterator](),o=r.next();if(!o.done&&t.capacity>0){let s=o.value,i=!0;for(;i;){t.slide();let a=t.publish(s);a&&(o=r.next())&&!o.done?s=o.value:a&&(i=!1)}}}},gv=(e,t,n,r,o)=>{let s=!0;for(;s&&!r.isEmpty();){let i=Os(o);if(i===Rr)PV(n,r,o),o.length===0?s=!1:MV(n,r,o);else{let a=r.poll();a===Rr?tv(o,i):(qf(i,kn(a)),e.onPubSubEmptySpaceUnsafe(t,n))}}},xv=(e,t,n)=>{for(let[r,o]of n)for(let s of o)e.completePollersUnsafe(t,n,r,s)},oy=class{capacity;head={value:Gt,index:0,next:null};tail=this.head;slideValues=[];size=0;index=0;publisherIndex=0;constructor(t){this.capacity=t}slide(t,n){this.slideValues[this.index%this.capacity]={value:t,index:n},this.index++}offer(t){let n=this.publisherIndex++;return this.tail.value=t,this.tail.index=n,this.tail.next={value:Gt,index:0,next:null},this.tail=this.tail.next,this.size===this.capacity?this.head=this.head.next:this.size+=1,n}offerAll(t){for(let n of t)this.offer(n)}},Sl=class{buffer;values;index=0;remaining;slideIndex;newestIndex=-1;constructor(t){this.buffer=t,this.remaining=t.size,this.slideIndex=t.index,this.values=new Array(this.remaining);let n=t.head;for(let r=0;r<this.remaining;r++)this.values[r]=n.value,this.newestIndex=n.index,n=n.next}close(){this.values.length=0,this.remaining=0}sync(){let t=this.buffer.index-this.slideIndex;if(t===0||this.remaining===0)return;let n=Math.min(t,this.buffer.capacity),r=this.buffer.index-n;for(let o=0;o<n;o++){let s=this.buffer.slideValues[(r+o)%this.buffer.capacity];s.index>this.newestIndex&&(this.index=(this.index+1)%this.values.length,this.values[(this.index+this.remaining-1)%this.values.length]=s.value,this.newestIndex=s.index)}this.slideIndex=this.buffer.index}take(){if(this.remaining===0)return;this.sync();let t=this.values[this.index];return this.values[this.index]=Gt,this.index=(this.index+1)%this.values.length,this.remaining--,this.remaining===0&&this.close(),t}takeN(t){let n=Math.min(t,this.remaining),r=new Array(n);for(let o=0;o<n;o++)r[o]=this.take();return r}takeAll(){return this.takeN(this.remaining)}},fy={remaining:0,take:()=>{},takeN:()=>[],takeAll:()=>[],close:()=>{}};var NV="~effect/Queue",LV="~effect/Queue/Enqueue",BV="~effect/Queue/Dequeue";var yv={_A:L,_E:L},jV={[NV]:yv,[LV]:yv,[BV]:yv,...vn,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:qV(this)}}},Xr=e=>de(t=>{let n=Object.create(jV);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??Number.POSITIVE_INFINITY,n.strategy=e?.strategy??"suspend",n.messages=ha(),n.scheduleRunning=!1,n.state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set},J(n)}),Ou=e=>Xr({capacity:e});var qp=()=>Xr(),Xn=(e,t)=>me(()=>{if(e.state._tag!=="Open")return py;if(e.messages.length>=e.capacity)switch(e.strategy){case"dropping":return py;case"suspend":return e.capacity<=0&&e.state.takers.size>0?(Yr(e.messages,t),Sv(e),dy):KV(e,t);case"sliding":return Os(e.messages),Yr(e.messages,t),dy}return Yr(e.messages,t),my(e),dy}),wl=(e,t)=>e.state._tag!=="Open"?!1:e.messages.length>=e.capacity?e.strategy==="sliding"?(Os(e.messages),Yr(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0?(Yr(e.messages,t),Sv(e),!0):!1:(Yr(e.messages,t),my(e),!0),ga=(e,t)=>me(()=>{if(e.state._tag!=="Open")return J(ht(t));let n=hy(e,t);return n.length===0?rt([]):e.strategy==="dropping"?J(n):VV(e,n)}),hy=(e,t)=>{if(e.state._tag!=="Open")return ht(t);if(e.capacity===Number.POSITIVE_INFINITY||e.strategy==="sliding")return ey(e.messages,t),e.strategy==="sliding"&&Cu(e.messages,e.messages.length-e.capacity),my(e),[];let n=e.capacity<=0?e.state.takers.size:e.capacity-e.messages.length;if(n===0)return ht(t);let r=[],o=0;for(let s of t)o<n?Yr(e.messages,s):r.push(s),o++;return my(e),r};var Zt=d(2,(e,t)=>he(()=>yi(e,t))),yi=(e,t)=>{if(e.state._tag!=="Open")return!1;let n=Rn(t),r=c_(n,zV);return e.state.offers.size===0&&e.messages.length===0?(Ev(e,r),!0):(e.state={...e.state,_tag:"Closing",exit:r},!0)},zp=e=>Zt(e,df(zc())),D1=e=>yi(e,df(zc()));var Rs=e=>he(()=>{if(e.state._tag==="Done")return!0;ma(e.messages);let t=e.state.offers;if(Ev(e,e.state._tag==="Open"?HV:e.state.exit),t.size>0){for(let n of t)n._tag==="Single"?n.resume(py):n.resume(rt(n.remaining.slice(n.offset)));t.clear()}return!0});var Il=e=>N1(e,1,Number.POSITIVE_INFINITY);var N1=(e,t,n)=>me(()=>WV(e,t,n)??Br(L1(e),N1(e,1,n))),zo=e=>me(()=>$V(e)??Br(L1(e),zo(e)));var $V=e=>{if(e.state._tag==="Done")return e.state.exit;if(e.messages.length>0){let t=Os(e.messages);return bl(e),rt(t)}else if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,bl(e),e.capacity=0;let t=Os(e.messages);return bl(e),rt(t)}};var qV=e=>e.state._tag==="Done"?0:e.messages.length;var py=rt(!1),dy=rt(!0),zV=io(zc()),HV=gg(),Sv=e=>{if(e.scheduleRunning=!1,!(e.state._tag==="Done"||e.state.takers.size===0)){for(let t of e.state.takers)if(e.state.takers.delete(t),t(Ir),e.messages.length===0)break}},my=e=>{e.scheduleRunning||e.state._tag==="Done"||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>Sv(e),0))},WV=(e,t,n)=>{if(e.state._tag==="Done")return e.state.exit;if(n<=0||t<=0)return rt([]);if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,bl(e),e.capacity=0;let r=[Os(e.messages)];return bl(e),rt(r)}if(t=Math.min(t,e.capacity||1),t<=e.messages.length){let r=Cu(e.messages,n);return bl(e),rt(r)}},KV=(e,t)=>Bt(n=>{if(e.state._tag!=="Open")return n(py);let r={_tag:"Single",message:t,resume:n};return e.state.offers.add(r),he(()=>{e.state._tag==="Open"&&e.state.offers.delete(r)})}),VV=(e,t)=>Bt(n=>{if(e.state._tag!=="Open")return n(rt(t));let r={_tag:"Array",remaining:t,offset:0,resume:n};return e.state.offers.add(r),he(()=>{e.state._tag==="Open"&&e.state.offers.delete(r)})}),bl=e=>{if(e.state._tag==="Done")return Uo(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag==="Closing"&&e.messages.length===0?(Ev(e,e.state.exit),Uo(e.state.exit.cause)):!1;let t=e.capacity-e.messages.length;for(let n of e.state.offers){if(t===0)break;if(n._tag==="Single")Yr(e.messages,n.message),t--,n.resume(dy),e.state.offers.delete(n);else{for(;n.offset<n.remaining.length;n.offset++){if(t===0)return!1;Yr(e.messages,n.remaining[n.offset]),t--}n.resume(rt([])),e.state.offers.delete(n)}}return!1},L1=e=>Bt(t=>e.state._tag==="Done"?t(e.state.exit):(e.state.takers.add(t),he(()=>{e.state._tag!=="Done"&&e.state.takers.delete(t)})));var Ev=(e,t)=>{if(e.state._tag==="Done")return;let n=e.state;e.state={_tag:"Done",exit:t};for(let r of n.takers)r(t);n.takers.clear();for(let r of n.awaiters)r(t);n.awaiters.clear()};var xa=e=>new bv(e),B1=(e,t,n)=>Bt(r=>{if(e.free>=t)return r(n);let o=()=>{e.free<t||(e.waiters.delete(o),r(n))};return e.waiters.add(o),he(()=>{e.waiters.delete(o)})}),bv=class{waiters=new Set;taken=0;permits;constructor(t){this.permits=t}get free(){return this.permits-this.taken}take(t){let n=me(()=>this.free<t?B1(this,t,n):(this.taken+=t,J(t)));return n}takeIfAvailable(t){return me(()=>this.free<t?J(!1):(this.taken+=t,J(!0)))}releaseUnsafe(t,n){return this.taken-=n,this.waiters.size>0&&t.currentDispatcher.scheduleTask(()=>{for(let r of this.waiters){if(this.free<=0)break;r()}},0),this.free}resize(t){return de(n=>(this.permits=t,this.free<0?we:(this.releaseUnsafe(n,0),we)))}release(t){return de(n=>J(this.releaseUnsafe(n,t)))}get releaseAll(){return de(t=>J(this.releaseUnsafe(t,this.taken)))}withPermits(t){return n=>jr(r=>{let o=me(()=>{if(this.free<t){let s=B1(this,t,we);return ne(r(s),()=>o)}return this.taken+=t,ls(r(n),()=>{this.releaseUnsafe(Ji(),t)},!0)});return o})}withPermit=this.withPermits(1);withPermitsIfAvailable(t){return n=>jr(r=>this.free<t?Xc:(this.taken+=t,ls(r(Af(n)),()=>{this.releaseUnsafe(Ji(),t)},!0)))}};var wv=e=>ms(e)?Ft(e)?pe(e.value):e:v(e);var z1="~effect/Channel",er=e=>B(e,z1),JV={[z1]:{_Env:L,_InErr:L,_InElem:L,_OutErr:L,_OutElem:L},pipe(){return ie(this,arguments)}},Ge=e=>{let t=Object.create(JV);return t.transform=(n,r)=>ft(e(n,r),o=>v(ct(o))),t},Ms=(e,t)=>Ge((n,r)=>A(Pe(e)(n,r),o=>t(o,r))),$n=e=>Ge((t,n)=>e),Ps=e=>Ge(ye(function*(t,n){let r=Cn(n),o=i=>Je(r,aw(i)),s=yield*mo(e(t,n,r),o);return mo(s,o)})),Pe=e=>e.transform,Hp=4096,GV=(e,t,n)=>Xr({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(Mt(r=>_t(e,Rs(r))),Mt(r=>Ut(Po(t(r),e),e)));var H1=(e,t)=>Ge((n,r)=>Y(GV(r,e,t),Il)),xy=e=>Ge((t,n)=>K(()=>Pe(e())(t,n))),ZV=(e,t,n)=>Ps(ye(function*(r,o,s){let i=U();yield*Fo(s,c=>Te(i)?n(i.value,c):H);let a=yield*fi(e);return i=N(a),yield*Pe(t(a))(r,o)}));var Iv=e=>$n(se(()=>{let t=0;return K(()=>t>=e.length?pe():v(e[t++]))}));var vv=(e,t=Hp)=>$n(se(()=>{let n=e(),r=U();return K(()=>{if(r._tag==="Some")return pe(r.value);let o=[];for(;o.length<t;){let s=n.next();if(s.done){if(o.length===0)return pe(s.value);r=N(s.value);break}o.push(s.value)}return v(o)})}));var W1=(e,t=Hp)=>vv(()=>e[Symbol.iterator](),t),yy=e=>Sy(v(e)),QV=e=>$n(v(pe(e)));var K1=e=>Sy(se(e)),vl=$n(v(pe())),V1=$n(v(Hr)),Si=e=>$n(v(G(e))),J1=e=>$n(ox(e)),Wp=e=>$n(ct(e)),G1=e=>$n(ea(e)),Tv=e=>Wp(ZM(e)),Sy=e=>$n(se(()=>{let t=!1;return K(()=>t?pe():(t=!0,e))}));var Z1=e=>$n(A(e,()=>pe())),kv=e=>$n(v(A(e,wv)));var Q1=e=>$n(v(Il(e)));var Cv=e=>$n(v(ui(F1(e),()=>pe())));var Y1=e=>ya(Y($p(e),Cv)),X1=e=>ya(Y($p(e),t=>kv(uy(t))));var eD=e=>Ge((t,n)=>YV({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd}));var YV=e=>{let t=e.readable.getReader(),n=e.exit??Np(void 0),r=K(()=>n.current?n.current:Kr(ys({try:()=>t.read(),catch:e.onError}),{onFailure:o=>n.current??ct(o),onSuccess:({done:o,value:s})=>n.current?n.current:o?pe():v(Ne(s))}));return zt(_t(e.scope,e.releaseLockOnEnd?se(()=>t.releaseLock()):nx(()=>t.cancel().catch(bn))),r)},XV=(e,t)=>Ge(ye(function*(n,r){let o=e[Symbol.asyncIterator]();return o.return&&(yield*_t(r,nx(()=>o.return()))),A(ys({try:()=>o.next(),catch:t}),s=>s.done?pe(s.value):v(s.value))})),tD=(e,t)=>Fs(XV(e,t),Ne),Fs=d(2,(e,t)=>Ms(e,n=>se(()=>{let r=0;return Y(n,o=>t(o,r++))})));var nD=e=>e===void 0||e!=="unbounded"&&e<=1,Ey=d(e=>er(e[0]),(e,t,n)=>nD(n?.concurrency)?rD(e,t):eJ(e,t,n)),rD=(e,t)=>Ge((n,r)=>{let o=0;return Y(Pe(e)(n,r),A(s=>t(s,o++)))}),eJ=(e,t,n)=>Ps(ye(function*(r,o,s){let i=0,a=yield*Pe(e)(r,o),c=n.concurrency==="unbounded"?Number.MAX_SAFE_INTEGER:n.concurrency,u=yield*Ou(0);yield*_t(s,Rs(u));let f=Ln(yield*ar()),l=da(s);if(n.unordered){let p=xa(c),m=Qe(p.release(1)),h=Kr({onFailure:g=>A(Zt(u,g),m),onSuccess:g=>A(Xn(u,g),m)});yield*p.take(1).pipe(A(()=>a),A(g=>(l(f(h(t(g,i++)))),H)),Ht({disableYield:!0}),ft(g=>p.withPermits(c-1)(Zt(u,g))),Ut(s))}else{let p=yield*Ou(c-2);yield*_t(s,Rs(p)),yield*zo(p).pipe(xw,A(g=>Xn(u,g)),Ht({disableYield:!0}),ft(g=>Zt(u,g)),Ut(s));let m,h=g=>{g._tag!=="Success"&&(m=g.cause,yi(u,g.cause))};yield*a.pipe(A(g=>{if(m)return ct(m);let x=f(t(g,i++));return l(x),x.addObserver(h),Xn(p,yl(x))}),Ht({disableYield:!0}),ft(g=>Xn(p,jt(g)).pipe(Dn(Zt(p,g)))),Ut(s))}return zo(u)}));var oD=d(e=>er(e[0]),(e,t,n)=>nD(n?.concurrency)?tJ(e,t):nJ(e,t,n)),tJ=(e,t)=>Ge((n,r)=>Y(Pe(e)(n,r),o=>{let s,i,a=A(o,u=>(i??=Cn(r),Bn(Pe(t(u))(n,i),f=>(s=c(f),s)))),c=$t(u=>{if(s=void 0,i.state._tag==="Open"&&q_(i)===1)return a;let f=Je(i,Vt);return i=void 0,A(f,()=>a)});return K(()=>s??a)})),nJ=(e,t,n)=>e.pipe(Fs(t),Iy(n)),by=d(2,(e,t)=>Ge((n,r)=>se(()=>{let o,s=Cn(r),i=A(Pe(e)(n,s),a=>(o=$t(a,c=>Je(s,Vt).pipe(A(()=>Pe(t(c))(n,r)),A(u=>(o=u,u)))),o));return K(()=>o??i)})));var Av=d(4,(e,t,n,r)=>Ge(ye(function*(o,s){let i=yield*Pe(e)(o,s),a=yield*Pe(t)(o,s),c=n();return K(()=>{let u=r(c,i,a);return Y(u,([f,l])=>(c=l,f))})}))),sD=d(2,(e,t)=>Ge((n,r)=>se(()=>{let o,s=Cn(r),i=A(Pe(e)(n,s),a=>{let c=a.pipe(Mt(()=>(o=a,H)),$t(u=>Je(s,kn(u)).pipe(Dn(Pe(t(u))(n,r)),A(f=>(o=f,f)))));return o=c,c});return K(()=>o??i)})));var lr=e=>Ms(e,t=>{let n,r=0,o=K(function s(){if(n===void 0)return A(t,a=>{switch(a.length){case 0:return s();case 1:return v(a[0]);default:return n=a,v(a[r++])}});let i=n[r++];return r>=n.length&&(n=void 0,r=0),v(i)});return v(o)}),iD=e=>rD(e,wv),aD=e=>Ms(e,t=>v(Ht(t,{disableYield:!0}))),cD=d(2,(e,t)=>xs(typeof t=="function"?t(L):t).pipe(Y(n=>{let r=Un.defaultValue(),o=by(Cy(e,Un,se(()=>r)),s=>n(s).pipe(Y(i=>(r=i,o)),$t(()=>v(QV(s))),ya));return o}),ya)),Ov=e=>by(e,()=>Ov(e)),uD=d(2,(e,t)=>Ms(e,(n,r)=>Y(Kf(t),o=>Mt(n,o)))),fD=d(2,(e,t)=>Ge((n,r)=>Y(Pe(e)(n,r),o=>A(o,function s(i){return t(i)?v(i):A(o,s)}))));var lD=d(2,(e,t)=>Ms(e,n=>v(A(n,function r(o){let s=[];for(let i=0;i<o.length;i++)t(o[i])&&s.push(o[i]);return Ye(s)?v(s):A(n,r)})))),dD=d(2,(e,t)=>Ms(e,n=>v(A(n,function r(o){let s=[];for(let i=0;i<o.length;i++){let a=t(o[i]);Kt(a)&&s.push(a.success)}return Ye(s)?v(s):A(n,r)})))),pD=d(2,(e,t)=>Ms(e,n=>{let r=A(n,o=>Tw(o,t));return v(A(r,function o(s){return Ye(s)?v(s):A(r,o)}))})),mD=d(2,(e,t)=>Ms(e,n=>v(A(n,function r(o){return A(kw(o,t),s=>Ye(s)?v(s):A(n,r))})))),Tl=d(e=>er(e[0]),(e,t,n,r)=>Ge((o,s)=>Y(Pe(e)(o,s),i=>{let a=t(),c,u=0,f,l=Kr(i,{onFailure(m){f=m;let h=r?.onHalt&&r.onHalt(a);return h&&h.length>0?v([a,h]):ct(m)},onSuccess(m){let h=n(a,m);return fO(h)?v(h):h}});return K(function m(){if(c===void 0)return f?ct(f):A(l,([g,x])=>(a=g,x.length===0?m():x.length===1?v(x[0]):(c=x,m())));let h=c[u++];return u>=c.length&&(c=void 0,u=0),v(h)})})));var hD=d(3,(e,t,n)=>Ge((r,o)=>Y(Pe(e)(r,o),s=>{let i=t,a=!0;return K(()=>a?(a=!1,v(i)):Y(A(s,c=>n(i,c)),c=>(i=c,i)))}))),kl=d(2,(e,t)=>Ge((n,r)=>{let o=Cn(r);return Y(Pe(e)(n,o),s=>{let i=s.pipe(ft(a=>{if(Uo(a))return ct(a);let c=o;return o=Cn(r),Je(c,jt(a)).pipe(Dn(Pe(t(a))(n,o)),A(u=>(i=u,u)))}));return K(()=>i)})})),wy=d(2,(e,t)=>kl(e,n=>Z1(A(t(n),r=>ct(n))))),gD=d(3,(e,t,n)=>kl(e,r=>t(r)?n(r):Wp(r))),Rv=d(3,(e,t,n)=>kl(e,r=>{let o=t(r);return Fe(o)?Wp(o.failure):n(o.success,r)})),_s=d(2,(e,t)=>Rv(e,jf,n=>t(n)));var xD=d(2,(e,t)=>Ms(e,n=>v(op(n,r=>Hd(r)?H:Lo(t(r)))))),yD=d(e=>er(e[0]),(e,t,n,r)=>_s(e,o=>t(o)?n(o):r?r(o):Si(o))),SD=d(e=>er(e[0]),(e,t,n,r)=>_s(e,o=>{let s=t(o);return Fe(s)?r?r(s.failure):Si(s.failure):n(s.success)}));var ED=d(e=>er(e[0]),(e,t,n,r,o)=>_s(e,s=>{if(yr(s,t)&&B(s,"reason")){let i=s.reason;return yr(i,n)?r(i,s):o?o(i,s):Si(s)}return Si(s)})),bD=d(e=>er(e[0]),(e,t,n,r)=>{let o;return _s(e,s=>{if(yr(s,t)&&B(s,"reason")&&B(s.reason,"_tag")&&Qg(s.reason._tag)){let i=s.reason;return o??=new Set(Object.keys(n)),o.has(i._tag)?n[i._tag](i,s):r?r(i,s):Si(s)}return Si(s)})});var wD=d(2,(e,t)=>_s(e,n=>Si(t(n)))),ID=e=>_s(e,Tv),vD=d(e=>er(e[0]),(e,t)=>{if(!t?.log)return _s(e,()=>vl);let n=nl(t.log===!0?void 0:t.log);return _s(wy(e,r=>YM(r)?n(r):H),()=>vl)}),$1=e=>kl(e,()=>vl),TD=d(e=>er(e[0]),(e,t)=>{if(!t?.log)return $1(e);let n=nl(t.log===!0?void 0:t.log);return $1(wy(e,r=>n(r)))}),kD=d(2,(e,t)=>xy(()=>{let n,r=Un.defaultValue(),o=Cy(e,Un,se(()=>r)),s=Pv(o,()=>(n=void 0,H)),i=typeof t=="function"?t(L):t,a=_s(s,ye(function*(c){return n||(n=yield*xs(i)),r=yield*n(c),a},(c,u)=>$t(c,()=>v(Si(u))),ya));return a})),CD=d(e=>er(e[0]),(e,t,n)=>e.pipe(Fs(t),Iy({...n,concurrency:n?.concurrency??1,switch:!0}))),Iy=d(2,(e,{bufferSize:t=16,concurrency:n,switch:r=!1})=>Ps(ye(function*(o,s,i){let a=n==="unbounded"?Number.MAX_SAFE_INTEGER:Math.max(1,n),c=r?void 0:xa(a),u=yield*k1(!0),f=new Set,l=yield*Ou(t);yield*_t(i,Rs(l));let p=yield*Pe(e)(o,s);return yield*qt(function*(){for(;;){let m;c&&(f.size<a?yield*c.take(1):(m=yield*el(p),yield*Ya(c.take(1),Dn(yl(m),Hr))));let h=m===void 0?yield*p:yield*yl(m),g=Cn(i),x=yield*Pe(h)(o,g);for(;f.size>=a;){let E=sO(f);f.delete(E),f.size===0&&(yield*u.open),yield*yo(E)}let b=yield*x.pipe(Mt(()=>rp),A(E=>Xn(l,E)),Ht({disableYield:!0}),mo(ye(function*(E){let y=Wf(E);if(yield*Wr(Je(g,Fe(y)?jt(y.failure):kn(y.success.value))),!!f.has(b)&&(f.delete(b),c&&(yield*c.release(1)),f.size===0&&(yield*u.open),!Kt(y)))return yield*Zt(l,E)})),el);u.closeUnsafe(),f.add(b)}}).pipe(ft(m=>{let h=Wf(m);return Kt(h)?u.whenOpen(Zt(l,m)):Zt(l,m)}),Ut(i)),zo(l)}))),vy=d(e=>er(e[0])&&er(e[1]),(e,t,n)=>Ps(ye(function*(r,o,s){let i=n?.haltStrategy??"both",a=yield*Ou(0);yield*_t(s,Rs(a));let c=0;function u(l,p){if(c++,!Uo(p))return Zt(a,p);switch(i){case"both":return c===2?Zt(a,p):H;case"left":case"right":return l===i?Zt(a,p):H;case"either":return Zt(a,p)}}let f=(l,p,m)=>Pe(p)(r,m).pipe(A(h=>h.pipe(A(g=>Xn(a,g)),Ht)),mo(h=>Dn(Je(m,aw(h)),u(l,h))),Ut(s));return yield*f("left",e,Cn(s)),yield*f("right",t,Cn(s)),zo(a)}))),AD=d(2,(e,t)=>vy(e,Z1(t),{haltStrategy:"left"})),OD=()=>Ge((e,t)=>se(()=>{let n="",r=!1,o=U();function s(c){let u=[];function f(l){n.length===0?u.push(l):(u.push(n+l),n="")}for(let l=0;l<c.length;l++){let p=c[l];if(p.length!==0){let m=0,h=p.indexOf("\r"),g=p.indexOf(`
|
|
22
|
+
${JO(e.cause,`${t} `)}
|
|
23
|
+
${t}}`),r},ug="~effect/Fiber",a4={_A:B,_E:B},c4={id:0},ea=()=>globalThis[mf],fg=class{constructor(t,n=!0){this[ug]=a4,this.setContext(t),this.id=++c4.id,this.currentOpCount=0,this.interruptible=n,this._stack=[],this._observers=[],this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this.runtimeMetrics?.recordFiberStart(this.context)}[ug];id;interruptible;currentOpCount;_stack;_observers;_exit;_children;_interruptedCause;_yielded;_running;_deferredInterrupt;context;currentScheduler;currentTracerContext;currentSpan;currentLogLevel;minimumLogLevel;currentStackFrame;runtimeMetrics;maxOpsBeforeYield;currentPreventYield;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.currentScheduler.makeDispatcher()}getRef(t){return $e(this.context,t)}addObserver(t){return this._exit?(t(this._exit),En):(this._observers.push(t),()=>{if(this._exit)return;let n=this._observers.indexOf(t);n>=0&&this._observers.splice(n,1)})}interruptUnsafe(t,n){if(this._exit)return;let r=Za(t);this.currentStackFrame&&(r=Id(r,cs(Fh,this.currentStackFrame))),n&&(r=Id(r,n)),this._interruptedCause=this._interruptedCause?l0(this._interruptedCause,r):r,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(ot(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(t){if(this._exit)return;if(this._yielded!==void 0){let o=this._yielded;this._yielded=void 0,o()}let n=this.runLoop(t);if(n===Gc)return;let r=ZE.interruptChildren&&ZE.interruptChildren(this);if(r!==void 0)return this.evaluate(ne(r,()=>n));this._exit=n,this.runtimeMetrics?.recordFiberEnd(this.context,this._exit);for(let o=0;o<this._observers.length;o++)this._observers[o](n);this._observers.length=0,this._stack.length=0,this._children=void 0,this.context=Et()}runLoop(t){let n=globalThis[mf];globalThis[mf]=this;let r=this._running;this._running=!0;let o=!1,s=t;this.currentOpCount=0;try{for(;;){if(this._deferredInterrupt&&(this._deferredInterrupt=!1,s=ot(this._interruptedCause)),this.currentOpCount++,!o&&!this.currentPreventYield&&this.currentScheduler.shouldYield(this)){o=!0;let i=s;s=ne(Pf,()=>i)}if(s=this.currentTracerContext?this.currentTracerContext(s,this):s[nn](this),s===Gc){let i=this._yielded;if(Vc in i)return this._deferredInterrupt=!1,this._yielded=void 0,i;if(this._deferredInterrupt){this._yielded=void 0,i();continue}return Gc}}}catch(i){return j(s,nn)?this.runLoop(uo(i)):uo(`Fiber.runLoop: Not a valid effect: ${String(s)}`)}finally{this._running=r,globalThis[mf]=n}}getCont(t){if(this._deferredInterrupt)return this._deferredInterrupt=!1,u4;for(;;){let n=this._stack.pop();if(!n)return;let r=n[La]&&n[La](this);if(r)return r[t]=r,r;if(n[t])return n}}yieldWith(t){return this._yielded=t,Gc}children(){return this._children??=new Set}pipe(){return ie(this,arguments)}setContext(t){let n=this.context;if(this.context=t,n!==void 0&&QR(n,t))return;let r=this.getRef(Ka);r!==this.currentScheduler&&(this.currentScheduler=r,this._dispatcher=void 0),this.currentSpan=Ji(t,zE),this.currentLogLevel=this.getRef(WE),this.minimumLogLevel=this.getRef(KE),this.currentStackFrame=this.getRef(Rf),this.maxOpsBeforeYield=this.getRef(lO),this.currentPreventYield=this.getRef(dO),this.runtimeMetrics=Ji(t,AO);let o=Ji(t,HE);this.currentTracerContext=o?o.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag==="Span"?this.currentSpan:void 0}},u4={[Sr](e,t){return ot(t._interruptedCause)},[ko](e,t){return ot(t._interruptedCause)}},ZE={interruptChildren:void 0},xg=e=>{if(!e.currentStackFrame)return;let t=new Map;return t.set(rE.key,e.currentStackFrame),Mo(t)},f4=e=>{if(!(e._children===void 0||e._children.size===0))return Ga(e._children)},d0=e=>{let t=e;return t._exit?J(t._exit):Bt(n=>t._exit?n(J(t._exit)):ge(e.addObserver(r=>n(J(r)))))},yg=e=>Bt(t=>{let n=e[Symbol.iterator](),r=[],o;function s(){let i=n.next();for(;!i.done;){if(i.value._exit){r.push(i.value._exit),i=n.next();continue}o=i.value.addObserver(a=>{r.push(a),s()});return}t(J(r))}return s(),ge(()=>o?.())}),GO=e=>{let t=e;return t._exit?t._exit:Bt(n=>t._exit?n(t._exit):ge(e.addObserver(n)))},ZO=e=>Bt(t=>{let n=Array.from(e);if(n.length===0)return t(J(rn()));let r=new Array(n.length),o=rn(),s=0,i=!1;for(let a=0;a<n.length&&!i;a++)o.push(n[a].addObserver(c=>{if(s++,c._tag==="Failure")return i=!0,o.forEach(u=>u()),t(c);r[a]=c.value,s===n.length&&t(J(r))}));return ge(()=>{i=!0,o.forEach(a=>a())})}),Sg=e=>pe(t=>QO(e,t.id)),QO=d(e=>j(e[0],ug),(e,t,n)=>pe(r=>{let o=xg(r);return o=o&&n?br(o,n):o??n,e.interruptUnsafe(t,o),zd(d0(e))})),Ga=e=>pe(t=>{let n=xg(t),r=rn();for(let o of e)o.interruptUnsafe(t.id,n),r.push(o);return zd(yg(r))});var J=rt,ot=On,wt=co,ge=Co({op:"Sync",[nn](e){let t=this[ye](),n=e.getCont(Sr);return n?n[Sr](t,e):e.yieldWith(rt(t))}}),he=Co({op:"Suspend",[nn](e){return this[ye]()}}),p0=d(e=>e.length>=2||Ys(e[0]),(e,t)=>xe(e)?wt(t?t():new os("Effect.fromOption: Option.none")):J(e.value)),Mf=_o({onFailure:wt,onSuccess:J}),YO=e=>e==null?wt(new os):J(e),m0=Co({op:"Yield",[nn](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(Ir)},this[ye]??0),e.yieldWith(()=>{t=!0})}}),Pf=m0(0),h0=e=>J(L(e)),iu=J(D()),XO=e=>xe(e)?iu:Be(e.value,L),e_=e=>he(()=>ot(je(e))),ta=e=>uo(e),bg=e=>he(()=>wt(je(e))),we=J(void 0);var t_=e=>{let t=typeof e=="function"?e:e.try,n=typeof e=="function"?r=>new qd(r,"An error occurred in Effect.try"):e.catch;return he(()=>{try{return J(je(t))}catch(r){return wt(je(()=>n(r)))}})};var g0=e=>x0(function(t,n){je(()=>e(n)).then(r=>t(J(r)),r=>t(ta(r)))},e.length!==0),n_=e=>{let t=typeof e=="function"?e:e.try,n=typeof e=="function"?r=>new qd(r,"An error occurred in Effect.tryPromise"):e.catch;return x0(function(r,o){let s=i=>{try{r(wt(je(()=>n(i))))}catch(a){r(ta(a))}};try{je(()=>t(o)).then(i=>r(J(i)),s)}catch(i){s(i)}},t.length!==0)},r_=e=>pe(t=>e(t.id)),o_=pe(J),s_=r_(J),x0=Co({op:"Async",single:!1,[nn](e){let t=je(()=>this[ye][0].bind(e.currentScheduler)),n=!1,r=!1,o=this[ye][1]?new AbortController:void 0,s=t(i=>{n||(n=!0,r?e.evaluate(i):r=i)},o?.signal);return r!==!1?r:(r=!0,e._yielded=()=>{n=!0},o===void 0&&s===void 0?Gc:(e._stack.push(l4(()=>(n=!0,o?.abort(),s??Ir))),Gc))}}),l4=Co({op:"AsyncFinalizer",[La](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Ug))},[ko](e,t){return u0(e)?ne(this[ye](),()=>ot(e)):ot(e)}}),Bt=e=>x0(e,e.length>=2),$d=Bt(En),i_=(...e)=>he(()=>Of(e.length===1?e[0]():e[1].call(e[0].self))),y0=(e,...t)=>{let n=t.length===0?function(){return he(()=>Of(e.apply(this,arguments)))}:function(){let r=he(()=>Of(e.apply(this,arguments)));for(let o=0;o<t.length;o++)r=t[o](r,...arguments);return r};return S0(e.length,n)},S0=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),_O=VE(2),a_=function(){let e=typeof arguments[0]=="string",t=e?arguments[0]:"Effect.fn",n=e?arguments[1]:void 0,r=ni();ir(2);let o=new globalThis.Error;return ir(r),e?(s,...i)=>MO(t,s,o,i,e,n):MO(t,arguments[0],o,Array.prototype.slice.call(arguments,1),e,n)},MO=(e,t,n,r,o,s)=>{let i=typeof t=="function"?t:r.shift().bind(t.self);return S0(i.length,function(...a){let c=he(()=>{let l=i.apply(this,arguments);return ve(l)?l:Of(l)});for(let l=0;l<r.length;l++)c=r[l](c,...a);if(!ve(c))return c;let u=ni();ir(2);let f=new globalThis.Error;return ir(u),na(o?jd(e,s,l=>t0(c,l)):c,Rf,l=>({name:e,stack:_O(()=>f.stack),parent:{name:`${e} (definition)`,stack:_O(()=>n.stack),parent:l}}))})},c_=(e,...t)=>S0(e.length,t.length===0?function(){return PO(()=>e.apply(this,arguments))}:function(){let n=PO(()=>e.apply(this,arguments));for(let r of t)n=r(n);return n}),PO=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return J(r.value);let o=r.value;if(o&&o._tag==="Success"){n=o.value;continue}else{if(o&&o._tag==="Failure")return r.value;{let s=!0;return he(()=>s?(s=!1,ne(r.value,i=>Of(t,i))):he(()=>Of(e())))}}}}catch(t){return ta(t)}},Of=Co({op:"Iterator",single:!1,[Sr](e,t){let n=this[ye][0];for(;;){let r=n.next(e);if(r.done)return J(r.value);if(xt(r.value)){if(r.value._tag==="Failure")return r.value}else return t._stack.push(this),r.value;e=r.value.value}},[nn](e){return this[Sr](this[ye][1],e)}}),Pn=d(2,(e,t)=>{let n=J(t);return ne(e,r=>n)}),Ff=e=>Be(e,L),u_=e=>au(e,{onFailure:J,onSuccess:wt}),jr=d(2,(e,t)=>ne(e,n=>ve(t)?t:je(()=>t(n)))),oi=d(2,(e,t)=>ne(e,n=>Pn(ve(t)?t:je(()=>t(n)),n))),zd=e=>ne(e,t=>Ir),f_=e=>Tr(e,wt),b0=(e,t)=>pe(n=>Bt(r=>{let o=ht(e),s=o.length,i=0,a=!1,c=new Set,u=[],f=(l,p,m)=>{if(i++,l._tag==="Failure"){u.push(...l.cause.reasons),i>=s&&r(ot($i(u)));return}let h=!a;a=!0,r(c.size===0?l:ne(oa(Ga(c)),()=>l)),h&&t?.onWinner&&t.onWinner({fiber:p,index:m,parentFiber:n})};for(let l=0;l<s;l++){let p=uu(n,o[l],!0,!0,!1);if(c.add(p),p.addObserver(m=>{c.delete(p),f(m,p,l)}),a)break}return Ga(c)})),E0=(e,t)=>pe(n=>Bt(r=>{let o=!1,s=new Set,i=c=>{o=!0,r(s.size===0?c:ne(oa(Ga(s)),()=>c))},a=0;for(let c of e){if(o)break;let u=a++,f=uu(n,c,!0,!0,!1);s.add(f),f.addObserver(l=>{s.delete(f);let p=!o;i(l),p&&t?.onWinner&&t.onWinner({fiber:f,index:u,parentFiber:n})})}return Ga(s)})),l_=d(e=>ve(e[1]),(e,t,n)=>b0([e,t],n)),Eg=d(e=>ve(e[1]),(e,t,n)=>E0([e,t],n)),ne=d(2,(e,t)=>{let n=Object.create(d4);return n[ye]=e,n[Sr]=t.length!==1?r=>t(r):t,n}),d4=zi({op:"OnSuccess",[nn](e){return e._stack.push(this),this[ye]}}),d_=d(2,(e,t)=>xt(e)?e._tag==="Success"?t.onSuccess(e.value):t.onFailure(e.cause):ls(e,t)),xt=e=>Vc in e,p_=d(2,(e,t)=>xt(e)?e._tag==="Success"?t(e.value):e:ne(e,t)),m_=e=>ne(e,B),Be=d(2,(e,t)=>ne(e,n=>J(je(()=>t(n))))),h_=d(2,(e,t)=>xt(e)?E_(e,t):Be(e,t)),g_=d(2,(e,t)=>xt(e)?w_(e,t):C0(e,t)),x_=d(2,(e,t)=>xt(e)?I_(e,t):A0(e,t)),y_=d(2,(e,t)=>{if(xt(e)){if(e._tag==="Success")return e;let n=ri(e.cause);return Fe(n)?e:t(n.success)}return kr(e,t)}),wg=e=>On(Za(e)),Uf=e=>e._tag==="Success";var S_=e=>e._tag==="Failure";var b_=e=>e._tag==="Failure"?Ce(e.cause):Ae(e);var Ir=rt(void 0),E_=d(2,(e,t)=>e._tag==="Success"?rt(t(e.value)):e),w_=d(2,(e,t)=>{if(e._tag==="Success")return e;let n=ri(e.cause);return Fe(n)?e:co(t(n.success))}),I_=d(2,(e,t)=>{if(e._tag==="Success")return rt(t.onSuccess(e.value));let n=ri(e.cause);return Fe(n)?e:co(t.onFailure(n.success))});var v_=d(2,(e,t)=>Uf(e)?t:e),T_=d(2,(e,t)=>Uf(e)?t.onSuccess(e.value):t.onFailure(e.cause));var k_=e=>{let t=[];for(let n of e)n._tag==="Failure"&&t.push(...n.cause.reasons);return t.length===0?Ir:On($i(t))};var C_=e=>e,A_=e=>pe(t=>J(AE(t.context,e))),p4=e=>pe(t=>p0(AE(t.context,e))),Df=d(2,(e,t)=>pe(n=>{let r=n.context,o=t(r);return r===o?e:(n.setContext(o),ms(e,()=>{n.setContext(r)}))})),na=d(3,(e,t,n)=>Df(e,r=>{let o=Jn(r,t),s=n(o);return o===s?r:Ve(r,t,s)})),R_=(e,t,n)=>oa(pe(r=>{let o=Jn(r.context,e),s=t(o);return r.setContext(Ve(r.context,e,s)),ps(Jn(r.context,Ya),i=>{let a=Jn(r.context,e),c;if(n?.reset===void 0){if(a!==s)return we;c=o}else c=n.reset(o,s,a);return r.setContext(Ve(r.context,e,c)),we})})),w0=()=>m4,m4=pe(e=>J(e.context)),Qa=e=>pe(t=>e(t.context)),O_=d(2,(e,t)=>Df(e,Qe(t))),ra=d(2,(e,t)=>xt(e)?e:Df(e,br(t))),vr=function(){return arguments.length===1?d(2,(e,t)=>FO(e,arguments[0],t)):d(3,(e,t,n)=>FO(e,t,n)).apply(this,arguments)},FO=(e,t,n)=>Df(e,Ve(t,n)),Ig=d(3,(e,t,n)=>ne(n,r=>vr(e,t,r))),__=d(e=>ve(e[1]),(e,t,n)=>I0(e,t,(r,o)=>[r,o],n)),I0=d(e=>ve(e[1]),(e,t,n,r)=>r?.concurrent?Be(qf([e,t],{concurrency:2}),([o,s])=>je(()=>n(o,s))):ne(e,o=>Be(t,s=>je(()=>n(o,s))))),M_=d(e=>ve(e[0]),(e,t,n)=>$0(e,t,n?r=>wt(n(r)):()=>wt(new os))),P_=d(2,(e,t)=>ne(t,n=>n?Ff(e):iu)),v0=d(2,(e,t)=>Array.from({length:t},()=>e)),F_=d(e=>ve(e[0]),(e,t,n)=>qf(v0(e,t),n)),vg=d(e=>ve(e[0]),(e,t)=>si({while:Xt,body:Qe(t?.disableYield?e:ne(e,n=>Pf)),step:En})),Tr=d(2,(e,t)=>{let n=Object.create(h4);return n[ye]=e,n[ko]=t.length!==1?r=>t(r):t,n}),h4=zi({op:"OnFailure",[nn](e){return e._stack.push(this),this[ye]}}),T0=d(3,(e,t,n)=>Tr(e,r=>t(r)?je(()=>n(r)):ot(r))),Nf=d(3,(e,t,n)=>Tr(e,r=>{let o=t(r);return Fe(o)?ot(o.failure):je(()=>n(o.success,r))})),kr=d(2,(e,t)=>Nf(e,ri,n=>t(n))),U_=e=>au(e,{onFailure:t=>oE(t)?iu:wt(t),onSuccess:h0}),D_=d(2,(e,t)=>Nf(e,c0,t)),N_=d(2,(e,t)=>Tr(e,n=>jr(je(()=>t(n)),ot(n)))),L_=d(3,(e,t,n)=>T0(e,t,r=>jr(je(()=>n(r)),ot(r)))),Tg=d(3,(e,t,n)=>Tr(e,r=>{let o=t(r);return Fe(o)?ot(r):jr(je(()=>n(o.success,r)),ot(r))})),k0=d(2,(e,t)=>Tg(e,ri,n=>t(n))),B_=d(3,(e,t,n)=>{let r=Array.isArray(t)?o=>j(o,"_tag")&&t.includes(o._tag):yr(t);return k0(e,o=>r(o)?n(o):we)}),j_=d(2,(e,t)=>Tg(e,c0,n=>t(n))),Hd=d(e=>ve(e[0]),(e,t,n,r)=>Tr(e,o=>{let s=ri(o);return Fe(s)?ot(s.failure):t(s.success)?je(()=>n(s.success)):r?je(()=>r(s.success)):ot(o)})),kg=d(e=>ve(e[0]),(e,t,n,r)=>Tr(e,o=>{let s=ri(o);if(Fe(s))return ot(s.failure);let i=t(s.success);return Fe(i)?r?je(()=>r(i.failure)):ot(o):je(()=>n(i.success))})),Cg=d(e=>ve(e[0]),(e,t,n,r)=>{let o=Array.isArray(t)?s=>j(s,"_tag")&&t.includes(s._tag):yr(t);return Hd(e,o,n,r)}),q_=d(e=>ve(e[0]),(e,t,n)=>{let r;return kg(e,o=>(r??=Object.keys(t),j(o,"_tag")&&io(o._tag)&&r.includes(o._tag)?Ce(o):Ae(o)),o=>je(()=>t[o._tag](o)),n)}),$_=d(e=>ve(e[0]),(e,t,n,r,o)=>Hd(e,s=>yr(s,t)&&j(s,"reason"),s=>{let i=s.reason;return yr(i,n)?r(i,s):o?je(()=>o(i,s)):wt(s)})),z_=d(e=>ve(e[0]),(e,t,n,r)=>{let o;return Hd(e,s=>yr(s,t)&&j(s,"reason")&&j(s.reason,"_tag")&&io(s.reason._tag),s=>{let i=s.reason;return o??=Object.keys(n),o.includes(i._tag)?je(()=>n[i._tag](i,s)):r?je(()=>r(i,s)):wt(s)})}),H_=d(2,(e,t)=>kg(e,n=>yr(n,t)&&j(n,"reason")?Ce(n.reason):Ae(n),wt)),C0=d(2,(e,t)=>kr(e,n=>bg(()=>t(n)))),A0=d(2,(e,t)=>au(e,{onFailure:n=>bg(()=>t.onFailure(n)),onSuccess:n=>ge(()=>t.onSuccess(n))})),Ag=e=>kr(e,ta),W_=d(2,(e,t)=>kr(e,n=>ge(t))),K_=e=>he(()=>{let t=e[Symbol.iterator](),n=t.next();if(n.done)return ta(new Error("Received an empty collection of effects"));function r(o){let s=t.next();return s.done?o.value:kr(o.value,i=>r(s))}return r(n)}),R0=e=>kr(e,t=>ne(Pf,()=>R0(e))),V_=d(e=>ve(e[0]),(e,t)=>{if(!t?.log)return au(e,{onFailure:r=>we,onSuccess:r=>we});let n=hs(t.log===!0?void 0:t.log);return ls(e,{onFailure(r){let o=BO(r);return Fe(o)?ot(o.failure):t.message===void 0?n(r):n(t.message,r)},onSuccess:r=>we})}),Rg=d(e=>ve(e[0]),(e,t)=>{if(!t?.log)return ls(e,{onFailure:r=>we,onSuccess:r=>we});let n=hs(t.log===!0?void 0:t.log);return ls(e,{onFailure:r=>t.message===void 0?n(r):n(t.message,r),onSuccess:r=>we})}),J_=e=>Og(e,{onFailure:D,onSuccess:L}),Ja=e=>Wd(e,{onFailure:Ae,onSuccess:Ce}),ls=d(2,(e,t)=>{let n=Object.create(g4);return n[ye]=e,n[Sr]=t.onSuccess.length!==1?r=>t.onSuccess(r):t.onSuccess,n[ko]=t.onFailure.length!==1?r=>t.onFailure(r):t.onFailure,n}),g4=zi({op:"OnSuccessAndFailure",[nn](e){return e._stack.push(this),this[ye]}}),O0=d(2,(e,t)=>ls(e,{onFailure:n=>ge(()=>t.onFailure(n)),onSuccess:n=>ge(()=>t.onSuccess(n))})),au=d(2,(e,t)=>ls(e,{onFailure:n=>{let r=n.reasons.find(Ba);return r?je(()=>t.onFailure(r.error)):ot(n)},onSuccess:t.onSuccess})),Og=d(2,(e,t)=>au(e,{onFailure:n=>ge(()=>t.onFailure(n)),onSuccess:n=>ge(()=>t.onSuccess(n))})),Wd=d(2,(e,t)=>{if(xt(e)){if(e._tag==="Success")return rt(t.onSuccess(e.value));let n=ri(e.cause);return Fe(n)?e:rt(t.onFailure(n.success))}return Og(e,t)}),G_=d(2,(e,t)=>xt(e)?e._tag==="Success"?rt(t.onSuccess(e.value)):rt(t.onFailure(e.cause)):O0(e,t)),Kd=e=>xt(e)?rt(e):x4(e),x4=Co({op:"Exit",[nn](e){return e._stack.push(this),this[ye]},[Sr](e,t,n){return J(n??rt(e))},[ko](e,t,n){return J(n??On(e))}}),Z_=Wd({onFailure:()=>!0,onSuccess:()=>!1}),Q_=Wd({onFailure:()=>!1,onSuccess:()=>!0}),Y_=d(2,(e,t)=>jr(fu(t),e)),_0=d(2,(e,t)=>Eg(e,ne(fu(t.duration),t.orElse))),X_=d(2,(e,t)=>_0(e,{duration:t,orElse:()=>wt(new lg)})),eM=d(2,(e,t)=>Eg(Ff(e),Pn(fu(t),D()))),tM=e=>$r(t=>{let n=t.monotonicTimeNanosUnsafe();return Be(e,r=>[Lr(t.monotonicTimeNanosUnsafe()-n),r])}),QE="~effect/Scope",YE="~effect/Scope/Closeable",Ya=Ke("effect/Scope"),M0=(e,t)=>he(()=>Lf(e,t)??we),Lf=(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 o=r.finalizers;if(!(o===void 0||o.size===0))return o.size===1?o.values().next().value(t):S4(e,o,t)},y4=(e,t)=>Uf(e)?t:Tr(t,n=>ot(l0(e.cause,n))),S4=y0(function*(e,t,n){let r=[],o=[],s=Array.from(t.values()),i=ea();for(let a=s.length-1;a>=0;a--){let c=s[a];e.strategy==="sequential"?r.push(yield*Kd(c(n))):o.push(uu(i,c(n),!0,!0,"inherit"))}return o.length>0&&(r=yield*yg(o)),yield*k_(r)});var nM=(e,t)=>{let n=cu(t);if(e.state._tag==="Closed")return n.state=e.state,n;let r={};return su(e,r,o=>M0(n,o)),su(n,r,o=>ge(()=>P0(e,r))),n},ps=(e,t)=>he(()=>e.state._tag==="Closed"?t(e.state.exit):(su(e,{},t),we)),rM=(e,t)=>ps(e,Qe(t)),su=(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=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0,r.finalizers.set(t,n)):r.finalizers===void 0?(r.finalizerKey=t,r.finalizer=n):r.finalizers.set(t,n)}},P0=(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)}},oM=e=>e.state._tag!=="Open"?0:e.state.finalizer!==void 0?1:e.state.finalizers?.size??0,cu=(e="sequential")=>({[YE]:YE,[QE]:QE,strategy:e,state:b4}),b4={_tag:"Empty"};var Vd=Ya,sM=vr(Ya),_g=e=>pe(t=>{let n=t.context,r=cu();return t.setContext(Ve(t.context,Ya,r)),ms(e,o=>(t.setContext(n),Lf(r,o)))});var Mg=e=>he(()=>{let t=cu();return Gn(e(t),n=>he(()=>Lf(t,n)??we))}),Pg=(e,t,n)=>Qa(r=>qr(o=>ne(Vd,s=>oi(n?.interruptible?o(e):e,i=>ps(s,a=>ra(t(i,a),r)))))),Bf=e=>ne(Vd,t=>Qa(n=>ps(t,r=>ra(e(r),n)))),ms=Co({op:"OnExit",single:!1,[nn](e){return e._stack.push(this),this[ye][0]},[La](e){e.interruptible&&this[ye][2]!==!0&&(e._stack.push(Ug),e.interruptible=!1)},[Sr](e,t,n){n??=rt(e);let r=this[ye][1](n);return r?ne(r,o=>n):n},[ko](e,t,n){n??=On(e);let r=this[ye][1](n);return r?ne(y4(n,r),o=>n):n}}),Gn=d(2,ms),iM=d(2,(e,t)=>Gn(e,n=>t)),F0=d(3,(e,t,n)=>Gn(e,r=>t(r)?n(r):we)),U0=d(3,(e,t,n)=>Gn(e,r=>{let o=t(r);return Fe(o)?we:n(o.success,r)})),D0=d(2,(e,t)=>U0(e,b_,t)),aM=d(3,(e,t,n)=>F0(e,r=>r._tag!=="Failure"?!1:t(r.cause),r=>n(r.cause))),N0=d(3,(e,t,n)=>Gn(e,r=>{if(r._tag!=="Failure")return we;let o=t(r.cause);return Fe(o)?we:n(o.success,r.cause)})),Fg=d(2,(e,t)=>N0(f0,t)(e)),cM=(e,t,n)=>qr(r=>ne(e,o=>ms(r(t(o)),s=>n(o,s),!0))),uM=e=>Pg(e,t=>j(t,Symbol.asyncDispose)?g0(()=>t[Symbol.asyncDispose]()):ge(()=>t[Symbol.dispose]())),L0=d(2,(e,t)=>ge(()=>{let n=Tn(gt(t)),r=Number.isFinite(n),o=Lg(!1),s=0,i=!1,a,c=ne(o.await,()=>a);return[pe(u=>{let f=u.getRef(mo),l=r?f.currentTimeMillisUnsafe():0;return i||l<s?a??c:(i=!0,o.closeUnsafe(),a=void 0,Gn(e,p=>ge(()=>{i=!1,s=f.currentTimeMillisUnsafe()+n,a=p,o.openUnsafe()})))}),ge(()=>{s=0,o.closeUnsafe(),a=void 0})]})),B0=d(2,(e,t)=>Be(L0(e,t),n=>n[0])),fM=e=>B0(e,po),jf=pe(e=>ot(Za(e.id))),oa=e=>pe(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(Ug)),e)),lM=Co({op:"SetInterruptible",[La](e){if(e.interruptible=this[ye],e._interruptedCause&&e.interruptible)return()=>ot(e._interruptedCause)}}),Ug=lM(!0),E4=lM(!1),dM=e=>{if(e.interruptible=!0,e._stack.push(E4),e._interruptedCause)return ot(e._interruptedCause)},j0=e=>pe(t=>t.interruptible?e:dM(t)??e),qr=e=>pe(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Ug),e(j0)):e(B)),pM=e=>pe(t=>{if(t.interruptible)return e(B);let n=dM(t),r=e(oa);return n??r}),mM=Be(Pg(ge(()=>new AbortController),e=>ge(()=>e.abort())),e=>e.signal),qf=(e,t)=>Js(e)?t?.mode==="result"?Br(e,Ja,t):Br(e,B,t):t?.discard?t.mode==="result"?Br(Object.values(e),Ja,t):Br(Object.values(e),B,t):he(()=>{let n={};return Pn(Br(Object.entries(e),([r,o])=>Be(t?.mode==="result"?Ja(o):o,s=>{W(n,r,s)}),{discard:!0,concurrency:t?.concurrency}),n)}),q0=d(e=>Js(e[0])&&!ve(e[0]),(e,t,n)=>Be(Br(e,(r,o)=>Ja(t(r,o)),n),r=>yE(r,B))),hM=d(3,(e,t,n)=>{let r=ht(e);return r.length===0?ge(t):he(()=>{let o=0,s=t();return Be(si({while:()=>o<r.length,body:()=>n(s,r[o],o),step(i){s=i,o++}}),()=>s)})}),gM=d(e=>Js(e[0])&&!ve(e[0]),(e,t,n)=>ne(q0(e,t,{concurrency:n?.concurrency}),([r,o])=>Vn(r)?wt(r):n?.discard?we:J(o))),xM=d(e=>Js(e[0])&&!ve(e[0]),(e,t)=>he(()=>{let n=e[Symbol.iterator](),r=n.next();return r.done?J(D()):yM(n,0,t,r.value)})),yM=(e,t,n,r)=>ne(n(r,t),o=>{if(o)return J(L(r));let s=e.next();return s.done?J(D()):yM(e,t+1,n,s.value)}),SM=d(e=>Js(e[0])&&!ve(e[0]),(e,t)=>he(()=>{let n=e[Symbol.iterator](),r=n.next();return r.done?J(D()):bM(n,0,t,r.value)})),bM=(e,t,n,r)=>ne(n(r,t),o=>{if(Kt(o))return J(L(o.success));let s=e.next();return s.done?J(D()):bM(e,t+1,n,s.value)}),si=Co({op:"While",[Sr](e,t){return this[ye].step(e),this[ye].while()?(t._stack.push(this),this[ye].body()):Ir},[nn](e){return this[ye].while()?(e._stack.push(this),this[ye].body()):Ir}}),Br=d(e=>typeof e[1]=="function",(e,t,n)=>he(()=>{let r=n?.concurrency??1,o=r==="unbounded"?Number.POSITIVE_INFINITY:Math.max(1,r);if(o===1)return w4(e,t,n);let s=ht(e),i=s.length;if(i===0)return n?.discard?we:J([]);let a=n?.discard?void 0:new Array(i),c=I4({f:t,out:a},s,{concurrency:o});return c?Pn(c,a):J(a)})),EM=e=>ne(e,t=>{let n=t[Symbol.iterator]().next();return n.done?wt(new os):J(n.value)}),w4=(e,t,n)=>he(()=>{let r=n?.discard?void 0:[],o=e[Symbol.iterator](),s=o.next(),i=0;return Pn(si({while:()=>!s.done,body:()=>t(s.value,i++),step:a=>{r&&r.push(a),s=o.next()}}),r)}),wM=e=>{let t=e.onItem,n=e.step,r=(o,s,i,a)=>{for(;i<a;i++){let c=s[i],u=t(o,c,i);if(!xt(u))return ne(Kd(u),l=>n(o,c,l,i)??r(o,s,i+1,a)??we);let f=n(o,c,u,i);if(f)return f._tag==="Failure"?f:void 0}};return(o,s,i)=>{let a=0,c=i?.end??s.length,u=i?.concurrency??1;if(u===1)return r(o,s,0,c);let f=i?.orderedStep===!0,l=!1,p,m,h,g=!1,x,E,b=a,y=f?new Array(c):void 0,w=M=>{let _=uo(M);return x=_,l=!0,g=!0,m&&m.size>0?ne(oa(Ga(Array.from(m))),()=>_):_},S=(M,_,P)=>{if(!f)return n(o,M,_,P);if(x)return x;for(y[P]=_;b<c;){let $=y[b];if($===void 0)return;y[b]=void 0;let F=b++,te=n(o,s[F],$,F);if(te)return te}},C=()=>{let M=!1;for(;!x&&a<c;a++){let _=s[a],P=E??t(o,_,a);if(xt(P)){if(x=S(_,P,a),x)break}else if(p){E=void 0;let $=uu(p,P,!0,!0,"inherit");if($._exit){if(x=S(_,$._exit,a),x)break;continue}m.add($);let F=a;if($.addObserver(te=>{m.delete($);try{if(x){if(!g&&te._tag==="Failure")for(let ee of te.cause.reasons)ee._tag!=="Interrupt"&&(x._tag==="Failure"?x.cause.reasons.push(ee):x=On($i([ee])))}else{let ee=S(_,te,F);ee&&(x=ee._tag==="Failure"?On($i(ee.cause.reasons.slice())):ee,C())}if(M){let ee=C();ee&&h(ee)}else l&&m.size===0&&h(x??we)}catch(ee){h(w(ee))}}),m.size<u)continue;M=!0,a++;return}else return Bt($=>{p=ea(),m=new Set,E=P,h=$;let F;try{F=C()}catch(te){return $(w(te))}return F?$(F):he(()=>(x=Ir,g=!0,m?Ga(m):we))})}if(l=!0,x){if(m&&m.size>0){let _=xg(p);m.forEach(P=>P.interruptUnsafe(p.id,_));return}if(h||x._tag==="Failure")return x}else if(h)if(m)m.size===0&&h(we);else return Ir};return C()}},Jd=()=>wM,I4=wM({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)}}),$0=d(3,(e,t,n)=>ne(e,r=>t(r)?J(r):n(r))),z0=d(3,(e,t,n)=>ne(e,r=>{let o=t(r);return Fe(o)?n(o.failure):J(o.success)})),IM=d(e=>ve(e[0]),(e,t,n)=>z0(e,t,n?r=>wt(n(r)):()=>wt(new os))),vM=d(e=>Js(e[0])&&!ve(e[0]),(e,t,n)=>he(()=>{let r=[];return Pn(Br(e,(o,s)=>{let i=t(o,s);return typeof i=="boolean"?(i&&r.push(o),we):Be(i,a=>{a&&r.push(o)})},{discard:!0,concurrency:n?.concurrency}),r)})),TM=d(e=>Js(e[0])&&!ve(e[0]),(e,t)=>he(()=>{let n=[];for(let r of e){let o=t(r);Kt(o)&&n.push(o.success)}return J(n)})),kM=d(e=>Js(e[0])&&!ve(e[0]),(e,t,n)=>he(()=>{let r=[];return Pn(Br(e,o=>Be(t(o),s=>{Kt(s)&&r.push(s.success)}),{discard:!0,concurrency:n?.concurrency}),r)})),CM=J({}),AM=kh(Be),RM=Ch(Be,ne),OM=Th(Be);var _M=d(e=>ve(e[0]),(e,t)=>pe(n=>(B4(),J(uu(n,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),uu=(e,t,n=!1,r=!1,o=!1)=>{let s=e,i=o==="inherit"?s.interruptible:!o,a=new fg(s.context,i);return n?a.evaluate(t):s.currentDispatcher.scheduleTask(()=>a.evaluate(t),0),!r&&!a._exit&&(s.children().add(a),a.addObserver(()=>s._children.delete(a))),a},MM=d(e=>ve(e[0]),(e,t)=>pe(n=>J(uu(n,e,t?.startImmediately,!0,t?.uninterruptible)))),PM=e=>pe(t=>{let n=t._children&&new Set(t._children);return Gn(e,r=>{let o=t._children;return o===void 0||o.size===0?we:(n&&(o=zh(o,s=>!n.has(s))),zd(yg(o)))})}),H0=d(e=>ve(e[0]),(e,t,n)=>pe(r=>{let o=uu(r,e,n?.startImmediately,!0,n?.uninterruptible);if(!o._exit)if(t.state._tag!=="Closed"){let s={};su(t,s,()=>r_(a=>a===o.id?we:Sg(o))),o.addObserver(()=>P0(t,s))}else o.interruptUnsafe(r.id,xg(r));return J(o)})),FM=d(e=>ve(e[0]),(e,t)=>ne(Vd,n=>H0(e,n,t))),sa=e=>(t,n)=>{let r=new fg(n?.scheduler?Ve(e,Ka,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 o=()=>r.interruptUnsafe();n.signal.addEventListener("abort",o,{once:!0}),r.addObserver(()=>n.signal.removeEventListener("abort",o))}return n?.onFiberStart&&n.onFiberStart(r),r},UM=d(2,(e,t)=>{if(e._exit)return e;if(t.state._tag==="Closed")return e.interruptUnsafe(e.id),e;let n={};return su(t,n,()=>Sg(e)),e.addObserver(()=>P0(t,n)),e}),DM=sa(Et()),W0=e=>{let t=sa(e);return(n,r)=>{let o=t(n,r);return r?.onExit&&o.addObserver(r.onExit),s=>o.interruptUnsafe(s)}},NM=W0(Et()),Dg=e=>{let t=sa(e);return(n,r)=>{let o=t(n,r);return new Promise(s=>{o.addObserver(i=>s(i))})}},LM=Dg(Et()),K0=e=>{let t=Dg(e);return(n,r)=>t(n,r).then(o=>{if(o._tag==="Failure")throw hg(o.cause);return o.value})},BM=K0(Et()),Ng=e=>{let t=sa(e);return n=>{if(xt(n))return n;let r=new ei("sync"),o=t(n,{scheduler:r});return o._dispatcher?.flush(),o._exit??uo(new mg(o))}},jM=Ng(Et()),V0=e=>{let t=Ng(e);return n=>{let r=t(n);if(r._tag==="Failure")throw hg(r.cause);return r.value}},qM=V0(Et()),UO=J(!0),DO=J(!1),XE=class{waiters=[];scheduled=void 0;_isOpen;constructor(t){this._isOpen=t}scheduleUnsafe(t){if(this.waiters.length===0)return UO;if(this.scheduled===void 0)this.scheduled=this.waiters,t.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let n=0;n<this.waiters.length;n++)this.scheduled.push(this.waiters[n]);return this.waiters=[],UO}flushScheduled=()=>{if(this.scheduled===void 0)return;let t=this.scheduled;this.scheduled=void 0;for(let n=0;n<t.length;n++)t[n](Ir)};flushWaiters(){let t=this.waiters;this.waiters=[],this.flushScheduled();for(let n=0;n<t.length;n++)t[n](Ir)}open=pe(t=>this._isOpen?DO:(this._isOpen=!0,this.scheduleUnsafe(t)));release=pe(t=>this._isOpen?DO:this.scheduleUnsafe(t));openUnsafe(){return this._isOpen?!1:(this._isOpen=!0,this.flushWaiters(),!0)}await=Bt(t=>this._isOpen?t(we):(this.waiters.push(t),ge(()=>{let n=this.waiters.indexOf(t);n!==-1?this.waiters.splice(n,1):this.scheduled!==void 0&&(n=this.scheduled.indexOf(t),n!==-1&&this.scheduled.splice(n,1))})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=ge(()=>this.closeUnsafe());whenOpen=t=>ne(this.await,()=>t);isOpen(){return this._isOpen}},Lg=e=>new XE(e??!1),$M=e=>ge(()=>Lg(e)),zM=pe(e=>J(e.getRef(og))),HM=d(2,(e,t)=>vr(e,og,t)),WM=vr(ig),KM=vr(ru),e0=BigInt(0),v4={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:e0,endTime:e0,exit:Ir},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},T4=e=>Object.assign(Object.create(v4),e),VM=e=>e?$e(e.annotations,Af)?e._tag==="Span"?VM(Oo(e.parent)):D():L(e):D(),J0=(e,t,n)=>{let r=!e.getRef(ig)||n?.annotations&&$e(n.annotations,Af),o=n?.parent!==void 0?L(n.parent):n?.root?D():VM(e.currentSpan),s;if(r)s=T4({name:t,parent:o,annotations:Ve(n?.annotations??Et(),Af,!0)});else{let i=e.getRef(og),a=e.getRef(mo),c=e.getRef(ru),u=e.getRef(Ld),f=e.getRef(Bd),l=n?.level??e.getRef(kO),p=n?.links!==void 0?[...f,...n.links]:f.length===0?[]:f.slice();s=i.span({name:t,parent:o,annotations:n?.annotations??Et(),links:p,startTime:c?a.currentTimeNanosUnsafe():BigInt(0),kind:n?.kind??"internal",root:n?.root??xe(o),sampled:n?.sampled??(Te(o)&&o.value.sampled===!1?!1:!cP(e.getRef(CO),l))});for(let m in u)s.attribute(m,u[m]);if(n?.attributes!==void 0)for(let m in n.attributes)s.attribute(m,n.attributes[m])}return s},JM=(e,t)=>pe(n=>J(J0(n,e,t))),ds=(e,t)=>oa(pe(n=>{let r=Jn(n.context,Ya),o=J0(n,e,t??{}),s=n.getRef(mo),i=n.getRef(ru);return Pn(ps(r,a=>Bg(o,a,s,i)),o)})),GM=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],n=Po(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return ne(ds(t,n),o=>_f(r,o,n))}return r=>ne(ds(t,n),o=>_f(r,o,n))},k4=(e,t)=>(t=typeof t=="function"?t:rs,na(Rf,n=>({name:e,stack:t,parent:n}))),ZM=Ld,QM=Bd,YM=d(e=>ve(e[0]),(e,t,n={})=>{let o=(Array.isArray(t)?t:[t]).map(s=>({span:s,attributes:n}));return na(e,Bd,s=>[...s,...o])}),Bg=(e,t,n,r)=>ge(()=>{e.status._tag!=="Ended"&&e.end(r?n.currentTimeNanosUnsafe():e0,t)}),jd=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return pe(o=>{let s=J0(o,e,n),i=o.getRef(mo),a=o.getRef(ru);return Gn(je(()=>r(s)),c=>Bg(s,c,i,a))})},t0=vr(ti),_f=function(){let e=ve(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=B;return t._tag==="Span"&&(n=Po(n),r=k4(t.name,n?.captureStackTrace)),e?t0(r(arguments[0]),t):o=>t0(r(o),t)},XM=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],n=Po(arguments[2]);if(e){let s=arguments[0];return jd(t,arguments[2],i=>_f(s,i,n))}let r=typeof arguments[1]=="function"?arguments[1]:void 0,o=r?void 0:arguments[1];return(s,...i)=>jd(t,r?r(...i):o,a=>_f(s,a,n))},eP=d(e=>ve(e[0]),(e,...t)=>na(e,Ld,n=>{let r=t.length===1?{...n,...t[0]}:{...n};return t.length===1||W(r,t[0],t[1]),r})),tP=(...e)=>pe(t=>{let n=t.currentSpanLocal;if(n)if(e.length===1)for(let[r,o]of Object.entries(e[0]))n.attribute(r,o);else n.attribute(e[0],e[1]);return we}),nP=pe(e=>{let t=e.currentSpanLocal;return t?J(t):wt(new os)}),rP=p4(ti),mo=Me("effect/Clock",{defaultValue:()=>new n0}),JE=2**31-1,n0=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=ge(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return C4()}currentTimeNanos=ge(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return sP()}monotonicTimeNanos=ge(()=>this.monotonicTimeNanosUnsafe());sleep(t){return this.sleepMillis(Tn(t))}sleepMillis(t){return t<=0?Pf:Number.isFinite(t)?Bt(n=>{let r=t>JE?this.sleepMillis(t-JE):we,o=setTimeout(()=>n(r),Math.min(t,JE));return ge(()=>clearTimeout(o))}):$d}},oP=BigInt(1e6),sP=(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 n=BigInt(Date.now())*oP;return n>t&&(t=n),t}})(),C4=(function(){let e=BigInt(1e9),t;return()=>{let n=sP(),r=BigInt(Date.now())*oP;if(t===void 0)t=r-n;else{let o=t+n;(r>o?r-o:o-r)>e&&(t=r-n)}return t+n}})(),$r=e=>pe(t=>e(t.getRef(mo))),fu=e=>$r(t=>t.sleep(gt(e))),jg=$r(e=>e.currentTimeMillis),iP=$r(e=>e.currentTimeNanos),aP=$r(e=>e.monotonicTimeNanos),r0="~effect/Cause/TimeoutError";var lg=class extends Hi("TimeoutError"){[r0]=r0;constructor(t){super({message:t})}},o0="~effect/Cause/IllegalArgumentError";var dg=class extends Hi("IllegalArgumentError"){[o0]=o0;constructor(t){super({message:t})}},s0="~effect/Cause/ExceededCapacityError";var pg=class extends Hi("ExceededCapacityError"){[s0]=s0;constructor(t){super({message:t})}},i0="~effect/Cause/AsyncFiberError";var mg=class extends Hi("AsyncFiberError"){[i0]=i0;constructor(t){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:t})}},a0="~effect/Cause/UnknownError";var qd=class extends Hi("UnknownError"){[a0]=a0;constructor(t,n){super({message:n,cause:t})}},A4=Me("effect/Console/CurrentConsole",{defaultValue:()=>globalThis.console}),R4=e=>{switch(e){case"All":return Number.MIN_SAFE_INTEGER;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 Number.MAX_SAFE_INTEGER}},O4=cE(fo,R4),cP=Wi(O4),G0=Me("effect/Loggers/CurrentLoggers",{defaultValue:()=>new Set([N4,L4])}),_4=Me("effect/Logger/LogToStderr",{defaultValue:jc}),uP=function(){let e=typeof arguments[0]=="string"?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return oa(pe(t=>{let n=t.getRef(Xi),r={...n};for(let o=0;o<e.length;o++){let[s,i]=e[o];W(r,s,i)}return t.setContext(Ve(t.context,Xi,r)),ps(Jn(t.context,Ya),o=>{let s=t.getRef(Xi),i={...s};for(let a=0;a<e.length;a++){let[c,u]=e[a];s[c]===u&&(Object.hasOwn(n,c)?W(i,c,n[c]):delete i[c])}return t.setContext(Ve(t.context,Xi,i)),we})}))},M4="~effect/Logger",P4={[M4]:{_Message:B,_Output:B},pipe(){return ie(this,arguments)}},fP=e=>{let t=Object.create(P4);return t.log=e,t},F4=e=>e.replace(/[\s="]/g,"_"),U4=(e,t)=>`${F4(e[0])}=${t-e[1]}ms`;var hs=e=>(...t)=>{let n;for(let r=0,o=t.length;r<o;r++){let s=t[r];xf(s)&&(n?t.splice(r,1):t=t.slice(0,r).concat(t.slice(r+1)),n=n?$i(n.reasons.concat(s.reasons)):s,r--)}return n===void 0&&(n=Ph),pe(r=>{let o=e??r.currentLogLevel;if(cP(r.minimumLogLevel,o))return we;let s=r.getRef(mo),i=r.getRef(G0);if(i.size>0){let a=new Date(s.currentTimeMillisUnsafe());for(let c of i)c.log({cause:n,fiber:r,date:a,logLevel:o,message:t})}return we})};var ou={bold:"1",red:"31",green:"32",yellow:"33",blue:"34",cyan:"36",white:"37",gray:"90",black:"30",bgBrightRed:"101"},eie={None:[],All:[],Trace:[ou.gray],Debug:[ou.blue],Info:[ou.green],Warn:[ou.yellow],Error:[ou.red],Fatal:[ou.bgBrightRed,ou.black]};var D4=e=>`${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}.${e.getMilliseconds().toString().padStart(3,"0")}`;var N4=fP(({cause:e,date:t,fiber:n,logLevel:r,message:o})=>{let s=Array.isArray(o)?o.slice():[o];e.reasons.length>0&&s.push(gg(e));let i=t.getTime(),a=n.getRef(ag),c="";for(let p of a)c+=` ${U4(p,i)}`;let u=n.getRef(Xi);Object.keys(u).length>0&&s.push(u);let f=n.getRef(A4);(n.getRef(_4)?f.error:f.log)(`[${D4(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...s)}),L4=fP(({cause:e,fiber:t,logLevel:n,message:r})=>{let o=t.getRef(mo),s=t.getRef(Xi),i=t.currentSpan;if(i===void 0||i._tag==="ExternalSpan")return;let a={};for(let[c,u]of Object.entries(s))W(a,c,u);a["effect.fiberId"]=t.id,a["effect.logLevel"]=n.toUpperCase(),e.reasons.length>0&&(a["effect.cause"]=gg(e)),i.event(JA(Array.isArray(r)&&r.length===1?r[0]:r),o.currentTimeNanosUnsafe(),a)});function B4(){ZE.interruptChildren??=f4}var qg=J(void 0);var lP=d(e=>ve(e[0]),(e,t)=>D0(e,n=>pe(r=>(j4(r,n,t?.defectsOnly),we)))),j4=(e,t,n)=>{let r=e.getRef(RO);if(r.size===0||n&&!jO(t))return;let o={cause:t,fiber:e,timestamp:e.getRef(mo).currentTimeNanosUnsafe()};r.forEach(s=>s.report(o))};var $f=xf,zf=YA,$g=Ba;var Xa=$i,dP=Ph,pP=yf,mP=nE,hP=Za,Hf=e=>new Jc(e),Wf=e=>new Ed(e),lu=NO,Z0=$O,ec=zO;var du=hg,gP=LO;var Kf=ri;var Q0=u0;var xP=qO;var yP=gg;var Vf=os,Gd=Cd;var SP=Zc,me=tR;var zg=dg;var bP=pg;var le={};ns(le,{Do:()=>l6,Transaction:()=>nl,TypeId:()=>r6,abortSignal:()=>lK,acquireDisposable:()=>oK,acquireRelease:()=>ic,acquireUseRelease:()=>FF,addFinalizer:()=>UF,all:()=>o6,andThen:()=>Dn,annotateCurrentSpan:()=>bK,annotateLogs:()=>xx,annotateLogsScoped:()=>HK,annotateSpans:()=>SK,as:()=>zt,asSome:()=>dx,asVoid:()=>jo,awaitAllChildren:()=>OK,bind:()=>m6,bindTo:()=>d6,cached:()=>hx,cachedInvalidateWithTTL:()=>fK,cachedWithTTL:()=>uK,callback:()=>ws,catch:()=>bu,catchCause:()=>ft,catchCauseFilter:()=>O6,catchCauseIf:()=>R6,catchDefect:()=>Mw,catchEager:()=>yx,catchFilter:()=>C6,catchIf:()=>k6,catchNoSuchElement:()=>A6,catchReason:()=>I6,catchReasons:()=>v6,catchTag:()=>AF,catchTags:()=>RF,clockWith:()=>Iu,context:()=>ar,contextWith:()=>cr,currentParentSpan:()=>wK,currentSpan:()=>EK,delay:()=>aa,die:()=>ho,effectify:()=>nV,ensuring:()=>ca,eventually:()=>U6,exit:()=>Vr,fail:()=>G,failCause:()=>ct,failCauseSync:()=>ia,failSync:()=>lx,fiber:()=>_K,fiberId:()=>MK,filter:()=>Lw,filterMap:()=>K6,filterMapEffect:()=>Bw,filterMapOrElse:()=>V6,filterMapOrFail:()=>J6,filterOrElse:()=>_F,filterOrFail:()=>MF,findFirst:()=>c6,findFirstFilter:()=>u6,firstSuccessOf:()=>j6,flatMap:()=>R,flatMapEager:()=>Bn,flatten:()=>Ow,flip:()=>E6,fn:()=>DK,fnUntraced:()=>Se,fnUntracedEager:()=>Sx,forEach:()=>Lo,forever:()=>Ht,forkChild:()=>il,forkDetach:()=>al,forkIn:()=>Ut,forkScoped:()=>Is,fromNullishOr:()=>y6,fromOption:()=>g6,fromResult:()=>Rw,gen:()=>$t,head:()=>f6,ignore:()=>Fw,ignoreCause:()=>Uw,interrupt:()=>xo,interruptible:()=>ua,interruptibleMask:()=>Ww,isEffect:()=>Cr,isFailure:()=>X6,isSuccess:()=>eK,let:()=>p6,linkSpans:()=>TK,log:()=>NK,logDebug:()=>qK,logError:()=>hp,logFatal:()=>LK,logInfo:()=>jK,logTrace:()=>$K,logWarning:()=>BK,logWithLevel:()=>cl,makeSpan:()=>Vw,makeSpanScoped:()=>Jw,map:()=>Y,mapBoth:()=>_6,mapBothEager:()=>fn,mapEager:()=>fa,mapError:()=>ol,mapErrorEager:()=>vu,match:()=>jw,matchCause:()=>Z6,matchCauseEager:()=>Q6,matchCauseEffect:()=>Jr,matchCauseEffectEager:()=>Y6,matchEager:()=>G6,matchEffect:()=>PF,never:()=>Kr,onError:()=>go,onErrorFilter:()=>iK,onErrorIf:()=>sK,onExit:()=>ur,onExitFilter:()=>cK,onExitIf:()=>aK,onExitPrimitive:()=>Hw,onInterrupt:()=>pi,option:()=>b6,orDie:()=>di,orElseSucceed:()=>B6,partition:()=>s6,promise:()=>ux,provide:()=>qw,provideContext:()=>Nn,provideService:()=>qo,provideServiceEffect:()=>rK,race:()=>W6,raceAll:()=>Nw,raceAllFirst:()=>H6,raceFirst:()=>sc,reduce:()=>i6,repeat:()=>DF,repeatOrElse:()=>dK,replicate:()=>pK,replicateEffect:()=>Kw,request:()=>AK,requestUnsafe:()=>RK,result:()=>S6,retry:()=>px,retryOrElse:()=>Pw,runCallback:()=>PK,runCallbackWith:()=>Gw,runFork:()=>mp,runForkWith:()=>Ln,runPromise:()=>Zw,runPromiseExit:()=>gx,runPromiseExitWith:()=>FK,runPromiseWith:()=>Qw,runSync:()=>hi,runSyncExit:()=>ac,runSyncExitWith:()=>UK,runSyncWith:()=>Yw,sandbox:()=>D6,satisfiesErrorType:()=>oV,satisfiesServicesType:()=>sV,satisfiesSuccessType:()=>rV,schedule:()=>mK,scheduleFrom:()=>NF,scope:()=>$o,scoped:()=>wu,scopedWith:()=>dp,service:()=>$w,serviceOption:()=>Eu,setContext:()=>tK,sleep:()=>oc,spanAnnotations:()=>IK,spanLinks:()=>vK,succeed:()=>v,succeedNone:()=>Es,succeedSome:()=>fx,suspend:()=>K,sync:()=>se,tap:()=>Mt,tapCause:()=>fp,tapCauseFilter:()=>F6,tapCauseIf:()=>P6,tapDefect:()=>OF,tapError:()=>up,tapErrorTag:()=>M6,timed:()=>z6,timeout:()=>Dw,timeoutOption:()=>q6,timeoutOrElse:()=>$6,tracer:()=>hK,track:()=>KK,trackDefects:()=>GK,trackDuration:()=>ZK,trackErrors:()=>JK,trackSuccesses:()=>VK,transposeOption:()=>x6,try:()=>Bo,tryPromise:()=>bs,tx:()=>QK,txRetry:()=>tV,undefined:()=>rl,uninterruptible:()=>mi,uninterruptibleMask:()=>yo,unwrapReason:()=>T6,updateContext:()=>lp,updateService:()=>zw,updateServiceScoped:()=>nK,useSpan:()=>pp,validate:()=>a6,void:()=>H,when:()=>mx,whileLoop:()=>Qn,withErrorReporting:()=>L6,withExecutionPlan:()=>N6,withFiber:()=>xn,withLogSpan:()=>WK,withLogger:()=>zK,withParentSpan:()=>sl,withSpan:()=>kK,withSpanScoped:()=>CK,withTracer:()=>gK,withTracerEnabled:()=>xK,withTracerTiming:()=>yK,yieldNow:()=>cp,yieldNowWith:()=>h6,zip:()=>_w,zipWith:()=>w6});var gs=tE,kn=rt,jt=On,Fo=co,Hg=uo,Wg=wg,Vt=Ir;var Ft=Uf,ii=S_;var EP=T_;var Wr={};ns(Wr,{CurrentMemoMap:()=>hu,build:()=>MP,buildWithMemoMap:()=>ci,buildWithScope:()=>Zd,catch:()=>o8,catchCause:()=>i8,catchTag:()=>s8,effect:()=>Hr,effectContext:()=>Gf,effectDiscard:()=>Y4,empty:()=>Q4,flatMap:()=>UP,forkMemoMap:()=>Z4,forkMemoMapUnsafe:()=>rw,fresh:()=>a8,fromBuild:()=>tc,fromBuildMemo:()=>Zg,isLayer:()=>Gg,launch:()=>c8,makeMemoMap:()=>G4,makeMemoMapUnsafe:()=>ai,merge:()=>e8,mergeAll:()=>Qg,mock:()=>u8,orDie:()=>Yg,parentSpan:()=>NP,provide:()=>ys,provideMerge:()=>Qd,satisfiesErrorType:()=>d8,satisfiesServicesType:()=>p8,satisfiesSuccessType:()=>l8,span:()=>m8,succeed:()=>ui,succeedContext:()=>gu,suspend:()=>X4,sync:()=>ow,syncContext:()=>ew,tap:()=>t8,tapCause:()=>r8,tapError:()=>n8,unwrap:()=>tw,updateService:()=>DP,withParentSpan:()=>nw,withSpan:()=>h8});var q4="~effect/Deferred";var $4={[q4]:{_A:B,_E:B},pipe(){return ie(this,arguments)}},pu=()=>{let e=Object.create($4);return e.resumes=void 0,e.effect=void 0,e};var mu=e=>Bt(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),ge(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)})));var z4=d(2,(e,t)=>ge(()=>Jf(e,t))),Y0=z4;var H4=d(2,(e,t)=>Y0(e,On(t)));var X0=d(2,(e,t)=>H4(e,Za(t)));var Jf=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let r=0;r<n.length;r++)n[r](t)}return!0};var wP=Xi;var IP=ag,vP=Rf;var TP=ru,kP=OO;var It=Ya;var zr=cu,Uo=sM,Do=ps,_t=rM;var Cn=nM,Je=M0;var _P="~effect/Layer",CP="~effect/Layer/MemoMap",K4=(e,t)=>(e.observers++,jr(ps(t,n=>e.finalizer(n)),e.effect)),Gg=e=>j(e,_P),V4={[_P]:{_ROut:B,_E:B,_RIn:B},pipe(){return ie(this,arguments)}},xu=e=>{let t=Object.create(V4);return t.build=e,t},tc=e=>xu((t,n)=>{let r=Cn(n);return Gn(e(t,r),o=>o._tag==="Failure"?Je(r,o):we)}),Zg=e=>{let t=tc((n,r)=>n.getOrElseMemoize(t,r,e));return t},J4=(e,t,n,r)=>{let o=zr(),s=pu(),i={observers:1,effect:mu(s),finalizer:a=>he(()=>(i.observers--,i.observers===0?(e.map.delete(t),Je(o,a)):we))};return e.map.set(t,i),ps(n,i.finalizer).pipe(ne(()=>r(e,o)),Gn(a=>(i.effect=a,Y0(s,a))))},Jg=class{get[CP](){return CP}parent;constructor(t){this.parent=t}map=new Map;get(t,n){let r=this.map.get(t);return r?K4(r,n):this.parent?.get(t,n)}getOrElseMemoize(t,n,r){return he(()=>{let o=this.get(t,n);return o||J4(this,t,n,r)})}},ai=()=>new Jg,rw=e=>new Jg(e),G4=ge(ai),Z4=e=>ge(()=>rw(e)),hu=class e extends Ke()("effect/Layer/CurrentMemoMap"){static forkOrCreate(t){let n=Vi(t,e);return n?rw(n):ai()}},ci=d(3,(e,t,n)=>vr(Be(e.build(t,n),Ve(hu,t)),hu,t)),MP=e=>pe(t=>ci(e,hu.forkOrCreate(t.context),Jn(t.context,It))),Zd=d(2,(e,t)=>pe(n=>ci(e,hu.forkOrCreate(n.context),t))),ui=function(){return arguments.length===1?e=>gu(cs(arguments[0],e)):gu(cs(arguments[0],arguments[1]))},gu=e=>xu(Qe(J(e))),Q4=gu(Et()),ow=function(){return arguments.length===1?e=>ew(()=>cs(arguments[0],e())):ew(()=>cs(arguments[0],arguments[1]()))},ew=e=>Zg(Qe(ge(e))),Hr=function(){return arguments.length===1?e=>AP(arguments[0],e):AP(arguments[0],arguments[1])},AP=(e,t)=>Gf(Be(t,n=>cs(e,n))),Gf=e=>Zg((t,n)=>Uo(e,n)),Y4=e=>Gf(Pn(e,Et())),X4=e=>Zg((t,n)=>he(()=>e().build(t,n))),tw=e=>{let t=Ke("effect/Layer/unwrap");return UP(Hr(t)(e),$e(t))},PP=(e,t,n)=>{let r=Cn(n,"parallel");return Br(e,o=>o.build(t,Cn(r,"sequential")),{concurrency:e.length}).pipe(Be(o=>eO(...o)))},Qg=(...e)=>tc((t,n)=>PP(e,t,n)),e8=d(2,(e,t)=>Qg(e,...Array.isArray(t)?t:[t])),FP=(e,t,n)=>tc((r,o)=>ne(Array.isArray(t)?PP(t,r,o):t.build(r,o),s=>e.build(r,o).pipe(ra(s),Be(i=>n(i,s))))),ys=d(2,(e,t)=>FP(e,t,B)),Qd=d(2,(e,t)=>FP(e,t,(n,r)=>br(r,n))),UP=d(2,(e,t)=>tc((n,r)=>ne(e.build(n,r),o=>t(o).build(n,r)))),t8=d(2,(e,t)=>tc((n,r)=>ne(e.build(n,r),o=>Uo(Pn(t(o),o),r)))),n8=d(2,(e,t)=>tc((n,r)=>kr(e.build(n,r),o=>Uo(jr(t(o),wt(o)),r)))),r8=d(2,(e,t)=>tc((n,r)=>Tr(e.build(n,r),o=>Uo(jr(t(o),ot(o)),r)))),Yg=e=>xu((t,n)=>Ag(e.build(t,n))),o8=d(2,(e,t)=>xu((n,r)=>kr(e.build(n,r),o=>t(o).build(n,r))));var s8=d(3,(e,t,n)=>xu((r,o)=>Cg(e.build(r,o),t,s=>n(s).build(r,o)))),i8=d(2,(e,t)=>xu((n,r)=>Tr(e.build(n,r),o=>t(o).build(n,r)))),DP=d(3,(e,t,n)=>ys(e,Hr(t,Be(t,n)))),a8=e=>xu((t,n)=>e.build(ai(),n)),c8=e=>_g(jr(MP(e),$d)),u8=function(){return arguments.length===1?e=>RP(arguments[0],e):RP(arguments[0],arguments[1])},RP=(e,t)=>ui(e)(new Proxy({...t},{get(n,r,o){if(r in n)return n[r];let s=ni();ir(2);let i=new Error(`${e.key}: Unimplemented method "${r.toString()}"`);return ir(s),i.name="UnimplementedError",f8(i)},has:Xt})),f8=e=>{let t=Object.assign(ta(e),{[OP]:OP,channel:{[Vg]:Vg,transform:()=>J(t),pipe(){return ie(this,arguments)}},[Vg]:Vg,transform:()=>J(t)});function n(){return t}return Object.assign(n,t),Object.setPrototypeOf(n,Object.getPrototypeOf(t)),n},OP="~effect/Stream",Vg="~effect/Channel",l8=()=>e=>e,d8=()=>e=>e,p8=()=>e=>e,m8=(e,t)=>(t=Po(t),Hr(ti,t?.onEnd?oi(ds(e,t),n=>Bf(r=>t.onEnd(n,r))):ds(e,t))),NP=e=>gu(ti.context(e)),h8=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],n=Po(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return tw(Be(n?.onEnd!==void 0?oi(ds(t,n),o=>Bf(s=>n.onEnd(o,s))):ds(t,n),o=>nw(r,o)))}return r=>tw(Be(n?.onEnd!==void 0?oi(ds(t,n),o=>Bf(s=>n.onEnd(o,s))):ds(t,n),o=>nw(r,o)))},nw=function(){let e=Gg(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=B;t._tag==="Span"&&(n=Po(n),r=g8(t.name,n?.captureStackTrace));let o=NP(t);return e?ys(r(arguments[0]),o):s=>ys(r(s),o)},g8=(e,t)=>(t=typeof t=="function"?t:rs,DP(vP,n=>({name:e,stack:t,parent:n})));var LP="~effect/ExecutionPlan";var x8={[LP]:LP,get captureRequirements(){let e=this;return Qa(t=>J(y8(e.steps.map(n=>({...n,provide:Gg(n.provide)?ys(n.provide,gu(t)):n.provide})))))},pipe(){return ie(this,arguments)}},y8=e=>{let t=Object.create(x8);return t.steps=e,t};var Xg=Me("effect/ExecutionPlan/CurrentMetadata",{defaultValue:Qe({attempt:0,stepIndex:0})});var fi={};ns(fi,{Clock:()=>nc,clockWith:()=>S8,currentTimeMillis:()=>b8,currentTimeNanos:()=>E8,monotonicTimeNanos:()=>w8});var nc=mo,S8=$r,b8=jg,E8=iP,w8=aP;var ex="~effect/time/DateTime",tx="~effect/time/DateTime/TimeZone",jP={[ex]:ex,pipe(){return ie(this,arguments)},[at](){return this.toString()},toJSON(){return tp(this).toJSON()}},I8={...jP,_tag:"Utc",[Oe](){return Nr(this.epochMilliseconds)},[_e](e){return Zf(e)&&e._tag==="Utc"&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${tp(this).toJSON()})`}},v8={...jP,_tag:"Zoned",[Oe](){return Nt(Nr(this.epochMilliseconds))(ce(this.zone))},[_e](e){return Zf(e)&&e._tag==="Zoned"&&this.epochMilliseconds===e.epochMilliseconds&&ae(this.zone,e.zone)},toString(){return`DateTime.Zoned(${xw(this)})`}},qP={[tx]:tx,[at](){return this.toString()}},T8={...qP,_tag:"Named",[Oe](){return it(`Named:${this.id}`)},[_e](e){return Su(e)&&e._tag==="Named"&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},k8={...qP,_tag:"Offset",[Oe](){return it(`Offset:${this.offset}`)},[_e](e){return Su(e)&&e._tag==="Offset"&&this.offset===e.offset},toString(){return`TimeZone.Offset(${mw(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},li=(e,t,n)=>{let r=Object.create(v8);return r.epochMilliseconds=e,r.zone=t,Object.defineProperty(r,"partsUtc",{value:n,enumerable:!1,writable:!0}),Object.defineProperty(r,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(r,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),r},Zf=e=>j(e,ex);var Su=e=>j(e,tx),$P=e=>Su(e)&&e._tag==="Offset",zP=e=>Su(e)&&e._tag==="Named",HP=e=>e._tag==="Utc",cw=e=>e._tag==="Zoned",WP=un((e,t)=>e.epochMilliseconds===t.epochMilliseconds),KP=ss((e,t)=>e.epochMilliseconds<t.epochMilliseconds?-1:e.epochMilliseconds>t.epochMilliseconds?1:0);var VP=e=>{let t=Object.create(I8);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},yu=e=>{let t=e.getTime();if(Number.isNaN(t))throw new zg("Invalid date");return VP(t)},nx=e=>{if(Zf(e))return e;if(e instanceof Date)return yu(e);if(typeof e=="object"){if("epochMilliseconds"in e)return yu(new Date(e.epochMilliseconds));let t=new Date(0);return F8(t,e),yu(t)}else if(typeof e=="string"&&!C8(e))return yu(new Date(e+"Z"));return yu(new Date(e))},C8=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),A8=-864e13+720*60*1e3,R8=864e13-840*60*1e3,uw=(e,t)=>{let n=t?.timeZone;if(n===void 0&&Zf(e)&&cw(e))return e;let r=nx(e);if(r.epochMilliseconds<A8||r.epochMilliseconds>R8)throw new RangeError(`Epoch millis out of range: ${r.epochMilliseconds}`);n===void 0&&typeof e=="object"&&"timeZoneId"in e&&(n=e.timeZoneId);let o;if(n===void 0){let s=new Date(r.epochMilliseconds).getTimezoneOffset()*-60*1e3;o=ep(s)}else if(Su(n))o=n;else if(typeof n=="number")o=ep(n);else{let s=dw(n);if(xe(s))throw new zg(`Invalid time zone: ${n}`);o=s.value}return t?.adjustForTimeZone!==!0?li(r.epochMilliseconds,o,r.partsUtc):U8(r.epochMilliseconds,o,t?.disambiguation??"compatible")},iw=$a(uw),JP=$a(nx),O8=/^(.{17,35})\[(.+)\]$/,GP=e=>{let t=O8.exec(e);if(t===null){let o=gw(e);return o!==null?iw(e,{timeZone:o}):D()}let[,n,r]=t;return iw(n,{timeZone:r})};var ZP=e=>VP(e.epochMilliseconds);var Xd=new Map,_8={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},M8=e=>{let t=e.resolvedOptions().timeZone;if(Xd.has(t))return Xd.get(t);let n=Object.create(T8);return n.id=t,n.format=e,Xd.set(t,n),n},fw=e=>{if(Xd.has(e))return Xd.get(e);try{return M8(new Intl.DateTimeFormat("en-US",{..._8,timeZone:e}))}catch{throw new zg(`Invalid time zone: ${e}`)}},ep=e=>{let t=Object.create(k8);return t.offset=e,t},lw=$a(fw);var P8=/^(?:GMT|[+-])/,dw=e=>{if(P8.test(e)){let t=gw(e);return t===null?D():L(ep(t))}return lw(e)},QP=e=>e._tag==="Offset"?mw(e.offset):e.id;var tp=e=>new Date(e.epochMilliseconds),rx=e=>{if(e._tag==="Utc")return new Date(e.epochMilliseconds);if(e.zone._tag==="Offset")return new Date(e.epochMilliseconds+e.zone.offset);if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=e.zone.format.formatToParts(e.epochMilliseconds).filter(r=>r.type!=="literal"),n=new Date(0);return n.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),n.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),Number(t[6].value)),e.adjustedEpochMilliseconds=n.getTime(),n},pw=e=>rx(e).getTime()-hw(e),mw=e=>{let t=Math.abs(e),n=Math.floor(t/(3600*1e3)),r=Math.round(t%(3600*1e3)/(60*1e3));return r===60&&(n+=1,r=0),`${e<0?"-":"+"}${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`},YP=e=>mw(pw(e)),hw=e=>e.epochMilliseconds;var F8=(e,t)=>{if(t.year!==void 0&&e.setUTCFullYear(t.year),t.month!==void 0&&e.setUTCMonth(t.month-1),t.day!==void 0&&e.setUTCDate(t.day),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond)};var BP=1440*60*1e3,U8=(e,t,n)=>{if(t._tag==="Offset")return li(e-t.offset,t);let r=Yd(e-BP,e,t),o=Yd(e+BP,e,t);if(r===o)return li(e-r,t);let s=r<o,i=r-o;if(s){if(Yd(e-o,e,t)===o)return li(e-o,t);let u=li(e-r,t),f=rx(u).getTime();if(e!==f)switch(n){case"reject":{let l=new Date(e).toISOString();throw new RangeError(`Gap time: ${l} does not exist in time zone ${t.id}`)}case"earlier":return li(e-o,t);case"compatible":case"later":return u}return u}if(Yd(e-r,e,t)===r){if(n==="earlier"||n==="compatible"||Yd(e-r+i,e+i,t)===r)return li(e-r,t);if(n==="reject"){let u=new Date(e).toISOString();throw new RangeError(`Ambiguous time: ${u} occurs twice in time zone ${t.id}`)}}return li(e-o,t)},D8=/([+-])(\d{2}):(\d{2})$/,gw=e=>{let t=D8.exec(e);if(t===null)return null;let[,n,r,o]=t;return(n==="+"?1:-1)*(Number(r)*60+Number(o))*60*1e3},Yd=(e,t,n)=>{let r=n.format.formatToParts(e).find(s=>s.type==="timeZoneName")?.value??"";if(r==="GMT")return 0;let o=gw(r);return o===null?pw(li(t,n)):o};var XP=e=>tp(e).toISOString();var aw=e=>{let t=rx(e);return e._tag==="Utc"?t.toISOString():`${t.toISOString().slice(0,-1)}${YP(e)}`},xw=e=>e.zone._tag==="Offset"?aw(e):`${aw(e)}[${e.zone.id}]`;var Lie=globalThis.Number;var tF=d(2,(e,t)=>{let n=e.toString(),r=t.toString();if(n.includes("e")||r.includes("e"))return!globalThis.Number.isFinite(e)||!globalThis.Number.isFinite(t)||t===0?NaN:L8(e,t);let o=(n.split(".")[1]||"").length,s=(r.split(".")[1]||"").length,i=o>s?o:s,a=parseInt(e.toFixed(i).replace(".","")),c=parseInt(t.toFixed(i).replace(".",""));return a%c/Math.pow(10,i)});function L8(e,t){let[n,r]=eF(e),[o,s]=eF(t),i=Math.min(r,s),a=n*BigInt(10)**BigInt(r-i),c=o*BigInt(10)**BigInt(s-i),u=a%c;if(u===BigInt(0))return e<0||Object.is(e,-0)?-0:0;let f=globalThis.Number(`${u}e${i}`);return f===0?Math.sign(e)*globalThis.Number.MIN_VALUE:f}function eF(e){let t=Math.abs(e).toExponential(),n=t.indexOf("e"),r=t.slice(0,n).replace(".","");return[BigInt(r)*(e<0?-BigInt(1):BigInt(1)),globalThis.Number(t.slice(n+1))-r.length+1]}var nF=e=>{let t=Math.ceil(Math.log(e)/Math.log(2));return Math.max(Math.pow(2,t),2)};var rF=vo((e,t)=>Math.max(e,t),-1/0),oF=vo((e,t)=>Math.min(e,t),1/0);var jie=globalThis.String,ox=io;var iF=e=>e.trim();var qt=d(2,(e,t)=>Nf(e,B8,n=>t(n))),No=e=>e.reasons.some(Sw),Sw=e=>e._tag==="Fail"&&Gd(e.error),Qf=e=>{let t,n=!1;for(let r of e.reasons)Sw(r)?t??=r.error:r._tag!=="Interrupt"&&(n=!0);return t===void 0?Ae(e):n?Ae(Xa(e.reasons.filter(r=>!Sw(r)))):Ce(t)};var B8=e=>{let t=Qf(e);return Fe(t)?t:Ce(t.success.value)},bw=e=>{let t=Qf(e);return Fe(t)?jt(t.failure):kn(t.success.value)},np=d(2,(e,t)=>ls(e,{onSuccess:t.onSuccess,onFailure:n=>{let r=Qf(n);return Fe(r)?t.onFailure(r.failure):t.onDone(r.success.value)}}));var aF="~effect/Schedule";var Un=Me("effect/Schedule/CurrentMetadata",{defaultValue:Qe({input:void 0,output:void 0,duration:Gi,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),j8={[aF]:{_Out:B,_In:B,_Env:B},pipe(){return ie(this,arguments)}},Ew=e=>j(e,aF),sx=e=>{let t=Object.create(j8);return t.step=e,t},ww=()=>{let e=0,t,n;return(r,o)=>{n===void 0&&(n=r);let s=r-n,i=t===void 0?0:r-t;return t=r,{input:o,attempt:++e,start:n,now:r,elapsed:s,elapsedSincePrevious:i}}},cF=e=>sx(Be(e,t=>{let n=ww();return(r,o)=>t(n(r,o))})),ix=e=>Tr(e.step,t=>J(()=>ot(t))),Ss=e=>$r(t=>Be(ix(e),n=>{let r=ww();return o=>he(()=>{let s=t.currentTimeMillisUnsafe();return ne(n(s,o),([i,a])=>{let c=r(s,o);return c.output=i,c.duration=a,Pn(fu(a),c)})})})),Yf=e=>Be(Ss(e),t=>n=>Be(t(n),r=>r.output));var uF=e=>sx(Be(qf(e.map(ix)),t=>(n,r)=>ne(Br(t,o=>np(o(n,r),{onSuccess:s=>J(s[1]),onDone:()=>qg,onFailure:ot})),o=>{let s=q8(o);return s===void 0?me(Gi):J([s,s])}))),q8=e=>{let t;for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(t=t===void 0?r:cO(t,r))}return t},fF=(e,t=2)=>{let n=Tn(gt(e));return cF(J(r=>{let o=us(n*Math.pow(t,r.attempt-1));return J([o,o])}))};var Iw=e=>sx(Be(ix(e),t=>(n,r)=>np(t(n,r),{onSuccess:o=>J([r,o[1]]),onFailure:ot,onDone:()=>me(r)}))),lF=e=>rp(op,({attempt:t})=>J(t<=e)),Xf=e=>{let t=gt(e);return cF(J(n=>J([n.attempt-1,t])))};var rp=d(2,(e,t)=>sx(Be(ix(e),n=>{let r=ww();return(o,s)=>ne(n(o,s),i=>{let[a,c]=i,u=t({...r(o,s),output:a,duration:c});return ne(ve(u)?u:J(u),f=>f?J(i):me(a))})})));var op=Xf(Gi);var $8=(e,t,n)=>Mg(r=>ne(n?.local?ci(t,ai(),r):Zd(t,r),o=>ra(e,o))),ax=d(e=>ve(e[0]),(e,t,n)=>Dd(t)?ra(e,t):$8(e,Array.isArray(t)?Qg(...t):t,n));var vw=d(3,(e,t,n)=>ne(Ss(t),r=>{let o=Un.defaultValue();return kr(vg(oi(ne(he(()=>vr(e,Un,o)),r),s=>ge(()=>{o=s})),{disableYield:!0}),s=>Cd(s)?J(s.value):n(s,o.attempt===0?D():L(o)))})),Tw=d(3,(e,t,n)=>ne(Ss(t),r=>{let o=Un.defaultValue(),s,i=kr(he(()=>vr(e,Un,o)),a=>(s=a,ne(r(a),c=>(o=c,i))));return qt(i,a=>je(()=>n(s,a)))})),pF=d(2,(e,t)=>{let n=typeof t=="function"?t(B):Ew(t)?t:ip(t);return vw(e,n,wt)}),sp=d(2,(e,t)=>{let n=typeof t=="function"?t(B):Ew(t)?t:ip(t);return Tw(e,n,wt)}),mF=d(3,(e,t,n)=>ne(Ss(n),r=>{let o=Un.defaultValue(),s=he(()=>vr(e,Un,o));return kr(ne(r(t),i=>{o=i;let a=Qe(ne(s,r));return si({while:Xt,body:a,step(c){o=c}})}),i=>Cd(i)?J(i.value):wt(i))})),z8=Iw(op),ip=e=>{let t=e.schedule?Iw(e.schedule):z8;return e.while&&(t=rp(t,({input:n})=>{let r=e.while(n);return ve(r)?r:J(r)})),e.until&&(t=rp(t,({input:n})=>{let r=e.until(n);return ve(r)?Be(r,o=>!o):J(!r)})),e.times!==void 0&&(t=rp(t,({attempt:n})=>J(n<=e.times))),t};var kw=(e,t)=>{let n=-1,r=0,o=s=>Rg(e(s));return{begin:$r(s=>he(()=>{let i=t();i.stepIndex!==n&&(n=i.stepIndex,r=0),r++;let a={attempt:i.attempt,stepAttempt:r,stepIndex:i.stepIndex,startNanos:s.monotonicTimeNanosUnsafe()};return Pn(o({_tag:"AttemptStart",attempt:a.attempt,stepAttempt:a.stepAttempt,stepIndex:a.stepIndex}),a)})),end:(s,i)=>$r(a=>{let c=Lr(a.monotonicTimeNanosUnsafe()-s.startNanos);return o(i._tag==="Success"?{_tag:"AttemptSuccess",attempt:s.attempt,stepAttempt:s.stepAttempt,stepIndex:s.stepIndex,duration:c}:{_tag:"AttemptFailure",attempt:s.attempt,stepAttempt:s.stepAttempt,stepIndex:s.stepIndex,duration:c,cause:i.cause})})}},gF=d(e=>ve(e[0]),(e,t,n)=>he(()=>{let r=0,o={attempt:0,stepIndex:0},s=Ig(Xg,ge(()=>(o={attempt:o.attempt+1,stepIndex:r},o))),i=n?.onEvent===void 0?void 0:kw(n.onEvent,()=>o),a=i===void 0?B:u=>qr(f=>ne(i.begin,l=>Gn(f(u),p=>i.end(l,p)))),c;return ne(si({while:()=>r<t.steps.length&&(c===void 0||Fe(c)),body(){let u=t.steps[r],f=s(a(ax(e,u.provide)));if(c){let l=!1,p=f;f=he(()=>l?p:(l=!0,Mf(c))),f=sp(f,ap(u,!1))}else{let l=ap(u,!0);f=l?sp(f,l):f}return Ja(f)},step(u){c=u,r++}}),()=>Mf(c))})),ap=(e,t)=>{if(t){if(e.attempts===1||!(e.schedule||e.attempts))return}else return ip({schedule:e.schedule?e.schedule:e.attempts?void 0:H8,times:e.attempts,while:e.while});return ip({schedule:e.schedule,while:e.while,times:e.attempts?e.attempts-1:void 0})},H8=lF(1);var W8="~effect/Request",K8=Zb({_E:e=>e,_A:e=>e,_R:e=>e}),tae={...QA,[W8]:K8};var yF=e=>e;var bF=d(2,(e,t)=>{let n=r=>Bt(o=>{let s=wF(r,e,o,ea());return J8(r,s)});return ve(t)?ne(t,n):n(t)}),EF=(e,t)=>{let n=wF(t.resolver,e,t.onExit,{context:t.context,currentScheduler:$e(t.context,Ka)});return()=>IF(t.resolver,n)},cx=[],Cw=new WeakMap,wF=(e,t,n,r)=>{let o=Cw.get(e);o||(o=new Map,Cw.set(e,o));let s,i=!1,a=yF({request:t,context:r.context,uninterruptible:!1,completeUnsafe(u){i||(i=!0,n(u),s?.entrySet.delete(a))}});if(e.preCheck!==void 0&&!e.preCheck(a))return a;let c=e.batchKey(a);if(s=o.get(c),!s){if(cx.length>0)s=cx.pop(),s.key=c,s.resolver=e,s.map=o;else{let u={key:c,resolver:e,map:o,entrySet:new Set,entries:new Set,delayEffect:ne(he(()=>u.resolver.delay),f=>SF(u)),run:Gn(he(()=>u.resolver.runAll(Array.from(u.entries),u.key)),f=>{for(let l of u.entrySet)l.completeUnsafe(f._tag==="Success"?uo(new Error("Effect.request: RequestResolver did not complete request",{cause:l.request})):f);return u.entries.clear(),cx.length<128&&(u.entrySet.clear(),u.key=void 0,u.fiber=void 0,u.resolver=void 0,u.map=void 0,cx.push(u)),we})};s=u}o.set(c,s),s.fiber=sa(r.context)(s.delayEffect,{scheduler:r.currentScheduler})}return s.entrySet.add(a),s.entries.add(a),s.resolver.collectWhile(s.entries)||(s.fiber.interruptUnsafe(r.id),s.fiber=sa(r.context)(SF(s),{scheduler:r.currentScheduler})),a},IF=(e,t)=>{if(t.uninterruptible)return;let n=Cw.get(e);if(!n)return;let r=e.batchKey(t),o=n.get(r);o&&(o.entries.delete(t),o.entrySet.delete(t),o.entries.size===0&&(n.delete(r),o.fiber?.interruptUnsafe()))},J8=(e,t)=>ge(()=>IF(e,t));function SF(e){return e.map.has(e.key)?(e.map.delete(e.key),e.run):we}var Z8="effect/Metric/CurrentMetricAttributes",Q8=Me(Z8,{defaultValue:()=>({})}),Y8="~effect/observability/Metric/MetricRegistryKey",X8=Me(Y8,{defaultValue:()=>new Map}),vF="~effect/observability/Metric",TF=class{[vF]=vF;#e=new WeakMap;#t;id;description;attributes;constructor(t,n,r){this.id=t,this.description=n,this.attributes=r}valueUnsafe(t){return this.hook(t).get(t)}modifyUnsafe(t,n){return this.hook(n).modify(t,n)}updateUnsafe(t,n){return this.hook(n).update(t,n)}hook(t){let n=$e(t,Q8);if(Object.keys(n).length===0)return Kn(this.#t)?this.#t.hooks:(this.#t=this.getOrCreate(t,this.attributes),this.#t.hooks);let r=n6(this.attributes,n),o=this.#e.get(r);return Kn(o)||(o=this.getOrCreate(t,r),this.#e.set(r,o)),o.hooks}getOrCreate(t,n){let r=e6(this,n),o=$e(t,X8);if(o.has(r))return o.get(r);let s=this.createHooks(),i={id:this.id,type:this.type,description:this.description,attributes:Aw(n),hooks:s};return o.set(r,i),i}pipe(){return ie(this,arguments)}};var tl=d(2,(e,t)=>Qa(n=>ge(()=>e.updateUnsafe(t,n))));function e6(e,t){let n=`${e.type}:${e.id}`;return Kn(e.description)&&(n+=`:${e.description}`),Kn(t)&&(n+=`:${t6(t)}`),n}function t6(e){return JSON.stringify(Array.isArray(e)?e:Object.entries(e))}function n6(e,t){return{...Aw(e),...Aw(t)}}function Aw(e){return Kn(e)&&Array.isArray(e)?e.reduce((t,[n,r])=>(W(t,n,r),t),{}):e}var r6=Qs,Cr=ve,o6=qf,s6=q0,i6=hM,a6=gM,c6=xM,u6=SM,Lo=Br,f6=EM,Qn=si,ux=g0,bs=n_,v=J,Es=iu,fx=h0,K=he,se=ge,H=we;var rl=qg;var ws=Bt,Kr=$d,l6=CM,d6=AM,p6=OM;var m6=RM,$t=i_,G=wt,lx=bg,ct=ot,ia=e_,ho=ta,Bo=t_;var cp=Pf,h6=m0,xn=pe,Rw=Mf,g6=p0,x6=XO,y6=YO,R=ne,Ow=m_,Dn=jr,Mt=oi,S6=Ja,b6=J_,Vr=Kd,Y=Be,zt=Pn,dx=Ff,jo=zd,E6=u_,_w=__,w6=I0,bu=kr;var AF=Cg,RF=q_,I6=$_,v6=z_,T6=H_,ft=Tr,Mw=D_,k6=Hd,C6=kg,A6=U_,R6=T0,O6=Nf,ol=C0,_6=A0,di=Ag,up=k0,M6=B_,fp=N_,P6=L_,F6=Tg,OF=j_,U6=R0,px=sp,Pw=Tw,D6=f_,Fw=V_,Uw=Rg,N6=gF,L6=lP,B6=W_,j6=K_,Dw=X_,q6=eM,$6=_0,aa=Y_,oc=fu,z6=tM,Nw=b0,H6=E0,W6=l_,sc=Eg,Lw=vM,K6=TM,Bw=kM,_F=$0,V6=z0,MF=M_,J6=IM,mx=P_,jw=Og,G6=Wd,Z6=O0,Q6=G_,Y6=d_,Jr=ls,PF=au,X6=Z_,eK=Q_,ar=w0,cr=Qa,qw=ax,Nn=ra,tK=O_,$w=C_,Eu=A_,lp=Df,zw=na,nK=R_,qo=vr,rK=Ig,$o=Vd,wu=_g,dp=Mg,ic=Pg,oK=uM,FF=cM,UF=Bf,ca=iM,go=D0,sK=aM,iK=N0,Hw=ms,ur=Gn,aK=F0,cK=U0,hx=fM,uK=B0,fK=L0,xo=jf,ua=j0,pi=Fg,mi=oa,yo=qr,Ww=pM,lK=mM,Ht=vg,DF=pF,dK=vw,pK=v0,Kw=F_,mK=d(2,(e,t)=>NF(e,void 0,t)),NF=mF,hK=zM,gK=HM,xK=WM,yK=KM,SK=eP,bK=tP,EK=nP,wK=rP,IK=ZM,vK=QM,TK=YM,Vw=JM,Jw=ds,pp=jd,kK=XM,CK=GM,sl=_f,AK=bF,RK=EF,il=_M,Ut=H0,Is=FM,al=MM,OK=PM,_K=o_,MK=s_,mp=DM,Ln=sa,Gw=W0,PK=NM,Zw=BM,Qw=K0,gx=LM,FK=Dg,hi=qM,Yw=V0,ac=jM,UK=Ng,Se=y0,DK=a_,Iu=$r,cl=hs,NK=hs(),LK=hs("Fatal"),BK=hs("Warn"),hp=hs("Error"),jK=hs("Info"),qK=hs("Debug"),$K=hs("Trace"),zK=d(2,(e,t)=>na(e,G0,n=>new Set([...n,t]))),xx=d(e=>Cr(e[0]),(e,...t)=>na(e,wP,n=>{let r=t.length===1?{...n,...t[0]}:{...n};return t.length===1||W(r,t[0],t[1]),r})),HK=uP,WK=d(2,(e,t)=>ne(jg,n=>na(e,IP,r=>[[t,n],...r]))),KK=d(e=>Cr(e[0]),(e,t,n)=>ur(e,r=>{let o=n===void 0?r:je(()=>n(r));return tl(t,o)})),VK=d(e=>Cr(e[0]),(e,t,n)=>Mt(e,r=>{let o=n===void 0?r:n(r);return tl(t,o)})),JK=d(e=>Cr(e[0]),(e,t,n)=>up(e,r=>{let o=n===void 0?r:je(()=>n(r));return tl(t,o)})),GK=d(e=>Cr(e[0]),(e,t,n)=>OF(e,r=>{let o=n===void 0?r:je(()=>n(r));return tl(t,o)})),ZK=d(e=>Cr(e[0]),(e,t,n)=>Iu(r=>{let o=r.monotonicTimeNanosUnsafe();return ur(e,()=>{let s=r.monotonicTimeNanosUnsafe(),i=uO(gt(s),gt(o)),a=n===void 0?i:je(()=>n(i));return tl(t,a)})})),nl=class extends Ke()("effect/Effect/Transaction"){},QK=e=>xn(t=>{let n=Vi(t.context,nl);if(n)return e;n={journal:new Map,retry:!1};let r;return yo(o=>R(Qn({while:()=>!r,body:Qe(o(e).pipe(qo(nl,n),fp(()=>n.retry?o(XK(n)):H),Vr)),step(s){if(n.retry||!YK(n))return CF(n);Ft(s)?eV(t,n):CF(n),r=s}}),()=>r))}),YK=e=>{for(let[t,{version:n}]of e.journal)if(t.version!==n)return!1;return!0},XK=e=>K(()=>{let t={},n=Array.from(e.journal.keys()),r=()=>{for(let o of n)o.pending.delete(t)};return ws(o=>{let s=()=>{r(),o(H)};for(let i of n)i.pending.set(t,s);return se(r)})});function eV(e,t){for(let[n,{value:r}]of t.journal){r!==n.value&&(n.version=n.version+1,n.value=r);for(let o of n.pending.values())e.currentDispatcher.scheduleTask(o,0);n.pending.clear()}}function CF(e){e.retry=!1,e.journal.clear()}var tV=R(nl,e=>(e.retry=!0,xo)),nV=(e,t,n)=>(...r)=>ws(o=>{try{e(...r,(s,i)=>{o(s?G(t?t(s,r):s):v(i))})}catch(s){o(n?G(n(s,r)):ho(s))}}),rV=()=>e=>e,oV=()=>e=>e,sV=()=>e=>e,fa=h_,vu=g_,fn=x_,Bn=p_,yx=y_,Sx=c_;function gi(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function gp(e){return t=>gi(t)?.[e]}var Gr="~structural",Tu="~identifier",xp="~sentinels",bx="~constructor",LF=["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"],ul=gp("identifier"),Xw=gp(Tu),eI=gp("title");var BF=gp("brands"),yp=wn(e=>{let t=gi(e)?.identifier;return typeof t=="string"?t:e.getExpected(yp)});var jF=new Set([xp,Gr,"representation","arbitrary","brands","toJsonSchema","toCode","toArbitrary","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecStringTree","toCodecIso"]);var ze=Symbol();var zo=kn,vs=zo(ze),on=zo(ze),Ex=e=>e===ze?D():L(e),tI=e=>e._tag==="None"?vs:zo(e.value);var bp="~effect/SchemaIssue/Issue";function rI(e){return j(e,bp)&&e[bp]===bp}function iV(e){return Object.hasOwn(e,"input")}var So=class{[bp]=bp;constructor(t,n){n?.reportInput===!0&&t!==ze&&(this.input=t)}},vx=class extends So{_tag="Filter";filter;issue;constructor(t,n,r,o){super(r,o),this.filter=t,this.issue=n}},Tx=class extends So{_tag="Encoding";ast;issue;constructor(t,n,r,o){super(r,o),this.ast=t,this.issue=n}},Ct=class extends So{_tag="Pointer";path;issue;constructor(t,n){super(),this.path=t,this.issue=n}},sn=class extends So{_tag="MissingKey";annotations;constructor(t){super(),this.annotations=t}},la=class extends So{_tag="UnexpectedKey";ast;constructor(t,n,r){super(n,r),this.ast=t}},At=class extends So{_tag="Composite";ast;issues;constructor(t,n,r,o){super(r,o),this.ast=t,this.issues=n}},st=class extends So{_tag="InvalidType";ast;constructor(t,n,r){super(n,r),this.ast=t}},ke=class extends So{_tag="InvalidValue";annotations;constructor(t,n,r){super(n,r),this.annotations=t}};function Yn(e,t,n,r,o){return new At(e,[new Ct([t],n)],r,o)}var Cu=class extends So{_tag="Forbidden";annotations;constructor(t,n,r){super(n,r),this.annotations=t}},ll=class extends So{_tag="AnyOf";ast;issues;constructor(t,n,r,o){super(r,o),this.ast=t,this.issues=n}},kx=class extends So{_tag="OneOf";ast;successes;constructor(t,n,r,o){super(r,o),this.ast=t,this.successes=n}};function nI(e,t,n){if(rI(e))return e;if(typeof e=="string")return new ke({message:e},t,n);let r=typeof e.issue=="string"?new ke({message:e.issue},t,n):e.issue;return new Ct(e.path,r)}function qF(e,t,n){if(e!==void 0)return typeof e=="boolean"?e?void 0:new ke(void 0,t,n):nI(e,t,n)}function $F(e,t,n,r){return Array.isArray(t)?Ye(t)?t.length===1?nI(t[0],n,r):new At(e,as(t,o=>nI(o,n,r)),n,r):void 0:qF(t,n,r)}var zF=e=>{let t=dl(e);if(t!==void 0)return t;switch(e._tag){case"InvalidType":return cc(yp(e.ast),e);case"InvalidValue":{let n=oI(e);if(n!==void 0)return cc(n,e);let r=Ix(e);return r===void 0?"Expected a valid value":`Invalid data ${r}`}case"MissingKey":return"Missing key";case"UnexpectedKey":{let n=Ix(e);return n===void 0?"Expected no excess property":`Unexpected key with value ${n}`}case"Forbidden":return"Forbidden operation";case"OneOf":{let n=Ix(e);return n===void 0?"Expected exactly one member to match":`Expected exactly one member to match the input ${n}`}}},HF=e=>dl(e.issue)??dl(e);function WF(e){return t=>({issues:fl(t,[],e?.leafHook??zF,e?.checkHook??HF)})}function Ix(e){return iV(e)?X(e.input):void 0}function oI(e){let t=e.annotations?.expected;return typeof t=="string"?t:void 0}function cc(e,t){let n=Ix(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function fl(e,t,n,r){switch(e._tag){case"Filter":{let o=r(e);if(o!==void 0)return[{path:t,message:o}];if(e.issue._tag!=="InvalidValue")return fl(e.issue,t,n,r);let s=oI(e.issue);return[{path:t,message:s===void 0?cc(sI(e.filter),e):cc(s,e.issue)}]}case"Encoding":return fl(e.issue,t,n,r);case"Pointer":return fl(e.issue,[...t,...e.path],n,r);case"Composite":return e.issues.flatMap(o=>fl(o,t,n,r));case"AnyOf":return e.issues.length===0?[{path:t,message:dl(e)??cc(yp(e.ast),e)}]:e.issues.flatMap(o=>fl(o,t,n,r));default:return[{path:t,message:n(e)}]}}function sI(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(n=>sI(n)).join(" & ")}}function aV(){return e=>Sp(e,"")}var KF=aV();function Sp(e,t){let n;switch(e._tag){case"Filter":{let r=HF(e);if(r!==void 0)n=r;else{if(e.issue._tag!=="InvalidValue")return Sp(e.issue,t);let o=oI(e.issue);n=o===void 0?cc(sI(e.filter),e):cc(o,e.issue)}break}case"Encoding":return Sp(e.issue,t);case"Pointer":return Sp(e.issue,t+Oh(e.path));case"Composite":case"AnyOf":{if(e._tag==="Composite"||e.issues.length>0)return e.issues.map(r=>Sp(r,t)).join(`
|
|
24
|
+
`);n=dl(e)??cc(yp(e.ast),e);break}default:n=zF(e);break}return t?`${n}
|
|
25
|
+
at ${t}`:n}function dl(e){if(e._tag==="Pointer")return;if(e._tag==="Encoding")return dl(e.issue);let n=(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 n=="string")return n}function Ep(e){let t;for(let n of e.reasons){if(!$g(n)||!rI(n.error))return;t??=n.error}return t}function da(e,t){let n=Ep(e);if(n===void 0)throw new Error(t,{cause:e});return n}var Au=Zf,JF=Su,GF=$P,ZF=zP,QF=HP,YF=cw,iI=WP,aI=KP;var XF=yu,eU=nx;var Cx=uw;var Ax=JP,tU=GP;var Rx=ZP;var cI=fw,wp=ep,nU=lw;var rU=dw,uc=QP;var Ox=tp;var oU=hw;var sU=XP;var _x=xw;var fc=class e extends Bc{run;constructor(t){super(),this.run=t}map(t){return new e((n,r)=>this.run(n,r).pipe(fa(Lt(t))))}compose(t){return iU(this)?t:iU(t)?this:new e((n,r)=>this.run(n,r).pipe(Bn(o=>t.run(o,r))))}};function cV(e){return new fc((t,n)=>G(e(t,n)))}function uI(e){return cV((t,n)=>{let r={message:e(t)};return Te(t)?new Cu(r,t.value,n):new Cu(r)})}var aU=new fc(v);function iU(e){return e.run===aU.run}function Ts(){return aU}function fI(e){return new fc((t,n)=>xe(t)?Es:e(t.value,n))}function De(e){return Mx(Lt(e))}function Zr(e){return fI((t,n)=>e(t,n).pipe(fa(L)))}function Mx(e){return new fc(t=>v(e(t)))}function lI(){return new fc(()=>Es)}function vp(e){return new fc(t=>{let n=za(t,Kn);return Te(n)?v(n):fa(e,L)})}function Ru(){return De(globalThis.String)}function Px(){return De(globalThis.Number)}function cU(){return De(globalThis.BigInt)}function dI(){return De(e=>new globalThis.Date(e))}function uU(){return De(iF)}function fU(e){return fI((t,n)=>Bo({try:()=>L(JSON.parse(t,e?.reviver)),catch:()=>new ke({expected:"a valid JSON string"},t,n)}))}function lU(e){return fI((t,n)=>Bo({try:()=>{let r=JSON.stringify(t,e?.replacer,e?.space);if(r===void 0)throw new TypeError("Value cannot be represented as JSON");return L(r)},catch:()=>new ke({expected:"a JSON-serializable value"},t,n)}))}function pI(){return De(ng)}function Fx(){return De(EO)}function Ux(){return De(IO)}function dU(){return Zr((e,t)=>vu(Rw(Cf(e)),()=>new ke({expected:"a valid Base64 string"},e,t)))}function pU(){return Zr((e,t)=>_o(bO(e),{onFailure:()=>G(new ke({expected:"a valid Base64 string"},e,t)),onSuccess:v}))}function mU(){return Zr((e,t)=>_o(NE(e),{onFailure:()=>G(new ke({expected:"a valid Base64Url string"},e,t)),onSuccess:v}))}function hU(){return Zr((e,t)=>_o(wO(e),{onFailure:()=>G(new ke({expected:"a valid Base64Url string"},e,t)),onSuccess:v}))}function gU(){return Zr((e,t)=>_o(BE(e),{onFailure:()=>G(new ke({expected:"a valid hexadecimal string"},e,t)),onSuccess:v}))}function xU(){return Zr((e,t)=>_o(vO(e),{onFailure:()=>G(new ke({expected:"a valid hexadecimal string"},e,t)),onSuccess:v}))}function yU(){return De(encodeURIComponent)}function SU(){return Zr((e,t)=>{try{return v(globalThis.decodeURIComponent(e))}catch{return G(new ke({expected:"a valid URI component"},e,t))}})}function mI(){return Zr((e,t)=>rr(Ax(e),{onNone:()=>G(new ke({message:"Invalid DateTime input"},e,t)),onSome:n=>v(Rx(n))}))}function bU(){return De(e=>vU(Array.from(e.entries())))}var uV=TU(e=>typeof e=="string"||typeof Blob<"u"&&e instanceof Blob);function EU(){return De(e=>{let t=new FormData;return typeof e=="object"&&e!==null&&uV(e).forEach(([r,o])=>{t.append(r,o)}),t})}function wU(){return De(e=>vU(Array.from(e.entries())))}var fV=TU(io);function IU(){return De(e=>typeof e=="object"&&e!==null?new URLSearchParams(fV(e)):new URLSearchParams)}var lV=/^\d+$/;function dV(e){if(e==="")return[""];let t=e.replace(/\[(.*?)\]/g,".$1"),n=t.split("."),r=t.startsWith(".")?1:0;return n.slice(r).map(o=>lV.test(o)?globalThis.Number(o):o)}function vU(e){let t={},n=new WeakSet;function r(o,s,i){let a=Object.hasOwn(o,s)?o[s]:void 0;if(n.has(a)&&Array.isArray(a)===i)return a;let c=i?[]:{};return n.add(c),W(o,s,c),c}return e.forEach(([o,s])=>{let i=dV(o),a=t;i.forEach((c,u)=>{let f=u===i.length-1;if(Array.isArray(a)&&c==="")if(f)a.push(s);else{let l=i[u+1],p=typeof l=="number"||l==="",m=a.length;a=r(a,m,p)}else if(f){let l=Object.hasOwn(a,c);l&&Array.isArray(a[c])?a[c].push(s):l?W(a,c,[a[c],s]):W(a,c,s)}else{let l=i[u+1];a=r(a,c,typeof l=="number"||l==="")}})}),t}function TU(e){return t=>{let n=[];function r(o,s){if(e(s))n.push([o,s]);else if(Array.isArray(s))s.every(e)?s.forEach(a=>{n.push([o,a])}):s.forEach((a,c)=>{r(`${o}[${c}]`,a)});else if(typeof s=="object"&&s!==null)for(let[i,a]of Object.entries(s))r(`${o}[${i}]`,a)}for(let[o,s]of Object.entries(t))r(o,s);return n}}var kp=class e{_tag="Middleware";decode;encode;constructor(t,n){this.decode=t,this.encode=n}flip(){return new e(this.encode,this.decode)}},Tp="~effect/SchemaTransformation/Transformation",et=class e{[Tp]=Tp;_tag="Transformation";decode;encode;constructor(t,n){this.decode=t,this.encode=n}flip(){return new e(this.encode,this.decode)}compose(t){return new e(this.decode.compose(t.decode),t.encode.compose(this.encode))}};function pV(e){return j(e,Tp)&&e[Tp]===Tp}var Nx=e=>pV(e)?e:new et(e.decode,e.encode);function Ar(e){return new et(Zr(e.decode),Zr(e.encode))}function vt(e){return new et(De(e.decode),De(e.encode))}function Lx(e){return new et(Mx(e.decode),Mx(e.encode))}function kU(){return new et(uU(),Ts())}var mV=new et(Ts(),Ts());function pl(){return mV}var ml=new et(Px(),Ru()),Bx=new et(cU(),Ru()),hI=new et(dI(),De(eE)),CU=new et(dI(),De(e=>e.getTime())),AU=Ar({decode:(e,t)=>rr(iO(e),{onNone:()=>G(new ke({expected:"a valid Duration string"},e,t)),onSome:v}),encode:e=>v(globalThis.String(e))}),RU=Ar({decode:e=>v(Lr(e)),encode:(e,t)=>rr(aO(e),{onNone:()=>G(new ke({expected:"a Duration representable as a bigint"},e,t)),onSome:n=>v(n)})}),OU=vt({decode:e=>us(e),encode:e=>Tn(e)}),hV=e=>en(e)&&typeof e.message=="string",_U=e=>{let n=Object.hasOwn(e,"cause")?new Error(e.message,{cause:PU(e.cause)}):new Error(e.message);return typeof e.name=="string"&&e.name!=="Error"&&(n.name=e.name),typeof e.stack=="string"&&(n.stack=e.stack),n},gV=e=>{try{let t=Kc(e);return t===void 0?X(e):JSON.parse(t)}catch{return X(e)}},xV=(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},MU=e=>{let t=new WeakSet,n=r=>{if(qA(r)){if(t.has(r))return"[Circular]";t.add(r);let o=xV(r,e,n);return t.delete(r),o}return gV(r)};return n},PU=e=>hV(e)?_U(e):e,FU=e=>vt({decode:_U,encode:t=>MU(e)(t)}),UU=e=>vt({decode:PU,encode:MU(e)});function DU(){return vt({decode:fE,encode:Od})}function NU(){return vt({decode:uE,encode:Oo})}function LU(e){return vt({decode:Xc,encode:e?.onNoneEncoding===null?Od:Oo})}function BU(){return Lx({decode:L,encode:eu})}function jU(){return Lx({decode:e=>e.pipe(za(Kn),L),encode:eu})}var gI=Ar({decode:(e,t)=>URL.canParse(e)?v(new URL(e)):G(new ke({expected:"a valid URL string"},e,t)),encode:e=>v(e.href)}),xI=Ar({decode:(e,t)=>{let n=BR(e);return xe(n)?G(new ke({expected:"a valid BigDecimal string"},e,t)):v(n.value)},encode:e=>v(Xs(e))}),yI=new et(dU(),pI()),qU=new et(pU(),pI()),$U=new et(hU(),Fx()),zU=new et(xU(),Ux()),HU=new et(SU(),yU());function WU(e){return new et(fU(e??{}),lU(e))}var KU=new et(bU(),EU()),VU=new et(wU(),IU()),JU=vt({decode:e=>wp(e),encode:e=>e.offset}),SI=Ar({decode:(e,t)=>rr(nU(e),{onNone:()=>G(new ke({expected:"a valid IANA time zone"},e,t)),onSome:v}),encode:e=>v(e.id)}),bI=Ar({decode:(e,t)=>rr(rU(e),{onNone:()=>G(new ke({expected:"a valid time zone"},e,t)),onSome:v}),encode:e=>v(uc(e))}),EI=Ar({decode:(e,t)=>rr(Ax(e),{onNone:()=>G(new ke({expected:"a valid UTC DateTime string"},e,t)),onSome:n=>v(Rx(n))}),encode:e=>v(sU(e))}),wI=Ar({decode:(e,t)=>rr(tU(e),{onNone:()=>G(new ke({expected:"a valid Zoned DateTime string"},e,t)),onSome:v}),encode:e=>v(_x(e))});function dc(e){return t=>t._tag===e}var pc=dc("Declaration");var yV=dc("Never");var hl=dc("Literal"),II=dc("UniqueSymbol");var $I=dc("Arrays"),SV=dc("Objects"),r1=dc("Union"),bV=dc("Suspend"),Dt=class{to;transformation;constructor(t,n){this.to=t,this.transformation=n}},Xr={},Yr=class{isOptional;isMutable;constructorDefault;annotations;constructor(t,n,r=void 0,o=void 0){this.isOptional=t,this.isMutable=n,this.constructorDefault=r,this.annotations=o}},GU="~effect/Schema",Jt=class{[GU]=GU;annotations;checks;encoding;context;constructor(t=void 0,n=void 0,r=void 0,o=void 0){this.annotations=t,this.checks=n,this.encoding=r,this.context=o}toString(){return`<${this._tag}>`}},pa=class e extends Jt{_tag="Declaration";typeParameters;run;encodingChecks;encodingRun;constructor(t,n,r,o,s,i,a,c){super(r,o,s,i),this.typeParameters=t,this.run=n,this.encodingChecks=a,this.encodingRun=c}getParser(){let t;return(n,r)=>n===ze?vs:(t??=this.run(this.typeParameters))(n,this,r)}_rebuild(t,n,r,o,s){let i=xl(this.typeParameters,t);return i===this.typeParameters&&n===this.checks&&r===this.encodingChecks&&o===this.run&&s===this.encodingRun?this:new e(i,o,this.annotations,n,void 0,this.context,r,s)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let t=this.annotations?.expected;return typeof t=="string"?t:"<Declaration>"}},vI=class extends Jt{_tag="Null";getParser(){return ty(this,null)}getExpected(){return"null"}},zI=new vI;var TI=class extends Jt{_tag="Undefined";getParser(){return ty(this,void 0)}toCodecJson(){return lt(this,[o1])}getExpected(){return"undefined"}},o1=new Dt(zI,new et(De(()=>{}),De(()=>null))),HI=new TI;var kI=class extends Jt{_tag="Void";getParser(){let t=zo(void 0);return n=>n===ze?vs:t}toCodecJson(){return lt(this,[o1])}getExpected(){return"void"}},s1=new kI;var CI=class extends Jt{_tag="Never";getParser(){return As(this,jA)}getExpected(){return"never"}},i1=new CI,AI=class extends Jt{_tag="Any";getParser(){return As(this,$b)}getExpected(){return"any"}},a1=new AI,RI=class extends Jt{_tag="Unknown";getParser(){return As(this,$b)}getExpected(){return"unknown"}},ma=new RI,OI=class extends Jt{_tag="ObjectKeyword";getParser(){return As(this,gd)}getExpected(){return"object | array | function"}},c1=new OI,jx=class extends Jt{_tag="Enum";enums;constructor(t,n,r,o,s){super(n,r,o,s),this.enums=t}getParser(){let t=new Set(this.enums.map(([,n])=>n));return As(this,n=>t.has(n))}toCodecStringTree(){if(this.enums.some(([t,n])=>typeof n=="number")){let t=Object.fromEntries(this.enums.map(([n,r])=>[globalThis.String(r),r]));return lt(this,[new Dt(new Rr(Object.keys(t).map(n=>new Qr(n)),"anyOf"),new et(De(n=>t[n]),Ru()))])}return this}getExpected(){return this.enums.map(([t,n])=>JSON.stringify(n)).join(" | ")}};function u1(e){switch(e._tag){case"String":case"Number":case"BigInt":return!0;case"Literal":case"TemplateLiteral":return!e.checks;case"Union":return!e.checks&&e.types.every(u1);default:return!1}}var qx=class extends Jt{_tag="TemplateLiteral";parts;encodedParts;literals;suffixLengths;constructor(t,n,r,o,s){super(n,r,o,s);let i=[],a=[];for(let u of t){let f=jn(u);if(u1(f))i.push(f),a.push(f._tag==="Literal"?globalThis.String(f.literal):void 0);else throw new Error(`Invalid TemplateLiteral part ${f._tag}`)}let c=new Array(i.length+1);c[i.length]=0;for(let u=i.length-1;u>=0;u--)c[u]=c[u+1]+(a[u]?.length??0);this.parts=t,this.encodedParts=i,this.literals=a,this.suffixLengths=c}getParser(t){let n=t(this.asTemplateLiteralParser());return(r,o)=>{if(r===ze)return vs;let s=n(r,o);return s._tag==="Success"?on:fn(s,{onSuccess:()=>r,onFailure:i=>new At(this,[i],r,o)})}}getExpected(){return"string"}matchPart(t,n){return n1(this,t,n)===void 0?void 0:t}asTemplateLiteralParser(){let t=new Cs(!1,this.parts.map(A1),[]);return ey(yi,t,new et(Zr((n,r)=>{let o=n1(this,n,r);return o?v(o):G(new ke({expected:"a string matching template literal parts"},n,r))}),De(n=>n.join(""))))}},$x=class extends Jt{_tag="UniqueSymbol";symbol;constructor(t,n,r,o,s){super(n,r,o,s),this.symbol=t}getParser(){return ty(this,this.symbol)}toCodecStringTree(){return lt(this,[_1])}getExpected(){return globalThis.String(this.symbol)}},Qr=class extends Jt{_tag="Literal";literal;constructor(t,n,r,o,s){if(super(n,r,o,s),typeof t=="number"&&!globalThis.Number.isFinite(t))throw new Error(`A numeric literal must be finite, got ${X(t)}`);this.literal=t}getParser(){return ty(this,this.literal)}matchPart(t,n){return t===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal=="bigint"?ZU(this):this}toCodecStringTree(){return typeof this.literal=="string"?this:ZU(this)}getExpected(){return typeof this.literal=="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};function ZU(e){let t=globalThis.String(e.literal);return lt(e,[new Dt(new Qr(t),new et(De(()=>e.literal),De(()=>t)))])}var _I=class extends Jt{_tag="String";getParser(){return As(this,io)}matchPart(t,n){let r=this.checks;return r&&!n.disableChecks&&Rs(r,t,void 0,this,n)?void 0:t}getExpected(){return"string"}},yi=new _I,MI=class extends Jt{_tag="Number";getParser(){return As(this,md)}matchKey(t,n){return this._match(MV,t,n)}matchPart(t,n){return this._match(BI,t,n)}_match(t,n,r){if(!t.test(n))return;let o=globalThis.Number(n);return r.disableChecks||!this.checks?o:Rs(this.checks,o,void 0,this,r)?void 0:o}toCodecJson(){return this.checks&&(PI(this.checks,"effect/schema/isFinite")||PI(this.checks,"effect/schema/isInt"))?this:lt(this,[kV])}toCodecStringTree(){return this.toCodecJson()===this?lt(this,[PV]):lt(this,[FV])}getExpected(){return"number"}};function PI(e,t){return e.some(n=>n.annotations?.representation?.id===t||n._tag==="FilterGroup"&&PI(n.checks,t))}var WI=new MI,FI=class extends Jt{_tag="Boolean";getParser(){return As(this,DA)}getExpected(){return"boolean"}},f1=new FI,UI=class extends Jt{_tag="Symbol";getParser(){return As(this,qb)}matchKey(t,n){return n.disableChecks||!this.checks?t:Rs(this.checks,t,void 0,this,n)?void 0:t}toCodecStringTree(){return lt(this,[_1])}getExpected(){return"symbol"}},l1=new UI,DI=class extends Jt{_tag="BigInt";getParser(){return As(this,NA)}matchPart(t,n){if(!jI.test(t))return;let r=globalThis.BigInt(t);return n.disableChecks||!this.checks?r:Rs(this.checks,r,void 0,this,n)?void 0:r}toCodecStringTree(){return lt(this,[DV])}getExpected(){return"bigint"}},d1=new DI,Cs=class e extends Jt{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(t,n,r,o,s,i,a,c){super(o,s,i,a),this.isMutable=t,this.elements=n,this.rest=r,this.encodingChecks=c;let u=!1;for(let f=0;f<n.length;f++)if(an(n[f]))u=!0;else if(u)throw new Error("A required element cannot follow an optional element. ts(1257)");if(u&&r.length>1)throw new Error("A required element cannot follow an optional element. ts(1257)");for(let f=1;f<r.length;f++)if(an(r[f]))throw new Error("An optional element cannot follow a rest element. ts(1266)")}getParser(t,n=t){let r=this,o,s,i=r.elements.length,a=Math.max(0,r.rest.length-1);function c(u,f){return f<i?o[f]:f>=u?s[f-u+1]:s[0]}return Sx(function*(u,f){if(u===ze)return ze;if(!Array.isArray(u))return yield*G(new st(r,u,f));o||(o=r.elements.map(g=>({ast:g,parser:n(g)})),s=r.rest.map(g=>({ast:g,parser:n(g)})));let l=u.length,p={ast:r,getParser:c,input:u,len:l,tailThreshold:Math.max(i,l-a),output:new globalThis.Array(l),issues:void 0,options:f},m=KI(f?.concurrency),h=EV(p,u,{concurrency:m?.concurrency,end:r.rest.length===0?i:Math.max(l,i+a)});if(h&&(yield*h),r.rest.length===0&&l>i)for(let g=i;g<=l-1;g++){let x=new la(r,u[g],f),E=new Ct([g],x);if(f.errors==="all")p.issues?p.issues.push(E):p.issues=[E];else return yield*G(new At(r,[E],u,f))}return p.issues?yield*G(new At(r,p.issues,u,f)):p.output})}_rebuild(t,n,r){let o=xl(this.elements,t),s=xl(this.rest,t);return o===this.elements&&s===this.rest&&n===this.checks&&r===this.encodingChecks?this:new e(this.isMutable,o,s,this.annotations,n,void 0,this.context,r)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks)}getExpected(){return"array"}},EV=Jd()({onItem(e,t,n){let r=n<e.len?t:ze;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step(e,t,n,r){if(n._tag==="Failure")return zx(e,e.ast,r,n);let o=n===on?t:n[ye];if(o!==ze)e.output[r]=o;else{let s=e.getParser(e.tailThreshold,r);if(an(s.ast))return;let i=new Ct([r],new sn(s.ast.context?.annotations));if(e.options.errors==="all")e.issues?e.issues.push(i):e.issues=[i];else return Fo(new At(e.ast,[i],e.input,e.options))}}}),KI=e=>(e=e==="unbounded"?1/0:e??1,e>1?{concurrency:e}:void 0),zx=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let o=Ep(r.cause);if(o===void 0)return jt(ec(r.cause,i=>new At(t,[new Ct([n],i)],e.input,e.options)));let s=new Ct([n],o);if(e.options.errors==="all")e.issues?e.issues.push(s):e.issues=[s];else return Fo(new At(t,[s],e.input,e.options))},Kx="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";function ha(e,t,n=Xr){let r,o;function s(i){switch(i._tag){case"String":case"TemplateLiteral":return(r??=Object.keys(e)).filter(a=>i.matchPart(a,n)!==void 0);case"Number":return(r??=Object.keys(e)).filter(a=>i.matchKey(a,n)!==void 0);case"Symbol":return(o??=Object.getOwnPropertySymbols(e)).filter(a=>i.matchKey(a,n)!==void 0);case"Union":return[...new Set(i.types.flatMap(s))];default:return[]}}return s(ev(jn(t)))}var Rp=class{name;type;constructor(t,n){this.name=t,this.type=n}};function NI(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(NI);default:return!1}}function wV(e){return NI(e)&&NI(jn(e))}var Op=class{parameter;type;constructor(t,n){if(!wV(t))throw new Error(`Invalid index signature parameter ${t._tag}`);if(this.parameter=t,this.type=n,an(n)&&!C1(n))throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},gl=class e extends Jt{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(t,n,r,o,s,i,a){super(r,o,s,i),this.propertySignatures=t,this.indexSignatures=n,this.encodingChecks=a;let c=t.map(u=>u.name).filter((u,f,l)=>l.indexOf(u)!==f);if(c.length>0)throw new Error(`Duplicate identifiers: ${JSON.stringify(c)}. ts(2300)`)}getParser(t,n=t){let r=this,o=[];for(let E of r.propertySignatures)o.push(E.name);let s=o.length,i=r.indexSignatures.length,a=s&&i?new Set(o):void 0;if(!s&&!i)return As(r,Sh);let c,u,f=(E,b,y,w,S)=>{if(S._tag==="Failure")return zx(E,r,b,S)??Vt;let C=S===on?w:S[ye];if(y!==ze&&C!==ze){if(s&&(a.has(b)||a.has(y)))return Vt;W(E.out,y,C)}return Vt},l=(E,b,y,w)=>{if(!w){let _=y.parserKey(b,E.options);if(!xt(_))return R(Vr(_),P=>l(E,b,y,P));w=_}if(w._tag==="Failure")return zx(E,r,b,w)??Vt;let S=w===on?b:w[ye],C=E.input[b],M=y.parserValue(C,E.options);return xt(M)?f(E,b,S,C,M):R(Vr(M),_=>f(E,b,S,C,_))},p=(E,b,y)=>{let w=E.input[b],S=y.parserValue(w,E.options);return xt(S)?f(E,b,b,w,S):R(Vr(S),C=>f(E,b,b,w,C))},m=i?Jd()({onItem:(E,[b,y])=>l(E,b,y),step:(E,b,y)=>y._tag==="Failure"?y:void 0}):void 0,h=()=>(c||(c=r.propertySignatures.map(E=>({parser:n(E.type),name:E.name,type:E.type})),u=i?r.indexSignatures.map(E=>({is:E,parserKey:t(ev(E.parameter)),parserValue:n(E.type)})):void 0),c),g=Sx(function*(E,b){if(E===ze)return ze;if(!(typeof E=="object"&&E!==null&&!Array.isArray(E)))return yield*G(new st(r,E,b));h();let y=E,w={},S={ast:r,input:y,out:w,issues:void 0,options:b},C=b.errors==="all",M=b.onExcessProperty==="error",_=b.onExcessProperty==="preserve",P;if(!i&&(M||_)){a??=new Set(o),P=Reflect.ownKeys(y);for(let F=0;F<P.length;F++){let te=P[F];if(!a.has(te))if(M){let ee=new la(r,y[te],b),T=new Ct([te],ee);if(C){S.issues?S.issues.push(T):S.issues=[T];continue}else return yield*G(new At(r,[T],E,b))}else W(w,te,y[te])}}let $=KI(b?.concurrency);if(s){let F=QU(S,c,$);F&&(yield*F)}if(i&&!$)for(let F=0;F<i;F++){let te=u[F],ee=te.is.parameter===yi?p:l,T=te.is.parameter===yi?Object.keys(y):ha(y,te.is.parameter,b);for(let z=0;z<T.length;z++){let U=ee(S,T[z],te);if(!xt(U))yield*U;else if(U._tag==="Failure")return yield*U}}else if(m){let F=rn();for(let ee=0;ee<i;ee++){let T=u[ee],z=ha(y,T.is.parameter,b);for(let U=0;U<z.length;U++)F.push([z[U],T])}let te=m(S,F,$);te&&(yield*te)}if(S.issues)return yield*G(new At(r,S.issues,E,b));if(b.propertyOrder==="original"){let F=(P??Reflect.ownKeys(y)).concat(o),te={};for(let ee of F)Object.hasOwn(w,ee)&&W(te,ee,w[ee]);return te}return w});if(i)return g;let x=(E,b,y)=>{let w=c[b];return R(Vr(y),S=>{let C=LI(E,w,S);if(C)return C;let M=()=>zo(E.out),_=QU(E,c.slice(b+1));return _?Bn(_,M):M()})};return(E,b)=>{if(E===ze)return vs;if(b.errors==="all"||b.onExcessProperty!==void 0||b.propertyOrder==="original"||b.concurrency!==void 0)return g(E,b);if(!(typeof E=="object"&&E!==null&&!Array.isArray(E)))return G(new st(r,E,b));let y=h(),w=E,S={},C={ast:r,input:w,out:S,issues:void 0,options:b};try{for(let M=0;M<y.length;M++){let _=y[M],P=_.name,$=Object.hasOwn(w,P),F=$?w[P]:ze,te=_.parser(F,b);if(!xt(te))return x(C,M,te);if(te===on){$&&W(S,P,F);continue}let ee=LI(C,_,te);if(ee)return ee}}catch(M){return ho(M)}return zo(S)}}_rebuild(t,n,r,o){let s=xl(this.propertySignatures,a=>{let c=t(a.type);return c===a.type?a:new Rp(a.name,c)}),i=xl(this.indexSignatures,a=>{let c=n(a.parameter),u=t(a.type);return c===a.parameter&&u===a.type?a:new Op(c,u)});return s===this.propertySignatures&&i===this.indexSignatures&&r===this.checks&&o===this.encodingChecks?this:new e(s,i,this.annotations,r,void 0,this.context,o)}flip(t){return this._rebuild(t,t,this.encodingChecks,this.checks)}recur(t,n=t){return this._rebuild(t,n,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?"object | array":"object"}};function LI(e,t,n){if(n._tag==="Failure")return zx(e,e.ast,t.name,n);if(n===on)return;let r=n[ye];if(r!==ze){W(e.out,t.name,r);return}if(delete e.out[t.name],!an(t.type)){let o=new Ct([t.name],new sn(t.type.context?.annotations));if(e.options.errors==="all"){e.issues?e.issues.push(o):e.issues=[o];return}else return Fo(new At(e.ast,[o],e.input,e.options))}}var QU=Jd()({onItem(e,t){if(!Object.hasOwn(e.input,t.name))return t.parser(ze,e.options);let n=e.input[t.name];return W(e.out,t.name,n),t.parser(n,e.options)},step:LI});function VI(e,t){return e?t?[...e,...t]:e:t}function Vx(e,t,n){return new gl(Reflect.ownKeys(e).map(r=>new Rp(r,e[r].ast)),[],n,t)}function _p(e){return e.ast}function JI(e,t=void 0){return new Cs(!1,e.map(n=>n.ast),[],void 0,t)}function Jx(e,t,n){return new Rr(e.map(_p),t,void 0,n)}function p1(e,t){if(e.encoding||t.some(s=>s.encoding))throw new Error("StructWithRest does not support encodings");let n=e.propertySignatures,r=e.indexSignatures,o=e.checks;for(let s of t)n=n.concat(s.propertySignatures),r=r.concat(s.indexSignatures),o=VI(o,s.checks);return new gl(n,r,void 0,o)}function m1(e,t){if(e.encoding)throw new Error("TupleWithRest does not support encodings");return new Cs(e.isMutable,e.elements,t,void 0,e.checks)}var Gx=$c(e=>{for(;;){if(bV(e))return ma;let t=e.encoding;if(!t)return e.recur?.(Gx,B)??e;if(t.some(n=>n.transformation._tag==="Middleware"&&n.transformation.decode!==B))return ma;e=t[t.length-1].to}});function h1(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(([,t])=>typeof t)));case"Literal":return[typeof e.literal];case"Union":return Array.from(new Set(e.types.flatMap(h1)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}function lc(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[xp];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap(t=>{let n=t.type;if(!an(n)){if(hl(n))return[{key:t.name,literal:n.literal}];if(II(n))return[{key:t.name,literal:n.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,n)=>{if(!an(t)){if(hl(t))return[{key:n,literal:t.literal}];if(II(t))return[{key:n,literal:t.symbol}]}return[]});case"Union":{if(e.types.length===0)return[];let t=e.types.map(n=>lc(Gx(n)));return t[0].filter(n=>t.every(r=>r.some(o=>o.key===n.key&&o.literal===n.literal)))}case"Suspend":return lc(e.thunk())}}var YU=new WeakMap,Ap=Object.freeze([]);function IV(e){let t=YU.get(e);if(t)return t;let n,r=0,o,s,i=!0;for(let a=0;a<e.length;a++){let c=e[a],u=Gx(c);if(yV(u))continue;if(i)if(hl(u)||II(u)){s??=new Map;let l=hl(u)?u.literal:u.symbol,p=s.get(l);p||s.set(l,p=[]),p.push(c)}else i=!1;let f=lc(u);if(f.length){n??=new Map,r++;for(let{key:l,literal:p}of f){let m=n.get(l);m||n.set(l,m=[new Map,new Set]),m[1].add(a);let h=m[0].get(p);h||m[0].set(p,h=new Set),h.add(a)}}else{o??={};let l=h1(u);for(let p of l)(o[p]??=[]).push(a)}}if(i&&s)s.forEach(Object.freeze),t=a=>s.get(a)??Ap;else if(n?.size===1&&!o){let[a,[c]]=n.entries().next().value,u=c;for(let[f,l]of c)u.set(f,Object.freeze(Array.from(l,p=>e[p])));t=(f,l)=>{if(gd(f)){let p=Object.hasOwn(f,a)?f[a]:void 0;if(p!==void 0)return u.get(p)??Ap;if(l)return e}return Ap}}else if(n){let a;for(let c of n)(!a||c[1][0].size>a[1][0].size)&&c[1][1].size===r&&(a=c);t=(c,u)=>{let f=c===null?"null":Array.isArray(c)?"array":typeof c,l=o?.[f]??Ap;if(!gd(c))return l.map(h=>e[h]);let p=new Set(l),m;if(a){let[h,[g]]=a,x=Object.hasOwn(c,h),E=x?c[h]:void 0;if(x&&(!u||E!==void 0)){let b=g.get(E);if(!b)return l.map(y=>e[y]);for(let y of b)p.add(y);m=h}}if(m===void 0)for(let[h,[g,x]]of n){let E=Object.hasOwn(c,h),b=E?c[h]:void 0;if(E&&(!u||b!==void 0)){let y=g.get(b);if(y)for(let w of y)p.add(w)}else if(u)for(let y of x)p.add(y)}for(let[h,[g,x]]of n){if(h===m)continue;let E=Object.hasOwn(c,h),b=E?c[h]:void 0;if(E&&(!u||b!==void 0)){let y=g.get(b);for(let w of p)x.has(w)&&!y?.has(w)&&p.delete(w)}}return Array.from(p).sort((h,g)=>h-g).map(h=>e[h])}}else t=a=>{let c=a===null?"null":Array.isArray(a)?"array":typeof a;return(o?.[c]??Ap).map(u=>e[u]).filter(vV(a))};return YU.set(e,t),t}function vV(e){return t=>{let n=Gx(t);return n._tag==="Literal"?n.literal===e:n._tag==="UniqueSymbol"?n.symbol===e:!0}}function Mp(e,t,n=!1){return IV(t)(e,n)}var Rr=class e extends Jt{_tag="Union";types;mode;encodingChecks;constructor(t,n,r,o,s,i,a){super(r,o,s,i),this.types=t,this.mode=n,this.encodingChecks=a}getParser(t,n){let r=this;return(o,s)=>{if(o===ze)return vs;let i=Mp(o,r.types,n!==void 0);if(i.length===1){let f=t(i[0])(o,s);return f._tag==="Success"?f:xt(f)?XU(r,f.cause,o,s):ft(f,l=>XU(r,l,o,s))}let a={ast:r,compile:t,input:o,out:void 0,successes:r.mode==="oneOf"?[]:void 0,issues:void 0,options:s},c=KI(s?.concurrency),u=TV(a,i,c?{...c,orderedStep:!0}:void 0);return u?Bn(u,f=>a.out===on?v(o):a.out?a.out:G(new ll(r,a.issues??[],o,s))):a.out?a.out:G(new ll(r,a.issues??[],o,s))}}_rebuild(t,n,r){let o=xl(this.types,t);return o===this.types&&n===this.checks&&r===this.encodingChecks?this:new e(o,this.mode,this.annotations,n,void 0,this.context,r)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks)}matchPart(t,n){for(let r of this.types){let o=r.matchPart(t,n);if(o!==void 0)return o}}getExpected(t){let n=this.annotations?.expected;if(typeof n=="string")return n;if(this.types.length===0)return"never";let r=this.types.map(o=>{let s=jn(o);switch(s._tag){case"Arrays":{let i=s.elements.filter(hl);if(i.length>0)return`${e1(s.isMutable)}[ ${i.map(a=>t(a)+t1(a.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{let i=s.propertySignatures.filter(a=>hl(a.type));if(i.length>0)return`{ ${i.map(a=>`${e1(a.type.context?.isMutable)}${qi(a.name)}${t1(a.type.context?.isOptional)}: ${t(a.type)}`).join(", ")}, ... }`;break}}return t(s)});return Array.from(new Set(r)).join(" | ")}};function XU(e,t,n,r){let o=Ep(t);return o?Fo(new ll(e,[o],n,r)):jt(t)}var TV=Jd()({onItem(e,t){return e.compile(t)(e.input,e.options)},step(e,t,n){if(n._tag==="Failure"){let r=Ep(n.cause);if(r===void 0)return n;e.issues?e.issues.push(r):e.issues=[r]}else{if(e.out&&e.successes)return e.successes.push(t),Fo(new kx(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(t);else return Vt}}}),g1=new Rr([new Qr("Infinity"),new Qr("-Infinity"),new Qr("NaN")],"anyOf");function e1(e){return e?"":"readonly "}function t1(e){return e?"?":""}function _u(e){let t=!1,n;return()=>(t||(n=e(),t=!0),n)}var Hx=class e extends Jt{_tag="Suspend";thunk;constructor(t,n,r,o,s){if(r)throw new Error("Cannot add checks to Suspend");super(n,void 0,o,s),this.thunk=_u(t)}getParser(t){let n;return(r,o)=>(n??=t(this.thunk()))(r,o)}recur(t){return new e(()=>t(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(t){return t(this.thunk())}},Wx=class e extends Bc{_tag="Filter";run;annotations;aborted;constructor(t,n=void 0,r=!1){super(),this.run=t,this.annotations=n,this.aborted=r}annotate(t){return new e(this.run,{...this.annotations,...t},this.aborted)}abort(){return new e(this.run,this.annotations,!0)}and(t,n){return new Ou([this,t],n)}},Ou=class e extends Bc{_tag="FilterGroup";checks;annotations;constructor(t,n=void 0){super(),this.checks=t,this.annotations=n}annotate(t){return new e(this.checks,{...this.annotations,...t})}and(t,n){return new e([this,t],n)}};function Zx(e,t,n=!1){return new Wx((r,o,s)=>$F(o,e(r,o,s),r,s),t,n)}function Qx(e,t){return new Wx((n,r,o)=>e(n)?void 0:new ke(void 0,n,o),t,!0)}function GI(e){return Zx(t=>globalThis.Number.isFinite(t),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:()=>({type:"number"}),toCode:()=>({runtime:"Schema.isFinite()"}),arbitrary:{constraint:{noInfinity:!0,noNaN:!0}},...e})}var ZI=Si(WI,[GI()]),kV=new Dt(new Rr([ZI,g1],"anyOf"),new et(Px(),De(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function Pp(e,t){let n=e.source,r=new globalThis.RegExp(n,e.flags);return Zx(o=>(r.lastIndex=0,r.test(o)),{expected:`a string matching the RegExp ${n}`,representation:{id:"effect/schema/isPattern",payload:{source:n,flags:e.flags}},toJsonSchema:()=>({pattern:n}),arbitrary:{constraint:{patterns:[e.source]}},...t})}function Fp(e,t){let n=Object.getOwnPropertyDescriptors(e);return t(n),Object.create(Object.getPrototypeOf(e),n)}var x1=new WeakMap;function QI(e){return x1.get(e)??e}function lt(e,t){return e.encoding===t?e:Fp(e,n=>{n.encoding.value=t})}function Up(e,t){if(e.context===t)return e;let n=QI(e);if(n.context===t)return n;let r=Fp(e,o=>{o.context.value=t});return x1.set(r,n),r}function Dp(e){return e.encoding?Dp(e.encoding[e.encoding.length-1].to):e}function Ho(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Yx(e,Kh(e.checks.slice(0,-1),n.annotate(t)))}return Fp(e,n=>{n.annotations.value={...n.annotations.value,...t}})}function Yx(e,t){if(e._tag==="Suspend"&&t)throw new Error("Cannot add checks to Suspend");return e.checks===t?e:Fp(e,n=>{n.checks.value=t})}function Si(e,t){return Yx(e,VI(e.checks,t))}function mc(e,t){let n=t(e.to);return n===e.to?e:new Dt(n,e.transformation)}function y1(e,t){let n=e,r=n[n.length-1],o=mc(r,t);return o===r?e:Kh(e.slice(0,e.length-1),o)}function Xx(e){return t=>t.encoding?lt(t,y1(t.encoding,e)):t}function Sl(e,t){return Xx(n=>Up(n,t))(e)}function ga(e,t){function n(r){if(r.encoding){let o=r.encoding[r.encoding.length-1];return t?.stopAt?.(o)?r:lt(r,y1(r.encoding,n))}return e(r)}return $c(n)}function S1(e,t){return YI(e,t,yn(e))}function b1(e,t){return YI(jn(e),t,e)}function YI(e,t,n){let r=new Dt(e,t);return lt(n,n.encoding?[...n.encoding,r]:[r])}function E1(e,t){let n=BF(e),r=n?[...n,t]:[t];return Ho(e,{brands:r})}function xl(e,t){let n=!1,r=new Array(e.length);for(let o=0;o<e.length;o++){let s=e[o],i=t(s);i!==s&&(n=!0),r[o]=i}return n?r:e}function bl(e,t){let n=e.context?new Yr(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new Yr(!1,!1,void 0,t);return Up(e,n)}var El=$c(e=>{let t=e.context?e.context.isOptional===!1?new Yr(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new Yr(!0,!1);return CV(Up(e,t))}),CV=Xx(El),w1=wn(e=>El(new Rr([e,HI],"anyOf"))),XI=$c(e=>{let t=e.context?e.context.isMutable===!1?new Yr(e.context.isOptional,!0,e.context.constructorDefault,e.context.annotations):e.context:new Yr(!1,!0);return AV(Up(e,t))}),AV=Xx(XI);function I1(e,t){let n=new et(vp(t),Ts()),r=new Dt(ma,n),o=e.context?new Yr(e.context.isOptional,e.context.isMutable,r,e.context.annotations):new Yr(!1,!1,r);return Up(e,o)}function ey(e,t,n){return YI(e,n,t)}function RV(e){let t=[],n=[];function r(o){switch(o._tag){case"Literal":yh(o.literal)&&t.push(o.literal);return;case"UniqueSymbol":t.push(o.symbol);return;case"Never":return;case"Union":for(let s=0;s<o.types.length;s++)r(o.types[s]);return;default:n.push(o)}}return r(e),{literals:t,parameters:n}}function v1(e,t){let{literals:n,parameters:r}=RV(e);return new gl(n.map(o=>new Rp(o,t)),r.map(o=>new Op(o,t)))}function an(e){return e.context?.isOptional??!1}function T1(e){return e.context?.isMutable??!1}function k1(e){return e.annotations?.[Gr]===!0||e._tag==="FilterGroup"&&e.checks.every(k1)}function OV(e){function t(r){return k1(r)?[r]:r._tag==="FilterGroup"?r.checks.flatMap(t):[]}let n=e.flatMap(t);return Vn(n)?n:void 0}var yn=$c(e=>{if(e.encoding)return yn(lt(e,void 0));let t=e,n=t.recur?.(yn)??t,r=n.encodingChecks;if(r){let o=n===e?r:$I(n)||SV(n)||pc(n)&&n.typeParameters.length>0?OV(r):void 0;return Fp(n,s=>{s.encodingChecks.value=void 0,s.checks.value=VI(n.checks,o)})}return n}),jn=$c(e=>yn(ks(e)));function _V(e,t){let n=t,r=n.length,o=n[r-1],s=[new Dt(ks(lt(e,void 0)),n[0].transformation.flip())];for(let a=1;a<r;a++)s.unshift(new Dt(ks(n[a-1].to),n[a].transformation.flip()));let i=ks(o.to);return i.encoding?lt(i,[...i.encoding,...s]):lt(i,s)}var ks=wn(e=>{if(e.encoding)return _V(e,e.encoding);let t=e;return t.flip?.(ks)??t.recur?.(ks)??t});function C1(e){switch(e._tag){case"Undefined":return!0;case"Union":return e.types.some(C1);default:return!1}}function ty(e,t){let n=zo(t);return(r,o)=>r===ze?vs:r===t?n:G(new st(e,r,o))}function As(e,t){return(n,r)=>n===ze?vs:t(n)?on:G(new st(e,n,r))}function n1(e,t,n){let r=e.encodedParts,o=e.literals,s=t.length;for(let u=0;u<o.length;u++){let f=o[u];if(f&&!t.includes(f))return}if(e.suffixLengths[0]>s)return;let i=new Array(r.length),a;function c(u,f){if(u===r.length)return f===s;if(a?.has(u*(s+1)+f))return!1;let l=r[u];if(u===r.length-1){let p=t.slice(f);if(l.matchPart(p,n)!==void 0)return i[u]=p,!0}else if(l._tag==="Literal"){let p=o[u];if(t.startsWith(p,f)&&c(u+1,f+p.length))return i[u]=p,!0}else{let p=s-e.suffixLengths[u+1],m=o[u+1],h=m===void 0?p:t.lastIndexOf(m,p);for(;h>=f;){let g=t.slice(f,h);if(l.matchPart(g,n)!==void 0&&c(u+1,h))return i[u]=g,!0;if(h===0)break;h=m===void 0?h-1:t.lastIndexOf(m,h-1)}}return a??=new Set,a.add(u*(s+1)+f),!1}return c(0,0)?i:void 0}var Np=wn(e=>new Rr(e.enums.map(t=>new Qr(t[1],{title:t[0]})),"anyOf")),ev=ga(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(ev)}}),ny=ga(e=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(ny)}}),A1=ga(e=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(A1)}}),R1="[\\s\\S]*?",BI=new globalThis.RegExp(`^${Kx}$`),MV=new globalThis.RegExp(`^(?:${Kx}|Infinity|-Infinity|NaN)$`);function tv(e){return Pp(BI,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:()=>({pattern:BI.source}),...e})}var O1=Si(yi,[tv()]),PV=new Dt(O1,ml),FV=new Dt(new Rr([O1,g1],"anyOf"),ml),UV="-?\\d+",jI=new globalThis.RegExp(`^${UV}$`);function nv(e){return Pp(jI,{expected:"a string representing a bigint",representation:{id:"effect/schema/isStringBigInt",payload:null},toJsonSchema:()=>({pattern:jI.source}),...e})}var rv=Si(yi,[nv({expected:"a string representing a bigint"})]),DV=new Dt(rv,Bx),NV="Symbol\\((.*)\\)",qI=new globalThis.RegExp(`^${NV}$`),LV=Si(yi,[ov()]),_1=new Dt(LV,new et(De(e=>globalThis.Symbol.for(qI.exec(e)[1])),Zr((e,t)=>globalThis.Symbol.keyFor(e)!==void 0?v(globalThis.String(e)):G(new Cu({message:"cannot serialize to string, Symbol is not registered"},e,t)))));function ov(e){return Pp(qI,{expected:"a string representing a symbol",representation:{id:"effect/schema/isStringSymbol",payload:null},toJsonSchema:()=>({pattern:qI.source}),...e})}function Rs(e,t,n,r,o){for(let s=0;s<e.length;s++){let i=e[s];if(i._tag==="FilterGroup"){if(n=Rs(i.checks,t,n,r,o),n&&(o.errors!=="all"||n[n.length-1].filter.aborted))return n}else{let a=i.run(t,r,o);if(a){let c=new vx(i,a,t,o);if(n?n.push(c):n=[c],o.errors!=="all"||i.aborted)return n}}}return n}function M1(e,t){let n=Rs(e,t,void 0,ma,{errors:"all"});if(n){let r=new At(ma,n);return Ae(r)}return Ce(t)}function P1(e){if(!pc(e))return;let t=e.annotations?.[bx];return cn(t)?t(e.typeParameters):void 0}function BV(e){return e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&globalThis.Number.isFinite(e)}function jV(e){return e===void 0||typeof e=="string"}function F1(e,t){let n=new WeakMap,r=[];e:for(;;){if(typeof e!="object"||e===null){if(!t(e))return!1}else{let o=e,s=n.get(o);if(s===!1)return!1;if(s===void 0){let i=Array.isArray(o);if(!i){let a=Object.getPrototypeOf(o);if(a!==null&&a!==Object.prototype&&Object.getPrototypeOf(a)!==null)return!1}n.set(o,!1),r.push({value:o,keys:i?o.length:Object.keys(o),index:0})}}for(;r.length>0;){let o=r[r.length-1],s=o.keys;if(typeof s=="number"){if(o.index<s){e=o.value[o.index++];continue e}}else if(o.index<s.length){e=o.value[s[o.index++]];continue e}n.set(o.value,!0),r.pop()}return!0}}function wl(e){return F1(e,BV)}var yl=new pa([],()=>(e,t,n)=>wl(e)?on:G(new st(t,e,n)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:()=>{},toCodecStringTree:()=>iv,toArbitrary:()=>e=>e.jsonValue()}),U1=Ho(yl,{representation:{id:"effect/schema/MutableJson",payload:null}}),sv=new Dt(yl,pl()),D1=new Dt(new Rr([new Cs(!1,[],[yl]),new gl([],[new Op(yi,yl)])],"anyOf"),pl());function qV(e){return F1(e,jV)}var $V=new pa([],()=>(e,t,n)=>qV(e)?on:G(new st(t,e,n)),{expected:"StringTree",toCodecStringTree:()=>{}}),iv=new Dt($V,pl());var N1="~effect/collections/MutableHashMap";var zV={[N1]:N1,[Symbol.iterator](){return this.backing[Symbol.iterator]()},toString(){return`MutableHashMap(${X(Array.from(this))})`},toJSON(){return{_id:"MutableHashMap",values:hn(Array.from(this))}},[at](){return this.toJSON()},pipe(){return ie(this,arguments)}},hc=()=>{let e=Object.create(zV);return e.backing=new Map,e.buckets=new Map,e};var Os=d(2,(e,t)=>{if(e.backing.has(t))return L(e.backing.get(t));if(av(t))return D();let n=Lp.get(e);if(n!==void 0)return e.backing.has(n)?L(e.backing.get(n)):D();let r=ce(t),o=e.buckets.get(r);return o===void 0?D():HV(e,o,t)}),Lp=new WeakMap,av=e=>typeof e!="object"&&typeof e!="function";var HV=(e,t,n)=>{for(let r=0,o=t.length;r<o;r++)if(ae(n,t[r])){let s=t[r];return Lp.set(n,s),L(e.backing.get(s))}return D()},L1=d(2,(e,t)=>Te(Os(e,t))),gc=d(3,(e,t,n)=>{if(e.backing.has(t)||av(t))return e.backing.set(t,n),e;let r=Lp.get(e);if(r!==void 0&&e.backing.has(r))return e.backing.set(r,n),e;let o=ce(t),s=e.buckets.get(o);return s===void 0?(e.buckets.set(o,[t]),e.backing.set(t,n),e):(r=WV(s,t),r===void 0&&(s.push(t),r=t),e.backing.set(r,n),e)}),WV=(e,t)=>{for(let n=0,r=e.length;n<r;n++)if(ae(t,e[n]))return Lp.set(t,e[n]),e[n]};var Mu=d(2,(e,t)=>{if(av(t))return e.backing.delete(t),e;let n=Lp.get(e)??t,r=ce(n),o=e.buckets.get(r);if(o===void 0)return e;for(let s=0,i=o.length;s<i;s++){let a=o[s];if(a===n||ae(n,a)){e.backing.delete(a),o.splice(s,1);break}}return o.length===0&&e.buckets.delete(r),e}),ry=e=>(e.backing.clear(),e.buckets.clear(),e),B1=e=>e.backing.size;var j1="~effect/collections/Chunk";function GV(e,t,n,r,o){for(let s=t;s<Math.min(e.length,t+o);s++)n[r+s-t]=e[s];return n}var q1=[],uv=e=>un((t,n)=>t.length===n.length&&Bp(t).every((r,o)=>e(r,jp(n,o)))),ZV=uv(ae),QV={[j1]:{_A:e=>e},toString(){return`Chunk(${X(Bp(this))})`},toJSON(){return{_id:"Chunk",values:hn(Bp(this))}},[at](){return this.toJSON()},[_e](e){return Il(e)&&ZV(this,e)},[Oe](){return Fa(Bp(this))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return q1[Symbol.iterator]();default:return Bp(this)[Symbol.iterator]()}},pipe(){return ie(this,arguments)}},fv=e=>{let t=Object.create(QV);switch(t.backing=e,e._tag){case"IEmpty":{t.length=0,t.depth=0,t.left=t,t.right=t;break}case"IConcat":{t.length=e.left.length+e.right.length,t.depth=1+Math.max(e.left.depth,e.right.depth),t.left=e.left,t.right=e.right;break}case"IArray":{t.length=e.array.length,t.depth=0,t.left=xa,t.right=xa;break}case"ISingleton":{t.length=1,t.depth=0,t.left=xa,t.right=xa;break}case"ISlice":{t.length=e.length,t.depth=e.chunk.depth+1,t.left=xa,t.right=xa;break}}return t},Il=e=>j(e,j1),xa=fv({_tag:"IEmpty"}),YV=()=>xa;var XV=e=>fv({_tag:"ISingleton",a:e}),sy=e=>Il(e)?e:tJ(ht(e)),cv=(e,t,n)=>{switch(e.backing._tag){case"IArray":{GV(e.backing.array,0,t,n,e.length);break}case"IConcat":{cv(e.left,t,n),cv(e.right,t,n+e.left.length);break}case"ISingleton":{t[n]=e.backing.a;break}case"ISlice":{let r=0,o=n;for(;r<e.length;)t[o]=jp(e,r),r+=1,o+=1;break}}};var eJ=e=>{switch(e.backing._tag){case"IEmpty":return q1;case"IArray":return e.backing.array;default:{let t=new Array(e.length);return cv(e,t,0),e.backing={_tag:"IArray",array:t},e.left=xa,e.right=xa,e.depth=0,t}}},Bp=eJ;var tJ=e=>e.length===0?YV():e.length===1?XV(e[0]):fv({_tag:"IArray",array:e});var jp=d(2,(e,t)=>{let n=Math.floor(t);switch(e.backing._tag){case"IEmpty":throw new Error(`Index out of bounds: ${n}`);case"ISingleton":{if(t!==0)throw new Error(`Index out of bounds: ${n}`);return e.backing.a}case"IArray":{if(n>=e.length||n<0)throw new Error(`Index out of bounds: ${n}`);return e.backing.array[n]}case"IConcat":return n<e.left.length?jp(e.left,n):jp(e.right,n-e.left.length);case"ISlice":return jp(e.backing.chunk,n+e.backing.offset)}});var $1=e=>e.length;var z1=d0;var vl=GO,iy=ZO,bo=Sg;var Ei=ea,ya=UM;var fr=Lg,H1=$M;var W1="~effect/MutableRef",nJ={[W1]:W1,...vn,toJSON(){return{_id:"MutableRef",current:hn(this.current)}}},$p=e=>{let t=Object.create(nJ);return t.current=e,t};var K1=e=>e.current;var dv=d(2,(e,t)=>(e.current=t,e));var Or=Symbol.for("effect/MutableList/Empty"),Ea=()=>({head:void 0,tail:void 0,length:0}),V1=()=>({array:[],mutable:!0,offset:0,next:void 0}),eo=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=V1(),e.tail=e.tail.next):e.head=e.tail=V1(),e.tail.array.push(t),e.length++},mv=(e,t)=>{e.head={array:[t],mutable:!0,offset:0,next:e.head},e.tail||(e.tail=e.head),e.length++};var ay=(e,t)=>cy(e,ht(t),!Array.isArray(t)),cy=(e,t,n=!1)=>{if(t.length===0)return 0;let r={array:t,mutable:n,offset:0,next:void 0};return e.head?e.tail=e.tail.next=r:e.head=e.tail=r,e.length+=t.length,t.length},ba=e=>{e.head=e.tail=void 0,e.length=0},Pu=(e,t)=>{if(t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let s=e.head.array;return ba(e),s}let n=new Array(t),r=0,o=e.head;for(;o;){for(;o.offset<o.array.length;)if(n[r++]=o.array[o.offset],o.mutable&&(o.array[o.offset]=void 0),o.offset++,r===t)return e.head=o,e.length-=t,e.length===0&&ba(e),n;o=o.next}return ba(e),n},zp=(e,t)=>{if(t<=0||!e.head)return;if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){ba(e);return}let n=0,r=e.head;for(;r;){let o=r.array.length-r.offset;if(n+o>t){r.offset+=t-n,e.head=r,e.length-=t;return}n+=o,r=r.next}ba(e)},Fu=e=>Pu(e,e.length),_s=e=>{if(!e.head)return Or;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:ba(e)),t},J1=(e,t)=>{if(t<=0)return[];let n=Math.min(t,e.length),r=new Array(n),o=0,s=e.head;for(;s;){for(let i=s.offset;i<s.array.length;i++)if(r[o++]=s.array[i],o===n)return r;s=s.next}return r};var hv=(e,t)=>{let n=[],r=e.head;for(;r;){for(let o=r.offset;o<r.array.length;o++)t(r.array[o],o)&&n.push(r.array[o]);r=r.next}if(n.length===0){ba(e);return}e.head=e.tail={array:n,mutable:!0,offset:0,next:void 0},e.length=n.length},G1=(e,t)=>hv(e,n=>n!==t);var rJ="~effect/PubSub",oJ="~effect/PubSub/Subscription",dy=e=>se(()=>fJ(e.atomicPubSub(),new Map,zr(),fr(!1),$p(!1),e.strategy())),py=e=>dy({atomicPubSub:()=>Av(e),strategy:()=>new kv}),my=e=>dy({atomicPubSub:()=>Av(e),strategy:()=>new fy}),hy=e=>dy({atomicPubSub:()=>Av(e),strategy:()=>new Cv}),Hp=e=>dy({atomicPubSub:()=>sJ(e),strategy:()=>new fy}),Av=e=>{let t=typeof e=="number"?{capacity:e}:e;lJ(t.capacity);let n=t.replay&&t.replay>0?new ly(Math.ceil(t.replay)):void 0;return t.capacity===1?new bv(n):nF(t.capacity)===t.capacity?new yv(t.capacity,n):new gv(t.capacity,n)},sJ=e=>{let t=e?.replay;return new wv(t&&t>0?new ly(Math.ceil(t)):void 0)};var Wp=e=>mi(xn(t=>(dv(e.shutdownFlag,!0),Je(e.scope,Wg(t.id)).pipe(Dn(e.strategy.shutdown),mx(e.shutdownHook.open),jo))));var kl=d(2,(e,t)=>K(()=>e.shutdownFlag.current?v(!1):e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),v(!0)):e.strategy.handleSurplus(e.pubsub,e.subscribers,[t],e.shutdownFlag))),Z1=d(2,(e,t)=>e.shutdownFlag.current?!1:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),!0):!1),Q1=d(2,(e,t)=>K(()=>{if(e.shutdownFlag.current)return v(!1);let n=e.pubsub.publishAll(t);return e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),n.length===0?v(!0):e.strategy.handleSurplus(e.pubsub,e.subscribers,n,e.shutdownFlag)})),Kp=e=>mi(cr(t=>{let n=$e(t,It),r=Cn(e.scope),o=uJ(e.pubsub,e.subscribers,e.strategy);return _t(r,iJ(o)).pipe(Dn(Do(n,s=>Je(r,s))),zt(o))})),iJ=e=>mi(xn(t=>(dv(e.shutdownFlag,!0),Lo(Fu(e.pollers),n=>X0(n,t.id),{discard:!0,concurrency:"unbounded"}).pipe(Mt(()=>se(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.replayWindow.close(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),mx(e.shutdownHook.open),jo)))),gy=e=>K(()=>{if(e.shutdownFlag.current)return xo;if(e.replayWindow.remaining>0){let n=e.replayWindow.take();return v(n)}let t=e.pollers.length===0?e.subscription.poll():Or;return t===Or?X1(e):(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),v(t))}),Y1=e=>K(function t(n){if(e.shutdownFlag.current)return xo;let r=e.pollers.length===0?e.subscription.pollUpTo(Number.POSITIVE_INFINITY):[];return n&&(r=n.concat(r)),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),e.replayWindow.remaining>0?v(e.replayWindow.takeAll().concat(r)):Vn(r)?v(r):R(X1(e),o=>t([o]))}),X1=e=>{let t=pu(),n=e.subscribers.get(e.subscription);return n||(n=new Set,e.subscribers.set(e.subscription,n)),n.add(e.pollers),eo(e.pollers,t),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),pi(mu(t),()=>(G1(e.pollers,t),H))};var Gt=Symbol.for("effect/PubSub/AbsentValue"),aJ=(e,t,n)=>{e.has(t)||e.set(t,new Set),e.get(t).add(n)},cJ=(e,t,n)=>{if(!e.has(t))return;let r=e.get(t);r.delete(n),r.size===0&&e.delete(t)},uJ=(e,t,n)=>new vv(e,t,e.subscribe(),Ea(),fr(!1),$p(!1),n,e.replayWindow()),gv=class{array;replayIndices;publisherIndex=0;subscribers;subscriberCount=0;subscribersIndex=0;capacity;replayBuffer;constructor(t,n){this.capacity=t,this.replayBuffer=n,this.array=Array.from({length:t}),this.replayIndices=n?Array.from({length:t}):[],this.subscribers=Array.from({length:t})}replayWindow(){return this.replayBuffer?new Tl(this.replayBuffer):xy}isEmpty(){return this.publisherIndex===this.subscribersIndex}isFull(){return this.publisherIndex===this.subscribersIndex+this.capacity}size(){return this.publisherIndex-this.subscribersIndex}publish(t){if(this.isFull())return!1;let n=this.replayBuffer?.offer(t);if(this.subscriberCount!==0){let r=this.publisherIndex%this.capacity;this.array[r]=t,n!==void 0&&(this.replayIndices[r]=n),this.subscribers[r]=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let n=ht(t),r=n.length,o=this.publisherIndex-this.subscribersIndex,s=this.capacity-o,i=Math.min(r,s);if(i===0)return n;let a=0,c=this.publisherIndex+i;for(;this.publisherIndex!==c;){let u=n[a++],f=this.publisherIndex%this.capacity;this.array[f]=u;let l=this.replayBuffer?.offer(u);l!==void 0&&(this.replayIndices[f]=l),this.subscribers[f]=this.subscriberCount,this.publisherIndex+=1}return n.slice(a)}slide(){if(this.subscribersIndex!==this.publisherIndex){let t=this.subscribersIndex%this.capacity,n=this.array[t];this.array[t]=Gt,this.subscribers[t]=0,this.subscribersIndex+=1,this.replayBuffer?.slide(n,this.replayIndices[t])}}subscribe(){return this.subscriberCount+=1,new xv(this,this.publisherIndex,!1)}},xv=class{self;subscriberIndex;unsubscribed;constructor(t,n,r){this.self=t,this.subscriberIndex=n,this.unsubscribed=r}isEmpty(){return this.unsubscribed||this.self.publisherIndex===this.subscriberIndex||this.self.publisherIndex===this.self.subscribersIndex}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Or;if(this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex),this.subscriberIndex!==this.self.publisherIndex){let t=this.subscriberIndex%this.self.capacity,n=this.self.array[t];return this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=Gt,this.self.subscribersIndex+=1),this.subscriberIndex+=1,n}return Or}pollUpTo(t){if(this.unsubscribed)return[];this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);let n=this.self.publisherIndex-this.subscriberIndex,r=Math.min(t,n);if(r<=0)return[];let o=[],s=this.subscriberIndex+r;for(;this.subscriberIndex!==s;){let i=this.subscriberIndex%this.self.capacity,a=this.self.array[i];this.self.subscribers[i]-=1,this.self.subscribers[i]===0&&(this.self.array[i]=Gt,this.self.subscribersIndex+=1),o.push(a),this.subscriberIndex+=1}return o}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);this.subscriberIndex!==this.self.publisherIndex;){let t=this.subscriberIndex%this.self.capacity;this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=Gt,this.self.subscribersIndex+=1),this.subscriberIndex+=1}}},yv=class{array;replayIndices;mask;publisherIndex=0;subscribers;subscriberCount=0;subscribersIndex=0;capacity;replayBuffer;constructor(t,n){this.capacity=t,this.replayBuffer=n,this.array=Array.from({length:t}),this.replayIndices=n?Array.from({length:t}):[],this.mask=t-1,this.subscribers=Array.from({length:t})}replayWindow(){return this.replayBuffer?new Tl(this.replayBuffer):xy}isEmpty(){return this.publisherIndex===this.subscribersIndex}isFull(){return this.publisherIndex===this.subscribersIndex+this.capacity}size(){return this.publisherIndex-this.subscribersIndex}publish(t){if(this.isFull())return!1;let n=this.replayBuffer?.offer(t);if(this.subscriberCount!==0){let r=this.publisherIndex&this.mask;this.array[r]=t,n!==void 0&&(this.replayIndices[r]=n),this.subscribers[r]=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let n=ht(t),r=n.length,o=this.publisherIndex-this.subscribersIndex,s=this.capacity-o,i=Math.min(r,s);if(i===0)return n;let a=0,c=this.publisherIndex+i;for(;this.publisherIndex!==c;){let u=n[a++],f=this.publisherIndex&this.mask;this.array[f]=u;let l=this.replayBuffer?.offer(u);l!==void 0&&(this.replayIndices[f]=l),this.subscribers[f]=this.subscriberCount,this.publisherIndex+=1}return n.slice(a)}slide(){if(this.subscribersIndex!==this.publisherIndex){let t=this.subscribersIndex&this.mask,n=this.array[t];this.array[t]=Gt,this.subscribers[t]=0,this.subscribersIndex+=1,this.replayBuffer?.slide(n,this.replayIndices[t])}}subscribe(){return this.subscriberCount+=1,new Sv(this,this.publisherIndex,!1)}},Sv=class{self;subscriberIndex;unsubscribed;constructor(t,n,r){this.self=t,this.subscriberIndex=n,this.unsubscribed=r}isEmpty(){return this.unsubscribed||this.self.publisherIndex===this.subscriberIndex||this.self.publisherIndex===this.self.subscribersIndex}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Or;if(this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex),this.subscriberIndex!==this.self.publisherIndex){let t=this.subscriberIndex&this.self.mask,n=this.self.array[t];return this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=Gt,this.self.subscribersIndex+=1),this.subscriberIndex+=1,n}return Or}pollUpTo(t){if(this.unsubscribed)return[];this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);let n=this.self.publisherIndex-this.subscriberIndex,r=Math.min(t,n);if(r<=0)return[];let o=[],s=this.subscriberIndex+r;for(;this.subscriberIndex!==s;){let i=this.subscriberIndex&this.self.mask,a=this.self.array[i];this.self.subscribers[i]-=1,this.self.subscribers[i]===0&&(this.self.array[i]=Gt,this.self.subscribersIndex+=1),o.push(a),this.subscriberIndex+=1}return o}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);this.subscriberIndex!==this.self.publisherIndex;){let t=this.subscriberIndex&this.self.mask;this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=Gt,this.self.subscribersIndex+=1),this.subscriberIndex+=1}}},bv=class{publisherIndex=0;subscriberCount=0;subscribers=0;value=Gt;replayIndex=0;capacity=1;replayBuffer;constructor(t){this.replayBuffer=t}replayWindow(){return this.replayBuffer?new Tl(this.replayBuffer):xy}pipe(){return ie(this,arguments)}isEmpty(){return this.subscribers===0}isFull(){return!this.isEmpty()}size(){return this.isEmpty()?0:1}publish(t){if(this.isFull())return!1;let n=this.replayBuffer?.offer(t);return this.subscriberCount!==0&&(this.value=t,n!==void 0&&(this.replayIndex=n),this.subscribers=this.subscriberCount,this.publisherIndex+=1),!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let n=ht(t);return n.length===0?n:this.publish(n[0])?n.slice(1):n}slide(){if(this.isFull()){let t=this.value;this.subscribers=0,this.value=Gt,this.replayBuffer?.slide(t,this.replayIndex)}}subscribe(){return this.subscriberCount+=1,new Ev(this,this.publisherIndex,!1)}},Ev=class{self;subscriberIndex;unsubscribed;constructor(t,n,r){this.self=t,this.subscriberIndex=n,this.unsubscribed=r}isEmpty(){return this.unsubscribed||this.self.subscribers===0||this.subscriberIndex===this.self.publisherIndex}size(){return this.isEmpty()?0:1}poll(){if(this.isEmpty())return Or;let t=this.self.value;return this.self.subscribers-=1,this.self.subscribers===0&&(this.self.value=Gt),this.subscriberIndex+=1,t}pollUpTo(t){if(this.isEmpty()||t<1)return[];let n=this.self.value;return this.self.subscribers-=1,this.self.subscribers===0&&(this.self.value=Gt),this.subscriberIndex+=1,[n]}unsubscribe(){this.unsubscribed||(this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex!==this.self.publisherIndex&&(this.self.subscribers-=1,this.self.subscribers===0&&(this.self.value=Gt)))}},wv=class{publisherHead={value:Gt,replayIndex:void 0,subscribers:0,next:null};publisherTail=this.publisherHead;publisherIndex=0;subscribersIndex=0;capacity=Number.MAX_SAFE_INTEGER;replayBuffer;constructor(t){this.replayBuffer=t}replayWindow(){return this.replayBuffer?new Tl(this.replayBuffer):xy}isEmpty(){return this.publisherHead===this.publisherTail}isFull(){return!1}size(){return this.publisherIndex-this.subscribersIndex}publish(t){let n=this.replayBuffer?.offer(t),r=this.publisherTail.subscribers;if(r!==0){let o={value:t,replayIndex:n,subscribers:r,next:null};this.publisherTail.next=o,this.publisherTail=this.publisherTail.next,this.publisherIndex+=1}return!0}publishAll(t){if(this.publisherTail.subscribers!==0)for(let n of t)this.publish(n);else this.replayBuffer&&this.replayBuffer.offerAll(t);return[]}slide(){if(this.publisherHead!==this.publisherTail){let t=this.publisherHead.next,n=t.value;this.publisherHead=this.publisherHead.next,this.publisherHead.value=Gt,this.subscribersIndex+=1,this.replayBuffer?.slide(n,t.replayIndex)}}subscribe(){return this.publisherTail.subscribers+=1,new Iv(this,this.publisherTail,this.publisherIndex,!1)}},Iv=class{self;subscriberHead;subscriberIndex;unsubscribed;constructor(t,n,r,o){this.self=t,this.subscriberHead=n,this.subscriberIndex=r,this.unsubscribed=o}isEmpty(){if(this.unsubscribed)return!0;let t=!0,n=!0;for(;n;)this.subscriberHead===this.self.publisherTail?n=!1:this.subscriberHead.next.value!==Gt?(t=!1,n=!1):(this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1);return t}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Or;let t=!0,n=Or;for(;t;)if(this.subscriberHead===this.self.publisherTail)t=!1;else{let r=this.subscriberHead.next.value;r!==Gt&&(n=r,this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=Gt,this.self.subscribersIndex+=1),t=!1),this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1}return n}pollUpTo(t){let n=[],r=0;for(;r!==t;){let o=this.poll();o===Or?r=t:(n.push(o),r+=1)}return n}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.publisherTail.subscribers-=1;this.subscriberHead!==this.self.publisherTail;)this.subscriberHead.next.value!==Gt&&(this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=Gt,this.self.subscribersIndex+=1)),this.subscriberHead=this.subscriberHead.next}},vv=class{[oJ]={_A:B};pubsub;subscribers;subscription;pollers;shutdownHook;shutdownFlag;strategy;replayWindow;constructor(t,n,r,o,s,i,a,c){this.pubsub=t,this.subscribers=n,this.subscription=r,this.pollers=o,this.shutdownHook=s,this.shutdownFlag=i,this.strategy=a,this.replayWindow=c}pipe(){return ie(this,arguments)}},Tv=class{[rJ]={_A:B};pubsub;subscribers;scope;shutdownHook;shutdownFlag;strategy;constructor(t,n,r,o,s,i){this.pubsub=t,this.subscribers=n,this.scope=r,this.shutdownHook=o,this.shutdownFlag=s,this.strategy=i}pipe(){return ie(this,arguments)}},fJ=(e,t,n,r,o,s)=>new Tv(e,t,n,r,o,s),lJ=e=>{if(e<=0)throw new Error(`Cannot construct PubSub with capacity of ${e}`)},kv=class{publishers=Ea();get shutdown(){return xn(t=>Lo(Fu(this.publishers),([n,r,o])=>o?X0(r,t.id):H,{concurrency:"unbounded",discard:!0}))}handleSurplus(t,n,r,o){return K(()=>{let s=pu();return this.offerUnsafe(r,s),this.onPubSubEmptySpaceUnsafe(t,n),this.completeSubscribersUnsafe(t,n),(K1(o)?xo:mu(s)).pipe(pi(()=>(this.removeUnsafe(s),H)))})}onPubSubEmptySpaceUnsafe(t,n){let r=!0;for(;r&&!t.isFull();){let o=_s(this.publishers);if(o===Or)r=!1;else{let[s,i]=o,a=t.publish(s);a&&o[2]?Jf(i,kn(!0)):a||mv(this.publishers,o),this.completeSubscribersUnsafe(t,n)}}}completePollersUnsafe(t,n,r,o){return Rv(this,t,n,r,o)}completeSubscribersUnsafe(t,n){return Ov(this,t,n)}offerUnsafe(t,n){let r=t[Symbol.iterator](),o=r.next();if(!o.done)for(;;){let s=o.value;if(o=r.next(),o.done){eo(this.publishers,[s,n,!0]);break}eo(this.publishers,[s,n,!1])}}removeUnsafe(t){hv(this.publishers,([n,r])=>r!==t)}},fy=class{get shutdown(){return H}handleSurplus(t,n,r,o){return v(!1)}onPubSubEmptySpaceUnsafe(t,n){}completePollersUnsafe(t,n,r,o){return Rv(this,t,n,r,o)}completeSubscribersUnsafe(t,n){return Ov(this,t,n)}},Cv=class{get shutdown(){return H}handleSurplus(t,n,r,o){return se(()=>(this.slidingPublishUnsafe(t,r),this.completeSubscribersUnsafe(t,n),!0))}onPubSubEmptySpaceUnsafe(t,n){}completePollersUnsafe(t,n,r,o){return Rv(this,t,n,r,o)}completeSubscribersUnsafe(t,n){return Ov(this,t,n)}slidingPublishUnsafe(t,n){let r=n[Symbol.iterator](),o=r.next();if(!o.done&&t.capacity>0){let s=o.value,i=!0;for(;i;){t.slide();let a=t.publish(s);a&&(o=r.next())&&!o.done?s=o.value:a&&(i=!1)}}}},Rv=(e,t,n,r,o)=>{let s=!0;for(;s&&!r.isEmpty();){let i=_s(o);if(i===Or)cJ(n,r,o),o.length===0?s=!1:aJ(n,r,o);else{let a=r.poll();a===Or?mv(o,i):(Jf(i,kn(a)),e.onPubSubEmptySpaceUnsafe(t,n))}}},Ov=(e,t,n)=>{for(let[r,o]of n)for(let s of o)e.completePollersUnsafe(t,n,r,s)},ly=class{capacity;head={value:Gt,index:0,next:null};tail=this.head;slideValues=[];size=0;index=0;publisherIndex=0;constructor(t){this.capacity=t}slide(t,n){this.slideValues[this.index%this.capacity]={value:t,index:n},this.index++}offer(t){let n=this.publisherIndex++;return this.tail.value=t,this.tail.index=n,this.tail.next={value:Gt,index:0,next:null},this.tail=this.tail.next,this.size===this.capacity?this.head=this.head.next:this.size+=1,n}offerAll(t){for(let n of t)this.offer(n)}},Tl=class{buffer;values;index=0;remaining;slideIndex;newestIndex=-1;constructor(t){this.buffer=t,this.remaining=t.size,this.slideIndex=t.index,this.values=new Array(this.remaining);let n=t.head;for(let r=0;r<this.remaining;r++)this.values[r]=n.value,this.newestIndex=n.index,n=n.next}close(){this.values.length=0,this.remaining=0}sync(){let t=this.buffer.index-this.slideIndex;if(t===0||this.remaining===0)return;let n=Math.min(t,this.buffer.capacity),r=this.buffer.index-n;for(let o=0;o<n;o++){let s=this.buffer.slideValues[(r+o)%this.buffer.capacity];s.index>this.newestIndex&&(this.index=(this.index+1)%this.values.length,this.values[(this.index+this.remaining-1)%this.values.length]=s.value,this.newestIndex=s.index)}this.slideIndex=this.buffer.index}take(){if(this.remaining===0)return;this.sync();let t=this.values[this.index];return this.values[this.index]=Gt,this.index=(this.index+1)%this.values.length,this.remaining--,this.remaining===0&&this.close(),t}takeN(t){let n=Math.min(t,this.remaining),r=new Array(n);for(let o=0;o<n;o++)r[o]=this.take();return r}takeAll(){return this.takeN(this.remaining)}},xy={remaining:0,take:()=>{},takeN:()=>[],takeAll:()=>[],close:()=>{}};var dJ="~effect/Queue",pJ="~effect/Queue/Enqueue",mJ="~effect/Queue/Dequeue";var _v={_A:B,_E:B},hJ={[dJ]:_v,[pJ]:_v,[mJ]:_v,...vn,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:xJ(this)}}},to=e=>pe(t=>{let n=Object.create(hJ);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??Number.POSITIVE_INFINITY,n.strategy=e?.strategy??"suspend",n.messages=Ea(),n.scheduleRunning=!1,n.state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set},J(n)}),Uu=e=>to({capacity:e});var Vp=()=>to(),Xn=(e,t)=>he(()=>{if(e.state._tag!=="Open")return by;if(e.messages.length>=e.capacity)switch(e.strategy){case"dropping":return by;case"suspend":return e.capacity<=0&&e.state.takers.size>0?(eo(e.messages,t),Mv(e),Sy):EJ(e,t);case"sliding":return _s(e.messages),eo(e.messages,t),Sy}return eo(e.messages,t),Ey(e),Sy}),Al=(e,t)=>e.state._tag!=="Open"?!1:e.messages.length>=e.capacity?e.strategy==="sliding"?(_s(e.messages),eo(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0?(eo(e.messages,t),Mv(e),!0):!1:(eo(e.messages,t),Ey(e),!0),wa=(e,t)=>he(()=>{if(e.state._tag!=="Open")return J(ht(t));let n=wy(e,t);return n.length===0?rt([]):e.strategy==="dropping"?J(n):wJ(e,n)}),wy=(e,t)=>{if(e.state._tag!=="Open")return ht(t);if(e.capacity===Number.POSITIVE_INFINITY||e.strategy==="sliding")return ay(e.messages,t),e.strategy==="sliding"&&Pu(e.messages,e.messages.length-e.capacity),Ey(e),[];let n=e.capacity<=0?e.state.takers.size:e.capacity-e.messages.length;if(n===0)return ht(t);let r=[],o=0;for(let s of t)o<n?eo(e.messages,s):r.push(s),o++;return Ey(e),r};var Zt=d(2,(e,t)=>ge(()=>wi(e,t))),wi=(e,t)=>{if(e.state._tag!=="Open")return!1;let n=On(t),r=v_(n,yJ);return e.state.offers.size===0&&e.messages.length===0?(Pv(e,r),!0):(e.state={...e.state,_tag:"Closing",exit:r},!0)},Jp=e=>Zt(e,yf(Zc())),eD=e=>wi(e,yf(Zc()));var Ms=e=>ge(()=>{if(e.state._tag==="Done")return!0;ba(e.messages);let t=e.state.offers;if(Pv(e,e.state._tag==="Open"?SJ:e.state.exit),t.size>0){for(let n of t)n._tag==="Single"?n.resume(by):n.resume(rt(n.remaining.slice(n.offset)));t.clear()}return!0});var Rl=e=>tD(e,1,Number.POSITIVE_INFINITY);var tD=(e,t,n)=>he(()=>bJ(e,t,n)??jr(nD(e),tD(e,1,n))),Wo=e=>he(()=>gJ(e)??jr(nD(e),Wo(e)));var gJ=e=>{if(e.state._tag==="Done")return e.state.exit;if(e.messages.length>0){let t=_s(e.messages);return Cl(e),rt(t)}else if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,Cl(e),e.capacity=0;let t=_s(e.messages);return Cl(e),rt(t)}};var xJ=e=>e.state._tag==="Done"?0:e.messages.length;var by=rt(!1),Sy=rt(!0),yJ=co(Zc()),SJ=wg(),Mv=e=>{if(e.scheduleRunning=!1,!(e.state._tag==="Done"||e.state.takers.size===0)){for(let t of e.state.takers)if(e.state.takers.delete(t),t(Ir),e.messages.length===0)break}},Ey=e=>{e.scheduleRunning||e.state._tag==="Done"||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>Mv(e),0))},bJ=(e,t,n)=>{if(e.state._tag==="Done")return e.state.exit;if(n<=0||t<=0)return rt([]);if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,Cl(e),e.capacity=0;let r=[_s(e.messages)];return Cl(e),rt(r)}if(t=Math.min(t,e.capacity||1),t<=e.messages.length){let r=Pu(e.messages,n);return Cl(e),rt(r)}},EJ=(e,t)=>Bt(n=>{if(e.state._tag!=="Open")return n(by);let r={_tag:"Single",message:t,resume:n};return e.state.offers.add(r),ge(()=>{e.state._tag==="Open"&&e.state.offers.delete(r)})}),wJ=(e,t)=>Bt(n=>{if(e.state._tag!=="Open")return n(rt(t));let r={_tag:"Array",remaining:t,offset:0,resume:n};return e.state.offers.add(r),ge(()=>{e.state._tag==="Open"&&e.state.offers.delete(r)})}),Cl=e=>{if(e.state._tag==="Done")return No(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag==="Closing"&&e.messages.length===0?(Pv(e,e.state.exit),No(e.state.exit.cause)):!1;let t=e.capacity-e.messages.length;for(let n of e.state.offers){if(t===0)break;if(n._tag==="Single")eo(e.messages,n.message),t--,n.resume(Sy),e.state.offers.delete(n);else{for(;n.offset<n.remaining.length;n.offset++){if(t===0)return!1;eo(e.messages,n.remaining[n.offset]),t--}n.resume(rt([])),e.state.offers.delete(n)}}return!1},nD=e=>Bt(t=>e.state._tag==="Done"?t(e.state.exit):(e.state.takers.add(t),ge(()=>{e.state._tag!=="Done"&&e.state.takers.delete(t)})));var Pv=(e,t)=>{if(e.state._tag==="Done")return;let n=e.state;e.state={_tag:"Done",exit:t};for(let r of n.takers)r(t);n.takers.clear();for(let r of n.awaiters)r(t);n.awaiters.clear()};var Ia=e=>new Fv(e),rD=(e,t,n)=>Bt(r=>{if(e.free>=t)return r(n);let o=()=>{e.free<t||(e.waiters.delete(o),r(n))};return e.waiters.add(o),ge(()=>{e.waiters.delete(o)})}),Fv=class{waiters=new Set;taken=0;permits;constructor(t){this.permits=t}get free(){return this.permits-this.taken}take(t){let n=he(()=>this.free<t?rD(this,t,n):(this.taken+=t,J(t)));return n}takeIfAvailable(t){return he(()=>this.free<t?J(!1):(this.taken+=t,J(!0)))}releaseUnsafe(t,n){return this.taken-=n,this.waiters.size>0&&t.currentDispatcher.scheduleTask(()=>{for(let r of this.waiters){if(this.free<=0)break;r()}},0),this.free}resize(t){return pe(n=>(this.permits=t,this.free<0?we:(this.releaseUnsafe(n,0),we)))}release(t){return pe(n=>J(this.releaseUnsafe(n,t)))}get releaseAll(){return pe(t=>J(this.releaseUnsafe(t,this.taken)))}withPermits(t){return n=>qr(r=>{let o=he(()=>{if(this.free<t){let s=rD(this,t,we);return ne(r(s),()=>o)}return this.taken+=t,ms(r(n),()=>{this.releaseUnsafe(ea(),t)},!0)});return o})}withPermit=this.withPermits(1);withPermitsIfAvailable(t){return n=>qr(r=>this.free<t?iu:(this.taken+=t,ms(r(Ff(n)),()=>{this.releaseUnsafe(ea(),t)},!0)))}};var Uv=e=>gs(e)?Ft(e)?me(e.value):e:v(e);var aD="~effect/Channel",er=e=>j(e,aD),IJ={[aD]:{_Env:B,_InErr:B,_InElem:B,_OutErr:B,_OutElem:B},pipe(){return ie(this,arguments)}},Ge=e=>{let t=Object.create(IJ);return t.transform=(n,r)=>ft(e(n,r),o=>v(ct(o))),t},Fs=(e,t)=>Ge((n,r)=>R(Pe(e)(n,r),o=>t(o,r))),qn=e=>Ge((t,n)=>e),Us=e=>Ge(Se(function*(t,n){let r=Cn(n),o=i=>Je(r,bw(i)),s=yield*go(e(t,n,r),o);return go(s,o)})),Pe=e=>e.transform,Gp=4096,vJ=(e,t,n)=>to({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(Mt(r=>_t(e,Ms(r))),Mt(r=>Ut(Uo(t(r),e),e)));var cD=(e,t)=>Ge((n,r)=>Y(vJ(r,e,t),Rl)),vy=e=>Ge((t,n)=>K(()=>Pe(e())(t,n))),TJ=(e,t,n)=>Us(Se(function*(r,o,s){let i=D();yield*Do(s,c=>Te(i)?n(i.value,c):H);let a=yield*mi(e);return i=L(a),yield*Pe(t(a))(r,o)}));var Dv=e=>qn(se(()=>{let t=0;return K(()=>t>=e.length?me():v(e[t++]))}));var Nv=(e,t=Gp)=>qn(se(()=>{let n=e(),r=D();return K(()=>{if(r._tag==="Some")return me(r.value);let o=[];for(;o.length<t;){let s=n.next();if(s.done){if(o.length===0)return me(s.value);r=L(s.value);break}o.push(s.value)}return v(o)})}));var uD=(e,t=Gp)=>Nv(()=>e[Symbol.iterator](),t),Ty=e=>ky(v(e)),kJ=e=>qn(v(me(e)));var fD=e=>ky(se(e)),Ol=qn(v(me())),lD=qn(v(Kr)),Ii=e=>qn(v(G(e))),dD=e=>qn(lx(e)),Zp=e=>qn(ct(e)),pD=e=>qn(ia(e)),Lv=e=>Zp(mP(e)),ky=e=>qn(se(()=>{let t=!1;return K(()=>t?me():(t=!0,e))}));var mD=e=>qn(R(e,()=>me())),Bv=e=>qn(v(R(e,Uv)));var hD=e=>qn(v(Rl(e)));var jv=e=>qn(v(pi(Y1(e),()=>me())));var gD=e=>va(Y(Kp(e),jv)),xD=e=>va(Y(Kp(e),t=>Bv(gy(t))));var yD=e=>Ge((t,n)=>CJ({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd}));var CJ=e=>{let t=e.readable.getReader(),n=e.exit??$p(void 0),r=K(()=>n.current?n.current:Jr(bs({try:()=>t.read(),catch:e.onError}),{onFailure:o=>n.current??ct(o),onSuccess:({done:o,value:s})=>n.current?n.current:o?me():v(Ne(s))}));return zt(_t(e.scope,e.releaseLockOnEnd?se(()=>t.releaseLock()):ux(()=>t.cancel().catch(En))),r)},AJ=(e,t)=>Ge(Se(function*(n,r){let o=e[Symbol.asyncIterator]();return o.return&&(yield*_t(r,ux(()=>o.return()))),R(bs({try:()=>o.next(),catch:t}),s=>s.done?me(s.value):v(s.value))})),SD=(e,t)=>Ds(AJ(e,t),Ne),Ds=d(2,(e,t)=>Fs(e,n=>se(()=>{let r=0;return Y(n,o=>t(o,r++))})));var bD=e=>e===void 0||e!=="unbounded"&&e<=1,Cy=d(e=>er(e[0]),(e,t,n)=>bD(n?.concurrency)?ED(e,t):RJ(e,t,n)),ED=(e,t)=>Ge((n,r)=>{let o=0;return Y(Pe(e)(n,r),R(s=>t(s,o++)))}),RJ=(e,t,n)=>Us(Se(function*(r,o,s){let i=0,a=yield*Pe(e)(r,o),c=n.concurrency==="unbounded"?Number.MAX_SAFE_INTEGER:n.concurrency,u=yield*Uu(0);yield*_t(s,Ms(u));let f=Ln(yield*ar()),l=ya(s);if(n.unordered){let p=Ia(c),m=Qe(p.release(1)),h=Jr({onFailure:g=>R(Zt(u,g),m),onSuccess:g=>R(Xn(u,g),m)});yield*p.take(1).pipe(R(()=>a),R(g=>(l(f(h(t(g,i++)))),H)),Ht({disableYield:!0}),ft(g=>p.withPermits(c-1)(Zt(u,g))),Ut(s))}else{let p=yield*Uu(c-2);yield*_t(s,Ms(p)),yield*Wo(p).pipe(Ow,R(g=>Xn(u,g)),Ht({disableYield:!0}),ft(g=>Zt(u,g)),Ut(s));let m,h=g=>{g._tag!=="Success"&&(m=g.cause,wi(u,g.cause))};yield*a.pipe(R(g=>{if(m)return ct(m);let x=f(t(g,i++));return l(x),x.addObserver(h),Xn(p,vl(x))}),Ht({disableYield:!0}),ft(g=>Xn(p,jt(g)).pipe(Dn(Zt(p,g)))),Ut(s))}return Wo(u)}));var wD=d(e=>er(e[0]),(e,t,n)=>bD(n?.concurrency)?OJ(e,t):_J(e,t,n)),OJ=(e,t)=>Ge((n,r)=>Y(Pe(e)(n,r),o=>{let s,i,a=R(o,u=>(i??=Cn(r),Bn(Pe(t(u))(n,i),f=>(s=c(f),s)))),c=qt(u=>{if(s=void 0,i.state._tag==="Open"&&oM(i)===1)return a;let f=Je(i,Vt);return i=void 0,R(f,()=>a)});return K(()=>s??a)})),_J=(e,t,n)=>e.pipe(Ds(t),Oy(n)),Ay=d(2,(e,t)=>Ge((n,r)=>se(()=>{let o,s=Cn(r),i=R(Pe(e)(n,s),a=>(o=qt(a,c=>Je(s,Vt).pipe(R(()=>Pe(t(c))(n,r)),R(u=>(o=u,u)))),o));return K(()=>o??i)})));var qv=d(4,(e,t,n,r)=>Ge(Se(function*(o,s){let i=yield*Pe(e)(o,s),a=yield*Pe(t)(o,s),c=n();return K(()=>{let u=r(c,i,a);return Y(u,([f,l])=>(c=l,f))})}))),ID=d(2,(e,t)=>Ge((n,r)=>se(()=>{let o,s=Cn(r),i=R(Pe(e)(n,s),a=>{let c=a.pipe(Mt(()=>(o=a,H)),qt(u=>Je(s,kn(u)).pipe(Dn(Pe(t(u))(n,r)),R(f=>(o=f,f)))));return o=c,c});return K(()=>o??i)})));var lr=e=>Fs(e,t=>{let n,r=0,o=K(function s(){if(n===void 0)return R(t,a=>{switch(a.length){case 0:return s();case 1:return v(a[0]);default:return n=a,v(a[r++])}});let i=n[r++];return r>=n.length&&(n=void 0,r=0),v(i)});return v(o)}),vD=e=>ED(e,Uv),TD=e=>Fs(e,t=>v(Ht(t,{disableYield:!0}))),kD=d(2,(e,t)=>Ss(typeof t=="function"?t(B):t).pipe(Y(n=>{let r=Un.defaultValue(),o=Ay(Fy(e,Un,se(()=>r)),s=>n(s).pipe(Y(i=>(r=i,o)),qt(()=>v(kJ(s))),va));return o}),va)),$v=e=>Ay(e,()=>$v(e)),CD=d(2,(e,t)=>Fs(e,(n,r)=>Y(Yf(t),o=>Mt(n,o)))),AD=d(2,(e,t)=>Ge((n,r)=>Y(Pe(e)(n,r),o=>R(o,function s(i){return t(i)?v(i):R(o,s)}))));var RD=d(2,(e,t)=>Fs(e,n=>v(R(n,function r(o){let s=[];for(let i=0;i<o.length;i++)t(o[i])&&s.push(o[i]);return Ye(s)?v(s):R(n,r)})))),OD=d(2,(e,t)=>Fs(e,n=>v(R(n,function r(o){let s=[];for(let i=0;i<o.length;i++){let a=t(o[i]);Kt(a)&&s.push(a.success)}return Ye(s)?v(s):R(n,r)})))),_D=d(2,(e,t)=>Fs(e,n=>{let r=R(n,o=>Lw(o,t));return v(R(r,function o(s){return Ye(s)?v(s):R(r,o)}))})),MD=d(2,(e,t)=>Fs(e,n=>v(R(n,function r(o){return R(Bw(o,t),s=>Ye(s)?v(s):R(n,r))})))),_l=d(e=>er(e[0]),(e,t,n,r)=>Ge((o,s)=>Y(Pe(e)(o,s),i=>{let a=t(),c,u=0,f,l=Jr(i,{onFailure(m){f=m;let h=r?.onHalt&&r.onHalt(a);return h&&h.length>0?v([a,h]):ct(m)},onSuccess(m){let h=n(a,m);return kR(h)?v(h):h}});return K(function m(){if(c===void 0)return f?ct(f):R(l,([g,x])=>(a=g,x.length===0?m():x.length===1?v(x[0]):(c=x,m())));let h=c[u++];return u>=c.length&&(c=void 0,u=0),v(h)})})));var PD=d(3,(e,t,n)=>Ge((r,o)=>Y(Pe(e)(r,o),s=>{let i=t,a=!0;return K(()=>a?(a=!1,v(i)):Y(R(s,c=>n(i,c)),c=>(i=c,i)))}))),Ml=d(2,(e,t)=>Ge((n,r)=>{let o=Cn(r);return Y(Pe(e)(n,o),s=>{let i=s.pipe(ft(a=>{if(No(a))return ct(a);let c=o;return o=Cn(r),Je(c,jt(a)).pipe(Dn(Pe(t(a))(n,o)),R(u=>(i=u,u)))}));return K(()=>i)})})),Ry=d(2,(e,t)=>Ml(e,n=>mD(R(t(n),r=>ct(n))))),FD=d(3,(e,t,n)=>Ml(e,r=>t(r)?n(r):Zp(r))),zv=d(3,(e,t,n)=>Ml(e,r=>{let o=t(r);return Fe(o)?Zp(o.failure):n(o.success,r)})),Ps=d(2,(e,t)=>zv(e,Kf,n=>t(n)));var UD=d(2,(e,t)=>Fs(e,n=>v(up(n,r=>Gd(r)?H:jo(t(r)))))),DD=d(e=>er(e[0]),(e,t,n,r)=>Ps(e,o=>t(o)?n(o):r?r(o):Ii(o))),ND=d(e=>er(e[0]),(e,t,n,r)=>Ps(e,o=>{let s=t(o);return Fe(s)?r?r(s.failure):Ii(s.failure):n(s.success)}));var LD=d(e=>er(e[0]),(e,t,n,r,o)=>Ps(e,s=>{if(yr(s,t)&&j(s,"reason")){let i=s.reason;return yr(i,n)?r(i,s):o?o(i,s):Ii(s)}return Ii(s)})),BD=d(e=>er(e[0]),(e,t,n,r)=>{let o;return Ps(e,s=>{if(yr(s,t)&&j(s,"reason")&&j(s.reason,"_tag")&&ox(s.reason._tag)){let i=s.reason;return o??=new Set(Object.keys(n)),o.has(i._tag)?n[i._tag](i,s):r?r(i,s):Ii(s)}return Ii(s)})});var jD=d(2,(e,t)=>Ps(e,n=>Ii(t(n)))),qD=e=>Ps(e,Lv),$D=d(e=>er(e[0]),(e,t)=>{if(!t?.log)return Ps(e,()=>Ol);let n=cl(t.log===!0?void 0:t.log);return Ps(Ry(e,r=>gP(r)?n(r):H),()=>Ol)}),sD=e=>Ml(e,()=>Ol),zD=d(e=>er(e[0]),(e,t)=>{if(!t?.log)return sD(e);let n=cl(t.log===!0?void 0:t.log);return sD(Ry(e,r=>n(r)))}),HD=d(2,(e,t)=>vy(()=>{let n,r=Un.defaultValue(),o=Fy(e,Un,se(()=>r)),s=Kv(o,()=>(n=void 0,H)),i=typeof t=="function"?t(B):t,a=Ps(s,Se(function*(c){return n||(n=yield*Ss(i)),r=yield*n(c),a},(c,u)=>qt(c,()=>v(Ii(u))),va));return a})),WD=d(e=>er(e[0]),(e,t,n)=>e.pipe(Ds(t),Oy({...n,concurrency:n?.concurrency??1,switch:!0}))),Oy=d(2,(e,{bufferSize:t=16,concurrency:n,switch:r=!1})=>Us(Se(function*(o,s,i){let a=n==="unbounded"?Number.MAX_SAFE_INTEGER:Math.max(1,n),c=r?void 0:Ia(a),u=yield*H1(!0),f=new Set,l=yield*Uu(t);yield*_t(i,Ms(l));let p=yield*Pe(e)(o,s);return yield*$t(function*(){for(;;){let m;c&&(f.size<a?yield*c.take(1):(m=yield*il(p),yield*sc(c.take(1),Dn(vl(m),Kr))));let h=m===void 0?yield*p:yield*vl(m),g=Cn(i),x=yield*Pe(h)(o,g);for(;f.size>=a;){let b=ER(f);f.delete(b),f.size===0&&(yield*u.open),yield*bo(b)}let E=yield*x.pipe(Mt(()=>cp),R(b=>Xn(l,b)),Ht({disableYield:!0}),go(Se(function*(b){let y=Qf(b);if(yield*Vr(Je(g,Fe(y)?jt(y.failure):kn(y.success.value))),!!f.has(E)&&(f.delete(E),c&&(yield*c.release(1)),f.size===0&&(yield*u.open),!Kt(y)))return yield*Zt(l,b)})),il);u.closeUnsafe(),f.add(E)}}).pipe(ft(m=>{let h=Qf(m);return Kt(h)?u.whenOpen(Zt(l,m)):Zt(l,m)}),Ut(i)),Wo(l)}))),_y=d(e=>er(e[0])&&er(e[1]),(e,t,n)=>Us(Se(function*(r,o,s){let i=n?.haltStrategy??"both",a=yield*Uu(0);yield*_t(s,Ms(a));let c=0;function u(l,p){if(c++,!No(p))return Zt(a,p);switch(i){case"both":return c===2?Zt(a,p):H;case"left":case"right":return l===i?Zt(a,p):H;case"either":return Zt(a,p)}}let f=(l,p,m)=>Pe(p)(r,m).pipe(R(h=>h.pipe(R(g=>Xn(a,g)),Ht)),go(h=>Dn(Je(m,bw(h)),u(l,h))),Ut(s));return yield*f("left",e,Cn(s)),yield*f("right",t,Cn(s)),Wo(a)}))),KD=d(2,(e,t)=>_y(e,mD(t),{haltStrategy:"left"})),VD=()=>Ge((e,t)=>se(()=>{let n="",r=!1,o=D();function s(c){let u=[];function f(l){n.length===0?u.push(l):(u.push(n+l),n="")}for(let l=0;l<c.length;l++){let p=c[l];if(p.length!==0){let m=0,h=p.indexOf("\r"),g=p.indexOf(`
|
|
26
26
|
`);for(r&&(g===0?(f(""),m=1,g=p.indexOf(`
|
|
27
27
|
`,m)):f(""),r=!1);h!==-1||g!==-1;)h===-1||g!==-1&&g<h?(f(p.substring(m,g)),m=g+1,g=p.indexOf(`
|
|
28
28
|
`,m)):p.length===h+1?(r=!0,h=-1):(f(p.substring(m,h)),m=h+(g===h+1?2:1),h=p.indexOf("\r",m),g=p.indexOf(`
|
|
29
|
-
`,m));n=n+p.substring(m,p.length-(r?1:0))}}return Ye(u)?u:null}let i=K(()=>o._tag==="Some"?pe(o.value):Qd(e,{onSuccess:a,onFailure:ct,onDone:c=>{if(o=N(c),n.length>0||r){let u=n;return n="",r=!1,v([u])}return pe(c)}}));function a(c){let u=s(c);return u!==null?v(u):i}return i}));var _v=d(2,(e,t)=>Ge((n,r)=>A(Pe(e)(n,r),o=>Pe(t)(o,r)))),Mv=d(2,(e,t)=>Ge((n,r)=>A(Pe(e)(n,r),o=>{let s=ft(o,i=>Uo(i)?ct(i):po(tP(i)));return Y(Pe(t)(s,r),i=>Sw(i,a=>Hd(a)?ct(a.value):po(a)))}))),ya=e=>Ge((t,n)=>{let r;return v(K(()=>r||e.pipe(Po(n),A(o=>Pe(o)(t,n)),A(o=>r=o))))}),RD=e=>Ps((t,n,r)=>Y(Po(Pe(e)(t,n),r),Po(r)));var _D=d(2,(e,t)=>Ge(ye(function*(n,r){let o=yield*Pe(e)(n,r),s=yield*Xr({capacity:t.capacity==="unbounded"?void 0:t.capacity,strategy:t.capacity==="unbounded"?void 0:t.strategy});return yield*_t(r,Rs(s)),yield*o.pipe(A(i=>Xn(s,i)),Ht({disableYield:!0}),mo(i=>Zt(s,i)),Ut(r)),zo(s)}))),MD=d(2,(e,t)=>Ge(ye(function*(n,r){let o=yield*Pe(e)(n,r),s=yield*Xr({capacity:t.capacity==="unbounded"?void 0:t.capacity,strategy:t.capacity==="unbounded"?void 0:t.strategy});return yield*_t(r,Rs(s)),yield*o.pipe(A(i=>ga(s,i)),Ht({disableYield:!0}),mo(i=>Zt(s,i)),Ut(r)),Il(s)}))),PD=d(2,(e,t)=>vy(e,$n(v(A(t,pe))),{haltStrategy:"either"})),FD=d(2,(e,t)=>Ps(ye(function*(n,r,o){let s=yield*Pe(e)(n,r),i=yield*Ut(t,o,{startImmediately:!0});return K(()=>{let a=i.pollUnsafe();return a===void 0?s:rP(a,{onFailure:ct,onSuccess:pe})})}))),UD=d(2,(e,t)=>Kp(e,n=>ri(n)?t(n.cause):H)),Kp=d(2,(e,t)=>Ps((n,r,o)=>Fo(o,t).pipe(Dn(Pe(e)(n,r))))),DD=d(2,(e,t)=>ya(zt(t,e))),Pv=d(2,(e,t)=>Ms(e,n=>se(()=>{let r=!0,o=Mt(n,s=>(r=!1,t(s)));return K(()=>r?o:n)}))),ND=d(2,(e,t)=>Ms(e,n=>v($t(n,r=>A(t,()=>pe(r)))))),LD=d(2,(e,t)=>Kp(e,n=>t)),_u=(e,t,n)=>K(()=>{let r=$r(),o=Pe(e)(pe(),r);return $t(A(o,t),n||v).pipe(ur(s=>Je(r,s)))});var Ty=d(2,(e,t)=>Ge((n,r)=>Y(Nn(Pe(e)(n,r),t),Nn(t)))),ky=d(3,(e,t,n)=>Ge((r,o)=>Y(Bo(Pe(e)(r,o),t,n),Bo(t,n)))),Cy=d(3,(e,t,n)=>Ge((r,o)=>A(n,s=>Pe(ky(e,t,s))(r,o)))),BD=d(e=>er(e[0]),(e,t,n)=>_d(t)?Ty(e,t):Ge((r,o)=>A(n?.local?si(t,oi(),o):Wd(t,o),s=>Y(Nn(Pe(e)(r,o),s),Nn(s))))),jD=d(2,(e,t)=>Ge((n,r)=>cr(o=>{let s=t(o);return Pe(Ty(e,s))(n,r)})));var Fv=function(){let e=er(arguments[0]),t=e?arguments[1]:arguments[0],n=_o(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return q1(r,t,n)}return r=>q1(r,t,n)},q1=(e,t,n)=>ZV(Fw(t,n),r=>ky(e,Ys,r),(r,o)=>xn(s=>{let i=s.getRef(lo),a=s.getRef(aP);return Pg(r,o,i,a)}));var $D=e=>_u(e,t=>Ht(t,{disableYield:!0})),Mu=d(2,(e,t)=>_u(e,n=>Ht(A(n,t),{disableYield:!0}))),qD=d(2,(e,t)=>_u(e,n=>n.pipe(A(t),A(r=>r?H:pe()),Ht({disableYield:!0})))),Uv=e=>Y(Pu(e,()=>({bytes:0,arrays:[]}),(t,n)=>{for(let r=0;r<n.length;r++)t.bytes+=n[r].length,t.arrays.push(n[r]);return t}),({arrays:t,bytes:n})=>{let r=new Uint8Array(n),o=0;for(let s=0;s<t.length;s++){let i=t[s];r.set(i,o),o+=i.length}return r});var zD=e=>K(()=>{let t=U();return _u(e,n=>n.pipe(sx,A(r=>(t=r,pe()))),()=>v(t))}),HD=e=>K(()=>{let t=Symbol(),n=t;return _u(e,r=>Ht(A(r,o=>(n=o,H)),{disableYield:!0}),()=>n===t?Ss:rx(n))}),Pu=d(3,(e,t,n)=>K(()=>{let r=t();return _u(e,o=>Qn({while:Xt,body:()=>o,step:s=>{r=n(r,s)}}),()=>v(r))})),WD=d(3,(e,t,n)=>K(()=>{let r=t();return _u(e,o=>Qn({while:Xt,body:Qe(o.pipe(A(s=>n(r,s)),Y(s=>{r=s}))),step:bn}),()=>v(r))})),Dv=ye(function*(e){let t=xa(1),n=yield*ar(),r=qe(n,It);return(yield*Pe(e)(pe(),r)).pipe(Nn(n),t.withPermits(1))},ft(e=>v(ct(e)))),Ho=(e,t)=>Pe(e)(pe(),t);var Nv=d(e=>er(e[0]),(e,t)=>go(n=>Mu(e,r=>ga(t,r)).pipe(n,Wr,A(r=>(Ft(r)?D1(t):yi(t,r.cause),H)))));var KD=d(e=>er(e[0]),ye(function*(e,t){let n=yield*jo,r=yield*Xr({capacity:typeof t.capacity=="number"?t.capacity:void 0,strategy:typeof t.capacity=="number"?t.strategy:void 0});return yield*_t(n,Rs(r)),yield*Ut(Nv(e,r),n),r}));var VD=e=>Xa(e.capacity==="unbounded"?Bp(e):e.strategy==="dropping"?ay(e):e.strategy==="sliding"?cy(e):iy(e),jp),JD=d(2,ye(function*(e,t){let n=yield*VD(t);return yield*bs(Lv(e,n,{shutdownOnEnd:t.shutdownOnEnd!==!1})),n})),Lv=d(e=>er(e[0]),(e,t,n)=>Mu(e,r=>P1(t,r)).pipe(n?.shutdownOnEnd===!0?na(jp(t)):L)),GD=d(2,ye(function*(e,t){let n=yield*VD(t);return yield*Mu(e,r=>El(n,r)).pipe(ur(r=>El(n,r)),bs),n}));var j={};Hs(j,{Any:()=>s5,Array:()=>Wt,ArrayEnsure:()=>m5,BigDecimal:()=>$T,BigDecimalFromString:()=>dQ,BigDecimalReviver:()=>lQ,BigInt:()=>bi,BigIntFromString:()=>wQ,Boolean:()=>xc,BooleanFromBit:()=>OQ,Cause:()=>Ll,CauseReason:()=>Yy,CauseReasonReviver:()=>UZ,CauseReviver:()=>DZ,Char:()=>wZ,Chunk:()=>gB,ChunkReviver:()=>GZ,Class:()=>cS,Date:()=>Bs,DateFromMillis:()=>tQ,DateFromString:()=>eQ,DateReviver:()=>XZ,DateTimeUtc:()=>bm,DateTimeUtcFromDate:()=>UQ,DateTimeUtcFromMillis:()=>NQ,DateTimeUtcFromString:()=>DQ,DateTimeUtcReviver:()=>FQ,DateTimeZoned:()=>VT,DateTimeZonedFromString:()=>HQ,DateTimeZonedReviver:()=>zQ,Defect:()=>ln,Duration:()=>Em,DurationFromMillis:()=>iQ,DurationFromNanos:()=>sQ,DurationFromString:()=>oQ,DurationReviver:()=>nQ,Enum:()=>o5,Error:()=>qn,ErrorInstance:()=>cB,ErrorInstanceReviver:()=>BZ,Exit:()=>iS,ExitReviver:()=>jZ,File:()=>qT,FileReviver:()=>hQ,Finite:()=>Ls,FiniteFromString:()=>bQ,FormData:()=>zT,FormDataReviver:()=>gQ,Graph:()=>dB,GraphReviver:()=>WZ,HashMap:()=>pB,HashMapReviver:()=>KZ,HashSet:()=>hB,HashSetReviver:()=>JZ,Int:()=>js,Json:()=>Im,JsonObject:()=>A7,JsonReviver:()=>O7,Literal:()=>Ot,Literals:()=>Ea,MutableJson:()=>$B,MutableJsonReviver:()=>_7,Natural:()=>tr,Never:()=>gc,NonEmptyArray:()=>rS,NonEmptyString:()=>bZ,Null:()=>tt,NullOr:()=>OT,NullishOr:()=>rL,Number:()=>$l,NumberFromString:()=>EQ,ObjectKeyword:()=>i5,Opaque:()=>A5,Option:()=>wi,OptionFromNullOr:()=>vZ,OptionFromNullishOr:()=>kZ,OptionFromOptional:()=>AZ,OptionFromOptionalKey:()=>CZ,OptionFromOptionalNullOr:()=>OZ,OptionFromUndefinedOr:()=>TZ,OptionReviver:()=>IZ,PropertyKey:()=>bT,ReadonlyMap:()=>lB,ReadonlyMapReviver:()=>$Z,ReadonlySet:()=>mB,ReadonlySetReviver:()=>VZ,Record:()=>AT,Redacted:()=>LT,RedactedFromValue:()=>FZ,RedactedReviver:()=>PZ,RegExp:()=>xB,RegExpReviver:()=>ZZ,Result:()=>XL,ResultReviver:()=>RZ,SchemaError:()=>Mr,StandardSchemaV1FailureResult:()=>AQ,String:()=>fe,StringFromBase64:()=>vQ,StringFromBase64Url:()=>TQ,StringFromHex:()=>kQ,StringFromUriComponent:()=>CQ,Struct:()=>oe,StructWithRest:()=>d5,Symbol:()=>eL,TaggedClass:()=>JQ,TaggedError:()=>GT,TaggedStruct:()=>yc,TaggedUnion:()=>C5,TemplateLiteral:()=>n5,TemplateLiteralParser:()=>r5,TimeZone:()=>KT,TimeZoneFromString:()=>qQ,TimeZoneNamed:()=>WT,TimeZoneNamedFromString:()=>jQ,TimeZoneNamedReviver:()=>BQ,TimeZoneOffset:()=>kB,TimeZoneOffsetReviver:()=>LQ,TimeZoneReviver:()=>$Q,Tree:()=>C7,Trim:()=>IQ,Trimmed:()=>vB,Tuple:()=>mc,TupleWithRest:()=>p5,URL:()=>BT,URLFromString:()=>YZ,URLReviver:()=>QZ,URLSearchParams:()=>HT,URLSearchParamsReviver:()=>yQ,Uint8Array:()=>Vo,Uint8ArrayFromBase64:()=>_Q,Uint8ArrayFromBase64Url:()=>MQ,Uint8ArrayFromHex:()=>PQ,Uint8ArrayReviver:()=>RQ,Undefined:()=>kT,UndefinedOr:()=>oS,Union:()=>He,UniqueArray:()=>h5,UniqueSymbol:()=>a5,Unknown:()=>TT,UnknownFromJsonString:()=>mQ,Void:()=>ql,annotate:()=>UG,annotateEncoded:()=>DG,annotateKey:()=>NG,asserts:()=>$G,brand:()=>sL,catchDecoding:()=>E5,catchDecodingWithContext:()=>cL,catchEncoding:()=>b5,catchEncodingWithContext:()=>uL,check:()=>x5,declare:()=>eo,declareConstructor:()=>An,decode:()=>w5,decodeEffect:()=>qG,decodeExit:()=>K2,decodeOption:()=>HG,decodePromise:()=>KG,decodeResult:()=>WG,decodeSync:()=>dm,decodeTo:()=>Ee,decodeUnknownEffect:()=>hc,decodeUnknownExit:()=>W2,decodeUnknownOption:()=>zG,decodeUnknownPromise:()=>J2,decodeUnknownResult:()=>V2,decodeUnknownSync:()=>eS,encode:()=>I5,encodeEffect:()=>tS,encodeExit:()=>Z2,encodeKeys:()=>f5,encodeOption:()=>JG,encodePromise:()=>ZG,encodeResult:()=>GG,encodeSync:()=>vT,encodeTo:()=>RT,encodeUnknownEffect:()=>pm,encodeUnknownExit:()=>G2,encodeUnknownOption:()=>VG,encodeUnknownPromise:()=>Y2,encodeUnknownResult:()=>Q2,encodeUnknownSync:()=>nS,extendTo:()=>l5,fieldsAssign:()=>c5,flip:()=>ST,fromBrand:()=>S5,fromFormData:()=>xQ,fromJsonString:()=>IB,fromURLSearchParams:()=>SQ,instanceOf:()=>Sc,is:()=>j2,isBase64:()=>PT,isBase64Reviver:()=>j5,isBase64Url:()=>EL,isBase64UrlReviver:()=>$5,isBetween:()=>sS,isBetweenBigDecimal:()=>uZ,isBetweenBigInt:()=>zL,isBetweenBigIntReviver:()=>b7,isBetweenDate:()=>LL,isBetweenDateReviver:()=>g7,isBetweenReviver:()=>eZ,isCapitalized:()=>kL,isCapitalizedReviver:()=>V5,isEndsWith:()=>wL,isEndsWithReviver:()=>z5,isFinite:()=>AL,isFiniteReviver:()=>G5,isGUID:()=>yL,isGUIDReviver:()=>L5,isGreaterThan:()=>RL,isGreaterThanBigDecimal:()=>sZ,isGreaterThanBigInt:()=>BL,isGreaterThanBigIntReviver:()=>x7,isGreaterThanDate:()=>FL,isGreaterThanDateReviver:()=>d7,isGreaterThanOrEqualTo:()=>FT,isGreaterThanOrEqualToBigDecimal:()=>iZ,isGreaterThanOrEqualToBigInt:()=>jL,isGreaterThanOrEqualToBigIntReviver:()=>y7,isGreaterThanOrEqualToDate:()=>UL,isGreaterThanOrEqualToDateReviver:()=>p7,isGreaterThanOrEqualToReviver:()=>Q5,isGreaterThanReviver:()=>Z5,isIncludes:()=>IL,isIncludesReviver:()=>H5,isInt:()=>Sm,isInt32:()=>rZ,isIntReviver:()=>nZ,isLengthBetween:()=>DT,isLengthBetweenReviver:()=>dZ,isLessThan:()=>_L,isLessThanBigDecimal:()=>aZ,isLessThanBigInt:()=>$L,isLessThanBigIntReviver:()=>S7,isLessThanDate:()=>DL,isLessThanDateReviver:()=>m7,isLessThanOrEqualTo:()=>ML,isLessThanOrEqualToBigDecimal:()=>cZ,isLessThanOrEqualToBigInt:()=>qL,isLessThanOrEqualToBigIntReviver:()=>E7,isLessThanOrEqualToDate:()=>NL,isLessThanOrEqualToDateReviver:()=>h7,isLessThanOrEqualToReviver:()=>X5,isLessThanReviver:()=>Y5,isLowercased:()=>TL,isLowercasedReviver:()=>K5,isMaxLength:()=>WL,isMaxLengthReviver:()=>lZ,isMaxProperties:()=>ZL,isMaxPropertiesReviver:()=>xZ,isMaxSize:()=>VL,isMaxSizeReviver:()=>mZ,isMinLength:()=>UT,isMinLengthReviver:()=>fZ,isMinProperties:()=>GL,isMinPropertiesReviver:()=>gZ,isMinSize:()=>KL,isMinSizeReviver:()=>pZ,isMultipleOf:()=>PL,isMultipleOfReviver:()=>tZ,isNonEmpty:()=>HL,isPattern:()=>Hu,isPatternReviver:()=>M5,isPropertiesLengthBetween:()=>QL,isPropertiesLengthBetweenReviver:()=>yZ,isPropertyNames:()=>YL,isPropertyNamesReviver:()=>SZ,isSchema:()=>zu,isSchemaError:()=>Bl,isSizeBetween:()=>JL,isSizeBetweenReviver:()=>hZ,isStartsWith:()=>bL,isStartsWithReviver:()=>q5,isStringBigInt:()=>hL,isStringBigIntReviver:()=>F5,isStringFinite:()=>mL,isStringFiniteReviver:()=>P5,isStringSymbol:()=>gL,isStringSymbolReviver:()=>U5,isTrimmed:()=>MT,isTrimmedReviver:()=>R5,isULID:()=>SL,isULIDReviver:()=>B5,isUUID:()=>xL,isUUIDReviver:()=>N5,isUint32:()=>oZ,isUncapitalized:()=>CL,isUncapitalizedReviver:()=>J5,isUnique:()=>NT,isUniqueReviver:()=>EZ,isUppercased:()=>vL,isUppercasedReviver:()=>W5,link:()=>pt,make:()=>re,makeFilter:()=>Tt,makeFilterGroup:()=>O5,makeIsBetween:()=>ym,makeIsGreaterThan:()=>mm,makeIsGreaterThanOrEqualTo:()=>hm,makeIsLessThan:()=>gm,makeIsLessThanOrEqualTo:()=>xm,makeIsMultipleOf:()=>OL,middlewareDecoding:()=>iL,middlewareEncoding:()=>aL,mutable:()=>g5,mutableKey:()=>XG,optional:()=>Pt,optionalKey:()=>qu,overrideToCodecIso:()=>T7,overrideToEquivalence:()=>YQ,overrideToFormatter:()=>ZQ,readonlyKey:()=>e5,refine:()=>y5,required:()=>YG,requiredKey:()=>QG,resolveAnnotations:()=>M7,resolveAnnotationsKey:()=>P7,revealBottom:()=>FG,revealCodec:()=>LG,suspend:()=>oL,tag:()=>Ze,tagDefaultOmit:()=>k5,toArbitrary:()=>GQ,toCodecArrayFromSingle:()=>o7,toCodecIso:()=>FB,toCodecJson:()=>Ec,toCodecJsonAST:()=>uS,toCodecStringTree:()=>DB,toDifferJsonPatch:()=>k7,toEncoded:()=>jl,toEncoderXml:()=>s7,toEquivalence:()=>XQ,toFormatter:()=>QQ,toIso:()=>w7,toIsoFocus:()=>v7,toIsoSource:()=>I7,toJsonSchemaDocument:()=>_B,toRepresentation:()=>e7,toStandardJSONSchemaV1:()=>jG,toStandardSchemaV1:()=>BG,toTaggedUnion:()=>pL,toType:()=>Pr,withConstructorDefault:()=>fL,withDecodingDefault:()=>dL,withDecodingDefaultKey:()=>_T,withDecodingDefaultType:()=>T5,withDecodingDefaultTypeKey:()=>v5});var Oy="~effect/collections/Graph",Bv=e=>e;var rJ=(e,t,n)=>(e==="directed"?t.source===n.source&&t.target===n.target:t.source===n.source&&t.target===n.target||t.source===n.target&&t.target===n.source)&&ae(t.data,n.data),oJ=(e,t)=>e==="directed"?ce(t):Oa(ce(t.data)^ce(t.source)+ce(t.target)),sJ={[Oy]:{_N:e=>e,_E:e=>e},[Symbol.iterator](){return this.nodes[Symbol.iterator]()},[at](){return this.toJSON()},[_e](e){if(B(e,Oy)){let t=Bv(e);if(this.nodes.size!==t.nodes.size||this.edges.size!==t.edges.size||this.type!==t.type)return!1;for(let[n,r]of this.nodes)if(!t.nodes.has(n)||!ae(r,t.nodes.get(n)))return!1;for(let[n,r]of this.edges){let o=t.edges.get(n);if(o===void 0||!rJ(this.type,r,o))return!1}return!0}return!1},[Re](){let e=it("Graph");e=e^it(this.type),e=e^Dr(this.nodes.size),e=e^Dr(this.edges.size);for(let[t,n]of this.nodes)e=e^ce(t)+ce(n);for(let[t,n]of this.edges)e=e^ce(t)+oJ(this.type,n);return e},toJSON(){return{_id:"Graph",nodeCount:this.nodes.size,edgeCount:this.edges.size,type:this.type}},toString(){return`Graph(${this.type}, ${this.nodes.size}, ${this.edges.size})`},pipe(){return ie(this,arguments)}},ZD=(e,t)=>{let n=Object.create(sJ);return n.type=e,n.mutable=t,n.transforming=!1,n.nodes=new Map,n.edges=new Map,n.adjacency=new Map,n.reverseAdjacency=new Map,n.nextNodeIndex=0,n.nextEdgeIndex=0,n.acyclic=N(!0),n};var Vp=e=>{let t=Bv(e);return{type:e.type,nodes:Array.from(t.nodes,([n,r])=>({index:n,data:r})).sort((n,r)=>n.index-r.index),edges:Array.from(t.edges,([n,r])=>({index:n,source:r.source,target:r.target,data:r.data})).sort((n,r)=>n.index-r.index)}},Jp=e=>{let t=ZD(e.type,!1);for(let n of e.nodes)t.nodes.set(n.index,n.data),t.adjacency.set(n.index,[]),t.reverseAdjacency.set(n.index,[]);for(let n of e.edges)t.edges.set(n.index,{source:n.source,target:n.target,data:n.data}),t.adjacency.get(n.source).push(n.index),t.reverseAdjacency.get(n.target).push(n.index),e.type==="undirected"&&(t.adjacency.get(n.target).push(n.index),t.reverseAdjacency.get(n.source).push(n.index));return t.nextNodeIndex=e.nodes.length===0?0:e.nodes[e.nodes.length-1].index+1,t.nextEdgeIndex=e.edges.length===0?0:e.edges[e.edges.length-1].index+1,t.acyclic=U(),t};var iJ=Oy;var jv=e=>B(e,iJ);var YD=class e{type;source;target;identity;constructor(t,n,r,o){this.type=t,this.source=n,this.target=r,this.identity=o}[_e](t){return!(t instanceof e)||this.type!==t.type||!ae(this.identity,t.identity)?!1:this.type==="directed"?ae(this.source,t.source)&&ae(this.target,t.target):ae(this.source,t.source)&&ae(this.target,t.target)||ae(this.source,t.target)&&ae(this.target,t.source)}[Re](){let t=ce(this.identity);return this.type==="directed"?Nt(ce(this.target))(Nt(ce(this.source))(t)):Oa(t^ce(this.source)+ce(this.target))}};var _y="~effect/collections/HashMap",Us=5,Zp=1<<Us,aJ=Zp/4,eN=Zp/2,cJ=Zp-1,uJ=e=>(e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24),Gp=(e,t)=>e>>>t&cJ,fc=(e,t)=>1<<Gp(e,t),Ry=(e,t)=>uJ(e&t-1);function tN(e,t,n,r,o,s){if(t>32)throw new Error("HashMap: max depth exceeded");let i=fc(n,t),a=fc(o,t);if(i===a){let f=tN(e,t+Us,n,r,o,s);return new Du(e,i,[f])}let c=i|a,u=i>>>0<a>>>0?[r,s]:[s,r];return new Du(e,c,u)}var Fu=class{canEdit(t){return this.edit===t}},$v=class extends Fu{_tag="EmptyNode";edit=0;get size(){return 0}get(t,n,r){return U()}has(t,n,r){return!1}set(t,n,r,o,s,i){return i.value=!0,new Uu(t,r,o,s)}remove(t,n,r,o,s){return this}iterator(){return[][Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}canEdit(t){return!1}},Uu=class e extends Fu{_tag="LeafNode";edit;hash;key;value;constructor(t,n,r,o){super(),this.edit=t,this.hash=n,this.key=r,this.value=o}get size(){return 1}get(t,n,r){return this.hash===n&&ae(this.key,r)?N(this.value):U()}has(t,n,r){return this.hash===n&&ae(this.key,r)}set(t,n,r,o,s,i){if(this.hash===r&&ae(this.key,o))return ae(this.value,s)?this:this.canEdit(t)?(this.value=s,this):new e(t,r,o,s);if(i.value=!0,this.hash===r)return new qv(t,r,[[this.key,this.value],[o,s]]);let a=fc(r,n),c=fc(this.hash,n);if(a===c)return new Du(t,a,[this.set(t,n+Us,r,o,s,i)]);let u=a|c,f=a>>>0<c>>>0?[new e(t,r,o,s),this]:[this,new e(t,r,o,s)];return new Du(t,u,f)}remove(t,n,r,o,s){if(this.hash===r&&ae(this.key,o)){s.value=!0;return}return this}iterator(){return[[this.key,this.value]][Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}},qv=class e extends Fu{_tag="CollisionNode";edit;hash;entries;constructor(t,n,r){super(),this.edit=t,this.hash=n,this.entries=r}get size(){return this.entries.length}get(t,n,r){if(this.hash!==n)return U();for(let[o,s]of this.entries)if(ae(o,r))return N(s);return U()}has(t,n,r){if(this.hash!==n)return!1;for(let[o]of this.entries)if(ae(o,r))return!0;return!1}set(t,n,r,o,s,i){if(this.hash!==r)return i.value=!0,tN(t,n,this.hash,this,r,new Uu(t,r,o,s));for(let a=0;a<this.entries.length;a++)if(ae(this.entries[a][0],o)){if(ae(this.entries[a][1],s))return this;if(this.canEdit(t))return this.entries[a]=[o,s],this;let c=[...this.entries];return c[a]=[o,s],new e(t,this.hash,c)}return i.value=!0,this.canEdit(t)?(this.entries.push([o,s]),this):new e(t,this.hash,[...this.entries,[o,s]])}remove(t,n,r,o,s){if(this.hash!==r)return this;let i=this.entries.findIndex(([c])=>ae(c,o));if(i===-1)return this;if(s.value=!0,this.entries.length===1)return;if(this.entries.length===2){let c=this.entries[i===0?1:0];return new Uu(t,this.hash,c[0],c[1])}if(this.canEdit(t))return this.entries.splice(i,1),this;let a=[...this.entries];return a.splice(i,1),new e(t,this.hash,a)}iterator(){return this.entries[Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}},Du=class e extends Fu{_tag="IndexedNode";edit;_size;bitmap;children;constructor(t,n,r){super(),this.edit=t,this.bitmap=n,this.children=r}get size(){return this._size===void 0&&(this._size=this.children.reduce((t,n)=>t+n.size,0)),this._size}get(t,n,r){let o=fc(n,t);if((this.bitmap&o)===0)return U();let s=Ry(this.bitmap,o);return this.children[s].get(t+Us,n,r)}has(t,n,r){let o=fc(n,t);if((this.bitmap&o)===0)return!1;let s=Ry(this.bitmap,o);return this.children[s].has(t+Us,n,r)}set(t,n,r,o,s,i){let a=fc(r,n),c=Ry(this.bitmap,a);if((this.bitmap&a)!==0){let u=this.children[c],f=u.set(t,n+Us,r,o,s,i);if(u===f)return this;if(this.canEdit(t))return this.children[c]=f,this;let l=[...this.children];return l[c]=f,new e(t,this.bitmap,l)}else{i.value=!0;let u=new Uu(t,r,o,s),f=this.bitmap|a;if(this.canEdit(t))return this.children.splice(c,0,u),this.bitmap=f,this._size=void 0,this.children.length>eN?this.expand(t,f,this.children):this;let l=[...this.children];return l.splice(c,0,u),l.length>eN?this.expand(t,f,l):new e(t,f,l)}}remove(t,n,r,o,s){let i=fc(r,n);if((this.bitmap&i)===0)return this;let a=Ry(this.bitmap,i),c=this.children[a],u=c.remove(t,n+Us,r,o,s);if(!s.value)return this;if(u===void 0){let l=this.bitmap^i;if(l===0)return;if(this.children.length===2){let m=this.children[a===0?1:0];if(m._tag==="LeafNode")return m}if(this.canEdit(t))return this.children.splice(a,1),this.bitmap=l,this._size=void 0,this;let p=[...this.children];return p.splice(a,1),new e(t,l,p)}if(c===u)return this;if(this.canEdit(t))return this.children[a]=u,this;let f=[...this.children];return f[a]=u,new e(t,this.bitmap,f)}expand(t,n,r){let o=new globalThis.Array(Zp),s=0;for(let i=0;i<Zp;i++)(n&1<<i)!==0&&(o[i]=r[s++]);return new zv(t,r.length,o)}iterator(){let t=0,n;return{next:()=>{for(;t<this.children.length;){n||(n=this.children[t].iterator());let r=n.next();if(!r.done)return r;n=void 0,t++}return{done:!0,value:void 0}}}}[Symbol.iterator](){return this.iterator()}},zv=class e extends Fu{_tag="ArrayNode";edit;_size;count;children;constructor(t,n,r){super(),this.edit=t,this.count=n,this.children=r}get size(){return this._size===void 0&&(this._size=this.children.reduce((t,n)=>t+(n?.size??0),0)),this._size}get(t,n,r){let o=Gp(n,t),s=this.children[o];return s?s.get(t+Us,n,r):U()}has(t,n,r){let o=Gp(n,t),s=this.children[o];return s?s.has(t+Us,n,r):!1}set(t,n,r,o,s,i){let a=Gp(r,n),c=this.children[a];if(c){let u=c.set(t,n+Us,r,o,s,i);if(c===u)return this;if(this.canEdit(t))return this.children[a]=u,this;let f=[...this.children];return f[a]=u,new e(t,this.count,f)}else{i.value=!0;let u=new Uu(t,r,o,s);if(this.canEdit(t))return this.children[a]=u,this.count++,this._size=void 0,this;let f=[...this.children];return f[a]=u,new e(t,this.count+1,f)}}remove(t,n,r,o,s){let i=Gp(r,n),a=this.children[i];if(!a)return this;let c=a.remove(t,n+Us,r,o,s);if(!s.value)return this;let u=this.count-(c?0:1);if(u<aJ)return this.pack(t,i,c);if(a===c)return this;if(this.canEdit(t))return this.children[i]=c,c||(this.count=u),this._size=void 0,this;let f=[...this.children];return f[i]=c,new e(t,u,f)}pack(t,n,r){let o=[],s=0,i=1;for(let a=0;a<this.children.length;a++){let c=a===n?r:this.children[a];c&&(o.push(c),s|=i),i<<=1}return new Du(t,s,o)}iterator(){let t=0,n;return{next:()=>{for(;t<this.children.length;){let r=this.children[t];if(!r){t++;continue}n||(n=r.iterator());let o=n.next();if(!o.done)return o;n=void 0,t++}return{done:!0,value:void 0}}}}[Symbol.iterator](){return this.iterator()}},Qp=class{[_y]=_y;_editable;_edit;_root;_size;constructor(t,n,r,o){this._editable=t,this._edit=n,this._root=r,this._size=o}get size(){return this._size}[Symbol.iterator](){return this._root.iterator()}[_e](t){if(Hv(t)){let n=t;if(this.size!==n.size)return!1;for(let[r,o]of this){let s=of(t,oN(r));if(ge(s)||!ae(o,s.value))return!1}return!0}return!1}[Re](){let t=it("HashMap");for(let[n,r]of this)t=t^ce(n)+ce(r);return t}[at](){return hn(this)}toString(){return`HashMap(${X(Array.from(this))})`}toJSON(){return{_id:"HashMap",values:Array.from(this).map(([t,n])=>[hn(t),hn(n)])}}pipe(){return ie(this,arguments)}},nN=new $v,Hv=e=>B(e,_y),Wv=()=>new Qp(!1,0,nN,0);var rN=e=>{let t=nN,n=0,r={value:!1};for(let[o,s]of e){let i=ce(o);r.value=!1,t=t.set(NaN,0,i,o,s,r),r.value&&n++}return new Qp(!1,0,t,n)};var oN=d(2,(e,t)=>e._root.get(0,ce(t),t));var Kv=d(2,(e,t)=>e._root.has(0,ce(t),t));var fJ=(e,t,n,r)=>{let o=e,s={value:!1},i=o._editable?o._edit:NaN,a=o._root.set(i,0,n,t,r,s);return o._editable?(o._root=a,s.value&&o._size++,e):o._root===a?e:new Qp(!1,o._edit,a,o._size+(s.value?1:0))},Vv=d(3,(e,t,n)=>fJ(e,t,ce(t),n)),Jv=e=>{let t=e[Symbol.iterator]();return{[Symbol.iterator](){return this},next(){let n=t.next();return n.done?{done:!0,value:void 0}:{done:!1,value:n.value[0]}}}};var sN=e=>{let t=e[Symbol.iterator]();return{[Symbol.iterator](){return this},next(){return t.next()}}},My=e=>e.size;var Py=Hv;var Fy=rN;var pJ=sN,Uy=e=>Array.from(pJ(e)),aN=My;var Yp="~effect/collections/HashSet",mJ={[Re](){return ce(Yp)},[_e](e){return Zv(e)&&Dy(this)===Dy(e)&&fN(this,t=>uN(e,t))},[Symbol.iterator](){return Jv(Qv(this))},toString(){return`HashSet(${X(Array.from(this))})`},toJSON(){return{_id:"HashSet",values:hn(Array.from(this))}},[at](){return this.toJSON()},pipe(){return ie(this,arguments)}},hJ=e=>{let t=Object.create(mJ);return t[Yp]=Yp,t.keyMap=e,t},Zv=e=>B(e,Yp),Qv=e=>e.keyMap;var cN=e=>{let t=Wv();for(let n of e)t=Vv(t,n,!0);return hJ(t)},uN=(e,t)=>Kv(Qv(e),t);var Dy=e=>My(Qv(e));var fN=(e,t)=>{for(let n of e)if(!t(n))return!1;return!0};var Ny=cN,Ly=Zv;var lN=Dy;function By(e){let t=IN($y,yn(e.ast));return(n,r)=>t(n,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function jy(e){let t=By(e);return(n,r)=>{let o=ec(t(n,r));return Ft(o)?N(o.value):(ia(o.cause,"Option adapter can only return none for schema issues"),U())}}function pN(e){let t=By(e);return(n,r)=>{let o=ec(t(n,r));if(Ft(o))return o.value;let s=ia(o.cause,"Constructor adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:s})}}function mN(e){return em(e.ast)}function em(e){let t=Nu(tm(yn(e)));return n=>{let r=t(n,Qr);return Ft(r)?!0:(ia(r.cause,"Type guard adapter can only return false for schema issues"),!1)}}function hN(e){let t=tm(e);return(n,r)=>{let o=ec(t(n,r));if(!Ft(o))return ia(o.cause,"Issue adapter can only return schema issues")}}function gN(e,t){let r=Nu(tm(yn(e.ast)))(t,Qr);if(ri(r)){let o=ia(r.cause,"Assertion adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:o})}}function dt(e,t){let n=tm(e.ast);return t===void 0?n:(r,o)=>n(r,Xp(t,o))}var Xv=dt;function xN(e,t){return Nu(dt(e,t))}function eT(e,t){return vN(dt(e,t))}var yN=eT;function SN(e,t){return TN(dt(e,t))}function xJ(e,t){return kN(dt(e,t))}var tT=xJ;function Cl(e,t){let n=tm(vs(e.ast));return t===void 0?n:(r,o)=>n(r,Xp(t,o))}function EN(e,t){return Nu(Cl(e,t))}function nT(e,t){return vN(Cl(e,t))}var bN=nT;function wN(e,t){return TN(Cl(e,t))}function yJ(e,t){return kN(Cl(e,t))}var rT=yJ,Xp=(e,t)=>t?{...e,...t}:e,dN=e=>e===ze?G(new ke):v(e);function tm(e){return IN(CN,e)}function IN(e,t){let n;return(r,o)=>{let s=(n??=e(t))(r,o??Qr);return s===on?v(r):xt(s)?s[xe]===ze?dN(ze):s:Bn(s,dN)}}function Nu(e){return(t,n)=>ec(e(t,n))}function vN(e){let t=Nu(e);return(n,r)=>{let o=t(n,r);return Ft(o)?N(o.value):(ia(o.cause,"Option adapter can only return none for schema issues"),U())}}function TN(e){let t=Nu(e);return(n,r)=>{let o=t(n,r);return Ft(o)?Ce(o.value):Ae(ia(o.cause,"Result adapter can only return schema issues"))}}function kN(e){let t=Nu(e);return(n,r)=>{let o=t(n,r);if(Ft(o))return o.value;let s=ia(o.cause,"Sync adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:s})}}var CN=wn(e=>oT(e,CN)),$y=wn(e=>oT(e,$y,AN)),SJ=wn(e=>oT(e,$y,AN,e.context?.constructorDefault));function AN(e){return e.context?.constructorDefault?SJ(e):$y(e)}function ON(e,t,n,r){let o;if(xt(e)&&e._tag==="Success"){let s=mx(e===on?t:e[xe]);o=n._tag==="Transformation"?n.decode.run(s,r):n.decode($o(s),r)}else n._tag==="Transformation"?o=Bn(e,s=>n.decode.run(mx(s),r)):o=n.decode(oa(e,mx),r);return xt(o)&&o._tag==="Success"?qw(o[xe]):Bn(o,qw)}function EJ(e,t){let n;return(r,o)=>{if(r===ze)return ws;if(e.isConstructed(r))return on;let s=(n??=t(e.link.to))(r,o);return ON(s,r,e.link.transformation,o)}}function oT(e,t,n,r){let o=n?h1(e):void 0,s=o?EJ(o,t):e.getParser(t,n),i=e.checks,a=r?e.encoding?[...e.encoding,r]:[r]:e.encoding,c=e.encodingChecks,u=(i?i[i.length-1].annotations:e.annotations)?.parseOptions;if(!a&&!i&&!c)return u?(p,m)=>s(p,Xp(m,u)):s;let f,l=(p,m)=>{let h=s(p,m);if(c&&!m.disableChecks)if(xt(h)){if(h._tag==="Success"){let g=h===on?p:h[xe];if(p!==ze&&g!==ze){let x=Cs(c,p,void 0,e,m);x&&(h=G(new At(e,x,p,m)))}}}else h=A(h,g=>{if(p!==ze&&g!==ze){let x=Cs(c,p,void 0,e,m);if(x)return G(new At(e,x,p,m))}return v(g)});if(i&&!m.disableChecks)if(xt(h)){if(h._tag==="Success"){let g=h===on?p:h[xe];if(g===ze)return h;let x=Cs(i,g,void 0,e,m);x&&(h=G(new At(e,x,g,m)))}}else h=A(h,g=>{if(g!==ze){let x=Cs(i,g,void 0,e,m);if(x)return G(new At(e,x,g,m))}return v(g)});return h};return a?(p,m)=>{u&&(m=Xp(m,u));let h=f??=a.map(b=>t(b.to)),g=p,x=h[h.length-1](p,m);for(let b=a.length-1;b>=0;b--)if(x=ON(x,g,a[b].transformation,m),b!==0){let E=h[b-1];x._tag==="Success"?(g=x[xe],x=E(g,m)):x=Bn(x,y=>{let w=E(y,m);return w===on?$o(y):w})}if(x._tag==="Success"){let b=x[xe],E=l(b,m);return E===on?x:E}return x=ft(x,b=>ea(()=>Ja(b,E=>new yx(e,E,p,m)))),Bn(x,b=>{let E=l(b,m);return E===on?$o(b):E})}:u?(p,m)=>l(p,Xp(m,u)):l}var qy="~effect/Schema/Schema";function _r(e,t,n){return{id:e,payloadSchema:t,revive:n}}function Oe(e,t,n){return{id:e,payloadSchema:t,revive:n}}var bJ={[qy]:qy,pipe(){return ie(this,arguments)},annotate(e){return this.rebuild(qo(this.ast,e))},annotateKey(e){return this.rebuild(ml(this.ast,e))},check(...e){return this.rebuild(hi(this.ast,e))}};function nm(e,t){function n(){}let r=Object.defineProperties(Object.setPrototypeOf(n,bJ),Object.getOwnPropertyDescriptors({...t}));return r.ast=e,r.rebuild=o=>nm(o,t),r.makeEffect=By(r),r.make=pN(r),r.makeOption=jy(r),r}var RN=d(2,(e,t)=>iT(e,(n,r)=>t.includes(n)?[n,r]:void 0)),_N=d(2,(e,t)=>iT(e,(n,r)=>t.includes(n)?void 0:[n,r])),MN=d(2,(e,t)=>({...e,...t}));var sT=d(2,(e,t)=>iT(e,(n,r)=>[Object.hasOwn(t,n)?t[n]:n,r]));var dr=e=>e;function iT(e,t){let n={};for(let r of Reflect.ownKeys(e)){if(!Object.prototype.propertyIsEnumerable.call(e,r))continue;let o=t(r,e[r]);if(o){let[s,i]=o;W(n,s,i)}}return n}function PN(e,t){let n=t?.omitKeyWhen??(()=>!1);return Ih((r,o)=>{let s=Reflect.ownKeys(e),i={};for(let a of s){let c=e[a].combine(r[a],o[a]);n(c)||W(i,a,c)}return i})}function rm(e){return wo((t,n)=>t===void 0?n:n===void 0?t:e.combine(t,n),void 0)}function Ei(e,t){return t.length>0&&(e+=`
|
|
30
|
-
at ${vh(t)}`),new Error(e)}var UN=new WeakMap,DN=new WeakMap,NN=[];function Sa(e){return new Error(`Unable to derive an arbitrary for ${e}`)}var LN=([e],[t])=>ae(e,t);function IJ(e,t,n){return t.reduce((r,o)=>r.filter(s=>o.run(s,e,Qr)===void 0),n)}function JN(e,t){if(e?.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength)throw Sa(`${t} constraints`)}function GN(e){return e===void 0||e.minLength===void 0&&e.maxLength===void 0?void 0:{...e.minLength!==void 0?{minLength:e.minLength}:{},...e.maxLength!==void 0?{maxLength:e.maxLength}:{}}}function aT(e,t,n,r){return r?e.uniqueArray(t,{...n,comparator:r}):e.array(t,n)}function BN(e,t,n,r=!1){let o=t.constraint,s=GN(o);return JN(s,"array"),aT(e,n,r?{...s,maxLength:s?.minLength??0}:s,o?.unique?ae:void 0)}function Hy(e,t,n,r){return t.chain(o=>o.length<n?e.constant(o):r.map(s=>[...o,...s]))}function jN(e,t){return e.chain(n=>t.map(r=>({...Object.fromEntries(r),...n})))}var vJ=rm(BP),TJ=rm(jP),Wy=rm(kO),kJ=rm(mO()),CJ=PN({integer:Wy,maxLength:TJ,minLength:vJ,noInfinity:Wy,noNaN:Wy,patterns:kJ,unique:Wy},{omitKeyWhen:wA});function $N(e,t,n,r,o,s){if(r===void 0||t===void 0)return r===void 0?[t,n]:[r,o];let i=e(t,r);return i===s?[r,o]:i===0?[t,n||o]:[t,n]}function AJ(e,t){if(e===void 0)return t;if(e.order!==t.order)throw new Error("Cannot merge ordered arbitrary constraints with different Order instances");let[n,r]=$N(e.order,e.minimum,e.exclusiveMinimum,t.minimum,t.exclusiveMinimum,-1),[o,s]=$N(e.order,e.maximum,e.exclusiveMaximum,t.maximum,t.exclusiveMaximum,1);return{order:e.order,...n!==void 0?{minimum:n}:{},...r!==void 0?{exclusiveMinimum:r}:{},...o!==void 0?{maximum:o}:{},...s!==void 0?{exclusiveMaximum:s}:{}}}function OJ(e,t){let{ordered:n,...r}=e??{},{ordered:o,...s}=t,i=o===void 0?n:AJ(n,o);return{...CJ.combine(r,s),...i===void 0?{}:{ordered:i}}}function qN(e){let t=[],n=[];function r(o){if(o.annotations?.arbitrary&&n.push(o.annotations.arbitrary),o._tag!=="Filter")for(let s of o.checks)r(s);else t.push(o)}return e?.forEach(r),{filters:t,arbitraries:n}}function RJ(e){let t=e.map(({constraint:n})=>n).filter(Kn);return n=>{let r=t.reduce((o,s)=>OJ(o,s),n.constraint);return{...n,constraint:r}}}function om(e){return{...e,constraint:void 0}}function zN(e,t,n){if(t===void 0||t.minLength===void 0&&t.maxLength===void 0)return;if(t.minLength!==void 0&&e.indexSignatures.length===0&&t.minLength>e.propertySignatures.length)throw Sa("object property constraints");let r={};if(t.minLength!==void 0&&(r.minLength=Math.max(0,t.minLength-n)),t.maxLength!==void 0&&(r.maxLength=t.maxLength-n,r.maxLength<0))throw Sa("object property constraints");return JN(r,"object property"),r}function _J(e,t,n,r,o,s){let i=r.length;if(s.maxLength!==void 0&&s.maxLength<i)throw Sa("object property constraints");let a=s.minLength===void 0?0:Math.max(0,s.minLength-i),c=s.maxLength===void 0?o.length:Math.min(o.length,s.maxLength-i);if(a>c)throw Sa("object property constraints");let u=e.record(t,{requiredKeys:[...r,...o]}),f=e.shuffledSubarray([...o],{minLength:a,maxLength:c});return e.tuple(u,f).map(([l,p])=>{let m=new Set([...r,...p]),h={};for(let g of n)m.has(g)&&W(h,g,l[g]);return h})}function ZN(e,t,n,r){let o={};if(e?.minimum!==void 0&&(o.min=t(e.minimum,e.exclusiveMinimum===!0)),e?.maximum!==void 0&&(o.max=n(e.maximum,e.exclusiveMaximum===!0)),o.min!==void 0&&o.max!==void 0&&o.min>o.max)throw Sa(r);return o}function MJ(e){return ZN(e,(t,n)=>n?Math.floor(t)+1:Math.ceil(t),(t,n)=>n?Math.ceil(t)-1:Math.floor(t),"integer constraints")}function PJ(e,t){let n={...e?.noInfinity?{noDefaultInfinity:!0}:{},...e?.noNaN?{noNaN:!0}:{},...t?.minimum!==void 0?{min:t.minimum}:{},...t?.exclusiveMinimum!==void 0?{minExcluded:t.exclusiveMinimum}:{},...t?.maximum!==void 0?{max:t.maximum}:{},...t?.exclusiveMaximum!==void 0?{maxExcluded:t.exclusiveMaximum}:{}};if(n.min!==void 0&&n.max!==void 0&&(n.min>n.max||n.min===n.max&&(n.minExcluded||n.maxExcluded)))throw Sa("number constraints");return n}function FJ(e){return ZN(e,(t,n)=>n?t+BigInt(1):t,(t,n)=>n?t-BigInt(1):t,"the ordered bigint constraints")}function Ol(e,t){let n=(r,o,s=NN)=>e(r,o,s);return n.terminal=(r,o,s=NN)=>t(r,o,s),n}function Wo(e){return Ol(e,e)}function HN(e,t){let n=DN.get(t)??e.createDepthIdentifier();return DN.set(t,n),{maxDepth:2,depthIdentifier:n}}function WN(e,t){return t.length===0?void 0:t.length===1?t[0]:e.oneof(...t)}var UJ={noInfinity:!0,noNaN:!0};function DJ(e){return{...e,constraint:UJ}}function NJ(e,t,n,r){let o=r===void 0?[]:[{arbitrary:r,weight:1}];for(let{candidate:s}of n){if(!s)continue;let i=s.make(e,t);if(i===void 0)continue;let a=s.weight??1;if(!globalThis.Number.isInteger(a)||a<=0)throw Sa("a candidate with an invalid weight");o.push({arbitrary:i,weight:a})}return o.length===0?void 0:o.length===1?o[0].arbitrary:e.oneof(...o)}function KN(e,t,n,r,o){let s=NJ(n,r,t.arbitraries,o);return s===void 0?void 0:IJ(e,t.filters,s)}function LJ(e,t){if(!(typeof e=="object"&&e!==null&&"arbitrary"in e))return{arbitrary:e,terminal:t?void 0:e};let n="terminal"in e?e.terminal:t?void 0:e.arbitrary;return{arbitrary:e.arbitrary,terminal:n}}function BJ(e,t,n,r,o){return e.map(s=>({arbitrary:o?t.constant(null).chain(()=>s(t,n,r)):s(t,n,r),terminal:s.terminal(t,n,r)}))}function VN(e,t,n,r){let o=RJ(t.arbitraries);return Ol((s,i,a)=>{let c=o(i);return KN(e,t,s,c,n(s,i,c,a))},(s,i,a)=>{let c=o(i);return KN(e,t,s,c,r(s,i,c,a))})}var QN=wn(e=>Ko(e,[]));function Ko(e,t){let n=di(e)?.toArbitrary;if(n){let r=ic(e)?e.typeParameters.map(i=>Ko(i,t)):[],o=qN(e.checks),s=i=>(a,c,u,f)=>LJ(n(BJ(r,a,om(c),f,i))(a,u),r.length>0)[i?"terminal":"arbitrary"];return VN(e,o,s(!1),s(!0))}if(e.checks){let r=qN(e.checks),o=Ko(Wx(e,void 0),t);return VN(e,r,(s,i,a,c)=>o(s,a,c),(s,i,a,c)=>o.terminal(s,a,c))}return jJ(e,t)}function jJ(e,t){switch(e._tag){case"Never":case"Declaration":throw Ei(`Unsupported AST ${e._tag}`,t);case"Null":return Wo(n=>n.constant(null));case"Void":case"Undefined":return Wo(n=>n.constant(void 0));case"Unknown":case"Any":return Wo(n=>n.anything());case"String":return Wo((n,r)=>{let o=r.constraint,s=o?.patterns;return s?n.oneof(...s.map(i=>n.stringMatching(new RegExp(i)))):n.string(GN(o))});case"Number":return Wo((n,r)=>{let o=r.constraint,s=o?.ordered?.order===co?o.ordered:void 0;return o?.integer?n.integer(MJ(s)):n.float(PJ(o,s))});case"Boolean":return Wo(n=>n.boolean());case"BigInt":return Wo((n,r)=>{let o=r.constraint?.ordered?.order===Co?r.constraint.ordered:void 0;return n.bigInt(FJ(o))});case"Symbol":return Wo(n=>n.string().map(Symbol.for));case"Literal":return Wo(n=>n.constant(e.literal));case"UniqueSymbol":return Wo(n=>n.constant(e.symbol));case"ObjectKeyword":return Wo(n=>n.oneof(n.object(),n.array(n.anything())));case"Enum":return Ko(Mp(e),t);case"TemplateLiteral":{let n=e.parts.map((r,o)=>Ko(jn(r),[...t,o]));return Wo((r,o,s)=>r.tuple(...n.map(i=>i(r,DJ(o),s))).map(i=>i.map(a=>globalThis.String(a)).join("")))}case"Arrays":{let n=e.elements.map((i,a)=>({ast:i,arbitrary:Ko(i,[...t,a])})),r=e.elements.length,o=e.rest.map((i,a)=>({ast:i,arbitrary:Ko(i,[...t,r+a])})),s=(i,a,c)=>{let u=om(a),f=[],l=[],p=0;for(let E of n){let y=E.arbitrary.terminal(i,u,c);if(an(E.ast)){l.push(y);continue}if(y===void 0)return;p++,f.push(y.map(N))}let m=a.constraint?.minLength??0,g=Ye(o)&&m>p+l.length?l.length:Math.max(0,m-p),x=0;for(let E of l){if(x>=g||E===void 0){f.push(i.constant(U()));continue}x++,p++,f.push(E.map(N))}if(x<g)return;let b=i.tuple(...f).map(rb);if(Ye(o)){let[E,...y]=o,w=e.elements.length===0?a:u,S=Math.max(0,m-p-y.length),C=S===0?void 0:E.arbitrary.terminal(i,u,c);if(S>0&&C===void 0)return;let _=S===0?i.constant([]):BN(i,{...w,constraint:{...w.constraint,minLength:S}},C,!0);if(b=Hy(i,b,r,_),y.length>0){let R=[];for(let q of y){let P=q.arbitrary.terminal(i,u,c);if(P===void 0)return;R.push(P)}let M=i.tuple(...R);b=Hy(i,b,r,M)}}return b};return Ol((i,a,c)=>{let u=om(a),f=n.map(({ast:p,arbitrary:m})=>{let h=m(i,u,c);return an(p)?h.chain(g=>i.boolean().map(x=>x?N(g):U())):h.map(N)}),l=i.tuple(...f).map(p=>rb(dO(p,Te)));if(Ye(o)){let[p,...m]=o.map(({arbitrary:g})=>g(i,u,c)),h=BN(i,e.elements.length===0?a:u,p);if(l=Hy(i,l,r,h),m.length>0){let g=i.tuple(...m);l=Hy(i,l,r,g)}}if(a.recursion){let p=s(i,a,c);if(p!==void 0)return i.oneof(a.recursion,p,l)}return l},s)}case"Objects":{let n=e.propertySignatures.map(s=>({ps:s,arbitrary:Ko(s.type,[...t,s.name])})),r=e.indexSignatures.map(s=>({is:s,parameter:Ko(s.parameter,t),type:Ko(s.type,t)}));return Ol((s,i,a)=>{let c=om(i),u={},f=[],l=[],p=[];for(let{ps:x,arbitrary:b}of n){let E=x.name;f.push(E),an(x.type)?p.push(E):l.push(E),W(u,E,b(s,c,a))}let m=i.constraint;if(p.length>0&&r.length===0&&m!==void 0&&(m.minLength!==void 0||m.maxLength!==void 0))return _J(s,u,f,l,p,m);let h=s.record(u,{requiredKeys:l}),g=zN(e,i.constraint,l.length);for(let{parameter:x,type:b}of r){let E=s.tuple(x(s,c,a),b(s,c,a)),y=aT(s,E,g,LN);h=jN(h,y)}return h},(s,i,a)=>{let c=om(i),u={},f=[],l=[];for(let{ps:x,arbitrary:b}of n){let E=x.name,y=b.terminal(s,c,a);if(an(x.type)){y!==void 0&&l.push([E,y]);continue}if(y===void 0)return;f.push(E),W(u,E,y)}let p=Math.max(0,(i.constraint?.minLength??0)-f.length);for(let[x,b]of l){if(p===0)break;p--,f.push(x),W(u,x,b)}if(p>0&&e.indexSignatures.length===0)return;let m=s.record(u,{requiredKeys:f}),h=zN(e,i.constraint,f.length),g=h?.minLength??0;for(let{parameter:x,type:b}of r){let E;if(g===0)E=s.constant([]);else{let y=x.terminal(s,c,a),w=b.terminal(s,c,a);if(y===void 0||w===void 0)return;E=aT(s,s.tuple(y,w),{...h,maxLength:g},LN)}m=jN(m,E)}return m})}case"Union":{let n=e.types.map(o=>Ko(o,t)),r=(o,s,i)=>WN(o,n.map(a=>a.terminal(o,s,i)).filter(Kn));return Ol((o,s,i)=>{let a=n.map(u=>u(o,s,i));if(s.recursion){let u=r(o,s,i);if(u!==void 0)return o.oneof(s.recursion,u,...a)}let c=WN(o,a);if(c===void 0)throw Sa("a union with no members");return c},r)}case"Suspend":{let n=UN.get(e);if(n)return n;let r=Tu(()=>Ko(e.thunk(),t)),o=Ol((s,i,a)=>{let c=HN(s,e),u={...i,recursion:c},f=a.includes(e)?a:[...a,e],l=r().terminal(s,u,f);if(l===void 0)throw Ei("Unable to derive an arbitrary for a recursive schema without a finite generation path",t);return s.oneof(c,l,s.constant(null).chain(()=>r()(s,u,f)))},(s,i,a)=>{if(a.includes(e))return;let c=HN(s,e);return r().terminal(s,{...i,recursion:c},[...a,e])});return UN.set(e,o),o}}}var YN=wn(e=>lc(e,[]));function lc(e,t){let n=di(e)?.toEquivalence;if(n)return n(ic(e)?e.typeParameters.map(r=>lc(r,t)):[]);switch(e._tag){case"Never":return Nc();case"Declaration":case"Null":case"Undefined":case"Void":case"Unknown":case"Any":case"String":case"Number":case"Boolean":case"BigInt":case"Symbol":case"Literal":case"UniqueSymbol":case"ObjectKeyword":case"Enum":case"TemplateLiteral":return ae;case"Arrays":{let r=e.elements.map((i,a)=>lc(i,[...t,a])),o=e.elements.length,s=e.rest.map((i,a)=>lc(i,[...t,o+a]));return un((i,a)=>{if(!Array.isArray(i)||!Array.isArray(a))return!1;let c=i.length;if(c!==a.length)return!1;let u=0;for(;u<Math.min(c,e.elements.length);u++)if(!r[u](i[u],a[u]))return!1;if(s.length>0){let[f,...l]=s;for(;u<c-l.length;u++)if(!f(i[u],a[u]))return!1;for(let p=0;p<l.length;p++)if(!l[p](i[u+p],a[u+p]))return!1}return!0})}case"Objects":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return ae;let r=e.propertySignatures.map(s=>lc(s.type,[...t,s.name])),o=e.indexSignatures.map(s=>lc(s.type,t));return un((s,i)=>{if(!en(s)||!en(i))return!1;for(let a=0;a<r.length;a++){let c=e.propertySignatures[a],u=c.name,f=Object.hasOwn(s,u),l=Object.hasOwn(i,u);if(an(c.type)&&f!==l||f&&l&&!r[a](s[u],i[u]))return!1}for(let a=0;a<o.length;a++){let c=e.indexSignatures[a],u=ua(s,c.parameter),f=ua(i,c.parameter);if(u.length!==f.length)return!1;for(let l=0;l<u.length;l++){let p=u[l];if(!Object.hasOwn(i,p)||!o[a](s[p],i[p]))return!1}}return!0})}case"Union":{let r=yn(e).types,o=new Map(r.map((s,i)=>[s,[em(s),lc(e.types[i],t)]]));return un((s,i)=>{let a=Cp(s,r);for(let c=0;c<a.length;c++){let[u,f]=o.get(a[c]);if(u(s)&&u(i))return f(s,i)}return!1})}case"Suspend":{let r=Tu(()=>lc(e.thunk(),t));return un((o,s)=>r()(o,s))}}}function Lu(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Rl(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}var HJ="http://json-schema.org/draft-07/schema#",XN="https://json-schema.org/draft/2020-12/schema";function e2(e,t){return e===t||e===(t.endsWith("#")?t.slice(0,-1):`${t}#`)}function r2(e){return{dialect:"draft-07",...QJ(e,aG)}}function WJ(e,t){return n(e,!1,!0);function n(r,o,s=!1){if(!en(r))return r;let i=o||!s&&i2(r.$id),a={};for(let c of Object.keys(r)){let u=r[c],f=u;switch(c){case"$defs":case"properties":case"patternProperties":case"dependentSchemas":f=uT(u,l=>n(l,i))??u;break;case"allOf":case"anyOf":case"oneOf":case"prefixItems":f=Array.isArray(u)?u.map(l=>n(l,i)):u;break;case"not":case"additionalProperties":case"propertyNames":case"unevaluatedProperties":case"items":case"contains":case"unevaluatedItems":case"if":case"then":case"else":case"contentSchema":f=n(u,i)}W(a,c,f)}return t(a,i),a}}function o2(e,t){return WJ(e,n=>{KJ(n,t)})}function KJ(e,t){typeof e.$ref=="string"&&W(e,"$ref",t(e.$ref,"$ref")),typeof e.$dynamicRef=="string"&&W(e,"$dynamicRef",t(e.$dynamicRef,"$dynamicRef"))}function uT(e,t){if(!en(e))return;let n={};for(let r of Object.keys(e))W(n,r,t(e[r],r));return n}function VJ(e,t,n){let r=new Map,o=[],s=cT;function i(p,m=[],h=[]){if(m.length===0&&t?.trackIds){let g=en(p)?f(p):void 0;s=t2(g,cT)??cT}return u(p,m,h,{sourceRoot:[],targetRoot:[],uri:s})}function a(){for(let[p,m,h]of o){let g=m,x=s2(m,h);if(x!==void 0){let b=JJ(x.hash);if(x.hash="",b!==void 0){let E=r.get(n2(x.href,b));E!==void 0&&(g=GJ(m,E))}}W(p,"$ref",g)}}let c=n(i);return a(),c;function u(p,m,h,g){if(typeof p=="boolean")return l(m,h,g),t?.booleanAdapter?.(p)??p;if(!en(p))return p;let x=g,b=f(p);if(m.length>0&&t?.trackIds&&i2(b)){let w=t2(b,g.uri);w!==void 0&&(x={parent:g,sourceRoot:m,targetRoot:h,uri:w})}l(m,h,x);let E=x.uri,y={isDocumentRoot:m.length===0,schema(w,S,C=S){return u(w,[...m,S],[...h,C],x)},schemaAt(w,S,C){return u(w,[...m,...S],[...h,...C],x)},schemaArray(w,S,C=S){return Array.isArray(w)?w.map((_,R)=>u(_,[...m,S,String(R)],[...h,C,String(R)],x)):w},schemaMap(w,S,C=S){return en(w)?uT(w,(_,R)=>u(_,[...m,S,R],[...h,C,R],x)):w},reference(w,S){typeof S=="string"?o.push([w,S,E]):W(w,"$ref",S)}};return e(p,y)}function f(p){return t?.ignoreRefSiblings===!0&&typeof p.$ref=="string"?void 0:p.$id}function l(p,m,h){h.parent!==void 0&&l(p,m,h.parent),r.set(n2(h.uri,p.slice(h.sourceRoot.length)),m.slice(h.targetRoot.length))}}var cT="https://effect.invalid/.json-schema/";function s2(e,t){return URL.canParse(e,t)?new URL(e,t):void 0}function t2(e,t){if(typeof e!="string")return;let n=s2(e,t);if(n!==void 0)return n.hash="",n.href}function JJ(e){if(e.length===0)return[];let t;try{t=decodeURIComponent(e.slice(1))}catch{return}if(t.startsWith("/"))return/~(?:[^01]|$)/.test(t)?void 0:t.slice(1).split("/").map(Rl)}function GJ(e,t){let n=e.indexOf("#");return n===-1&&t.length===0?e:`${n===-1?e:e.slice(0,n)}${ZJ(t)}`}function ZJ(e){return e.length===0?"#":`#/${e.map(t=>encodeURI(Lu(t)).replace(/#/g,"%23")).join("/")}`}function n2(e,t){return`${e}\0${JSON.stringify(t)}`}function i2(e){return typeof e=="string"&&e.length>0&&e[0]!=="#"}function QJ(e,t,n){return VJ(t,{...n,trackIds:!0},r=>({schema:r(e.schema),definitions:uT(e.definitions,(o,s)=>r(o,["$defs",s],["definitions",s]))}))}var YJ=new Set(["properties","patternProperties"]),XJ=new Set(["allOf","anyOf","oneOf"]),eG=new Set(["not","additionalProperties","propertyNames","contains","if","then","else","contentSchema"]);function tG(e,t,n,r,o,s=YJ){let i;if(s.has(t))i=r.schemaMap(n,t);else if(XJ.has(t))i=r.schemaArray(n,t);else if(o.has(t))i=r.schema(n,t);else return!1;return W(e,t,i),!0}var a2=["$anchor","$defs","$dynamicAnchor","$dynamicRef","$vocabulary","contentSchema","dependentRequired","dependentSchemas","maxContains","minContains","prefixItems","unevaluatedItems","unevaluatedProperties"],Gue=[...a2,"deprecated"],Zue=[...a2,"$comment","$id","$schema","const","contains","contentEncoding","contentMediaType","else","examples","if","patternProperties","propertyNames","then"],nG=/^[A-Za-z_][-A-Za-z0-9._]*$/,rG=/^[A-Za-z][-A-Za-z0-9._:]*$/;function Bu(e,t,n){throw new Error(`Cannot convert JSON Schema keyword "${e}" to ${t}: ${n}`)}function oG(e,t,n,r){for(let o of t)Object.hasOwn(e,o)&&Bu(o,n,`it is not active in ${r} but would become active in the target`)}var sG=["additionalItems","definitions","dependencies"];function iG(e,t,n,r,o){n.isDocumentRoot?W(e,"$schema",e2(t,XN)?r:t):e2(t,XN)||Bu("$schema",o,"an embedded resource cannot declare a different dialect")}function aG(e,t){oG(e,sG,"Draft-07","Draft 2020-12");let n={},r,o,s;for(let i of Object.keys(e)){let a=e[i];if(!tG(n,i,a,t,eG))switch(i){case"$ref":r=a;break;case"$schema":iG(n,a,t,HJ,"Draft-07");break;case"$id":case"$anchor":break;case"$defs":W(n,"definitions",t.schemaMap(a,i,"definitions"));break;case"prefixItems":o=a;break;case"items":s=a;break;case"dependentRequired":case"dependentSchemas":case"minContains":case"maxContains":break;case"$dynamicRef":case"$dynamicAnchor":case"$vocabulary":case"unevaluatedProperties":case"unevaluatedItems":Bu(i,"Draft-07","the target dialect has no equivalent");case"required":if(Array.isArray(a)&&a.length===0)break;W(n,i,a);break;default:W(n,i,a)}}if(cG(n,o,s,t),Object.hasOwn(e,"contains")){let i=e.minContains,a=e.maxContains;(i!==void 0&&i!==1||a!==void 0)&&Bu("minContains/maxContains","Draft-07","contains cardinality cannot be represented"),Object.hasOwn(e,"minContains")&&W(n,"minContains",i)}else Object.hasOwn(e,"minContains")&&W(n,"minContains",e.minContains),Object.hasOwn(e,"maxContains")&&W(n,"maxContains",e.maxContains);return fG(e,n,t,"draft-07"),dG(e,n,"$id","Draft-07"),uG(n,r,t),n}function cG(e,t,n,r){if(t===void 0){n!==void 0&&W(e,"items",r.schema(n,"items"));return}W(e,"items",r.schemaArray(t,"prefixItems","items")),n!==void 0&&W(e,"additionalItems",r.schema(n,"items","additionalItems"))}function uG(e,t,n){if(t!==void 0)if(typeof t=="string"&&Object.keys(e).length>0){let r={};n.reference(r,t),lG(e,r)}else n.reference(e,t)}function fG(e,t,n,r){let o=en(e.dependentRequired)?e.dependentRequired:void 0,s=en(e.dependentSchemas)?e.dependentSchemas:void 0;if(o===void 0&&s===void 0)return;let i={},a=new Set([...Object.keys(o??{}),...Object.keys(s??{})]);for(let c of a){let u=o?.[c],f=s?.[c],l=r==="draft-04"&&Array.isArray(u)&&u.length===0;f===void 0?l||W(i,c,u):u===void 0||l?W(i,c,n.schemaAt(f,["dependentSchemas",c],["dependencies",c])):W(i,c,{allOf:[n.schemaAt(f,["dependentSchemas",c],["dependencies",c,"allOf","0"]),{required:u}]})}Object.keys(i).length>0&&W(t,"dependencies",i)}function lG(e,t){Array.isArray(e.allOf)?e.allOf.push(t):W(e,"allOf",[t])}function dG(e,t,n,r){let o=e.$id,s=e.$anchor;if(s===void 0){o!==void 0&&W(t,n,o);return}(typeof s!="string"||!nG.test(s))&&Bu("$anchor",r,"the anchor is not valid"),rG.test(s)||Bu("$anchor",r,"the anchor cannot be represented as a plain-name fragment identifier"),o===void 0?W(t,n,`#${s}`):Bu("$anchor",r,"it cannot be combined with the schema $id")}var Que=globalThis.RegExp;var _l=e=>e.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");var pG=new Set([...wF,Su,...EF]);function sm(e,t){if(e===void 0)return;let n={},r=e.title;typeof r=="string"&&(n.title=r);let o=e.description,s=e.expected;typeof o=="string"?n.description=o:t?.generateDescriptions===!0&&typeof s=="string"&&(n.description=s);let i=e.default;gl(i)&&(n.default=i);let a=e.examples;Array.isArray(a)&&gl(a)&&(n.examples=a);let c=e.readOnly;typeof c=="boolean"&&(n.readOnly=c);let u=e.writeOnly;typeof u=="boolean"&&(n.writeOnly=u);let f=e.format;typeof f=="string"&&(n.format=f);let l=e.contentEncoding;typeof l=="string"&&(n.contentEncoding=l);let p=e.contentMediaType;typeof p=="string"&&(n.contentMediaType=p);let m=e.contentSchema;if(gl(m)&&(n.contentSchema=m),t?.includeAnnotationKey!==void 0)for(let[h,g]of Object.entries(e))pG.has(h)||!t.includeAnnotationKey(h)||gl(g)&&W(n,h,g);return Object.keys(n).length===0?void 0:n}function f2(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 r=[],o=!1;for(let s of n.allOf){let i=f2(s);i.type!==void 0&&(o=!0,(t===void 0||i.type==="integer")&&(t=i.type)),Object.keys(i.schema).length>0&&r.push(i.schema)}if(o){let{allOf:s,...i}=n;n=r.length===0?i:{...i,allOf:r}}}return{type:t,schema:n}}function mG(e){return Array.isArray(e.anyOf)&&e.anyOf.length===4&&e.anyOf[0]?.type==="number"&&e.anyOf.slice(1).every(t=>t.type==="string")}var l2="|type|format|pattern|multipleOf|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minProperties|maxProperties|propertyNames|";function lT(e,t){return Object.keys(e).every(n=>t.includes(`|${n}|`))}function u2(e,t){return typeof e.$ref!="string"&&t.every(n=>!Object.hasOwn(e,n))}var dT="|title|description|default|examples|readOnly|writeOnly|",hG=l2+dT;function im(e,t,n){if(Object.keys(e).length===0)return t;let r=Object.keys(t);if(r.length===0)return e;let o=e.type==="number"||e.type==="integer"?e.type:void 0,s=mG(e);if(o!==void 0||s){let a=f2(t);if(a.type!==void 0){let c=o==="integer"||a.type==="integer"?"integer":"number",u={...e,type:c};s&&delete u.anyOf;let f=Object.keys(a.schema);return f.length===0?u:lT(a.schema,dT)&&u2(u,f)?{...u,...a.schema}:im(u,a.schema,n)}}if(n&&u2(e,r))return{...e,...t};let i=Array.isArray(t.allOf)&&r.length===1?t.allOf:[t];return Array.isArray(e.allOf)?{...e,allOf:[...e.allOf,...i]}:typeof e.$ref=="string"?{allOf:[e,...i]}:{...e,allOf:i}}function gG(e,t,n,r){let o=new Map,s=new WeakMap,i=new Map,a=!1,c=Object.keys(n);for(let y of c)l(y,["references",y]);let u=os(e,(y,w)=>p(x(y,t[w]))),f={};for(let y of c){let w=o.get(y);typeof w!="string"&&W(f,y,p(w))}return{dialect:"draft-2020-12",schemas:u,definitions:f};function l(y,w){let S=o.get(y);if(S!==void 0)return typeof S=="string"?S:y;if(!Object.hasOwn(n,y))throw Ei(`Invalid reference ${y}`,[...w,"$ref"]);o.set(y,null);let C=n[y],_=x(C,["references",y]),R=m(C);if(R!==void 0){let M=i.get(R),q=M?.find(P=>ae(o.get(P),_));if(q===void 0)M===void 0?i.set(R,[y]):M.push(y);else return a=!0,o.set(y,q),q}return o.set(y,_),y}function p(y){return a?o2(y,w=>w.replace(/^#\/\$defs\/([^/]*)/,(S,C)=>{let _=o.get(Rl(C));return typeof _=="string"?`#/$defs/${Lu(_)}`:S})):y}function m(y){if(y._tag==="Reference")return;let w=y.checks.length===0?y.annotations:y.checks[y.checks.length-1].annotations;return typeof w?.identifier!="string"&&typeof w?.[Su]=="string"?w[Su]:void 0}function h(y,w){return y?.schemas?.map((S,C)=>x(S,[...w,"schemas",C]))??[]}function g(y,w,S){let C=y.annotations,_=C?.toJsonSchema;if(_!==void 0){let P=h(y.representation,[...S,"representation"]),te=_({type:w,schemas:P}),ee=sm(C,r),T=ee===void 0?te:{...te,...ee},z=ee===void 0?l2:hG;return y._tag==="Filter"&&lT(T,z)&&(ee===void 0||lT(ee,dT))?[T,!0]:[T]}if(y._tag==="Filter")return;let R=y.checks.map((P,te)=>g(P,w,[...S,"checks",te])).filter(P=>P!==void 0);if(R.length===0)return;let M=sm(C,r),q=R.map(([P])=>P);return[M===void 0?{allOf:q}:{allOf:q,...M}]}function x(y,w){if(y._tag==="Reference"){let R=l(y.$ref,w);return{$ref:`#/$defs/${Lu(R)}`}}let S=s.get(y);if(S!==void 0)return S;let C=b(y,w),_=sm(y.annotations,r);_!==void 0&&(C={...C,..._});for(let R=0;R<y.checks.length;R++){let M=typeof C.type=="string"&&xG(C.type)?C.type:void 0,q=g(y.checks[R],M,[...w,"checks",R]);q!==void 0&&(C=im(C,...q))}return s.set(y,C),C}function b(y,w){switch(y._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":case"UniqueSymbol":return{type:"string",allOf:[{pattern:"^Symbol\\((.*)\\)$"}]};case"Declaration":return{};case"Suspend":return x(y.thunk,[...w,"thunk"]);case"Never":return{not:{}};case"String":return{type:"string"};case"Number":return{anyOf:[{type:"number"},{type:"string",enum:["NaN"]},{type:"string",enum:["Infinity"]},{type:"string",enum:["-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let S=y.literal;return typeof S=="bigint"?{type:"string",enum:[globalThis.String(S)]}:{type:typeof S,enum:[S]}}case"Enum":{let S=y.enums.map(([C,_])=>typeof _=="number"&&!globalThis.Number.isFinite(_)?{type:"string",enum:[globalThis.String(_)],title:C}:{type:typeof _,enum:[_],title:C});return S.length===0?{not:{}}:{anyOf:S}}case"TemplateLiteral":return{type:"string",pattern:`^${y.parts.map(Ky).join("")}$`};case"Arrays":{if(y.rest.length>1)throw Ei("Invalid schema representation document",[...w,"rest"]);let S={type:"array"},C=y.elements.length,_=y.elements.map((R,M)=>{R.isOptional&&C--;let q=x(R.type,[...w,"elements",M,"type"]),P=sm(R.annotations,r);return P===void 0?q:im(q,P)});if(_.length>0?(S.prefixItems=_,S.maxItems=y.elements.length,C>0&&(S.minItems=C)):S.items=!1,y.rest.length===1){delete S.maxItems;let R=x(y.rest[0],[...w,"rest",0]);Object.keys(R).length>0?S.items=R:delete S.items}return S}case"Objects":{if(y.propertySignatures.length===0&&y.indexSignatures.length===0)return{anyOf:[{type:"object"},{type:"array"}]};let S={type:"object"},C={},_=[];for(let P=0;P<y.propertySignatures.length;P++){let te=y.propertySignatures[P];if(typeof te.name!="string")throw Ei("Invalid schema representation document",[...w,"propertySignatures",P,"name"]);let ee=te.name,T=x(te.type,[...w,"propertySignatures",P,"type"]),z=sm(te.annotations,r);W(C,ee,z===void 0?T:im(T,z)),te.isOptional||_.push(ee)}y.propertySignatures.length>0&&(S.properties=C),_.length>0&&(S.required=_);let R={},M=[];for(let P=0;P<y.indexSignatures.length;P++){let te=y.indexSignatures[P],ee=x(te.type,[...w,"indexSignatures",P,"type"]);Object.keys(ee).length===1&&"not"in ee&&(ee=!1);let T=E(te.parameter,[...w,"indexSignatures",P,"parameter"],new Set);if(T.length===0)M.push(ee);else for(let z of T){let F=R[z];W(R,z,F===void 0?ee:F===!1||ee===!1?!1:im(F,ee))}}let q=Object.keys(R).length>0;return q&&(S.patternProperties=R),y.indexSignatures.length===0?S.additionalProperties=r?.additionalProperties??!1:M.length===1&&y.propertySignatures.length===0&&!q?S.additionalProperties=M[0]:M.length>0&&(S.allOf=M.map(P=>({type:"object",additionalProperties:P}))),typeof S.additionalProperties=="object"&&S.additionalProperties!==null&&Object.keys(S.additionalProperties).length===0&&delete S.additionalProperties,S}case"Union":{let S=y.types.map((C,_)=>x(C,[...w,"types",_]));if(S.length===0)return{not:{}};if(y.mode==="anyOf"&&S.length>1){let C=yG(S);if(C!==void 0)return C}return y.mode==="anyOf"?{anyOf:S}:{oneOf:S}}}}function E(y,w,S){switch(y._tag){case"Reference":{if(!Object.hasOwn(n,y.$ref))throw Ei(`Invalid reference ${y.$ref}`,[...w,"$ref"]);if(l(y.$ref,w),S.has(y.$ref))return[];let C=new Set(S).add(y.$ref);return E(n[y.$ref],["references",y.$ref],C)}case"String":return d2(x(y,w));case"TemplateLiteral":return[`^${y.parts.map(Ky).join("")}$`];case"Union":return y.types.flatMap((C,_)=>E(C,[...w,"types",_],S));default:throw Ei("Invalid schema representation document",w)}}}function xG(e){return e==="string"||e==="number"||e==="boolean"||e==="array"||e==="object"||e==="null"||e==="integer"}function yG(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;n.push(...r.enum)}return{type:t,enum:n}}function d2(e){let t=[];typeof e.pattern=="string"&&t.push(e.pattern);for(let n of["allOf","anyOf","oneOf"]){let r=e[n];if(Array.isArray(r))for(let o of r)typeof o=="object"&&o!==null&&!Array.isArray(o)&&t.push(...d2(o))}return t}function Ky(e){switch(e._tag){case"Literal":return _l(globalThis.String(e.literal));case"String":return l1;case"Number":return Bx;case"TemplateLiteral":return e.parts.map(Ky).join("");case"Union":return e.types.map(Ky).join("|");default:throw Ei("Invalid schema representation document",[])}}function p2(e,t){let n=gG([e.representation],[["representation"]],e.references,t);return{dialect:n.dialect,schema:n.schemas[0],definitions:n.definitions}}var EG=({identifier:e})=>e;function Ds(e){return e===void 0?void 0:{annotations:e}}function pT(e,t){let{references:n,representations:r}=bG([e],t);return{representation:r[0],references:n}}function bG(e,t){let n={},r=new Map,o=new Set,s=new Map,i=new Set;for(let S of e)m(S);let a=t?.referencePolicy??EG;for(let S of s.values())for(let C of S.values()){let _=a({ast:C.ast,occurrences:C.occurrences,identifier:C.identifier});if(_!==void 0){let R=_===C.identifier||!_.endsWith("_")?"_":"";C.reference=u(_,C,R)}else C.isRecursive&&(C.reference=u(`${C.ast._tag}_`,C,""))}return{representations:os(e,S=>g(S)),references:n};function u(S,C,_="_"){let R=S,M=0;for(;r.has(R);){if(r.get(R)===C)return R;R=`${S}${_}${++M}`}return r.set(R,C),R}function f(S,C,_){let R=C.fallback;return R!==void 0?jw(S)===R?S:qo(S,{[Su]:R}):_===C.identifier?S:qo(S,{identifier:_})}function l(S,C){if(!Object.hasOwn(n,S)&&!o.has(S)){o.add(S);let _=x(C);o.delete(S),W(n,S,_)}return{_tag:"Reference",$ref:S}}function p(S){let C=_p(S),_=LI(C),R=rl(C),M=R===void 0?(C!==S?rl(S):void 0)??jw(C):void 0;M!==void 0&&(R=`${M}Encoded`);let q=s.get(_);q===void 0&&(q=new Map,s.set(_,q));let P=q.get(R);return P===void 0&&(P={ast:_,identifier:R,fallback:M,occurrences:0,isRecursive:!1,reference:void 0},q.set(R,P)),P}function m(S){let C=p(S),_=C.ast;if(C.occurrences++,i.has(C)){C.isRecursive=!0;return}if(!(C.occurrences>1)){switch(i.add(C),h(_.checks),_._tag){case"Declaration":case"Arrays":case"Objects":case"Union":_.recur(R=>(m(R),R));break;case"TemplateLiteral":_.parts.forEach(m);break;case"Suspend":m(_.thunk());break}i.delete(C)}}function h(S){S?.forEach(C=>{C.annotations?.representation?.schemas?.forEach(_=>m(yn(_))),C._tag==="FilterGroup"&&h(C.checks)})}function g(S){let C=p(S),_=C.ast,R=C.reference;if(R!==void 0){let M=C.identifier===void 0?_:f(_,C,R);return l(R,M)}return x(_)}function x(S){let C=b(S.checks);switch(S._tag){case"Declaration":return{_tag:"Declaration",typeParameters:S.typeParameters.map(_=>g(_)),checks:C,...y(S.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:S._tag,checks:C,...Ds(S.annotations)};case"Literal":return{_tag:"Literal",literal:S.literal,checks:C,...Ds(S.annotations)};case"UniqueSymbol":return{_tag:"UniqueSymbol",symbol:S.symbol,checks:C,...Ds(S.annotations)};case"Enum":return{_tag:"Enum",enums:S.enums,checks:C,...Ds(S.annotations)};case"TemplateLiteral":return{_tag:"TemplateLiteral",parts:S.parts.map(_=>g(_)),checks:C,...Ds(S.annotations)};case"Arrays":return{_tag:"Arrays",elements:S.elements.map(_=>{let R=_p(_),M=R.context?.annotations;return{isOptional:an(R),type:g(_),...Ds(M)}}),rest:S.rest.map(_=>g(_)),checks:C,...Ds(S.annotations)};case"Objects":return{_tag:"Objects",propertySignatures:S.propertySignatures.map(_=>{let R=_p(_.type),M=R.context?.annotations;return{name:_.name,type:g(_.type),isOptional:an(R),isMutable:a1(R),...Ds(M)}}),indexSignatures:S.indexSignatures.map(_=>({parameter:g(_.parameter),type:g(_.type)})),checks:C,...Ds(S.annotations)};case"Union":return{_tag:"Union",types:S.types.map(_=>g(_)),mode:S.mode,checks:C,...Ds(S.annotations)};case"Suspend":return{_tag:"Suspend",checks:[],thunk:g(S.thunk()),...Ds(S.annotations)}}}function b(S){return S?.map(E)??[]}function E(S){switch(S._tag){case"Filter":return{_tag:"Filter",aborted:S.aborted,...w(S.annotations)};case"FilterGroup":return{_tag:"FilterGroup",checks:os(S.checks,E),...w(S.annotations)}}}function y(S){if(S===void 0)return;let{representation:C,..._}=S;return{...C===void 0?void 0:{representation:C},...Object.keys(_).length===0?void 0:{annotations:_}}}function w(S){if(S===void 0)return;let{representation:C,..._}=S,R=C===void 0?void 0:C.schemas===void 0?C:{...C,schemas:C.schemas.map(M=>g(yn(M)))};return{...R===void 0?void 0:{representation:R},...Object.keys(_).length===0?void 0:{annotations:_}}}}function h2(e,t){let n=[];return mT(e,t,"",n),n}function mT(e,t,n,r){if(!Object.is(e,t)){if(Array.isArray(e)&&Array.isArray(t)){let o=e.length,s=t.length,i=Math.min(o,s);for(let a=0;a<i;a++)mT(e[a],t[a],`${n}/${a}`,r);for(let a=o-1;a>=s;a--)r.push({op:"remove",path:`${n}/${a}`});for(let a=o;a<s;a++)r.push({op:"add",path:`${n}/${a}`,value:t[a]});return}if(Vy(e)&&Vy(t)){let o=Object.keys(e),s=Object.keys(t),i=Array.from(new Set([...o,...s])).sort();for(let a of i){let c=`${n}/${Lu(a)}`,u=Object.hasOwn(e,a),f=Object.hasOwn(t,a);u&&f?mT(e[a],t[a],c,r):!u&&f?r.push({op:"add",path:c,value:t[a]}):r.push({op:"remove",path:c})}return}r.push({op:"replace",path:n,value:t})}}function g2(e,t){let n=t;for(let r of e)n=vG(n,r);return n}function Vy(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function IG(e){if(e==="")return[];if(e.charCodeAt(0)!==47)throw new Error(`Invalid JSON Pointer, it must start with "/": ${JSON.stringify(e)}`);return e.split("/").slice(1).map(Rl)}function x2(e){if(!/^(0|[1-9]\d*)$/.test(e))throw new Error(`Invalid array index: "${e}"`);return Number(e)}function vG(e,t){if(t.path===""){if(t.op==="remove")throw new Error("Unsupported operation at the root");return t.value}let n=TG(e,t.path);if(n===null)throw new Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`);let{lastToken:r,parent:o,stack:s}=n;if(Array.isArray(o)){if(r==="-"&&t.op!=="add")throw new Error(`"-" is not valid for ${t.op} at "${t.path}".`);let i=r==="-"?o.length:x2(r),a=t.op==="add"?o.length:o.length-1;if(i>a)throw new Error(`Array index out of bounds at "${t.path}".`);let c=o.slice();return t.op==="add"?c.splice(i,0,t.value):t.op==="remove"?c.splice(i,1):c[i]=t.value,m2(s,c)}if(Vy(o)){if(t.op!=="add"&&!Object.hasOwn(o,r))throw new Error(`Property "${r}" does not exist at "${t.path}".`);let i={...o};return t.op==="remove"?delete i[r]:W(i,r,t.value),m2(s,i)}throw new Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`)}function TG(e,t){let n=IG(t);if(n.length===0)return null;let r=n[n.length-1],o=[],s=e;for(let i=0;i<n.length-1;i++){let a=n[i];if(Array.isArray(s)){let c=x2(a);if(c>=s.length)return null;o.push({container:s,token:c}),s=s[c];continue}if(Vy(s)){if(!Object.hasOwn(s,a))return null;o.push({container:s,token:a}),s=s[a];continue}return null}return{stack:o,parent:s,lastToken:r}}function m2(e,t){let n=t;for(let r=e.length-1;r>=0;r--){let{container:o,token:s}=e[r];if(Array.isArray(o)){let i=o.slice();i[s]=n,n=i}else{let i={...o};W(i,s,n),n=i}}return n}function b2(e,t){return Ns(Ml("Iso",e,t))}function S2(e,t){return Ns(Ml("Lens",e,t))}function Ml(e,t,n){return[{_tag:"PrimitiveNode",kind:e,get:t,set:n}]}var kG={kind:"Iso",get:L,set:L},Jy=class{_tag="PathNode";kind="Lens";path;get;set;constructor(t){this.path=t,this.get=n=>{let r=n;for(let o=0;o<t.length;o++)r=r[t[o]];return r},this.set=(n,r)=>{let o=Gy(r),s=o,i=0;for(;i<t.length-1;i++){let a=t[i];W(s,a,Gy(s[a])),s=s[a]}return W(s,t[i],n),o}}},am=class{_tag="CheckNode";kind="Prism";checks;get;set=L;constructor(t){this.checks=t,this.get=n=>m1(t,n)}};function ju(e,t){if(e.length===0)return t;if(t.length===0)return e;let n=e.slice();for(let r=0;r<t.length;r++){let o=t[r],s=n[n.length-1];s._tag==="PathNode"&&o._tag==="PathNode"?n[n.length-1]=new Jy([...s.path,...o.path]):s._tag==="CheckNode"&&o._tag==="CheckNode"?n[n.length-1]=new am([...s.checks,...o.checks]):n.push(o)}return n}function CG(e,t){return Ns(Ml("Optional",e,t))}var Pl=class{node;getResult;replaceResult;constructor(t,n,r){this.node=t,this.getResult=n,this.replaceResult=r}replace(t,n){return Cd(this.replaceResult(t,n),()=>n)}modify(t){return n=>Cd(Dh(this.getResult(n),r=>this.replaceResult(t(r),n)),()=>n)}compose(t){return Ns(ju(this.node,t.node))}key(t){return Ns(ju(this.node,[new Jy([t])]))}optionalKey(t){return Ns(ju(this.node,Ml("Lens",n=>n[t],(n,r)=>{let o=Gy(r);return n===void 0?Array.isArray(o)&&typeof t=="number"?o.splice(t,1):delete o[t]:W(o,t,n),o})))}check(...t){return Ns(ju(this.node,[new am(t)]))}refine(t,n){return Ns(ju(this.node,[new am([Hx(t,n)])]))}tag(t){let n=Ae(new ke({expected:`${JSON.stringify(t)} tag`}));return Ns(ju(this.node,Ml("Prism",r=>r._tag===t?Ce(r):n,L)))}at(t,...n){let r=Ae(new Ct([t],new sn(void 0)));return Ns(ju(this.node,Ml("Optional",o=>Object.hasOwn(o,t)?Ce(o[t]):r,(o,s)=>{if(Object.hasOwn(s,t)){let i=Gy(s);return W(i,t,o),Ce(i)}else return r})))}pick(t){return this.compose(S2(RN(t),(n,r)=>({...r,...n})))}omit(t){return this.compose(S2(_N(t),(n,r)=>({...r,...n})))}notUndefined(){return this.refine(Kn,{expected:"a value other than `undefined`"})}forEach(t){let n=t(Zy());return CG(r=>Jc(this.getResult(r),o=>{let s=[];for(let i=0;i<o.length;i++){let a=n.getResult(o[i]);Kt(a)&&s.push(a.success)}return s}),(r,o)=>Dh(this.getResult(o),s=>{let i=[];for(let c=0;c<s.length;c++)Kt(n.getResult(s[c]))&&i.push(c);if(r.length!==i.length)return Ae(new ke({message:`each: replacement length mismatch: ${r.length} !== ${i.length}`}));let a=s.slice();for(let c=0;c<i.length;c++){let u=i[c],f=n.replaceResult(r[c],s[u]);if(Fe(f))return Ae(new Ct([u],f.failure));a[u]=f.success}return this.replaceResult(a,o)}))}modifyAll(t){return n=>Cd(Dh(this.getResult(n),r=>this.replaceResult(r.map(t),n)),()=>n)}},hT=class extends Pl{get;set;constructor(t,n,r){super(t,o=>Ce(n(o)),o=>Ce(r(o))),this.get=n,this.set=r}replace(t,n){return this.set(t)}modify(t){return n=>this.set(t(this.get(n)))}},gT=class extends Pl{get;constructor(t,n,r){super(t,o=>Ce(n(o)),(o,s)=>Ce(r(o,s))),this.get=n,this.replace=r}modify(t){return n=>this.replace(t(this.get(n)),n)}},xT=class extends Pl{set;constructor(t,n,r){super(t,n,(o,s)=>Ce(r(o))),this.set=r}replace(t,n){return this.set(t)}modify(t){return n=>Cd(Jc(this.getResult(n),r=>this.set(t(r))),()=>n)}};function Ns(e){let t=e[0]??kG;if(e.length>1){let n=e.reduce((r,o)=>RG(r,o.kind),"Iso");t={kind:n,get:AG(e,n),set:OG(e,n)}}switch(t.kind){case"Iso":return new hT(e,t.get,t.set);case"Lens":return new gT(e,t.get,t.set);case"Prism":return new xT(e,t.get,t.set);case"Optional":return new Pl(e,t.get,t.set)}}function Gy(e){if(Array.isArray(e))return e.slice();if(typeof e=="object"&&e!==null){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new Error("Cannot clone object with non-Object constructor or null prototype");return{...e}}return e}function AG(e,t){return n=>{for(let r=0;r<e.length;r++){let o=e[r],s=o.get(n);if(yT(o.kind)){if(Fe(s))return s;n=s.success}else n=s}return yT(t)?Ce(n):n}}function OG(e,t){return E2(t)?n=>{for(let r=e.length-1;r>=0;r--)n=e[r].set(n);return n}:(n,r)=>{let o=e.length,s=new Array(o);for(let i=0;i<o;i++){s[i]=r;let a=e[i];if(yT(a.kind)){let c=a.get(r);if(Fe(c))return c;r=c.success}else r=a.get(r)}for(let i=o-1;i>=0;i--){let a=e[i];if(E2(a.kind))n=a.set(n);else if(a.kind==="Lens")n=a.set(n,s[i]);else{let c=a.set(n,s[i]);if(Fe(c))return c;n=c.success}}return t==="Optional"?Ce(n):n}}function yT(e){return e==="Prism"||e==="Optional"}function E2(e){return e==="Iso"||e==="Prism"}function RG(e,t){return e==="Iso"?t:t==="Iso"||e===t?e:"Optional"}var _G=Ns([]);function Zy(){return _G}var $u=new WeakMap,I2=e=>{if($u.has(e))return $u.get(e);throw new Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var v2="~effect/data/Redacted",cm=e=>B(e,v2),pc=(e,t)=>{let n=Object.create(PG);return t?.label&&(n.label=t.label),$u.set(n,e),n},PG={[v2]:{_A:e=>e},label:void 0,...vn,toJSON(){return this.toString()},toString(){return`<redacted${oo(this.label)?":"+this.label:""}>`},[Re](){return ce($u.get(this))},[_e](e){return cm(e)&&ae($u.get(this),$u.get(e))}},dc=I2;var T2=e=>un((t,n)=>e(dc(t),dc(n)));var um=qy;function An(){return(e,t,n)=>re(new aa(e.map(kp),r=>t(r.map(o=>re(o))),n))}function eo(e,t){return An()([],()=>(n,r,o)=>e(n)?v(n):G(new st(r,n,o)),t)}function FG(e){return e}function UG(e){return t=>t.annotate(e)}function DG(e){return t=>ST(ST(t).annotate(e))}function NG(e){return t=>t.rebuild(ml(t.ast,e))}function LG(e){return e}var fm="~effect/SchemaError/SchemaError",Mr=class extends Mn("SchemaError"){[fm]=fm;constructor(t){let n=Xs();ir(0);try{super({issue:t})}finally{ir(n)}}get message(){return AF(this.issue)}toString(){return`SchemaError(${this.message})`}};function Bl(e){return B(e,fm)&&e[fm]===fm}function k2(e){return Ft(e)?e.value:{issues:[{message:eP(e.cause)}]}}function BG(e,t){let n=dt(e),r={errors:"all",...t?.parseOptions},o=CF(t),s=i=>{let a=new Qs("sync"),c=up(Cw(n(i,r),{onFailure:o,onSuccess:f=>({value:f})}),{scheduler:a});c.currentDispatcher?.flush();let u=c.pollUnsafe();return u?k2(u):new Promise(f=>{c.addObserver(l=>{f(k2(l))})})};if("~standard"in e){let i=e;return"validate"in i["~standard"]||Object.assign(i["~standard"],{validate:s}),i}else return Object.assign(e,{"~standard":{version:1,vendor:"effect",validate:s}})}function C2(e,t){let n=_B(e);if(t==="draft-2020-12"){let r=n.schema;return Object.keys(n.definitions).length>0&&(r.$defs=n.definitions),r}else if(t==="draft-07"){let r=r2(n),o=r.schema;return Object.keys(r.definitions).length>0&&(o.definitions=r.definitions),o}throw new globalThis.Error(`Unsupported target: ${t}`)}function jG(e){let t={input(n){return C2(e,n.target)},output(n){return C2(Pr(e),n.target)}};if("~standard"in e){let n=e;return"jsonSchema"in n["~standard"]||Object.assign(n["~standard"],{jsonSchema:t}),n}else return Object.assign(e,{"~standard":{version:1,vendor:"effect",jsonSchema:t}})}var j2=mN,$G=gN;function hc(e,t){let n=dt(e,t);return(r,o)=>$2(n(r,o))}function $2(e){return xt(e)?IT(e):ft(e,t=>ea(()=>Ja(t,n=>new Mr(n))))}var qG=hc;function q2(e,t){let n;for(let r of e.reasons){if(!Ug(r)||!Bl(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 z2(e){return ux(e).then(t=>{if(Ft(t))return t.value;throw q2(t.cause,"Promise adapter can only reject schema errors")})}function H2(e){let t=ec(e);if(Ft(t))return t.value;throw q2(t.cause,"Sync adapter can only throw schema errors")}function W2(e,t){let n=xN(e,t);return(r,o)=>IT(n(r,o))}function IT(e){return Ft(e)?e:jt(Ja(e.cause,t=>new Mr(t)))}var K2=W2,zG=eT,HG=yN;function V2(e,t){let n=SN(e,t);return(r,o)=>eb(n(r,o),s=>new Mr(s))}var WG=V2;function J2(e,t){let n=hc(e,t);return(r,o)=>z2(n(r,o))}var KG=J2;function eS(e,t){let n=hc(e,t);return(r,o)=>H2(n(r,o))}var dm=eS;function pm(e,t){let n=Cl(e,t);return(r,o)=>$2(n(r,o))}var tS=pm;function G2(e,t){let n=EN(e,t);return(r,o)=>IT(n(r,o))}var Z2=G2,VG=nT,JG=bN;function Q2(e,t){let n=wN(e,t);return(r,o)=>eb(n(r,o),s=>new Mr(s))}var GG=Q2;function Y2(e,t){let n=pm(e,t);return(r,o)=>z2(n(r,o))}var ZG=Y2;function nS(e,t){let n=pm(e,t);return(r,o)=>H2(n(r,o))}var vT=nS,re=nm;function zu(e){return B(e,um)&&e[um]===um}var qu=dr(e=>re(hl(e.ast),{schema:e})),QG=dr(e=>e.schema),Pt=dr(e=>{let t=oS(e);return re(o1(e.ast),{schema:t})}),YG=dr(e=>e.schema.members[0]),XG=dr(e=>re(jI(e.ast),{schema:e})),e5=dr(e=>e.schema),Pr=dr(e=>re(yn(e.ast),{schema:e})),jl=dr(e=>re(jn(e.ast),{schema:e})),lm="~effect/Schema/flip";function t5(e){return B(e,lm)&&e[lm]===lm}function ST(e){return t5(e)?e.schema.rebuild(vs(e.ast)):re(vs(e.ast),{[lm]:lm,schema:e})}function Ot(e){let t=re(new Gr(e),{literal:e,transform(n){return t.pipe(Ee(Ot(n),{decode:De(()=>n),encode:De(()=>e)}))}});return t}function X2(e){return new Fx(e.map(t=>zu(t)?t.ast:new Gr(t)))}function n5(e){return re(X2(e),{parts:e})}function r5(e){return re(X2(e).asTemplateLiteralParser(),{parts:e})}function o5(e){return re(new Px(Object.keys(e).filter(t=>typeof e[e[t]]!="number").map(t=>[t,e[t]])),{enums:e})}var gc=re(qU),s5=re(zU),TT=re(ca),tt=re(RI),kT=re(_I),fe=re(mi),$l=re(MI),xc=re(KU),eL=re(VU),bi=re(JU),ql=re($U),i5=re(HU);function a5(e){return re(new Ux(e))}function CT(e,t){return re(e,{fields:t,mapFields(n,r){let o=n(this.fields);return CT(jx(o,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function oe(e){return CT(jx(e,void 0),e)}function c5(e){return dr(t=>t.mapFields(MN(e)))}var u5=e=>typeof e=="symbol"?e:globalThis.String(e);function f5(e){return function(t){let n={},r=Object.create(null),o=Object.create(null),s=new Set;for(let i of Reflect.ownKeys(t.fields)){let a=jl(t.fields[i]),c=Object.hasOwn(e,i),u=c?e[i]:i,f=u5(u);if(s.has(f))throw new globalThis.Error(`Duplicate encoded keys: ${Ui(u)}`);s.add(f),W(n,u,a),c&&(r[i]=u,o[u]=i)}return oe(n).pipe(Ee(t,vt({decode:sT(o),encode:sT(r)})))}}function l5(e,t){return n=>{let r=Lh(n.fields,Pr),o=oe({...r,...e});return n.pipe(Ee(o,vt({decode:s=>{let i={...s};for(let a in e){let c=t[a],u=c(s);Te(u)&&W(i,a,u.value)}return i},encode:s=>{let i={...s};for(let a in e)delete i[a];return i}})))}}function AT(e,t){return re(i1(e.ast,t.ast),{key:e,value:t})}function d5(e,t){return re(GU(e.ast,t.map(kp)),{schema:e,records:t})}function tL(e,t){return re(e,{elements:t,mapElements(n,r){let o=n(this.elements);return tL(UI(o,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function mc(e){return tL(UI(e),e)}function p5(e,t){return re(ZU(e.ast,t.map(kp)),{schema:e,rest:t})}var Wt=dr(e=>re(new Ts(!1,[],[e.ast]),{value:e}));var rS=dr(e=>re(new Ts(!1,[e.ast],[e.ast]),{value:e}));function m5(e){return He([e,Wt(e)]).pipe(Ee(Wt(Pr(e)),vt({decode:uO,encode:t=>t.length===1?t[0]:t})))}function h5(e){return Wt(e).check(NT())}var g5=dr(e=>re(new Ts(!0,e.ast.elements,e.ast.rest),{schema:e}));function nL(e,t){return re(e,{members:t,mapMembers(n,r){let o=n(this.members);return nL($x(o,this.ast.mode,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function He(e,t){return nL($x(e,t?.mode??"anyOf",void 0),e)}function Ea(e){let t=e.map(Ot);return re($x(t,"anyOf",void 0),{literals:e,members:t,mapMembers(n){return He(n(this.members))},pick(n){return Ea(n)},transform(n){return He(t.map((r,o)=>r.transform(n[o])))}})}var OT=dr(e=>He([e,tt])),oS=dr(e=>He([e,kT])),rL=dr(e=>He([e,tt,kT]));function oL(e){return re(new Nx(()=>e().ast))}function x5(...e){return t=>t.check(...e)}function y5(e,t){return n=>re(hi(n.ast,[Hx(e,t)]),{schema:n})}function sL(e){return t=>re(r1(t.ast,e),{schema:t,identifier:e})}function S5(e,t){return n=>(t.checks?n.check(...t.checks):n).pipe(sL(e))}function iL(e){return t=>re(t1(t.ast,new bp(e,L)),{schema:t})}function aL(e){return t=>re(n1(t.ast,new bp(L,e)),{schema:t})}function E5(e){return cL(e)}function cL(e){return t=>iL(lx(e))(t)}function b5(e){return uL(e)}function uL(e){return t=>aL(lx(e))(t)}function Ee(e,t){return n=>re(Vx(n.ast,e.ast,t?Rx(t):al()),{from:n,to:e})}function w5(e){return t=>Ee(Pr(t),e)(t)}function RT(e,t){return n=>t?Ee(n,t)(e):Ee(n)(e)}function I5(e){return t=>Ee(t,e)(jl(t))}function fL(e){return t=>re(s1(t.ast,e),{schema:t})}function lL(e){return ft(e,t=>ea(()=>Ja(t,n=>n.issue)))}function _T(e,t){let n=t?.encodingStrategy==="omit"?Yw():Is();return r=>qu(jl(r)).pipe(Ee(r,{decode:Sp(lL(e)),encode:n}))}function v5(e,t){return n=>Pr(n).pipe(_T(e,t),RT(qu(n)))}function dL(e,t){let n=t?.encodingStrategy==="omit"?Yw():Is();return r=>Pt(jl(r)).pipe(Ee(r,{decode:Sp(lL(e)),encode:n}))}function T5(e,t){return n=>Pr(n).pipe(dL(e,t),RT(Pt(n)))}function Ze(e){return Ot(e).pipe(fL(v(e)))}function k5(e){return Ze(e).pipe(_T(v(e),{encodingStrategy:"omit"}))}function yc(e,t){return oe({_tag:Ze(e),...t})}function pL(e){return t=>{let n={},r=[],o=new Set,s={},i=f=>l=>f.includes(l[e]);return a(t),Object.assign(t,{cases:n,discriminants:r,isAnyOf:i,guards:s,match:c,matchOrElse:u});function a(f){let l=f.ast;if(BU(l)&&"members"in f&&globalThis.Array.isArray(f.members)&&f.members.every(zu))return f.members.forEach(a);let p=oc(l);if(p.length>0){let m=p.find(h=>h.key===e)?.literal;if(dh(m)){let h=typeof m=="number"?globalThis.String(m):m;if(o.has(h))throw new globalThis.Error(`Duplicate discriminant: ${globalThis.String(m)}`);o.add(h),r.push(m),W(n,m,f),W(s,m,j2(Pr(f)));return}}throw new globalThis.Error("No literal or unique symbol found")}function c(){if(arguments.length===1){let h=arguments[0];return function(g){let x=g[e];return(Object.hasOwn(h,x)?h[x]:void 0)(g)}}let f=arguments[0],l=arguments[1],p=f[e];return(Object.hasOwn(l,p)?l[p]:void 0)(f)}function u(){if(arguments.length===2){let g=arguments[0],x=arguments[1];return function(b){let E=b[e];return(Object.hasOwn(g,E)?g[E]??x:x)(b)}}let f=arguments[0],l=arguments[1],p=arguments[2],m=f[e];return(Object.hasOwn(l,m)?l[m]??p:p)(f)}}}function C5(e){let t={},n=[];for(let c of Object.keys(e)){let u=yc(c,e[c]);W(t,c,u),n.push(u)}let r=He(n),{guards:o,isAnyOf:s,match:i,matchOrElse:a}=pL("_tag")(r);return re(r.ast,{cases:t,isAnyOf:s,guards:o,match:i,matchOrElse:a})}function A5(){return e=>e}function Sc(e,t){return eo(n=>n instanceof e,t)}function pt(){return(e,t)=>new Dt(e.ast,Rx(t))}var Tt=zx;function O5(e,t=void 0){return new vu(e,t)}function pr(e,t){return _r(e,tt,({annotations:n})=>n===void 0?t:t.annotate(n))}var A2="^\\S[\\s\\S]*\\S$|^\\S$|^$";function MT(e){let t=new globalThis.RegExp(A2);return Tt(n=>n.trim()===n,{expected:"a string with no leading or trailing whitespace",representation:{id:"effect/schema/isTrimmed",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isTrimmed()"}),arbitrary:{constraint:{patterns:[A2]}},...e})}var R5=Oe("effect/schema/isTrimmed",tt,({annotations:e})=>MT(e));function Hu(e,t){let n=e.source,r=e.flags,o=r===""?`new RegExp(${X(n)})`:`new RegExp(${X(n)}, ${X(r)})`;return Ap(e,{toCode:()=>({runtime:`Schema.isPattern(${o})`}),...t})}var _5=oe({source:fe,flags:fe}).check(Tt(e=>{let t=Uh(()=>new globalThis.RegExp(e.source,e.flags));return Kt(t)&&t.success.source===e.source&&t.success.flags===e.flags})),M5={id:"effect/schema/isPattern",payloadSchema:_5,revive:({annotations:e,payload:t})=>Hu(new globalThis.RegExp(t.source,t.flags),e)};function mL(e){return qI({toCode:()=>({runtime:"Schema.isStringFinite()"}),...e})}var P5=Oe("effect/schema/isStringFinite",tt,({annotations:e})=>mL(e));function hL(e){return zI({toCode:()=>({runtime:"Schema.isStringBigInt()"}),...e})}var F5=Oe("effect/schema/isStringBigInt",tt,({annotations:e})=>hL(e));function gL(e){return WI({toCode:()=>({runtime:"Schema.isStringSymbol()"}),...e})}var U5=Oe("effect/schema/isStringSymbol",tt,({annotations:e})=>gL(e)),D5=e=>e?new globalThis.RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/;function xL(e,t){let n=D5(e);return Hu(n,{expected:e?`a UUID v${e}`:"a UUID",representation:{id:"effect/schema/isUUID",payload:{version:e??null}},toJsonSchema:()=>({pattern:n.source,format:"uuid"}),toCode:()=>({runtime:e===void 0?"Schema.isUUID()":`Schema.isUUID(${e})`}),...t})}var N5=Oe("effect/schema/isUUID",oe({version:He([Ea([1,2,3,4,5,6,7,8]),tt])}),({annotations:e,payload:t})=>xL(t.version??void 0,e)),O2=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;function yL(e){return Hu(O2,{expected:"a GUID",representation:{id:"effect/schema/isGUID",payload:null},toJsonSchema:()=>({pattern:O2.source}),toCode:()=>({runtime:"Schema.isGUID()"}),...e})}var L5=Oe("effect/schema/isGUID",tt,({annotations:e})=>yL(e));function SL(e){let t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;return Hu(t,{representation:{id:"effect/schema/isULID",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isULID()"}),...e})}var B5=Oe("effect/schema/isULID",tt,({annotations:e})=>SL(e));function PT(e){let t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;return Hu(t,{expected:"a base64 encoded string",representation:{id:"effect/schema/isBase64",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64()"}),...e})}var j5=Oe("effect/schema/isBase64",tt,({annotations:e})=>PT(e));function EL(e){let t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;return Hu(t,{expected:"a base64url encoded string",representation:{id:"effect/schema/isBase64Url",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64Url()"}),...e})}var $5=Oe("effect/schema/isBase64Url",tt,({annotations:e})=>EL(e));function bL(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`^${_l(e)}`);return Tt(o=>o.startsWith(e),{expected:`a string starting with ${n}`,representation:{id:"effect/schema/isStartsWith",payload:{startsWith:e}},toJsonSchema:()=>({pattern:r.source}),toCode:()=>({runtime:`Schema.isStartsWith(${X(e)})`}),arbitrary:{constraint:{patterns:[r.source]}},...t})}var q5=Oe("effect/schema/isStartsWith",oe({startsWith:fe}),({annotations:e,payload:t})=>bL(t.startsWith,e));function wL(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`${_l(e)}$`);return Tt(o=>o.endsWith(e),{expected:`a string ending with ${n}`,representation:{id:"effect/schema/isEndsWith",payload:{endsWith:e}},toJsonSchema:()=>({pattern:r.source}),toCode:()=>({runtime:`Schema.isEndsWith(${X(e)})`}),arbitrary:{constraint:{patterns:[r.source]}},...t})}var z5=Oe("effect/schema/isEndsWith",oe({endsWith:fe}),({annotations:e,payload:t})=>wL(t.endsWith,e));function IL(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(_l(e));return Tt(o=>o.includes(e),{expected:`a string including ${n}`,representation:{id:"effect/schema/isIncludes",payload:{includes:e}},toJsonSchema:()=>({pattern:r.source}),toCode:()=>({runtime:`Schema.isIncludes(${X(e)})`}),arbitrary:{constraint:{patterns:[r.source]}},...t})}var H5=Oe("effect/schema/isIncludes",oe({includes:fe}),({annotations:e,payload:t})=>IL(t.includes,e)),R2="^[^a-z]*$";function vL(e){let t=new globalThis.RegExp(R2);return Tt(n=>n.toUpperCase()===n,{expected:"a string with all characters in uppercase",representation:{id:"effect/schema/isUppercased",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isUppercased()"}),arbitrary:{constraint:{patterns:[R2]}},...e})}var W5=Oe("effect/schema/isUppercased",tt,({annotations:e})=>vL(e)),_2="^[^A-Z]*$";function TL(e){let t=new globalThis.RegExp(_2);return Tt(n=>n.toLowerCase()===n,{expected:"a string with all characters in lowercase",representation:{id:"effect/schema/isLowercased",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isLowercased()"}),arbitrary:{constraint:{patterns:[_2]}},...e})}var K5=Oe("effect/schema/isLowercased",tt,({annotations:e})=>TL(e)),M2="^[^a-z]?.*$";function kL(e){let t=new globalThis.RegExp(M2);return Tt(n=>n.charAt(0).toUpperCase()===n.charAt(0),{expected:"a string with the first character in uppercase",representation:{id:"effect/schema/isCapitalized",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isCapitalized()"}),arbitrary:{constraint:{patterns:[M2]}},...e})}var V5=Oe("effect/schema/isCapitalized",tt,({annotations:e})=>kL(e)),P2="^[^A-Z]?.*$";function CL(e){let t=new globalThis.RegExp(P2);return Tt(n=>n.charAt(0).toLowerCase()===n.charAt(0),{expected:"a string with the first character in lowercase",representation:{id:"effect/schema/isUncapitalized",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isUncapitalized()"}),arbitrary:{constraint:{patterns:[P2]}},...e})}var J5=Oe("effect/schema/isUncapitalized",tt,({annotations:e})=>CL(e)),Ls=re(NI),AL=DI,G5=Oe("effect/schema/isFinite",tt,({annotations:e})=>AL(e));function mm(e){let t=Bi(e.order),n=e.formatter??X;return(r,o)=>Tt(s=>t(s,r),{expected:`a value greater than ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:r,exclusiveMinimum:!0}}},...e.annotate?.(r),...o})}function hm(e){let t=gf(e.order),n=e.formatter??X;return(r,o)=>Tt(s=>t(s,r),{expected:`a value greater than or equal to ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:r}}},...e.annotate?.(r),...o})}function gm(e){let t=Wc(e.order),n=e.formatter??X;return(r,o)=>Tt(s=>t(s,r),{expected:`a value less than ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,maximum:r,exclusiveMaximum:!0}}},...e.annotate?.(r),...o})}function xm(e){let t=hf(e.order),n=e.formatter??X;return(r,o)=>Tt(s=>t(s,r),{expected:`a value less than or equal to ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,maximum:r}}},...e.annotate?.(r),...o})}function ym(e){let t=gf(e.order),n=Bi(e.order),r=hf(e.order),o=Wc(e.order),s=e.formatter??X;return(i,a)=>{let c=i.exclusiveMinimum?n:t,u=i.exclusiveMaximum?o:r;return Tt(f=>c(f,i.minimum)&&u(f,i.maximum),{expected:`a value between ${s(i.minimum)}${i.exclusiveMinimum?" (excluded)":""} and ${s(i.maximum)}${i.exclusiveMaximum?" (excluded)":""}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:i.minimum,maximum:i.maximum,...i.exclusiveMinimum&&{exclusiveMinimum:!0},...i.exclusiveMaximum&&{exclusiveMaximum:!0}}}},...e.annotate?.(i),...a})}}function OL(e){return(t,n)=>{let r=e.formatter??X;return Tt(o=>e.remainder(o,t)===e.zero,{expected:`a value that is a multiple of ${r(t)}`,...e.annotate?.(t),...n})}}function Ul(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${X(e)}`);return e}var RL=mm({order:co,annotate:e=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:Ul(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${X(e)})`})})}),Z5=Oe("effect/schema/isGreaterThan",oe({exclusiveMinimum:Ls}),({annotations:e,payload:t})=>RL(t.exclusiveMinimum,e)),FT=hm({order:co,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:Ul(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${X(e)})`})})}),Q5=Oe("effect/schema/isGreaterThanOrEqualTo",oe({minimum:Ls}),({annotations:e,payload:t})=>FT(t.minimum,e)),_L=gm({order:co,annotate:e=>({representation:{id:"effect/schema/isLessThan",payload:{exclusiveMaximum:Ul(e)}},toJsonSchema:()=>({exclusiveMaximum:e}),toCode:()=>({runtime:`Schema.isLessThan(${X(e)})`})})}),Y5=Oe("effect/schema/isLessThan",oe({exclusiveMaximum:Ls}),({annotations:e,payload:t})=>_L(t.exclusiveMaximum,e)),ML=xm({order:co,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:Ul(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${X(e)})`})})}),X5=Oe("effect/schema/isLessThanOrEqualTo",oe({maximum:Ls}),({annotations:e,payload:t})=>ML(t.maximum,e)),sS=ym({order:co,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:Ul(e.minimum),maximum:Ul(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[n?"exclusiveMaximum":"maximum"]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${X(e.minimum)}, maximum: ${X(e.maximum)}, exclusiveMinimum: ${X(t)}, exclusiveMaximum: ${X(n)} })`})}}}),eZ=Oe("effect/schema/isBetween",oe({minimum:Ls,maximum:Ls,exclusiveMinimum:Pt(Ot(!0)),exclusiveMaximum:Pt(Ot(!0))}),({annotations:e,payload:t})=>sS(t,e)),PL=OL({remainder:NP,zero:0,annotate:e=>({expected:`a value that is a multiple of ${e}`,representation:{id:"effect/schema/isMultipleOf",payload:{divisor:e}},toJsonSchema:()=>({multipleOf:e}),toCode:()=>({runtime:`Schema.isMultipleOf(${X(e)})`})})}),tZ=Oe("effect/schema/isMultipleOf",oe({divisor:Ls}),({annotations:e,payload:t})=>PL(t.divisor,e));function Sm(e){return Tt(t=>globalThis.Number.isSafeInteger(t),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:()=>({type:"integer"}),toCode:()=>({runtime:"Schema.isInt()"}),arbitrary:{constraint:{integer:!0}},...e})}var nZ=Oe("effect/schema/isInt",tt,({annotations:e})=>Sm(e)),js=$l.check(Sm()),tr=js.check(FT(0));function rZ(e){return new vu([Sm(),sS({minimum:-2147483648,maximum:2147483647})],{expected:"a 32-bit integer",...e})}function oZ(e){return new vu([Sm(),sS({minimum:0,maximum:4294967295})],{expected:"a 32-bit unsigned integer",...e})}function Dl(e){if(globalThis.Number.isNaN(e.getTime()))throw new globalThis.RangeError(`Expected a valid Date, got ${X(e)}`);return e.toISOString()}function Nl(e){return`new Date(${X(e.getTime())})`}var FL=mm({order:Hc,annotate:e=>({representation:{id:"effect/schema/isGreaterThanDate",payload:{exclusiveMinimum:Dl(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanDate(${Nl(e)})`})})}),UL=hm({order:Hc,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualToDate",payload:{minimum:Dl(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToDate(${Nl(e)})`})})}),DL=gm({order:Hc,annotate:e=>({representation:{id:"effect/schema/isLessThanDate",payload:{exclusiveMaximum:Dl(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanDate(${Nl(e)})`})})}),NL=xm({order:Hc,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualToDate",payload:{maximum:Dl(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanOrEqualToDate(${Nl(e)})`})})}),LL=ym({order:Hc,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenDate",payload:{minimum:Dl(e.minimum),maximum:Dl(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isBetweenDate({ minimum: ${Nl(e.minimum)}, maximum: ${Nl(e.maximum)}, exclusiveMinimum: ${X(t)}, exclusiveMaximum: ${X(n)} })`})}}}),BL=mm({order:Co,annotate:e=>({representation:{id:"effect/schema/isGreaterThanBigInt",payload:{exclusiveMinimum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanBigInt(${X(e)})`})})}),jL=hm({order:Co,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualToBigInt",payload:{minimum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToBigInt(${X(e)})`})})}),$L=gm({order:Co,annotate:e=>({representation:{id:"effect/schema/isLessThanBigInt",payload:{exclusiveMaximum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanBigInt(${X(e)})`})})}),qL=xm({order:Co,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualToBigInt",payload:{maximum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanOrEqualToBigInt(${X(e)})`})})}),zL=ym({order:Co,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenBigInt",payload:{minimum:e.minimum.toString(10),maximum:e.maximum.toString(10),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isBetweenBigInt({ minimum: ${X(e.minimum)}, maximum: ${X(e.maximum)}, exclusiveMinimum: ${X(t)}, exclusiveMaximum: ${X(n)} })`})}}}),sZ=mm({order:ji,formatter:e=>Zs(e)}),iZ=hm({order:ji,formatter:e=>Zs(e)}),aZ=gm({order:ji,formatter:e=>Zs(e)}),cZ=xm({order:ji,formatter:e=>Zs(e)}),uZ=ym({order:ji,formatter:e=>Zs(e)});function UT(e,t){return e=Math.max(0,Math.floor(e)),Tt(n=>n.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:({type:n})=>n==="array"?{minItems:e}:{minLength:e},toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[Vr]:!0,arbitrary:{constraint:{minLength:e}},...t})}var fZ=Oe("effect/schema/isMinLength",oe({minLength:tr}),({annotations:e,payload:t})=>UT(t.minLength,e));function HL(e){return UT(1,e)}function WL(e,t){return e=Math.max(0,Math.floor(e)),Tt(n=>n.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:({type:n})=>n==="array"?{maxItems:e}:{maxLength:e},toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[Vr]:!0,arbitrary:{constraint:{maxLength:e}},...t})}var lZ=Oe("effect/schema/isMaxLength",oe({maxLength:tr}),({annotations:e,payload:t})=>WL(t.maxLength,e));function DT(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),Tt(r=>r.length>=e&&r.length<=t,{expected:e===t?`a value with a length of ${e}`:`a value with a length between ${e} and ${t}`,representation:{id:"effect/schema/isLengthBetween",payload:{minimum:e,maximum:t}},toJsonSchema:({type:r})=>r==="array"?{allOf:[{minItems:e},{maxItems:t}]}:{allOf:[{minLength:e},{maxLength:t}]},toCode:()=>({runtime:`Schema.isLengthBetween(${e}, ${t})`}),[Vr]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}var dZ=Oe("effect/schema/isLengthBetween",oe({minimum:tr,maximum:tr}),({annotations:e,payload:t})=>DT(t.minimum,t.maximum,e));function KL(e,t){return e=Math.max(0,Math.floor(e)),Tt(n=>n.size>=e,{expected:`a value with a size of at least ${e}`,representation:{id:"effect/schema/isMinSize",payload:{minSize:e}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isMinSize(${e})`}),[Vr]:!0,arbitrary:{constraint:{minLength:e}},...t})}var pZ=Oe("effect/schema/isMinSize",oe({minSize:tr}),({annotations:e,payload:t})=>KL(t.minSize,e));function VL(e,t){return e=Math.max(0,Math.floor(e)),Tt(n=>n.size<=e,{expected:`a value with a size of at most ${e}`,representation:{id:"effect/schema/isMaxSize",payload:{maxSize:e}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isMaxSize(${e})`}),[Vr]:!0,arbitrary:{constraint:{maxLength:e}},...t})}var mZ=Oe("effect/schema/isMaxSize",oe({maxSize:tr}),({annotations:e,payload:t})=>VL(t.maxSize,e));function JL(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),Tt(r=>r.size>=e&&r.size<=t,{expected:e===t?`a value with a size of ${e}`:`a value with a size between ${e} and ${t}`,representation:{id:"effect/schema/isSizeBetween",payload:{minimum:e,maximum:t}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isSizeBetween(${e}, ${t})`}),[Vr]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}var hZ=Oe("effect/schema/isSizeBetween",oe({minimum:tr,maximum:tr}),({annotations:e,payload:t})=>JL(t.minimum,t.maximum,e));function GL(e,t){return e=Math.max(0,Math.floor(e)),Tt(n=>Reflect.ownKeys(n).length>=e,{expected:`a value with at least ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMinProperties",payload:{minProperties:e}},toJsonSchema:()=>({minProperties:e}),toCode:()=>({runtime:`Schema.isMinProperties(${e})`}),[Vr]:!0,arbitrary:{constraint:{minLength:e}},...t})}var gZ=Oe("effect/schema/isMinProperties",oe({minProperties:tr}),({annotations:e,payload:t})=>GL(t.minProperties,e));function ZL(e,t){return e=Math.max(0,Math.floor(e)),Tt(n=>Reflect.ownKeys(n).length<=e,{expected:`a value with at most ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMaxProperties",payload:{maxProperties:e}},toJsonSchema:()=>({maxProperties:e}),toCode:()=>({runtime:`Schema.isMaxProperties(${e})`}),[Vr]:!0,arbitrary:{constraint:{maxLength:e}},...t})}var xZ=Oe("effect/schema/isMaxProperties",oe({maxProperties:tr}),({annotations:e,payload:t})=>ZL(t.maxProperties,e));function QL(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),Tt(r=>Reflect.ownKeys(r).length>=e&&Reflect.ownKeys(r).length<=t,{expected:e===t?`a value with exactly ${e===1?"1 entry":`${e} entries`}`:`a value with between ${e} and ${t} entries`,representation:{id:"effect/schema/isPropertiesLengthBetween",payload:{minimum:e,maximum:t}},toJsonSchema:()=>({minProperties:e,maxProperties:t}),toCode:()=>({runtime:`Schema.isPropertiesLengthBetween(${e}, ${t})`}),[Vr]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}var yZ=Oe("effect/schema/isPropertiesLengthBetween",oe({minimum:tr,maximum:tr}),({annotations:e,payload:t})=>QL(t.minimum,t.maximum,e));function YL(e,t){let n=jl(e),r=hN(n.ast);return Tt((o,s,i)=>{let a=Reflect.ownKeys(o),c=[];for(let u of a){let f=r(u,i);if(f!==void 0&&(c.push(new Ct([u],f)),i.errors==="first"))break}return Vn(c)?new At(s,c,o,i):!0},{expected:"an object with property names matching the schema",representation:{id:"effect/schema/isPropertyNames",payload:null,schemas:[n.ast]},toJsonSchema:({schemas:o})=>({propertyNames:o[0]}),toCode:({schemas:o})=>({runtime:`Schema.isPropertyNames(${o[0].runtime})`}),[Vr]:!0,...t})}var SZ=Oe("effect/schema/isPropertyNames",tt,({annotations:e,schemas:t})=>YL(t[0],e));function NT(e){return Tt(t=>qh(t).length===t.length,{expected:"an array with unique items",representation:{id:"effect/schema/isUnique",payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:"Schema.isUnique()"}),arbitrary:{constraint:{unique:!0}},...e})}var EZ=Oe("effect/schema/isUnique",tt,({annotations:e})=>NT(e)),bZ=fe.check(HL()),wZ=fe.check(DT(1,1));function wi(e){let t=An()([e],([n])=>(r,o,s)=>Gs(r)?ge(r)?Ss:fn(dt(n)(r.value,s),{onSuccess:N,onFailure:i=>Yn(o,"value",i,r,s)}):G(new st(o,r,s)),{representation:{id:"effect/schema/Option",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Option(${n[0].runtime})`,Type:`Option.Option<${n[0].Type}>`,importDeclarations:['import * as Option from "effect/Option"']}),expected:"Option",toCodec:([n])=>pt()(He([oe({_tag:Ot("Some"),value:n}),oe({_tag:Ot("None")})]),vt({decode:r=>r._tag==="None"?U():N(r.value),encode:r=>Te(r)?{_tag:"Some",value:r.value}:{_tag:"None"}})),toArbitrary:([n])=>(r,o)=>{let s=r.constant(U()),i=r.oneof(s,n.arbitrary.map(N));return Wu(r,o,s,i)},toEquivalence:([n])=>XE(n),toFormatter:([n])=>rr({onNone:()=>"none()",onSome:r=>`some(${n(r)})`})});return re(t.ast,{value:e})}var IZ=_r("effect/schema/Option",tt,({annotations:e,typeParameters:t})=>{let n=wi(t[0]);return e===void 0?n:n.annotate(e)});function vZ(e){return OT(e).pipe(Ee(wi(Pr(e)),yU()))}function TZ(e){return oS(e).pipe(Ee(wi(Pr(e)),SU()))}function kZ(e,t){return rL(e).pipe(Ee(wi(Pr(e)),EU(t)))}function CZ(e){return qu(e).pipe(Ee(wi(Pr(e)),bU()))}function AZ(e){return Pt(e).pipe(Ee(wi(Pr(e)),wU()))}function OZ(e,t){let n=t===void 0?"omit":t.onNoneEncoding,r=n===null?null:void 0;return Pt(OT(e)).pipe(Ee(wi(Pr(e)),_x({decode:o=>o.pipe(Na(ph),N),encode:n==="omit"?Vc:o=>N(Ua(Vc(o),()=>r))})))}function XL(e,t){let n=An()([e,t],([r,o])=>(s,i,a)=>{if(!xf(s))return G(new st(i,s,a));switch(s._tag){case"Success":return fn(Xv(r)(s.success,a),{onSuccess:Ce,onFailure:c=>Yn(i,"success",c,s,a)});case"Failure":return fn(Xv(o)(s.failure,a),{onSuccess:Ae,onFailure:c=>Yn(i,"failure",c,s,a)})}},{representation:{id:"effect/schema/Result",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Result(${r[0].runtime}, ${r[1].runtime})`,Type:`Result.Result<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Result from "effect/Result"']}),expected:"Result",toCodec:([r,o])=>pt()(He([oe({_tag:Ot("Success"),success:r}),oe({_tag:Ot("Failure"),failure:o})]),vt({decode:s=>s._tag==="Success"?Ce(s.success):Ae(s.failure),encode:s=>Kt(s)?{_tag:"Success",success:s.success}:{_tag:"Failure",failure:s.failure}})),toArbitrary:([r,o])=>(s,i)=>{let a=uB(s,r.terminal?.map(u=>Ce(u)),o.terminal?.map(u=>Ae(u))),c=s.oneof(r.arbitrary.map(u=>Ce(u)),o.arbitrary.map(u=>Ae(u)));return Wu(s,i,a,c)},toEquivalence:([r,o])=>eO(r,o),toFormatter:([r,o])=>Oo({onSuccess:s=>`success(${r(s)})`,onFailure:s=>`failure(${o(s)})`})});return re(n.ast,{success:e,failure:t})}var RZ=_r("effect/schema/Result",tt,({annotations:e,typeParameters:t})=>{let n=XL(t[0],t[1]);return e===void 0?n:n.annotate(e)}),_Z=eo(e=>{if(!en(e))return!1;let t=globalThis.Object.keys(e);return t.length>0&&t.every(n=>{switch(n){case"label":return typeof e[n]=="string";case"disallowJsonEncode":return e[n]===!0;default:return!1}})}),MZ=He([tt,_Z]);function LT(e,t){let n=typeof t?.label=="string"?t.label:void 0,r=t?.disallowJsonEncode===!0,o=n!==void 0?r?{label:n,disallowJsonEncode:!0}:{label:n}:r?{disallowJsonEncode:!0}:void 0,s=n!==void 0?dt(Ot(n)):void 0,i=An()([e],([a])=>(c,u,f)=>{if(cm(c)){let l=s!==void 0?yu(s(c.label,f),p=>new Ct(["label"],p)):H;return Bn(l,()=>fn(dt(a)(dc(c),f),{onSuccess:()=>c,onFailure:()=>new At(u,[new Ct(["value"],new ke(void 0,c,f))],c,f)}))}return G(new st(u,c,f))},{representation:{id:"effect/schema/Redacted",payload:o??null},toCode:({typeParameters:a})=>({runtime:o!==void 0?`Schema.Redacted(${a[0].runtime}, ${X(o)})`:`Schema.Redacted(${a[0].runtime})`,Type:`Redacted.Redacted<${a[0].Type}>`,importDeclarations:['import * as Redacted from "effect/Redacted"']}),expected:"Redacted",toCodecJson:([a])=>pt()(a,{decode:De(c=>pc(c,{label:n})),encode:r?Zw(c=>"Cannot serialize Redacted"+(Te(c)&&typeof c.value.label=="string"?` with label: "${c.value.label}"`:"")):De(dc)}),toArbitrary:([a])=>()=>({arbitrary:a.arbitrary.map(c=>pc(c,{label:n})),terminal:a.terminal?.map(c=>pc(c,{label:n}))}),toFormatter:()=>globalThis.String,toEquivalence:([a])=>T2(a)});return re(i.ast,{value:e})}var PZ=_r("effect/schema/Redacted",MZ,({annotations:e,payload:t,typeParameters:n})=>{let r=LT(n[0],t??void 0);return e===void 0?r:r.annotate(e)});function FZ(e,t){return Ee(LT(Pr(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:De(n=>pc(n,{label:t?.label})),encode:t?.disallowEncode?Zw(n=>"Cannot encode Redacted"+(Te(n)&&typeof n.value.label=="string"?` with label: "${n.value.label}"`:"")):De(dc)})(e)}function Yy(e,t){let n=An()([e,t],([r,o])=>(s,i,a)=>{if(!Nf(s))return G(new st(i,s,a));switch(s._tag){case"Fail":return fn(dt(r)(s.error,a),{onSuccess:Lf,onFailure:c=>Yn(i,"error",c,s,a)});case"Die":return fn(dt(o)(s.defect,a),{onSuccess:Bf,onFailure:c=>Yn(i,"defect",c,s,a)});case"Interrupt":return v(s)}},{representation:{id:"effect/schema/CauseReason",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.CauseReason(${r[0].runtime}, ${r[1].runtime})`,Type:`Cause.Failure<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause.Failure",toCodec:([r,o])=>pt()(He([oe({_tag:Ot("Fail"),error:r}),oe({_tag:Ot("Die"),defect:o}),oe({_tag:Ot("Interrupt"),fiberId:oS(Ls)})]),vt({decode:s=>{switch(s._tag){case"Fail":return Lf(s.error);case"Die":return Bf(s.defect);case"Interrupt":return ou(s.fiberId)}},encode:L})),toArbitrary:([r,o])=>eB(r,o),toEquivalence:([r,o])=>tB(r,o),toFormatter:([r,o])=>nB(r,o)});return re(n.ast,{error:e,defect:t})}var UZ=_r("effect/schema/CauseReason",tt,({annotations:e,typeParameters:t})=>{let n=Yy(t[0],t[1]);return e===void 0?n:n.annotate(e)});function eB(e,t){return(n,r)=>{let o=n.constant(ou()),s=n.oneof(o,n.integer({min:1}).map(ou),e.arbitrary.map(i=>Lf(i)),t.arbitrary.map(i=>Bf(i)));return Wu(n,r,o,s)}}function tB(e,t){return(n,r)=>{if(n._tag!==r._tag)return!1;switch(n._tag){case"Fail":return e(n.error,r.error);case"Die":return t(n.defect,r.defect);case"Interrupt":return n.fiberId===r.fiberId}}}function nB(e,t){return n=>{switch(n._tag){case"Fail":return`Fail(${e(n.error)})`;case"Die":return`Die(${t(n.defect)})`;case"Interrupt":return"Interrupt"}}}function Ll(e,t){let n=An()([e,t],([r,o])=>{let s=Wt(Yy(r,o));return(i,a,c)=>Df(i)?fn(dt(s)(i.reasons,c),{onSuccess:Va,onFailure:u=>Yn(a,"failures",u,i,c)}):G(new st(a,i,c))},{representation:{id:"effect/schema/Cause",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Cause(${r[0].runtime}, ${r[1].runtime})`,Type:`Cause.Cause<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause",toCodec:([r,o])=>pt()(Wt(Yy(r,o)),vt({decode:Va,encode:({reasons:s})=>s})),toArbitrary:([r,o])=>rB(r,o),toEquivalence:([r,o])=>oB(r,o),toFormatter:([r,o])=>sB(r,o)});return re(n.ast,{error:e,defect:t})}var DZ=_r("effect/schema/Cause",tt,({annotations:e,typeParameters:t})=>{let n=Ll(t[0],t[1]);return e===void 0?n:n.annotate(e)});function rB(e,t){return(n,r)=>{let o=eB(e,t)(n,r),s=n.constant(JM),i=n.array(o.arbitrary).map(Va);return Wu(n,r,s,i)}}function oB(e,t){let n=yh(tB(e,t));return(r,o)=>n(r.reasons,o.reasons)}function sB(e,t){let n=nB(e,t);return r=>`Cause([${r.reasons.map(n).join(", ")}])`}var NZ=eo(e=>{if(!en(e))return!1;let t=globalThis.Object.keys(e);return t.length>0&&t.every(n=>(n==="includeStack"||n==="excludeCause")&&e[n]===!0)}),LZ=He([tt,NZ]),iB=e=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),aB=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},F2=[];function cB(e){let t=iB(e),n=F2[t];if(n!==void 0)return n;let r=aB(t),o=Sc(globalThis.Error,{representation:{id:"effect/schema/Error",payload:r??null},toCode:()=>({runtime:r!==void 0?`Schema.ErrorInstance(${X(r)})`:"Schema.ErrorInstance()",Type:"globalThis.Error"}),expected:"Error",toCodecJson:()=>pt()(R7,gU(r)),toArbitrary:()=>s=>s.string().map(i=>new globalThis.Error(i))});return F2[t]=o,o}var BZ=_r("effect/schema/Error",LZ,({annotations:e,payload:t})=>{let n=cB(t??void 0);return e===void 0?n:n.annotate(e)}),U2=[];function ln(e){let t=iB(e),n=U2[t];if(n!==void 0)return n;let r=Im.pipe(Ee(TT,xU(aB(t))));return U2[t]=r,r}function iS(e,t,n){let r=An()([e,t,n],([o,s,i])=>{let a=Ll(s,i);return(c,u,f)=>{if(!ms(c))return G(new st(u,c,f));switch(c._tag){case"Success":return fn(dt(o)(c.value,f),{onSuccess:kn,onFailure:l=>Yn(u,"value",l,c,f)});case"Failure":return fn(dt(a)(c.cause,f),{onSuccess:jt,onFailure:l=>Yn(u,"cause",l,c,f)})}}},{representation:{id:"effect/schema/Exit",payload:null},toCode:({typeParameters:o})=>({runtime:`Schema.Exit(${o[0].runtime}, ${o[1].runtime}, ${o[2].runtime})`,Type:`Exit.Exit<${o[0].Type}, ${o[1].Type}, ${o[2].Type}>`,importDeclarations:['import * as Exit from "effect/Exit"']}),expected:"Exit",toCodec:([o,s,i])=>pt()(He([oe({_tag:Ot("Success"),value:o}),oe({_tag:Ot("Failure"),cause:Ll(s,i)})]),vt({decode:a=>a._tag==="Success"?kn(a.value):jt(a.cause),encode:a=>Ft(a)?{_tag:"Success",value:a.value}:{_tag:"Failure",cause:a.cause}})),toArbitrary:([o,s,i])=>(a,c)=>{let u=rB(s,i)(a,c),f=uB(a,o.terminal?.map(p=>kn(p)),u.terminal?.map(p=>jt(p))),l=a.oneof(o.arbitrary.map(p=>kn(p)),u.arbitrary.map(p=>jt(p)));return Wu(a,c,f,l)},toEquivalence:([o,s,i])=>{let a=oB(s,i);return(c,u)=>{if(c._tag!==u._tag)return!1;switch(c._tag){case"Success":return o(c.value,u.value);case"Failure":return a(c.cause,u.cause)}}},toFormatter:([o,s,i])=>{let a=sB(s,i);return c=>{switch(c._tag){case"Success":return`Exit.Success(${o(c.value)})`;case"Failure":return`Exit.Failure(${a(c.cause)})`}}}});return re(r.ast,{value:e,error:t,defect:n})}var jZ=_r("effect/schema/Exit",tt,({annotations:e,typeParameters:t})=>{let n=iS(t[0],t[1],t[2]);return e===void 0?n:n.annotate(e)});function uB(e,t,n){return t===void 0?n:n===void 0?t:e.oneof(t,n)}function Wu(e,t,n,r){return{arbitrary:n===void 0||t.recursion===void 0?r:e.oneof(t.recursion,n,r),terminal:n}}function D2(e,t,n,r){return r===void 0?e.array(t,n):e.uniqueArray(t,{...n,comparator:r})}function aS(e,t,n,r,o,s){let i=t.constraint,a=i===void 0||i.minLength===void 0&&i.maxLength===void 0?void 0:{...i.minLength!==void 0?{minLength:i.minLength}:{},...i.maxLength!==void 0?{maxLength:i.maxLength}:{}};if(a?.minLength!==void 0&&a.maxLength!==void 0&&a.minLength>a.maxLength)throw new globalThis.Error("Unable to derive an arbitrary for size constraints");let c=a?.minLength??0,u=c===0?e.constant([]):r===void 0?void 0:D2(e,r,{...a,maxLength:c},s),f=Wu(e,t,u,D2(e,n,a,s));return{arbitrary:f.arbitrary.map(o),terminal:f.terminal?.map(o)}}function fB(e,t,n,r,o){return aS(e,t,e.tuple(n.arbitrary,r.arbitrary),n.terminal===void 0||r.terminal===void 0?void 0:e.tuple(n.terminal,r.terminal),o,([s],[i])=>ae(s,i))}function lB(e,t){let n=An()([e,t],([r,o])=>{let s=Wt(mc([r,o]));return(i,a,c)=>i instanceof globalThis.Map?fn(dt(s)([...i],c),{onSuccess:u=>new globalThis.Map(u),onFailure:u=>Yn(a,"entries",u,i,c)}):G(new st(a,i,c))},{representation:{id:"effect/schema/ReadonlyMap",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.ReadonlyMap(${r[0].runtime}, ${r[1].runtime})`,Type:`globalThis.ReadonlyMap<${r[0].Type}, ${r[1].Type}>`}),expected:"ReadonlyMap",toCodec:([r,o])=>pt()(Wt(mc([r,o])),vt({decode:s=>new globalThis.Map(s),encode:s=>[...s.entries()]})),toArbitrary:([r,o])=>(s,i)=>fB(s,i,r,o,a=>new globalThis.Map(a)),toEquivalence:([r,o])=>gh(r,o),toFormatter:([r,o])=>s=>{let i=s.size;if(i===0)return"ReadonlyMap(0) {}";let a=globalThis.Array.from(s.entries()).sort().map(([c,u])=>`${r(c)} => ${o(u)}`);return`ReadonlyMap(${i}) { ${a.join(", ")} }`}});return re(n.ast,{key:e,value:t})}var $Z=_r("effect/schema/ReadonlyMap",tt,({annotations:e,typeParameters:t})=>{let n=lB(t[0],t[1]);return e===void 0?n:n.annotate(e)});function N2(e,t,n){return oe({type:Ot(e),nodes:Wt(oe({index:tr,data:t})),edges:Wt(oe({index:tr,source:tr,target:tr,data:n}))})}function L2(e,t){let n=-1,r=new Set;for(let o=0;o<e.nodes.length;o++){let s=e.nodes[o].index;if(s<=n)return G(new Ct(["nodes",o,"index"],new ke({expected:"a strictly increasing node index"},s,t)));n=s,r.add(s)}n=-1;for(let o=0;o<e.edges.length;o++){let s=e.edges[o];if(s.index<=n)return G(new Ct(["edges",o,"index"],new ke({expected:"a strictly increasing edge index"},s.index,t)));if(n=s.index,!r.has(s.source))return G(new Ct(["edges",o,"source"],new ke({expected:"an encoded node index"},s.source,t)));if(!r.has(s.target))return G(new Ct(["edges",o,"target"],new ke({expected:"an encoded node index"},s.target,t)))}return v(Jp(e))}function qZ(e,t,n){return!jv(e)||e.mutable||e.type!==t?G(new ke({expected:`an immutable ${t} Graph`},e,n)):v(Vp(e))}function zZ(e,t){return(n,r)=>{let o=Vp(n),s=Vp(r);if(o.type!==s.type||o.nodes.length!==s.nodes.length||o.edges.length!==s.edges.length)return!1;for(let i=0;i<o.nodes.length;i++)if(o.nodes[i].index!==s.nodes[i].index||!e(o.nodes[i].data,s.nodes[i].data))return!1;for(let i=0;i<o.edges.length;i++){let a=o.edges[i],c=s.edges[i],u=o.type==="directed"?a.source===c.source&&a.target===c.target:a.source===c.source&&a.target===c.target||a.source===c.target&&a.target===c.source;if(a.index!==c.index||!u||!t(a.data,c.data))return!1}return!0}}function HZ(e,t,n){return(r,o)=>{let s=Jp({type:e,nodes:[],edges:[]}),i=r.constant(s),a=r.array(t.arbitrary).chain(c=>{let u=c.map((l,p)=>({index:p,data:l}));if(u.length===0)return i;let f=r.integer({min:0,max:u.length-1});return r.array(r.tuple(f,f,n.arbitrary)).map(l=>Jp({type:e,nodes:u,edges:l.map(([p,m,h],g)=>({index:g,source:p,target:m,data:h}))}))});return Wu(r,o,i,a)}}function dB(e,t,n){let r=An()([t,n],([o,s])=>{let i=N2(e,o,s);return(a,c,u)=>!jv(a)||a.mutable||a.type!==e?G(new st(c,a,u)):A(dt(i)(Vp(a),u),f=>L2(f,u))},{representation:{id:"effect/schema/Graph",payload:e},toCode:({typeParameters:o})=>({runtime:`Schema.Graph(${X(e)}, ${o[0].runtime}, ${o[1].runtime})`,Type:`Graph.Graph<${o[0].Type}, ${o[1].Type}, ${X(e)}>`,importDeclarations:['import * as Graph from "effect/Graph"']}),expected:`an immutable ${e} Graph`,toCodec:([o,s])=>pt()(N2(e,o,s),Ar({decode:L2,encode:(i,a)=>qZ(i,e,a)})),toArbitrary:([o,s])=>HZ(e,o,s),toEquivalence:([o,s])=>zZ(o,s),toFormatter:()=>globalThis.String});return re(r.ast,{type:e,node:t,edge:n})}var WZ=_r("effect/schema/Graph",Ea(["directed","undirected"]),({annotations:e,payload:t,typeParameters:n})=>{let r=dB(t,n[0],n[1]);return e===void 0?r:r.annotate(e)});function pB(e,t){let n=An()([e,t],([r,o])=>{let s=Wt(mc([r,o]));return(i,a,c)=>Py(i)?fn(dt(s)(Uy(i),c),{onSuccess:Fy,onFailure:u=>Yn(a,"entries",u,i,c)}):G(new st(a,i,c))},{representation:{id:"effect/schema/HashMap",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.HashMap(${r[0].runtime}, ${r[1].runtime})`,Type:`HashMap.HashMap<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as HashMap from "effect/HashMap"']}),expected:"HashMap",toCodec:([r,o])=>pt()(Wt(mc([r,o])),vt({decode:Fy,encode:Uy})),toArbitrary:([r,o])=>(s,i)=>fB(s,i,r,o,Fy),toEquivalence:([r,o])=>gh(r,o),toFormatter:([r,o])=>s=>{let i=aN(s);if(i===0)return"HashMap(0) {}";let a=Uy(s).sort().map(([c,u])=>`${r(c)} => ${o(u)}`);return`HashMap(${i}) { ${a.join(", ")} }`}});return re(n.ast,{key:e,value:t})}var KZ=_r("effect/schema/HashMap",tt,({annotations:e,typeParameters:t})=>{let n=pB(t[0],t[1]);return e===void 0?n:n.annotate(e)});function mB(e){let t=An()([e],([n])=>{let r=Wt(n);return(o,s,i)=>o instanceof globalThis.Set?fn(dt(r)([...o],i),{onSuccess:a=>new globalThis.Set(a),onFailure:a=>Yn(s,"values",a,o,i)}):G(new st(s,o,i))},{representation:{id:"effect/schema/ReadonlySet",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.ReadonlySet(${n[0].runtime})`,Type:`globalThis.ReadonlySet<${n[0].Type}>`}),expected:"ReadonlySet",toCodec:([n])=>pt()(Wt(n),vt({decode:r=>new globalThis.Set(r),encode:r=>[...r.values()]})),toArbitrary:([n])=>(r,o)=>aS(r,o,n.arbitrary,n.terminal,s=>new globalThis.Set(s),ae),toEquivalence:([n])=>xh(n),toFormatter:([n])=>r=>{let o=r.size;if(o===0)return"ReadonlySet(0) {}";let s=globalThis.Array.from(r.values()).sort().map(i=>`${n(i)}`);return`ReadonlySet(${o}) { ${s.join(", ")} }`}});return re(t.ast,{value:e})}var VZ=_r("effect/schema/ReadonlySet",tt,({annotations:e,typeParameters:t})=>{let n=mB(t[0]);return e===void 0?n:n.annotate(e)});function hB(e){let t=An()([e],([n])=>{let r=Wt(n);return(o,s,i)=>Ly(o)?fn(dt(r)(ht(o),i),{onSuccess:Ny,onFailure:a=>Yn(s,"values",a,o,i)}):G(new st(s,o,i))},{representation:{id:"effect/schema/HashSet",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.HashSet(${n[0].runtime})`,Type:`HashSet.HashSet<${n[0].Type}>`}),expected:"HashSet",toCodec:([n])=>pt()(Wt(n),vt({decode:Ny,encode:ht})),toArbitrary:([n])=>(r,o)=>aS(r,o,n.arbitrary,n.terminal,Ny,ae),toEquivalence:([n])=>xh(n),toFormatter:([n])=>r=>{let o=lN(r);if(o===0)return"HashSet(0) {}";let s=globalThis.Array.from(r).sort().map(i=>`${n(i)}`);return`HashSet(${o}) { ${s.join(", ")} }`}});return re(t.ast,{value:e})}var JZ=_r("effect/schema/HashSet",tt,({annotations:e,typeParameters:t})=>{let n=hB(t[0]);return e===void 0?n:n.annotate(e)});function gB(e){let t=An()([e],([n])=>{let r=Wt(n);return(o,s,i)=>xl(o)?fn(dt(r)(ht(o),i),{onSuccess:Yx,onFailure:a=>Yn(s,"values",a,o,i)}):G(new st(s,o,i))},{representation:{id:"effect/schema/Chunk",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Chunk(${n[0].runtime})`,Type:`Chunk.Chunk<${n[0].Type}>`}),expected:"Chunk",toCodec:([n])=>pt()(Wt(n),vt({decode:Yx,encode:ht})),toArbitrary:([n])=>(r,o)=>aS(r,o,n.arbitrary,n.terminal,Yx),toEquivalence:([n])=>ZI(n),toFormatter:([n])=>r=>{let o=v1(r);if(o===0)return"Chunk(0) {}";let s=globalThis.Array.from(r).sort().map(i=>`${n(i)}`);return`Chunk(${o}) { ${s.join(", ")} }`}});return re(t.ast,{value:e})}var GZ=_r("effect/schema/Chunk",tt,({annotations:e,typeParameters:t})=>{let n=gB(t[0]);return e===void 0?n:n.annotate(e)}),xB=Sc(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},toCode:()=>({runtime:"Schema.RegExp",Type:"globalThis.RegExp"}),expected:"RegExp",toCodecJson:()=>pt()(oe({source:fe,flags:fe}),Ar({decode:(e,t)=>No({try:()=>new globalThis.RegExp(e.source,e.flags),catch:()=>new ke({expected:"valid RegExp source and flags"},e,t)}),encode:e=>v({source:e.source,flags:e.flags})})),toArbitrary:()=>e=>e.tuple(e.constantFrom(".",".*","\\d+","\\w+","[a-z]+","[A-Z]+","[0-9]+","^[a-zA-Z0-9]+$","^\\d{4}-\\d{2}-\\d{2}$"),e.uniqueArray(e.constantFrom("g","i","m","s","u","y"),{minLength:0,maxLength:6}).map(t=>t.join(""))).map(([t,n])=>new globalThis.RegExp(t,n)),toEquivalence:()=>(e,t)=>e.source===t.source&&e.flags===t.flags}),ZZ=pr("effect/schema/RegExp",xB),yB=fe.annotate({expected:"a string that will be decoded as a URL"}),BT=Sc(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},toCode:()=>({runtime:"Schema.URL",Type:"globalThis.URL"}),expected:"URL",toCodecJson:()=>pt()(yB,rI),toArbitrary:()=>e=>e.webUrl().map(t=>new globalThis.URL(t)),toEquivalence:()=>(e,t)=>e.toString()===t.toString()}),QZ=pr("effect/schema/URL",BT),YZ=yB.pipe(Ee(BT,rI));function jT(e,t,n){let r={...t};if(e?.minimum!==void 0){let o=n===void 0?e.minimum:n(e.minimum),s=e.exclusiveMinimum?new globalThis.Date(o.getTime()+1):o;(r.min===void 0||s.getTime()>r.min.getTime())&&(r.min=s)}if(e?.maximum!==void 0){let o=n===void 0?e.maximum:n(e.maximum),s=e.exclusiveMaximum?new globalThis.Date(o.getTime()-1):o;(r.max===void 0||s.getTime()<r.max.getTime())&&(r.max=s)}return r}var SB=fe.annotate({expected:"a string that will be decoded as a Date"}),Bs=eo(e=>e instanceof globalThis.Date&&!globalThis.Number.isNaN(e.getTime()),{representation:{id:"effect/schema/Date",payload:null},toCode:()=>({runtime:"Schema.Date",Type:"globalThis.Date"}),expected:"a valid Date",toCodecJson:()=>pt()(SB,nI),toArbitrary:()=>(e,t)=>e.date(jT(t?.constraint?.ordered?.order===Hc?t.constraint.ordered:void 0,{noInvalidDate:!0}))}),XZ=pr("effect/schema/Date",Bs),eQ=SB.pipe(Ee(Bs,nI)),tQ=js.pipe(Ee(Bs,uU)),Em=eo(Gc,{representation:{id:"effect/schema/Duration",payload:null},toCode:()=>({runtime:"Schema.Duration",Type:"Duration.Duration",importDeclarations:['import * as Duration from "effect/Duration"']}),expected:"Duration",toCodecJson:()=>pt()(He([oe({_tag:Ot("Infinity")}),oe({_tag:Ot("NegativeInfinity")}),oe({_tag:Ot("Nanos"),value:bi}),oe({_tag:Ot("Millis"),value:js})]),vt({decode:e=>{switch(e._tag){case"Infinity":return fo;case"NegativeInfinity":return Hi;case"Nanos":return Nr(e.value);case"Millis":return is(e.value)}},encode:e=>{switch(e.value._tag){case"Infinity":return{_tag:"Infinity"};case"NegativeInfinity":return{_tag:"NegativeInfinity"};case"Nanos":return{_tag:"Nanos",value:e.value.nanos};case"Millis":return{_tag:"Millis",value:e.value.millis}}}})),toArbitrary:()=>e=>e.oneof(e.constant(fo),e.constant(Hi),e.bigInt().map(Nr),e.maxSafeInteger().map(is)),toFormatter:()=>globalThis.String,toEquivalence:()=>Sb}),nQ=pr("effect/schema/Duration",Em),rQ=fe.annotate({expected:"a string that will be decoded as a Duration"}),oQ=rQ.pipe(Ee(Em,fU)),sQ=bi.pipe(Ee(Em,lU)),iQ=$l.pipe(Ee(Em,dU)),EB=fe.annotate({expected:"a string that will be decoded as a BigDecimal"}),bB=20,wB="Unable to derive an arbitrary for the ordered BigDecimal constraints";function Xy(e,t){return La(e,t).value}function aQ(e,t,n){return n?Xy(ub(e,t),t)+globalThis.BigInt(1):Xy(cb(e,t),t)}function cQ(e,t,n){return n?Xy(cb(e,t),t)-globalThis.BigInt(1):Xy(ub(e,t),t)}function uQ(e){return Math.max(bB,e.minimum?.scale??0,e.maximum?.scale??0,e.exclusiveMinimum&&e.minimum!==void 0?e.minimum.scale+1:0,e.exclusiveMaximum&&e.maximum!==void 0?e.maximum.scale+1:0)}function ET(e,t){let n={};if(e.minimum!==void 0&&(n.min=aQ(e.minimum,t,e.exclusiveMinimum===!0)),e.maximum!==void 0&&(n.max=cQ(e.maximum,t,e.exclusiveMaximum===!0)),!(n.min!==void 0&&n.max!==void 0&&n.min>n.max))return n}function fQ(e){let t=uQ(e);if(ET(e,t)===void 0)throw new globalThis.Error(wB);let n=0,r=t;for(;n<r;){let o=n+Math.floor((r-n)/2);ET(e,o)===void 0?n=o+1:r=o}return{min:n,max:t}}var $T=eo(Ba,{representation:{id:"effect/schema/BigDecimal",payload:null},toCode:()=>({runtime:"Schema.BigDecimal",Type:"BigDecimal.BigDecimal",importDeclarations:['import * as BigDecimal from "effect/BigDecimal"']}),expected:"BigDecimal",toCodecJson:()=>pt()(EB,oI),toArbitrary:()=>(e,t)=>{let n=t.constraint?.ordered?.order===ji?t.constraint.ordered:void 0;return n===void 0?e.tuple(e.bigInt(),e.integer({min:0,max:bB})).map(([r,o])=>sr(r,o)):e.integer(fQ(n)).chain(r=>{let o=ET(n,r);if(o===void 0)throw new globalThis.Error(wB);return e.bigInt(o).map(s=>sr(s,r))})},toFormatter:()=>e=>Zs(e),toEquivalence:()=>ib}),lQ=pr("effect/schema/BigDecimal",$T),dQ=EB.pipe(Ee($T,oI)),pQ=fe.annotate({expected:"a string that will be decoded as JSON",contentMediaType:"application/json"});function IB(e,t){return pQ.pipe(Ee(e,CU(t)))}var mQ=IB(TT),qT=Sc(globalThis.File,{representation:{id:"effect/schema/File",payload:null},toCode:()=>({runtime:"Schema.File",Type:"globalThis.File"}),expected:"File",toCodecJson:()=>pt()(oe({data:fe.check(PT()),type:fe,name:fe,lastModified:js}),Ar({decode:(e,t)=>Oo(bf(e.data),{onFailure:()=>G(new ke({expected:"a valid Base64 string"},e.data,t)),onSuccess:n=>{let r=new globalThis.Uint8Array(n);return v(new globalThis.File([r],e.name,{type:e.type,lastModified:e.lastModified}))}}),encode:(e,t)=>ys({try:async()=>{let n=new globalThis.Uint8Array(await e.arrayBuffer());return{data:Zh(n),type:e.type,name:e.name,lastModified:e.lastModified}},catch:()=>new ke({expected:"a readable File"},e,t)})}))}),hQ=pr("effect/schema/File",qT),zT=Sc(globalThis.FormData,{representation:{id:"effect/schema/FormData",payload:null},toCode:()=>({runtime:"Schema.FormData",Type:"globalThis.FormData"}),expected:"FormData",toCodecJson:()=>pt()(Wt(mc([fe,He([oe({_tag:Ze("String"),value:fe}),oe({_tag:Ze("File"),value:qT})])])),Ar({decode:e=>{let t=new globalThis.FormData;for(let[n,r]of e)t.append(n,r.value);return v(t)},encode:e=>v(globalThis.Array.from(e.entries()).map(([t,n])=>typeof n=="string"?[t,{_tag:"String",value:n}]:[t,{_tag:"File",value:n}]))}))}),gQ=pr("effect/schema/FormData",zT);function xQ(e){return zT.pipe(Ee(e,AU))}var HT=Sc(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},toCode:()=>({runtime:"Schema.URLSearchParams",Type:"globalThis.URLSearchParams"}),expected:"URLSearchParams",toCodecJson:()=>pt()(fe.annotate({expected:"a query string that will be decoded as URLSearchParams"}),vt({decode:e=>new globalThis.URLSearchParams(e),encode:e=>e.toString()}))}),yQ=pr("effect/schema/URLSearchParams",HT);function SQ(e){return HT.pipe(Ee(e,OU))}var EQ=fe.annotate({expected:"a string that will be decoded as a number"}).pipe(Ee($l,cl)),bQ=fe.annotate({expected:"a string that will be decoded as a finite number"}).pipe(Ee(Ls,cl)),wQ=re(HI).pipe(Ee(bi,Mx)),vB=fe.check(MT()),IQ=fe.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(Ee(vB,cU())),vQ=fe.annotate({expected:"a base64 encoded string that will be decoded as a UTF-8 string"}).pipe(Ee(fe,IU)),TQ=fe.annotate({expected:"a base64 (URL) encoded string that will be decoded as a UTF-8 string"}).pipe(Ee(fe,vU)),kQ=fe.annotate({expected:"a hex encoded string that will be decoded as a UTF-8 string"}).pipe(Ee(fe,TU)),CQ=fe.annotate({expected:"a URI component encoded string that will be decoded as a UTF-8 string"}).pipe(Ee(fe,kU)),bT=He([Ls,eL,fe]),AQ=oe({issues:Wt(oe({message:fe,path:Pt(Wt(He([bT,oe({key:bT})])))}))}),OQ=Ea([0,1]).pipe(Ee(xc,vt({decode:e=>e===1,encode:e=>e?1:0}))),TB=fe.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),Vo=Sc(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},toCode:()=>({runtime:"Schema.Uint8Array",Type:"globalThis.Uint8Array"}),expected:"Uint8Array",toCodecJson:()=>pt()(TB,sI),toArbitrary:()=>e=>e.uint8Array()}),RQ=pr("effect/schema/Uint8Array",Vo),_Q=TB.pipe(Ee(Vo,sI)),MQ=fe.annotate({expected:"a base64 (URL) encoded string that will be decoded as a Uint8Array"}).pipe(Ee(Vo,{decode:ZF(),encode:Cx()})),PQ=fe.annotate({expected:"a hex encoded string that will be decoded as a Uint8Array"}).pipe(Ee(Vo,{decode:YF(),encode:Ax()})),bm=eo(e=>wu(e)&&PF(e),{representation:{id:"effect/schema/DateTimeUtc",payload:null},toCode:()=>({runtime:"Schema.DateTimeUtc",Type:"DateTime.Utc",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Utc",toCodecJson:()=>pt()(fe,cI),toArbitrary:()=>(e,t)=>e.date(jT(t?.constraint?.ordered?.order===Jw?t.constraint.ordered:void 0,{noInvalidDate:!0},Ix)).map(n=>UF(n)),toFormatter:()=>e=>e.toString(),toEquivalence:()=>Vw}),FQ=pr("effect/schema/DateTimeUtc",bm),UQ=Bs.pipe(Ee(bm,{decode:tI(),encode:De(Ix)})),DQ=fe.annotate({expected:"a string that will be decoded as a DateTime.Utc"}).pipe(Ee(bm,cI)),NQ=js.pipe(Ee(bm,{decode:tI(),encode:De(jF)})),kB=eo(_F,{representation:{id:"effect/schema/TimeZoneOffset",payload:null},toCode:()=>({runtime:"Schema.TimeZoneOffset",Type:"DateTime.TimeZone.Offset",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Offset",toCodecJson:()=>pt()(js,RU),toArbitrary:()=>e=>e.integer({min:-720*60*1e3,max:840*60*1e3}).map(t=>xp(t)),toFormatter:()=>e=>nc(e),toEquivalence:()=>(e,t)=>e.offset===t.offset}),LQ=pr("effect/schema/TimeZoneOffset",kB),CB=fe.annotate({expected:"an IANA time zone identifier"}),WT=eo(MF,{representation:{id:"effect/schema/TimeZoneNamed",payload:null},toCode:()=>({runtime:"Schema.TimeZoneNamed",Type:"DateTime.TimeZone.Named",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Named",toCodecJson:()=>pt()(CB,iI),toArbitrary:()=>e=>e.constantFrom(...["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"].map(Gw)),toFormatter:()=>e=>nc(e),toEquivalence:()=>(e,t)=>e.id===t.id}),BQ=pr("effect/schema/TimeZoneNamed",WT),jQ=CB.pipe(Ee(WT,iI)),AB=fe.annotate({expected:"a time zone string (IANA identifier or offset like +03:00)"}),KT=eo(RF,{representation:{id:"effect/schema/TimeZone",payload:null},toCode:()=>({runtime:"Schema.TimeZone",Type:"DateTime.TimeZone",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone",toCodecJson:()=>pt()(AB,aI),toArbitrary:()=>e=>e.oneof(e.integer({min:-720*60*1e3,max:840*60*1e3}).map(t=>xp(t)),e.constantFrom(...["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"].map(Gw))),toFormatter:()=>e=>nc(e),toEquivalence:()=>(e,t)=>nc(e)===nc(t)}),$Q=pr("effect/schema/TimeZone",KT),qQ=AB.pipe(Ee(KT,aI)),OB=fe.annotate({expected:"a zoned DateTime string (e.g. 2024-01-01T00:00:00.000+00:00[Europe/London])"}),VT=eo(e=>wu(e)&&FF(e),{representation:{id:"effect/schema/DateTimeZoned",payload:null},toCode:()=>({runtime:"Schema.DateTimeZoned",Type:"DateTime.Zoned",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Zoned",toCodecJson:()=>pt()(OB,uI),toArbitrary:()=>(e,t)=>e.tuple(e.date(jT(t?.constraint?.ordered?.order===Jw?t.constraint.ordered:void 0,{max:new globalThis.Date(864e13-840*60*1e3),min:new globalThis.Date(-864e13+840*60*1e3),noInvalidDate:!0},Ix)),e.constantFrom("UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney")).map(([n,r])=>Ex(n,{timeZone:r})),toFormatter:()=>e=>vx(e),toEquivalence:()=>Vw}),zQ=pr("effect/schema/DateTimeZoned",VT),HQ=OB.pipe(Ee(VT,uI)),WQ=globalThis.Symbol.for("immer-draftable"),wT={};function JT(e,t,n,r,o){let s=VQ(n,t,r),i=RB(t),a=class extends e{constructor(...[c,u]){let l=u?.["~payload"],p=l?.token===wT?l.value:n.make(c??{},u);super(p,{...u,disableChecks:!0,"~payload":{token:wT,value:p}})}static[um]=um;get[i](){return i}static[WQ]=!0;static identifier=t;static fields=n.fields;static get ast(){return s(this).ast}static pipe(){return ie(this,arguments)}static rebuild(c){return s(this).rebuild(c)}static make(c,u){return new this(c,u)}static makeOption(c,u){return jy(s(this))(c??{},u)}static makeEffect(c,u){return s(this).makeEffect(c??{},u)}static annotate(c){return this.rebuild(qo(this.ast,c))}static annotateKey(c){return this.rebuild(ml(this.ast,c))}static check(...c){return this.rebuild(hi(this.ast,c))}static extend(c){return(u,f)=>{let l=wm(u)?u:oe(u),p={...n.fields,...l.fields},m=jx(p,n.ast.checks,{identifier:c});return JT(this,c,CT(hi(m,l.ast.checks),p),f,o)}}static mapFields(c,u){return n.mapFields(c,u)}};return o!==void 0&&Object.assign(a.prototype,o(t)),a}function KQ(e){return new et(De(t=>new e(t,{"~payload":{token:wT,value:t}})),Is())}function RB(e){return`~effect/Schema/Class/${e}`}function VQ(e,t,n){let r;return o=>{if(r!==void 0)return r;let s=RB(t),i=u=>u instanceof o||B(u,s),a=KQ(o),c=re(new aa([e.ast],()=>(u,f,l)=>i(u)?v(u):G(new st(f,u,l)),{identifier:t,[px]:([u])=>({isConstructed:i,link:new Dt(u,a)}),toCodec:([u])=>new Dt(u.ast,a),toArbitrary:([u])=>()=>({arbitrary:u.arbitrary.map(f=>new o(f)),terminal:u.terminal?.map(f=>new o(f))}),toFormatter:([u])=>f=>`${o.identifier}(${u(f)})`,[dp]:oc(e.ast),...n}));return r=Ee(c,a)(e)}}function wm(e){return zu(e)}var cS=e=>(t,n)=>{let r=wm(t)?t:oe(t);return JT(QO,e,r,n,o=>({toString(){return`${o}(${X({...this})})`}}))},JQ=e=>(t,n,r)=>{let o=wm(n)?n.mapFields(s=>({_tag:Ze(t),...s}),{unsafePreserveChecks:!0}):yc(t,n);return cS(e??t)(o,r)},qn=e=>(t,n)=>{let r=wm(t)?t:oe(t);return JT(bd,e,r,n,s=>({name:s}))},GT=e=>(t,n,r)=>{let o=wm(n)?n.mapFields(s=>({_tag:Ze(t),...s}),{unsafePreserveChecks:!0}):yc(t,n);return qn(e??t)(o,r)};function GQ(e){let t=QN(e.ast);return n=>t(n,{})}function ZQ(e){return t=>t.annotate({toFormatter:e})}function QQ(e,t){return n(e.ast);function n(o){let s=di(o)?.toFormatter;if(typeof s=="function")return s(ic(o)?o.typeParameters.map(n):[]);if(t?.onBefore){let i=t.onBefore(o,n);if(i!==void 0)return i}return r(o)}function r(o){switch(o._tag){default:return X;case"Never":return()=>"never";case"Void":return()=>"void";case"Arrays":{let s=o.elements.map(n),i=o.rest.map(n);return a=>{let c=[],u=0;for(;u<s.length;u++)if(a.length<u+1){if(an(o.elements[u]))continue}else c.push(s[u](a[u]));if(i.length>0){let[f,...l]=i;for(;u<a.length-l.length;u++)c.push(f(a[u]));for(let p=0;p<l.length;p++)c.push(l[p](a[u+p]))}return"["+c.join(", ")+"]"}}case"Objects":{let s=o.propertySignatures.map(a=>n(a.type)),i=o.indexSignatures.map(a=>n(a.type));return o.propertySignatures.length===0&&o.indexSignatures.length===0?X:a=>{let c=[],u=new Set;for(let f=0;f<s.length;f++){let l=o.propertySignatures[f],p=l.name;u.add(p),!(an(l.type)&&!Object.hasOwn(a,p))&&c.push(`${Ui(p)}: ${s[f](a[p])}`)}for(let f=0;f<i.length;f++){let l=ua(a,o.indexSignatures[f].parameter);for(let p of l)u.has(p)||(u.add(p),c.push(`${Ui(p)}: ${i[f](a[p])}`))}return c.length>0?"{ "+c.join(", ")+" }":"{}"}}case"Union":{let s=yn(o).types,i=c=>Cp(c,s),a=new Map(s.map((c,u)=>[c,[em(c),n(o.types[u])]]));return c=>{let u=i(c);for(let f=0;f<u.length;f++){let[l,p]=a.get(u[f]);if(l(c))return p(c)}return X(c)}}case"Suspend":{let s=Tu(()=>n(o.thunk()));return i=>s()(i)}}}}function YQ(e){return t=>t.annotate({toEquivalence:e})}function XQ(e){return YN(e.ast)}function e7(e,t){return pT(e.ast,t)}function _B(e,t){let n=pT(uS(e.ast),t);return p2(n,t)}function Ec(e){return re(uS(e.ast),{schema:e})}var uS=fa(e=>{let t=n7(e,uS),n=e.context;return t===e||n===void 0?t:pl(t,ZT(n))});function ZT(e){return e.constructorDefault===void 0?e:new Zr(e.isOptional,e.isMutable,void 0,e.annotations)}function MB(e){if(e.propertySignatures.some(t=>typeof t.name!="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function PB(e){return t=>{let n=new Map;for(let s=0;s<t.length;s++)n.set(jn(t[s]),s);let r=[...t].sort((s,i)=>{s=jn(s),i=jn(i);let a=e(s),c=e(i);return a!==c?a-c:n.get(s)-n.get(i)});return r.some((s,i)=>s!==t[i])?r:t}}var t7=PB(e=>{switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function n7(e,t){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!cn(n))return lt(e,[KI]);let r=e.typeParameters.map(s=>nm(jn(s))),o=n(r);return o===void 0?e:lt(e,[ac(o,t)])}case"Unknown":return lt(e,[KI]);case"ObjectKeyword":return lt(e,[y1]);case"Undefined":case"Void":case"Literal":case"Number":return e.toCodecJson();case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return MB(e),e.recur(t,Gx);case"Union":{let n=t7(e.types);return n!==e.types?new Or(n,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t):e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}function FB(e){return re(UB(yn(e.ast)))}var UB=wn(e=>{let t=r7(e,UB);return t!==e&&e.context!==void 0?pl(t,ZT(e.context)):t});function r7(e,t){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecIso??e.annotations?.toCodec;if(cn(n)){let r=n(e.typeParameters.map(o=>nm(o)));return lt(e,[ac(r,t)])}return e}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(t)}return e}function DB(e){return re(BB(e.ast),{schema:e})}function o7(e){return re(jB(e.ast))}function s7(e,t){let n=rl(e.ast)??$w(e.ast),r=tS(DB(e));return o=>r(o).pipe(Y(s=>i7(s,{rootName:n,...t})))}function i7(e,t){let n=t.rootName??"root",r=t.arrayItemName??"item",o=t.pretty??!0,s=t.indent??" ",i=t.sortKeys??!0,a=new Set,c=[];return f(n,e,0),c.join(o?`
|
|
31
|
-
`:"");function u(l,p){c.push(o?s.repeat(l)+p:p)}function f(l,p,m,h){let{attrs:g,safe:x}=Fl.tagInfo(l,h);if(p===void 0)u(m,`<${x}${g}/>`);else if(typeof p=="string")u(m,`<${x}${g}>${Fl.escapeText(p)}</${x}>`);else if(typeof p!="object"||p===null)u(m,`<${x}${g}>${Fl.escapeText(X(p))}</${x}>`);else{if(a.has(p))throw new globalThis.Error("Cycle detected while serializing to XML.",{cause:p});a.add(p);try{if(globalThis.globalThis.Array.isArray(p)){if(p.length===0){u(m,`<${x}${g}/>`);return}u(m,`<${x}${g}>`);for(let y of p)f(r,y,m+1);u(m,`</${x}>`);return}let b=p,E=Object.keys(b);if(i&&E.sort(),E.length===0){u(m,`<${x}${g}/>`);return}u(m,`<${x}${g}>`);for(let y of E)f(Fl.parseTagName(y).safe,b[y],m+1,y);u(m,`</${x}>`)}finally{a.delete(p)}}}}var Fl={escapeText(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")},escapeAttribute(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")},parseTagName(e){let t=e,n=e;return/^[A-Za-z_]/.test(n)||(n="_"+n),n=n.replace(/[^A-Za-z0-9._-]/g,"_"),/^xml/i.test(n)&&(n="_"+n),{safe:n,changed:n!==t}},tagInfo(e,t){let{changed:n,safe:r}=Fl.parseTagName(e),s=n||t&&t!==e?` data-name="${Fl.escapeAttribute(t??e)}"`:"";return{safe:r,attrs:s}}},a7=PB(e=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function c7(e,t,n){switch(e._tag){case"Declaration":{let r=e.typeParameters.map(u=>re(t(jn(u)))),o=e.annotations?.toCodecStringTree;if(cn(o)){let u=o(r);return u===void 0?e:lt(e,[ac(u,t)])}let s=e.annotations?.toCodecJson,i=cn(s)?s(r):void 0,a=i===void 0?e.annotations?.toCodec:void 0,c=i??(cn(a)?a(r):void 0);return c===void 0?n(e):lt(e,[ac(c,t)])}case"Null":return lt(e,[u7]);case"Boolean":return lt(e,[f7]);case"Unknown":case"ObjectKeyword":return lt(e,[VI]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return MB(e),e.recur(t,Gx);case"Union":{let r=a7(e.types);return r!==e.types?new Or(r,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t):e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}var u7=new Dt(new Gr("null"),new et(De(()=>null),De(()=>"null"))),f7=new Dt(new Or([new Gr("true"),new Gr("false")],"anyOf"),new et(De(e=>e==="true"),Iu())),NB=new et(De(e=>typeof e=="string"?[e]:e),Is()),LB=e=>e.transformation===NB,BB=fa(e=>{let t=c7(e,BB,n=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:n})});return t!==e&&e.context!==void 0?pl(t,ZT(e.context)):t},{stopAt:LB}),B2=e=>an(e)?hl(ca):ca,jB=fa(e=>{let t=l7(e);if(OI(t)){let n=Vx(new Or([new Ts(t.isMutable,t.elements.map(B2),t.rest.map(B2)),mi],"anyOf"),t,NB);return an(e)?hl(n):n}return t},{stopAt:LB});function l7(e){return e._tag==="Declaration"||e._tag==="Arrays"||e._tag==="Objects"||e._tag==="Union"||e._tag==="Suspend"?e.recur(jB):e}var d7=Oe("effect/schema/isGreaterThanDate",oe({exclusiveMinimum:Bs}),({annotations:e,payload:t})=>FL(t.exclusiveMinimum,e)),p7=Oe("effect/schema/isGreaterThanOrEqualToDate",oe({minimum:Bs}),({annotations:e,payload:t})=>UL(t.minimum,e)),m7=Oe("effect/schema/isLessThanDate",oe({exclusiveMaximum:Bs}),({annotations:e,payload:t})=>DL(t.exclusiveMaximum,e)),h7=Oe("effect/schema/isLessThanOrEqualToDate",oe({maximum:Bs}),({annotations:e,payload:t})=>NL(t.maximum,e)),g7=Oe("effect/schema/isBetweenDate",oe({minimum:Bs,maximum:Bs,exclusiveMinimum:Pt(Ot(!0)),exclusiveMaximum:Pt(Ot(!0))}),({annotations:e,payload:t})=>LL(t,e)),x7=Oe("effect/schema/isGreaterThanBigInt",oe({exclusiveMinimum:bi}),({annotations:e,payload:t})=>BL(t.exclusiveMinimum,e)),y7=Oe("effect/schema/isGreaterThanOrEqualToBigInt",oe({minimum:bi}),({annotations:e,payload:t})=>jL(t.minimum,e)),S7=Oe("effect/schema/isLessThanBigInt",oe({exclusiveMaximum:bi}),({annotations:e,payload:t})=>$L(t.exclusiveMaximum,e)),E7=Oe("effect/schema/isLessThanOrEqualToBigInt",oe({maximum:bi}),({annotations:e,payload:t})=>qL(t.maximum,e)),b7=Oe("effect/schema/isBetweenBigInt",oe({minimum:bi,maximum:bi,exclusiveMinimum:Pt(Ot(!0)),exclusiveMaximum:Pt(Ot(!0))}),({annotations:e,payload:t})=>zL(t,e));function w7(e){let t=FB(e);return b2(rT(t),tT(t))}function I7(e){return Zy()}function v7(e){return Zy()}function T7(e,t){return n=>re(qo(n.ast,{toCodecIso:()=>new Dt(e.ast,Rx(t))}),{schema:n})}function k7(e){let t=Ec(e),n=rT(t),r=tT(t);return{empty:[],diff:(o,s)=>h2(n(o),n(s)),combine:(o,s)=>[...o,...s],patch:(o,s)=>{let i=n(o),a=g2(s,i);return Object.is(a,i)?o:r(a)}}}function C7(e){let t=oL(()=>n),n=He([e,Wt(t),AT(fe,t)]);return n}var Im=re(qo(dl,{toCode:()=>({runtime:"Schema.Json",Type:"Schema.Json"})})),A7=AT(fe,Im),O7=pr("effect/schema/Json",Im),R7=oe({message:fe,name:qu(fe),stack:qu(fe),cause:qu(Im)}),$B=re(qo(x1,{toCode:()=>({runtime:"Schema.MutableJson",Type:"Schema.MutableJson"})})),_7=pr("effect/schema/MutableJson",$B);function M7(e){return di(e.ast)}function P7(e){return e.ast.context?.annotations}var F7="~effect/Stream",U7={_R:L,_E:L,_A:L},D7={[F7]:U7,pipe(){return ie(this,arguments)}},qB=e=>{let t=Object.create(D7);return t.channel=e,t};var L7="~effect/Sink";var B7={_A:L,_In:L,_L:L,_E:L,_R:L},j7={[L7]:B7,pipe(){return ie(this,arguments)}};var $7=e=>{let t=Object.create(j7);return t.transform=e,t},zB=e=>Ge((t,n)=>v(A(e.transform(t,n),pe)));var HB=e=>$7(t=>{let n=[];if(e<=0)return v([n]);let r;return t.pipe(A(o=>{if(n.length+o.length<=e)return n.push(...o),n.length===e?pe():H;for(let s=0;s<o.length;s++)if(n.push(o[s]),n.length===e)return s+1<o.length&&(r=o.slice(s+1)),pe();return H}),Ht({disableYield:!0}),$t(()=>v([n,r])))});var nr={};Hs(nr,{DefaultChunkSize:()=>nj,Do:()=>yX,TypeId:()=>tj,accumulate:()=>oX,aggregate:()=>ZY,aggregateWithin:()=>lk,bind:()=>EX,bindEffect:()=>bX,bindTo:()=>wX,broadcast:()=>Aj,broadcastN:()=>QY,buffer:()=>iY,bufferArray:()=>aY,callback:()=>lS,catch:()=>km,catchCause:()=>pj,catchCauseFilter:()=>mY,catchCauseIf:()=>pY,catchFilter:()=>gj,catchIf:()=>hj,catchReason:()=>lY,catchReasons:()=>dY,catchTag:()=>uY,catchTags:()=>fY,changes:()=>Oj,changesWith:()=>Rj,changesWithEffect:()=>sX,chunks:()=>Ij,collect:()=>rX,combine:()=>PY,combineArray:()=>FY,concat:()=>vm,cross:()=>j9,crossWith:()=>lj,debounce:()=>jY,decodeText:()=>iX,die:()=>n9,drain:()=>k9,drainFork:()=>C9,drop:()=>fk,dropRight:()=>RY,dropUntil:()=>CY,dropUntilEffect:()=>AY,dropWhile:()=>bj,dropWhileEffect:()=>wj,dropWhileFilter:()=>OY,empty:()=>vi,encodeText:()=>aX,ensuring:()=>Cm,fail:()=>Ku,failCause:()=>sj,failCauseSync:()=>r9,failSync:()=>t9,filter:()=>ck,filterEffect:()=>eY,filterMap:()=>X9,filterMapEffect:()=>tY,flatMap:()=>Hl,flatten:()=>ok,flattenArray:()=>T9,flattenEffect:()=>S9,flattenIterable:()=>P9,flattenTake:()=>F9,forever:()=>M9,fromArray:()=>Tm,fromArrayEffect:()=>a9,fromArrays:()=>c9,fromAsyncIterable:()=>u9,fromChannel:()=>$,fromEffect:()=>fS,fromEffectDrain:()=>rj,fromEffectRepeat:()=>oj,fromEffectSchedule:()=>Q7,fromEventListener:()=>d9,fromIterable:()=>Vu,fromIterableEffect:()=>s9,fromIterableEffectRepeat:()=>i9,fromIteratorSucceed:()=>o9,fromPubSub:()=>nk,fromPubSubTake:()=>ij,fromPull:()=>$s,fromQueue:()=>Ii,fromReadableStream:()=>rk,fromSchedule:()=>f9,fromSubscription:()=>l9,groupAdjacentBy:()=>JY,groupBy:()=>KY,groupByKey:()=>VY,grouped:()=>HY,groupedWithin:()=>WY,haltWhen:()=>dX,ignore:()=>yY,ignoreCause:()=>SY,interleave:()=>fX,interleaveWith:()=>Mj,interruptWhen:()=>lX,intersperse:()=>_j,intersperseAffixes:()=>uX,isStream:()=>Ue,iterate:()=>m9,let:()=>SX,limitBytes:()=>IY,make:()=>X7,map:()=>So,mapAccum:()=>UY,mapAccumArray:()=>Gu,mapAccumArrayEffect:()=>NY,mapAccumEffect:()=>DY,mapArray:()=>cj,mapArrayEffect:()=>E9,mapBoth:()=>y9,mapEffect:()=>Ju,mapError:()=>xj,merge:()=>sk,mergeAll:()=>B9,mergeEffect:()=>dS,mergeLeft:()=>N9,mergeResult:()=>D9,mergeRight:()=>L9,mkArrayBuffer:()=>MX,mkString:()=>_X,mkUint8Array:()=>PX,never:()=>g9,onEnd:()=>mX,onError:()=>pX,onExit:()=>Pj,onFirst:()=>Uj,onStart:()=>Fj,orDie:()=>xY,orElseIfEmpty:()=>hY,orElseSucceed:()=>gY,paginate:()=>p9,partition:()=>rY,partitionEffect:()=>nY,partitionQueue:()=>uk,peel:()=>sY,pipeThrough:()=>nX,pipeThroughChannel:()=>eX,pipeThroughChannelOrFail:()=>tX,prepend:()=>U9,provide:()=>Dj,provideContext:()=>dk,provideService:()=>hX,provideServiceEffect:()=>pk,race:()=>Y9,raceAll:()=>dj,range:()=>h9,rechunk:()=>vj,repeat:()=>A9,repeatElements:()=>_9,result:()=>b9,retry:()=>EY,run:()=>Lj,runCollect:()=>Bj,runCount:()=>IX,runDrain:()=>mS,runFold:()=>TX,runFoldEffect:()=>kX,runForEach:()=>OX,runForEachArray:()=>Wl,runForEachWhile:()=>RX,runHead:()=>CX,runIntoPubSub:()=>NX,runIntoQueue:()=>jX,runLast:()=>AX,runSum:()=>vX,scan:()=>LY,scanEffect:()=>BY,schedule:()=>O9,scoped:()=>x9,service:()=>G7,serviceOption:()=>Z7,share:()=>XY,sliding:()=>_Y,slidingSize:()=>Tj,split:()=>MY,splitLines:()=>cX,succeed:()=>zl,suspend:()=>Fr,switchMap:()=>v9,sync:()=>e9,take:()=>wY,takeRight:()=>vY,takeUntil:()=>yj,takeUntilEffect:()=>Sj,takeWhile:()=>Ej,takeWhileEffect:()=>kY,takeWhileFilter:()=>TY,tap:()=>uj,tapBoth:()=>w9,tapCause:()=>cY,tapError:()=>mj,tapSink:()=>I9,throttle:()=>zY,throttleEffect:()=>kj,tick:()=>Y7,timeout:()=>R9,timeoutOrElse:()=>fj,toAsyncIterable:()=>DX,toAsyncIterableEffect:()=>UX,toAsyncIterableWith:()=>xk,toChannel:()=>Jo,toPubSub:()=>LX,toPubSubTake:()=>jj,toPull:()=>mk,toQueue:()=>BX,toReadableStream:()=>FX,toReadableStreamEffect:()=>gk,toReadableStreamWith:()=>hk,transduce:()=>GY,transformPull:()=>Sn,transformPullBracket:()=>tk,unfold:()=>aj,unwrap:()=>mr,updateContext:()=>Nj,updateService:()=>gX,when:()=>oY,withExecutionPlan:()=>bY,withSpan:()=>xX,zip:()=>q9,zipFlatten:()=>W9,zipLatest:()=>Z9,zipLatestAll:()=>ak,zipLatestWith:()=>Q9,zipLeft:()=>z9,zipRight:()=>H9,zipWith:()=>ik,zipWithArray:()=>pS,zipWithIndex:()=>K9,zipWithNext:()=>V9,zipWithPrevious:()=>J9,zipWithPreviousAndNext:()=>G9});var KB="~effect/RcMap",q7=e=>({[KB]:KB,lookup:e.lookup,context:e.context,scope:e.scope,idleTimeToLive:e.idleTimeToLive,capacity:e.capacity,state:{_tag:"Open",map:cc()},pipe(){return ie(this,arguments)}}),VB=e=>xn(t=>{let n=t.context,r=qe(n,It),o=q7({lookup:e.lookup,context:n,scope:r,idleTimeToLive:typeof e.idleTimeToLive=="function"?Fc(e.idleTimeToLive,gt):Qe(gt(e.idleTimeToLive??zi)),capacity:Math.max(e.capacity??Number.POSITIVE_INFINITY,0)});return zt(Fo(r,()=>{if(o.state._tag==="Closed")return H;let s=o.state.map;return o.state={_tag:"Closed"},Do(s,([,i])=>Wr(Je(i.scope,Vt))).pipe(Mt(()=>se(()=>{Zx(s)})))}),o)}),QT=d(2,(e,t)=>go(n=>{if(e.state._tag==="Closed")return ho;let r=e.state,o=xi(),s=As(r.map,t),i;if(s._tag==="Some")i=s.value,i.refCount++;else{if(Number.isFinite(e.capacity)&&b1(e.state.map)>=e.capacity)return G(new nP(`RcMap attempted to exceed capacity of ${e.capacity}`));{i={deferred:iu(),scope:$r(),idleTimeToLive:e.idleTimeToLive(t),finalizer:void 0,fiber:void 0,expiresAt:0,refCount:1},i.finalizer=z7(e,t,i),uc(r.map,t,i);let c=new Map(e.context.mapUnsafe);o.context.mapUnsafe.forEach((u,f)=>{c.set(f,u)}),c.set(It.key,i.scope),e.lookup(t).pipe(Ln(Ro(c)),da(i.scope)).addObserver(u=>qf(i.deferred,u))}}let a=Jn(o.context,It);return _t(a,i.finalizer).pipe(Dn(n(au(i.deferred))))}));var z7=(e,t,n)=>xn(r=>{if(n.refCount--,n.refCount>0)return H;if(e.state._tag==="Closed"||!E1(e.state.map,t)||Md(n.idleTimeToLive))return e.state._tag==="Open"&&ku(e.state.map,t),Je(n.scope,Vt);if(!as(n.idleTimeToLive))return H;let o=r.getRef(lu);return n.expiresAt=o.currentTimeMillisUnsafe()+Tn(n.idleTimeToLive),n.fiber?H:(n.fiber=Mw(function s(i){let a=o.currentTimeMillisUnsafe(),c=n.expiresAt-a;return c<=0?e.state._tag==="Closed"||n.refCount>0?H:(ku(e.state.map,t),i(Je(n.scope,Vt))):A(o.sleep(is(c)),()=>s(i))}).pipe(na(se(()=>{n.fiber=void 0})),Ln(r.context),da(e.scope)),H)});var YT=d(2,(e,t)=>xu(n=>{if(e.state._tag==="Closed")return H;let r=As(e.state.map,t);if(r._tag==="None"||Md(r.value.idleTimeToLive))return H;let o=r.value;return o.expiresAt=n.currentTimeMillisUnsafe()+Tn(o.idleTimeToLive),H}));var H7="~effect/RcRef",XT={_tag:"Empty"},W7={_tag:"Closed"},K7={_A:L,_E:L},ek=class{[H7]=K7;pipe(){return ie(this,arguments)}state=XT;semaphore=xa(1);acquire;context;scope;idleTimeToLive;constructor(t,n,r,o){this.acquire=t,this.context=n,this.scope=r,this.idleTimeToLive=o}},GB=e=>xn(t=>{let n=t.context,r=qe(n,It),o=new ek(e.acquire,n,r,e.idleTimeToLive?gt(e.idleTimeToLive):void 0);return zt(Fo(r,()=>{let s=o.state._tag==="Acquired"?Je(o.state.scope,Vt):H;return o.state=W7,s}),o)}),V7=e=>go(function t(n){switch(e.state._tag){case"Closed":return ho;case"Acquired":return e.state.refCount++,e.state.fiber?zt(yo(e.state.fiber),e.state):v(e.state);case"Empty":{let r=$r();return e.semaphore.withPermit(K(()=>e.state._tag!=="Empty"?t(n):n(Nn(e.acquire,Ve(e.context,It,r))).pipe(Y(o=>{let s={_tag:"Acquired",value:o,scope:r,fiber:void 0,refCount:1,invalidated:!1};return e.state=s,s}),ur(o=>ri(o)?Je(r,o):H))))}}}),ZB=ye(function*(e){let t=e,n=yield*V7(t),r=yield*jo,o=t.idleTimeToLive!==void 0&&as(t.idleTimeToLive);return yield*Fo(r,()=>(n.refCount--,n.refCount>0?H:t.idleTimeToLive===void 0?(t.state=XT,Je(n.scope,Vt)):n.invalidated?Je(n.scope,Vt):o?(n.fiber=Qa(t.idleTimeToLive).pipe(A(()=>t.state._tag==="Acquired"&&t.state.refCount===0?(t.state=XT,Je(n.scope,Vt)):H),na(se(()=>{n.fiber=void 0})),Ln(t.context),da(t.scope)),H):H)),n.value});var QB=GB,YB=ZB;var tj="~effect/Stream",Ue=e=>B(e,tj),nj=Hp,$=qB,fS=e=>$(Sy(Y(e,Ne))),G7=e=>fS(Ow(e)),Z7=e=>fS(hu(e)),rj=e=>$s(v(A(e,()=>pe()))),oj=e=>$s(v(Y(e,Ne))),Q7=(e,t)=>$s(qt(function*(){let n=yield*xs(t),r=yield*Bo(e,Un,Un.defaultValue()),o=!0,s=K(()=>n(r)).pipe(A(i=>Bo(e,Un,i)),Y(i=>(r=i,Ne(i))));return K(()=>o?(o=!1,v(Ne(r))):s)})),Y7=e=>$s(se(()=>{let t=!0,n=v(Ne(void 0)),r=ta(n,e);return K(()=>t?(t=!1,n):r)})),$s=e=>$($n(e)),Sn=(e,t)=>$(Ge((n,r)=>A(Ho(e.channel,r),o=>t(o,r)))),tk=(e,t)=>$(Ps((n,r,o)=>A(Ho(e.channel,r),s=>t(s,r,o)))),Jo=e=>e.channel,lS=(e,t)=>$(H1(e,t)),vi=$(vl),zl=e=>$(yy(Ne(e))),X7=(...e)=>Tm(e),e9=e=>$(K1(()=>Ne(e()))),Fr=e=>$(xy(()=>e().channel)),Ku=e=>$(Si(e)),t9=e=>$(J1(e)),sj=e=>$(Wp(e)),n9=e=>$(Tv(e)),r9=e=>$(G1(e)),o9=(e,t)=>$(vv(()=>e,t)),Vu=(e,t)=>Array.isArray(e)&&t?.chunkSize===void 0?Tm(e):$(W1(e,t?.chunkSize)),s9=e=>mr(Y(e,Vu)),i9=e=>Hl(oj(e),Vu),Tm=e=>Ye(e)?$(yy(e)):vi,a9=e=>mr(Y(e,Tm)),c9=(...e)=>$(Iv($h(e,Ye))),Ii=e=>$(Q1(e)),nk=e=>$(Y1(e)),ij=e=>$(X1(e)),rk=e=>$(eD(e)),u9=(e,t)=>$(tD(e,t)),f9=e=>$s(Y(Kf(e),t=>$t(Y(t(void 0),Ne),()=>pe()))),l9=e=>$(Cv(e)),d9=(e,t,n)=>lS(r=>{function o(s){wl(r,s)}return Xa(se(()=>e.addEventListener(t,o,n)),()=>se(()=>e.removeEventListener(t,o,n)))},{bufferSize:typeof n=="object"?n.bufferSize:void 0}),aj=(e,t)=>$s(se(()=>{let n=e;return A(K(()=>t(n)),r=>r===void 0?pe():(n=r[1],v(Ne(r[0]))))})),p9=(e,t)=>$s(se(()=>{let n=e,r=!1;return K(function o(){return r?pe():A(t(n),([s,i])=>(ge(i)?r=!0:n=i.value,Ye(s)?v(s):o()))})})),m9=(e,t)=>aj(e,n=>v([n,t(n)])),h9=(e,t,n=Hp)=>e>t?vi:$s(se(()=>{let r=Math.max(1,n),o=e,s=!1;return K(()=>{if(s)return pe();let i=t-o+1;if(i>r){let c=tb(o,o+r-1);return o+=r,v(c)}let a=tb(o,o+i-1);return s=!0,v(a)})})),g9=$(V1),mr=e=>$(ya(Y(e,Jo))),x9=e=>$(RD(e.channel)),So=d(2,(e,t)=>Fr(()=>{let n=0;return $(Fs(e.channel,os(r=>t(r,n++))))})),y9=d(2,(e,t)=>e.pipe(So(t.onSuccess),xj(t.onFailure))),cj=d(2,(e,t)=>$(Fs(e.channel,t))),Ju=d(e=>Ue(e[0]),(e,t,n)=>e.channel.pipe(lr,Ey(t,n),Fs(Ne),$)),S9=d(e=>Ue(e[0]),(e,t)=>Ju(e,L,t)),E9=d(2,(e,t)=>$(Ey(e.channel,t))),b9=e=>e.pipe(So(Ce),km(t=>zl(Ae(t)))),uj=d(e=>Ue(e[0]),(e,t,n)=>Ju(e,r=>zt(t(r),r),n)),w9=d(2,(e,t)=>e.pipe(mj(t.onError),uj(t.onElement,{concurrency:t.concurrency}))),I9=d(2,(e,t)=>tk(e,ye(function*(n,r,o){let s=fr(),i=fr(),a,c,u=!1,f=!1,l=s.whenOpen(K(()=>{if(a){let m=a;return a=void 0,f||s.closeUnsafe(),zt(i.open,m)}return pe()}));yield*K(()=>t.transform(l,o)).pipe(m=>_w(m,h=>(u=!0,ri(h)&&(c=h.cause),i.open),!0),Ut(o));let p=n.pipe(A(m=>(a=m,i.closeUnsafe(),s.openUnsafe(),zt(i.await,m))),$t(()=>(f=!0,i.closeUnsafe(),s.openUnsafe(),A(i.await,()=>pe()))));return K(()=>c?ct(c):u?n:p)}))),Hl=d(e=>Ue(e[0]),(e,t,n)=>e.channel.pipe(lr,oD(r=>t(r).channel,n),$)),v9=d(e=>Ue(e[0]),(e,t,n)=>e.channel.pipe(lr,CD(r=>t(r).channel,n),$)),ok=d(e=>Ue(e[0]),(e,t)=>Hl(e,L,t)),T9=e=>$(lr(e.channel)),k9=e=>$(aD(e.channel)),C9=d(2,(e,t)=>dS(e,mS(t))),A9=d(2,(e,t)=>$(cD(e.channel,t))),O9=d(2,(e,t)=>e.channel.pipe(lr,uD(t),Fs(Ne),$)),R9=d(2,(e,t)=>fj(e,{duration:t,orElse:()=>vi})),fj=d(2,(e,t)=>{let n=gt(t.duration);if(!as(n))return e;if(Md(n))return Fr(t.orElse);let r=Symbol();return pj(Fr(()=>{let s=xi().getRef(lu),i=Tn(n),a,c=fr(!1);return sk(Sn(e,(u,f)=>K(()=>(a=s.currentTimeMillisUnsafe()+i,c.openUnsafe(),u)).pipe(Y(l=>(c.closeUnsafe(),a=void 0,l)),v)),rj(qt(function*(){for(;;)if(yield*c.await,!(a===void 0||(yield*Qa(a-s.currentTimeMillisUnsafe()),a===void 0)||a-s.currentTimeMillisUnsafe()>0))return yield*po(r)})),{haltStrategy:"left"})}),o=>o.reasons.find(i=>i._tag==="Die"&&i.defect===r)?t.orElse():sj(o))}),_9=d(2,(e,t)=>$(Ge((n,r)=>Y(Pe(lr(e.channel))(n,r),o=>{let s,i=qt(function*(){let a=yield*o,c=Ne(a);return s=(yield*Kf(t))(a).pipe(zt(c),$t(f=>(s=void 0,i))),c});return K(()=>s??i)})))),M9=e=>$(Ov(e.channel)),P9=e=>Hl(e,Vu),F9=e=>e.channel.pipe(lr,iD,$),vm=d(2,(e,t)=>ok(Tm([e,t]))),U9=d(2,(e,t)=>vm(Vu(t),e)),sk=d(e=>Ue(e[0])&&Ue(e[1]),(e,t,n)=>$(vy(Jo(e),Jo(t),n))),dS=d(2,(e,t)=>e.channel.pipe(AD(t),$)),D9=d(2,(e,t)=>sk(So(e,Ce),So(t,Ae))),N9=d(2,(e,t)=>dS(e,mS(t))),L9=d(2,(e,t)=>dS(t,mS(e))),B9=d(2,(e,t)=>ok(Vu(e),t)),j9=d(2,(e,t)=>lj(e,t,(n,r)=>[n,r])),lj=d(3,(e,t,n)=>Hl(e,r=>So(t,o=>n(r,o)))),ik=d(3,(e,t,n)=>pS(e,t,$9(n))),$9=e=>(t,n)=>{let r=Math.min(t.length,n.length),o=[];for(let s=0;s<r;s++)o.push(e(t[s],n[s]));return[o,t.slice(r),n.slice(r)]},pS=d(3,(e,t,n)=>$(Ps(ye(function*(r,o){let s=yield*Ho(e.channel,o),i=yield*Ho(t.channel,o),a=qt(function*(){let f=yield*Ut(s,o),l=yield*Ut(i,o);return yield*Xx([f,l])}),c={_tag:"PullBoth"};return qt(function*(){let[f,l]=c._tag==="PullBoth"?yield*a:c._tag==="PullLeft"?[yield*s,c.rightArray]:[c.leftArray,yield*i],p=n(f,l);return Ye(p[1])?c={_tag:"PullRight",leftArray:p[1]}:Ye(p[2])?c={_tag:"PullLeft",rightArray:p[2]}:c={_tag:"PullBoth"},p[0]})})))),q9=d(2,(e,t)=>ik(e,t,(n,r)=>[n,r])),z9=d(2,(e,t)=>pS(e,t,(n,r)=>{let o=Math.min(n.length,r.length),s=n.slice(0,o),i=n.slice(o),a=r.slice(o);return[s,i,a]})),H9=d(2,(e,t)=>pS(e,t,(n,r)=>{let o=Math.min(n.length,r.length),s=r.slice(0,o),i=n.slice(o),a=r.slice(o);return[s,i,a]})),W9=d(2,(e,t)=>ik(e,t,(n,r)=>[...n,r])),K9=e=>So(e,(t,n)=>[t,n]),V9=e=>Gu(e,U,(t,n)=>{let r=0;t._tag==="None"&&(r=1,t=N(n[0]));let o=rn();for(;r<n.length;r++){let s=t.value;t=N(n[r]),o.push([s,t])}return[t,o]},{onHalt(t){return t._tag==="Some"?[[t.value,U()]]:[]}}),J9=e=>Gu(e,U,(t,n)=>{let r=rn();for(let o=0;o<n.length;o++){let s=n[o];r.push([t,s]),t=N(n[o])}return[t,r]}),G9=e=>Gu(e,()=>({prev:U(),current:U()}),(t,n)=>{let r=0,o;t.current._tag==="None"?(r=1,o=n[0],t.current=N(o)):o=t.current.value;let s=rn();for(;r<n.length;r++){let i=n[r];t.current=N(i),s.push([t.prev,o,t.current]),t.prev=N(o),o=i}return[t,s]},{onHalt(t){return t.current._tag==="Some"?[[t.prev,t.current.value,U()]]:[]}}),ak=(...e)=>$(xy(()=>{let t=[],n=new Set,r=fr();return Iy(Iv(e.map((o,s)=>o.channel.pipe(lr,Ey(i=>(t[s]=i,n.has(s)?v(Ne(t.slice())):(n.add(s),n.size<e.length?r.await:zt(r.open,Ne(t.slice()))))),fD(Kn)))),{concurrency:"unbounded",bufferSize:0})})),Z9=d(2,(e,t)=>ak(e,t)),Q9=d(3,(e,t,n)=>So(ak(e,t),([r,o])=>n(r,o))),dj=(...e)=>$(Ge((t,n)=>se(()=>{let r,o=vw(e.map(s=>{let i=Cn(n);return Ho(s.channel,i).pipe(A(a=>yw(v(a),a)),ur(a=>a._tag==="Success"?r?Je(i,a):(r=a.value[0],H):Je(i,a)),Y(([,a])=>a))}));return K(()=>r??o)}))),Y9=d(2,(e,t)=>dj(e,t)),ck=d(2,(e,t)=>$(lD(Jo(e),t))),X9=d(2,(e,t)=>$(dD(Jo(e),t))),eY=d(2,(e,t)=>$(pD(Jo(e),t))),tY=d(2,(e,t)=>$(mD(Jo(e),t))),uk=d(e=>Ue(e[0]),ye(function*(e,t,n){let r=yield*jo,o=yield*Ho(e.channel,r),s=n?.capacity==="unbounded"?void 0:n?.capacity??nj,i=yield*Xr({capacity:s}),a=yield*Xr({capacity:s});return yield*qt(function*(){for(;;){let c=yield*o,u=[],f=[];for(let p=0;p<c.length;p++){let m=t(c[p]);Fe(m)?u.push(m.failure):f.push(m.success)}let l;if(f.length>0){let p=hy(i,f);p.length>0&&(l=yield*el(ga(i,p)))}if(u.length>0){let p=hy(a,u);p.length>0&&(yield*ga(a,p))}l&&(yield*yl(l))}}).pipe(mo(c=>(yi(i,c),yi(a,c),H)),Ut(r)),[i,a]})),nY=d(e=>Ue(e[0]),(e,t,n)=>Y(uk(Ju(e,r=>t(r),n),r=>r,n),([r,o])=>[Ii(r),Ii(o)])),rY=d(e=>Ue(e[0]),(e,t,n)=>Y(uk(e,t,{capacity:n?.bufferSize??16}),([r,o])=>[Ii(o),Ii(r)])),oY=d(2,(e,t)=>t.pipe(Y(n=>n?e:vi),mr)),sY=d(2,ye(function*(e,t){let n,r=yield*Dv(e.channel),o=ft(r,a=>(n=a,ct(a))),s=$s(v(o)),i=yield*Lj(s,t);return n?[i,vi]:(s=$s(v(r)),[i,s])})),iY=d(2,(e,t)=>$(MD(e.channel,t))),aY=d(2,(e,t)=>$(_D(e.channel,t))),pj=d(2,(e,t)=>e.channel.pipe(kl(n=>t(n).channel),$)),cY=d(2,(e,t)=>e.channel.pipe(wy(t),$)),km=d(2,(e,t)=>$(_s(e.channel,n=>t(n).channel)));var mj=d(2,(e,t)=>e.channel.pipe(xD(t),$)),hj=d(e=>Ue(e[0]),(e,t,n,r)=>$(yD(Jo(e),t,o=>n(o).channel,r&&(o=>r(o).channel)))),gj=d(e=>Ue(e[0]),(e,t,n,r)=>$(SD(Jo(e),t,o=>n(o).channel,r&&(o=>r(o).channel)))),uY=d(e=>Ue(e[0]),(e,t,n,r)=>{let o=Array.isArray(t)?s=>B(s,"_tag")&&t.includes(s._tag):yr(t);return hj(e,o,n,r)}),fY=d(e=>Ue(e[0]),(e,t,n)=>{let r;return gj(e,o=>(r??=Object.keys(t),B(o,"_tag")&&Qg(o._tag)&&r.includes(o._tag)?Ce(o):Ae(o)),o=>t[o._tag](o),n)}),lY=d(e=>Ue(e[0]),(e,t,n,r,o)=>$(ED(Jo(e),t,n,(s,i)=>r(s,i).channel,o&&((s,i)=>o(s,i).channel)))),dY=d(e=>Ue(e[0]),(e,t,n,r)=>{let o=Object.create(null);for(let i of Object.keys(n)){let a=n[i];o[i]=(c,u)=>a(c,u).channel}let s=r&&((i,a)=>r(i,a).channel);return $(bD(e.channel,t,o,s))}),xj=d(2,(e,t)=>$(wD(e.channel,t))),pY=d(3,(e,t,n)=>$(gD(e.channel,t,r=>n(r).channel))),mY=d(3,(e,t,n)=>$(Rv(e.channel,t,(r,o)=>n(r,o).channel))),hY=d(2,(e,t)=>$(sD(e.channel,n=>Jo(t())))),gY=d(2,(e,t)=>km(e,n=>zl(t(n)))),xY=e=>$(ID(e.channel)),yY=d(e=>Ue(e[0]),(e,t)=>$(vD(e.channel,t))),SY=d(e=>Ue(e[0]),(e,t)=>$(TD(e.channel,t))),EY=d(2,(e,t)=>$(kD(e.channel,t))),ej=(e,t)=>mr(Y(xs(t),n=>{let r=Un.defaultValue(),o=()=>km(pk(e,Un,se(()=>r)),s=>mr($t(Y(n(s),i=>(r=i,mr(zt(rp,o())))),()=>v(Ku(s)))));return o()})),bY=d(e=>Ue(e[0]),(e,t,n)=>Fr(()=>{let r=n?.preventFallbackOnPartialStream??!1,o=0,s={attempt:0,stepIndex:0},i=pk(Kg,se(()=>(s={attempt:s.attempt+1,stepIndex:o},s))),a=n?.onEvent===void 0?void 0:pw(n.onEvent,()=>s),c,u=a===void 0?L:p=>Pj(Fj(p,Y(a.begin,m=>{c=m})),m=>K(()=>{if(c===void 0)return H;let h=c;return c=void 0,a.end(h,m)})),f=U(),l=Fr(()=>{let p=t.steps[o];if(!p)return Ku(QE(f));let m=i(u(Dj(e,p.provide))),h=!1;if(Te(f)){let g=f.value,x=!1,b=m;m=Fr(()=>x?b:(x=!0,Ku(g))),m=ej(m,np(p,!1))}else{let g=np(p,!0);m=g?ej(m,g):m}return km(r?Uj(m,g=>(h=!0,H)):m,g=>(o++,r&&h?Ku(g):(f=N(g),l)))});return l})),wY=d(2,(e,t)=>t<1?vi:yj(e,(n,r)=>r===t-1)),IY=d(3,(e,t,n)=>Fr(()=>{let r=BigInt(t),o=BigInt(0),s=!1;return vm(Ej(e,i=>{let a=o+BigInt(i.length);return a>r?(s=!0,!1):(o=a,!0)}),Fr(()=>s?n():vi))})),vY=d(2,(e,t)=>Gu(e,ha,(n,r)=>(ey(n,r),n.length>t&&Lp(n,n.length-t),[n,ba]),{onHalt(n){return Au(n)}})),yj=d(e=>Ue(e[0]),(e,t,n)=>Sn(e,(r,o)=>se(()=>{let s=0,i=!1;return A(K(()=>i?pe():r),c=>{let u=c.findIndex(f=>t(f,s++));if(u>=0){i=!0;let f=c.slice(0,n?.excludeLast?u:u+1);return Ye(f)?v(f):pe()}return v(c)})}))),Sj=d(e=>Ue(e[0]),(e,t,n)=>Sn(e,(r,o)=>se(()=>{let s=0,i=!1;return qt(function*(){if(i)return yield*pe();let a=yield*r;for(let c=0;c<a.length;c++)if(yield*t(a[c],s++)){i=!0;let u=a.slice(0,n?.excludeLast?c:c+1);return Ye(u)?u:yield*pe()}return a})}))),Ej=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o=0,s=!1,i=A(K(()=>s?pe():n),a=>{let c=[];for(let u=0;u<a.length;u++){if(!t(a[u],o++)){s=!0;break}c.push(a[u])}return Ye(c)?v(c):s?pe():i});return i}))),TY=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o=!1,s=A(K(()=>o?pe():n),i=>{let a=[];for(let c=0;c<i.length;c++){let u=t(i[c]);if(Fe(u)){o=!0;break}a.push(u.success)}return Ye(a)?v(a):o?pe():s});return s}))),kY=d(2,(e,t)=>Sj(e,(n,r)=>Y(t(n,r),o=>!o),{excludeLast:!0})),fk=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o=0,s=n.pipe(A(i=>o>=t?v(i):(o+=i.length,o<=t?s:v(i.slice(t-o)))));return s}))),CY=d(2,(e,t)=>fk(bj(e,(n,r)=>!t(n,r)),1)),AY=d(2,(e,t)=>fk(wj(e,(n,r)=>Y(t(n,r),o=>!o)),1)),bj=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o=!0,s=0,i=A(n,a=>{let c=a.findIndex(u=>!t(u,s++));return c===-1?i:(o=!1,v(a.slice(c)))});return K(()=>o?i:n)}))),OY=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o=!0,s=A(n,i=>{let a=i.findIndex(c=>Fe(t(c)));return a===-1?s:(o=!1,v(i.slice(a)))});return K(()=>o?s:n)}))),wj=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o=!0,s=0,i=qt(function*(){for(;;){let a=yield*n;for(let c=0;c<a.length;c++)if(!(yield*t(a[c],s++)))return o=!1,a.slice(c)}});return K(()=>o?i:n)}))),RY=d(2,(e,t)=>t<=0?e:Sn(e,(n,r)=>se(()=>{let o=ha(),s=A(n,i=>{ty(o,i);let a=o.length-t,c=Cu(o,a);return Vn(c)?v(c):s});return s}))),Ij=e=>e.channel.pipe(Fs(Ne),$),vj=d(2,(e,t)=>(t=Math.max(1,t),Sn(e,(n,r)=>se(()=>{let o=rn(),s=0,i,a=!1;return K(function c(){if(a)return pe();if(i===void 0)return A(n,u=>o.length===0&&u.length===t?v(u):o.length+u.length<t?(o.push(...u),c()):(i=u,c()));for(;s<i.length;)if(o.push(i[s++]),o.length===t){let u=o;return o=[],v(u)}return s=0,i=void 0,c()}).pipe($t(()=>{if(o.length===0)return pe();let c=o;return a=!0,o=[],v(c)}))})))),_Y=d(2,(e,t)=>Tj(e,t,1)),Tj=d(3,(e,t,n)=>Sn(e,(r,o)=>se(()=>{let s=null,i=ha(),a=!1,c=0,u=Kr(r,{onSuccess(f){if(ty(i,f),c>0){let p=i.length;Lp(i,c),c=Math.max(0,c-p)}if(i.length<t)return u;a=!0;let l=[];for(;i.length>=t;)if(t===n)l.push(Cu(i,t));else if(l.push(R1(i,t)),t===1&&n<=0)Os(i);else{let p=i.length;Lp(i,n),c=Math.max(0,n-p)}return v(l)},onFailure(f){return a&&Lp(i,t-n),i.length===0?ct(f):(s=f,v(Ne(Au(i))))}});return K(()=>s?ct(s):u)}))),MY=d(2,(e,t)=>Gu(e,rn,(n,r)=>{let o=rn();for(let s=0;s<r.length;s++)t(r[s])?Vn(n)&&(o.push(n),n=[]):n.push(r[s]);return[n,o]},{onHalt(n){return Vn(n)?Ne(n):ba}})),PY=d(4,(e,t,n,r)=>Av(lr(e.channel),lr(t.channel),n,r).pipe(Fs(Ne),$)),FY=d(4,(e,t,n,r)=>$(Av(e.channel,t.channel,n,r))),UY=d(e=>Ue(e[0]),(e,t,n,r)=>$(Tl(e.channel,t,(o,s)=>{let i=rn();for(let a=0;a<s.length;a++){let[c,u]=n(o,s[a]);o=c,i.push(...u)}return[o,Vn(i)?Ne(i):ba]},r?.onHalt?{onHalt(o){let s=r.onHalt(o);return Ye(s)?Ne(s):ba}}:void 0))),Gu=d(e=>Ue(e[0]),(e,t,n,r)=>$(Tl(e.channel,t,(o,s)=>{let[i,a]=n(o,s);return o=i,[o,Ye(a)?Ne(a):ba]},r?.onHalt?{onHalt(o){let s=r.onHalt(o);return Ye(s)?Ne(s):ba}}:void 0))),ba=rn(),DY=d(e=>Ue(e[0]),(e,t,n,r)=>e.channel.pipe(lr,Tl(t,(o,s)=>Y(n(o,s),([i,a])=>[i,Ye(a)?Ne(a):rn()]),r?.onHalt?{onHalt(o){let s=r.onHalt(o);return Ye(s)?Ne(s):ba}}:void 0),$)),NY=d(e=>Ue(e[0]),(e,t,n,r)=>e.channel.pipe(Tl(t,(o,s)=>Y(n(o,s),([i,a])=>[i,Ye(a)?Ne(a):ba]),r?.onHalt?{onHalt(o){let s=r.onHalt(o);return Ye(s)?Ne(s):ba}}:void 0),$)),LY=d(3,(e,t,n)=>Fr(()=>{let r=!0;return $(Tl(e.channel,Qe(t),(o,s)=>{let i=rn();r&&(r=!1,i.push(o));for(let a=0;a<s.length;a++)o=n(o,s[a]),i.push(o);return[o,Ne(i)]}))})),BY=d(3,(e,t,n)=>e.channel.pipe(lr,hD(t,n),Fs(Ne),$)),jY=d(2,(e,t)=>Sn(e,ye(function*(n,r){let o=yield*lu,s=Tn(gt(t)),i,a,c=1/0,u=fr(),f=fr(),l=fr();yield*n.pipe(u.whenOpen,A(m=>(f.openUnsafe(),i=m,c=o.currentTimeMillisUnsafe()+s,H)),Ht({disableYield:!0}),mo(m=>(a=m,c=o.currentTimeMillisUnsafe(),f.openUnsafe(),l.openUnsafe(),H)),Ut(r));let p=K(function m(){let h=o.currentTimeMillisUnsafe(),g=c<h?s:Math.min(s,c-h);return A(Ya(Qa(g),l.await),()=>{if(o.currentTimeMillisUnsafe()<c)return m();if(i){f.closeUnsafe(),u.closeUnsafe();let b=v(Ne(Sf(i)));return i=void 0,b}else if(a)return ct(a);return m()})});return K(()=>{if(a){if(i){let m=v(Ne(Sf(i)));return i=void 0,m}return ct(a)}return u.openUnsafe(),f.whenOpen(p)})}))),kj=d(2,(e,t)=>{let n=t.burst??0;return t.strategy==="enforce"?$Y(e,t.cost,t.units,t.duration,n):qY(e,t.cost,t.units,t.duration,n)}),$Y=(e,t,n,r,o)=>Sn(e,s=>xu(i=>{let a=Tn(gt(r)),c=n+o<0?Number.POSITIVE_INFINITY:n+o,u=n,f=i.currentTimeMillisUnsafe();return v(A(s,function l(p){return A(t(p),m=>{let h=i.currentTimeMillisUnsafe(),x=(h-f)/a,b=u+x*n,E=b<0?c:Math.min(b,c);return m<=E?(u=E-m,f=h,v(p)):A(s,l)})}))})),qY=(e,t,n,r,o)=>Sn(e,s=>xu(i=>{let a=Tn(gt(r)),c=n+o<0?Number.POSITIVE_INFINITY:n+o,u=n,f=i.currentTimeMillisUnsafe();return v(A(s,l=>A(t(l),p=>{let m=i.currentTimeMillisUnsafe(),g=(m-f)/a,x=u+g*n,E=(x<0?c:Math.min(x,c))-p;if(E>=0)return u=E,f=m,v(l);let y=-E/n,w=Math.max(0,y*a);return w>0?A(Qa(w),()=>(u=E,f=m,v(l))):(u=E,f=m,v(l))})))})),zY=d(2,(e,t)=>kj(e,{...t,cost:n=>v(t.cost(n))})),HY=d(2,(e,t)=>Ij(vj(e,t))),WY=d(3,(e,t,n)=>lk(e,HB(t),Vf(n))),KY=d(e=>Ue(e[0]),(e,t,n)=>Cj(e,ye(function*(r,o,s){for(let i=0;i<r.length;i++){let[a,c]=yield*t(r[i]),u=As(s,a),f=Te(u)?u.value:yield*gu(QT(o,a));yield*YT(o,a),yield*Xn(f,c)}}),n)),VY=d(e=>Ue(e[0]),(e,t,n)=>Fr(()=>{let r=cc();return Cj(e,ye(function*(o,s,i){for(let a=0;a<o.length;a++){let c=t(o[a]),u=As(r,c);ge(u)?uc(r,c,[o[a]]):u.value.push(o[a])}for(let[a,c]of r){let u=As(i,a),f=Te(u)?u.value:yield*gu(QT(s,a));yield*YT(s,a),yield*ga(f,c)}Zx(r)}),n)})),Cj=(e,t,n)=>tk(e,ye(function*(r,o,s){let i=yield*qp();yield*_t(o,Rs(i));let a=cc(),c=yield*VB({lookup:u=>Xa(Xr({capacity:n?.bufferSize??4096}).pipe(Mt(f=>(uc(a,u,f),Xn(i,[u,Ii(f)])))),f=>(ku(a,u),zp(f))),idleTimeToLive:n?.idleTimeToLive??fo}).pipe(Po(s));return yield*Qn({while:Xt,body:Qe(A(r,u=>t(u,c,a))),step:bn}).pipe(ft(u=>Zt(i,u)),Ut(o)),Il(i)})),JY=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o,s,i=rn(),a=n.pipe(A(u=>{for(let f=0;f<u.length;f++){let l=u[f],p=t(l);if(s===void 0){o=p,s=[l];continue}else if(ae(p,o)){s.push(l);continue}i.push([o,s]),o=p,s=[l]}if(Vn(i)){let f=i;return i=[],v(f)}return a})),c=!1;return $t(K(()=>c?pe():a),()=>{c=!0;let u=s;return s=void 0,u&&Vn(u)?v(Ne([o,u])):pe()})}))),GY=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o,s,i=K(()=>{if(s!==void 0){let c=s;return s=void 0,v(c)}return n}).pipe(mu(c=>(o=Mo(c),pe()))),a=Y(K(()=>t.transform(i,r)),([c,u])=>(s=u,Ne(c)));return K(()=>o||a)}))),ZY=d(2,(e,t)=>lk(e,t,Xd)),lk=d(3,(e,t,n)=>$(Ps(ye(function*(r,o,s){let i=yield*Ho(e.channel,o),a=fr(!1),c=Symbol(),u=yield*Xr({capacity:0});yield*i.pipe(a.whenOpen,A(y=>(a.closeUnsafe(),Xn(u,y))),Ht,ft(y=>Zt(u,y)),Ut(s));let f=U(),l,p=!1,m=yield*Kf(n),g=K(function y(){return A(m(f),()=>p?Xn(u,c):y())}).pipe(A(()=>Hr),$t(()=>pe())),x=zo(u).pipe(A(y=>y===c?pe():(p=!0,v(y)))),b=K(()=>{if(l!==void 0){let y=l;return l=void 0,p=!0,v(y)}return a.openUnsafe(),x}),E=A(([y,w])=>!p&&u.state._tag==="Done"?pe():(f=N(y),l=w,v(Ne(y))));return K(()=>u.state._tag==="Done"&&l===void 0?u.state.exit:(p=l!==void 0,v(K(()=>t.transform(b,s))))).pipe(A(y=>Ya(E(y),g)))})))),QY=d(2,ye(function*(e,t){let n=yield*YY(t),r=new Array(t.n),o=yield*It;for(let s=0;s<t.n;s++){let i=Cn(o),a=yield*$p(n).pipe(Bo(It,i));r[s]=kv(uy(a)).pipe(Kp(c=>Je(i,c)),$)}return yield*Mu(e.channel,s=>El(n,s)).pipe(ur(s=>El(n,s)),bs),r})),YY=e=>Xa(e.capacity==="unbounded"?Bp(e):e.strategy==="dropping"?ay(e):e.strategy==="sliding"?cy(e):iy(e),jp),Aj=d(2,(e,t)=>Y(jj(e,t),ij)),XY=d(2,(e,t)=>Y(QB({acquire:Aj(e,t),idleTimeToLive:t.idleTimeToLive}),n=>mr(YB(n)))),eX=d(2,(e,t)=>$(_v(e.channel,t))),tX=d(2,(e,t)=>$(Mv(e.channel,t))),nX=d(2,(e,t)=>e.channel.pipe(Mv(zB(t)),by(([n,r])=>r?yy(r):vl),$)),rX=e=>fS(Bj(e)),oX=e=>Gu(e,rn,(t,n)=>{let r=yf(t,n);return[r,[r]]}),Oj=e=>Rj(e,ae),Rj=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o=!0,s;return A(n,function i(a){let c=[],u=0;for(o&&(o=!1,s=a[0],u=1,c.push(s));u<a.length;u++){let f=a[u];t(f,s)||(s=f,c.push(f))}return Vn(c)?v(c):A(n,i)})}))),sX=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o=!0,s;return A(n,ye(function*i(a){let c=[],u=0;for(o&&(o=!1,s=a[0],u=1,c.push(s));u<a.length;u++){let f=a[u];(yield*t(f,s))||(s=f,c.push(f))}return Vn(c)?c:yield*A(n,ye(i))}))}))),iX=d(e=>Ue(e[0]),(e,t)=>Fr(()=>{let n=new TextDecoder(t?.encoding);return So(e,r=>n.decode(r,{stream:!0}))})),aX=e=>Fr(()=>{let t=new TextEncoder;return So(e,n=>t.encode(n))}),cX=e=>e.channel.pipe(_v(OD()),$),_j=d(2,(e,t)=>cj(e,(n,r)=>{let o=r===0?[]:[t],s=n.length-1;for(let i=0;i<n.length;i++)i===s?o.push(n[i]):o.push(n[i],t);return o})),uX=d(2,(e,t)=>zl(t.start).pipe(vm(_j(e,t.middle)),vm(zl(t.end)))),fX=d(2,(e,t)=>Mj(e,t,Vu(rO([!0,!1])))),Mj=d(3,(e,t,n)=>$(Ge(ye(function*(r,o){let s=yield*Pe(lr(n.channel))(r,o),i=Symbol(),a=!1,c=!1,u=(yield*Pe(lr(e.channel))(r,o)).pipe($t(()=>(a=!0,v(i)))),f=(yield*Pe(lr(t.channel))(r,o)).pipe($t(()=>(c=!0,v(i))));return qt(function*(){for(;;){if(a&&c)return yield*pe();let l=yield*s;if(l&&a||!l&&c)continue;let p=yield*l?u:f;if(p!==i)return Ne(p)}})})))),lX=d(2,(e,t)=>$(PD(e.channel,t))),dX=d(2,(e,t)=>$(FD(e.channel,t))),Pj=d(2,(e,t)=>$(Kp(e.channel,t))),pX=d(2,(e,t)=>$(UD(e.channel,t))),Fj=d(2,(e,t)=>$(DD(e.channel,t))),Uj=d(2,(e,t)=>$(Pv(e.channel,n=>t(n[0])))),mX=d(2,(e,t)=>$(ND(e.channel,t))),Cm=d(2,(e,t)=>$(LD(e.channel,t))),Dj=d(e=>Ue(e[0]),(e,t,n)=>$(BD(e.channel,t,n))),dk=d(2,(e,t)=>$(Ty(e.channel,t))),hX=d(3,(e,t,n)=>$(ky(e.channel,t,n))),pk=d(3,(e,t,n)=>$(Cy(e.channel,t,n))),Nj=d(2,(e,t)=>$(jD(e.channel,t))),gX=d(3,(e,t,n)=>Nj(e,r=>Ve(r,t,n(qe(r,t))))),xX=function(){let e=Ue(arguments[0]),t=e?arguments[1]:arguments[0],n=_o(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return $(Fv(r.channel,t,n))}return r=>$(Fv(r.channel,t,n))},yX=zl({}),SX=d(3,(e,t,n)=>So(e,r=>({...r,[t]:n(r)})));var EX=d(e=>Ue(e[0]),(e,t,n,r)=>Hl(e,o=>So(n(o),s=>({...o,[t]:s})),r)),bX=d(e=>Ue(e[0]),(e,t,n,r)=>Ju(e,o=>Y(n(o),s=>({...o,[t]:s})),r)),wX=d(2,(e,t)=>So(e,n=>({[t]:n}))),Lj=d(2,(e,t)=>ap(n=>Ho(e.channel,n).pipe(A(r=>t.transform(r,n)),Y(([r])=>r)))),Bj=e=>Pu(e.channel,()=>[],(t,n)=>{for(let r=0;r<n.length;r++)t.push(n[r]);return t}),IX=e=>Pu(e.channel,()=>0,(t,n)=>t+n.length),vX=e=>Pu(e.channel,()=>0,(t,n)=>{for(let r=0;r<n.length;r++)t+=n[r];return t}),TX=d(3,(e,t,n)=>Pu(e.channel,t,(r,o)=>{for(let s=0;s<o.length;s++)r=n(r,o[s]);return r})),kX=d(3,(e,t,n)=>WD(e.channel,t,(r,o)=>{let s=0,i=r;return Y(Qn({while:()=>s<o.length,body:()=>n(i,o[s]),step(a){i=a,s++}}),()=>i)})),CX=e=>Y(zD(e.channel),Lt(lO(0))),AX=e=>Y(HD(e.channel),Lt(Sf)),OX=d(2,(e,t)=>Mu(e.channel,n=>{let r=0;return Qn({while:()=>r<n.length,body:()=>t(n[r++]),step:bn})})),RX=d(2,(e,t)=>qD(e.channel,n=>{let r=!1,o=0;return Y(Qn({while:()=>!r&&o<n.length,body:()=>t(n[o]),step(s){o++,s||(r=!0)}}),()=>!r)})),Wl=d(2,(e,t)=>Mu(e.channel,t)),mS=e=>$D(e.channel),mk=e=>Dv(e.channel),_X=e=>Pu(e.channel,()=>"",(t,n)=>t+n.join("")),MX=e=>Y(Uv(e.channel),t=>t.buffer),PX=e=>Uv(e.channel),hk=d(e=>Ue(e[0]),(e,t,n)=>{let r,o,s=fr(!1);return new ReadableStream({start(i){o=up(Nn(Wl(e,a=>s.whenOpen(se(()=>{s.closeUnsafe();for(let c=0;c<a.length;c++)i.enqueue(a[c]);r(),r=void 0}))),t)),o.addObserver(a=>{a._tag==="Failure"?i.error(su(a.cause)):i.close()})},pull(){return new Promise(i=>{r=i,s.openUnsafe()})},cancel(){if(o)return Nw(Lo(yo(o)))}},n?.strategy)}),FX=d(e=>Ue(e[0]),(e,t)=>hk(e,bt(),t)),gk=d(e=>Ue(e[0]),(e,t)=>Y(ar(),n=>hk(e,n,t))),xk=d(2,(e,t)=>({[Symbol.asyncIterator](){let n=Lw(t),r=Ln(t),o=$r(),s,i,a,c,u=l=>{if(c)return c;let p=a;return c=n(zt(Dn(p?yo(p):H,Je(o,l)),{done:!0,value:void 0})),c},f=async l=>{try{await u(l)}catch(p){await n(fp("Suppressed error while closing Stream async iterator",p))}};return{async next(){if(c)return c;if(i){let m=i.next();if(!m.done)return m;i=void 0}let l=r(s??A(Ho(e.channel,o),m=>(s=m,m)));a=l;let p=await n(T1(l));if(a===l&&(a=void 0),Ft(p))return i=p.value[Symbol.iterator](),i.next();if(Uo(p.cause))return u(Vt);if(c&&N0(p.cause))return c;throw await f(p),su(p.cause)},return(){return u(Vt)},async throw(l){throw await f(Ng(l)),l}}}})),UX=e=>Y(ar(),t=>xk(e,t)),DX=e=>xk(e,bt()),NX=d(e=>Ue(e[0]),(e,t,n)=>Lv(e.channel,t,n)),LX=d(2,(e,t)=>JD(e.channel,t)),jj=d(2,(e,t)=>GD(e.channel,t)),BX=d(2,(e,t)=>KD(e.channel,t)),jX=d(2,(e,t)=>Nv(e.channel,t));var $j="~effect/interfaces/PrimaryKey";var zj="~effect/Pool",Kj=Symbol(),Vj=Symbol();var Jj=e=>Zj({...e,min:e.size,max:e.size,strategy:xS}),Gj=e=>A(e.timeToLiveStrategy==="creation"?VX(e.timeToLive):JX(e.timeToLive),t=>Zj({...e,strategy:t})),Zj=e=>go(ye(function*(t){let n=yield*ar(),r=qe(n,It),o=ip(e.acquire,u=>Er(n,u)),s=e.concurrency??1,i={acquire:o,concurrency:s,isFixed:e.min===e.max,minSize:e.min,maxSize:e.max,strategy:e.strategy,targetUtilization:Math.min(Math.max(e.targetUtilization??1,.1),1)},a={scope:r,isShuttingDown:!1,usage:0,resizeSemaphore:xa(1),items:new Set,availableHead:void 0,availableTail:void 0,invalidated:new Set,waiters:new Set},c={[zj]:zj,[Kj]:e.acquire,[Vj]:n,config:i,state:a,pipe(){return ie(this,arguments)}};return yield*_t(r,$X(c)),i.minSize>0&&(yield*Mt(tl(t(wk(c)),{startImmediately:!0}),u=>_t(r,yo(u)))),e.strategy!==xS&&(yield*Mt(tl(t(e.strategy.run(c))),u=>_t(r,yo(u)))),c})),$X=ye(function*(e){if(e.state.isShuttingDown)return;e.state.isShuttingDown=!0;let t=e.state.items.size,n=xa(t);for(let r of e.state.items)r.refCount>0?(r.finalizer=Mt(r.finalizer,n.release(1)),e.state.invalidated.add(r),yield*n.take(1)):(e.state.items.delete(r),Am(e,r),e.state.invalidated.delete(r),yield*r.finalizer);if(yield*n.releaseAll,e.state.waiters.size>0){let r=Array.from(e.state.waiters);e.state.waiters.clear();for(let o of r)o()}yield*n.take(t)}),Sk=e=>de(t=>{let n=e.state;if(n.isShuttingDown)return Ff;if(n.availableHead!==void 0){if(n.usage++,e.config.isFixed||hS(e)<=gS(e))return Qj(e,n.availableHead,t);n.usage--}return qX(e,HX)});var qX=(e,t)=>jr(n=>{let r=e.state;r.usage++;let o=ne(Ag(n(KX(e)),()=>he(()=>{r.usage--})),()=>i),s=de(a=>r.isShuttingDown?(r.usage--,Ff):r.availableHead!==void 0?t(e,r.availableHead,a,n):o),i=me(()=>r.isShuttingDown?(r.usage--,Ff):hS(e)>gS(e)?ne(r.resizeSemaphore.withPermitsIfAvailable(1)(Ut(ra(wk(e)),r.scope)),()=>s):s);return i}),zX=(e,t)=>{let n=e.state;return t.exit._tag==="Failure"?(n.usage--,n.items.delete(t),n.invalidated.delete(t),Am(e,t),!1):(t.refCount++,t.refCount>=e.config.concurrency&&Am(e,t),!0)},Qj=(e,t,n)=>{if(!zX(e,t))return t.exit;let r=Jn(n.context,It);return r.state._tag==="Closed"?ne(t.release(t.exit),()=>t.exit):(Yc(r,{},t.release),t.exit)},HX=(e,t,n)=>Qj(e,t,n),WX=(e,t)=>de(n=>{let r=e.state;return t.refCount--,r.usage--,r.invalidated.has(t)?bk(e,t):(t.refCount===e.config.concurrency-1&&(Ek(e,t),Yj(e,n,1)),we)}),KX=e=>Bt(t=>{let n=e.state;if(n.availableHead!==void 0||n.isShuttingDown)return t(we);let r=()=>{n.waiters.delete(r),t(we)};return n.waiters.add(r),he(()=>{n.waiters.delete(r)})}),Yj=(e,t,n)=>{let r=e.state.waiters;r.size!==0&&t.currentDispatcher.scheduleTask(()=>{let o=n,s=[];for(let i of r){if(o--<=0)break;s.push(i)}for(let i=0;i<s.length;i++)s[i]()},0)},Hj=e=>de(t=>(Yj(e,t,Number.POSITIVE_INFINITY),we)),Ek=(e,t)=>{t.isAvailable||(t.isAvailable=!0,t.availablePrevious=e.state.availableTail,t.availableNext=void 0,e.state.availableTail!==void 0?e.state.availableTail.availableNext=t:e.state.availableHead=t,e.state.availableTail=t)},Am=(e,t)=>{t.isAvailable&&(t.isAvailable=!1,t.availablePrevious!==void 0?t.availablePrevious.availableNext=t.availableNext:e.state.availableHead=t.availableNext,t.availableNext!==void 0?t.availableNext.availablePrevious=t.availablePrevious:e.state.availableTail=t.availablePrevious,t.availablePrevious=void 0,t.availableNext=void 0)};var bk=(e,t)=>K(()=>{if(e.state.items.has(t)){if(t.refCount===0)return e.state.items.delete(t),Am(e,t),e.state.invalidated.delete(t),Lo(A(t.finalizer,()=>Ut(ra(wk(e)),e.state.scope,{startImmediately:!0})))}else return H;return e.state.invalidated.add(t),Am(e,t),H}),wk=e=>e.state.resizeSemaphore.withPermits(1)(yk(e)),yk=e=>K(()=>{let t=gS(e),n=hS(e);if(t>=n)return H;let r=n-t,o=e.config.strategy===xS?Wj(e):A(e.config.strategy.reclaim(e),i=>i?v(i):Wj(e));if(r===1){let i=Mt(o,Hj(e));return e.config.isFixed?Lo(i):A(i,a=>a.exit._tag==="Failure"?H:yk(e))}let s=o.pipe(Pw(r,{concurrency:r}),Mt(Hj(e)));return e.config.isFixed?Lo(s):A(s,i=>i.some(a=>a.exit._tag==="Failure")?H:yk(e))}),Wj=e=>jr(t=>de(n=>{let r=e,o=tu(),s=n.context;n.setContext(Ve(r[Vj],It,o));let i=A(Wr(r[Kj]),a=>{let c={exit:a,finalizer:ft(Je(o,a),GX),refCount:0,disableReclaim:!1,isAvailable:!1,availablePrevious:void 0,availableNext:void 0,release:void 0};return c.release=Qe(WX(e,c)),e.state.items.add(c),Ek(e,c),e.config.strategy===xS?a._tag==="Success"?v(c):zt(c.finalizer,c):zt(a._tag==="Success"?e.config.strategy.onAcquire(c):A(c.finalizer,()=>e.config.strategy.onAcquire(c)),c)});return ls(t(i),a=>(n.setContext(s),a._tag==="Failure"?Mf(o,a):void 0),!0)})),hS=e=>{if(e.state.isShuttingDown)return 0;if(e.config.isFixed)return e.config.minSize;let t=e.state.usage/e.config.targetUtilization,n=Math.ceil(t/e.config.concurrency);return Math.min(Math.max(e.config.minSize,n),e.config.maxSize)},gS=e=>e.state.items.size-e.state.invalidated.size,xS={run:e=>H,onAcquire:e=>H,reclaim:e=>Qf},VX=ye(function*(e){let t=yield*lu,n=yield*qp(),r=Tn(gt(e)),o=new WeakMap;return L({run:s=>{let i=a=>K(()=>{if(!s.state.items.has(a)||s.state.invalidated.has(a))return H;let c=t.currentTimeMillisUnsafe(),u=o.get(a),f=r-(c-u);return f>0?ta(i(a),f):bk(s,a)});return zo(n).pipe(Mt(i),Ht({disableYield:!0}))},onAcquire:s=>K(()=>(o.set(s,t.currentTimeMillisUnsafe()),Xn(n,s))),reclaim:s=>Qf})}),JX=ye(function*(e){let t=yield*qp();return L({run:n=>{let r=K(()=>gS(n)-hS(n)<=0?H:zo(t).pipe(Mt(s=>bk(n,s)),A(()=>r)));return r.pipe(ta(e),Ht({disableYield:!0}))},onAcquire:n=>Xn(t,n),reclaim(n){return K(()=>{if(n.state.invalidated.size===0)return Qf;let r=oO(Nh(n.state.invalidated,o=>!o.disableReclaim));return r._tag==="None"?Qf:(n.state.invalidated.delete(r.value),r.value.refCount<n.config.concurrency&&Ek(n,r.value),zt(Xn(t,r.value),r.value))})}})}),GX=e=>xn(t=>{let n=t.getRef(cP);return n?nl(n)("Unhandled error in pool finalizer",e):H});var Ti=class extends Ke()("effect/reactivity/Reactivity"){},ZX=se(()=>{let e=new Map,t=c=>{Ik(c,u=>{let f=e.get(u);f!==void 0&&f.forEach(l=>l())})},n=c=>cr(u=>{let f=$i(u,yS);return f?Ik(c,l=>{f.add(l)}):t(c),H}),r=(c,u)=>Mt(u,n(c)),o=(c,u)=>{let f=[];return Ik(c,l=>{f.push(l);let p=e.get(l);p===void 0&&(p=new Set,e.set(l,p)),p.add(u)}),()=>{for(let l=0;l<f.length;l++){let p=e.get(f[l]);p.delete(u),p.size===0&&e.delete(f[l])}}},s=(c,u)=>qt(function*(){let f=yield*ar(),l=qe(f,It),p=yield*Xr(),m=Fc(Ln(f),da(l)),h=!1,g=!1,x=y=>{y._tag==="Failure"?yi(p,y.cause):wl(p,y.value),g?(g=!1,m(u).addObserver(x)):h=!1};function b(){if(h){g=!0;return}h=!0,m(u).addObserver(x)}let E=o(c,b);return yield*_t(l,se(E)),b(),p}),i=(c,u)=>s(c,u).pipe(Y(Ii),mr),a=c=>K(()=>{let u=new Set;return c.pipe(Bo(yS,u),ur(f=>se(()=>{u.forEach(l=>{let p=e.get(l);p!==void 0&&p.forEach(m=>m())})})))});return Ti.of({mutation:r,query:s,stream:i,invalidateUnsafe:t,invalidate:n,registerUnsafe:o,withBatch:a})}),yS=class extends Ke()("effect/reactivity/Reactivity/PendingInvalidation"){},SS=d(2,(e,t)=>Ti.use(n=>n.mutation(t,e)));var ES=e=>Ti.use(t=>t.invalidate(e)),bS=qr(Ti)(ZX);function e$(e){switch(typeof e){case"string":case"number":case"bigint":case"boolean":return String(e);default:return ce(e)}}var Ik=(e,t)=>{if(Array.isArray(e)){for(let n=0;n<e.length;n++)t(e$(e[n]));return}for(let n in e){t(n);let r=e[n];for(let o=0;o<r.length;o++)t(`${n}:${e$(r[o])}`)}};var t$="~effect/SubscriptionRef",Om=e=>B(e,t$),Nfe={...vn,[t$]:{_A:L},toJSON(){return{_id:"SubscriptionRef",value:this.value}}};var vk=e=>nk(e.pubsub);var n$=e=>se(()=>e.value);var QX=(e,t)=>{e.value=t,M1(e.pubsub,t)};var Tk=d(2,(e,t)=>e.semaphore.withPermit(se(()=>QX(e,t))));var o$="~effect/http/Cookies";var s$="~effect/http/Cookies/Cookie";var i$="~effect/http/Cookies/CookieError",kk=class extends YO{},a$=class e extends Mn("CookieError"){static fromReason(t,n){return new e({reason:new kk({_tag:t,cause:n})})}[i$]=i$;get message(){return this.reason._tag}},YX={[o$]:o$,...Ks,toJSON(){return{_id:"effect/Cookies",cookies:Lh(this.cookies,e=>e.toJSON())}},pipe(){return ie(this,arguments)}},XX=e=>{let t=Object.create(YX);return t.cookies=e,t},eee=e=>{let t={};for(let n of e)W(t,n.name,n);return XX(t)},u$=e=>{let t=typeof e=="string"?[e]:e,n=[];for(let r of t){let o=tee(r.trim());o&&n.push(o)}return eee(n)};function tee(e){let t=e.split(";").map(a=>a.trim()).filter(a=>a!=="");if(t.length===0)return;let n=t[0].indexOf("=");if(n===-1)return;let r=t[0].slice(0,n);if(!nee.test(r))return;let o=t[0].slice(n+1),s=ree(o);if(t.length===1)return Object.assign(Object.create(c$),{name:r,value:s,valueEncoded:o});let i={};for(let a=1;a<t.length;a++){let c=t[a],u=c.indexOf("="),f=u===-1?c:c.slice(0,u).trim(),l=u===-1?void 0:c.slice(u+1).trim();switch(f.toLowerCase()){case"domain":{if(l===void 0)break;let p=l.trim().replace(/^\./,"");p&&(i.domain=p);break}case"expires":{if(l===void 0)break;let p=new Date(l);isNaN(p.getTime())||(i.expires=p);break}case"max-age":{if(l===void 0)break;let p=parseInt(l,10);isNaN(p)||(i.maxAge=xb(p));break}case"path":{if(l===void 0)break;l[0]==="/"&&(i.path=l);break}case"priority":{if(l===void 0)break;switch(l.toLowerCase()){case"low":i.priority="low";break;case"medium":i.priority="medium";break;case"high":i.priority="high";break}break}case"httponly":{i.httpOnly=!0;break}case"secure":{i.secure=!0;break}case"partitioned":{i.partitioned=!0;break}case"samesite":{if(l===void 0)break;switch(l.toLowerCase()){case"lax":i.sameSite="lax";break;case"strict":i.sameSite="strict";break;case"none":i.sameSite="none";break}break}}}return Object.assign(Object.create(c$),{name:r,value:s,valueEncoded:o,options:Object.keys(i).length>0?i:void 0})}var nee=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;var c$={[s$]:s$,...Ks,toJSON(){return{_id:"effect/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};var ree=e=>{try{return decodeURIComponent(e)}catch{return e}};var US={};Hs(US,{Fetch:()=>q$,RequestInit:()=>FS,layer:()=>Aee});var l$=Symbol.for("~effect/http/Headers");var Rm=Object.defineProperties(Object.create(null),{[l$]:{value:l$},[Lc]:{value(e){return see(this,qe(e,Ak))}},toJSON:{value(){return Io(this)}},[_e]:{value(e){return oee(this,e)}},[Re]:{value(){return dd(this)}},toString:{value:Ks.toString},[at]:{value:Ks[at]}}),IS=e=>Object.assign(Object.create(Rm),e),oee=aO(Nc());var Kl=Object.create(Rm),ki=e=>{if(e===void 0)return Kl;if(Symbol.iterator in e){let n=Object.create(Rm);for(let[r,o]of e)n[r.toLowerCase()]=o;return n}let t=Object.create(Rm);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},d$=e=>Object.setPrototypeOf(e,Rm);var _m=d(3,(e,t,n)=>{let r=IS(e);return r[t.toLowerCase()]=n,r}),p$=d(2,(e,t)=>IS({...e,...ki(t)})),Vl=d(2,(e,t)=>{let n=IS(e);return Object.assign(n,t),n}),bc=d(2,(e,t)=>{let n=IS(e);return delete n[t.toLowerCase()],n});var see=d(2,(e,t)=>{let n={...e},r=o=>{if(typeof o=="string"){let s=o.toLowerCase();s in e&&(n[s]=pc(e[s]))}else for(let s in e)o.test(s)&&(n[s]=pc(e[s]))};if(Array.isArray(t))for(let o=0;o<t.length;o++)r(t[o]);else r(t);return n}),Ck=(e,t)=>{for(let n=0;n<t.length;n++){let r=t[n];if(typeof r=="string"){if(r.toLowerCase()===e)return!0}else if(r.test(e))return!0}return!1},Ak=Me("effect/Headers/CurrentRedactedNames",{defaultValue:()=>["authorization","cookie","set-cookie","x-api-key"]});var Ok="~effect/http/UrlParams",iee=e=>B(e,Ok),aee={...vn,[Ok]:Ok,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:"UrlParams",params:Object.fromEntries(this.params)}},[_e](e){return cee(this,e)},[Re](){return Aa(this.params.flat())}},m$=e=>{let t=Object.create(aee);return t.params=e,t},Mm=e=>{if(iee(e))return e;let t=h$(e),n=[];for(let r=0;r<t.length;r++)if(Array.isArray(t[r][0])){let[o,s]=t[r];n.push([`${o[0]}[${o.slice(1).join("][")}]`,s])}else n.push(t[r]);return m$(n)},h$=e=>{let t=typeof e[Symbol.iterator]=="function"?ht(e):Object.entries(e),n=[];for(let[r,o]of t)if(Array.isArray(o))for(let s=0;s<o.length;s++)o[s]!==void 0&&n.push([r,String(o[s])]);else if(typeof o=="object"){let s=h$(o);for(let[i,a]of s)n.push([[r,...typeof i=="string"?[i]:i],a])}else o!==void 0&&n.push([r,String(o)]);return n},cee=un((e,t)=>uee(e.params,t.params)),uee=pO(tO([Nc(),Nc()]));var g$=m$([]);var x$=d(2,(e,t)=>{let n=Mm(t),r=n.params,o=new Set;for(let s=0;s<r.length;s++)o.add(r[s][0]);for(let s=0;s<e.params.length;s++)o.has(e.params[s][0])||r.push(e.params[s]);return n});var _k="~effect/http/HttpBody";var y$="~effect/http/HttpBody/HttpBodyError",S$=class extends Mn("HttpBodyError"){[y$]=y$},vS=class{[_k];constructor(){this[_k]=_k}[at](){return this.toJSON()}toString(){return X(this,{ignoreToString:!0})}},Mk=class extends vS{_tag="Empty";toJSON(){return{_id:"effect/HttpBody",_tag:"Empty"}}},E$=new Mk;var Pk=class extends vS{_tag="Uint8Array";body;contentType;contentLength;constructor(t,n,r){super(),this.body=t,this.contentType=n,this.contentLength=r}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}}},TS=(e,t)=>new Pk(e,t??"application/octet-stream",e.length),fee=new TextEncoder,Fk=(e,t)=>TS(fee.encode(e),t??"text/plain");var Dk="~effect/http/HttpClientError";var Eo=class extends Mn("HttpClientError"){constructor(t){"cause"in t.reason?super({...t,cause:t.reason.cause}):super(t)}[Dk]=Dk;get request(){return this.reason.request}get response(){return"response"in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},OS=e=>e.endsWith("Error")?e.slice(0,-5):e,RS=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,kS=class extends Mn("TransportError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return RS(OS(this._tag),this.description,this.methodAndUrl)}};var CS=class extends Mn("InvalidUrlError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return RS(OS(this._tag),this.description,this.methodAndUrl)}};var wc=class extends Mn("DecodeError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return RS(OS(this._tag),this.description,t)}},AS=class extends Mn("EmptyBodyError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return RS(OS(this._tag),this.description,t)}},Jl=class e extends qn(Dk)({_tag:Ze("HttpError"),kind:Ea(["EncodeError","DecodeError","TransportError","InvalidUrlError","StatusCodeError","EmptyBodyError"]),cause:Pt(ln())}){static fromHttpClientError(t){return new e({_tag:"HttpError",kind:t.reason._tag,cause:t.reason})}};var b$=[["GET","get"],["POST","post"],["PUT","put"],["DELETE","del"],["PATCH","patch"],["HEAD","head"],["OPTIONS","options"],["TRACE","trace"]];var I$=(e,t)=>t._tag==="Empty"||t._tag==="FormData"?bc(bc(e,"content-type"),"content-length"):(e=t.contentType===void 0?bc(e,"content-type"):_m(e,"content-type",t.contentType),t.contentLength===void 0?bc(e,"content-length"):_m(e,"content-length",t.contentLength.toString()));var Nk=class extends Mn("UrlError"){},v$=(e,t,n)=>Uh({try:()=>{let r=new URL(e,dee());for(let o=0;o<t.params.length;o++){let[s,i]=t.params[o];i!==void 0&&r.searchParams.append(s,i)}return n!==void 0&&(r.hash=n),r},catch:r=>new Nk({cause:r})}),dee=()=>{if("location"in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname};var k$="~effect/http/HttpClientRequest";var pee={[k$]:k$,...Ks,toJSON(){return{_id:"HttpClientRequest",method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Io(this.headers),body:this.body.toJSON()}},pipe(){return ie(this,arguments)}};function Ci(e,t,n,r,o,s){let i=Object.create(pee);return i.method=e,i.url=t,i.urlParams=n,i.hash=r,i.headers=o,i.body=s,i}var mee=Ci("GET","",g$,U(),Kl,E$),C$=e=>(t,n)=>hee(mee,{method:e,url:t,...n??void 0});var hee=d(2,(e,t)=>{let n=e;return t.method&&(n=A$(n,t.method)),t.url&&(n=_$(n,t.url)),t.headers&&(n=Lk(n,t.headers)),t.urlParams&&(n=yee(n,t.urlParams)),t.hash&&(n=See(n,t.hash)),t.body&&(n=P$(n,t.body)),t.accept&&(n=R$(n,t.accept)),t.acceptJson&&(n=gee(n)),n}),A$=d(2,(e,t)=>Ci(t,e.url,e.urlParams,e.hash,e.headers,e.body)),O$=d(3,(e,t,n)=>Ci(e.method,e.url,e.urlParams,e.hash,_m(e.headers,t,n),e.body)),Lk=d(2,(e,t)=>Ci(e.method,e.url,e.urlParams,e.hash,p$(e.headers,t),e.body));var R$=d(2,(e,t)=>O$(e,"Accept",t)),gee=R$("application/json"),_$=d(2,(e,t)=>{if(typeof t=="string")return Ci(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Mm(n.searchParams),o=Kc(n.hash===""?void 0:n.hash.slice(1));return n.search="",n.hash="",Ci(e.method,n.toString(),r,o,e.headers,e.body)}),M$=d(2,(e,t)=>t===""?e:Ci(e.method,xee(t,e.url),e.urlParams,e.hash,e.headers,e.body));var xee=(e,t)=>{let n=e.endsWith("/"),r=t.startsWith("/");return n&&r?e+t.slice(1):!n&&!r?e+"/"+t:e+t};var yee=d(2,(e,t)=>Ci(e.method,e.url,x$(e.urlParams,t),e.hash,e.headers,e.body));var See=d(2,(e,t)=>Ci(e.method,e.url,e.urlParams,N(t),e.headers,e.body));var P$=d(2,(e,t)=>Ci(e.method,e.url,e.urlParams,e.hash,I$(e.headers,t),t));var Zu="~effect/http/HttpIncomingMessage";var F$=(e,t)=>{let n=e.headers["content-type"]??"",r;if(n.includes("application/json"))try{r=li(e.json)}catch{}else if(n.includes("text/")||n.includes("urlencoded"))try{r=li(e.text)}catch{}let o={...t,headers:Io(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(o.body=r),o};var Gl="~effect/http/HttpClientResponse",U$=(e,t)=>new $k(e,t);var $k=class extends Th{[Zu];[Gl];request;source;constructor(t,n){super(),this.request=t,this.source=n,this[Zu]=Zu,this[Gl]=Gl}toJSON(){return F$(this,{_id:"HttpClientResponse",request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get headers(){return ki(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=u$(this.source.headers.getSetCookie())}get remoteAddress(){return U()}get stream(){return this.source.body?rk({evaluate:()=>this.source.body,onError:t=>new Eo({reason:new wc({request:this.request,response:this,cause:t})})}):Ku(new Eo({reason:new AS({request:this.request,response:this,description:"can not create stream from empty body"})}))}get json(){return A(this.text,t=>No({try:()=>t===""?null:JSON.parse(t),catch:n=>new Eo({reason:new wc({request:this.request,response:this,cause:n})})}))}textBody;get text(){return this.textBody??=Y(this.arrayBuffer,t=>new TextDecoder().decode(t))}get urlParamsBody(){return A(this.text,t=>No({try:()=>Mm(new URLSearchParams(t)),catch:n=>new Eo({reason:new wc({request:this.request,response:this,cause:n})})}))}formDataBody;get formData(){return this.formDataBody??=ys({try:()=>this.source.formData(),catch:t=>new Eo({reason:new wc({request:this.request,response:this,cause:t})})}).pipe(cx,li)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody?this.arrayBufferBody:(this.arrayBufferBody=ys({try:()=>this.source.arrayBuffer(),catch:t=>new Eo({reason:new wc({request:this.request,response:this,cause:t})})}).pipe(cx,li),this.arrayBufferBody)}pipe(){return ie(this,arguments)}};var D$=e=>d$({b3:`${e.traceId}-${e.spanId}-${e.sampled?"1":"0"}${rr(e.parent,{onNone:()=>"",onSome:t=>`-${t.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?"01":"00"}`});var L$="~effect/http/HttpClient";var zk=Ke("effect/HttpClient");var Eee=d(2,(e,t)=>Hk(n=>t(e.postprocess(n)),e.preprocess));var Hk=(e,t)=>{let n=Object.create(bee);return n.preprocess=t,n.postprocess=e,n.execute=function(r){return e(t(r))},n},bee={[L$]:L$,pipe(){return ie(this,arguments)},...Ks,toJSON(){return{_id:"effect/HttpClient"}},...Object.fromEntries(b$.map(([e,t])=>[t,function(n,r){return this.execute(C$(e)(n,r))}]))},B$=e=>Hk(t=>A(t,n=>xn(r=>{let o=kee.get(n),s=o??new AbortController,i=v$(n.url,n.urlParams,Ao(n.hash));if(Fe(i))return G(new Eo({reason:new CS({request:n,cause:i.failure})}));let a=i.success;if(r.getRef(wf)||r.getRef(wee)(n)){let u=e(n,a,s.signal,r);return o?u:go(f=>Kr(f(u),{onSuccess(l){return MS.register(l,s),v(new PS(l,s))},onFailure(l){return L0(l)&&s.abort(),ct(l)}}))}return cp(r.getRef(Tee)(n),{kind:"client"},u=>{u.attribute("http.request.method",n.method),u.attribute("server.address",a.origin),a.port!==""&&u.attribute("server.port",+a.port),u.attribute("url.full",a.toString()),u.attribute("url.path",a.pathname),u.attribute("url.scheme",a.protocol.slice(0,-1));let f=a.search.slice(1);f!==""&&u.attribute("url.query",f);let l=r.getRef(Ak),p=r.getRef(Iee);for(let m in n.headers)p(m,"request")&&u.attribute(`http.request.header.${m}`,Ck(m,l)?"<redacted>":n.headers[m]);return n=r.getRef(vee)?Lk(n,D$(u)):n,go(m=>m(e(n,a,s.signal,r)).pipe(Xf(u,{captureStackTrace:!1}),Kr({onSuccess:h=>{u.attribute("http.response.status_code",h.status);for(let g in h.headers)p(g,"response")&&u.attribute(`http.response.header.${g}`,Ck(g,l)?"<redacted>":h.headers[g]);return o?v(h):(MS.register(h,s),v(new PS(h,s)))},onFailure(h){return!o&&L0(h)&&s.abort(),ct(h)}})))})})),v),j$=d(2,(e,t)=>Hk(e.postprocess,n=>Y(e.preprocess(n),t)));var wee=Me("effect/http/HttpClient/TracerDisabledWhen",{defaultValue:()=>Pc}),Iee=Me("effect/http/HttpClient/TracerHeaderFilter",{defaultValue:()=>Xt}),vee=Me("effect/HttpClient/TracerPropagationEnabled",{defaultValue:Xt}),Tee=Me("effect/http/HttpClient/SpanNameGenerator",{defaultValue:()=>e=>`http.client ${e.method}`}),$$=e=>qr(zk)(cr(t=>Y(e,n=>Eee(n,ip(r=>Er(t,r)))))),MS=(()=>{if("FinalizationRegistry"in globalThis&&globalThis.FinalizationRegistry){let t=new FinalizationRegistry(n=>{n.abort()});return{register(n,r){t.register(n,r,n)},unregister(n){t.unregister(n)}}}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))}}})(),kee=new WeakMap,PS=class{original;controller;constructor(t,n){this.original=t,this.controller=n}[Gl]=Gl;[Zu]=Zu;applyInterrupt(t){return K(()=>(MS.unregister(this.original),ui(t,()=>se(()=>{this.controller.abort()}))))}get request(){return this.original.request}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return Fr(()=>(MS.unregister(this.original),Cm(this.original.stream,se(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[at](){return this.original[at]()}pipe(){return ie(this,arguments)}};var q$=Me("effect/http/FetchHttpClient/Fetch",{defaultValue:()=>globalThis.fetch}),FS=class extends Ke()("effect/http/FetchHttpClient/RequestInit"){},Cee=B$((e,t,n,r)=>{let o=r.getRef(q$),s=$i(r.context,FS)??{},i=s.headers?Vl(ki(s.headers),e.headers):e.headers;i["content-length"]&&(i=bc(i,"content-length"));let a=c=>Y(ys({try:()=>o(t,{...s,method:e.method,headers:i,body:c,duplex:e.body._tag==="Stream"?"half":void 0,signal:n}),catch:u=>new Eo({reason:new kS({request:e,cause:u})})}),u=>U$(e,u));switch(e.body._tag){case"Raw":case"Uint8Array":return a(e.body.body);case"FormData":return a(e.body.formData);case"Stream":return A(gk(e.body.stream),a)}return a(void 0)}),Aee=$$(v(Cee));var H$=Ke("effect/socket/Socket");var Kk="~effect/socket/Socket/CloseEvent",z$=class{[Kk];code;reason;constructor(t=1e3,n){this[Kk]=Kk,this.code=t,this.reason=n}toString(){return this.reason?`${this.code}: ${this.reason}`:`${this.code}`}};var DS="~effect/socket/Socket/SocketError",Oee=e=>B(e,DS),Vk=class extends qn("effect/socket/Socket/SocketReadError")({_tag:Ze("SocketReadError"),cause:ln()}){message="An error occurred during Read"},Jk=class extends qn("effect/socket/Socket/SocketWriteError")({_tag:Ze("SocketWriteError"),cause:ln()}){message="An error occurred during Write"},Pm=class extends qn("effect/socket/Socket/SocketOpenError")({_tag:Ze("SocketOpenError"),kind:Ea(["Unknown","Timeout"]),cause:ln()}){get message(){return this.kind==="Timeout"?'timeout waiting for "open"':"An error occurred during Open"}},Fm=class extends qn("effect/socket/Socket/SocketCloseError")({_tag:Ze("SocketCloseError"),code:js,closeReason:Pt(fe)}){static filterClean(t){return function(n){return Zl.is(n)&&n.reason._tag==="SocketCloseError"&&t(n.reason.code)?Ce(n.reason):Ae(n)}}get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},Gk=He([Vk,Jk,Pm,Fm]),Zl=class extends GT(DS)("SocketError",{_tag:Ze("SocketError"),reason:Gk}){constructor(t){"cause"in t.reason?super({...t,cause:t.reason.cause}):super(t)}[DS]=DS;static is(t){return Oee(t)}message=this.reason.message};var W$="~effect/reactivity/AsyncResult",K$=e=>B(e,W$),NS={[W$]:{E:L,A:L},pipe(){return ie(this,arguments)},[_e](e){if(this._tag!==e._tag||this.waiting!==e.waiting)return!1;switch(this._tag){case"Initial":return!0;case"Success":return ae(this.value,e.value);case"Failure":return ae(this.cause,e.cause)}},[Re](){let e=it(`${this._tag}:${this.waiting}`);return this._tag==="Initial"?e:Nt(e)(this._tag==="Success"?ce(this.value):ce(this.cause))}};var Qk=(e,t)=>e._tag==="Success"?Go(e.value):Yl(e.cause,{previous:t}),LS=e=>e._tag==="None"?Ia(!0):Um(e.value);var V$=e=>e._tag!=="Initial",Ia=(e=!1)=>{let t=Object.create(NS);return t._tag="Initial",t.waiting=e,t},Ql=e=>e._tag==="Success",Go=(e,t)=>{let n=Object.create(NS);return n._tag="Success",n.value=e,n.waiting=t?.waiting??!1,n.timestamp=t?.timestamp??Date.now(),n},J$=e=>e._tag==="Failure";var Zk=(e,t)=>{let n=Object.create(NS);return n._tag="Failure",n.cause=e,n.previousSuccess=t?.previousSuccess??U(),n.waiting=t?.waiting??!1,n},Yl=(e,t)=>Zk(e,{previousSuccess:rs(t.previous,n=>Ql(n)?N(n):J$(n)?n.previousSuccess:U()),waiting:t.waiting});var G$=(e,t)=>Yl(GM(e),t),Um=(e,t)=>{if(e.waiting)return t?.touch?_ee(e):e;let n=Object.assign(Object.create(NS),e);return n.waiting=!0,t?.touch&&Ql(n)&&(n.timestamp=Date.now()),n},_ee=e=>Ql(e)?Go(e.value,{waiting:e.waiting}):e,Dm=(e,t)=>e._tag==="Failure"?Yl(e.cause,{previous:t,waiting:e.waiting}):e,Yk=e=>e._tag==="Success"?N(e.value):e._tag==="Failure"?Lt(e.previousSuccess,t=>t.value):U();var Xk=e=>kd(Yk(e),()=>new $f("AsyncResult.getOrThrow: no value found"));var Xl=e=>{switch(e._tag){case"Success":return kn(e.value);case"Failure":return jt(e.cause);default:return Mo(new $f)}};var eC=e=>{let t=e.success??gc,n=e.error??gc,r=An()([t,Ll(n,ln())],([o,s])=>(i,a,c)=>{if(!K$(i))return G(new st(a,i,c));switch(i._tag){case"Initial":return v(i);case"Success":return fn(dt(o)(i.value,c),{onSuccess:u=>Go(u,i),onFailure:u=>Yn(a,"value",u,i,c)});case"Failure":{let u=i.previousSuccess.pipe(Lt(l=>fn(dt(o)(l.value,c),{onSuccess:p=>N(Go(p,l)),onFailure:p=>new At(a,[new Ct(["previousSuccess","value"],p)],i,c)})),Ua(()=>Ss)),f=yu(dt(s)(i.cause,c),l=>Yn(a,"cause",l,i,c));return Bn(u,l=>oa(f,p=>Zk(p,{previousSuccess:l,waiting:i.waiting})))}}},{expected:"AsyncResult",toCodec([o,s]){let i=yc("Success",{value:o,waiting:xc,timestamp:js});return pt()(He([yc("Initial",{waiting:xc}),i,yc("Failure",{cause:s,previousSuccess:wi(i),waiting:xc})]),vt({decode:a=>{switch(a._tag){case"Initial":return Ia(a.waiting);case"Success":return Go(a.value,{waiting:a.waiting,timestamp:a.timestamp});case"Failure":return Zk(a.cause,{previousSuccess:Lt(a.previousSuccess,c=>Go(c.value,c)),waiting:a.waiting})}},encode(a){switch(a._tag){case"Initial":return{_tag:"Initial",waiting:a.waiting};case"Success":return{_tag:"Success",value:a.value,waiting:a.waiting,timestamp:a.timestamp};case"Failure":return{_tag:"Failure",cause:a.cause,previousSuccess:a.previousSuccess,waiting:a.waiting}}}}))},toEquivalence:pd,toFormatter:([o,s])=>i=>{switch(i._tag){case"Success":return`AsyncResult.Success(${o(i.value)}, ${i.waiting}, ${i.timestamp})`;case"Failure":return`AsyncResult.Failure(${s(i.cause)}, ${i.waiting})`;case"Initial":return`AsyncResult.Initial(${i.waiting}, ${i.waiting})`}}});return Object.assign(r,{success:t,error:n})};var Lm="~effect/reactivity/AtomRegistry",Mee=e=>B(e,Lm),Z$=e=>new rC(e?.initialValues,e?.scheduleTask,e?.timeoutResolution,e?.defaultIdleTTL),BS=Ke(Lm);var jS=d(e=>Mee(e[0]),(e,t,n)=>{let r=n?.suspendOnWaiting??!1;return Es(o=>{let s=e.get(t);if(s._tag!=="Initial"&&!(r&&s.waiting))return o(Xl(s));let i=e.subscribe(t,a=>{a._tag!=="Initial"&&!(r&&a.waiting)&&(o(Xl(a)),i())});return se(i)})});var Pee={immediate:!0},Fee=e=>{e()},nC="~effect-atom/atom/Atom/Serializable",Nm=e=>nC in e?e[nC].key:e,rC=class{[Lm];timeoutResolution;defaultIdleTTL;scheduler;schedulerAsync;dispatcher;onNodeAdded;onNodeRemoved;constructor(t,n,r,o){if(this[Lm]=Lm,this.scheduler=new Qs("sync",n),this.schedulerAsync=new Qs("async",n),this.dispatcher=this.schedulerAsync.makeDispatcher(),this.defaultIdleTTL=o,r===void 0&&o!==void 0?this.timeoutResolution=Math.round(o/2):this.timeoutResolution=r??1e3,t!==void 0)for(let[s,i]of t){let a=s;for(;a.initialValueTarget;)a=a.initialValueTarget;this.ensureNode(a).setInitialValue(i)}}nodes=new Map;preloadedSerializable=new Map;timeoutBuckets=new Map;nodeTimeoutBucket=new Map;disposed=!1;getNodes(){return this.nodes}get(t){return this.ensureNode(t).value()}set(t,n){t.write(this.ensureNode(t).writeContext,n)}setSerializable(t,n){this.preloadedSerializable.set(t,n)}modify(t,n){let r=this.ensureNode(t),o=n(r.value());return t.write(r.writeContext,o[1]),o[0]}update(t,n){let r=this.ensureNode(t);t.write(r.writeContext,n(r.value()))}refresh=t=>{t.refresh!==void 0?t.refresh(this.refresh):this.invalidateAtom(t)};subscribe(t,n,r){let o=this.ensureNode(t);r?.immediate&&n(o.value());let s=o.subscribe(function(){n(o._value)});return()=>{s(),o.canBeRemoved&&this.scheduleNodeRemoval(o)}}mount(t){return this.subscribe(t,bn,Pee)}atomHasTtl(t){return!t.keepAlive&&t.idleTTL!==0&&(t.idleTTL!==void 0||this.defaultIdleTTL!==void 0)}ensureNode(t){let n=Nm(t),r=this.nodes.get(n);if(r===void 0?(r=this.createNode(t),this.nodes.set(n,r),this.onNodeAdded?.(r)):this.atomHasTtl(t)&&this.removeNodeTimeout(r),typeof n=="string"&&this.preloadedSerializable.has(n)){let o=this.preloadedSerializable.get(n);this.preloadedSerializable.delete(n);let s=t[nC].decode(o),i=t;for(;i.initialValueTarget;)i=i.initialValueTarget;i===t?r.setValue(s):this.ensureNode(i).setInitialValue(s)}return r}createNode(t){if(this.disposed)throw new Error(`Cannot access Atom ${t}: registry is disposed`);return t.keepAlive||this.scheduleAtomRemoval(t),new oC(this,t)}invalidateAtom=t=>{this.ensureNode(t).invalidate()};scheduleAtomRemoval(t){this.dispatcher.scheduleTask(()=>{let n=this.nodes.get(Nm(t));n!==void 0&&n.canBeRemoved&&this.removeNode(n)},0)}scheduleNodeRemoval(t){this.dispatcher.scheduleTask(()=>{t.canBeRemoved&&this.removeNode(t)},0)}removeNode(t){this.atomHasTtl(t.atom)?this.setNodeTimeout(t):(this.nodes.delete(Nm(t.atom)),t.remove(),this.onNodeRemoved?.(t))}setNodeTimeout(t){if(this.nodeTimeoutBucket.has(t))return;let n=t.atom.idleTTL??this.defaultIdleTTL;if(this.#e!==null&&(n-=this.#e,n<=0)){this.nodes.delete(Nm(t.atom)),t.remove(),this.onNodeRemoved?.(t);return}let r=Math.ceil(n/this.timeoutResolution)*this.timeoutResolution,o=Date.now()+r,s=o-o%this.timeoutResolution+this.timeoutResolution,i=this.timeoutBuckets.get(s);i===void 0&&(i=[new Set,setTimeout(()=>this.sweepBucket(s),s-Date.now())],this.timeoutBuckets.set(s,i)),i[0].add(t),this.nodeTimeoutBucket.set(t,s)}removeNodeTimeout(t){let n=this.nodeTimeoutBucket.get(t);if(n===void 0)return;this.nodeTimeoutBucket.delete(t),this.scheduleNodeRemoval(t);let[r,o]=this.timeoutBuckets.get(n);r.delete(t),r.size===0&&(clearTimeout(o),this.timeoutBuckets.delete(n))}#e=null;sweepBucket(t){let n=this.timeoutBuckets.get(t)[0];this.timeoutBuckets.delete(t),n.forEach(r=>{this.nodeTimeoutBucket.delete(r),r.canBeRemoved&&(this.nodes.delete(Nm(r.atom)),this.onNodeRemoved?.(r),this.#e=r.atom.idleTTL??this.defaultIdleTTL,r.remove(),this.#e=null)})}reset(){this.timeoutBuckets.forEach(([,t])=>clearTimeout(t)),this.timeoutBuckets.clear(),this.nodeTimeoutBucket.clear(),this.nodes.forEach(t=>{t.remove(),this.onNodeRemoved?.(t)}),this.nodes.clear()}dispose(){this.disposed=!0,this.reset()}},Zo={alive:1,initialized:2,waitingForValue:4},Ur={uninitialized:Zo.alive|Zo.waitingForValue,stale:Zo.alive|Zo.initialized|Zo.waitingForValue,valid:Zo.alive|Zo.initialized,removed:0},oC=class{constructor(t,n){this.registry=t,this.atom=n,this.writeContext=new sC(t,this)}registry;atom;state=Ur.uninitialized;lifetime;writeContext;preserveInitialValueOnBuild=!1;parents=new Set;previousParents;children=new Set;listeners=new Set;skipInvalidation=!1;building=!1;invalidatedDuringBuild=!1;currentState(){switch(this.state){case Ur.uninitialized:return"uninitialized";case Ur.stale:return"stale";case Ur.valid:return"valid";default:return"removed"}}get canBeRemoved(){return!this.atom.keepAlive&&this.listeners.size===0&&this.children.size===0&&this.state!==0}_value=void 0;value(){if((this.state&Zo.waitingForValue)!==0){this.lifetime=Nee(this),this.building=!0;let t=this.atom.read(this.lifetime);if(this.building=!1,(this.state&Zo.waitingForValue)!==0&&(this.preserveInitialValueOnBuild?(this.preserveInitialValueOnBuild=!1,this.state=Ur.valid):this.setValue(t)),this.previousParents){let n=this.previousParents;this.previousParents=void 0;for(let r of n)r.removeChild(this),r.canBeRemoved&&this.registry.scheduleNodeRemoval(r)}}return this._value}valueOption(){return(this.state&Zo.initialized)===0?U():N(this._value)}setInitialValue(t){if((this.state&Zo.initialized)===0){this.preserveInitialValueOnBuild=!0,this.state=Ur.stale,this._value=t,Qt.phase===Ai.collect?Qt.notify.add(this):this.notify();return}this.setValue(t)}setValue(t){if((this.state&Zo.initialized)===0){this.state=Ur.valid,this._value=t,Qt.phase===Ai.collect?Qt.notify.add(this):this.notify();return}this.state=Ur.valid,!this.atom.equals(this._value,t)&&(this._value=t,this.skipInvalidation?this.skipInvalidation=!1:this.invalidateChildren(),this.listeners.size>0&&(Qt.phase===Ai.collect?Qt.notify.add(this):this.notify()))}addParent(t){this.parents.add(t),this.previousParents!==void 0&&(this.previousParents.delete(t),this.previousParents.size===0&&(this.previousParents=void 0)),t.children.has(this)||(t.children.add(this),t.skipInvalidation&&(t.skipInvalidation=!1))}removeChild(t){this.children.delete(t)}invalidate(){this.building&&Qt.phase===Ai.collect&&(this.invalidatedDuringBuild=!0),this.state===Ur.valid&&(this.state=Ur.stale,this.disposeLifetime()),Qt.phase===Ai.collect?Qt.stale.push(this):this.atom.lazy&&this.listeners.size===0&&!Uee(this.children)?(this.invalidateChildren(),this.skipInvalidation=!0):this.value()}invalidateChildren(){if(this.children.size===0)return;let t=this.children;this.children=new Set;for(let n of t)n.invalidate()}notify(){this.listeners.forEach(Fee),Qt.phase===Ai.commit&&Qt.notify.delete(this)}disposeLifetime(){this.lifetime!==void 0&&(this.lifetime.dispose(),this.lifetime=void 0),this.parents.size!==0&&(this.previousParents=this.parents,this.parents=new Set)}remove(){if(this.state=Ur.removed,this.listeners.clear(),this.lifetime===void 0||(this.disposeLifetime(),this.previousParents===void 0))return;let t=this.previousParents;this.previousParents=void 0;for(let n of t)n.removeChild(this),n.canBeRemoved&&this.registry.removeNode(n)}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}};function Uee(e){if(e.size===0)return!1;let t=e,n,r=0;for(;t!==void 0;){for(let o of t){if(!o.atom.lazy||o.listeners.size>0)return!0;o.children.size>0&&(n===void 0?n=[o.children]:n.push(o.children))}t=n?.[r++]}return!1}var Dee={get registry(){return this.node.registry},addFinalizer(e){if(this.disposed)return e();this.finalizers??=[],this.finalizers.push(e)},get(e){if(this.disposed)return this.node.registry.get(e);let t=this.node.registry.ensureNode(e),n=t.value();return this.node.addParent(t),n},result(e,t){if(this.disposed||this.isFn)return this.resultOnce(e,t);let n=this.get(e);if(t?.suspendOnWaiting&&n.waiting)return Hr;switch(n._tag){case"Initial":return Hr;case"Failure":return jt(n.cause);case"Success":return v(n.value)}},resultOnce(e,t){return Es(n=>{let r=this.once(e);if(r._tag!=="Initial"&&!(t?.suspendOnWaiting&&r.waiting))return n(Xl(r));let o=this.node.registry.subscribe(e,s=>{s._tag==="Initial"||t?.suspendOnWaiting&&s.waiting||(o(),n(Xl(s)))},{immediate:!1});return se(o)})},setResult(e,t){return this.disposed?Hr:(this.node.registry.set(e,t),this.resultOnce(e,{suspendOnWaiting:!0}))},some(e){if(this.disposed||this.isFn)return this.someOnce(e);let t=this.get(e);return t._tag==="None"?Hr:v(t.value)},someOnce(e){return Es(t=>{let n=this.once(e);if(Te(n))return t(v(n.value));let r=this.node.registry.subscribe(e,o=>{ge(o)||(r(),t(v(o.value)))},{immediate:!1});return se(r)})},once(e){return this.node.registry.get(e)},self(){return this.disposed?U():this.node.valueOption()},refresh(e){this.disposed||this.node.registry.refresh(e)},refreshSelf(){this.disposed||this.node.invalidate()},mount(e){this.disposed||this.addFinalizer(this.node.registry.mount(e))},subscribe(e,t,n){this.disposed||this.addFinalizer(this.node.registry.subscribe(e,t,n))},setSelf(e){this.disposed||this.node.setValue(e)},set(e,t){this.disposed||this.node.registry.set(e,t)},stream(e,t){return this.disposed?vi:lS(n=>se(()=>{this.subscribe(e,r=>wl(n,r),{immediate:!t?.withoutInitialValue})}))},streamResult(e,t){return this.stream(e,t).pipe(ck(V$),Ju(n=>n._tag==="Success"?v(n.value):ct(n.cause)))},dispose(){if(this.disposed=!0,this.finalizers===void 0)return;let e=this.finalizers;this.finalizers=void 0;for(let t=e.length-1;t>=0;t--)e[t]()}},Nee=e=>{function t(n){if(t.disposed)return e.registry.get(n);if(t.isFn)return e.registry.get(n);let r=e.registry.ensureNode(n),o=r.value();return e.addParent(r),o}return Object.setPrototypeOf(t,Dee),t.isFn=!1,t.disposed=!1,t.finalizers=void 0,t.node=e,t},sC=class{constructor(t,n){this.registry=t,this.node=n}registry;node;get(t){return this.registry.get(t)}set(t,n){return this.registry.set(t,n)}setSelf(t){return this.node.setValue(t)}refreshSelf(){return this.node.invalidate()}},Ai={disabled:0,collect:1,commit:2},Qt={phase:Ai.disabled,depth:0,stale:[],notify:new Set};function Q$(e){Qt.phase=Ai.collect,Qt.depth++;try{if(e(),Qt.depth===1){for(let t=0;t<Qt.stale.length;t++)Y$(Qt.stale[t]);Qt.phase=Ai.commit;for(let t of Qt.notify)t.notify();Qt.notify.clear()}}finally{Qt.depth--,Qt.depth===0&&(Qt.phase=Ai.disabled,Qt.stale=[])}}function Y$(e){if(e.state===Ur.valid){if(!e.invalidatedDuringBuild)return;e.invalidatedDuringBuild=!1,e.state=Ur.stale,e.disposeLifetime()}for(let t of e.parents)t.state!==Ur.valid&&Y$(t);e.state!==Ur.valid&&e.value()}var ah={};Hs(ah,{ConnectionHooks:()=>ih,CurrentHeaders:()=>SE,Protocol:()=>Pi,layerProtocolHttp:()=>mre,layerProtocolSocket:()=>xre,layerProtocolWorker:()=>yre,make:()=>sA,makeNoSerialization:()=>Gz,makeProtocolHttp:()=>Zz,makeProtocolSocket:()=>Qz,makeProtocolWorker:()=>Yz,withHeaders:()=>pre});var Bm=class extends Ke()("effect/workers/Transferable/Collector"){},eq=()=>{let e=[],t=o=>{e.push(...o)},n=()=>e,r=()=>{let o=e;return e=[],o};return Bm.of({addAllUnsafe:t,addAll:o=>se(()=>t(o)),readUnsafe:n,read:se(n),clearUnsafe:r,clear:se(r)})};var iC="~effect/workers/WorkerError";var aC=class extends qn("effect/workers/WorkerError/WorkerSpawnError")({_tag:Ze("WorkerSpawnError"),message:fe,cause:Pt(ln())}){},cC=class extends qn("effect/workers/WorkerError/WorkerSendError")({_tag:Ze("WorkerSendError"),message:fe,cause:Pt(ln())}){},uC=class extends qn("effect/workers/WorkerError/WorkerReceiveError")({_tag:Ze("WorkerReceiveError"),message:fe,cause:Pt(ln())}){},fC=class extends qn("effect/workers/WorkerError/WorkerUnknownError")({_tag:Ze("WorkerUnknownError"),message:fe,cause:Pt(ln())}){},lC=He([aC,cC,uC,fC]),tq=class extends qn(iC)({_tag:Ze("WorkerError"),reason:lC}){constructor(t){super({...t,cause:t.reason.cause})}[iC]=iC;get message(){return this.reason.message}};var $S=class extends Ke()("effect/workers/Worker/WorkerPlatform"){};var vc={};Hs(vc,{ServerClient:()=>hC,custom:()=>zee,exitSchema:()=>gC,fork:()=>Kee,isRpc:()=>$ee,isWrapper:()=>ed,make:()=>rq,uninterruptible:()=>Vee,unwrap:()=>Hee,wrap:()=>HS,wrapMap:()=>Wee});var dC="~effect/rpc/RpcSchema/StreamSchema";function jm(e){return B(e,dC)}function qS(e){return jm(e)?N({success:e.success,error:e.error}):U()}var jee=eo(Ue);function nq(e,t){return re(jee.ast,{[dC]:dC,success:e,error:t})}var mC="~effect/rpc/Rpc",$ee=e=>B(e,mC),hC=class{id;annotations;constructor(t){this.id=t,this.annotations=bt()}annotate(t,n){return this.annotations=Ve(this.annotations,t,n),this}},qee={[mC]:mC,pipe(){return ie(this,arguments)},setSuccess(e){return Ic({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return Ic({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return Ic({_tag:this._tag,payloadSchema:zu(e)?e:oe(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return Ic({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},prefix(e){return Ic({_tag:`${e}${this._tag}`,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},annotate(e,t){return Ic({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:Ve(this.annotations,e,t)})},annotateMerge(e){return Ic({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:Er(this.annotations,e)})}},Ic=e=>{function t(){}return Object.setPrototypeOf(t,qee),Object.assign(t,e),t.key=`effect/rpc/Rpc/${e._tag}`,t},rq=(e,t)=>{let n=t?.success??ql,r=t?.error??gc,o=t?.defect??ln(),s;return t?.primaryKey?s=class extends cS(`effect/rpc/Rpc/${e}`)(t.payload){[$j](){return t.primaryKey(this)}}:s=zu(t?.payload)?t?.payload:t?.payload?oe(t?.payload):ql,Ic({_tag:e,payloadSchema:s,successSchema:t?.stream?nq(n,r):n,errorSchema:t?.stream?gc:r,defectSchema:o,annotations:bt(),middlewares:new Set})},zee=e=>(t,n)=>{let r=n?.success??ql,o=n?.error??gc,s=n?.defect??ln(),i=e({success:r,error:o,defect:s});return rq(t,{...i,primaryKey:n?.primaryKey,payload:n?.payload,stream:n?.stream})},pC=new WeakMap,gC=e=>{if(pC.has(e))return pC.get(e);let t=e,n=new Set([t.errorSchema]),r=qS(t.successSchema);Te(r)&&n.add(r.value.error);for(let s of t.middlewares)n.add(s.error);let o=iS(Te(r)?ql:t.successSchema,He([...n]),t.defectSchema);return pC.set(e,o),o},$m="~effect/rpc/Rpc/Wrapper",ed=e=>$m in e,HS=e=>t=>ed(t)?{[$m]:$m,value:t.value,fork:e.fork??t.fork,uninterruptible:e.uninterruptible??t.uninterruptible}:{[$m]:$m,value:t,fork:e.fork??!1,uninterruptible:e.uninterruptible??!1},Hee=e=>ed(e)?e.value:e,Wee=(e,t)=>ed(e)?HS(e)(t(e.value)):t(e),Kee=HS({fork:!0}),Vee=HS({uninterruptible:!0});var xC="~effect/rpc/RpcClientError",Tc=class extends qn("effect/rpc/RpcClientError/RpcClientDefect")({_tag:Ze("RpcClientDefect"),message:fe,cause:ln()}){},qs=class extends qn(xC)({_tag:Ze("RpcClientError"),reason:He([lC,Gk,Jl,Tc])}){[xC]=xC;get message(){return`${this.reason._tag}: ${this.reason.message}`}};var zm=e=>e;var oq={_tag:"Ping"};var qm=He([fe,$l]),Gee=oe({_tag:Ze("Request"),id:qm,tag:fe,payload:Vo,headers:Wt(mc([fe,fe])),isNotification:Pt(Ot(!0)),traceId:Pt(fe),spanId:Pt(fe),sampled:Pt(xc)}),yC=He([Gee,oe({_tag:Ze("Ack"),requestId:qm}),oe({_tag:Ze("Interrupt"),requestId:qm}),oe({_tag:Ze("Ping")}),oe({_tag:Ze("Eof")}),oe({_tag:Ze("Chunk"),requestId:qm,values:Vo}),oe({_tag:Ze("Exit"),requestId:qm,exit:Vo}),oe({_tag:Ze("Defect"),defect:Vo}),oe({_tag:Ze("Pong")})]);var SC=e=>{switch(e._tag){case"Exit":case"Defect":case"ClientProtocolError":return!0;default:return!1}};var sh={};Hs(sh,{MaxBufferSizeExceeded:()=>rh,RpcSerialization:()=>En,json:()=>jz,jsonRpc:()=>qz,layerJson:()=>ere,layerJsonRpc:()=>rre,layerMsgPack:()=>sre,layerMsgPackWith:()=>ire,layerNdJsonRpc:()=>ore,layerNdjson:()=>tre,layerNdjsonWith:()=>nre,layerSchemaBinary:()=>are,makeMsgPack:()=>oA,makeNdjson:()=>xE,msgPack:()=>Kz,ndJsonRpc:()=>zz,ndjson:()=>$z});var bC;try{bC=new TextDecoder}catch{}var Z,to,I=0;var gq=[],wC=gq,IC=0,mt={},We,kc,Qo=0,Oi=0,Hn,va,no=[],$e,iq={useRecords:!1,mapsAsObjects:!0},Hm=class{},TC=new Hm;TC.name="MessagePack 0xC1";var Cc=!1,aq=2;var Ri=class e{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.sequential&&t.trusted!==!1&&(t.trusted=!0,!t.structures&&t.useRecords!=!1&&(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0),t.int64AsNumber&&(t.int64AsType="number")),Object.assign(this,t)}unpack(t,n){if(Z)return bq(()=>(KS(),this?this.unpack(t,n):e.prototype.unpack.call(iq,t,n)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof n=="object"?(to=n.end||t.length,I=n.start||0):(I=0,to=n>-1?n:t.length),IC=0,Oi=0,kc=null,wC=gq,Hn=null,Z=t;try{$e=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw Z=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof e){if(mt=this,this.structures)return We=this.structures,WS(n);(!We||We.length>0)&&(We=[])}else mt=iq,(!We||We.length>0)&&(We=[]);return WS(n)}unpackMultiple(t,n){let r,o=0;try{Cc=!0;let s=t.length,i=this?this.unpack(t,s):JS.unpack(t,s);if(n){if(n(i,o,I)===!1)return;for(;I<s;)if(o=I,n(WS(),o,I)===!1)return}else{for(r=[i];I<s;)o=I,r.push(WS());return r}}catch(s){throw s.lastPosition=o,s.values=r,s}finally{Cc=!1,KS()}}_mergeStructures(t,n){this._onLoadedStructures&&(t=this._onLoadedStructures(t)),t=t||[],Object.isFrozen(t)&&(t=t.map(r=>r.slice(0)));for(let r=0,o=t.length;r<o;r++){let s=t[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in n||[])if(r>=0){let o=t[r],s=n[r];s&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[r]=o),t[r]=s)}return this.structures=t}decode(t,n){return this.unpack(t,n)}};function WS(e){try{if(!mt.trusted&&!Cc){let n=We.sharedLength||0;n<We.length&&(We.length=n)}let t;if(mt._readStruct&&Z[I]<64&&Z[I]>=32?(t=mt._readStruct(Z,I,to),Z=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),I=to):t=dn(),Hn&&(I=Hn.postBundlePosition,Hn=null),Cc&&(We.restoreStructures=null),I==to)We&&We.restoreStructures&&cq(),We=null,Z=null,va&&(va=null);else{if(I>to)throw new Error("Unexpected end of MessagePack data");if(!Cc){let n;try{n=JSON.stringify(t,(r,o)=>typeof o=="bigint"?`${o}n`:o).slice(0,100)}catch(r){n="(JSON view not available "+r+")"}throw new Error("Data read, but end of buffer not reached "+n)}}return t}catch(t){throw We&&We.restoreStructures&&cq(),KS(),(t instanceof RangeError||t.message.startsWith("Unexpected end of buffer")||I>to)&&(t.incomplete=!0),t}}function cq(){for(let e in We.restoreStructures)We[e]=We.restoreStructures[e];We.restoreStructures=null}function dn(){let e=Z[I++];if(e<160)if(e<128){if(e<64)return e;{let t=We[e&63]||mt.getStructures&&xq()[e&63];return t?(t.read||(t.read=kC(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,mt.mapsAsObjects){let t={};for(let n=0;n<e;n++){let r=Sq();r==="__proto__"&&(r="__proto_"),t[r]=dn()}return t}else{let t=new Map;for(let n=0;n<e;n++)t.set(dn(),dn());return t}else{e-=144;let t=new Array(e);for(let n=0;n<e;n++)t[n]=dn();return mt.freezeData?Object.freeze(t):t}else if(e<192){let t=e-160;if(Oi>=I)return kc.slice(I-Qo,(I+=t)-Qo);if(Oi==0&&to<140){let n=t<16?AC(t):yq(t);if(n!=null)return n}return vC(t)}else{let t;switch(e){case 192:return null;case 193:return Hn?(t=dn(),t>0?Hn[1].slice(Hn.position1,Hn.position1+=t):Hn[0].slice(Hn.position0,Hn.position0-=t)):TC;case 194:return!1;case 195:return!0;case 196:if(t=Z[I++],t===void 0)throw new Error("Unexpected end of buffer");return EC(t);case 197:return t=$e.getUint16(I),I+=2,EC(t);case 198:return t=$e.getUint32(I),I+=4,EC(t);case 199:return Qu(Z[I++]);case 200:return t=$e.getUint16(I),I+=2,Qu(t);case 201:return t=$e.getUint32(I),I+=4,Qu(t);case 202:if(t=$e.getFloat32(I),mt.useFloat32>2){let n=VS[(Z[I]&127)<<1|Z[I+1]>>7];return I+=4,(n*t+(t>0?.5:-.5)>>0)/n}return I+=4,t;case 203:return t=$e.getFloat64(I),I+=8,t;case 204:return Z[I++];case 205:return t=$e.getUint16(I),I+=2,t;case 206:return t=$e.getUint32(I),I+=4,t;case 207:return mt.int64AsType==="number"?(t=$e.getUint32(I)*4294967296,t+=$e.getUint32(I+4)):mt.int64AsType==="string"?t=$e.getBigUint64(I).toString():mt.int64AsType==="auto"?(t=$e.getBigUint64(I),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=$e.getBigUint64(I),I+=8,t;case 208:return $e.getInt8(I++);case 209:return t=$e.getInt16(I),I+=2,t;case 210:return t=$e.getInt32(I),I+=4,t;case 211:return mt.int64AsType==="number"?(t=$e.getInt32(I)*4294967296,t+=$e.getUint32(I+4)):mt.int64AsType==="string"?t=$e.getBigInt64(I).toString():mt.int64AsType==="auto"?(t=$e.getBigInt64(I),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=$e.getBigInt64(I),I+=8,t;case 212:if(t=Z[I++],t==114)return mq(Z[I++]&63);{let n=no[t];if(n)return n.read?(I++,n.read(dn())):n.noBuffer?(I++,n()):n(Z.subarray(I,++I));throw new Error("Unknown extension "+t)}case 213:return t=Z[I],t==114?(I++,mq(Z[I++]&63,Z[I++])):Qu(2);case 214:return Qu(4);case 215:return Qu(8);case 216:return Qu(16);case 217:return t=Z[I++],Oi>=I?kc.slice(I-Qo,(I+=t)-Qo):Qee(t);case 218:return t=$e.getUint16(I),I+=2,Oi>=I?kc.slice(I-Qo,(I+=t)-Qo):Yee(t);case 219:return t=$e.getUint32(I),I+=4,Oi>=I?kc.slice(I-Qo,(I+=t)-Qo):Xee(t);case 220:return t=$e.getUint16(I),I+=2,fq(t);case 221:return t=$e.getUint32(I),I+=4,fq(t);case 222:return t=$e.getUint16(I),I+=2,lq(t);case 223:return t=$e.getUint32(I),I+=4,lq(t);default:if(e>=224)return e-256;throw e===void 0?CC():new Error("Unknown MessagePack token "+e)}}}var Zee=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function kC(e,t){function n(){if(n.count++>aq){let o;try{o=e.read=new Function("r","return function(){return "+(mt.freezeData?"Object.freeze":"")+"({"+e.map(s=>s==="__proto__"?"__proto_:r()":Zee.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"})}")(dn)}catch{return aq=1/0,n()}return e.read0=o,e.highByte===0&&(e.read=uq(t,e.read)),o()}let r={};for(let o=0,s=e.length;o<s;o++){let i=e[o];i==="__proto__"&&(i="__proto_"),r[i]=dn()}return mt.freezeData?Object.freeze(r):r}return n.count=0,e.read0=n,e.highByte===0?uq(t,n):n}var uq=(e,t)=>function(){let n=Z[I++];if(n===0)return t();let r=e<32?-(e+(n<<5)):e+(n<<5),o=We[r]||xq()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=kC(o,e)),o.read()};function xq(){let e=bq(()=>(Z=null,mt.getStructures()));return We=mt._mergeStructures(e,We)}var vC=Wm,Qee=Wm,Yee=Wm,Xee=Wm;function Wm(e){let t;if(e<16&&(t=AC(e)))return t;if(e>64&&bC)return bC.decode(Z.subarray(I,I+=e));let n=I+e,r=[];for(t="";I<n;){let o=Z[I++];if((o&128)===0)r.push(o);else if((o&224)===192)if(o<194||I>=n||(Z[I]&192)!==128)r.push(65533);else{let s=Z[I++]&63;r.push((o&31)<<6|s)}else if((o&240)===224){let s=I<n?Z[I]:0;if(I>=n||(s&192)!==128||o===224&&s<160||o===237&&s>=160)r.push(65533);else if(I++,I>=n||(Z[I]&192)!==128)r.push(65533);else{let i=Z[I++]&63;r.push((o&31)<<12|(s&63)<<6|i)}}else if((o&248)===240){let s=I<n?Z[I]:0;if(o>244||I>=n||(s&192)!==128||o===240&&s<144||o===244&&s>=144)r.push(65533);else if(I++,I>=n||(Z[I]&192)!==128)r.push(65533);else{let i=Z[I++]&63;if(I>=n||(Z[I]&192)!==128)r.push(65533);else{let a=Z[I++]&63,c=(o&7)<<18|(s&63)<<12|i<<6|a;c-=65536,r.push(c>>>10&1023|55296),r.push(56320|c&1023)}}}else r.push(65533);r.length>=4096&&(t+=zn.apply(String,r),r.length=0)}return r.length>0&&(t+=zn.apply(String,r)),t}function CC(){let e=new Error("Unexpected end of MessagePack data");return e.incomplete=!0,e}function fq(e){if(e>to-I)throw CC();let t=new Array(e);for(let n=0;n<e;n++)t[n]=dn();return mt.freezeData?Object.freeze(t):t}function lq(e){if(e>(to-I)/2)throw CC();if(mt.mapsAsObjects){let t={};for(let n=0;n<e;n++){let r=Sq();r==="__proto__"&&(r="__proto_"),t[r]=dn()}return t}else{let t=new Map;for(let n=0;n<e;n++)t.set(dn(),dn());return t}}var zn=String.fromCharCode;function yq(e){let t=I,n=new Array(e);for(let r=0;r<e;r++){let o=Z[I++];if((o&128)>0){I=t;return}n[r]=o}return zn.apply(String,n)}function AC(e){if(e<4)if(e<2){if(e===0)return"";{let t=Z[I++];if((t&128)>1){I-=1;return}return zn(t)}}else{let t=Z[I++],n=Z[I++];if((t&128)>0||(n&128)>0){I-=2;return}if(e<3)return zn(t,n);let r=Z[I++];if((r&128)>0){I-=3;return}return zn(t,n,r)}else{let t=Z[I++],n=Z[I++],r=Z[I++],o=Z[I++];if((t&128)>0||(n&128)>0||(r&128)>0||(o&128)>0){I-=4;return}if(e<6){if(e===4)return zn(t,n,r,o);{let s=Z[I++];if((s&128)>0){I-=5;return}return zn(t,n,r,o,s)}}else if(e<8){let s=Z[I++],i=Z[I++];if((s&128)>0||(i&128)>0){I-=6;return}if(e<7)return zn(t,n,r,o,s,i);let a=Z[I++];if((a&128)>0){I-=7;return}return zn(t,n,r,o,s,i,a)}else{let s=Z[I++],i=Z[I++],a=Z[I++],c=Z[I++];if((s&128)>0||(i&128)>0||(a&128)>0||(c&128)>0){I-=8;return}if(e<10){if(e===8)return zn(t,n,r,o,s,i,a,c);{let u=Z[I++];if((u&128)>0){I-=9;return}return zn(t,n,r,o,s,i,a,c,u)}}else if(e<12){let u=Z[I++],f=Z[I++];if((u&128)>0||(f&128)>0){I-=10;return}if(e<11)return zn(t,n,r,o,s,i,a,c,u,f);let l=Z[I++];if((l&128)>0){I-=11;return}return zn(t,n,r,o,s,i,a,c,u,f,l)}else{let u=Z[I++],f=Z[I++],l=Z[I++],p=Z[I++];if((u&128)>0||(f&128)>0||(l&128)>0||(p&128)>0){I-=12;return}if(e<14){if(e===12)return zn(t,n,r,o,s,i,a,c,u,f,l,p);{let m=Z[I++];if((m&128)>0){I-=13;return}return zn(t,n,r,o,s,i,a,c,u,f,l,p,m)}}else{let m=Z[I++],h=Z[I++];if((m&128)>0||(h&128)>0){I-=14;return}if(e<15)return zn(t,n,r,o,s,i,a,c,u,f,l,p,m,h);let g=Z[I++];if((g&128)>0){I-=15;return}return zn(t,n,r,o,s,i,a,c,u,f,l,p,m,h,g)}}}}}function dq(){let e=Z[I++],t;if(e<192)t=e-160;else switch(e){case 217:t=Z[I++];break;case 218:t=$e.getUint16(I),I+=2;break;case 219:t=$e.getUint32(I),I+=4;break;default:throw new Error("Expected string")}return Wm(t)}function EC(e){return mt.copyBuffers?Uint8Array.prototype.slice.call(Z,I,I+=e):Z.subarray(I,I+=e)}function Qu(e){let t=Z[I++];if(no[t]){let n;return no[t](Z.subarray(I,n=I+=e),r=>{I=r;try{return dn()}finally{I=n}})}else throw new Error("Unknown extension type "+t)}var pq=new Array(4096);function Sq(){let e=Z[I++];if(e>=160&&e<192){if(e=e-160,Oi>=I)return kc.slice(I-Qo,(I+=e)-Qo);if(!(Oi==0&&to<180))return vC(e)}else return I--,Eq(dn());let t=(e<<5^(e>1?$e.getUint16(I):e>0?Z[I]:0))&4095,n=pq[t],r=I,o=I+e-3,s,i=0;if(n&&n.bytes==e){for(;r<o;){if(s=$e.getUint32(r),s!=n[i++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(s=Z[r++],s!=n[i++]){r=1879048192;break}if(r===o)return I=r,n.string;o-=3,r=I}for(n=[],pq[t]=n,n.bytes=e;r<o;)s=$e.getUint32(r),n.push(s),r+=4;for(o+=3;r<o;)s=Z[r++],n.push(s);let a=e<16?AC(e):yq(e);return a!=null?n.string=a:n.string=vC(e)}function Eq(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return e.toString();if(e==null)return e+"";if(mt.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(t=>["string","number","boolean","bigint"].includes(typeof t)))return e.flat().toString();throw new Error(`Invalid property type for record: ${typeof e}`)}var mq=(e,t)=>{let n=dn().map(Eq),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,n.highByte=t);let o=We[e];return o&&(o.isShared||Cc)&&((We.restoreStructures||(We.restoreStructures=[]))[e]=o),We[e]=n,n.read=kC(n,r),(n.read0||n.read)()};no[0]=()=>{};no[0].noBuffer=!0;no[66]=e=>{let t=e.byteLength%8||8,n=BigInt(e[0]&128?e[0]-256:e[0]);for(let r=1;r<t;r++)n<<=BigInt(8),n+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),o=(s,i)=>{let a=i-s;if(a<=40){let l=r.getBigUint64(s);for(let p=s+8;p<i;p+=8)l<<=BigInt(64),l|=r.getBigUint64(p);return l}let c=s+(a>>4<<3),u=o(s,c),f=o(c,i);return u<<BigInt((i-c)*8)|f};n=n<<BigInt((r.byteLength-t)*8)|o(t,r.byteLength)}return n};var hq={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null};no[101]=()=>{let e=dn();if(!hq[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return hq[e[0]](e[1],{cause:e[2]})};no[105]=e=>{if(mt.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=$e.getUint32(I-4);va||(va=new Map);let n=Z[I],r;n>=144&&n<160||n==220||n==221?r=[]:n>=128&&n<144||n==222||n==223?r=new Map:(n>=199&&n<=201||n>=212&&n<=216)&&Z[I+1]===115?r=new Set:r={};let o={target:r};va.set(t,o);let s=dn();if(o.used)Object.assign(r,s);else return o.target=s;if(r instanceof Map)for(let[i,a]of s.entries())r.set(i,a);if(r instanceof Set)for(let i of Array.from(s))r.add(i);return r};no[112]=e=>{if(mt.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=$e.getUint32(I-4),n=va.get(t);return n.used=!0,n.target};no[115]=()=>new Set(dn());var OC=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array"),ete=typeof globalThis=="object"?globalThis:window;no[116]=e=>{let t=e[0],n=Uint8Array.prototype.slice.call(e,1).buffer,r=OC[t];if(!r){if(t===16)return n;if(t===17)return new DataView(n);throw new Error("Could not find typed array for code "+t)}return new ete[r](n)};no[120]=()=>{let e=dn();return new RegExp(e[0],e[1])};var tte=[];no[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],n=I;return I+=t-e.length,Hn=tte,Hn=[dq(),dq()],Hn.position0=0,Hn.position1=0,Hn.postBundlePosition=I,I=n,dn()};no[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function bq(e){mt&&mt._onSaveState&&mt._onSaveState();let t=to,n=I,r=IC,o=Qo,s=Oi,i=kc,a=wC,c=va,u=Hn,f=new Uint8Array(Z.slice(0,to)),l=We,p=We.slice(0,We.length),m=mt,h=Cc,g=e();return to=t,I=n,IC=r,Qo=o,Oi=s,kc=i,wC=a,va=c,Hn=u,Z=f,Cc=h,We=l,We.splice(0,We.length,...p),mt=m,$e=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),g}function KS(){Z=null,va=null,We=null}var VS=new Array(147);for(let e=0;e<256;e++)VS[e]=+("1e"+Math.floor(45.15-e*.30103));var JS=new Ri({useRecords:!1}),nte=JS.unpack,rte=JS.unpackMultiple,ote=JS.unpack,GS={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},ste=new Float32Array(1),rpe=new Uint8Array(ste.buffer,0,4);Ri.SUPPORTS_STRUCT_HOOKS=!0;var QS;try{QS=new TextEncoder}catch{}var MC,PC,nd=typeof Buffer<"u",ZS=nd?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,Tq=nd?Buffer:Uint8Array,wq=nd?4294967296:2144337920,O,Km,Rt,k=0,hr,Yt=null,ite=21760,ate=/[\u0080-\uFFFF]/,td=Symbol("record-id"),Ac=class extends Ri{constructor(t){super(t),this.offset=0;let n,r,o,s,i,a=Tq.prototype.utf8Write?function(T,z){return O.utf8Write(T,z,O.byteLength-z)}:QS&&QS.encodeInto?function(T,z){return QS.encodeInto(T,O.subarray(z)).written}:!1,c=this;t||(t={});let u=t&&t.sequential,f=t.structures||t.saveStructures,l=t.maxSharedStructures;if(l==null&&(l=f?32:0),l>8160)throw new Error("Maximum maxSharedStructure is 8160");t.structuredClone&&t.moreTypes==null&&(this.moreTypes=!0);let p=t.maxOwnStructures;p==null&&(p=f?32:64),!this.structures&&t.useRecords!=!1&&(this.structures=[]);let m=l>32||p+l>64,h=l+64,g=l+p+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let x=[],b=0,E=0;this.pack=this.encode=function(T,z){if(O||(O=new ZS(8192),Rt=O.dataView||(O.dataView=new DataView(O.buffer,0,8192)),k=0),hr=O.length-10,hr-k<2048?(O=new ZS(O.length),Rt=O.dataView||(O.dataView=new DataView(O.buffer,0,O.length)),hr=O.length-10,k=0):k=k+7&2147483640,r=k,z&Oq&&(k+=z&255),i=c.structuredClone?new Map:null,c.bundleStrings&&typeof T!="string"?(Yt=[],Yt.size=1/0):Yt=null,s=c.structures,s){s.uninitialized&&(s=c._mergeStructures(c.getStructures()));let D=s.sharedLength||0;if(D>l)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+s.sharedLength);if(!s.transitions){s.transitions=Object.create(null);for(let V=0;V<D;V++){let be=s[V];if(!be)continue;let Ie,le=s.transitions;for(let ut=0,Et=be.length;ut<Et;ut++){let zs=be[ut];Ie=le[zs],Ie||(Ie=le[zs]=Object.create(null)),le=Ie}le[td]=V+64}this.lastNamedStructuresLength=D}u||(s.nextId=D+64)}o&&(o=!1);let F;try{c._writeStruct&&T&&typeof T=="object"?T.constructor===Object?q(T):T.constructor!==Map&&!Array.isArray(T)&&!PC.some(V=>T instanceof V)?q(c.useToJSON!==!1&&T.toJSON?T.toJSON():T):S(T):S(T);let D=Yt;if(Yt&&vq(r,S,0),i&&i.idsToInsert){let V=i.idsToInsert.sort((ut,Et)=>ut.offset>Et.offset?1:-1),be=V.length,Ie=-1;for(;D&&be>0;){let ut=V[--be].offset+r;ut<D.stringsPosition+r&&Ie===-1&&(Ie=0),ut>D.position+r?Ie>=0&&(Ie+=6):(Ie>=0&&(Rt.setUint32(D.position+r,Rt.getUint32(D.position+r)+Ie),Ie=-1),D=D.previous,be++)}Ie>=0&&D&&Rt.setUint32(D.position+r,Rt.getUint32(D.position+r)+Ie),k+=V.length*6,k>hr&&P(k),c.offset=k;let le=cte(O.subarray(r,k),V);return i=null,le}return c.offset=k,z&Cq?(O.start=r,O.end=k,O):O.subarray(r,k)}catch(D){throw F=D,D}finally{if(s&&(y(),o&&c.saveStructures)){let D=s.sharedLength||0,V=O.subarray(r,k),be=(c._prepareStructures||ute)(s,c);if(!F)return c.saveStructures(be,be.isCompatible)===!1?(s.uninitialized=!0,c.pack(T,z)):(c.lastNamedStructuresLength=D,O.length>1073741824&&(O=null),V)}O.length>1073741824&&(O=null),z&Aq&&(k=r)}};let y=()=>{E<10&&E++;let T=s.sharedLength||0;if(s.length>T&&!u&&(s.length=T),b>1e4)s.transitions=null,E=0,b=0,x.length>0&&(x=[]);else if(x.length>0&&!u){for(let z=0,F=x.length;z<F;z++)x[z][td]=0;x=[]}},w=T=>{var z=T.length;z<16?O[k++]=144|z:z<65536?(O[k++]=220,O[k++]=z>>8,O[k++]=z&255):(O[k++]=221,Rt.setUint32(k,z),k+=4);for(let F=0;F<z;F++)S(T[F])},S=T=>{k>hr&&(O=P(k));var z=typeof T,F;if(z==="string"){let D=T.length;if(Yt&&D>=4&&D<4096){if((Yt.size+=D)>ite){let le,ut=(Yt[0]?Yt[0].length*3+Yt[1].length:0)+10;k+ut>hr&&(O=P(k+ut));let Et;Yt.position?(Et=Yt,O[k]=200,k+=3,O[k++]=98,le=k-r,k+=4,vq(r,S,0),Rt.setUint16(le+r-3,k-r-le)):(O[k++]=214,O[k++]=98,le=k-r,k+=4),Yt=["",""],Yt.previous=Et,Yt.size=0,Yt.position=le}let Ie=ate.test(T);Yt[Ie?0:1]+=T,O[k++]=193,S(Ie?-D:D);return}let V;D<32?V=1:D<256?V=2:D<65536?V=3:V=5;let be=D*3;if(k+be>hr&&(O=P(k+be)),D<64||!a){let Ie,le,ut,Et=k+V;for(Ie=0;Ie<D;Ie++)le=T.charCodeAt(Ie),le<128?O[Et++]=le:le<2048?(O[Et++]=le>>6|192,O[Et++]=le&63|128):(le&64512)===55296&&((ut=T.charCodeAt(Ie+1))&64512)===56320?(le=65536+((le&1023)<<10)+(ut&1023),Ie++,O[Et++]=le>>18|240,O[Et++]=le>>12&63|128,O[Et++]=le>>6&63|128,O[Et++]=le&63|128):(O[Et++]=le>>12|224,O[Et++]=le>>6&63|128,O[Et++]=le&63|128);F=Et-k-V}else F=a(T,k+V);F<32?O[k++]=160|F:F<256?(V<2&&O.copyWithin(k+2,k+1,k+1+F),O[k++]=217,O[k++]=F):F<65536?(V<3&&O.copyWithin(k+3,k+2,k+2+F),O[k++]=218,O[k++]=F>>8,O[k++]=F&255):(V<5&&O.copyWithin(k+5,k+3,k+3+F),O[k++]=219,Rt.setUint32(k,F),k+=4),k+=F}else if(z==="number")if(T>>>0===T)T<32||T<128&&this.useRecords===!1||T<64&&!this._writeStruct?O[k++]=T:T<256?(O[k++]=204,O[k++]=T):T<65536?(O[k++]=205,O[k++]=T>>8,O[k++]=T&255):(O[k++]=206,Rt.setUint32(k,T),k+=4);else if(T>>0===T)T>=-32?O[k++]=256+T:T>=-128?(O[k++]=208,O[k++]=T+256):T>=-32768?(O[k++]=209,Rt.setInt16(k,T),k+=2):(O[k++]=210,Rt.setInt32(k,T),k+=4);else{let D;if((D=this.useFloat32)>0&&T<4294967296&&T>=-2147483648){O[k++]=202,Rt.setFloat32(k,T);let V;if(D<4||(V=T*VS[(O[k]&127)<<1|O[k+1]>>7])>>0===V){k+=4;return}else k--}O[k++]=203,Rt.setFloat64(k,T),k+=8}else if(z==="object"||z==="function")if(!T)O[k++]=192;else{if(i){let V=i.get(T);if(V){if(!V.id){let be=i.idsToInsert||(i.idsToInsert=[]);V.id=be.push(V)}O[k++]=214,O[k++]=112,Rt.setUint32(k,V.id),k+=4;return}else i.set(T,{offset:k-r})}let D=T.constructor;if(D===Object)M(T);else if(D===Array)w(T);else if(D===Map)if(this.mapAsEmptyObject)O[k++]=128;else{F=T.size,F<16?O[k++]=128|F:F<65536?(O[k++]=222,O[k++]=F>>8,O[k++]=F&255):(O[k++]=223,Rt.setUint32(k,F),k+=4);for(let[V,be]of T)S(V),S(be)}else{for(let V=0,be=MC.length;V<be;V++){let Ie=PC[V];if(T instanceof Ie){let le=MC[V];if(le.write){le.type&&(O[k++]=212,O[k++]=le.type,O[k++]=0);let ad=le.write.call(this,T);ad===T?Array.isArray(T)?w(T):M(T):S(ad);return}let ut=O,Et=Rt,zs=k;O=null;let Ca;try{Ca=le.pack.call(this,T,ad=>(O=ut,ut=null,k+=ad,k>hr&&P(k),{target:O,targetView:Rt,position:k-ad}),S)}finally{ut&&(O=ut,Rt=Et,k=zs,hr=O.length-10)}Ca&&(Ca.length+k>hr&&P(Ca.length+k),k=Iq(Ca,O,k,le.type));return}}if(Array.isArray(T))w(T);else{if(c.useToJSON!==!1&&T.toJSON){let V=T.toJSON();if(V!==T)return S(V)}if(z==="function")return S(this.writeFunction&&this.writeFunction(T));M(T)}}}else if(z==="boolean")O[k++]=T?195:194;else if(z==="bigint"){if(T<9223372036854776e3&&T>=-9223372036854776e3)O[k++]=211,Rt.setBigInt64(k,T);else if(T<18446744073709552e3&&T>0)O[k++]=207,Rt.setBigUint64(k,T);else if(this.largeBigIntToFloat)O[k++]=203,Rt.setFloat64(k,Number(T));else{if(this.largeBigIntToString)return S(T.toString());if(this.useBigIntExtension||this.moreTypes){let D=T<0?BigInt(-1):BigInt(0),V;if(T>>BigInt(65536)===D){let be=BigInt(18446744073709552e3)-BigInt(1),Ie=[];for(;Ie.push(T&be),T>>BigInt(63)!==D;)T>>=BigInt(64);V=new Uint8Array(new BigUint64Array(Ie).buffer),V.reverse()}else{let be=T<0,Ie=(be?~T:T).toString(16);if(Ie.length%2?Ie="0"+Ie:parseInt(Ie.charAt(0),16)>=8&&(Ie="00"+Ie),nd)V=Buffer.from(Ie,"hex");else{V=new Uint8Array(Ie.length/2);for(let le=0;le<V.length;le++)V[le]=parseInt(Ie.slice(le*2,le*2+2),16)}if(be)for(let le=0;le<V.length;le++)V[le]=~V[le]}V.length+k>hr&&P(V.length+k),k=Iq(V,O,k,66);return}else throw new RangeError(T+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string")}k+=8}else if(z==="undefined")this.encodeUndefinedAsNil?O[k++]=192:(O[k++]=212,O[k++]=0,O[k++]=0);else throw new Error("Unknown type: "+z)},C=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?T=>{let z;if(this.skipValues){z=[];for(let V in T)(typeof T.hasOwnProperty!="function"||T.hasOwnProperty(V))&&!this.skipValues.includes(T[V])&&z.push(V)}else z=Object.keys(T);let F=z.length;F<16?O[k++]=128|F:F<65536?(O[k++]=222,O[k++]=F>>8,O[k++]=F&255):(O[k++]=223,Rt.setUint32(k,F),k+=4);let D;if(this.coercibleKeyAsNumber)for(let V=0;V<F;V++){D=z[V];let be=Number(D);S(isNaN(be)?D:be),S(T[D])}else for(let V=0;V<F;V++)S(D=z[V]),S(T[D])}:T=>{O[k++]=222;let z=k-r;k+=2;let F=0;for(let D in T)(typeof T.hasOwnProperty!="function"||T.hasOwnProperty(D))&&(S(D),S(T[D]),F++);if(F>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');O[z+++r]=F>>8,O[z+r]=F&255},_=this.useRecords===!1?C:t.progressiveRecords&&!m?T=>{let z,F=s.transitions||(s.transitions=Object.create(null)),D=k++-r,V;for(let be in T)if(typeof T.hasOwnProperty!="function"||T.hasOwnProperty(be)){if(z=F[be],z)F=z;else{let Ie=Object.keys(T),le=F;F=s.transitions;let ut=0;for(let Et=0,zs=Ie.length;Et<zs;Et++){let Ca=Ie[Et];z=F[Ca],z||(z=F[Ca]=Object.create(null),ut++),F=z}D+r+1==k?(k--,te(F,Ie,ut)):ee(F,Ie,D,ut),V=!0,F=le[be]}S(T[be])}if(!V){let be=F[td];be?O[D+r]=be:ee(F,Object.keys(T),D,0)}}:T=>{let z,F=s.transitions||(s.transitions=Object.create(null)),D=0;for(let be in T)(typeof T.hasOwnProperty!="function"||T.hasOwnProperty(be))&&(z=F[be],z||(z=F[be]=Object.create(null),D++),F=z);let V=F[td];V?V>=96&&m?(O[k++]=((V-=96)&31)+96,O[k++]=V>>5):O[k++]=V:te(F,F.__keys__||Object.keys(T),D);for(let be in T)(typeof T.hasOwnProperty!="function"||T.hasOwnProperty(be))&&S(T[be])},R=typeof this.useRecords=="function"&&this.useRecords,M=R?T=>{R(T)?_(T):C(T)}:_,q=T=>{let z=c._writeStruct(T,O,r,k,s,P,(F,D,V)=>{if(V)return o=!0;k=D;let be=O;return S(F),y(),be!==O?{position:k,targetView:Rt,target:O}:k});if(z===0)return M(T);k=z},P=T=>{let z;if(T>16777216){if(T-r>wq)throw new Error("Packed buffer would be larger than maximum buffer size");z=Math.min(wq,Math.round(Math.max((T-r)*(T>67108864?1.25:2),4194304)/4096)*4096)}else z=(Math.max(T-r<<2,O.length-1)>>12)+1<<12;let F=new ZS(z);return Rt=F.dataView||(F.dataView=new DataView(F.buffer,0,z)),T=Math.min(T,O.length),O.copy?O.copy(F,0,r,T):F.set(O.slice(r,T)),k-=r,r=0,hr=F.length-10,O=F},te=(T,z,F)=>{let D=s.nextId;D||(D=64),D<h&&this.shouldShareStructure&&!this.shouldShareStructure(z)?(D=s.nextOwnId,D<g||(D=h),s.nextOwnId=D+1):(D>=g&&(D=h),s.nextId=D+1);let V=z.highByte=D>=96&&m?D-96>>5:-1;T[td]=D,T.__keys__=z,s[D-64]=z,D<h?(z.isShared=!0,s.sharedLength=D-63,o=!0,V>=0?(O[k++]=(D&31)+96,O[k++]=V):O[k++]=D):(V>=0?(O[k++]=213,O[k++]=114,O[k++]=(D&31)+96,O[k++]=V):(O[k++]=212,O[k++]=114,O[k++]=D),F&&(b+=E*F),x.length>=p&&(x.shift()[td]=0),x.push(T),S(z))},ee=(T,z,F,D)=>{let V=O,be=k,Ie=hr,le=r;O=Km,k=0,r=0,O||(Km=O=new ZS(8192)),hr=O.length-10,te(T,z,D),Km=O;let ut=k;if(O=V,k=be,hr=Ie,r=le,ut>1){let Et=k+ut-1;Et>hr&&P(Et);let zs=F+r;O.copyWithin(zs+ut,zs+1,k),O.set(Km.slice(0,ut),zs),k=Et}else O[F+r]=Km[0]}}useBuffer(t){O=t,O.dataView||(O.dataView=new DataView(O.buffer,O.byteOffset,O.byteLength)),Rt=O.dataView,k=0}set position(t){k=t}get position(){return k}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}};PC=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,Hm];MC=[{pack(e,t,n){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:s,position:i}=t(6);o[i++]=214,o[i++]=255,s.setUint32(i,r)}else if(r>0&&r<4294967296){let{target:o,targetView:s,position:i}=t(10);o[i++]=215,o[i++]=255,s.setUint32(i,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(i+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),n(this.onInvalidDate());let{target:o,targetView:s,position:i}=t(3);o[i++]=212,o[i++]=255,o[i++]=255}else{let{target:o,targetView:s,position:i}=t(15);o[i++]=199,o[i++]=12,o[i++]=255,s.setUint32(i,e.getMilliseconds()*1e6),s.setBigInt64(i+4,BigInt(Math.floor(r)))}}},{pack(e,t,n){if(this.setAsEmptyObject)return t(0),n({});let r=Array.from(e),{target:o,position:s}=t(this.moreTypes?3:0);this.moreTypes&&(o[s++]=212,o[s++]=115,o[s++]=0),n(r)}},{pack(e,t,n){let{target:r,position:o}=t(this.moreTypes?3:0);this.moreTypes&&(r[o++]=212,r[o++]=101,r[o++]=0),n([e.name,e.message,e.cause])}},{pack(e,t,n){let{target:r,position:o}=t(this.moreTypes?3:0);this.moreTypes&&(r[o++]=212,r[o++]=120,r[o++]=0),n([e.source,e.flags])}},{pack(e,t){this.moreTypes?RC(e,16,t):_C(nd?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let n=e.constructor;n!==Tq&&this.moreTypes?RC(e,OC.indexOf(n.name),t):_C(e,t)}},{pack(e,t){this.moreTypes?RC(e,17,t):_C(nd?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:n,position:r}=t(1);n[r]=193}}];function RC(e,t,n,r){let o=e.byteLength;if(o+1<256){var{target:s,position:i}=n(4+o);s[i++]=199,s[i++]=o+1}else if(o+1<65536){var{target:s,position:i}=n(5+o);s[i++]=200,s[i++]=o+1>>8,s[i++]=o+1&255}else{var{target:s,position:i,targetView:a}=n(7+o);s[i++]=201,a.setUint32(i,o+1),i+=4}s[i++]=116,s[i++]=t,e.buffer||(e=new Uint8Array(e)),s.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),i)}function _C(e,t){let n=e.byteLength;var r,o;if(n<256){var{target:r,position:o}=t(n+2);r[o++]=196,r[o++]=n}else if(n<65536){var{target:r,position:o}=t(n+3);r[o++]=197,r[o++]=n>>8,r[o++]=n&255}else{var{target:r,position:o,targetView:s}=t(n+5);r[o++]=198,s.setUint32(o,n),o+=4}r.set(e,o)}function Iq(e,t,n,r){let o=e.length;switch(o){case 1:t[n++]=212;break;case 2:t[n++]=213;break;case 4:t[n++]=214;break;case 8:t[n++]=215;break;case 16:t[n++]=216;break;default:o<256?(t[n++]=199,t[n++]=o):o<65536?(t[n++]=200,t[n++]=o>>8,t[n++]=o&255):(t[n++]=201,t[n++]=o>>24,t[n++]=o>>16&255,t[n++]=o>>8&255,t[n++]=o&255)}return t[n++]=r,t.set(e,n),n+=o,n}function cte(e,t){let n,r=t.length*6,o=e.length-r;for(;n=t.pop();){let s=n.offset,i=n.id;e.copyWithin(s+r,s,o),r-=6;let a=s+r;e[a++]=214,e[a++]=105,e[a++]=i>>24,e[a++]=i>>16&255,e[a++]=i>>8&255,e[a++]=i&255,o=s}return e}function vq(e,t,n){if(Yt.length>0){Rt.setUint32(Yt.position+e,k+n-Yt.position-e),Yt.stringsPosition=k-e;let r=Yt;Yt=null,t(r[0]),t(r[1])}}function ute(e,t){return e.isCompatible=n=>{let r=!n||(t.lastNamedStructuresLength||0)===n.length;return r||t._mergeStructures(n),r},e}Ac.SUPPORTS_STRUCT_HOOKS=!0;var kq=new Ac({useRecords:!1}),fte=kq.pack,lte=kq.pack;var{NEVER:dte,ALWAYS:pte,DECIMAL_ROUND:mte,DECIMAL_FIT:hte}=GS,Cq=512,Aq=1024,Oq=2048;function Jq(e,t){let{exact:n,layout:r,recursive:o,target:s}=sd(e),i=Xu(r,t?.fingerprint),a=n?{value:void 0}:void 0;return UC(a===void 0?s:Hne(s,a,!o),r,i,a)}function VC(e,t){let{exact:n,exitSuccess:r,layout:o,target:s}=sd(e);if(!n){if(!r)return Jq(e,t);let i={value:void 0};return UC(Kne(s,i),o,Xu(o,t?.fingerprint),i,!0)}return UC(Vne(s),o,Xu(o,t?.fingerprint),void 0)}function UC(e,t,n,r,o=!1){return Vo.pipe(Ee(e,$ne(t,n,r,o)))}function Gq(e,t){let{exact:n,exitSuccess:r,layout:o}=sd(e),s=Xu(o,t?.fingerprint),i=t??Qr;if(!n){let a=nS(Jq(e,t),t);return!r||i.onExcessProperty==="error"?a:c=>{if(!hE(c))return a(c);try{return fE(o,c,i,s)}catch(u){throw u instanceof Mi?new Mr(u.issue):u}}}return a=>{try{return fE(o,a,i,s)}catch(c){throw c instanceof Mi?new Mr(c.issue):c}}}function xte(e,t){let{exact:n,layout:r}=sd(e);if(!n){let i=Gq(e,t);return a=>yte(a.map(i))}let o=Xu(r,t?.fingerprint),s=t??Qr;return i=>{try{return kz(r,i,s,o)}catch(a){throw a instanceof Mi?new Mr(a.issue):a}}}function yte(e){if(e.length===1)return e[0];let t=0;for(let o of e)t+=o.length;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.length;return n}function Zq(e,t){let{exact:n,exitSuccess:r,layout:o,target:s}=sd(e),i=t??Qr,a=n?void 0:eS(s,i),c=a!==void 0&&r?u=>hE(u)?u:a(u):a;return Ste(o,Xu(o,t?.fingerprint),i,t?.maxFrameSize,c,Qq(n,t))}function Qq(e,t){if(t?.dictionary!==!0)return!1;if(!e)throw new Error("Binary layout: dictionary needs a schema the binary layer validates on its own");return!0}function Yq(e,t){let{exact:n,layout:r}=sd(e),o=Qq(n,t),s=Gq(e,t),i=xte(e,t);if(!o)return{encode:s,encodeMany:i};let a=Xu(r,t?.fingerprint),c=t??Qr,u=dne(),f=l=>{try{return l()}catch(p){throw p instanceof Mi?new Mr(p.issue):p}};return{encode:l=>f(()=>fE(r,l,c,a,u)),encodeMany:l=>f(()=>kz(r,l,c,a,u))}}function Ste(e,t,n,r,o,s){let i=s?[]:void 0,a=new Uint8Array(0),c=0,u=0,f,l=!1,p=new Gm,m=new Jm(n,Lte),h=()=>{p.release(),m.clear(),a=jC,c=u=0},g=(y,w)=>{throw new Mr(new ke({expected:y},w,n))},x=()=>{let y=f;throw f=void 0,y},b=(y,w)=>{let S=y.length-w;S>a.length&&(a=new Uint8Array(Math.max(256,S))),a.set(w===0?y:y.subarray(w),0),c=0,u=S},E={feedSync(y){if(f!==void 0)return x();if(l)return g("parser is spent");let w=u===c,S,C,_;if(w)S=y,C=0,_=y.length;else{if(y.length>0){let P=u-c,te=P+y.length;if(te>a.length){let ee=new Uint8Array(Math.max(256,a.length*2,te));ee.set(a.subarray(c,u)),a=ee,c=0,u=P}else c>0&&(a.copyWithin(0,c,u),c=0,u=P);a.set(y,u),u+=y.length}S=a,C=c,_=u}let R=[],M=()=>(w?C<_&&b(y,C):(c=C,c===u&&(c=u=0)),R),q=(P,te)=>{l=!0;let ee=new Mr(new ke({expected:P},te,n));if(h(),R.length===0)throw ee;return f=ee,R};for(;;){let P=0,te=-1,ee=_-C,T=1;for(let F=0;F<Math.min(6,ee);F++){let D=S[C+F];if(P+=(D&127)*T,(D&128)===0){te=F+1;break}T*=128}if(te===-1){if(ee<6)return M();let F=BigInt(P);for(let D=6;D<Math.min(10,ee);D++){let V=S[C+D];if(F|=BigInt(V&127)<<BigInt(D*7),(V&128)===0){if(te=D+1,F>DC)return q("safe integer length",F);P=Number(F);break}}if(te===-1)return ee>=10?q("uvarint",S.subarray(C,C+10)):M()}if(P===0)return q("nonzero frame length",P);if(r!==void 0&&P>r)return q("frame within maxFrameSize",P);if(te+P>ee)return M();let z=ue;try{ue=0;let F=C+te;m.beginFrame(),p.reset(S,F,F+P,n,m,t.positional,i);let D=Fz(e,p,t);R.push(o===void 0?D:o(D))}catch(F){l=!0,h();let D=F instanceof Mi?new Mr(F.issue):Bl(F)?F:(()=>{throw F})();if(R.length===0)throw D;return f=D,R}finally{ue=z}C+=te+P}},endSync(){if(f!==void 0)return x();if(l)return g("parser is spent");l=!0;let y=c<u?a.subarray(c,u):void 0;if(h(),y!==void 0)return g("complete value",y)},feed:y=>K(()=>{try{return v(E.feedSync(y))}catch(w){if(Bl(w))return G(w);throw w}}),end:K(()=>{try{return E.endSync(),H}catch(y){if(Bl(y))return G(y);throw y}})};return E}var Ete="~effect/encoding/SchemaBinary/fieldId",bte=32,wte=33,DC=BigInt(Number.MAX_SAFE_INTEGER),oE=BigInt(0),Yo=BigInt(1),Ite=BigInt(2),Xq=BigInt(7),Rq=BigInt(127),vte=BigInt(1e6),Tte=BigInt(255),_q=BigInt(4294967295),kte=BigInt(32),_i=new TextEncoder,Cte=new TextDecoder("utf-8",{fatal:!0}),ez=7,Mq=0xffffffffffff,Ate=0xfffffffffffff,tz=0,nz=1,rz=2,ef=0,Yu=1,Ym=2,Xm=3,eh=4,th=5,Ote=6,Rte=7,Xo=8;function JC(e){return typeof e=="number"&&Number.isInteger(e)&&e>=-Mq&&e<=Mq}var lE=8,NC=2199023255551,Rc=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];function GC(e){for(let t=1;t<=lE;t++){let n=Math.round(e*Rc[t]);if(!(n>=-NC&&n<=NC))return 0;if(n/Rc[t]===e)return t}return 0}function oz(e){let t=Math.floor(e/2);return e%2===1?-t:t}var St={bool:1,null:2,undefined:3,number:4,string:5,bytes:6,bigint:7,int64:8,struct:9,variant:10,array:11,option:12,result:13,duration:14,bigDecimal:15,dateTimeZoned:16,json:17,exit:18,cause:19,causeReason:20};function sz(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e[n],16777619);return t>>>0}var _te=BigInt("14695981039346656037"),Mte=BigInt("1099511628211"),Pte=BigInt("18446744073709551615");function Pq(e){let t=_te;for(let n=0;n<e.length;n++)t=(t^BigInt(e[n]))*Mte&Pte;return t}function sE(e,t){for(let n=0;n<t.length;n++)e.push(t[n])}function Oc(e,t){for(;t>127;)e.push(t&127|128),t=Math.floor(t/128);e.push(t)}function iE(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}function bo(e,t){for(let n=0;n<8;n++)e.push(Number(t>>BigInt(n*8)&Tte))}function iz(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e[r]-t[r];return e.length-t.length}var Mi=class extends Error{issue;constructor(t){super("SchemaBinary failure"),this.issue=t}};function Q(e,t,n){throw pn(new ke({expected:e},t,n))}var nt=[],ue=0;function pn(e){return new Mi(ue===0?e:new Ct(nt.slice(0,ue),e))}function Fte(e){let t=new Uint8Array(az(e)),n=0;for(;e>127;)t[n++]=e&127|128,e=Math.floor(e/128);return t[n]=e,t}function az(e){let t=1;for(;e>127;)e=Math.floor(e/128),t++;return t}var Ute=32;function Dte(e,t,n,r){let o=n-t;if(o===0)return"";if(o<=Ute){let s=Nte(e,t,n);if(s!==void 0)return s}try{return Cte.decode(e.subarray(t,n))}catch{Q("utf-8",void 0,r)}}function Nte(e,t,n){let r="",o=t;for(;o+16<=n;o+=16){let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],l=e[o+6],p=e[o+7],m=e[o+8],h=e[o+9],g=e[o+10],x=e[o+11],b=e[o+12],E=e[o+13],y=e[o+14],w=e[o+15];if((s|i|a|c|u|f|l|p|m|h|g|x|b|E|y|w)>127)return;r+=String.fromCharCode(s,i,a,c,u,f,l,p,m,h,g,x,b,E,y,w)}if(o+8<=n){let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],l=e[o+6],p=e[o+7];if((s|i|a|c|u|f|l|p)>127)return;r+=String.fromCharCode(s,i,a,c,u,f,l,p),o+=8}switch(n-o){case 0:return r;case 1:{let s=e[o];return s>127?void 0:r+String.fromCharCode(s)}case 2:{let s=e[o],i=e[o+1];return(s|i)>127?void 0:r+String.fromCharCode(s,i)}case 3:{let s=e[o],i=e[o+1],a=e[o+2];return(s|i|a)>127?void 0:r+String.fromCharCode(s,i,a)}case 4:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3];return(s|i|a|c)>127?void 0:r+String.fromCharCode(s,i,a,c)}case 5:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4];return(s|i|a|c|u)>127?void 0:r+String.fromCharCode(s,i,a,c,u)}case 6:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5];return(s|i|a|c|u|f)>127?void 0:r+String.fromCharCode(s,i,a,c,u,f)}default:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],l=e[o+6];return(s|i|a|c|u|f|l)>127?void 0:r+String.fromCharCode(s,i,a,c,u,f,l)}}}var LC=64*1024,Lte=256,Bte=512,jte=16*1024;function BC(e){let t=new Uint8Array(e);return{buf:t,view:new DataView(t.buffer),offset:0,writing:!1}}var Vm=BC(LC),aE=class{buf=new Uint8Array(0);view=new DataView(this.buf.buffer);arena;start=0;limit=0;len=0;reset(){let t=Vm;(t.writing||t.offset>=t.buf.length)&&(t=Vm=BC(LC)),t.writing=!0,this.arena=t,this.buf=t.buf,this.view=t.view,this.start=t.offset,this.limit=t.buf.length-t.offset,this.len=0}ensure(t){if(this.len+t>this.limit){let n=this.arena,r=this.len+t,o=LC;for(;o<r;)o*=2;let s=BC(o);s.writing=!0,s.buf.set(this.buf.subarray(this.start,this.start+this.len)),n.writing=!1,this.arena=Vm=s,this.buf=s.buf,this.view=s.view,this.start=0,this.limit=s.buf.length}}byte(t){this.ensure(1),this.buf[this.start+this.len++]=t}bytes(t){this.ensure(t.length),this.buf.set(t,this.start+this.len),this.len+=t.length}uvarint(t){this.ensure(10);let n=this.buf,r=this.start+this.len;if(t<128)n[r++]=t;else if(n[r++]=t&127|128,t<16384)n[r++]=t>>>7;else{for(n[r++]=t>>>7&127|128,t=Math.floor(t/16384);t>127;)n[r++]=t&127|128,t=Math.floor(t/128);n[r++]=t}this.len=r-this.start}uvarintBig(t){for(;t>Rq;)this.byte(Number(t&Rq)|128),t>>=Xq;this.byte(Number(t))}zigzag(t){this.uvarintBig(t>=oE?t<<Yo:(-t<<Yo)-Yo)}numberVarint(t){let n=t<0||t===0&&1/t<0,r=n?-t:t;r<=Ate?this.uvarint(r*2+(n?1:0)):this.uvarintBig(BigInt(r)*Ite+(n?Yo:oE))}f64(t){this.ensure(8),this.view.setFloat64(this.start+this.len,t,!0),this.len+=8}i64(t){this.ensure(8),this.view.setBigInt64(this.start+this.len,t,!0),this.len+=8}u32le(t){this.ensure(4),this.view.setUint32(this.start+this.len,t>>>0,!0),this.len+=4}i32le(t){this.ensure(4),this.view.setInt32(this.start+this.len,t|0,!0),this.len+=4}idAndMark(t){let n=t.length;this.ensure(n+1);let r=this.buf,o=this.start+this.len;for(let i=0;i<n;i++)r[o++]=t[i];let s=o-this.start;return this.len=s+1,s}beginSized(){return this.ensure(1),this.len++}endSized(t){let n=this.len-t-1;n<128?this.buf[this.start+t]=n:this.growSized(t,n)}endSizedRun(t){let n=(this.len-t-1)*2;n<128?this.buf[this.start+t]=n:this.growSized(t,n)}growSized(t,n){let r=az(n),o=r-1;this.ensure(o);let s=this.start+t;this.buf.copyWithin(s+r,s+1,this.start+this.len),this.len+=o;let i=n,a=s;for(;i>127;)this.buf[a++]=i&127|128,i=Math.floor(i/128);this.buf[a]=i}string(t){let n=t.length;if(n===0)return;this.ensure(n*3);let r=this.buf,o=this.start+this.len,s=0;for(;s+4<=n;s+=4){let i=t.charCodeAt(s),a=t.charCodeAt(s+1),c=t.charCodeAt(s+2),u=t.charCodeAt(s+3);if((i|a|c|u)>127){this.len+=_i.encodeInto(t,r.subarray(this.start+this.len)).written;return}r[o++]=i,r[o++]=a,r[o++]=c,r[o++]=u}for(;s<n;s++){let i=t.charCodeAt(s);if(i>127){this.len+=_i.encodeInto(t,r.subarray(this.start+this.len)).written;return}r[o++]=i}this.len=o-this.start}out(){let t=this.arena,n=new Uint8Array(t.buf.buffer,this.start,this.len);return t===Vm&&(t.offset=this.start+this.len),t.writing=!1,this.arena=void 0,n}abort(){let t=this.arena;t!==void 0&&(t===Vm&&(t.offset=this.start),t.writing=!1,this.arena=void 0)}};function $te(e){let t=jn(e);return t._tag==="String"&&t.checks===void 0}function qte(e,t,n){return e.extra.find(r=>ua({[t]:null},r.parameter,n).length>0)}var Jm=class{entries=new WeakMap;orderLayouts;orderKeys;options;size=0;next=0;replace=!1;constructor(t,n){this.options=t,this.orderLayouts=n===void 0?void 0:new Array(n),this.orderKeys=n===void 0?void 0:new Array(n)}beginFrame(){this.replace=!0}find(t,n){let r=this.entries.get(t);if(r===void 0&&(r=new Map,this.entries.set(t,r)),r.has(n))return r.get(n);let o=qte(t,n,this.options),s=this.orderLayouts;if(s===void 0)return r.set(n,o),o;let i=this.orderKeys;if(this.size<s.length)s[this.size]=t,i[this.size]=n,this.size++,r.set(n,o);else if(this.replace){this.replace=!1;let a=s[this.next];(a===t?r:this.entries.get(a))?.delete(i[this.next]),s[this.next]=t,i[this.next]=n,this.next=(this.next+1)%s.length,r.set(n,o)}return o}clear(){this.entries=new WeakMap,this.orderLayouts?.fill(void 0),this.orderKeys?.fill(void 0),this.size=this.next=0,this.replace=!1}},cE=new ArrayBuffer(0),jC=new Uint8Array(cE),Fq=new DataView(cE),Gm=class{pos=0;buf=jC;view;viewCache=Fq;viewBuffer=cE;viewOffset=0;viewLength=0;end=0;options=Qr;indexSignatures;positional=!1;intern;dict;reset(t,n,r,o,s,i,a){this.view=void 0,this.buf=t,this.pos=n,this.end=r,this.options=o,this.indexSignatures=s,this.positional=i,this.intern=void 0,this.dict=a}release(){this.pos=this.end=0,this.buf=jC,this.view=void 0,this.viewCache=Fq,this.viewBuffer=cE,this.viewOffset=this.viewLength=0,this.options=Qr,this.indexSignatures=void 0,this.positional=!1,this.intern=void 0,this.dict=void 0}get remaining(){return this.end-this.pos}dataView(){let t=this.buf;return(t.buffer!==this.viewBuffer||t.byteOffset!==this.viewOffset||t.byteLength!==this.viewLength)&&(this.viewBuffer=t.buffer,this.viewOffset=t.byteOffset,this.viewLength=t.byteLength,this.viewCache=new DataView(t.buffer,t.byteOffset,t.byteLength)),this.view=this.viewCache}byte(){return this.pos>=this.end&&Q("complete value",void 0,this.options),this.buf[this.pos++]}take(t){this.pos+t>this.end&&Q("complete value",void 0,this.options);let n=this.buf.subarray(this.pos,this.pos+t);return this.pos+=t,n}takeCopy(t){this.pos+t>this.end&&Q("complete value",void 0,this.options);let n=this.buf.slice(this.pos,this.pos+t);return this.pos+=t,n}enter(t){this.pos+t>this.end&&Q("complete value",void 0,this.options);let n=this.end;return this.end=this.pos+t,n}exit(t){this.pos=this.end,this.end=t}readUtf8(t){this.pos+t>this.end&&Q("complete value",void 0,this.options);let n=this.pos;return this.pos+=t,Dte(this.buf,n,n+t,this.options)}uvarint(){let t=this.buf,n=this.end,r=this.pos;r>=n&&Q("complete value",void 0,this.options);let o=t[r++];if(o<128)return this.pos=r,o;let s=o&127;if(r>=n&&Q("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<7,o<128)return this.pos=r,s;if(r>=n&&Q("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<14,o<128)return this.pos=r,s;if(r>=n&&Q("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<21,o<128)return this.pos=r,s;let i=268435456;for(let a=4;a<10;a++){r>=n&&(this.pos=r,Q("complete value",void 0,this.options)),o=t[r++];let c=(o&127)*i;if(c>Number.MAX_SAFE_INTEGER-s&&(this.pos=r,Q("safe integer length",void 0,this.options)),s+=c,o<128)return this.pos=r,s;i*=128}this.pos=r,Q("uvarint",void 0,this.options)}fieldTag(){let t=this.buf,n=this.end,r=this.pos;r>=n&&Q("complete value",void 0,this.options);let o=t[r++];if(o<128)return this.pos=r,o;let s=o&127;return r>=n&&Q("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<7,o<128?(this.pos=r,s):(r>=n&&Q("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<14,o<128?(this.pos=r,s):(r>=n&&Q("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<21,o<128?(this.pos=r,s):(r>=n&&Q("complete value",void 0,this.options),o=t[r++],this.pos=r,o>=128&&Q("uvarint",void 0,this.options),s+o*268435456)))}uvarintBig(){let t=oE,n=oE;for(;;){let r=this.byte();if(t|=BigInt(r&127)<<n,(r&128)===0)return t;n+=Xq}}numberVarint(){let t=this.buf,n=this.end,r=this.pos,o=0,s=1;for(let c=0;c<ez;c++){r>=n&&(this.pos=r,Q("complete value",void 0,this.options));let u=t[r++];if(o+=(u&127)*s,u<128)return this.pos=r,oz(o);s*=128}let i=this.uvarintBig(),a=Number(i>>Yo);return Number.isFinite(a)||Q("safe integer length",void 0,this.options),(i&Yo)===Yo?-a:a}zigzag(){let t=this.uvarintBig();return(t&Yo)===Yo?-(t+Yo>>Yo):t>>Yo}f64(){this.pos+8>this.end&&Q("complete value",void 0,this.options);let t=(this.view??this.dataView()).getFloat64(this.pos,!0);return this.pos+=8,t}i64(){this.pos+8>this.end&&Q("complete value",void 0,this.options);let t=(this.view??this.dataView()).getBigInt64(this.pos,!0);return this.pos+=8,t}u32le(){this.pos+4>this.end&&Q("complete value",void 0,this.options);let t=(this.view??this.dataView()).getUint32(this.pos,!0);return this.pos+=4,t}i32le(){this.pos+4>this.end&&Q("complete value",void 0,this.options);let t=(this.view??this.dataView()).getInt32(this.pos,!0);return this.pos+=4,t}};function Uq(e,t){return{_:"literal",leaf:e,values:t,valueSet:t.length>4?new Set(t):void 0}}function nh(e,t){let n=e.values;return e.valueSet!==void 0?e.valueSet.has(t):n.length===1?t===n[0]:n.includes(t)}function dE(e){return e.values.map(t=>typeof t=="string"?JSON.stringify(t):String(t)).join(" | ")}var eE=0,ZC=1,cz=2,uz=3,fz=30,tE=1<<fz;function pE(e){return e._==="literal"?pE(e.leaf):e._==="int"}function mE(e){switch(e._){case"literal":return mE(e.leaf);case"bool":return 1;case"int64":return 8;default:return}}function $C(e){return mE(e)!==void 0||pE(e)||e._==="null"||e._==="undefined"}var Zm={"effect/schema/Date":{kind:St.int64,exact:!0},"effect/schema/DateTimeUtc":{kind:St.int64,exact:!0},"effect/schema/DateTimeZoned":{kind:St.dateTimeZoned,exact:!0},"effect/schema/Duration":{kind:St.duration,exact:!0},"effect/schema/BigDecimal":{kind:St.bigDecimal,exact:!0},"effect/schema/Uint8Array":{kind:St.bytes,exact:!0},"effect/schema/Option":{kind:St.option,exact:"parameters"},"effect/schema/Result":{kind:St.result,exact:"parameters"},"effect/schema/Exit":{kind:St.exit,exact:"parameters"},"effect/schema/Cause":{kind:St.cause,exact:"parameters"},"effect/schema/CauseReason":{kind:St.causeReason,exact:"parameters"}};function od(e){let t=e.annotations?.representation;return en(t)&&typeof t.id=="string"?t.id:void 0}var nE=fa(e=>{let t=zte(e),n=e.context;return t===e||n===void 0?t:pl(t,new Zr(n.isOptional,n.isMutable,void 0,n.annotations))});function zte(e){switch(e._tag){case"Declaration":{let t=od(e);if(t!==void 0&&(t in Zm||t==="effect/schema/Json"||t==="effect/schema/MutableJson"))return e.recur(nE);let n=e.annotations?.toCodecJson,r=e.annotations?.toCodec;if(!cn(n)&&!cn(r))return e;let o=e.typeParameters.map(i=>re(jn(i))),s=(cn(n)?n(o):void 0)??(cn(r)?r(o):void 0);return s===void 0?e:lt(e,[ac(s,nE)])}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(nE);default:return e}}function Hte(e){let t=[...e].sort((r,o)=>{let s=typeof r.key=="number",i=typeof o.key=="number";return s!==i?s?-1:1:s?r.key-o.key:iz(_i.encode(r.key),_i.encode(o.key))}),n=[];for(let r of t){let o=_i.encode(String(r.key));n.push(typeof r.key=="number"?0:1),iE(n,o.length),sE(n,o);let s=r.literal,i=_i.encode(dz(s));n.push(lz(s)),iE(n,i.length),sE(n,i)}return sz(n)}function lz(e){switch(typeof e){case"string":return 1;case"number":return 2;case"boolean":return 3;case"bigint":return 4;default:return 5}}function dz(e){if(typeof e=="symbol"){let t=globalThis.Symbol.keyFor(e);if(t===void 0)throw new Error("Binary layout: unregistered unique symbol (Symbol.keyFor)");return t}return String(e)}function pz(e){switch(e._tag){case"Symbol":return!0;case"Union":return e.types.some(pz);default:return!1}}function mz(e){let t=od(e);return t==="effect/schema/Json"||t==="effect/schema/MutableJson"?!0:cn(e.annotations?.toCodecJson)}function Wte(e){let t=e.checks;if(t===void 0)return!1;let n=r=>r.annotations?.representation?.id==="effect/schema/isInt"?!0:r._tag==="FilterGroup"&&r.checks.some(n);return t.some(n)}function hz(e){for(;e._tag==="Suspend";)e=e.thunk();return e}function Dq(e){let t=[],n=new Set,r=o=>{let s=hz(o);if(!n.has(s))switch(n.add(s),s._tag){case"Never":return;case"Union":s.types.forEach(r);return;case"Enum":Mp(s).types.forEach(r);return;default:t.push(s)}};return e.types.forEach(r),t}function Nq(e){switch(typeof e){case"string":return"string";case"number":return"number";case"boolean":return"bool";default:return"bigint"}}function rE(e){switch(e._tag){case"String":case"TemplateLiteral":case"Symbol":return St.string;case"UniqueSymbol":if(globalThis.Symbol.keyFor(e.symbol)===void 0)throw new Error("Binary layout: unregistered unique symbol (Symbol.keyFor)");return St.string;case"Boolean":return St.bool;case"Null":return St.null;case"Undefined":case"Void":return St.undefined;case"Number":return St.number;case"BigInt":return St.bigint;case"Literal":switch(typeof e.literal){case"string":return St.string;case"number":return St.number;case"boolean":return St.bool;default:return St.bigint}case"Unknown":case"Any":case"ObjectKeyword":return St.json;case"Objects":return St.struct;case"Arrays":return St.array;case"Declaration":{let t=od(e);if(t!==void 0&&t in Zm)return Zm[t].kind;if(mz(e))return St.json;throw new Error(`Binary layout: declaration ${t??"<anonymous>"} has no toCodecJson or toCodec`)}case"Suspend":return rE(hz(e));default:throw new Error("Binary layout: union members are not uniquely identifiable")}}function Lq(e){for(let t of e.fields)t.optional||(t.index<32?e.requiredMask|=1<<t.index:e.requiredWide=!0)}function Kte(e){let t=gz(e),n=!t&&Vte(e);e=jn(e);let r=new Map,o=!1,s=0,i=h=>({_:h,slot:h==="string"?s++:0});function a(h){let g=r.get(h);if(g!==void 0)return g;let x=c(h);return r.set(h,x),x}function c(h){switch(h._tag){case"String":case"TemplateLiteral":return i("string");case"Symbol":case"UniqueSymbol":return i("symbol");case"Boolean":return i("bool");case"Null":return i("null");case"Undefined":case"Void":return i("undefined");case"Number":return i(Wte(h)?"int":"number");case"BigInt":return i("bigint");case"Literal":return Uq(i(Nq(h.literal)),[h.literal]);case"Unknown":case"Any":case"ObjectKeyword":return i("json");case"Never":return{_:"never",ast:h};case"Enum":return p(h,Dq(Mp(h)));case"Suspend":{o=!0;let g=a(h.thunk());return r.set(h,g),g}case"Objects":return u(h);case"Arrays":return f(h);case"Union":return p(h,Dq(h));case"Declaration":return l(h)}}function u(h){let g=[],x=[],b=new Map;for(let w of h.propertySignatures){if(typeof w.name=="symbol")throw new Error("Binary layout: symbol property names are illegal");let S=String(w.name),C=w.type.context?.annotations,_=C?.[Ete],R=typeof _=="number"?_:sz(_i.encode(S));if(!Number.isInteger(R)||R<0||R>4294967295)throw new Error(`Binary layout: illegal field id for ${S}`);let M=b.get(R);M===void 0?b.set(R,[S]):M.push(S),g.push({name:S,id:R,tagBytes:Fte(R*Xo+ef),index:0,optional:w.type.context?.isOptional===!0,annotations:C,layout:void 0,wireMask:0,inline:!1}),x.push(w.type)}for(let[w,S]of b)if(w===0||S.length>1)throw new Error(`Binary layout field id collision: ${w} (${S.join(", ")})`);let E=[];for(let w of h.indexSignatures){if(pz(w.parameter))throw new Error("Binary layout: symbol property names are illegal");E.push({parameter:w.parameter,layout:void 0,wireMask:0})}let y={_:"struct",ast:h,fields:g,byId:new Map,extra:E,extraAll:E.length===1&&$te(E[0].parameter)?E[0]:void 0,names:new Set(g.map(w=>w.name)),extraShape:void 0,optionalCount:0,requiredMask:0,requiredWide:!1};r.set(h,y);for(let w=0;w<g.length;w++){let S=g[w];S.layout=a(x[w]),S.wireMask=WC(S.layout),S.inline=$C(S.layout),S.optional&&y.optionalCount++,y.byId.set(S.id,S)}g.sort((w,S)=>w.id-S.id);for(let w=0;w<g.length;w++)g[w].index=w;Lq(y);for(let w=0;w<E.length;w++)E[w].layout=a(h.indexSignatures[w].type),E[w].wireMask=WC(E[w].layout);return y}function f(h){let g=h.rest.length>0||h.elements.some(y=>y.context?.isOptional===!0),x=h.elements.filter(y=>y.context?.isOptional!==!0).length,b=Math.max(0,h.rest.length-1),E={_:"array",ast:h,elements:[],rest:[],hasCount:g,minCount:x+b,uniform:void 0,uniformInline:!1,uniformPacked:void 0,uniformNumbers:!1,run:void 0};r.set(h,E);for(let y of h.elements)E.elements.push({optional:y.context?.isOptional===!0,layout:a(y)});for(let y of h.rest)E.rest.push(a(y));if(E.elements.length===0&&E.rest.length===1){let y=E.rest[0];E.uniform=y,E.uniformPacked=mE(y),E.uniformNumbers=y._==="number",E.uniformInline=$C(y)}return E}function l(h){let g=od(h);switch(g){case"effect/schema/Date":return{_:"int64",flavor:"date"};case"effect/schema/DateTimeUtc":return{_:"int64",flavor:"utc"};case"effect/schema/DateTimeZoned":return i("dateTimeZoned");case"effect/schema/Duration":return i("duration");case"effect/schema/BigDecimal":return i("bigDecimal");case"effect/schema/Uint8Array":return i("bytes")}let x=h.typeParameters;switch(g){case"effect/schema/Option":{let b={_:"option",value:void 0};return r.set(h,b),b.value=a(x[0]),b}case"effect/schema/Result":{let b={_:"result",success:void 0,failure:void 0};return r.set(h,b),b.success=a(x[0]),b.failure=a(x[1]),b}case"effect/schema/Exit":{let b={_:"cause",error:void 0,defect:void 0},E={_:"exit",value:void 0,cause:b};return r.set(h,E),E.value=a(x[0]),b.error=a(x[1]),b.defect=a(x[2]),E}case"effect/schema/Cause":case"effect/schema/CauseReason":{let b={_:g==="effect/schema/Cause"?"cause":"causeReason",error:void 0,defect:void 0};return r.set(h,b),b.error=a(x[0]),b.defect=a(x[1]),b}}if(g!==void 0&&g in Zm)throw new Error(`Binary layout: native declaration ${g} has no layout constructor`);if(mz(h))return i("json");throw new Error(`Binary layout: declaration ${g??"<anonymous>"} has no toCodecJson or toCodec`)}function p(h,g){if(g.length===0)return{_:"never",ast:h};let x=[],b=[],E=new Map,y=new Map,w=(M,q)=>{let P=E.get(M);if(P!==void 0&&P._!==q._)throw new Error("Binary layout: union members are not uniquely identifiable");E.set(M,q)};for(let M of g){if(M._tag==="Literal"){let q=rE(M),P=y.get(q);P===void 0?y.set(q,[M.literal]):P.includes(M.literal)||P.push(M.literal);continue}if(M._tag==="UniqueSymbol"){rE(M),w(St.string,i("symbol"));continue}if(M._tag==="Objects"||M._tag==="Arrays"){let q=oc(M);if(q!==void 0&&q.length>0){for(let P of q)if(typeof P.key=="symbol")throw new Error("Binary layout: symbol property names are illegal");x.push({member:M,sentinels:q});continue}}b.push({member:M,kind:rE(M)})}for(let[M,q]of y)w(M,Uq(i(Nq(q[0])),q));if(x.length===0&&b.length===0&&E.size===1)return E.values().next().value;let S=new Set(E.keys());for(let{kind:M}of b){if(S.has(M))throw new Error("Binary layout: union members are not uniquely identifiable");S.add(M)}if(x.length===0&&E.size===0&&b.length===1){let M=a(b[0].member);return r.set(h,M),M}let C=new Map,_=[];for(let{sentinels:M}of x){let q=Hte(M);if(C.has(q))throw new Error(`Binary layout sentinel collision: ${q}`);C.set(q,M),_.push(q)}let R={_:"union",ast:h,variants:[],byTag:new Map,discriminator:void 0,others:[],byKind:new Map,byPos:[]};r.set(h,R);for(let M=0;M<x.length;M++){let{member:q,sentinels:P}=x[M],te=_[M],ee=a(q),T,z;if(q._tag==="Objects"){let D=ee,V=new Set(P.map(le=>String(le.key))),be=D.fields.filter(le=>!V.has(le.name)),Ie={_:"struct",ast:D.ast,fields:be,byId:new Map(be.map(le=>[le.id,le])),extra:D.extra,extraAll:D.extraAll,names:D.names,extraShape:void 0,optionalCount:be.reduce((le,ut)=>ut.optional?le+1:le,0),requiredMask:0,requiredWide:!1};Lq(Ie),T=Ie,z=!1}else T=ee,z=!0;let F={tag:te,sentinels:P,tuple:z,payload:T,position:0};R.variants.push(F),R.byTag.set(te,F)}for(let[M,q]of E)R.others.push({kind:M,layout:q,position:0}),R.byKind.set(M,q);for(let{kind:M,member:q}of b){let P=a(q);R.others.push({kind:M,layout:P,position:0}),R.byKind.set(M,P)}for(let M of[...R.variants].sort((q,P)=>q.tag-P.tag))M.position=R.byPos.length,R.byPos.push({variant:M,layout:M.payload});for(let M of[...R.others].sort((q,P)=>q.kind-P.kind))M.position=R.byPos.length,R.byPos.push({variant:void 0,layout:M.layout});return R.others.sort((M,q)=>Bq(M.layout)-Bq(q.layout)),R.discriminator=wne(R.variants),R}return{layout:a(e),recursive:o,exact:t,exitSuccess:n}}function gz(e){let t=new Map,n=r=>{if(r.encoding!==void 0||r.checks!==void 0||r.encodingChecks!==void 0||r.annotations?.parseOptions!==void 0)return!1;switch(r._tag){case"String":case"Symbol":case"Boolean":case"Null":case"Undefined":case"Void":case"Number":case"BigInt":case"Literal":return!0;case"Never":return!0;case"Unknown":case"Any":return!0;case"Arrays":return r.elements.every(n)&&r.rest.every(n);case"Objects":return r.propertySignatures.every(o=>n(o.type))&&r.indexSignatures.every(o=>o.parameter._tag==="String"&&n(o.parameter)&&n(o.type));case"Union":return r.mode==="anyOf"&&r.types.every(n);case"Suspend":{let o=t.get(r);if(o!==void 0)return o;t.set(r,!0);let s=n(r.thunk());return t.set(r,s),s}case"Declaration":{let o=od(r),s=o!==void 0?Zm[o]:void 0;return s===void 0?!1:s.exact===!0||r.typeParameters.every(n)}default:return!1}};return n(e)}function Vte(e){return e._tag==="Declaration"&&e.encoding===void 0&&e.checks===void 0&&e.encodingChecks===void 0&&e.annotations?.parseOptions===void 0&&od(e)==="effect/schema/Exit"&&gz(e.typeParameters[0])}var ro={backEdge:0,bool:1,null:2,undefined:3,number:4,int:5,string:6,symbol:7,bytes:8,bigint:9,json:10,duration:11,bigDecimal:12,dateTimeZoned:13,date:14,dateTimeUtc:15,never:16,struct:17,array:18,union:19,option:20,result:21,exit:22,cause:23,causeReason:24,literal:25};function Jte(e){let t=new Map,n=[],r=Number.MAX_SAFE_INTEGER;function o(i){let a=n.lastIndexOf(i);if(a>=0){a<r&&(r=a);let m=[ro.backEdge];return Oc(m,n.length-a),Pq(m)}let c=t.get(i);if(c!==void 0)return c;let u=n.length,f=r;r=Number.MAX_SAFE_INTEGER,n.push(i);let l=Pq(s(i));n.pop();let p=r>=u;return p&&t.set(i,l),r=p?f:Math.min(f,r),l}function s(i){let a=[];switch(i._){case"bool":case"null":case"undefined":case"number":case"int":case"string":case"symbol":case"bytes":case"bigint":case"json":case"duration":case"bigDecimal":case"dateTimeZoned":return a.push(ro[i._]),a;case"literal":{a.push(ro.literal),sE(a,s(i.leaf)),Oc(a,i.values.length);let c=i.values.map(u=>[lz(u),dz(u)]).sort((u,f)=>u[1]<f[1]?-1:u[1]>f[1]?1:u[0]-f[0]);for(let[u,f]of c){a.push(u);let l=_i.encode(f);Oc(a,l.length),sE(a,l)}return a}case"int64":return a.push(i.flavor==="date"?ro.date:ro.dateTimeUtc),a;case"never":return a.push(ro.never),a;case"struct":{a.push(ro.struct),Oc(a,i.fields.length);for(let c of i.fields)iE(a,c.id),a.push(c.optional?1:0),bo(a,o(c.layout));Oc(a,i.extra.length);for(let c of i.extra)bo(a,o(c.layout));return a}case"array":{a.push(ro.array),Oc(a,i.elements.length);for(let c of i.elements)a.push(c.optional?1:0),bo(a,o(c.layout));Oc(a,i.rest.length);for(let c of i.rest)bo(a,o(c));return a}case"union":{a.push(ro.union),Oc(a,i.byPos.length);for(let c of i.byPos){let u=c.variant;u===void 0?a.push(0):(a.push(1,u.tuple?1:0),iE(a,u.tag)),bo(a,o(c.layout))}return a}case"option":return a.push(ro.option),bo(a,o(i.value)),a;case"result":return a.push(ro.result),bo(a,o(i.success)),bo(a,o(i.failure)),a;case"exit":return a.push(ro.exit),bo(a,o(i.value)),bo(a,o(i.cause.error)),bo(a,o(i.cause.defect)),a;case"cause":case"causeReason":return a.push(i._==="cause"?ro.cause:ro.causeReason),bo(a,o(i.error)),bo(a,o(i.defect)),a}}return o(e)}function Gte(e,t){let n=new Uint8Array(8);for(let r=0;r<4;r++)n[r]=e>>>r*8&255,n[r+4]=t>>>r*8&255;return n}var Zte={positional:!1,envelope:bte,expectedEnvelope:"version 2 envelope, flags 0",fingerprint:new Uint8Array(8)};function Qte(e){let t=Jte(e);return{positional:!0,envelope:wte,expectedEnvelope:"version 2 envelope, flags 1",fingerprint:Gte(Number(t&_q),Number(t>>kte&_q))}}function Bq(e){switch(e._){case"json":return 2;case"struct":return 1;default:return 0}}function qC(e,t){switch(e._){case"literal":return nh(e,t);case"bool":return typeof t=="boolean";case"null":return t===null;case"undefined":return t===void 0;case"number":case"int":return typeof t=="number";case"string":return typeof t=="string";case"symbol":return typeof t=="symbol";case"bigint":return typeof t=="bigint";case"bytes":return t instanceof Uint8Array;case"int64":return e.flavor==="date"?t instanceof Date:wu(t)&&t._tag==="Utc";case"dateTimeZoned":return wu(t)&&t._tag==="Zoned";case"duration":return Gc(t);case"bigDecimal":return Ba(t);case"option":return Gs(t);case"result":return xf(t);case"exit":return ms(t);case"cause":return Df(t);case"causeReason":return Nf(t);case"array":return Array.isArray(t);case"struct":return en(t)&&!Array.isArray(t);case"json":return!0;case"union":case"never":return!1}}function yt(e,t,n){throw pn(new ke({expected:e},t,n))}function gr(e,t=new Set){if(!fd(e))return!1;let n=Array.isArray(e),r=Object.getPrototypeOf(e);if(n||r===Object.prototype||r===null){if(t.has(e))return!0;t.add(e);try{if(n){for(let o=0;o<e.length;o++)if(gr(e[o],t))return!0}else for(let o of Object.keys(e))if(gr(e[o],t))return!0}finally{t.delete(e)}return!1}if(e instanceof Date||e instanceof Uint8Array||wu(e)||Gc(e)||Ba(e))return!1;if(t.has(e))return!0;t.add(e);try{if(Gs(e))return Te(e)&&gr(e.value,t);if(xf(e))return gr(Kt(e)?e.success:e.failure,t);if(ms(e))return gr(Ft(e)?e.value:e.cause,t);if(Df(e))return e.reasons.some(o=>gr(o,t));if(Nf(e))switch(e._tag){case"Fail":return gr(e.error,t);case"Die":return gr(e.defect,t);case"Interrupt":return!1}if(xl(e)){for(let o of e)if(gr(o,t))return!0;return!1}if(Py(e)){for(let[o,s]of e)if(gr(o,t)||gr(s,t))return!0;return!1}if(Ly(e)){for(let o of e)if(gr(o,t))return!0;return!1}if(cm(e))return gr(dc(e),t);for(let o of Object.keys(e))if(gr(e[o],t))return!0}finally{t.delete(e)}return!1}function uE(e,t,n,r){let o=r.beginSized();Wn(e,t,n,r),r.endSized(o)}function Yte(e,t,n){let r=globalThis.Symbol.keyFor(t);r===void 0&&yt("registered symbol",t,e.options),n.string(r)}function jq(e,t,n,r){let o=n;switch(o._tag){case"Fail":r.byte(0),Wn(e,t.error,o.error,r);return;case"Die":r.byte(1),Wn(e,t.defect,o.defect,r);return;case"Interrupt":o.fiberId===void 0?r.byte(2):(r.byte(3),r.f64(o.fiberId))}}function Xte(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!1;return!0}function $q(e,t,n){if(e.layout!==t||e.keys.length!==n.length)return!1;for(let r=0;r<n.length;r++)if(e.keys[r]!==n[r])return!1;return!0}function ene(e,t){if(e.extraAll===void 0||t.length>Bte)return!1;let n=0;for(let r=0;r<t.length;r++)if(n+=t[r].length,n>jte)return!1;return!0}function QC(e,t,n){let r=Object.keys(n),o=t.extraShape;if(o!==void 0&&$q(o,t,r))return o.pairs;let s=ene(t,r),i=s?void 0:e.extraShape;if(i!==void 0&&$q(i,t,r))return i.pairs;let a=t.names,c=t.extraAll,u=[],f=!0;for(let p of r){if(a.has(p))continue;let m=c??(e.indexSignatures??=new Jm(e.options)).find(t,p);m!==void 0&&(f&&!Xte(p)&&(f=!1),u.push([p,m,void 0]))}if(f)u.sort((p,m)=>p[0]<m[0]?-1:p[0]>m[0]?1:0);else{for(let p of u)p[2]=_i.encode(p[0]);u.sort((p,m)=>iz(p[2],m[2]))}if(s)for(let p of u)p[2]??=_i.encode(p[0]);let l={layout:t,keys:r,pairs:u};return s?t.extraShape=l:e.extraShape=l,u}function YC(e,t,n,r,o){for(let[s,i,a]of t){let c=a===void 0?s.length:a.length,u=n[s],f=XC(i.layout,u,e.options),l=f%Xo;if(o===void 0)r.uvarint(c*Xo+l);else{if(!o.disabled){let p=yz(o,s);if(p!==void 0){r.uvarint(p*16+l*2+1),nt[ue++]=s,zC(e,i.layout,u,f,r),ue--;continue}Sz(o,s)}r.uvarint(c*16+l*2)}a===void 0?r.string(s):r.bytes(a),nt[ue++]=s,zC(e,i.layout,u,f,r),ue--}}function XC(e,t,n){if(e._==="literal")return nh(e,t)||yt(dE(e),t,n),XC(e.leaf,t,n);switch(e._){case"bool":return typeof t!="boolean"&&yt("a boolean",t,n),t?eh:Xm;case"number":if(typeof t!="number"&&yt("a number",t,n),JC(t))return Yu;{let r=GC(t);return r===0?Ym:r*Xo+th}case"int":return Number.isSafeInteger(t)||yt("an integer",t,n),Yu;default:return ef}}function zC(e,t,n,r,o){switch(r%Xo){case Xm:case eh:return;case Yu:o.numberVarint(n);return;case Ym:o.f64(n);return;case th:{let i=Math.floor(r/Xo);o.numberVarint(Math.round(n*Rc[i])),o.uvarint(i);return}default:uE(e,t,n,o)}}function tne(e,t,n,r){let o=XC(t.layout,n,e.options),s=o%Xo;if(s===ef){let i=r.idAndMark(t.tagBytes);Wn(e,t.layout,n,r),r.endSized(i);return}r.uvarint(t.id*Xo+s),zC(e,t.layout,n,o,r)}function nne(e,t){let n=e.byName;if(n===void 0)return;let r=Object.getOwnPropertyNames(t),o=0;for(let i=0;i<r.length;i++){let a=n.get(r[i]);a!==void 0&&(o|=1<<a)}let s=e.struct;if((o&s.requiredMask)!==s.requiredMask){let i=s.fields;for(let a=0;a<i.length;a++){let c=i[a];if(!c.optional&&(o&1<<a)===0)throw nt[ue++]=c.name,pn(new sn(c.annotations))}}return o}function rne(e,t,n,r){let o=n;if(t.extra.length>0){let i=e.intern;e.intern=void 0;let a=QC(e,t,o);if(a.length>0){r.uvarint(0);let c=r.beginSized();YC(e,a,o,r,i),r.endSized(c)}}let s=t.fields;for(let i=0;i<s.length;i++){let a=s[i],c=a.name;if(!Object.hasOwn(o,c)){if(a.optional)continue;throw nt[ue++]=c,pn(new sn(a.annotations))}nt[ue++]=c,tne(e,a,o[c],r),ue--}}function one(e,t,n,r){let o=n,s=e.intern;e.intern=void 0;let i=t.optionalCount+7>>3,a=0;if(i>0){a=r.len;for(let f=0;f<i;f++)r.byte(0)}let c=t.fields,u=0;for(let f=0;f<c.length;f++){let l=c[f],p=l.name,m=Object.hasOwn(o,p);if(l.optional){if(m&&(r.buf[r.start+a+(u>>3)]|=1<<(u&7)),u++,!m)continue}else if(!m)throw nt[ue++]=p,pn(new sn(l.annotations));nt[ue++]=p,l.inline?Wn(e,l.layout,o[p],r):uE(e,l.layout,o[p],r),ue--}if(t.extra.length>0){let f=QC(e,t,o);r.uvarint(f.length),YC(e,f,o,r,s)}}function sne(e){switch(e._){case"string":return ZC;case"array":return e.uniform?._==="string"?cz:eE;case"struct":return e.extra.length>0?uz:eE;default:return eE}}function ine(e){let t=e.uniform;if(t===void 0){if(e.rest.length!==1)return;t=e.rest[0];for(let n of e.elements)if(n.optional||n.layout!==t)return}return t._==="struct"?t:void 0}function xz(e){let t=e.run;if(t!==void 0)return t;let n=ine(e);if(n===void 0)return e.run=t=null,t;let r=n.fields.map(s=>sne(s.layout)),o=n.fields.length<=fz;return t={struct:n,intern:r,shapes:o,byName:o&&n.extra.length===0?new Map(n.fields.map((s,i)=>[s.name,i])):void 0},e.run=t,t}var ane=16,cne=64;function qq(e,t){return e[t]??={values:[],refs:void 0,hits:0,disabled:!1}}function yz(e,t){let n=e.refs;if(n!==void 0){let o=n.get(t);return o!==void 0&&e.hits++,o}let r=e.values;for(let o=0;o<r.length;o++)if(r[o]===t)return e.hits++,o}function Sz(e,t){let n=e.values;if(e.refs!==void 0){if(e.hits===0&&n.length>=cne){e.disabled=!0,e.refs=void 0;return}e.refs.set(t,n.length)}else if(n.length>=ane){let r=e.refs=new Map;for(let o=0;o<n.length;o++)r.set(n[o],o);r.set(t,n.length)}n.push(t)}var eA=0,une=1,tA=2,fne=64,lne=512;function dne(){return{slots:[],marks:[],frame:0}}function Ez(e,t){return e[t]??={values:[],refs:new Map,state:eA,stamp:-1}}function bz(e,t){if(e.refs.has(t)){e.state=une;return}e.refs.set(t,e.values.length),e.values.push(t),e.values.length>=fne&&(e.state=tA)}function wz(e,t){let n=e.values;n.length>=lne||(e.refs.set(t,n.length),n.push(t))}function pne(e,t){t.stamp!==e.frame&&(t.stamp=e.frame,e.marks.push({slot:t,length:t.values.length,state:t.state}))}function mne(e){e.marks.length=0,e.frame++}function hne(e){let t=e.marks;for(let n=t.length-1;n>=0;n--){let{length:r,slot:o,state:s}=t[n],i=o.values;for(let a=r;a<i.length;a++)o.refs.delete(i[a]);i.length=r,o.state=s}t.length=0,e.frame++}function gne(e,t,n,r){let o=Ez(e.slots,t.slot),s=o.state;if(s===tA){r.string(n);return}if(pne(e,o),s===eA){r.string(n),bz(o,n);return}let i=o.refs.get(n);if(i!==void 0){r.uvarint(i*2+1);return}r.byte(0),wz(o,n),r.string(n)}function xne(e,t,n){let r=Ez(e,t.slot),o=r.state;if(o===tA)return n.readUtf8(n.end-n.pos);if(o===eA){let a=n.readUtf8(n.end-n.pos);return bz(r,a),a}let s=n.uvarint();if((s&1)===1){let a=(s-1)/2,c=r.values;return a>=c.length&&Q("a dictionary reference",s,n.options),c[a]}s!==0&&Q("a dictionary marker",s,n.options);let i=n.readUtf8(n.end-n.pos);return wz(r,i),i}function Iz(e,t,n,r,o){if(!e.disabled){let i=yz(e,r);if(i!==void 0){o.uvarint(i*2+1);return}Sz(e,r)}let s=o.beginSized();Wn(t,n,r,o),o.endSizedRun(s)}function yne(e,t,n,r,o){let s=[],i=[];for(let a=0;a<r;a++){nt[ue++]=a;let c=o.beginSized();Sne(e,t,s,i,n[a],o),o.endSized(c),ue--}}function Sne(e,t,n,r,o,s){let i=t.struct,a=o,c=i.fields,u;if(i.extra.length>0){let x=QC(e,i,a);x.length>0&&(u=x)}let f=!t.shapes,l=u===void 0?0:tE,p=nne(t,a);if(p!==void 0)l=p;else for(let x=0;x<c.length;x++){let b=c[x];if(Object.hasOwn(a,b.name))f||(l|=1<<x);else if(!b.optional)throw nt[ue++]=b.name,pn(new sn(b.annotations))}let m=-1;for(let x=0;x<n.length;x++)if(n[x]===l){m=x;break}m>=0?s.uvarint(m+1):(s.uvarint(0),f||n.push(l));let h=m<0,g=e.positional&&!f;if(h&&g&&s.uvarint(l),u!==void 0){h&&!g&&s.uvarint(0);let x=s.beginSized();YC(e,u,a,s),s.endSizedRun(x)}for(let x=0;x<c.length;x++){let b=c[x];if(f?!Object.hasOwn(a,b.name):(l&1<<x)===0)continue;h&&!g&&s.uvarint(b.id),nt[ue++]=b.name;let E=t.intern[x];if(E===ZC)Iz(qq(r,x),e,b.layout,a[b.name],s);else{E!==eE&&(e.intern=qq(r,x));let y=s.beginSized();Wn(e,b.layout,a[b.name],s),s.endSizedRun(y),e.intern=void 0}ue--}}function vz(e,t,n){let r=e.elements.length;if(t<r)return e.elements[t].layout;let o=Math.max(0,e.rest.length-1),s=Math.max(r,n-o);return t>=s?e.rest[t-s+1]:e.rest[0]}function Ene(e,t,n,r){let o=n.length;if(t.rest.length===0&&o>t.elements.length)throw nt[ue++]=t.elements.length,pn(new sa(t.ast,n[t.elements.length],e.options));if(o<t.minCount)throw nt[ue++]=o,pn(new sn(void 0));if(t.hasCount&&r.uvarint(o),o>0){let i=xz(t);if(i!==null){yne(e,i,n,o,r);return}}let s=t.uniform;if(s!==void 0){if(t.uniformNumbers){bne(n,o,r);return}let i=e.intern;if(e.intern=void 0,i!==void 0){for(let c=0;c<o;c++)nt[ue++]=c,Iz(i,e,s,n[c],r),ue--;return}let a=t.uniformInline;for(let c=0;c<o;c++)nt[ue++]=c,a?Wn(e,s,n[c],r):uE(e,s,n[c],r),ue--;return}for(let i=0;i<o;i++){let a=vz(t,i,o);nt[ue++]=i,$C(a)?Wn(e,a,n[i],r):uE(e,a,n[i],r),ue--}}var zq=[];function bne(e,t,n){let r=!0,o=!0;for(let s=0;s<t;s++){let i=e[s];if(JC(i))(i<0?-i:i)>NC&&(o=!1);else if(r=!1,typeof i!="number")o=!1;else{let a=GC(i);a===0?o=!1:zq[s]=a}if(!r&&!o)break}if(r){n.byte(nz);for(let s=0;s<t;s++)n.numberVarint(e[s])}else if(o){n.byte(rz);for(let s=0;s<t;s++){let i=e[s],a=Number.isInteger(i)?0:zq[s],c=a===0?i:Math.round(i*Rc[a]),u=c<0||c===0&&1/c<0,f=u?-c:c;n.uvarint((f*2+(u?1:0))*16+a)}}else{n.byte(tz);for(let s=0;s<t;s++)n.f64(e[s])}}function wne(e){if(!(e.length<2||e.some(t=>t.tuple)))for(let t of e[0].sentinels){let n=new Map;for(let r of e){let o=r.sentinels.find(s=>s.key===t.key);if(o===void 0||n.has(o.literal)||Number.isNaN(o.literal))break;n.set(o.literal,r)}if(n.size===e.length)return{key:t.key,rows:n}}}function HC(e,t){let n=e.sentinels;for(let r=0;r<n.length;r++){let{key:o,literal:s}=n[r];if(t[o]!==s||!Object.hasOwn(t,o))return!1}return!0}function Ine(e,t){return e.tuple?Array.isArray(t)&&HC(e,t):en(t)&&!Array.isArray(t)&&HC(e,t)}function Hq(e,t,n,r){e.positional?r.uvarint(t.position):(r.byte(St.variant),r.u32le(t.tag)),Wn(e,t.payload,n,r)}function vne(e,t,n,r){let o=t.discriminator;if(o!==void 0){if(en(n)&&!Array.isArray(n)){let s=n,i=o.rows.get(s[o.key]);if(i!==void 0&&HC(i,s)){Hq(e,i,n,r);return}}}else for(let s of t.variants)if(Ine(s,n)){Hq(e,s,n,r);return}for(let s of t.others)if(qC(s.layout,n)){e.positional?r.uvarint(s.position):r.byte(s.kind),Wn(e,s.layout,n,r);return}throw pn(new st(t.ast,n,e.options))}function Wn(e,t,n,r){switch(t._){case"literal":nh(t,n)||yt(dE(t),n,e.options),Wn(e,t.leaf,n,r);return;case"bool":typeof n!="boolean"&&yt("a boolean",n,e.options),r.byte(n===!0?1:0);return;case"null":n!==null&&yt("null",n,e.options);return;case"undefined":n!==void 0&&yt("undefined",n,e.options);return;case"number":{if(typeof n!="number"&&yt("a number",n,e.options),JC(n)){r.numberVarint(n);return}let o=GC(n);o>0?(r.numberVarint(Math.round(n*Rc[o])),r.byte(o)):r.f64(n);return}case"int":{Number.isSafeInteger(n)||yt("an integer",n,e.options),r.numberVarint(n);return}case"string":{typeof n!="string"&&yt("a string",n,e.options);let o=e.dict;o===void 0?r.string(n):gne(o,t,n,r);return}case"symbol":typeof n!="symbol"&&yt("a symbol",n,e.options),Yte(e,n,r);return;case"bytes":n instanceof Uint8Array||yt("a Uint8Array",n,e.options),r.bytes(n);return;case"bigint":typeof n!="bigint"&&yt("a bigint",n,e.options),r.zigzag(n);return;case"int64":{qC(t,n)||yt(t.flavor==="date"?"a Date":"a DateTime.Utc",n,e.options);let o=t.flavor==="date"?n.getTime():n.epochMilliseconds;Number.isNaN(o)&&yt("a valid Date",n,e.options),r.i64(BigInt(o));return}case"dateTimeZoned":{qC(t,n)||yt("a DateTime.Zoned",n,e.options);let o=n;r.i64(BigInt(o.epochMilliseconds)),o.zone._tag==="Offset"?(r.byte(0),r.i32le(o.zone.offset)):(r.byte(1),r.string(o.zone.id));return}case"duration":{Gc(n)||yt("a Duration",n,e.options);let o=n.value;switch(o._tag){case"Infinity":r.byte(1);return;case"NegativeInfinity":r.byte(2);return;case"Nanos":r.byte(0),r.zigzag(o.nanos);return;case"Millis":r.byte(0),r.zigzag(BigInt(o.millis)*vte);return}}case"bigDecimal":{Ba(n)||yt("a BigDecimal",n,e.options);let o=Rd(n);r.zigzag(o.value),r.zigzag(BigInt(o.scale));return}case"json":{let o;try{o=JSON.stringify(n)}catch{o=void 0}o===void 0&&(gr(n)&&yt("acyclic value",n,e.options),yt("a JSON-serializable value",n,e.options)),r.string(o);return}case"option":{Gs(n)||yt("an Option",n,e.options);let o=n;o._tag==="None"?r.byte(0):(r.byte(1),Wn(e,t.value,o.value,r));return}case"result":{xf(n)||yt("a Result",n,e.options);let o=n;o._tag==="Success"?(r.byte(0),Wn(e,t.success,o.success,r)):(r.byte(1),Wn(e,t.failure,o.failure,r));return}case"exit":{ms(n)||yt("an Exit",n,e.options);let o=n;o._tag==="Success"?(r.byte(0),Wn(e,t.value,o.value,r)):(r.byte(1),Wn(e,t.cause,o.cause,r));return}case"cause":{Df(n)||yt("a Cause",n,e.options);let o=n.reasons;r.uvarint(o.length);for(let s of o){let i=r.beginSized();jq(e,t,s,r),r.endSized(i)}return}case"causeReason":{Nf(n)||yt("a Cause.Reason",n,e.options),jq(e,t,n,r);return}case"struct":{(!en(n)||Array.isArray(n))&&yt("an object",n,e.options),e.positional?one(e,t,n,r):rne(e,t,n,r);return}case"array":{Array.isArray(n)||yt("an array",n,e.options),Ene(e,t,n,r);return}case"union":vne(e,t,n,r);return;case"never":throw pn(new st(t.ast,n,e.options))}}var YS=new aE;function Wq(e,t,n,r,o){let s=o.beginSized();o.byte(r.envelope),r.positional&&o.bytes(r.fingerprint),Wn(e,t,n,o),o.endSized(s)}function Tz(e,t,n,r,o,s){let i={options:r,positional:o.positional,indexSignatures:void 0,extraShape:void 0,intern:void 0,dict:s},a=YS??new aE,c=a===YS;c&&(YS=void 0),a.reset();let u=ue,f=!1;try{if(n===void 0)ue=0,Wq(i,e,t,o,a);else for(let p=0;p<n.length;p++)ue=0,Wq(i,e,n[p],o,a);let l=a.out();return f=!0,l}finally{s!==void 0&&(f?mne(s):hne(s)),a.abort(),ue=u,c&&(YS=a)}}function kz(e,t,n,r,o){return Tz(e,void 0,t,n,r,o)}function fE(e,t,n,r,o){return Tz(e,t,void 0,n,r,o)}function hE(e){return ms(e)&&Ft(e)}var On=globalThis.Symbol.for("~effect/encoding/SchemaBinary/absent");function xr(e,t){let n=Qm(e,t);return n!==On&&t.pos!==t.end&&Q("no leftover bytes",void 0,t.options),n}function Tne(e,t){let n=t.enter(t.uvarint()),r=xr(e,t);return t.exit(n),r}function Cz(e,t){if(pE(e))return Qm(e,t);let n=mE(e),r=t.enter(n!==void 0?n:e._==="null"||e._==="undefined"?0:t.uvarint()),o=xr(e,t);return t.exit(r),o}var kne=8;function Cne(e,t){let n=e.set;if(n!==void 0)return n.has(t)?!0:(n.add(t),!1);let r=e.list;if(r.includes(t))return!0;if(r.length>=kne){let o=e.set=new Set;for(let s=0;s<r.length;s++)o.add(r[s]);o.add(t)}else r.push(t);return!1}function Az(e,t,n,r,o){let s=t.uvarint(),i=Math.floor(o===void 0?s/Xo:s/16),a=o===void 0?s-i*Xo:Math.floor((s-i*16)/2),c=o===void 0?t.readUtf8(i):Ane(o,s,i,t);Cne(r,c)&&Q("unique extra keys",void 0,t.options);let u=e.extraAll??(t.indexSignatures??=new Jm(t.options)).find(e,c);if(u===void 0){nA(a,t);return}nt[ue++]=c;let f=_z(u.layout,u.wireMask,a,t);ue--,f!==On&&W(n,c,f)}function Ane(e,t,n,r){if((t&1)===1)return n>=e.length&&Q("a known back-reference",void 0,r.options),e[n];let o=r.readUtf8(n);return e.push(o),o}function Oz(e){return new Ct([e.name],new sn(e.annotations))}function Rz(e,t){throw pn(new At(e.ast,t))}function FC(e){for(;(e.byte()&128)!==0;);}function nA(e,t){switch(e){case ef:t.take(t.uvarint());return;case Yu:FC(t);return;case Ym:t.take(8);return;case Xm:case eh:case Rte:return;case th:FC(t),FC(t);return;case Ote:t.take(4);return}}function WC(e){if(e._==="literal")return WC(e.leaf);switch(e._){case"bool":return 1<<Xm|1<<eh;case"number":return 1<<Yu|1<<Ym|1<<th;case"int":return 1<<Yu;default:return 1<<ef}}function One(e,t){switch(e){case Xm:return!1;case eh:return!0;case Yu:return t.numberVarint();case Ym:return t.f64();case th:{let n=t.numberVarint(),r=t.uvarint();return(r===0||r>lE)&&Q("a decimal scale in [1, 8]",r,t.options),n/Rc[r]}}return Q("matching field wire kind",void 0,t.options)}function _z(e,t,n,r){if((t&1<<n)===0)return nA(n,r),On;if(n!==ef){let i=One(n,r);return e._==="literal"&&!nh(e,i)&&Q(dE(e),i,r.options),i}let o=r.enter(r.uvarint()),s=xr(e,r);return r.exit(o),s}function Rne(e,t){let n;e.extra.length>0&&(n=t.intern,t.intern=void 0);let r={},o=0,s=0,i,a,c,u=!1,f=e.fields,l=0;for(;t.pos<t.end;){let p=t.fieldTag(),m=Math.floor(p/Xo),h=p-m*Xo;if(m===0){u&&Q("unique field ids",void 0,t.options),u=!0,h!==ef&&Q("extra field map",void 0,t.options);let E=t.enter(t.uvarint());Pz(e,t,r,n),t.exit(E);continue}let g;if(l<f.length&&f[l].id===m?(g=f[l],l++):(g=e.byId.get(m),g!==void 0&&(l=g.index+1)),g===void 0){c===void 0?c=new Set:c.has(m)&&Q("unique field ids",void 0,t.options),c.add(m),nA(h,t);continue}let x=g.index;if(x<32){let E=1<<x;(o&E)!==0&&Q("unique field ids",void 0,t.options),o|=E}else i===void 0?i=new Set([x]):(i.has(x)&&Q("unique field ids",void 0,t.options),i.add(x));nt[ue++]=g.name;let b=_z(g.layout,g.wireMask,h,t);ue--,b!==On&&(W(r,g.name,b),x<32?s|=1<<x:(a??=new Set).add(x))}return Mz(e,s,a,t),r}function Mz(e,t,n,r){if((t&e.requiredMask)===e.requiredMask&&!e.requiredWide)return;let o=e.fields,s;for(let i=0;i<o.length;i++){let a=o[i],c=a.index,u=c<32?(t&1<<c)!==0:n?.has(c)===!0;if(!a.optional&&!u&&((s??=[]).push(Oz(a)),r.options.errors!=="all"))break}s!==void 0&&Rz(e,s)}function _ne(e,t){let n;e.extra.length>0&&(n=t.intern,t.intern=void 0);let r={},o=e.optionalCount+7>>3,s=0;o>0&&(t.pos+o>t.end&&Q("complete value",void 0,t.options),s=t.pos,t.pos+=o);let i=t.buf,a=e.fields,c=0,u;for(let f=0;f<a.length;f++){let l=a[f];if(l.optional){let m=(i[s+(c>>3)]&1<<(c&7))!==0;if(c++,!m)continue}nt[ue++]=l.name;let p=l.inline?Cz(l.layout,t):Tne(l.layout,t);if(ue--,p!==On)W(r,l.name,p);else if(!l.optional&&((u??=[]).push(Oz(l)),t.options.errors!=="all"))break}if(u!==void 0&&Rz(e,u),e.extra.length>0){let f=t.uvarint();if(f>t.remaining&&Q("complete value",void 0,t.options),f>0){let l={list:[],set:void 0};for(let p=0;p<f;p++)Az(e,t,r,l,n)}}return r}function Pz(e,t,n,r){let o={list:[],set:void 0};for(;t.pos<t.end;)Az(e,t,n,o,r)}function Mne(e,t,n){let r=n.uvarint();if((r&1)===1){let i=(r-1)/2;return i>=e.length&&Q("a known back-reference",void 0,n.options),e[i]}if(t._==="string"){let i=n.readUtf8(r/2);return e.push(i),i}let o=n.enter(r/2),s=xr(t,n);return n.exit(o),e.push(s),s}function Pne(e,t,n){let r=new Array(t),o=[],s=[];for(let i=0;i<t;i++){nt[ue++]=i;let a=n.enter(n.uvarint());r[i]=Une(e,o,s,n),n.exit(a),ue--}return r}function Fne(e,t){let n=t.uvarint(),r=e.fields,o=n&~tE;(n>tE*2-1||o>>>r.length)&&Q("a known row shape",void 0,t.options);let s=[];(n&tE)!==0&&s.push(null);for(let i=0;i<r.length;i++)(o&1<<i)!==0&&s.push(r[i]);return s}function Une(e,t,n,r){let o=e.struct,s={},i=0,a,c=r.uvarint(),u;if(c===0?r.positional&&e.shapes&&(u=Fne(o,r),t.push(u)):(u=t[c-1],u===void 0&&Q("a known row shape",void 0,r.options)),u!==void 0){for(let f=0;f<u.length;f++){let l=Kq(e,n,u[f],s,r);l>=0&&(l<32?i|=1<<l:(a??=new Set).add(l))}r.pos!==r.end&&Q("no leftover bytes",void 0,r.options)}else{let f=e.shapes?[]:void 0,l=0,p,m,h=!1;for(;r.pos<r.end;){let g=r.uvarint(),x;g===0?(h&&Q("unique field ids",void 0,r.options),h=!0,x=null):(x=o.byId.get(g),x===void 0?m===void 0?m=new Set([g]):m.has(g)?Q("unique field ids",void 0,r.options):m.add(g):x.index<32?((l&1<<x.index)!==0&&Q("unique field ids",void 0,r.options),l|=1<<x.index):p===void 0?p=new Set([x.index]):(p.has(x.index)&&Q("unique field ids",void 0,r.options),p.add(x.index))),f?.push(x);let b=Kq(e,n,x,s,r);b>=0&&(b<32?i|=1<<b:(a??=new Set).add(b))}f!==void 0&&t.push(f)}return Mz(o,i,a,r),s}function Kq(e,t,n,r,o){let s=o.uvarint();if((s&1)===1){if(n==null)return-1;let u=t[n.index],f=(s-1)/2;(u===void 0||f>=u.length)&&Q("a known back-reference",void 0,o.options);let l=u[f];return l===On?-1:(W(r,n.name,l),n.index)}let i=o.enter(s/2);if(n===null)return Pz(e.struct,o,r),o.exit(i),-1;if(n===void 0)return o.exit(i),-1;let a=e.intern[n.index];(a===cz||a===uz)&&(o.intern=t[n.index]??=[]),nt[ue++]=n.name;let c=xr(n.layout,o);return ue--,o.intern=void 0,o.exit(i),a===ZC&&(t[n.index]??=[]).push(c),c===On?-1:(W(r,n.name,c),n.index)}function Dne(e,t){let n=e.elements.length,r=e.hasCount?t.uvarint():n;if(e.hasCount&&r>t.remaining+1048576&&Q("array count within allocation limit",r,t.options),e.rest.length===0&&r>n)throw nt[ue++]=n,pn(new sa(e.ast,void 0,t.options));if(r<e.minCount)throw nt[ue++]=r,pn(new sn(void 0));if(r>0){let i=xz(e);if(i!==null)return Pne(i,r,t)}let o=new Array(r),s=e.uniform;if(s!==void 0){if(e.uniformNumbers)return Nne(o,r,t);let i=t.intern;if(t.intern=void 0,i!==void 0){for(let u=0;u<r;u++){nt[ue++]=u;let f=Mne(i,s,t);if(f===On)throw pn(new sn(void 0));ue--,o[u]=f}return o}if(pE(s)){for(let u=0;u<r;u++)nt[ue++]=u,o[u]=Qm(s,t),ue--;return o}if(s._==="string"){for(let u=0;u<r;u++)nt[ue++]=u,o[u]=t.readUtf8(t.uvarint()),ue--;return o}let a=e.uniformPacked,c=e.uniformInline;for(let u=0;u<r;u++){nt[ue++]=u;let f=t.enter(c?a??0:t.uvarint()),l=xr(s,t);if(t.exit(f),l===On)throw pn(new sn(void 0));ue--,o[u]=l}return o}for(let i=0;i<r;i++){let a=vz(e,i,r),c=i<n&&e.elements[i].optional;if(!e.hasCount&&t.remaining===0&&!c&&a._!=="null"&&a._!=="undefined")throw nt[ue++]=i,pn(new sn(void 0));nt[ue++]=i;let u=Cz(a,t);if(u===On)throw c&&Q("known union member",void 0,t.options),pn(new sn(void 0));ue--,o[i]=u}if(!e.hasCount&&t.pos<t.end)throw nt[ue++]=n,pn(new sa(e.ast,void 0,t.options));return o}function Nne(e,t,n){let r=n.byte();if(r===tz){n.remaining!==t*8&&Q("f64",void 0,n.options);for(let o=0;o<t;o++)e[o]=n.f64();return e}if(r===rz){for(let o=0;o<t;o++){nt[ue++]=o;let s=n.uvarint(),i=s%16;i>lE&&Q("decimal",void 0,n.options);let a=oz((s-i)/16);e[o]=i===0?a:a/Rc[i],ue--}return e}r!==nz&&Q("f64",void 0,n.options);for(let o=0;o<t;o++)nt[ue++]=o,e[o]=n.numberVarint(),ue--;return e}function Lne(e,t){let n=t.byte();if(n===St.variant){let o=t.u32le(),s=e.byTag.get(o);if(s===void 0)return t.take(t.remaining),On;let i=xr(s.payload,t);if(i===On)return On;if(!s.tuple)for(let a of s.sentinels)W(i,a.key,a.literal);return i}let r=e.byKind.get(n);return r===void 0?(t.take(t.remaining),On):xr(r,t)}function Bne(e,t){let n=e.byPos[t.uvarint()];n===void 0&&Q("known union member",void 0,t.options);let r=xr(n.layout,t),o=n.variant;if(o!==void 0&&!o.tuple&&r!==On)for(let s of o.sentinels)W(r,s.key,s.literal);return r}function Vq(e,t){switch(t.byte()){case 0:return Lf(rd(xr(e.error,t)));case 1:return Bf(rd(xr(e.defect,t)));case 2:return t.remaining!==0&&Q("empty",void 0,t.options),ou();case 3:return t.remaining!==8&&Q("f64",void 0,t.options),ou(t.f64());default:return t.take(t.remaining),On}}function rd(e){if(e===On)throw pn(new sn(void 0));return e}function Qm(e,t){switch(e._){case"literal":{let n=Qm(e.leaf,t);return nh(e,n)||Q(dE(e),n,t.options),n}case"bool":{t.remaining!==1&&Q("bool",void 0,t.options);let n=t.byte();return n>1&&Q("bool",void 0,t.options),n===1}case"null":return t.remaining!==0&&Q("empty",void 0,t.options),null;case"undefined":t.remaining!==0&&Q("empty",void 0,t.options);return;case"number":{let n=t.remaining;if(n===8)return t.f64();(n===0||n>ez)&&Q("f64",void 0,t.options);let r=t.numberVarint();if(t.remaining===0)return r;let o=t.byte();return(t.remaining!==0||o===0||o>lE)&&Q("decimal",void 0,t.options),r/Rc[o]}case"int":return t.numberVarint();case"string":{let n=t.dict;return n===void 0?t.readUtf8(t.end-t.pos):xne(n,e,t)}case"symbol":return globalThis.Symbol.for(t.readUtf8(t.end-t.pos));case"bytes":return t.takeCopy(t.end-t.pos);case"bigint":return t.zigzag();case"int64":{t.remaining!==8&&Q("int64",void 0,t.options);let n=Number(t.i64());if(e.flavor!=="date")return DF(n);let r=new Date(n);return Number.isNaN(r.getTime())&&Q("a valid Date",n,t.options),r}case"dateTimeZoned":{let n=Number(t.i64()),r=t.byte(),o;if(r===0)t.remaining!==4&&Q("time zone",void 0,t.options),o=t.i32le();else if(r===1)o=t.readUtf8(t.end-t.pos);else return Q("time zone",void 0,t.options);try{return Ex(n,{timeZone:o})}catch{return Q("time zone",void 0,t.options)}}case"duration":switch(t.byte()){case 0:return Nr(t.zigzag());case 1:return fo;case 2:return Hi;default:return Q("duration",void 0,t.options)}case"bigDecimal":{let n=t.zigzag(),r=t.zigzag();return(r>DC||-r>DC)&&Q("safe integer length",void 0,t.options),sr(n,Number(r))}case"json":{let n=t.readUtf8(t.end-t.pos);try{return JSON.parse(n)}catch{return Q("json",void 0,t.options)}}case"option":{let n=t.byte();return n===0?(t.remaining!==0&&Q("empty",void 0,t.options),U()):(n!==1&&Q("bool",void 0,t.options),N(rd(xr(e.value,t))))}case"result":{let n=t.byte();return n===0?Ce(rd(xr(e.success,t))):(n!==1&&Q("bool",void 0,t.options),Ae(rd(xr(e.failure,t))))}case"exit":{let n=t.byte();if(n===0)return kn(rd(xr(e.value,t)));n!==1&&Q("bool",void 0,t.options);let r=Qm(e.cause,t);return jt(r)}case"cause":{let n=t.uvarint(),r=[];for(let o=0;o<n;o++){nt[ue++]=o;let s=t.enter(t.uvarint()),i=Vq(e,t);t.exit(s),ue--,i!==On&&r.push(i)}return t.pos!==t.end&&Q("no leftover bytes",void 0,t.options),Va(r)}case"causeReason":return Vq(e,t);case"struct":return t.positional?_ne(e,t):Rne(e,t);case"array":return Dne(e,t);case"union":return t.positional?Bne(e,t):Lne(e,t);case"never":throw pn(new st(e.ast,void 0,t.options))}}function Fz(e,t,n){let r=t.byte();if(r!==n.envelope&&Q(n.expectedEnvelope,r,t.options),n.positional){t.remaining<8&&Q("complete value",void 0,t.options);let s=t.buf,i=n.fingerprint,a=t.pos;for(let c=0;c<8;c++)s[a+c]!==i[c]&&Q("matching layout fingerprint",void 0,t.options);t.pos=a+8}let o=xr(e,t);if(o===On)throw pn(new sn(void 0));return o}var XS=new Gm;function jne(e,t,n,r){let o=XS??new Gm,s=o===XS;s&&(XS=void 0),o.reset(t,0,t.length,n,void 0,r.positional,void 0);let i=ue;ue=0;try{let a=o.uvarint();a===0&&Q("nonzero frame length",void 0,n);let c=o.enter(a),u=Fz(e,o,r);return o.exit(c),o.pos!==t.length&&Q("no leftover bytes",void 0,n),u}finally{ue=i,o.release(),s&&(XS=o)}}function $ne(e,t,n,r=!1){return Ar({decode:(o,s)=>{try{let i=jne(e,o,s,t);return n!==void 0&&fd(i)&&(!r||hE(i))&&(n.value=i),v(i)}catch(i){return i instanceof Mi?G(i.issue):po(i)}},encode:(o,s)=>{try{return v(fE(e,o,s,t))}catch(i){return i instanceof Mi?G(i.issue):po(i)}}})}var qne=wn(Qte);function Xu(e,t){return t===!0?qne(e):Zte}var zne=wn(e=>{let t=re(nE(e)),{exact:n,exitSuccess:r,layout:o,recursive:s}=Kte(t.ast);return{target:s?Jne(t):t,layout:o,exact:n,exitSuccess:r,recursive:s}});function sd(e){return zne(e.ast)}function Uz(e,t){return e.value===void 0||t!==e.value?!1:(e.value=void 0,!0)}function Dz(e,t,n){let r=re(yn(e.ast)),o=dt(r),s=i=>()=>(a,c,u)=>i(a,u)?on:o(a,u);return re(new aa([r.ast],s(t),{identifier:"binary value"},void 0,void 0,void 0,void 0,s(n)))}function KC(e,t){return t.onExcessProperty!=="error"}function Hne(e,t,n){return Dz(e,r=>Uz(t,r),n?KC:Wne)}function Wne(){return!1}function Kne(e,t){return An()([e],([n])=>{let r=dt(n);return(o,s,i)=>Uz(t,o)||hE(o)&&i.onExcessProperty!=="error"?v(o):r(o,i)},{identifier:"binary exit value"})}function Vne(e){return Dz(e,KC,KC)}function Jne(e){let t=re(yn(e.ast)),n=new WeakSet,r=An()([t],([o])=>(s,i,a)=>fd(s)&&n.delete(s)?v(s):gr(s)?G(new st(i,s,a)):dt(o)(s,a),{identifier:"acyclic value"});return Ee(r,vt({decode:o=>(fd(o)&&n.add(o),o),encode:o=>o}))(e)}var oh=Ec,En=class extends Ke()("effect/rpc/RpcSerialization"){},rh=class extends Mn("MaxBufferSizeExceeded"){get message(){return`RPC serialization buffer exceeded the maximum size of ${this.maxBufferSize}`}},Bz=16*1024*1024,gE=(e,t)=>t!=="unbounded"&&e>t,jz=En.of({contentType:"application/json",includesFraming:!1,codecFor:oh,makeUnsafe:()=>{let e=new TextDecoder;return{decode:t=>{let n=JSON.parse(typeof t=="string"?t:e.decode(t));return Array.isArray(n)?n:[n]},encode:t=>JSON.stringify(t)}}}),xE=e=>{let t=e?.maxBufferSize??Bz;return En.of({contentType:"application/ndjson",includesFraming:!0,codecFor:oh,makeUnsafe:()=>{let n=new TextDecoder,r="",o=s=>{throw r="",new rh({maxBufferSize:s})};return{decode:s=>{r+=typeof s=="string"?s:n.decode(s,{stream:!0});let i=0,a=r.indexOf(`
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
`,m));n=n+p.substring(m,p.length-(r?1:0))}}return Ye(u)?u:null}let i=K(()=>o._tag==="Some"?me(o.value):np(e,{onSuccess:a,onFailure:ct,onDone:c=>{if(o=L(c),n.length>0||r){let u=n;return n="",r=!1,v([u])}return me(c)}}));function a(c){let u=s(c);return u!==null?v(u):i}return i}));var Hv=d(2,(e,t)=>Ge((n,r)=>R(Pe(e)(n,r),o=>Pe(t)(o,r)))),Wv=d(2,(e,t)=>Ge((n,r)=>R(Pe(e)(n,r),o=>{let s=ft(o,i=>No(i)?ct(i):ho(SP(i)));return Y(Pe(t)(s,r),i=>Mw(i,a=>Gd(a)?ct(a.value):ho(a)))}))),va=e=>Ge((t,n)=>{let r;return v(K(()=>r||e.pipe(Uo(n),R(o=>Pe(o)(t,n)),R(o=>r=o))))}),JD=e=>Us((t,n,r)=>Y(Uo(Pe(e)(t,n),r),Uo(r)));var GD=d(2,(e,t)=>Ge(Se(function*(n,r){let o=yield*Pe(e)(n,r),s=yield*to({capacity:t.capacity==="unbounded"?void 0:t.capacity,strategy:t.capacity==="unbounded"?void 0:t.strategy});return yield*_t(r,Ms(s)),yield*o.pipe(R(i=>Xn(s,i)),Ht({disableYield:!0}),go(i=>Zt(s,i)),Ut(r)),Wo(s)}))),ZD=d(2,(e,t)=>Ge(Se(function*(n,r){let o=yield*Pe(e)(n,r),s=yield*to({capacity:t.capacity==="unbounded"?void 0:t.capacity,strategy:t.capacity==="unbounded"?void 0:t.strategy});return yield*_t(r,Ms(s)),yield*o.pipe(R(i=>wa(s,i)),Ht({disableYield:!0}),go(i=>Zt(s,i)),Ut(r)),Rl(s)}))),QD=d(2,(e,t)=>_y(e,qn(v(R(t,me))),{haltStrategy:"either"})),YD=d(2,(e,t)=>Us(Se(function*(n,r,o){let s=yield*Pe(e)(n,r),i=yield*Ut(t,o,{startImmediately:!0});return K(()=>{let a=i.pollUnsafe();return a===void 0?s:EP(a,{onFailure:ct,onSuccess:me})})}))),XD=d(2,(e,t)=>Qp(e,n=>ii(n)?t(n.cause):H)),Qp=d(2,(e,t)=>Us((n,r,o)=>Do(o,t).pipe(Dn(Pe(e)(n,r))))),eN=d(2,(e,t)=>va(zt(t,e))),Kv=d(2,(e,t)=>Fs(e,n=>se(()=>{let r=!0,o=Mt(n,s=>(r=!1,t(s)));return K(()=>r?o:n)}))),tN=d(2,(e,t)=>Fs(e,n=>v(qt(n,r=>R(t,()=>me(r)))))),nN=d(2,(e,t)=>Qp(e,n=>t)),Nu=(e,t,n)=>K(()=>{let r=zr(),o=Pe(e)(me(),r);return qt(R(o,t),n||v).pipe(ur(s=>Je(r,s)))});var My=d(2,(e,t)=>Ge((n,r)=>Y(Nn(Pe(e)(n,r),t),Nn(t)))),Py=d(3,(e,t,n)=>Ge((r,o)=>Y(qo(Pe(e)(r,o),t,n),qo(t,n)))),Fy=d(3,(e,t,n)=>Ge((r,o)=>R(n,s=>Pe(Py(e,t,s))(r,o)))),rN=d(e=>er(e[0]),(e,t,n)=>Dd(t)?My(e,t):Ge((r,o)=>R(n?.local?ci(t,ai(),o):Zd(t,o),s=>Y(Nn(Pe(e)(r,o),s),Nn(s))))),oN=d(2,(e,t)=>Ge((n,r)=>cr(o=>{let s=t(o);return Pe(My(e,s))(n,r)})));var Vv=function(){let e=er(arguments[0]),t=e?arguments[1]:arguments[0],n=Po(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return iD(r,t,n)}return r=>iD(r,t,n)},iD=(e,t,n)=>TJ(Vw(t,n),r=>Py(e,ti,r),(r,o)=>xn(s=>{let i=s.getRef(mo),a=s.getRef(TP);return Bg(r,o,i,a)}));var sN=e=>Nu(e,t=>Ht(t,{disableYield:!0})),Lu=d(2,(e,t)=>Nu(e,n=>Ht(R(n,t),{disableYield:!0}))),iN=d(2,(e,t)=>Nu(e,n=>n.pipe(R(t),R(r=>r?H:me()),Ht({disableYield:!0})))),Jv=e=>Y(Bu(e,()=>({bytes:0,arrays:[]}),(t,n)=>{for(let r=0;r<n.length;r++)t.bytes+=n[r].length,t.arrays.push(n[r]);return t}),({arrays:t,bytes:n})=>{let r=new Uint8Array(n),o=0;for(let s=0;s<t.length;s++){let i=t[s];r.set(i,o),o+=i.length}return r});var aN=e=>K(()=>{let t=D();return Nu(e,n=>n.pipe(dx,R(r=>(t=r,me()))),()=>v(t))}),cN=e=>K(()=>{let t=Symbol(),n=t;return Nu(e,r=>Ht(R(r,o=>(n=o,H)),{disableYield:!0}),()=>n===t?Es:fx(n))}),Bu=d(3,(e,t,n)=>K(()=>{let r=t();return Nu(e,o=>Qn({while:Xt,body:()=>o,step:s=>{r=n(r,s)}}),()=>v(r))})),uN=d(3,(e,t,n)=>K(()=>{let r=t();return Nu(e,o=>Qn({while:Xt,body:Qe(o.pipe(R(s=>n(r,s)),Y(s=>{r=s}))),step:En}),()=>v(r))})),Gv=Se(function*(e){let t=Ia(1),n=yield*ar(),r=$e(n,It);return(yield*Pe(e)(me(),r)).pipe(Nn(n),t.withPermits(1))},ft(e=>v(ct(e)))),Ko=(e,t)=>Pe(e)(me(),t);var Zv=d(e=>er(e[0]),(e,t)=>yo(n=>Lu(e,r=>wa(t,r)).pipe(n,Vr,R(r=>(Ft(r)?eD(t):wi(t,r.cause),H)))));var fN=d(e=>er(e[0]),Se(function*(e,t){let n=yield*$o,r=yield*to({capacity:typeof t.capacity=="number"?t.capacity:void 0,strategy:typeof t.capacity=="number"?t.strategy:void 0});return yield*_t(n,Ms(r)),yield*Ut(Zv(e,r),n),r}));var lN=e=>ic(e.capacity==="unbounded"?Hp(e):e.strategy==="dropping"?my(e):e.strategy==="sliding"?hy(e):py(e),Wp),dN=d(2,Se(function*(e,t){let n=yield*lN(t);return yield*Is(Qv(e,n,{shutdownOnEnd:t.shutdownOnEnd!==!1})),n})),Qv=d(e=>er(e[0]),(e,t,n)=>Lu(e,r=>Q1(t,r)).pipe(n?.shutdownOnEnd===!0?ca(Wp(t)):B)),pN=d(2,Se(function*(e,t){let n=yield*lN(t);return yield*Lu(e,r=>kl(n,r)).pipe(ur(r=>kl(n,r)),Is),n}));var A={};ns(A,{Any:()=>F5,Array:()=>Wt,ArrayEnsure:()=>z5,BigDecimal:()=>ek,BigDecimalFromString:()=>qQ,BigDecimalReviver:()=>jQ,BigInt:()=>Ti,BigIntFromString:()=>QQ,Boolean:()=>vc,BooleanFromBit:()=>o7,Cause:()=>Hl,CauseReason:()=>sS,CauseReasonReviver:()=>fQ,CauseReviver:()=>lQ,Char:()=>QZ,Chunk:()=>FB,ChunkReviver:()=>vQ,Class:()=>hS,Date:()=>qs,DateFromMillis:()=>OQ,DateFromString:()=>RQ,DateReviver:()=>AQ,DateTimeUtc:()=>km,DateTimeUtcFromDate:()=>f7,DateTimeUtcFromMillis:()=>d7,DateTimeUtcFromString:()=>l7,DateTimeUtcReviver:()=>u7,DateTimeZoned:()=>ik,DateTimeZonedFromString:()=>S7,DateTimeZonedReviver:()=>y7,Defect:()=>ln,Duration:()=>Tm,DurationFromMillis:()=>UQ,DurationFromNanos:()=>FQ,DurationFromString:()=>PQ,DurationReviver:()=>_Q,Enum:()=>P5,Error:()=>$n,ErrorInstance:()=>kB,ErrorInstanceReviver:()=>mQ,Exit:()=>pS,ExitReviver:()=>hQ,File:()=>tk,FileReviver:()=>HQ,Finite:()=>js,FiniteFromString:()=>ZQ,FormData:()=>nk,FormDataReviver:()=>WQ,Graph:()=>OB,GraphReviver:()=>bQ,HashMap:()=>_B,HashMapReviver:()=>EQ,HashSet:()=>PB,HashSetReviver:()=>IQ,Int:()=>$s,Json:()=>Am,JsonObject:()=>r9,JsonReviver:()=>o9,Literal:()=>Rt,Literals:()=>ka,MutableJson:()=>sj,MutableJsonReviver:()=>i9,Natural:()=>tr,Never:()=>Ic,NonEmptyArray:()=>fS,NonEmptyString:()=>ZZ,Null:()=>tt,NullOr:()=>$T,NullishOr:()=>EL,Number:()=>Vl,NumberFromString:()=>GQ,ObjectKeyword:()=>U5,Opaque:()=>rZ,Option:()=>ki,OptionFromNullOr:()=>XZ,OptionFromNullishOr:()=>tQ,OptionFromOptional:()=>rQ,OptionFromOptionalKey:()=>nQ,OptionFromOptionalNullOr:()=>oQ,OptionFromUndefinedOr:()=>eQ,OptionReviver:()=>YZ,PropertyKey:()=>FT,ReadonlyMap:()=>RB,ReadonlyMapReviver:()=>gQ,ReadonlySet:()=>MB,ReadonlySetReviver:()=>wQ,Record:()=>qT,Redacted:()=>QT,RedactedFromValue:()=>uQ,RedactedReviver:()=>cQ,RegExp:()=>UB,RegExpReviver:()=>TQ,Result:()=>xB,ResultReviver:()=>sQ,SchemaError:()=>Mr,StandardSchemaV1FailureResult:()=>r7,String:()=>fe,StringFromBase64:()=>XQ,StringFromBase64Url:()=>e7,StringFromHex:()=>t7,StringFromUriComponent:()=>n7,Struct:()=>oe,StructWithRest:()=>q5,Symbol:()=>yL,TaggedClass:()=>I7,TaggedError:()=>ck,TaggedStruct:()=>Tc,TaggedUnion:()=>nZ,TemplateLiteral:()=>_5,TemplateLiteralParser:()=>M5,TimeZone:()=>sk,TimeZoneFromString:()=>x7,TimeZoneNamed:()=>ok,TimeZoneNamedFromString:()=>h7,TimeZoneNamedReviver:()=>m7,TimeZoneOffset:()=>HB,TimeZoneOffsetReviver:()=>p7,TimeZoneReviver:()=>g7,Tree:()=>n9,Trim:()=>YQ,Trimmed:()=>$B,Tuple:()=>Ec,TupleWithRest:()=>$5,URL:()=>YT,URLFromString:()=>CQ,URLReviver:()=>kQ,URLSearchParams:()=>rk,URLSearchParamsReviver:()=>VQ,Uint8Array:()=>Go,Uint8ArrayFromBase64:()=>i7,Uint8ArrayFromBase64Url:()=>a7,Uint8ArrayFromHex:()=>c7,Uint8ArrayReviver:()=>s7,Undefined:()=>BT,UndefinedOr:()=>lS,Union:()=>He,UniqueArray:()=>H5,UniqueSymbol:()=>D5,Unknown:()=>LT,UnknownFromJsonString:()=>zQ,Void:()=>Jl,annotate:()=>f5,annotateEncoded:()=>l5,annotateKey:()=>d5,asserts:()=>g5,brand:()=>IL,catchDecoding:()=>G5,catchDecodingWithContext:()=>kL,catchEncoding:()=>Z5,catchEncodingWithContext:()=>CL,check:()=>K5,declare:()=>no,declareConstructor:()=>An,decode:()=>Q5,decodeEffect:()=>x5,decodeExit:()=>fL,decodeOption:()=>S5,decodePromise:()=>E5,decodeResult:()=>b5,decodeSync:()=>xm,decodeTo:()=>be,decodeUnknownEffect:()=>wc,decodeUnknownExit:()=>uL,decodeUnknownOption:()=>y5,decodeUnknownPromise:()=>dL,decodeUnknownResult:()=>lL,decodeUnknownSync:()=>aS,encode:()=>Y5,encodeEffect:()=>cS,encodeExit:()=>mL,encodeKeys:()=>B5,encodeOption:()=>I5,encodePromise:()=>T5,encodeResult:()=>v5,encodeSync:()=>NT,encodeTo:()=>zT,encodeUnknownEffect:()=>ym,encodeUnknownExit:()=>pL,encodeUnknownOption:()=>w5,encodeUnknownPromise:()=>gL,encodeUnknownResult:()=>hL,encodeUnknownSync:()=>uS,extendTo:()=>j5,fieldsAssign:()=>N5,flip:()=>MT,fromBrand:()=>J5,fromFormData:()=>KQ,fromJsonString:()=>qB,fromURLSearchParams:()=>JQ,instanceOf:()=>kc,is:()=>oL,isBase64:()=>KT,isBase64Reviver:()=>hZ,isBase64Url:()=>LL,isBase64UrlReviver:()=>gZ,isBetween:()=>dS,isBetweenBigDecimal:()=>LZ,isBetweenBigInt:()=>aB,isBetweenBigIntReviver:()=>Z7,isBetweenDate:()=>nB,isBetweenDateReviver:()=>W7,isBetweenReviver:()=>RZ,isCapitalized:()=>HL,isCapitalizedReviver:()=>wZ,isEndsWith:()=>jL,isEndsWithReviver:()=>yZ,isFinite:()=>KL,isFiniteReviver:()=>vZ,isGUID:()=>DL,isGUIDReviver:()=>pZ,isGreaterThan:()=>JL,isGreaterThanBigDecimal:()=>FZ,isGreaterThanBigInt:()=>rB,isGreaterThanBigIntReviver:()=>K7,isGreaterThanDate:()=>YL,isGreaterThanDateReviver:()=>q7,isGreaterThanOrEqualTo:()=>VT,isGreaterThanOrEqualToBigDecimal:()=>UZ,isGreaterThanOrEqualToBigInt:()=>oB,isGreaterThanOrEqualToBigIntReviver:()=>V7,isGreaterThanOrEqualToDate:()=>XL,isGreaterThanOrEqualToDateReviver:()=>$7,isGreaterThanOrEqualToReviver:()=>kZ,isGreaterThanReviver:()=>TZ,isIncludes:()=>qL,isIncludesReviver:()=>SZ,isInt:()=>vm,isInt32:()=>MZ,isIntReviver:()=>_Z,isLengthBetween:()=>GT,isLengthBetweenReviver:()=>qZ,isLessThan:()=>GL,isLessThanBigDecimal:()=>DZ,isLessThanBigInt:()=>sB,isLessThanBigIntReviver:()=>J7,isLessThanDate:()=>eB,isLessThanDateReviver:()=>z7,isLessThanOrEqualTo:()=>ZL,isLessThanOrEqualToBigDecimal:()=>NZ,isLessThanOrEqualToBigInt:()=>iB,isLessThanOrEqualToBigIntReviver:()=>G7,isLessThanOrEqualToDate:()=>tB,isLessThanOrEqualToDateReviver:()=>H7,isLessThanOrEqualToReviver:()=>AZ,isLessThanReviver:()=>CZ,isLowercased:()=>zL,isLowercasedReviver:()=>EZ,isMaxLength:()=>uB,isMaxLengthReviver:()=>jZ,isMaxProperties:()=>mB,isMaxPropertiesReviver:()=>KZ,isMaxSize:()=>lB,isMaxSizeReviver:()=>zZ,isMinLength:()=>JT,isMinLengthReviver:()=>BZ,isMinProperties:()=>pB,isMinPropertiesReviver:()=>WZ,isMinSize:()=>fB,isMinSizeReviver:()=>$Z,isMultipleOf:()=>QL,isMultipleOfReviver:()=>OZ,isNonEmpty:()=>cB,isPattern:()=>Zu,isPatternReviver:()=>aZ,isPropertiesLengthBetween:()=>hB,isPropertiesLengthBetweenReviver:()=>VZ,isPropertyNames:()=>gB,isPropertyNamesReviver:()=>JZ,isSchema:()=>Gu,isSchemaError:()=>Wl,isSizeBetween:()=>dB,isSizeBetweenReviver:()=>HZ,isStartsWith:()=>BL,isStartsWithReviver:()=>xZ,isStringBigInt:()=>PL,isStringBigIntReviver:()=>uZ,isStringFinite:()=>ML,isStringFiniteReviver:()=>cZ,isStringSymbol:()=>FL,isStringSymbolReviver:()=>fZ,isTrimmed:()=>WT,isTrimmedReviver:()=>sZ,isULID:()=>NL,isULIDReviver:()=>mZ,isUUID:()=>UL,isUUIDReviver:()=>dZ,isUint32:()=>PZ,isUncapitalized:()=>WL,isUncapitalizedReviver:()=>IZ,isUnique:()=>ZT,isUniqueReviver:()=>GZ,isUppercased:()=>$L,isUppercasedReviver:()=>bZ,link:()=>pt,make:()=>re,makeFilter:()=>Tt,makeFilterGroup:()=>oZ,makeIsBetween:()=>Im,makeIsGreaterThan:()=>Sm,makeIsGreaterThanOrEqualTo:()=>bm,makeIsLessThan:()=>Em,makeIsLessThanOrEqualTo:()=>wm,makeIsMultipleOf:()=>VL,middlewareDecoding:()=>vL,middlewareEncoding:()=>TL,mutable:()=>W5,mutableKey:()=>A5,optional:()=>Pt,optionalKey:()=>Ju,overrideToCodecIso:()=>e9,overrideToEquivalence:()=>C7,overrideToFormatter:()=>T7,readonlyKey:()=>R5,refine:()=>V5,required:()=>C5,requiredKey:()=>k5,resolveAnnotations:()=>a9,resolveAnnotationsKey:()=>c9,revealBottom:()=>u5,revealCodec:()=>p5,suspend:()=>wL,tag:()=>Ze,tagDefaultOmit:()=>tZ,toArbitrary:()=>v7,toCodecArrayFromSingle:()=>P7,toCodecIso:()=>YB,toCodecJson:()=>Cc,toCodecJsonAST:()=>gS,toCodecStringTree:()=>ej,toDifferJsonPatch:()=>t9,toEncoded:()=>Kl,toEncoderXml:()=>F7,toEquivalence:()=>A7,toFormatter:()=>k7,toIso:()=>Q7,toIsoFocus:()=>X7,toIsoSource:()=>Y7,toJsonSchemaDocument:()=>GB,toRepresentation:()=>R7,toStandardJSONSchemaV1:()=>h5,toStandardSchemaV1:()=>m5,toTaggedUnion:()=>_L,toType:()=>Pr,withConstructorDefault:()=>AL,withDecodingDefault:()=>OL,withDecodingDefaultKey:()=>HT,withDecodingDefaultType:()=>eZ,withDecodingDefaultTypeKey:()=>X5});var Dy="~effect/collections/Graph",Yv=e=>e;var MJ=(e,t,n)=>(e==="directed"?t.source===n.source&&t.target===n.target:t.source===n.source&&t.target===n.target||t.source===n.target&&t.target===n.source)&&ae(t.data,n.data),PJ=(e,t)=>e==="directed"?ce(t):Ua(ce(t.data)^ce(t.source)+ce(t.target)),FJ={[Dy]:{_N:e=>e,_E:e=>e},[Symbol.iterator](){return this.nodes[Symbol.iterator]()},[at](){return this.toJSON()},[_e](e){if(j(e,Dy)){let t=Yv(e);if(this.nodes.size!==t.nodes.size||this.edges.size!==t.edges.size||this.type!==t.type)return!1;for(let[n,r]of this.nodes)if(!t.nodes.has(n)||!ae(r,t.nodes.get(n)))return!1;for(let[n,r]of this.edges){let o=t.edges.get(n);if(o===void 0||!MJ(this.type,r,o))return!1}return!0}return!1},[Oe](){let e=it("Graph");e=e^it(this.type),e=e^Nr(this.nodes.size),e=e^Nr(this.edges.size);for(let[t,n]of this.nodes)e=e^ce(t)+ce(n);for(let[t,n]of this.edges)e=e^ce(t)+PJ(this.type,n);return e},toJSON(){return{_id:"Graph",nodeCount:this.nodes.size,edgeCount:this.edges.size,type:this.type}},toString(){return`Graph(${this.type}, ${this.nodes.size}, ${this.edges.size})`},pipe(){return ie(this,arguments)}},mN=(e,t)=>{let n=Object.create(FJ);return n.type=e,n.mutable=t,n.transforming=!1,n.nodes=new Map,n.edges=new Map,n.adjacency=new Map,n.reverseAdjacency=new Map,n.nextNodeIndex=0,n.nextEdgeIndex=0,n.acyclic=L(!0),n};var Yp=e=>{let t=Yv(e);return{type:e.type,nodes:Array.from(t.nodes,([n,r])=>({index:n,data:r})).sort((n,r)=>n.index-r.index),edges:Array.from(t.edges,([n,r])=>({index:n,source:r.source,target:r.target,data:r.data})).sort((n,r)=>n.index-r.index)}},Xp=e=>{let t=mN(e.type,!1);for(let n of e.nodes)t.nodes.set(n.index,n.data),t.adjacency.set(n.index,[]),t.reverseAdjacency.set(n.index,[]);for(let n of e.edges)t.edges.set(n.index,{source:n.source,target:n.target,data:n.data}),t.adjacency.get(n.source).push(n.index),t.reverseAdjacency.get(n.target).push(n.index),e.type==="undirected"&&(t.adjacency.get(n.target).push(n.index),t.reverseAdjacency.get(n.source).push(n.index));return t.nextNodeIndex=e.nodes.length===0?0:e.nodes[e.nodes.length-1].index+1,t.nextEdgeIndex=e.edges.length===0?0:e.edges[e.edges.length-1].index+1,t.acyclic=D(),t};var UJ=Dy;var Xv=e=>j(e,UJ);var gN=class e{type;source;target;identity;constructor(t,n,r,o){this.type=t,this.source=n,this.target=r,this.identity=o}[_e](t){return!(t instanceof e)||this.type!==t.type||!ae(this.identity,t.identity)?!1:this.type==="directed"?ae(this.source,t.source)&&ae(this.target,t.target):ae(this.source,t.source)&&ae(this.target,t.target)||ae(this.source,t.target)&&ae(this.target,t.source)}[Oe](){let t=ce(this.identity);return this.type==="directed"?Nt(ce(this.target))(Nt(ce(this.source))(t)):Ua(t^ce(this.source)+ce(this.target))}};var Ly="~effect/collections/HashMap",Ns=5,tm=1<<Ns,DJ=tm/4,yN=tm/2,NJ=tm-1,LJ=e=>(e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24),em=(e,t)=>e>>>t&NJ,xc=(e,t)=>1<<em(e,t),Ny=(e,t)=>LJ(e&t-1);function SN(e,t,n,r,o,s){if(t>32)throw new Error("HashMap: max depth exceeded");let i=xc(n,t),a=xc(o,t);if(i===a){let f=SN(e,t+Ns,n,r,o,s);return new $u(e,i,[f])}let c=i|a,u=i>>>0<a>>>0?[r,s]:[s,r];return new $u(e,c,u)}var ju=class{canEdit(t){return this.edit===t}},eT=class extends ju{_tag="EmptyNode";edit=0;get size(){return 0}get(t,n,r){return D()}has(t,n,r){return!1}set(t,n,r,o,s,i){return i.value=!0,new qu(t,r,o,s)}remove(t,n,r,o,s){return this}iterator(){return[][Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}canEdit(t){return!1}},qu=class e extends ju{_tag="LeafNode";edit;hash;key;value;constructor(t,n,r,o){super(),this.edit=t,this.hash=n,this.key=r,this.value=o}get size(){return 1}get(t,n,r){return this.hash===n&&ae(this.key,r)?L(this.value):D()}has(t,n,r){return this.hash===n&&ae(this.key,r)}set(t,n,r,o,s,i){if(this.hash===r&&ae(this.key,o))return ae(this.value,s)?this:this.canEdit(t)?(this.value=s,this):new e(t,r,o,s);if(i.value=!0,this.hash===r)return new tT(t,r,[[this.key,this.value],[o,s]]);let a=xc(r,n),c=xc(this.hash,n);if(a===c)return new $u(t,a,[this.set(t,n+Ns,r,o,s,i)]);let u=a|c,f=a>>>0<c>>>0?[new e(t,r,o,s),this]:[this,new e(t,r,o,s)];return new $u(t,u,f)}remove(t,n,r,o,s){if(this.hash===r&&ae(this.key,o)){s.value=!0;return}return this}iterator(){return[[this.key,this.value]][Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}},tT=class e extends ju{_tag="CollisionNode";edit;hash;entries;constructor(t,n,r){super(),this.edit=t,this.hash=n,this.entries=r}get size(){return this.entries.length}get(t,n,r){if(this.hash!==n)return D();for(let[o,s]of this.entries)if(ae(o,r))return L(s);return D()}has(t,n,r){if(this.hash!==n)return!1;for(let[o]of this.entries)if(ae(o,r))return!0;return!1}set(t,n,r,o,s,i){if(this.hash!==r)return i.value=!0,SN(t,n,this.hash,this,r,new qu(t,r,o,s));for(let a=0;a<this.entries.length;a++)if(ae(this.entries[a][0],o)){if(ae(this.entries[a][1],s))return this;if(this.canEdit(t))return this.entries[a]=[o,s],this;let c=[...this.entries];return c[a]=[o,s],new e(t,this.hash,c)}return i.value=!0,this.canEdit(t)?(this.entries.push([o,s]),this):new e(t,this.hash,[...this.entries,[o,s]])}remove(t,n,r,o,s){if(this.hash!==r)return this;let i=this.entries.findIndex(([c])=>ae(c,o));if(i===-1)return this;if(s.value=!0,this.entries.length===1)return;if(this.entries.length===2){let c=this.entries[i===0?1:0];return new qu(t,this.hash,c[0],c[1])}if(this.canEdit(t))return this.entries.splice(i,1),this;let a=[...this.entries];return a.splice(i,1),new e(t,this.hash,a)}iterator(){return this.entries[Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}},$u=class e extends ju{_tag="IndexedNode";edit;_size;bitmap;children;constructor(t,n,r){super(),this.edit=t,this.bitmap=n,this.children=r}get size(){return this._size===void 0&&(this._size=this.children.reduce((t,n)=>t+n.size,0)),this._size}get(t,n,r){let o=xc(n,t);if((this.bitmap&o)===0)return D();let s=Ny(this.bitmap,o);return this.children[s].get(t+Ns,n,r)}has(t,n,r){let o=xc(n,t);if((this.bitmap&o)===0)return!1;let s=Ny(this.bitmap,o);return this.children[s].has(t+Ns,n,r)}set(t,n,r,o,s,i){let a=xc(r,n),c=Ny(this.bitmap,a);if((this.bitmap&a)!==0){let u=this.children[c],f=u.set(t,n+Ns,r,o,s,i);if(u===f)return this;if(this.canEdit(t))return this.children[c]=f,this;let l=[...this.children];return l[c]=f,new e(t,this.bitmap,l)}else{i.value=!0;let u=new qu(t,r,o,s),f=this.bitmap|a;if(this.canEdit(t))return this.children.splice(c,0,u),this.bitmap=f,this._size=void 0,this.children.length>yN?this.expand(t,f,this.children):this;let l=[...this.children];return l.splice(c,0,u),l.length>yN?this.expand(t,f,l):new e(t,f,l)}}remove(t,n,r,o,s){let i=xc(r,n);if((this.bitmap&i)===0)return this;let a=Ny(this.bitmap,i),c=this.children[a],u=c.remove(t,n+Ns,r,o,s);if(!s.value)return this;if(u===void 0){let l=this.bitmap^i;if(l===0)return;if(this.children.length===2){let m=this.children[a===0?1:0];if(m._tag==="LeafNode")return m}if(this.canEdit(t))return this.children.splice(a,1),this.bitmap=l,this._size=void 0,this;let p=[...this.children];return p.splice(a,1),new e(t,l,p)}if(c===u)return this;if(this.canEdit(t))return this.children[a]=u,this;let f=[...this.children];return f[a]=u,new e(t,this.bitmap,f)}expand(t,n,r){let o=new globalThis.Array(tm),s=0;for(let i=0;i<tm;i++)(n&1<<i)!==0&&(o[i]=r[s++]);return new nT(t,r.length,o)}iterator(){let t=0,n;return{next:()=>{for(;t<this.children.length;){n||(n=this.children[t].iterator());let r=n.next();if(!r.done)return r;n=void 0,t++}return{done:!0,value:void 0}}}}[Symbol.iterator](){return this.iterator()}},nT=class e extends ju{_tag="ArrayNode";edit;_size;count;children;constructor(t,n,r){super(),this.edit=t,this.count=n,this.children=r}get size(){return this._size===void 0&&(this._size=this.children.reduce((t,n)=>t+(n?.size??0),0)),this._size}get(t,n,r){let o=em(n,t),s=this.children[o];return s?s.get(t+Ns,n,r):D()}has(t,n,r){let o=em(n,t),s=this.children[o];return s?s.has(t+Ns,n,r):!1}set(t,n,r,o,s,i){let a=em(r,n),c=this.children[a];if(c){let u=c.set(t,n+Ns,r,o,s,i);if(c===u)return this;if(this.canEdit(t))return this.children[a]=u,this;let f=[...this.children];return f[a]=u,new e(t,this.count,f)}else{i.value=!0;let u=new qu(t,r,o,s);if(this.canEdit(t))return this.children[a]=u,this.count++,this._size=void 0,this;let f=[...this.children];return f[a]=u,new e(t,this.count+1,f)}}remove(t,n,r,o,s){let i=em(r,n),a=this.children[i];if(!a)return this;let c=a.remove(t,n+Ns,r,o,s);if(!s.value)return this;let u=this.count-(c?0:1);if(u<DJ)return this.pack(t,i,c);if(a===c)return this;if(this.canEdit(t))return this.children[i]=c,c||(this.count=u),this._size=void 0,this;let f=[...this.children];return f[i]=c,new e(t,u,f)}pack(t,n,r){let o=[],s=0,i=1;for(let a=0;a<this.children.length;a++){let c=a===n?r:this.children[a];c&&(o.push(c),s|=i),i<<=1}return new $u(t,s,o)}iterator(){let t=0,n;return{next:()=>{for(;t<this.children.length;){let r=this.children[t];if(!r){t++;continue}n||(n=r.iterator());let o=n.next();if(!o.done)return o;n=void 0,t++}return{done:!0,value:void 0}}}}[Symbol.iterator](){return this.iterator()}},nm=class{[Ly]=Ly;_editable;_edit;_root;_size;constructor(t,n,r,o){this._editable=t,this._edit=n,this._root=r,this._size=o}get size(){return this._size}[Symbol.iterator](){return this._root.iterator()}[_e](t){if(rT(t)){let n=t;if(this.size!==n.size)return!1;for(let[r,o]of this){let s=lf(t,wN(r));if(xe(s)||!ae(o,s.value))return!1}return!0}return!1}[Oe](){let t=it("HashMap");for(let[n,r]of this)t=t^ce(n)+ce(r);return t}[at](){return hn(this)}toString(){return`HashMap(${X(Array.from(this))})`}toJSON(){return{_id:"HashMap",values:Array.from(this).map(([t,n])=>[hn(t),hn(n)])}}pipe(){return ie(this,arguments)}},bN=new eT,rT=e=>j(e,Ly),oT=()=>new nm(!1,0,bN,0);var EN=e=>{let t=bN,n=0,r={value:!1};for(let[o,s]of e){let i=ce(o);r.value=!1,t=t.set(NaN,0,i,o,s,r),r.value&&n++}return new nm(!1,0,t,n)};var wN=d(2,(e,t)=>e._root.get(0,ce(t),t));var sT=d(2,(e,t)=>e._root.has(0,ce(t),t));var BJ=(e,t,n,r)=>{let o=e,s={value:!1},i=o._editable?o._edit:NaN,a=o._root.set(i,0,n,t,r,s);return o._editable?(o._root=a,s.value&&o._size++,e):o._root===a?e:new nm(!1,o._edit,a,o._size+(s.value?1:0))},iT=d(3,(e,t,n)=>BJ(e,t,ce(t),n)),aT=e=>{let t=e[Symbol.iterator]();return{[Symbol.iterator](){return this},next(){let n=t.next();return n.done?{done:!0,value:void 0}:{done:!1,value:n.value[0]}}}};var IN=e=>{let t=e[Symbol.iterator]();return{[Symbol.iterator](){return this},next(){return t.next()}}},By=e=>e.size;var jy=rT;var qy=EN;var $J=IN,$y=e=>Array.from($J(e)),TN=By;var rm="~effect/collections/HashSet",zJ={[Oe](){return ce(rm)},[_e](e){return uT(e)&&zy(this)===zy(e)&&AN(this,t=>CN(e,t))},[Symbol.iterator](){return aT(fT(this))},toString(){return`HashSet(${X(Array.from(this))})`},toJSON(){return{_id:"HashSet",values:hn(Array.from(this))}},[at](){return this.toJSON()},pipe(){return ie(this,arguments)}},HJ=e=>{let t=Object.create(zJ);return t[rm]=rm,t.keyMap=e,t},uT=e=>j(e,rm),fT=e=>e.keyMap;var kN=e=>{let t=oT();for(let n of e)t=iT(t,n,!0);return HJ(t)},CN=(e,t)=>sT(fT(e),t);var zy=e=>By(fT(e));var AN=(e,t)=>{for(let n of e)if(!t(n))return!1;return!0};var Hy=kN,Wy=uT;var RN=zy;function Ky(e){let t=qN(Jy,yn(e.ast));return(n,r)=>t(n,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function Vy(e){let t=Ky(e);return(n,r)=>{let o=ac(t(n,r));return Ft(o)?L(o.value):(da(o.cause,"Option adapter can only return none for schema issues"),D())}}function _N(e){let t=Ky(e);return(n,r)=>{let o=ac(t(n,r));if(Ft(o))return o.value;let s=da(o.cause,"Constructor adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:s})}}function MN(e){return sm(e.ast)}function sm(e){let t=zu(im(yn(e)));return n=>{let r=t(n,Xr);return Ft(r)?!0:(da(r.cause,"Type guard adapter can only return false for schema issues"),!1)}}function PN(e){let t=im(e);return(n,r)=>{let o=ac(t(n,r));if(!Ft(o))return da(o.cause,"Issue adapter can only return schema issues")}}function FN(e,t){let r=zu(im(yn(e.ast)))(t,Xr);if(ii(r)){let o=da(r.cause,"Assertion adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:o})}}function dt(e,t){let n=im(e.ast);return t===void 0?n:(r,o)=>n(r,om(t,o))}var dT=dt;function UN(e,t){return zu(dt(e,t))}function pT(e,t){return $N(dt(e,t))}var DN=pT;function NN(e,t){return zN(dt(e,t))}function KJ(e,t){return HN(dt(e,t))}var mT=KJ;function Pl(e,t){let n=im(ks(e.ast));return t===void 0?n:(r,o)=>n(r,om(t,o))}function LN(e,t){return zu(Pl(e,t))}function hT(e,t){return $N(Pl(e,t))}var BN=hT;function jN(e,t){return zN(Pl(e,t))}function VJ(e,t){return HN(Pl(e,t))}var gT=VJ,om=(e,t)=>t?{...e,...t}:e,ON=e=>e===ze?G(new ke):v(e);function im(e){return qN(WN,e)}function qN(e,t){let n;return(r,o)=>{let s=(n??=e(t))(r,o??Xr);return s===on?v(r):xt(s)?s[ye]===ze?ON(ze):s:Bn(s,ON)}}function zu(e){return(t,n)=>ac(e(t,n))}function $N(e){let t=zu(e);return(n,r)=>{let o=t(n,r);return Ft(o)?L(o.value):(da(o.cause,"Option adapter can only return none for schema issues"),D())}}function zN(e){let t=zu(e);return(n,r)=>{let o=t(n,r);return Ft(o)?Ce(o.value):Ae(da(o.cause,"Result adapter can only return schema issues"))}}function HN(e){let t=zu(e);return(n,r)=>{let o=t(n,r);if(Ft(o))return o.value;let s=da(o.cause,"Sync adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:s})}}var WN=wn(e=>xT(e,WN)),Jy=wn(e=>xT(e,Jy,KN)),JJ=wn(e=>xT(e,Jy,KN,e.context?.constructorDefault));function KN(e){return e.context?.constructorDefault?JJ(e):Jy(e)}function VN(e,t,n,r){let o;if(xt(e)&&e._tag==="Success"){let s=Ex(e===on?t:e[ye]);o=n._tag==="Transformation"?n.decode.run(s,r):n.decode(zo(s),r)}else n._tag==="Transformation"?o=Bn(e,s=>n.decode.run(Ex(s),r)):o=n.decode(fa(e,Ex),r);return xt(o)&&o._tag==="Success"?tI(o[ye]):Bn(o,tI)}function GJ(e,t){let n;return(r,o)=>{if(r===ze)return vs;if(e.isConstructed(r))return on;let s=(n??=t(e.link.to))(r,o);return VN(s,r,e.link.transformation,o)}}function xT(e,t,n,r){let o=n?P1(e):void 0,s=o?GJ(o,t):e.getParser(t,n),i=e.checks,a=r?e.encoding?[...e.encoding,r]:[r]:e.encoding,c=e.encodingChecks,u=(i?i[i.length-1].annotations:e.annotations)?.parseOptions;if(!a&&!i&&!c)return u?(p,m)=>s(p,om(m,u)):s;let f,l=(p,m)=>{let h=s(p,m);if(c&&!m.disableChecks)if(xt(h)){if(h._tag==="Success"){let g=h===on?p:h[ye];if(p!==ze&&g!==ze){let x=Rs(c,p,void 0,e,m);x&&(h=G(new At(e,x,p,m)))}}}else h=R(h,g=>{if(p!==ze&&g!==ze){let x=Rs(c,p,void 0,e,m);if(x)return G(new At(e,x,p,m))}return v(g)});if(i&&!m.disableChecks)if(xt(h)){if(h._tag==="Success"){let g=h===on?p:h[ye];if(g===ze)return h;let x=Rs(i,g,void 0,e,m);x&&(h=G(new At(e,x,g,m)))}}else h=R(h,g=>{if(g!==ze){let x=Rs(i,g,void 0,e,m);if(x)return G(new At(e,x,g,m))}return v(g)});return h};return a?(p,m)=>{u&&(m=om(m,u));let h=f??=a.map(E=>t(E.to)),g=p,x=h[h.length-1](p,m);for(let E=a.length-1;E>=0;E--)if(x=VN(x,g,a[E].transformation,m),E!==0){let b=h[E-1];x._tag==="Success"?(g=x[ye],x=b(g,m)):x=Bn(x,y=>{let w=b(y,m);return w===on?zo(y):w})}if(x._tag==="Success"){let E=x[ye],b=l(E,m);return b===on?x:b}return x=ft(x,E=>ia(()=>ec(E,b=>new Tx(e,b,p,m)))),Bn(x,E=>{let b=l(E,m);return b===on?zo(E):b})}:u?(p,m)=>l(p,om(m,u)):l}var Gy="~effect/Schema/Schema";function _r(e,t,n){return{id:e,payloadSchema:t,revive:n}}function Re(e,t,n){return{id:e,payloadSchema:t,revive:n}}var ZJ={[Gy]:Gy,pipe(){return ie(this,arguments)},annotate(e){return this.rebuild(Ho(this.ast,e))},annotateKey(e){return this.rebuild(bl(this.ast,e))},check(...e){return this.rebuild(Si(this.ast,e))}};function am(e,t){function n(){}let r=Object.defineProperties(Object.setPrototypeOf(n,ZJ),Object.getOwnPropertyDescriptors({...t}));return r.ast=e,r.rebuild=o=>am(o,t),r.makeEffect=Ky(r),r.make=_N(r),r.makeOption=Vy(r),r}var JN=d(2,(e,t)=>ST(e,(n,r)=>t.includes(n)?[n,r]:void 0)),GN=d(2,(e,t)=>ST(e,(n,r)=>t.includes(n)?void 0:[n,r])),ZN=d(2,(e,t)=>({...e,...t}));var yT=d(2,(e,t)=>ST(e,(n,r)=>[Object.hasOwn(t,n)?t[n]:n,r]));var dr=e=>e;function ST(e,t){let n={};for(let r of Reflect.ownKeys(e)){if(!Object.prototype.propertyIsEnumerable.call(e,r))continue;let o=t(r,e[r]);if(o){let[s,i]=o;W(n,s,i)}}return n}function QN(e,t){let n=t?.omitKeyWhen??(()=>!1);return Rh((r,o)=>{let s=Reflect.ownKeys(e),i={};for(let a of s){let c=e[a].combine(r[a],o[a]);n(c)||W(i,a,c)}return i})}function cm(e){return vo((t,n)=>t===void 0?n:n===void 0?t:e.combine(t,n),void 0)}function vi(e,t){return t.length>0&&(e+=`
|
|
30
|
+
at ${Oh(t)}`),new Error(e)}var XN=new WeakMap,e2=new WeakMap,t2=[];function Ta(e){return new Error(`Unable to derive an arbitrary for ${e}`)}var n2=([e],[t])=>ae(e,t);function YJ(e,t,n){return t.reduce((r,o)=>r.filter(s=>o.run(s,e,Xr)===void 0),n)}function d2(e,t){if(e?.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength)throw Ta(`${t} constraints`)}function p2(e){return e===void 0||e.minLength===void 0&&e.maxLength===void 0?void 0:{...e.minLength!==void 0?{minLength:e.minLength}:{},...e.maxLength!==void 0?{maxLength:e.maxLength}:{}}}function bT(e,t,n,r){return r?e.uniqueArray(t,{...n,comparator:r}):e.array(t,n)}function r2(e,t,n,r=!1){let o=t.constraint,s=p2(o);return d2(s,"array"),bT(e,n,r?{...s,maxLength:s?.minLength??0}:s,o?.unique?ae:void 0)}function Qy(e,t,n,r){return t.chain(o=>o.length<n?e.constant(o):r.map(s=>[...o,...s]))}function o2(e,t){return e.chain(n=>t.map(r=>({...Object.fromEntries(r),...n})))}var XJ=cm(rF),eG=cm(oF),Yy=cm($R),tG=cm(OR()),nG=QN({integer:Yy,maxLength:eG,minLength:XJ,noInfinity:Yy,noNaN:Yy,patterns:tG,unique:Yy},{omitKeyWhen:LA});function s2(e,t,n,r,o,s){if(r===void 0||t===void 0)return r===void 0?[t,n]:[r,o];let i=e(t,r);return i===s?[r,o]:i===0?[t,n||o]:[t,n]}function rG(e,t){if(e===void 0)return t;if(e.order!==t.order)throw new Error("Cannot merge ordered arbitrary constraints with different Order instances");let[n,r]=s2(e.order,e.minimum,e.exclusiveMinimum,t.minimum,t.exclusiveMinimum,-1),[o,s]=s2(e.order,e.maximum,e.exclusiveMaximum,t.maximum,t.exclusiveMaximum,1);return{order:e.order,...n!==void 0?{minimum:n}:{},...r!==void 0?{exclusiveMinimum:r}:{},...o!==void 0?{maximum:o}:{},...s!==void 0?{exclusiveMaximum:s}:{}}}function oG(e,t){let{ordered:n,...r}=e??{},{ordered:o,...s}=t,i=o===void 0?n:rG(n,o);return{...nG.combine(r,s),...i===void 0?{}:{ordered:i}}}function i2(e){let t=[],n=[];function r(o){if(o.annotations?.arbitrary&&n.push(o.annotations.arbitrary),o._tag!=="Filter")for(let s of o.checks)r(s);else t.push(o)}return e?.forEach(r),{filters:t,arbitraries:n}}function sG(e){let t=e.map(({constraint:n})=>n).filter(Kn);return n=>{let r=t.reduce((o,s)=>oG(o,s),n.constraint);return{...n,constraint:r}}}function um(e){return{...e,constraint:void 0}}function a2(e,t,n){if(t===void 0||t.minLength===void 0&&t.maxLength===void 0)return;if(t.minLength!==void 0&&e.indexSignatures.length===0&&t.minLength>e.propertySignatures.length)throw Ta("object property constraints");let r={};if(t.minLength!==void 0&&(r.minLength=Math.max(0,t.minLength-n)),t.maxLength!==void 0&&(r.maxLength=t.maxLength-n,r.maxLength<0))throw Ta("object property constraints");return d2(r,"object property"),r}function iG(e,t,n,r,o,s){let i=r.length;if(s.maxLength!==void 0&&s.maxLength<i)throw Ta("object property constraints");let a=s.minLength===void 0?0:Math.max(0,s.minLength-i),c=s.maxLength===void 0?o.length:Math.min(o.length,s.maxLength-i);if(a>c)throw Ta("object property constraints");let u=e.record(t,{requiredKeys:[...r,...o]}),f=e.shuffledSubarray([...o],{minLength:a,maxLength:c});return e.tuple(u,f).map(([l,p])=>{let m=new Set([...r,...p]),h={};for(let g of n)m.has(g)&&W(h,g,l[g]);return h})}function m2(e,t,n,r){let o={};if(e?.minimum!==void 0&&(o.min=t(e.minimum,e.exclusiveMinimum===!0)),e?.maximum!==void 0&&(o.max=n(e.maximum,e.exclusiveMaximum===!0)),o.min!==void 0&&o.max!==void 0&&o.min>o.max)throw Ta(r);return o}function aG(e){return m2(e,(t,n)=>n?Math.floor(t)+1:Math.ceil(t),(t,n)=>n?Math.ceil(t)-1:Math.floor(t),"integer constraints")}function cG(e,t){let n={...e?.noInfinity?{noDefaultInfinity:!0}:{},...e?.noNaN?{noNaN:!0}:{},...t?.minimum!==void 0?{min:t.minimum}:{},...t?.exclusiveMinimum!==void 0?{minExcluded:t.exclusiveMinimum}:{},...t?.maximum!==void 0?{max:t.maximum}:{},...t?.exclusiveMaximum!==void 0?{maxExcluded:t.exclusiveMaximum}:{}};if(n.min!==void 0&&n.max!==void 0&&(n.min>n.max||n.min===n.max&&(n.minExcluded||n.maxExcluded)))throw Ta("number constraints");return n}function uG(e){return m2(e,(t,n)=>n?t+BigInt(1):t,(t,n)=>n?t-BigInt(1):t,"the ordered bigint constraints")}function Ul(e,t){let n=(r,o,s=t2)=>e(r,o,s);return n.terminal=(r,o,s=t2)=>t(r,o,s),n}function Vo(e){return Ul(e,e)}function c2(e,t){let n=e2.get(t)??e.createDepthIdentifier();return e2.set(t,n),{maxDepth:2,depthIdentifier:n}}function u2(e,t){return t.length===0?void 0:t.length===1?t[0]:e.oneof(...t)}var fG={noInfinity:!0,noNaN:!0};function lG(e){return{...e,constraint:fG}}function dG(e,t,n,r){let o=r===void 0?[]:[{arbitrary:r,weight:1}];for(let{candidate:s}of n){if(!s)continue;let i=s.make(e,t);if(i===void 0)continue;let a=s.weight??1;if(!globalThis.Number.isInteger(a)||a<=0)throw Ta("a candidate with an invalid weight");o.push({arbitrary:i,weight:a})}return o.length===0?void 0:o.length===1?o[0].arbitrary:e.oneof(...o)}function f2(e,t,n,r,o){let s=dG(n,r,t.arbitraries,o);return s===void 0?void 0:YJ(e,t.filters,s)}function pG(e,t){if(!(typeof e=="object"&&e!==null&&"arbitrary"in e))return{arbitrary:e,terminal:t?void 0:e};let n="terminal"in e?e.terminal:t?void 0:e.arbitrary;return{arbitrary:e.arbitrary,terminal:n}}function mG(e,t,n,r,o){return e.map(s=>({arbitrary:o?t.constant(null).chain(()=>s(t,n,r)):s(t,n,r),terminal:s.terminal(t,n,r)}))}function l2(e,t,n,r){let o=sG(t.arbitraries);return Ul((s,i,a)=>{let c=o(i);return f2(e,t,s,c,n(s,i,c,a))},(s,i,a)=>{let c=o(i);return f2(e,t,s,c,r(s,i,c,a))})}var h2=wn(e=>Jo(e,[]));function Jo(e,t){let n=gi(e)?.toArbitrary;if(n){let r=pc(e)?e.typeParameters.map(i=>Jo(i,t)):[],o=i2(e.checks),s=i=>(a,c,u,f)=>pG(n(mG(r,a,um(c),f,i))(a,u),r.length>0)[i?"terminal":"arbitrary"];return l2(e,o,s(!1),s(!0))}if(e.checks){let r=i2(e.checks),o=Jo(Yx(e,void 0),t);return l2(e,r,(s,i,a,c)=>o(s,a,c),(s,i,a,c)=>o.terminal(s,a,c))}return hG(e,t)}function hG(e,t){switch(e._tag){case"Never":case"Declaration":throw vi(`Unsupported AST ${e._tag}`,t);case"Null":return Vo(n=>n.constant(null));case"Void":case"Undefined":return Vo(n=>n.constant(void 0));case"Unknown":case"Any":return Vo(n=>n.anything());case"String":return Vo((n,r)=>{let o=r.constraint,s=o?.patterns;return s?n.oneof(...s.map(i=>n.stringMatching(new RegExp(i)))):n.string(p2(o))});case"Number":return Vo((n,r)=>{let o=r.constraint,s=o?.ordered?.order===fo?o.ordered:void 0;return o?.integer?n.integer(aG(s)):n.float(cG(o,s))});case"Boolean":return Vo(n=>n.boolean());case"BigInt":return Vo((n,r)=>{let o=r.constraint?.ordered?.order===Ro?r.constraint.ordered:void 0;return n.bigInt(uG(o))});case"Symbol":return Vo(n=>n.string().map(Symbol.for));case"Literal":return Vo(n=>n.constant(e.literal));case"UniqueSymbol":return Vo(n=>n.constant(e.symbol));case"ObjectKeyword":return Vo(n=>n.oneof(n.object(),n.array(n.anything())));case"Enum":return Jo(Np(e),t);case"TemplateLiteral":{let n=e.parts.map((r,o)=>Jo(jn(r),[...t,o]));return Vo((r,o,s)=>r.tuple(...n.map(i=>i(r,lG(o),s))).map(i=>i.map(a=>globalThis.String(a)).join("")))}case"Arrays":{let n=e.elements.map((i,a)=>({ast:i,arbitrary:Jo(i,[...t,a])})),r=e.elements.length,o=e.rest.map((i,a)=>({ast:i,arbitrary:Jo(i,[...t,r+a])})),s=(i,a,c)=>{let u=um(a),f=[],l=[],p=0;for(let b of n){let y=b.arbitrary.terminal(i,u,c);if(an(b.ast)){l.push(y);continue}if(y===void 0)return;p++,f.push(y.map(L))}let m=a.constraint?.minLength??0,g=Ye(o)&&m>p+l.length?l.length:Math.max(0,m-p),x=0;for(let b of l){if(x>=g||b===void 0){f.push(i.constant(D()));continue}x++,p++,f.push(b.map(L))}if(x<g)return;let E=i.tuple(...f).map(xE);if(Ye(o)){let[b,...y]=o,w=e.elements.length===0?a:u,S=Math.max(0,m-p-y.length),C=S===0?void 0:b.arbitrary.terminal(i,u,c);if(S>0&&C===void 0)return;let M=S===0?i.constant([]):r2(i,{...w,constraint:{...w.constraint,minLength:S}},C,!0);if(E=Qy(i,E,r,M),y.length>0){let _=[];for(let $ of y){let F=$.arbitrary.terminal(i,u,c);if(F===void 0)return;_.push(F)}let P=i.tuple(..._);E=Qy(i,E,r,P)}}return E};return Ul((i,a,c)=>{let u=um(a),f=n.map(({ast:p,arbitrary:m})=>{let h=m(i,u,c);return an(p)?h.chain(g=>i.boolean().map(x=>x?L(g):D())):h.map(L)}),l=i.tuple(...f).map(p=>xE(AR(p,Te)));if(Ye(o)){let[p,...m]=o.map(({arbitrary:g})=>g(i,u,c)),h=r2(i,e.elements.length===0?a:u,p);if(l=Qy(i,l,r,h),m.length>0){let g=i.tuple(...m);l=Qy(i,l,r,g)}}if(a.recursion){let p=s(i,a,c);if(p!==void 0)return i.oneof(a.recursion,p,l)}return l},s)}case"Objects":{let n=e.propertySignatures.map(s=>({ps:s,arbitrary:Jo(s.type,[...t,s.name])})),r=e.indexSignatures.map(s=>({is:s,parameter:Jo(s.parameter,t),type:Jo(s.type,t)}));return Ul((s,i,a)=>{let c=um(i),u={},f=[],l=[],p=[];for(let{ps:x,arbitrary:E}of n){let b=x.name;f.push(b),an(x.type)?p.push(b):l.push(b),W(u,b,E(s,c,a))}let m=i.constraint;if(p.length>0&&r.length===0&&m!==void 0&&(m.minLength!==void 0||m.maxLength!==void 0))return iG(s,u,f,l,p,m);let h=s.record(u,{requiredKeys:l}),g=a2(e,i.constraint,l.length);for(let{parameter:x,type:E}of r){let b=s.tuple(x(s,c,a),E(s,c,a)),y=bT(s,b,g,n2);h=o2(h,y)}return h},(s,i,a)=>{let c=um(i),u={},f=[],l=[];for(let{ps:x,arbitrary:E}of n){let b=x.name,y=E.terminal(s,c,a);if(an(x.type)){y!==void 0&&l.push([b,y]);continue}if(y===void 0)return;f.push(b),W(u,b,y)}let p=Math.max(0,(i.constraint?.minLength??0)-f.length);for(let[x,E]of l){if(p===0)break;p--,f.push(x),W(u,x,E)}if(p>0&&e.indexSignatures.length===0)return;let m=s.record(u,{requiredKeys:f}),h=a2(e,i.constraint,f.length),g=h?.minLength??0;for(let{parameter:x,type:E}of r){let b;if(g===0)b=s.constant([]);else{let y=x.terminal(s,c,a),w=E.terminal(s,c,a);if(y===void 0||w===void 0)return;b=bT(s,s.tuple(y,w),{...h,maxLength:g},n2)}m=o2(m,b)}return m})}case"Union":{let n=e.types.map(o=>Jo(o,t)),r=(o,s,i)=>u2(o,n.map(a=>a.terminal(o,s,i)).filter(Kn));return Ul((o,s,i)=>{let a=n.map(u=>u(o,s,i));if(s.recursion){let u=r(o,s,i);if(u!==void 0)return o.oneof(s.recursion,u,...a)}let c=u2(o,a);if(c===void 0)throw Ta("a union with no members");return c},r)}case"Suspend":{let n=XN.get(e);if(n)return n;let r=_u(()=>Jo(e.thunk(),t)),o=Ul((s,i,a)=>{let c=c2(s,e),u={...i,recursion:c},f=a.includes(e)?a:[...a,e],l=r().terminal(s,u,f);if(l===void 0)throw vi("Unable to derive an arbitrary for a recursive schema without a finite generation path",t);return s.oneof(c,l,s.constant(null).chain(()=>r()(s,u,f)))},(s,i,a)=>{if(a.includes(e))return;let c=c2(s,e);return r().terminal(s,{...i,recursion:c},[...a,e])});return XN.set(e,o),o}}}var g2=wn(e=>yc(e,[]));function yc(e,t){let n=gi(e)?.toEquivalence;if(n)return n(pc(e)?e.typeParameters.map(r=>yc(r,t)):[]);switch(e._tag){case"Never":return Hc();case"Declaration":case"Null":case"Undefined":case"Void":case"Unknown":case"Any":case"String":case"Number":case"Boolean":case"BigInt":case"Symbol":case"Literal":case"UniqueSymbol":case"ObjectKeyword":case"Enum":case"TemplateLiteral":return ae;case"Arrays":{let r=e.elements.map((i,a)=>yc(i,[...t,a])),o=e.elements.length,s=e.rest.map((i,a)=>yc(i,[...t,o+a]));return un((i,a)=>{if(!Array.isArray(i)||!Array.isArray(a))return!1;let c=i.length;if(c!==a.length)return!1;let u=0;for(;u<Math.min(c,e.elements.length);u++)if(!r[u](i[u],a[u]))return!1;if(s.length>0){let[f,...l]=s;for(;u<c-l.length;u++)if(!f(i[u],a[u]))return!1;for(let p=0;p<l.length;p++)if(!l[p](i[u+p],a[u+p]))return!1}return!0})}case"Objects":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return ae;let r=e.propertySignatures.map(s=>yc(s.type,[...t,s.name])),o=e.indexSignatures.map(s=>yc(s.type,t));return un((s,i)=>{if(!en(s)||!en(i))return!1;for(let a=0;a<r.length;a++){let c=e.propertySignatures[a],u=c.name,f=Object.hasOwn(s,u),l=Object.hasOwn(i,u);if(an(c.type)&&f!==l||f&&l&&!r[a](s[u],i[u]))return!1}for(let a=0;a<o.length;a++){let c=e.indexSignatures[a],u=ha(s,c.parameter),f=ha(i,c.parameter);if(u.length!==f.length)return!1;for(let l=0;l<u.length;l++){let p=u[l];if(!Object.hasOwn(i,p)||!o[a](s[p],i[p]))return!1}}return!0})}case"Union":{let r=yn(e).types,o=new Map(r.map((s,i)=>[s,[sm(s),yc(e.types[i],t)]]));return un((s,i)=>{let a=Mp(s,r);for(let c=0;c<a.length;c++){let[u,f]=o.get(a[c]);if(u(s)&&u(i))return f(s,i)}return!1})}case"Suspend":{let r=_u(()=>yc(e.thunk(),t));return un((o,s)=>r()(o,s))}}}function Hu(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Dl(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}var SG="http://json-schema.org/draft-07/schema#",x2="https://json-schema.org/draft/2020-12/schema";function y2(e,t){return e===t||e===(t.endsWith("#")?t.slice(0,-1):`${t}#`)}function E2(e){return{dialect:"draft-07",...kG(e,DG)}}function bG(e,t){return n(e,!1,!0);function n(r,o,s=!1){if(!en(r))return r;let i=o||!s&&v2(r.$id),a={};for(let c of Object.keys(r)){let u=r[c],f=u;switch(c){case"$defs":case"properties":case"patternProperties":case"dependentSchemas":f=wT(u,l=>n(l,i))??u;break;case"allOf":case"anyOf":case"oneOf":case"prefixItems":f=Array.isArray(u)?u.map(l=>n(l,i)):u;break;case"not":case"additionalProperties":case"propertyNames":case"unevaluatedProperties":case"items":case"contains":case"unevaluatedItems":case"if":case"then":case"else":case"contentSchema":f=n(u,i)}W(a,c,f)}return t(a,i),a}}function w2(e,t){return bG(e,n=>{EG(n,t)})}function EG(e,t){typeof e.$ref=="string"&&W(e,"$ref",t(e.$ref,"$ref")),typeof e.$dynamicRef=="string"&&W(e,"$dynamicRef",t(e.$dynamicRef,"$dynamicRef"))}function wT(e,t){if(!en(e))return;let n={};for(let r of Object.keys(e))W(n,r,t(e[r],r));return n}function wG(e,t,n){let r=new Map,o=[],s=ET;function i(p,m=[],h=[]){if(m.length===0&&t?.trackIds){let g=en(p)?f(p):void 0;s=S2(g,ET)??ET}return u(p,m,h,{sourceRoot:[],targetRoot:[],uri:s})}function a(){for(let[p,m,h]of o){let g=m,x=I2(m,h);if(x!==void 0){let E=IG(x.hash);if(x.hash="",E!==void 0){let b=r.get(b2(x.href,E));b!==void 0&&(g=vG(m,b))}}W(p,"$ref",g)}}let c=n(i);return a(),c;function u(p,m,h,g){if(typeof p=="boolean")return l(m,h,g),t?.booleanAdapter?.(p)??p;if(!en(p))return p;let x=g,E=f(p);if(m.length>0&&t?.trackIds&&v2(E)){let w=S2(E,g.uri);w!==void 0&&(x={parent:g,sourceRoot:m,targetRoot:h,uri:w})}l(m,h,x);let b=x.uri,y={isDocumentRoot:m.length===0,schema(w,S,C=S){return u(w,[...m,S],[...h,C],x)},schemaAt(w,S,C){return u(w,[...m,...S],[...h,...C],x)},schemaArray(w,S,C=S){return Array.isArray(w)?w.map((M,_)=>u(M,[...m,S,String(_)],[...h,C,String(_)],x)):w},schemaMap(w,S,C=S){return en(w)?wT(w,(M,_)=>u(M,[...m,S,_],[...h,C,_],x)):w},reference(w,S){typeof S=="string"?o.push([w,S,b]):W(w,"$ref",S)}};return e(p,y)}function f(p){return t?.ignoreRefSiblings===!0&&typeof p.$ref=="string"?void 0:p.$id}function l(p,m,h){h.parent!==void 0&&l(p,m,h.parent),r.set(b2(h.uri,p.slice(h.sourceRoot.length)),m.slice(h.targetRoot.length))}}var ET="https://effect.invalid/.json-schema/";function I2(e,t){return URL.canParse(e,t)?new URL(e,t):void 0}function S2(e,t){if(typeof e!="string")return;let n=I2(e,t);if(n!==void 0)return n.hash="",n.href}function IG(e){if(e.length===0)return[];let t;try{t=decodeURIComponent(e.slice(1))}catch{return}if(t.startsWith("/"))return/~(?:[^01]|$)/.test(t)?void 0:t.slice(1).split("/").map(Dl)}function vG(e,t){let n=e.indexOf("#");return n===-1&&t.length===0?e:`${n===-1?e:e.slice(0,n)}${TG(t)}`}function TG(e){return e.length===0?"#":`#/${e.map(t=>encodeURI(Hu(t)).replace(/#/g,"%23")).join("/")}`}function b2(e,t){return`${e}\0${JSON.stringify(t)}`}function v2(e){return typeof e=="string"&&e.length>0&&e[0]!=="#"}function kG(e,t,n){return wG(t,{...n,trackIds:!0},r=>({schema:r(e.schema),definitions:wT(e.definitions,(o,s)=>r(o,["$defs",s],["definitions",s]))}))}var CG=new Set(["properties","patternProperties"]),AG=new Set(["allOf","anyOf","oneOf"]),RG=new Set(["not","additionalProperties","propertyNames","contains","if","then","else","contentSchema"]);function OG(e,t,n,r,o,s=CG){let i;if(s.has(t))i=r.schemaMap(n,t);else if(AG.has(t))i=r.schemaArray(n,t);else if(o.has(t))i=r.schema(n,t);else return!1;return W(e,t,i),!0}var T2=["$anchor","$defs","$dynamicAnchor","$dynamicRef","$vocabulary","contentSchema","dependentRequired","dependentSchemas","maxContains","minContains","prefixItems","unevaluatedItems","unevaluatedProperties"],Afe=[...T2,"deprecated"],Rfe=[...T2,"$comment","$id","$schema","const","contains","contentEncoding","contentMediaType","else","examples","if","patternProperties","propertyNames","then"],_G=/^[A-Za-z_][-A-Za-z0-9._]*$/,MG=/^[A-Za-z][-A-Za-z0-9._:]*$/;function Wu(e,t,n){throw new Error(`Cannot convert JSON Schema keyword "${e}" to ${t}: ${n}`)}function PG(e,t,n,r){for(let o of t)Object.hasOwn(e,o)&&Wu(o,n,`it is not active in ${r} but would become active in the target`)}var FG=["additionalItems","definitions","dependencies"];function UG(e,t,n,r,o){n.isDocumentRoot?W(e,"$schema",y2(t,x2)?r:t):y2(t,x2)||Wu("$schema",o,"an embedded resource cannot declare a different dialect")}function DG(e,t){PG(e,FG,"Draft-07","Draft 2020-12");let n={},r,o,s;for(let i of Object.keys(e)){let a=e[i];if(!OG(n,i,a,t,RG))switch(i){case"$ref":r=a;break;case"$schema":UG(n,a,t,SG,"Draft-07");break;case"$id":case"$anchor":break;case"$defs":W(n,"definitions",t.schemaMap(a,i,"definitions"));break;case"prefixItems":o=a;break;case"items":s=a;break;case"dependentRequired":case"dependentSchemas":case"minContains":case"maxContains":break;case"$dynamicRef":case"$dynamicAnchor":case"$vocabulary":case"unevaluatedProperties":case"unevaluatedItems":Wu(i,"Draft-07","the target dialect has no equivalent");case"required":if(Array.isArray(a)&&a.length===0)break;W(n,i,a);break;default:W(n,i,a)}}if(NG(n,o,s,t),Object.hasOwn(e,"contains")){let i=e.minContains,a=e.maxContains;(i!==void 0&&i!==1||a!==void 0)&&Wu("minContains/maxContains","Draft-07","contains cardinality cannot be represented"),Object.hasOwn(e,"minContains")&&W(n,"minContains",i)}else Object.hasOwn(e,"minContains")&&W(n,"minContains",e.minContains),Object.hasOwn(e,"maxContains")&&W(n,"maxContains",e.maxContains);return BG(e,n,t,"draft-07"),qG(e,n,"$id","Draft-07"),LG(n,r,t),n}function NG(e,t,n,r){if(t===void 0){n!==void 0&&W(e,"items",r.schema(n,"items"));return}W(e,"items",r.schemaArray(t,"prefixItems","items")),n!==void 0&&W(e,"additionalItems",r.schema(n,"items","additionalItems"))}function LG(e,t,n){if(t!==void 0)if(typeof t=="string"&&Object.keys(e).length>0){let r={};n.reference(r,t),jG(e,r)}else n.reference(e,t)}function BG(e,t,n,r){let o=en(e.dependentRequired)?e.dependentRequired:void 0,s=en(e.dependentSchemas)?e.dependentSchemas:void 0;if(o===void 0&&s===void 0)return;let i={},a=new Set([...Object.keys(o??{}),...Object.keys(s??{})]);for(let c of a){let u=o?.[c],f=s?.[c],l=r==="draft-04"&&Array.isArray(u)&&u.length===0;f===void 0?l||W(i,c,u):u===void 0||l?W(i,c,n.schemaAt(f,["dependentSchemas",c],["dependencies",c])):W(i,c,{allOf:[n.schemaAt(f,["dependentSchemas",c],["dependencies",c,"allOf","0"]),{required:u}]})}Object.keys(i).length>0&&W(t,"dependencies",i)}function jG(e,t){Array.isArray(e.allOf)?e.allOf.push(t):W(e,"allOf",[t])}function qG(e,t,n,r){let o=e.$id,s=e.$anchor;if(s===void 0){o!==void 0&&W(t,n,o);return}(typeof s!="string"||!_G.test(s))&&Wu("$anchor",r,"the anchor is not valid"),MG.test(s)||Wu("$anchor",r,"the anchor cannot be represented as a plain-name fragment identifier"),o===void 0?W(t,n,`#${s}`):Wu("$anchor",r,"it cannot be combined with the schema $id")}var Ofe=globalThis.RegExp;var Nl=e=>e.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");var $G=new Set([...jF,Tu,...LF]);function fm(e,t){if(e===void 0)return;let n={},r=e.title;typeof r=="string"&&(n.title=r);let o=e.description,s=e.expected;typeof o=="string"?n.description=o:t?.generateDescriptions===!0&&typeof s=="string"&&(n.description=s);let i=e.default;wl(i)&&(n.default=i);let a=e.examples;Array.isArray(a)&&wl(a)&&(n.examples=a);let c=e.readOnly;typeof c=="boolean"&&(n.readOnly=c);let u=e.writeOnly;typeof u=="boolean"&&(n.writeOnly=u);let f=e.format;typeof f=="string"&&(n.format=f);let l=e.contentEncoding;typeof l=="string"&&(n.contentEncoding=l);let p=e.contentMediaType;typeof p=="string"&&(n.contentMediaType=p);let m=e.contentSchema;if(wl(m)&&(n.contentSchema=m),t?.includeAnnotationKey!==void 0)for(let[h,g]of Object.entries(e))$G.has(h)||!t.includeAnnotationKey(h)||wl(g)&&W(n,h,g);return Object.keys(n).length===0?void 0:n}function A2(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 r=[],o=!1;for(let s of n.allOf){let i=A2(s);i.type!==void 0&&(o=!0,(t===void 0||i.type==="integer")&&(t=i.type)),Object.keys(i.schema).length>0&&r.push(i.schema)}if(o){let{allOf:s,...i}=n;n=r.length===0?i:{...i,allOf:r}}}return{type:t,schema:n}}function zG(e){return Array.isArray(e.anyOf)&&e.anyOf.length===4&&e.anyOf[0]?.type==="number"&&e.anyOf.slice(1).every(t=>t.type==="string")}var R2="|type|format|pattern|multipleOf|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minProperties|maxProperties|propertyNames|";function vT(e,t){return Object.keys(e).every(n=>t.includes(`|${n}|`))}function C2(e,t){return typeof e.$ref!="string"&&t.every(n=>!Object.hasOwn(e,n))}var TT="|title|description|default|examples|readOnly|writeOnly|",HG=R2+TT;function lm(e,t,n){if(Object.keys(e).length===0)return t;let r=Object.keys(t);if(r.length===0)return e;let o=e.type==="number"||e.type==="integer"?e.type:void 0,s=zG(e);if(o!==void 0||s){let a=A2(t);if(a.type!==void 0){let c=o==="integer"||a.type==="integer"?"integer":"number",u={...e,type:c};s&&delete u.anyOf;let f=Object.keys(a.schema);return f.length===0?u:vT(a.schema,TT)&&C2(u,f)?{...u,...a.schema}:lm(u,a.schema,n)}}if(n&&C2(e,r))return{...e,...t};let i=Array.isArray(t.allOf)&&r.length===1?t.allOf:[t];return Array.isArray(e.allOf)?{...e,allOf:[...e.allOf,...i]}:typeof e.$ref=="string"?{allOf:[e,...i]}:{...e,allOf:i}}function WG(e,t,n,r){let o=new Map,s=new WeakMap,i=new Map,a=!1,c=Object.keys(n);for(let y of c)l(y,["references",y]);let u=as(e,(y,w)=>p(x(y,t[w]))),f={};for(let y of c){let w=o.get(y);typeof w!="string"&&W(f,y,p(w))}return{dialect:"draft-2020-12",schemas:u,definitions:f};function l(y,w){let S=o.get(y);if(S!==void 0)return typeof S=="string"?S:y;if(!Object.hasOwn(n,y))throw vi(`Invalid reference ${y}`,[...w,"$ref"]);o.set(y,null);let C=n[y],M=x(C,["references",y]),_=m(C);if(_!==void 0){let P=i.get(_),$=P?.find(F=>ae(o.get(F),M));if($===void 0)P===void 0?i.set(_,[y]):P.push(y);else return a=!0,o.set(y,$),$}return o.set(y,M),y}function p(y){return a?w2(y,w=>w.replace(/^#\/\$defs\/([^/]*)/,(S,C)=>{let M=o.get(Dl(C));return typeof M=="string"?`#/$defs/${Hu(M)}`:S})):y}function m(y){if(y._tag==="Reference")return;let w=y.checks.length===0?y.annotations:y.checks[y.checks.length-1].annotations;return typeof w?.identifier!="string"&&typeof w?.[Tu]=="string"?w[Tu]:void 0}function h(y,w){return y?.schemas?.map((S,C)=>x(S,[...w,"schemas",C]))??[]}function g(y,w,S){let C=y.annotations,M=C?.toJsonSchema;if(M!==void 0){let F=h(y.representation,[...S,"representation"]),te=M({type:w,schemas:F}),ee=fm(C,r),T=ee===void 0?te:{...te,...ee},z=ee===void 0?R2:HG;return y._tag==="Filter"&&vT(T,z)&&(ee===void 0||vT(ee,TT))?[T,!0]:[T]}if(y._tag==="Filter")return;let _=y.checks.map((F,te)=>g(F,w,[...S,"checks",te])).filter(F=>F!==void 0);if(_.length===0)return;let P=fm(C,r),$=_.map(([F])=>F);return[P===void 0?{allOf:$}:{allOf:$,...P}]}function x(y,w){if(y._tag==="Reference"){let _=l(y.$ref,w);return{$ref:`#/$defs/${Hu(_)}`}}let S=s.get(y);if(S!==void 0)return S;let C=E(y,w),M=fm(y.annotations,r);M!==void 0&&(C={...C,...M});for(let _=0;_<y.checks.length;_++){let P=typeof C.type=="string"&&KG(C.type)?C.type:void 0,$=g(y.checks[_],P,[...w,"checks",_]);$!==void 0&&(C=lm(C,...$))}return s.set(y,C),C}function E(y,w){switch(y._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":case"UniqueSymbol":return{type:"string",allOf:[{pattern:"^Symbol\\((.*)\\)$"}]};case"Declaration":return{};case"Suspend":return x(y.thunk,[...w,"thunk"]);case"Never":return{not:{}};case"String":return{type:"string"};case"Number":return{anyOf:[{type:"number"},{type:"string",enum:["NaN"]},{type:"string",enum:["Infinity"]},{type:"string",enum:["-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let S=y.literal;return typeof S=="bigint"?{type:"string",enum:[globalThis.String(S)]}:{type:typeof S,enum:[S]}}case"Enum":{let S=y.enums.map(([C,M])=>typeof M=="number"&&!globalThis.Number.isFinite(M)?{type:"string",enum:[globalThis.String(M)],title:C}:{type:typeof M,enum:[M],title:C});return S.length===0?{not:{}}:{anyOf:S}}case"TemplateLiteral":return{type:"string",pattern:`^${y.parts.map(Xy).join("")}$`};case"Arrays":{if(y.rest.length>1)throw vi("Invalid schema representation document",[...w,"rest"]);let S={type:"array"},C=y.elements.length,M=y.elements.map((_,P)=>{_.isOptional&&C--;let $=x(_.type,[...w,"elements",P,"type"]),F=fm(_.annotations,r);return F===void 0?$:lm($,F)});if(M.length>0?(S.prefixItems=M,S.maxItems=y.elements.length,C>0&&(S.minItems=C)):S.items=!1,y.rest.length===1){delete S.maxItems;let _=x(y.rest[0],[...w,"rest",0]);Object.keys(_).length>0?S.items=_:delete S.items}return S}case"Objects":{if(y.propertySignatures.length===0&&y.indexSignatures.length===0)return{anyOf:[{type:"object"},{type:"array"}]};let S={type:"object"},C={},M=[];for(let F=0;F<y.propertySignatures.length;F++){let te=y.propertySignatures[F];if(typeof te.name!="string")throw vi("Invalid schema representation document",[...w,"propertySignatures",F,"name"]);let ee=te.name,T=x(te.type,[...w,"propertySignatures",F,"type"]),z=fm(te.annotations,r);W(C,ee,z===void 0?T:lm(T,z)),te.isOptional||M.push(ee)}y.propertySignatures.length>0&&(S.properties=C),M.length>0&&(S.required=M);let _={},P=[];for(let F=0;F<y.indexSignatures.length;F++){let te=y.indexSignatures[F],ee=x(te.type,[...w,"indexSignatures",F,"type"]);Object.keys(ee).length===1&&"not"in ee&&(ee=!1);let T=b(te.parameter,[...w,"indexSignatures",F,"parameter"],new Set);if(T.length===0)P.push(ee);else for(let z of T){let U=_[z];W(_,z,U===void 0?ee:U===!1||ee===!1?!1:lm(U,ee))}}let $=Object.keys(_).length>0;return $&&(S.patternProperties=_),y.indexSignatures.length===0?S.additionalProperties=r?.additionalProperties??!1:P.length===1&&y.propertySignatures.length===0&&!$?S.additionalProperties=P[0]:P.length>0&&(S.allOf=P.map(F=>({type:"object",additionalProperties:F}))),typeof S.additionalProperties=="object"&&S.additionalProperties!==null&&Object.keys(S.additionalProperties).length===0&&delete S.additionalProperties,S}case"Union":{let S=y.types.map((C,M)=>x(C,[...w,"types",M]));if(S.length===0)return{not:{}};if(y.mode==="anyOf"&&S.length>1){let C=VG(S);if(C!==void 0)return C}return y.mode==="anyOf"?{anyOf:S}:{oneOf:S}}}}function b(y,w,S){switch(y._tag){case"Reference":{if(!Object.hasOwn(n,y.$ref))throw vi(`Invalid reference ${y.$ref}`,[...w,"$ref"]);if(l(y.$ref,w),S.has(y.$ref))return[];let C=new Set(S).add(y.$ref);return b(n[y.$ref],["references",y.$ref],C)}case"String":return O2(x(y,w));case"TemplateLiteral":return[`^${y.parts.map(Xy).join("")}$`];case"Union":return y.types.flatMap((C,M)=>b(C,[...w,"types",M],S));default:throw vi("Invalid schema representation document",w)}}}function KG(e){return e==="string"||e==="number"||e==="boolean"||e==="array"||e==="object"||e==="null"||e==="integer"}function VG(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;n.push(...r.enum)}return{type:t,enum:n}}function O2(e){let t=[];typeof e.pattern=="string"&&t.push(e.pattern);for(let n of["allOf","anyOf","oneOf"]){let r=e[n];if(Array.isArray(r))for(let o of r)typeof o=="object"&&o!==null&&!Array.isArray(o)&&t.push(...O2(o))}return t}function Xy(e){switch(e._tag){case"Literal":return Nl(globalThis.String(e.literal));case"String":return R1;case"Number":return Kx;case"TemplateLiteral":return e.parts.map(Xy).join("");case"Union":return e.types.map(Xy).join("|");default:throw vi("Invalid schema representation document",[])}}function _2(e,t){let n=WG([e.representation],[["representation"]],e.references,t);return{dialect:n.dialect,schema:n.schemas[0],definitions:n.definitions}}var GG=({identifier:e})=>e;function Ls(e){return e===void 0?void 0:{annotations:e}}function kT(e,t){let{references:n,representations:r}=ZG([e],t);return{representation:r[0],references:n}}function ZG(e,t){let n={},r=new Map,o=new Set,s=new Map,i=new Set;for(let S of e)m(S);let a=t?.referencePolicy??GG;for(let S of s.values())for(let C of S.values()){let M=a({ast:C.ast,occurrences:C.occurrences,identifier:C.identifier});if(M!==void 0){let _=M===C.identifier||!M.endsWith("_")?"_":"";C.reference=u(M,C,_)}else C.isRecursive&&(C.reference=u(`${C.ast._tag}_`,C,""))}return{representations:as(e,S=>g(S)),references:n};function u(S,C,M="_"){let _=S,P=0;for(;r.has(_);){if(r.get(_)===C)return _;_=`${S}${M}${++P}`}return r.set(_,C),_}function f(S,C,M){let _=C.fallback;return _!==void 0?Xw(S)===_?S:Ho(S,{[Tu]:_}):M===C.identifier?S:Ho(S,{identifier:M})}function l(S,C){if(!Object.hasOwn(n,S)&&!o.has(S)){o.add(S);let M=x(C);o.delete(S),W(n,S,M)}return{_tag:"Reference",$ref:S}}function p(S){let C=Dp(S),M=QI(C),_=ul(C),P=_===void 0?(C!==S?ul(S):void 0)??Xw(C):void 0;P!==void 0&&(_=`${P}Encoded`);let $=s.get(M);$===void 0&&($=new Map,s.set(M,$));let F=$.get(_);return F===void 0&&(F={ast:M,identifier:_,fallback:P,occurrences:0,isRecursive:!1,reference:void 0},$.set(_,F)),F}function m(S){let C=p(S),M=C.ast;if(C.occurrences++,i.has(C)){C.isRecursive=!0;return}if(!(C.occurrences>1)){switch(i.add(C),h(M.checks),M._tag){case"Declaration":case"Arrays":case"Objects":case"Union":M.recur(_=>(m(_),_));break;case"TemplateLiteral":M.parts.forEach(m);break;case"Suspend":m(M.thunk());break}i.delete(C)}}function h(S){S?.forEach(C=>{C.annotations?.representation?.schemas?.forEach(M=>m(yn(M))),C._tag==="FilterGroup"&&h(C.checks)})}function g(S){let C=p(S),M=C.ast,_=C.reference;if(_!==void 0){let P=C.identifier===void 0?M:f(M,C,_);return l(_,P)}return x(M)}function x(S){let C=E(S.checks);switch(S._tag){case"Declaration":return{_tag:"Declaration",typeParameters:S.typeParameters.map(M=>g(M)),checks:C,...y(S.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:S._tag,checks:C,...Ls(S.annotations)};case"Literal":return{_tag:"Literal",literal:S.literal,checks:C,...Ls(S.annotations)};case"UniqueSymbol":return{_tag:"UniqueSymbol",symbol:S.symbol,checks:C,...Ls(S.annotations)};case"Enum":return{_tag:"Enum",enums:S.enums,checks:C,...Ls(S.annotations)};case"TemplateLiteral":return{_tag:"TemplateLiteral",parts:S.parts.map(M=>g(M)),checks:C,...Ls(S.annotations)};case"Arrays":return{_tag:"Arrays",elements:S.elements.map(M=>{let _=Dp(M),P=_.context?.annotations;return{isOptional:an(_),type:g(M),...Ls(P)}}),rest:S.rest.map(M=>g(M)),checks:C,...Ls(S.annotations)};case"Objects":return{_tag:"Objects",propertySignatures:S.propertySignatures.map(M=>{let _=Dp(M.type),P=_.context?.annotations;return{name:M.name,type:g(M.type),isOptional:an(_),isMutable:T1(_),...Ls(P)}}),indexSignatures:S.indexSignatures.map(M=>({parameter:g(M.parameter),type:g(M.type)})),checks:C,...Ls(S.annotations)};case"Union":return{_tag:"Union",types:S.types.map(M=>g(M)),mode:S.mode,checks:C,...Ls(S.annotations)};case"Suspend":return{_tag:"Suspend",checks:[],thunk:g(S.thunk()),...Ls(S.annotations)}}}function E(S){return S?.map(b)??[]}function b(S){switch(S._tag){case"Filter":return{_tag:"Filter",aborted:S.aborted,...w(S.annotations)};case"FilterGroup":return{_tag:"FilterGroup",checks:as(S.checks,b),...w(S.annotations)}}}function y(S){if(S===void 0)return;let{representation:C,...M}=S;return{...C===void 0?void 0:{representation:C},...Object.keys(M).length===0?void 0:{annotations:M}}}function w(S){if(S===void 0)return;let{representation:C,...M}=S,_=C===void 0?void 0:C.schemas===void 0?C:{...C,schemas:C.schemas.map(P=>g(yn(P)))};return{..._===void 0?void 0:{representation:_},...Object.keys(M).length===0?void 0:{annotations:M}}}}function P2(e,t){let n=[];return CT(e,t,"",n),n}function CT(e,t,n,r){if(!Object.is(e,t)){if(Array.isArray(e)&&Array.isArray(t)){let o=e.length,s=t.length,i=Math.min(o,s);for(let a=0;a<i;a++)CT(e[a],t[a],`${n}/${a}`,r);for(let a=o-1;a>=s;a--)r.push({op:"remove",path:`${n}/${a}`});for(let a=o;a<s;a++)r.push({op:"add",path:`${n}/${a}`,value:t[a]});return}if(eS(e)&&eS(t)){let o=Object.keys(e),s=Object.keys(t),i=Array.from(new Set([...o,...s])).sort();for(let a of i){let c=`${n}/${Hu(a)}`,u=Object.hasOwn(e,a),f=Object.hasOwn(t,a);u&&f?CT(e[a],t[a],c,r):!u&&f?r.push({op:"add",path:c,value:t[a]}):r.push({op:"remove",path:c})}return}r.push({op:"replace",path:n,value:t})}}function F2(e,t){let n=t;for(let r of e)n=XG(n,r);return n}function eS(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function YG(e){if(e==="")return[];if(e.charCodeAt(0)!==47)throw new Error(`Invalid JSON Pointer, it must start with "/": ${JSON.stringify(e)}`);return e.split("/").slice(1).map(Dl)}function U2(e){if(!/^(0|[1-9]\d*)$/.test(e))throw new Error(`Invalid array index: "${e}"`);return Number(e)}function XG(e,t){if(t.path===""){if(t.op==="remove")throw new Error("Unsupported operation at the root");return t.value}let n=e5(e,t.path);if(n===null)throw new Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`);let{lastToken:r,parent:o,stack:s}=n;if(Array.isArray(o)){if(r==="-"&&t.op!=="add")throw new Error(`"-" is not valid for ${t.op} at "${t.path}".`);let i=r==="-"?o.length:U2(r),a=t.op==="add"?o.length:o.length-1;if(i>a)throw new Error(`Array index out of bounds at "${t.path}".`);let c=o.slice();return t.op==="add"?c.splice(i,0,t.value):t.op==="remove"?c.splice(i,1):c[i]=t.value,M2(s,c)}if(eS(o)){if(t.op!=="add"&&!Object.hasOwn(o,r))throw new Error(`Property "${r}" does not exist at "${t.path}".`);let i={...o};return t.op==="remove"?delete i[r]:W(i,r,t.value),M2(s,i)}throw new Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`)}function e5(e,t){let n=YG(t);if(n.length===0)return null;let r=n[n.length-1],o=[],s=e;for(let i=0;i<n.length-1;i++){let a=n[i];if(Array.isArray(s)){let c=U2(a);if(c>=s.length)return null;o.push({container:s,token:c}),s=s[c];continue}if(eS(s)){if(!Object.hasOwn(s,a))return null;o.push({container:s,token:a}),s=s[a];continue}return null}return{stack:o,parent:s,lastToken:r}}function M2(e,t){let n=t;for(let r=e.length-1;r>=0;r--){let{container:o,token:s}=e[r];if(Array.isArray(o)){let i=o.slice();i[s]=n,n=i}else{let i={...o};W(i,s,n),n=i}}return n}function B2(e,t){return Bs(Ll("Iso",e,t))}function N2(e,t){return Bs(Ll("Lens",e,t))}function Ll(e,t,n){return[{_tag:"PrimitiveNode",kind:e,get:t,set:n}]}var t5={kind:"Iso",get:B,set:B},tS=class{_tag="PathNode";kind="Lens";path;get;set;constructor(t){this.path=t,this.get=n=>{let r=n;for(let o=0;o<t.length;o++)r=r[t[o]];return r},this.set=(n,r)=>{let o=nS(r),s=o,i=0;for(;i<t.length-1;i++){let a=t[i];W(s,a,nS(s[a])),s=s[a]}return W(s,t[i],n),o}}},dm=class{_tag="CheckNode";kind="Prism";checks;get;set=B;constructor(t){this.checks=t,this.get=n=>M1(t,n)}};function Ku(e,t){if(e.length===0)return t;if(t.length===0)return e;let n=e.slice();for(let r=0;r<t.length;r++){let o=t[r],s=n[n.length-1];s._tag==="PathNode"&&o._tag==="PathNode"?n[n.length-1]=new tS([...s.path,...o.path]):s._tag==="CheckNode"&&o._tag==="CheckNode"?n[n.length-1]=new dm([...s.checks,...o.checks]):n.push(o)}return n}function n5(e,t){return Bs(Ll("Optional",e,t))}var Bl=class{node;getResult;replaceResult;constructor(t,n,r){this.node=t,this.getResult=n,this.replaceResult=r}replace(t,n){return Md(this.replaceResult(t,n),()=>n)}modify(t){return n=>Md($h(this.getResult(n),r=>this.replaceResult(t(r),n)),()=>n)}compose(t){return Bs(Ku(this.node,t.node))}key(t){return Bs(Ku(this.node,[new tS([t])]))}optionalKey(t){return Bs(Ku(this.node,Ll("Lens",n=>n[t],(n,r)=>{let o=nS(r);return n===void 0?Array.isArray(o)&&typeof t=="number"?o.splice(t,1):delete o[t]:W(o,t,n),o})))}check(...t){return Bs(Ku(this.node,[new dm(t)]))}refine(t,n){return Bs(Ku(this.node,[new dm([Qx(t,n)])]))}tag(t){let n=Ae(new ke({expected:`${JSON.stringify(t)} tag`}));return Bs(Ku(this.node,Ll("Prism",r=>r._tag===t?Ce(r):n,B)))}at(t,...n){let r=Ae(new Ct([t],new sn(void 0)));return Bs(Ku(this.node,Ll("Optional",o=>Object.hasOwn(o,t)?Ce(o[t]):r,(o,s)=>{if(Object.hasOwn(s,t)){let i=nS(s);return W(i,t,o),Ce(i)}else return r})))}pick(t){return this.compose(N2(JN(t),(n,r)=>({...r,...n})))}omit(t){return this.compose(N2(GN(t),(n,r)=>({...r,...n})))}notUndefined(){return this.refine(Kn,{expected:"a value other than `undefined`"})}forEach(t){let n=t(rS());return n5(r=>tu(this.getResult(r),o=>{let s=[];for(let i=0;i<o.length;i++){let a=n.getResult(o[i]);Kt(a)&&s.push(a.success)}return s}),(r,o)=>$h(this.getResult(o),s=>{let i=[];for(let c=0;c<s.length;c++)Kt(n.getResult(s[c]))&&i.push(c);if(r.length!==i.length)return Ae(new ke({message:`each: replacement length mismatch: ${r.length} !== ${i.length}`}));let a=s.slice();for(let c=0;c<i.length;c++){let u=i[c],f=n.replaceResult(r[c],s[u]);if(Fe(f))return Ae(new Ct([u],f.failure));a[u]=f.success}return this.replaceResult(a,o)}))}modifyAll(t){return n=>Md($h(this.getResult(n),r=>this.replaceResult(r.map(t),n)),()=>n)}},AT=class extends Bl{get;set;constructor(t,n,r){super(t,o=>Ce(n(o)),o=>Ce(r(o))),this.get=n,this.set=r}replace(t,n){return this.set(t)}modify(t){return n=>this.set(t(this.get(n)))}},RT=class extends Bl{get;constructor(t,n,r){super(t,o=>Ce(n(o)),(o,s)=>Ce(r(o,s))),this.get=n,this.replace=r}modify(t){return n=>this.replace(t(this.get(n)),n)}},OT=class extends Bl{set;constructor(t,n,r){super(t,n,(o,s)=>Ce(r(o))),this.set=r}replace(t,n){return this.set(t)}modify(t){return n=>Md(tu(this.getResult(n),r=>this.set(t(r))),()=>n)}};function Bs(e){let t=e[0]??t5;if(e.length>1){let n=e.reduce((r,o)=>s5(r,o.kind),"Iso");t={kind:n,get:r5(e,n),set:o5(e,n)}}switch(t.kind){case"Iso":return new AT(e,t.get,t.set);case"Lens":return new RT(e,t.get,t.set);case"Prism":return new OT(e,t.get,t.set);case"Optional":return new Bl(e,t.get,t.set)}}function nS(e){if(Array.isArray(e))return e.slice();if(typeof e=="object"&&e!==null){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new Error("Cannot clone object with non-Object constructor or null prototype");return{...e}}return e}function r5(e,t){return n=>{for(let r=0;r<e.length;r++){let o=e[r],s=o.get(n);if(_T(o.kind)){if(Fe(s))return s;n=s.success}else n=s}return _T(t)?Ce(n):n}}function o5(e,t){return L2(t)?n=>{for(let r=e.length-1;r>=0;r--)n=e[r].set(n);return n}:(n,r)=>{let o=e.length,s=new Array(o);for(let i=0;i<o;i++){s[i]=r;let a=e[i];if(_T(a.kind)){let c=a.get(r);if(Fe(c))return c;r=c.success}else r=a.get(r)}for(let i=o-1;i>=0;i--){let a=e[i];if(L2(a.kind))n=a.set(n);else if(a.kind==="Lens")n=a.set(n,s[i]);else{let c=a.set(n,s[i]);if(Fe(c))return c;n=c.success}}return t==="Optional"?Ce(n):n}}function _T(e){return e==="Prism"||e==="Optional"}function L2(e){return e==="Iso"||e==="Prism"}function s5(e,t){return e==="Iso"?t:t==="Iso"||e===t?e:"Optional"}var i5=Bs([]);function rS(){return i5}var Vu=new WeakMap,q2=e=>{if(Vu.has(e))return Vu.get(e);throw new Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var $2="~effect/data/Redacted",pm=e=>j(e,$2),bc=(e,t)=>{let n=Object.create(c5);return t?.label&&(n.label=t.label),Vu.set(n,e),n},c5={[$2]:{_A:e=>e},label:void 0,...vn,toJSON(){return this.toString()},toString(){return`<redacted${io(this.label)?":"+this.label:""}>`},[Oe](){return ce(Vu.get(this))},[_e](e){return pm(e)&&ae(Vu.get(this),Vu.get(e))}},Sc=q2;var z2=e=>un((t,n)=>e(Sc(t),Sc(n)));var mm=Gy;function An(){return(e,t,n)=>re(new pa(e.map(_p),r=>t(r.map(o=>re(o))),n))}function no(e,t){return An()([],()=>(n,r,o)=>e(n)?v(n):G(new st(r,n,o)),t)}function u5(e){return e}function f5(e){return t=>t.annotate(e)}function l5(e){return t=>MT(MT(t).annotate(e))}function d5(e){return t=>t.rebuild(bl(t.ast,e))}function p5(e){return e}var hm="~effect/SchemaError/SchemaError",Mr=class extends Mn("SchemaError"){[hm]=hm;constructor(t){let n=ni();ir(0);try{super({issue:t})}finally{ir(n)}}get message(){return KF(this.issue)}toString(){return`SchemaError(${this.message})`}};function Wl(e){return j(e,hm)&&e[hm]===hm}function H2(e){return Ft(e)?e.value:{issues:[{message:yP(e.cause)}]}}function m5(e,t){let n=dt(e),r={errors:"all",...t?.parseOptions},o=WF(t),s=i=>{let a=new ei("sync"),c=mp(jw(n(i,r),{onFailure:o,onSuccess:f=>({value:f})}),{scheduler:a});c.currentDispatcher?.flush();let u=c.pollUnsafe();return u?H2(u):new Promise(f=>{c.addObserver(l=>{f(H2(l))})})};if("~standard"in e){let i=e;return"validate"in i["~standard"]||Object.assign(i["~standard"],{validate:s}),i}else return Object.assign(e,{"~standard":{version:1,vendor:"effect",validate:s}})}function W2(e,t){let n=GB(e);if(t==="draft-2020-12"){let r=n.schema;return Object.keys(n.definitions).length>0&&(r.$defs=n.definitions),r}else if(t==="draft-07"){let r=E2(n),o=r.schema;return Object.keys(r.definitions).length>0&&(o.definitions=r.definitions),o}throw new globalThis.Error(`Unsupported target: ${t}`)}function h5(e){let t={input(n){return W2(e,n.target)},output(n){return W2(Pr(e),n.target)}};if("~standard"in e){let n=e;return"jsonSchema"in n["~standard"]||Object.assign(n["~standard"],{jsonSchema:t}),n}else return Object.assign(e,{"~standard":{version:1,vendor:"effect",jsonSchema:t}})}var oL=MN,g5=FN;function wc(e,t){let n=dt(e,t);return(r,o)=>sL(n(r,o))}function sL(e){return xt(e)?DT(e):ft(e,t=>ia(()=>ec(t,n=>new Mr(n))))}var x5=wc;function iL(e,t){let n;for(let r of e.reasons){if(!$g(r)||!Wl(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 aL(e){return gx(e).then(t=>{if(Ft(t))return t.value;throw iL(t.cause,"Promise adapter can only reject schema errors")})}function cL(e){let t=ac(e);if(Ft(t))return t.value;throw iL(t.cause,"Sync adapter can only throw schema errors")}function uL(e,t){let n=UN(e,t);return(r,o)=>DT(n(r,o))}function DT(e){return Ft(e)?e:jt(ec(e.cause,t=>new Mr(t)))}var fL=uL,y5=pT,S5=DN;function lL(e,t){let n=NN(e,t);return(r,o)=>mE(n(r,o),s=>new Mr(s))}var b5=lL;function dL(e,t){let n=wc(e,t);return(r,o)=>aL(n(r,o))}var E5=dL;function aS(e,t){let n=wc(e,t);return(r,o)=>cL(n(r,o))}var xm=aS;function ym(e,t){let n=Pl(e,t);return(r,o)=>sL(n(r,o))}var cS=ym;function pL(e,t){let n=LN(e,t);return(r,o)=>DT(n(r,o))}var mL=pL,w5=hT,I5=BN;function hL(e,t){let n=jN(e,t);return(r,o)=>mE(n(r,o),s=>new Mr(s))}var v5=hL;function gL(e,t){let n=ym(e,t);return(r,o)=>aL(n(r,o))}var T5=gL;function uS(e,t){let n=ym(e,t);return(r,o)=>cL(n(r,o))}var NT=uS,re=am;function Gu(e){return j(e,mm)&&e[mm]===mm}var Ju=dr(e=>re(El(e.ast),{schema:e})),k5=dr(e=>e.schema),Pt=dr(e=>{let t=lS(e);return re(w1(e.ast),{schema:t})}),C5=dr(e=>e.schema.members[0]),A5=dr(e=>re(XI(e.ast),{schema:e})),R5=dr(e=>e.schema),Pr=dr(e=>re(yn(e.ast),{schema:e})),Kl=dr(e=>re(jn(e.ast),{schema:e})),gm="~effect/Schema/flip";function O5(e){return j(e,gm)&&e[gm]===gm}function MT(e){return O5(e)?e.schema.rebuild(ks(e.ast)):re(ks(e.ast),{[gm]:gm,schema:e})}function Rt(e){let t=re(new Qr(e),{literal:e,transform(n){return t.pipe(be(Rt(n),{decode:De(()=>n),encode:De(()=>e)}))}});return t}function xL(e){return new qx(e.map(t=>Gu(t)?t.ast:new Qr(t)))}function _5(e){return re(xL(e),{parts:e})}function M5(e){return re(xL(e).asTemplateLiteralParser(),{parts:e})}function P5(e){return re(new jx(Object.keys(e).filter(t=>typeof e[e[t]]!="number").map(t=>[t,e[t]])),{enums:e})}var Ic=re(i1),F5=re(a1),LT=re(ma),tt=re(zI),BT=re(HI),fe=re(yi),Vl=re(WI),vc=re(f1),yL=re(l1),Ti=re(d1),Jl=re(s1),U5=re(c1);function D5(e){return re(new $x(e))}function jT(e,t){return re(e,{fields:t,mapFields(n,r){let o=n(this.fields);return jT(Vx(o,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function oe(e){return jT(Vx(e,void 0),e)}function N5(e){return dr(t=>t.mapFields(ZN(e)))}var L5=e=>typeof e=="symbol"?e:globalThis.String(e);function B5(e){return function(t){let n={},r=Object.create(null),o=Object.create(null),s=new Set;for(let i of Reflect.ownKeys(t.fields)){let a=Kl(t.fields[i]),c=Object.hasOwn(e,i),u=c?e[i]:i,f=L5(u);if(s.has(f))throw new globalThis.Error(`Duplicate encoded keys: ${qi(u)}`);s.add(f),W(n,u,a),c&&(r[i]=u,o[u]=i)}return oe(n).pipe(be(t,vt({decode:yT(o),encode:yT(r)})))}}function j5(e,t){return n=>{let r=Hh(n.fields,Pr),o=oe({...r,...e});return n.pipe(be(o,vt({decode:s=>{let i={...s};for(let a in e){let c=t[a],u=c(s);Te(u)&&W(i,a,u.value)}return i},encode:s=>{let i={...s};for(let a in e)delete i[a];return i}})))}}function qT(e,t){return re(v1(e.ast,t.ast),{key:e,value:t})}function q5(e,t){return re(p1(e.ast,t.map(_p)),{schema:e,records:t})}function SL(e,t){return re(e,{elements:t,mapElements(n,r){let o=n(this.elements);return SL(JI(o,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function Ec(e){return SL(JI(e),e)}function $5(e,t){return re(m1(e.ast,t.map(_p)),{schema:e,rest:t})}var Wt=dr(e=>re(new Cs(!1,[],[e.ast]),{value:e}));var fS=dr(e=>re(new Cs(!1,[e.ast],[e.ast]),{value:e}));function z5(e){return He([e,Wt(e)]).pipe(be(Wt(Pr(e)),vt({decode:TR,encode:t=>t.length===1?t[0]:t})))}function H5(e){return Wt(e).check(ZT())}var W5=dr(e=>re(new Cs(!0,e.ast.elements,e.ast.rest),{schema:e}));function bL(e,t){return re(e,{members:t,mapMembers(n,r){let o=n(this.members);return bL(Jx(o,this.ast.mode,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function He(e,t){return bL(Jx(e,t?.mode??"anyOf",void 0),e)}function ka(e){let t=e.map(Rt);return re(Jx(t,"anyOf",void 0),{literals:e,members:t,mapMembers(n){return He(n(this.members))},pick(n){return ka(n)},transform(n){return He(t.map((r,o)=>r.transform(n[o])))}})}var $T=dr(e=>He([e,tt])),lS=dr(e=>He([e,BT])),EL=dr(e=>He([e,tt,BT]));function wL(e){return re(new Hx(()=>e().ast))}function K5(...e){return t=>t.check(...e)}function V5(e,t){return n=>re(Si(n.ast,[Qx(e,t)]),{schema:n})}function IL(e){return t=>re(E1(t.ast,e),{schema:t,identifier:e})}function J5(e,t){return n=>(t.checks?n.check(...t.checks):n).pipe(IL(e))}function vL(e){return t=>re(S1(t.ast,new kp(e,B)),{schema:t})}function TL(e){return t=>re(b1(t.ast,new kp(B,e)),{schema:t})}function G5(e){return kL(e)}function kL(e){return t=>vL(yx(e))(t)}function Z5(e){return CL(e)}function CL(e){return t=>TL(yx(e))(t)}function be(e,t){return n=>re(ey(n.ast,e.ast,t?Nx(t):pl()),{from:n,to:e})}function Q5(e){return t=>be(Pr(t),e)(t)}function zT(e,t){return n=>t?be(n,t)(e):be(n)(e)}function Y5(e){return t=>be(t,e)(Kl(t))}function AL(e){return t=>re(I1(t.ast,e),{schema:t})}function RL(e){return ft(e,t=>ia(()=>ec(t,n=>n.issue)))}function HT(e,t){let n=t?.encodingStrategy==="omit"?lI():Ts();return r=>Ju(Kl(r)).pipe(be(r,{decode:vp(RL(e)),encode:n}))}function X5(e,t){return n=>Pr(n).pipe(HT(e,t),zT(Ju(n)))}function OL(e,t){let n=t?.encodingStrategy==="omit"?lI():Ts();return r=>Pt(Kl(r)).pipe(be(r,{decode:vp(RL(e)),encode:n}))}function eZ(e,t){return n=>Pr(n).pipe(OL(e,t),zT(Pt(n)))}function Ze(e){return Rt(e).pipe(AL(v(e)))}function tZ(e){return Ze(e).pipe(HT(v(e),{encodingStrategy:"omit"}))}function Tc(e,t){return oe({_tag:Ze(e),...t})}function _L(e){return t=>{let n={},r=[],o=new Set,s={},i=f=>l=>f.includes(l[e]);return a(t),Object.assign(t,{cases:n,discriminants:r,isAnyOf:i,guards:s,match:c,matchOrElse:u});function a(f){let l=f.ast;if(r1(l)&&"members"in f&&globalThis.Array.isArray(f.members)&&f.members.every(Gu))return f.members.forEach(a);let p=lc(l);if(p.length>0){let m=p.find(h=>h.key===e)?.literal;if(yh(m)){let h=typeof m=="number"?globalThis.String(m):m;if(o.has(h))throw new globalThis.Error(`Duplicate discriminant: ${globalThis.String(m)}`);o.add(h),r.push(m),W(n,m,f),W(s,m,oL(Pr(f)));return}}throw new globalThis.Error("No literal or unique symbol found")}function c(){if(arguments.length===1){let h=arguments[0];return function(g){let x=g[e];return(Object.hasOwn(h,x)?h[x]:void 0)(g)}}let f=arguments[0],l=arguments[1],p=f[e];return(Object.hasOwn(l,p)?l[p]:void 0)(f)}function u(){if(arguments.length===2){let g=arguments[0],x=arguments[1];return function(E){let b=E[e];return(Object.hasOwn(g,b)?g[b]??x:x)(E)}}let f=arguments[0],l=arguments[1],p=arguments[2],m=f[e];return(Object.hasOwn(l,m)?l[m]??p:p)(f)}}}function nZ(e){let t={},n=[];for(let c of Object.keys(e)){let u=Tc(c,e[c]);W(t,c,u),n.push(u)}let r=He(n),{guards:o,isAnyOf:s,match:i,matchOrElse:a}=_L("_tag")(r);return re(r.ast,{cases:t,isAnyOf:s,guards:o,match:i,matchOrElse:a})}function rZ(){return e=>e}function kc(e,t){return no(n=>n instanceof e,t)}function pt(){return(e,t)=>new Dt(e.ast,Nx(t))}var Tt=Zx;function oZ(e,t=void 0){return new Ou(e,t)}function pr(e,t){return _r(e,tt,({annotations:n})=>n===void 0?t:t.annotate(n))}var K2="^\\S[\\s\\S]*\\S$|^\\S$|^$";function WT(e){let t=new globalThis.RegExp(K2);return Tt(n=>n.trim()===n,{expected:"a string with no leading or trailing whitespace",representation:{id:"effect/schema/isTrimmed",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isTrimmed()"}),arbitrary:{constraint:{patterns:[K2]}},...e})}var sZ=Re("effect/schema/isTrimmed",tt,({annotations:e})=>WT(e));function Zu(e,t){let n=e.source,r=e.flags,o=r===""?`new RegExp(${X(n)})`:`new RegExp(${X(n)}, ${X(r)})`;return Pp(e,{toCode:()=>({runtime:`Schema.isPattern(${o})`}),...t})}var iZ=oe({source:fe,flags:fe}).check(Tt(e=>{let t=qh(()=>new globalThis.RegExp(e.source,e.flags));return Kt(t)&&t.success.source===e.source&&t.success.flags===e.flags})),aZ={id:"effect/schema/isPattern",payloadSchema:iZ,revive:({annotations:e,payload:t})=>Zu(new globalThis.RegExp(t.source,t.flags),e)};function ML(e){return tv({toCode:()=>({runtime:"Schema.isStringFinite()"}),...e})}var cZ=Re("effect/schema/isStringFinite",tt,({annotations:e})=>ML(e));function PL(e){return nv({toCode:()=>({runtime:"Schema.isStringBigInt()"}),...e})}var uZ=Re("effect/schema/isStringBigInt",tt,({annotations:e})=>PL(e));function FL(e){return ov({toCode:()=>({runtime:"Schema.isStringSymbol()"}),...e})}var fZ=Re("effect/schema/isStringSymbol",tt,({annotations:e})=>FL(e)),lZ=e=>e?new globalThis.RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/;function UL(e,t){let n=lZ(e);return Zu(n,{expected:e?`a UUID v${e}`:"a UUID",representation:{id:"effect/schema/isUUID",payload:{version:e??null}},toJsonSchema:()=>({pattern:n.source,format:"uuid"}),toCode:()=>({runtime:e===void 0?"Schema.isUUID()":`Schema.isUUID(${e})`}),...t})}var dZ=Re("effect/schema/isUUID",oe({version:He([ka([1,2,3,4,5,6,7,8]),tt])}),({annotations:e,payload:t})=>UL(t.version??void 0,e)),V2=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;function DL(e){return Zu(V2,{expected:"a GUID",representation:{id:"effect/schema/isGUID",payload:null},toJsonSchema:()=>({pattern:V2.source}),toCode:()=>({runtime:"Schema.isGUID()"}),...e})}var pZ=Re("effect/schema/isGUID",tt,({annotations:e})=>DL(e));function NL(e){let t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;return Zu(t,{representation:{id:"effect/schema/isULID",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isULID()"}),...e})}var mZ=Re("effect/schema/isULID",tt,({annotations:e})=>NL(e));function KT(e){let t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;return Zu(t,{expected:"a base64 encoded string",representation:{id:"effect/schema/isBase64",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64()"}),...e})}var hZ=Re("effect/schema/isBase64",tt,({annotations:e})=>KT(e));function LL(e){let t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;return Zu(t,{expected:"a base64url encoded string",representation:{id:"effect/schema/isBase64Url",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64Url()"}),...e})}var gZ=Re("effect/schema/isBase64Url",tt,({annotations:e})=>LL(e));function BL(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`^${Nl(e)}`);return Tt(o=>o.startsWith(e),{expected:`a string starting with ${n}`,representation:{id:"effect/schema/isStartsWith",payload:{startsWith:e}},toJsonSchema:()=>({pattern:r.source}),toCode:()=>({runtime:`Schema.isStartsWith(${X(e)})`}),arbitrary:{constraint:{patterns:[r.source]}},...t})}var xZ=Re("effect/schema/isStartsWith",oe({startsWith:fe}),({annotations:e,payload:t})=>BL(t.startsWith,e));function jL(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`${Nl(e)}$`);return Tt(o=>o.endsWith(e),{expected:`a string ending with ${n}`,representation:{id:"effect/schema/isEndsWith",payload:{endsWith:e}},toJsonSchema:()=>({pattern:r.source}),toCode:()=>({runtime:`Schema.isEndsWith(${X(e)})`}),arbitrary:{constraint:{patterns:[r.source]}},...t})}var yZ=Re("effect/schema/isEndsWith",oe({endsWith:fe}),({annotations:e,payload:t})=>jL(t.endsWith,e));function qL(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(Nl(e));return Tt(o=>o.includes(e),{expected:`a string including ${n}`,representation:{id:"effect/schema/isIncludes",payload:{includes:e}},toJsonSchema:()=>({pattern:r.source}),toCode:()=>({runtime:`Schema.isIncludes(${X(e)})`}),arbitrary:{constraint:{patterns:[r.source]}},...t})}var SZ=Re("effect/schema/isIncludes",oe({includes:fe}),({annotations:e,payload:t})=>qL(t.includes,e)),J2="^[^a-z]*$";function $L(e){let t=new globalThis.RegExp(J2);return Tt(n=>n.toUpperCase()===n,{expected:"a string with all characters in uppercase",representation:{id:"effect/schema/isUppercased",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isUppercased()"}),arbitrary:{constraint:{patterns:[J2]}},...e})}var bZ=Re("effect/schema/isUppercased",tt,({annotations:e})=>$L(e)),G2="^[^A-Z]*$";function zL(e){let t=new globalThis.RegExp(G2);return Tt(n=>n.toLowerCase()===n,{expected:"a string with all characters in lowercase",representation:{id:"effect/schema/isLowercased",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isLowercased()"}),arbitrary:{constraint:{patterns:[G2]}},...e})}var EZ=Re("effect/schema/isLowercased",tt,({annotations:e})=>zL(e)),Z2="^[^a-z]?.*$";function HL(e){let t=new globalThis.RegExp(Z2);return Tt(n=>n.charAt(0).toUpperCase()===n.charAt(0),{expected:"a string with the first character in uppercase",representation:{id:"effect/schema/isCapitalized",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isCapitalized()"}),arbitrary:{constraint:{patterns:[Z2]}},...e})}var wZ=Re("effect/schema/isCapitalized",tt,({annotations:e})=>HL(e)),Q2="^[^A-Z]?.*$";function WL(e){let t=new globalThis.RegExp(Q2);return Tt(n=>n.charAt(0).toLowerCase()===n.charAt(0),{expected:"a string with the first character in lowercase",representation:{id:"effect/schema/isUncapitalized",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isUncapitalized()"}),arbitrary:{constraint:{patterns:[Q2]}},...e})}var IZ=Re("effect/schema/isUncapitalized",tt,({annotations:e})=>WL(e)),js=re(ZI),KL=GI,vZ=Re("effect/schema/isFinite",tt,({annotations:e})=>KL(e));function Sm(e){let t=Wi(e.order),n=e.formatter??X;return(r,o)=>Tt(s=>t(s,r),{expected:`a value greater than ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:r,exclusiveMinimum:!0}}},...e.annotate?.(r),...o})}function bm(e){let t=wf(e.order),n=e.formatter??X;return(r,o)=>Tt(s=>t(s,r),{expected:`a value greater than or equal to ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:r}}},...e.annotate?.(r),...o})}function Em(e){let t=Yc(e.order),n=e.formatter??X;return(r,o)=>Tt(s=>t(s,r),{expected:`a value less than ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,maximum:r,exclusiveMaximum:!0}}},...e.annotate?.(r),...o})}function wm(e){let t=Ef(e.order),n=e.formatter??X;return(r,o)=>Tt(s=>t(s,r),{expected:`a value less than or equal to ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,maximum:r}}},...e.annotate?.(r),...o})}function Im(e){let t=wf(e.order),n=Wi(e.order),r=Ef(e.order),o=Yc(e.order),s=e.formatter??X;return(i,a)=>{let c=i.exclusiveMinimum?n:t,u=i.exclusiveMaximum?o:r;return Tt(f=>c(f,i.minimum)&&u(f,i.maximum),{expected:`a value between ${s(i.minimum)}${i.exclusiveMinimum?" (excluded)":""} and ${s(i.maximum)}${i.exclusiveMaximum?" (excluded)":""}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:i.minimum,maximum:i.maximum,...i.exclusiveMinimum&&{exclusiveMinimum:!0},...i.exclusiveMaximum&&{exclusiveMaximum:!0}}}},...e.annotate?.(i),...a})}}function VL(e){return(t,n)=>{let r=e.formatter??X;return Tt(o=>e.remainder(o,t)===e.zero,{expected:`a value that is a multiple of ${r(t)}`,...e.annotate?.(t),...n})}}function ql(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${X(e)}`);return e}var JL=Sm({order:fo,annotate:e=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:ql(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${X(e)})`})})}),TZ=Re("effect/schema/isGreaterThan",oe({exclusiveMinimum:js}),({annotations:e,payload:t})=>JL(t.exclusiveMinimum,e)),VT=bm({order:fo,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:ql(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${X(e)})`})})}),kZ=Re("effect/schema/isGreaterThanOrEqualTo",oe({minimum:js}),({annotations:e,payload:t})=>VT(t.minimum,e)),GL=Em({order:fo,annotate:e=>({representation:{id:"effect/schema/isLessThan",payload:{exclusiveMaximum:ql(e)}},toJsonSchema:()=>({exclusiveMaximum:e}),toCode:()=>({runtime:`Schema.isLessThan(${X(e)})`})})}),CZ=Re("effect/schema/isLessThan",oe({exclusiveMaximum:js}),({annotations:e,payload:t})=>GL(t.exclusiveMaximum,e)),ZL=wm({order:fo,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:ql(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${X(e)})`})})}),AZ=Re("effect/schema/isLessThanOrEqualTo",oe({maximum:js}),({annotations:e,payload:t})=>ZL(t.maximum,e)),dS=Im({order:fo,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:ql(e.minimum),maximum:ql(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[n?"exclusiveMaximum":"maximum"]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${X(e.minimum)}, maximum: ${X(e.maximum)}, exclusiveMinimum: ${X(t)}, exclusiveMaximum: ${X(n)} })`})}}}),RZ=Re("effect/schema/isBetween",oe({minimum:js,maximum:js,exclusiveMinimum:Pt(Rt(!0)),exclusiveMaximum:Pt(Rt(!0))}),({annotations:e,payload:t})=>dS(t,e)),QL=VL({remainder:tF,zero:0,annotate:e=>({expected:`a value that is a multiple of ${e}`,representation:{id:"effect/schema/isMultipleOf",payload:{divisor:e}},toJsonSchema:()=>({multipleOf:e}),toCode:()=>({runtime:`Schema.isMultipleOf(${X(e)})`})})}),OZ=Re("effect/schema/isMultipleOf",oe({divisor:js}),({annotations:e,payload:t})=>QL(t.divisor,e));function vm(e){return Tt(t=>globalThis.Number.isSafeInteger(t),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:()=>({type:"integer"}),toCode:()=>({runtime:"Schema.isInt()"}),arbitrary:{constraint:{integer:!0}},...e})}var _Z=Re("effect/schema/isInt",tt,({annotations:e})=>vm(e)),$s=Vl.check(vm()),tr=$s.check(VT(0));function MZ(e){return new Ou([vm(),dS({minimum:-2147483648,maximum:2147483647})],{expected:"a 32-bit integer",...e})}function PZ(e){return new Ou([vm(),dS({minimum:0,maximum:4294967295})],{expected:"a 32-bit unsigned integer",...e})}function $l(e){if(globalThis.Number.isNaN(e.getTime()))throw new globalThis.RangeError(`Expected a valid Date, got ${X(e)}`);return e.toISOString()}function zl(e){return`new Date(${X(e.getTime())})`}var YL=Sm({order:Qc,annotate:e=>({representation:{id:"effect/schema/isGreaterThanDate",payload:{exclusiveMinimum:$l(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanDate(${zl(e)})`})})}),XL=bm({order:Qc,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualToDate",payload:{minimum:$l(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToDate(${zl(e)})`})})}),eB=Em({order:Qc,annotate:e=>({representation:{id:"effect/schema/isLessThanDate",payload:{exclusiveMaximum:$l(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanDate(${zl(e)})`})})}),tB=wm({order:Qc,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualToDate",payload:{maximum:$l(e)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanOrEqualToDate(${zl(e)})`})})}),nB=Im({order:Qc,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenDate",payload:{minimum:$l(e.minimum),maximum:$l(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isBetweenDate({ minimum: ${zl(e.minimum)}, maximum: ${zl(e.maximum)}, exclusiveMinimum: ${X(t)}, exclusiveMaximum: ${X(n)} })`})}}}),rB=Sm({order:Ro,annotate:e=>({representation:{id:"effect/schema/isGreaterThanBigInt",payload:{exclusiveMinimum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanBigInt(${X(e)})`})})}),oB=bm({order:Ro,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualToBigInt",payload:{minimum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToBigInt(${X(e)})`})})}),sB=Em({order:Ro,annotate:e=>({representation:{id:"effect/schema/isLessThanBigInt",payload:{exclusiveMaximum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanBigInt(${X(e)})`})})}),iB=wm({order:Ro,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualToBigInt",payload:{maximum:e.toString(10)}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isLessThanOrEqualToBigInt(${X(e)})`})})}),aB=Im({order:Ro,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenBigInt",payload:{minimum:e.minimum.toString(10),maximum:e.maximum.toString(10),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isBetweenBigInt({ minimum: ${X(e.minimum)}, maximum: ${X(e.maximum)}, exclusiveMinimum: ${X(t)}, exclusiveMaximum: ${X(n)} })`})}}}),FZ=Sm({order:Ki,formatter:e=>Xs(e)}),UZ=bm({order:Ki,formatter:e=>Xs(e)}),DZ=Em({order:Ki,formatter:e=>Xs(e)}),NZ=wm({order:Ki,formatter:e=>Xs(e)}),LZ=Im({order:Ki,formatter:e=>Xs(e)});function JT(e,t){return e=Math.max(0,Math.floor(e)),Tt(n=>n.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:({type:n})=>n==="array"?{minItems:e}:{minLength:e},toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[Gr]:!0,arbitrary:{constraint:{minLength:e}},...t})}var BZ=Re("effect/schema/isMinLength",oe({minLength:tr}),({annotations:e,payload:t})=>JT(t.minLength,e));function cB(e){return JT(1,e)}function uB(e,t){return e=Math.max(0,Math.floor(e)),Tt(n=>n.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:({type:n})=>n==="array"?{maxItems:e}:{maxLength:e},toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[Gr]:!0,arbitrary:{constraint:{maxLength:e}},...t})}var jZ=Re("effect/schema/isMaxLength",oe({maxLength:tr}),({annotations:e,payload:t})=>uB(t.maxLength,e));function GT(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),Tt(r=>r.length>=e&&r.length<=t,{expected:e===t?`a value with a length of ${e}`:`a value with a length between ${e} and ${t}`,representation:{id:"effect/schema/isLengthBetween",payload:{minimum:e,maximum:t}},toJsonSchema:({type:r})=>r==="array"?{allOf:[{minItems:e},{maxItems:t}]}:{allOf:[{minLength:e},{maxLength:t}]},toCode:()=>({runtime:`Schema.isLengthBetween(${e}, ${t})`}),[Gr]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}var qZ=Re("effect/schema/isLengthBetween",oe({minimum:tr,maximum:tr}),({annotations:e,payload:t})=>GT(t.minimum,t.maximum,e));function fB(e,t){return e=Math.max(0,Math.floor(e)),Tt(n=>n.size>=e,{expected:`a value with a size of at least ${e}`,representation:{id:"effect/schema/isMinSize",payload:{minSize:e}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isMinSize(${e})`}),[Gr]:!0,arbitrary:{constraint:{minLength:e}},...t})}var $Z=Re("effect/schema/isMinSize",oe({minSize:tr}),({annotations:e,payload:t})=>fB(t.minSize,e));function lB(e,t){return e=Math.max(0,Math.floor(e)),Tt(n=>n.size<=e,{expected:`a value with a size of at most ${e}`,representation:{id:"effect/schema/isMaxSize",payload:{maxSize:e}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isMaxSize(${e})`}),[Gr]:!0,arbitrary:{constraint:{maxLength:e}},...t})}var zZ=Re("effect/schema/isMaxSize",oe({maxSize:tr}),({annotations:e,payload:t})=>lB(t.maxSize,e));function dB(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),Tt(r=>r.size>=e&&r.size<=t,{expected:e===t?`a value with a size of ${e}`:`a value with a size between ${e} and ${t}`,representation:{id:"effect/schema/isSizeBetween",payload:{minimum:e,maximum:t}},toJsonSchema:()=>({}),toCode:()=>({runtime:`Schema.isSizeBetween(${e}, ${t})`}),[Gr]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}var HZ=Re("effect/schema/isSizeBetween",oe({minimum:tr,maximum:tr}),({annotations:e,payload:t})=>dB(t.minimum,t.maximum,e));function pB(e,t){return e=Math.max(0,Math.floor(e)),Tt(n=>Reflect.ownKeys(n).length>=e,{expected:`a value with at least ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMinProperties",payload:{minProperties:e}},toJsonSchema:()=>({minProperties:e}),toCode:()=>({runtime:`Schema.isMinProperties(${e})`}),[Gr]:!0,arbitrary:{constraint:{minLength:e}},...t})}var WZ=Re("effect/schema/isMinProperties",oe({minProperties:tr}),({annotations:e,payload:t})=>pB(t.minProperties,e));function mB(e,t){return e=Math.max(0,Math.floor(e)),Tt(n=>Reflect.ownKeys(n).length<=e,{expected:`a value with at most ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMaxProperties",payload:{maxProperties:e}},toJsonSchema:()=>({maxProperties:e}),toCode:()=>({runtime:`Schema.isMaxProperties(${e})`}),[Gr]:!0,arbitrary:{constraint:{maxLength:e}},...t})}var KZ=Re("effect/schema/isMaxProperties",oe({maxProperties:tr}),({annotations:e,payload:t})=>mB(t.maxProperties,e));function hB(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),Tt(r=>Reflect.ownKeys(r).length>=e&&Reflect.ownKeys(r).length<=t,{expected:e===t?`a value with exactly ${e===1?"1 entry":`${e} entries`}`:`a value with between ${e} and ${t} entries`,representation:{id:"effect/schema/isPropertiesLengthBetween",payload:{minimum:e,maximum:t}},toJsonSchema:()=>({minProperties:e,maxProperties:t}),toCode:()=>({runtime:`Schema.isPropertiesLengthBetween(${e}, ${t})`}),[Gr]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}var VZ=Re("effect/schema/isPropertiesLengthBetween",oe({minimum:tr,maximum:tr}),({annotations:e,payload:t})=>hB(t.minimum,t.maximum,e));function gB(e,t){let n=Kl(e),r=PN(n.ast);return Tt((o,s,i)=>{let a=Reflect.ownKeys(o),c=[];for(let u of a){let f=r(u,i);if(f!==void 0&&(c.push(new Ct([u],f)),i.errors==="first"))break}return Vn(c)?new At(s,c,o,i):!0},{expected:"an object with property names matching the schema",representation:{id:"effect/schema/isPropertyNames",payload:null,schemas:[n.ast]},toJsonSchema:({schemas:o})=>({propertyNames:o[0]}),toCode:({schemas:o})=>({runtime:`Schema.isPropertyNames(${o[0].runtime})`}),[Gr]:!0,...t})}var JZ=Re("effect/schema/isPropertyNames",tt,({annotations:e,schemas:t})=>gB(t[0],e));function ZT(e){return Tt(t=>Jh(t).length===t.length,{expected:"an array with unique items",representation:{id:"effect/schema/isUnique",payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:"Schema.isUnique()"}),arbitrary:{constraint:{unique:!0}},...e})}var GZ=Re("effect/schema/isUnique",tt,({annotations:e})=>ZT(e)),ZZ=fe.check(cB()),QZ=fe.check(GT(1,1));function ki(e){let t=An()([e],([n])=>(r,o,s)=>Ys(r)?xe(r)?Es:fn(dt(n)(r.value,s),{onSuccess:L,onFailure:i=>Yn(o,"value",i,r,s)}):G(new st(o,r,s)),{representation:{id:"effect/schema/Option",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Option(${n[0].runtime})`,Type:`Option.Option<${n[0].Type}>`,importDeclarations:['import * as Option from "effect/Option"']}),expected:"Option",toCodec:([n])=>pt()(He([oe({_tag:Rt("Some"),value:n}),oe({_tag:Rt("None")})]),vt({decode:r=>r._tag==="None"?D():L(r.value),encode:r=>Te(r)?{_tag:"Some",value:r.value}:{_tag:"None"}})),toArbitrary:([n])=>(r,o)=>{let s=r.constant(D()),i=r.oneof(s,n.arbitrary.map(L));return Qu(r,o,s,i)},toEquivalence:([n])=>pE(n),toFormatter:([n])=>rr({onNone:()=>"none()",onSome:r=>`some(${n(r)})`})});return re(t.ast,{value:e})}var YZ=_r("effect/schema/Option",tt,({annotations:e,typeParameters:t})=>{let n=ki(t[0]);return e===void 0?n:n.annotate(e)});function XZ(e){return $T(e).pipe(be(ki(Pr(e)),DU()))}function eQ(e){return lS(e).pipe(be(ki(Pr(e)),NU()))}function tQ(e,t){return EL(e).pipe(be(ki(Pr(e)),LU(t)))}function nQ(e){return Ju(e).pipe(be(ki(Pr(e)),BU()))}function rQ(e){return Pt(e).pipe(be(ki(Pr(e)),jU()))}function oQ(e,t){let n=t===void 0?"omit":t.onNoneEncoding,r=n===null?null:void 0;return Pt($T(e)).pipe(be(ki(Pr(e)),Lx({decode:o=>o.pipe(za(Sh),L),encode:n==="omit"?eu:o=>L(qa(eu(o),()=>r))})))}function xB(e,t){let n=An()([e,t],([r,o])=>(s,i,a)=>{if(!If(s))return G(new st(i,s,a));switch(s._tag){case"Success":return fn(dT(r)(s.success,a),{onSuccess:Ce,onFailure:c=>Yn(i,"success",c,s,a)});case"Failure":return fn(dT(o)(s.failure,a),{onSuccess:Ae,onFailure:c=>Yn(i,"failure",c,s,a)})}},{representation:{id:"effect/schema/Result",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Result(${r[0].runtime}, ${r[1].runtime})`,Type:`Result.Result<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Result from "effect/Result"']}),expected:"Result",toCodec:([r,o])=>pt()(He([oe({_tag:Rt("Success"),success:r}),oe({_tag:Rt("Failure"),failure:o})]),vt({decode:s=>s._tag==="Success"?Ce(s.success):Ae(s.failure),encode:s=>Kt(s)?{_tag:"Success",success:s.success}:{_tag:"Failure",failure:s.failure}})),toArbitrary:([r,o])=>(s,i)=>{let a=CB(s,r.terminal?.map(u=>Ce(u)),o.terminal?.map(u=>Ae(u))),c=s.oneof(r.arbitrary.map(u=>Ce(u)),o.arbitrary.map(u=>Ae(u)));return Qu(s,i,a,c)},toEquivalence:([r,o])=>gR(r,o),toFormatter:([r,o])=>_o({onSuccess:s=>`success(${r(s)})`,onFailure:s=>`failure(${o(s)})`})});return re(n.ast,{success:e,failure:t})}var sQ=_r("effect/schema/Result",tt,({annotations:e,typeParameters:t})=>{let n=xB(t[0],t[1]);return e===void 0?n:n.annotate(e)}),iQ=no(e=>{if(!en(e))return!1;let t=globalThis.Object.keys(e);return t.length>0&&t.every(n=>{switch(n){case"label":return typeof e[n]=="string";case"disallowJsonEncode":return e[n]===!0;default:return!1}})}),aQ=He([tt,iQ]);function QT(e,t){let n=typeof t?.label=="string"?t.label:void 0,r=t?.disallowJsonEncode===!0,o=n!==void 0?r?{label:n,disallowJsonEncode:!0}:{label:n}:r?{disallowJsonEncode:!0}:void 0,s=n!==void 0?dt(Rt(n)):void 0,i=An()([e],([a])=>(c,u,f)=>{if(pm(c)){let l=s!==void 0?vu(s(c.label,f),p=>new Ct(["label"],p)):H;return Bn(l,()=>fn(dt(a)(Sc(c),f),{onSuccess:()=>c,onFailure:()=>new At(u,[new Ct(["value"],new ke(void 0,c,f))],c,f)}))}return G(new st(u,c,f))},{representation:{id:"effect/schema/Redacted",payload:o??null},toCode:({typeParameters:a})=>({runtime:o!==void 0?`Schema.Redacted(${a[0].runtime}, ${X(o)})`:`Schema.Redacted(${a[0].runtime})`,Type:`Redacted.Redacted<${a[0].Type}>`,importDeclarations:['import * as Redacted from "effect/Redacted"']}),expected:"Redacted",toCodecJson:([a])=>pt()(a,{decode:De(c=>bc(c,{label:n})),encode:r?uI(c=>"Cannot serialize Redacted"+(Te(c)&&typeof c.value.label=="string"?` with label: "${c.value.label}"`:"")):De(Sc)}),toArbitrary:([a])=>()=>({arbitrary:a.arbitrary.map(c=>bc(c,{label:n})),terminal:a.terminal?.map(c=>bc(c,{label:n}))}),toFormatter:()=>globalThis.String,toEquivalence:([a])=>z2(a)});return re(i.ast,{value:e})}var cQ=_r("effect/schema/Redacted",aQ,({annotations:e,payload:t,typeParameters:n})=>{let r=QT(n[0],t??void 0);return e===void 0?r:r.annotate(e)});function uQ(e,t){return be(QT(Pr(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:De(n=>bc(n,{label:t?.label})),encode:t?.disallowEncode?uI(n=>"Cannot encode Redacted"+(Te(n)&&typeof n.value.label=="string"?` with label: "${n.value.label}"`:"")):De(Sc)})(e)}function sS(e,t){let n=An()([e,t],([r,o])=>(s,i,a)=>{if(!zf(s))return G(new st(i,s,a));switch(s._tag){case"Fail":return fn(dt(r)(s.error,a),{onSuccess:Hf,onFailure:c=>Yn(i,"error",c,s,a)});case"Die":return fn(dt(o)(s.defect,a),{onSuccess:Wf,onFailure:c=>Yn(i,"defect",c,s,a)});case"Interrupt":return v(s)}},{representation:{id:"effect/schema/CauseReason",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.CauseReason(${r[0].runtime}, ${r[1].runtime})`,Type:`Cause.Failure<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause.Failure",toCodec:([r,o])=>pt()(He([oe({_tag:Rt("Fail"),error:r}),oe({_tag:Rt("Die"),defect:o}),oe({_tag:Rt("Interrupt"),fiberId:lS(js)})]),vt({decode:s=>{switch(s._tag){case"Fail":return Hf(s.error);case"Die":return Wf(s.defect);case"Interrupt":return lu(s.fiberId)}},encode:B})),toArbitrary:([r,o])=>yB(r,o),toEquivalence:([r,o])=>SB(r,o),toFormatter:([r,o])=>bB(r,o)});return re(n.ast,{error:e,defect:t})}var fQ=_r("effect/schema/CauseReason",tt,({annotations:e,typeParameters:t})=>{let n=sS(t[0],t[1]);return e===void 0?n:n.annotate(e)});function yB(e,t){return(n,r)=>{let o=n.constant(lu()),s=n.oneof(o,n.integer({min:1}).map(lu),e.arbitrary.map(i=>Hf(i)),t.arbitrary.map(i=>Wf(i)));return Qu(n,r,o,s)}}function SB(e,t){return(n,r)=>{if(n._tag!==r._tag)return!1;switch(n._tag){case"Fail":return e(n.error,r.error);case"Die":return t(n.defect,r.defect);case"Interrupt":return n.fiberId===r.fiberId}}}function bB(e,t){return n=>{switch(n._tag){case"Fail":return`Fail(${e(n.error)})`;case"Die":return`Die(${t(n.defect)})`;case"Interrupt":return"Interrupt"}}}function Hl(e,t){let n=An()([e,t],([r,o])=>{let s=Wt(sS(r,o));return(i,a,c)=>$f(i)?fn(dt(s)(i.reasons,c),{onSuccess:Xa,onFailure:u=>Yn(a,"failures",u,i,c)}):G(new st(a,i,c))},{representation:{id:"effect/schema/Cause",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Cause(${r[0].runtime}, ${r[1].runtime})`,Type:`Cause.Cause<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause",toCodec:([r,o])=>pt()(Wt(sS(r,o)),vt({decode:Xa,encode:({reasons:s})=>s})),toArbitrary:([r,o])=>EB(r,o),toEquivalence:([r,o])=>wB(r,o),toFormatter:([r,o])=>IB(r,o)});return re(n.ast,{error:e,defect:t})}var lQ=_r("effect/schema/Cause",tt,({annotations:e,typeParameters:t})=>{let n=Hl(t[0],t[1]);return e===void 0?n:n.annotate(e)});function EB(e,t){return(n,r)=>{let o=yB(e,t)(n,r),s=n.constant(dP),i=n.array(o.arbitrary).map(Xa);return Qu(n,r,s,i)}}function wB(e,t){let n=vh(SB(e,t));return(r,o)=>n(r.reasons,o.reasons)}function IB(e,t){let n=bB(e,t);return r=>`Cause([${r.reasons.map(n).join(", ")}])`}var dQ=no(e=>{if(!en(e))return!1;let t=globalThis.Object.keys(e);return t.length>0&&t.every(n=>(n==="includeStack"||n==="excludeCause")&&e[n]===!0)}),pQ=He([tt,dQ]),vB=e=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),TB=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},Y2=[];function kB(e){let t=vB(e),n=Y2[t];if(n!==void 0)return n;let r=TB(t),o=kc(globalThis.Error,{representation:{id:"effect/schema/Error",payload:r??null},toCode:()=>({runtime:r!==void 0?`Schema.ErrorInstance(${X(r)})`:"Schema.ErrorInstance()",Type:"globalThis.Error"}),expected:"Error",toCodecJson:()=>pt()(s9,FU(r)),toArbitrary:()=>s=>s.string().map(i=>new globalThis.Error(i))});return Y2[t]=o,o}var mQ=_r("effect/schema/Error",pQ,({annotations:e,payload:t})=>{let n=kB(t??void 0);return e===void 0?n:n.annotate(e)}),X2=[];function ln(e){let t=vB(e),n=X2[t];if(n!==void 0)return n;let r=Am.pipe(be(LT,UU(TB(t))));return X2[t]=r,r}function pS(e,t,n){let r=An()([e,t,n],([o,s,i])=>{let a=Hl(s,i);return(c,u,f)=>{if(!gs(c))return G(new st(u,c,f));switch(c._tag){case"Success":return fn(dt(o)(c.value,f),{onSuccess:kn,onFailure:l=>Yn(u,"value",l,c,f)});case"Failure":return fn(dt(a)(c.cause,f),{onSuccess:jt,onFailure:l=>Yn(u,"cause",l,c,f)})}}},{representation:{id:"effect/schema/Exit",payload:null},toCode:({typeParameters:o})=>({runtime:`Schema.Exit(${o[0].runtime}, ${o[1].runtime}, ${o[2].runtime})`,Type:`Exit.Exit<${o[0].Type}, ${o[1].Type}, ${o[2].Type}>`,importDeclarations:['import * as Exit from "effect/Exit"']}),expected:"Exit",toCodec:([o,s,i])=>pt()(He([oe({_tag:Rt("Success"),value:o}),oe({_tag:Rt("Failure"),cause:Hl(s,i)})]),vt({decode:a=>a._tag==="Success"?kn(a.value):jt(a.cause),encode:a=>Ft(a)?{_tag:"Success",value:a.value}:{_tag:"Failure",cause:a.cause}})),toArbitrary:([o,s,i])=>(a,c)=>{let u=EB(s,i)(a,c),f=CB(a,o.terminal?.map(p=>kn(p)),u.terminal?.map(p=>jt(p))),l=a.oneof(o.arbitrary.map(p=>kn(p)),u.arbitrary.map(p=>jt(p)));return Qu(a,c,f,l)},toEquivalence:([o,s,i])=>{let a=wB(s,i);return(c,u)=>{if(c._tag!==u._tag)return!1;switch(c._tag){case"Success":return o(c.value,u.value);case"Failure":return a(c.cause,u.cause)}}},toFormatter:([o,s,i])=>{let a=IB(s,i);return c=>{switch(c._tag){case"Success":return`Exit.Success(${o(c.value)})`;case"Failure":return`Exit.Failure(${a(c.cause)})`}}}});return re(r.ast,{value:e,error:t,defect:n})}var hQ=_r("effect/schema/Exit",tt,({annotations:e,typeParameters:t})=>{let n=pS(t[0],t[1],t[2]);return e===void 0?n:n.annotate(e)});function CB(e,t,n){return t===void 0?n:n===void 0?t:e.oneof(t,n)}function Qu(e,t,n,r){return{arbitrary:n===void 0||t.recursion===void 0?r:e.oneof(t.recursion,n,r),terminal:n}}function eL(e,t,n,r){return r===void 0?e.array(t,n):e.uniqueArray(t,{...n,comparator:r})}function mS(e,t,n,r,o,s){let i=t.constraint,a=i===void 0||i.minLength===void 0&&i.maxLength===void 0?void 0:{...i.minLength!==void 0?{minLength:i.minLength}:{},...i.maxLength!==void 0?{maxLength:i.maxLength}:{}};if(a?.minLength!==void 0&&a.maxLength!==void 0&&a.minLength>a.maxLength)throw new globalThis.Error("Unable to derive an arbitrary for size constraints");let c=a?.minLength??0,u=c===0?e.constant([]):r===void 0?void 0:eL(e,r,{...a,maxLength:c},s),f=Qu(e,t,u,eL(e,n,a,s));return{arbitrary:f.arbitrary.map(o),terminal:f.terminal?.map(o)}}function AB(e,t,n,r,o){return mS(e,t,e.tuple(n.arbitrary,r.arbitrary),n.terminal===void 0||r.terminal===void 0?void 0:e.tuple(n.terminal,r.terminal),o,([s],[i])=>ae(s,i))}function RB(e,t){let n=An()([e,t],([r,o])=>{let s=Wt(Ec([r,o]));return(i,a,c)=>i instanceof globalThis.Map?fn(dt(s)([...i],c),{onSuccess:u=>new globalThis.Map(u),onFailure:u=>Yn(a,"entries",u,i,c)}):G(new st(a,i,c))},{representation:{id:"effect/schema/ReadonlyMap",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.ReadonlyMap(${r[0].runtime}, ${r[1].runtime})`,Type:`globalThis.ReadonlyMap<${r[0].Type}, ${r[1].Type}>`}),expected:"ReadonlyMap",toCodec:([r,o])=>pt()(Wt(Ec([r,o])),vt({decode:s=>new globalThis.Map(s),encode:s=>[...s.entries()]})),toArbitrary:([r,o])=>(s,i)=>AB(s,i,r,o,a=>new globalThis.Map(a)),toEquivalence:([r,o])=>wh(r,o),toFormatter:([r,o])=>s=>{let i=s.size;if(i===0)return"ReadonlyMap(0) {}";let a=globalThis.Array.from(s.entries()).sort().map(([c,u])=>`${r(c)} => ${o(u)}`);return`ReadonlyMap(${i}) { ${a.join(", ")} }`}});return re(n.ast,{key:e,value:t})}var gQ=_r("effect/schema/ReadonlyMap",tt,({annotations:e,typeParameters:t})=>{let n=RB(t[0],t[1]);return e===void 0?n:n.annotate(e)});function tL(e,t,n){return oe({type:Rt(e),nodes:Wt(oe({index:tr,data:t})),edges:Wt(oe({index:tr,source:tr,target:tr,data:n}))})}function nL(e,t){let n=-1,r=new Set;for(let o=0;o<e.nodes.length;o++){let s=e.nodes[o].index;if(s<=n)return G(new Ct(["nodes",o,"index"],new ke({expected:"a strictly increasing node index"},s,t)));n=s,r.add(s)}n=-1;for(let o=0;o<e.edges.length;o++){let s=e.edges[o];if(s.index<=n)return G(new Ct(["edges",o,"index"],new ke({expected:"a strictly increasing edge index"},s.index,t)));if(n=s.index,!r.has(s.source))return G(new Ct(["edges",o,"source"],new ke({expected:"an encoded node index"},s.source,t)));if(!r.has(s.target))return G(new Ct(["edges",o,"target"],new ke({expected:"an encoded node index"},s.target,t)))}return v(Xp(e))}function xQ(e,t,n){return!Xv(e)||e.mutable||e.type!==t?G(new ke({expected:`an immutable ${t} Graph`},e,n)):v(Yp(e))}function yQ(e,t){return(n,r)=>{let o=Yp(n),s=Yp(r);if(o.type!==s.type||o.nodes.length!==s.nodes.length||o.edges.length!==s.edges.length)return!1;for(let i=0;i<o.nodes.length;i++)if(o.nodes[i].index!==s.nodes[i].index||!e(o.nodes[i].data,s.nodes[i].data))return!1;for(let i=0;i<o.edges.length;i++){let a=o.edges[i],c=s.edges[i],u=o.type==="directed"?a.source===c.source&&a.target===c.target:a.source===c.source&&a.target===c.target||a.source===c.target&&a.target===c.source;if(a.index!==c.index||!u||!t(a.data,c.data))return!1}return!0}}function SQ(e,t,n){return(r,o)=>{let s=Xp({type:e,nodes:[],edges:[]}),i=r.constant(s),a=r.array(t.arbitrary).chain(c=>{let u=c.map((l,p)=>({index:p,data:l}));if(u.length===0)return i;let f=r.integer({min:0,max:u.length-1});return r.array(r.tuple(f,f,n.arbitrary)).map(l=>Xp({type:e,nodes:u,edges:l.map(([p,m,h],g)=>({index:g,source:p,target:m,data:h}))}))});return Qu(r,o,i,a)}}function OB(e,t,n){let r=An()([t,n],([o,s])=>{let i=tL(e,o,s);return(a,c,u)=>!Xv(a)||a.mutable||a.type!==e?G(new st(c,a,u)):R(dt(i)(Yp(a),u),f=>nL(f,u))},{representation:{id:"effect/schema/Graph",payload:e},toCode:({typeParameters:o})=>({runtime:`Schema.Graph(${X(e)}, ${o[0].runtime}, ${o[1].runtime})`,Type:`Graph.Graph<${o[0].Type}, ${o[1].Type}, ${X(e)}>`,importDeclarations:['import * as Graph from "effect/Graph"']}),expected:`an immutable ${e} Graph`,toCodec:([o,s])=>pt()(tL(e,o,s),Ar({decode:nL,encode:(i,a)=>xQ(i,e,a)})),toArbitrary:([o,s])=>SQ(e,o,s),toEquivalence:([o,s])=>yQ(o,s),toFormatter:()=>globalThis.String});return re(r.ast,{type:e,node:t,edge:n})}var bQ=_r("effect/schema/Graph",ka(["directed","undirected"]),({annotations:e,payload:t,typeParameters:n})=>{let r=OB(t,n[0],n[1]);return e===void 0?r:r.annotate(e)});function _B(e,t){let n=An()([e,t],([r,o])=>{let s=Wt(Ec([r,o]));return(i,a,c)=>jy(i)?fn(dt(s)($y(i),c),{onSuccess:qy,onFailure:u=>Yn(a,"entries",u,i,c)}):G(new st(a,i,c))},{representation:{id:"effect/schema/HashMap",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.HashMap(${r[0].runtime}, ${r[1].runtime})`,Type:`HashMap.HashMap<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as HashMap from "effect/HashMap"']}),expected:"HashMap",toCodec:([r,o])=>pt()(Wt(Ec([r,o])),vt({decode:qy,encode:$y})),toArbitrary:([r,o])=>(s,i)=>AB(s,i,r,o,qy),toEquivalence:([r,o])=>wh(r,o),toFormatter:([r,o])=>s=>{let i=TN(s);if(i===0)return"HashMap(0) {}";let a=$y(s).sort().map(([c,u])=>`${r(c)} => ${o(u)}`);return`HashMap(${i}) { ${a.join(", ")} }`}});return re(n.ast,{key:e,value:t})}var EQ=_r("effect/schema/HashMap",tt,({annotations:e,typeParameters:t})=>{let n=_B(t[0],t[1]);return e===void 0?n:n.annotate(e)});function MB(e){let t=An()([e],([n])=>{let r=Wt(n);return(o,s,i)=>o instanceof globalThis.Set?fn(dt(r)([...o],i),{onSuccess:a=>new globalThis.Set(a),onFailure:a=>Yn(s,"values",a,o,i)}):G(new st(s,o,i))},{representation:{id:"effect/schema/ReadonlySet",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.ReadonlySet(${n[0].runtime})`,Type:`globalThis.ReadonlySet<${n[0].Type}>`}),expected:"ReadonlySet",toCodec:([n])=>pt()(Wt(n),vt({decode:r=>new globalThis.Set(r),encode:r=>[...r.values()]})),toArbitrary:([n])=>(r,o)=>mS(r,o,n.arbitrary,n.terminal,s=>new globalThis.Set(s),ae),toEquivalence:([n])=>Ih(n),toFormatter:([n])=>r=>{let o=r.size;if(o===0)return"ReadonlySet(0) {}";let s=globalThis.Array.from(r.values()).sort().map(i=>`${n(i)}`);return`ReadonlySet(${o}) { ${s.join(", ")} }`}});return re(t.ast,{value:e})}var wQ=_r("effect/schema/ReadonlySet",tt,({annotations:e,typeParameters:t})=>{let n=MB(t[0]);return e===void 0?n:n.annotate(e)});function PB(e){let t=An()([e],([n])=>{let r=Wt(n);return(o,s,i)=>Wy(o)?fn(dt(r)(ht(o),i),{onSuccess:Hy,onFailure:a=>Yn(s,"values",a,o,i)}):G(new st(s,o,i))},{representation:{id:"effect/schema/HashSet",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.HashSet(${n[0].runtime})`,Type:`HashSet.HashSet<${n[0].Type}>`}),expected:"HashSet",toCodec:([n])=>pt()(Wt(n),vt({decode:Hy,encode:ht})),toArbitrary:([n])=>(r,o)=>mS(r,o,n.arbitrary,n.terminal,Hy,ae),toEquivalence:([n])=>Ih(n),toFormatter:([n])=>r=>{let o=RN(r);if(o===0)return"HashSet(0) {}";let s=globalThis.Array.from(r).sort().map(i=>`${n(i)}`);return`HashSet(${o}) { ${s.join(", ")} }`}});return re(t.ast,{value:e})}var IQ=_r("effect/schema/HashSet",tt,({annotations:e,typeParameters:t})=>{let n=PB(t[0]);return e===void 0?n:n.annotate(e)});function FB(e){let t=An()([e],([n])=>{let r=Wt(n);return(o,s,i)=>Il(o)?fn(dt(r)(ht(o),i),{onSuccess:sy,onFailure:a=>Yn(s,"values",a,o,i)}):G(new st(s,o,i))},{representation:{id:"effect/schema/Chunk",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Chunk(${n[0].runtime})`,Type:`Chunk.Chunk<${n[0].Type}>`}),expected:"Chunk",toCodec:([n])=>pt()(Wt(n),vt({decode:sy,encode:ht})),toArbitrary:([n])=>(r,o)=>mS(r,o,n.arbitrary,n.terminal,sy),toEquivalence:([n])=>uv(n),toFormatter:([n])=>r=>{let o=$1(r);if(o===0)return"Chunk(0) {}";let s=globalThis.Array.from(r).sort().map(i=>`${n(i)}`);return`Chunk(${o}) { ${s.join(", ")} }`}});return re(t.ast,{value:e})}var vQ=_r("effect/schema/Chunk",tt,({annotations:e,typeParameters:t})=>{let n=FB(t[0]);return e===void 0?n:n.annotate(e)}),UB=kc(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},toCode:()=>({runtime:"Schema.RegExp",Type:"globalThis.RegExp"}),expected:"RegExp",toCodecJson:()=>pt()(oe({source:fe,flags:fe}),Ar({decode:(e,t)=>Bo({try:()=>new globalThis.RegExp(e.source,e.flags),catch:()=>new ke({expected:"valid RegExp source and flags"},e,t)}),encode:e=>v({source:e.source,flags:e.flags})})),toArbitrary:()=>e=>e.tuple(e.constantFrom(".",".*","\\d+","\\w+","[a-z]+","[A-Z]+","[0-9]+","^[a-zA-Z0-9]+$","^\\d{4}-\\d{2}-\\d{2}$"),e.uniqueArray(e.constantFrom("g","i","m","s","u","y"),{minLength:0,maxLength:6}).map(t=>t.join(""))).map(([t,n])=>new globalThis.RegExp(t,n)),toEquivalence:()=>(e,t)=>e.source===t.source&&e.flags===t.flags}),TQ=pr("effect/schema/RegExp",UB),DB=fe.annotate({expected:"a string that will be decoded as a URL"}),YT=kc(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},toCode:()=>({runtime:"Schema.URL",Type:"globalThis.URL"}),expected:"URL",toCodecJson:()=>pt()(DB,gI),toArbitrary:()=>e=>e.webUrl().map(t=>new globalThis.URL(t)),toEquivalence:()=>(e,t)=>e.toString()===t.toString()}),kQ=pr("effect/schema/URL",YT),CQ=DB.pipe(be(YT,gI));function XT(e,t,n){let r={...t};if(e?.minimum!==void 0){let o=n===void 0?e.minimum:n(e.minimum),s=e.exclusiveMinimum?new globalThis.Date(o.getTime()+1):o;(r.min===void 0||s.getTime()>r.min.getTime())&&(r.min=s)}if(e?.maximum!==void 0){let o=n===void 0?e.maximum:n(e.maximum),s=e.exclusiveMaximum?new globalThis.Date(o.getTime()-1):o;(r.max===void 0||s.getTime()<r.max.getTime())&&(r.max=s)}return r}var NB=fe.annotate({expected:"a string that will be decoded as a Date"}),qs=no(e=>e instanceof globalThis.Date&&!globalThis.Number.isNaN(e.getTime()),{representation:{id:"effect/schema/Date",payload:null},toCode:()=>({runtime:"Schema.Date",Type:"globalThis.Date"}),expected:"a valid Date",toCodecJson:()=>pt()(NB,hI),toArbitrary:()=>(e,t)=>e.date(XT(t?.constraint?.ordered?.order===Qc?t.constraint.ordered:void 0,{noInvalidDate:!0}))}),AQ=pr("effect/schema/Date",qs),RQ=NB.pipe(be(qs,hI)),OQ=$s.pipe(be(qs,CU)),Tm=no(nu,{representation:{id:"effect/schema/Duration",payload:null},toCode:()=>({runtime:"Schema.Duration",Type:"Duration.Duration",importDeclarations:['import * as Duration from "effect/Duration"']}),expected:"Duration",toCodecJson:()=>pt()(He([oe({_tag:Rt("Infinity")}),oe({_tag:Rt("NegativeInfinity")}),oe({_tag:Rt("Nanos"),value:Ti}),oe({_tag:Rt("Millis"),value:$s})]),vt({decode:e=>{switch(e._tag){case"Infinity":return po;case"NegativeInfinity":return Zi;case"Nanos":return Lr(e.value);case"Millis":return us(e.value)}},encode:e=>{switch(e.value._tag){case"Infinity":return{_tag:"Infinity"};case"NegativeInfinity":return{_tag:"NegativeInfinity"};case"Nanos":return{_tag:"Nanos",value:e.value.nanos};case"Millis":return{_tag:"Millis",value:e.value.millis}}}})),toArbitrary:()=>e=>e.oneof(e.constant(po),e.constant(Zi),e.bigInt().map(Lr),e.maxSafeInteger().map(us)),toFormatter:()=>globalThis.String,toEquivalence:()=>PE}),_Q=pr("effect/schema/Duration",Tm),MQ=fe.annotate({expected:"a string that will be decoded as a Duration"}),PQ=MQ.pipe(be(Tm,AU)),FQ=Ti.pipe(be(Tm,RU)),UQ=Vl.pipe(be(Tm,OU)),LB=fe.annotate({expected:"a string that will be decoded as a BigDecimal"}),BB=20,jB="Unable to derive an arbitrary for the ordered BigDecimal constraints";function iS(e,t){return Ha(e,t).value}function DQ(e,t,n){return n?iS(IE(e,t),t)+globalThis.BigInt(1):iS(wE(e,t),t)}function NQ(e,t,n){return n?iS(wE(e,t),t)-globalThis.BigInt(1):iS(IE(e,t),t)}function LQ(e){return Math.max(BB,e.minimum?.scale??0,e.maximum?.scale??0,e.exclusiveMinimum&&e.minimum!==void 0?e.minimum.scale+1:0,e.exclusiveMaximum&&e.maximum!==void 0?e.maximum.scale+1:0)}function PT(e,t){let n={};if(e.minimum!==void 0&&(n.min=DQ(e.minimum,t,e.exclusiveMinimum===!0)),e.maximum!==void 0&&(n.max=NQ(e.maximum,t,e.exclusiveMaximum===!0)),!(n.min!==void 0&&n.max!==void 0&&n.min>n.max))return n}function BQ(e){let t=LQ(e);if(PT(e,t)===void 0)throw new globalThis.Error(jB);let n=0,r=t;for(;n<r;){let o=n+Math.floor((r-n)/2);PT(e,o)===void 0?n=o+1:r=o}return{min:n,max:t}}var ek=no(Wa,{representation:{id:"effect/schema/BigDecimal",payload:null},toCode:()=>({runtime:"Schema.BigDecimal",Type:"BigDecimal.BigDecimal",importDeclarations:['import * as BigDecimal from "effect/BigDecimal"']}),expected:"BigDecimal",toCodecJson:()=>pt()(LB,xI),toArbitrary:()=>(e,t)=>{let n=t.constraint?.ordered?.order===Ki?t.constraint.ordered:void 0;return n===void 0?e.tuple(e.bigInt(),e.integer({min:0,max:BB})).map(([r,o])=>sr(r,o)):e.integer(BQ(n)).chain(r=>{let o=PT(n,r);if(o===void 0)throw new globalThis.Error(jB);return e.bigInt(o).map(s=>sr(s,r))})},toFormatter:()=>e=>Xs(e),toEquivalence:()=>bE}),jQ=pr("effect/schema/BigDecimal",ek),qQ=LB.pipe(be(ek,xI)),$Q=fe.annotate({expected:"a string that will be decoded as JSON",contentMediaType:"application/json"});function qB(e,t){return $Q.pipe(be(e,WU(t)))}var zQ=qB(LT),tk=kc(globalThis.File,{representation:{id:"effect/schema/File",payload:null},toCode:()=>({runtime:"Schema.File",Type:"globalThis.File"}),expected:"File",toCodecJson:()=>pt()(oe({data:fe.check(KT()),type:fe,name:fe,lastModified:$s}),Ar({decode:(e,t)=>_o(Cf(e.data),{onFailure:()=>G(new ke({expected:"a valid Base64 string"},e.data,t)),onSuccess:n=>{let r=new globalThis.Uint8Array(n);return v(new globalThis.File([r],e.name,{type:e.type,lastModified:e.lastModified}))}}),encode:(e,t)=>bs({try:async()=>{let n=new globalThis.Uint8Array(await e.arrayBuffer());return{data:ng(n),type:e.type,name:e.name,lastModified:e.lastModified}},catch:()=>new ke({expected:"a readable File"},e,t)})}))}),HQ=pr("effect/schema/File",tk),nk=kc(globalThis.FormData,{representation:{id:"effect/schema/FormData",payload:null},toCode:()=>({runtime:"Schema.FormData",Type:"globalThis.FormData"}),expected:"FormData",toCodecJson:()=>pt()(Wt(Ec([fe,He([oe({_tag:Ze("String"),value:fe}),oe({_tag:Ze("File"),value:tk})])])),Ar({decode:e=>{let t=new globalThis.FormData;for(let[n,r]of e)t.append(n,r.value);return v(t)},encode:e=>v(globalThis.Array.from(e.entries()).map(([t,n])=>typeof n=="string"?[t,{_tag:"String",value:n}]:[t,{_tag:"File",value:n}]))}))}),WQ=pr("effect/schema/FormData",nk);function KQ(e){return nk.pipe(be(e,KU))}var rk=kc(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},toCode:()=>({runtime:"Schema.URLSearchParams",Type:"globalThis.URLSearchParams"}),expected:"URLSearchParams",toCodecJson:()=>pt()(fe.annotate({expected:"a query string that will be decoded as URLSearchParams"}),vt({decode:e=>new globalThis.URLSearchParams(e),encode:e=>e.toString()}))}),VQ=pr("effect/schema/URLSearchParams",rk);function JQ(e){return rk.pipe(be(e,VU))}var GQ=fe.annotate({expected:"a string that will be decoded as a number"}).pipe(be(Vl,ml)),ZQ=fe.annotate({expected:"a string that will be decoded as a finite number"}).pipe(be(js,ml)),QQ=re(rv).pipe(be(Ti,Bx)),$B=fe.check(WT()),YQ=fe.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(be($B,kU())),XQ=fe.annotate({expected:"a base64 encoded string that will be decoded as a UTF-8 string"}).pipe(be(fe,qU)),e7=fe.annotate({expected:"a base64 (URL) encoded string that will be decoded as a UTF-8 string"}).pipe(be(fe,$U)),t7=fe.annotate({expected:"a hex encoded string that will be decoded as a UTF-8 string"}).pipe(be(fe,zU)),n7=fe.annotate({expected:"a URI component encoded string that will be decoded as a UTF-8 string"}).pipe(be(fe,HU)),FT=He([js,yL,fe]),r7=oe({issues:Wt(oe({message:fe,path:Pt(Wt(He([FT,oe({key:FT})])))}))}),o7=ka([0,1]).pipe(be(vc,vt({decode:e=>e===1,encode:e=>e?1:0}))),zB=fe.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),Go=kc(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},toCode:()=>({runtime:"Schema.Uint8Array",Type:"globalThis.Uint8Array"}),expected:"Uint8Array",toCodecJson:()=>pt()(zB,yI),toArbitrary:()=>e=>e.uint8Array()}),s7=pr("effect/schema/Uint8Array",Go),i7=zB.pipe(be(Go,yI)),a7=fe.annotate({expected:"a base64 (URL) encoded string that will be decoded as a Uint8Array"}).pipe(be(Go,{decode:mU(),encode:Fx()})),c7=fe.annotate({expected:"a hex encoded string that will be decoded as a Uint8Array"}).pipe(be(Go,{decode:gU(),encode:Ux()})),km=no(e=>Au(e)&&QF(e),{representation:{id:"effect/schema/DateTimeUtc",payload:null},toCode:()=>({runtime:"Schema.DateTimeUtc",Type:"DateTime.Utc",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Utc",toCodecJson:()=>pt()(fe,EI),toArbitrary:()=>(e,t)=>e.date(XT(t?.constraint?.ordered?.order===aI?t.constraint.ordered:void 0,{noInvalidDate:!0},Ox)).map(n=>XF(n)),toFormatter:()=>e=>e.toString(),toEquivalence:()=>iI}),u7=pr("effect/schema/DateTimeUtc",km),f7=qs.pipe(be(km,{decode:mI(),encode:De(Ox)})),l7=fe.annotate({expected:"a string that will be decoded as a DateTime.Utc"}).pipe(be(km,EI)),d7=$s.pipe(be(km,{decode:mI(),encode:De(oU)})),HB=no(GF,{representation:{id:"effect/schema/TimeZoneOffset",payload:null},toCode:()=>({runtime:"Schema.TimeZoneOffset",Type:"DateTime.TimeZone.Offset",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Offset",toCodecJson:()=>pt()($s,JU),toArbitrary:()=>e=>e.integer({min:-720*60*1e3,max:840*60*1e3}).map(t=>wp(t)),toFormatter:()=>e=>uc(e),toEquivalence:()=>(e,t)=>e.offset===t.offset}),p7=pr("effect/schema/TimeZoneOffset",HB),WB=fe.annotate({expected:"an IANA time zone identifier"}),ok=no(ZF,{representation:{id:"effect/schema/TimeZoneNamed",payload:null},toCode:()=>({runtime:"Schema.TimeZoneNamed",Type:"DateTime.TimeZone.Named",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Named",toCodecJson:()=>pt()(WB,SI),toArbitrary:()=>e=>e.constantFrom(...["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"].map(cI)),toFormatter:()=>e=>uc(e),toEquivalence:()=>(e,t)=>e.id===t.id}),m7=pr("effect/schema/TimeZoneNamed",ok),h7=WB.pipe(be(ok,SI)),KB=fe.annotate({expected:"a time zone string (IANA identifier or offset like +03:00)"}),sk=no(JF,{representation:{id:"effect/schema/TimeZone",payload:null},toCode:()=>({runtime:"Schema.TimeZone",Type:"DateTime.TimeZone",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone",toCodecJson:()=>pt()(KB,bI),toArbitrary:()=>e=>e.oneof(e.integer({min:-720*60*1e3,max:840*60*1e3}).map(t=>wp(t)),e.constantFrom(...["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"].map(cI))),toFormatter:()=>e=>uc(e),toEquivalence:()=>(e,t)=>uc(e)===uc(t)}),g7=pr("effect/schema/TimeZone",sk),x7=KB.pipe(be(sk,bI)),VB=fe.annotate({expected:"a zoned DateTime string (e.g. 2024-01-01T00:00:00.000+00:00[Europe/London])"}),ik=no(e=>Au(e)&&YF(e),{representation:{id:"effect/schema/DateTimeZoned",payload:null},toCode:()=>({runtime:"Schema.DateTimeZoned",Type:"DateTime.Zoned",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Zoned",toCodecJson:()=>pt()(VB,wI),toArbitrary:()=>(e,t)=>e.tuple(e.date(XT(t?.constraint?.ordered?.order===aI?t.constraint.ordered:void 0,{max:new globalThis.Date(864e13-840*60*1e3),min:new globalThis.Date(-864e13+840*60*1e3),noInvalidDate:!0},Ox)),e.constantFrom("UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney")).map(([n,r])=>Cx(n,{timeZone:r})),toFormatter:()=>e=>_x(e),toEquivalence:()=>iI}),y7=pr("effect/schema/DateTimeZoned",ik),S7=VB.pipe(be(ik,wI)),b7=globalThis.Symbol.for("immer-draftable"),UT={};function ak(e,t,n,r,o){let s=w7(n,t,r),i=JB(t),a=class extends e{constructor(...[c,u]){let l=u?.["~payload"],p=l?.token===UT?l.value:n.make(c??{},u);super(p,{...u,disableChecks:!0,"~payload":{token:UT,value:p}})}static[mm]=mm;get[i](){return i}static[b7]=!0;static identifier=t;static fields=n.fields;static get ast(){return s(this).ast}static pipe(){return ie(this,arguments)}static rebuild(c){return s(this).rebuild(c)}static make(c,u){return new this(c,u)}static makeOption(c,u){return Vy(s(this))(c??{},u)}static makeEffect(c,u){return s(this).makeEffect(c??{},u)}static annotate(c){return this.rebuild(Ho(this.ast,c))}static annotateKey(c){return this.rebuild(bl(this.ast,c))}static check(...c){return this.rebuild(Si(this.ast,c))}static extend(c){return(u,f)=>{let l=Cm(u)?u:oe(u),p={...n.fields,...l.fields},m=Vx(p,n.ast.checks,{identifier:c});return ak(this,c,jT(Si(m,l.ast.checks),p),f,o)}}static mapFields(c,u){return n.mapFields(c,u)}};return o!==void 0&&Object.assign(a.prototype,o(t)),a}function E7(e){return new et(De(t=>new e(t,{"~payload":{token:UT,value:t}})),Ts())}function JB(e){return`~effect/Schema/Class/${e}`}function w7(e,t,n){let r;return o=>{if(r!==void 0)return r;let s=JB(t),i=u=>u instanceof o||j(u,s),a=E7(o),c=re(new pa([e.ast],()=>(u,f,l)=>i(u)?v(u):G(new st(f,u,l)),{identifier:t,[bx]:([u])=>({isConstructed:i,link:new Dt(u,a)}),toCodec:([u])=>new Dt(u.ast,a),toArbitrary:([u])=>()=>({arbitrary:u.arbitrary.map(f=>new o(f)),terminal:u.terminal?.map(f=>new o(f))}),toFormatter:([u])=>f=>`${o.identifier}(${u(f)})`,[xp]:lc(e.ast),...n}));return r=be(c,a)(e)}}function Cm(e){return Gu(e)}var hS=e=>(t,n)=>{let r=Cm(t)?t:oe(t);return ak(pO,e,r,n,o=>({toString(){return`${o}(${X({...this})})`}}))},I7=e=>(t,n,r)=>{let o=Cm(n)?n.mapFields(s=>({_tag:Ze(t),...s}),{unsafePreserveChecks:!0}):Tc(t,n);return hS(e??t)(o,r)},$n=e=>(t,n)=>{let r=Cm(t)?t:oe(t);return ak(kd,e,r,n,s=>({name:s}))},ck=e=>(t,n,r)=>{let o=Cm(n)?n.mapFields(s=>({_tag:Ze(t),...s}),{unsafePreserveChecks:!0}):Tc(t,n);return $n(e??t)(o,r)};function v7(e){let t=h2(e.ast);return n=>t(n,{})}function T7(e){return t=>t.annotate({toFormatter:e})}function k7(e,t){return n(e.ast);function n(o){let s=gi(o)?.toFormatter;if(typeof s=="function")return s(pc(o)?o.typeParameters.map(n):[]);if(t?.onBefore){let i=t.onBefore(o,n);if(i!==void 0)return i}return r(o)}function r(o){switch(o._tag){default:return X;case"Never":return()=>"never";case"Void":return()=>"void";case"Arrays":{let s=o.elements.map(n),i=o.rest.map(n);return a=>{let c=[],u=0;for(;u<s.length;u++)if(a.length<u+1){if(an(o.elements[u]))continue}else c.push(s[u](a[u]));if(i.length>0){let[f,...l]=i;for(;u<a.length-l.length;u++)c.push(f(a[u]));for(let p=0;p<l.length;p++)c.push(l[p](a[u+p]))}return"["+c.join(", ")+"]"}}case"Objects":{let s=o.propertySignatures.map(a=>n(a.type)),i=o.indexSignatures.map(a=>n(a.type));return o.propertySignatures.length===0&&o.indexSignatures.length===0?X:a=>{let c=[],u=new Set;for(let f=0;f<s.length;f++){let l=o.propertySignatures[f],p=l.name;u.add(p),!(an(l.type)&&!Object.hasOwn(a,p))&&c.push(`${qi(p)}: ${s[f](a[p])}`)}for(let f=0;f<i.length;f++){let l=ha(a,o.indexSignatures[f].parameter);for(let p of l)u.has(p)||(u.add(p),c.push(`${qi(p)}: ${i[f](a[p])}`))}return c.length>0?"{ "+c.join(", ")+" }":"{}"}}case"Union":{let s=yn(o).types,i=c=>Mp(c,s),a=new Map(s.map((c,u)=>[c,[sm(c),n(o.types[u])]]));return c=>{let u=i(c);for(let f=0;f<u.length;f++){let[l,p]=a.get(u[f]);if(l(c))return p(c)}return X(c)}}case"Suspend":{let s=_u(()=>n(o.thunk()));return i=>s()(i)}}}}function C7(e){return t=>t.annotate({toEquivalence:e})}function A7(e){return g2(e.ast)}function R7(e,t){return kT(e.ast,t)}function GB(e,t){let n=kT(gS(e.ast),t);return _2(n,t)}function Cc(e){return re(gS(e.ast),{schema:e})}var gS=ga(e=>{let t=_7(e,gS),n=e.context;return t===e||n===void 0?t:Sl(t,uk(n))});function uk(e){return e.constructorDefault===void 0?e:new Yr(e.isOptional,e.isMutable,void 0,e.annotations)}function ZB(e){if(e.propertySignatures.some(t=>typeof t.name!="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function QB(e){return t=>{let n=new Map;for(let s=0;s<t.length;s++)n.set(jn(t[s]),s);let r=[...t].sort((s,i)=>{s=jn(s),i=jn(i);let a=e(s),c=e(i);return a!==c?a-c:n.get(s)-n.get(i)});return r.some((s,i)=>s!==t[i])?r:t}}var O7=QB(e=>{switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function _7(e,t){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!cn(n))return lt(e,[sv]);let r=e.typeParameters.map(s=>am(jn(s))),o=n(r);return o===void 0?e:lt(e,[mc(o,t)])}case"Unknown":return lt(e,[sv]);case"ObjectKeyword":return lt(e,[D1]);case"Undefined":case"Void":case"Literal":case"Number":return e.toCodecJson();case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return ZB(e),e.recur(t,ny);case"Union":{let n=O7(e.types);return n!==e.types?new Rr(n,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t):e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}function YB(e){return re(XB(yn(e.ast)))}var XB=wn(e=>{let t=M7(e,XB);return t!==e&&e.context!==void 0?Sl(t,uk(e.context)):t});function M7(e,t){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecIso??e.annotations?.toCodec;if(cn(n)){let r=n(e.typeParameters.map(o=>am(o)));return lt(e,[mc(r,t)])}return e}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(t)}return e}function ej(e){return re(rj(e.ast),{schema:e})}function P7(e){return re(oj(e.ast))}function F7(e,t){let n=ul(e.ast)??eI(e.ast),r=cS(ej(e));return o=>r(o).pipe(Y(s=>U7(s,{rootName:n,...t})))}function U7(e,t){let n=t.rootName??"root",r=t.arrayItemName??"item",o=t.pretty??!0,s=t.indent??" ",i=t.sortKeys??!0,a=new Set,c=[];return f(n,e,0),c.join(o?`
|
|
31
|
+
`:"");function u(l,p){c.push(o?s.repeat(l)+p:p)}function f(l,p,m,h){let{attrs:g,safe:x}=jl.tagInfo(l,h);if(p===void 0)u(m,`<${x}${g}/>`);else if(typeof p=="string")u(m,`<${x}${g}>${jl.escapeText(p)}</${x}>`);else if(typeof p!="object"||p===null)u(m,`<${x}${g}>${jl.escapeText(X(p))}</${x}>`);else{if(a.has(p))throw new globalThis.Error("Cycle detected while serializing to XML.",{cause:p});a.add(p);try{if(globalThis.globalThis.Array.isArray(p)){if(p.length===0){u(m,`<${x}${g}/>`);return}u(m,`<${x}${g}>`);for(let y of p)f(r,y,m+1);u(m,`</${x}>`);return}let E=p,b=Object.keys(E);if(i&&b.sort(),b.length===0){u(m,`<${x}${g}/>`);return}u(m,`<${x}${g}>`);for(let y of b)f(jl.parseTagName(y).safe,E[y],m+1,y);u(m,`</${x}>`)}finally{a.delete(p)}}}}var jl={escapeText(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")},escapeAttribute(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")},parseTagName(e){let t=e,n=e;return/^[A-Za-z_]/.test(n)||(n="_"+n),n=n.replace(/[^A-Za-z0-9._-]/g,"_"),/^xml/i.test(n)&&(n="_"+n),{safe:n,changed:n!==t}},tagInfo(e,t){let{changed:n,safe:r}=jl.parseTagName(e),s=n||t&&t!==e?` data-name="${jl.escapeAttribute(t??e)}"`:"";return{safe:r,attrs:s}}},D7=QB(e=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function N7(e,t,n){switch(e._tag){case"Declaration":{let r=e.typeParameters.map(u=>re(t(jn(u)))),o=e.annotations?.toCodecStringTree;if(cn(o)){let u=o(r);return u===void 0?e:lt(e,[mc(u,t)])}let s=e.annotations?.toCodecJson,i=cn(s)?s(r):void 0,a=i===void 0?e.annotations?.toCodec:void 0,c=i??(cn(a)?a(r):void 0);return c===void 0?n(e):lt(e,[mc(c,t)])}case"Null":return lt(e,[L7]);case"Boolean":return lt(e,[B7]);case"Unknown":case"ObjectKeyword":return lt(e,[iv]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return ZB(e),e.recur(t,ny);case"Union":{let r=D7(e.types);return r!==e.types?new Rr(r,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t):e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}var L7=new Dt(new Qr("null"),new et(De(()=>null),De(()=>"null"))),B7=new Dt(new Rr([new Qr("true"),new Qr("false")],"anyOf"),new et(De(e=>e==="true"),Ru())),tj=new et(De(e=>typeof e=="string"?[e]:e),Ts()),nj=e=>e.transformation===tj,rj=ga(e=>{let t=N7(e,rj,n=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:n})});return t!==e&&e.context!==void 0?Sl(t,uk(e.context)):t},{stopAt:nj}),rL=e=>an(e)?El(ma):ma,oj=ga(e=>{let t=j7(e);if($I(t)){let n=ey(new Rr([new Cs(t.isMutable,t.elements.map(rL),t.rest.map(rL)),yi],"anyOf"),t,tj);return an(e)?El(n):n}return t},{stopAt:nj});function j7(e){return e._tag==="Declaration"||e._tag==="Arrays"||e._tag==="Objects"||e._tag==="Union"||e._tag==="Suspend"?e.recur(oj):e}var q7=Re("effect/schema/isGreaterThanDate",oe({exclusiveMinimum:qs}),({annotations:e,payload:t})=>YL(t.exclusiveMinimum,e)),$7=Re("effect/schema/isGreaterThanOrEqualToDate",oe({minimum:qs}),({annotations:e,payload:t})=>XL(t.minimum,e)),z7=Re("effect/schema/isLessThanDate",oe({exclusiveMaximum:qs}),({annotations:e,payload:t})=>eB(t.exclusiveMaximum,e)),H7=Re("effect/schema/isLessThanOrEqualToDate",oe({maximum:qs}),({annotations:e,payload:t})=>tB(t.maximum,e)),W7=Re("effect/schema/isBetweenDate",oe({minimum:qs,maximum:qs,exclusiveMinimum:Pt(Rt(!0)),exclusiveMaximum:Pt(Rt(!0))}),({annotations:e,payload:t})=>nB(t,e)),K7=Re("effect/schema/isGreaterThanBigInt",oe({exclusiveMinimum:Ti}),({annotations:e,payload:t})=>rB(t.exclusiveMinimum,e)),V7=Re("effect/schema/isGreaterThanOrEqualToBigInt",oe({minimum:Ti}),({annotations:e,payload:t})=>oB(t.minimum,e)),J7=Re("effect/schema/isLessThanBigInt",oe({exclusiveMaximum:Ti}),({annotations:e,payload:t})=>sB(t.exclusiveMaximum,e)),G7=Re("effect/schema/isLessThanOrEqualToBigInt",oe({maximum:Ti}),({annotations:e,payload:t})=>iB(t.maximum,e)),Z7=Re("effect/schema/isBetweenBigInt",oe({minimum:Ti,maximum:Ti,exclusiveMinimum:Pt(Rt(!0)),exclusiveMaximum:Pt(Rt(!0))}),({annotations:e,payload:t})=>aB(t,e));function Q7(e){let t=YB(e);return B2(gT(t),mT(t))}function Y7(e){return rS()}function X7(e){return rS()}function e9(e,t){return n=>re(Ho(n.ast,{toCodecIso:()=>new Dt(e.ast,Nx(t))}),{schema:n})}function t9(e){let t=Cc(e),n=gT(t),r=mT(t);return{empty:[],diff:(o,s)=>P2(n(o),n(s)),combine:(o,s)=>[...o,...s],patch:(o,s)=>{let i=n(o),a=F2(s,i);return Object.is(a,i)?o:r(a)}}}function n9(e){let t=wL(()=>n),n=He([e,Wt(t),qT(fe,t)]);return n}var Am=re(Ho(yl,{toCode:()=>({runtime:"Schema.Json",Type:"Schema.Json"})})),r9=qT(fe,Am),o9=pr("effect/schema/Json",Am),s9=oe({message:fe,name:Ju(fe),stack:Ju(fe),cause:Ju(Am)}),sj=re(Ho(U1,{toCode:()=>({runtime:"Schema.MutableJson",Type:"Schema.MutableJson"})})),i9=pr("effect/schema/MutableJson",sj);function a9(e){return gi(e.ast)}function c9(e){return e.ast.context?.annotations}var u9="~effect/Stream",f9={_R:B,_E:B,_A:B},l9={[u9]:f9,pipe(){return ie(this,arguments)}},ij=e=>{let t=Object.create(l9);return t.channel=e,t};var p9="~effect/Sink";var m9={_A:B,_In:B,_L:B,_E:B,_R:B},h9={[p9]:m9,pipe(){return ie(this,arguments)}};var g9=e=>{let t=Object.create(h9);return t.transform=e,t},aj=e=>Ge((t,n)=>v(R(e.transform(t,n),me)));var cj=e=>g9(t=>{let n=[];if(e<=0)return v([n]);let r;return t.pipe(R(o=>{if(n.length+o.length<=e)return n.push(...o),n.length===e?me():H;for(let s=0;s<o.length;s++)if(n.push(o[s]),n.length===e)return s+1<o.length&&(r=o.slice(s+1)),me();return H}),Ht({disableYield:!0}),qt(()=>v([n,r])))});var nr={};ns(nr,{DefaultChunkSize:()=>bj,Do:()=>VX,TypeId:()=>Sj,accumulate:()=>PX,aggregate:()=>TX,aggregateWithin:()=>vk,bind:()=>GX,bindEffect:()=>ZX,bindTo:()=>QX,broadcast:()=>Kj,broadcastN:()=>kX,buffer:()=>UY,bufferArray:()=>DY,callback:()=>yS,catch:()=>_m,catchCause:()=>_j,catchCauseFilter:()=>zY,catchCauseIf:()=>$Y,catchFilter:()=>Fj,catchIf:()=>Pj,catchReason:()=>jY,catchReasons:()=>qY,catchTag:()=>LY,catchTags:()=>BY,changes:()=>Vj,changesWith:()=>Jj,changesWithEffect:()=>FX,chunks:()=>qj,collect:()=>MX,combine:()=>cX,combineArray:()=>uX,concat:()=>Rm,cross:()=>hY,crossWith:()=>Rj,debounce:()=>hX,decodeText:()=>UX,die:()=>_9,drain:()=>tY,drainFork:()=>nY,drop:()=>Ik,dropRight:()=>sX,dropUntil:()=>nX,dropUntilEffect:()=>rX,dropWhile:()=>Bj,dropWhileEffect:()=>jj,dropWhileFilter:()=>oX,empty:()=>Ai,encodeText:()=>DX,ensuring:()=>Mm,fail:()=>Yu,failCause:()=>Ij,failCauseSync:()=>M9,failSync:()=>O9,filter:()=>Ek,filterEffect:()=>RY,filterMap:()=>AY,filterMapEffect:()=>OY,flatMap:()=>Zl,flatten:()=>xk,flattenArray:()=>eY,flattenEffect:()=>J9,flattenIterable:()=>cY,flattenTake:()=>uY,forever:()=>aY,fromArray:()=>Om,fromArrayEffect:()=>D9,fromArrays:()=>N9,fromAsyncIterable:()=>L9,fromChannel:()=>q,fromEffect:()=>xS,fromEffectDrain:()=>Ej,fromEffectRepeat:()=>wj,fromEffectSchedule:()=>k9,fromEventListener:()=>q9,fromIterable:()=>Xu,fromIterableEffect:()=>F9,fromIterableEffectRepeat:()=>U9,fromIteratorSucceed:()=>P9,fromPubSub:()=>hk,fromPubSubTake:()=>vj,fromPull:()=>zs,fromQueue:()=>Ci,fromReadableStream:()=>gk,fromSchedule:()=>B9,fromSubscription:()=>j9,groupAdjacentBy:()=>IX,groupBy:()=>EX,groupByKey:()=>wX,grouped:()=>SX,groupedWithin:()=>bX,haltWhen:()=>qX,ignore:()=>VY,ignoreCause:()=>JY,interleave:()=>BX,interleaveWith:()=>Zj,interruptWhen:()=>jX,intersperse:()=>Gj,intersperseAffixes:()=>LX,isStream:()=>Ue,iterate:()=>z9,let:()=>JX,limitBytes:()=>YY,make:()=>A9,map:()=>Eo,mapAccum:()=>fX,mapAccumArray:()=>tf,mapAccumArrayEffect:()=>dX,mapAccumEffect:()=>lX,mapArray:()=>kj,mapArrayEffect:()=>G9,mapBoth:()=>V9,mapEffect:()=>ef,mapError:()=>Uj,merge:()=>yk,mergeAll:()=>mY,mergeEffect:()=>SS,mergeLeft:()=>dY,mergeResult:()=>lY,mergeRight:()=>pY,mkArrayBuffer:()=>aee,mkString:()=>iee,mkUint8Array:()=>cee,never:()=>W9,onEnd:()=>zX,onError:()=>$X,onExit:()=>Qj,onFirst:()=>Xj,onStart:()=>Yj,orDie:()=>KY,orElseIfEmpty:()=>HY,orElseSucceed:()=>WY,paginate:()=>$9,partition:()=>MY,partitionEffect:()=>_Y,partitionQueue:()=>wk,peel:()=>FY,pipeThrough:()=>_X,pipeThroughChannel:()=>RX,pipeThroughChannelOrFail:()=>OX,prepend:()=>fY,provide:()=>eq,provideContext:()=>Tk,provideService:()=>HX,provideServiceEffect:()=>kk,race:()=>CY,raceAll:()=>Oj,range:()=>H9,rechunk:()=>$j,repeat:()=>rY,repeatElements:()=>iY,result:()=>Z9,retry:()=>GY,run:()=>nq,runCollect:()=>rq,runCount:()=>YX,runDrain:()=>ES,runFold:()=>eee,runFoldEffect:()=>tee,runForEach:()=>oee,runForEachArray:()=>Ql,runForEachWhile:()=>see,runHead:()=>nee,runIntoPubSub:()=>dee,runIntoQueue:()=>hee,runLast:()=>ree,runSum:()=>XX,scan:()=>pX,scanEffect:()=>mX,schedule:()=>oY,scoped:()=>K9,service:()=>v9,serviceOption:()=>T9,share:()=>AX,sliding:()=>iX,slidingSize:()=>zj,split:()=>aX,splitLines:()=>NX,succeed:()=>Gl,suspend:()=>Fr,switchMap:()=>X9,sync:()=>R9,take:()=>QY,takeRight:()=>XY,takeUntil:()=>Dj,takeUntilEffect:()=>Nj,takeWhile:()=>Lj,takeWhileEffect:()=>tX,takeWhileFilter:()=>eX,tap:()=>Cj,tapBoth:()=>Q9,tapCause:()=>NY,tapError:()=>Mj,tapSink:()=>Y9,throttle:()=>yX,throttleEffect:()=>Hj,tick:()=>C9,timeout:()=>sY,timeoutOrElse:()=>Aj,toAsyncIterable:()=>lee,toAsyncIterableEffect:()=>fee,toAsyncIterableWith:()=>Ok,toChannel:()=>Zo,toPubSub:()=>pee,toPubSubTake:()=>oq,toPull:()=>Ck,toQueue:()=>mee,toReadableStream:()=>uee,toReadableStreamEffect:()=>Rk,toReadableStreamWith:()=>Ak,transduce:()=>vX,transformPull:()=>Sn,transformPullBracket:()=>mk,unfold:()=>Tj,unwrap:()=>mr,updateContext:()=>tq,updateService:()=>WX,when:()=>PY,withExecutionPlan:()=>ZY,withSpan:()=>KX,zip:()=>xY,zipFlatten:()=>bY,zipLatest:()=>TY,zipLatestAll:()=>bk,zipLatestWith:()=>kY,zipLeft:()=>yY,zipRight:()=>SY,zipWith:()=>Sk,zipWithArray:()=>bS,zipWithIndex:()=>EY,zipWithNext:()=>wY,zipWithPrevious:()=>IY,zipWithPreviousAndNext:()=>vY});var fj="~effect/RcMap",x9=e=>({[fj]:fj,lookup:e.lookup,context:e.context,scope:e.scope,idleTimeToLive:e.idleTimeToLive,capacity:e.capacity,state:{_tag:"Open",map:hc()},pipe(){return ie(this,arguments)}}),lj=e=>xn(t=>{let n=t.context,r=$e(n,It),o=x9({lookup:e.lookup,context:n,scope:r,idleTimeToLive:typeof e.idleTimeToLive=="function"?qc(e.idleTimeToLive,gt):Qe(gt(e.idleTimeToLive??Gi)),capacity:Math.max(e.capacity??Number.POSITIVE_INFINITY,0)});return zt(Do(r,()=>{if(o.state._tag==="Closed")return H;let s=o.state.map;return o.state={_tag:"Closed"},Lo(s,([,i])=>Vr(Je(i.scope,Vt))).pipe(Mt(()=>se(()=>{ry(s)})))}),o)}),fk=d(2,(e,t)=>yo(n=>{if(e.state._tag==="Closed")return xo;let r=e.state,o=Ei(),s=Os(r.map,t),i;if(s._tag==="Some")i=s.value,i.refCount++;else{if(Number.isFinite(e.capacity)&&B1(e.state.map)>=e.capacity)return G(new bP(`RcMap attempted to exceed capacity of ${e.capacity}`));{i={deferred:pu(),scope:zr(),idleTimeToLive:e.idleTimeToLive(t),finalizer:void 0,fiber:void 0,expiresAt:0,refCount:1},i.finalizer=y9(e,t,i),gc(r.map,t,i);let c=new Map(e.context.mapUnsafe);o.context.mapUnsafe.forEach((u,f)=>{c.set(f,u)}),c.set(It.key,i.scope),e.lookup(t).pipe(Ln(Mo(c)),ya(i.scope)).addObserver(u=>Jf(i.deferred,u))}}let a=Jn(o.context,It);return _t(a,i.finalizer).pipe(Dn(n(mu(i.deferred))))}));var y9=(e,t,n)=>xn(r=>{if(n.refCount--,n.refCount>0)return H;if(e.state._tag==="Closed"||!L1(e.state.map,t)||Nd(n.idleTimeToLive))return e.state._tag==="Open"&&Mu(e.state.map,t),Je(n.scope,Vt);if(!fs(n.idleTimeToLive))return H;let o=r.getRef(nc);return n.expiresAt=o.currentTimeMillisUnsafe()+Tn(n.idleTimeToLive),n.fiber?H:(n.fiber=Ww(function s(i){let a=o.currentTimeMillisUnsafe(),c=n.expiresAt-a;return c<=0?e.state._tag==="Closed"||n.refCount>0?H:(Mu(e.state.map,t),i(Je(n.scope,Vt))):R(o.sleep(us(c)),()=>s(i))}).pipe(ca(se(()=>{n.fiber=void 0})),Ln(r.context),ya(e.scope)),H)});var lk=d(2,(e,t)=>Iu(n=>{if(e.state._tag==="Closed")return H;let r=Os(e.state.map,t);if(r._tag==="None"||Nd(r.value.idleTimeToLive))return H;let o=r.value;return o.expiresAt=n.currentTimeMillisUnsafe()+Tn(o.idleTimeToLive),H}));var S9="~effect/RcRef",dk={_tag:"Empty"},b9={_tag:"Closed"},E9={_A:B,_E:B},pk=class{[S9]=E9;pipe(){return ie(this,arguments)}state=dk;semaphore=Ia(1);acquire;context;scope;idleTimeToLive;constructor(t,n,r,o){this.acquire=t,this.context=n,this.scope=r,this.idleTimeToLive=o}},pj=e=>xn(t=>{let n=t.context,r=$e(n,It),o=new pk(e.acquire,n,r,e.idleTimeToLive?gt(e.idleTimeToLive):void 0);return zt(Do(r,()=>{let s=o.state._tag==="Acquired"?Je(o.state.scope,Vt):H;return o.state=b9,s}),o)}),w9=e=>yo(function t(n){switch(e.state._tag){case"Closed":return xo;case"Acquired":return e.state.refCount++,e.state.fiber?zt(bo(e.state.fiber),e.state):v(e.state);case"Empty":{let r=zr();return e.semaphore.withPermit(K(()=>e.state._tag!=="Empty"?t(n):n(Nn(e.acquire,Ve(e.context,It,r))).pipe(Y(o=>{let s={_tag:"Acquired",value:o,scope:r,fiber:void 0,refCount:1,invalidated:!1};return e.state=s,s}),ur(o=>ii(o)?Je(r,o):H))))}}}),mj=Se(function*(e){let t=e,n=yield*w9(t),r=yield*$o,o=t.idleTimeToLive!==void 0&&fs(t.idleTimeToLive);return yield*Do(r,()=>(n.refCount--,n.refCount>0?H:t.idleTimeToLive===void 0?(t.state=dk,Je(n.scope,Vt)):n.invalidated?Je(n.scope,Vt):o?(n.fiber=oc(t.idleTimeToLive).pipe(R(()=>t.state._tag==="Acquired"&&t.state.refCount===0?(t.state=dk,Je(n.scope,Vt)):H),ca(se(()=>{n.fiber=void 0})),Ln(t.context),ya(t.scope)),H):H)),n.value});var hj=pj,gj=mj;var Sj="~effect/Stream",Ue=e=>j(e,Sj),bj=Gp,q=ij,xS=e=>q(ky(Y(e,Ne))),v9=e=>xS($w(e)),T9=e=>xS(Eu(e)),Ej=e=>zs(v(R(e,()=>me()))),wj=e=>zs(v(Y(e,Ne))),k9=(e,t)=>zs($t(function*(){let n=yield*Ss(t),r=yield*qo(e,Un,Un.defaultValue()),o=!0,s=K(()=>n(r)).pipe(R(i=>qo(e,Un,i)),Y(i=>(r=i,Ne(i))));return K(()=>o?(o=!1,v(Ne(r))):s)})),C9=e=>zs(se(()=>{let t=!0,n=v(Ne(void 0)),r=aa(n,e);return K(()=>t?(t=!1,n):r)})),zs=e=>q(qn(e)),Sn=(e,t)=>q(Ge((n,r)=>R(Ko(e.channel,r),o=>t(o,r)))),mk=(e,t)=>q(Us((n,r,o)=>R(Ko(e.channel,r),s=>t(s,r,o)))),Zo=e=>e.channel,yS=(e,t)=>q(cD(e,t)),Ai=q(Ol),Gl=e=>q(Ty(Ne(e))),A9=(...e)=>Om(e),R9=e=>q(fD(()=>Ne(e()))),Fr=e=>q(vy(()=>e().channel)),Yu=e=>q(Ii(e)),O9=e=>q(dD(e)),Ij=e=>q(Zp(e)),_9=e=>q(Lv(e)),M9=e=>q(pD(e)),P9=(e,t)=>q(Nv(()=>e,t)),Xu=(e,t)=>Array.isArray(e)&&t?.chunkSize===void 0?Om(e):q(uD(e,t?.chunkSize)),F9=e=>mr(Y(e,Xu)),U9=e=>Zl(wj(e),Xu),Om=e=>Ye(e)?q(Ty(e)):Ai,D9=e=>mr(Y(e,Om)),N9=(...e)=>q(Dv(Vh(e,Ye))),Ci=e=>q(hD(e)),hk=e=>q(gD(e)),vj=e=>q(xD(e)),gk=e=>q(yD(e)),L9=(e,t)=>q(SD(e,t)),B9=e=>zs(Y(Yf(e),t=>qt(Y(t(void 0),Ne),()=>me()))),j9=e=>q(jv(e)),q9=(e,t,n)=>yS(r=>{function o(s){Al(r,s)}return ic(se(()=>e.addEventListener(t,o,n)),()=>se(()=>e.removeEventListener(t,o,n)))},{bufferSize:typeof n=="object"?n.bufferSize:void 0}),Tj=(e,t)=>zs(se(()=>{let n=e;return R(K(()=>t(n)),r=>r===void 0?me():(n=r[1],v(Ne(r[0]))))})),$9=(e,t)=>zs(se(()=>{let n=e,r=!1;return K(function o(){return r?me():R(t(n),([s,i])=>(xe(i)?r=!0:n=i.value,Ye(s)?v(s):o()))})})),z9=(e,t)=>Tj(e,n=>v([n,t(n)])),H9=(e,t,n=Gp)=>e>t?Ai:zs(se(()=>{let r=Math.max(1,n),o=e,s=!1;return K(()=>{if(s)return me();let i=t-o+1;if(i>r){let c=hE(o,o+r-1);return o+=r,v(c)}let a=hE(o,o+i-1);return s=!0,v(a)})})),W9=q(lD),mr=e=>q(va(Y(e,Zo))),K9=e=>q(JD(e.channel)),Eo=d(2,(e,t)=>Fr(()=>{let n=0;return q(Ds(e.channel,as(r=>t(r,n++))))})),V9=d(2,(e,t)=>e.pipe(Eo(t.onSuccess),Uj(t.onFailure))),kj=d(2,(e,t)=>q(Ds(e.channel,t))),ef=d(e=>Ue(e[0]),(e,t,n)=>e.channel.pipe(lr,Cy(t,n),Ds(Ne),q)),J9=d(e=>Ue(e[0]),(e,t)=>ef(e,B,t)),G9=d(2,(e,t)=>q(Cy(e.channel,t))),Z9=e=>e.pipe(Eo(Ce),_m(t=>Gl(Ae(t)))),Cj=d(e=>Ue(e[0]),(e,t,n)=>ef(e,r=>zt(t(r),r),n)),Q9=d(2,(e,t)=>e.pipe(Mj(t.onError),Cj(t.onElement,{concurrency:t.concurrency}))),Y9=d(2,(e,t)=>mk(e,Se(function*(n,r,o){let s=fr(),i=fr(),a,c,u=!1,f=!1,l=s.whenOpen(K(()=>{if(a){let m=a;return a=void 0,f||s.closeUnsafe(),zt(i.open,m)}return me()}));yield*K(()=>t.transform(l,o)).pipe(m=>Hw(m,h=>(u=!0,ii(h)&&(c=h.cause),i.open),!0),Ut(o));let p=n.pipe(R(m=>(a=m,i.closeUnsafe(),s.openUnsafe(),zt(i.await,m))),qt(()=>(f=!0,i.closeUnsafe(),s.openUnsafe(),R(i.await,()=>me()))));return K(()=>c?ct(c):u?n:p)}))),Zl=d(e=>Ue(e[0]),(e,t,n)=>e.channel.pipe(lr,wD(r=>t(r).channel,n),q)),X9=d(e=>Ue(e[0]),(e,t,n)=>e.channel.pipe(lr,WD(r=>t(r).channel,n),q)),xk=d(e=>Ue(e[0]),(e,t)=>Zl(e,B,t)),eY=e=>q(lr(e.channel)),tY=e=>q(TD(e.channel)),nY=d(2,(e,t)=>SS(e,ES(t))),rY=d(2,(e,t)=>q(kD(e.channel,t))),oY=d(2,(e,t)=>e.channel.pipe(lr,CD(t),Ds(Ne),q)),sY=d(2,(e,t)=>Aj(e,{duration:t,orElse:()=>Ai})),Aj=d(2,(e,t)=>{let n=gt(t.duration);if(!fs(n))return e;if(Nd(n))return Fr(t.orElse);let r=Symbol();return _j(Fr(()=>{let s=Ei().getRef(nc),i=Tn(n),a,c=fr(!1);return yk(Sn(e,(u,f)=>K(()=>(a=s.currentTimeMillisUnsafe()+i,c.openUnsafe(),u)).pipe(Y(l=>(c.closeUnsafe(),a=void 0,l)),v)),Ej($t(function*(){for(;;)if(yield*c.await,!(a===void 0||(yield*oc(a-s.currentTimeMillisUnsafe()),a===void 0)||a-s.currentTimeMillisUnsafe()>0))return yield*ho(r)})),{haltStrategy:"left"})}),o=>o.reasons.find(i=>i._tag==="Die"&&i.defect===r)?t.orElse():Ij(o))}),iY=d(2,(e,t)=>q(Ge((n,r)=>Y(Pe(lr(e.channel))(n,r),o=>{let s,i=$t(function*(){let a=yield*o,c=Ne(a);return s=(yield*Yf(t))(a).pipe(zt(c),qt(f=>(s=void 0,i))),c});return K(()=>s??i)})))),aY=e=>q($v(e.channel)),cY=e=>Zl(e,Xu),uY=e=>e.channel.pipe(lr,vD,q),Rm=d(2,(e,t)=>xk(Om([e,t]))),fY=d(2,(e,t)=>Rm(Xu(t),e)),yk=d(e=>Ue(e[0])&&Ue(e[1]),(e,t,n)=>q(_y(Zo(e),Zo(t),n))),SS=d(2,(e,t)=>e.channel.pipe(KD(t),q)),lY=d(2,(e,t)=>yk(Eo(e,Ce),Eo(t,Ae))),dY=d(2,(e,t)=>SS(e,ES(t))),pY=d(2,(e,t)=>SS(t,ES(e))),mY=d(2,(e,t)=>xk(Xu(e),t)),hY=d(2,(e,t)=>Rj(e,t,(n,r)=>[n,r])),Rj=d(3,(e,t,n)=>Zl(e,r=>Eo(t,o=>n(r,o)))),Sk=d(3,(e,t,n)=>bS(e,t,gY(n))),gY=e=>(t,n)=>{let r=Math.min(t.length,n.length),o=[];for(let s=0;s<r;s++)o.push(e(t[s],n[s]));return[o,t.slice(r),n.slice(r)]},bS=d(3,(e,t,n)=>q(Us(Se(function*(r,o){let s=yield*Ko(e.channel,o),i=yield*Ko(t.channel,o),a=$t(function*(){let f=yield*Ut(s,o),l=yield*Ut(i,o);return yield*iy([f,l])}),c={_tag:"PullBoth"};return $t(function*(){let[f,l]=c._tag==="PullBoth"?yield*a:c._tag==="PullLeft"?[yield*s,c.rightArray]:[c.leftArray,yield*i],p=n(f,l);return Ye(p[1])?c={_tag:"PullRight",leftArray:p[1]}:Ye(p[2])?c={_tag:"PullLeft",rightArray:p[2]}:c={_tag:"PullBoth"},p[0]})})))),xY=d(2,(e,t)=>Sk(e,t,(n,r)=>[n,r])),yY=d(2,(e,t)=>bS(e,t,(n,r)=>{let o=Math.min(n.length,r.length),s=n.slice(0,o),i=n.slice(o),a=r.slice(o);return[s,i,a]})),SY=d(2,(e,t)=>bS(e,t,(n,r)=>{let o=Math.min(n.length,r.length),s=r.slice(0,o),i=n.slice(o),a=r.slice(o);return[s,i,a]})),bY=d(2,(e,t)=>Sk(e,t,(n,r)=>[...n,r])),EY=e=>Eo(e,(t,n)=>[t,n]),wY=e=>tf(e,D,(t,n)=>{let r=0;t._tag==="None"&&(r=1,t=L(n[0]));let o=rn();for(;r<n.length;r++){let s=t.value;t=L(n[r]),o.push([s,t])}return[t,o]},{onHalt(t){return t._tag==="Some"?[[t.value,D()]]:[]}}),IY=e=>tf(e,D,(t,n)=>{let r=rn();for(let o=0;o<n.length;o++){let s=n[o];r.push([t,s]),t=L(n[o])}return[t,r]}),vY=e=>tf(e,()=>({prev:D(),current:D()}),(t,n)=>{let r=0,o;t.current._tag==="None"?(r=1,o=n[0],t.current=L(o)):o=t.current.value;let s=rn();for(;r<n.length;r++){let i=n[r];t.current=L(i),s.push([t.prev,o,t.current]),t.prev=L(o),o=i}return[t,s]},{onHalt(t){return t.current._tag==="Some"?[[t.prev,t.current.value,D()]]:[]}}),bk=(...e)=>q(vy(()=>{let t=[],n=new Set,r=fr();return Oy(Dv(e.map((o,s)=>o.channel.pipe(lr,Cy(i=>(t[s]=i,n.has(s)?v(Ne(t.slice())):(n.add(s),n.size<e.length?r.await:zt(r.open,Ne(t.slice()))))),AD(Kn)))),{concurrency:"unbounded",bufferSize:0})})),TY=d(2,(e,t)=>bk(e,t)),kY=d(3,(e,t,n)=>Eo(bk(e,t),([r,o])=>n(r,o))),Oj=(...e)=>q(Ge((t,n)=>se(()=>{let r,o=Nw(e.map(s=>{let i=Cn(n);return Ko(s.channel,i).pipe(R(a=>_w(v(a),a)),ur(a=>a._tag==="Success"?r?Je(i,a):(r=a.value[0],H):Je(i,a)),Y(([,a])=>a))}));return K(()=>r??o)}))),CY=d(2,(e,t)=>Oj(e,t)),Ek=d(2,(e,t)=>q(RD(Zo(e),t))),AY=d(2,(e,t)=>q(OD(Zo(e),t))),RY=d(2,(e,t)=>q(_D(Zo(e),t))),OY=d(2,(e,t)=>q(MD(Zo(e),t))),wk=d(e=>Ue(e[0]),Se(function*(e,t,n){let r=yield*$o,o=yield*Ko(e.channel,r),s=n?.capacity==="unbounded"?void 0:n?.capacity??bj,i=yield*to({capacity:s}),a=yield*to({capacity:s});return yield*$t(function*(){for(;;){let c=yield*o,u=[],f=[];for(let p=0;p<c.length;p++){let m=t(c[p]);Fe(m)?u.push(m.failure):f.push(m.success)}let l;if(f.length>0){let p=wy(i,f);p.length>0&&(l=yield*il(wa(i,p)))}if(u.length>0){let p=wy(a,u);p.length>0&&(yield*wa(a,p))}l&&(yield*vl(l))}}).pipe(go(c=>(wi(i,c),wi(a,c),H)),Ut(r)),[i,a]})),_Y=d(e=>Ue(e[0]),(e,t,n)=>Y(wk(ef(e,r=>t(r),n),r=>r,n),([r,o])=>[Ci(r),Ci(o)])),MY=d(e=>Ue(e[0]),(e,t,n)=>Y(wk(e,t,{capacity:n?.bufferSize??16}),([r,o])=>[Ci(o),Ci(r)])),PY=d(2,(e,t)=>t.pipe(Y(n=>n?e:Ai),mr)),FY=d(2,Se(function*(e,t){let n,r=yield*Gv(e.channel),o=ft(r,a=>(n=a,ct(a))),s=zs(v(o)),i=yield*nq(s,t);return n?[i,Ai]:(s=zs(v(r)),[i,s])})),UY=d(2,(e,t)=>q(ZD(e.channel,t))),DY=d(2,(e,t)=>q(GD(e.channel,t))),_j=d(2,(e,t)=>e.channel.pipe(Ml(n=>t(n).channel),q)),NY=d(2,(e,t)=>e.channel.pipe(Ry(t),q)),_m=d(2,(e,t)=>q(Ps(e.channel,n=>t(n).channel)));var Mj=d(2,(e,t)=>e.channel.pipe(UD(t),q)),Pj=d(e=>Ue(e[0]),(e,t,n,r)=>q(DD(Zo(e),t,o=>n(o).channel,r&&(o=>r(o).channel)))),Fj=d(e=>Ue(e[0]),(e,t,n,r)=>q(ND(Zo(e),t,o=>n(o).channel,r&&(o=>r(o).channel)))),LY=d(e=>Ue(e[0]),(e,t,n,r)=>{let o=Array.isArray(t)?s=>j(s,"_tag")&&t.includes(s._tag):yr(t);return Pj(e,o,n,r)}),BY=d(e=>Ue(e[0]),(e,t,n)=>{let r;return Fj(e,o=>(r??=Object.keys(t),j(o,"_tag")&&ox(o._tag)&&r.includes(o._tag)?Ce(o):Ae(o)),o=>t[o._tag](o),n)}),jY=d(e=>Ue(e[0]),(e,t,n,r,o)=>q(LD(Zo(e),t,n,(s,i)=>r(s,i).channel,o&&((s,i)=>o(s,i).channel)))),qY=d(e=>Ue(e[0]),(e,t,n,r)=>{let o=Object.create(null);for(let i of Object.keys(n)){let a=n[i];o[i]=(c,u)=>a(c,u).channel}let s=r&&((i,a)=>r(i,a).channel);return q(BD(e.channel,t,o,s))}),Uj=d(2,(e,t)=>q(jD(e.channel,t))),$Y=d(3,(e,t,n)=>q(FD(e.channel,t,r=>n(r).channel))),zY=d(3,(e,t,n)=>q(zv(e.channel,t,(r,o)=>n(r,o).channel))),HY=d(2,(e,t)=>q(ID(e.channel,n=>Zo(t())))),WY=d(2,(e,t)=>_m(e,n=>Gl(t(n)))),KY=e=>q(qD(e.channel)),VY=d(e=>Ue(e[0]),(e,t)=>q($D(e.channel,t))),JY=d(e=>Ue(e[0]),(e,t)=>q(zD(e.channel,t))),GY=d(2,(e,t)=>q(HD(e.channel,t))),yj=(e,t)=>mr(Y(Ss(t),n=>{let r=Un.defaultValue(),o=()=>_m(kk(e,Un,se(()=>r)),s=>mr(qt(Y(n(s),i=>(r=i,mr(zt(cp,o())))),()=>v(Yu(s)))));return o()})),ZY=d(e=>Ue(e[0]),(e,t,n)=>Fr(()=>{let r=n?.preventFallbackOnPartialStream??!1,o=0,s={attempt:0,stepIndex:0},i=kk(Xg,se(()=>(s={attempt:s.attempt+1,stepIndex:o},s))),a=n?.onEvent===void 0?void 0:kw(n.onEvent,()=>s),c,u=a===void 0?B:p=>Qj(Yj(p,Y(a.begin,m=>{c=m})),m=>K(()=>{if(c===void 0)return H;let h=c;return c=void 0,a.end(h,m)})),f=D(),l=Fr(()=>{let p=t.steps[o];if(!p)return Yu(lE(f));let m=i(u(eq(e,p.provide))),h=!1;if(Te(f)){let g=f.value,x=!1,E=m;m=Fr(()=>x?E:(x=!0,Yu(g))),m=yj(m,ap(p,!1))}else{let g=ap(p,!0);m=g?yj(m,g):m}return _m(r?Xj(m,g=>(h=!0,H)):m,g=>(o++,r&&h?Yu(g):(f=L(g),l)))});return l})),QY=d(2,(e,t)=>t<1?Ai:Dj(e,(n,r)=>r===t-1)),YY=d(3,(e,t,n)=>Fr(()=>{let r=BigInt(t),o=BigInt(0),s=!1;return Rm(Lj(e,i=>{let a=o+BigInt(i.length);return a>r?(s=!0,!1):(o=a,!0)}),Fr(()=>s?n():Ai))})),XY=d(2,(e,t)=>tf(e,Ea,(n,r)=>(ay(n,r),n.length>t&&zp(n,n.length-t),[n,Ca]),{onHalt(n){return Fu(n)}})),Dj=d(e=>Ue(e[0]),(e,t,n)=>Sn(e,(r,o)=>se(()=>{let s=0,i=!1;return R(K(()=>i?me():r),c=>{let u=c.findIndex(f=>t(f,s++));if(u>=0){i=!0;let f=c.slice(0,n?.excludeLast?u:u+1);return Ye(f)?v(f):me()}return v(c)})}))),Nj=d(e=>Ue(e[0]),(e,t,n)=>Sn(e,(r,o)=>se(()=>{let s=0,i=!1;return $t(function*(){if(i)return yield*me();let a=yield*r;for(let c=0;c<a.length;c++)if(yield*t(a[c],s++)){i=!0;let u=a.slice(0,n?.excludeLast?c:c+1);return Ye(u)?u:yield*me()}return a})}))),Lj=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o=0,s=!1,i=R(K(()=>s?me():n),a=>{let c=[];for(let u=0;u<a.length;u++){if(!t(a[u],o++)){s=!0;break}c.push(a[u])}return Ye(c)?v(c):s?me():i});return i}))),eX=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o=!1,s=R(K(()=>o?me():n),i=>{let a=[];for(let c=0;c<i.length;c++){let u=t(i[c]);if(Fe(u)){o=!0;break}a.push(u.success)}return Ye(a)?v(a):o?me():s});return s}))),tX=d(2,(e,t)=>Nj(e,(n,r)=>Y(t(n,r),o=>!o),{excludeLast:!0})),Ik=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o=0,s=n.pipe(R(i=>o>=t?v(i):(o+=i.length,o<=t?s:v(i.slice(t-o)))));return s}))),nX=d(2,(e,t)=>Ik(Bj(e,(n,r)=>!t(n,r)),1)),rX=d(2,(e,t)=>Ik(jj(e,(n,r)=>Y(t(n,r),o=>!o)),1)),Bj=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o=!0,s=0,i=R(n,a=>{let c=a.findIndex(u=>!t(u,s++));return c===-1?i:(o=!1,v(a.slice(c)))});return K(()=>o?i:n)}))),oX=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o=!0,s=R(n,i=>{let a=i.findIndex(c=>Fe(t(c)));return a===-1?s:(o=!1,v(i.slice(a)))});return K(()=>o?s:n)}))),jj=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o=!0,s=0,i=$t(function*(){for(;;){let a=yield*n;for(let c=0;c<a.length;c++)if(!(yield*t(a[c],s++)))return o=!1,a.slice(c)}});return K(()=>o?i:n)}))),sX=d(2,(e,t)=>t<=0?e:Sn(e,(n,r)=>se(()=>{let o=Ea(),s=R(n,i=>{cy(o,i);let a=o.length-t,c=Pu(o,a);return Vn(c)?v(c):s});return s}))),qj=e=>e.channel.pipe(Ds(Ne),q),$j=d(2,(e,t)=>(t=Math.max(1,t),Sn(e,(n,r)=>se(()=>{let o=rn(),s=0,i,a=!1;return K(function c(){if(a)return me();if(i===void 0)return R(n,u=>o.length===0&&u.length===t?v(u):o.length+u.length<t?(o.push(...u),c()):(i=u,c()));for(;s<i.length;)if(o.push(i[s++]),o.length===t){let u=o;return o=[],v(u)}return s=0,i=void 0,c()}).pipe(qt(()=>{if(o.length===0)return me();let c=o;return a=!0,o=[],v(c)}))})))),iX=d(2,(e,t)=>zj(e,t,1)),zj=d(3,(e,t,n)=>Sn(e,(r,o)=>se(()=>{let s=null,i=Ea(),a=!1,c=0,u=Jr(r,{onSuccess(f){if(cy(i,f),c>0){let p=i.length;zp(i,c),c=Math.max(0,c-p)}if(i.length<t)return u;a=!0;let l=[];for(;i.length>=t;)if(t===n)l.push(Pu(i,t));else if(l.push(J1(i,t)),t===1&&n<=0)_s(i);else{let p=i.length;zp(i,n),c=Math.max(0,n-p)}return v(l)},onFailure(f){return a&&zp(i,t-n),i.length===0?ct(f):(s=f,v(Ne(Fu(i))))}});return K(()=>s?ct(s):u)}))),aX=d(2,(e,t)=>tf(e,rn,(n,r)=>{let o=rn();for(let s=0;s<r.length;s++)t(r[s])?Vn(n)&&(o.push(n),n=[]):n.push(r[s]);return[n,o]},{onHalt(n){return Vn(n)?Ne(n):Ca}})),cX=d(4,(e,t,n,r)=>qv(lr(e.channel),lr(t.channel),n,r).pipe(Ds(Ne),q)),uX=d(4,(e,t,n,r)=>q(qv(e.channel,t.channel,n,r))),fX=d(e=>Ue(e[0]),(e,t,n,r)=>q(_l(e.channel,t,(o,s)=>{let i=rn();for(let a=0;a<s.length;a++){let[c,u]=n(o,s[a]);o=c,i.push(...u)}return[o,Vn(i)?Ne(i):Ca]},r?.onHalt?{onHalt(o){let s=r.onHalt(o);return Ye(s)?Ne(s):Ca}}:void 0))),tf=d(e=>Ue(e[0]),(e,t,n,r)=>q(_l(e.channel,t,(o,s)=>{let[i,a]=n(o,s);return o=i,[o,Ye(a)?Ne(a):Ca]},r?.onHalt?{onHalt(o){let s=r.onHalt(o);return Ye(s)?Ne(s):Ca}}:void 0))),Ca=rn(),lX=d(e=>Ue(e[0]),(e,t,n,r)=>e.channel.pipe(lr,_l(t,(o,s)=>Y(n(o,s),([i,a])=>[i,Ye(a)?Ne(a):rn()]),r?.onHalt?{onHalt(o){let s=r.onHalt(o);return Ye(s)?Ne(s):Ca}}:void 0),q)),dX=d(e=>Ue(e[0]),(e,t,n,r)=>e.channel.pipe(_l(t,(o,s)=>Y(n(o,s),([i,a])=>[i,Ye(a)?Ne(a):Ca]),r?.onHalt?{onHalt(o){let s=r.onHalt(o);return Ye(s)?Ne(s):Ca}}:void 0),q)),pX=d(3,(e,t,n)=>Fr(()=>{let r=!0;return q(_l(e.channel,Qe(t),(o,s)=>{let i=rn();r&&(r=!1,i.push(o));for(let a=0;a<s.length;a++)o=n(o,s[a]),i.push(o);return[o,Ne(i)]}))})),mX=d(3,(e,t,n)=>e.channel.pipe(lr,PD(t,n),Ds(Ne),q)),hX=d(2,(e,t)=>Sn(e,Se(function*(n,r){let o=yield*nc,s=Tn(gt(t)),i,a,c=1/0,u=fr(),f=fr(),l=fr();yield*n.pipe(u.whenOpen,R(m=>(f.openUnsafe(),i=m,c=o.currentTimeMillisUnsafe()+s,H)),Ht({disableYield:!0}),go(m=>(a=m,c=o.currentTimeMillisUnsafe(),f.openUnsafe(),l.openUnsafe(),H)),Ut(r));let p=K(function m(){let h=o.currentTimeMillisUnsafe(),g=c<h?s:Math.min(s,c-h);return R(sc(oc(g),l.await),()=>{if(o.currentTimeMillisUnsafe()<c)return m();if(i){f.closeUnsafe(),u.closeUnsafe();let E=v(Ne(Tf(i)));return i=void 0,E}else if(a)return ct(a);return m()})});return K(()=>{if(a){if(i){let m=v(Ne(Tf(i)));return i=void 0,m}return ct(a)}return u.openUnsafe(),f.whenOpen(p)})}))),Hj=d(2,(e,t)=>{let n=t.burst??0;return t.strategy==="enforce"?gX(e,t.cost,t.units,t.duration,n):xX(e,t.cost,t.units,t.duration,n)}),gX=(e,t,n,r,o)=>Sn(e,s=>Iu(i=>{let a=Tn(gt(r)),c=n+o<0?Number.POSITIVE_INFINITY:n+o,u=n,f=i.currentTimeMillisUnsafe();return v(R(s,function l(p){return R(t(p),m=>{let h=i.currentTimeMillisUnsafe(),x=(h-f)/a,E=u+x*n,b=E<0?c:Math.min(E,c);return m<=b?(u=b-m,f=h,v(p)):R(s,l)})}))})),xX=(e,t,n,r,o)=>Sn(e,s=>Iu(i=>{let a=Tn(gt(r)),c=n+o<0?Number.POSITIVE_INFINITY:n+o,u=n,f=i.currentTimeMillisUnsafe();return v(R(s,l=>R(t(l),p=>{let m=i.currentTimeMillisUnsafe(),g=(m-f)/a,x=u+g*n,b=(x<0?c:Math.min(x,c))-p;if(b>=0)return u=b,f=m,v(l);let y=-b/n,w=Math.max(0,y*a);return w>0?R(oc(w),()=>(u=b,f=m,v(l))):(u=b,f=m,v(l))})))})),yX=d(2,(e,t)=>Hj(e,{...t,cost:n=>v(t.cost(n))})),SX=d(2,(e,t)=>qj($j(e,t))),bX=d(3,(e,t,n)=>vk(e,cj(t),Xf(n))),EX=d(e=>Ue(e[0]),(e,t,n)=>Wj(e,Se(function*(r,o,s){for(let i=0;i<r.length;i++){let[a,c]=yield*t(r[i]),u=Os(s,a),f=Te(u)?u.value:yield*wu(fk(o,a));yield*lk(o,a),yield*Xn(f,c)}}),n)),wX=d(e=>Ue(e[0]),(e,t,n)=>Fr(()=>{let r=hc();return Wj(e,Se(function*(o,s,i){for(let a=0;a<o.length;a++){let c=t(o[a]),u=Os(r,c);xe(u)?gc(r,c,[o[a]]):u.value.push(o[a])}for(let[a,c]of r){let u=Os(i,a),f=Te(u)?u.value:yield*wu(fk(s,a));yield*lk(s,a),yield*wa(f,c)}ry(r)}),n)})),Wj=(e,t,n)=>mk(e,Se(function*(r,o,s){let i=yield*Vp();yield*_t(o,Ms(i));let a=hc(),c=yield*lj({lookup:u=>ic(to({capacity:n?.bufferSize??4096}).pipe(Mt(f=>(gc(a,u,f),Xn(i,[u,Ci(f)])))),f=>(Mu(a,u),Jp(f))),idleTimeToLive:n?.idleTimeToLive??po}).pipe(Uo(s));return yield*Qn({while:Xt,body:Qe(R(r,u=>t(u,c,a))),step:En}).pipe(ft(u=>Zt(i,u)),Ut(o)),Rl(i)})),IX=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o,s,i=rn(),a=n.pipe(R(u=>{for(let f=0;f<u.length;f++){let l=u[f],p=t(l);if(s===void 0){o=p,s=[l];continue}else if(ae(p,o)){s.push(l);continue}i.push([o,s]),o=p,s=[l]}if(Vn(i)){let f=i;return i=[],v(f)}return a})),c=!1;return qt(K(()=>c?me():a),()=>{c=!0;let u=s;return s=void 0,u&&Vn(u)?v(Ne([o,u])):me()})}))),vX=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o,s,i=K(()=>{if(s!==void 0){let c=s;return s=void 0,v(c)}return n}).pipe(bu(c=>(o=Fo(c),me()))),a=Y(K(()=>t.transform(i,r)),([c,u])=>(s=u,Ne(c)));return K(()=>o||a)}))),TX=d(2,(e,t)=>vk(e,t,op)),vk=d(3,(e,t,n)=>q(Us(Se(function*(r,o,s){let i=yield*Ko(e.channel,o),a=fr(!1),c=Symbol(),u=yield*to({capacity:0});yield*i.pipe(a.whenOpen,R(y=>(a.closeUnsafe(),Xn(u,y))),Ht,ft(y=>Zt(u,y)),Ut(s));let f=D(),l,p=!1,m=yield*Yf(n),g=K(function y(){return R(m(f),()=>p?Xn(u,c):y())}).pipe(R(()=>Kr),qt(()=>me())),x=Wo(u).pipe(R(y=>y===c?me():(p=!0,v(y)))),E=K(()=>{if(l!==void 0){let y=l;return l=void 0,p=!0,v(y)}return a.openUnsafe(),x}),b=R(([y,w])=>!p&&u.state._tag==="Done"?me():(f=L(y),l=w,v(Ne(y))));return K(()=>u.state._tag==="Done"&&l===void 0?u.state.exit:(p=l!==void 0,v(K(()=>t.transform(E,s))))).pipe(R(y=>sc(b(y),g)))})))),kX=d(2,Se(function*(e,t){let n=yield*CX(t),r=new Array(t.n),o=yield*It;for(let s=0;s<t.n;s++){let i=Cn(o),a=yield*Kp(n).pipe(qo(It,i));r[s]=Bv(gy(a)).pipe(Qp(c=>Je(i,c)),q)}return yield*Lu(e.channel,s=>kl(n,s)).pipe(ur(s=>kl(n,s)),Is),r})),CX=e=>ic(e.capacity==="unbounded"?Hp(e):e.strategy==="dropping"?my(e):e.strategy==="sliding"?hy(e):py(e),Wp),Kj=d(2,(e,t)=>Y(oq(e,t),vj)),AX=d(2,(e,t)=>Y(hj({acquire:Kj(e,t),idleTimeToLive:t.idleTimeToLive}),n=>mr(gj(n)))),RX=d(2,(e,t)=>q(Hv(e.channel,t))),OX=d(2,(e,t)=>q(Wv(e.channel,t))),_X=d(2,(e,t)=>e.channel.pipe(Wv(aj(t)),Ay(([n,r])=>r?Ty(r):Ol),q)),MX=e=>xS(rq(e)),PX=e=>tf(e,rn,(t,n)=>{let r=vf(t,n);return[r,[r]]}),Vj=e=>Jj(e,ae),Jj=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o=!0,s;return R(n,function i(a){let c=[],u=0;for(o&&(o=!1,s=a[0],u=1,c.push(s));u<a.length;u++){let f=a[u];t(f,s)||(s=f,c.push(f))}return Vn(c)?v(c):R(n,i)})}))),FX=d(2,(e,t)=>Sn(e,(n,r)=>se(()=>{let o=!0,s;return R(n,Se(function*i(a){let c=[],u=0;for(o&&(o=!1,s=a[0],u=1,c.push(s));u<a.length;u++){let f=a[u];(yield*t(f,s))||(s=f,c.push(f))}return Vn(c)?c:yield*R(n,Se(i))}))}))),UX=d(e=>Ue(e[0]),(e,t)=>Fr(()=>{let n=new TextDecoder(t?.encoding);return Eo(e,r=>n.decode(r,{stream:!0}))})),DX=e=>Fr(()=>{let t=new TextEncoder;return Eo(e,n=>t.encode(n))}),NX=e=>e.channel.pipe(Hv(VD()),q),Gj=d(2,(e,t)=>kj(e,(n,r)=>{let o=r===0?[]:[t],s=n.length-1;for(let i=0;i<n.length;i++)i===s?o.push(n[i]):o.push(n[i],t);return o})),LX=d(2,(e,t)=>Gl(t.start).pipe(Rm(Gj(e,t.middle)),Rm(Gl(t.end)))),BX=d(2,(e,t)=>Zj(e,t,Xu(SR([!0,!1])))),Zj=d(3,(e,t,n)=>q(Ge(Se(function*(r,o){let s=yield*Pe(lr(n.channel))(r,o),i=Symbol(),a=!1,c=!1,u=(yield*Pe(lr(e.channel))(r,o)).pipe(qt(()=>(a=!0,v(i)))),f=(yield*Pe(lr(t.channel))(r,o)).pipe(qt(()=>(c=!0,v(i))));return $t(function*(){for(;;){if(a&&c)return yield*me();let l=yield*s;if(l&&a||!l&&c)continue;let p=yield*l?u:f;if(p!==i)return Ne(p)}})})))),jX=d(2,(e,t)=>q(QD(e.channel,t))),qX=d(2,(e,t)=>q(YD(e.channel,t))),Qj=d(2,(e,t)=>q(Qp(e.channel,t))),$X=d(2,(e,t)=>q(XD(e.channel,t))),Yj=d(2,(e,t)=>q(eN(e.channel,t))),Xj=d(2,(e,t)=>q(Kv(e.channel,n=>t(n[0])))),zX=d(2,(e,t)=>q(tN(e.channel,t))),Mm=d(2,(e,t)=>q(nN(e.channel,t))),eq=d(e=>Ue(e[0]),(e,t,n)=>q(rN(e.channel,t,n))),Tk=d(2,(e,t)=>q(My(e.channel,t))),HX=d(3,(e,t,n)=>q(Py(e.channel,t,n))),kk=d(3,(e,t,n)=>q(Fy(e.channel,t,n))),tq=d(2,(e,t)=>q(oN(e.channel,t))),WX=d(3,(e,t,n)=>tq(e,r=>Ve(r,t,n($e(r,t))))),KX=function(){let e=Ue(arguments[0]),t=e?arguments[1]:arguments[0],n=Po(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return q(Vv(r.channel,t,n))}return r=>q(Vv(r.channel,t,n))},VX=Gl({}),JX=d(3,(e,t,n)=>Eo(e,r=>({...r,[t]:n(r)})));var GX=d(e=>Ue(e[0]),(e,t,n,r)=>Zl(e,o=>Eo(n(o),s=>({...o,[t]:s})),r)),ZX=d(e=>Ue(e[0]),(e,t,n,r)=>ef(e,o=>Y(n(o),s=>({...o,[t]:s})),r)),QX=d(2,(e,t)=>Eo(e,n=>({[t]:n}))),nq=d(2,(e,t)=>dp(n=>Ko(e.channel,n).pipe(R(r=>t.transform(r,n)),Y(([r])=>r)))),rq=e=>Bu(e.channel,()=>[],(t,n)=>{for(let r=0;r<n.length;r++)t.push(n[r]);return t}),YX=e=>Bu(e.channel,()=>0,(t,n)=>t+n.length),XX=e=>Bu(e.channel,()=>0,(t,n)=>{for(let r=0;r<n.length;r++)t+=n[r];return t}),eee=d(3,(e,t,n)=>Bu(e.channel,t,(r,o)=>{for(let s=0;s<o.length;s++)r=n(r,o[s]);return r})),tee=d(3,(e,t,n)=>uN(e.channel,t,(r,o)=>{let s=0,i=r;return Y(Qn({while:()=>s<o.length,body:()=>n(i,o[s]),step(a){i=a,s++}}),()=>i)})),nee=e=>Y(aN(e.channel),Lt(CR(0))),ree=e=>Y(cN(e.channel),Lt(Tf)),oee=d(2,(e,t)=>Lu(e.channel,n=>{let r=0;return Qn({while:()=>r<n.length,body:()=>t(n[r++]),step:En})})),see=d(2,(e,t)=>iN(e.channel,n=>{let r=!1,o=0;return Y(Qn({while:()=>!r&&o<n.length,body:()=>t(n[o]),step(s){o++,s||(r=!0)}}),()=>!r)})),Ql=d(2,(e,t)=>Lu(e.channel,t)),ES=e=>sN(e.channel),Ck=e=>Gv(e.channel),iee=e=>Bu(e.channel,()=>"",(t,n)=>t+n.join("")),aee=e=>Y(Jv(e.channel),t=>t.buffer),cee=e=>Jv(e.channel),Ak=d(e=>Ue(e[0]),(e,t,n)=>{let r,o,s=fr(!1);return new ReadableStream({start(i){o=mp(Nn(Ql(e,a=>s.whenOpen(se(()=>{s.closeUnsafe();for(let c=0;c<a.length;c++)i.enqueue(a[c]);r(),r=void 0}))),t)),o.addObserver(a=>{a._tag==="Failure"?i.error(du(a.cause)):i.close()})},pull(){return new Promise(i=>{r=i,s.openUnsafe()})},cancel(){if(o)return Zw(jo(bo(o)))}},n?.strategy)}),uee=d(e=>Ue(e[0]),(e,t)=>Ak(e,Et(),t)),Rk=d(e=>Ue(e[0]),(e,t)=>Y(ar(),n=>Ak(e,n,t))),Ok=d(2,(e,t)=>({[Symbol.asyncIterator](){let n=Qw(t),r=Ln(t),o=zr(),s,i,a,c,u=l=>{if(c)return c;let p=a;return c=n(zt(Dn(p?bo(p):H,Je(o,l)),{done:!0,value:void 0})),c},f=async l=>{try{await u(l)}catch(p){await n(hp("Suppressed error while closing Stream async iterator",p))}};return{async next(){if(c)return c;if(i){let m=i.next();if(!m.done)return m;i=void 0}let l=r(s??R(Ko(e.channel,o),m=>(s=m,m)));a=l;let p=await n(z1(l));if(a===l&&(a=void 0),Ft(p))return i=p.value[Symbol.iterator](),i.next();if(No(p.cause))return u(Vt);if(c&&Z0(p.cause))return c;throw await f(p),du(p.cause)},return(){return u(Vt)},async throw(l){throw await f(Hg(l)),l}}}})),fee=e=>Y(ar(),t=>Ok(e,t)),lee=e=>Ok(e,Et()),dee=d(e=>Ue(e[0]),(e,t,n)=>Qv(e.channel,t,n)),pee=d(2,(e,t)=>dN(e.channel,t)),oq=d(2,(e,t)=>pN(e.channel,t)),mee=d(2,(e,t)=>fN(e.channel,t)),hee=d(2,(e,t)=>Zv(e.channel,t));var sq="~effect/interfaces/PrimaryKey";var aq="~effect/Pool",fq=Symbol(),lq=Symbol();var dq=e=>mq({...e,min:e.size,max:e.size,strategy:vS}),pq=e=>R(e.timeToLiveStrategy==="creation"?wee(e.timeToLive):Iee(e.timeToLive),t=>mq({...e,strategy:t})),mq=e=>yo(Se(function*(t){let n=yield*ar(),r=$e(n,It),o=lp(e.acquire,u=>br(n,u)),s=e.concurrency??1,i={acquire:o,concurrency:s,isFixed:e.min===e.max,minSize:e.min,maxSize:e.max,strategy:e.strategy,targetUtilization:Math.min(Math.max(e.targetUtilization??1,.1),1)},a={scope:r,isShuttingDown:!1,usage:0,resizeSemaphore:Ia(1),items:new Set,availableHead:void 0,availableTail:void 0,invalidated:new Set,waiters:new Set},c={[aq]:aq,[fq]:e.acquire,[lq]:n,config:i,state:a,pipe(){return ie(this,arguments)}};return yield*_t(r,gee(c)),i.minSize>0&&(yield*Mt(al(t(Uk(c)),{startImmediately:!0}),u=>_t(r,bo(u)))),e.strategy!==vS&&(yield*Mt(al(t(e.strategy.run(c))),u=>_t(r,bo(u)))),c})),gee=Se(function*(e){if(e.state.isShuttingDown)return;e.state.isShuttingDown=!0;let t=e.state.items.size,n=Ia(t);for(let r of e.state.items)r.refCount>0?(r.finalizer=Mt(r.finalizer,n.release(1)),e.state.invalidated.add(r),yield*n.take(1)):(e.state.items.delete(r),Pm(e,r),e.state.invalidated.delete(r),yield*r.finalizer);if(yield*n.releaseAll,e.state.waiters.size>0){let r=Array.from(e.state.waiters);e.state.waiters.clear();for(let o of r)o()}yield*n.take(t)}),Mk=e=>pe(t=>{let n=e.state;if(n.isShuttingDown)return jf;if(n.availableHead!==void 0){if(n.usage++,e.config.isFixed||wS(e)<=IS(e))return hq(e,n.availableHead,t);n.usage--}return xee(e,See)});var xee=(e,t)=>qr(n=>{let r=e.state;r.usage++;let o=ne(Fg(n(Eee(e)),()=>ge(()=>{r.usage--})),()=>i),s=pe(a=>r.isShuttingDown?(r.usage--,jf):r.availableHead!==void 0?t(e,r.availableHead,a,n):o),i=he(()=>r.isShuttingDown?(r.usage--,jf):wS(e)>IS(e)?ne(r.resizeSemaphore.withPermitsIfAvailable(1)(Ut(ua(Uk(e)),r.scope)),()=>s):s);return i}),yee=(e,t)=>{let n=e.state;return t.exit._tag==="Failure"?(n.usage--,n.items.delete(t),n.invalidated.delete(t),Pm(e,t),!1):(t.refCount++,t.refCount>=e.config.concurrency&&Pm(e,t),!0)},hq=(e,t,n)=>{if(!yee(e,t))return t.exit;let r=Jn(n.context,It);return r.state._tag==="Closed"?ne(t.release(t.exit),()=>t.exit):(su(r,{},t.release),t.exit)},See=(e,t,n)=>hq(e,t,n),bee=(e,t)=>pe(n=>{let r=e.state;return t.refCount--,r.usage--,r.invalidated.has(t)?Fk(e,t):(t.refCount===e.config.concurrency-1&&(Pk(e,t),gq(e,n,1)),we)}),Eee=e=>Bt(t=>{let n=e.state;if(n.availableHead!==void 0||n.isShuttingDown)return t(we);let r=()=>{n.waiters.delete(r),t(we)};return n.waiters.add(r),ge(()=>{n.waiters.delete(r)})}),gq=(e,t,n)=>{let r=e.state.waiters;r.size!==0&&t.currentDispatcher.scheduleTask(()=>{let o=n,s=[];for(let i of r){if(o--<=0)break;s.push(i)}for(let i=0;i<s.length;i++)s[i]()},0)},cq=e=>pe(t=>(gq(e,t,Number.POSITIVE_INFINITY),we)),Pk=(e,t)=>{t.isAvailable||(t.isAvailable=!0,t.availablePrevious=e.state.availableTail,t.availableNext=void 0,e.state.availableTail!==void 0?e.state.availableTail.availableNext=t:e.state.availableHead=t,e.state.availableTail=t)},Pm=(e,t)=>{t.isAvailable&&(t.isAvailable=!1,t.availablePrevious!==void 0?t.availablePrevious.availableNext=t.availableNext:e.state.availableHead=t.availableNext,t.availableNext!==void 0?t.availableNext.availablePrevious=t.availablePrevious:e.state.availableTail=t.availablePrevious,t.availablePrevious=void 0,t.availableNext=void 0)};var Fk=(e,t)=>K(()=>{if(e.state.items.has(t)){if(t.refCount===0)return e.state.items.delete(t),Pm(e,t),e.state.invalidated.delete(t),jo(R(t.finalizer,()=>Ut(ua(Uk(e)),e.state.scope,{startImmediately:!0})))}else return H;return e.state.invalidated.add(t),Pm(e,t),H}),Uk=e=>e.state.resizeSemaphore.withPermits(1)(_k(e)),_k=e=>K(()=>{let t=IS(e),n=wS(e);if(t>=n)return H;let r=n-t,o=e.config.strategy===vS?uq(e):R(e.config.strategy.reclaim(e),i=>i?v(i):uq(e));if(r===1){let i=Mt(o,cq(e));return e.config.isFixed?jo(i):R(i,a=>a.exit._tag==="Failure"?H:_k(e))}let s=o.pipe(Kw(r,{concurrency:r}),Mt(cq(e)));return e.config.isFixed?jo(s):R(s,i=>i.some(a=>a.exit._tag==="Failure")?H:_k(e))}),uq=e=>qr(t=>pe(n=>{let r=e,o=cu(),s=n.context;n.setContext(Ve(r[lq],It,o));let i=R(Vr(r[fq]),a=>{let c={exit:a,finalizer:ft(Je(o,a),vee),refCount:0,disableReclaim:!1,isAvailable:!1,availablePrevious:void 0,availableNext:void 0,release:void 0};return c.release=Qe(bee(e,c)),e.state.items.add(c),Pk(e,c),e.config.strategy===vS?a._tag==="Success"?v(c):zt(c.finalizer,c):zt(a._tag==="Success"?e.config.strategy.onAcquire(c):R(c.finalizer,()=>e.config.strategy.onAcquire(c)),c)});return ms(t(i),a=>(n.setContext(s),a._tag==="Failure"?Lf(o,a):void 0),!0)})),wS=e=>{if(e.state.isShuttingDown)return 0;if(e.config.isFixed)return e.config.minSize;let t=e.state.usage/e.config.targetUtilization,n=Math.ceil(t/e.config.concurrency);return Math.min(Math.max(e.config.minSize,n),e.config.maxSize)},IS=e=>e.state.items.size-e.state.invalidated.size,vS={run:e=>H,onAcquire:e=>H,reclaim:e=>rl},wee=Se(function*(e){let t=yield*nc,n=yield*Vp(),r=Tn(gt(e)),o=new WeakMap;return B({run:s=>{let i=a=>K(()=>{if(!s.state.items.has(a)||s.state.invalidated.has(a))return H;let c=t.currentTimeMillisUnsafe(),u=o.get(a),f=r-(c-u);return f>0?aa(i(a),f):Fk(s,a)});return Wo(n).pipe(Mt(i),Ht({disableYield:!0}))},onAcquire:s=>K(()=>(o.set(s,t.currentTimeMillisUnsafe()),Xn(n,s))),reclaim:s=>rl})}),Iee=Se(function*(e){let t=yield*Vp();return B({run:n=>{let r=K(()=>IS(n)-wS(n)<=0?H:Wo(t).pipe(Mt(s=>Fk(n,s)),R(()=>r)));return r.pipe(aa(e),Ht({disableYield:!0}))},onAcquire:n=>Xn(t,n),reclaim(n){return K(()=>{if(n.state.invalidated.size===0)return rl;let r=bR(zh(n.state.invalidated,o=>!o.disableReclaim));return r._tag==="None"?rl:(n.state.invalidated.delete(r.value),r.value.refCount<n.config.concurrency&&Pk(n,r.value),zt(Xn(t,r.value),r.value))})}})}),vee=e=>xn(t=>{let n=t.getRef(kP);return n?cl(n)("Unhandled error in pool finalizer",e):H});var Ri=class extends Ke()("effect/reactivity/Reactivity"){},Tee=se(()=>{let e=new Map,t=c=>{Dk(c,u=>{let f=e.get(u);f!==void 0&&f.forEach(l=>l())})},n=c=>cr(u=>{let f=Vi(u,TS);return f?Dk(c,l=>{f.add(l)}):t(c),H}),r=(c,u)=>Mt(u,n(c)),o=(c,u)=>{let f=[];return Dk(c,l=>{f.push(l);let p=e.get(l);p===void 0&&(p=new Set,e.set(l,p)),p.add(u)}),()=>{for(let l=0;l<f.length;l++){let p=e.get(f[l]);p.delete(u),p.size===0&&e.delete(f[l])}}},s=(c,u)=>$t(function*(){let f=yield*ar(),l=$e(f,It),p=yield*to(),m=qc(Ln(f),ya(l)),h=!1,g=!1,x=y=>{y._tag==="Failure"?wi(p,y.cause):Al(p,y.value),g?(g=!1,m(u).addObserver(x)):h=!1};function E(){if(h){g=!0;return}h=!0,m(u).addObserver(x)}let b=o(c,E);return yield*_t(l,se(b)),E(),p}),i=(c,u)=>s(c,u).pipe(Y(Ci),mr),a=c=>K(()=>{let u=new Set;return c.pipe(qo(TS,u),ur(f=>se(()=>{u.forEach(l=>{let p=e.get(l);p!==void 0&&p.forEach(m=>m())})})))});return Ri.of({mutation:r,query:s,stream:i,invalidateUnsafe:t,invalidate:n,registerUnsafe:o,withBatch:a})}),TS=class extends Ke()("effect/reactivity/Reactivity/PendingInvalidation"){},kS=d(2,(e,t)=>Ri.use(n=>n.mutation(t,e)));var CS=e=>Ri.use(t=>t.invalidate(e)),AS=Hr(Ri)(Tee);function yq(e){switch(typeof e){case"string":case"number":case"bigint":case"boolean":return String(e);default:return ce(e)}}var Dk=(e,t)=>{if(Array.isArray(e)){for(let n=0;n<e.length;n++)t(yq(e[n]));return}for(let n in e){t(n);let r=e[n];for(let o=0;o<r.length;o++)t(`${n}:${yq(r[o])}`)}};var Sq="~effect/SubscriptionRef",Fm=e=>j(e,Sq),gle={...vn,[Sq]:{_A:B},toJSON(){return{_id:"SubscriptionRef",value:this.value}}};var Nk=e=>hk(e.pubsub);var bq=e=>se(()=>e.value);var kee=(e,t)=>{e.value=t,Z1(e.pubsub,t)};var Lk=d(2,(e,t)=>e.semaphore.withPermit(se(()=>kee(e,t))));function OS(e,t){if(e===null)return{drafts:{},expired:!1};if(new TextEncoder().encode(e).length>2097152)throw new Error("Draft storage exceeds the workspace limit.");let n=JSON.parse(e);if(typeof n!="object"||n===null||Array.isArray(n))throw new Error("Draft storage is malformed.");let r={},o=!1;for(let[s,i]of Object.entries(n)){if(typeof i!="object"||i===null||!("author"in i)||!("body"in i)||!("id"in i)||!("revision"in i)||!("type"in i)||!("updatedAt"in i)||typeof i.author!="string"||typeof i.body!="string"||typeof i.id!="string"||typeof i.revision!="string"||i.type!=="answer"&&i.type!=="clarify"&&i.type!=="not_now"||typeof i.updatedAt!="number"||!Number.isFinite(i.updatedAt))throw new Error("Draft storage is malformed.");if(i.updatedAt>t||t-i.updatedAt>=2592e6){o=!0;continue}r[s]={author:i.author,body:i.body,id:i.id,revision:i.revision,type:i.type,updatedAt:i.updatedAt}}return{drafts:r,expired:o}}function _S(e){let t=JSON.stringify(e);if(new TextEncoder().encode(t).length>2097152)throw new Error("Draft storage is full. Copy this draft before clearing workspace drafts.");return t}var Aa=new Map;function wq(e,t,n,r,o){function s(){if(!n)throw new Error("Draft storage unavailable");return n}let i=!1,a={};try{let m=OS(s().getItem(r),le.runSync(fi.currentTimeMillis));a=m.drafts,m.expired&&o("Expired drafts were cleared after 30 days. Saved responses are unaffected."),s().setItem(r,_S(a))}catch{i=!0,o("Draft history is unavailable or malformed. Keep a copy; edits remain in this window.")}let c=Aa.get(e);c&&le.runSync(fi.currentTimeMillis)-c.updatedAt>=2592e6&&(Aa.delete(e),o("A window draft expired after 30 days. Saved responses are unaffected."));let u=Aa.get(e)??a[e]??{author:"",body:"",id:`response.${crypto.randomUUID()}`,revision:t,type:"answer",updatedAt:le.runSync(fi.currentTimeMillis)};u.revision!==t&&o("Source changed since this draft. Your text is retained; review the new source and preview to bind it to this revision.");function f(m){u={...Aa.get(e)??u,...m,updatedAt:le.runSync(fi.currentTimeMillis)},Aa.set(e,u);try{if(i)throw new Error("Unknown draft history");let h=OS(s().getItem(r),le.runSync(fi.currentTimeMillis)).drafts;s().setItem(r,_S({...h,[e]:u}))}catch{o("Draft could not be persisted (storage full or unavailable). Keep a copy; your text remains in this window.")}return u}function l(){try{s().removeItem(r),i=!1,Aa.clear(),o("Workspace drafts cleared. Saved responses are unchanged; this visible text remains until you navigate away.")}catch{o("Draft storage could not be cleared.")}}function p(m){if(Aa.get(e)!==m)return Aa.get(e)?.id===m.id&&f({id:`response.${crypto.randomUUID()}`}),!1;Aa.delete(e);try{let h=OS(s().getItem(r),le.runSync(fi.currentTimeMillis)).drafts;h[e]?.id===m.id&&delete h[e],s().setItem(r,_S(h))}catch{o("Saved response confirmed, but its browser draft could not be cleared.")}return u={...u,body:"",id:`response.${crypto.randomUUID()}`,updatedAt:le.runSync(fi.currentTimeMillis)},!0}return{clear:l,current:()=>u,saved:p,update:f}}function Iq(e,t){return`New file: responses/${e.id}.md
|
|
32
|
+
Registration (if needed): responses/${t}.md
|
|
33
|
+
Recorded time is assigned by the server when saving.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
${JSON.stringify({id:e.id,kind:"response",response:{author:e.author,question:t,reviewedRevision:e.revision,type:e.type}},null,2)}
|
|
37
|
+
---
|
|
38
|
+
${e.body}`}var vq="~effect/http/Cookies";var Tq="~effect/http/Cookies/Cookie";var kq="~effect/http/Cookies/CookieError",Bk=class extends mO{},Cq=class e extends Mn("CookieError"){static fromReason(t,n){return new e({reason:new Bk({_tag:t,cause:n})})}[kq]=kq;get message(){return this.reason._tag}},Aee={[vq]:vq,...Gs,toJSON(){return{_id:"effect/Cookies",cookies:Hh(this.cookies,e=>e.toJSON())}},pipe(){return ie(this,arguments)}},Ree=e=>{let t=Object.create(Aee);return t.cookies=e,t},Oee=e=>{let t={};for(let n of e)W(t,n.name,n);return Ree(t)},Rq=e=>{let t=typeof e=="string"?[e]:e,n=[];for(let r of t){let o=_ee(r.trim());o&&n.push(o)}return Oee(n)};function _ee(e){let t=e.split(";").map(a=>a.trim()).filter(a=>a!=="");if(t.length===0)return;let n=t[0].indexOf("=");if(n===-1)return;let r=t[0].slice(0,n);if(!Mee.test(r))return;let o=t[0].slice(n+1),s=Pee(o);if(t.length===1)return Object.assign(Object.create(Aq),{name:r,value:s,valueEncoded:o});let i={};for(let a=1;a<t.length;a++){let c=t[a],u=c.indexOf("="),f=u===-1?c:c.slice(0,u).trim(),l=u===-1?void 0:c.slice(u+1).trim();switch(f.toLowerCase()){case"domain":{if(l===void 0)break;let p=l.trim().replace(/^\./,"");p&&(i.domain=p);break}case"expires":{if(l===void 0)break;let p=new Date(l);isNaN(p.getTime())||(i.expires=p);break}case"max-age":{if(l===void 0)break;let p=parseInt(l,10);isNaN(p)||(i.maxAge=_E(p));break}case"path":{if(l===void 0)break;l[0]==="/"&&(i.path=l);break}case"priority":{if(l===void 0)break;switch(l.toLowerCase()){case"low":i.priority="low";break;case"medium":i.priority="medium";break;case"high":i.priority="high";break}break}case"httponly":{i.httpOnly=!0;break}case"secure":{i.secure=!0;break}case"partitioned":{i.partitioned=!0;break}case"samesite":{if(l===void 0)break;switch(l.toLowerCase()){case"lax":i.sameSite="lax";break;case"strict":i.sameSite="strict";break;case"none":i.sameSite="none";break}break}}}return Object.assign(Object.create(Aq),{name:r,value:s,valueEncoded:o,options:Object.keys(i).length>0?i:void 0})}var Mee=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;var Aq={[Tq]:Tq,...Gs,toJSON(){return{_id:"effect/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};var Pee=e=>{try{return decodeURIComponent(e)}catch{return e}};var HS={};ns(HS,{Fetch:()=>c$,RequestInit:()=>zS,layer:()=>ote});var _q=Symbol.for("~effect/http/Headers");var Um=Object.defineProperties(Object.create(null),{[_q]:{value:_q},[Wc]:{value(e){return Uee(this,$e(e,qk))}},toJSON:{value(){return To(this)}},[_e]:{value(e){return Fee(this,e)}},[Oe]:{value(){return xd(this)}},toString:{value:Gs.toString},[at]:{value:Gs[at]}}),MS=e=>Object.assign(Object.create(Um),e),Fee=IR(Hc());var Yl=Object.create(Um),Oi=e=>{if(e===void 0)return Yl;if(Symbol.iterator in e){let n=Object.create(Um);for(let[r,o]of e)n[r.toLowerCase()]=o;return n}let t=Object.create(Um);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},Mq=e=>Object.setPrototypeOf(e,Um);var Dm=d(3,(e,t,n)=>{let r=MS(e);return r[t.toLowerCase()]=n,r}),Pq=d(2,(e,t)=>MS({...e,...Oi(t)})),Xl=d(2,(e,t)=>{let n=MS(e);return Object.assign(n,t),n}),Ac=d(2,(e,t)=>{let n=MS(e);return delete n[t.toLowerCase()],n});var Uee=d(2,(e,t)=>{let n={...e},r=o=>{if(typeof o=="string"){let s=o.toLowerCase();s in e&&(n[s]=bc(e[s]))}else for(let s in e)o.test(s)&&(n[s]=bc(e[s]))};if(Array.isArray(t))for(let o=0;o<t.length;o++)r(t[o]);else r(t);return n}),jk=(e,t)=>{for(let n=0;n<t.length;n++){let r=t[n];if(typeof r=="string"){if(r.toLowerCase()===e)return!0}else if(r.test(e))return!0}return!1},qk=Me("effect/Headers/CurrentRedactedNames",{defaultValue:()=>["authorization","cookie","set-cookie","x-api-key"]});var $k="~effect/http/UrlParams",Dee=e=>j(e,$k),Nee={...vn,[$k]:$k,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:"UrlParams",params:Object.fromEntries(this.params)}},[_e](e){return Lee(this,e)},[Oe](){return Fa(this.params.flat())}},Fq=e=>{let t=Object.create(Nee);return t.params=e,t},Nm=e=>{if(Dee(e))return e;let t=Uq(e),n=[];for(let r=0;r<t.length;r++)if(Array.isArray(t[r][0])){let[o,s]=t[r];n.push([`${o[0]}[${o.slice(1).join("][")}]`,s])}else n.push(t[r]);return Fq(n)},Uq=e=>{let t=typeof e[Symbol.iterator]=="function"?ht(e):Object.entries(e),n=[];for(let[r,o]of t)if(Array.isArray(o))for(let s=0;s<o.length;s++)o[s]!==void 0&&n.push([r,String(o[s])]);else if(typeof o=="object"){let s=Uq(o);for(let[i,a]of s)n.push([[r,...typeof i=="string"?[i]:i],a])}else o!==void 0&&n.push([r,String(o)]);return n},Lee=un((e,t)=>Bee(e.params,t.params)),Bee=RR(xR([Hc(),Hc()]));var Dq=Fq([]);var Nq=d(2,(e,t)=>{let n=Nm(t),r=n.params,o=new Set;for(let s=0;s<r.length;s++)o.add(r[s][0]);for(let s=0;s<e.params.length;s++)o.has(e.params[s][0])||r.push(e.params[s]);return n});var Hk="~effect/http/HttpBody";var Lq="~effect/http/HttpBody/HttpBodyError",Bq=class extends Mn("HttpBodyError"){[Lq]=Lq},PS=class{[Hk];constructor(){this[Hk]=Hk}[at](){return this.toJSON()}toString(){return X(this,{ignoreToString:!0})}},Wk=class extends PS{_tag="Empty";toJSON(){return{_id:"effect/HttpBody",_tag:"Empty"}}},jq=new Wk;var Kk=class extends PS{_tag="Uint8Array";body;contentType;contentLength;constructor(t,n,r){super(),this.body=t,this.contentType=n,this.contentLength=r}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}}},FS=(e,t)=>new Kk(e,t??"application/octet-stream",e.length),jee=new TextEncoder,Vk=(e,t)=>FS(jee.encode(e),t??"text/plain");var Gk="~effect/http/HttpClientError";var wo=class extends Mn("HttpClientError"){constructor(t){"cause"in t.reason?super({...t,cause:t.reason.cause}):super(t)}[Gk]=Gk;get request(){return this.reason.request}get response(){return"response"in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},LS=e=>e.endsWith("Error")?e.slice(0,-5):e,BS=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,US=class extends Mn("TransportError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return BS(LS(this._tag),this.description,this.methodAndUrl)}};var DS=class extends Mn("InvalidUrlError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return BS(LS(this._tag),this.description,this.methodAndUrl)}};var Rc=class extends Mn("DecodeError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return BS(LS(this._tag),this.description,t)}},NS=class extends Mn("EmptyBodyError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return BS(LS(this._tag),this.description,t)}},ed=class e extends $n(Gk)({_tag:Ze("HttpError"),kind:ka(["EncodeError","DecodeError","TransportError","InvalidUrlError","StatusCodeError","EmptyBodyError"]),cause:Pt(ln())}){static fromHttpClientError(t){return new e({_tag:"HttpError",kind:t.reason._tag,cause:t.reason})}};var qq=[["GET","get"],["POST","post"],["PUT","put"],["DELETE","del"],["PATCH","patch"],["HEAD","head"],["OPTIONS","options"],["TRACE","trace"]];var zq=(e,t)=>t._tag==="Empty"||t._tag==="FormData"?Ac(Ac(e,"content-type"),"content-length"):(e=t.contentType===void 0?Ac(e,"content-type"):Dm(e,"content-type",t.contentType),t.contentLength===void 0?Ac(e,"content-length"):Dm(e,"content-length",t.contentLength.toString()));var Zk=class extends Mn("UrlError"){},Hq=(e,t,n)=>qh({try:()=>{let r=new URL(e,$ee());for(let o=0;o<t.params.length;o++){let[s,i]=t.params[o];i!==void 0&&r.searchParams.append(s,i)}return n!==void 0&&(r.hash=n),r},catch:r=>new Zk({cause:r})}),$ee=()=>{if("location"in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname};var Kq="~effect/http/HttpClientRequest";var zee={[Kq]:Kq,...Gs,toJSON(){return{_id:"HttpClientRequest",method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:To(this.headers),body:this.body.toJSON()}},pipe(){return ie(this,arguments)}};function _i(e,t,n,r,o,s){let i=Object.create(zee);return i.method=e,i.url=t,i.urlParams=n,i.hash=r,i.headers=o,i.body=s,i}var Hee=_i("GET","",Dq,D(),Yl,jq),Vq=e=>(t,n)=>Wee(Hee,{method:e,url:t,...n??void 0});var Wee=d(2,(e,t)=>{let n=e;return t.method&&(n=Jq(n,t.method)),t.url&&(n=Qq(n,t.url)),t.headers&&(n=Qk(n,t.headers)),t.urlParams&&(n=Jee(n,t.urlParams)),t.hash&&(n=Gee(n,t.hash)),t.body&&(n=Xq(n,t.body)),t.accept&&(n=Zq(n,t.accept)),t.acceptJson&&(n=Kee(n)),n}),Jq=d(2,(e,t)=>_i(t,e.url,e.urlParams,e.hash,e.headers,e.body)),Gq=d(3,(e,t,n)=>_i(e.method,e.url,e.urlParams,e.hash,Dm(e.headers,t,n),e.body)),Qk=d(2,(e,t)=>_i(e.method,e.url,e.urlParams,e.hash,Pq(e.headers,t),e.body));var Zq=d(2,(e,t)=>Gq(e,"Accept",t)),Kee=Zq("application/json"),Qq=d(2,(e,t)=>{if(typeof t=="string")return _i(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Nm(n.searchParams),o=Xc(n.hash===""?void 0:n.hash.slice(1));return n.search="",n.hash="",_i(e.method,n.toString(),r,o,e.headers,e.body)}),Yq=d(2,(e,t)=>t===""?e:_i(e.method,Vee(t,e.url),e.urlParams,e.hash,e.headers,e.body));var Vee=(e,t)=>{let n=e.endsWith("/"),r=t.startsWith("/");return n&&r?e+t.slice(1):!n&&!r?e+"/"+t:e+t};var Jee=d(2,(e,t)=>_i(e.method,e.url,Nq(e.urlParams,t),e.hash,e.headers,e.body));var Gee=d(2,(e,t)=>_i(e.method,e.url,e.urlParams,L(t),e.headers,e.body));var Xq=d(2,(e,t)=>_i(e.method,e.url,e.urlParams,e.hash,zq(e.headers,t),t));var nf="~effect/http/HttpIncomingMessage";var e$=(e,t)=>{let n=e.headers["content-type"]??"",r;if(n.includes("application/json"))try{r=hi(e.json)}catch{}else if(n.includes("text/")||n.includes("urlencoded"))try{r=hi(e.text)}catch{}let o={...t,headers:To(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(o.body=r),o};var td="~effect/http/HttpClientResponse",t$=(e,t)=>new eC(e,t);var eC=class extends _h{[nf];[td];request;source;constructor(t,n){super(),this.request=t,this.source=n,this[nf]=nf,this[td]=td}toJSON(){return e$(this,{_id:"HttpClientResponse",request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get headers(){return Oi(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=Rq(this.source.headers.getSetCookie())}get remoteAddress(){return D()}get stream(){return this.source.body?gk({evaluate:()=>this.source.body,onError:t=>new wo({reason:new Rc({request:this.request,response:this,cause:t})})}):Yu(new wo({reason:new NS({request:this.request,response:this,description:"can not create stream from empty body"})}))}get json(){return R(this.text,t=>Bo({try:()=>t===""?null:JSON.parse(t),catch:n=>new wo({reason:new Rc({request:this.request,response:this,cause:n})})}))}textBody;get text(){return this.textBody??=Y(this.arrayBuffer,t=>new TextDecoder().decode(t))}get urlParamsBody(){return R(this.text,t=>Bo({try:()=>Nm(new URLSearchParams(t)),catch:n=>new wo({reason:new Rc({request:this.request,response:this,cause:n})})}))}formDataBody;get formData(){return this.formDataBody??=bs({try:()=>this.source.formData(),catch:t=>new wo({reason:new Rc({request:this.request,response:this,cause:t})})}).pipe(hx,hi)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody?this.arrayBufferBody:(this.arrayBufferBody=bs({try:()=>this.source.arrayBuffer(),catch:t=>new wo({reason:new Rc({request:this.request,response:this,cause:t})})}).pipe(hx,hi),this.arrayBufferBody)}pipe(){return ie(this,arguments)}};var n$=e=>Mq({b3:`${e.traceId}-${e.spanId}-${e.sampled?"1":"0"}${rr(e.parent,{onNone:()=>"",onSome:t=>`-${t.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?"01":"00"}`});var o$="~effect/http/HttpClient";var nC=Ke("effect/HttpClient");var Zee=d(2,(e,t)=>rC(n=>t(e.postprocess(n)),e.preprocess));var rC=(e,t)=>{let n=Object.create(Qee);return n.preprocess=t,n.postprocess=e,n.execute=function(r){return e(t(r))},n},Qee={[o$]:o$,pipe(){return ie(this,arguments)},...Gs,toJSON(){return{_id:"effect/HttpClient"}},...Object.fromEntries(qq.map(([e,t])=>[t,function(n,r){return this.execute(Vq(e)(n,r))}]))},s$=e=>rC(t=>R(t,n=>xn(r=>{let o=nte.get(n),s=o??new AbortController,i=Hq(n.url,n.urlParams,Oo(n.hash));if(Fe(i))return G(new wo({reason:new DS({request:n,cause:i.failure})}));let a=i.success;if(r.getRef(Af)||r.getRef(Yee)(n)){let u=e(n,a,s.signal,r);return o?u:yo(f=>Jr(f(u),{onSuccess(l){return qS.register(l,s),v(new $S(l,s))},onFailure(l){return Q0(l)&&s.abort(),ct(l)}}))}return pp(r.getRef(tte)(n),{kind:"client"},u=>{u.attribute("http.request.method",n.method),u.attribute("server.address",a.origin),a.port!==""&&u.attribute("server.port",+a.port),u.attribute("url.full",a.toString()),u.attribute("url.path",a.pathname),u.attribute("url.scheme",a.protocol.slice(0,-1));let f=a.search.slice(1);f!==""&&u.attribute("url.query",f);let l=r.getRef(qk),p=r.getRef(Xee);for(let m in n.headers)p(m,"request")&&u.attribute(`http.request.header.${m}`,jk(m,l)?"<redacted>":n.headers[m]);return n=r.getRef(ete)?Qk(n,n$(u)):n,yo(m=>m(e(n,a,s.signal,r)).pipe(sl(u,{captureStackTrace:!1}),Jr({onSuccess:h=>{u.attribute("http.response.status_code",h.status);for(let g in h.headers)p(g,"response")&&u.attribute(`http.response.header.${g}`,jk(g,l)?"<redacted>":h.headers[g]);return o?v(h):(qS.register(h,s),v(new $S(h,s)))},onFailure(h){return!o&&Q0(h)&&s.abort(),ct(h)}})))})})),v),i$=d(2,(e,t)=>rC(e.postprocess,n=>Y(e.preprocess(n),t)));var Yee=Me("effect/http/HttpClient/TracerDisabledWhen",{defaultValue:()=>jc}),Xee=Me("effect/http/HttpClient/TracerHeaderFilter",{defaultValue:()=>Xt}),ete=Me("effect/HttpClient/TracerPropagationEnabled",{defaultValue:Xt}),tte=Me("effect/http/HttpClient/SpanNameGenerator",{defaultValue:()=>e=>`http.client ${e.method}`}),a$=e=>Hr(nC)(cr(t=>Y(e,n=>Zee(n,lp(r=>br(t,r)))))),qS=(()=>{if("FinalizationRegistry"in globalThis&&globalThis.FinalizationRegistry){let t=new FinalizationRegistry(n=>{n.abort()});return{register(n,r){t.register(n,r,n)},unregister(n){t.unregister(n)}}}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))}}})(),nte=new WeakMap,$S=class{original;controller;constructor(t,n){this.original=t,this.controller=n}[td]=td;[nf]=nf;applyInterrupt(t){return K(()=>(qS.unregister(this.original),pi(t,()=>se(()=>{this.controller.abort()}))))}get request(){return this.original.request}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return Fr(()=>(qS.unregister(this.original),Mm(this.original.stream,se(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[at](){return this.original[at]()}pipe(){return ie(this,arguments)}};var c$=Me("effect/http/FetchHttpClient/Fetch",{defaultValue:()=>globalThis.fetch}),zS=class extends Ke()("effect/http/FetchHttpClient/RequestInit"){},rte=s$((e,t,n,r)=>{let o=r.getRef(c$),s=Vi(r.context,zS)??{},i=s.headers?Xl(Oi(s.headers),e.headers):e.headers;i["content-length"]&&(i=Ac(i,"content-length"));let a=c=>Y(bs({try:()=>o(t,{...s,method:e.method,headers:i,body:c,duplex:e.body._tag==="Stream"?"half":void 0,signal:n}),catch:u=>new wo({reason:new US({request:e,cause:u})})}),u=>t$(e,u));switch(e.body._tag){case"Raw":case"Uint8Array":return a(e.body.body);case"FormData":return a(e.body.formData);case"Stream":return R(Rk(e.body.stream),a)}return a(void 0)}),ote=a$(v(rte));var f$=Ke("effect/socket/Socket");var sC="~effect/socket/Socket/CloseEvent",u$=class{[sC];code;reason;constructor(t=1e3,n){this[sC]=sC,this.code=t,this.reason=n}toString(){return this.reason?`${this.code}: ${this.reason}`:`${this.code}`}};var WS="~effect/socket/Socket/SocketError",ste=e=>j(e,WS),iC=class extends $n("effect/socket/Socket/SocketReadError")({_tag:Ze("SocketReadError"),cause:ln()}){message="An error occurred during Read"},aC=class extends $n("effect/socket/Socket/SocketWriteError")({_tag:Ze("SocketWriteError"),cause:ln()}){message="An error occurred during Write"},Lm=class extends $n("effect/socket/Socket/SocketOpenError")({_tag:Ze("SocketOpenError"),kind:ka(["Unknown","Timeout"]),cause:ln()}){get message(){return this.kind==="Timeout"?'timeout waiting for "open"':"An error occurred during Open"}},Bm=class extends $n("effect/socket/Socket/SocketCloseError")({_tag:Ze("SocketCloseError"),code:$s,closeReason:Pt(fe)}){static filterClean(t){return function(n){return nd.is(n)&&n.reason._tag==="SocketCloseError"&&t(n.reason.code)?Ce(n.reason):Ae(n)}}get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},cC=He([iC,aC,Lm,Bm]),nd=class extends ck(WS)("SocketError",{_tag:Ze("SocketError"),reason:cC}){constructor(t){"cause"in t.reason?super({...t,cause:t.reason.cause}):super(t)}[WS]=WS;static is(t){return ste(t)}message=this.reason.message};var l$="~effect/reactivity/AsyncResult",d$=e=>j(e,l$),KS={[l$]:{E:B,A:B},pipe(){return ie(this,arguments)},[_e](e){if(this._tag!==e._tag||this.waiting!==e.waiting)return!1;switch(this._tag){case"Initial":return!0;case"Success":return ae(this.value,e.value);case"Failure":return ae(this.cause,e.cause)}},[Oe](){let e=it(`${this._tag}:${this.waiting}`);return this._tag==="Initial"?e:Nt(e)(this._tag==="Success"?ce(this.value):ce(this.cause))}};var fC=(e,t)=>e._tag==="Success"?Qo(e.value):od(e.cause,{previous:t}),VS=e=>e._tag==="None"?Oa(!0):jm(e.value);var p$=e=>e._tag!=="Initial",Oa=(e=!1)=>{let t=Object.create(KS);return t._tag="Initial",t.waiting=e,t},rd=e=>e._tag==="Success",Qo=(e,t)=>{let n=Object.create(KS);return n._tag="Success",n.value=e,n.waiting=t?.waiting??!1,n.timestamp=t?.timestamp??Date.now(),n},m$=e=>e._tag==="Failure";var uC=(e,t)=>{let n=Object.create(KS);return n._tag="Failure",n.cause=e,n.previousSuccess=t?.previousSuccess??D(),n.waiting=t?.waiting??!1,n},od=(e,t)=>uC(e,{previousSuccess:is(t.previous,n=>rd(n)?L(n):m$(n)?n.previousSuccess:D()),waiting:t.waiting});var h$=(e,t)=>od(pP(e),t),jm=(e,t)=>{if(e.waiting)return t?.touch?ate(e):e;let n=Object.assign(Object.create(KS),e);return n.waiting=!0,t?.touch&&rd(n)&&(n.timestamp=Date.now()),n},ate=e=>rd(e)?Qo(e.value,{waiting:e.waiting}):e,qm=(e,t)=>e._tag==="Failure"?od(e.cause,{previous:t,waiting:e.waiting}):e,lC=e=>e._tag==="Success"?L(e.value):e._tag==="Failure"?Lt(e.previousSuccess,t=>t.value):D();var dC=e=>_d(lC(e),()=>new Vf("AsyncResult.getOrThrow: no value found"));var sd=e=>{switch(e._tag){case"Success":return kn(e.value);case"Failure":return jt(e.cause);default:return Fo(new Vf)}};var pC=e=>{let t=e.success??Ic,n=e.error??Ic,r=An()([t,Hl(n,ln())],([o,s])=>(i,a,c)=>{if(!d$(i))return G(new st(a,i,c));switch(i._tag){case"Initial":return v(i);case"Success":return fn(dt(o)(i.value,c),{onSuccess:u=>Qo(u,i),onFailure:u=>Yn(a,"value",u,i,c)});case"Failure":{let u=i.previousSuccess.pipe(Lt(l=>fn(dt(o)(l.value,c),{onSuccess:p=>L(Qo(p,l)),onFailure:p=>new At(a,[new Ct(["previousSuccess","value"],p)],i,c)})),qa(()=>Es)),f=vu(dt(s)(i.cause,c),l=>Yn(a,"cause",l,i,c));return Bn(u,l=>fa(f,p=>uC(p,{previousSuccess:l,waiting:i.waiting})))}}},{expected:"AsyncResult",toCodec([o,s]){let i=Tc("Success",{value:o,waiting:vc,timestamp:$s});return pt()(He([Tc("Initial",{waiting:vc}),i,Tc("Failure",{cause:s,previousSuccess:ki(i),waiting:vc})]),vt({decode:a=>{switch(a._tag){case"Initial":return Oa(a.waiting);case"Success":return Qo(a.value,{waiting:a.waiting,timestamp:a.timestamp});case"Failure":return uC(a.cause,{previousSuccess:Lt(a.previousSuccess,c=>Qo(c.value,c)),waiting:a.waiting})}},encode(a){switch(a._tag){case"Initial":return{_tag:"Initial",waiting:a.waiting};case"Success":return{_tag:"Success",value:a.value,waiting:a.waiting,timestamp:a.timestamp};case"Failure":return{_tag:"Failure",cause:a.cause,previousSuccess:a.previousSuccess,waiting:a.waiting}}}}))},toEquivalence:yd,toFormatter:([o,s])=>i=>{switch(i._tag){case"Success":return`AsyncResult.Success(${o(i.value)}, ${i.waiting}, ${i.timestamp})`;case"Failure":return`AsyncResult.Failure(${s(i.cause)}, ${i.waiting})`;case"Initial":return`AsyncResult.Initial(${i.waiting}, ${i.waiting})`}}});return Object.assign(r,{success:t,error:n})};var zm="~effect/reactivity/AtomRegistry",cte=e=>j(e,zm),g$=e=>new gC(e?.initialValues,e?.scheduleTask,e?.timeoutResolution,e?.defaultIdleTTL),JS=Ke(zm);var Hm=d(e=>cte(e[0]),(e,t,n)=>{let r=n?.suspendOnWaiting??!1;return ws(o=>{let s=e.get(t);if(s._tag!=="Initial"&&!(r&&s.waiting))return o(sd(s));let i=e.subscribe(t,a=>{a._tag!=="Initial"&&!(r&&a.waiting)&&(o(sd(a)),i())});return se(i)})});var ute={immediate:!0},fte=e=>{e()},hC="~effect-atom/atom/Atom/Serializable",$m=e=>hC in e?e[hC].key:e,gC=class{[zm];timeoutResolution;defaultIdleTTL;scheduler;schedulerAsync;dispatcher;onNodeAdded;onNodeRemoved;constructor(t,n,r,o){if(this[zm]=zm,this.scheduler=new ei("sync",n),this.schedulerAsync=new ei("async",n),this.dispatcher=this.schedulerAsync.makeDispatcher(),this.defaultIdleTTL=o,r===void 0&&o!==void 0?this.timeoutResolution=Math.round(o/2):this.timeoutResolution=r??1e3,t!==void 0)for(let[s,i]of t){let a=s;for(;a.initialValueTarget;)a=a.initialValueTarget;this.ensureNode(a).setInitialValue(i)}}nodes=new Map;preloadedSerializable=new Map;timeoutBuckets=new Map;nodeTimeoutBucket=new Map;disposed=!1;getNodes(){return this.nodes}get(t){return this.ensureNode(t).value()}set(t,n){t.write(this.ensureNode(t).writeContext,n)}setSerializable(t,n){this.preloadedSerializable.set(t,n)}modify(t,n){let r=this.ensureNode(t),o=n(r.value());return t.write(r.writeContext,o[1]),o[0]}update(t,n){let r=this.ensureNode(t);t.write(r.writeContext,n(r.value()))}refresh=t=>{t.refresh!==void 0?t.refresh(this.refresh):this.invalidateAtom(t)};subscribe(t,n,r){let o=this.ensureNode(t);r?.immediate&&n(o.value());let s=o.subscribe(function(){n(o._value)});return()=>{s(),o.canBeRemoved&&this.scheduleNodeRemoval(o)}}mount(t){return this.subscribe(t,En,ute)}atomHasTtl(t){return!t.keepAlive&&t.idleTTL!==0&&(t.idleTTL!==void 0||this.defaultIdleTTL!==void 0)}ensureNode(t){let n=$m(t),r=this.nodes.get(n);if(r===void 0?(r=this.createNode(t),this.nodes.set(n,r),this.onNodeAdded?.(r)):this.atomHasTtl(t)&&this.removeNodeTimeout(r),typeof n=="string"&&this.preloadedSerializable.has(n)){let o=this.preloadedSerializable.get(n);this.preloadedSerializable.delete(n);let s=t[hC].decode(o),i=t;for(;i.initialValueTarget;)i=i.initialValueTarget;i===t?r.setValue(s):this.ensureNode(i).setInitialValue(s)}return r}createNode(t){if(this.disposed)throw new Error(`Cannot access Atom ${t}: registry is disposed`);return t.keepAlive||this.scheduleAtomRemoval(t),new xC(this,t)}invalidateAtom=t=>{this.ensureNode(t).invalidate()};scheduleAtomRemoval(t){this.dispatcher.scheduleTask(()=>{let n=this.nodes.get($m(t));n!==void 0&&n.canBeRemoved&&this.removeNode(n)},0)}scheduleNodeRemoval(t){this.dispatcher.scheduleTask(()=>{t.canBeRemoved&&this.removeNode(t)},0)}removeNode(t){this.atomHasTtl(t.atom)?this.setNodeTimeout(t):(this.nodes.delete($m(t.atom)),t.remove(),this.onNodeRemoved?.(t))}setNodeTimeout(t){if(this.nodeTimeoutBucket.has(t))return;let n=t.atom.idleTTL??this.defaultIdleTTL;if(this.#e!==null&&(n-=this.#e,n<=0)){this.nodes.delete($m(t.atom)),t.remove(),this.onNodeRemoved?.(t);return}let r=Math.ceil(n/this.timeoutResolution)*this.timeoutResolution,o=Date.now()+r,s=o-o%this.timeoutResolution+this.timeoutResolution,i=this.timeoutBuckets.get(s);i===void 0&&(i=[new Set,setTimeout(()=>this.sweepBucket(s),s-Date.now())],this.timeoutBuckets.set(s,i)),i[0].add(t),this.nodeTimeoutBucket.set(t,s)}removeNodeTimeout(t){let n=this.nodeTimeoutBucket.get(t);if(n===void 0)return;this.nodeTimeoutBucket.delete(t),this.scheduleNodeRemoval(t);let[r,o]=this.timeoutBuckets.get(n);r.delete(t),r.size===0&&(clearTimeout(o),this.timeoutBuckets.delete(n))}#e=null;sweepBucket(t){let n=this.timeoutBuckets.get(t)[0];this.timeoutBuckets.delete(t),n.forEach(r=>{this.nodeTimeoutBucket.delete(r),r.canBeRemoved&&(this.nodes.delete($m(r.atom)),this.onNodeRemoved?.(r),this.#e=r.atom.idleTTL??this.defaultIdleTTL,r.remove(),this.#e=null)})}reset(){this.timeoutBuckets.forEach(([,t])=>clearTimeout(t)),this.timeoutBuckets.clear(),this.nodeTimeoutBucket.clear(),this.nodes.forEach(t=>{t.remove(),this.onNodeRemoved?.(t)}),this.nodes.clear()}dispose(){this.disposed=!0,this.reset()}},Yo={alive:1,initialized:2,waitingForValue:4},Ur={uninitialized:Yo.alive|Yo.waitingForValue,stale:Yo.alive|Yo.initialized|Yo.waitingForValue,valid:Yo.alive|Yo.initialized,removed:0},xC=class{constructor(t,n){this.registry=t,this.atom=n,this.writeContext=new yC(t,this)}registry;atom;state=Ur.uninitialized;lifetime;writeContext;preserveInitialValueOnBuild=!1;parents=new Set;previousParents;children=new Set;listeners=new Set;skipInvalidation=!1;building=!1;invalidatedDuringBuild=!1;currentState(){switch(this.state){case Ur.uninitialized:return"uninitialized";case Ur.stale:return"stale";case Ur.valid:return"valid";default:return"removed"}}get canBeRemoved(){return!this.atom.keepAlive&&this.listeners.size===0&&this.children.size===0&&this.state!==0}_value=void 0;value(){if((this.state&Yo.waitingForValue)!==0){this.lifetime=pte(this),this.building=!0;let t=this.atom.read(this.lifetime);if(this.building=!1,(this.state&Yo.waitingForValue)!==0&&(this.preserveInitialValueOnBuild?(this.preserveInitialValueOnBuild=!1,this.state=Ur.valid):this.setValue(t)),this.previousParents){let n=this.previousParents;this.previousParents=void 0;for(let r of n)r.removeChild(this),r.canBeRemoved&&this.registry.scheduleNodeRemoval(r)}}return this._value}valueOption(){return(this.state&Yo.initialized)===0?D():L(this._value)}setInitialValue(t){if((this.state&Yo.initialized)===0){this.preserveInitialValueOnBuild=!0,this.state=Ur.stale,this._value=t,Qt.phase===Mi.collect?Qt.notify.add(this):this.notify();return}this.setValue(t)}setValue(t){if((this.state&Yo.initialized)===0){this.state=Ur.valid,this._value=t,Qt.phase===Mi.collect?Qt.notify.add(this):this.notify();return}this.state=Ur.valid,!this.atom.equals(this._value,t)&&(this._value=t,this.skipInvalidation?this.skipInvalidation=!1:this.invalidateChildren(),this.listeners.size>0&&(Qt.phase===Mi.collect?Qt.notify.add(this):this.notify()))}addParent(t){this.parents.add(t),this.previousParents!==void 0&&(this.previousParents.delete(t),this.previousParents.size===0&&(this.previousParents=void 0)),t.children.has(this)||(t.children.add(this),t.skipInvalidation&&(t.skipInvalidation=!1))}removeChild(t){this.children.delete(t)}invalidate(){this.building&&Qt.phase===Mi.collect&&(this.invalidatedDuringBuild=!0),this.state===Ur.valid&&(this.state=Ur.stale,this.disposeLifetime()),Qt.phase===Mi.collect?Qt.stale.push(this):this.atom.lazy&&this.listeners.size===0&&!lte(this.children)?(this.invalidateChildren(),this.skipInvalidation=!0):this.value()}invalidateChildren(){if(this.children.size===0)return;let t=this.children;this.children=new Set;for(let n of t)n.invalidate()}notify(){this.listeners.forEach(fte),Qt.phase===Mi.commit&&Qt.notify.delete(this)}disposeLifetime(){this.lifetime!==void 0&&(this.lifetime.dispose(),this.lifetime=void 0),this.parents.size!==0&&(this.previousParents=this.parents,this.parents=new Set)}remove(){if(this.state=Ur.removed,this.listeners.clear(),this.lifetime===void 0||(this.disposeLifetime(),this.previousParents===void 0))return;let t=this.previousParents;this.previousParents=void 0;for(let n of t)n.removeChild(this),n.canBeRemoved&&this.registry.removeNode(n)}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}};function lte(e){if(e.size===0)return!1;let t=e,n,r=0;for(;t!==void 0;){for(let o of t){if(!o.atom.lazy||o.listeners.size>0)return!0;o.children.size>0&&(n===void 0?n=[o.children]:n.push(o.children))}t=n?.[r++]}return!1}var dte={get registry(){return this.node.registry},addFinalizer(e){if(this.disposed)return e();this.finalizers??=[],this.finalizers.push(e)},get(e){if(this.disposed)return this.node.registry.get(e);let t=this.node.registry.ensureNode(e),n=t.value();return this.node.addParent(t),n},result(e,t){if(this.disposed||this.isFn)return this.resultOnce(e,t);let n=this.get(e);if(t?.suspendOnWaiting&&n.waiting)return Kr;switch(n._tag){case"Initial":return Kr;case"Failure":return jt(n.cause);case"Success":return v(n.value)}},resultOnce(e,t){return ws(n=>{let r=this.once(e);if(r._tag!=="Initial"&&!(t?.suspendOnWaiting&&r.waiting))return n(sd(r));let o=this.node.registry.subscribe(e,s=>{s._tag==="Initial"||t?.suspendOnWaiting&&s.waiting||(o(),n(sd(s)))},{immediate:!1});return se(o)})},setResult(e,t){return this.disposed?Kr:(this.node.registry.set(e,t),this.resultOnce(e,{suspendOnWaiting:!0}))},some(e){if(this.disposed||this.isFn)return this.someOnce(e);let t=this.get(e);return t._tag==="None"?Kr:v(t.value)},someOnce(e){return ws(t=>{let n=this.once(e);if(Te(n))return t(v(n.value));let r=this.node.registry.subscribe(e,o=>{xe(o)||(r(),t(v(o.value)))},{immediate:!1});return se(r)})},once(e){return this.node.registry.get(e)},self(){return this.disposed?D():this.node.valueOption()},refresh(e){this.disposed||this.node.registry.refresh(e)},refreshSelf(){this.disposed||this.node.invalidate()},mount(e){this.disposed||this.addFinalizer(this.node.registry.mount(e))},subscribe(e,t,n){this.disposed||this.addFinalizer(this.node.registry.subscribe(e,t,n))},setSelf(e){this.disposed||this.node.setValue(e)},set(e,t){this.disposed||this.node.registry.set(e,t)},stream(e,t){return this.disposed?Ai:yS(n=>se(()=>{this.subscribe(e,r=>Al(n,r),{immediate:!t?.withoutInitialValue})}))},streamResult(e,t){return this.stream(e,t).pipe(Ek(p$),ef(n=>n._tag==="Success"?v(n.value):ct(n.cause)))},dispose(){if(this.disposed=!0,this.finalizers===void 0)return;let e=this.finalizers;this.finalizers=void 0;for(let t=e.length-1;t>=0;t--)e[t]()}},pte=e=>{function t(n){if(t.disposed)return e.registry.get(n);if(t.isFn)return e.registry.get(n);let r=e.registry.ensureNode(n),o=r.value();return e.addParent(r),o}return Object.setPrototypeOf(t,dte),t.isFn=!1,t.disposed=!1,t.finalizers=void 0,t.node=e,t},yC=class{constructor(t,n){this.registry=t,this.node=n}registry;node;get(t){return this.registry.get(t)}set(t,n){return this.registry.set(t,n)}setSelf(t){return this.node.setValue(t)}refreshSelf(){return this.node.invalidate()}},Mi={disabled:0,collect:1,commit:2},Qt={phase:Mi.disabled,depth:0,stale:[],notify:new Set};function x$(e){Qt.phase=Mi.collect,Qt.depth++;try{if(e(),Qt.depth===1){for(let t=0;t<Qt.stale.length;t++)y$(Qt.stale[t]);Qt.phase=Mi.commit;for(let t of Qt.notify)t.notify();Qt.notify.clear()}}finally{Qt.depth--,Qt.depth===0&&(Qt.phase=Mi.disabled,Qt.stale=[])}}function y$(e){if(e.state===Ur.valid){if(!e.invalidatedDuringBuild)return;e.invalidatedDuringBuild=!1,e.state=Ur.stale,e.disposeLifetime()}for(let t of e.parents)t.state!==Ur.valid&&y$(t);e.state!==Ur.valid&&e.value()}var ph={};ns(ph,{ConnectionHooks:()=>dh,CurrentHeaders:()=>Cb,Protocol:()=>Ni,layerProtocolHttp:()=>Hre,layerProtocolSocket:()=>Vre,layerProtocolWorker:()=>Jre,make:()=>yA,makeNoSerialization:()=>hH,makeProtocolHttp:()=>gH,makeProtocolSocket:()=>xH,makeProtocolWorker:()=>yH,withHeaders:()=>zre});var Wm=class extends Ke()("effect/workers/Transferable/Collector"){},b$=()=>{let e=[],t=o=>{e.push(...o)},n=()=>e,r=()=>{let o=e;return e=[],o};return Wm.of({addAllUnsafe:t,addAll:o=>se(()=>t(o)),readUnsafe:n,read:se(n),clearUnsafe:r,clear:se(r)})};var SC="~effect/workers/WorkerError";var bC=class extends $n("effect/workers/WorkerError/WorkerSpawnError")({_tag:Ze("WorkerSpawnError"),message:fe,cause:Pt(ln())}){},EC=class extends $n("effect/workers/WorkerError/WorkerSendError")({_tag:Ze("WorkerSendError"),message:fe,cause:Pt(ln())}){},wC=class extends $n("effect/workers/WorkerError/WorkerReceiveError")({_tag:Ze("WorkerReceiveError"),message:fe,cause:Pt(ln())}){},IC=class extends $n("effect/workers/WorkerError/WorkerUnknownError")({_tag:Ze("WorkerUnknownError"),message:fe,cause:Pt(ln())}){},vC=He([bC,EC,wC,IC]),E$=class extends $n(SC)({_tag:Ze("WorkerError"),reason:vC}){constructor(t){super({...t,cause:t.reason.cause})}[SC]=SC;get message(){return this.reason.message}};var GS=class extends Ke()("effect/workers/Worker/WorkerPlatform"){};var _c={};ns(_c,{ServerClient:()=>AC,custom:()=>Ste,exitSchema:()=>RC,fork:()=>wte,isRpc:()=>xte,isWrapper:()=>id,make:()=>I$,uninterruptible:()=>Ite,unwrap:()=>bte,wrap:()=>YS,wrapMap:()=>Ete});var TC="~effect/rpc/RpcSchema/StreamSchema";function Km(e){return j(e,TC)}function ZS(e){return Km(e)?L({success:e.success,error:e.error}):D()}var gte=no(Ue);function w$(e,t){return re(gte.ast,{[TC]:TC,success:e,error:t})}var CC="~effect/rpc/Rpc",xte=e=>j(e,CC),AC=class{id;annotations;constructor(t){this.id=t,this.annotations=Et()}annotate(t,n){return this.annotations=Ve(this.annotations,t,n),this}},yte={[CC]:CC,pipe(){return ie(this,arguments)},setSuccess(e){return Oc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return Oc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return Oc({_tag:this._tag,payloadSchema:Gu(e)?e:oe(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return Oc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},prefix(e){return Oc({_tag:`${e}${this._tag}`,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},annotate(e,t){return Oc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:Ve(this.annotations,e,t)})},annotateMerge(e){return Oc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:br(this.annotations,e)})}},Oc=e=>{function t(){}return Object.setPrototypeOf(t,yte),Object.assign(t,e),t.key=`effect/rpc/Rpc/${e._tag}`,t},I$=(e,t)=>{let n=t?.success??Jl,r=t?.error??Ic,o=t?.defect??ln(),s;return t?.primaryKey?s=class extends hS(`effect/rpc/Rpc/${e}`)(t.payload){[sq](){return t.primaryKey(this)}}:s=Gu(t?.payload)?t?.payload:t?.payload?oe(t?.payload):Jl,Oc({_tag:e,payloadSchema:s,successSchema:t?.stream?w$(n,r):n,errorSchema:t?.stream?Ic:r,defectSchema:o,annotations:Et(),middlewares:new Set})},Ste=e=>(t,n)=>{let r=n?.success??Jl,o=n?.error??Ic,s=n?.defect??ln(),i=e({success:r,error:o,defect:s});return I$(t,{...i,primaryKey:n?.primaryKey,payload:n?.payload,stream:n?.stream})},kC=new WeakMap,RC=e=>{if(kC.has(e))return kC.get(e);let t=e,n=new Set([t.errorSchema]),r=ZS(t.successSchema);Te(r)&&n.add(r.value.error);for(let s of t.middlewares)n.add(s.error);let o=pS(Te(r)?Jl:t.successSchema,He([...n]),t.defectSchema);return kC.set(e,o),o},Vm="~effect/rpc/Rpc/Wrapper",id=e=>Vm in e,YS=e=>t=>id(t)?{[Vm]:Vm,value:t.value,fork:e.fork??t.fork,uninterruptible:e.uninterruptible??t.uninterruptible}:{[Vm]:Vm,value:t,fork:e.fork??!1,uninterruptible:e.uninterruptible??!1},bte=e=>id(e)?e.value:e,Ete=(e,t)=>id(e)?YS(e)(t(e.value)):t(e),wte=YS({fork:!0}),Ite=YS({uninterruptible:!0});var OC="~effect/rpc/RpcClientError",Mc=class extends $n("effect/rpc/RpcClientError/RpcClientDefect")({_tag:Ze("RpcClientDefect"),message:fe,cause:ln()}){},Hs=class extends $n(OC)({_tag:Ze("RpcClientError"),reason:He([vC,cC,ed,Mc])}){[OC]=OC;get message(){return`${this.reason._tag}: ${this.reason.message}`}};var Gm=e=>e;var v$={_tag:"Ping"};var Jm=He([fe,Vl]),Tte=oe({_tag:Ze("Request"),id:Jm,tag:fe,payload:Go,headers:Wt(Ec([fe,fe])),isNotification:Pt(Rt(!0)),traceId:Pt(fe),spanId:Pt(fe),sampled:Pt(vc)}),_C=He([Tte,oe({_tag:Ze("Ack"),requestId:Jm}),oe({_tag:Ze("Interrupt"),requestId:Jm}),oe({_tag:Ze("Ping")}),oe({_tag:Ze("Eof")}),oe({_tag:Ze("Chunk"),requestId:Jm,values:Go}),oe({_tag:Ze("Exit"),requestId:Jm,exit:Go}),oe({_tag:Ze("Defect"),defect:Go}),oe({_tag:Ze("Pong")})]);var MC=e=>{switch(e._tag){case"Exit":case"Defect":case"ClientProtocolError":return!0;default:return!1}};var lh={};ns(lh,{MaxBufferSizeExceeded:()=>uh,RpcSerialization:()=>bn,json:()=>iH,jsonRpc:()=>cH,layerJson:()=>Ore,layerJsonRpc:()=>Pre,layerMsgPack:()=>Ure,layerMsgPackWith:()=>Dre,layerNdJsonRpc:()=>Fre,layerNdjson:()=>_re,layerNdjsonWith:()=>Mre,layerSchemaBinary:()=>Nre,makeMsgPack:()=>xA,makeNdjson:()=>Tb,msgPack:()=>dH,ndJsonRpc:()=>uH,ndjson:()=>aH});var FC;try{FC=new TextDecoder}catch{}var Z,ro,I=0;var D$=[],UC=D$,DC=0,mt={},We,Pc,Xo=0,Pi=0,Hn,_a,oo=[],qe,k$={useRecords:!1,mapsAsObjects:!0},Zm=class{},LC=new Zm;LC.name="MessagePack 0xC1";var Fc=!1,C$=2;var Fi=class e{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.sequential&&t.trusted!==!1&&(t.trusted=!0,!t.structures&&t.useRecords!=!1&&(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0),t.int64AsNumber&&(t.int64AsType="number")),Object.assign(this,t)}unpack(t,n){if(Z)return q$(()=>(eb(),this?this.unpack(t,n):e.prototype.unpack.call(k$,t,n)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof n=="object"?(ro=n.end||t.length,I=n.start||0):(I=0,ro=n>-1?n:t.length),DC=0,Pi=0,Pc=null,UC=D$,Hn=null,Z=t;try{qe=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw Z=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof e){if(mt=this,this.structures)return We=this.structures,XS(n);(!We||We.length>0)&&(We=[])}else mt=k$,(!We||We.length>0)&&(We=[]);return XS(n)}unpackMultiple(t,n){let r,o=0;try{Fc=!0;let s=t.length,i=this?this.unpack(t,s):nb.unpack(t,s);if(n){if(n(i,o,I)===!1)return;for(;I<s;)if(o=I,n(XS(),o,I)===!1)return}else{for(r=[i];I<s;)o=I,r.push(XS());return r}}catch(s){throw s.lastPosition=o,s.values=r,s}finally{Fc=!1,eb()}}_mergeStructures(t,n){this._onLoadedStructures&&(t=this._onLoadedStructures(t)),t=t||[],Object.isFrozen(t)&&(t=t.map(r=>r.slice(0)));for(let r=0,o=t.length;r<o;r++){let s=t[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in n||[])if(r>=0){let o=t[r],s=n[r];s&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[r]=o),t[r]=s)}return this.structures=t}decode(t,n){return this.unpack(t,n)}};function XS(e){try{if(!mt.trusted&&!Fc){let n=We.sharedLength||0;n<We.length&&(We.length=n)}let t;if(mt._readStruct&&Z[I]<64&&Z[I]>=32?(t=mt._readStruct(Z,I,ro),Z=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),I=ro):t=dn(),Hn&&(I=Hn.postBundlePosition,Hn=null),Fc&&(We.restoreStructures=null),I==ro)We&&We.restoreStructures&&A$(),We=null,Z=null,_a&&(_a=null);else{if(I>ro)throw new Error("Unexpected end of MessagePack data");if(!Fc){let n;try{n=JSON.stringify(t,(r,o)=>typeof o=="bigint"?`${o}n`:o).slice(0,100)}catch(r){n="(JSON view not available "+r+")"}throw new Error("Data read, but end of buffer not reached "+n)}}return t}catch(t){throw We&&We.restoreStructures&&A$(),eb(),(t instanceof RangeError||t.message.startsWith("Unexpected end of buffer")||I>ro)&&(t.incomplete=!0),t}}function A$(){for(let e in We.restoreStructures)We[e]=We.restoreStructures[e];We.restoreStructures=null}function dn(){let e=Z[I++];if(e<160)if(e<128){if(e<64)return e;{let t=We[e&63]||mt.getStructures&&N$()[e&63];return t?(t.read||(t.read=BC(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,mt.mapsAsObjects){let t={};for(let n=0;n<e;n++){let r=B$();r==="__proto__"&&(r="__proto_"),t[r]=dn()}return t}else{let t=new Map;for(let n=0;n<e;n++)t.set(dn(),dn());return t}else{e-=144;let t=new Array(e);for(let n=0;n<e;n++)t[n]=dn();return mt.freezeData?Object.freeze(t):t}else if(e<192){let t=e-160;if(Pi>=I)return Pc.slice(I-Xo,(I+=t)-Xo);if(Pi==0&&ro<140){let n=t<16?qC(t):L$(t);if(n!=null)return n}return NC(t)}else{let t;switch(e){case 192:return null;case 193:return Hn?(t=dn(),t>0?Hn[1].slice(Hn.position1,Hn.position1+=t):Hn[0].slice(Hn.position0,Hn.position0-=t)):LC;case 194:return!1;case 195:return!0;case 196:if(t=Z[I++],t===void 0)throw new Error("Unexpected end of buffer");return PC(t);case 197:return t=qe.getUint16(I),I+=2,PC(t);case 198:return t=qe.getUint32(I),I+=4,PC(t);case 199:return rf(Z[I++]);case 200:return t=qe.getUint16(I),I+=2,rf(t);case 201:return t=qe.getUint32(I),I+=4,rf(t);case 202:if(t=qe.getFloat32(I),mt.useFloat32>2){let n=tb[(Z[I]&127)<<1|Z[I+1]>>7];return I+=4,(n*t+(t>0?.5:-.5)>>0)/n}return I+=4,t;case 203:return t=qe.getFloat64(I),I+=8,t;case 204:return Z[I++];case 205:return t=qe.getUint16(I),I+=2,t;case 206:return t=qe.getUint32(I),I+=4,t;case 207:return mt.int64AsType==="number"?(t=qe.getUint32(I)*4294967296,t+=qe.getUint32(I+4)):mt.int64AsType==="string"?t=qe.getBigUint64(I).toString():mt.int64AsType==="auto"?(t=qe.getBigUint64(I),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=qe.getBigUint64(I),I+=8,t;case 208:return qe.getInt8(I++);case 209:return t=qe.getInt16(I),I+=2,t;case 210:return t=qe.getInt32(I),I+=4,t;case 211:return mt.int64AsType==="number"?(t=qe.getInt32(I)*4294967296,t+=qe.getUint32(I+4)):mt.int64AsType==="string"?t=qe.getBigInt64(I).toString():mt.int64AsType==="auto"?(t=qe.getBigInt64(I),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=qe.getBigInt64(I),I+=8,t;case 212:if(t=Z[I++],t==114)return F$(Z[I++]&63);{let n=oo[t];if(n)return n.read?(I++,n.read(dn())):n.noBuffer?(I++,n()):n(Z.subarray(I,++I));throw new Error("Unknown extension "+t)}case 213:return t=Z[I],t==114?(I++,F$(Z[I++]&63,Z[I++])):rf(2);case 214:return rf(4);case 215:return rf(8);case 216:return rf(16);case 217:return t=Z[I++],Pi>=I?Pc.slice(I-Xo,(I+=t)-Xo):Cte(t);case 218:return t=qe.getUint16(I),I+=2,Pi>=I?Pc.slice(I-Xo,(I+=t)-Xo):Ate(t);case 219:return t=qe.getUint32(I),I+=4,Pi>=I?Pc.slice(I-Xo,(I+=t)-Xo):Rte(t);case 220:return t=qe.getUint16(I),I+=2,O$(t);case 221:return t=qe.getUint32(I),I+=4,O$(t);case 222:return t=qe.getUint16(I),I+=2,_$(t);case 223:return t=qe.getUint32(I),I+=4,_$(t);default:if(e>=224)return e-256;throw e===void 0?jC():new Error("Unknown MessagePack token "+e)}}}var kte=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function BC(e,t){function n(){if(n.count++>C$){let o;try{o=e.read=new Function("r","return function(){return "+(mt.freezeData?"Object.freeze":"")+"({"+e.map(s=>s==="__proto__"?"__proto_:r()":kte.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"})}")(dn)}catch{return C$=1/0,n()}return e.read0=o,e.highByte===0&&(e.read=R$(t,e.read)),o()}let r={};for(let o=0,s=e.length;o<s;o++){let i=e[o];i==="__proto__"&&(i="__proto_"),r[i]=dn()}return mt.freezeData?Object.freeze(r):r}return n.count=0,e.read0=n,e.highByte===0?R$(t,n):n}var R$=(e,t)=>function(){let n=Z[I++];if(n===0)return t();let r=e<32?-(e+(n<<5)):e+(n<<5),o=We[r]||N$()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=BC(o,e)),o.read()};function N$(){let e=q$(()=>(Z=null,mt.getStructures()));return We=mt._mergeStructures(e,We)}var NC=Qm,Cte=Qm,Ate=Qm,Rte=Qm;function Qm(e){let t;if(e<16&&(t=qC(e)))return t;if(e>64&&FC)return FC.decode(Z.subarray(I,I+=e));let n=I+e,r=[];for(t="";I<n;){let o=Z[I++];if((o&128)===0)r.push(o);else if((o&224)===192)if(o<194||I>=n||(Z[I]&192)!==128)r.push(65533);else{let s=Z[I++]&63;r.push((o&31)<<6|s)}else if((o&240)===224){let s=I<n?Z[I]:0;if(I>=n||(s&192)!==128||o===224&&s<160||o===237&&s>=160)r.push(65533);else if(I++,I>=n||(Z[I]&192)!==128)r.push(65533);else{let i=Z[I++]&63;r.push((o&31)<<12|(s&63)<<6|i)}}else if((o&248)===240){let s=I<n?Z[I]:0;if(o>244||I>=n||(s&192)!==128||o===240&&s<144||o===244&&s>=144)r.push(65533);else if(I++,I>=n||(Z[I]&192)!==128)r.push(65533);else{let i=Z[I++]&63;if(I>=n||(Z[I]&192)!==128)r.push(65533);else{let a=Z[I++]&63,c=(o&7)<<18|(s&63)<<12|i<<6|a;c-=65536,r.push(c>>>10&1023|55296),r.push(56320|c&1023)}}}else r.push(65533);r.length>=4096&&(t+=zn.apply(String,r),r.length=0)}return r.length>0&&(t+=zn.apply(String,r)),t}function jC(){let e=new Error("Unexpected end of MessagePack data");return e.incomplete=!0,e}function O$(e){if(e>ro-I)throw jC();let t=new Array(e);for(let n=0;n<e;n++)t[n]=dn();return mt.freezeData?Object.freeze(t):t}function _$(e){if(e>(ro-I)/2)throw jC();if(mt.mapsAsObjects){let t={};for(let n=0;n<e;n++){let r=B$();r==="__proto__"&&(r="__proto_"),t[r]=dn()}return t}else{let t=new Map;for(let n=0;n<e;n++)t.set(dn(),dn());return t}}var zn=String.fromCharCode;function L$(e){let t=I,n=new Array(e);for(let r=0;r<e;r++){let o=Z[I++];if((o&128)>0){I=t;return}n[r]=o}return zn.apply(String,n)}function qC(e){if(e<4)if(e<2){if(e===0)return"";{let t=Z[I++];if((t&128)>1){I-=1;return}return zn(t)}}else{let t=Z[I++],n=Z[I++];if((t&128)>0||(n&128)>0){I-=2;return}if(e<3)return zn(t,n);let r=Z[I++];if((r&128)>0){I-=3;return}return zn(t,n,r)}else{let t=Z[I++],n=Z[I++],r=Z[I++],o=Z[I++];if((t&128)>0||(n&128)>0||(r&128)>0||(o&128)>0){I-=4;return}if(e<6){if(e===4)return zn(t,n,r,o);{let s=Z[I++];if((s&128)>0){I-=5;return}return zn(t,n,r,o,s)}}else if(e<8){let s=Z[I++],i=Z[I++];if((s&128)>0||(i&128)>0){I-=6;return}if(e<7)return zn(t,n,r,o,s,i);let a=Z[I++];if((a&128)>0){I-=7;return}return zn(t,n,r,o,s,i,a)}else{let s=Z[I++],i=Z[I++],a=Z[I++],c=Z[I++];if((s&128)>0||(i&128)>0||(a&128)>0||(c&128)>0){I-=8;return}if(e<10){if(e===8)return zn(t,n,r,o,s,i,a,c);{let u=Z[I++];if((u&128)>0){I-=9;return}return zn(t,n,r,o,s,i,a,c,u)}}else if(e<12){let u=Z[I++],f=Z[I++];if((u&128)>0||(f&128)>0){I-=10;return}if(e<11)return zn(t,n,r,o,s,i,a,c,u,f);let l=Z[I++];if((l&128)>0){I-=11;return}return zn(t,n,r,o,s,i,a,c,u,f,l)}else{let u=Z[I++],f=Z[I++],l=Z[I++],p=Z[I++];if((u&128)>0||(f&128)>0||(l&128)>0||(p&128)>0){I-=12;return}if(e<14){if(e===12)return zn(t,n,r,o,s,i,a,c,u,f,l,p);{let m=Z[I++];if((m&128)>0){I-=13;return}return zn(t,n,r,o,s,i,a,c,u,f,l,p,m)}}else{let m=Z[I++],h=Z[I++];if((m&128)>0||(h&128)>0){I-=14;return}if(e<15)return zn(t,n,r,o,s,i,a,c,u,f,l,p,m,h);let g=Z[I++];if((g&128)>0){I-=15;return}return zn(t,n,r,o,s,i,a,c,u,f,l,p,m,h,g)}}}}}function M$(){let e=Z[I++],t;if(e<192)t=e-160;else switch(e){case 217:t=Z[I++];break;case 218:t=qe.getUint16(I),I+=2;break;case 219:t=qe.getUint32(I),I+=4;break;default:throw new Error("Expected string")}return Qm(t)}function PC(e){return mt.copyBuffers?Uint8Array.prototype.slice.call(Z,I,I+=e):Z.subarray(I,I+=e)}function rf(e){let t=Z[I++];if(oo[t]){let n;return oo[t](Z.subarray(I,n=I+=e),r=>{I=r;try{return dn()}finally{I=n}})}else throw new Error("Unknown extension type "+t)}var P$=new Array(4096);function B$(){let e=Z[I++];if(e>=160&&e<192){if(e=e-160,Pi>=I)return Pc.slice(I-Xo,(I+=e)-Xo);if(!(Pi==0&&ro<180))return NC(e)}else return I--,j$(dn());let t=(e<<5^(e>1?qe.getUint16(I):e>0?Z[I]:0))&4095,n=P$[t],r=I,o=I+e-3,s,i=0;if(n&&n.bytes==e){for(;r<o;){if(s=qe.getUint32(r),s!=n[i++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(s=Z[r++],s!=n[i++]){r=1879048192;break}if(r===o)return I=r,n.string;o-=3,r=I}for(n=[],P$[t]=n,n.bytes=e;r<o;)s=qe.getUint32(r),n.push(s),r+=4;for(o+=3;r<o;)s=Z[r++],n.push(s);let a=e<16?qC(e):L$(e);return a!=null?n.string=a:n.string=NC(e)}function j$(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return e.toString();if(e==null)return e+"";if(mt.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(t=>["string","number","boolean","bigint"].includes(typeof t)))return e.flat().toString();throw new Error(`Invalid property type for record: ${typeof e}`)}var F$=(e,t)=>{let n=dn().map(j$),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,n.highByte=t);let o=We[e];return o&&(o.isShared||Fc)&&((We.restoreStructures||(We.restoreStructures=[]))[e]=o),We[e]=n,n.read=BC(n,r),(n.read0||n.read)()};oo[0]=()=>{};oo[0].noBuffer=!0;oo[66]=e=>{let t=e.byteLength%8||8,n=BigInt(e[0]&128?e[0]-256:e[0]);for(let r=1;r<t;r++)n<<=BigInt(8),n+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),o=(s,i)=>{let a=i-s;if(a<=40){let l=r.getBigUint64(s);for(let p=s+8;p<i;p+=8)l<<=BigInt(64),l|=r.getBigUint64(p);return l}let c=s+(a>>4<<3),u=o(s,c),f=o(c,i);return u<<BigInt((i-c)*8)|f};n=n<<BigInt((r.byteLength-t)*8)|o(t,r.byteLength)}return n};var U$={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null};oo[101]=()=>{let e=dn();if(!U$[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return U$[e[0]](e[1],{cause:e[2]})};oo[105]=e=>{if(mt.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=qe.getUint32(I-4);_a||(_a=new Map);let n=Z[I],r;n>=144&&n<160||n==220||n==221?r=[]:n>=128&&n<144||n==222||n==223?r=new Map:(n>=199&&n<=201||n>=212&&n<=216)&&Z[I+1]===115?r=new Set:r={};let o={target:r};_a.set(t,o);let s=dn();if(o.used)Object.assign(r,s);else return o.target=s;if(r instanceof Map)for(let[i,a]of s.entries())r.set(i,a);if(r instanceof Set)for(let i of Array.from(s))r.add(i);return r};oo[112]=e=>{if(mt.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=qe.getUint32(I-4),n=_a.get(t);return n.used=!0,n.target};oo[115]=()=>new Set(dn());var $C=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array"),Ote=typeof globalThis=="object"?globalThis:window;oo[116]=e=>{let t=e[0],n=Uint8Array.prototype.slice.call(e,1).buffer,r=$C[t];if(!r){if(t===16)return n;if(t===17)return new DataView(n);throw new Error("Could not find typed array for code "+t)}return new Ote[r](n)};oo[120]=()=>{let e=dn();return new RegExp(e[0],e[1])};var _te=[];oo[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],n=I;return I+=t-e.length,Hn=_te,Hn=[M$(),M$()],Hn.position0=0,Hn.position1=0,Hn.postBundlePosition=I,I=n,dn()};oo[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function q$(e){mt&&mt._onSaveState&&mt._onSaveState();let t=ro,n=I,r=DC,o=Xo,s=Pi,i=Pc,a=UC,c=_a,u=Hn,f=new Uint8Array(Z.slice(0,ro)),l=We,p=We.slice(0,We.length),m=mt,h=Fc,g=e();return ro=t,I=n,DC=r,Xo=o,Pi=s,Pc=i,UC=a,_a=c,Hn=u,Z=f,Fc=h,We=l,We.splice(0,We.length,...p),mt=m,qe=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),g}function eb(){Z=null,_a=null,We=null}var tb=new Array(147);for(let e=0;e<256;e++)tb[e]=+("1e"+Math.floor(45.15-e*.30103));var nb=new Fi({useRecords:!1}),Mte=nb.unpack,Pte=nb.unpackMultiple,Fte=nb.unpack,rb={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Ute=new Float32Array(1),qpe=new Uint8Array(Ute.buffer,0,4);Fi.SUPPORTS_STRUCT_HOOKS=!0;var sb;try{sb=new TextEncoder}catch{}var WC,KC,cd=typeof Buffer<"u",ob=cd?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,W$=cd?Buffer:Uint8Array,$$=cd?4294967296:2144337920,O,Ym,Ot,k=0,hr,Yt=null,Dte=21760,Nte=/[\u0080-\uFFFF]/,ad=Symbol("record-id"),Uc=class extends Fi{constructor(t){super(t),this.offset=0;let n,r,o,s,i,a=W$.prototype.utf8Write?function(T,z){return O.utf8Write(T,z,O.byteLength-z)}:sb&&sb.encodeInto?function(T,z){return sb.encodeInto(T,O.subarray(z)).written}:!1,c=this;t||(t={});let u=t&&t.sequential,f=t.structures||t.saveStructures,l=t.maxSharedStructures;if(l==null&&(l=f?32:0),l>8160)throw new Error("Maximum maxSharedStructure is 8160");t.structuredClone&&t.moreTypes==null&&(this.moreTypes=!0);let p=t.maxOwnStructures;p==null&&(p=f?32:64),!this.structures&&t.useRecords!=!1&&(this.structures=[]);let m=l>32||p+l>64,h=l+64,g=l+p+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let x=[],E=0,b=0;this.pack=this.encode=function(T,z){if(O||(O=new ob(8192),Ot=O.dataView||(O.dataView=new DataView(O.buffer,0,8192)),k=0),hr=O.length-10,hr-k<2048?(O=new ob(O.length),Ot=O.dataView||(O.dataView=new DataView(O.buffer,0,O.length)),hr=O.length-10,k=0):k=k+7&2147483640,r=k,z&G$&&(k+=z&255),i=c.structuredClone?new Map:null,c.bundleStrings&&typeof T!="string"?(Yt=[],Yt.size=1/0):Yt=null,s=c.structures,s){s.uninitialized&&(s=c._mergeStructures(c.getStructures()));let N=s.sharedLength||0;if(N>l)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+s.sharedLength);if(!s.transitions){s.transitions=Object.create(null);for(let V=0;V<N;V++){let Ee=s[V];if(!Ee)continue;let Ie,de=s.transitions;for(let ut=0,bt=Ee.length;ut<bt;ut++){let Vs=Ee[ut];Ie=de[Vs],Ie||(Ie=de[Vs]=Object.create(null)),de=Ie}de[ad]=V+64}this.lastNamedStructuresLength=N}u||(s.nextId=N+64)}o&&(o=!1);let U;try{c._writeStruct&&T&&typeof T=="object"?T.constructor===Object?$(T):T.constructor!==Map&&!Array.isArray(T)&&!KC.some(V=>T instanceof V)?$(c.useToJSON!==!1&&T.toJSON?T.toJSON():T):S(T):S(T);let N=Yt;if(Yt&&H$(r,S,0),i&&i.idsToInsert){let V=i.idsToInsert.sort((ut,bt)=>ut.offset>bt.offset?1:-1),Ee=V.length,Ie=-1;for(;N&&Ee>0;){let ut=V[--Ee].offset+r;ut<N.stringsPosition+r&&Ie===-1&&(Ie=0),ut>N.position+r?Ie>=0&&(Ie+=6):(Ie>=0&&(Ot.setUint32(N.position+r,Ot.getUint32(N.position+r)+Ie),Ie=-1),N=N.previous,Ee++)}Ie>=0&&N&&Ot.setUint32(N.position+r,Ot.getUint32(N.position+r)+Ie),k+=V.length*6,k>hr&&F(k),c.offset=k;let de=Lte(O.subarray(r,k),V);return i=null,de}return c.offset=k,z&V$?(O.start=r,O.end=k,O):O.subarray(r,k)}catch(N){throw U=N,N}finally{if(s&&(y(),o&&c.saveStructures)){let N=s.sharedLength||0,V=O.subarray(r,k),Ee=(c._prepareStructures||Bte)(s,c);if(!U)return c.saveStructures(Ee,Ee.isCompatible)===!1?(s.uninitialized=!0,c.pack(T,z)):(c.lastNamedStructuresLength=N,O.length>1073741824&&(O=null),V)}O.length>1073741824&&(O=null),z&J$&&(k=r)}};let y=()=>{b<10&&b++;let T=s.sharedLength||0;if(s.length>T&&!u&&(s.length=T),E>1e4)s.transitions=null,b=0,E=0,x.length>0&&(x=[]);else if(x.length>0&&!u){for(let z=0,U=x.length;z<U;z++)x[z][ad]=0;x=[]}},w=T=>{var z=T.length;z<16?O[k++]=144|z:z<65536?(O[k++]=220,O[k++]=z>>8,O[k++]=z&255):(O[k++]=221,Ot.setUint32(k,z),k+=4);for(let U=0;U<z;U++)S(T[U])},S=T=>{k>hr&&(O=F(k));var z=typeof T,U;if(z==="string"){let N=T.length;if(Yt&&N>=4&&N<4096){if((Yt.size+=N)>Dte){let de,ut=(Yt[0]?Yt[0].length*3+Yt[1].length:0)+10;k+ut>hr&&(O=F(k+ut));let bt;Yt.position?(bt=Yt,O[k]=200,k+=3,O[k++]=98,de=k-r,k+=4,H$(r,S,0),Ot.setUint16(de+r-3,k-r-de)):(O[k++]=214,O[k++]=98,de=k-r,k+=4),Yt=["",""],Yt.previous=bt,Yt.size=0,Yt.position=de}let Ie=Nte.test(T);Yt[Ie?0:1]+=T,O[k++]=193,S(Ie?-N:N);return}let V;N<32?V=1:N<256?V=2:N<65536?V=3:V=5;let Ee=N*3;if(k+Ee>hr&&(O=F(k+Ee)),N<64||!a){let Ie,de,ut,bt=k+V;for(Ie=0;Ie<N;Ie++)de=T.charCodeAt(Ie),de<128?O[bt++]=de:de<2048?(O[bt++]=de>>6|192,O[bt++]=de&63|128):(de&64512)===55296&&((ut=T.charCodeAt(Ie+1))&64512)===56320?(de=65536+((de&1023)<<10)+(ut&1023),Ie++,O[bt++]=de>>18|240,O[bt++]=de>>12&63|128,O[bt++]=de>>6&63|128,O[bt++]=de&63|128):(O[bt++]=de>>12|224,O[bt++]=de>>6&63|128,O[bt++]=de&63|128);U=bt-k-V}else U=a(T,k+V);U<32?O[k++]=160|U:U<256?(V<2&&O.copyWithin(k+2,k+1,k+1+U),O[k++]=217,O[k++]=U):U<65536?(V<3&&O.copyWithin(k+3,k+2,k+2+U),O[k++]=218,O[k++]=U>>8,O[k++]=U&255):(V<5&&O.copyWithin(k+5,k+3,k+3+U),O[k++]=219,Ot.setUint32(k,U),k+=4),k+=U}else if(z==="number")if(T>>>0===T)T<32||T<128&&this.useRecords===!1||T<64&&!this._writeStruct?O[k++]=T:T<256?(O[k++]=204,O[k++]=T):T<65536?(O[k++]=205,O[k++]=T>>8,O[k++]=T&255):(O[k++]=206,Ot.setUint32(k,T),k+=4);else if(T>>0===T)T>=-32?O[k++]=256+T:T>=-128?(O[k++]=208,O[k++]=T+256):T>=-32768?(O[k++]=209,Ot.setInt16(k,T),k+=2):(O[k++]=210,Ot.setInt32(k,T),k+=4);else{let N;if((N=this.useFloat32)>0&&T<4294967296&&T>=-2147483648){O[k++]=202,Ot.setFloat32(k,T);let V;if(N<4||(V=T*tb[(O[k]&127)<<1|O[k+1]>>7])>>0===V){k+=4;return}else k--}O[k++]=203,Ot.setFloat64(k,T),k+=8}else if(z==="object"||z==="function")if(!T)O[k++]=192;else{if(i){let V=i.get(T);if(V){if(!V.id){let Ee=i.idsToInsert||(i.idsToInsert=[]);V.id=Ee.push(V)}O[k++]=214,O[k++]=112,Ot.setUint32(k,V.id),k+=4;return}else i.set(T,{offset:k-r})}let N=T.constructor;if(N===Object)P(T);else if(N===Array)w(T);else if(N===Map)if(this.mapAsEmptyObject)O[k++]=128;else{U=T.size,U<16?O[k++]=128|U:U<65536?(O[k++]=222,O[k++]=U>>8,O[k++]=U&255):(O[k++]=223,Ot.setUint32(k,U),k+=4);for(let[V,Ee]of T)S(V),S(Ee)}else{for(let V=0,Ee=WC.length;V<Ee;V++){let Ie=KC[V];if(T instanceof Ie){let de=WC[V];if(de.write){de.type&&(O[k++]=212,O[k++]=de.type,O[k++]=0);let dd=de.write.call(this,T);dd===T?Array.isArray(T)?w(T):P(T):S(dd);return}let ut=O,bt=Ot,Vs=k;O=null;let Pa;try{Pa=de.pack.call(this,T,dd=>(O=ut,ut=null,k+=dd,k>hr&&F(k),{target:O,targetView:Ot,position:k-dd}),S)}finally{ut&&(O=ut,Ot=bt,k=Vs,hr=O.length-10)}Pa&&(Pa.length+k>hr&&F(Pa.length+k),k=z$(Pa,O,k,de.type));return}}if(Array.isArray(T))w(T);else{if(c.useToJSON!==!1&&T.toJSON){let V=T.toJSON();if(V!==T)return S(V)}if(z==="function")return S(this.writeFunction&&this.writeFunction(T));P(T)}}}else if(z==="boolean")O[k++]=T?195:194;else if(z==="bigint"){if(T<9223372036854776e3&&T>=-9223372036854776e3)O[k++]=211,Ot.setBigInt64(k,T);else if(T<18446744073709552e3&&T>0)O[k++]=207,Ot.setBigUint64(k,T);else if(this.largeBigIntToFloat)O[k++]=203,Ot.setFloat64(k,Number(T));else{if(this.largeBigIntToString)return S(T.toString());if(this.useBigIntExtension||this.moreTypes){let N=T<0?BigInt(-1):BigInt(0),V;if(T>>BigInt(65536)===N){let Ee=BigInt(18446744073709552e3)-BigInt(1),Ie=[];for(;Ie.push(T&Ee),T>>BigInt(63)!==N;)T>>=BigInt(64);V=new Uint8Array(new BigUint64Array(Ie).buffer),V.reverse()}else{let Ee=T<0,Ie=(Ee?~T:T).toString(16);if(Ie.length%2?Ie="0"+Ie:parseInt(Ie.charAt(0),16)>=8&&(Ie="00"+Ie),cd)V=Buffer.from(Ie,"hex");else{V=new Uint8Array(Ie.length/2);for(let de=0;de<V.length;de++)V[de]=parseInt(Ie.slice(de*2,de*2+2),16)}if(Ee)for(let de=0;de<V.length;de++)V[de]=~V[de]}V.length+k>hr&&F(V.length+k),k=z$(V,O,k,66);return}else throw new RangeError(T+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string")}k+=8}else if(z==="undefined")this.encodeUndefinedAsNil?O[k++]=192:(O[k++]=212,O[k++]=0,O[k++]=0);else throw new Error("Unknown type: "+z)},C=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?T=>{let z;if(this.skipValues){z=[];for(let V in T)(typeof T.hasOwnProperty!="function"||T.hasOwnProperty(V))&&!this.skipValues.includes(T[V])&&z.push(V)}else z=Object.keys(T);let U=z.length;U<16?O[k++]=128|U:U<65536?(O[k++]=222,O[k++]=U>>8,O[k++]=U&255):(O[k++]=223,Ot.setUint32(k,U),k+=4);let N;if(this.coercibleKeyAsNumber)for(let V=0;V<U;V++){N=z[V];let Ee=Number(N);S(isNaN(Ee)?N:Ee),S(T[N])}else for(let V=0;V<U;V++)S(N=z[V]),S(T[N])}:T=>{O[k++]=222;let z=k-r;k+=2;let U=0;for(let N in T)(typeof T.hasOwnProperty!="function"||T.hasOwnProperty(N))&&(S(N),S(T[N]),U++);if(U>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');O[z+++r]=U>>8,O[z+r]=U&255},M=this.useRecords===!1?C:t.progressiveRecords&&!m?T=>{let z,U=s.transitions||(s.transitions=Object.create(null)),N=k++-r,V;for(let Ee in T)if(typeof T.hasOwnProperty!="function"||T.hasOwnProperty(Ee)){if(z=U[Ee],z)U=z;else{let Ie=Object.keys(T),de=U;U=s.transitions;let ut=0;for(let bt=0,Vs=Ie.length;bt<Vs;bt++){let Pa=Ie[bt];z=U[Pa],z||(z=U[Pa]=Object.create(null),ut++),U=z}N+r+1==k?(k--,te(U,Ie,ut)):ee(U,Ie,N,ut),V=!0,U=de[Ee]}S(T[Ee])}if(!V){let Ee=U[ad];Ee?O[N+r]=Ee:ee(U,Object.keys(T),N,0)}}:T=>{let z,U=s.transitions||(s.transitions=Object.create(null)),N=0;for(let Ee in T)(typeof T.hasOwnProperty!="function"||T.hasOwnProperty(Ee))&&(z=U[Ee],z||(z=U[Ee]=Object.create(null),N++),U=z);let V=U[ad];V?V>=96&&m?(O[k++]=((V-=96)&31)+96,O[k++]=V>>5):O[k++]=V:te(U,U.__keys__||Object.keys(T),N);for(let Ee in T)(typeof T.hasOwnProperty!="function"||T.hasOwnProperty(Ee))&&S(T[Ee])},_=typeof this.useRecords=="function"&&this.useRecords,P=_?T=>{_(T)?M(T):C(T)}:M,$=T=>{let z=c._writeStruct(T,O,r,k,s,F,(U,N,V)=>{if(V)return o=!0;k=N;let Ee=O;return S(U),y(),Ee!==O?{position:k,targetView:Ot,target:O}:k});if(z===0)return P(T);k=z},F=T=>{let z;if(T>16777216){if(T-r>$$)throw new Error("Packed buffer would be larger than maximum buffer size");z=Math.min($$,Math.round(Math.max((T-r)*(T>67108864?1.25:2),4194304)/4096)*4096)}else z=(Math.max(T-r<<2,O.length-1)>>12)+1<<12;let U=new ob(z);return Ot=U.dataView||(U.dataView=new DataView(U.buffer,0,z)),T=Math.min(T,O.length),O.copy?O.copy(U,0,r,T):U.set(O.slice(r,T)),k-=r,r=0,hr=U.length-10,O=U},te=(T,z,U)=>{let N=s.nextId;N||(N=64),N<h&&this.shouldShareStructure&&!this.shouldShareStructure(z)?(N=s.nextOwnId,N<g||(N=h),s.nextOwnId=N+1):(N>=g&&(N=h),s.nextId=N+1);let V=z.highByte=N>=96&&m?N-96>>5:-1;T[ad]=N,T.__keys__=z,s[N-64]=z,N<h?(z.isShared=!0,s.sharedLength=N-63,o=!0,V>=0?(O[k++]=(N&31)+96,O[k++]=V):O[k++]=N):(V>=0?(O[k++]=213,O[k++]=114,O[k++]=(N&31)+96,O[k++]=V):(O[k++]=212,O[k++]=114,O[k++]=N),U&&(E+=b*U),x.length>=p&&(x.shift()[ad]=0),x.push(T),S(z))},ee=(T,z,U,N)=>{let V=O,Ee=k,Ie=hr,de=r;O=Ym,k=0,r=0,O||(Ym=O=new ob(8192)),hr=O.length-10,te(T,z,N),Ym=O;let ut=k;if(O=V,k=Ee,hr=Ie,r=de,ut>1){let bt=k+ut-1;bt>hr&&F(bt);let Vs=U+r;O.copyWithin(Vs+ut,Vs+1,k),O.set(Ym.slice(0,ut),Vs),k=bt}else O[U+r]=Ym[0]}}useBuffer(t){O=t,O.dataView||(O.dataView=new DataView(O.buffer,O.byteOffset,O.byteLength)),Ot=O.dataView,k=0}set position(t){k=t}get position(){return k}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}};KC=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,Zm];WC=[{pack(e,t,n){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:s,position:i}=t(6);o[i++]=214,o[i++]=255,s.setUint32(i,r)}else if(r>0&&r<4294967296){let{target:o,targetView:s,position:i}=t(10);o[i++]=215,o[i++]=255,s.setUint32(i,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(i+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),n(this.onInvalidDate());let{target:o,targetView:s,position:i}=t(3);o[i++]=212,o[i++]=255,o[i++]=255}else{let{target:o,targetView:s,position:i}=t(15);o[i++]=199,o[i++]=12,o[i++]=255,s.setUint32(i,e.getMilliseconds()*1e6),s.setBigInt64(i+4,BigInt(Math.floor(r)))}}},{pack(e,t,n){if(this.setAsEmptyObject)return t(0),n({});let r=Array.from(e),{target:o,position:s}=t(this.moreTypes?3:0);this.moreTypes&&(o[s++]=212,o[s++]=115,o[s++]=0),n(r)}},{pack(e,t,n){let{target:r,position:o}=t(this.moreTypes?3:0);this.moreTypes&&(r[o++]=212,r[o++]=101,r[o++]=0),n([e.name,e.message,e.cause])}},{pack(e,t,n){let{target:r,position:o}=t(this.moreTypes?3:0);this.moreTypes&&(r[o++]=212,r[o++]=120,r[o++]=0),n([e.source,e.flags])}},{pack(e,t){this.moreTypes?zC(e,16,t):HC(cd?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let n=e.constructor;n!==W$&&this.moreTypes?zC(e,$C.indexOf(n.name),t):HC(e,t)}},{pack(e,t){this.moreTypes?zC(e,17,t):HC(cd?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:n,position:r}=t(1);n[r]=193}}];function zC(e,t,n,r){let o=e.byteLength;if(o+1<256){var{target:s,position:i}=n(4+o);s[i++]=199,s[i++]=o+1}else if(o+1<65536){var{target:s,position:i}=n(5+o);s[i++]=200,s[i++]=o+1>>8,s[i++]=o+1&255}else{var{target:s,position:i,targetView:a}=n(7+o);s[i++]=201,a.setUint32(i,o+1),i+=4}s[i++]=116,s[i++]=t,e.buffer||(e=new Uint8Array(e)),s.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),i)}function HC(e,t){let n=e.byteLength;var r,o;if(n<256){var{target:r,position:o}=t(n+2);r[o++]=196,r[o++]=n}else if(n<65536){var{target:r,position:o}=t(n+3);r[o++]=197,r[o++]=n>>8,r[o++]=n&255}else{var{target:r,position:o,targetView:s}=t(n+5);r[o++]=198,s.setUint32(o,n),o+=4}r.set(e,o)}function z$(e,t,n,r){let o=e.length;switch(o){case 1:t[n++]=212;break;case 2:t[n++]=213;break;case 4:t[n++]=214;break;case 8:t[n++]=215;break;case 16:t[n++]=216;break;default:o<256?(t[n++]=199,t[n++]=o):o<65536?(t[n++]=200,t[n++]=o>>8,t[n++]=o&255):(t[n++]=201,t[n++]=o>>24,t[n++]=o>>16&255,t[n++]=o>>8&255,t[n++]=o&255)}return t[n++]=r,t.set(e,n),n+=o,n}function Lte(e,t){let n,r=t.length*6,o=e.length-r;for(;n=t.pop();){let s=n.offset,i=n.id;e.copyWithin(s+r,s,o),r-=6;let a=s+r;e[a++]=214,e[a++]=105,e[a++]=i>>24,e[a++]=i>>16&255,e[a++]=i>>8&255,e[a++]=i&255,o=s}return e}function H$(e,t,n){if(Yt.length>0){Ot.setUint32(Yt.position+e,k+n-Yt.position-e),Yt.stringsPosition=k-e;let r=Yt;Yt=null,t(r[0]),t(r[1])}}function Bte(e,t){return e.isCompatible=n=>{let r=!n||(t.lastNamedStructuresLength||0)===n.length;return r||t._mergeStructures(n),r},e}Uc.SUPPORTS_STRUCT_HOOKS=!0;var K$=new Uc({useRecords:!1}),jte=K$.pack,qte=K$.pack;var{NEVER:$te,ALWAYS:zte,DECIMAL_ROUND:Hte,DECIMAL_FIT:Wte}=rb,V$=512,J$=1024,G$=2048;function mz(e,t){let{exact:n,layout:r,recursive:o,target:s}=ld(e),i=sf(r,t?.fingerprint),a=n?{value:void 0}:void 0;return JC(a===void 0?s:bre(s,a,!o),r,i,a)}function iA(e,t){let{exact:n,exitSuccess:r,layout:o,target:s}=ld(e);if(!n){if(!r)return mz(e,t);let i={value:void 0};return JC(wre(s,i),o,sf(o,t?.fingerprint),i,!0)}return JC(Ire(s),o,sf(o,t?.fingerprint),void 0)}function JC(e,t,n,r,o=!1){return Go.pipe(be(e,xre(t,n,r,o)))}function hz(e,t){let{exact:n,exitSuccess:r,layout:o}=ld(e),s=sf(o,t?.fingerprint),i=t??Xr;if(!n){let a=uS(mz(e,t),t);return!r||i.onExcessProperty==="error"?a:c=>{if(!Ib(c))return a(c);try{return yb(o,c,i,s)}catch(u){throw u instanceof Di?new Mr(u.issue):u}}}return a=>{try{return yb(o,a,i,s)}catch(c){throw c instanceof Di?new Mr(c.issue):c}}}function Vte(e,t){let{exact:n,layout:r}=ld(e);if(!n){let i=hz(e,t);return a=>Jte(a.map(i))}let o=sf(r,t?.fingerprint),s=t??Xr;return i=>{try{return Kz(r,i,s,o)}catch(a){throw a instanceof Di?new Mr(a.issue):a}}}function Jte(e){if(e.length===1)return e[0];let t=0;for(let o of e)t+=o.length;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.length;return n}function gz(e,t){let{exact:n,exitSuccess:r,layout:o,target:s}=ld(e),i=t??Xr,a=n?void 0:aS(s,i),c=a!==void 0&&r?u=>Ib(u)?u:a(u):a;return Gte(o,sf(o,t?.fingerprint),i,t?.maxFrameSize,c,xz(n,t))}function xz(e,t){if(t?.dictionary!==!0)return!1;if(!e)throw new Error("Binary layout: dictionary needs a schema the binary layer validates on its own");return!0}function yz(e,t){let{exact:n,layout:r}=ld(e),o=xz(n,t),s=hz(e,t),i=Vte(e,t);if(!o)return{encode:s,encodeMany:i};let a=sf(r,t?.fingerprint),c=t??Xr,u=$ne(),f=l=>{try{return l()}catch(p){throw p instanceof Di?new Mr(p.issue):p}};return{encode:l=>f(()=>yb(r,l,c,a,u)),encodeMany:l=>f(()=>Kz(r,l,c,a,u))}}function Gte(e,t,n,r,o,s){let i=s?[]:void 0,a=new Uint8Array(0),c=0,u=0,f,l=!1,p=new th,m=new eh(n,mne),h=()=>{p.release(),m.clear(),a=XC,c=u=0},g=(y,w)=>{throw new Mr(new ke({expected:y},w,n))},x=()=>{let y=f;throw f=void 0,y},E=(y,w)=>{let S=y.length-w;S>a.length&&(a=new Uint8Array(Math.max(256,S))),a.set(w===0?y:y.subarray(w),0),c=0,u=S},b={feedSync(y){if(f!==void 0)return x();if(l)return g("parser is spent");let w=u===c,S,C,M;if(w)S=y,C=0,M=y.length;else{if(y.length>0){let F=u-c,te=F+y.length;if(te>a.length){let ee=new Uint8Array(Math.max(256,a.length*2,te));ee.set(a.subarray(c,u)),a=ee,c=0,u=F}else c>0&&(a.copyWithin(0,c,u),c=0,u=F);a.set(y,u),u+=y.length}S=a,C=c,M=u}let _=[],P=()=>(w?C<M&&E(y,C):(c=C,c===u&&(c=u=0)),_),$=(F,te)=>{l=!0;let ee=new Mr(new ke({expected:F},te,n));if(h(),_.length===0)throw ee;return f=ee,_};for(;;){let F=0,te=-1,ee=M-C,T=1;for(let U=0;U<Math.min(6,ee);U++){let N=S[C+U];if(F+=(N&127)*T,(N&128)===0){te=U+1;break}T*=128}if(te===-1){if(ee<6)return P();let U=BigInt(F);for(let N=6;N<Math.min(10,ee);N++){let V=S[C+N];if(U|=BigInt(V&127)<<BigInt(N*7),(V&128)===0){if(te=N+1,U>GC)return $("safe integer length",U);F=Number(U);break}}if(te===-1)return ee>=10?$("uvarint",S.subarray(C,C+10)):P()}if(F===0)return $("nonzero frame length",F);if(r!==void 0&&F>r)return $("frame within maxFrameSize",F);if(te+F>ee)return P();let z=ue;try{ue=0;let U=C+te;m.beginFrame(),p.reset(S,U,U+F,n,m,t.positional,i);let N=eH(e,p,t);_.push(o===void 0?N:o(N))}catch(U){l=!0,h();let N=U instanceof Di?new Mr(U.issue):Wl(U)?U:(()=>{throw U})();if(_.length===0)throw N;return f=N,_}finally{ue=z}C+=te+F}},endSync(){if(f!==void 0)return x();if(l)return g("parser is spent");l=!0;let y=c<u?a.subarray(c,u):void 0;if(h(),y!==void 0)return g("complete value",y)},feed:y=>K(()=>{try{return v(b.feedSync(y))}catch(w){if(Wl(w))return G(w);throw w}}),end:K(()=>{try{return b.endSync(),H}catch(y){if(Wl(y))return G(y);throw y}})};return b}var Zte="~effect/encoding/SchemaBinary/fieldId",Qte=32,Yte=33,GC=BigInt(Number.MAX_SAFE_INTEGER),db=BigInt(0),es=BigInt(1),Xte=BigInt(2),Sz=BigInt(7),Z$=BigInt(127),ene=BigInt(1e6),tne=BigInt(255),Q$=BigInt(4294967295),nne=BigInt(32),Ui=new TextEncoder,rne=new TextDecoder("utf-8",{fatal:!0}),bz=7,Y$=0xffffffffffff,one=0xfffffffffffff,Ez=0,wz=1,Iz=2,af=0,of=1,oh=2,sh=3,ih=4,ah=5,sne=6,ine=7,ts=8;function aA(e){return typeof e=="number"&&Number.isInteger(e)&&e>=-Y$&&e<=Y$}var Sb=8,ZC=2199023255551,Nc=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];function cA(e){for(let t=1;t<=Sb;t++){let n=Math.round(e*Nc[t]);if(!(n>=-ZC&&n<=ZC))return 0;if(n/Nc[t]===e)return t}return 0}function vz(e){let t=Math.floor(e/2);return e%2===1?-t:t}var St={bool:1,null:2,undefined:3,number:4,string:5,bytes:6,bigint:7,int64:8,struct:9,variant:10,array:11,option:12,result:13,duration:14,bigDecimal:15,dateTimeZoned:16,json:17,exit:18,cause:19,causeReason:20};function Tz(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e[n],16777619);return t>>>0}var ane=BigInt("14695981039346656037"),cne=BigInt("1099511628211"),une=BigInt("18446744073709551615");function X$(e){let t=ane;for(let n=0;n<e.length;n++)t=(t^BigInt(e[n]))*cne&une;return t}function pb(e,t){for(let n=0;n<t.length;n++)e.push(t[n])}function Dc(e,t){for(;t>127;)e.push(t&127|128),t=Math.floor(t/128);e.push(t)}function mb(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}function Io(e,t){for(let n=0;n<8;n++)e.push(Number(t>>BigInt(n*8)&tne))}function kz(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e[r]-t[r];return e.length-t.length}var Di=class extends Error{issue;constructor(t){super("SchemaBinary failure"),this.issue=t}};function Q(e,t,n){throw pn(new ke({expected:e},t,n))}var nt=[],ue=0;function pn(e){return new Di(ue===0?e:new Ct(nt.slice(0,ue),e))}function fne(e){let t=new Uint8Array(Cz(e)),n=0;for(;e>127;)t[n++]=e&127|128,e=Math.floor(e/128);return t[n]=e,t}function Cz(e){let t=1;for(;e>127;)e=Math.floor(e/128),t++;return t}var lne=32;function dne(e,t,n,r){let o=n-t;if(o===0)return"";if(o<=lne){let s=pne(e,t,n);if(s!==void 0)return s}try{return rne.decode(e.subarray(t,n))}catch{Q("utf-8",void 0,r)}}function pne(e,t,n){let r="",o=t;for(;o+16<=n;o+=16){let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],l=e[o+6],p=e[o+7],m=e[o+8],h=e[o+9],g=e[o+10],x=e[o+11],E=e[o+12],b=e[o+13],y=e[o+14],w=e[o+15];if((s|i|a|c|u|f|l|p|m|h|g|x|E|b|y|w)>127)return;r+=String.fromCharCode(s,i,a,c,u,f,l,p,m,h,g,x,E,b,y,w)}if(o+8<=n){let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],l=e[o+6],p=e[o+7];if((s|i|a|c|u|f|l|p)>127)return;r+=String.fromCharCode(s,i,a,c,u,f,l,p),o+=8}switch(n-o){case 0:return r;case 1:{let s=e[o];return s>127?void 0:r+String.fromCharCode(s)}case 2:{let s=e[o],i=e[o+1];return(s|i)>127?void 0:r+String.fromCharCode(s,i)}case 3:{let s=e[o],i=e[o+1],a=e[o+2];return(s|i|a)>127?void 0:r+String.fromCharCode(s,i,a)}case 4:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3];return(s|i|a|c)>127?void 0:r+String.fromCharCode(s,i,a,c)}case 5:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4];return(s|i|a|c|u)>127?void 0:r+String.fromCharCode(s,i,a,c,u)}case 6:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5];return(s|i|a|c|u|f)>127?void 0:r+String.fromCharCode(s,i,a,c,u,f)}default:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],l=e[o+6];return(s|i|a|c|u|f|l)>127?void 0:r+String.fromCharCode(s,i,a,c,u,f,l)}}}var QC=64*1024,mne=256,hne=512,gne=16*1024;function YC(e){let t=new Uint8Array(e);return{buf:t,view:new DataView(t.buffer),offset:0,writing:!1}}var Xm=YC(QC),hb=class{buf=new Uint8Array(0);view=new DataView(this.buf.buffer);arena;start=0;limit=0;len=0;reset(){let t=Xm;(t.writing||t.offset>=t.buf.length)&&(t=Xm=YC(QC)),t.writing=!0,this.arena=t,this.buf=t.buf,this.view=t.view,this.start=t.offset,this.limit=t.buf.length-t.offset,this.len=0}ensure(t){if(this.len+t>this.limit){let n=this.arena,r=this.len+t,o=QC;for(;o<r;)o*=2;let s=YC(o);s.writing=!0,s.buf.set(this.buf.subarray(this.start,this.start+this.len)),n.writing=!1,this.arena=Xm=s,this.buf=s.buf,this.view=s.view,this.start=0,this.limit=s.buf.length}}byte(t){this.ensure(1),this.buf[this.start+this.len++]=t}bytes(t){this.ensure(t.length),this.buf.set(t,this.start+this.len),this.len+=t.length}uvarint(t){this.ensure(10);let n=this.buf,r=this.start+this.len;if(t<128)n[r++]=t;else if(n[r++]=t&127|128,t<16384)n[r++]=t>>>7;else{for(n[r++]=t>>>7&127|128,t=Math.floor(t/16384);t>127;)n[r++]=t&127|128,t=Math.floor(t/128);n[r++]=t}this.len=r-this.start}uvarintBig(t){for(;t>Z$;)this.byte(Number(t&Z$)|128),t>>=Sz;this.byte(Number(t))}zigzag(t){this.uvarintBig(t>=db?t<<es:(-t<<es)-es)}numberVarint(t){let n=t<0||t===0&&1/t<0,r=n?-t:t;r<=one?this.uvarint(r*2+(n?1:0)):this.uvarintBig(BigInt(r)*Xte+(n?es:db))}f64(t){this.ensure(8),this.view.setFloat64(this.start+this.len,t,!0),this.len+=8}i64(t){this.ensure(8),this.view.setBigInt64(this.start+this.len,t,!0),this.len+=8}u32le(t){this.ensure(4),this.view.setUint32(this.start+this.len,t>>>0,!0),this.len+=4}i32le(t){this.ensure(4),this.view.setInt32(this.start+this.len,t|0,!0),this.len+=4}idAndMark(t){let n=t.length;this.ensure(n+1);let r=this.buf,o=this.start+this.len;for(let i=0;i<n;i++)r[o++]=t[i];let s=o-this.start;return this.len=s+1,s}beginSized(){return this.ensure(1),this.len++}endSized(t){let n=this.len-t-1;n<128?this.buf[this.start+t]=n:this.growSized(t,n)}endSizedRun(t){let n=(this.len-t-1)*2;n<128?this.buf[this.start+t]=n:this.growSized(t,n)}growSized(t,n){let r=Cz(n),o=r-1;this.ensure(o);let s=this.start+t;this.buf.copyWithin(s+r,s+1,this.start+this.len),this.len+=o;let i=n,a=s;for(;i>127;)this.buf[a++]=i&127|128,i=Math.floor(i/128);this.buf[a]=i}string(t){let n=t.length;if(n===0)return;this.ensure(n*3);let r=this.buf,o=this.start+this.len,s=0;for(;s+4<=n;s+=4){let i=t.charCodeAt(s),a=t.charCodeAt(s+1),c=t.charCodeAt(s+2),u=t.charCodeAt(s+3);if((i|a|c|u)>127){this.len+=Ui.encodeInto(t,r.subarray(this.start+this.len)).written;return}r[o++]=i,r[o++]=a,r[o++]=c,r[o++]=u}for(;s<n;s++){let i=t.charCodeAt(s);if(i>127){this.len+=Ui.encodeInto(t,r.subarray(this.start+this.len)).written;return}r[o++]=i}this.len=o-this.start}out(){let t=this.arena,n=new Uint8Array(t.buf.buffer,this.start,this.len);return t===Xm&&(t.offset=this.start+this.len),t.writing=!1,this.arena=void 0,n}abort(){let t=this.arena;t!==void 0&&(t===Xm&&(t.offset=this.start),t.writing=!1,this.arena=void 0)}};function xne(e){let t=jn(e);return t._tag==="String"&&t.checks===void 0}function yne(e,t,n){return e.extra.find(r=>ha({[t]:null},r.parameter,n).length>0)}var eh=class{entries=new WeakMap;orderLayouts;orderKeys;options;size=0;next=0;replace=!1;constructor(t,n){this.options=t,this.orderLayouts=n===void 0?void 0:new Array(n),this.orderKeys=n===void 0?void 0:new Array(n)}beginFrame(){this.replace=!0}find(t,n){let r=this.entries.get(t);if(r===void 0&&(r=new Map,this.entries.set(t,r)),r.has(n))return r.get(n);let o=yne(t,n,this.options),s=this.orderLayouts;if(s===void 0)return r.set(n,o),o;let i=this.orderKeys;if(this.size<s.length)s[this.size]=t,i[this.size]=n,this.size++,r.set(n,o);else if(this.replace){this.replace=!1;let a=s[this.next];(a===t?r:this.entries.get(a))?.delete(i[this.next]),s[this.next]=t,i[this.next]=n,this.next=(this.next+1)%s.length,r.set(n,o)}return o}clear(){this.entries=new WeakMap,this.orderLayouts?.fill(void 0),this.orderKeys?.fill(void 0),this.size=this.next=0,this.replace=!1}},gb=new ArrayBuffer(0),XC=new Uint8Array(gb),ez=new DataView(gb),th=class{pos=0;buf=XC;view;viewCache=ez;viewBuffer=gb;viewOffset=0;viewLength=0;end=0;options=Xr;indexSignatures;positional=!1;intern;dict;reset(t,n,r,o,s,i,a){this.view=void 0,this.buf=t,this.pos=n,this.end=r,this.options=o,this.indexSignatures=s,this.positional=i,this.intern=void 0,this.dict=a}release(){this.pos=this.end=0,this.buf=XC,this.view=void 0,this.viewCache=ez,this.viewBuffer=gb,this.viewOffset=this.viewLength=0,this.options=Xr,this.indexSignatures=void 0,this.positional=!1,this.intern=void 0,this.dict=void 0}get remaining(){return this.end-this.pos}dataView(){let t=this.buf;return(t.buffer!==this.viewBuffer||t.byteOffset!==this.viewOffset||t.byteLength!==this.viewLength)&&(this.viewBuffer=t.buffer,this.viewOffset=t.byteOffset,this.viewLength=t.byteLength,this.viewCache=new DataView(t.buffer,t.byteOffset,t.byteLength)),this.view=this.viewCache}byte(){return this.pos>=this.end&&Q("complete value",void 0,this.options),this.buf[this.pos++]}take(t){this.pos+t>this.end&&Q("complete value",void 0,this.options);let n=this.buf.subarray(this.pos,this.pos+t);return this.pos+=t,n}takeCopy(t){this.pos+t>this.end&&Q("complete value",void 0,this.options);let n=this.buf.slice(this.pos,this.pos+t);return this.pos+=t,n}enter(t){this.pos+t>this.end&&Q("complete value",void 0,this.options);let n=this.end;return this.end=this.pos+t,n}exit(t){this.pos=this.end,this.end=t}readUtf8(t){this.pos+t>this.end&&Q("complete value",void 0,this.options);let n=this.pos;return this.pos+=t,dne(this.buf,n,n+t,this.options)}uvarint(){let t=this.buf,n=this.end,r=this.pos;r>=n&&Q("complete value",void 0,this.options);let o=t[r++];if(o<128)return this.pos=r,o;let s=o&127;if(r>=n&&Q("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<7,o<128)return this.pos=r,s;if(r>=n&&Q("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<14,o<128)return this.pos=r,s;if(r>=n&&Q("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<21,o<128)return this.pos=r,s;let i=268435456;for(let a=4;a<10;a++){r>=n&&(this.pos=r,Q("complete value",void 0,this.options)),o=t[r++];let c=(o&127)*i;if(c>Number.MAX_SAFE_INTEGER-s&&(this.pos=r,Q("safe integer length",void 0,this.options)),s+=c,o<128)return this.pos=r,s;i*=128}this.pos=r,Q("uvarint",void 0,this.options)}fieldTag(){let t=this.buf,n=this.end,r=this.pos;r>=n&&Q("complete value",void 0,this.options);let o=t[r++];if(o<128)return this.pos=r,o;let s=o&127;return r>=n&&Q("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<7,o<128?(this.pos=r,s):(r>=n&&Q("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<14,o<128?(this.pos=r,s):(r>=n&&Q("complete value",void 0,this.options),o=t[r++],s|=(o&127)<<21,o<128?(this.pos=r,s):(r>=n&&Q("complete value",void 0,this.options),o=t[r++],this.pos=r,o>=128&&Q("uvarint",void 0,this.options),s+o*268435456)))}uvarintBig(){let t=db,n=db;for(;;){let r=this.byte();if(t|=BigInt(r&127)<<n,(r&128)===0)return t;n+=Sz}}numberVarint(){let t=this.buf,n=this.end,r=this.pos,o=0,s=1;for(let c=0;c<bz;c++){r>=n&&(this.pos=r,Q("complete value",void 0,this.options));let u=t[r++];if(o+=(u&127)*s,u<128)return this.pos=r,vz(o);s*=128}let i=this.uvarintBig(),a=Number(i>>es);return Number.isFinite(a)||Q("safe integer length",void 0,this.options),(i&es)===es?-a:a}zigzag(){let t=this.uvarintBig();return(t&es)===es?-(t+es>>es):t>>es}f64(){this.pos+8>this.end&&Q("complete value",void 0,this.options);let t=(this.view??this.dataView()).getFloat64(this.pos,!0);return this.pos+=8,t}i64(){this.pos+8>this.end&&Q("complete value",void 0,this.options);let t=(this.view??this.dataView()).getBigInt64(this.pos,!0);return this.pos+=8,t}u32le(){this.pos+4>this.end&&Q("complete value",void 0,this.options);let t=(this.view??this.dataView()).getUint32(this.pos,!0);return this.pos+=4,t}i32le(){this.pos+4>this.end&&Q("complete value",void 0,this.options);let t=(this.view??this.dataView()).getInt32(this.pos,!0);return this.pos+=4,t}};function tz(e,t){return{_:"literal",leaf:e,values:t,valueSet:t.length>4?new Set(t):void 0}}function ch(e,t){let n=e.values;return e.valueSet!==void 0?e.valueSet.has(t):n.length===1?t===n[0]:n.includes(t)}function bb(e){return e.values.map(t=>typeof t=="string"?JSON.stringify(t):String(t)).join(" | ")}var cb=0,uA=1,Az=2,Rz=3,Oz=30,ub=1<<Oz;function Eb(e){return e._==="literal"?Eb(e.leaf):e._==="int"}function wb(e){switch(e._){case"literal":return wb(e.leaf);case"bool":return 1;case"int64":return 8;default:return}}function eA(e){return wb(e)!==void 0||Eb(e)||e._==="null"||e._==="undefined"}var nh={"effect/schema/Date":{kind:St.int64,exact:!0},"effect/schema/DateTimeUtc":{kind:St.int64,exact:!0},"effect/schema/DateTimeZoned":{kind:St.dateTimeZoned,exact:!0},"effect/schema/Duration":{kind:St.duration,exact:!0},"effect/schema/BigDecimal":{kind:St.bigDecimal,exact:!0},"effect/schema/Uint8Array":{kind:St.bytes,exact:!0},"effect/schema/Option":{kind:St.option,exact:"parameters"},"effect/schema/Result":{kind:St.result,exact:"parameters"},"effect/schema/Exit":{kind:St.exit,exact:"parameters"},"effect/schema/Cause":{kind:St.cause,exact:"parameters"},"effect/schema/CauseReason":{kind:St.causeReason,exact:"parameters"}};function fd(e){let t=e.annotations?.representation;return en(t)&&typeof t.id=="string"?t.id:void 0}var fb=ga(e=>{let t=Sne(e),n=e.context;return t===e||n===void 0?t:Sl(t,new Yr(n.isOptional,n.isMutable,void 0,n.annotations))});function Sne(e){switch(e._tag){case"Declaration":{let t=fd(e);if(t!==void 0&&(t in nh||t==="effect/schema/Json"||t==="effect/schema/MutableJson"))return e.recur(fb);let n=e.annotations?.toCodecJson,r=e.annotations?.toCodec;if(!cn(n)&&!cn(r))return e;let o=e.typeParameters.map(i=>re(jn(i))),s=(cn(n)?n(o):void 0)??(cn(r)?r(o):void 0);return s===void 0?e:lt(e,[mc(s,fb)])}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(fb);default:return e}}function bne(e){let t=[...e].sort((r,o)=>{let s=typeof r.key=="number",i=typeof o.key=="number";return s!==i?s?-1:1:s?r.key-o.key:kz(Ui.encode(r.key),Ui.encode(o.key))}),n=[];for(let r of t){let o=Ui.encode(String(r.key));n.push(typeof r.key=="number"?0:1),mb(n,o.length),pb(n,o);let s=r.literal,i=Ui.encode(Mz(s));n.push(_z(s)),mb(n,i.length),pb(n,i)}return Tz(n)}function _z(e){switch(typeof e){case"string":return 1;case"number":return 2;case"boolean":return 3;case"bigint":return 4;default:return 5}}function Mz(e){if(typeof e=="symbol"){let t=globalThis.Symbol.keyFor(e);if(t===void 0)throw new Error("Binary layout: unregistered unique symbol (Symbol.keyFor)");return t}return String(e)}function Pz(e){switch(e._tag){case"Symbol":return!0;case"Union":return e.types.some(Pz);default:return!1}}function Fz(e){let t=fd(e);return t==="effect/schema/Json"||t==="effect/schema/MutableJson"?!0:cn(e.annotations?.toCodecJson)}function Ene(e){let t=e.checks;if(t===void 0)return!1;let n=r=>r.annotations?.representation?.id==="effect/schema/isInt"?!0:r._tag==="FilterGroup"&&r.checks.some(n);return t.some(n)}function Uz(e){for(;e._tag==="Suspend";)e=e.thunk();return e}function nz(e){let t=[],n=new Set,r=o=>{let s=Uz(o);if(!n.has(s))switch(n.add(s),s._tag){case"Never":return;case"Union":s.types.forEach(r);return;case"Enum":Np(s).types.forEach(r);return;default:t.push(s)}};return e.types.forEach(r),t}function rz(e){switch(typeof e){case"string":return"string";case"number":return"number";case"boolean":return"bool";default:return"bigint"}}function lb(e){switch(e._tag){case"String":case"TemplateLiteral":case"Symbol":return St.string;case"UniqueSymbol":if(globalThis.Symbol.keyFor(e.symbol)===void 0)throw new Error("Binary layout: unregistered unique symbol (Symbol.keyFor)");return St.string;case"Boolean":return St.bool;case"Null":return St.null;case"Undefined":case"Void":return St.undefined;case"Number":return St.number;case"BigInt":return St.bigint;case"Literal":switch(typeof e.literal){case"string":return St.string;case"number":return St.number;case"boolean":return St.bool;default:return St.bigint}case"Unknown":case"Any":case"ObjectKeyword":return St.json;case"Objects":return St.struct;case"Arrays":return St.array;case"Declaration":{let t=fd(e);if(t!==void 0&&t in nh)return nh[t].kind;if(Fz(e))return St.json;throw new Error(`Binary layout: declaration ${t??"<anonymous>"} has no toCodecJson or toCodec`)}case"Suspend":return lb(Uz(e));default:throw new Error("Binary layout: union members are not uniquely identifiable")}}function oz(e){for(let t of e.fields)t.optional||(t.index<32?e.requiredMask|=1<<t.index:e.requiredWide=!0)}function wne(e){let t=Dz(e),n=!t&&Ine(e);e=jn(e);let r=new Map,o=!1,s=0,i=h=>({_:h,slot:h==="string"?s++:0});function a(h){let g=r.get(h);if(g!==void 0)return g;let x=c(h);return r.set(h,x),x}function c(h){switch(h._tag){case"String":case"TemplateLiteral":return i("string");case"Symbol":case"UniqueSymbol":return i("symbol");case"Boolean":return i("bool");case"Null":return i("null");case"Undefined":case"Void":return i("undefined");case"Number":return i(Ene(h)?"int":"number");case"BigInt":return i("bigint");case"Literal":return tz(i(rz(h.literal)),[h.literal]);case"Unknown":case"Any":case"ObjectKeyword":return i("json");case"Never":return{_:"never",ast:h};case"Enum":return p(h,nz(Np(h)));case"Suspend":{o=!0;let g=a(h.thunk());return r.set(h,g),g}case"Objects":return u(h);case"Arrays":return f(h);case"Union":return p(h,nz(h));case"Declaration":return l(h)}}function u(h){let g=[],x=[],E=new Map;for(let w of h.propertySignatures){if(typeof w.name=="symbol")throw new Error("Binary layout: symbol property names are illegal");let S=String(w.name),C=w.type.context?.annotations,M=C?.[Zte],_=typeof M=="number"?M:Tz(Ui.encode(S));if(!Number.isInteger(_)||_<0||_>4294967295)throw new Error(`Binary layout: illegal field id for ${S}`);let P=E.get(_);P===void 0?E.set(_,[S]):P.push(S),g.push({name:S,id:_,tagBytes:fne(_*ts+af),index:0,optional:w.type.context?.isOptional===!0,annotations:C,layout:void 0,wireMask:0,inline:!1}),x.push(w.type)}for(let[w,S]of E)if(w===0||S.length>1)throw new Error(`Binary layout field id collision: ${w} (${S.join(", ")})`);let b=[];for(let w of h.indexSignatures){if(Pz(w.parameter))throw new Error("Binary layout: symbol property names are illegal");b.push({parameter:w.parameter,layout:void 0,wireMask:0})}let y={_:"struct",ast:h,fields:g,byId:new Map,extra:b,extraAll:b.length===1&&xne(b[0].parameter)?b[0]:void 0,names:new Set(g.map(w=>w.name)),extraShape:void 0,optionalCount:0,requiredMask:0,requiredWide:!1};r.set(h,y);for(let w=0;w<g.length;w++){let S=g[w];S.layout=a(x[w]),S.wireMask=oA(S.layout),S.inline=eA(S.layout),S.optional&&y.optionalCount++,y.byId.set(S.id,S)}g.sort((w,S)=>w.id-S.id);for(let w=0;w<g.length;w++)g[w].index=w;oz(y);for(let w=0;w<b.length;w++)b[w].layout=a(h.indexSignatures[w].type),b[w].wireMask=oA(b[w].layout);return y}function f(h){let g=h.rest.length>0||h.elements.some(y=>y.context?.isOptional===!0),x=h.elements.filter(y=>y.context?.isOptional!==!0).length,E=Math.max(0,h.rest.length-1),b={_:"array",ast:h,elements:[],rest:[],hasCount:g,minCount:x+E,uniform:void 0,uniformInline:!1,uniformPacked:void 0,uniformNumbers:!1,run:void 0};r.set(h,b);for(let y of h.elements)b.elements.push({optional:y.context?.isOptional===!0,layout:a(y)});for(let y of h.rest)b.rest.push(a(y));if(b.elements.length===0&&b.rest.length===1){let y=b.rest[0];b.uniform=y,b.uniformPacked=wb(y),b.uniformNumbers=y._==="number",b.uniformInline=eA(y)}return b}function l(h){let g=fd(h);switch(g){case"effect/schema/Date":return{_:"int64",flavor:"date"};case"effect/schema/DateTimeUtc":return{_:"int64",flavor:"utc"};case"effect/schema/DateTimeZoned":return i("dateTimeZoned");case"effect/schema/Duration":return i("duration");case"effect/schema/BigDecimal":return i("bigDecimal");case"effect/schema/Uint8Array":return i("bytes")}let x=h.typeParameters;switch(g){case"effect/schema/Option":{let E={_:"option",value:void 0};return r.set(h,E),E.value=a(x[0]),E}case"effect/schema/Result":{let E={_:"result",success:void 0,failure:void 0};return r.set(h,E),E.success=a(x[0]),E.failure=a(x[1]),E}case"effect/schema/Exit":{let E={_:"cause",error:void 0,defect:void 0},b={_:"exit",value:void 0,cause:E};return r.set(h,b),b.value=a(x[0]),E.error=a(x[1]),E.defect=a(x[2]),b}case"effect/schema/Cause":case"effect/schema/CauseReason":{let E={_:g==="effect/schema/Cause"?"cause":"causeReason",error:void 0,defect:void 0};return r.set(h,E),E.error=a(x[0]),E.defect=a(x[1]),E}}if(g!==void 0&&g in nh)throw new Error(`Binary layout: native declaration ${g} has no layout constructor`);if(Fz(h))return i("json");throw new Error(`Binary layout: declaration ${g??"<anonymous>"} has no toCodecJson or toCodec`)}function p(h,g){if(g.length===0)return{_:"never",ast:h};let x=[],E=[],b=new Map,y=new Map,w=(P,$)=>{let F=b.get(P);if(F!==void 0&&F._!==$._)throw new Error("Binary layout: union members are not uniquely identifiable");b.set(P,$)};for(let P of g){if(P._tag==="Literal"){let $=lb(P),F=y.get($);F===void 0?y.set($,[P.literal]):F.includes(P.literal)||F.push(P.literal);continue}if(P._tag==="UniqueSymbol"){lb(P),w(St.string,i("symbol"));continue}if(P._tag==="Objects"||P._tag==="Arrays"){let $=lc(P);if($!==void 0&&$.length>0){for(let F of $)if(typeof F.key=="symbol")throw new Error("Binary layout: symbol property names are illegal");x.push({member:P,sentinels:$});continue}}E.push({member:P,kind:lb(P)})}for(let[P,$]of y)w(P,tz(i(rz($[0])),$));if(x.length===0&&E.length===0&&b.size===1)return b.values().next().value;let S=new Set(b.keys());for(let{kind:P}of E){if(S.has(P))throw new Error("Binary layout: union members are not uniquely identifiable");S.add(P)}if(x.length===0&&b.size===0&&E.length===1){let P=a(E[0].member);return r.set(h,P),P}let C=new Map,M=[];for(let{sentinels:P}of x){let $=bne(P);if(C.has($))throw new Error(`Binary layout sentinel collision: ${$}`);C.set($,P),M.push($)}let _={_:"union",ast:h,variants:[],byTag:new Map,discriminator:void 0,others:[],byKind:new Map,byPos:[]};r.set(h,_);for(let P=0;P<x.length;P++){let{member:$,sentinels:F}=x[P],te=M[P],ee=a($),T,z;if($._tag==="Objects"){let N=ee,V=new Set(F.map(de=>String(de.key))),Ee=N.fields.filter(de=>!V.has(de.name)),Ie={_:"struct",ast:N.ast,fields:Ee,byId:new Map(Ee.map(de=>[de.id,de])),extra:N.extra,extraAll:N.extraAll,names:N.names,extraShape:void 0,optionalCount:Ee.reduce((de,ut)=>ut.optional?de+1:de,0),requiredMask:0,requiredWide:!1};oz(Ie),T=Ie,z=!1}else T=ee,z=!0;let U={tag:te,sentinels:F,tuple:z,payload:T,position:0};_.variants.push(U),_.byTag.set(te,U)}for(let[P,$]of b)_.others.push({kind:P,layout:$,position:0}),_.byKind.set(P,$);for(let{kind:P,member:$}of E){let F=a($);_.others.push({kind:P,layout:F,position:0}),_.byKind.set(P,F)}for(let P of[..._.variants].sort(($,F)=>$.tag-F.tag))P.position=_.byPos.length,_.byPos.push({variant:P,layout:P.payload});for(let P of[..._.others].sort(($,F)=>$.kind-F.kind))P.position=_.byPos.length,_.byPos.push({variant:void 0,layout:P.layout});return _.others.sort((P,$)=>sz(P.layout)-sz($.layout)),_.discriminator=Yne(_.variants),_}return{layout:a(e),recursive:o,exact:t,exitSuccess:n}}function Dz(e){let t=new Map,n=r=>{if(r.encoding!==void 0||r.checks!==void 0||r.encodingChecks!==void 0||r.annotations?.parseOptions!==void 0)return!1;switch(r._tag){case"String":case"Symbol":case"Boolean":case"Null":case"Undefined":case"Void":case"Number":case"BigInt":case"Literal":return!0;case"Never":return!0;case"Unknown":case"Any":return!0;case"Arrays":return r.elements.every(n)&&r.rest.every(n);case"Objects":return r.propertySignatures.every(o=>n(o.type))&&r.indexSignatures.every(o=>o.parameter._tag==="String"&&n(o.parameter)&&n(o.type));case"Union":return r.mode==="anyOf"&&r.types.every(n);case"Suspend":{let o=t.get(r);if(o!==void 0)return o;t.set(r,!0);let s=n(r.thunk());return t.set(r,s),s}case"Declaration":{let o=fd(r),s=o!==void 0?nh[o]:void 0;return s===void 0?!1:s.exact===!0||r.typeParameters.every(n)}default:return!1}};return n(e)}function Ine(e){return e._tag==="Declaration"&&e.encoding===void 0&&e.checks===void 0&&e.encodingChecks===void 0&&e.annotations?.parseOptions===void 0&&fd(e)==="effect/schema/Exit"&&Dz(e.typeParameters[0])}var so={backEdge:0,bool:1,null:2,undefined:3,number:4,int:5,string:6,symbol:7,bytes:8,bigint:9,json:10,duration:11,bigDecimal:12,dateTimeZoned:13,date:14,dateTimeUtc:15,never:16,struct:17,array:18,union:19,option:20,result:21,exit:22,cause:23,causeReason:24,literal:25};function vne(e){let t=new Map,n=[],r=Number.MAX_SAFE_INTEGER;function o(i){let a=n.lastIndexOf(i);if(a>=0){a<r&&(r=a);let m=[so.backEdge];return Dc(m,n.length-a),X$(m)}let c=t.get(i);if(c!==void 0)return c;let u=n.length,f=r;r=Number.MAX_SAFE_INTEGER,n.push(i);let l=X$(s(i));n.pop();let p=r>=u;return p&&t.set(i,l),r=p?f:Math.min(f,r),l}function s(i){let a=[];switch(i._){case"bool":case"null":case"undefined":case"number":case"int":case"string":case"symbol":case"bytes":case"bigint":case"json":case"duration":case"bigDecimal":case"dateTimeZoned":return a.push(so[i._]),a;case"literal":{a.push(so.literal),pb(a,s(i.leaf)),Dc(a,i.values.length);let c=i.values.map(u=>[_z(u),Mz(u)]).sort((u,f)=>u[1]<f[1]?-1:u[1]>f[1]?1:u[0]-f[0]);for(let[u,f]of c){a.push(u);let l=Ui.encode(f);Dc(a,l.length),pb(a,l)}return a}case"int64":return a.push(i.flavor==="date"?so.date:so.dateTimeUtc),a;case"never":return a.push(so.never),a;case"struct":{a.push(so.struct),Dc(a,i.fields.length);for(let c of i.fields)mb(a,c.id),a.push(c.optional?1:0),Io(a,o(c.layout));Dc(a,i.extra.length);for(let c of i.extra)Io(a,o(c.layout));return a}case"array":{a.push(so.array),Dc(a,i.elements.length);for(let c of i.elements)a.push(c.optional?1:0),Io(a,o(c.layout));Dc(a,i.rest.length);for(let c of i.rest)Io(a,o(c));return a}case"union":{a.push(so.union),Dc(a,i.byPos.length);for(let c of i.byPos){let u=c.variant;u===void 0?a.push(0):(a.push(1,u.tuple?1:0),mb(a,u.tag)),Io(a,o(c.layout))}return a}case"option":return a.push(so.option),Io(a,o(i.value)),a;case"result":return a.push(so.result),Io(a,o(i.success)),Io(a,o(i.failure)),a;case"exit":return a.push(so.exit),Io(a,o(i.value)),Io(a,o(i.cause.error)),Io(a,o(i.cause.defect)),a;case"cause":case"causeReason":return a.push(i._==="cause"?so.cause:so.causeReason),Io(a,o(i.error)),Io(a,o(i.defect)),a}}return o(e)}function Tne(e,t){let n=new Uint8Array(8);for(let r=0;r<4;r++)n[r]=e>>>r*8&255,n[r+4]=t>>>r*8&255;return n}var kne={positional:!1,envelope:Qte,expectedEnvelope:"version 2 envelope, flags 0",fingerprint:new Uint8Array(8)};function Cne(e){let t=vne(e);return{positional:!0,envelope:Yte,expectedEnvelope:"version 2 envelope, flags 1",fingerprint:Tne(Number(t&Q$),Number(t>>nne&Q$))}}function sz(e){switch(e._){case"json":return 2;case"struct":return 1;default:return 0}}function tA(e,t){switch(e._){case"literal":return ch(e,t);case"bool":return typeof t=="boolean";case"null":return t===null;case"undefined":return t===void 0;case"number":case"int":return typeof t=="number";case"string":return typeof t=="string";case"symbol":return typeof t=="symbol";case"bigint":return typeof t=="bigint";case"bytes":return t instanceof Uint8Array;case"int64":return e.flavor==="date"?t instanceof Date:Au(t)&&t._tag==="Utc";case"dateTimeZoned":return Au(t)&&t._tag==="Zoned";case"duration":return nu(t);case"bigDecimal":return Wa(t);case"option":return Ys(t);case"result":return If(t);case"exit":return gs(t);case"cause":return $f(t);case"causeReason":return zf(t);case"array":return Array.isArray(t);case"struct":return en(t)&&!Array.isArray(t);case"json":return!0;case"union":case"never":return!1}}function yt(e,t,n){throw pn(new ke({expected:e},t,n))}function gr(e,t=new Set){if(!hd(e))return!1;let n=Array.isArray(e),r=Object.getPrototypeOf(e);if(n||r===Object.prototype||r===null){if(t.has(e))return!0;t.add(e);try{if(n){for(let o=0;o<e.length;o++)if(gr(e[o],t))return!0}else for(let o of Object.keys(e))if(gr(e[o],t))return!0}finally{t.delete(e)}return!1}if(e instanceof Date||e instanceof Uint8Array||Au(e)||nu(e)||Wa(e))return!1;if(t.has(e))return!0;t.add(e);try{if(Ys(e))return Te(e)&&gr(e.value,t);if(If(e))return gr(Kt(e)?e.success:e.failure,t);if(gs(e))return gr(Ft(e)?e.value:e.cause,t);if($f(e))return e.reasons.some(o=>gr(o,t));if(zf(e))switch(e._tag){case"Fail":return gr(e.error,t);case"Die":return gr(e.defect,t);case"Interrupt":return!1}if(Il(e)){for(let o of e)if(gr(o,t))return!0;return!1}if(jy(e)){for(let[o,s]of e)if(gr(o,t)||gr(s,t))return!0;return!1}if(Wy(e)){for(let o of e)if(gr(o,t))return!0;return!1}if(pm(e))return gr(Sc(e),t);for(let o of Object.keys(e))if(gr(e[o],t))return!0}finally{t.delete(e)}return!1}function xb(e,t,n,r){let o=r.beginSized();Wn(e,t,n,r),r.endSized(o)}function Ane(e,t,n){let r=globalThis.Symbol.keyFor(t);r===void 0&&yt("registered symbol",t,e.options),n.string(r)}function iz(e,t,n,r){let o=n;switch(o._tag){case"Fail":r.byte(0),Wn(e,t.error,o.error,r);return;case"Die":r.byte(1),Wn(e,t.defect,o.defect,r);return;case"Interrupt":o.fiberId===void 0?r.byte(2):(r.byte(3),r.f64(o.fiberId))}}function Rne(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!1;return!0}function az(e,t,n){if(e.layout!==t||e.keys.length!==n.length)return!1;for(let r=0;r<n.length;r++)if(e.keys[r]!==n[r])return!1;return!0}function One(e,t){if(e.extraAll===void 0||t.length>hne)return!1;let n=0;for(let r=0;r<t.length;r++)if(n+=t[r].length,n>gne)return!1;return!0}function fA(e,t,n){let r=Object.keys(n),o=t.extraShape;if(o!==void 0&&az(o,t,r))return o.pairs;let s=One(t,r),i=s?void 0:e.extraShape;if(i!==void 0&&az(i,t,r))return i.pairs;let a=t.names,c=t.extraAll,u=[],f=!0;for(let p of r){if(a.has(p))continue;let m=c??(e.indexSignatures??=new eh(e.options)).find(t,p);m!==void 0&&(f&&!Rne(p)&&(f=!1),u.push([p,m,void 0]))}if(f)u.sort((p,m)=>p[0]<m[0]?-1:p[0]>m[0]?1:0);else{for(let p of u)p[2]=Ui.encode(p[0]);u.sort((p,m)=>kz(p[2],m[2]))}if(s)for(let p of u)p[2]??=Ui.encode(p[0]);let l={layout:t,keys:r,pairs:u};return s?t.extraShape=l:e.extraShape=l,u}function lA(e,t,n,r,o){for(let[s,i,a]of t){let c=a===void 0?s.length:a.length,u=n[s],f=dA(i.layout,u,e.options),l=f%ts;if(o===void 0)r.uvarint(c*ts+l);else{if(!o.disabled){let p=Lz(o,s);if(p!==void 0){r.uvarint(p*16+l*2+1),nt[ue++]=s,nA(e,i.layout,u,f,r),ue--;continue}Bz(o,s)}r.uvarint(c*16+l*2)}a===void 0?r.string(s):r.bytes(a),nt[ue++]=s,nA(e,i.layout,u,f,r),ue--}}function dA(e,t,n){if(e._==="literal")return ch(e,t)||yt(bb(e),t,n),dA(e.leaf,t,n);switch(e._){case"bool":return typeof t!="boolean"&&yt("a boolean",t,n),t?ih:sh;case"number":if(typeof t!="number"&&yt("a number",t,n),aA(t))return of;{let r=cA(t);return r===0?oh:r*ts+ah}case"int":return Number.isSafeInteger(t)||yt("an integer",t,n),of;default:return af}}function nA(e,t,n,r,o){switch(r%ts){case sh:case ih:return;case of:o.numberVarint(n);return;case oh:o.f64(n);return;case ah:{let i=Math.floor(r/ts);o.numberVarint(Math.round(n*Nc[i])),o.uvarint(i);return}default:xb(e,t,n,o)}}function _ne(e,t,n,r){let o=dA(t.layout,n,e.options),s=o%ts;if(s===af){let i=r.idAndMark(t.tagBytes);Wn(e,t.layout,n,r),r.endSized(i);return}r.uvarint(t.id*ts+s),nA(e,t.layout,n,o,r)}function Mne(e,t){let n=e.byName;if(n===void 0)return;let r=Object.getOwnPropertyNames(t),o=0;for(let i=0;i<r.length;i++){let a=n.get(r[i]);a!==void 0&&(o|=1<<a)}let s=e.struct;if((o&s.requiredMask)!==s.requiredMask){let i=s.fields;for(let a=0;a<i.length;a++){let c=i[a];if(!c.optional&&(o&1<<a)===0)throw nt[ue++]=c.name,pn(new sn(c.annotations))}}return o}function Pne(e,t,n,r){let o=n;if(t.extra.length>0){let i=e.intern;e.intern=void 0;let a=fA(e,t,o);if(a.length>0){r.uvarint(0);let c=r.beginSized();lA(e,a,o,r,i),r.endSized(c)}}let s=t.fields;for(let i=0;i<s.length;i++){let a=s[i],c=a.name;if(!Object.hasOwn(o,c)){if(a.optional)continue;throw nt[ue++]=c,pn(new sn(a.annotations))}nt[ue++]=c,_ne(e,a,o[c],r),ue--}}function Fne(e,t,n,r){let o=n,s=e.intern;e.intern=void 0;let i=t.optionalCount+7>>3,a=0;if(i>0){a=r.len;for(let f=0;f<i;f++)r.byte(0)}let c=t.fields,u=0;for(let f=0;f<c.length;f++){let l=c[f],p=l.name,m=Object.hasOwn(o,p);if(l.optional){if(m&&(r.buf[r.start+a+(u>>3)]|=1<<(u&7)),u++,!m)continue}else if(!m)throw nt[ue++]=p,pn(new sn(l.annotations));nt[ue++]=p,l.inline?Wn(e,l.layout,o[p],r):xb(e,l.layout,o[p],r),ue--}if(t.extra.length>0){let f=fA(e,t,o);r.uvarint(f.length),lA(e,f,o,r,s)}}function Une(e){switch(e._){case"string":return uA;case"array":return e.uniform?._==="string"?Az:cb;case"struct":return e.extra.length>0?Rz:cb;default:return cb}}function Dne(e){let t=e.uniform;if(t===void 0){if(e.rest.length!==1)return;t=e.rest[0];for(let n of e.elements)if(n.optional||n.layout!==t)return}return t._==="struct"?t:void 0}function Nz(e){let t=e.run;if(t!==void 0)return t;let n=Dne(e);if(n===void 0)return e.run=t=null,t;let r=n.fields.map(s=>Une(s.layout)),o=n.fields.length<=Oz;return t={struct:n,intern:r,shapes:o,byName:o&&n.extra.length===0?new Map(n.fields.map((s,i)=>[s.name,i])):void 0},e.run=t,t}var Nne=16,Lne=64;function cz(e,t){return e[t]??={values:[],refs:void 0,hits:0,disabled:!1}}function Lz(e,t){let n=e.refs;if(n!==void 0){let o=n.get(t);return o!==void 0&&e.hits++,o}let r=e.values;for(let o=0;o<r.length;o++)if(r[o]===t)return e.hits++,o}function Bz(e,t){let n=e.values;if(e.refs!==void 0){if(e.hits===0&&n.length>=Lne){e.disabled=!0,e.refs=void 0;return}e.refs.set(t,n.length)}else if(n.length>=Nne){let r=e.refs=new Map;for(let o=0;o<n.length;o++)r.set(n[o],o);r.set(t,n.length)}n.push(t)}var pA=0,Bne=1,mA=2,jne=64,qne=512;function $ne(){return{slots:[],marks:[],frame:0}}function jz(e,t){return e[t]??={values:[],refs:new Map,state:pA,stamp:-1}}function qz(e,t){if(e.refs.has(t)){e.state=Bne;return}e.refs.set(t,e.values.length),e.values.push(t),e.values.length>=jne&&(e.state=mA)}function $z(e,t){let n=e.values;n.length>=qne||(e.refs.set(t,n.length),n.push(t))}function zne(e,t){t.stamp!==e.frame&&(t.stamp=e.frame,e.marks.push({slot:t,length:t.values.length,state:t.state}))}function Hne(e){e.marks.length=0,e.frame++}function Wne(e){let t=e.marks;for(let n=t.length-1;n>=0;n--){let{length:r,slot:o,state:s}=t[n],i=o.values;for(let a=r;a<i.length;a++)o.refs.delete(i[a]);i.length=r,o.state=s}t.length=0,e.frame++}function Kne(e,t,n,r){let o=jz(e.slots,t.slot),s=o.state;if(s===mA){r.string(n);return}if(zne(e,o),s===pA){r.string(n),qz(o,n);return}let i=o.refs.get(n);if(i!==void 0){r.uvarint(i*2+1);return}r.byte(0),$z(o,n),r.string(n)}function Vne(e,t,n){let r=jz(e,t.slot),o=r.state;if(o===mA)return n.readUtf8(n.end-n.pos);if(o===pA){let a=n.readUtf8(n.end-n.pos);return qz(r,a),a}let s=n.uvarint();if((s&1)===1){let a=(s-1)/2,c=r.values;return a>=c.length&&Q("a dictionary reference",s,n.options),c[a]}s!==0&&Q("a dictionary marker",s,n.options);let i=n.readUtf8(n.end-n.pos);return $z(r,i),i}function zz(e,t,n,r,o){if(!e.disabled){let i=Lz(e,r);if(i!==void 0){o.uvarint(i*2+1);return}Bz(e,r)}let s=o.beginSized();Wn(t,n,r,o),o.endSizedRun(s)}function Jne(e,t,n,r,o){let s=[],i=[];for(let a=0;a<r;a++){nt[ue++]=a;let c=o.beginSized();Gne(e,t,s,i,n[a],o),o.endSized(c),ue--}}function Gne(e,t,n,r,o,s){let i=t.struct,a=o,c=i.fields,u;if(i.extra.length>0){let x=fA(e,i,a);x.length>0&&(u=x)}let f=!t.shapes,l=u===void 0?0:ub,p=Mne(t,a);if(p!==void 0)l=p;else for(let x=0;x<c.length;x++){let E=c[x];if(Object.hasOwn(a,E.name))f||(l|=1<<x);else if(!E.optional)throw nt[ue++]=E.name,pn(new sn(E.annotations))}let m=-1;for(let x=0;x<n.length;x++)if(n[x]===l){m=x;break}m>=0?s.uvarint(m+1):(s.uvarint(0),f||n.push(l));let h=m<0,g=e.positional&&!f;if(h&&g&&s.uvarint(l),u!==void 0){h&&!g&&s.uvarint(0);let x=s.beginSized();lA(e,u,a,s),s.endSizedRun(x)}for(let x=0;x<c.length;x++){let E=c[x];if(f?!Object.hasOwn(a,E.name):(l&1<<x)===0)continue;h&&!g&&s.uvarint(E.id),nt[ue++]=E.name;let b=t.intern[x];if(b===uA)zz(cz(r,x),e,E.layout,a[E.name],s);else{b!==cb&&(e.intern=cz(r,x));let y=s.beginSized();Wn(e,E.layout,a[E.name],s),s.endSizedRun(y),e.intern=void 0}ue--}}function Hz(e,t,n){let r=e.elements.length;if(t<r)return e.elements[t].layout;let o=Math.max(0,e.rest.length-1),s=Math.max(r,n-o);return t>=s?e.rest[t-s+1]:e.rest[0]}function Zne(e,t,n,r){let o=n.length;if(t.rest.length===0&&o>t.elements.length)throw nt[ue++]=t.elements.length,pn(new la(t.ast,n[t.elements.length],e.options));if(o<t.minCount)throw nt[ue++]=o,pn(new sn(void 0));if(t.hasCount&&r.uvarint(o),o>0){let i=Nz(t);if(i!==null){Jne(e,i,n,o,r);return}}let s=t.uniform;if(s!==void 0){if(t.uniformNumbers){Qne(n,o,r);return}let i=e.intern;if(e.intern=void 0,i!==void 0){for(let c=0;c<o;c++)nt[ue++]=c,zz(i,e,s,n[c],r),ue--;return}let a=t.uniformInline;for(let c=0;c<o;c++)nt[ue++]=c,a?Wn(e,s,n[c],r):xb(e,s,n[c],r),ue--;return}for(let i=0;i<o;i++){let a=Hz(t,i,o);nt[ue++]=i,eA(a)?Wn(e,a,n[i],r):xb(e,a,n[i],r),ue--}}var uz=[];function Qne(e,t,n){let r=!0,o=!0;for(let s=0;s<t;s++){let i=e[s];if(aA(i))(i<0?-i:i)>ZC&&(o=!1);else if(r=!1,typeof i!="number")o=!1;else{let a=cA(i);a===0?o=!1:uz[s]=a}if(!r&&!o)break}if(r){n.byte(wz);for(let s=0;s<t;s++)n.numberVarint(e[s])}else if(o){n.byte(Iz);for(let s=0;s<t;s++){let i=e[s],a=Number.isInteger(i)?0:uz[s],c=a===0?i:Math.round(i*Nc[a]),u=c<0||c===0&&1/c<0,f=u?-c:c;n.uvarint((f*2+(u?1:0))*16+a)}}else{n.byte(Ez);for(let s=0;s<t;s++)n.f64(e[s])}}function Yne(e){if(!(e.length<2||e.some(t=>t.tuple)))for(let t of e[0].sentinels){let n=new Map;for(let r of e){let o=r.sentinels.find(s=>s.key===t.key);if(o===void 0||n.has(o.literal)||Number.isNaN(o.literal))break;n.set(o.literal,r)}if(n.size===e.length)return{key:t.key,rows:n}}}function rA(e,t){let n=e.sentinels;for(let r=0;r<n.length;r++){let{key:o,literal:s}=n[r];if(t[o]!==s||!Object.hasOwn(t,o))return!1}return!0}function Xne(e,t){return e.tuple?Array.isArray(t)&&rA(e,t):en(t)&&!Array.isArray(t)&&rA(e,t)}function fz(e,t,n,r){e.positional?r.uvarint(t.position):(r.byte(St.variant),r.u32le(t.tag)),Wn(e,t.payload,n,r)}function ere(e,t,n,r){let o=t.discriminator;if(o!==void 0){if(en(n)&&!Array.isArray(n)){let s=n,i=o.rows.get(s[o.key]);if(i!==void 0&&rA(i,s)){fz(e,i,n,r);return}}}else for(let s of t.variants)if(Xne(s,n)){fz(e,s,n,r);return}for(let s of t.others)if(tA(s.layout,n)){e.positional?r.uvarint(s.position):r.byte(s.kind),Wn(e,s.layout,n,r);return}throw pn(new st(t.ast,n,e.options))}function Wn(e,t,n,r){switch(t._){case"literal":ch(t,n)||yt(bb(t),n,e.options),Wn(e,t.leaf,n,r);return;case"bool":typeof n!="boolean"&&yt("a boolean",n,e.options),r.byte(n===!0?1:0);return;case"null":n!==null&&yt("null",n,e.options);return;case"undefined":n!==void 0&&yt("undefined",n,e.options);return;case"number":{if(typeof n!="number"&&yt("a number",n,e.options),aA(n)){r.numberVarint(n);return}let o=cA(n);o>0?(r.numberVarint(Math.round(n*Nc[o])),r.byte(o)):r.f64(n);return}case"int":{Number.isSafeInteger(n)||yt("an integer",n,e.options),r.numberVarint(n);return}case"string":{typeof n!="string"&&yt("a string",n,e.options);let o=e.dict;o===void 0?r.string(n):Kne(o,t,n,r);return}case"symbol":typeof n!="symbol"&&yt("a symbol",n,e.options),Ane(e,n,r);return;case"bytes":n instanceof Uint8Array||yt("a Uint8Array",n,e.options),r.bytes(n);return;case"bigint":typeof n!="bigint"&&yt("a bigint",n,e.options),r.zigzag(n);return;case"int64":{tA(t,n)||yt(t.flavor==="date"?"a Date":"a DateTime.Utc",n,e.options);let o=t.flavor==="date"?n.getTime():n.epochMilliseconds;Number.isNaN(o)&&yt("a valid Date",n,e.options),r.i64(BigInt(o));return}case"dateTimeZoned":{tA(t,n)||yt("a DateTime.Zoned",n,e.options);let o=n;r.i64(BigInt(o.epochMilliseconds)),o.zone._tag==="Offset"?(r.byte(0),r.i32le(o.zone.offset)):(r.byte(1),r.string(o.zone.id));return}case"duration":{nu(n)||yt("a Duration",n,e.options);let o=n.value;switch(o._tag){case"Infinity":r.byte(1);return;case"NegativeInfinity":r.byte(2);return;case"Nanos":r.byte(0),r.zigzag(o.nanos);return;case"Millis":r.byte(0),r.zigzag(BigInt(o.millis)*ene);return}}case"bigDecimal":{Wa(n)||yt("a BigDecimal",n,e.options);let o=Ud(n);r.zigzag(o.value),r.zigzag(BigInt(o.scale));return}case"json":{let o;try{o=JSON.stringify(n)}catch{o=void 0}o===void 0&&(gr(n)&&yt("acyclic value",n,e.options),yt("a JSON-serializable value",n,e.options)),r.string(o);return}case"option":{Ys(n)||yt("an Option",n,e.options);let o=n;o._tag==="None"?r.byte(0):(r.byte(1),Wn(e,t.value,o.value,r));return}case"result":{If(n)||yt("a Result",n,e.options);let o=n;o._tag==="Success"?(r.byte(0),Wn(e,t.success,o.success,r)):(r.byte(1),Wn(e,t.failure,o.failure,r));return}case"exit":{gs(n)||yt("an Exit",n,e.options);let o=n;o._tag==="Success"?(r.byte(0),Wn(e,t.value,o.value,r)):(r.byte(1),Wn(e,t.cause,o.cause,r));return}case"cause":{$f(n)||yt("a Cause",n,e.options);let o=n.reasons;r.uvarint(o.length);for(let s of o){let i=r.beginSized();iz(e,t,s,r),r.endSized(i)}return}case"causeReason":{zf(n)||yt("a Cause.Reason",n,e.options),iz(e,t,n,r);return}case"struct":{(!en(n)||Array.isArray(n))&&yt("an object",n,e.options),e.positional?Fne(e,t,n,r):Pne(e,t,n,r);return}case"array":{Array.isArray(n)||yt("an array",n,e.options),Zne(e,t,n,r);return}case"union":ere(e,t,n,r);return;case"never":throw pn(new st(t.ast,n,e.options))}}var ib=new hb;function lz(e,t,n,r,o){let s=o.beginSized();o.byte(r.envelope),r.positional&&o.bytes(r.fingerprint),Wn(e,t,n,o),o.endSized(s)}function Wz(e,t,n,r,o,s){let i={options:r,positional:o.positional,indexSignatures:void 0,extraShape:void 0,intern:void 0,dict:s},a=ib??new hb,c=a===ib;c&&(ib=void 0),a.reset();let u=ue,f=!1;try{if(n===void 0)ue=0,lz(i,e,t,o,a);else for(let p=0;p<n.length;p++)ue=0,lz(i,e,n[p],o,a);let l=a.out();return f=!0,l}finally{s!==void 0&&(f?Hne(s):Wne(s)),a.abort(),ue=u,c&&(ib=a)}}function Kz(e,t,n,r,o){return Wz(e,void 0,t,n,r,o)}function yb(e,t,n,r,o){return Wz(e,t,void 0,n,r,o)}function Ib(e){return gs(e)&&Ft(e)}var Rn=globalThis.Symbol.for("~effect/encoding/SchemaBinary/absent");function xr(e,t){let n=rh(e,t);return n!==Rn&&t.pos!==t.end&&Q("no leftover bytes",void 0,t.options),n}function tre(e,t){let n=t.enter(t.uvarint()),r=xr(e,t);return t.exit(n),r}function Vz(e,t){if(Eb(e))return rh(e,t);let n=wb(e),r=t.enter(n!==void 0?n:e._==="null"||e._==="undefined"?0:t.uvarint()),o=xr(e,t);return t.exit(r),o}var nre=8;function rre(e,t){let n=e.set;if(n!==void 0)return n.has(t)?!0:(n.add(t),!1);let r=e.list;if(r.includes(t))return!0;if(r.length>=nre){let o=e.set=new Set;for(let s=0;s<r.length;s++)o.add(r[s]);o.add(t)}else r.push(t);return!1}function Jz(e,t,n,r,o){let s=t.uvarint(),i=Math.floor(o===void 0?s/ts:s/16),a=o===void 0?s-i*ts:Math.floor((s-i*16)/2),c=o===void 0?t.readUtf8(i):ore(o,s,i,t);rre(r,c)&&Q("unique extra keys",void 0,t.options);let u=e.extraAll??(t.indexSignatures??=new eh(t.options)).find(e,c);if(u===void 0){hA(a,t);return}nt[ue++]=c;let f=Qz(u.layout,u.wireMask,a,t);ue--,f!==Rn&&W(n,c,f)}function ore(e,t,n,r){if((t&1)===1)return n>=e.length&&Q("a known back-reference",void 0,r.options),e[n];let o=r.readUtf8(n);return e.push(o),o}function Gz(e){return new Ct([e.name],new sn(e.annotations))}function Zz(e,t){throw pn(new At(e.ast,t))}function VC(e){for(;(e.byte()&128)!==0;);}function hA(e,t){switch(e){case af:t.take(t.uvarint());return;case of:VC(t);return;case oh:t.take(8);return;case sh:case ih:case ine:return;case ah:VC(t),VC(t);return;case sne:t.take(4);return}}function oA(e){if(e._==="literal")return oA(e.leaf);switch(e._){case"bool":return 1<<sh|1<<ih;case"number":return 1<<of|1<<oh|1<<ah;case"int":return 1<<of;default:return 1<<af}}function sre(e,t){switch(e){case sh:return!1;case ih:return!0;case of:return t.numberVarint();case oh:return t.f64();case ah:{let n=t.numberVarint(),r=t.uvarint();return(r===0||r>Sb)&&Q("a decimal scale in [1, 8]",r,t.options),n/Nc[r]}}return Q("matching field wire kind",void 0,t.options)}function Qz(e,t,n,r){if((t&1<<n)===0)return hA(n,r),Rn;if(n!==af){let i=sre(n,r);return e._==="literal"&&!ch(e,i)&&Q(bb(e),i,r.options),i}let o=r.enter(r.uvarint()),s=xr(e,r);return r.exit(o),s}function ire(e,t){let n;e.extra.length>0&&(n=t.intern,t.intern=void 0);let r={},o=0,s=0,i,a,c,u=!1,f=e.fields,l=0;for(;t.pos<t.end;){let p=t.fieldTag(),m=Math.floor(p/ts),h=p-m*ts;if(m===0){u&&Q("unique field ids",void 0,t.options),u=!0,h!==af&&Q("extra field map",void 0,t.options);let b=t.enter(t.uvarint());Xz(e,t,r,n),t.exit(b);continue}let g;if(l<f.length&&f[l].id===m?(g=f[l],l++):(g=e.byId.get(m),g!==void 0&&(l=g.index+1)),g===void 0){c===void 0?c=new Set:c.has(m)&&Q("unique field ids",void 0,t.options),c.add(m),hA(h,t);continue}let x=g.index;if(x<32){let b=1<<x;(o&b)!==0&&Q("unique field ids",void 0,t.options),o|=b}else i===void 0?i=new Set([x]):(i.has(x)&&Q("unique field ids",void 0,t.options),i.add(x));nt[ue++]=g.name;let E=Qz(g.layout,g.wireMask,h,t);ue--,E!==Rn&&(W(r,g.name,E),x<32?s|=1<<x:(a??=new Set).add(x))}return Yz(e,s,a,t),r}function Yz(e,t,n,r){if((t&e.requiredMask)===e.requiredMask&&!e.requiredWide)return;let o=e.fields,s;for(let i=0;i<o.length;i++){let a=o[i],c=a.index,u=c<32?(t&1<<c)!==0:n?.has(c)===!0;if(!a.optional&&!u&&((s??=[]).push(Gz(a)),r.options.errors!=="all"))break}s!==void 0&&Zz(e,s)}function are(e,t){let n;e.extra.length>0&&(n=t.intern,t.intern=void 0);let r={},o=e.optionalCount+7>>3,s=0;o>0&&(t.pos+o>t.end&&Q("complete value",void 0,t.options),s=t.pos,t.pos+=o);let i=t.buf,a=e.fields,c=0,u;for(let f=0;f<a.length;f++){let l=a[f];if(l.optional){let m=(i[s+(c>>3)]&1<<(c&7))!==0;if(c++,!m)continue}nt[ue++]=l.name;let p=l.inline?Vz(l.layout,t):tre(l.layout,t);if(ue--,p!==Rn)W(r,l.name,p);else if(!l.optional&&((u??=[]).push(Gz(l)),t.options.errors!=="all"))break}if(u!==void 0&&Zz(e,u),e.extra.length>0){let f=t.uvarint();if(f>t.remaining&&Q("complete value",void 0,t.options),f>0){let l={list:[],set:void 0};for(let p=0;p<f;p++)Jz(e,t,r,l,n)}}return r}function Xz(e,t,n,r){let o={list:[],set:void 0};for(;t.pos<t.end;)Jz(e,t,n,o,r)}function cre(e,t,n){let r=n.uvarint();if((r&1)===1){let i=(r-1)/2;return i>=e.length&&Q("a known back-reference",void 0,n.options),e[i]}if(t._==="string"){let i=n.readUtf8(r/2);return e.push(i),i}let o=n.enter(r/2),s=xr(t,n);return n.exit(o),e.push(s),s}function ure(e,t,n){let r=new Array(t),o=[],s=[];for(let i=0;i<t;i++){nt[ue++]=i;let a=n.enter(n.uvarint());r[i]=lre(e,o,s,n),n.exit(a),ue--}return r}function fre(e,t){let n=t.uvarint(),r=e.fields,o=n&~ub;(n>ub*2-1||o>>>r.length)&&Q("a known row shape",void 0,t.options);let s=[];(n&ub)!==0&&s.push(null);for(let i=0;i<r.length;i++)(o&1<<i)!==0&&s.push(r[i]);return s}function lre(e,t,n,r){let o=e.struct,s={},i=0,a,c=r.uvarint(),u;if(c===0?r.positional&&e.shapes&&(u=fre(o,r),t.push(u)):(u=t[c-1],u===void 0&&Q("a known row shape",void 0,r.options)),u!==void 0){for(let f=0;f<u.length;f++){let l=dz(e,n,u[f],s,r);l>=0&&(l<32?i|=1<<l:(a??=new Set).add(l))}r.pos!==r.end&&Q("no leftover bytes",void 0,r.options)}else{let f=e.shapes?[]:void 0,l=0,p,m,h=!1;for(;r.pos<r.end;){let g=r.uvarint(),x;g===0?(h&&Q("unique field ids",void 0,r.options),h=!0,x=null):(x=o.byId.get(g),x===void 0?m===void 0?m=new Set([g]):m.has(g)?Q("unique field ids",void 0,r.options):m.add(g):x.index<32?((l&1<<x.index)!==0&&Q("unique field ids",void 0,r.options),l|=1<<x.index):p===void 0?p=new Set([x.index]):(p.has(x.index)&&Q("unique field ids",void 0,r.options),p.add(x.index))),f?.push(x);let E=dz(e,n,x,s,r);E>=0&&(E<32?i|=1<<E:(a??=new Set).add(E))}f!==void 0&&t.push(f)}return Yz(o,i,a,r),s}function dz(e,t,n,r,o){let s=o.uvarint();if((s&1)===1){if(n==null)return-1;let u=t[n.index],f=(s-1)/2;(u===void 0||f>=u.length)&&Q("a known back-reference",void 0,o.options);let l=u[f];return l===Rn?-1:(W(r,n.name,l),n.index)}let i=o.enter(s/2);if(n===null)return Xz(e.struct,o,r),o.exit(i),-1;if(n===void 0)return o.exit(i),-1;let a=e.intern[n.index];(a===Az||a===Rz)&&(o.intern=t[n.index]??=[]),nt[ue++]=n.name;let c=xr(n.layout,o);return ue--,o.intern=void 0,o.exit(i),a===uA&&(t[n.index]??=[]).push(c),c===Rn?-1:(W(r,n.name,c),n.index)}function dre(e,t){let n=e.elements.length,r=e.hasCount?t.uvarint():n;if(e.hasCount&&r>t.remaining+1048576&&Q("array count within allocation limit",r,t.options),e.rest.length===0&&r>n)throw nt[ue++]=n,pn(new la(e.ast,void 0,t.options));if(r<e.minCount)throw nt[ue++]=r,pn(new sn(void 0));if(r>0){let i=Nz(e);if(i!==null)return ure(i,r,t)}let o=new Array(r),s=e.uniform;if(s!==void 0){if(e.uniformNumbers)return pre(o,r,t);let i=t.intern;if(t.intern=void 0,i!==void 0){for(let u=0;u<r;u++){nt[ue++]=u;let f=cre(i,s,t);if(f===Rn)throw pn(new sn(void 0));ue--,o[u]=f}return o}if(Eb(s)){for(let u=0;u<r;u++)nt[ue++]=u,o[u]=rh(s,t),ue--;return o}if(s._==="string"){for(let u=0;u<r;u++)nt[ue++]=u,o[u]=t.readUtf8(t.uvarint()),ue--;return o}let a=e.uniformPacked,c=e.uniformInline;for(let u=0;u<r;u++){nt[ue++]=u;let f=t.enter(c?a??0:t.uvarint()),l=xr(s,t);if(t.exit(f),l===Rn)throw pn(new sn(void 0));ue--,o[u]=l}return o}for(let i=0;i<r;i++){let a=Hz(e,i,r),c=i<n&&e.elements[i].optional;if(!e.hasCount&&t.remaining===0&&!c&&a._!=="null"&&a._!=="undefined")throw nt[ue++]=i,pn(new sn(void 0));nt[ue++]=i;let u=Vz(a,t);if(u===Rn)throw c&&Q("known union member",void 0,t.options),pn(new sn(void 0));ue--,o[i]=u}if(!e.hasCount&&t.pos<t.end)throw nt[ue++]=n,pn(new la(e.ast,void 0,t.options));return o}function pre(e,t,n){let r=n.byte();if(r===Ez){n.remaining!==t*8&&Q("f64",void 0,n.options);for(let o=0;o<t;o++)e[o]=n.f64();return e}if(r===Iz){for(let o=0;o<t;o++){nt[ue++]=o;let s=n.uvarint(),i=s%16;i>Sb&&Q("decimal",void 0,n.options);let a=vz((s-i)/16);e[o]=i===0?a:a/Nc[i],ue--}return e}r!==wz&&Q("f64",void 0,n.options);for(let o=0;o<t;o++)nt[ue++]=o,e[o]=n.numberVarint(),ue--;return e}function mre(e,t){let n=t.byte();if(n===St.variant){let o=t.u32le(),s=e.byTag.get(o);if(s===void 0)return t.take(t.remaining),Rn;let i=xr(s.payload,t);if(i===Rn)return Rn;if(!s.tuple)for(let a of s.sentinels)W(i,a.key,a.literal);return i}let r=e.byKind.get(n);return r===void 0?(t.take(t.remaining),Rn):xr(r,t)}function hre(e,t){let n=e.byPos[t.uvarint()];n===void 0&&Q("known union member",void 0,t.options);let r=xr(n.layout,t),o=n.variant;if(o!==void 0&&!o.tuple&&r!==Rn)for(let s of o.sentinels)W(r,s.key,s.literal);return r}function pz(e,t){switch(t.byte()){case 0:return Hf(ud(xr(e.error,t)));case 1:return Wf(ud(xr(e.defect,t)));case 2:return t.remaining!==0&&Q("empty",void 0,t.options),lu();case 3:return t.remaining!==8&&Q("f64",void 0,t.options),lu(t.f64());default:return t.take(t.remaining),Rn}}function ud(e){if(e===Rn)throw pn(new sn(void 0));return e}function rh(e,t){switch(e._){case"literal":{let n=rh(e.leaf,t);return ch(e,n)||Q(bb(e),n,t.options),n}case"bool":{t.remaining!==1&&Q("bool",void 0,t.options);let n=t.byte();return n>1&&Q("bool",void 0,t.options),n===1}case"null":return t.remaining!==0&&Q("empty",void 0,t.options),null;case"undefined":t.remaining!==0&&Q("empty",void 0,t.options);return;case"number":{let n=t.remaining;if(n===8)return t.f64();(n===0||n>bz)&&Q("f64",void 0,t.options);let r=t.numberVarint();if(t.remaining===0)return r;let o=t.byte();return(t.remaining!==0||o===0||o>Sb)&&Q("decimal",void 0,t.options),r/Nc[o]}case"int":return t.numberVarint();case"string":{let n=t.dict;return n===void 0?t.readUtf8(t.end-t.pos):Vne(n,e,t)}case"symbol":return globalThis.Symbol.for(t.readUtf8(t.end-t.pos));case"bytes":return t.takeCopy(t.end-t.pos);case"bigint":return t.zigzag();case"int64":{t.remaining!==8&&Q("int64",void 0,t.options);let n=Number(t.i64());if(e.flavor!=="date")return eU(n);let r=new Date(n);return Number.isNaN(r.getTime())&&Q("a valid Date",n,t.options),r}case"dateTimeZoned":{let n=Number(t.i64()),r=t.byte(),o;if(r===0)t.remaining!==4&&Q("time zone",void 0,t.options),o=t.i32le();else if(r===1)o=t.readUtf8(t.end-t.pos);else return Q("time zone",void 0,t.options);try{return Cx(n,{timeZone:o})}catch{return Q("time zone",void 0,t.options)}}case"duration":switch(t.byte()){case 0:return Lr(t.zigzag());case 1:return po;case 2:return Zi;default:return Q("duration",void 0,t.options)}case"bigDecimal":{let n=t.zigzag(),r=t.zigzag();return(r>GC||-r>GC)&&Q("safe integer length",void 0,t.options),sr(n,Number(r))}case"json":{let n=t.readUtf8(t.end-t.pos);try{return JSON.parse(n)}catch{return Q("json",void 0,t.options)}}case"option":{let n=t.byte();return n===0?(t.remaining!==0&&Q("empty",void 0,t.options),D()):(n!==1&&Q("bool",void 0,t.options),L(ud(xr(e.value,t))))}case"result":{let n=t.byte();return n===0?Ce(ud(xr(e.success,t))):(n!==1&&Q("bool",void 0,t.options),Ae(ud(xr(e.failure,t))))}case"exit":{let n=t.byte();if(n===0)return kn(ud(xr(e.value,t)));n!==1&&Q("bool",void 0,t.options);let r=rh(e.cause,t);return jt(r)}case"cause":{let n=t.uvarint(),r=[];for(let o=0;o<n;o++){nt[ue++]=o;let s=t.enter(t.uvarint()),i=pz(e,t);t.exit(s),ue--,i!==Rn&&r.push(i)}return t.pos!==t.end&&Q("no leftover bytes",void 0,t.options),Xa(r)}case"causeReason":return pz(e,t);case"struct":return t.positional?are(e,t):ire(e,t);case"array":return dre(e,t);case"union":return t.positional?hre(e,t):mre(e,t);case"never":throw pn(new st(e.ast,void 0,t.options))}}function eH(e,t,n){let r=t.byte();if(r!==n.envelope&&Q(n.expectedEnvelope,r,t.options),n.positional){t.remaining<8&&Q("complete value",void 0,t.options);let s=t.buf,i=n.fingerprint,a=t.pos;for(let c=0;c<8;c++)s[a+c]!==i[c]&&Q("matching layout fingerprint",void 0,t.options);t.pos=a+8}let o=xr(e,t);if(o===Rn)throw pn(new sn(void 0));return o}var ab=new th;function gre(e,t,n,r){let o=ab??new th,s=o===ab;s&&(ab=void 0),o.reset(t,0,t.length,n,void 0,r.positional,void 0);let i=ue;ue=0;try{let a=o.uvarint();a===0&&Q("nonzero frame length",void 0,n);let c=o.enter(a),u=eH(e,o,r);return o.exit(c),o.pos!==t.length&&Q("no leftover bytes",void 0,n),u}finally{ue=i,o.release(),s&&(ab=o)}}function xre(e,t,n,r=!1){return Ar({decode:(o,s)=>{try{let i=gre(e,o,s,t);return n!==void 0&&hd(i)&&(!r||Ib(i))&&(n.value=i),v(i)}catch(i){return i instanceof Di?G(i.issue):ho(i)}},encode:(o,s)=>{try{return v(yb(e,o,s,t))}catch(i){return i instanceof Di?G(i.issue):ho(i)}}})}var yre=wn(Cne);function sf(e,t){return t===!0?yre(e):kne}var Sre=wn(e=>{let t=re(fb(e)),{exact:n,exitSuccess:r,layout:o,recursive:s}=wne(t.ast);return{target:s?vre(t):t,layout:o,exact:n,exitSuccess:r,recursive:s}});function ld(e){return Sre(e.ast)}function tH(e,t){return e.value===void 0||t!==e.value?!1:(e.value=void 0,!0)}function nH(e,t,n){let r=re(yn(e.ast)),o=dt(r),s=i=>()=>(a,c,u)=>i(a,u)?on:o(a,u);return re(new pa([r.ast],s(t),{identifier:"binary value"},void 0,void 0,void 0,void 0,s(n)))}function sA(e,t){return t.onExcessProperty!=="error"}function bre(e,t,n){return nH(e,r=>tH(t,r),n?sA:Ere)}function Ere(){return!1}function wre(e,t){return An()([e],([n])=>{let r=dt(n);return(o,s,i)=>tH(t,o)||Ib(o)&&i.onExcessProperty!=="error"?v(o):r(o,i)},{identifier:"binary exit value"})}function Ire(e){return nH(e,sA,sA)}function vre(e){let t=re(yn(e.ast)),n=new WeakSet,r=An()([t],([o])=>(s,i,a)=>hd(s)&&n.delete(s)?v(s):gr(s)?G(new st(i,s,a)):dt(o)(s,a),{identifier:"acyclic value"});return be(r,vt({decode:o=>(hd(o)&&n.add(o),o),encode:o=>o}))(e)}var fh=Cc,bn=class extends Ke()("effect/rpc/RpcSerialization"){},uh=class extends Mn("MaxBufferSizeExceeded"){get message(){return`RPC serialization buffer exceeded the maximum size of ${this.maxBufferSize}`}},sH=16*1024*1024,vb=(e,t)=>t!=="unbounded"&&e>t,iH=bn.of({contentType:"application/json",includesFraming:!1,codecFor:fh,makeUnsafe:()=>{let e=new TextDecoder;return{decode:t=>{let n=JSON.parse(typeof t=="string"?t:e.decode(t));return Array.isArray(n)?n:[n]},encode:t=>JSON.stringify(t)}}}),Tb=e=>{let t=e?.maxBufferSize??sH;return bn.of({contentType:"application/ndjson",includesFraming:!0,codecFor:fh,makeUnsafe:()=>{let n=new TextDecoder,r="",o=s=>{throw r="",new uh({maxBufferSize:s})};return{decode:s=>{r+=typeof s=="string"?s:n.decode(s,{stream:!0});let i=0,a=r.indexOf(`
|
|
39
|
+
`,i),c=[];for(;a!==-1;){vb(a-i,t)&&o(t);let u=JSON.parse(r.slice(i,a));c.push(u),i=a+1,a=r.indexOf(`
|
|
40
|
+
`,i)}return r=r.slice(i),vb(r.length,t)&&o(t),c},encode:s=>{if(Array.isArray(s)){if(s.length===0)return;let i="";for(let a=0;a<s.length;a++)i+=JSON.stringify(s[a])+`
|
|
34
41
|
`;return i}return JSON.stringify(s)+`
|
|
35
|
-
`}}}})},$z=xE(),qz=e=>En.of({contentType:e?.contentType??"application/json",includesFraming:!1,codecFor:oh,makeUnsafe:()=>{let t=new TextDecoder,n=new Map;return{decode:r=>{let o=JSON.parse(typeof r=="string"?r:t.decode(r));return Hz(o,n)},encode:r=>{let o=Wz(r,n);return o&&JSON.stringify(o)}}}}),zz=e=>En.of({contentType:e?.contentType??"application/json-rpc",includesFraming:!0,codecFor:oh,makeUnsafe:()=>{let t=xE({maxBufferSize:e?.maxBufferSize}).makeUnsafe(),n=new Map;return{decode:r=>{let o=t.decode(r);if(o.length===0)return[];let s=[];for(let i=0;i<o.length;i++){let a=o[i];s.push(...Hz(a,n))}return s},encode:r=>{let o=Wz(r,n);return o&&t.encode(o)}}}});function Hz(e,t){if(Array.isArray(e)){let n={size:0,responses:new Map},r=[];for(let o=0;o<e.length;o++){let s=Nz(e[o]);r.push(s),s._tag==="Request"&&!s.isNotification&&(n.size++,t.set(s.id,n))}return r}return[Nz(e)]}function Nz(e){if(Object.hasOwn(e,"method")){let r=e;if(IA(r.id)&&r.method.startsWith("@effect/rpc/")){let o=r.method.slice(12),s=r.params?.requestId;return s?{_tag:o,requestId:s}:{_tag:o}}return{_tag:"Request",id:r.id??"",tag:r.method,payload:r.params??null,headers:r.headers??[],...B(r,"id")?{}:{isNotification:!0},...r.spanId?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{}}}let t=e,n=Object.hasOwn(t,"error");return n&&t.error&&t.error._tag==="Defect"?{_tag:"Defect",defect:t.error.data}:Object.hasOwn(t,"chunk")&&t.chunk===!0?{_tag:"Chunk",requestId:t.id??"",values:t.result}:{_tag:"Exit",requestId:t.id??"",exit:n&&t.error!=null?{_tag:"Failure",cause:t.error._tag==="Cause"?t.error.data:[{_tag:"Die",defect:t.error}]}:{_tag:"Success",value:t.result}}}function Lz(e,t){if(!("requestId"in e))return rA(e);let n=t.get(e.requestId);return n?(t.delete(e.requestId),n.responses.set(e.requestId,e),n.size===n.responses.size?Array.from(n.responses.values(),rA):void 0):rA(e)}function Wz(e,t){if(Array.isArray(e)===!1)return Lz(e,t);if(e.length===0)return;let n=[];for(let o=0;o<e.length;o++){let s=Lz(e[o],t);s!==void 0&&n.push(s)}if(n.length===0)return;if(n.length===1)return n[0];let r=[];for(let o=0;o<n.length;o++){let s=n[o];Array.isArray(s)?r.push(...s):r.push(s)}return r}function rA(e){switch(e._tag){case"Request":return{jsonrpc:"2.0",method:e.tag,params:e.payload,...e.isNotification?{}:{id:e.id},...e.headers?.length>0?{headers:e.headers}:{},traceId:e.traceId,spanId:e.spanId,sampled:e.sampled};case"Ping":case"Pong":case"Interrupt":case"Ack":case"Eof":return{jsonrpc:"2.0",method:`@effect/rpc/${e._tag}`,params:"requestId"in e?{requestId:e.requestId}:void 0};case"Chunk":return{jsonrpc:"2.0",chunk:!0,id:e.requestId,result:e.values};case"Exit":{if(e.exit._tag==="Success")return{jsonrpc:"2.0",id:e.requestId??void 0,result:e.exit.value};let t=e.exit.cause.find(r=>r._tag==="Fail"),n=t?._tag==="Fail"?t.error:void 0;return{jsonrpc:"2.0",id:e.requestId??void 0,error:e.exit._tag==="Failure"?{_tag:"Cause",code:n&&B(n,"code")?Number(n.code):0,message:n&&B(n,"message")?n.message:JSON.stringify(e.exit.cause),data:e.exit.cause}:void 0}}case"Defect":return{jsonrpc:"2.0",id:Zne,error:{_tag:"Defect",code:1,message:"A defect occurred",data:e.defect}};case"ClientProtocolError":return{}}}var Zne=-32603,oA=e=>{let{maxBufferSize:t=Bz,...n}=e??{};return En.of({contentType:"application/msgpack",includesFraming:!0,codecFor:oh,makeUnsafe:()=>{let r=new Ri(n),o=new Ac(n),s=new TextEncoder,i,a=c=>{throw i=void 0,new rh({maxBufferSize:c})};return{decode(c){let u=typeof c=="string"?s.encode(c):c;if(i!==void 0){gE(i.length+u.length,t)&&a(t);let f=u;c=new Uint8Array(i.length+u.length),c.set(i),c.set(f,i.length),u=c,i=void 0}try{return r.unpackMultiple(u)}catch(f){let l=f;if(l.incomplete)return i=u.subarray(l.lastPosition),gE(i.length,t)&&a(t),l.values??[];throw f}},encode:c=>o.pack(c)}}})},Kz=oA({useRecords:!0}),Qne=16*1024*1024,Yne=new TextEncoder,Xne=e=>{let t=e?.maxFrameSize??Qne,n=e?.fingerprintPayloads===!0?o=>VC(o,{fingerprint:!0}):VC,r={fingerprint:!0,dictionary:!0};return En.of({contentType:"application/vnd.effect.rpc+schema-binary",includesFraming:!0,codecFor:n,makeUnsafe:()=>{let o=Zq(yC,{...r,maxFrameSize:t}),s=Yq(yC,r);return{decode:i=>o.feedSync(typeof i=="string"?Yne.encode(i):i),encode:i=>{if(!Array.isArray(i))return s.encode(i);if(i.length!==0)return s.encodeMany(i)}}}})},ere=ii(En)(jz),tre=ii(En)($z),nre=e=>ii(En)(xE(e)),rre=e=>ii(En)(qz(e)),ore=e=>ii(En)(zz(e)),sre=ii(En)(Kz),ire=e=>ii(En)(oA(e)),are=e=>W0(En)(()=>Xne(e));var yE=class extends Ke()("effect/rpc/RpcWorker/InitialMessage"){};var Jz=e=>K(()=>{let t=new Set,n=new Map,r=new Map,o=(s,i)=>cr(a=>{let c=n.get(s);return c||(c=[],n.set(s,c)),c.push([i,a]),H});return Y(e((s,i)=>{let a=r.get(s);return a?a(i):o(s,i)},t),s=>({...s,run(i,a){return qt(function*(){t.add(i),r.set(i,a);let c=n.get(i);if(c){n.delete(i);for(let[u,f]of c)yield*Nn(K(()=>a(u)),f)}return yield*ur(Hr,()=>(t.delete(i),r.delete(i),H))})}}))});var ure=e=>yr(e,"RpcClientError"),fre=0,Gz=ye(function*(e,t){let n=t?.spanPrefix??"RpcClient",r=t?.supportsAck??!0,o=t?.disableTracing??!1,s=t?.generateRequestId??(()=>fre++),i=yield*ar(),a=qe(i,It),c=new Map,u=!1;yield*_t(a,xn(E=>(u=!0,f(Lg(E.id)))));let f=ye(function*(E){for(let[y,w]of c)c.delete(y),w._tag==="Queue"?yield*E._tag==="Success"?zp(w.queue):Zt(w.queue,E.cause):w.resume(E)}),l=E=>{let y=jm(E.successSchema),w=h(E);return(S,C)=>{let _=C?.headers?ki(C.headers):Kl,R=C?.context??bt();if(!y){let q=P=>p(E,w,P,E.payloadSchema.make(S),_,R,C?.discard??!1);return o?q(void 0):cp(`${n}.${E._tag}`,{attributes:t.spanAttributes},q)}let M=m(E,w,E.payloadSchema.make(S),_,C?.streamBufferSize??16,R);return C?.asQueue?M:mr(Y(M,Ii))}},p=(E,y,w,S,C,_,R)=>xn(M=>{if(u)return ho;let q=s(),P=y(ee=>t.onFromClient({message:ee,context:_,discard:R}),{_tag:"Request",id:q,tag:E._tag,payload:S,...w?{traceId:w.traceId,spanId:w.spanId,sampled:w.sampled}:{},headers:Vl(M.getRef(SE),C)});if(R)return P;let te;return ui(Es(ee=>{let T={_tag:"Effect",rpc:E,context:_,resume(z){ee(z),te&&!te.pollUnsafe()&&M.currentDispatcher.scheduleTask(()=>{te.interruptUnsafe(M.id)},0)}};c.set(q,T),te=P.pipe(w?Xf(w,{captureStackTrace:!1}):L,Ln(M.context)),te.addObserver(z=>{if(z._tag==="Failure")return ee(z)})}),ee=>(c.delete(q),Dn(yo(te),g(q,Array.from(ee),_))))}),m=ye(function*(E,y,w,S,C,_){if(u)return yield*ho;let R=o?void 0:yield*Uw(`${n}.${E._tag}`,{attributes:t.spanAttributes}),M=xi(),q=s(),P=Jn(M.context,It);yield*Fo(P,ee=>c.has(q)?(c.delete(q),g(q,ri(ee)?Array.from(XM(ee.cause)):[],_)):H);let te=yield*Ou(C);return c.set(q,{_tag:"Queue",rpc:E,queue:te,scope:P,context:_}),yield*y(ee=>t.onFromClient({message:ee,context:_,discard:!1}),{_tag:"Request",id:q,tag:E._tag,payload:w,...R?{traceId:R.traceId,spanId:R.spanId,sampled:R.sampled}:{},headers:Vl(M.getRef(SE),S)}).pipe(R?Xf(R,{captureStackTrace:!1}):L,ft(ee=>Zt(te,ee)),ra,Ut(P,{startImmediately:!0})),te}),h=E=>{let y=[];for(let w of E.middlewares.values()){let S=qi(i,`${w.key}/Client`);S&&y.push(S)}return y.length===0?(w,S)=>w(S):function w(S,C,_=y.length-1){return _===-1?S(C):y[_]({rpc:E,request:C,next(R){return w(S,R,_-1)}})}},g=(E,y,w)=>Es(S=>{let C=xi();t.onFromClient({message:{_tag:"Interrupt",requestId:E,interruptors:y},context:w,discard:!1}).pipe(Iw(1e3),Ln(C.context)).addObserver(()=>{S(H)})}),x=E=>{switch(E._tag){case"Chunk":{let y=E.requestId,w=c.get(y);return!w||w._tag!=="Queue"?H:ga(w.queue,E.values).pipe(r?A(()=>t.onFromClient({message:{_tag:"Ack",requestId:E.requestId},context:w.context,discard:!1})):L,ft(S=>Zt(w.queue,S)))}case"Exit":{let y=E.requestId,w=c.get(y);return w?(c.delete(y),w._tag==="Effect"?(w.resume(E.exit),H):E.exit._tag==="Success"?zp(w.queue):Zt(w.queue,E.exit.cause)):H}case"Defect":return f(Ng(E.defect));case"ClientEnd":return H}},b;if(t.flatten){let E=new Map;b=function(w,S,C){let _=E.get(w);return _||(_=l(e.requests.get(w)),E.set(w,_)),_(S,C)}}else b={},e.requests.forEach(E=>{W(b,E._tag,l(E))});return{client:b,write:x}}),lre=0,sA=ye(function*(e,t){let n=lre++,{codecFor:r,run:o,send:s,supportsAck:i,supportsTransferables:a}=yield*Pi,c=dre(r),u=dm(r(ln())),f=new Map,{client:l,write:p}=yield*Gz(e,{...t,supportsAck:i,onFromClient({message:m}){switch(m._tag){case"Request":{let h=e.requests.get(m.tag),g=a?eq():void 0,x=xi(),b={rpc:h,context:g?Ve(x.context,Bm,g):x.context,schemas:c(h)};return f.set(m.id,b),b.schemas.encodePayload(m.payload).pipe(Nn(b.context),ci,A(E=>s(n,{...m,id:m.id,payload:E,headers:Object.entries(m.headers)},g&&g.readUnsafe())))}case"Ack":return f.get(m.requestId)?s(n,{_tag:"Ack",requestId:m.requestId}):H;case"Interrupt":return f.get(m.requestId)?(f.delete(m.requestId),s(n,{_tag:"Interrupt",requestId:m.requestId})):H;case"Eof":return H}}});return yield*o(n,m=>{switch(m._tag){case"Chunk":{let h=zm(m.requestId),g=f.get(h);return!g||ge(g.schemas.decodeChunk)?H:g.schemas.decodeChunk.value(m.values).pipe(Nn(g.context),ci,A(x=>p({_tag:"Chunk",clientId:0,requestId:zm(m.requestId),values:x})),mo(x=>p({_tag:"Exit",clientId:0,requestId:zm(m.requestId),exit:jt(x)})))}case"Exit":{let h=zm(m.requestId),g=f.get(h);return g?(f.delete(h),g.schemas.decodeExit(m.exit).pipe(Nn(g.context),ci,Kr({onSuccess:x=>p({_tag:"Exit",clientId:0,requestId:h,exit:x}),onFailure:x=>p({_tag:"Exit",clientId:0,requestId:h,exit:jt(x)})}))):H}case"Defect":return p({_tag:"Defect",clientId:0,defect:u(m.defect)});case"ClientProtocolError":{let h=Mo(m.error);return Do(f.keys(),g=>p({_tag:"Exit",clientId:0,requestId:g,exit:h}))}default:return H}}).pipe(ft(fp),ra,bs),l}),dre=e=>{let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let o=qS(n.successSchema);return r={decodeChunk:Lt(o,s=>hc(e(rS(s.success)))),encodePayload:tS(e(n.payloadSchema)),decodeExit:hc(e(gC(n)))},t.set(n,r),r}},SE=Me("effect/rpc/RpcClient/CurrentHeaders",{defaultValue:()=>Kl}),pre=d(2,(e,t)=>Rw(e,SE,Vl(ki(t)))),Pi=class extends Ke()("effect/rpc/RpcClient/Protocol"){static make=Jz},Zz=e=>Pi.make(ye(function*(t){let n=yield*En,r=n.includesFraming,o=u=>new qs({reason:Jl.fromHttpClientError(u)}),s=(u,f)=>new qs({reason:new Tc({message:u,cause:f})}),i=u=>s("Received empty HTTP response from RPC server",u),a=u=>s("HTTP response ended before RPC request completed",u);return{send:ye(function*(u,f){if(f._tag!=="Request")return;let l=n.makeUnsafe(),p=l.encode(f),m=typeof p=="string"?Fk(p,n.contentType):TS(p,n.contentType),h=yield*e.post("",{body:m}).pipe(Yf(o));if(!r){let b=yield*h.text.pipe(Yf(o)),E=yield*No({try:()=>l.decode(b),catch:S=>s("Error decoding HTTP response",S)});if(!Array.isArray(E))return yield*s("Expected an array of responses",E);if(E.length===0)return yield*i(f);let y=!1,w=0;return yield*Qn({while:()=>w<E.length,body:()=>{let S=E[w++];return SC(S)&&(y=!0),t(u,S)},step:bn}),y?void 0:yield*a(f)}let g=!1,x=!1;if(yield*Wl(h.stream,b=>No({try:()=>b.flatMap(l.decode),catch:E=>s("Error decoding HTTP response",E)}).pipe(A(E=>{if(E.length===0)return H;g=!0;let y=0;return Qn({while:()=>y<E.length,body:()=>{let w=E[y++];return SC(w)&&(x=!0),t(u,w)},step:bn})}))).pipe(Yf(b=>ure(b)?b:o(b))),g){if(!x)return yield*a(f)}else return yield*i(f)}),supportsAck:!1,supportsTransferables:!1,codecFor:n.codecFor}})),mre=e=>qr(Pi)(A(zk,t=>(t=j$(t,M$(e.url)),Zz(e.transformClient?e.transformClient(t):t)))),Qz=e=>Pi.make(ye(function*(t,n){let r=yield*H$,o=yield*En,s=yield*hu(ih),i=new Map,a=yield*r.writer,c=o.makeUnsafe(),u=yield*gre(K(()=>a(c.encode(oq)))),f,l=K(()=>(f=void 0,Te(s)?s.value.onConnect:H)),p=h=>Do(n,g=>t(g,h)),m=h=>(f=h,p({_tag:"ClientProtocolError",error:h}));return yield*K(()=>(c=o.makeUnsafe(),u.reset(),r.runRaw(h=>{try{let g=c.decode(h);if(g.length===0)return;let x=0;return Qn({while:()=>x<g.length,body:()=>{let b=g[x++];if(b._tag==="Pong")return u.onPong(),H;if(Object.hasOwn(b,"requestId")){let E=b.requestId,y=i.get(E);if(y!==void 0)return b._tag==="Exit"&&i.delete(E),t(y,b)}return p(b)},step:bn})}catch(g){return p({_tag:"ClientProtocolError",error:new qs({reason:new Tc({message:"Error decoding message",cause:g})})})}},{onOpen:l}).pipe(Ya(A(u.timeout,()=>G(new Zl({reason:new Pm({kind:"Timeout",cause:new Error("ping timeout")})}))))))).pipe(A(()=>G(new Zl({reason:new Fm({code:1e3})}))),Te(s)?na(s.value.onDisconnect):L,sp(h=>{let g=jf(h),x=Kt(g),b=new qs({reason:x?g.success.reason:new Tc({message:"Unknown socket error",cause:su(h)})});return e?.retryTransientErrors&&x&&g.success.reason._tag==="SocketOpenError"?(e.onTransientError?.(b)??H).pipe(ww({log:!0,message:"RpcClient onTransientError hook failed"})):m(b)}),Ew(e?.retryPolicy??hre,h=>m(new qs({reason:h.reason}))),fx({module:"RpcClient",method:"makeProtocolSocket"}),bs),{send(h,g){if(f)return G(f);g._tag==="Request"&&i.set(g.id,h);let x=c.encode(g);return x===void 0?H:ci(a(x))},supportsAck:!0,supportsTransferables:!1,codecFor:o.codecFor}})),hre=WP([KP(500,1.5),Vf(5e3)]),gre=ye(function*(e){let t=!0,n=fr(),r=()=>{t=!0,n.closeUnsafe()},o=()=>{t=!0};return yield*K(()=>t?(t=!1,e):n.open).pipe(ta("5 seconds"),bw,Ht,ra,bs),{timeout:n.await,reset:r,onPong:o}}),xre=e=>qr(Pi)(Qz(e)),Yz=e=>Pi.make(ye(function*(t,n){let r=yield*$S,o=yield*jo,s=0,i=yield*hu(yE),a=yield*hu(ih),c=new Map,u=m=>Do(n,h=>t(h,m)),f=qt(function*(){let m=s++,h=yield*r.spawn(m);return yield*h.run(g=>{if(g._tag==="Exit"){let x=c.get(g.requestId);if(x)return c.delete(g.requestId),x.latch.openUnsafe(),t(x.clientId,g)}else if(g._tag==="Defect"){for(let[x,b]of c)c.delete(x),b.latch.openUnsafe();return u(g)}else if("requestId"in g){let x=c.get(g.requestId);if(x)return t(x.clientId,g)}return u(g)},{onSpawn:Te(i)?A(i.value,([g,x])=>ci(h.send({_tag:"InitialMessage",value:g},x))):void 0}).pipe(sp(g=>{for(let[b,E]of c)E.worker===h&&(c.delete(b),E.latch.openUnsafe());let x=jf(g);return u({_tag:"ClientProtocolError",error:new qs({reason:Kt(x)?x.success.reason:new Tc({message:"Error in worker",cause:su(g)})})})}),ix(Vf(1e3)),fx({module:"RpcClient",method:"makeProtocolWorker"}),ra,bs),h}),l="minSize"in e?yield*Gj({acquire:f,min:e.minSize,max:e.maxSize,concurrency:e.concurrency,targetUtilization:e.targetUtilization,timeToLive:e.timeToLive}):yield*Jj({acquire:f,size:e.size,concurrency:e.concurrency,targetUtilization:e.targetUtilization});yield*_t(o,se(()=>{for(let m of c.values())m.latch.openUnsafe();c.clear()}));let p=(m,h,g)=>{switch(h._tag){case"Request":return Sk(l).pipe(A(x=>{let b=fr(!1);return c.set(h.id,{clientId:m,worker:x,latch:b}),A(x.send(h,g),()=>b.await)}),gu,ci);case"Interrupt":{let x=c.get(h.requestId);return x?(c.delete(h.requestId),x.latch.openUnsafe(),ci(x.worker.send(h))):H}case"Ack":{let x=c.get(h.requestId);return x?ci(x.worker.send(h)):H}}return H};return yield*gu(Sk(l)),Te(a)&&(yield*a.value.onConnect),{send:p,supportsAck:!0,supportsTransferables:!0,codecFor:Ec}})),yre=Fc(Yz,qr(Pi)),ih=class extends Ke()("effect/rpc/RpcClient/ConnectionHooks"){};var EE="~effect/reactivity/Atom",tH=e=>B(e,EE),aA="~effect/reactivity/Atom/Writable",uh=d(2,(e,t)=>{let n=gt(t),r=as(n);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!r,idleTTL:r?Tn(n):void 0})}),tf=uh(0),uA={[EE]:EE,equals:Object.is,...vn,toJSON(){return{_id:"Atom",keepAlive:this.keepAlive,lazy:this.lazy,label:this.label}}},Sre={...uA,atom(e,t){let n=nH(e,t);return Fi(r=>{let o=r.self(),s=r(this);return s._tag!=="Success"?Dm(s,o):n(r,s.value)})},fn(e,t){return arguments.length===0?(n,r)=>Xz(this,n,r):Xz(this,e,t)},pull(e,t){let n=tf(fA(0)),r=Fi(o=>{let s=o.self(),i=o(this);return i._tag!=="Success"?Dm(i,s):bE(o,Ore(o,n,e,t),Ia(!0),i.value)});return Rre(n,r)},subscriptionRef(e){return kre(tf(Fi(t=>{let n=t.self(),r=t(this);if(r._tag!=="Success")return Dm(r,n);let o=typeof e=="function"?e(t):e;return Om(o)?o:bE(t,o,Ia(!0),r.value)})),(t,n)=>{let r=Xk(t(this));return Tre(t,n,r)})}},Xz=(e,t,n)=>{let[r,o,s]=Are(n?.reactivityKeys?(i,a)=>{let c=t(i,a);return Cr(c)?SS(c,n.reactivityKeys):Cm(c,ES(n.reactivityKeys))}:t,n);return fh(i=>{i.get(s);let a=i.self(),c=i.get(e);return c._tag!=="Success"?Dm(c,a):r(i,c.value)},o)},Ere={...uA,[aA]:aA},bre=e=>aA in e,Fi=(e,t)=>{let n=Object.create(uA);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.refresh=t,n},fh=(e,t,n)=>{let r=Object.create(Ere);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.write=t,r.refresh=n,r};function wre(e,t){e.setSelf(t)}var ch=(e,t)=>{let n=nH(e,t);return EE in n?n:Fi(n)},nH=(e,t)=>{if(typeof e=="function"&&!Cr(e)&&!Ue(e)){let n=e;return function(r,o){let s=n(r);switch(typeof s){case"function":case"object":return s===null?s:rH in s?cA(r,s,t,o):Ire in s?eH(r,s,t,o):s;default:return s}}}else{if(Cr(e))return function(n,r){return cA(n,e,t,r)};if(Ue(e))return function(n,r){return eH(n,e,t,r)}}return fA(e)},rH="~effect/Effect",Ire="~effect/Stream",fA=e=>fh(function(t){return e},wre),cA=(e,t,n,r)=>{let o=n?.initialValue!==void 0?Go(n.initialValue):Ia();return bE(e,t,o,r,n?.uninterruptible)};function bE(e,t,n,r=bt(),o=!1){let s=e.self(),i=$r();e.addFinalizer(()=>{Ln(r)(Je(i,Vt))});let a,c=!1,u=lA(r.pipe(Ve(It,i),Ve(BS,e.registry),Ve(ja,e.registry.scheduler)),t,function(f){a=Qk(f,s),c&&e.setSelf(a)},o);return c=!0,u!==void 0&&e.addFinalizer(u),a!==void 0?a:s._tag==="Some"?LS(s):Um(n)}function lA(e,t,n,r=!1){if(ms(t)){n(t);return}let s=Ln(e)(t);s.currentDispatcher?.flush();let i=s.pollUnsafe();if(i){n(i);return}let a=s.addObserver(n);function c(){a(),r||s.interruptUnsafe()}return c}function vre(e){let t=e?.memoMap??tf(ch(()=>oi())),n=i=>tH(t)?i(t):t,r=bS;function o(i){let a=Object.create(Sre);a.keepAlive=!1,a.lazy=!0,a.refresh=void 0,a.factory=o;let c=hA(Fi(typeof i=="function"?u=>Kd(i(u),r):()=>Kd(i,r)));return a.layer=c,a.read=function(f){let l=f(c),p=A(jo,m=>si(l,n(f),m));return cA(f,p,{uninterruptible:!0})},a}o.memoMap=t,o.addGlobalLayer=i=>{r=Kd(r,gs(i,bS))};let s=tf(ch(i=>cr(a=>si(bS,n(i),qe(a,It))).pipe(Y(qe(Ti)))));return o.withReactivity=i=>a=>_re(a,c=>{let u=Xk(c(s));return c.addFinalizer(u.registerUnsafe(i,()=>{c.refresh(a)})),c.subscribe(a,f=>c.setSelf(f)),c.once(a)},{initialValueTarget:a}),o}var dA=vre(),$pe=dA.withReactivity,eH=(e,t,n,r)=>{let o=n?.initialValue!==void 0?Go(n.initialValue):Ia();return pA(e,t,o,r)};function pA(e,t,n,r=bt()){let o=e.self();r=Ve(r,BS,e.registry);let s=ap(a=>A(Ho(t.channel,a),c=>Qn({while:Xt,body:()=>c,step(u){e.setSelf(Go(Sf(u),{waiting:!0}))}}))).pipe(ft(a=>(Uo(a)?of(e.self(),rs(Yk),rr({onNone:()=>e.setSelf(G$(new $f,{previous:e.self()})),onSome:c=>e.setSelf(Go(c))})):e.setSelf(Yl(a,{previous:e.self()})),H))),i=lA(r.pipe(Ve(BS,e.registry),Ve(ja,e.registry.scheduler)),s,bn,!1);return i!==void 0&&e.addFinalizer(i),o._tag==="Some"?LS(o):Um(n)}var Tre=(e,t,n=bt())=>Om(t)?(e.addFinalizer(vk(t).pipe(Wl(r=>{for(let o=0;o<r.length;o++)e.setSelf(r[o]);return H}),Dw(n))),Bw(n)(n$(t))):t._tag!=="Success"?t:pA(e,vk(t.value),Ia(!0),n),kre=(e,t)=>{function n(r,o){let s=r.get(e);Om(s)?li(Tk(s,o)):Ql(s)&&li(Tk(s.value,o))}return fh(r=>{let o=r(e);return Om(o)||Ql(o)?t(r,o):o},n)};var Cre=Symbol.for("effect/reactivity/atom/Atom/Reset"),iA=Symbol.for("effect/reactivity/atom/Atom/Interrupt");function Are(e,t){let n=tf(fA([0,void 0])),r=t?.initialValue!==void 0?Go(t.initialValue):Ia(),o=t?.concurrent?tf(Fi(a=>{let c=new Set;return a.addFinalizer(()=>c.forEach(u=>u.interruptUnsafe())),c})):void 0;function s(a,c){let u=o?a(o):void 0;a.isFn=!0;let[f,l]=a.get(n);if(f===0)return r;if(l===iA)return Yl(QM(),{previous:a.self()});let p=e(l,a);return rH in p?(u&&(p=A(tl(p,{startImmediately:!0}),h=>(u.add(h),h.addObserver(()=>u.delete(h)),Y(Xx(u),g=>g[0])))),bE(a,p,r,c,!1)):pA(a,p,r,c)}function i(a,c){Pre(()=>{c===Cre?a.set(n,[0,void 0]):c===iA?a.set(n,[a.get(n)[0]+1,iA]):a.set(n,[a.get(n)[0]+1,c]),a.refreshSelf()})}return[s,i,n]}var Ore=(e,t,n,r)=>A(mk(typeof n=="function"?n(e):n),o=>{let i=xi().context,a=rn(),c=Kr(o,{onFailure(f){return Uo(f)?Ye(a)?v({done:!0,items:a}):G(new $f("Atom.pull: no items")):ct(f)},onSuccess(f){let l;return r?.disableAccumulation?l=f:(l=yf(a,f),a=l),v({done:!1,items:l})}}),u=new Set;return e.addFinalizer(()=>{for(let f of u)f()}),e.once(t),e.subscribe(t,()=>{e.setSelf(LS(e.self()));let f;f=lA(i,c,l=>{f&&u.delete(f);let p=Qk(l,e.self()),m=u.size>0;e.setSelf(m?Um(p):p)}),f&&u.add(f)}),c}),Rre=(e,t)=>fh(t.read,function(n,r){n.set(e,n.get(e)+1)}),mA=typeof WeakRef>"u"||typeof FinalizationRegistry>"u"?e=>{let t=cc();return function(n){let r=As(t,n);if(r._tag==="Some")return r.value;let o=e(n);return uc(t,n,o),o}}:e=>{let t=cc(),n=new FinalizationRegistry(r=>{ku(t,r)});return function(r){let o=As(t,r).pipe(YE(i=>i.deref()));if(o._tag==="Some")return o.value;let s=e(r);return uc(t,r,new WeakRef(s)),n.register(s,r),s}};var hA=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0});var _re=d(e=>tH(e[0]),(e,t,n)=>{let r=tf(bre(e)?fh(o=>t(o,e),function(o,s){o.set(e,s)},e.refresh??function(o){o(e)}):Fi(o=>t(o,e),e.refresh??function(o){o(e)}));return n?.initialValueTarget&&(r.initialValueTarget=Mre(n.initialValueTarget)),r}),Mre=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t};var Pre=Q$;var Fre="~effect-atom/atom/Atom/Serializable";var gA=d(2,(e,t)=>{let n=Ec(t.schema);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:e.label??[t.key,new Error().stack?.split(`
|
|
36
|
-
`)[5]??""],[Fre]:{key:t.key,encode:vT(n),decode:dm(n)}})});var sH=()=>(e,t)=>{let n=Ke()(e),r=qr(n,t.makeEffect??sA(t.group,{...t,flatten:!0})),o=t.runtime??dA;n.runtime=o(typeof t.protocol=="function"?i=>gs(r,Wg(t.protocol(i))):gs(r,Wg(t.protocol))),n.mutation=mA(i=>{let a=t.group.requests.get(i);return n.runtime.fn()(ye(function*({headers:c,payload:u,reactivityKeys:f}){let p=(yield*n)(i,u,{headers:c});return yield*f?SS(p,f):p})).pipe(gA({key:`AtomRpc:mutation:${i}`,schema:eC({success:a.successSchema,error:oH(a)})}))});let s=mA(i=>{let{headers:a,payload:c,reactivityKeys:u,tag:f,timeToLive:l}=i,p=t.group.requests.get(f),m=jm(p.successSchema),h=m?n.runtime.pull(mr(n.use(g=>v(g(f,c,{headers:a}))))):n.runtime.atom(n.use(g=>g(f,c,{headers:a})));return u&&(h=n.runtime.factory.withReactivity(u)(h)),!m&&i.serializationKey&&(h=gA(h,{key:`AtomRpc:${i.tag}:${i.serializationKey}`,schema:eC({success:p.successSchema,error:oH(p)})})),l&&(h=as(l)?uh(h,l):hA(h)),h});return n.query=(i,a,c)=>{let u={tag:i,payload:a,headers:c?.headers?ki(c.headers):void 0,reactivityKeys:c?.reactivityKeys,timeToLive:c?.timeToLive?gt(c.timeToLive):void 0,serializationKey:c?.serializationKey};return s(u)},n},oH=e=>He([e.errorSchema,...Array.from(e.middlewares,t=>t.error),qs]);var wE={};Hs(wE,{make:()=>Nre});var Dre={add(...e){let t=new Map(this.requests);for(let n of e)t.set(n._tag,n);return Ta({requests:t,annotations:this.annotations})},merge(...e){let t=new Map(this.requests),n=new Map(this.annotations.mapUnsafe);for(let r of e){for(let[o,s]of r.requests)t.set(o,s);for(let[o,s]of r.annotations.mapUnsafe)n.set(o,s)}return Ta({requests:t,annotations:Ro(n)})},omit(...e){let t=new Map(this.requests);for(let n of e)t.delete(n);return Ta({requests:t,annotations:this.annotations})},middleware(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.middleware(e));return Ta({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return qt(function*(){let n=yield*ar(),r=Cr(e)?yield*e:e,o=new Map;return t.requests.forEach((s,i)=>{o.set(s.key,{tag:s._tag,handler:r[i],context:n})}),Ro(o)})},prefix(e){let t=new Map;for(let n of this.requests.values()){let r=n.prefix(e);t.set(r._tag,r)}return Ta({requests:t,annotations:this.annotations})},toLayer(e){return zf(this.toHandlers(e))},of:L,toLayerHandler(e,t){let n=this;return zf(qt(function*(){let r=yield*ar(),o=Cr(t)?yield*t:t,s=new Map,i=n.requests.get(e);return s.set(i.key,{handler:o,context:r}),Ro(s)}))},accessHandler(e){return cr(t=>{let n=this.requests.get(e),{handler:r,context:o}=qi(t,n.key);return v((s,i)=>{i.rpc=n;let a=r(s,i),c=ed(a)?a.value:a;return Cr(c)?Aw(c,o):dk(c,o)})})},annotate(e,t){return Ta({requests:this.requests,annotations:Ve(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(ss(e,t))},annotateMerge(e){return Ta({requests:this.requests,annotations:Er(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.annotateMerge(Er(e,r.annotations)));return Ta({requests:t,annotations:this.annotations})}},Ta=e=>Object.assign(function(){},Dre,{requests:e.requests,annotations:e.annotations}),Nre=(...e)=>Ta({requests:new Map(e.map(t=>[t._tag,t])),annotations:bt()});var iH=j.Union([j.Struct({_tag:j.Literal("List"),collection:j.String}),j.Struct({_tag:j.Literal("Item"),collection:j.String,id:j.Union([j.String,j.Number])})]),nf=(e,t)=>({item:n=>({_tag:"Item",collection:e,id:n}),list:{_tag:"List",collection:e},name:e}),aH=e=>e._tag==="List"?e.collection:`${e.collection}:${e.id}`,IE=e=>[...new Set(e.map(aH))],vE=e=>[...new Set(e.flatMap(t=>t._tag==="List"?[t.collection]:[aH(t),t.collection]))];var Lre=Se.fn("EffectContract.invalidateAfter")(function*(e){yield*ES(vE(e))});function Bre(e,t,n){function r(o){return IE(n.reads(o))}return{query:(o,s={})=>e.query(t,o,{...s,reactivityKeys:r(o)}),run:o=>e.use(s=>s(t,o))}}function jre(e,t,n){return{run:r=>e.use(o=>o(t,r)).pipe(Se.tap(o=>Lre(n.invalidates(r,o))))}}function cH(e,t){let{name:n,queries:r,commands:o}=e.declaration;return Object.fromEntries([...r.map(s=>[s.name,Bre(t,`${n}.${s.name}`,s)]),...o.map(s=>[s.name,jre(t,`${n}.${s.name}`,s)])])}var uH=j.Union([j.Struct({_tag:j.Literal("Changed"),keys:j.Array(iH)}),j.Struct({_tag:j.Literal("Resync")})]),$re=256;function fH(e,t){let n=ch(!1),r=ch({connection:"connecting",failure:Le.none(),needsResync:!0,pending:0});return{connection:e.atom(s=>Se.gen(function*(){s.mount(r);let i=yield*Ti;function a(f){s.set(r,{...s.once(r),...f})}function c(){if(s.once(n)){a({needsResync:!0});return}i.invalidateUnsafe(IE(t.resyncKeys)),a({needsResync:!1,pending:0})}s.subscribe(n,f=>{f||c()}),t.resume!==void 0&&(s.once(t.resume),s.subscribe(t.resume,c));let u=Se.suspend(()=>{let f=!0;function l(p){a({connection:"live",failure:Le.none()}),s.once(n)?a({needsResync:!0,pending:Math.min($re,s.once(r).pending+1)}):f||p._tag==="Resync"?c():i.invalidateUnsafe(vE(p.keys)),f=!1}return t.stream.pipe(nr.runForEach(p=>Se.sync(()=>l(p))),Se.scoped,Se.catchCause(p=>Se.sync(()=>a({failure:Le.some(p)}))),Se.andThen(Se.sync(()=>a({connection:"reconnecting",needsResync:!0}))),Se.andThen(Se.sleep(t.retryDelay??"1 second")))});yield*Se.forever(u)})).pipe(uh(0)),paused:n,status:r}}function lH(e,t){return n=>{function r(){e.document.visibilityState==="visible"&&n()}return e.addEventListener(t,r),()=>e.removeEventListener(t,r)}}function dH({window:e,native:t}){let n=e===void 0?[]:[lH(e,"visibilitychange"),lH(e,"online")],r=t===void 0?n:[...n,t];return Fi(o=>{let s=0;function i(){s+=1,o.setSelf(s)}for(let a of r)o.addFinalizer(a(i));return s})}var qre=e=>{let t=e.map(({name:n})=>n).filter((n,r,o)=>o.indexOf(n)!==r);if(t.length>0)throw new Error(`Operation names must be unique; duplicated: ${[...new Set(t)].join(", ")}`)},pH=(e,t)=>{let n=e.middleware.bind(e);return Object.assign(e,{declaration:t,middleware:r=>pH(n(r),t)})};function mH(e,t){let{queries:n=[],commands:r=[]}=t;qre([...n,...r]);let o=[...n,...r].map(s=>vc.make(`${e}.${s.name}`,{error:s.error,payload:s.payload,success:s.success}));return pH(wE.make(...o),{commands:r,name:e,queries:n})}function hH(e){let t=Object.entries(e).map(([n,r])=>[n,j.isSchema(r)?r:j.TaggedError()(n,r)]);return{error:t.length===0?j.Never:j.Union(t.map(([,n])=>n)),Rejection:Object.fromEntries(t),reject:Object.fromEntries(t.map(([n,r])=>[n,(...o)=>Se.fail(Reflect.construct(r,o))]))}}var zre=e=>e===void 0?j.Void:j.isSchema(e)?e:j.Struct(e),Hre=(e,t,n)=>{let{payload:r,success:o,rejections:s={}}=n;return{kind:e,name:t,payload:zre(r),rejections:s,success:o??j.Void,...hH(s)}};function id(e,t){return{...Hre("query",e,t),reads:t.reads}}function Wre(e){return e.startsWith(".")||e==="node_modules"}function gH(e){return e.endsWith(".md")&&!e.split("/").some(Wre)}var Kre=j.String.check(j.makeFilter(e=>gH(e)&&!e.includes("\\")&&!e.includes("\0")&&e.split("/").every(t=>t.length>0&&t!=="..")||"Expected a relative readable Markdown path")),Vre=j.String.check(j.makeFilter(e=>Number.isFinite(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T.*(?:Z|[+-]\d{2}:\d{2})$/u.exec(e)!==null||"Expected an ISO observation time with timezone")),pme=j.Struct({documents:j.Array(j.Struct({file:Kre,source:j.String})).check(j.makeFilter(e=>new Set(e.map(t=>t.file)).size===e.length||"Duplicate source paths are not a complete observation")),recordedAt:Vre,version:j.Literal(1)}).pipe(j.encodeKeys({recordedAt:"recorded_at"})),xH=j.Struct({action:j.Literals(["check","compare","observe"]),baseline:j.NullOr(j.String)}),yH=j.Struct({discardBaseline:j.Boolean,html:j.String,reason:j.String,snapshot:j.NullOr(j.String)});var ka=nf("work-board/workspace",j.String),SH=nf("work-board/documents",j.String),EH=nf("work-board/identities",j.String),bH=nf("work-board/navigation",j.String),lh=nf("work-board/index",j.String),wH=nf("work-board/watcher",j.String);function IH(e){let t=new URL(e,"http://127.0.0.1").pathname,n=/^\/_board\/item\/(?<id>[^/]+)\/$/u.exec(t)?.groups?.id,r=SH.item(decodeURIComponent(t.slice(1)));return n?r=EH.item(decodeURIComponent(n)):t.startsWith("/_board/")&&(r=lh.list),[ka.list,r]}var _c=class extends j.TaggedError()("ReadFailed",{operation:j.String,status:j.Number}){},Jre=j.String.check(j.isMaxLength(8192),j.makeFilter(e=>{if(!e.startsWith("/")||e.startsWith("//"))return"Expected a local reading URL";try{let t=new URL(e,"http://127.0.0.1").pathname;return t==="/"||["/_board/work","/_board/overview","/_board/changes","/_board/start"].includes(t)||/^\/_board\/item\/[^/]+\/$/u.exec(t)!==null||/\.md$/iu.exec(t)!==null||"Expected a local reading URL"}catch{return"Expected a local reading URL"}})),Gre=j.Struct({html:j.String,status:j.Number}),Zre=j.Struct({file:j.String,href:j.String,kind:j.Literals(["document","heading","passage"]),line:j.optional(j.Number),snippet:j.String,text:j.String,title:j.String}),Qre=id("page",{payload:{url:Jre},reads:({url:e})=>IH(e),rejections:{ReadFailed:_c},success:Gre}),Yre=id("navigation",{reads:()=>[ka.list,bH.list],rejections:{ReadFailed:_c},success:j.String}),Xre=id("search",{payload:{query:j.String.check(j.isMaxLength(8192))},reads:()=>[ka.list,lh.list],rejections:{ReadFailed:_c},success:j.Struct({results:j.Array(Zre),total:j.Number,unavailable:j.Array(j.String)})}),eoe=id("history",{payload:xH,reads:()=>[ka.list,lh.list],rejections:{ReadFailed:_c},success:yH}),toe=id("watcher",{reads:()=>[ka.list,wH.list],rejections:{ReadFailed:_c},success:j.Struct({watching:j.Boolean})}),yA=mH("work-board",{queries:[Qre,Yre,Xre,eoe,toe]}),noe=vc.make("work-board.subscribe",{error:_c,stream:!0,success:uH}),vH=yA.add(noe);function TH(e,t={}){class n extends sH()("WorkBoard/Reader",{group:vH,protocol:ah.layerProtocolHttp({url:`${e}/_board/rpc`}).pipe(zr.provide([US.layer,sh.layerNdjson]))}){}let r=cH(yA,n),o=Z$({defaultIdleTTL:0,timeoutResolution:1}),s=fH(n.runtime,{resume:dH(t),resyncKeys:[ka.list],stream:nr.unwrap(n.use(c=>Se.succeed(c("work-board.subscribe",void 0))))});o.mount(s.connection);async function i(c,u){try{return await Se.runPromise(jS(o,c,{suspendOnWaiting:!0}),{signal:u})}catch(f){if(u?.aborted){let l=new Error("Reading canceled",{cause:f});throw l.name="AbortError",l}throw f}}async function a(c,u){try{return await Se.runPromise(Se.flatMap(jS(o,n.runtime),f=>Se.provideContext(c,f)),{signal:u})}catch(f){if(u?.aborted){let l=new Error("Reading canceled",{cause:f});throw l.name="AbortError",l}throw f}}return{api:r,read:i,registry:o,run:a,updates:s}}var TE=new WeakMap;function Bme(e){let t=TE.get(e);if(t===void 0){let o=function(){r.registry.dispose(),TE.get(e)===r&&TE.delete(e),e.removeEventListener("pagehide",o)};var n=o;t=TH(e.location.origin,{window:e}),TE.set(e,t);let r=t;e.addEventListener("pagehide",o)}return t}export{Bme as session};
|
|
42
|
+
`}}}})},aH=Tb(),cH=e=>bn.of({contentType:e?.contentType??"application/json",includesFraming:!1,codecFor:fh,makeUnsafe:()=>{let t=new TextDecoder,n=new Map;return{decode:r=>{let o=JSON.parse(typeof r=="string"?r:t.decode(r));return fH(o,n)},encode:r=>{let o=lH(r,n);return o&&JSON.stringify(o)}}}}),uH=e=>bn.of({contentType:e?.contentType??"application/json-rpc",includesFraming:!0,codecFor:fh,makeUnsafe:()=>{let t=Tb({maxBufferSize:e?.maxBufferSize}).makeUnsafe(),n=new Map;return{decode:r=>{let o=t.decode(r);if(o.length===0)return[];let s=[];for(let i=0;i<o.length;i++){let a=o[i];s.push(...fH(a,n))}return s},encode:r=>{let o=lH(r,n);return o&&t.encode(o)}}}});function fH(e,t){if(Array.isArray(e)){let n={size:0,responses:new Map},r=[];for(let o=0;o<e.length;o++){let s=rH(e[o]);r.push(s),s._tag==="Request"&&!s.isNotification&&(n.size++,t.set(s.id,n))}return r}return[rH(e)]}function rH(e){if(Object.hasOwn(e,"method")){let r=e;if(BA(r.id)&&r.method.startsWith("@effect/rpc/")){let o=r.method.slice(12),s=r.params?.requestId;return s?{_tag:o,requestId:s}:{_tag:o}}return{_tag:"Request",id:r.id??"",tag:r.method,payload:r.params??null,headers:r.headers??[],...j(r,"id")?{}:{isNotification:!0},...r.spanId?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{}}}let t=e,n=Object.hasOwn(t,"error");return n&&t.error&&t.error._tag==="Defect"?{_tag:"Defect",defect:t.error.data}:Object.hasOwn(t,"chunk")&&t.chunk===!0?{_tag:"Chunk",requestId:t.id??"",values:t.result}:{_tag:"Exit",requestId:t.id??"",exit:n&&t.error!=null?{_tag:"Failure",cause:t.error._tag==="Cause"?t.error.data:[{_tag:"Die",defect:t.error}]}:{_tag:"Success",value:t.result}}}function oH(e,t){if(!("requestId"in e))return gA(e);let n=t.get(e.requestId);return n?(t.delete(e.requestId),n.responses.set(e.requestId,e),n.size===n.responses.size?Array.from(n.responses.values(),gA):void 0):gA(e)}function lH(e,t){if(Array.isArray(e)===!1)return oH(e,t);if(e.length===0)return;let n=[];for(let o=0;o<e.length;o++){let s=oH(e[o],t);s!==void 0&&n.push(s)}if(n.length===0)return;if(n.length===1)return n[0];let r=[];for(let o=0;o<n.length;o++){let s=n[o];Array.isArray(s)?r.push(...s):r.push(s)}return r}function gA(e){switch(e._tag){case"Request":return{jsonrpc:"2.0",method:e.tag,params:e.payload,...e.isNotification?{}:{id:e.id},...e.headers?.length>0?{headers:e.headers}:{},traceId:e.traceId,spanId:e.spanId,sampled:e.sampled};case"Ping":case"Pong":case"Interrupt":case"Ack":case"Eof":return{jsonrpc:"2.0",method:`@effect/rpc/${e._tag}`,params:"requestId"in e?{requestId:e.requestId}:void 0};case"Chunk":return{jsonrpc:"2.0",chunk:!0,id:e.requestId,result:e.values};case"Exit":{if(e.exit._tag==="Success")return{jsonrpc:"2.0",id:e.requestId??void 0,result:e.exit.value};let t=e.exit.cause.find(r=>r._tag==="Fail"),n=t?._tag==="Fail"?t.error:void 0;return{jsonrpc:"2.0",id:e.requestId??void 0,error:e.exit._tag==="Failure"?{_tag:"Cause",code:n&&j(n,"code")?Number(n.code):0,message:n&&j(n,"message")?n.message:JSON.stringify(e.exit.cause),data:e.exit.cause}:void 0}}case"Defect":return{jsonrpc:"2.0",id:kre,error:{_tag:"Defect",code:1,message:"A defect occurred",data:e.defect}};case"ClientProtocolError":return{}}}var kre=-32603,xA=e=>{let{maxBufferSize:t=sH,...n}=e??{};return bn.of({contentType:"application/msgpack",includesFraming:!0,codecFor:fh,makeUnsafe:()=>{let r=new Fi(n),o=new Uc(n),s=new TextEncoder,i,a=c=>{throw i=void 0,new uh({maxBufferSize:c})};return{decode(c){let u=typeof c=="string"?s.encode(c):c;if(i!==void 0){vb(i.length+u.length,t)&&a(t);let f=u;c=new Uint8Array(i.length+u.length),c.set(i),c.set(f,i.length),u=c,i=void 0}try{return r.unpackMultiple(u)}catch(f){let l=f;if(l.incomplete)return i=u.subarray(l.lastPosition),vb(i.length,t)&&a(t),l.values??[];throw f}},encode:c=>o.pack(c)}}})},dH=xA({useRecords:!0}),Cre=16*1024*1024,Are=new TextEncoder,Rre=e=>{let t=e?.maxFrameSize??Cre,n=e?.fingerprintPayloads===!0?o=>iA(o,{fingerprint:!0}):iA,r={fingerprint:!0,dictionary:!0};return bn.of({contentType:"application/vnd.effect.rpc+schema-binary",includesFraming:!0,codecFor:n,makeUnsafe:()=>{let o=gz(_C,{...r,maxFrameSize:t}),s=yz(_C,r);return{decode:i=>o.feedSync(typeof i=="string"?Are.encode(i):i),encode:i=>{if(!Array.isArray(i))return s.encode(i);if(i.length!==0)return s.encodeMany(i)}}}})},Ore=ui(bn)(iH),_re=ui(bn)(aH),Mre=e=>ui(bn)(Tb(e)),Pre=e=>ui(bn)(cH(e)),Fre=e=>ui(bn)(uH(e)),Ure=ui(bn)(dH),Dre=e=>ui(bn)(xA(e)),Nre=e=>ow(bn)(()=>Rre(e));var kb=class extends Ke()("effect/rpc/RpcWorker/InitialMessage"){};var mH=e=>K(()=>{let t=new Set,n=new Map,r=new Map,o=(s,i)=>cr(a=>{let c=n.get(s);return c||(c=[],n.set(s,c)),c.push([i,a]),H});return Y(e((s,i)=>{let a=r.get(s);return a?a(i):o(s,i)},t),s=>({...s,run(i,a){return $t(function*(){t.add(i),r.set(i,a);let c=n.get(i);if(c){n.delete(i);for(let[u,f]of c)yield*Nn(K(()=>a(u)),f)}return yield*ur(Kr,()=>(t.delete(i),r.delete(i),H))})}}))});var Bre=e=>yr(e,"RpcClientError"),jre=0,hH=Se(function*(e,t){let n=t?.spanPrefix??"RpcClient",r=t?.supportsAck??!0,o=t?.disableTracing??!1,s=t?.generateRequestId??(()=>jre++),i=yield*ar(),a=$e(i,It),c=new Map,u=!1;yield*_t(a,xn(b=>(u=!0,f(Wg(b.id)))));let f=Se(function*(b){for(let[y,w]of c)c.delete(y),w._tag==="Queue"?yield*b._tag==="Success"?Jp(w.queue):Zt(w.queue,b.cause):w.resume(b)}),l=b=>{let y=Km(b.successSchema),w=h(b);return(S,C)=>{let M=C?.headers?Oi(C.headers):Yl,_=C?.context??Et();if(!y){let $=F=>p(b,w,F,b.payloadSchema.make(S),M,_,C?.discard??!1);return o?$(void 0):pp(`${n}.${b._tag}`,{attributes:t.spanAttributes},$)}let P=m(b,w,b.payloadSchema.make(S),M,C?.streamBufferSize??16,_);return C?.asQueue?P:mr(Y(P,Ci))}},p=(b,y,w,S,C,M,_)=>xn(P=>{if(u)return xo;let $=s(),F=y(ee=>t.onFromClient({message:ee,context:M,discard:_}),{_tag:"Request",id:$,tag:b._tag,payload:S,...w?{traceId:w.traceId,spanId:w.spanId,sampled:w.sampled}:{},headers:Xl(P.getRef(Cb),C)});if(_)return F;let te;return pi(ws(ee=>{let T={_tag:"Effect",rpc:b,context:M,resume(z){ee(z),te&&!te.pollUnsafe()&&P.currentDispatcher.scheduleTask(()=>{te.interruptUnsafe(P.id)},0)}};c.set($,T),te=F.pipe(w?sl(w,{captureStackTrace:!1}):B,Ln(P.context)),te.addObserver(z=>{if(z._tag==="Failure")return ee(z)})}),ee=>(c.delete($),Dn(bo(te),g($,Array.from(ee),M))))}),m=Se(function*(b,y,w,S,C,M){if(u)return yield*xo;let _=o?void 0:yield*Jw(`${n}.${b._tag}`,{attributes:t.spanAttributes}),P=Ei(),$=s(),F=Jn(P.context,It);yield*Do(F,ee=>c.has($)?(c.delete($),g($,ii(ee)?Array.from(xP(ee.cause)):[],M)):H);let te=yield*Uu(C);return c.set($,{_tag:"Queue",rpc:b,queue:te,scope:F,context:M}),yield*y(ee=>t.onFromClient({message:ee,context:M,discard:!1}),{_tag:"Request",id:$,tag:b._tag,payload:w,..._?{traceId:_.traceId,spanId:_.spanId,sampled:_.sampled}:{},headers:Xl(P.getRef(Cb),S)}).pipe(_?sl(_,{captureStackTrace:!1}):B,ft(ee=>Zt(te,ee)),ua,Ut(F,{startImmediately:!0})),te}),h=b=>{let y=[];for(let w of b.middlewares.values()){let S=Ji(i,`${w.key}/Client`);S&&y.push(S)}return y.length===0?(w,S)=>w(S):function w(S,C,M=y.length-1){return M===-1?S(C):y[M]({rpc:b,request:C,next(_){return w(S,_,M-1)}})}},g=(b,y,w)=>ws(S=>{let C=Ei();t.onFromClient({message:{_tag:"Interrupt",requestId:b,interruptors:y},context:w,discard:!1}).pipe(Dw(1e3),Ln(C.context)).addObserver(()=>{S(H)})}),x=b=>{switch(b._tag){case"Chunk":{let y=b.requestId,w=c.get(y);return!w||w._tag!=="Queue"?H:wa(w.queue,b.values).pipe(r?R(()=>t.onFromClient({message:{_tag:"Ack",requestId:b.requestId},context:w.context,discard:!1})):B,ft(S=>Zt(w.queue,S)))}case"Exit":{let y=b.requestId,w=c.get(y);return w?(c.delete(y),w._tag==="Effect"?(w.resume(b.exit),H):b.exit._tag==="Success"?Jp(w.queue):Zt(w.queue,b.exit.cause)):H}case"Defect":return f(Hg(b.defect));case"ClientEnd":return H}},E;if(t.flatten){let b=new Map;E=function(w,S,C){let M=b.get(w);return M||(M=l(e.requests.get(w)),b.set(w,M)),M(S,C)}}else E={},e.requests.forEach(b=>{W(E,b._tag,l(b))});return{client:E,write:x}}),qre=0,yA=Se(function*(e,t){let n=qre++,{codecFor:r,run:o,send:s,supportsAck:i,supportsTransferables:a}=yield*Ni,c=$re(r),u=xm(r(ln())),f=new Map,{client:l,write:p}=yield*hH(e,{...t,supportsAck:i,onFromClient({message:m}){switch(m._tag){case"Request":{let h=e.requests.get(m.tag),g=a?b$():void 0,x=Ei(),E={rpc:h,context:g?Ve(x.context,Wm,g):x.context,schemas:c(h)};return f.set(m.id,E),E.schemas.encodePayload(m.payload).pipe(Nn(E.context),di,R(b=>s(n,{...m,id:m.id,payload:b,headers:Object.entries(m.headers)},g&&g.readUnsafe())))}case"Ack":return f.get(m.requestId)?s(n,{_tag:"Ack",requestId:m.requestId}):H;case"Interrupt":return f.get(m.requestId)?(f.delete(m.requestId),s(n,{_tag:"Interrupt",requestId:m.requestId})):H;case"Eof":return H}}});return yield*o(n,m=>{switch(m._tag){case"Chunk":{let h=Gm(m.requestId),g=f.get(h);return!g||xe(g.schemas.decodeChunk)?H:g.schemas.decodeChunk.value(m.values).pipe(Nn(g.context),di,R(x=>p({_tag:"Chunk",clientId:0,requestId:Gm(m.requestId),values:x})),go(x=>p({_tag:"Exit",clientId:0,requestId:Gm(m.requestId),exit:jt(x)})))}case"Exit":{let h=Gm(m.requestId),g=f.get(h);return g?(f.delete(h),g.schemas.decodeExit(m.exit).pipe(Nn(g.context),di,Jr({onSuccess:x=>p({_tag:"Exit",clientId:0,requestId:h,exit:x}),onFailure:x=>p({_tag:"Exit",clientId:0,requestId:h,exit:jt(x)})}))):H}case"Defect":return p({_tag:"Defect",clientId:0,defect:u(m.defect)});case"ClientProtocolError":{let h=Fo(m.error);return Lo(f.keys(),g=>p({_tag:"Exit",clientId:0,requestId:g,exit:h}))}default:return H}}).pipe(ft(hp),ua,Is),l}),$re=e=>{let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let o=ZS(n.successSchema);return r={decodeChunk:Lt(o,s=>wc(e(fS(s.success)))),encodePayload:cS(e(n.payloadSchema)),decodeExit:wc(e(RC(n)))},t.set(n,r),r}},Cb=Me("effect/rpc/RpcClient/CurrentHeaders",{defaultValue:()=>Yl}),zre=d(2,(e,t)=>zw(e,Cb,Xl(Oi(t)))),Ni=class extends Ke()("effect/rpc/RpcClient/Protocol"){static make=mH},gH=e=>Ni.make(Se(function*(t){let n=yield*bn,r=n.includesFraming,o=u=>new Hs({reason:ed.fromHttpClientError(u)}),s=(u,f)=>new Hs({reason:new Mc({message:u,cause:f})}),i=u=>s("Received empty HTTP response from RPC server",u),a=u=>s("HTTP response ended before RPC request completed",u);return{send:Se(function*(u,f){if(f._tag!=="Request")return;let l=n.makeUnsafe(),p=l.encode(f),m=typeof p=="string"?Vk(p,n.contentType):FS(p,n.contentType),h=yield*e.post("",{body:m}).pipe(ol(o));if(!r){let E=yield*h.text.pipe(ol(o)),b=yield*Bo({try:()=>l.decode(E),catch:S=>s("Error decoding HTTP response",S)});if(!Array.isArray(b))return yield*s("Expected an array of responses",b);if(b.length===0)return yield*i(f);let y=!1,w=0;return yield*Qn({while:()=>w<b.length,body:()=>{let S=b[w++];return MC(S)&&(y=!0),t(u,S)},step:En}),y?void 0:yield*a(f)}let g=!1,x=!1;if(yield*Ql(h.stream,E=>Bo({try:()=>E.flatMap(l.decode),catch:b=>s("Error decoding HTTP response",b)}).pipe(R(b=>{if(b.length===0)return H;g=!0;let y=0;return Qn({while:()=>y<b.length,body:()=>{let w=b[y++];return MC(w)&&(x=!0),t(u,w)},step:En})}))).pipe(ol(E=>Bre(E)?E:o(E))),g){if(!x)return yield*a(f)}else return yield*i(f)}),supportsAck:!1,supportsTransferables:!1,codecFor:n.codecFor}})),Hre=e=>Hr(Ni)(R(nC,t=>(t=i$(t,Yq(e.url)),gH(e.transformClient?e.transformClient(t):t)))),xH=e=>Ni.make(Se(function*(t,n){let r=yield*f$,o=yield*bn,s=yield*Eu(dh),i=new Map,a=yield*r.writer,c=o.makeUnsafe(),u=yield*Kre(K(()=>a(c.encode(v$)))),f,l=K(()=>(f=void 0,Te(s)?s.value.onConnect:H)),p=h=>Lo(n,g=>t(g,h)),m=h=>(f=h,p({_tag:"ClientProtocolError",error:h}));return yield*K(()=>(c=o.makeUnsafe(),u.reset(),r.runRaw(h=>{try{let g=c.decode(h);if(g.length===0)return;let x=0;return Qn({while:()=>x<g.length,body:()=>{let E=g[x++];if(E._tag==="Pong")return u.onPong(),H;if(Object.hasOwn(E,"requestId")){let b=E.requestId,y=i.get(b);if(y!==void 0)return E._tag==="Exit"&&i.delete(b),t(y,E)}return p(E)},step:En})}catch(g){return p({_tag:"ClientProtocolError",error:new Hs({reason:new Mc({message:"Error decoding message",cause:g})})})}},{onOpen:l}).pipe(sc(R(u.timeout,()=>G(new nd({reason:new Lm({kind:"Timeout",cause:new Error("ping timeout")})}))))))).pipe(R(()=>G(new nd({reason:new Bm({code:1e3})}))),Te(s)?ca(s.value.onDisconnect):B,fp(h=>{let g=Kf(h),x=Kt(g),E=new Hs({reason:x?g.success.reason:new Mc({message:"Unknown socket error",cause:du(h)})});return e?.retryTransientErrors&&x&&g.success.reason._tag==="SocketOpenError"?(e.onTransientError?.(E)??H).pipe(Uw({log:!0,message:"RpcClient onTransientError hook failed"})):m(E)}),Pw(e?.retryPolicy??Wre,h=>m(new Hs({reason:h.reason}))),xx({module:"RpcClient",method:"makeProtocolSocket"}),Is),{send(h,g){if(f)return G(f);g._tag==="Request"&&i.set(g.id,h);let x=c.encode(g);return x===void 0?H:di(a(x))},supportsAck:!0,supportsTransferables:!1,codecFor:o.codecFor}})),Wre=uF([fF(500,1.5),Xf(5e3)]),Kre=Se(function*(e){let t=!0,n=fr(),r=()=>{t=!0,n.closeUnsafe()},o=()=>{t=!0};return yield*K(()=>t?(t=!1,e):n.open).pipe(aa("5 seconds"),Fw,Ht,ua,Is),{timeout:n.await,reset:r,onPong:o}}),Vre=e=>Hr(Ni)(xH(e)),yH=e=>Ni.make(Se(function*(t,n){let r=yield*GS,o=yield*$o,s=0,i=yield*Eu(kb),a=yield*Eu(dh),c=new Map,u=m=>Lo(n,h=>t(h,m)),f=$t(function*(){let m=s++,h=yield*r.spawn(m);return yield*h.run(g=>{if(g._tag==="Exit"){let x=c.get(g.requestId);if(x)return c.delete(g.requestId),x.latch.openUnsafe(),t(x.clientId,g)}else if(g._tag==="Defect"){for(let[x,E]of c)c.delete(x),E.latch.openUnsafe();return u(g)}else if("requestId"in g){let x=c.get(g.requestId);if(x)return t(x.clientId,g)}return u(g)},{onSpawn:Te(i)?R(i.value,([g,x])=>di(h.send({_tag:"InitialMessage",value:g},x))):void 0}).pipe(fp(g=>{for(let[E,b]of c)b.worker===h&&(c.delete(E),b.latch.openUnsafe());let x=Kf(g);return u({_tag:"ClientProtocolError",error:new Hs({reason:Kt(x)?x.success.reason:new Mc({message:"Error in worker",cause:du(g)})})})}),px(Xf(1e3)),xx({module:"RpcClient",method:"makeProtocolWorker"}),ua,Is),h}),l="minSize"in e?yield*pq({acquire:f,min:e.minSize,max:e.maxSize,concurrency:e.concurrency,targetUtilization:e.targetUtilization,timeToLive:e.timeToLive}):yield*dq({acquire:f,size:e.size,concurrency:e.concurrency,targetUtilization:e.targetUtilization});yield*_t(o,se(()=>{for(let m of c.values())m.latch.openUnsafe();c.clear()}));let p=(m,h,g)=>{switch(h._tag){case"Request":return Mk(l).pipe(R(x=>{let E=fr(!1);return c.set(h.id,{clientId:m,worker:x,latch:E}),R(x.send(h,g),()=>E.await)}),wu,di);case"Interrupt":{let x=c.get(h.requestId);return x?(c.delete(h.requestId),x.latch.openUnsafe(),di(x.worker.send(h))):H}case"Ack":{let x=c.get(h.requestId);return x?di(x.worker.send(h)):H}}return H};return yield*wu(Mk(l)),Te(a)&&(yield*a.value.onConnect),{send:p,supportsAck:!0,supportsTransferables:!0,codecFor:Cc}})),Jre=qc(yH,Hr(Ni)),dh=class extends Ke()("effect/rpc/RpcClient/ConnectionHooks"){};var Ab="~effect/reactivity/Atom",EH=e=>j(e,Ab),bA="~effect/reactivity/Atom/Writable",hh=d(2,(e,t)=>{let n=gt(t),r=fs(n);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!r,idleTTL:r?Tn(n):void 0})}),cf=hh(0),wA={[Ab]:Ab,equals:Object.is,...vn,toJSON(){return{_id:"Atom",keepAlive:this.keepAlive,lazy:this.lazy,label:this.label}}},Gre={...wA,atom(e,t){let n=wH(e,t);return Li(r=>{let o=r.self(),s=r(this);return s._tag!=="Success"?qm(s,o):n(r,s.value)})},fn(e,t){return arguments.length===0?(n,r)=>SH(this,n,r):SH(this,e,t)},pull(e,t){let n=cf(IA(0)),r=Li(o=>{let s=o.self(),i=o(this);return i._tag!=="Success"?qm(i,s):Rb(o,soe(o,n,e,t),Oa(!0),i.value)});return ioe(n,r)},subscriptionRef(e){return noe(cf(Li(t=>{let n=t.self(),r=t(this);if(r._tag!=="Success")return qm(r,n);let o=typeof e=="function"?e(t):e;return Fm(o)?o:Rb(t,o,Oa(!0),r.value)})),(t,n)=>{let r=dC(t(this));return toe(t,n,r)})}},SH=(e,t,n)=>{let[r,o,s]=ooe(n?.reactivityKeys?(i,a)=>{let c=t(i,a);return Cr(c)?kS(c,n.reactivityKeys):Mm(c,CS(n.reactivityKeys))}:t,n);return gh(i=>{i.get(s);let a=i.self(),c=i.get(e);return c._tag!=="Success"?qm(c,a):r(i,c.value)},o)},Zre={...wA,[bA]:bA},Qre=e=>bA in e,Li=(e,t)=>{let n=Object.create(wA);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.refresh=t,n},gh=(e,t,n)=>{let r=Object.create(Zre);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.write=t,r.refresh=n,r};function Yre(e,t){e.setSelf(t)}var mh=(e,t)=>{let n=wH(e,t);return Ab in n?n:Li(n)},wH=(e,t)=>{if(typeof e=="function"&&!Cr(e)&&!Ue(e)){let n=e;return function(r,o){let s=n(r);switch(typeof s){case"function":case"object":return s===null?s:IH in s?EA(r,s,t,o):Xre in s?bH(r,s,t,o):s;default:return s}}}else{if(Cr(e))return function(n,r){return EA(n,e,t,r)};if(Ue(e))return function(n,r){return bH(n,e,t,r)}}return IA(e)},IH="~effect/Effect",Xre="~effect/Stream",IA=e=>gh(function(t){return e},Yre),EA=(e,t,n,r)=>{let o=n?.initialValue!==void 0?Qo(n.initialValue):Oa();return Rb(e,t,o,r,n?.uninterruptible)};function Rb(e,t,n,r=Et(),o=!1){let s=e.self(),i=zr();e.addFinalizer(()=>{Ln(r)(Je(i,Vt))});let a,c=!1,u=vA(r.pipe(Ve(It,i),Ve(JS,e.registry),Ve(Ka,e.registry.scheduler)),t,function(f){a=fC(f,s),c&&e.setSelf(a)},o);return c=!0,u!==void 0&&e.addFinalizer(u),a!==void 0?a:s._tag==="Some"?VS(s):jm(n)}function vA(e,t,n,r=!1){if(gs(t)){n(t);return}let s=Ln(e)(t);s.currentDispatcher?.flush();let i=s.pollUnsafe();if(i){n(i);return}let a=s.addObserver(n);function c(){a(),r||s.interruptUnsafe()}return c}function eoe(e){let t=e?.memoMap??cf(mh(()=>ai())),n=i=>EH(t)?i(t):t,r=AS;function o(i){let a=Object.create(Gre);a.keepAlive=!1,a.lazy=!0,a.refresh=void 0,a.factory=o;let c=AA(Li(typeof i=="function"?u=>Qd(i(u),r):()=>Qd(i,r)));return a.layer=c,a.read=function(f){let l=f(c),p=R($o,m=>ci(l,n(f),m));return EA(f,p,{uninterruptible:!0})},a}o.memoMap=t,o.addGlobalLayer=i=>{r=Qd(r,ys(i,AS))};let s=cf(mh(i=>cr(a=>ci(AS,n(i),$e(a,It))).pipe(Y($e(Ri)))));return o.withReactivity=i=>a=>aoe(a,c=>{let u=dC(c(s));return c.addFinalizer(u.registerUnsafe(i,()=>{c.refresh(a)})),c.subscribe(a,f=>c.setSelf(f)),c.once(a)},{initialValueTarget:a}),o}var TA=eoe(),Tme=TA.withReactivity,bH=(e,t,n,r)=>{let o=n?.initialValue!==void 0?Qo(n.initialValue):Oa();return kA(e,t,o,r)};function kA(e,t,n,r=Et()){let o=e.self();r=Ve(r,JS,e.registry);let s=dp(a=>R(Ko(t.channel,a),c=>Qn({while:Xt,body:()=>c,step(u){e.setSelf(Qo(Tf(u),{waiting:!0}))}}))).pipe(ft(a=>(No(a)?lf(e.self(),is(lC),rr({onNone:()=>e.setSelf(h$(new Vf,{previous:e.self()})),onSome:c=>e.setSelf(Qo(c))})):e.setSelf(od(a,{previous:e.self()})),H))),i=vA(r.pipe(Ve(JS,e.registry),Ve(Ka,e.registry.scheduler)),s,En,!1);return i!==void 0&&e.addFinalizer(i),o._tag==="Some"?VS(o):jm(n)}var toe=(e,t,n=Et())=>Fm(t)?(e.addFinalizer(Nk(t).pipe(Ql(r=>{for(let o=0;o<r.length;o++)e.setSelf(r[o]);return H}),Gw(n))),Yw(n)(bq(t))):t._tag!=="Success"?t:kA(e,Nk(t.value),Oa(!0),n),noe=(e,t)=>{function n(r,o){let s=r.get(e);Fm(s)?hi(Lk(s,o)):rd(s)&&hi(Lk(s.value,o))}return gh(r=>{let o=r(e);return Fm(o)||rd(o)?t(r,o):o},n)};var roe=Symbol.for("effect/reactivity/atom/Atom/Reset"),SA=Symbol.for("effect/reactivity/atom/Atom/Interrupt");function ooe(e,t){let n=cf(IA([0,void 0])),r=t?.initialValue!==void 0?Qo(t.initialValue):Oa(),o=t?.concurrent?cf(Li(a=>{let c=new Set;return a.addFinalizer(()=>c.forEach(u=>u.interruptUnsafe())),c})):void 0;function s(a,c){let u=o?a(o):void 0;a.isFn=!0;let[f,l]=a.get(n);if(f===0)return r;if(l===SA)return od(hP(),{previous:a.self()});let p=e(l,a);return IH in p?(u&&(p=R(al(p,{startImmediately:!0}),h=>(u.add(h),h.addObserver(()=>u.delete(h)),Y(iy(u),g=>g[0])))),Rb(a,p,r,c,!1)):kA(a,p,r,c)}function i(a,c){uoe(()=>{c===roe?a.set(n,[0,void 0]):c===SA?a.set(n,[a.get(n)[0]+1,SA]):a.set(n,[a.get(n)[0]+1,c]),a.refreshSelf()})}return[s,i,n]}var soe=(e,t,n,r)=>R(Ck(typeof n=="function"?n(e):n),o=>{let i=Ei().context,a=rn(),c=Jr(o,{onFailure(f){return No(f)?Ye(a)?v({done:!0,items:a}):G(new Vf("Atom.pull: no items")):ct(f)},onSuccess(f){let l;return r?.disableAccumulation?l=f:(l=vf(a,f),a=l),v({done:!1,items:l})}}),u=new Set;return e.addFinalizer(()=>{for(let f of u)f()}),e.once(t),e.subscribe(t,()=>{e.setSelf(VS(e.self()));let f;f=vA(i,c,l=>{f&&u.delete(f);let p=fC(l,e.self()),m=u.size>0;e.setSelf(m?jm(p):p)}),f&&u.add(f)}),c}),ioe=(e,t)=>gh(t.read,function(n,r){n.set(e,n.get(e)+1)}),CA=typeof WeakRef>"u"||typeof FinalizationRegistry>"u"?e=>{let t=hc();return function(n){let r=Os(t,n);if(r._tag==="Some")return r.value;let o=e(n);return gc(t,n,o),o}}:e=>{let t=hc(),n=new FinalizationRegistry(r=>{Mu(t,r)});return function(r){let o=Os(t,r).pipe(dE(i=>i.deref()));if(o._tag==="Some")return o.value;let s=e(r);return gc(t,r,new WeakRef(s)),n.register(s,r),s}};var AA=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0});var aoe=d(e=>EH(e[0]),(e,t,n)=>{let r=cf(Qre(e)?gh(o=>t(o,e),function(o,s){o.set(e,s)},e.refresh??function(o){o(e)}):Li(o=>t(o,e),e.refresh??function(o){o(e)}));return n?.initialValueTarget&&(r.initialValueTarget=coe(n.initialValueTarget)),r}),coe=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t};var uoe=x$;var foe="~effect-atom/atom/Atom/Serializable";var RA=d(2,(e,t)=>{let n=Cc(t.schema);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:e.label??[t.key,new Error().stack?.split(`
|
|
43
|
+
`)[5]??""],[foe]:{key:t.key,encode:NT(n),decode:xm(n)}})});var TH=()=>(e,t)=>{let n=Ke()(e),r=Hr(n,t.makeEffect??yA(t.group,{...t,flatten:!0})),o=t.runtime??TA;n.runtime=o(typeof t.protocol=="function"?i=>ys(r,Yg(t.protocol(i))):ys(r,Yg(t.protocol))),n.mutation=CA(i=>{let a=t.group.requests.get(i);return n.runtime.fn()(Se(function*({headers:c,payload:u,reactivityKeys:f}){let p=(yield*n)(i,u,{headers:c});return yield*f?kS(p,f):p})).pipe(RA({key:`AtomRpc:mutation:${i}`,schema:pC({success:a.successSchema,error:vH(a)})}))});let s=CA(i=>{let{headers:a,payload:c,reactivityKeys:u,tag:f,timeToLive:l}=i,p=t.group.requests.get(f),m=Km(p.successSchema),h=m?n.runtime.pull(mr(n.use(g=>v(g(f,c,{headers:a}))))):n.runtime.atom(n.use(g=>g(f,c,{headers:a})));return u&&(h=n.runtime.factory.withReactivity(u)(h)),!m&&i.serializationKey&&(h=RA(h,{key:`AtomRpc:${i.tag}:${i.serializationKey}`,schema:pC({success:p.successSchema,error:vH(p)})})),l&&(h=fs(l)?hh(h,l):AA(h)),h});return n.query=(i,a,c)=>{let u={tag:i,payload:a,headers:c?.headers?Oi(c.headers):void 0,reactivityKeys:c?.reactivityKeys,timeToLive:c?.timeToLive?gt(c.timeToLive):void 0,serializationKey:c?.serializationKey};return s(u)},n},vH=e=>He([e.errorSchema,...Array.from(e.middlewares,t=>t.error),Hs]);var Ob={};ns(Ob,{make:()=>poe});var doe={add(...e){let t=new Map(this.requests);for(let n of e)t.set(n._tag,n);return Ma({requests:t,annotations:this.annotations})},merge(...e){let t=new Map(this.requests),n=new Map(this.annotations.mapUnsafe);for(let r of e){for(let[o,s]of r.requests)t.set(o,s);for(let[o,s]of r.annotations.mapUnsafe)n.set(o,s)}return Ma({requests:t,annotations:Mo(n)})},omit(...e){let t=new Map(this.requests);for(let n of e)t.delete(n);return Ma({requests:t,annotations:this.annotations})},middleware(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.middleware(e));return Ma({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return $t(function*(){let n=yield*ar(),r=Cr(e)?yield*e:e,o=new Map;return t.requests.forEach((s,i)=>{o.set(s.key,{tag:s._tag,handler:r[i],context:n})}),Mo(o)})},prefix(e){let t=new Map;for(let n of this.requests.values()){let r=n.prefix(e);t.set(r._tag,r)}return Ma({requests:t,annotations:this.annotations})},toLayer(e){return Gf(this.toHandlers(e))},of:B,toLayerHandler(e,t){let n=this;return Gf($t(function*(){let r=yield*ar(),o=Cr(t)?yield*t:t,s=new Map,i=n.requests.get(e);return s.set(i.key,{handler:o,context:r}),Mo(s)}))},accessHandler(e){return cr(t=>{let n=this.requests.get(e),{handler:r,context:o}=Ji(t,n.key);return v((s,i)=>{i.rpc=n;let a=r(s,i),c=id(a)?a.value:a;return Cr(c)?qw(c,o):Tk(c,o)})})},annotate(e,t){return Ma({requests:this.requests,annotations:Ve(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(cs(e,t))},annotateMerge(e){return Ma({requests:this.requests,annotations:br(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.annotateMerge(br(e,r.annotations)));return Ma({requests:t,annotations:this.annotations})}},Ma=e=>Object.assign(function(){},doe,{requests:e.requests,annotations:e.annotations}),poe=(...e)=>Ma({requests:new Map(e.map(t=>[t._tag,t])),annotations:Et()});var kH=A.Union([A.Struct({_tag:A.Literal("List"),collection:A.String}),A.Struct({_tag:A.Literal("Item"),collection:A.String,id:A.Union([A.String,A.Number])})]),uf=(e,t)=>({item:n=>({_tag:"Item",collection:e,id:n}),list:{_tag:"List",collection:e},name:e}),CH=e=>e._tag==="List"?e.collection:`${e.collection}:${e.id}`,_b=e=>[...new Set(e.map(CH))],Mb=e=>[...new Set(e.flatMap(t=>t._tag==="List"?[t.collection]:[CH(t),t.collection]))];var moe=le.fn("EffectContract.invalidateAfter")(function*(e){yield*CS(Mb(e))});function hoe(e,t,n){function r(o){return _b(n.reads(o))}return{query:(o,s={})=>e.query(t,o,{...s,reactivityKeys:r(o)}),run:o=>e.use(s=>s(t,o))}}function goe(e,t,n){return{run:r=>e.use(o=>o(t,r)).pipe(le.tap(o=>moe(n.invalidates(r,o))))}}function _A(e,t){let{name:n,queries:r,commands:o}=e.declaration;return Object.fromEntries([...r.map(s=>[s.name,hoe(t,`${n}.${s.name}`,s)]),...o.map(s=>[s.name,goe(t,`${n}.${s.name}`,s)])])}var AH=A.Union([A.Struct({_tag:A.Literal("Changed"),keys:A.Array(kH)}),A.Struct({_tag:A.Literal("Resync")})]),xoe=256;function RH(e,t){let n=mh(!1),r=mh({connection:"connecting",failure:Le.none(),needsResync:!0,pending:0});return{connection:e.atom(s=>le.gen(function*(){s.mount(r);let i=yield*Ri;function a(f){s.set(r,{...s.once(r),...f})}function c(){if(s.once(n)){a({needsResync:!0});return}i.invalidateUnsafe(_b(t.resyncKeys)),a({needsResync:!1,pending:0})}s.subscribe(n,f=>{f||c()}),t.resume!==void 0&&(s.once(t.resume),s.subscribe(t.resume,c));let u=le.suspend(()=>{let f=!0;function l(p){a({connection:"live",failure:Le.none()}),s.once(n)?a({needsResync:!0,pending:Math.min(xoe,s.once(r).pending+1)}):f||p._tag==="Resync"?c():i.invalidateUnsafe(Mb(p.keys)),f=!1}return t.stream.pipe(nr.runForEach(p=>le.sync(()=>l(p))),le.scoped,le.catchCause(p=>le.sync(()=>a({failure:Le.some(p)}))),le.andThen(le.sync(()=>a({connection:"reconnecting",needsResync:!0}))),le.andThen(le.sleep(t.retryDelay??"1 second")))});yield*le.forever(u)})).pipe(hh(0)),paused:n,status:r}}function OH(e,t){return n=>{function r(){e.document.visibilityState==="visible"&&n()}return e.addEventListener(t,r),()=>e.removeEventListener(t,r)}}function _H({window:e,native:t}){let n=e===void 0?[]:[OH(e,"visibilitychange"),OH(e,"online")],r=t===void 0?n:[...n,t];return Li(o=>{let s=0;function i(){s+=1,o.setSelf(s)}for(let a of r)o.addFinalizer(a(i));return s})}var yoe=e=>{let t=e.map(({name:n})=>n).filter((n,r,o)=>o.indexOf(n)!==r);if(t.length>0)throw new Error(`Operation names must be unique; duplicated: ${[...new Set(t)].join(", ")}`)},MH=(e,t)=>{let n=e.middleware.bind(e);return Object.assign(e,{declaration:t,middleware:r=>MH(n(r),t)})};function Pb(e,t){let{queries:n=[],commands:r=[]}=t;yoe([...n,...r]);let o=[...n,...r].map(s=>_c.make(`${e}.${s.name}`,{error:s.error,payload:s.payload,success:s.success}));return MH(Ob.make(...o),{commands:r,name:e,queries:n})}function PH(e){let t=Object.entries(e).map(([n,r])=>[n,A.isSchema(r)?r:A.TaggedError()(n,r)]);return{error:t.length===0?A.Never:A.Union(t.map(([,n])=>n)),Rejection:Object.fromEntries(t),reject:Object.fromEntries(t.map(([n,r])=>[n,(...o)=>le.fail(Reflect.construct(r,o))]))}}var Soe=e=>e===void 0?A.Void:A.isSchema(e)?e:A.Struct(e),FH=(e,t,n)=>{let{payload:r,success:o,rejections:s={}}=n;return{kind:e,name:t,payload:Soe(r),rejections:s,success:o??A.Void,...PH(s)}};function Bi(e,t){return{...FH("query",e,t),reads:t.reads}}function MA(e,t){return{...FH("command",e,t),invalidates:t.invalidates}}function boe(e){return e.startsWith(".")||e==="node_modules"}function UH(e){return e.endsWith(".md")&&!e.split("/").some(boe)}var Eoe=A.String.check(A.makeFilter(e=>UH(e)&&!e.includes("\\")&&!e.includes("\0")&&e.split("/").every(t=>t.length>0&&t!=="..")||"Expected a relative readable Markdown path")),woe=A.String.check(A.makeFilter(e=>Number.isFinite(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T.*(?:Z|[+-]\d{2}:\d{2})$/u.exec(e)!==null||"Expected an ISO observation time with timezone")),Qme=A.Struct({documents:A.Array(A.Struct({file:Eoe,source:A.String})).check(A.makeFilter(e=>new Set(e.map(t=>t.file)).size===e.length||"Duplicate source paths are not a complete observation")),recordedAt:woe,version:A.Literal(1)}).pipe(A.encodeKeys({recordedAt:"recorded_at"})),DH=A.Struct({action:A.Literals(["check","compare","observe"]),baseline:A.NullOr(A.String)}),NH=A.Struct({discardBaseline:A.Boolean,html:A.String,reason:A.String,snapshot:A.NullOr(A.String)});var Ws=A.String.check(A.isPattern(/^[a-zA-Z\d][a-zA-Z\d._-]*$/u));var xh=A.String.check(A.isPattern(/^[a-f\d]{64}$/u)),Fb=A.Literals(["answer","clarify","not_now"]),Ioe=A.Struct({deadline:A.Number.check(A.isFinite(),A.isGreaterThanOrEqualTo(0),A.isLessThanOrEqualTo(864e13)),item:Ws,reason:A.String,registeredAt:A.Number.check(A.isFinite(),A.isGreaterThanOrEqualTo(0),A.isLessThanOrEqualTo(864e13)),request:Ws,reviewedRevision:xh,source:A.String}),LH=A.Struct({author:A.String.check(A.isPattern(/\S/u),A.isMaxLength(200)),question:Ws,recordedAt:A.Number.check(A.isFinite(),A.isGreaterThanOrEqualTo(0),A.isLessThanOrEqualTo(864e13)),reviewedRevision:xh,type:Fb}),BH=A.Struct({context:A.String,id:Ws,item:Ws,reason:A.String,request:Ws,reviewedRevision:xh,source:A.String}),Ub=A.Struct({context:A.String,id:Ws,question:Ioe}),Db=A.Struct({body:A.String,id:Ws,response:LH}),jH=A.Struct({question:Ub,responses:A.Array(Db)}),qH=A.Struct({expired:A.Boolean,question:Ub,response:A.optional(Db)}),ji=class extends A.TaggedError()("ResponseFailed",{cause:A.optional(A.Defect()),code:A.Literals(["Disabled","Missing","Stale","Conflict","Unavailable","Unsupported","Uncertain","Unanswered"]),message:A.String}){},$H=A.Struct({author:LH.fields.author,body:A.String.check(A.isPattern(/\S/u),A.isMaxLength(32768)),id:Ws,question:Ws,type:Fb});var Dr=uf("work-board/workspace",A.String),zH=uf("work-board/documents",A.String),HH=uf("work-board/identities",A.String),WH=uf("work-board/navigation",A.String),Ks=uf("work-board/index",A.String),KH=uf("work-board/watcher",A.String);var voe=Bi("question",{payload:{item:A.String,request:A.String},reads:()=>[Dr.list,Ks.list],rejections:{ResponseFailed:ji},success:BH}),Toe=Bi("awaitResponse",{payload:{after:A.optional(A.String),question:A.String},reads:()=>[Dr.list,Ks.list],rejections:{ResponseFailed:ji},success:qH}),koe=Bi("responses",{payload:{question:A.String},reads:()=>[Dr.list,Ks.list],rejections:{ResponseFailed:ji},success:jH}),Coe=MA("registerQuestion",{invalidates:()=>[Dr.list,Ks.list],payload:{item:A.String,request:A.String,revision:xh},rejections:{ResponseFailed:ji},success:Ub}),Aoe=MA("recordResponse",{invalidates:()=>[Dr.list,Ks.list],payload:$H,rejections:{ResponseFailed:ji},success:Db}),Nb=Pb("work-board",{commands:[Coe,Aoe],queries:[voe,koe,Toe]});function VH(e){let t=new URL(e,"http://127.0.0.1").pathname,n=/^\/_board\/item\/(?<id>[^/]+)\/$/u.exec(t)?.groups?.id,r=zH.item(decodeURIComponent(t.slice(1)));return n?r=HH.item(decodeURIComponent(n)):t.startsWith("/_board/")&&(r=Ks.list),[Dr.list,r]}var Lc=class extends A.TaggedError()("ReadFailed",{operation:A.String,status:A.Number}){},Roe=A.String.check(A.isMaxLength(8192),A.makeFilter(e=>{if(!e.startsWith("/")||e.startsWith("//"))return"Expected a local reading URL";try{let t=new URL(e,"http://127.0.0.1").pathname;return t==="/"||["/_board/work","/_board/overview","/_board/changes","/_board/start","/_board/respond"].includes(t)||/^\/_board\/item\/[^/]+\/$/u.exec(t)!==null||/\.md$/iu.exec(t)!==null||"Expected a local reading URL"}catch{return"Expected a local reading URL"}})),Ooe=A.Struct({html:A.String,status:A.Number}),_oe=A.Struct({file:A.String,href:A.String,kind:A.Literals(["document","heading","passage"]),line:A.optional(A.Number),snippet:A.String,text:A.String,title:A.String}),Moe=Bi("page",{payload:{url:Roe},reads:({url:e})=>VH(e),rejections:{ReadFailed:Lc},success:Ooe}),Poe=Bi("navigation",{reads:()=>[Dr.list,WH.list],rejections:{ReadFailed:Lc},success:A.String}),Foe=Bi("search",{payload:{query:A.String.check(A.isMaxLength(8192))},reads:()=>[Dr.list,Ks.list],rejections:{ReadFailed:Lc},success:A.Struct({results:A.Array(_oe),total:A.Number,unavailable:A.Array(A.String)})}),Uoe=Bi("history",{payload:DH,reads:()=>[Dr.list,Ks.list],rejections:{ReadFailed:Lc},success:NH}),Doe=Bi("watcher",{reads:()=>[Dr.list,KH.list],rejections:{ReadFailed:Lc},success:A.Struct({watching:A.Boolean})}),PA=Pb("work-board",{queries:[Moe,Poe,Foe,Uoe,Doe]}),Noe=_c.make("work-board.subscribe",{error:Lc,stream:!0,success:AH}),JH=PA.add(Noe).merge(Nb);function GH(e,t={}){class n extends TH()("WorkBoard/Reader",{group:JH,protocol:ph.layerProtocolHttp({url:`${e}/_board/rpc`}).pipe(Wr.provide([HS.layer,lh.layerNdjson]))}){}let r=_A(PA,n),o=g$({defaultIdleTTL:0,timeoutResolution:1}),s=RH(n.runtime,{resume:_H(t),resyncKeys:[Dr.list],stream:nr.unwrap(n.use(f=>le.succeed(f("work-board.subscribe",void 0))))});o.mount(s.connection);async function i(f,l){try{return await le.runPromise(Hm(o,f,{suspendOnWaiting:!0}),{signal:l})}catch(p){if(l?.aborted){let m=new Error("Reading canceled",{cause:p});throw m.name="AbortError",m}throw p}}async function a(f,l){try{return await le.runPromise(le.flatMap(Hm(o,n.runtime),p=>le.provideContext(f,p)),{signal:l})}catch(p){if(l?.aborted){let m=new Error("Reading canceled",{cause:p});throw m.name="AbortError",m}throw p}}async function c(f,l){let p=await le.runPromise(le.result(Hm(o,n.runtime.atom(f),{suspendOnWaiting:!0})),{signal:l});if(p._tag==="Failure")throw p.failure;return p.success}let u=_A(Nb,n);return{api:r,mutate:c,read:i,registry:o,responses:u,run:a,updates:s}}var Lb=new WeakMap;function Bb(e){let t=Lb.get(e);if(t===void 0){let o=function(){r.registry.dispose(),Lb.get(e)===r&&Lb.delete(e),e.removeEventListener("pagehide",o)};var n=o;t=GH(e.location.origin,{window:e}),Lb.set(e,t);let r=t;e.addEventListener("pagehide",o)}return t}async function ZH(e,t,n,r){t.dataset.outcome="pending",t.textContent="Pending: registering reviewed context, then recording response\u2026";let o=Bb(window);try{let s=await o.mutate(o.responses.registerQuestion.run({item:e.dataset.item??"",request:e.dataset.request??"",revision:r.revision}));await o.mutate(o.responses.recordResponse.run({author:r.author,body:r.body,id:r.id,question:s.id,type:A.decodeUnknownSync(Fb)(r.type)})),e.isConnected&&(t.dataset.outcome="saved",t.textContent=`Saved: responses/${r.id}.md. This records feedback, not acceptance.`);let i=n.saved(r);return!i&&e.isConnected&&(t.textContent+=" Your current draft remains unsaved."),i}catch(s){if(e.isConnected){let i=s instanceof ji&&s.code!=="Uncertain"?"rejected":"uncertain";t.dataset.outcome=i,t.textContent=`${i==="rejected"?"Rejected":"Uncertain"}: ${String(s)}. Draft retained. Preview and retry with the same identity; saved content will be reconciled.`}return!1}}function FA(){let e=document.getElementById("doc");if(e?.dataset.view!=="response")return;let t=e.querySelector("#response-form");if(!t||t.dataset.bound==="true")return;t.dataset.bound="true";let n=t.querySelector("#response-status"),r=t.elements.namedItem("author"),o=t.elements.namedItem("body"),s=t.elements.namedItem("type"),i=t.querySelector("#response-submit"),a=t.querySelector("#response-preview-content"),c=t.querySelector("#response-clear"),u=t.querySelector("#response-preview");if(!(n&&r instanceof HTMLInputElement&&o instanceof HTMLTextAreaElement&&s instanceof HTMLSelectElement&&i&&a&&c&&u))return;n.textContent?.includes("JavaScript is required")&&(n.textContent="Draft ready. Preview the Markdown before recording it.");let f=t.dataset.item??"",l=t.dataset.request??"",p=t.dataset.revision??"",m=`${f}/${l}`,h=`work-board:drafts:${document.documentElement.dataset.workspace}`,g;try{g=window.localStorage}catch{g=void 0}let x=wq(m,p,g,h,w=>{n.textContent=w}),E=x.current();r.value=E.author,o.value=E.body,s.value=E.type;let b={author:r,body:o,type:s};function y(){E=x.update({author:b.author.value,body:b.body.value,revision:E.revision,type:b.type.value})}t.addEventListener("input",()=>{y(),a.hidden=!0,i.disabled=!0}),u.disabled=!1,c.disabled=!1,u.addEventListener("click",()=>{E=x.update({author:r.value,body:o.value,id:E.revision===p?x.current().id:`response.${crypto.randomUUID()}`,revision:p,type:s.value}),a.textContent=Iq(E,t.dataset.question??""),a.hidden=!1,i.disabled=t.dataset.writable!=="true"||!t.checkValidity()}),c.addEventListener("click",x.clear),t.addEventListener("submit",async w=>{w.preventDefault(),!(i.disabled||E.revision!==p||!t.reportValidity())&&(i.disabled=!0,u.disabled=!0,await ZH(t,n,x,E)&&(E=x.current(),t.isConnected&&(o.value="")),u.disabled=!1)})}function QH(){document.addEventListener("board-page",FA),window.addEventListener("pageshow",FA),FA()}typeof window<"u"&&typeof document<"u"&&QH();var Vhe=Bb;export{Vhe as session};
|