@gjermundgaraba/clankerauth-dev 0.13.0 → 0.15.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.
@@ -1,49 +0,0 @@
1
- (function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=Symbol.for(`better-auth:broadcast-channel`),t=()=>Math.floor(Date.now()/1e3),n=class{listeners=new Set;name;constructor(e=`better-auth.message`){this.name=e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}post(e){if(typeof window<`u`)try{localStorage.setItem(this.name,JSON.stringify({...e,timestamp:t()}))}catch{}}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=e=>{if(e.key!==this.name)return;let t=JSON.parse(e.newValue??`{}`);t?.event===`session`&&t?.data&&this.listeners.forEach(e=>e(t))};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}}};function r(t=`better-auth.message`){return globalThis[e]||(globalThis[e]=new n(t)),globalThis[e]}var i=[],a=0,o=null,s=4,c=globalThis.nanostoresGlobal||={epoch:0},l=()=>{let e,t;for(;a<i.length;){t=a,a+=s;try{i[t](i[t+1].value,i[t+2],i[t+3])}catch(t){e=t}}if(i.length=a=0,e)throw e},u=e=>{let t=[],n={eq:Object.is,get(){return n.lc||n.listen(()=>{})(),n.value},init:e,lc:0,listen(e){return n.lc=t.push(e),()=>{for(let t=a;t<i.length;)i[t]===e?i.splice(t,s):t+=s;let r=t.indexOf(e);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(e,r){c.epoch++;let a=!i.length&&!0;for(let a of t)o?.has(a)||(o?.add(a),i.push(a,n,e,r));a&&l()},off(){},set(e){let t=n.value;n.eq(t,e)||(n.value=e,n.notify(t))},subscribe(e){let t=n.listen(e);return e(n.value),t},value:e};return n},d=2,f=5,p=6,m=10,h=(e,t,n,r)=>(e.events=e.events||{},e.events[n+m]||(e.events[n+m]=r(t=>{e.events[n].reduceRight((e,t)=>(t(e),e),{shared:{},...t})})),e.events[n]=e.events[n]||[],e.events[n].push(t),()=>{let r=e.events[n],i=r.indexOf(t);~i&&(r.splice(i,1),r.length||(e.events[n+m](),delete e.events[n+m]))}),ee=(e,t)=>h(e,t,d,t=>{let n=e.set,r=e.setKey;return e.setKey&&=(n,i)=>{let a;if(t({abort:()=>{a=!0},changed:n,newValue:{...e.value,[n]:i}}),!a)return r(n,i)},e.set=e=>{let r;if(t({abort:()=>{r=!0},newValue:e}),!r)return n(e)},()=>{e.set=n,e.setKey=r}}),te=1e3,ne=(e,t)=>h(e,n=>{let r=t(n);r&&e.events[p].push(r)},f,t=>{let n=e.listen;e.listen=(...r)=>(!e.lc&&!e.active&&(e.active=!0,t()),n(...r));let r=e.off;return e.events[p]=[],e.off=()=>{r(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let t of e.events[p])t();e.events[p]=[]}},te)},()=>{e.listen=n,e.off=r}});function re(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ie(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!ie(e[n],t[n]))return!1;return!0}if(re(e)&&re(t)){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!(r in t)||!ie(e[r],t[r]))return!1;return!0}return!1}function ae(e,t){return ee(e,({newValue:n,abort:r})=>{t(e.value,n)&&r()})}var oe=Symbol.for(`better-auth:focus-manager`),se=class{listeners=new Set;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setFocused(e){this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||typeof document>`u`||window.addEventListener===void 0)return()=>{};let e=()=>{document.visibilityState===`visible`&&this.setFocused(!0)};return document.addEventListener(`visibilitychange`,e,!1),()=>{document.removeEventListener(`visibilitychange`,e,!1)}}};function ce(){return globalThis[oe]||(globalThis[oe]=new se),globalThis[oe]}var le=Symbol.for(`better-auth:online-manager`),ue=class{listeners=new Set;isOnline=typeof navigator<`u`?navigator.onLine:!0;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOnline(e){this.isOnline=e,this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=()=>this.setOnline(!0),t=()=>this.setOnline(!1);return window.addEventListener(`online`,e,!1),window.addEventListener(`offline`,t,!1),()=>{window.removeEventListener(`online`,e,!1),window.removeEventListener(`offline`,t,!1)}}};function de(){return globalThis[le]||(globalThis[le]=new ue),globalThis[le]}var fe={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},pe=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,me={true:!0,false:!1,null:null,undefined:void 0,nan:NaN,infinity:1/0,"-infinity":-1/0},he=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function ge(e){return e instanceof Date&&!isNaN(e.getTime())}function _e(e){let t=he.exec(e);if(!t)return null;let[,n,r,i,a,o,s,c,l,u,d]=t,f=new Date(Date.UTC(parseInt(n,10),parseInt(r,10)-1,parseInt(i,10),parseInt(a,10),parseInt(o,10),parseInt(s,10),c?parseInt(c.padEnd(3,`0`),10):0));if(l){let e=(parseInt(u,10)*60+parseInt(d,10))*(l===`+`?-1:1);f.setUTCMinutes(f.getUTCMinutes()+e)}return ge(f)?f:null}function ve(e,t={}){let{strict:n=!1,warnings:r=!1,reviver:i,parseDates:a=!0}=t;if(typeof e!=`string`)return e;let o=e.trim(),s=o.toLowerCase();if(s.length<=9&&s in me)return me[s];if(!pe.test(o)){if(n)throw SyntaxError(`[better-json] Invalid JSON`);return e}if(Object.entries(fe).some(([e,t])=>{let n=t.test(o);return n&&r&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${e} pattern`),n})&&n)throw Error(`[better-json] Potential prototype pollution attempt detected`);try{return JSON.parse(o,(e,t)=>{if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t){r&&console.warn(`[better-json] Dropping "${e}" key to prevent prototype pollution`);return}if(a&&typeof t==`string`){let e=_e(t);if(e)return e}return i?i(e,t):t})}catch(t){if(n)throw t;return e}}function ye(e,t={strict:!0}){return ve(e,t)}var be=()=>Math.floor(Date.now()/1e3),xe=5;function Se(e){let{fetchSession:t,shouldPollSession:n=()=>!0,sessionSignal:i,options:a={}}=e,o=a.sessionOptions?.refetchInterval??0,s=a.sessionOptions?.refetchOnWindowFocus??!0,c=a.sessionOptions?.refetchWhenOffline??!1,l={isInitialized:!1,lastSessionRequest:0},u=()=>c||de().isOnline,d=e=>{if(u()){if(e?.event===`storage`){t();return}if(e?.event===`poll`){l.lastSessionRequest=be(),t();return}if(e?.event===`visibilitychange`){if(be()-l.lastSessionRequest<xe)return;l.lastSessionRequest=be(),t();return}t()}},f=e=>{r().post({event:`session`,data:{trigger:e},clientId:Math.random().toString(36).substring(7)})},p=()=>{o&&o>0&&(l.pollInterval=setInterval(()=>{n()&&d({event:`poll`})},o*1e3))},m=()=>{l.unsubscribeBroadcast=r().subscribe(()=>{d({event:`storage`})})},h=()=>{s&&(l.unsubscribeFocus=ce().subscribe(()=>{d({event:`visibilitychange`})}))},ee=()=>{l.unsubscribeOnline=de().subscribe(e=>{e&&d({event:`visibilitychange`})})},te=()=>{l.unsubscribeSignal=i.listen(()=>{t()})};return{init:()=>{l.isInitialized||(l.isInitialized=!0,p(),m(),h(),ee(),te(),l.cleanupBroadcastSetup=r().setup(),l.cleanupFocusSetup=ce().setup(),l.cleanupOnlineSetup=de().setup())},cleanup:()=>{l.isInitialized&&(l.pollInterval&&=(clearInterval(l.pollInterval),void 0),l.unsubscribeBroadcast&&=(l.unsubscribeBroadcast(),void 0),l.unsubscribeFocus&&=(l.unsubscribeFocus(),void 0),l.unsubscribeOnline&&=(l.unsubscribeOnline(),void 0),l.unsubscribeSignal&&=(l.unsubscribeSignal(),void 0),l.cleanupBroadcastSetup&&=(l.cleanupBroadcastSetup(),void 0),l.cleanupFocusSetup&&=(l.cleanupFocusSetup(),void 0),l.cleanupOnlineSetup&&=(l.cleanupOnlineSetup(),void 0),l.isInitialized=!1,l.lastSessionRequest=0)},triggerRefetch:d,broadcastSessionUpdate:f}}var Ce=Object.create(null),we=e=>({}),Te=new Proxy(Ce,{get(e,t){return we()[t]??Ce[t]},has(e,t){return t in we()||t in Ce},set(e,t,n){let r=we(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=we(!0);return delete n[t],!0},ownKeys(){let e=we(!0);return Object.keys(e)}});Te.NODE_ENV;function g(e,t){return typeof process<`u`?{}[e]??t:typeof Deno<`u`?Deno.env.get(e)??t:typeof Bun<`u`?Bun.env[e]??t:t}Object.freeze({get BETTER_AUTH_SECRET(){return g(`BETTER_AUTH_SECRET`)},get AUTH_SECRET(){return g(`AUTH_SECRET`)},get BETTER_AUTH_TELEMETRY(){return g(`BETTER_AUTH_TELEMETRY`)},get BETTER_AUTH_TELEMETRY_ID(){return g(`BETTER_AUTH_TELEMETRY_ID`)},get NODE_ENV(){return g(`NODE_ENV`,`development`)},get PACKAGE_VERSION(){return g(`PACKAGE_VERSION`,`0.0.0`)},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return g(`BETTER_AUTH_TELEMETRY_ENDPOINT`,``)}});var Ee=1,_=4,De=8,Oe=24,ke={eterm:_,cons25:_,console:_,cygwin:_,dtterm:_,gnome:_,hurd:_,jfbterm:_,konsole:_,kterm:_,mlterm:_,mosh:Oe,putty:_,st:_,"rxvt-unicode-24bit":Oe,terminator:Oe,"xterm-kitty":Oe},Ae=new Map(Object.entries({APPVEYOR:De,BUILDKITE:De,CIRCLECI:Oe,DRONE:De,GITEA_ACTIONS:Oe,GITHUB_ACTIONS:Oe,GITLAB_CI:De,TRAVIS:De})),je=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Me(){if(g(`FORCE_COLOR`)!==void 0)switch(g(`FORCE_COLOR`)){case``:case`1`:case`true`:return _;case`2`:return De;case`3`:return Oe;default:return Ee}if(g(`NODE_DISABLE_COLORS`)!==void 0&&g(`NODE_DISABLE_COLORS`)!==``||g(`NO_COLOR`)!==void 0&&g(`NO_COLOR`)!==``||g(`TERM`)===`dumb`)return Ee;if(g(`TMUX`))return Oe;if(`TF_BUILD`in Te&&`AGENT_NAME`in Te)return _;if(`CI`in Te){for(let{0:e,1:t}of Ae)if(e in Te)return t;return g(`CI_NAME`)===`codeship`?De:Ee}if(`TEAMCITY_VERSION`in Te)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(g(`TEAMCITY_VERSION`))===null?Ee:_;switch(g(`TERM_PROGRAM`)){case`iTerm.app`:return!g(`TERM_PROGRAM_VERSION`)||/^[0-2]\./.exec(g(`TERM_PROGRAM_VERSION`))!==null?De:Oe;case`HyperTerm`:case`MacTerm`:return Oe;case`Apple_Terminal`:return De}if(g(`COLORTERM`)===`truecolor`||g(`COLORTERM`)===`24bit`)return Oe;if(g(`TERM`)){if(/truecolor/.exec(g(`TERM`))!==null)return Oe;if(/^xterm-256/.exec(g(`TERM`))!==null)return De;let e=g(`TERM`).toLowerCase();if(ke[e])return ke[e];if(je.some(t=>t.exec(e)!==null))return _}return g(`COLORTERM`)?_:Ee}var Ne=Symbol.for(`better-auth:global`),Pe=null,Fe={},Ie=`1.7.5`;function Le(){return globalThis[Ne]||(globalThis[Ne]={version:Ie,epoch:1,context:Fe},Pe=globalThis[Ne]),Pe=globalThis[Ne],Pe.version!==Ie&&(Pe.version=Ie,Pe.epoch++),globalThis[Ne]}function Re(){return Le().context.endpointContextAsyncStorage?.getStore()}var ze={reset:`\x1B[0m`,bright:`\x1B[1m`,dim:`\x1B[2m`,undim:`\x1B[22m`,underscore:`\x1B[4m`,blink:`\x1B[5m`,reverse:`\x1B[7m`,hidden:`\x1B[8m`,fg:{black:`\x1B[30m`,red:`\x1B[31m`,green:`\x1B[32m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,white:`\x1B[37m`},bg:{black:`\x1B[40m`,red:`\x1B[41m`,green:`\x1B[42m`,yellow:`\x1B[43m`,blue:`\x1B[44m`,magenta:`\x1B[45m`,cyan:`\x1B[46m`,white:`\x1B[47m`}},Be=[`debug`,`info`,`success`,`warn`,`error`];function Ve(e,t){return Be.indexOf(t)>=Be.indexOf(e)}var He={info:ze.fg.blue,success:ze.fg.green,warn:ze.fg.yellow,error:ze.fg.red,debug:ze.fg.magenta},Ue=(e,t,n)=>{let r=new Date().toISOString();return n?`${ze.dim}${r}${ze.reset} ${He[e]}${e.toUpperCase()}${ze.reset} ${ze.bright}[Better Auth]:${ze.reset} ${t}`:`${r} ${e.toUpperCase()} [Better Auth]: ${t}`},We=(e=>{let t=e?.disabled!==!0,n=e?.level??`warn`,r=e?.disableColors===void 0?Me()!==1:!e.disableColors,i=(i,a,o=[])=>{if(!t||!Ve(n,i))return;let s=Ue(i,a,r);if(!e||typeof e.log!=`function`){i===`error`?console.error(s,...o):i===`warn`?console.warn(s,...o):console.log(s,...o);return}e.log(i===`success`?`info`:i,a,...o)};return{...Object.fromEntries(Be.map(e=>[e,(...[t,...n])=>i(e,t,n)])),get level(){return n}}})(),Ge=()=>{let e=Re()?.context.logger;return e&&e!==Ke?e:We},Ke={debug:(...e)=>Ge().debug(...e),info:(...e)=>Ge().info(...e),success:(...e)=>Ge().success(...e),warn:(...e)=>Ge().warn(...e),error:(...e)=>Ge().error(...e),get level(){return Ge().level}};function qe(){let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.prototype.hasOwnProperty.call(e,`writable`)?e.writable:e.set!==void 0}function Je(e){let t=e.split(`
2
- at `);return t.length<=1?e:(t.splice(1,1),t.join(`
3
- at `))}function Ye(e,t){class n extends e{#e;constructor(...e){if(qe()){let t=Error.stackTraceLimit;Error.stackTraceLimit=0,super(...e),Error.stackTraceLimit=t}else super(...e);let t=Error().stack;t&&(this.#e=Je(t.replace(/^Error/,this.name)))}get errorStack(){return this.#e}}return Object.defineProperty(n.prototype,"constructor",{get(){return t},enumerable:!1,configurable:!0}),n}var Xe={OK:200,CREATED:201,ACCEPTED:202,NO_CONTENT:204,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,FOUND:302,SEE_OTHER:303,NOT_MODIFIED:304,TEMPORARY_REDIRECT:307,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,"I'M_A_TEAPOT":418,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE:431,UNAVAILABLE_FOR_LEGAL_REASONS:451,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511};Ye(class extends Error{status;body;headers;statusCode;constructor(e=`INTERNAL_SERVER_ERROR`,t=void 0,n={},r=typeof e==`number`?e:Xe[e]){super(t?.message,t?.cause?{cause:t.cause}:void 0),this.status=e,this.body=t,this.headers=n,this.statusCode=r,this.name=`APIError`,this.status=e,this.headers=n,this.statusCode=r,this.body=t}},Error);var Ze=class extends Error{constructor(e,t){super(e,t),this.name=`BetterAuthError`,this.message=e,this.stack=``}},Qe=47;function $e(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===Qe;)t--;return t===e.length?e:e.slice(0,t)}function et(e){try{return($e(new URL(e).pathname)||`/`)!==`/`}catch{throw new Ze(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function tt(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new Ze(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){throw t instanceof Ze?t:new Ze(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}}function nt(e,t=`/api/auth`){if(tt(e),et(e))return e;let n=$e(e);return!t||t===`/`?n:(t=t.startsWith(`/`)?t:`/${t}`,`${n}${t}`)}function rt(e,t){return!e||e.trim()===``?!1:t===`proto`?e===`http`||e===`https`:t===`host`?[/\.\./,/\0/,/[\s]/,/^[.]/,/[<>'"]/,/javascript:/i,/file:/i,/data:/i].some(t=>t.test(e))?!1:/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(e)||/^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(e)||/^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(e)||/^localhost(:[0-9]{1,5})?$/i.test(e):!1}function it(e,t,n,r,i){if(e)return nt(e,t);if(r!==!1){let e=Te.BETTER_AUTH_URL||Te.NEXT_PUBLIC_BETTER_AUTH_URL||Te.PUBLIC_BETTER_AUTH_URL||Te.NUXT_PUBLIC_BETTER_AUTH_URL||Te.NUXT_PUBLIC_AUTH_URL||(Te.BASE_URL===`/`?void 0:Te.BASE_URL);if(e)return nt(e,t)}let a=n?.headers.get(`x-forwarded-host`),o=n?.headers.get(`x-forwarded-proto`);if(a&&o&&i&&rt(o,`proto`)&&rt(a,`host`))try{return nt(`${o}://${a}`,t)}catch{}if(n){let e=at(n.url);if(!e)throw new Ze(`Could not get origin from request. Please provide a valid base URL.`);return nt(e,t)}if(typeof window<`u`&&window.location)return nt(window.location.origin,t)}function at(e){try{let t=new URL(e);return t.origin===`null`?null:t.origin}catch{return null}}var ot=[`javascript:`,`data:`,`vbscript:`];function st(e){let t;try{t=new URL(e)}catch{return!0}return!ot.includes(t.protocol)}var ct={id:`redirect`,name:`Redirect`,hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&st(e.data.url)&&typeof window<`u`&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}},lt=()=>typeof window>`u`,ut=te;function dt(e,t){if(typeof window>`u`)return;let n=e.get();n.data===null&&t!==null&&e.set({...n,data:t,error:null,isPending:!1})}function ft(e){return typeof e==`object`&&e&&`data`in e&&`error`in e?e:{data:e,error:null}}function pt(e){return!e||e.session===null&&e.user===null?null:e}function mt(e,t){return ie(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}function ht(e,t){let n=u(!1),r,i=0,a=0;n.listen(()=>{a++,i=0});let o=e=>d(e),s=u({data:null,error:null,isPending:!0,isRefetching:!1,refetch:o});ae(s,mt);let c=async(t,n)=>{let r=s.value;if(s.set({...r,isPending:r.data===null,isRefetching:!0,error:null,refetch:o}),t.aborted)return`aborted`;try{let r=await e(`/get-session`,{method:`GET`,query:n?.query,signal:t});if(t.aborted)return`aborted`;let{data:i,error:a}=ft(r),c=`fresh`;if(i?.needsRefresh)try{let n=await e(`/get-session`,{method:`POST`,signal:t});if(t.aborted)return`aborted`;({data:i,error:a}=ft(n))}catch{if(t.aborted)return`aborted`;c=`stale`}if(a){let e=s.value,t=a?.status===401;return s.set({data:t?null:e.data,error:a,isPending:!1,isRefetching:!1,refetch:o}),`failed`}let l=pt(i),u=s.value,d=u.data!=null&&l!=null&&ie(u.data,l)?u.data:l;return s.set({data:d,error:null,isPending:!1,isRefetching:!1,refetch:o}),c}catch(e){if(t.aborted)return`aborted`;let n=s.value;return s.set({data:n.data,error:e,isPending:!1,isRefetching:!1,refetch:o}),`failed`}},l=()=>{let e=s.value.data?.session?.expiresAt,t=e instanceof Date?e.getTime():1/0;return Math.min(Date.now()+ut,t)},d=e=>{i=0,r?.cancel();let t=new AbortController,n={cancel:()=>t.abort(),promise:Promise.resolve().then(()=>t.signal.aborted?`aborted`:c(t.signal,e)),revision:a};r=n;let o=e=>{r===n&&(r=void 0,e===`fresh`&&n.revision===a&&(i=l()))};return n.promise.then(o,()=>o(`failed`)),n.promise.then(()=>void 0)},f=()=>r?.revision===a?r.promise.then(()=>void 0):Date.now()<i?Promise.resolve():d(),p=()=>{};return ne(s,()=>{let e;lt()||(e=setTimeout(()=>{f()},0));let r=Se({fetchSession:d,shouldPollSession:()=>s.value.data!=null,sessionSignal:n,options:t});return r.init(),p=r.broadcastSessionUpdate,()=>{e&&clearTimeout(e),r.cleanup()}}),{session:s,$sessionSignal:n,broadcastSessionUpdate:e=>p(e)}}function gt(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function _t(e,t,n=`.`,r){if(!gt(t))return _t(e,{},n,r);let i={...t};for(let t of Object.keys(e)){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(i[t]=Array.isArray(a)&&Array.isArray(i[t])?[...a,...i[t]]:gt(a)&&gt(i[t])?_t(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function vt(e){return(...t)=>t.reduce((t,n)=>_t(t,n,``,e),{})}var yt=vt(),bt=class extends Error{constructor(e,t,n){super(t||e.toString(),{cause:n}),this.status=e,this.statusText=t,this.error=n,Error.captureStackTrace(this,this.constructor)}},xt=async(e,t)=>{let n=t||{},r={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:n,hooks:r};for(let i of t?.plugins||[]){if(i.init){let t=await i.init?.call(i,e.toString(),n);n=t.options||n,e=t.url}r.onRequest.push(i.hooks?.onRequest),r.onResponse.push(i.hooks?.onResponse),r.onSuccess.push(i.hooks?.onSuccess),r.onError.push(i.hooks?.onError),r.onRetry.push(i.hooks?.onRetry)}return{url:e,options:n,hooks:r}},St=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},Ct=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function wt(e){if(typeof e==`number`)return new St({type:`linear`,attempts:e,delay:1e3});switch(e.type){case`linear`:return new St(e);case`exponential`:return new Ct(e);default:throw Error(`Invalid retry strategy`)}}var Tt=[`get`,`post`,`put`,`patch`,`delete`];function Et(e){if(!e.startsWith(`@`))return{method:void 0,path:e};let t=e.indexOf(`/`),n=e.slice(1,t===-1?void 0:t);return Tt.includes(n)?{method:n,path:t===-1?e:e.slice(t+1)}:{method:void 0,path:e}}var Dt=e=>e===`.`||e===`..`,Ot=e=>e.split(`:`).map(e=>encodeURIComponent(e)).join(`:`);function kt(e,t){let n=t.get(e);if(n===void 0)return Ot(e);if(Dt(n))throw TypeError(`Path parameters cannot be reserved path segments`);return encodeURIComponent(n)}function At(e,t){let{baseURL:n,params:r,query:i}=t||{query:{},params:{},baseURL:``},a=e.startsWith(`http`)?e.split(`/`).slice(0,3).join(`/`):n||``,{path:o}=Et(e);o!==e&&(e=`/${o}`),a.endsWith(`/`)||(a+=`/`);let[s,c]=e.replace(a,``).split(`?`),l=new URLSearchParams(c);for(let[e,t]of Object.entries(i||{})){if(t==null)continue;let n;if(typeof t==`string`)n=t;else if(Array.isArray(t)){for(let n of t)l.append(e,n);continue}else n=JSON.stringify(t);l.set(e,n)}let u=new Map;if(r){if(Array.isArray(r)){let e=s.split(`/`).filter(e=>e.startsWith(`:`));for(let[t,n]of e.entries()){let e=r[t];u.set(n,String(e))}}else for(let[e,t]of Object.entries(r))u.set(`:${e}`,String(t))}s=s.split(`/`).map(e=>kt(e,u)).join(`/`),s=s.replace(/^\/+/,``);let d=l.toString();return d=d.length>0?`?${d}`.replace(/\+/g,`%20`):``,a.startsWith(`http`)?new URL(`${s}${d}`,a):`${a}${s}${d}`}var jt=async e=>{let t={},n=async e=>typeof e==`function`?await e():e;if(e?.auth){if(e.auth.type===`Bearer`){let r=await n(e.auth.token);if(!r)return t;t.authorization=`Bearer ${r}`}else if(e.auth.type===`Basic`){let[r,i]=await Promise.all([n(e.auth.username),n(e.auth.password)]);if(!r||!i)return t;t.authorization=`Basic ${btoa(`${r}:${i}`)}`}else if(e.auth.type===`Custom`){let[r,i]=await Promise.all([n(e.auth.prefix),n(e.auth.value)]);if(!i)return t;t.authorization=`${r??``} ${i}`}}return t},Mt=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Nt(e){let t=e.headers.get(`content-type`),n=new Set([`image/svg`,`application/xml`,`application/xhtml`,`application/html`]);if(!t)return`json`;let r=t.split(`;`).shift()||``;return Mt.test(r)?`json`:n.has(r)||r.startsWith(`text/`)?`text`:`blob`}function Pt(e){try{return JSON.parse(e),!0}catch{return!1}}function Ft(e){if(e===void 0)return!1;let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===null?!0:t===`object`?Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name===`Object`||typeof e.toJSON==`function`:!1}function It(e){try{return JSON.parse(e)}catch{return e}}function Lt(e){return typeof e==`function`}function Rt(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<`u`&&Lt(globalThis.fetch))return globalThis.fetch;if(typeof window<`u`&&Lt(window.fetch))return window.fetch;throw Error(`No fetch implementation found`)}function zt(...e){let t={};for(let n of e)if(n){if(n instanceof Headers)n.forEach((e,n)=>{t[n]=e});else{let e=Array.isArray(n)?n:Object.entries(n);for(let[n,r]of e)r!=null&&(t[n]=r)}}return t}async function Bt(e){let t=new Headers(zt(e?.headers,await jt(e)));if(!t.has(`content-type`)){let n=Vt(e?.body);n&&t.set(`content-type`,n)}return t}function Vt(e){return Ft(e)?`application/json`:null}function Ht(e){let t=e.get(`content-type`);return t?t.split(`;`)[0].trim().toLowerCase():null}function Ut(e,t){let{body:n}=e;return n?!Ft(n)||typeof n==`string`?n:Ht(t)===`application/x-www-form-urlencoded`?new URLSearchParams(n).toString():JSON.stringify(n):null}function Wt(e,t){if(t?.method)return t.method.toUpperCase();let{method:n}=Et(e);return n?n.toUpperCase():t?.body?`POST`:`GET`}function Gt(e,t){let n;return!e?.signal&&e?.timeout&&(n=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:n,clearTimeout:()=>{n&&clearTimeout(n)}}}var Kt=class e extends Error{constructor(t,n){super(n||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,e.prototype)}};async function qt(e,t){let n=await e[`~standard`].validate(t);if(n.issues)throw new Kt(n.issues);return n.value}function Jt(e){"@babel/helpers - typeof";return Jt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Jt(e)}function Yt(e,t){if(Jt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Jt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Xt(e){var t=Yt(e,`string`);return Jt(t)==`symbol`?t:t+``}function Zt(e,t,n){return(t=Xt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function v(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Qt(Object(n),!0).forEach(function(t){Zt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var $t=async(e,t)=>{var n;let{hooks:r,url:i,options:a}=await xt(e,t),o=Rt(a),s=new AbortController,c=a.signal??s.signal,l=At(i,a),u=await Bt(a),d=Ut(a,u),f=Wt(i,a),p=v(v({},a),{},{url:l,headers:u,body:d,method:f,signal:c});for(let e of r.onRequest)if(e){let t=await e(p);typeof t==`object`&&t&&Object.assign(p,t)}(`pipeTo`in p&&typeof p.pipeTo==`function`||typeof(t==null||(n=t.body)==null?void 0:n.pipe)==`function`)&&(`duplex`in p||(p.duplex=`half`));let{clearTimeout:m}=Gt(a,s),h=await o(p.url,p);m();let ee={response:h,request:p};for(let e of r.onResponse)if(e){var te;let n=await e(v(v({},ee),{},{response:t!=null&&(te=t.hookOptions)!=null&&te.cloneResponse?h.clone():h}));n instanceof Response?h=n:typeof n==`object`&&n&&(h=n.response)}if(h.ok){if(p.method===`HEAD`)return{data:``,error:null};let e=Nt(h),n={data:null,response:h,request:p};if(e===`json`||e===`text`){let e=await h.text();n.data=await(p.jsonParser??It)(e)}else n.data=await h[e]();p?.output&&p.output&&!p.disableValidation&&(n.data=await qt(p.output,n.data));for(let e of r.onSuccess)if(e){var ne;await e(v(v({},n),{},{response:t!=null&&(ne=t.hookOptions)!=null&&ne.cloneResponse?h.clone():h}))}return t?.throw?n.data:{data:n.data,error:null}}let re=t?.jsonParser??It,ie=await h.text(),ae=Pt(ie),oe=ae?await re(ie):null,se={response:h,responseText:ie,request:p,error:v(v({},oe),{},{status:h.status,statusText:h.statusText})};for(let e of r.onError)if(e){var ce;await e(v(v({},se),{},{response:t!=null&&(ce=t.hookOptions)!=null&&ce.cloneResponse?h.clone():h}))}if(t?.retry){let n=wt(t.retry),i=t.retryAttempt??0;if(await n.shouldAttemptRetry(i,h)){for(let e of r.onRetry)e&&await e(ee);let a=n.getDelay(i);return await new Promise(e=>setTimeout(e,a)),await $t(e,v(v({},t),{},{retryAttempt:i+1}))}}if(t?.throw)throw new bt(h.status,h.statusText,ae?oe:ie);return{data:null,error:v(v({},oe),{},{status:h.status,statusText:h.statusText})}},en=e=>({id:`apply-schema`,name:`Apply Schema`,version:`1.0.0`,async init(t,n){var r;let i=v(v({},n),e.query!==void 0&&{query:v(v({},e.query),n?.query)}),a=((r=e.plugins)==null||(r=r.find(e=>e.schema?.config?t.startsWith(e.schema.config.baseURL||``)||t.startsWith(e.schema.config.prefix||``):!1))==null?void 0:r.schema)||e.schema;if(a){let r=t;a.config?.prefix&&r.startsWith(a.config.prefix)&&(r=r.replace(a.config.prefix,``),a.config.baseURL&&(t=t.replace(a.config.prefix,a.config.baseURL))),a.config?.baseURL&&r.startsWith(a.config.baseURL)&&(r=r.replace(a.config.baseURL,``)),r.startsWith(`/`)&&r.charAt(1)===`@`&&(r=r.substring(1));let o=a.schema[r];if(o){let{method:a,path:s}=Et(r);a&&(t=t.slice(0,t.length-r.length)+s);let c=n?.headers;if(o.headers&&!n?.disableValidation){let e={};if(n?.headers){if(n.headers instanceof Headers)n.headers.forEach((t,n)=>{e[n.toLowerCase()]=t});else if(typeof n.headers==`object`)for(let[t,r]of Object.entries(n.headers))r!=null&&(e[t.toLowerCase()]=r)}let t=await qt(o.headers,e),r={};for(let[e,n]of Object.entries(t))r[e.toLowerCase()]=n;c=r}let l=o.method??a;if(i=v(v(v(v({},i),l!==void 0&&{method:l}),o.output!==void 0&&{output:o.output}),c!==void 0&&{headers:c}),!n?.disableValidation){if(o.query&&(i.query=await qt(o.query,n?.query),i.query!==null&&typeof i.query==`object`)){let t=v({},e.query);for(let e of Object.keys(t))n?.query&&Object.prototype.hasOwnProperty.call(n.query,e)&&(t[e]=n.query[e]);i.query=v(v({},t),i.query)}i=v(v({},i),{},{body:o.input?await qt(o.input,n?.body):n?.body,params:o.params?await qt(o.params,n?.params):n?.params})}return{url:t,options:i}}}return v({url:t},(n!==void 0||e.query!==void 0)&&{options:i})}}),tn=e=>{async function t(t,n){let r=v(v(v({},e),n),{},{headers:zt(e?.headers,n?.headers),plugins:[...e?.plugins||[],en(e||{}),...n?.plugins||[]]});if(e?.catchAllError)try{return await $t(t,r)}catch(e){return{data:null,error:{status:500,statusText:`Fetch Error`,message:`Fetch related error. Captured by catchAllError option. See error property for more details.`,error:e}}}return await $t(t,r)}return t},nn=e=>{if(typeof process>`u`)return;let t=e??`/api/auth`;if({}.NEXT_PUBLIC_AUTH_URL)return{}.NEXT_PUBLIC_AUTH_URL;if(typeof window>`u`){if({}.NEXTAUTH_URL)try{return{}.NEXTAUTH_URL}catch{}if({}.VERCEL_URL)try{let e={}.VERCEL_URL.startsWith(`http`)?``:`https://`;return`${new URL(`${e}${{}.VERCEL_URL}`).origin}${t}`}catch{}}},rn=(e,t)=>{let n=`credentials`in Request.prototype,r=it(e?.baseURL,e?.basePath,void 0,t)??nn(e?.basePath)??`/api/auth`,i=e?.plugins?.flatMap(e=>e.fetchPlugins).filter(e=>e!==void 0)||[],a={id:`lifecycle-hooks`,name:`lifecycle-hooks`,hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:o,onError:s,onRequest:c,onResponse:l,...u}=e?.fetchOptions||{},d=tn({baseURL:r,...n?{credentials:`include`}:{},method:`GET`,jsonParser(e){return e?ye(e,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[a,...u.plugins||[],...e?.disableDefaultFetchPlugins?[]:[ct],...i]}),{$sessionSignal:f,session:p,broadcastSessionUpdate:m}=ht(d,e),h=!1,ee=e=>{h||e===null||(h=!0,dt(p,e))},te=e?.plugins||[],ne={},re={$sessionSignal:f,session:p},ie={"/sign-out":`POST`,"/revoke-sessions":`POST`,"/revoke-other-sessions":`POST`,"/delete-user":`POST`},ae=[{signal:`$sessionSignal`,matcher(e){return e===`/sign-out`||e===`/update-user`||e===`/update-session`||e===`/sign-up/email`||e===`/sign-in/email`||e===`/delete-user`||e===`/verify-email`||e===`/revoke-sessions`||e===`/revoke-session`||e===`/revoke-other-sessions`||e===`/change-email`||e===`/change-password`},callback(e){e===`/sign-out`?m(`signout`):(e===`/update-user`||e===`/update-session`)&&m(`updateUser`)}}];for(let e of te)e.getAtoms&&Object.assign(re,e.getAtoms?.(d)),e.pathMethods&&Object.assign(ie,e.pathMethods),e.atomListeners&&ae.push(...e.atomListeners);let oe={notify:e=>{re[e].set(!re[e].get())},listen:(e,t)=>{re[e].subscribe(t)},atoms:re};for(let t of te)t.getActions&&(ne=yt(t.getActions?.(d,oe,e)??{},ne));return{get baseURL(){return r},pluginsActions:ne,pluginsAtoms:re,pluginPathMethods:ie,atomListeners:ae,hydrateSession:ee,$sessionSignal:f,$fetch:d,$store:oe}};function an(e){return typeof e==`object`&&!!e&&`get`in e&&typeof e.get==`function`&&`lc`in e&&typeof e.lc==`number`}function on(e){return e.charAt(0).toUpperCase()+e.slice(1)}var sn=/[\p{Ll}\d]+|\p{Lu}+(?!\p{Ll})|\p{Lu}[\p{Ll}\d]+|\p{Lo}+/gu,cn=/['\u2019]/g;function ln(e){return e.replace(cn,``).match(sn)??[]}function un(e){return ln(e).map(e=>e.toLowerCase()).join(`-`)}function dn(e,t,n){let r=t[e],{fetchOptions:i,query:a,...o}=n||{};return r||(i?.method?i.method:o&&Object.keys(o).length>0?`POST`:`GET`)}function fn(e,t,n,r,i){function a(o=[]){return new Proxy(function(){},{get(t,n){if(typeof n!=`string`||n===`then`||n===`catch`||n===`finally`)return;let r=[...o,n],i=e;for(let e of r)if(i&&typeof i==`object`&&e in i)i=i[e];else{i=void 0;break}return typeof i==`function`||an(i)?i:a(r)},apply:async(e,a,s)=>{let c=`/`+o.map(un).join(`/`),l=s[0]||{},u=s[1]||{},{query:d,fetchOptions:f,...p}=l,m={...u,...f},h=dn(c,n,l);return await t(c,{...m,body:h===`GET`?void 0:{...p,...m?.body||{}},query:d||m?.query,method:h,async onSuccess(e){if(await m?.onSuccess?.(e),!i||m.disableSignal)return;let t=i.filter(e=>e.matcher(c));if(!t.length)return;let n=new Set;for(let e of t){let t=r[e.signal];if(!t)return;if(n.has(e.signal))continue;n.add(e.signal);let i=t.get();setTimeout(()=>{t.set(!i)},10),e.callback?.(c)}}})}})}return a()}function pn(e){let{pluginPathMethods:t,pluginsActions:n,pluginsAtoms:r,hydrateSession:i,$fetch:a,atomListeners:o,$store:s}=rn(e),c={};for(let[e,t]of Object.entries(r))c[`use${on(e)}`]=t;return fn({...n,...c,hydrateSession:i,$fetch:a,$store:s},a,t,r,o)}var mn=`ba_param`;function hn(e){let t=e.getAll(mn);if(t.length)return new Set(t)}function gn(e){let t=new URLSearchParams(e);if(!t.has(`sig`))return;let n=hn(t);if(!n)return;let r=new URLSearchParams;for(let[e,i]of t.entries())(e===`sig`||e===mn||n.has(e))&&r.append(e,i);return r.toString()}var _n=`1.7.5`,vn=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;function yn(e){if(typeof e==`string`&&vn.test(e)){let t=new Date(e);if(!isNaN(t.getTime()))return t}return e}function bn(e){if(e==null)return e;if(typeof e==`string`)return yn(e);if(e instanceof Date)return e;if(Array.isArray(e))return e.map(bn);if(typeof e==`object`){let t={};for(let n of Object.keys(e))t[n]=bn(e[n]);return t}return e}function xn(e){try{return typeof e==`string`?JSON.parse(e,(e,t)=>yn(t)):e==null?null:bn(e)}catch(e){return Ke.error(`Error parsing JSON`,{error:e}),null}}var Sn=()=>({id:`oauth-provider-client`,version:_n,fetchPlugins:[{id:`oauth-provider-signin`,name:`oauth-provider-signin`,description:`Adds the current page query to oauth requests`,hooks:{async onRequest(e){let t=e.headers,n=typeof e.body==`string`?t.get(`content-type`)===`application/x-www-form-urlencoded`?Object.fromEntries(new URLSearchParams(e.body)):xn(e.body??`{}`):e.body;n?.oauth_query||typeof window<`u`&&window?.location?.search&&e.method!==`GET`&&e.method!==`DELETE`&&(e.body=JSON.stringify({...n,oauth_query:gn(window.location.search)}))}}}],$InferServerPlugin:{}}),y=(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 e=0,r=t.length;e<r;e++)n=t[e](n);return n}}},Cn={pipe(){return y(this,arguments)}},wn=function(){function e(){}return e.prototype=Cn,e}(),b=function(e,t){if(typeof e==`function`)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,n){return arguments.length>=2?t(e,n):function(n){return t(n,e)}};case 3:return function(e,n,r){return arguments.length>=3?t(e,n,r):function(r){return t(r,e,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(e){return t(e,...n)}}}},x=e=>e,Tn=e=>()=>e,En=Tn(!0),Dn=Tn(!1),On=Tn(void 0),kn=On;function An(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i}}function jn(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i!==n&&t.set(i,i),i}}var Mn=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 e=Reflect.ownKeys(r);for(let n=0;n<e.length;n++)t.add(e[n]);r=Object.getPrototypeOf(r)}return t.has(`constructor`)&&typeof e.constructor==`function`&&n===e.constructor.prototype&&t.delete(`constructor`),t},Nn=new WeakSet,Pn=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Fn=0,In=()=>{Fn++};function Ln(e){return typeof e==`string`}function Rn(e){return typeof e==`number`}function zn(e){return typeof e==`boolean`}function Bn(e){return typeof e==`symbol`}function Vn(e){return Ln(e)||Rn(e)||Bn(e)}function Hn(e){return typeof e==`function`}function Un(e){return e!=null}function Wn(e){return!1}function Gn(e){return!0}function Kn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qn(e){return typeof e==`object`&&!!e||Hn(e)}var S=b(2,(e,t)=>qn(e)&&t in e),Jn=b(2,(e,t)=>S(e,`_tag`)&&e._tag===t);function Yn(e){return e instanceof Error}function Xn(e){return S(e,Symbol.iterator)||Ln(e)}var C=`~effect/Hash`,w=e=>{switch(typeof e){case`number`:return nr(e);case`bigint`:return rr(e.toString(10));case`string`:return rr(e);case`function`:case`object`:if(e===null)break;if(e instanceof Date)return Number.isNaN(e.getTime())?rr(`Invalid Date`):rr(e.toISOString());if(e instanceof RegExp)return rr(e.toString());{if(Nn.has(e))return Zn(e);let t=fr.get(e);if(t!==void 0)return t;if(pr.has(e))return In(),rr(`[Circular]`);pr.add(e);let n=Fn,r;try{r=`~effect/Hash`in e?e[C]():typeof e==`function`?Zn(e):e instanceof DataView?sr(Pn(e)):Array.isArray(e)||ArrayBuffer.isView(e)?sr(e):e instanceof Map?cr(e):e instanceof Set?ur(e):ar(e)}finally{pr.delete(e)}return n===Fn&&fr.set(e,r),r}}return er(Qn(rr(String(e))))},Zn=e=>(dr.has(e)||dr.set(e,er(Math.random()*4294967296|0)),dr.get(e)),Qn=e=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),$n=b(2,(e,t)=>Qn(Math.imul(e,2654435761)+Math.imul(t,2246822507))),er=e=>e&3221225471|e>>>1&1073741824,tr=new DataView(new ArrayBuffer(8)),nr=e=>{let t=e|0;return t===e?er(t):(tr.setFloat64(0,e===e?e:NaN),er($n(tr.getInt32(0),tr.getInt32(4))))},rr=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return er(t)},ir=(e,t)=>{let n=12289;for(let r of t)n^=$n(w(r),w(e[r]));return er(n)},ar=e=>ir(e,Mn(e)),or=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return er(r)},sr=e=>{let t=6151;for(let n of e)t=$n(t,w(n));return er(t)},cr=or(rr(`Map`),([e,t])=>$n(w(e),w(t))),lr=rr(`Set`),ur=or(lr,e=>$n(lr,w(e))),dr=new WeakMap,fr=new WeakMap,pr=new WeakSet,T=`~effect/Equal`;function mr(){return arguments.length===1?e=>hr(e,arguments[0]):hr(arguments[0],arguments[1])}function hr(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n===typeof t?n===`number`&&e!==e&&t!==t?!0:n!==`object`&&n!==`function`||Nn.has(e)||Nn.has(t)?!1:gr(e,t):!1}function gr(e,t){let n=vr.length;for(let r=n;r-->0;)if(vr[r]===e&&yr[r]===t)return!0;if(n)return _r(e,t);let r=br.get(e);r||br.set(e,r=new WeakMap);let i=r.get(t);return i===void 0&&r.set(t,i=_r(e,t)),i}function _r(e,t){vr.push(e),yr.push(t);try{return xr(e,t)}finally{vr.pop(),yr.pop()}}var vr=[],yr=[],br=new WeakMap;function xr(e,t){if(w(e)!==w(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let n=e.getTime(),r=t.getTime();return n===r||Number.isNaN(n)&&Number.isNaN(r)}if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let n=Or(e);if(n!==Or(t)||typeof e==`function`&&!n)return!1;if(n)return e[T](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:Sr(e,t);if(ArrayBuffer.isView(e)){let n=e instanceof DataView;return!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView?!1:n?Cr(Pn(e),Pn(t)):Cr(e,t)}return e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:Tr(e,t,Er,Dr):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:Tr(e,t,w,hr):wr(e,t)}function Sr(e,t){for(let n=0;n<e.length;n++)if(!hr(e[n],t[n]))return!1;return!0}function Cr(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 wr(e,t){let n=Mn(e),r=Mn(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!hr(e[i],t[i]))return!1;return!0}function Tr(e,t,n,r){let i=new Map;for(let e of t){let t=n(e),r=i.get(t);r?r.push(e):i.set(t,[e])}outer:for(let t of e){let e=i.get(n(t));if(e){for(let n=0;n<e.length;n++)if(r(t,e[n])){e[n]=e[e.length-1],e.pop();continue outer}}return!1}return!0}var Er=e=>w(e[0]),Dr=(e,t)=>hr(e[0],t[0])&&hr(e[1],t[1]),Or=e=>S(e,T),kr=Symbol.for(`~effect/Redactable`),Ar=e=>S(e,kr);function jr(e){return Ar(e)?Mr(e):e}function Mr(e){return e[kr](globalThis[`~effect/Fiber/currentFiber`]?.context??Fr)}var Nr=`~effect/Fiber/currentFiber`,Pr=new Map,Fr={"~effect/Context":{},base:Pr,depth:0,mapUnsafe:Pr,pipe(){return y(this,arguments)}};function E(e,t){let n=t?.space??0,r=new WeakSet,i=n?typeof n==`number`?` `.repeat(n):n:``,a=e=>i.repeat(e),o=(e,t)=>{let n=e?.constructor;return n&&n!==Object.prototype.constructor&&n.name?`${n.name}(${t})`:t},s=e=>{try{return Reflect.ownKeys(e)}catch{return[`[ownKeys threw]`]}};function c(e,t=0){try{return l(e,t)}catch{return(typeof e==`object`&&e||typeof e==`function`)&&r.delete(e),`[inspection threw]`}}function l(e,n=0){if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`||e==null||typeof e==`boolean`||typeof e==`symbol`)return String(e);if(typeof e==`bigint`)return String(e)+`n`;if(typeof e==`object`||typeof e==`function`){if(r.has(e))return Ir;r.add(e);let l;if(kr in e)l=c(Mr(e),n);else if(Array.isArray(e))l=!i||e.length<=1?`[${e.map(e=>c(e,n)).join(`,`)}]`:`[\n${a(n+1)}${e.map(e=>c(e,n+1)).join(`,
4
- `+a(n+1))}\n${a(n)}]`;else if(e instanceof Date)l=zr(e);else if(!t?.ignoreToString&&S(e,`toString`)&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=Br(e);l=e instanceof Error&&e.cause!==void 0?`${t} (cause: ${c(e.cause,n)})`:t}else if(Symbol.iterator in e)l=`${e.constructor.name}(${c(Array.from(e),n)})`;else{let t=s(e);if(!i||t.length<=1){let r=`{${t.map(t=>`${Lr(t)}:${c(Vr(e,t),n)}`).join(`,`)}}`;l=o(e,r)}else{let r=`{\n${t.map(t=>`${a(n+1)}${Lr(t)}: ${c(Vr(e,t),n+1)}`).join(`,
5
- `)}\n${a(n)}}`;l=o(e,r)}}return r.delete(e),l}return String(e)}return c(e,0)}var Ir=`[Circular]`;function Lr(e){return typeof e==`string`?JSON.stringify(e):String(e)}function Rr(e){return e.map(e=>`[${Lr(e)}]`).join(``)}function zr(e){try{return e.toISOString()}catch{return`Invalid Date`}}function Br(e){try{let t=e.toString();return typeof t==`string`?t:String(t)}catch{return`[toString threw]`}}function Vr(e,t){try{return e[t]}catch{return`[property access threw]`}}function Hr(e,t){let n=[];return JSON.stringify(e,function(e,t){let r=Object.getOwnPropertyDescriptor(this,e)?.value,i=S(r,kr)?jr(r):jr(t);if(typeof i==`bigint`)return E(i);if(typeof i!=`object`||!i)return i;let a=i instanceof Error&&!S(i,`toJSON`)?{...i,name:i.name,message:i.message}:i;for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(!n.includes(i))return n.push(i),a!==i&&n.push(a),a},t?.space)??`null`}var Ur=Symbol.for(`nodejs.util.inspect.custom`),Wr=e=>{try{return e=jr(e),S(e,`toJSON`)&&Hn(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(Wr):e}catch{return`[toJSON threw]`}},Gr={toJSON(){return Wr(this)},[Ur](){return this.toJSON()},toString(){return E(this.toJSON())}},Kr=class{[Ur](){return this.toJSON()}toString(){return E(this.toJSON())}},qr=(()=>{let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,`writable`)?e.writable===!0:e.set!==void 0})(),Jr=()=>Error.stackTraceLimit,Yr=e=>{qr&&(Error.stackTraceLimit=e)},Xr=class{constructor(e){this.value=e,this.done=!1}next(e){return this.done?(this.value=e,this):(this.done=!0,{value:this.value,done:!1})}},Zr=(()=>{let e=`~effect/Utils/internal`,t={[e]:e=>e()},n={[e]:e=>{try{return e()}finally{}}};return Jr()!==0&&t[e](()=>Error().stack)?.includes(e)===!0?t[e]:n[e]})();function Qr(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function $r(e,t){for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&Qr(e,n,t[n])}var ei=`~effect/Effect`,ti=`~effect/Exit`,ni={_A:x,_E:x,_R:x},ri=`${ei}/identifier`,D=`${ei}/args`,O=`${ei}/evaluate`,k=`${ei}/successCont`,ii=`${ei}/failureCont`,ai=`${ei}/ensureCont`,oi=Symbol.for(`effect/Effect/Yield`),si={pipe(){return y(this,arguments)},toJSON(){return{...this}},toString(){return E(this.toJSON(),{ignoreToString:!0,space:2})},[Ur](){return this.toJSON()}},ci={[ei]:ni,...si,[Symbol.iterator](){return new Xr(this)},toJSON(){return{_id:`Effect`,op:this[ri],...D in this?{args:this[D]}:void 0}}},li=e=>S(e,ei),ui=e=>S(e,ti),di=`~effect/Cause`,fi=`~effect/Cause/Reason`,pi=e=>S(e,di),mi=e=>S(e,fi),hi=class{constructor(e){this[di]=di,this.reasons=e}pipe(){return y(this,arguments)}toJSON(){return{_id:`Cause`,failures:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${E(this.reasons)})`}[Ur](){return this.toJSON()}[T](e){return pi(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>mr(t,e.reasons[n]))}[C](){return sr(this.reasons)}},gi=new WeakMap,_i=class{[fi];annotations;_tag;constructor(e,t,n){if(this[fi]=fi,this._tag=e,t!==vi&&typeof n==`object`&&n&&t.size>0){let e=gi.get(n);e&&(t=new Map([...e,...t])),gi.set(n,t)}this.annotations=t}annotate(e,t){if(e.mapUnsafe.size===0)return this;let n=new Map(this.annotations);e.mapUnsafe.forEach((e,r)=>{t?.overwrite!==!0&&n.has(r)||n.set(r,e)});let r=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return r.annotations=n,r}pipe(){return y(this,arguments)}toString(){return E(this)}[Ur](){return this.toString()}},vi=new Map,yi=class extends _i{constructor(e,t=vi){super(`Fail`,t,e),this.error=e}toString(){return`Fail(${E(this.error)})`}toJSON(){return{_tag:`Fail`,error:this.error}}[T](e){return Ti(e)&&mr(this.error,e.error)&&mr(this.annotations,e.annotations)}[C](){return $n(rr(this._tag))($n(w(this.error))(w(this.annotations)))}},bi=e=>new hi(e),xi=e=>new hi([new yi(e)]),Si=class extends _i{constructor(e,t=vi){super(`Die`,t,e),this.defect=e}toString(){return`Die(${E(this.defect)})`}toJSON(){return{_tag:`Die`,defect:this.defect}}[T](e){return Ei(e)&&mr(this.defect,e.defect)&&mr(this.annotations,e.annotations)}[C](){return $n(rr(this._tag))($n(w(this.defect))(w(this.annotations)))}},Ci=e=>new hi([new Si(e)]),wi=b(e=>pi(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new hi(e.reasons.map(e=>e.annotate(t,n)))),Ti=e=>e._tag===`Fail`,Ei=e=>e._tag===`Die`,Di=e=>e._tag===`Interrupt`;function Oi(e){return Li(`Effect.evaluate: Not implemented`)}var ki=e=>({...ci,[ri]:e.op,[O]:e[O]??Oi,[k]:e[k],[ii]:e[ii],[ai]:e[ai]}),Ai=e=>{let t=ki(e),n=function(e){this[D]=e};return n.prototype=t,function(e){return new n(e)}},ji=e=>{let t={[ti]:ti,_tag:e.op,get[e.prop](){return this[D]},...ki(e),toString(){return`${e.op}(${E(this[D])})`},toJSON(){return{_id:`Exit`,_tag:e.op,[e.prop]:this[D]}},[T](e){return ui(e)&&e._tag===this._tag&&mr(this[D],e[D])},[C](){return $n(rr(e.op),w(this[D]))}},n=function(e){this[D]=e};return n.prototype=t,function(e){return new n(e)}},Mi=ji({op:`Success`,prop:`value`,[O](e){let t=e.getCont(k);return t?t[k](this[D],e,this):e.yieldWith(this)}}),Ni={key:`effect/Cause/StackTrace`},Pi={key:`effect/Cause/InterruptorStackTrace`},Fi=ji({op:`Failure`,prop:`cause`,[O](e){let t=this[D],n=!1;e.cache.stackFrame&&(t=wi(t,{mapUnsafe:new Map([[Ni.key,e.cache.stackFrame]])}),n=!0);let r=e.getCont(ii);for(;e.interruptible&&e._interruptedCause&&r;)r=e.getCont(ii);return r?r[ii](t,e,n?void 0:this):e.yieldWith(n?Fi(t):this)}}),Ii=e=>Fi(xi(e)),Li=e=>Fi(Ci(e)),A=Ai({op:`WithFiber`,[O](e){return this[D](e)}}),Ri=function(){class e extends globalThis.Error{}let t=ki({op:`YieldableError`,[O](){return Ii(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),zi=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return class extends Ri{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&($r(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}(),Bi=e=>{class t extends zi{_tag=e}return t.prototype.name=e,t},Vi=`~effect/Cause/Done`,Hi=e=>S(e,Vi),Ui={[Vi]:Vi,_tag:`Done`,value:void 0},Wi=e=>e===void 0?Ui:{[Vi]:Vi,_tag:`Done`,value:e},Gi=Ii(Ui),Ki=e=>e===void 0?Gi:Ii(Wi(e)),qi=e=>ki({op:e.label,[O]:e.evaluate}),Ji=e=>(t,n)=>t===n||e(t,n),Yi=(e,t)=>e===t,Xi=()=>Yi;function Zi(e){return Ji((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 Qi(e){return Ji((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 $i=`~effect/Option`,ea={[$i]:{_A:e=>e},...si,[Symbol.iterator](){return new Xr(this)}},ta=Object.defineProperty(Object.assign(Object.create(ea),{_tag:`Some`,_op:`Some`,[T](e){return ia(e)&&oa(e)&&mr(this.value,e.value)},[C](){return $n(w(this._tag))(w(this.value))},toString(){return`some(${E(this.value)})`},toJSON(){return{_id:`Option`,_tag:this._tag,value:Wr(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),na=w(`None`),ra=Object.assign(Object.create(ea),{_tag:`None`,_op:`None`,valueOrUndefined:void 0,[T](e){return ia(e)&&aa(e)},[C](){return na},toString(){return`none()`},toJSON(){return{_id:`Option`,_tag:this._tag}}}),ia=e=>S(e,$i),aa=e=>e._tag===`None`,oa=e=>e._tag===`Some`,sa=Object.create(ra),ca=function(e){this.value=e};ca.prototype=ta;var la=e=>new ca(e),ua=`~effect/Result`,da={[ua]:{_A:e=>e,_E:e=>e},...si,[Symbol.iterator](){return new Xr(this)}},fa=Object.assign(Object.create(da),{_tag:`Success`,_op:`Success`,[T](e){return ma(e)&&ga(e)&&mr(this.success,e.success)},[C](){return $n(w(this._tag))(w(this.success))},toString(){return`success(${E(this.success)})`},toJSON(){return{_id:`Result`,_tag:this._tag,value:Wr(this.success)}}}),pa=Object.assign(Object.create(da),{_tag:`Failure`,_op:`Failure`,[T](e){return ma(e)&&ha(e)&&mr(this.failure,e.failure)},[C](){return $n(w(this._tag))(w(this.failure))},toString(){return`failure(${E(this.failure)})`},toJSON(){return{_id:`Result`,_tag:this._tag,failure:Wr(this.failure)}}}),ma=e=>S(e,ua),ha=e=>e._tag===`Failure`,ga=e=>e._tag===`Success`,_a=function(e){this.failure=e};_a.prototype=pa;var va=e=>new _a(e),ya=function(e){this.success=e};ya.prototype=fa;var ba=e=>new ya(e);function xa(e){return(t,n)=>t===n?0:e(t,n)}var Sa=xa((e,t)=>e<t?-1:1),Ca=xa((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),wa=b(2,(e,t)=>xa((n,r)=>e(t(n),t(r)))),Ta=e=>b(2,(t,n)=>e(t,n)===-1),Ea=e=>b(2,(t,n)=>e(t,n)===1),Da=e=>b(2,(t,n)=>e(t,n)!==1),Oa=e=>b(2,(t,n)=>e(t,n)!==-1),ka=()=>sa,Aa=la,ja=aa,Ma=oa,Na=b(2,(e,{onNone:t,onSome:n})=>ja(e)?t():n(e.value)),Pa=b(2,(e,t)=>ja(e)?t():e.value),Fa=e=>e==null?ka():Aa(e),Ia=Pa(On),La=e=>(...t)=>{try{return Aa(e(...t))}catch{return ka()}},Ra=`~effect/Context/Service`,j=function(){function e(){}let t=e;Object.setPrototypeOf(t,za);let n=(e,n)=>(t.key=e,n?.defaultValue&&(t[Va]=Va,t.defaultValue=n.defaultValue),n?.make&&(t.make=n.make),n?.fiberCached&&Ba.add(e),t);return arguments.length>0?n(arguments[0],arguments[1]):n},za={[Ra]:Ra,...qi({label:`Service`,evaluate(e){return Mi(fo(e.context,this))}}),toJSON(){return{_id:`Service`,key:this.key}},of(e){return e},context(e){return ao(this,e)},use(e){return A(t=>e(fo(t.context,this)))},useSync(e){return A(t=>Mi(e(fo(t.context,this))))}},Ba=new Set,Va=`~effect/Context/Reference`,Ha=`~effect/Context`,Ua=8,Wa=8,Ga=(e,t,n,r)=>{let i=Object.create(Qa);return i.cacheRoot=e??i,i.base=t,i.overlay=n,i.depth=r,i._flat=void 0,i.baseHits=0,i},Ka=(e,t)=>{t&&(Ka(e,t.parent),e.set(t.key,t.value))},qa=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return Ka(t,e.overlay),e._flat=t},Ja=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),Za(n)},Ya=Symbol(),Xa=(e,t)=>{let n=e;for(let e=n.overlay;e;e=e.parent)if(e.key===t)return e.value;let r=n.base.get(t);return r===void 0&&!n.base.has(t)?Ya:(n.overlay&&++n.baseHits>=n.base.size&&n.baseHits>=Wa&&(n.base=qa(n),n.overlay=void 0,n.depth=0),r)},Za=e=>Ga(void 0,e,void 0,0),Qa={get mapUnsafe(){return qa(this)},...si,[Ha]:{_Services:e=>e},toJSON(){return{_id:`Context`,services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[T](e){if(!eo(e))return!1;let t=this.mapUnsafe,n=e.mapUnsafe;if(t.size!==n.size)return!1;for(let[e,r]of t)if(!n.has(e)||!mr(r,n.get(e)))return!1;return!0},[C](){return nr(this.mapUnsafe.size)}},$a=(e,t)=>e.cacheRoot===t.cacheRoot,eo=e=>S(e,Ha),to=e=>S(e,Ra),no=e=>!!e[Va],ro=()=>io,io=Za(new Map),ao=(e,t)=>Za(new Map([[e.key,t]])),oo=b(3,(e,t,n)=>so(e,t.key,n)),so=(e,t,n)=>{let r=e,i=Ba.has(t)?void 0:r.cacheRoot;if(r.depth>=Ua){let e=new Map(r.mapUnsafe);return e.set(t,n),Ga(i,e,void 0,0)}return Ga(i,r.base,{key:t,value:n,parent:r.overlay},r.depth+1)},co=b(2,(e,t)=>lo(e,t.key)),lo=(e,t)=>{let n=Xa(e,t);return n===Ya?void 0:n},uo=b(2,(e,t)=>{let n=Xa(e,t.key);if(n===Ya){if(no(t))return mo(t);throw ho(t)}return n}),fo=uo,po=`~effect/Context/defaultValue`,mo=e=>po in e?e[po]:e[po]=e.defaultValue(),ho=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:``}`);if(t.stack){let e=t.stack.split(`
6
- `);e.splice(1,3),t.stack=e.join(`
7
- `)}return t},go=b(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:Ja(e,e=>t.mapUnsafe.forEach((t,n)=>e.set(n,t)))),_o=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((e,n)=>{t.set(n,e)});return Za(t)},M=j,vo=e=>e.length>0,yo=ba,bo=va,xo=e=>{if(Hn(e))try{return yo(e())}catch(e){return bo(e)}try{return yo(e.try())}catch(t){return bo(e.catch(t))}},So=ha,Co=ga,wo=b(2,(e,{onFailure:t,onSuccess:n})=>So(e)?t(e.failure):n(e.success)),To=Zi,Eo=b(2,(e,t)=>Object.hasOwn(e,t)),Do=b(2,(e,t)=>{let n={...e};for(let r of Oo(e))Qr(n,r,t(e[r],r));return n}),Oo=e=>Object.keys(e),ko=e=>b(2,(t,n)=>{for(let r of Oo(t))if(!Eo(n,r)||!e(t[r],n[r]))return!1;return!0}),Ao=e=>{let t=ko(e);return(e,n)=>t(e,n)&&t(n,e)},jo=globalThis.Array,Mo=e=>jo.isArray(e)?e:jo.from(e),No=e=>jo.isArray(e)?e:[e],Po=b(2,(e,t)=>[...e,t]),Fo=b(2,(e,t)=>Mo(e).concat(Mo(t)));jo.isArray;var Io=vo,Lo=vo,Ro=(e,t)=>{let n=w(t),r=e.get(n);if(r===void 0)return e.set(n,[t]),!0;for(let e of r)if(mr(e,t))return!1;return r.push(t),!0},zo=()=>[],Bo=e=>[e],Vo=b(2,(e,t)=>e.map(t)),Ho=Qi,Uo=e=>{let t=Mo(e);if(t.length<2)return[...t];let n=new Map,r=[];for(let e of t)Ro(n,e)&&r.push(e);return r},Wo=`~effect/Duration`,Go=BigInt(0),Ko=BigInt(1),qo=BigInt(2),Jo=BigInt(10),Yo=BigInt(1e3),Xo=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),Zo=e=>Xo(e*1e6),Qo=(e,t)=>{let n=e.indexOf(`.`);if(n===-1)return BigInt(e)*t;let r=e[0]===`-`,i=e.slice(n+1),a=Jo**BigInt(i.length),o=(BigInt(e.slice(+!!r,n))*a+BigInt(i))*t,s=o/a+(o%a*qo>=a?Ko:Go);return r?-s:s},$o=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,es=e=>{switch(typeof e){case`number`:return fs(e);case`bigint`:return ds(e);case`string`:{if(e===`Infinity`)return ls;if(e===`-Infinity`)return us;let t=$o.exec(e);if(!t)break;let[n,r,i]=t;if(i===`nano`||i===`nanos`)return ds(Qo(r,Ko));if(i===`micro`||i===`micros`)return ds(Qo(r,Yo));let a=Number(r);switch(i){case`milli`:case`millis`:return fs(a);case`second`:case`seconds`:return ps(a);case`minute`:case`minutes`:return ms(a);case`hour`:case`hours`:return hs(a);case`day`:case`days`:return gs(a);case`week`:case`weeks`:return _s(a)}break}case`object`:{if(e===null)break;if(Wo in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(Rn)?ts(e):Number.isNaN(e[0])||Number.isNaN(e[1])?cs:e[0]===-1/0||e[1]===-1/0?us:e[0]===1/0||e[1]===1/0?ls:os(Xo(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?os(n):os(Xo(n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0)))}}return ts(e)},ts=e=>{throw Error(`Invalid Input: ${e}`)},ns={_tag:`Millis`,millis:0},rs={_tag:`Infinity`},is={_tag:`NegativeInfinity`},as={[Wo]:Wo,[C](){switch(this.value._tag){case`Millis`:{let e=this.value.millis*1e6;return Number.isFinite(e)?w(Xo(e)):nr(this.value.millis)}case`Nanos`:return w(this.value.nanos);default:return ar(this.value)}},[T](e){return ss(e)&&Cs(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`}}},[Ur](){return this.toJSON()},pipe(){return y(this,arguments)}},os=e=>{let t=Object.create(as);return t.value=typeof e==`number`?isNaN(e)||e===0||Object.is(e,-0)?ns:Number.isFinite(e)?Number.isInteger(e)?{_tag:`Millis`,millis:e}:{_tag:`Nanos`,nanos:Zo(e)}:e>0?rs:is:e===Go?ns:{_tag:`Nanos`,nanos:e},t},ss=e=>S(e,Wo),cs=os(0),ls=os(1/0),us=os(-1/0),ds=e=>os(e),fs=e=>os(e),ps=e=>os(e*1e3),ms=e=>os(e*6e4),hs=e=>os(e*36e5),gs=e=>os(e*864e5),_s=e=>os(e*6048e5),vs=e=>bs(es(e),{onMillis:x,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),ys=e=>{let t=es(e);switch(t.value._tag){case`Infinity`:case`NegativeInfinity`:throw Error(`Cannot convert infinite duration to nanos`);case`Nanos`:return t.value.nanos;case`Millis`:return Zo(t.value.millis)}},bs=b(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)()}}),xs=b(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(ys(e),t.value.nanos):n.onNanos(e.value.nanos,ys(t))),Ss=(e,t)=>xs(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),Cs=b(2,(e,t)=>Ss(e,t)),ws=M(`effect/Scheduler`,{fiberCached:!0,defaultValue:()=>new ks}),Ts=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},Es=`setImmediate`in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},Ds=e=>{try{return Es(e)}catch{return Ts(e)}},Os=class{buckets=[];scheduleTask(e,t){let n=this.buckets,r=n.length,i,a=0;for(;a<r&&!(n[a][0]>t);a++)i=n[a];i&&i[0]===t?i[1].push(e):a===r?n.push([t,[e]]):n.splice(a,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}},ks=class{executionMode;setImmediate;constructor(e=`async`,t){this.executionMode=e,this.setImmediate=t??(e===`sync`?Ts:Ds)}shouldYield(e){return e.currentOpCount>=e.cache.maxOpsBeforeYield}makeDispatcher(){return new As(this.setImmediate)}},As=class{tasks=new Os;running=void 0;setImmediate;constructor(e=Ds){this.setImmediate=e}scheduleTask(e,t){this.tasks.scheduleTask(e,t),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let n=e[t][1];for(let e=0;e<n.length;e++)n[e]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}},js=M(`effect/Scheduler/MaxOpsBeforeYield`,{fiberCached:!0,defaultValue:()=>2048}),Ms=M(`effect/Scheduler/PreventSchedulerYield`,{fiberCached:!0,defaultValue:()=>!1}),Ns=class extends wn{constructor(e){super(),e&&$r(this,e)}},Ps=e=>class extends Ns{_tag=e},Fs=Bi,Is=`~effect/encoding/EncodingError`,Ls=class extends Fs(`EncodingError`){[Is]=Is},Rs=e=>{switch(e){case 16:return Vs();case 32:return Hs();default:{let t=``;for(let n=e>>>3;n>0;n--)t+=Bs();return t}}},N=Uint8Array.from(`0123456789abcdef`,e=>e.charCodeAt(0)),zs=()=>Math.random()*4294967296>>>0,Bs=()=>{let e=zs();return String.fromCharCode(N[e>>>28],N[e>>>24&15],N[e>>>20&15],N[e>>>16&15],N[e>>>12&15],N[e>>>8&15],N[e>>>4&15],N[e&15])},Vs=()=>{let e=zs(),t=zs();return String.fromCharCode(N[e>>>28],N[e>>>24&15],N[e>>>20&15],N[e>>>16&15],N[e>>>12&15],N[e>>>8&15],N[e>>>4&15],N[e&15],N[t>>>28],N[t>>>24&15],N[t>>>20&15],N[t>>>16&15],N[t>>>12&15],N[t>>>8&15],N[t>>>4&15],N[t&15])},Hs=()=>{let e=zs(),t=zs(),n=zs(),r=zs();return String.fromCharCode(N[e>>>28],N[e>>>24&15],N[e>>>20&15],N[e>>>16&15],N[e>>>12&15],N[e>>>8&15],N[e>>>4&15],N[e&15],N[t>>>28],N[t>>>24&15],N[t>>>20&15],N[t>>>16&15],N[t>>>12&15],N[t>>>8&15],N[t>>>4&15],N[t&15],N[n>>>28],N[n>>>24&15],N[n>>>20&15],N[n>>>16&15],N[n>>>12&15],N[n>>>8&15],N[n>>>4&15],N[n&15],N[r>>>28],N[r>>>24&15],N[r>>>20&15],N[r>>>16&15],N[r>>>12&15],N[r>>>8&15],N[r>>>4&15],N[r&15])},Us=`effect/Tracer/ParentSpan`,Ws=class extends j()(Us,{fiberCached:!0}){},Gs=e=>e,Ks=M(`effect/Tracer/DisablePropagation`,{defaultValue:Dn}),qs=M(`effect/Tracer/CurrentTraceLevel`,{defaultValue:()=>`Info`}),Js=M(`effect/Tracer/MinimumTraceLevel`,{defaultValue:()=>`All`}),Ys=`effect/Tracer`,Xs=Gs({span:e=>new Zs(e)}),Zs=class{_tag=`Span`;sampled;name;parent;annotations;links;startTime;kind;status;_traceId=void 0;_spanId=void 0;_attributes=void 0;_events=void 0;constructor(e){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.startTime=e.startTime,this.kind=e.kind,this.sampled=e.sampled,this.status={_tag:`Started`,startTime:e.startTime}}get traceId(){return this._traceId??=Ia(this.parent)?.traceId??Rs(32)}get spanId(){return this._spanId??=Rs(16)}get attributes(){return this._attributes??=new Map}get events(){return this._events??=[]}end(e,t){this.status={_tag:`Ended`,endTime:e,exit:t,startTime:this.status.startTime}}attribute(e,t){this.attributes.set(e,t)}event(e,t,n){this.events.push([e,t,n??{}])}addLinks(e){this.links.push(...e)}},Qs=`effect/Metric/FiberRuntimeMetrics`,$s=M(`effect/References/CurrentStackFrame`,{fiberCached:!0,defaultValue:On}),ec=M(`effect/References/TracerEnabled`,{fiberCached:!0,defaultValue:En}),tc=M(`effect/References/TracerTimingEnabled`,{defaultValue:En}),nc=M(`effect/References/TracerSpanAnnotations`,{defaultValue:()=>({})}),rc=M(`effect/References/TracerSpanLinks`,{defaultValue:()=>[]}),ic=M(`effect/References/CurrentLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),ac=M(`effect/References/MinimumLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),oc=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!=`boolean`)return e;let t=Jr();if(t===0&&e?.captureStackTrace!==!0)return{...e,captureStackTrace:!1};Yr(3);let n=Error();return Yr(t),{...e,captureStackTrace:sc(()=>n.stack)}},sc=(e=>t=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let i=r.split(`
8
- `);if(i[e]!==void 0)return n=i[e].trim(),n}})(3),cc=class extends _i{constructor(e,t=vi){super(`Interrupt`,t,`Interrupted`),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:`Interrupt`,fiberId:this.fiberId}}[T](e){return Di(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[C](){return $n(rr(`${this._tag}:${this.fiberId}`))(Zn(this.annotations))}},lc=e=>new cc(e),uc=e=>new hi([new cc(e)]),dc=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag===`Fail`)return yo(n.error)}return bo(e)},fc=e=>e.reasons.some(Di),pc=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?yo(t):bo(e)},mc=(e,t)=>{let n=new Map,r=[];for(let i of e.concat(t)){let e=w(i),t=n.get(e);if(t===void 0)n.set(e,[i]);else if(t.some(e=>mr(e,i)))continue;else t.push(i);r.push(i)}return r},hc=b(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new hi(mc(e.reasons,t.reasons));return mr(e,n)?e:n}),gc=b(2,(e,t)=>{let n=!1,r=e.reasons.map(e=>Ti(e)?(n=!0,new yi(t(e.error),e.annotations)):e);return n?bi(r):e}),_c=e=>{let t;for(let n of e.reasons){if(n._tag===`Fail`)return n.error;n._tag===`Die`&&(t??=n)}return t===void 0?e.reasons.length>0?new globalThis.Error(`All fibers interrupted without error`):new globalThis.Error(`Empty cause`):t.defect},vc=`~effect/Fiber`,yc={_A:x,_E:x},bc={id:0},xc=()=>globalThis[Nr],Sc=class{constructor(e,t=!0){this.setContext(e),this.id=++bc.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[vc](){return yc}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return fo(this.context,e)}addObserver(e){return this._exit?(e(this._exit),kn):(this._observers===void 0?this._observers=[e]:this._observers.push(e),()=>this.removeObserver(e))}removeObserver(e){if(this._exit||this._observers===void 0)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)}interruptUnsafe(e,t){if(this._exit)return;let n=uc(e);this.cache.stackFrame&&(n=wi(n,ao(Ni,this.cache.stackFrame))),t&&(n=wi(n,t)),this._interruptedCause=this._interruptedCause?hc(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(Nc(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===oi)return;let n=Ec.interruptChildren&&Ec.interruptChildren(this);if(n!==void 0)return this.evaluate(ml(n,()=>t));if(this._exit=t,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&=(this._parent._children?.delete(this),void 0),this._observers!==void 0){let e=this._observers;this._observers=void 0;for(let n=0;n<e.length;n++)e[n](t)}this._stack.length=0,this._children=void 0,this.context=ro()}runLoop(e){let t=globalThis[Nr];globalThis[Nr]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;){this._deferredInterrupt&&(this._deferredInterrupt=!1,i=Nc(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!r&&!e.preventYield&&e.scheduler.shouldYield(this)){r=!0;let e=i;i=ml(Lc,()=>e)}if(i=e.tracerContext?e.tracerContext(i,this):i[O](this),i===oi){let e=this._yielded;if(ti in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return oi}}}catch(e){return S(i,O)?this.runLoop(Li(e)):Li(`Fiber.runLoop: Not a valid effect: ${String(i)}`)}finally{this._running=n,globalThis[Nr]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,wc;for(;;){let t=this._stack.pop();if(!t)return;let n=t[ai];if(n!==void 0){let r=n.call(t,this);if(r)return r[e]=r,r}if(t[e])return t}}succeedWith(e){if(!(++this.currentOpCount&Tc-1))return Mi(e);let t=this.getCont(k);return t?t[k](e,this):this.yieldWith(Mi(e))}yieldWith(e){return this._yielded=e,oi}children(){return this._children??=new Set}pipe(){return y(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&$a(t,e))return;let n=e.cacheRoot,r=n._fiberCache??=Cc(e);this.cache?.scheduler!==r.scheduler&&(this._dispatcher=void 0),this.cache=r}get currentSpanLocal(){let e=this.cache.span;return e?._tag===`Span`?e:void 0}},Cc=e=>{let t=lo(e,Ys);return{scheduler:fo(e,ws),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:fo(e,ec),span:lo(e,Us),logLevel:fo(e,ic),minimumLogLevel:fo(e,ac),stackFrame:fo(e,$s),runtimeMetrics:lo(e,Qs),maxOpsBeforeYield:fo(e,js),preventYield:fo(e,Ms)}},wc={[k](e,t){return Nc(t._interruptedCause)},[ii](e,t){return Nc(t._interruptedCause)}},Tc=32,Ec={interruptChildren:void 0},Dc=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(Pi.key,e.cache.stackFrame),Za(t)},Oc=e=>{let t=e;return t._exit?P(t._exit):Kc(n=>t._exit?n(P(t._exit)):Fc(e.addObserver(e=>n(P(e)))))},kc=e=>Kc(t=>{let n=e[Symbol.iterator](),r=[],i;function a(){let e=n.next();for(;!e.done;){if(e.value._exit){r.push(e.value._exit),e=n.next();continue}i=e.value.addObserver(e=>{r.push(e),a()});return}t(P(r))}return a(),Fc(()=>i?.())}),Ac=e=>A(t=>jc(e,t.id)),jc=b(e=>S(e[0],vc),(e,t,n)=>A(r=>{let i=Dc(r);return i=i&&n?go(i,n):i??n,e.interruptUnsafe(t,i),pl(Oc(e))})),Mc=e=>A(t=>{let n=Dc(t),r=zo();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return pl(kc(r))}),P=Mi,Nc=Fi,Pc=Ii,Fc=Ai({op:`Sync`,[O](e){let t=this[D](),n=e.getCont(k);return n?n[k](t,e):e.yieldWith(Mi(t))}}),F=Ai({op:`Suspend`,[O](e){return this[D]()}}),Ic=wo({onFailure:Pc,onSuccess:P}),Lc=Ai({op:`Yield`,[O](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(Sl)},this[D]??0),e.yieldWith(()=>{t=!0})}})(0),Rc=e=>F(()=>Nc(e())),zc=e=>Li(e),Bc=e=>F(()=>Pc(e())),I=P(void 0),Vc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Td(e,`An error occurred in Effect.try`):e.catch;return F(()=>{try{return P(t())}catch(e){return Pc(n(e))}})},Hc=e=>Wc(function(t,n){e(n).then(e=>t(P(e)),e=>t(zc(e)))},e.length!==0),Uc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Td(e,`An error occurred in Effect.tryPromise`):e.catch;return Wc(function(e,r){let i=t=>{try{e(Pc(Zr(()=>n(t))))}catch(t){e(zc(t))}};try{t(r).then(t=>e(P(t)),i)}catch(e){i(e)}},t.length!==0)},Wc=function(){let e=ki({op:`Async`,[O](e){let t=!1,n=!1,r=this.withSignal?new AbortController:void 0,i=this.register.call(e.cache.scheduler,r=>{t||(t=!0,n?e.evaluate(r):n=r)},r?.signal);return n===!1?(n=!0,e._yielded=()=>{t=!0},r===void 0&&i===void 0||e._stack.push(Gc(()=>(t=!0,r?.abort(),i??Sl))),oi):n}}),t=function(e,t){this.register=e,this.withSignal=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),Gc=Ai({op:`AsyncFinalizer`,[ai](e){e.interruptible&&(e.interruptible=!1,e._stack.push(ju))},[ii](e,t){return fc(e)?ml(cu(Fi(e),this[D]()),()=>Nc(e)):Nc(e)}}),Kc=e=>Wc(e,e.length>=2),qc=Kc(kn),Jc=(...e)=>{if(e.length===1){let t=e[0];return F(()=>$c(t()))}let[t,n]=e;return F(()=>$c(n.call(t.self)))},Yc=(e,...t)=>{let n=t.length===0?function(){return F(()=>$c(e.apply(this,arguments)))}:function(){let n=F(()=>$c(e.apply(this,arguments)));for(let e=0;e<t.length;e++)n=t[e](n,...arguments);return n};return Xc(e.length,n)},Xc=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),Zc=(e,...t)=>Xc(e.length,t.length===0?function(){return Qc(()=>e.apply(this,arguments))}:function(){let n=Qc(()=>e.apply(this,arguments));for(let e of t)n=e(n,...arguments);return n}),Qc=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return P(r.value);let i=r.value;if(i&&i._tag===`Success`){n=i.value;continue}if(i&&i._tag===`Failure`)return r.value;{let n=!0;return F(()=>n?(n=!1,ml(r.value,e=>$c(t,e))):F(()=>$c(e())))}}}catch(e){return zc(e)}},$c=function(){let e=ki({op:`Iterator`,[k](e,t){let n=this.iterator;for(;;){let r=n.next(e);if(r.done)return P(r.value);if(!L(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[O](e){return this[k](this.initial,e)}}),t=function(e,t){this.iterator=e,this.initial=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),el=b(2,(e,t)=>new rl(e,il,P(t))),tl=function(e){return e._stack.push(this),this[D]},nl=ki({op:`OnSuccess`,[O]:tl}),rl=function(e,t,n){this[D]=e,this[k]=t,this.payload=n};rl.prototype=nl;var il=function(){return this.payload},al=function(e,t){return t.succeedWith(this.payload)},ol=(()=>{let e=`~effect/Effect/stackProbe`;return{[e]:function(){return Error().stack}}[e]()?.includes(`[as `+e+`]`)===!0})(),sl=function(e,t){let n=this.payload;return t.succeedWith(ol?n(e):Zr(()=>n(e)))},cl=function(e){let t=this.payload;return t(e)},ll=function(e){let t=this.payload;return new rl(t(e),al,e)},ul=function(e){return new rl(this.payload,al,e)},dl=b(2,(e,t)=>new rl(e,li(t)?il:cl,t)),fl=b(2,(e,t)=>new rl(e,li(t)?ul:ll,t)),pl=e=>new rl(e,il,Sl),ml=b(2,(e,t)=>new rl(e,cl,t)),L=e=>e[ti]!==void 0,hl=b(2,(e,t)=>L(e)?e._tag===`Success`?t(e.value):e:ml(e,t)),gl=b(2,(e,t)=>new rl(e,sl,t)),_l=b(2,(e,t)=>L(e)?Cl(e,t):gl(e,t)),vl=b(2,(e,t)=>L(e)?wl(e,t):Ul(e,t)),yl=b(2,(e,t)=>L(e)?Tl(e,t):Wl(e,t)),bl=e=>e._tag===`Success`,xl=e=>e._tag===`Failure`?yo(e.cause):bo(e),Sl=Mi(void 0),Cl=b(2,(e,t)=>e._tag===`Success`?Mi(t(e.value)):e),wl=b(2,(e,t)=>{if(e._tag===`Success`)return e;let n=dc(e.cause);return So(n)?e:Ii(t(n.success))}),Tl=b(2,(e,t)=>{if(e._tag===`Success`)return Mi(t.onSuccess(e.value));let n=dc(e.cause);return So(n)?e:Ii(t.onFailure(n.success))}),El=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?Sl:Fi(bi(t))},Dl=b(2,(e,t)=>A(n=>{let r=n.context,i=t(r);return r===i?e:(n.setContext(i),Su(n,()=>{n.setContext(r)}),e)})),Ol=b(3,(e,t,n)=>Dl(e,e=>{let r=uo(e,t),i=n(r);return r===i?e:oo(e,t,i)})),kl=()=>Al,Al=A(e=>P(e.context)),jl=e=>A(t=>e(t.context)),Ml=b(2,(e,t)=>L(e)?e:Dl(e,go(t))),Nl=function(){return arguments.length===1?b(2,(e,t)=>Pl(e,arguments[0],t)):b(3,(e,t,n)=>Pl(e,t,n)).apply(this,arguments)},Pl=(e,t,n)=>Dl(e,oo(t,n)),Fl=b(e=>li(e[0]),(e,t)=>Ru({while:En,body:Tn(t?.disableYield?e:ml(e,e=>Lc)),step:kn})),Il=b(2,(e,t)=>new Rl(e,t.length===1?t:e=>t(e))),Ll=ki({op:`OnFailure`,[O]:tl}),Rl=function(e,t){this[D]=e,this[ii]=t};Rl.prototype=Ll;var zl=b(3,(e,t,n)=>Il(e,e=>{let r=t(e);return So(r)?Nc(r.failure):n(r.success,e)})),Bl=b(2,(e,t)=>zl(e,dc,e=>t(e))),Vl=b(e=>li(e[0]),(e,t,n,r)=>Il(e,e=>{let i=dc(e);return So(i)?Nc(i.failure):t(i.success)?n(i.success):r?r(i.success):Nc(e)})),Hl=b(e=>li(e[0]),(e,t,n,r)=>Vl(e,Array.isArray(t)?e=>S(e,`_tag`)&&t.includes(e._tag):Jn(t),n,r)),Ul=b(2,(e,t)=>Bl(e,e=>Bc(()=>t(e)))),Wl=b(2,(e,t)=>Zl(e,{onFailure:e=>Bc(()=>t.onFailure(e)),onSuccess:e=>Fc(()=>t.onSuccess(e))})),Gl=e=>$l(e,{onFailure:bo,onSuccess:yo}),Kl=b(2,(e,t)=>new Jl(e,t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),t.onFailure.length===1?t.onFailure:e=>t.onFailure(e))),ql=ki({op:`OnSuccessAndFailure`,[O]:tl}),Jl=function(e,t,n){this[D]=e,this[k]=t,this[ii]=n};Jl.prototype=ql;var Yl=function(e,t){let n=this.payload;return t.succeedWith(ol?n.onSuccess(e):Zr(()=>n.onSuccess(e)))},Xl=((e,t)=>{let n=ki({op:e,[O]:tl,[k]:Yl,[ii]:t}),r=function(e,t){this[D]=e,this.payload=t};return r.prototype=n,r})(`Match`,function(e,t){let n=e.reasons.find(Ti);if(n===void 0)return Nc(e);let r=this.payload;return t.succeedWith(ol?r.onFailure(n.error):Zr(()=>r.onFailure(n.error)))}),Zl=b(2,(e,t)=>Kl(e,{onFailure:e=>{let n=e.reasons.find(Ti);return n?t.onFailure(n.error):Nc(e)},onSuccess:t.onSuccess})),Ql=b(2,(e,t)=>new Xl(e,t)),$l=b(2,(e,t)=>{if(L(e)){if(e._tag===`Success`)return Mi(t.onSuccess(e.value));let n=dc(e.cause);return So(n)?e:Mi(t.onFailure(n.success))}return Ql(e,t)}),eu=e=>L(e)?Mi(e):tu(e),tu=Ai({op:`Exit`,[O](e){return e._stack.push(this),this[D]},[k](e,t,n){return t.succeedWith(n??Mi(e))},[ii](e,t,n){return t.succeedWith(n??Fi(e))}}),nu=`~effect/Scope`,ru=`~effect/Scope/Closeable`,iu=j(`effect/Scope`),au=(e,t)=>A(n=>{let r=ou(e,t);return r===void 0?I:(Pu(n),r)}),ou=(e,t)=>{let n=e.state;if(n._tag===`Closed`||(e.state={_tag:`Closed`,exit:t},e.parent!==void 0&&mu(e.parent,e),n._tag===`Empty`))return;if(n.finalizer!==void 0)return su(n.finalizer,t);let r=n.finalizers;return r.size===1?su(r.values().next().value,t):lu(e,r,t)},su=(e,t)=>{try{return e(t)}catch(e){return Li(e)}},cu=(e,t)=>bl(e)?t:Il(t,t=>Nc(hc(e.cause,t))),lu=Yc(function*(e,t,n){let r=[],i=[],a=Array.from(t.values()),o=xc();for(let t=a.length-1;t>=0;t--){let s=a[t];e.strategy===`sequential`?r.push(yield*eu(su(s,n))):i.push(Ku(o,su(s,n),!0,!0,`inherit`))}return i.length>0&&(r=yield*kc(i)),yield*El(r)}),uu=(e,t)=>{let n=gu(t,e);return e.state._tag===`Closed`?(n.state=e.state,n):(pu(e,n,e=>au(n,e)),n)},du=(e,t)=>F(()=>e.state._tag===`Closed`?t(e.state.exit):(pu(e,{},t),I)),fu=(e,t)=>du(e,Tn(t)),pu=(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.set(t,n):(r.finalizers=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0,r.finalizers.set(t,n))}},mu=(e,t)=>{if(e.state._tag!==`Open`)return;let n=e.state;n.finalizerKey===t?e.state=_u:n.finalizers!==void 0&&(n.finalizers.delete(t),n.finalizers.size===0&&(e.state=_u))},hu=e=>gu(e,void 0),gu=(e=`sequential`,t)=>({[ru]:ru,[nu]:nu,strategy:e,parent:t,state:_u}),_u={_tag:`Empty`},vu=Nl(iu),yu=e=>F(()=>{let t=hu();return Cu(e(t),e=>F(()=>ou(t,e)??I))}),bu=function(){let e=ki({op:`OnExit`,[O](e){return e._stack.push(this),this.effect},[ai](e){e.interruptible&&this.interruptible!==!0&&(e._stack.push(ju),e.interruptible=!1)},[k](e,t,n){n??=Mi(e);let r;try{r=this.onExit(n)}catch(e){r=Li(e)}return r?ml(r,e=>n):n},[ii](e,t,n){n??=Fi(e);let r;try{r=this.onExit(n)}catch(e){r=Li(e)}return r?ml(cu(n,r),e=>n):n}}),t=function(e,t,n){this.effect=e,this.onExit=t,this.interruptible=n};return t.prototype=e,t}(),xu=(e,t,n)=>new bu(e,t,n),Su=(e,t)=>{e._stack.push(new bu(void 0,t,void 0))},Cu=b(2,xu),wu=b(3,(e,t,n)=>Cu(e,e=>{let r=t(e);return So(r)?I:n(r.success,e)})),Tu=b(2,(e,t)=>wu(e,xl,t)),Eu=b(3,(e,t,n)=>Cu(e,e=>{if(e._tag!==`Failure`)return I;let r=t(e.cause);return So(r)?I:n(r.success,e.cause)})),Du=b(2,(e,t)=>Eu(pc,t)(e)),Ou=e=>Fc(()=>{let t=rd(!1),n=!1,r,i=ml(t.await,()=>r);return A(a=>r===void 0?n?i:(n=!0,Su(a,e=>Fc(()=>{r=e,t.openUnsafe()})),e):r)}),ku=e=>A(t=>t.interruptible?(t.interruptible=!1,t._stack.push(ju),e):e),Au=Ai({op:`SetInterruptible`,[ai](e){if(e.interruptible=this[D],e._interruptedCause&&e.interruptible)return()=>Nc(e._interruptedCause)}}),ju=Au(!0),Mu=Au(!1),Nu=e=>{if(e.interruptible=!0,e._stack.push(Mu),e._interruptedCause)return Nc(e._interruptedCause)},Pu=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(ju))},Fu=e=>A(t=>t.interruptible?e:Nu(t)??e),Iu=e=>A(t=>t.interruptible?(t.interruptible=!1,t._stack.push(ju),e(Fu)):e(x)),Lu=(e,t)=>Xn(e)?t?.mode===`result`?zu(e,Gl,t):zu(e,x,t):t?.discard?t.mode===`result`?zu(Object.values(e),Gl,t):zu(Object.values(e),x,t):F(()=>{let n={};return el(zu(Object.entries(e),([e,r])=>gl(t?.mode===`result`?Gl(r):r,t=>{Qr(n,e,t)}),{discard:!0,concurrency:t?.concurrency}),n)}),Ru=Ai({op:`While`,[k](e,t){return this[D].step(e),this[D].while()?(t._stack.push(this),this[D].body()):Sl},[O](e){return this[D].while()?(e._stack.push(this),this[D].body()):Sl}}),zu=b(e=>typeof e[1]==`function`,(e,t,n)=>F(()=>{let r=Vu(n?.concurrency);if(r===1)return Bu(e,t,n);let i=Mo(e),a=i.length;if(a===0)return n?.discard?I:P([]);let o=n?.discard?void 0:Array(a),s=Gu({f:t,out:o},i,{concurrency:r});return s?el(s,o):P(o)})),Bu=(e,t,n)=>F(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return el(Ru({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),Vu=e=>e===`unbounded`?1/0:Math.max(1,e??1),Hu=()=>e=>{let t=e.onItem,n=e.step,r=(e,t,r,a,o)=>ml(eu(o),o=>n(e,t[r],o,r)??i(e,t,r+1,a)??I),i=(e,i,a=0,o=i.length)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!L(c))return r(e,i,a,o,c);let l=n(e,s,c,a);if(l)return l._tag===`Failure`?l:void 0}};return i},Uu=e=>{let t=e.onItem,n=e.step;return(e,r,i)=>{let a=0,o=i.end??r.length,s=i.concurrency,c=!1,l,u,d,f,p,m=e=>{let t=Li(e);return f=t,c=!0,u&&u.size>0?ml(ku(Mc(Array.from(u))),()=>f??t):t},h=()=>{let i=!1;for(;!f&&a<o;a++){let o=r[a],ee=p??t(e,o,a);if(L(ee)){if(f=n(e,o,ee,a),f)break}else if(l){p=void 0;let t=Ku(l,ee,!0,!0,`inherit`);if(t._exit){if(f=n(e,o,t._exit,a),f)break;continue}u.add(t);let r=a;if(t.addObserver(a=>{u.delete(t);try{if(f){if(a._tag===`Failure`){let e=a.cause.reasons.filter(e=>e._tag!==`Interrupt`);if(e.length>0){let t=bi(e);f=Fi(f._tag===`Failure`?hc(f.cause,t):t)}}}else{let t=n(e,o,a,r);t&&(f=t,h())}if(i){let e=h();e&&d(e)}else c&&u.size===0&&d(f??I)}catch(e){d(m(e))}}),u.size<s)continue;i=!0,a++;return}else return Kc(e=>{l=xc(),u=new Set,p=ee,d=e;let t;try{t=h()}catch(t){return e(m(t))}return t?e(t):F(()=>(f??=Sl,ml(u?Mc(u):I,()=>f?._tag===`Failure`?f:I)))})}if(c=!0,f){if(u&&u.size>0){let e=Dc(l);u.forEach(t=>t.interruptUnsafe(l.id,e));return}if(d||f._tag===`Failure`)return f}else if(d){if(u)u.size===0&&d(I);else return Sl}};return h()}},Wu=()=>e=>Uu(e),Gu=Uu({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)}}),Ku=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new Sc(a.context,o);return n?s.evaluate(t):a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0),!r&&!s._exit&&(a.children().add(s),s._parent=a),s},qu=e=>(t,n)=>{let r=new Sc(n?.scheduler?oo(e,ws,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal){if(n.signal.aborted)r.interruptUnsafe();else{let e=()=>r.interruptUnsafe();n.signal.addEventListener(`abort`,e,{once:!0}),r.addObserver(()=>n.signal.removeEventListener(`abort`,e))}}return n?.onFiberStart&&n.onFiberStart(r),r},Ju=qu(ro()),Yu=e=>{let t=qu(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},Xu=(e=>{let t=Yu(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw _c(e.cause);return e.value})})(ro()),Zu=e=>{let t=qu(e);return e=>{if(L(e))return e;let n=new ks(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??Li(new Cd(r))}},Qu=Zu(ro()),$u=(e=>{let t=Zu(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw _c(n.cause);return n.value}})(ro()),ed=P(!0),td=P(!1),nd=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return ed;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let e=0;e<this.waiters.length;e++)this.scheduled.push(this.waiters[e]);return this.waiters=[],ed}flushScheduled=()=>{if(this.scheduled===void 0)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](Sl)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](Sl)}open=A(e=>this._isOpen?td:(this._isOpen=!0,this.scheduleUnsafe(e)));release=A(e=>this._isOpen?td:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=Kc(e=>this._isOpen?e(I):(this.waiters.push(e),Fc(()=>{let t=this.waiters.indexOf(e);t===-1?this.scheduled!==void 0&&(t=this.scheduled.indexOf(e),t!==-1&&this.scheduled.splice(t,1)):this.waiters.splice(t,1)})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=Fc(()=>this.closeUnsafe());whenOpen=e=>ml(this.await,()=>e);isOpen(){return this._isOpen}},rd=e=>new nd(e??!1),id=BigInt(0),ad={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:id,endTime:id,exit:Sl},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},od=e=>Object.assign(Object.create(ad),e),sd=e=>e?fo(e.annotations,Ks)?e._tag===`Span`?sd(Ia(e.parent)):ka():Aa(e):ka(),cd=(e,t,n)=>{let r=!e.cache.tracerEnabled||n?.annotations&&fo(n.annotations,Ks),i=n?.parent===void 0?n?.root?ka():sd(e.cache.span):Aa(n.parent),a;if(r)a=od({name:t,parent:i,annotations:oo(n?.annotations??ro(),Ks,!0)});else{let r=e.cache.tracer??Xs,o=e.getRef(md),s=e.getRef(tc),c=e.getRef(nc),l=e.getRef(rc),u=n?.level??e.getRef(qs),d=n?.links===void 0?l.length===0?[]:l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??ro(),links:d,startTime:s?o.currentTimeNanosUnsafe():id,kind:n?.kind??`internal`,root:n?.root??ja(i),sampled:n?.sampled??(Ma(i)&&i.value.sampled===!1?!1:!Ed(e.getRef(Js),u))});for(let e in c)a.attribute(e,c[e]);if(n?.attributes!==void 0)for(let e in n.attributes)a.attribute(e,n.attributes[e])}return a},ld=(e,t)=>(t=typeof t==`function`?t:On,Ol($s,n=>({name:e,stack:t,parent:n}))),ud=(e,t,n,r)=>Fc(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():id,t)}),dd=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return A(t=>{let i=cd(t,e,n),a=t.getRef(md),o=t.getRef(tc);return Su(t,e=>ud(i,e,a,o)),r(i)})},fd=Nl(Ws),pd=function(){let e=li(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=x;return t._tag===`Span`&&(n=oc(n),r=ld(t.name,n?.captureStackTrace)),e?fd(r(arguments[0]),t):e=>fd(r(e),t)},md=M(`effect/Clock`,{defaultValue:()=>new gd}),hd=2**31-1,gd=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=Fc(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return yd()}currentTimeNanos=Fc(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return vd()}monotonicTimeNanos=Fc(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(vs(e))}sleepMillis(e){return e<=0?Lc:Number.isFinite(e)?Kc(t=>{let n=e>hd?this.sleepMillis(e-hd):I,r=setTimeout(()=>t(n),Math.min(e,hd));return Fc(()=>clearTimeout(r))}):qc}},_d=BigInt(1e6),vd=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==`function`)return()=>e.bigint();if(typeof performance<`u`&&typeof performance.now==`function`)return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*_d;return e>t&&(t=e),t}}(),yd=function(){let e=BigInt(1e9),t;return()=>{let n=vd(),r=BigInt(Date.now())*_d;if(t===void 0)t=r-n;else{let i=t+n;(r>i?r-i:i-r)>e&&(t=r-n)}return t+n}}(),bd=`~effect/Cause/IllegalArgumentError`,xd=class extends Bi(`IllegalArgumentError`){[bd]=bd;constructor(e){super({message:e})}},Sd=`~effect/Cause/AsyncFiberError`,Cd=class extends Bi(`AsyncFiberError`){[Sd]=Sd;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},wd=`~effect/Cause/UnknownError`,Td=class extends Bi(`UnknownError`){[wd]=wd;constructor(e,t){super({message:t,cause:e})}},Ed=Ea(wa(Ca,e=>{switch(e){case`All`:return-(2**53-1);case`Fatal`:return 5e4;case`Error`:return 4e4;case`Warn`:return 3e4;case`Info`:return 2e4;case`Debug`:return 1e4;case`Trace`:return 0;case`None`:return 2**53-1}})),Dd={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};Dd.gray,Dd.blue,Dd.green,Dd.yellow,Dd.red,Dd.bgBrightRed,Dd.black;var Od=pi,kd=mi,Ad=Ti,jd=bi,Md=xi,Nd=Ci,Pd=e=>new yi(e),Fd=e=>new Si(e),Id=lc,Ld=gc,Rd=hc,zd=_c,Bd=fc,Vd=Hi,Hd=Ki,Ud=xd,Wd=Mi,Gd=Fi,Kd=Ii,qd=Sl,Jd=bl,Yd={"~effect/Deferred":{_A:x,_E:x},pipe(){return y(this,arguments)}},Xd=function(){this.resumes=void 0,this.effect=void 0};Xd.prototype=Yd;var Zd=()=>new Xd,Qd=e=>Kc(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),Fc(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),$d=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let e=0;e<n.length;e++)n[e](t)}return!0},ef=iu,tf=hu,nf=vu,rf=du,af=fu,of=uu,sf=au,cf=`~effect/Layer`,lf=`~effect/Layer/MemoMap`,uf=(e,t)=>{let n={observers:0,deferred:Zd(),scope:tf(),finalizer:r=>F(()=>--n.observers>0?I:(e.map.delete(t),sf(n.scope,r)))};return n},df=(e,t)=>t.state._tag!==`Closed`&&(e.observers++,pu(t,{},e.finalizer),!0),ff={[cf]:{_ROut:x,_E:x,_RIn:x},pipe(){return y(this,arguments)}},pf=e=>{let t=Object.create(ff);return t.build=e,t},mf=e=>pf((t,n)=>{let r=of(n);return Cu(e(t,r),e=>e._tag===`Failure`?sf(r,e):I)}),hf=e=>{let t=mf((n,r)=>n.getOrElseMemoize(t,r,e));return t},gf=class{get[lf](){return lf}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?(df(n,t),n.deferred.effect??Qd(n.deferred)):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return F(()=>{let r;return xu(F(()=>{let i=this.get(e,t);if(i)return i;let a=uf(this,e);return df(a,t)?(r=a.deferred,this.map.set(e,a),n(this,a.scope)):n(this,t)}),e=>{r&&$d(r,e)})})}},_f=()=>new gf,vf=e=>new gf(e),yf=class e extends j()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=co(t,e);return n?vf(n):_f()}},bf=b(3,(e,t,n)=>Nl(gl(e.build(t,n),oo(yf,t)),yf,t)),xf=b(2,(e,t)=>A(n=>bf(e,yf.forkOrCreate(n.context),t))),Sf=e=>pf(Tn(P(e))),Cf=function(){return arguments.length===1?e=>wf(arguments[0],e):wf(arguments[0],arguments[1])},wf=(e,t)=>Tf(gl(t,t=>ao(e,t))),Tf=e=>hf((t,n)=>nf(e,n)),Ef=e=>Tf(el(e,ro())),Df=(e,t,n)=>{let r=of(n,`parallel`);return zu(e,e=>e.build(t,of(r,`sequential`)),{concurrency:e.length}).pipe(gl(e=>_o(...e)))},Of=(...e)=>mf((t,n)=>Df(e,t,n)),kf=(e,t,n)=>mf((r,i)=>ml(Array.isArray(t)?Df(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(Ml(t),gl(e=>n(e,t))))),Af=b(2,(e,t)=>kf(e,t,x)),jf=b(2,(e,t)=>kf(e,t,(e,t)=>go(t,e))),Mf=`~effect/DateTime`,Nf=`~effect/DateTime/TimeZone`,Pf={[Mf]:Mf,pipe(){return y(this,arguments)},[Ur](){return this.toString()},toJSON(){return Kf(this).toJSON()}},Ff={...Pf,_tag:`Utc`,[C](){return nr(this.epochMilliseconds)},[T](e){return Lf(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Kf(this).toJSON()})`}};({...Pf});var If={[Nf]:Nf,[Ur](){return this.toString()}};({...If}),{...If};var Lf=e=>S(e,Mf),Rf=e=>Lf(e[0]),zf=e=>e._tag===`Utc`,Bf=e=>{let t=Object.create(Ff);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},Vf=e=>{let t=e.getTime();if(Number.isNaN(t))throw new Ud(`Invalid date`);return Bf(t)},Hf=e=>{if(Lf(e))return e;if(e instanceof Date)return Vf(e);if(typeof e==`object`){if(`epochMilliseconds`in e)return Vf(new Date(e.epochMilliseconds));let t=new Date(0);return qf(t,e),Vf(t)}return typeof e==`string`&&!Uf(e)?Vf(new Date(e+`Z`)):Vf(new Date(e))},Uf=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),Wf=La(Hf),Gf=e=>Bf(e.epochMilliseconds),Kf=e=>new Date(e.epochMilliseconds),qf=(e,t)=>{if((t.year!==void 0||t.month!==void 0||t.day!==void 0)&&e.setUTCFullYear(t.year??e.getUTCFullYear(),t.month===void 0?e.getUTCMonth():t.month-1,t.day??e.getUTCDate()),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)},Jf=b(Rf,(e,t)=>new Intl.DateTimeFormat(t?.locale,t).format(e.epochMilliseconds)),Yf=e=>Kf(e).toISOString(),Xf=b(2,(e,t)=>zl(e,$f,e=>t(e))),Zf=e=>e._tag===`Fail`&&Vd(e.error),Qf=e=>{let t,n=!1;for(let r of e.reasons)Zf(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?bo(e):n?bo(jd(e.reasons.filter(e=>!Zf(e)))):yo(t)},$f=e=>{let t=Qf(e);return So(t)?t:yo(t.success.value)},ep=e=>{let t=Qf(e);return So(t)?Gd(t.failure):Wd(t.success.value)},tp=(e,t,n)=>yu(r=>ml(n?.local?bf(t,_f(),r):xf(t,r),t=>Ml(e,t))),np=b(e=>li(e[0]),(e,t,n)=>eo(t)?Ml(e,t):tp(e,Array.isArray(t)?Of(...t):t,n)),rp=li,ip=Lu,ap=Hc,op=Uc,R=P,sp=F,cp=Fc,lp=I,up=Jc,z=Pc,dp=Nc,fp=Rc,pp=zc,mp=Vc,hp=A,gp=Ic,B=ml,_p=dl,vp=fl,yp=eu,bp=gl,xp=el,Sp=pl,Cp=Hl,wp=Il,Tp=Ul,Ep=Kl,Dp=kl,Op=jl,kp=np,Ap=Ml,jp=Dl,Mp=Nl,Np=Tu,Pp=Cu,Fp=Ou,Ip=Du,Lp=Iu,Rp=Fl,zp=dd,Bp=pd,Vp=Ju,Hp=Xu,Up=$u,Wp=Qu,Gp=Yc,Kp=_l,qp=vl,Jp=yl,Yp=hl,Xp=Zc,Zp=`~effect/BigDecimal`,Qp={[Zp]:Zp,[C](){let e=om(this);return $n(rr(String(e.value)),nr(e.scale))},[T](e){return $p(e)&&dm(this,e)===0},toString(){return`BigDecimal(${pm(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[Ur](){return this.toJSON()},pipe(){return y(this,arguments)}},$p=e=>S(e,Zp),em=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(Qp);return n.value=e,n.scale=t,n},tm=(e,t)=>{let n=em(e,t);return n.normalized=n,n},nm=BigInt(0),rm=BigInt(1),im=BigInt(10),am=tm(nm,0),om=e=>{if(e.normalized===void 0){if(e.value===nm)e.normalized=am;else{let t=`${e.value}`,n=t.length;for(;t[n-1]===`0`;)n--;e.normalized=tm(BigInt(t.slice(0,n)),e.scale-(t.length-n))}}return e.normalized},sm=100,cm=[rm],lm=(e,t)=>e===t?0:e<t?-1:1,um=(e,t)=>{let n=`${e.value<nm?-e.value:e.value}`,r=`${t.value<nm?-t.value:t.value}`,i=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==nm)return i<nm?-1:1;let a=Math.max(n.length,r.length);return Sa(n.padEnd(a,`0`),r.padEnd(a,`0`))},dm=(e,t)=>{if(e.scale===t.scale)return lm(e.value,t.value);let n=fm(e),r=fm(t);if(n!==r)return n<r?-1:1;if(n===0)return 0;let i=e.scale-t.scale,a=Math.abs(i);if(a>sm)return n===-1?um(t,e):um(e,t);let o=cm[a]??=im**BigInt(a);return i>0?lm(e.value,t.value*o):lm(e.value*o,t.value)},fm=e=>e.value===nm?0:e.value<nm?-1:1,pm=e=>{let t=om(e);if(Math.abs(t.scale)>=16)return mm(t);let n=t.value<nm,r=`${n?-t.value:t.value}`,i=t.scale>0?r.padStart(t.scale+1,`0`):r.padEnd(r.length-t.scale,`0`),a=i.length-t.scale,o=t.scale>0?`${i.slice(0,a)}.${i.slice(a)}`:i;return n?`-${o}`:o},mm=e=>{if(hm(e))return`0e+0`;let t=om(e),n=`${t.value}`,r=t.value<nm?2:1,i=n.slice(0,r),a=n.slice(r),o=a.length-t.scale;return`${i}${a===``?``:`.${a}`}e${o>=0?`+`:``}${o}`},hm=e=>e.value===nm,gm=BigInt(1),_m=BigInt(1e3),vm=BigInt(1024),ym=[{symbol:`B`,factor:gm,names:[`B`,`byte`,`bytes`]},{symbol:`kB`,factor:_m,names:[`kB`,`kilobyte`,`kilobytes`]},{symbol:`MB`,factor:_m**BigInt(2),names:[`MB`,`megabyte`,`megabytes`]},{symbol:`GB`,factor:_m**BigInt(3),names:[`GB`,`gigabyte`,`gigabytes`]},{symbol:`TB`,factor:_m**BigInt(4),names:[`TB`,`terabyte`,`terabytes`]},{symbol:`PB`,factor:_m**BigInt(5),names:[`PB`,`petabyte`,`petabytes`]},{symbol:`EB`,factor:_m**BigInt(6),names:[`EB`,`exabyte`,`exabytes`]},{symbol:`ZB`,factor:_m**BigInt(7),names:[`ZB`,`zettabyte`,`zettabytes`]},{symbol:`YB`,factor:_m**BigInt(8),names:[`YB`,`yottabyte`,`yottabytes`]},{symbol:`RB`,factor:_m**BigInt(9),names:[`RB`,`ronnabyte`,`ronnabytes`]},{symbol:`QB`,factor:_m**BigInt(10),names:[`QB`,`quettabyte`,`quettabytes`]}],bm=[ym[0],{symbol:`KiB`,factor:vm,names:[`KiB`,`kibibyte`,`kibibytes`]},{symbol:`MiB`,factor:vm**BigInt(2),names:[`MiB`,`mebibyte`,`mebibytes`]},{symbol:`GiB`,factor:vm**BigInt(3),names:[`GiB`,`gibibyte`,`gibibytes`]},{symbol:`TiB`,factor:vm**BigInt(4),names:[`TiB`,`tebibyte`,`tebibytes`]},{symbol:`PiB`,factor:vm**BigInt(5),names:[`PiB`,`pebibyte`,`pebibytes`]},{symbol:`EiB`,factor:vm**BigInt(6),names:[`EiB`,`exbibyte`,`exbibytes`]},{symbol:`ZiB`,factor:vm**BigInt(7),names:[`ZiB`,`zebibyte`,`zebibytes`]},{symbol:`YiB`,factor:vm**BigInt(8),names:[`YiB`,`yobibyte`,`yobibytes`]}];[...ym,...bm.slice(1)];var xm=Lf,Sm=zf,Cm=Vf,wm=Hf,Tm=Wf,Em=Gf,Dm=Jf,Om=Yf,km=e=>jm(typeof e==`string`?Mm.encode(e):e),Am=e=>{let t=Nm(e),n=t.length;if(n%4!=0)return bo(new Ls({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 bo(new Ls({kind:`Decode`,module:`Base64`,input:t,message:`Found a '=' character, but it is not at the end`}));try{let e=t.endsWith(`==`)?2:+!!t.endsWith(`=`),r=new Uint8Array(n/4*3-e);for(let e=0,i=0;e<n;e+=4,i+=3){let n=Im(t.charCodeAt(e))<<18|Im(t.charCodeAt(e+1))<<12|Im(t.charCodeAt(e+2))<<6|Im(t.charCodeAt(e+3));r[i]=n>>16,r[i+1]=n>>8&255,r[i+2]=n&255}return yo(r)}catch(e){return bo(new Ls({kind:`Decode`,module:`Base64`,input:t,message:e instanceof Error?e.message:`Invalid input`}))}},jm=e=>{let t=e.length,n=``,r=2;for(;r<t;r+=3)n+=Pm[e[r-2]>>2],n+=Pm[(e[r-2]&3)<<4|e[r-1]>>4],n+=Pm[(e[r-1]&15)<<2|e[r]>>6],n+=Pm[e[r]&63];return r===t+1&&(n+=Pm[e[r-2]>>2],n+=Pm[(e[r-2]&3)<<4],n+=`==`),r===t&&(n+=Pm[e[r-2]>>2],n+=Pm[(e[r-2]&3)<<4|e[r-1]>>4],n+=Pm[(e[r-1]&15)<<2],n+=`=`),n},Mm=new TextEncoder,Nm=e=>e.replace(/[\n\r]/g,``),Pm=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Fm=new Uint8Array(123).fill(255);for(let e=0;e<64;e++)Fm[Pm.charCodeAt(e)]=e;Fm[61]=0;var Im=e=>{if(e>=Fm.length||Fm[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return Fm[e]},Lm=`~effect/http/Cookies`,Rm=`~effect/http/Cookies/Cookie`,zm={[Lm]:Lm,...Gr,toJSON(){return{_id:`effect/Cookies`,cookies:Do(this.cookies,e=>e.toJSON())}},pipe(){return y(this,arguments)}},Bm=e=>{let t=Object.create(zm);return t.cookies=e,t},Vm=e=>{let t={};for(let n of e)Qr(t,n.name,n);return Bm(t)},Hm=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=Um(e.trim());t&&n.push(t)}return Vm(n)};function Um(e){let t=e.split(`;`).map(e=>e.trim()).filter(e=>e!==``);if(t.length===0)return;let n=t[0].indexOf(`=`);if(n===-1)return;let r=t[0].slice(0,n);if(!Wm.test(r))return;let i=t[0].slice(n+1),a=Km(i);if(t.length===1)return Object.assign(Object.create(Gm),{name:r,value:a,valueEncoded:i});let o={};for(let e=1;e<t.length;e++){let n=t[e],r=n.indexOf(`=`),i=r===-1?n:n.slice(0,r).trim(),a=r===-1?void 0:n.slice(r+1).trim();switch(i.toLowerCase()){case`domain`:{if(a===void 0)break;let e=a.trim().replace(/^\./,``);e&&(o.domain=e);break}case`expires`:{if(a===void 0)break;let e=new Date(a);isNaN(e.getTime())||(o.expires=e);break}case`max-age`:{if(a===void 0)break;let e=parseInt(a,10);isNaN(e)||(o.maxAge=ps(e));break}case`path`:if(a===void 0)break;a[0]===`/`&&(o.path=a);break;case`priority`:if(a===void 0)break;switch(a.toLowerCase()){case`low`:o.priority=`low`;break;case`medium`:o.priority=`medium`;break;case`high`:o.priority=`high`}break;case`httponly`:o.httpOnly=!0;break;case`secure`:o.secure=!0;break;case`partitioned`:o.partitioned=!0;break;case`samesite`:if(a===void 0)break;switch(a.toLowerCase()){case`lax`:o.sameSite=`lax`;break;case`strict`:o.sameSite=`strict`;break;case`none`:o.sameSite=`none`}}}return Object.assign(Object.create(Gm),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var Wm=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Gm={[Rm]:Rm,...Gr,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},Km=e=>{try{return decodeURIComponent(e)}catch{return e}},qm=new WeakMap,Jm=`~effect/Redacted`,Ym=e=>S(e,Jm),Xm=(e,t)=>{let n=Object.create(Zm);return t?.label&&(n.label=t.label),qm.set(n,e),n},Zm={[Jm]:{_A:e=>e},label:void 0,...si,toJSON(){return this.toString()},toString(){return`<redacted${Ln(this.label)?`:`+this.label:``}>`},[C](){return w(qm.get(this))},[T](e){return Ym(e)&&mr(qm.get(this),qm.get(e))}},Qm=Symbol.for(`~effect/http/Headers`),$m=Object.defineProperties(Object.create(null),{[Qm]:{value:Qm},[kr]:{value(e){return lh(this,fo(e,dh))}},toJSON:{value(){return jr(this)}},[T]:{value(e){return th(this,e)}},[C]:{value(){return ar(this)}},toString:{value:Gr.toString},[Ur]:{value:Gr[Ur]}}),eh=e=>Object.assign(Object.create($m),e),th=Ao(Xi()),nh=Object.create($m),rh=e=>{if(e===void 0)return nh;if(Symbol.iterator in e){let t=Object.create($m);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create($m);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},ih=e=>Object.setPrototypeOf(e,$m),ah=b(3,(e,t,n)=>{let r=eh(e);return r[t.toLowerCase()]=n,r}),oh=b(2,(e,t)=>eh({...e,...rh(t)})),sh=b(2,(e,t)=>{let n=eh(e);return Object.assign(n,t),n}),ch=b(2,(e,t)=>{let n=eh(e);return delete n[t.toLowerCase()],n}),lh=b(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=Xm(e[r]))}else for(let r in e)r.search(t)!==-1&&(n[r]=Xm(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),uh=(e,t)=>{for(let n=0;n<t.length;n++){let r=t[n];if(typeof r==`string`){if(r.toLowerCase()===e.toLowerCase())return!0}else if(e.search(r)!==-1)return!0}return!1},dh=M(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),fh=`~effect/http/UrlParams`,ph=e=>S(e,fh),mh={...si,[fh]:fh,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:`UrlParams`,params:Object.fromEntries(this.params)}},[T](e){return vh(this,e)},[C](){return sr(this.params.flat())}},hh=e=>{let t=Object.create(mh);return t.params=e,t},gh=e=>{if(ph(e))return e;let t=_h(e),n=[];for(let e=0;e<t.length;e++)if(Array.isArray(t[e][0])){let[r,i]=t[e];n.push([`${r[0]}[${r.slice(1).join(`][`)}]`,i])}else n.push(t[e]);return hh(n)},_h=e=>{let t=typeof e[Symbol.iterator]==`function`?Mo(e):Object.entries(e),n=[];for(let[e,r]of t)if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]!==void 0&&n.push([e,String(r[t])]);else if(typeof r==`object`&&r){let t=_h(r);for(let[r,i]of t)n.push([[e,...typeof r==`string`?[r]:r],i])}else r!==void 0&&n.push([e,String(r)]);return n},vh=Ji((e,t)=>yh(e.params,t.params)),yh=Ho(To([Xi(),Xi()])),bh=hh([]),xh=b(2,(e,t)=>hh(t(e.params))),Sh=b(2,(e,t)=>{let n=gh(t).params.slice(),r=new Set;for(let e=0;e<n.length;e++)r.add(n[e][0]);for(let t=0;t<e.params.length;t++)r.has(e.params[t][0])||n.push(e.params[t]);return hh(n)}),Ch=b(2,(e,t)=>xh(e,Fo(gh(t).params))),wh=e=>new URLSearchParams(gh(e).params).toString(),Th=e=>{let t={};for(let[n,r]of e.params)if(!Object.hasOwn(t,n))Qr(t,n,r);else{let e=t[n];typeof e==`string`?Qr(t,n,[e,r]):e.push(r)}return t};function Eh(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function Dh(e){return t=>Eh(t)?.[e]}var Oh=`~structural`,kh=`~sentinels`,Ah=`~constructor`,jh=An(e=>{let t=Eh(e)?.identifier;return typeof t==`string`?t:e.getExpected(jh)}),V=Symbol(),Mh=Wd,Nh=Mh(V),H=Mh(V),Ph=e=>e===V?ka():Aa(e),Fh=e=>e._tag===`None`?Nh:Mh(e.value),Ih=`~effect/SchemaIssue/Issue`;function Lh(e){return S(e,Ih)&&e[Ih]===Ih}function Rh(e){return Object.hasOwn(e,`input`)}var zh=class{[Ih]=Ih;constructor(e,t){t?.reportInput===!0&&e!==V&&(this.input=e)}},Bh=class extends zh{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},Vh=class extends zh{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},Hh=class extends zh{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},Uh=class extends zh{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},Wh=class extends zh{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},Gh=class extends zh{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},Kh=class extends zh{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},qh=class extends zh{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}};function Jh(e,t,n,r,i){return new Gh(e,[new Hh([t],n)],r,i)}var Yh=class extends zh{_tag=`Forbidden`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},Xh=class extends zh{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},Zh=class extends zh{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function Qh(e,t,n){if(Lh(e))return e;if(typeof e==`string`)return new qh({message:e},t,n);let r=typeof e.issue==`string`?new qh({message:e.issue},t,n):e.issue;return new Hh(e.path,r)}function $h(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new qh(void 0,t,n):Qh(e,t,n)}function eg(e,t,n,r){return Array.isArray(t)?Lo(t)?t.length===1?Qh(t[0],n,r):new Gh(e,Vo(t,e=>Qh(e,n,r)),n,r):void 0:$h(t,n,r)}var tg=e=>{let t=fg(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return og(jh(e.ast),e);case`InvalidValue`:{let t=ag(e);if(t!==void 0)return og(t,e);let n=ig(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=ig(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=ig(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},ng=e=>fg(e.issue)??fg(e);function rg(e){return t=>({issues:sg(t,[],e?.leafHook??tg,e?.checkHook??ng)})}function ig(e){return Rh(e)?E(e.input):void 0}function ag(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function og(e,t){let n=ig(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function sg(e,t,n,r){switch(e._tag){case`Filter`:{let i=r(e);if(i!==void 0)return[{path:t,message:i}];if(e.issue._tag!==`InvalidValue`)return sg(e.issue,t,n,r);let a=ag(e.issue);return[{path:t,message:a===void 0?og(cg(e.filter),e):og(a,e.issue)}]}case`Encoding`:return sg(e.issue,t,n,r);case`Pointer`:return sg(e.issue,[...t,...e.path],n,r);case`Composite`:return e.issues.flatMap(e=>sg(e,t,n,r));case`AnyOf`:return e.issues.length===0?[{path:t,message:fg(e)??og(jh(e.ast),e)}]:e.issues.flatMap(e=>sg(e,t,n,r));default:return[{path:t,message:n(e)}]}}function cg(e){let t=e.annotations?.expected;if(typeof t==`string`)return t;switch(e._tag){case`Filter`:return`<filter>`;case`FilterGroup`:return e.checks.map(e=>cg(e)).join(` & `)}}function lg(){return e=>dg(e,``)}var ug=lg();function dg(e,t){let n;switch(e._tag){case`Filter`:{let r=ng(e);if(r!==void 0)n=r;else{if(e.issue._tag!==`InvalidValue`)return dg(e.issue,t);let r=ag(e.issue);n=r===void 0?og(cg(e.filter),e):og(r,e.issue)}break}case`Encoding`:return dg(e.issue,t);case`Pointer`:return dg(e.issue,t+Rr(e.path));case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>dg(e,t)).join(`
9
- `);n=fg(e)??og(jh(e.ast),e);break;default:n=tg(e)}return t?`${n}\n at ${t}`:n}function fg(e){if(e._tag===`Pointer`)return;if(e._tag===`Encoding`)return fg(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function pg(e){let t;for(let n of e.reasons){if(!Ad(n)||!Lh(n.error))return;t??=n.error}return t}function mg(e,t){let n=pg(e);if(n===void 0)throw Error(t,{cause:e});return n}var hg=e=>Object.assign(Object.create(Cn),e);function gg(e){return Sg((t,n)=>z(e(t,n)))}function _g(e){return gg((t,n)=>{let r={message:e(t)};return Ma(t)?new Yh(r,t.value,n):new Yh(r)})}var vg=_g(()=>`Encoding is not supported`),yg=hg({_tag:`Passthrough`});function bg(){return yg}function U(e){return hg({_tag:`Transform`,transform:e})}function xg(e){return hg({_tag:`TransformEffect`,transform:e})}function Sg(e){return hg({_tag:`TransformOptionalEffect`,transform:e})}function Cg(){return U(globalThis.String)}function wg(){return U(globalThis.Number)}function Tg(e){return xg((t,n)=>mp({try:()=>JSON.parse(t,e?.reviver),catch:()=>new qh({expected:`a valid JSON string`},t,n)}))}function Eg(e){return xg((t,n)=>mp({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return n},catch:()=>new qh({expected:`a JSON-serializable value`},t,n)}))}function Dg(){return U(km)}function Og(){return xg((e,t)=>qp(gp(Am(e)),()=>new qh({expected:`a valid Base64 string`},e,t)))}var kg=class extends wn{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new kg(this.encode,this.decode)}},Ag=`~effect/SchemaTransformation/Transformation`,jg=class extends wn{[Ag]=Ag;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new jg(this.encode,this.decode)}};function Mg(e){return S(e,Ag)&&e[Ag]===Ag}var Ng=e=>Mg(e)?e:new jg(e.decode,e.encode);function Pg(e){return new jg(xg(e.decode),xg(e.encode))}function Fg(e){return new jg(U(e.decode),U(e.encode))}var Ig=new jg(bg(),bg());function Lg(){return Ig}var Rg=new jg(wg(),Cg()),zg=e=>Kn(e)&&typeof e.message==`string`,Bg=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:Wg(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},Vg=e=>{try{let t=Hr(e);return t===void 0?E(e):JSON.parse(t)}catch{return E(e)}},Hg=(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},Ug=e=>{let t=new WeakSet,n=r=>{if(Yn(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=Hg(r,e,n);return t.delete(r),i}return Vg(r)};return n},Wg=e=>zg(e)?Bg(e):e,Gg=e=>Fg({decode:Wg,encode:Ug(e)}),Kg=new jg(Og(),Dg());function qg(e){return new jg(Tg(e??{}),Eg(e))}function Jg(e){return t=>t._tag===e}var Yg=Jg(`Declaration`),Xg=Jg(`Null`),Zg=Jg(`Void`),Qg=Jg(`Never`),$g=Jg(`Literal`),e_=Jg(`UniqueSymbol`),t_=Jg(`Enum`),n_=Jg(`Arrays`),r_=Jg(`Objects`),i_=Jg(`Union`),a_=Jg(`Suspend`),W=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},o_={},s_=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},c_=`~effect/Schema`,l_=class{[c_]=c_;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},u_=class extends l_{_tag=`Declaration`;typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,i,a,o,s){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o,this.encodingRun=s}getParser(){let e;return(t,n)=>t===V?Nh:(e??=this.run(this.typeParameters))(t,this,n)}_rebuild(e,t,n,r,i){let a=Mv(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new u_(a,r,this.annotations,t,void 0,this.context,n,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},d_=new class extends l_{_tag=`Null`;getParser(){return Xv(this,null)}getExpected(){return`null`}},f_=class extends l_{_tag=`Undefined`;getParser(){return Xv(this,void 0)}toCodecJson(){return G(this,[p_])}getExpected(){return`undefined`}},p_=new W(d_,new jg(U(()=>void 0),U(()=>null))),m_=new f_,h_=new class extends l_{_tag=`Void`;getParser(){let e=Mh(void 0);return t=>t===V?Nh:e}toCodecJson(){return G(this,[p_])}getExpected(){return`void`}},g_=new class extends l_{_tag=`Never`;getParser(){return Zv(this,Wn)}getExpected(){return`never`}},__=new class extends l_{_tag=`Unknown`;getParser(){return Zv(this,Gn)}getExpected(){return`unknown`}},v_=class extends l_{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${E(e)}`);this.literal=e}getParser(){return Xv(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?y_(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:y_(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function y_(e){let t=globalThis.String(e.literal);return G(e,[new W(new v_(t),new jg(U(()=>e.literal),U(()=>t)))])}var b_=new class extends l_{_tag=`String`;getParser(){return Zv(this,Ln)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&oy(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},x_=class extends l_{_tag=`Number`;getParser(){return Zv(this,Rn)}matchKey(e,t){return this._match(ty,e,t)}matchPart(e,t){return this._match(ey,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:oy(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(S_(this.checks,`effect/schema/isFinite`)||S_(this.checks,`effect/schema/isInt`))?this:G(this,[gv])}toCodecStringTree(){return this.toCodecJson()===this?G(this,[iy]):G(this,[ay])}getExpected(){return`number`}};function S_(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&S_(e.checks,t))}var C_=new x_,w_=new class extends l_{_tag=`Boolean`;getParser(){return Zv(this,zn)}getExpected(){return`boolean`}},T_=class extends l_{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(Vv(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(Vv(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}let c=e=>{let{input:t,len:r,options:i}=e;if(n.rest.length===0&&r>a)for(let o=a;o<r;o++){let r=new Wh(n,t[o],i),a=new Hh([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return z(new Gh(n,[a],t,i))}return e.issues?z(new Gh(n,e.issues,t,i)):Mh(e.output)},l=(e,t)=>{let r=e.length,i={ast:n,getParser:s,input:e,len:r,tailThreshold:Math.max(a,r-o),output:new globalThis.Array(r),issues:void 0,options:t},u=n.rest.length===0?a:Math.max(r,a+o),d=t.concurrency===void 0?1:Vu(t.concurrency),f=d===1?O_(i,e,0,u):k_(i,e,{concurrency:d,end:u});if(!f)return c(i);if(L(f))return Yp(f,()=>c(i));let p=!0;return sp(()=>p?(p=!1,B(f,()=>c(i))):l(e,t))};return(e,a)=>{if(e===V)return Nh;try{return Array.isArray(e)?(r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)}))),l(e,a)):z(new Kh(n,e,a))}catch(e){return pp(e)}}}_rebuild(e,t,n){let r=Mv(this.elements,e),i=Mv(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new T_(this.isMutable,r,i,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}};function E_(e,t,n,r){if(n._tag===`Failure`)return A_(e,e.ast,r,n);let i=n===H?t:n[D];if(i!==V)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(Vv(t.ast))return;let n=new Hh([r],new Uh(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return Kd(new Gh(e.ast,[n],e.input,e.options))}}var D_={onItem(e,t,n){let r=n<e.len?t:V;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:E_},O_=Hu()(D_),k_=Wu()(D_),A_=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=pg(r.cause);if(i===void 0)return Gd(Ld(r.cause,r=>new Gh(t,[new Hh([n],r)],e.input,e.options)));let a=new Hh([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return Kd(new Gh(t,[a],e.input,e.options))},j_=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;function M_(e,t,n=o_){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(r=>Object.prototype.propertyIsEnumerable.call(e,r)&&t.matchKey(r,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(Qv(Kv(t)))}var N_=class{name;type;constructor(e,t){this.name=e,this.type=t}};function P_(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(P_);default:return!1}}function F_(e){let t=Sv(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(F_);default:return!1}}function I_(e){return P_(e)&&F_(e)}var L_=class{parameter;type;constructor(e,t){if(!I_(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,Vv(t)&&!Yv(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},R_=class extends l_{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o}getParser(e,t=e){let n=this,r=n.propertySignatures.length,i=n.indexSignatures.length;if(!r&&!i)return Zv(n,Un);let a,o,s=()=>(a||(a=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),o=i?n.indexSignatures.map(n=>({is:n,parserKey:e(Qv(n.parameter)),parserValue:t(n.type)})):void 0),a),c=()=>{let e=new Set(n.propertySignatures.map(e=>typeof e.name==`number`?globalThis.String(e.name):e.name)),t=(t,i,a,o,s)=>{if(s._tag===`Failure`)return A_(t,n,i,s)??qd;let c=s===H?o:s[D];if(a!==V&&c!==V){if(r&&(e.has(i)||e.has(typeof a==`number`?globalThis.String(a):a)))return qd;Qr(t.out,a,c)}return qd},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!L(t))return B(yp(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return A_(e,n,r,a)??qd;let o=a===H?r:a[D],s=e.input[r],l=i.parserValue(s,e.options);return L(l)?t(e,r,o,s,l):B(yp(l),n=>t(e,r,o,s,n))},l=(e,n,r)=>{let i=e.input[n],a=r.parserValue(i,e.options);return L(a)?t(e,n,n,i,a):B(yp(a),r=>t(e,n,n,i,r))},u=i?Wu()({onItem:(e,[t,n])=>n.is.parameter===b_?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return Xp(function*(t,d){if(t===V)return V;if(typeof t!=`object`||!t||Array.isArray(t))return yield*z(new Kh(n,t,d));s();let f=t,p={},m={ast:n,input:f,out:p,issues:void 0,options:d},h=d.errors===`all`,ee=d.onExcessProperty===`error`,te=d.concurrency===void 0?1:Vu(d.concurrency),ne=i&&ee?n.indexSignatures.map(e=>M_(f,e.parameter,d)):void 0;if(ee){let r=ne?new Set(e):e;if(ne)for(let e of ne)for(let t of e)r.add(t);let i=Reflect.ownKeys(f);for(let e=0;e<i.length;e++){let a=i[e];if(!r.has(a)&&Object.prototype.propertyIsEnumerable.call(f,a)){let e=new Wh(n,f[a],d),r=new Hh([a],e);if(h){m.issues?m.issues.push(r):m.issues=[r];continue}return yield*z(new Gh(n,[r],t,d))}}}if(r){let e=te===1?V_(m,a):H_(m,a,{concurrency:te});e&&(yield*e)}if(i&&te===1)for(let e=0;e<i;e++){let t=o[e],n=t.is.parameter===b_?l:c,r=ne?.[e]??(t.is.parameter===b_?Object.keys(f):M_(f,t.is.parameter,d));for(let e=0;e<r.length;e++){let i=n(m,r[e],t);if(!L(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(u){let e=zo();for(let t=0;t<i;t++){let n=o[t],r=ne?.[t]??(n.is.parameter===b_?Object.keys(f):M_(f,n.is.parameter,d));for(let t=0;t<r.length;t++)e.push([r[t],n])}let t=u(m,e,{concurrency:te});t&&(yield*t)}return m.issues?yield*z(new Gh(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return B(yp(n),n=>{let i=z_(e,r,n);if(i)return i;let o=()=>Mh(e.out),s=V_(e,a.slice(t+1));return s?Yp(s,o):o()})};return(e,t)=>{if(e===V)return Nh;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&Vu(t.concurrency)!==1)return(l??=c())(e,t);if(typeof e!=`object`||!e||Array.isArray(e))return z(new Kh(n,e,t));let r=s(),i=e,a={},o={ast:n,input:i,out:a,issues:void 0,options:t};try{for(let e=0;e<r.length;e++){let n=r[e],s=n.name,c=ev(i,s),l=c?i[s]:V,d=n.parser(l,t);if(!L(d))return u(o,e,d);if(d===H){c&&Qr(a,s,l);continue}let f=z_(o,n,d);if(f)return f}}catch(e){return pp(e)}return Mh(a)}}_rebuild(e,t,n,r){let i=Mv(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new N_(t.name,n)}),a=Mv(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new L_(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new R_(i,a,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function z_(e,t,n){if(n._tag===`Failure`)return A_(e,e.ast,t.name,n);if(n===H)return;let r=n[D];if(r!==V){Qr(e.out,t.name,r);return}if(delete e.out[t.name],!Vv(t.type)){let n=new Hh([t.name],new Uh(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return Kd(new Gh(e.ast,[n],e.input,e.options))}}var B_={onItem(e,t){if(!ev(e.input,t.name))return t.parser(V,e.options);let n=e.input[t.name];return Qr(e.out,t.name,n),t.parser(n,e.options)},step:z_},V_=Hu()(B_),H_=Wu()(B_);function U_(e,t){return e?t?[...e,...t]:e:t}function W_(e,t,n){return new R_(Reflect.ownKeys(e).map(t=>new N_(t,e[t].ast)),[],n,t)}function G_(e){return e.ast}function K_(e,t=void 0){return new T_(!1,e.map(e=>e.ast),[],void 0,t)}function q_(e,t,n){return new nv(e.map(G_),t,void 0,n)}var J_=jn(e=>{for(;;){if(a_(e))return __;let t=e.encoding;if(!t)return e.recur?.(J_,x)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==x))return __;e=t[t.length-1].to}});function Y_(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(Y_)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function X_(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[kh];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!Vv(t)){if($g(t))return[{key:e.name,literal:t.literal}];if(e_(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!Vv(e)){if($g(e))return[{key:t,literal:e.literal}];if(e_(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>X_(J_(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return X_(e.thunk())}}var Z_=new WeakMap,Q_=Object.freeze([]),$_=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,ev=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function tv(e){let t=Z_.get(e);if(t)return t;let n,r=0,i,a,o=!0,s=[];for(let t=0;t<e.length;t++){let c=e[t],l=J_(c);if(Qg(l))continue;if($g(l)||e_(l)){a??=new Map;let e=$g(l)?l.literal:l.symbol;s[t]=e;let n=a.get(e);n||a.set(e,n=[]),n.push(t)}else o=!1;let u=X_(l);if(u.length){n??=new Map,r++;for(let{key:e,literal:r}of u){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=Y_(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??Q_);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??Q_;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=new Map;for(let[e,t]of i)a.set(e,Object.freeze(Array.from(t)));let o=Object.freeze(e.map((e,t)=>t));t=(e,t)=>{if(qn(e)){let n=ev(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??Q_;if(t)return o}return Q_}}else if(n){let e;for(let t of n)(!e||t[1][0].size>e[1][0].size)&&t[1][1].size===r&&(e=t);t=(t,r)=>{let a=$_(t);if(!qn(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=ev(t,n),u=c?t[n]:void 0;if(c&&(!r||u!==void 0)){let e=i.get(u);if(!e)return l(a);for(let t of e)o.add(t);s=n}}if(s===void 0)for(let[e,[i,a]]of n){let n=ev(t,e),s=n?t[e]:void 0;if(n&&(!r||s!==void 0)){let e=i.get(s);if(e)for(let t of e)o.add(t)}else if(r)for(let e of a)o.add(e)}for(let[e,[i,a]]of n){if(e===s)continue;let n=ev(t,e),c=n?t[e]:void 0;if(n&&(!r||c!==void 0)){let e=i.get(c);for(let t of o)a.has(t)&&!e?.has(t)&&o.delete(t)}}return Array.from(o).sort((e,t)=>e-t)}}else t=e=>{let t=l($_(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return Z_.set(e,t),t}var nv=class extends l_{_tag=`Union`;types;options;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.options=t,this.encodingChecks=o}getParser(e,t){let n=this,r=t!==void 0,i=[],a=t=>i[t]??=e(n.types[t]),o;return(e,t)=>{if(e===V)return Nh;let i=(o??=tv(n.types))(e,r);if(i.length===0)return z(new Xh(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:L(r)?rv(n,r.cause,e,t):iv(n,r,e,t)}return av(n,a,i,e,t)}}_rebuild(e,t,n){let r=Mv(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new nv(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=Kv(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter($g);if(t.length>0)return`${lv(n.isMutable)}[ ${t.map(t=>e(t)+uv(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>$g(e.type));if(t.length>0)return`{ ${t.map(t=>`${lv(t.type.context?.isMutable)}${Lr(t.name)}${uv(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function rv(e,t,n,r){let i=pg(t);return i?Kd(new Xh(e,[i],n,r)):Gd(t)}function iv(e,t,n,r){return wp(t,t=>rv(e,t,n,r))}function av(e,t,n,r,i){let a={ast:e,parser:t,input:r,out:void 0,successes:e.options?.mode===`oneOf`?[]:void 0,issues:void 0,options:i},o=sv(a,n);return o?ov(o,a):a.out?a.out:z(new Xh(e,a.issues??[],r,i))}function ov(e,t){return Yp(e,e=>t.out===H?R(t.input):t.out?t.out:z(new Xh(t.ast,t.issues??[],t.input,t.options)))}var sv=Hu()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=pg(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),Kd(new Zh(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return qd}}}),cv=new nv([new v_(`Infinity`),new v_(`-Infinity`),new v_(`NaN`)]);function lv(e){return e?``:`readonly `}function uv(e){return e?`?`:``}var dv=class extends wn{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new dv(this.run,{...this.annotations,...e},this.aborted)}abort(){return new dv(this.run,this.annotations,!0)}and(e,t){return new fv([this,e],t)}},fv=class extends wn{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new fv(this.checks,{...this.annotations,...e})}and(e,t){return new fv([this,e],t)}};function pv(e,t,n=!1){return new dv((t,n,r)=>eg(n,e(t,n,r),t,r),t,n)}function mv(e){return pv(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitraryConstraint:{number:`finite`},...e})}var hv=Tv(C_,[mv()]),gv=new W(new nv([hv,cv]),new jg(wg(),U(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function _v(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return pv(e=>(n.lastIndex=0,n.test(e)),{expected:`a string matching the RegExp ${r.source}`,representation:{id:`effect/schema/isPattern`,payload:r},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[r]},...t})}var vv=new WeakMap;function yv(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&vv.set(n,bv(e)),n}function bv(e){let t=vv.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return vv.set(e,n),n}function G(e,t){return e.encoding===t?e:yv(e,{encoding:t})}function xv(e,t){if(e.context===t)return e;let n=bv(e);return n.context===t&&n.encoding===e.encoding?n:yv(e,{context:t})}function Sv(e){return e.encoding?Sv(e.encoding[e.encoding.length-1].to):e}function Cv(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return wv(e,Po(e.checks.slice(0,-1),n.annotate(t)))}return yv(e,{annotations:{...e.annotations,...t}})}function wv(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:yv(e,{checks:t})}function Tv(e,t){return wv(e,U_(e.checks,t))}function Ev(e,t){let n=t(e.to);return n===e.to?e:new W(n,e.transformation)}function Dv(e,t){let n=e,r=n[n.length-1],i=Ev(r,t);return i===r?e:Po(e.slice(0,e.length-1),i)}function Ov(e){return t=>t.encoding?G(t,Dv(t.encoding,e)):t}function kv(e,t){return Ov(e=>xv(e,t))(e)}function Av(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:G(r,Dv(r.encoding,n))}return e(r)}return jn(n)}function jv(e,t,n){let r=new W(e,t);return G(n,n.encoding?[...n.encoding,r]:[r])}function Mv(e,t){let n;for(let r=0;r<e.length;r++){let i=e[r],a=t(i);if(n)n[r]=a;else if(a!==i){n=Array(e.length);for(let t=0;t<r;t++)n[t]=e[t];n[r]=a}}return n??e}function Nv(e,t){return xv(e,e.context?new s_(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new s_(!1,!1,void 0,t))}var Pv=jn(e=>Fv(xv(e,e.context?e.context.isOptional===!1?new s_(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new s_(!0,!1)))),Fv=Ov(Pv),Iv=An(e=>Pv(new nv([e,m_])));function Lv(e,t){return xv(e,e.context?new s_(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new s_(!1,!1,t))}function Rv(e,t,n){return jv(e,n,t)}function zv(e){let t=[],n=[];function r(e){switch(e._tag){case`Literal`:Vn(e.literal)&&!t.includes(e.literal)&&t.push(e.literal);return;case`UniqueSymbol`:t.includes(e.symbol)||t.push(e.symbol);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)r(e.types[t]);return;default:n.push(e)}}return r(e),{literals:t,parameters:n}}function Bv(e,t){let{literals:n,parameters:r}=zv(e);return new R_(n.map(e=>new N_(e,t)),r.map(e=>new L_(e,t)))}function Vv(e){return e.context?.isOptional??!1}function Hv(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(Hv)}function Uv(e){function t(e){return Hv(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return Io(n)?n:void 0}function Wv(e){let t=!0;function n(e){return t=t&&!e.encoding&&!a_(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}var Gv=jn(e=>{let t=bv(e);if(t!==e){let n=Gv(t);return n===t&&e.encoding===void 0?e:xv(n,e.context)}let n=`recur`in e?e.recur(Gv):e;if(`encodingChecks`in n&&n.encodingChecks){let t=Wv(e)?n.encodingChecks:n_(n)||r_(n)||Yg(n)&&n.typeParameters.length>0?Uv(n.encodingChecks):void 0;return yv(n,{encodingChecks:void 0,checks:U_(n.checks,t)})}return n}),Kv=jn(e=>Gv(Jv(e)));function qv(e,t){let n=t,r=n.length,i=n[r-1],a=[new W(Jv(G(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new W(Jv(n[e-1].to),n[e].transformation.flip()));let o=Jv(i.to);return o.encoding?G(o,[...o.encoding,...a]):G(o,a)}var Jv=An(e=>{if(e.encoding)return qv(e,e.encoding);let t=bv(e);if(t!==e){let n=Jv(t);return n===t?e:xv(n,e.context)}return`flip`in e?e.flip(Jv):`recur`in e?e.recur(Jv):e});function Yv(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(Yv);default:return!1}}function Xv(e,t){let n=t===0?H:Mh(t);return(r,i)=>r===V?Nh:r===t?n:z(new Kh(e,r,i))}function Zv(e,t){return(n,r)=>n===V?Nh:t(n)?H:z(new Kh(e,n,r))}var Qv=Av(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(Qv)}}),$v=Av(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur($v)}}),ey=new globalThis.RegExp(`^${j_}$`),ty=new globalThis.RegExp(`^(?:${j_}|Infinity|-Infinity|NaN)$`);function ny(e){return _v(ey,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:ey.source}),...e})}var ry=Tv(b_,[ny()]),iy=new W(ry,Rg),ay=new W(new nv([ry,cv]),Rg);function oy(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=oy(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new Bh(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function sy(e){if(!Yg(e))return;let t=e.annotations?.[Ah];return Hn(t)?t(e.typeParameters):void 0}var cy=Dh;function ly(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function uy(e){return e===void 0||typeof e==`string`}function dy(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function fy(e){return dy(e,ly)}var py=new u_([],()=>(e,t,n)=>fy(e)?H:z(new Kh(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>_y}),my=new W(py,Lg()),hy=new W(new nv([new T_(!1,[],[py]),new R_([],[new L_(b_,py)])]),Lg());function gy(e){return dy(e,uy)}var _y=new W(new u_([],()=>(e,t,n)=>gy(e)?H:z(new Kh(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),Lg()),vy=(e,t,n)=>e===H?n(t):Yp(e,n);function yy(e){if(e._tag===`Middleware`)return(t,n,r)=>by(t===H?e.decode(Mh(Ph(n)),r):e.decode(Kp(t,Ph),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===H?Mh(t):e;case`Transform`:{let e=e=>e===V?Nh:Mh(t.transform(e));return(t,n)=>vy(t,n,e)}case`TransformOptional`:{let e=e=>Fh(t.transform(Ph(e)));return(t,n)=>vy(t,n,e)}case`TransformEffect`:return(e,n,r)=>vy(e,n,e=>e===V?Nh:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>vy(e,n,e=>by(t.transform(Ph(e),r)))}}var by=e=>Yp(e,Fh),xy=(e,t,n,r)=>wp(r,r=>fp(()=>Ld(r,r=>new Vh(e,r,t,n))));function Sy(e,t){let n=yy(e.link.transformation),r;return(i,a)=>{if(i===V)return Nh;if(e.isConstructed(i))return H;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function Cy(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==V&&r!==void 0)return t(r,i);let a=n;if(L(a)&&a._tag===`Success`){let e=t(a[D],i);return e===H?a:e}return Yp(xy(e,r,i,a),e=>{let n=t(e,i);return n===H?Mh(e):n})}}function wy(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:Cy(e,n)}function Ty(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?sy(e):void 0,o=a?Sy(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>yy(e.transformation)),u=e.encodingChecks;if(!c&&!s&&!u)return o;let d,f=(t,n)=>{let r=o(t,n);if(u&&!n.disableChecks){if(L(r)){if(r._tag===`Success`){let i=r===H?t:r[D];if(t!==V&&i!==V){let i=oy(u,t,void 0,e,n);i&&(r=z(new Gh(e,i,t,n)))}}}else r=B(r,r=>{if(t!==V&&r!==V){let r=oy(u,t,void 0,e,n);if(r)return z(new Gh(e,r,t,n))}return R(r)})}if(s&&!n.disableChecks){if(L(r)){if(r._tag===`Success`){let i=r===H?t:r[D];if(i===V)return r;let a=oy(s,i,void 0,e,n);a&&(r=z(new Gh(e,a,i,n)))}}else r=B(r,t=>{if(t!==V){let r=oy(s,t,void 0,e,n);if(r)return z(new Gh(e,r,t,n))}return R(t)})}return r},p=i===void 0?f:i(f);return c?(n,r)=>{let i=d??=c.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=c.length-1;e>=0;e--)if(o=l[e](o,a,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[D],o=t(a,r)):o=Yp(o,e=>{let n=t(e,r);return n===H?Mh(e):n})}if(o._tag===`Success`){let e=o[D],t=p(e,r);return t===H?o:t}return o=xy(e,n,r,o),Yp(o,e=>{let t=p(e,r);return t===H?Mh(e):t})}:p}var Ey=Symbol(),Dy=new WeakMap,Oy=e=>My(e).parser,ky=e=>My(e).makeEffect,Ay=e=>wy(e,ky),jy=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=Ty(this.ast,Oy)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=Ty(this.ast,ky,Ay)}};function My(e){let t=Dy.get(e);if(t!==void 0)return t;let n=new jy(e);return Dy.set(e,n),n}function Ny(e){let t=e.ast,n;return(e,r)=>(n??=Gy(Xy,Gv(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function Py(e){let t=Ny(e);return(e,n)=>{let r=Wp(t(e,n));return Jd(r)?Aa(r.value):(mg(r.cause,`Option adapter can only return none for schema issues`),ka())}}function Fy(e){return Jy(Gv(e.ast))}function Iy(e){return Ry(e.ast)}function Ly(e){{let t=Ky(Uy(e));return e=>{let n=t(e,o_);return Jd(n)?!0:(mg(n.cause,`Type guard adapter can only return false for schema issues`),!1)}}}function Ry(e){let t=Gv(e),n=e=>(n=Ly(t),n(e));return e=>n(e)}function zy(e,t){let n=Uy(e.ast);return t===void 0?n:(e,r)=>n(e,Vy(t,r))}function By(e,t){let n=Uy(Jv(e.ast));return t===void 0?n:(e,r)=>n(e,Vy(t,r))}var Vy=(e,t)=>t?{...e,...t}:e,Hy=e=>e===V?z(new qh):R(e);function Uy(e){return Gy(Yy,e)}function Wy(e,t){return e===H?R(t):L(e)?e[D]===V?Hy(V):e:Yp(e,Hy)}function Gy(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??o_);return a===H?R(r):L(a)?a[D]===V?Hy(V):a:Yp(a,Hy)}}function Ky(e){return(t,n)=>Wp(e(t,n))}function qy(e,t){let n=Wp(e);if(Jd(n))return n.value;let r=mg(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}function Jy(e){let t,n;return(r,i)=>{t??=My(e);let a=i?.disableChecks?i.parseOptions?{...i.parseOptions,disableChecks:!0}:{disableChecks:!0}:i?.parseOptions??o_,o=t.make;if(o!==void 0&&r!==V){let e;try{e=o(r,a)}catch(e){throw mg(Nd(e),`Constructor adapter can only throw schema issues`),e}if(e!==Ey&&e!==V)return e}return qy(Wy((n??=t.makeEffect)(r,a),r),`Constructor adapter can only throw schema issues`)}}var Yy=e=>My(e).parser,Xy=e=>My(e).makeEffect,Zy=`~effect/Schema/Schema`,Qy=Symbol(),$y={[Zy]:Zy,get make(){let e=Fy(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=Ny(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=Py(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return y(this,arguments)},annotate(e){return this.rebuild(Cv(this.ast,e))},annotateKey(e){return this.rebuild(Nv(this.ast,e))},check(...e){return this.rebuild(Tv(this.ast,e))},rebuild(e){return eb(e,this[Qy])}};function eb(e,t){function n(){}let r=Object.setPrototypeOf(n,$y);return t&&(Object.hasOwn(t,`name`)||Object.hasOwn(t,`length`)||Object.hasOwn(t,`__proto__`))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r[Qy]=t,r.ast=e,r}function tb(e){return eb(nb(e.ast),{schema:e})}var nb=Av(e=>{let t=sb(e,nb),n=e.context;return t===e||n===void 0?t:kv(t,rb(n))});function rb(e){return e.constructorDefault===void 0?e:new s_(e.isOptional,e.isMutable,void 0,e.annotations)}function ib(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function ab(e){return t=>{let n=[...t].sort((t,n)=>e(Kv(t))-e(Kv(n)));return n.some((e,n)=>e!==t[n])?n:t}}var ob=ab(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function sb(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!Hn(n))return G(e,[my]);let r=n(e.typeParameters.map(e=>eb(Kv(e))));return r===void 0?e:G(e,[Ev(r,t)])}case`Unknown`:return G(e,[my]);case`ObjectKeyword`:return G(e,[hy]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return ib(e),e.recur(t,$v);case`Union`:{let n=ob(e.types);return n===e.types?e.recur(t):new nv(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}function cb(e){return eb(mb(e.ast),{schema:e})}var lb=ab(e=>{switch(e._tag){case`Null`:case`Boolean`:case`Number`:case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function ub(e,t,n){switch(e._tag){case`Declaration`:{let r=e.typeParameters.map(e=>eb(t(Kv(e)))),i=e.annotations?.toCodecStringTree;if(Hn(i)){let n=i(r);return n===void 0?e:G(e,[Ev(n,t)])}let a=e.annotations?.toCodecJson,o=Hn(a)?a(r):void 0,s=o===void 0?e.annotations?.toCodec:void 0,c=o??(Hn(s)?s(r):void 0);return c===void 0?n(e):G(e,[Ev(c,t)])}case`Null`:return G(e,[db]);case`Boolean`:return G(e,[fb]);case`Unknown`:case`ObjectKeyword`:return G(e,[_y]);case`Enum`:case`Number`:case`Literal`:case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return ib(e),e.recur(t,$v);case`Union`:{let n=lb(e.types);return n===e.types?e.recur(t):new nv(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}var db=new W(new v_(`null`),new jg(U(()=>null),U(()=>`null`))),fb=new W(new nv([new v_(`true`),new v_(`false`)]),new jg(U(e=>e===`true`),Cg())),pb=new jg(U(e=>typeof e==`string`?[e]:e),bg()),mb=Av(e=>{let t=ub(e,mb,e=>{throw new globalThis.Error(`Missing structural codec for StringTree`,{cause:e})});return t!==e&&e.context!==void 0?kv(t,rb(e.context)):t},{stopAt:e=>e.transformation===pb}),hb=b(2,(e,t)=>({...e,...t})),gb=e=>e,_b=`~effect/Schema/SchemaError`;function vb(e){return S(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}var yb=Zy;function bb(){return(e,t,n)=>K(new u_(e.map(G_),e=>t(e.map(e=>K(e))),n))}function xb(e,t){return bb()([],()=>(t,n,r)=>e(t)?R(t):z(new Kh(n,t,r)),t)}var Sb=class extends Fs(`SchemaError`){[_b]=_b;constructor(e){let t=Jr();Yr(0);try{super({issue:e})}finally{Yr(t)}}get message(){return ug(this.issue)}toString(){return`SchemaError(${this.message})`}};function Cb(e){return vb(e)}function wb(e){return L(e)?Tb(e):wp(e,e=>fp(()=>Ld(e,e=>new Sb(e))))}function Tb(e){return Jd(e)?e:Gd(Ld(e.cause,e=>new Sb(e)))}function Eb(e,t){let n;for(let r of e.reasons){if(!Ad(r)||!Cb(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 Db(e){let t=Wp(e);if(Jd(t))return t.value;throw Eb(t.cause,`Sync adapter can only throw schema errors`)}var Ob=Iy;function kb(e,t){let n=zy(e,t);return(e,t)=>wb(n(e,t))}var Ab=kb;function jb(e,t){let n=kb(e,t);return(e,t)=>Db(n(e,t))}function Mb(e,t){let n=By(e,t);return(e,t)=>wb(n(e,t))}var K=eb;function Nb(e){return S(e,yb)&&e[yb]===yb}var Pb=gb(e=>K(Pv(e.ast),{schema:e})),Fb=gb(e=>{let t=tx(e);return K(Iv(e.ast),{schema:t})}),Ib=gb(e=>K(Gv(e.ast),{schema:e}));function Lb(e){let t=K(new v_(e),{literal:e,transform(n){return t.pipe(nx(Lb(n),{decode:U(()=>n),encode:U(()=>e)}))}});return t}var Rb=K(g_),zb=K(__),Bb=K(d_),Vb=K(m_),q=K(b_),Hb=K(C_),Ub=K(w_),Wb=K(h_);function Gb(e,t){return K(e,{fields:t,mapFields(e,t){let n=e(this.fields);return Gb(W_(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function J(e){return Gb(W_(e,void 0),e)}function Kb(e){return gb(t=>t.mapFields(hb(e)))}function qb(e,t){return K(Bv(e.ast,t.ast),{key:e,value:t})}function Jb(e,t){return K(e,{elements:t,mapElements(e,t){let n=e(this.elements);return Jb(K_(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function Yb(e){return Jb(K_(e),e)}var Y=gb(e=>K(new T_(!1,[],[e.ast]),{value:e})),Xb=gb(e=>K(new T_(!1,[e.ast],[e.ast]),{value:e}));function Zb(e,t){return K(e,{members:t,mapMembers(e,t){let n=e(this.members);return Zb(q_(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function Qb(e,t){return Zb(q_(e,t,void 0),e)}function $b(e){let t=e.map(Lb);return K(q_(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return Qb(e(this.members))},pick(e){return $b(e)},transform(e){return Qb(t.map((t,n)=>t.transform(e[n])))}})}var ex=gb(e=>Qb([e,Bb])),tx=gb(e=>Qb([e,Vb]));function nx(e,t){return n=>K(Rv(n.ast,e.ast,t?Ng(t):Lg()),{from:n,to:e})}function rx(){return(e,t)=>cx()(e,{decode:t,encode:vg})}function ix(e){return t=>K(Lv(t.ast,e),{schema:t})}function ax(e){return Lb(e).pipe(ix(R(e)))}function ox(e,t){return J({_tag:ax(e),...t})}function sx(e,t){return xb(t=>t instanceof e,t)}function cx(){return(e,t)=>new W(e.ast,Ng(t))}var lx=pv;function ux(e,t){let n=e.source,r=e.flags,i=/^[dg]*uy?$/.test(r),a=r===``?`new RegExp(${E(n)})`:`new RegExp(${E(n)}, ${E(r)})`;return _v(e,{toJsonSchema:()=>i?{pattern:r.endsWith(`y`)?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}var dx=K(hv);function fx(e){let t=Oa(e.order),n=Ea(e.order),r=Da(e.order),i=Ta(e.order),a=e.formatter??E;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return lx(e=>c(e,o.minimum)&&l(e,o.maximum),{expected:`a value between ${a(o.minimum)}${o.exclusiveMinimum?` (excluded)`:``} and ${a(o.maximum)}${o.exclusiveMaximum?` (excluded)`:``}`,arbitraryConstraint:{order:e.order,minimum:o.minimum,maximum:o.maximum,...o.exclusiveMinimum&&{exclusiveMinimum:!0},...o.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(o),...s})}}function px(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${E(e)}`);return e}var mx=fx({order:Ca,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:px(e.minimum),maximum:px(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${E(e.minimum)}, maximum: ${E(e.maximum)}, exclusiveMinimum: ${E(t)}, exclusiveMaximum: ${E(n)} })`})}}});function hx(e){return lx(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>[{type:`integer`},!0],toCode:()=>({runtime:`Schema.isInt()`}),arbitraryConstraint:{number:`integer`},...e})}var gx=Hb.check(hx());function _x(e,t){return e=bx(e),vx(e,Math.ceil(e/2),t)}function vx(e,t,n){return lx(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:`effect/schema/isMinLength`,payload:{minLength:e}},toJsonSchema:({type:n})=>n===`string`?e<=1?{minLength:t}:[{minLength:t},!0]:n===`array`?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[Oh]:!0,arbitraryConstraint:{minLength:e},...n})}function yx(e,t){return e=bx(e),lx(t=>t.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:`effect/schema/isMaxLength`,payload:{maxLength:e}},toJsonSchema:({type:t})=>t===`string`?e===0?{maxLength:e}:[{maxLength:e},!0]:t===`array`?{maxItems:e}:t===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[Oh]:!0,arbitraryConstraint:{maxLength:e},...t})}function bx(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}function xx(e,t){return e=bx(e),lx(t=>Reflect.ownKeys(t).length>=e,{expected:`a value with at least ${e===1?`1 entry`:`${e} entries`}`,representation:{id:`effect/schema/isMinProperties`,payload:{minProperties:e}},toJsonSchema:({type:t})=>t===`object`?{minProperties:e}:[{minProperties:e},!0],toCode:()=>({runtime:`Schema.isMinProperties(${e})`}),[Oh]:!0,arbitraryConstraint:{minProperties:e},...t})}function Sx(e){return lx(e=>Uo(e).length===e.length,{expected:`an array with unique items`,representation:{id:`effect/schema/isUnique`,payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:`Schema.isUnique()`}),arbitraryConstraint:{uniqueBy:x},...e})}var Cx=e=>+(e?.includeStack===!0)|(e?.excludeCause===!0?2:0),wx=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},Tx=[];function Ex(e){let t=Cx(e),n=Tx[t];if(n!==void 0)return n;let r=$x.pipe(nx(zb,Gg(wx(t))));return Tx[t]=r,r}globalThis.RegExp,globalThis.URL;var Dx=q.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`});function Ox(e,t){return Dx.pipe(nx(e,qg(t)))}var kx=Ox(zb);globalThis.File,globalThis.FormData,globalThis.URLSearchParams;var Ax=q.annotate({expected:`a base64 encoded string that will be decoded as Uint8Array`,format:`byte`,contentEncoding:`base64`}),jx=sx(globalThis.Uint8Array,{representation:{id:`effect/schema/Uint8Array`,payload:null},toCode:()=>({runtime:`Schema.Uint8Array`,Type:`globalThis.Uint8Array`}),expected:`Uint8Array`,toCodecJson:()=>cx()(Ax,Kg)});function Mx(e,t){return K(bb()([e,t],([e,t])=>(n,r,i)=>{if(!kd(n))return z(new Kh(r,n,i));switch(n._tag){case`Fail`:return Jp(zy(e)(n.error,i),{onSuccess:Pd,onFailure:e=>Jh(r,`error`,e,n,i)});case`Die`:return Jp(zy(t)(n.defect,i),{onSuccess:Fd,onFailure:e=>Jh(r,`defect`,e,n,i)});case`Interrupt`:return R(n)}},{representation:{id:`effect/schema/CauseReason`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.CauseReason(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Failure<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause.Failure`,toCodec:([e,t])=>cx()(Qb([J({_tag:Lb(`Fail`),error:e}),J({_tag:Lb(`Die`),defect:t}),J({_tag:Lb(`Interrupt`),fiberId:tx(dx)})]),Fg({decode:e=>{switch(e._tag){case`Fail`:return Pd(e.error);case`Die`:return Fd(e.defect);case`Interrupt`:return Id(e.fiberId)}},encode:e=>{switch(e._tag){case`Fail`:return{_tag:`Fail`,error:e.error};case`Die`:return{_tag:`Die`,defect:e.defect};case`Interrupt`:return{_tag:`Interrupt`,fiberId:e.fiberId}}}}))}).ast,{error:e,defect:t})}function Nx(e,t){return K(bb()([e,t],([e,t])=>{let n=Y(Mx(e,t));return(e,t,r)=>Od(e)?Jp(zy(n)(e.reasons,r),{onSuccess:jd,onFailure:n=>Jh(t,`failures`,n,e,r)}):z(new Kh(t,e,r))},{representation:{id:`effect/schema/Cause`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Cause(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Cause<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause`,toCodec:([e,t])=>cx()(Y(Mx(e,t)),Fg({decode:jd,encode:({reasons:e})=>e}))}).ast,{error:e,defect:t})}var Px=Pg({decode:(e,t)=>Na(Tm(e),{onNone:()=>z(new qh({expected:`a valid UTC DateTime string`},e,t)),onSome:e=>R(Em(e))}),encode:e=>R(Om(e))}),Fx=-864e13,Ix=864e13;function Lx(e,t,n){let r=Math.max(t,e?.minimum===void 0?t:e.minimum.epochMilliseconds+ +(e.exclusiveMinimum===!0)),i=Math.min(n,e?.maximum===void 0?n:e.maximum.epochMilliseconds-+(e.exclusiveMaximum===!0));return r<=i?[r,i]:[t,n]}function Rx(e,t){return gx.check(mx({minimum:e,maximum:t}))}var zx=xb(e=>xm(e)&&Sm(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`,toCodecArbitrary:({constraint:e})=>{let[t,n]=Lx(e,Fx,Ix);return rx()(Rx(t,n),U(wm))},toCodecJson:()=>cx()(q,Px),toFormatter:()=>e=>e.toString()}),Bx=q.annotate({expected:`a string that will be decoded as a DateTime.Utc`}).pipe(nx(zx,Px)),Vx=xb(ph,{representation:{id:`effect/http/UrlParams`,payload:null},toCode:()=>({runtime:`Schema.UrlParams`,Type:`UrlParams.UrlParams`,importDeclarations:[`import * as UrlParams from "effect/http/UrlParams"`]}),expected:`UrlParams`,toEquivalence:()=>vh,toCodec:()=>cx()(Y(Yb([q,q])),Fg({decode:hh,encode:e=>e.params}))}).pipe(nx(qb(q,Qb([q,Xb(q)])),Fg({decode:Th,encode:gh}))),Hx=globalThis.Symbol.for(`immer-draftable`),Ux={};function Wx(e,t,n,r,i){let a=qx(n,t,r),o=Kx(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===Ux?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:Ux,value:i}})}static[yb]=yb;get[o](){return o}static[Hx]=!0;static identifier=t;static fields=n.fields;static get ast(){return a(this).ast}static pipe(){return y(this,arguments)}static rebuild(e){return a(this).rebuild(e)}static make(e,t){return Fy(a(this))(e??{},t)}static makeOption(e,t){return Py(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(Cv(this.ast,e))}static annotateKey(e){return this.rebuild(Nv(this.ast,e))}static check(...e){return this.rebuild(Tv(this.ast,e))}static extend(e){return(t,r)=>{let a=Jx(t)?t:J(t),o={...n.fields,...a.fields},s=W_(o,n.ast.checks,{identifier:e});return Wx(this,e,Gb(Tv(s,a.ast.checks),o),r,i)}}static mapFields(e,t){return n.mapFields(e,t)}};return i!==void 0&&Object.assign(s.prototype,i(t)),s}function Gx(e){return new jg(U(t=>new e(t,{"~payload":{token:Ux,value:t}})),bg())}function Kx(e){return`~effect/Schema/Class/${e}`}function qx(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=Kx(t),o=e=>e instanceof i||S(e,a),s=Gx(i);return r=nx(K(new u_([e.ast],()=>(e,t,n)=>o(e)?R(e):z(new Kh(t,e,n)),{identifier:t,[Ah]:([e])=>({isConstructed:o,link:new W(e,s)}),toCodec:([e])=>new W(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[kh]:X_(e.ast),...n})),s)(e)}}function Jx(e){return Nb(e)}var Yx=e=>(t,n)=>Wx(zi,e,Jx(t)?t:J(t),n,e=>({name:e})),Xx=e=>(t,n,r)=>{let i=Jx(n)?n.mapFields(e=>({_tag:ax(t),...e}),{unsafePreserveChecks:!0}):ox(t,n);return Yx(e??t)(i,r)},Zx=tb,Qx=cb,$x=K(Cv(py,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),eS=Ac,tS=rd,nS=`~effect/MutableRef`,rS={[nS]:nS,...si,toJSON(){return{_id:`MutableRef`,current:Wr(this.current)}}},iS=e=>{let t=Object.create(rS);return t.current=e,t},aS={"~effect/Channel":{_Env:x,_InErr:x,_InElem:x,_OutErr:x,_OutElem:x},pipe(){return y(this,arguments)}},oS=e=>{let t=Object.create(aS);return t.transform=(t,n)=>wp(e(t,n),e=>R(dp(e))),t},sS=(e,t)=>oS((n,r)=>B(uS(e)(n,r),e=>t(e,r))),cS=e=>oS((t,n)=>e),lS=e=>oS(Gp(function*(t,n){let r=of(n),i=e=>sf(r,ep(e));return Np(yield*Np(e(t,n,r),i),i)})),uS=e=>e.transform,dS=e=>oS((t,n)=>sp(()=>uS(e())(t,n))),fS=e=>cS(R(z(e))),pS=e=>oS((t,n)=>mS({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),mS=e=>{let t=e.readable.getReader(),n=e.exit??iS(void 0),r=sp(()=>n.current?n.current:Ep(op({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??dp(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?Hd():R(Bo(t))}));return xp(af(e.scope,e.releaseLockOnEnd?cp(()=>t.releaseLock()):ap(()=>t.cancel().catch(kn))),r)},hS=b(2,(e,t)=>sS(e,e=>cp(()=>{let n=0;return bp(e,e=>t(e,n++))}))),gS=b(2,(e,t)=>oS((n,r)=>B(uS(e)(n,r),e=>uS(t)(e,r)))),_S=b(2,(e,t)=>lS((n,r,i)=>rf(i,t).pipe(_p(uS(e)(n,r))))),vS=b(2,(e,t)=>_S(e,e=>t)),yS=(e,t,n)=>sp(()=>{let r=tf();return Xf(B(uS(e)(Hd(),r),t),n||R).pipe(Pp(e=>sf(r,e)))}),bS=b(2,(e,t)=>oS((n,r)=>bp(Ap(uS(e)(n,r),t),Ap(t)))),xS=b(2,(e,t)=>yS(e,e=>Rp(B(e,t),{disableYield:!0}))),SS=(e,t)=>uS(e)(Hd(),t),CS=(e,t)=>()=>{let n=Ab(Xb(e),t);return oS((e,t)=>R(B(e,e=>n(e))))},wS=`~effect/Stream`,TS={_R:x,_E:x,_A:x},ES=function(e){this.channel=e};ES.prototype={[wS]:TS,pipe(){return y(this,arguments)}};var DS=e=>new ES(e),OS=`~effect/Stream`,kS=e=>S(e,OS),AS=DS,jS=(e,t)=>AS(oS((n,r)=>B(SS(e.channel,r),e=>t(e,r)))),MS=e=>AS(dS(()=>e().channel)),NS=e=>AS(fS(e)),PS=e=>AS(pS(e)),FS=b(2,(e,t)=>MS(()=>{let n=0;return AS(hS(e.channel,Vo(e=>t(e,n++))))})),IS=b(2,(e,t)=>AS(gS(e.channel,t))),LS=b(e=>kS(e[0]),(e,t)=>MS(()=>{let n=new TextDecoder(t?.encoding);return FS(e,e=>n.decode(e,{stream:!0}))})),RS=b(2,(e,t)=>AS(vS(e.channel,t))),zS=b(2,(e,t)=>AS(bS(e.channel,t))),BS=b(2,(e,t)=>xS(e.channel,t)),VS=b(e=>kS(e[0]),(e,t,n)=>{let r,i,a=tS(!1);return new ReadableStream({start(n){i=Vp(Ap(BS(e,e=>a.whenOpen(cp(()=>{a.closeUnsafe();for(let t=0;t<e.length;t++)n.enqueue(e[t]);r(),r=void 0}))),t)),i.addObserver(e=>{e._tag===`Failure`?n.error(zd(e.cause)):n.close()})},pull(){return new Promise(e=>{r=e,a.openUnsafe()})},cancel(){if(i)return Hp(Sp(eS(i)))}},n?.strategy)}),HS=b(e=>kS(e[0]),(e,t)=>bp(Dp(),n=>VS(e,n,t))),US=b(2,(e,t)=>e===void 0?void 0:t(e)),WS=e=>q.pipe(ix(R(e))),GS={InvalidInput:400,Unauthenticated:401,Forbidden:403},KS=J({path:Y(Qb([q,dx])),message:q}),qS=rg(),JS=class e extends Xx()(`InvalidInput`,{message:WS(`The input does not match the action's input.`),issues:Y(KS).pipe(ix(R([])))},{httpApiStatus:GS.InvalidInput}){static fromSchemaError=({issue:t,message:n})=>new e({message:n,issues:qS(t).issues.map(e=>({path:(e.path??[]).map(e=>{let t=Vn(e)?e:e.key;return Bn(t)?String(t):t}),message:e.message}))})},YS=class extends Xx()(`Unauthenticated`,{message:WS(`Authentication is required.`)},{httpApiStatus:GS.Unauthenticated}){},XS=q.check(ux(/^[\x21\x23-\x5B\x5D-\x7E]+$/)),ZS=[YS,class extends Xx()(`Forbidden`,{message:WS(`Not allowed.`),scopes:Pb(Xb(XS))},{httpApiStatus:GS.Forbidden}){}];Qb(ZS);var QS=[JS,...ZS],$S=Qb(QS),eC=e=>e===void 0?[]:Nb(e)?[e]:e,tC=(e,t=[])=>[...new Set([...QS,...e.error,...t])],nC=Symbol.for(`@gjermundgaraba/effect-actions/Anyone`),rC=/^[A-Za-z0-9_-]{1,128}$/,iC=(e,t)=>{if(!rC.test(t)||t===`then`)throw Error(`Invalid ${e}: ${t}`)},aC=(e,t,n,r=n)=>{let i=new Map;for(let a of t){let t=n(a),o=r(a),s=i.get(t);if(s!==void 0){let n=s===o?``:`, claimed by ${s} and ${o}`;throw Error(`Duplicate ${e}: ${t}${n}`)}i.set(t,o)}},oC=(e,t)=>aC(e,t,e=>e.name),sC=e=>a_(e)?sC(e.thunk()):e,cC=e=>{let t=sC(e);return i_(t)?t.types.flatMap(cC):[t]},lC=e=>$g(e)?[e.literal]:t_(e)?e.enums.map(([,e])=>e):[void 0],uC=e=>cC(Kv(e)).flatMap(e=>{let t=r_(e)?e.propertySignatures.find(e=>e.name===`_tag`)?.type:void 0;return t===void 0?[]:cC(t).flatMap(lC).filter(Ln)}),dC=(e,t)=>{let n=t.flatMap(e=>uC(e.ast)).find(e=>Object.hasOwn(GS,e));if(n!==void 0)throw Error(`${e}: error _tag "${n}" is built in, and declared on every surface`)},fC=(e,t)=>t.length===0?kb(Zx(e.input))({}):R(t[0]),pC=qb(q,Rb),mC=e=>Nb(e)?e:Reflect.ownKeys(e).length===0?pC:J(e);function X(e,t){iC(`action name`,e);let{caller:n,readOnly:r}=t;if(n!==nC&&!to(n))throw Error(`Missing caller: declare Action.Anyone or an identity service key`);if(n!==nC&&no(n))throw Error(`Invalid caller: an identity is a Context.Service, not a Context.Reference`);if(r!==!0&&r!==!1)throw Error(`Invalid readOnly: ${String(r)}`);let i={caller:n,name:e,description:t.description,input:mC(t.input??{}),success:t.success===void 0?Wb:mC(t.success),error:eC(t.error),readOnly:r,mcp:{...t.mcp}};return dC(`Action "${i.name}"`,i.error),i}var hC=(e,t)=>{for(let n of e)if(n.caller!==nC&&(t===void 0||n.caller.key!==t.identity.key))throw Error(`Protected action '${n.name}' requires its matching authentication descriptor`)},gC=`~effect/http/HttpBody`,_C=e=>S(e,gC),vC=class{[gC];constructor(){this[gC]=gC}[Ur](){return this.toJSON()}toString(){return E(this,{ignoreToString:!0})}},yC=new class extends vC{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},bC=class extends vC{_tag=`Uint8Array`;contentType;contentLength;text;_body;constructor(e,t,n,r){super(),this._body=e,this.text=r,this.contentType=t,this.contentLength=n}get body(){return this._body??=wC(this.text)}toJSON(){return{_id:`effect/HttpBody`,_tag:`Uint8Array`,body:this.contentType.startsWith(`text/`)||this.contentType.endsWith(`json`)?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},xC=(e,t)=>new bC(e,t??`application/octet-stream`,e.length),SC=new TextEncoder,CC=globalThis.Buffer,wC=CC===void 0?e=>SC.encode(e):e=>CC.from(e,`utf8`),TC=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),CC!==void 0)return new bC(void 0,t??`text/plain`,CC.byteLength(e,`utf8`),e);let n=SC.encode(e);return new bC(n,t??`text/plain`,n.length,e)},EC=(e,t)=>TC(wh(gh(e)),t??`application/x-www-form-urlencoded`),DC=class extends vC{_tag=`FormData`;contentType=void 0;contentLength=void 0;formData;constructor(e){super(),this.formData=e}toJSON(){return{_id:`effect/HttpBody`,_tag:`FormData`,formData:this.formData}}},OC=e=>new DC(e),kC=`~effect/http/HttpClientError`,AC=class extends Fs(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[kC]=kC;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},jC=e=>e.endsWith(`Error`)?e.slice(0,-5):e,MC=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,NC=class extends Fs(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return MC(jC(this._tag),this.description,this.methodAndUrl)}},PC=class extends Fs(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return MC(jC(this._tag),this.description,this.methodAndUrl)}},FC=class extends Fs(`StatusCodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return MC(jC(this._tag),this.description,e)}},IC=class extends Fs(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return MC(jC(this._tag),this.description,e)}},LC=class extends Fs(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return MC(jC(this._tag),this.description,e)}},RC=e=>e!==`GET`&&e!==`HEAD`&&e!==`OPTIONS`&&e!==`TRACE`,zC=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],BC=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?ch(ch(e,`content-type`),`content-length`):(e=t.contentType===void 0?ch(e,`content-type`):ah(e,`content-type`,t.contentType),t.contentLength===void 0?ch(e,`content-length`):ah(e,`content-length`,t.contentLength.toString())),VC=class extends Fs(`UrlError`){},HC=(e,t,n)=>xo({try:()=>{let r=new URL(e,UC());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,i)}return n!==void 0&&(r.hash=n),r},catch:e=>new VC({cause:e})}),UC=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},WC=`~effect/http/HttpClientRequest`,GC={[WC]:WC,...Gr,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:jr(this.headers),body:this.body.toJSON()}},pipe(){return y(this,arguments)}};function KC(e,t,n,r,i,a){let o=Object.create(GC);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var qC=KC(`GET`,``,bh,ka(),nh,yC),JC=e=>(t,n)=>YC(qC,{method:e,url:t,...n??void 0}),YC=b(2,(e,t)=>{let n=e;return t.method&&(n=XC(n,t.method)),t.url&&(n=tw(n,t.url)),t.headers&&(n=QC(n,t.headers)),t.urlParams&&(n=iw(n,t.urlParams)),t.hash&&(n=ow(n,t.hash)),t.body&&(n=sw(n,t.body)),t.accept&&(n=$C(n,t.accept)),t.acceptJson&&(n=ew(n)),n}),XC=b(2,(e,t)=>KC(t,e.url,e.urlParams,e.hash,e.headers,e.body)),ZC=b(3,(e,t,n)=>KC(e.method,e.url,e.urlParams,e.hash,ah(e.headers,t,n),e.body)),QC=b(2,(e,t)=>KC(e.method,e.url,e.urlParams,e.hash,oh(e.headers,t),e.body)),$C=b(2,(e,t)=>ZC(e,`Accept`,t)),ew=$C(`application/json`),tw=b(2,(e,t)=>{if(typeof t==`string`)return KC(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=gh(n.searchParams),i=Fa(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,KC(e.method,n.toString(),r,i,e.headers,e.body)}),nw=b(2,(e,t)=>t===``?e:KC(e.method,rw(t,e.url),e.urlParams,e.hash,e.headers,e.body)),rw=(e,t)=>{let n=e.endsWith(`/`),r=t.startsWith(`/`);return n&&r?e+t.slice(1):!n&&!r?e+`/`+t:e+t},iw=b(2,(e,t)=>KC(e.method,e.url,Sh(e.urlParams,t),e.hash,e.headers,e.body)),aw=b(2,(e,t)=>KC(e.method,e.url,Ch(e.urlParams,t),e.hash,e.headers,e.body)),ow=b(2,(e,t)=>KC(e.method,e.url,e.urlParams,Aa(t),e.headers,e.body)),sw=b(2,(e,t)=>KC(e.method,e.url,e.urlParams,e.hash,BC(e.headers,t),t)),cw=b(2,(e,t)=>sw(e,OC(t)));function lw(e){let t=HC(e.url,e.urlParams,Ia(e.hash));return Co(t)?Aa(t.success):ka()}var uw=`~effect/http/HttpIncomingMessage`,dw=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=Up(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=Up(e.text)}catch{}let i={...t,headers:jr(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},fw=`~effect/http/HttpClientResponse`,pw=(e,t)=>new mw(e,t),mw=class extends Kr{[uw];[fw];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[uw]=uw,this[fw]=fw}toJSON(){return dw(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split(`#`)[0];let e=lw(this.request);return ja(e)?``:(e.value.hash=``,e.value.href)}get headers(){return rh(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=Hm(this.source.headers.getSetCookie())}get remoteAddress(){return ka()}get stream(){return this.source.body?PS({evaluate:()=>this.source.body,onError:e=>new AC({reason:new IC({request:this.request,response:this,cause:e})})}):NS(new AC({reason:new LC({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return B(this.text,e=>mp({try:()=>e===``?null:JSON.parse(e),catch:e=>new AC({reason:new IC({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=bp(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return B(this.text,e=>mp({try:()=>gh(new URLSearchParams(e)),catch:e=>new AC({reason:new IC({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=op({try:()=>this.source.formData(),catch:e=>new AC({reason:new IC({request:this.request,response:this,cause:e})})}).pipe(Fp,Up)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=op({try:()=>this.source.arrayBuffer(),catch:e=>new AC({reason:new IC({request:this.request,response:this,cause:e})})}).pipe(Fp,Up),this.arrayBufferBody}pipe(){return y(this,arguments)}},hw=e=>ih({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${Na(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),gw=`~effect/http/HttpClient`,_w=j(`effect/HttpClient`),vw=b(2,(e,t)=>yw(n=>t(e.postprocess(n)),e.preprocess)),yw=(e,t)=>{let n=Object.create(bw);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},bw={[gw]:gw,pipe(){return y(this,arguments)},...Gr,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(zC.map(([e,t])=>[t,function(t,n){return this.execute(JC(e)(t,n))}]))},xw=e=>yw(t=>B(t,t=>hp(n=>{let r=kw.get(t),i=r??new AbortController,a=HC(t.url,t.urlParams,Ia(t.hash));if(So(a))return z(new AC({reason:new PC({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(Ks)||n.getRef(Cw)(t)){let a=e(t,o,i.signal,n);return r?a:Lp(e=>Ep(e(a),{onSuccess(e){return Ow.register(e,i),R(new Aw(e,i))},onFailure(e){return Bd(e)&&i.abort(),dp(e)}}))}return zp(n.getRef(Ew)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method),a.attribute(`server.address`,o.origin),o.port!==``&&a.attribute(`server.port`,+o.port),a.attribute(`url.full`,o.toString()),a.attribute(`url.path`,o.pathname),a.attribute(`url.scheme`,o.protocol.slice(0,-1));let s=o.search.slice(1);s!==``&&a.attribute(`url.query`,s);let c=n.getRef(dh),l=n.getRef(ww);for(let e in t.headers)l(e,`request`)&&a.attribute(`http.request.header.${e}`,uh(e,c)?`<redacted>`:t.headers[e]);return t=n.getRef(Tw)?QC(t,hw(a)):t,Lp(s=>s(e(t,o,i.signal,n)).pipe(Bp(a,{captureStackTrace:!1}),Ep({onSuccess:e=>{a.attribute(`http.response.status_code`,e.status);for(let t in e.headers)l(t,`response`)&&a.attribute(`http.response.header.${t}`,uh(t,c)?`<redacted>`:e.headers[t]);return r?R(e):(Ow.register(e,i),R(new Aw(e,i)))},onFailure(e){return!r&&Bd(e)&&i.abort(),dp(e)}})))})})),R),Sw=b(2,(e,t)=>yw(e.postprocess,n=>bp(e.preprocess(n),t))),Cw=M(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>Dn}),ww=M(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>En}),Tw=M(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:En}),Ew=M(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),Dw=e=>Cf(_w)(Op(t=>bp(e,e=>vw(e,jp(e=>go(t,e)))))),Ow=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),kw=new WeakMap,Aw=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[fw]=fw;[uw]=uw;applyInterrupt(e){return sp(()=>(Ow.unregister(this.original),Ip(e,()=>cp(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return MS(()=>(Ow.unregister(this.original),RS(this.original.stream,cp(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Ur](){return this.original[Ur]()}pipe(){return y(this,arguments)}},jw=M(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),Mw=class extends j()(`effect/http/FetchHttpClient/RequestInit`){},Nw=Dw(R(xw((e,t,n,r)=>{let i=r.getRef(jw),a=co(r.context,Mw)??{},o=a.headers?sh(rh(a.headers),e.headers):e.headers;o[`content-length`]&&(o=ch(o,`content-length`));let s=r=>bp(op({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:typeof ReadableStream<`u`&&r instanceof ReadableStream?`half`:void 0,signal:n}),catch:t=>new AC({reason:new NC({request:e,cause:t})})}),t=>pw(e,t));switch(e.body._tag){case`Raw`:case`Uint8Array`:return s(e.body.body);case`FormData`:return s(e.body.formData);case`Stream`:return B(HS(e.body.stream),s)}return s(void 0)})));({...si});var Pw=new Uint8Array(256);for(let e of"!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")Pw[e.charCodeAt(0)]=1;var Fw=new Uint8Array(256);Fw[9]=1;for(let e=32;e<=126;e++)Fw[e]=1;for(let e=128;e<=255;e++)Fw[e]=1;var Iw=j(`effect/http/HttpServerRequest`),Lw=new WeakSet,Rw=e=>hp(t=>{let n=uo(t.context,Iw);return Lw.add(n.source),e}),zw=j(`effect/http/HttpRouter`),Bw=e=>e.endsWith(`/`)?e.slice(0,-1):e,Vw=b(2,(e,t)=>(t=Bw(t),e===`*`?`${t}/*`:e===`/`?t:t+e)),Hw=`~effect/http/HttpRouter/Middleware`,Uw=function(){return arguments.length===0?Ww:Ww(arguments[0],arguments[1])},Ww=(e,t)=>t?.global?Ef(up(function*(){let t=yield*zw,n=rp(e)?yield*e:e;yield*t.addGlobalMiddleware(n)})):new qw(rp(e)?Tf(bp(e,e=>Za(new Map([[Kw,e]])))):Sf(Za(new Map([[Kw,e]])))),Gw=0,Kw=`effect/http/HttpRouter/MiddlewareFn`,qw=class e{[Hw]={};layerFn;dependencies;constructor(e,t){this.layerFn=e,this.dependencies=t;let n=`effect/http/HttpRouter/Middleware-${++Gw}`;this.layer=Tf(up({self:this},function*(){let e=yield*Dp(),t=[lo(e,Kw)];if(this.dependencies){let n=yield*yf,r=fo(e,ef),i=yield*bf(this.dependencies,n,r);t.push(...Yw(i))}return Za(new Map([[n,t]]))})).pipe(Af(this.layerFn))}layer;combine(t){return new e(this.layerFn,this.dependencies?jf(this.dependencies,t.layer):t.layer)}},Jw=new WeakMap,Yw=e=>{let t=Jw.get(e);if(t)return t;let n=zo(),r=0;for(let[t,i]of e.mapUnsafe)t.startsWith(`effect/http/HttpRouter/Middleware-`)&&(n.push(i),i.length>r&&(r=i.length));if(n.length===0)t=[];else{let e=new Set;for(let t=r-1;t>=0;t--)for(let r of n)t<r.length&&e.add(r[t]);t=Mo(e).reverse()}return Jw.set(e,t),t};Uw(Rw).layer;var Xw={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,OK:200,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511},Zw=e=>Xw[e],Qw=`~effect/encoding/Sse/SseError`,$w=class extends Fs(`EventTooLarge`){get message(){return`Pending SSE event exceeded the maximum size of ${this.maxEventSize}`}},eT=class extends Fs(`SseError`){[Qw]=Qw;get message(){return this.reason.message}},tT=10485760,nT=e=>oS((t,n)=>cp(()=>{let n=[],r,i=iT(e=>{e._tag===`Retry`?r=e:n.push(e)},e),a=B(t,e=>{for(let t=0;t<e.length;t++){let n=i.feed(e[t]);if(n!==void 0)return z(n)}return lp});return sp(function e(){if(Io(n)){let e=n;return n=[],R(e)}return r?z(r):B(a,e)})})),rT=(e,t,n)=>gS(nT(t),CS(oT.pipe(nx(e,sT)),n)());function iT(e,t){let n=t?.maxEventSize??tT,r,i,a,o,s,c,l,u;return d(),{feed:f,reset:d};function d(){r=!0,i=``,a=0,o=-1,s=!1,c=void 0,l=void 0,u=``}function f(e){i=i?i+e:e,r&&i.startsWith(aT)&&(i=i.slice(aT.length)),r=!1;let t=i.length,c=0;for(;c<t;){s&&=(i[c]===`
10
- `&&++c,!1);let e=-1,n=o,r;for(let o=c+a;e<0&&o<t;++o)r=i[o],r===`:`&&n<0?n=o-c:r===`\r`?(s=!0,e=o-c):r===`
11
- `&&(e=o-c);if(e<0){a=t-c,o=n;break}a=0,o=-1,p(i,c,n,e),c+=e+1}if(c===t?i=``:c>0&&(i=i.slice(c)),i.length+u.length>n){let e=new eT({reason:new $w({maxEventSize:n})});return d(),e}}function p(t,n,r,i){if(i===0){u.length>0&&(e({_tag:`Event`,id:c,event:l||`message`,data:u.slice(0,-1)}),u=``),l=void 0;return}let a=r<0,o=t.slice(n,n+(a?i:r)),s=0;s=a?i:t[n+r+1]===` `?r+2:r+1;let d=n+s,f=i-s,p=t.slice(d,d+f).toString();o===`data`?u+=p?`${p}\n`:`
12
- `:o===`event`?l=p:o===`id`&&!p.includes(`\0`)?c=p:o===`retry`&&/^\d+$/.test(p)&&e(new lT({duration:fs(parseInt(p,10)),lastEventId:c}))}}var aT=``,oT=J({_tag:ax(`Event`),id:tx(q),event:q,data:q}),sT=Fg({decode:e=>e.id===void 0?{event:e.event,data:e.data}:{id:e.id,event:e.event,data:e.data},encode:e=>({_tag:`Event`,id:e.id,event:e.event??`message`,data:e.data})}),cT=`~effect/encoding/Sse/Retry`,lT=class e extends Ps(`Retry`){[cT]=cT;static is(e){return S(e,cT)}static filter(t){return e.is(t)?yo(t):bo(t)}},uT=`~effect/http-api/HttpApiSchema/Stream`;function dT(e){let t=typeof e==`string`?Zw(e):e;return e=>e.annotate({httpApiStatus:t})}var fT=(e=>Wb.pipe(dT(e)))(204),pT=e=>Nb(e)&&S(e,uT),mT=e=>pT(e)&&e._tag===`StreamSse`,hT=e=>pT(e)&&e._tag===`StreamUint8Array`,gT=`~effect/http-api/HttpApiSchema/WithHeaders`,_T=`~effect/http-api/HttpApiSchema/WithHeadersValue`,vT=e=>({[_T]:_T,body:e.body,headers:e.headers}),yT=e=>Nb(e)&&S(e,`~effect/http-api/HttpApiSchema/WithHeaders`);function bT(e,t,n){return K(e.ast,{[gT]:gT,schema:t,headers:n})}function xT(e,t){return e.annotate({"~httpApiEncoding":{_tag:t._tag,contentType:t.contentType??ST(t._tag)}})}function ST(e){switch(e){case`Multipart`:return`multipart/form-data`;case`Json`:return`application/json`;case`FormUrlEncoded`:return`application/x-www-form-urlencoded`;case`Uint8Array`:return`application/octet-stream`;case`Text`:return`text/plain`}}function CT(e){return t=>xT(t,{_tag:`Json`,...e})}function wT(e){return t=>xT(t,{_tag:`FormUrlEncoded`,...e})}var TT=e=>{if(Zg(e)||Zg(Kv(e)))return!0;let t=e.encoding?.[0].to;return t!==void 0&&Zg(t)},ET=cy(`~httpApiEncoding`),DT=cy(`~httpApiWithHeaders`),OT=cy(`httpApiStatus`),kT={_tag:`Json`,contentType:`application/json`},AT={_tag:`FormUrlEncoded`,contentType:`application/x-www-form-urlencoded`};function jT(e){return ET(e)??kT}function MT(e,t){return ET(e)||(RC(t)?kT:AT)}function NT(e){let t=jT(e);if(t._tag===`Multipart`)throw Error(`Multipart is not supported in response`);return t}function PT(e){return OT(e)??200}function FT(e){return yT(e)?OT(e.ast)??PT(e.schema.ast):PT(e.ast)}function IT(e){return yT(e)&&ET(e.ast)===void 0?NT(e.schema.ast):NT(e.ast)}function LT(e){return OT(e)??500}function RT(e){return yT(e)?OT(e.ast)??LT(e.schema.ast):LT(e.ast)}function zT(e){let t=e.toLowerCase().trim(),n=t.indexOf(`;`);return n===-1?t:t.slice(0,n).trim()}var BT=`~effect/http-api/HttpApiEndpoint`;function VT(e){let t=[];for(let{schemas:n}of e.payload.values())t.push(...n);return t}function HT(e){let t=Array.from(e.success);return Io(t)?t:[fT]}function UT(e){let t=new Set(e.error),n=e.disableCodecs?x:QT;for(let r of e.middlewares){let e=r;for(let r of e.error)t.add(n(r))}return Array.from(t)}var WT={[BT]:BT,pipe(){return y(this,arguments)},prefix(e){return KT({...GT(this),path:Vw(this.path,e)})},middleware(e){return KT({...GT(this),middlewares:new Set([...this.middlewares,e])})},annotate(e,t){return KT({...GT(this),annotations:oo(this.annotations,e,t)})},annotateMerge(e){return KT({...GT(this),annotations:go(this.annotations,e)})}},GT=e=>({identifier:e.identifier,path:e.path,method:e.method,params:e.params,query:e.query,headers:e.headers,payload:e.payload,success:e.success,error:e.error,annotations:e.annotations,middlewares:e.middlewares,disableCodecs:e.disableCodecs});function KT(e){function t(){}return Object.setPrototypeOf(t,WT),Object.assign(t,e)}var qT=e=>(t,n,r)=>{let i=r?.disableCodecs??!1,a=i?x:Qx;return KT({identifier:t,path:n,method:e,params:JT(r?.params,a),query:JT(r?.query,a),headers:JT(r?.headers,a),payload:YT(r?.payload,e,i),success:ZT(r?.success,e,i),error:$T(r?.error,i),annotations:ro(),middlewares:new Set,disableCodecs:i})};function JT(e,t){if(e!==void 0)return Nb(e)?t(e):t(J(e))}function YT(e,t,n){let r=new Map;if(e===void 0)return r;let i=Array.isArray(e)?e:Nb(e)?[e]:[J(e).pipe(wT())],a=n?x:lE;for(let e of i){let n=MT(e.ast,t),i=zT(n.contentType),o=r.get(i);if(o){if(o.encoding._tag!==n._tag)throw Error(`Multiple payload encodings for content-type: ${n.contentType}`);if(o.encoding._tag===`Multipart`)throw Error(`Multiple multipart payloads for content-type: ${n.contentType}`);o.schemas.push(a(e,t))}else r.set(i,{encoding:n,schemas:[a(e,t)]})}return r}var XT=`effect/http-api/stream/failure`;function ZT(e,t,n){if(e===void 0)return new Set;let r=No(e);return eE(r,t),new Set(n?r:r.map(QT))}var QT=An(e=>pT(e)?e:yT(e)?bT(e,pT(e.schema)?e.schema:cE(e.schema,IT(e)),Qx(e.headers)):sE(e));function $T(e,t){if(e===void 0)return new Set;let n=No(e);for(let e of n)if(pT(yT(e)?e.schema:e))throw Error(`Streaming schemas are not supported in error responses`);return nE(n,RT),new Set(t?n:n.map(QT))}function eE(e,t){let n=!1,r=new Map;for(let i of e){let e=yT(i)?i.schema:i,a=FT(i);if(pT(e)){if(rE(e,t),n)throw Error(`Multiple streaming success responses are not supported`);n=!0;let i=tE(r,a);if(i.noContent)throw Error(`Cannot combine no-content and streaming success responses for status: ${a}`);if(i.bufferedContentTypes.has(zT(e.contentType)))throw Error(`Cannot combine buffered and streaming success responses for status ${a} and content-type: ${e.contentType}`);r.set(a,{...i,stream:e})}else{let t=tE(r,a),n=TT(e.ast);if(t.stream!==void 0){if(n)throw Error(`Cannot combine no-content and streaming success responses for status: ${a}`);let e=IT(i);if(zT(e.contentType)===zT(t.stream.contentType))throw Error(`Cannot combine buffered and streaming success responses for status ${a} and content-type: ${e.contentType}`)}n||t.bufferedContentTypes.add(zT(IT(i).contentType)),t.noContent=t.noContent||n}}nE(e,FT)}function tE(e,t){let n=e.get(t);return n===void 0&&(n={bufferedContentTypes:new Set,noContent:!1},e.set(t,n)),n}function nE(e,t){let n=new Map;for(let r of e){let e=t(r),i=DT(r.ast),a=yT(r)?r.schema:i?.body??r,o=TT(a.ast)?``:zT(pT(a)?a.contentType:IT(r).contentType),s=n.get(e);s===void 0&&(s={headerContentType:void 0,plainContentTypes:new Set},n.set(e,s));let c=()=>Error(`Cannot combine a response with headers with another response for status ${e} and content-type: ${o||`<no content>`}`);if(yT(r)||i!==void 0){if(s.headerContentType!==void 0)throw Error(`Cannot declare multiple responses with headers for status ${e}`);if(s.plainContentTypes.has(o))throw c();s.headerContentType=o}else{if(s.headerContentType===o)throw c();s.plainContentTypes.add(o)}}}function rE(e,t){if(t===`HEAD`)throw Error(`HEAD endpoints cannot declare streaming success responses`);if(mT(e)&&iE(e.events.ast))throw Error(`SSE event name is reserved: ${XT}`)}function iE(e){return aE(Kv(e),new Set)}function aE(e,t){if(t.has(e))return!1;if(t.add(e),i_(e))return e.types.some(e=>aE(e,t));if(a_(e))return aE(e.thunk(),t);if(!r_(e))return!1;let n=e.propertySignatures.find(e=>e.name===`event`);return n!==void 0&&oE(n.type,t)}function oE(e,t){if(t.has(e))return!1;t.add(e);let n=Kv(e);return n===e?$g(e)?e.literal===XT:i_(e)?e.types.some(e=>oE(e,t)):a_(e)?oE(e.thunk(),t):!1:oE(n,t)}function sE(e){let t=NT(e.ast),n=DT(e.ast);return n===void 0?cE(e,t):e.annotate({"~httpApiWithHeaders":{...n,bodyCodec:cE(n.body,t),headersCodec:Qx(n.headers)}})}function cE(e,t){switch(t._tag){case`Json`:return Zx(e);case`FormUrlEncoded`:return Qx(e);case`Text`:case`Uint8Array`:return e}}function lE(e,t){switch(MT(e.ast,t)._tag){case`Json`:return Zx(e);case`FormUrlEncoded`:return Qx(e);case`Text`:case`Uint8Array`:case`Multipart`:return e}}var uE=qT(`POST`),dE=`~effect/http-api/HttpApi`,fE={[dE]:dE,pipe(){return y(this,arguments)},add(...e){let t={...this.groups};for(let n of e)Qr(t,n.identifier,n);return mE({...pE(this),groups:t})},addHttpApi(e){let t={...this.groups};for(let n of Object.keys(e.groups)){let r=e.groups[n];Qr(t,n,r.annotateMerge(go(e.annotations,r.annotations)))}return mE({...pE(this),groups:t})},prefix(e){return mE({...pE(this),groups:Do(this.groups,t=>t.prefix(e))})},middleware(e){return mE({...pE(this),groups:Do(this.groups,t=>t.middleware(e))})},annotate(e,t){return mE({...pE(this),annotations:oo(this.annotations,e,t)})},annotateMerge(e){return mE({...pE(this),annotations:go(this.annotations,e)})}},pE=e=>({identifier:e.identifier,groups:e.groups,annotations:e.annotations}),mE=e=>{function t(){}return Object.setPrototypeOf(t,fE),Object.assign(t,e)},hE=e=>mE({identifier:e,groups:{},annotations:ro()}),gE=(e,t)=>{let n=Object.values(e.groups);for(let r of n){let n=go(e.annotations,r.annotations);t.onGroup({group:r,mergedAnnotations:n});let i=Object.values(r.endpoints);for(let e of i)(!t.predicate||t.predicate({endpoint:e,group:r}))&&t.onEndpoint({group:r,endpoint:e,middleware:e.middlewares,mergedAnnotations:go(n,e.annotations),successes:_E(HT(e),FT),errors:_E(UT(e),RT)})}},_E=(e,t)=>{let n=new Map;return e.forEach(r),n;function r(e){if(pT(yT(e)?e.schema:e))return;let r=t(e),i=n.get(r);i===void 0?n.set(r,[e]):i.push(e)}},vE=class extends j()(`effect/http-api/HttpApi/ParseOptions`){},yE=class extends j()(`effect/http-api/HttpApi/ParamsParseOptions`){},bE=class extends j()(`effect/http-api/HttpApi/QueryParseOptions`){},xE=class extends j()(`effect/http-api/HttpApi/HeadersParseOptions`){},SE=class extends j()(`effect/http-api/HttpApi/PayloadParseOptions`){},CE=class extends j()(`effect/http-api/HttpApi/SuccessParseOptions`){},wE=class extends j()(`effect/http-api/HttpApi/ErrorParseOptions`){},TE=e=>{let t=co(e,vE);return{params:co(e,yE)??t,query:co(e,bE)??t,headers:co(e,xE)??t,payload:co(e,SE)??t,success:co(e,CE)??t,error:co(e,wE)??t}},EE=`~effect/http-api/HttpApiMiddleware`,DE=`~effect/http-api/HttpApiMiddleware/Security`,OE=()=>(e,t)=>{let n=Jr(),r;n!==0&&(Yr(2),r=new globalThis.Error,Yr(n));class i extends j()(e){}let a=i;if(Object.defineProperty(i,"stack",{get(){return r?.stack}}),a[EE]=EE,a.error=kE(t?.error),a.requiredForClient=t?.requiredForClient??!1,t?.security!==void 0){if(Object.keys(t.security).length===0)throw Error(`HttpApiMiddleware.Service: security object must not be empty`);a[DE]=DE,a.security=t.security}return a};function kE(e){return e===void 0?new Set:new Set(Array.isArray(e)?e:[e])}var AE=new Set;function jE(e){if(e===void 0)return AE;let t=Sv(e.ast);return r_(t)&&t.indexSignatures.length===0?new Set(t.propertySignatures.map(e=>String(e.name))):void 0}var ME=class extends j()(`effect/http-api/OpenApi/Description`){},NE=(e,t)=>up(function*(){let n=yield*Dp(),r=t.httpClient.pipe(t?.baseUrl===void 0?x:Sw(nw(t.baseUrl.toString())));function i(e,t,a,o,s){if(s===-1)return r.execute(a);let c=n.mapUnsafe.get(o[s]);return c===void 0?i(e,t,a,o,s-1):c({endpoint:t,group:e,request:a,next(n){return i(e,t,n,o,s-1)}})}gE(e,{predicate:t?.predicate,onGroup(e){t.onGroup?.(e)},onEndpoint(e){let{group:n,endpoint:r,errors:a,successes:o,mergedAnnotations:s}=e,c=TE(s),l=LE(r.path,r.params),u={orElse:rD},d=new Map;for(let[e,t]of a.entries()){let n=UE(t);for(let[t,r]of n.entries())VE(d,e,t,RE(r,c.error,c.headers))}for(let[e,t]of d.entries()){let n=HE(t);u[e]=e=>B(wp(n(e),t=>dp(Rd(Md(new AC({reason:new FC({request:e.request,response:e})})),t))),z)}let f=new Map;for(let[e,t]of o.entries()){let n=UE(t);for(let[t,r]of n.entries())VE(f,e,t,RE(r,c.success,c.headers))}for(let e of qE(r)){let t=KE(e)?e.schema:e;VE(f,FT(e),t.contentType,JE(e,c.success,c.headers))}for(let[e,t]of f.entries())u[e]=HE(t);let p=US(r.params,e=>Mb(e,c.params)),m=VT(r),h=Io(m)?Mb(RC(r.method)?aD(m,r.method):Qb(m),c.payload):void 0,ee=US(r.headers,e=>Mb(e,c.headers)),te=US(r.query,e=>Mb(e,c.query)),ne=Array.from(e.middleware,e=>`${e.key}/Client`),re=Gp(function*(e){let a=JC(r.method)(r.path);if(e!==void 0){if(p!==void 0){let t=yield*p(e.params);a=tw(a,l(t))}if(h!==void 0){if(RC(r.method)){if(e.payload instanceof FormData)a=cw(a,e.payload);else{let t=yield*h(e.payload);a=sw(a,t)}}else{let t=yield*h(e.payload);a=aw(a,t)}}if(ee!==void 0){let t=yield*ee(e.headers);a=QC(a,t)}if(te!==void 0){let t=yield*te(e.query);a=aw(a,t)}}let o=yield*i(n,r,a,ne,ne.length-1);if(e?.responseMode===`response-only`)return o;let s=(u[o.status]??u.orElse)(o,e?.sseOptions),c=yield*t.transformResponse===void 0?s:t.transformResponse(s);return e?.responseMode===`decoded-and-response`?[c,o]:c});t.onEndpoint({...e,endpointFn:re})}})}),PE=(e,t)=>B(_w,n=>FE(e,{...t,httpClient:t?.transformClient?t.transformClient(n):n})),FE=(e,t)=>{let n={};return NE(e,{...t,onGroup({group:e}){e.topLevel||Qr(n,e.identifier,{})},onEndpoint({endpoint:e,endpointFn:t,group:r}){Qr(r.topLevel?n:n[r.identifier],e.identifier,t)}}).pipe(xp(n))},IE=/(\/?):(\w+)(\?)?/g,LE=(e,t)=>{if(t===void 0||!e.includes(`:`))return t=>e;let n=jE(t);return t=>e.replace(IE,(e,r,i,a)=>{if(n!==void 0&&!n.has(i))return e;let o=t[i];if(o===void 0){if(a!==void 0)return``;throw Error(`Missing path parameter: ${i}`)}return`${r}${encodeURIComponent(o)}`})};function RE(e,t,n){let r=e.some(e=>yT(e)||DT(e.ast)!==void 0),i=kb(r?Qb(e.map(e=>BE(e,t,n))):tD(e),t);return e=>B(e.arrayBuffer,r?t=>i({body:t,headers:e.headers}):i)}var zE=J({body:zb,headers:zb});function BE(e,t,n){let r=DT(e.ast),i=r===void 0?yT(e)?{body:e.schema,headers:e.headers,toValue:vT}:{body:e,headers:zb,toValue:e=>e.body}:{body:r.bodyCodec,headers:r.headersCodec,toValue:r.transformation.decode},a=kb(nD(i.body).pipe(nx(i.body)),t),o=kb(i.headers,n);return zE.pipe(nx(yT(e)?e:Ib(e),Pg({decode:e=>ip({body:a(e.body),headers:o(e.headers)}).pipe(bp(i.toValue),Tp(e=>e.issue)),encode:(e,t)=>z(new Yh({message:`Decode only schema`},e,t))})))}function VE(e,t,n,r){let i=zT(n),a=e.get(t);a===void 0?e.set(t,[{contentType:i,decode:r}]):a.push({contentType:i,decode:r})}function HE(e){let t=e[0];return e.length===1&&t!==void 0?t.decode:(t,n)=>{let r=zT(t.headers[`content-type`]??``),i=e.find(e=>e.contentType===r);return i===void 0?WE(t,r,e):i.decode(t,n)}}function UE(e){let t=new Map;for(let n of e){let e=TT((yT(n)?n.schema:n).ast)?``:zT(IT(n).contentType),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return t}function WE(e,t,n){let r=Array.from(new Set(n.map(e=>e.contentType))).join(`, `);return z(new AC({reason:new IC({request:e.request,response:e,description:`Unsupported response content-type for status ${e.status}: ${t||`<missing>`}. Expected one of: ${r}`})}))}var GE=`effect/http-api/stream/failure`,KE=e=>yT(e);function qE(e){let t=[];for(let n of e.success)pT(yT(n)?n.schema:n)&&t.push(n);return t}function JE(e,t,n){let r=KE(e),i=r?e.schema:e,a=hT(i)?void 0:{declaration:i,decoder:YE(i,t)},o=(e,t)=>bp(Dp(),n=>zS(a===void 0?e.stream:XE(e.stream,a.declaration,a.decoder(t)),n));if(!r)return o;let s=kb(e.headers,n);return(e,t)=>B(s(e.headers),n=>bp(o(e,t),e=>vT({body:e,headers:n})))}function YE(e,t){let n=Qb([J({id:Fb(q),event:Lb(GE),data:Ox(Zx(Nx(e.error,Ex())))}),e.events]),r=rT(n,void 0,t);return e=>e===void 0?r:rT(n,e,t)}function XE(e,t,n){let r=jS(e.pipe(LS,IS(n)),e=>cp(()=>{let t;return sp(()=>t===void 0?B(e,e=>{for(let n=0;n<e.length;n++){let r=e[n];if(r.event===GE&&Od(r.data)){if(n===0)return dp(r.data);t=r.data,e=e.slice(0,n);break}}return R(e)}):dp(t))}));return t.sseMode===`data`?FS(r,e=>e.data):r}var ZE=sx(globalThis.ArrayBuffer,{expected:`ArrayBuffer`}),QE=ZE.pipe(nx(jx,Fg({decode(e){return new Uint8Array(e)},encode(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}}))),$E=ZE.pipe(nx(q,Fg({decode(e){return new TextDecoder().decode(e)},encode(e){let t=new TextEncoder().encode(e);return t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}}))),eD=$E.pipe(nx(Qb([Lb(``).pipe(nx(Vb,Fg({decode:()=>void 0,encode:()=>``}))),kx])));function tD(e){return Qb(e.map(t));function t(e){return nD(e).pipe(nx(e))}}function nD(e){switch(NT(e.ast)._tag){case`Json`:return Xg(Kv(e.ast))?eD.pipe(nx(zb,Fg({decode:e=>e===void 0?null:e,encode:e=>e===null?void 0:e}))):eD;case`FormUrlEncoded`:return $E.pipe(nx(Vx,Fg({decode:e=>gh(new URLSearchParams(e)),encode:wh})));case`Uint8Array`:return QE;case`Text`:return $E}}var rD=e=>z(new AC({reason:new IC({request:e.request,response:e})})),iD=xb(_C);function aD(e,t){return Qb(e.map(e=>sD(e,t)))}var oD=new WeakMap;function sD(e,t){let n=e.ast,r=oD.get(n);if(r!==void 0)return r;let i=MT(n,t),a=iD.pipe(nx(e,Pg({decode(e,t){return z(new Yh({message:`Encode only schema`},e,t))},encode(e,t){switch(i._tag){case`Multipart`:return z(new Yh({message:`Payload must be a FormData`},e,t));case`Json`:try{return R(TC(JSON.stringify(e),i.contentType))}catch{return z(new qh({expected:`a JSON-serializable request body`},e,t))}case`Text`:return typeof e==`string`?R(TC(e,i.contentType)):z(new qh({message:`Expected a string`},e,t));case`FormUrlEncoded`:return Kn(e)?R(EC(gh(e),i.contentType)):z(new qh({message:`Expected a record`},e,t));case`Uint8Array`:return e instanceof Uint8Array?R(xC(e,i.contentType)):z(new qh({message:`Expected a Uint8Array`},e,t))}}})));return oD.set(n,a),a}var cD=`~effect/http-api/HttpApiGroup`,lD={[cD]:cD,add(...e){let t={...this.endpoints};for(let n of e)Qr(t,n.identifier,n);return dD({...uD(this),endpoints:t})},prefix(e){return dD({...uD(this),endpoints:Do(this.endpoints,t=>t.prefix(e))})},middleware(e){return dD({...uD(this),endpoints:Do(this.endpoints,t=>t.middleware(e))})},annotateMerge(e){return dD({...uD(this),annotations:go(this.annotations,e)})},annotate(e,t){return dD({...uD(this),annotations:oo(this.annotations,e,t)})},annotateEndpointsMerge(e){return dD({...uD(this),endpoints:Do(this.endpoints,t=>t.annotateMerge(e))})},annotateEndpoints(e,t){return dD({...uD(this),endpoints:Do(this.endpoints,n=>n.annotate(e,t))})},pipe(){return y(this,arguments)}},uD=e=>({identifier:e.identifier,topLevel:e.topLevel,endpoints:e.endpoints,annotations:e.annotations}),dD=e=>{function t(){}return Object.setPrototypeOf(t,lD),t.key=`effect/http-api/HttpApiGroup/${e.identifier}`,Object.assign(t,e)},fD=(e,t)=>dD({identifier:e,topLevel:t?.topLevel??!1,endpoints:{},annotations:ro()}),pD=`~effect/http-api/HttpApiSecurity`,mD={[pD]:pD,pipe(){return y(this,arguments)}},hD=(e=>Object.assign(Object.create(mD),{_tag:`Http`,scheme:e.scheme,schemeLength:e.scheme.length,annotations:ro()}))({scheme:`Bearer`}),gD=e=>Object.assign(Object.create(mD),{_tag:`ApiKey`,key:e.key,in:e.in??`header`,annotations:ro()}),_D=cy(`httpApiStatus`),vD=e=>_D(e)??(a_(e)?vD(e.thunk()):void 0),yD=e=>{let t=vD(e.ast);if(t!==void 0)return[_D(e.ast)===void 0?dT(t)(e):e];let n=sC(e.ast);return i_(n)&&n.checks===void 0&&n.encoding===void 0?n.types.flatMap(e=>yD(K(e))):[dT(422)(e)]},bD=(e,t={})=>bp(PE(e.api,t),e=>{let t=e;return e=>{let n=t[e.name];if(n===void 0)throw Error(`No client method for ${e.name}`);let r=Mb(Zx(e.input),{errors:`all`});return(...t)=>fC(e,t).pipe(vp(r),Tp(JS.fromSchemaError),B(e=>n({payload:e})))}}),xD=e=>(e??`/api`).split(`/`).filter(e=>e!==``),SD=e=>`/${e.join(`/`)}`,CD=e=>e.join(`/`)||`/`,wD=(e,t)=>{let n=fD(e,{topLevel:!0}),[r,...i]=t;return hE(`actions`).annotate(vE,{errors:`all`}).add(r===void 0?n:n.add(r,...i))},TD=(e,t,n)=>uE(e.name,t,{payload:e.input.pipe(CT()),success:e.success,error:tC(e,n).flatMap(yD)});function ED(e,t={}){oC(`action`,e);let n=eC(t.error);dC(`ActionHttp binding`,n),hC(e,t.authentication);let r=xD(t.prefix),i=t.authentication?.[`~middleware`],a=t.authentication?.error??[],o=e.map(e=>{let t=i===void 0||e.caller===nC,o=TD(e,SD([...r,e.name]),t?n:[...n,...a]).annotate(ME,e.description);return t?o:o.middleware(i)}),s=wD(CD(r),o);return{actions:e,error:n,prefix:SD(r),api:s,authentication:t.authentication}}OE()(`effect-actions/ActionHttp/StepUp`),OE()(`effect-actions/ActionHttp/JsonContentType`);var DD=(e,t)=>bp(bD(e,t),t=>Object.fromEntries(e.actions.map(e=>[e.name,t(e)])));function OD(e,{fetch:t,...n}={}){return DD(e,n).pipe(kp(Nw),Mp(jw,t??((e,t)=>globalThis.fetch(e,t))),Up)}var kD=/^[\w.-]+$/,AD=(e,t,...n)=>{let r=n[0]?.security??hD,i=eC(n[0]?.error);if(!kD.test(e))throw Error(`Invalid authentication name: ${JSON.stringify(e)}, not an OpenAPI key`);if(dC(`Authentication "${e}"`,i),!Jn(r,`Http`)&&!Jn(r,`ApiKey`)&&!Jn(r,`Basic`))throw Error(`Authentication takes one native HttpApiSecurity scheme`);return{name:e,identity:t,security:r,error:i,"~provider":j(`effect-actions/Authentication/Provider/${e}`),"~middleware":OE()(`effect-actions/Authentication/Security/${e}`,{security:{[e]:r}}),"~verified":j(`effect-actions/Authentication/Verified/${e}`)}},jD=[class extends Xx()(`BadRequest`,{error:q},{httpApiStatus:400}){},class extends Xx()(`NotFound`,{error:q},{httpApiStatus:404}){},class extends Xx()(`Conflict`,{error:q},{httpApiStatus:409}){},class extends Xx()(`TooManyRequests`,{error:q},{httpApiStatus:429}){},class extends Xx()(`InternalServerError`,{error:q},{httpApiStatus:500}){cause},class extends Xx()(`ServiceUnavailable`,{error:q},{httpApiStatus:503}){}];[...jD];var MD=class extends j()(`clankerauth/CurrentOwner`){},ND=(e=>AD(`clankerauth.OwnerSession`,MD,{security:gD({in:`cookie`,key:e}),error:jD}))(`better-auth.session_token`);AD(`clankerauth.OwnerToken`,MD,{error:jD});var PD=J({email:q,password:q}),FD=$b([`none`,`client_secret_basic`,`client_secret_post`]),ID=$b([`web`,`native`]),LD=Y(q).check(Sx({message:`Choose unique Resources`})),RD=J({client_name:q,redirect_uris:Y(q),resources:LD,token_endpoint_auth_method:FD,application_type:ID}),zD=J({client_id:q,client_name:q,redirect_uris:Y(q),application_type:ID}),BD=J({client_id:q}),VD=J({client_id:q,resource:Fb(q)}),HD=J({client_id:q,blocked:Ub}),UD=J({onboarding:Fb($b([`managed`,`dcr`,`cimd`])),blocked:Fb(Ub),client_id:q,client_name:Fb(q),redirect_uris:Y(q),token_endpoint_auth_method:Fb(q),application_type:Fb(ex(q)),scope:Fb(q),grant_types:Fb(Y(q))}),WD=UD.pipe(Kb({client_secret:Fb(q),client_secret_expires_at:Fb(Hb)})),GD=J({identifier:q,name:q,scopes:Y(q)}),KD=GD.pipe(Kb({builtIn:Ub})),qD=J({identifier:q,name:q.check(ux(/\S/u,{message:`Resources require a name`})),scopes:Y(q.check(ux(/^\s*[\x21\x23-\x5B\x5D-\x7E]+\s*$/u,{message:`Resources require well-formed custom scopes`})))}),JD=J({identifier:q}),YD=J({client_id:q,resource:q}),XD=J({client_id:q,resources:LD}),ZD=J({clientAccess:Y(YD)}),QD=qb(q,Y(q)),$D=qb(q,Y(q).check(_x(1,{message:`Select explicitly granted, currently available Resource scopes`}),Sx({message:`Select explicitly granted, currently available Resource scopes`}))).check(xx(1,{message:`Select at least one Resource and scope`})),eO=q.check(yx(100,{message:`Key names require 1–100 characters`}),ux(/\S/u,{message:`Key names require 1–100 characters`})),tO=Bx,nO=J({client_id:q,resource:q,scopes:Y(q),approvedAt:ex(tO),refreshedAt:ex(tO)}),rO=J({name:eO,permissions:$D,expiresAt:ex(tO)}),iO=J({keyId:q}),aO=J({keyId:q,name:Fb(eO),permissions:Fb($D),enabled:Fb(Ub)}),oO=J({keyId:q,name:q,enabled:Ub,permissions:QD,expiresAt:ex(tO),createdAt:tO}),sO={caller:nC,error:jD},cO={caller:MD,error:jD},lO=[X(`setupStatus`,{description:`Check whether the issuer needs its first owner account.`,readOnly:!0,...sO,success:J({required:Ub})}),X(`setupOwner`,{description:`Create the first owner account.`,readOnly:!1,...sO,input:PD,success:J({created:Ub}).pipe(dT(201))}),X(`keyList`,{description:`The signed list a resource server verifies API keys against: one sealed entry per key granted on the resource, readable only with that key.`,readOnly:!0,...sO,input:J({resource:q}),success:J({list:q})})],uO=J({clients:Y(UD),resources:Y(KD),clientAccess:Y(YD),connections:Y(nO),email:q,issuer:q}),dO=[X(`listClients`,{description:`List clients, resources, managed clients' resource access (what they may obtain), and every client's connections (what it holds).`,readOnly:!0,...cO,success:uO}),X(`createClient`,{description:`Register a first-party OAuth client. Returns its secret once when confidential.`,readOnly:!1,...cO,input:RD,success:WD.pipe(dT(201))}),X(`updateClient`,{description:`Rename a first-party client or change its redirect URIs and application type.`,readOnly:!1,...cO,input:zD,success:UD}),X(`deleteClient`,{description:`Delete a client and its stored authorization. An automatic client can register again; block it to keep it out.`,readOnly:!1,...cO,input:BD,success:J({deleted:Ub})}),X(`revokeClient`,{description:`Revoke a client’s stored authorization, for one resource or all. It must authorize again; an automatic client asks for consent.`,readOnly:!1,...cO,input:VD,success:J({revoked:Ub})}),X(`blockClient`,{description:`Block or unblock OAuth authorization for a client.`,readOnly:!1,...cO,input:HD,success:J({blocked:Ub})}),X(`rotateClientSecret`,{description:`Rotate a confidential client secret. Returns the new secret once.`,readOnly:!1,...cO,input:BD,success:WD}),X(`setClientAccess`,{description:`Set the resources a managed client may obtain. Removing one revokes its authorization for it. Automatic clients may ask for any resource with consent.`,readOnly:!1,...cO,input:XD,success:ZD}),X(`createResource`,{description:`Create an OAuth resource and its scopes.`,readOnly:!1,...cO,input:qD,success:GD.pipe(dT(201))}),X(`updateResource`,{description:`Update an OAuth resource and its scopes.`,readOnly:!1,...cO,input:qD,success:GD}),X(`deleteResource`,{description:`Delete a resource, its client access and every client’s authorization for it. API-key permissions are retained; recreating the resource restores them.`,readOnly:!1,...cO,input:JD,success:J({deleted:Ub})}),X(`listApiKeys`,{description:`List API key metadata without secret values.`,readOnly:!0,...cO,success:J({keys:Y(oO)})}),X(`createApiKey`,{description:`Create a scoped API key. Returns its secret once.`,readOnly:!1,...cO,input:rO,success:oO.pipe(Kb({key:q}),dT(201))}),X(`updateApiKey`,{description:`Update an API key’s name, permissions or enabled state.`,readOnly:!1,...cO,input:aO,success:oO}),X(`deleteApiKey`,{description:`Delete an API key.`,readOnly:!1,...cO,input:iO,success:J({deleted:Ub})})],Z=OD((e=>ED([...dO,...lO],{authentication:e}))(ND)),fO=Ob(Qb(jD)),pO=Ob($S),mO=e=>fO(e)?Error(e.error):e instanceof JS&&e.issues.length?Error([...new Set(e.issues.map(e=>e.message))].join(` `)):pO(e)?Error(e.message):Error(`Request could not be completed. Please try again.`);async function Q(e){try{return await Hp(e)}catch(e){throw mO(e)}}var hO=pn({plugins:[Sn()]}),gO=document.querySelector(`#app`);gO.innerHTML=`<header><a href="/" class="brand"><span class="mark">c.</span> clanker<span class="muted">auth</span></a><span class="tag">PRIVATE IDENTITY</span></header><main id="main"></main><footer>Local accounts. Explicit access.<span>Self-hosted authorization server</span></footer>`;var _O=document.querySelector(`#main`),$=e=>e.replace(/[&<>"']/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`})[e]);function vO(e){let t=document.querySelector(`#message`);t.textContent=e,e&&t.hasAttribute(`tabindex`)&&(t.focus(),t.scrollIntoView({behavior:`smooth`,block:`center`}))}var yO=!1;async function bO(e){if(yO)return;yO=!0;let t=Array.from(_O.querySelectorAll(`button`),e=>({button:e,disabled:e.disabled}));t.forEach(({button:e})=>e.disabled=!0),vO(``);try{await e()}catch(e){vO(e instanceof Error?e.message:`Request failed`)}finally{t.forEach(({button:e,disabled:t})=>e.disabled=t),yO=!1}}function xO(e,t){!yO&&confirm(e)&&bO(t)}function SO(){_O.innerHTML=`<section class="intro"><p class="eyebrow">YOUR NETWORK, YOUR IDENTITY</p><h1>Your identity.<br>Starts here.</h1><p>Create the owner account for your private applications.<br>Your account stays on your infrastructure.</p><div class="note"><span class="dot"></span> One owner · Explicit access</div></section>
13
- <section class="card login"><p class="eyebrow">FIRST-TIME SETUP</p><h2>Create your account</h2><p class="muted">This account manages Clients and Resources and approves access.</p>
14
- <form id="setup"><label>Email<input name="email" type="email" autocomplete="username" required placeholder="owner@example.internal"></label>
15
- <label>Password<input name="password" type="password" autocomplete="new-password" required minlength="8" maxlength="128" aria-describedby="password-help"></label><p id="password-help" class="help">Use 8–128 characters. Save your password somewhere safe.</p>
16
- <label>Confirm password<input name="confirmation" type="password" autocomplete="new-password" required minlength="8" maxlength="128"></label>
17
- <p id="message" role="alert"></p><button>Create account <span>→</span></button></form></section>`;let e=document.querySelector(`#setup`);e.addEventListener(`submit`,t=>{t.preventDefault(),bO(async()=>{let t=e.querySelector(`[name="password"]`).value,n=e.querySelector(`[name="confirmation"]`).value;if(t.length<8||t.length>128)throw Error(`Use a password between 8 and 128 characters.`);if(t!==n)throw Error(`Passwords do not match.`);let r=await Q(Z.setupOwner({email:e.querySelector(`[name="email"]`).value,password:t}).pipe(xp(`/`),Cp(`Conflict`,()=>R(`/login`))));location.replace(r)})})}function CO(){_O.innerHTML=`<section class="intro"><p class="eyebrow">YOUR NETWORK, YOUR IDENTITY</p><h1>One identity.<br>Deliberate access.</h1><p>Sign in to authorize your private applications.<br>Your account stays on your infrastructure.</p><div class="note"><span class="dot"></span> Password login · No external identity provider</div></section>
18
- <section class="card login"><p class="eyebrow">OWNER ACCESS</p><h2>Welcome back</h2><p class="muted">Use your local account to continue.</p>
19
- <form id="login"><label>Email<input name="email" type="email" autocomplete="username" required placeholder="owner@example.internal"></label>
20
- <label>Password<input name="password" type="password" autocomplete="current-password" required></label>
21
- <p id="message" role="alert"></p><button>Sign in <span>→</span></button></form></section>`;let e=document.querySelector(`#login`);e.addEventListener(`submit`,t=>{t.preventDefault(),bO(async()=>{if((await hO.signIn.email({email:e.querySelector(`[name="email"]`).value,password:e.querySelector(`[name="password"]`).value})).error)throw Error(`Sign-in failed. Check your credentials or try again later.`);let t=new URLSearchParams(location.search),n=t.get(`rd`)??`/`;t.has(`sig`)||location.assign(new URL(n,location.origin).origin===location.origin?n:`/`)})})}async function wO(){let e=new URLSearchParams(location.search),t=e.get(`client_id`);if(!t||!e.has(`sig`))throw Error(`Start authorization from your application; this consent link is incomplete.`);let n=await hO.oauth2.publicClient({query:{client_id:t}});if(n.error||!n.data)throw Error(`Sign in through your application to continue authorization.`);let r=(e.get(`scope`)??``).split(` `).filter(Boolean),i=e.getAll(`resource`),a;try{let e=new URL(t);e.protocol===`https:`&&(a=e.hostname)}catch{}let o=e.get(`redirect_uri`);_O.className=`center`,_O.innerHTML=`<section class="card consent"><p class="eyebrow">PERMISSION REQUEST</p><h1>Allow this connection?</h1>
22
- <p><strong>${$(n.data.client_name??t)}</strong> wants to act on your behalf.</p>
23
- ${a?`<p>Client metadata host: <strong>${$(a)}</strong></p>`:``}
24
- <label>Client ID<code>${$(t)}</code></label>
25
- <label>Callback destination<code>${$(o??`Not supplied in this request`)}</code></label>
26
- <p class="help">The client supplies its display name. Review the identifier and callback before approving.</p>
27
- <div class="resource"><span class="eyebrow">ONLY FOR THIS RESOURCE</span>${i.map(e=>`<code>${$(e)}</code>`).join(``)}</div>
28
- <form id="consent"><h3>Requested access</h3><ul class="scopes">${r.map(e=>`<li><label class="checkbox"><input type="checkbox" name="scope" value="${$(e)}" checked><code>${$(e)}</code></label></li>`).join(``)}</ul>
29
- <p class="help">Untick anything this Client should not get. It receives only what stays ticked.</p>
30
- ${e.has(`claims`)?`<h3>Additional identity claims</h3><pre>${$(e.get(`claims`))}</pre>`:``}
31
- <p class="help">Access tokens expire after fifteen minutes. Offline access lets the Client renew them until you revoke its authorization.</p>
32
- <p id="message" role="alert"></p><div class="actions"><button type="submit" name="decision" value="deny" class="secondary">Deny</button><button type="submit" name="decision" value="allow">Allow access →</button></div></form></section>`;let s=document.querySelector(`#consent`);s.addEventListener(`submit`,e=>{e.preventDefault();let t=e.submitter;if(!(t instanceof HTMLButtonElement))throw Error(`Consent must be decided with the Allow or Deny button.`);let n=t.value===`allow`,i=Array.from(new FormData(s).getAll(`scope`),String);bO(async()=>{if(n&&r.length&&!i.length)throw Error(`Tick at least one permission, or deny the request.`);if((await hO.oauth2.consent(n&&i.length?{accept:n,scope:i.join(` `)}:{accept:n})).error)throw Error(`Authorization could not be completed. Restart from your application.`)})})}function TO(e,t){let n=e.get(t);if(n===null||n instanceof File)throw Error(`Missing form field: ${t}`);return n.trim()}function EO(e){return Array.from(e.querySelectorAll(`input[name="resources"]:checked`),e=>e.value)}function DO(e){let t=[...new Set(TO(e,`scopes`).split(/\s+/).filter(Boolean))];return{name:TO(e,`name`),scopes:t}}function OO(e){let t=[...new Set(TO(e,`redirect_uris`).split(/\s+/).filter(Boolean))];if(!t.length)throw Error(`Add at least one redirect URI.`);return t}var kO={none:`Public client (PKCE only)`,client_secret_basic:`Confidential client · HTTP Basic secret`,client_secret_post:`Confidential client · secret in request body`},AO=e=>jb(FD)(TO(e,`token_endpoint_auth_method`)),jO=e=>jb(ID)(e.has(`native`)?`native`:`web`);function MO(e){let t={};for(let n of e.querySelectorAll(`input[name="key-scope"]:checked`))(t[n.dataset.resource]??=[]).push(n.value);return t}var NO=new Map,PO=new Map;function FO(){let e=document.querySelector(`#credentials`);if(e.classList.toggle(`hidden`,PO.size===0&&NO.size===0),e.replaceChildren(),!PO.size&&!NO.size)return;e.innerHTML=`<h2>Save these credentials now</h2><p>API keys and client secrets are shown only once.</p><button class="secondary">Saved — dismiss credentials</button>`;let t=e.querySelector(`button`);for(let e of PO.values()){let n=document.createElement(`pre`);n.textContent=JSON.stringify(e,null,2),t.before(n)}for(let e of NO.values()){let n=document.createElement(`pre`);n.textContent=e,t.before(n)}t.addEventListener(`click`,()=>{NO.clear(),PO.clear(),FO()})}function IO(){FO(),document.querySelector(`#credentials`).scrollIntoView({behavior:`smooth`})}async function LO(){try{await ek()}catch{document.querySelector(`#dashboard-mutations`).disabled=!0,vO(`Saved, but the dashboard could not refresh.`);let e=document.createElement(`button`);e.type=`button`,e.className=`secondary`,e.textContent=`Retry refresh`,e.addEventListener(`click`,()=>{bO(LO)}),document.querySelector(`#message`).append(` `,e)}}var RO=`Optional. Separate scopes with spaces. offline_access is reserved.`,zO={managed:`Managed registration · first party, no consent screen`,dcr:`Dynamic registration`,cimd:`Client ID Metadata Document`},BO=e=>!e.onboarding||e.onboarding===`managed`,VO=(e,t,n,r,i)=>`<div class="columns dashboard-section"><section><h2>${e} <span class="count">${t}</span></h2><p class="muted">${n}</p>${r}</section><section class="card registration">${i}</section></div>`,HO=(e,t)=>`<div class="empty"><h3>${e}</h3><p>${t}</p></div>`,UO=e=>`<code>${$(e.identifier)}</code><span class="muted">${$(e.scopes.join(` · `))}</span>`,WO=(e,t)=>e.map(e=>`<label class="checkbox resource-choice"><input type="checkbox" name="resources" value="${$(e.identifier)}" ${t.includes(e.identifier)?`checked`:``}><span>${$(e.name)}${UO(e)}</span></label>`).join(``),GO=(e,t)=>e.map(e=>`<fieldset><legend>${$(e.name)}</legend><code>${$(e.identifier)}</code>${e.scopes.map(n=>`<label class="checkbox"><input type="checkbox" name="key-scope" data-resource="${$(e.identifier)}" value="${$(n)}" ${t[e.identifier]?.includes(n)?`checked`:``}><code>${$(n)}</code></label>`).join(``)}</fieldset>`).join(``)||`<p class="help">Add a Resource to grant access.</p>`,KO=(e,t)=>`<article class="resource"><h3>${$(e.name)}</h3>${UO(e)}
33
- <p class="help dependencies">Connected Clients: ${t.length?t.map(e=>$(e.client_name??e.client_id)).join(`, `):`None`}</p>
34
- ${e.builtIn?`<p class="help">Built-in administration resource, fixed. OAuth access tokens are required. clankerauth:read allows listing; clankerauth:write also allows every change.</p>`:`<details><summary>Edit resource</summary><form data-resource-edit="${$(e.identifier)}"><label>Name<input name="name" value="${$(e.name)}" required maxlength="100"></label><label>Scopes<input name="scopes" value="${$(e.scopes.join(` `))}"></label><p class="help">Added scopes need new consent. Removed scopes are no longer issued, but approvals are kept and work again if the scope is restored.</p><button>Save resource</button></form></details>
35
- <button class="danger" data-resource-delete="${$(e.identifier)}">Delete resource</button>`}</article>`,qO=()=>`<h2>Add resource</h2><form id="resource-create"><label>Name<input name="name" required maxlength="100" placeholder="Notes MCP"></label><label>HTTP or HTTPS identifier<input name="identifier" type="url" required placeholder="https://notes.internal/mcp"></label><p class="help">The identifier is the token audience and cannot be changed later. Use the canonical form a client sends back, such as the application\u2019s origin root with its trailing slash.</p><label>Scopes<input name="scopes" placeholder="notes:read notes:write"></label><p class="help">${RO}</p><button>Add resource +</button></form>`,JO=(e,t)=>`<article class="resource"><h3>${$(e.name)}</h3><p>${e.enabled?`Enabled`:`Disabled`} · ${e.expiresAt?`Expires ${$(Dm(e.expiresAt,{dateStyle:`medium`,timeStyle:`short`}))}`:`Valid until revoked`}</p>${Object.entries(e.permissions).map(([e,t])=>`<code>${$(e)}</code><p class="help">${$(t.join(` · `))}</p>`).join(``)}
36
- <details><summary>Rename key</summary><form data-key-rename="${$(e.keyId)}"><label>Name<input name="name" required maxlength="100" value="${$(e.name)}"></label><button>Save name</button></form></details>
37
- <details><summary>Edit grants</summary><form data-key-grants="${$(e.keyId)}">${GO(t,e.permissions)}<p class="help">Saving replaces all grants, including any not currently available, with the selected scopes.</p><button>Save grants</button></form></details>
38
- <div class="actions"><button class="secondary" data-key-toggle="${$(e.keyId)}" data-enabled="${e.enabled}">${e.enabled?`Disable key`:`Enable key`}</button><button class="danger" data-key-delete="${$(e.keyId)}">Delete key</button></div></article>`,YO=e=>`<h2>Create API key</h2><form id="key-create"><label>Name<input name="name" required maxlength="100" placeholder="Backup script"></label>${GO(e,{})}<label>Expiry (optional)<input name="expiry" type="datetime-local"></label><p class="help">Blank means valid until revoked. The key is shown once and works within about a minute.</p><button ${e.length?``:`disabled`}>Create API key</button></form>`,XO=e=>$(Dm(e,{dateStyle:`medium`,timeStyle:`short`})),ZO=(e,t)=>{let n=t.find(t=>t.identifier===e.resource),r=[e.approvedAt?`Approved ${XO(e.approvedAt)}`:`First party, no consent`,e.refreshedAt?`last token ${XO(e.refreshedAt)}`:`no refresh token`].join(` · `);return`<div class="allowed-resource connection"><strong>${$(n?.name??e.resource)}</strong><code>${$(e.resource)}</code><span class="muted">${$(e.scopes.join(` · `)||`No Resource scopes`)}</span><p class="help">${r}</p><button class="secondary" data-disconnect="${$(e.client_id)}" data-resource="${$(e.resource)}">Revoke</button></div>`},QO=(e,t,n,r)=>{let i=BO(e),a=$(e.client_id),o=r.map(e=>ZO(e,t)).join(``)||`<p class="help">${i?`Holds no refresh token.`:`No Resource approved yet.`}</p>`,s=i?`<details><summary>Allowed Resources · ${n.length} of ${t.length}</summary><form data-client-access="${a}"><fieldset><legend>Allowed Resources</legend>${WO(t,n)||`<p class="help">Add a Resource above to configure access.</p>`}</fieldset><p class="help">This Client skips consent for the Resources ticked here. Unticking one revokes its authorization for it.</p><button>Save access</button></form></details>`:`<p class="help">May ask for any Resource; each needs your consent. Revoke a connection, or block the Client to keep it out.</p>`,c=i?`<details><summary>Edit client</summary><form data-client-edit="${a}"><label>Client name<input name="name" required maxlength="100" value="${$(e.client_name??``)}"></label><label>Redirect URIs (one per line)<textarea name="redirect_uris" required rows="3">${$(e.redirect_uris.join(`
39
- `))}</textarea></label><label class="checkbox"><input type="checkbox" name="native" ${e.application_type===`native`?`checked`:``}>Native / desktop client (loopback redirect)</label><p class="help">The authentication method is fixed at registration.</p><button>Save client</button></form></details>`:``,l=[`<button class="secondary" data-revoke="${a}">Revoke all</button>`,`<button class="secondary" data-block="${a}" data-blocked="${e.blocked?`true`:`false`}">${e.blocked?`Unblock client`:`Block client`}</button>`,i&&e.token_endpoint_auth_method!==`none`?`<button class="secondary" data-rotate="${a}">Rotate secret</button>`:``,`<button class="danger" data-delete="${a}" data-managed="${i}">Delete client</button>`].join(``);return`<article class="card client"><div class="client-heading"><h3>${$(e.client_name??`Unnamed client`)}</h3><span class="tag">${e.token_endpoint_auth_method===`none`?`PUBLIC · PKCE`:`CONFIDENTIAL · PKCE`}</span></div><p class="help">${zO[e.onboarding??`managed`]}${e.blocked?` · BLOCKED`:``}</p><label>Client ID<code>${a}</code></label><label>Redirect URIs${e.redirect_uris.map(e=>`<code>${$(e)}</code>`).join(``)}</label>
40
- <h3>Connections</h3>${o}${s}${c}<div class="actions">${l}</div></article>`},$O=e=>`<p class="eyebrow">MANAGED REGISTRATION</p><h2>Register client</h2><form id="register"><fieldset><label>Client name<input name="name" required maxlength="100" placeholder="My MCP client"></label><label>Redirect URIs (one per line)<textarea name="redirect_uris" required rows="3" placeholder="https://app.internal/callback"></textarea></label><fieldset><legend>Allowed Resources (optional)</legend>${WO(e,[])||`<p class="help">You can configure Resource access after registration.</p>`}</fieldset><label class="checkbox"><input type="checkbox" name="native">Native / desktop client (loopback redirect)</label><label>Client authentication<select name="token_endpoint_auth_method">${Object.entries(kO).map(([e,t])=>`<option value="${e}">${t}</option>`).join(``)}</select></label><button>Register client +</button></fieldset><p class="help">S256 PKCE is always required. Clients you register here are first party and skip the consent screen.</p></form>`;async function ek(){let[e,t]=await Q(ip([Z.listClients(),Z.listApiKeys()],{concurrency:`unbounded`})),{resources:n}=e,r=n.filter(e=>!e.builtIn),i=t=>e.clientAccess.filter(e=>e.client_id===t).map(e=>e.resource),a=t=>e.connections.filter(e=>e.client_id===t);_O.className=`dashboard`,_O.innerHTML=`
41
- <div class="page-title"><div><p class="eyebrow">CONTROL PLANE</p><h1>Clients and Resources</h1><p class="muted">Signed in as ${$(e.email)}</p></div><button id="logout" class="secondary">Sign out</button></div>
42
- <div class="issuer"><span class="dot"></span><span>Canonical issuer</span><code>${$(e.issuer)}</code></div>
43
- <p id="message" role="alert" tabindex="-1"></p>
44
- <section id="credentials" class="card hidden" aria-live="polite"></section>
45
- <fieldset id="dashboard-mutations" aria-label="Clients and Resources">
46
- ${VO(`Resources`,n.length,`Protected APIs and MCP servers, and the scopes they define.`,n.map(t=>KO(t,e.clients.filter(e=>a(e.client_id).some(e=>e.resource===t.identifier)))).join(``)||HO(`Add your first Resource`,`Define a protected API or MCP server. Compatible MCP clients onboard automatically when you connect.`),qO())}
47
- ${VO(`API keys`,t.keys.length,`Direct access for CLIs and automation. Keys carry only the scopes you select, filtered by current Resource policy. Policy changes do not revoke stored grants; restoring policy restores access. Resource servers verify keys offline: a new key works within seconds and a key's expiry applies at once; any other change takes effect within about a minute, and a Resource server that cannot reach this issuer keeps accepting the keys it last saw for up to 24 hours.`,t.keys.map(e=>JO(e,r)).join(``)||HO(`No API keys`,`Create a key for a CLI or automation that needs direct access.`),YO(r))}
48
- ${VO(`Clients`,e.clients.length,`Compatible MCP clients register themselves when they connect; registration alone grants no access. Revoking or blocking stops new authorization and refresh at once; already-issued access tokens stay valid until they expire, at most fifteen minutes.`,e.clients.map(e=>QO(e,n,i(e.client_id),a(e.client_id))).join(``)||HO(`No Clients registered`,`Connect your MCP client to a configured server to onboard automatically, or register a managed Client here.`),$O(n))}
49
- </fieldset>`,FO();let o=e=>document.querySelector(e),s=(e,t)=>e.addEventListener(`submit`,n=>{n.preventDefault(),bO(()=>t(e))}),c=(e,t)=>{for(let n of _O.querySelectorAll(e))n.addEventListener(`click`,()=>t(n))};document.querySelector(`#logout`).addEventListener(`click`,()=>{bO(async()=>{await hO.signOut(),location.assign(`/login`)})}),s(o(`#register`),async e=>{let t=new FormData(e),n=await Q(Z.createClient({client_name:TO(t,`name`),redirect_uris:OO(t),resources:EO(e),application_type:jO(t),token_endpoint_auth_method:AO(t)}));e.reset(),PO.set(n.client_id,n),IO(),await LO()}),s(o(`#key-create`),async e=>{let t=new FormData(e),n=TO(t,`expiry`),r=await Q(Z.createApiKey({name:TO(t,`name`),permissions:MO(e),expiresAt:n?Cm(new Date(n)):null}));NO.set(r.keyId,`${r.name}\n${r.key}`),e.reset(),IO(),await LO()}),s(o(`#resource-create`),async e=>{let t=new FormData(e);await Q(Z.createResource({identifier:TO(t,`identifier`),...DO(t)})),e.reset(),await LO()});for(let e of _O.querySelectorAll(`[data-key-rename]`))s(e,async e=>{await Q(Z.updateApiKey({keyId:e.dataset.keyRename,name:TO(new FormData(e),`name`)})),await LO()});for(let e of _O.querySelectorAll(`[data-key-grants]`))s(e,async e=>{await Q(Z.updateApiKey({keyId:e.dataset.keyGrants,permissions:MO(e)})),await LO()});for(let e of _O.querySelectorAll(`[data-resource-edit]`))s(e,async e=>{await Q(Z.updateResource({identifier:e.dataset.resourceEdit,...DO(new FormData(e))})),await LO()});for(let e of _O.querySelectorAll(`[data-client-edit]`))s(e,async e=>{let t=new FormData(e);await Q(Z.updateClient({client_id:e.dataset.clientEdit,client_name:TO(t,`name`),redirect_uris:OO(t),application_type:jO(t)})),await LO()});for(let e of _O.querySelectorAll(`[data-client-access]`))e.addEventListener(`submit`,t=>{t.preventDefault();let n=e.dataset.clientAccess,r=EO(e),a=i(n).filter(e=>!r.includes(e)),o=async()=>{await Q(Z.setClientAccess({client_id:n,resources:r})),await LO()};a.length?xO(`Remove access to ${a.join(`, `)}? This revokes the Client\u2019s authorization for ${a.length===1?`it`:`them`}.`,o):bO(o)});c(`[data-key-toggle]`,e=>{bO(async()=>{await Q(Z.updateApiKey({keyId:e.dataset.keyToggle,enabled:e.dataset.enabled!==`true`})),await LO()})}),c(`[data-key-delete]`,e=>{let t=e.dataset.keyDelete;xO(`Delete this API key?`,async()=>{await Q(Z.deleteApiKey({keyId:t})),NO.delete(t),FO(),await LO()})}),c(`[data-revoke]`,e=>{let t=e.dataset.revoke;xO(`Revoke all of this Client’s authorization? It must authorize again, and an automatic Client asks for consent.`,async()=>{await Q(Z.revokeClient({client_id:t})),await LO()})}),c(`[data-disconnect]`,e=>{let t=e.dataset.disconnect,n=e.dataset.resource;xO(`Revoke this Client’s authorization for ${n}? It must authorize again, and an automatic Client asks for consent.`,async()=>{await Q(Z.revokeClient({client_id:t,resource:n})),await LO()})}),c(`[data-block]`,e=>{let t=e.dataset.block,n=e.dataset.blocked!==`true`;xO(n?`Block this Client and revoke its authorization?`:`Unblock this Client?`,async()=>{await Q(Z.blockClient({client_id:t,blocked:n})),await LO()})}),c(`[data-rotate]`,e=>{let t=e.dataset.rotate;xO(`Rotate the secret? The old one stops working immediately.`,async()=>{let e=await Q(Z.rotateClientSecret({client_id:t}));PO.set(e.client_id,e),IO()})}),c(`[data-delete]`,e=>{let t=e.dataset.delete;xO(e.dataset.managed===`true`?`Delete this Client and its authorization?`:`Forget this Client and its authorization? It can register again; block it to keep it out.`,async()=>{await Q(Z.deleteClient({client_id:t})),PO.delete(t),FO(),await LO()})}),c(`[data-resource-delete]`,e=>{let t=e.dataset.resourceDelete;xO(`Delete Resource ${t}? Every Client\u2019s authorization for it is revoked; API-key grants are kept.`,async()=>{await Q(Z.deleteResource({identifier:t})),await LO()})})}try{if((await Q(Z.setupStatus())).required)location.pathname===`/setup`?SO():location.replace(`/setup`);else if(location.pathname===`/setup`){let e=await hO.getSession();location.replace(e.data?`/`:`/login`)}else location.pathname===`/consent`?await wO():!(await hO.getSession()).data||location.pathname===`/login`?CO():await ek()}catch(e){_O.innerHTML=`<section class="card"><h1>Unable to continue</h1><p>${$(e instanceof Error?e.message:`Please try again`)}</p><a href="/login">Return to sign in</a></section>`}