@gjermundgaraba/clankerauth-dev 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +38 -38
- package/dist/web/assets/index-85TPARGi.js +49 -0
- package/dist/web/index.html +1 -1
- package/package.json +2 -2
- package/dist/web/assets/index-DZ3X5haa.js +0 -49
|
@@ -0,0 +1,49 @@
|
|
|
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=Symbol.for(`better-auth:auth-query`);function xe(e){let t=u(e);return Object.defineProperty(t,be,{value:!0}),t}var Se=()=>Math.floor(Date.now()/1e3),Ce=5;function we(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=Se(),t();return}if(e?.event===`visibilitychange`){if(Se()-l.lastSessionRequest<Ce)return;l.lastSessionRequest=Se(),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 Te=Object.create(null),Ee=e=>({}),De=new Proxy(Te,{get(e,t){return Ee()[t]??Te[t]},has(e,t){return t in Ee()||t in Te},set(e,t,n){let r=Ee(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=Ee(!0);return delete n[t],!0},ownKeys(){let e=Ee(!0);return Object.keys(e)}});De.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 Oe=1,_=4,ke=8,Ae=24,je={eterm:_,cons25:_,console:_,cygwin:_,dtterm:_,gnome:_,hurd:_,jfbterm:_,konsole:_,kterm:_,mlterm:_,mosh:Ae,putty:_,st:_,"rxvt-unicode-24bit":Ae,terminator:Ae,"xterm-kitty":Ae},Me=new Map(Object.entries({APPVEYOR:ke,BUILDKITE:ke,CIRCLECI:Ae,DRONE:ke,GITEA_ACTIONS:Ae,GITHUB_ACTIONS:Ae,GITLAB_CI:ke,TRAVIS:ke})),Ne=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Pe(){if(g(`FORCE_COLOR`)!==void 0)switch(g(`FORCE_COLOR`)){case``:case`1`:case`true`:return _;case`2`:return ke;case`3`:return Ae;default:return Oe}if(g(`NODE_DISABLE_COLORS`)!==void 0&&g(`NODE_DISABLE_COLORS`)!==``||g(`NO_COLOR`)!==void 0&&g(`NO_COLOR`)!==``||g(`TERM`)===`dumb`)return Oe;if(g(`TMUX`))return Ae;if(`TF_BUILD`in De&&`AGENT_NAME`in De)return _;if(`CI`in De){for(let{0:e,1:t}of Me)if(e in De)return t;return g(`CI_NAME`)===`codeship`?ke:Oe}if(`TEAMCITY_VERSION`in De)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(g(`TEAMCITY_VERSION`))===null?Oe:_;switch(g(`TERM_PROGRAM`)){case`iTerm.app`:return!g(`TERM_PROGRAM_VERSION`)||/^[0-2]\./.exec(g(`TERM_PROGRAM_VERSION`))!==null?ke:Ae;case`HyperTerm`:case`MacTerm`:return Ae;case`Apple_Terminal`:return ke}if(g(`COLORTERM`)===`truecolor`||g(`COLORTERM`)===`24bit`)return Ae;if(g(`TERM`)){if(/truecolor/.exec(g(`TERM`))!==null)return Ae;if(/^xterm-256/.exec(g(`TERM`))!==null)return ke;let e=g(`TERM`).toLowerCase();if(je[e])return je[e];if(Ne.some(t=>t.exec(e)!==null))return _}return g(`COLORTERM`)?_:Oe}var Fe=Symbol.for(`better-auth:global`),Ie=null,Le={},Re=`1.7.7`;function ze(){return globalThis[Fe]||(globalThis[Fe]={version:Re,epoch:1,context:Le},Ie=globalThis[Fe]),Ie=globalThis[Fe],Ie.version!==Re&&(Ie.version=Re,Ie.epoch++),globalThis[Fe]}function Be(){return ze().context.endpointContextAsyncStorage?.getStore()}var Ve={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`}},He=[`debug`,`info`,`success`,`warn`,`error`];function Ue(e,t){return He.indexOf(t)>=He.indexOf(e)}var We={info:Ve.fg.blue,success:Ve.fg.green,warn:Ve.fg.yellow,error:Ve.fg.red,debug:Ve.fg.magenta},Ge=(e,t,n)=>{let r=new Date().toISOString();return n?`${Ve.dim}${r}${Ve.reset} ${We[e]}${e.toUpperCase()}${Ve.reset} ${Ve.bright}[Better Auth]:${Ve.reset} ${t}`:`${r} ${e.toUpperCase()} [Better Auth]: ${t}`},Ke=(e=>{let t=e?.disabled!==!0,n=e?.level??`warn`,r=e?.disableColors===void 0?Pe()!==1:!e.disableColors,i=(i,a,o=[])=>{if(!t||!Ue(n,i))return;let s=Ge(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(He.map(e=>[e,(...[t,...n])=>i(e,t,n)])),get level(){return n}}})(),qe=()=>{let e=Be()?.context.logger;return e&&e!==Je?e:Ke},Je={debug:(...e)=>qe().debug(...e),info:(...e)=>qe().info(...e),success:(...e)=>qe().success(...e),warn:(...e)=>qe().warn(...e),error:(...e)=>qe().error(...e),get level(){return qe().level}};function Ye(){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 Xe(e){let t=e.split(`
|
|
2
|
+
at `);return t.length<=1?e:(t.splice(1,1),t.join(`
|
|
3
|
+
at `))}function Ze(e,t){class n extends e{#e;constructor(...e){if(Ye()){let t=Error.stackTraceLimit;Error.stackTraceLimit=0,super(...e),Error.stackTraceLimit=t}else super(...e);let t=Error().stack;t&&(this.#e=Xe(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 Qe={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};Ze(class extends Error{status;body;headers;statusCode;constructor(e=`INTERNAL_SERVER_ERROR`,t=void 0,n={},r=typeof e==`number`?e:Qe[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 $e=class extends Error{constructor(e,t){super(e,t),this.name=`BetterAuthError`,this.message=e,this.stack=``}},et=47;function tt(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===et;)t--;return t===e.length?e:e.slice(0,t)}function nt(e){try{return(tt(new URL(e).pathname)||`/`)!==`/`}catch{throw new $e(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function rt(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new $e(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){throw t instanceof $e?t:new $e(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}}function it(e,t=`/api/auth`){if(rt(e),nt(e))return e;let n=tt(e);return!t||t===`/`?n:(t=t.startsWith(`/`)?t:`/${t}`,`${n}${t}`)}function at(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 ot(e,t,n,r,i){if(e)return it(e,t);if(r!==!1){let e=De.BETTER_AUTH_URL||De.NEXT_PUBLIC_BETTER_AUTH_URL||De.PUBLIC_BETTER_AUTH_URL||De.NUXT_PUBLIC_BETTER_AUTH_URL||De.NUXT_PUBLIC_AUTH_URL||(De.BASE_URL===`/`?void 0:De.BASE_URL);if(e)return it(e,t)}let a=n?.headers.get(`x-forwarded-host`),o=n?.headers.get(`x-forwarded-proto`);if(a&&o&&i&&at(o,`proto`)&&at(a,`host`))try{return it(`${o}://${a}`,t)}catch{}if(n){let e=st(n.url);if(!e)throw new $e(`Could not get origin from request. Please provide a valid base URL.`);return it(e,t)}if(typeof window<`u`&&window.location)return it(window.location.origin,t)}function st(e){try{let t=new URL(e);return t.origin===`null`?null:t.origin}catch{return null}}var ct=[`javascript:`,`data:`,`vbscript:`];function lt(e){let t;try{t=new URL(e)}catch{return!0}return!ct.includes(t.protocol)}var ut={id:`redirect`,name:`Redirect`,hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&<(e.data.url)&&typeof window<`u`&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}},dt=()=>typeof window>`u`,ft=te;function pt(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 mt(e){return typeof e==`object`&&e&&`data`in e&&`error`in e?e:{data:e,error:null}}function ht(e){return!e||e.session===null&&e.user===null?null:e}function gt(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 _t(e,t){let n=u(!1),r,i=0,a=0;n.listen(()=>{a++,i=0});let o=e=>d(e),s=xe({data:null,error:null,isPending:!0,isRefetching:!1,refetch:o});ae(s,gt);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}=mt(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}=mt(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=ht(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()+ft,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;dt()||(e=setTimeout(()=>{f()},0));let r=we({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 vt(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 yt(e,t,n=`.`,r){if(!vt(t))return yt(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]]:vt(a)&&vt(i[t])?yt(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function bt(e){return(...t)=>t.reduce((t,n)=>yt(t,n,``,e),{})}var xt=bt(),St=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)}},Ct=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}},wt=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}},Tt=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 Et(e){if(typeof e==`number`)return new wt({type:`linear`,attempts:e,delay:1e3});switch(e.type){case`linear`:return new wt(e);case`exponential`:return new Tt(e);default:throw Error(`Invalid retry strategy`)}}var Dt=[`get`,`post`,`put`,`patch`,`delete`];function Ot(e){if(!e.startsWith(`@`))return{method:void 0,path:e};let t=e.indexOf(`/`),n=e.slice(1,t===-1?void 0:t);return Dt.includes(n)?{method:n,path:t===-1?e:e.slice(t+1)}:{method:void 0,path:e}}var kt=e=>e===`.`||e===`..`,At=e=>e.split(`:`).map(e=>encodeURIComponent(e)).join(`:`);function jt(e,t){let n=t.get(e);if(n===void 0)return At(e);if(kt(n))throw TypeError(`Path parameters cannot be reserved path segments`);return encodeURIComponent(n)}function Mt(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}=Ot(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=>jt(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 Nt=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},Pt=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Ft(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 Pt.test(r)?`json`:n.has(r)||r.startsWith(`text/`)?`text`:`blob`}function It(e){try{return JSON.parse(e),!0}catch{return!1}}function Lt(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 Rt(e){try{return JSON.parse(e)}catch{return e}}function zt(e){return typeof e==`function`}function Bt(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<`u`&&zt(globalThis.fetch))return globalThis.fetch;if(typeof window<`u`&&zt(window.fetch))return window.fetch;throw Error(`No fetch implementation found`)}function Vt(...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 Ht(e){let t=new Headers(Vt(e?.headers,await Nt(e)));if(!t.has(`content-type`)){let n=Ut(e?.body);n&&t.set(`content-type`,n)}return t}function Ut(e){return Lt(e)?`application/json`:null}function Wt(e){let t=e.get(`content-type`);return t?t.split(`;`)[0].trim().toLowerCase():null}function Gt(e,t){let{body:n}=e;return n?!Lt(n)||typeof n==`string`?n:Wt(t)===`application/x-www-form-urlencoded`?new URLSearchParams(n).toString():JSON.stringify(n):null}function Kt(e,t){if(t?.method)return t.method.toUpperCase();let{method:n}=Ot(e);return n?n.toUpperCase():t?.body?`POST`:`GET`}function qt(e,t){let n;return!e?.signal&&e?.timeout&&(n=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:n,clearTimeout:()=>{n&&clearTimeout(n)}}}var Jt=class e extends Error{constructor(t,n){super(n||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,e.prototype)}};async function Yt(e,t){let n=await e[`~standard`].validate(t);if(n.issues)throw new Jt(n.issues);return n.value}function Xt(e){"@babel/helpers - typeof";return Xt=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},Xt(e)}function Zt(e,t){if(Xt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Xt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Qt(e){var t=Zt(e,`string`);return Xt(t)==`symbol`?t:t+``}function $t(e,t,n){return(t=Qt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function en(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?en(Object(n),!0).forEach(function(t){$t(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):en(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var tn=async(e,t)=>{var n;let{hooks:r,url:i,options:a}=await Ct(e,t),o=Bt(a),s=new AbortController,c=a.signal??s.signal,l=Mt(i,a),u=await Ht(a),d=Gt(a,u),f=Kt(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}=qt(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=Ft(h),n={data:null,response:h,request:p};if(e===`json`||e===`text`){let e=await h.text();n.data=await(p.jsonParser??Rt)(e)}else n.data=await h[e]();p?.output&&p.output&&!p.disableValidation&&(n.data=await Yt(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??Rt,ie=await h.text(),ae=It(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=Et(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 tn(e,v(v({},t),{},{retryAttempt:i+1}))}}if(t?.throw)throw new St(h.status,h.statusText,ae?oe:ie);return{data:null,error:v(v({},oe),{},{status:h.status,statusText:h.statusText})}},nn=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}=Ot(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 Yt(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 Yt(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 Yt(o.input,n?.body):n?.body,params:o.params?await Yt(o.params,n?.params):n?.params})}return{url:t,options:i}}}return v({url:t},(n!==void 0||e.query!==void 0)&&{options:i})}}),rn=e=>{async function t(t,n){let r=v(v(v({},e),n),{},{headers:Vt(e?.headers,n?.headers),plugins:[...e?.plugins||[],nn(e||{}),...n?.plugins||[]]});if(e?.catchAllError)try{return await tn(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 tn(t,r)}return t},an=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{}}},on=e=>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`,sn=(e,t)=>{let n=`credentials`in Request.prototype,r=ot(e?.baseURL,e?.basePath,void 0,t)??an(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=rn({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?[]:[ut],...i]}),{$sessionSignal:f,session:p,broadcastSessionUpdate:m}=_t(d,e),h=!1,ee=e=>{h||e===null||(h=!0,pt(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:on,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=xt(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 cn(e){return typeof e==`object`&&!!e&&`get`in e&&typeof e.get==`function`&&`lc`in e&&typeof e.lc==`number`}function ln(e){return e.charAt(0).toUpperCase()+e.slice(1)}var un=/[\p{Ll}\d]+|\p{Lu}+(?!\p{Ll})|\p{Lu}[\p{Ll}\d]+|\p{Lo}+/gu,dn=/['\u2019]/g;function fn(e){return e.replace(dn,``).match(un)??[]}function pn(e){return fn(e).map(e=>e.toLowerCase()).join(`-`)}function mn(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 hn(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`||cn(i)?i:a(r)},apply:async(e,a,s)=>{let c=`/`+o.map(pn).join(`/`),l=s[0]||{},u=s[1]||{},{query:d,fetchOptions:f,...p}=l,m={...u,...f},h=mn(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 gn(e){let{pluginPathMethods:t,pluginsActions:n,pluginsAtoms:r,hydrateSession:i,$fetch:a,atomListeners:o,$store:s}=sn(e),c={};for(let[e,t]of Object.entries(r))c[`use${ln(e)}`]=t;return hn({...n,...c,hydrateSession:i,$fetch:a,$store:s},a,t,r,o)}var _n=`ba_param`;function vn(e){let t=e.getAll(_n);if(t.length)return new Set(t)}function yn(e){let t=new URLSearchParams(e);if(!t.has(`sig`))return;let n=vn(t);if(!n)return;let r=new URLSearchParams;for(let[e,i]of t.entries())(e===`sig`||e===_n||n.has(e))&&r.append(e,i);return r.toString()}var bn=`1.7.7`,xn=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;function Sn(e){if(typeof e==`string`&&xn.test(e)){let t=new Date(e);if(!isNaN(t.getTime()))return t}return e}function Cn(e){if(e==null)return e;if(typeof e==`string`)return Sn(e);if(e instanceof Date)return e;if(Array.isArray(e))return e.map(Cn);if(typeof e==`object`){let t={};for(let n of Object.keys(e))t[n]=Cn(e[n]);return t}return e}function wn(e){try{return typeof e==`string`?JSON.parse(e,(e,t)=>Sn(t)):e==null?null:Cn(e)}catch(e){return Je.error(`Error parsing JSON`,{error:e}),null}}var Tn=()=>({id:`oauth-provider-client`,version:bn,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)):wn(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:yn(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}}},En={pipe(){return y(this,arguments)}},Dn=function(){function e(){}return e.prototype=En,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,On=e=>()=>e,kn=On(!0),An=On(!1),jn=On(void 0),Mn=jn;function Nn(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 Pn(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 Fn=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},In=new WeakSet,Ln=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Rn=0,zn=()=>{Rn++};function Bn(e){return typeof e==`string`}function Vn(e){return typeof e==`number`}function Hn(e){return typeof e==`boolean`}function Un(e){return typeof e==`symbol`}function Wn(e){return Bn(e)||Vn(e)||Un(e)}function Gn(e){return typeof e==`function`}function Kn(e){return e!=null}function qn(e){return!1}function Jn(e){return!0}function Yn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Xn(e){return typeof e==`object`&&!!e||Gn(e)}var S=b(2,(e,t)=>Xn(e)&&t in e),Zn=b(2,(e,t)=>S(e,`_tag`)&&e._tag===t);function Qn(e){return e instanceof Error}function $n(e){return S(e,Symbol.iterator)||Bn(e)}var er=`~effect/Hash`,C=e=>{switch(typeof e){case`number`:return or(e);case`bigint`:return sr(e.toString(10));case`string`:return sr(e);case`function`:case`object`:if(e===null)break;if(e instanceof Date)return Number.isNaN(e.getTime())?sr(`Invalid Date`):sr(e.toISOString());if(e instanceof RegExp)return sr(e.toString());{if(In.has(e))return tr(e);let t=gr.get(e);if(t!==void 0)return t;if(_r.has(e))return zn(),sr(`[Circular]`);_r.add(e);let n=Rn,r;try{r=`~effect/Hash`in e?e[er]():typeof e==`function`?tr(e):e instanceof DataView?dr(Ln(e)):Array.isArray(e)||ArrayBuffer.isView(e)?dr(e):e instanceof Map?fr(e):e instanceof Set?mr(e):lr(e)}finally{_r.delete(e)}return n===Rn&&gr.set(e,r),r}}return ir(nr(sr(String(e))))},tr=e=>(hr.has(e)||hr.set(e,ir(Math.random()*4294967296|0)),hr.get(e)),nr=e=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),rr=b(2,(e,t)=>nr(Math.imul(e,2654435761)+Math.imul(t,2246822507))),ir=e=>e&3221225471|e>>>1&1073741824,ar=new DataView(new ArrayBuffer(8)),or=e=>{let t=e|0;return t===e?ir(t):(ar.setFloat64(0,e===e?e:NaN),ir(rr(ar.getInt32(0),ar.getInt32(4))))},sr=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return ir(t)},cr=(e,t)=>{let n=12289;for(let r of t)n^=rr(C(r),C(e[r]));return ir(n)},lr=e=>cr(e,Fn(e)),ur=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return ir(r)},dr=e=>{let t=6151;for(let n of e)t=rr(t,C(n));return ir(t)},fr=ur(sr(`Map`),([e,t])=>rr(C(e),C(t))),pr=sr(`Set`),mr=ur(pr,e=>rr(pr,C(e))),hr=new WeakMap,gr=new WeakMap,_r=new WeakSet,w=`~effect/Equal`;function vr(){return arguments.length===1?e=>yr(e,arguments[0]):yr(arguments[0],arguments[1])}function yr(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`||In.has(e)||In.has(t)?!1:br(e,t):!1}function br(e,t){let n=Sr.length;for(let r=n;r-->0;)if(Sr[r]===e&&Cr[r]===t)return!0;if(n)return xr(e,t);let r=wr.get(e);r||wr.set(e,r=new WeakMap);let i=r.get(t);return i===void 0&&r.set(t,i=xr(e,t)),i}function xr(e,t){Sr.push(e),Cr.push(t);try{return Tr(e,t)}finally{Sr.pop(),Cr.pop()}}var Sr=[],Cr=[],wr=new WeakMap;function Tr(e,t){if(C(e)!==C(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=Mr(e);if(n!==Mr(t)||typeof e==`function`&&!n)return!1;if(n)return e[w](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:Er(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?Dr(Ln(e),Ln(t)):Dr(e,t)}return e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:kr(e,t,Ar,jr):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:kr(e,t,C,yr):Or(e,t)}function Er(e,t){for(let n=0;n<e.length;n++)if(!yr(e[n],t[n]))return!1;return!0}function Dr(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 Or(e,t){let n=Fn(e),r=Fn(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!yr(e[i],t[i]))return!1;return!0}function kr(e,t,n,r){let i=new Map,a=0;for(let e of t){let t=n(e),r=i.get(t);r?r.push(e):i.set(t,[e]),a++}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(),a--;continue outer}}return!1}return a===0}var Ar=e=>C(e[0]),jr=(e,t)=>yr(e[0],t[0])&&yr(e[1],t[1]),Mr=e=>S(e,w),Nr=Symbol.for(`~effect/Redactable`),Pr=e=>S(e,Nr);function Fr(e){return Pr(e)?Ir(e):e}function Ir(e){return e[Nr](globalThis[`~effect/Fiber/currentFiber`]?.context??zr)}var Lr=`~effect/Fiber/currentFiber`,Rr=new Map,zr={"~effect/Context":{},base:Rr,depth:0,mapUnsafe:Rr,pipe(){return y(this,arguments)}};function T(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 Br;r.add(e);let l;if(Nr in e)l=c(Ir(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=Ur(e);else if(!t?.ignoreToString&&S(e,`toString`)&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=Wr(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=>`${Vr(t)}:${c(Gr(e,t),n)}`).join(`,`)}}`;l=o(e,r)}else{let r=`{\n${t.map(t=>`${a(n+1)}${Vr(t)}: ${c(Gr(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 Br=`[Circular]`;function Vr(e){return typeof e==`string`?JSON.stringify(e):String(e)}function Hr(e){return e.map(e=>`[${Vr(e)}]`).join(``)}function Ur(e){try{return e.toISOString()}catch{return`Invalid Date`}}function Wr(e){try{let t=e.toString();return typeof t==`string`?t:String(t)}catch{return`[toString threw]`}}function Gr(e,t){try{return e[t]}catch{return`[property access threw]`}}function Kr(e,t){let n=[];return JSON.stringify(e,function(e,t){let r=Object.getOwnPropertyDescriptor(this,e)?.value,i=S(r,Nr)?Fr(r):Fr(t);if(typeof i==`bigint`)return T(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;if(n.push(i),a!==i&&n.push(a),!qr(a)||Jr(a))return a;let o=new Proxy(a,{get(e,t){let n=Reflect.get(e,t,e);return Object.getOwnPropertyDescriptor(e,t)?.get===void 0?n:Fr(n)}});return n.push(o),o},t?.space)??`null`}function qr(e){for(let t of Object.getOwnPropertyNames(e))if(Object.getOwnPropertyDescriptor(e,t)?.get!==void 0)return!0;return!1}function Jr(e){for(let t of[Number.prototype.valueOf,Boolean.prototype.valueOf,String.prototype.valueOf])try{return Reflect.apply(t,e,[]),!0}catch{}return!1}var Yr=Symbol.for(`nodejs.util.inspect.custom`),Xr=e=>{try{return e=Fr(e),S(e,`toJSON`)&&Gn(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(Xr):e}catch{return`[toJSON threw]`}},Zr={toJSON(){return Xr(this)},[Yr](){return this.toJSON()},toString(){return T(this.toJSON())}},Qr=class{[Yr](){return this.toJSON()}toString(){return T(this.toJSON())}},$r=(()=>{let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,`writable`)?e.writable===!0:e.set!==void 0})(),ei=()=>Error.stackTraceLimit,ti=e=>{$r&&(Error.stackTraceLimit=e)},ni=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})}},ri=(()=>{let e=`~effect/Utils/internal`,t={[e]:e=>e()},n={[e]:e=>{try{return e()}finally{}}};return ei()!==0&&t[e](()=>Error().stack)?.includes(e)===!0?t[e]:n[e]})();function ii(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function ai(e,t){for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&ii(e,n,t[n])}var oi=`~effect/Effect`,si=`~effect/Exit`,ci={_A:x,_E:x,_R:x},li=`${oi}/identifier`,E=`${oi}/args`,D=`${oi}/evaluate`,O=`${oi}/successCont`,ui=`${oi}/failureCont`,di=`${oi}/ensureCont`,fi=Symbol.for(`effect/Effect/Yield`),pi={pipe(){return y(this,arguments)},toJSON(){return{...this}},toString(){return T(this.toJSON(),{ignoreToString:!0,space:2})},[Yr](){return this.toJSON()}},mi={[oi]:ci,...pi,[Symbol.iterator](){return new ni(this)},toJSON(){return{_id:`Effect`,op:this[li],...E in this?{args:this[E]}:void 0}}},hi=e=>S(e,oi),gi=e=>S(e,si),_i=`~effect/Cause`,vi=`~effect/Cause/Reason`,yi=e=>S(e,_i),bi=e=>S(e,vi),xi=class{constructor(e){this[_i]=_i,this.reasons=e}pipe(){return y(this,arguments)}toJSON(){return{_id:`Cause`,failures:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${T(this.reasons)})`}[Yr](){return this.toJSON()}[w](e){return yi(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>vr(t,e.reasons[n]))}[er](){return dr(this.reasons)}},Si=new WeakMap,Ci=class{[vi];annotations;_tag;constructor(e,t,n){if(this[vi]=vi,this._tag=e,t!==wi&&typeof n==`object`&&n&&t.size>0){let e=Si.get(n);e&&(t=new Map([...e,...t])),Si.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 T(this)}[Yr](){return this.toString()}},wi=new Map,Ti=class extends Ci{constructor(e,t=wi){super(`Fail`,t,e),this.error=e}toString(){return`Fail(${T(this.error)})`}toJSON(){return{_tag:`Fail`,error:this.error}}[w](e){return Ni(e)&&vr(this.error,e.error)&&vr(this.annotations,e.annotations)}[er](){return rr(sr(this._tag))(rr(C(this.error))(C(this.annotations)))}},Ei=e=>new xi(e),Di=(e,t)=>{let n=new Map,r=[];for(let i of e.concat(t)){let e=C(i),t=n.get(e);if(t===void 0)n.set(e,[i]);else if(t.some(e=>vr(e,i)))continue;else t.push(i);r.push(i)}return r},Oi=b(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new xi(Di(e.reasons,t.reasons));return vr(e,n)?e:n}),ki=e=>new xi([new Ti(e)]),Ai=class extends Ci{constructor(e,t=wi){super(`Die`,t,e),this.defect=e}toString(){return`Die(${T(this.defect)})`}toJSON(){return{_tag:`Die`,defect:this.defect}}[w](e){return Pi(e)&&vr(this.defect,e.defect)&&vr(this.annotations,e.annotations)}[er](){return rr(sr(this._tag))(rr(C(this.defect))(C(this.annotations)))}},ji=e=>new xi([new Ai(e)]),Mi=b(e=>yi(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new xi(e.reasons.map(e=>e.annotate(t,n)))),Ni=e=>e._tag===`Fail`,Pi=e=>e._tag===`Die`,Fi=e=>e._tag===`Interrupt`;function Ii(e){return Gi(`Effect.evaluate: Not implemented`)}var Li=e=>({...mi,[li]:e.op,[D]:e[D]??Ii,[O]:e[O],[ui]:e[ui],[di]:e[di]}),Ri=e=>{let t=Li(e),n=function(e){this[E]=e};return n.prototype=t,function(e){return new n(e)}},zi=e=>{let t={[si]:si,_tag:e.op,get[e.prop](){return this[E]},...Li(e),toString(){return`${e.op}(${T(this[E])})`},toJSON(){return{_id:`Exit`,_tag:e.op,[e.prop]:this[E]}},[w](e){return gi(e)&&e._tag===this._tag&&vr(this[E],e[E])},[er](){return rr(sr(e.op),C(this[E]))}},n=function(e){this[E]=e};return n.prototype=t,function(e){return new n(e)}},Bi=zi({op:`Success`,prop:`value`,[D](e){let t=e.getCont(O);return t?t[O](this[E],e,this):e.yieldWith(this)}}),Vi={key:`effect/Cause/StackTrace`},Hi={key:`effect/Cause/InterruptorStackTrace`},Ui=zi({op:`Failure`,prop:`cause`,[D](e){let t=this[E],n=!1;e.cache.stackFrame&&(t=Mi(t,{mapUnsafe:new Map([[Vi.key,e.cache.stackFrame]])}),n=!0);let r=e.getCont(ui),i=e._interruptedCause;if(i&&e.interruptible){let a=!1;for(;r&&e.interruptible;)a||=li in r,r=e.getCont(ui);a&&(t=Ei(t.reasons.filter(e=>e._tag!==`Fail`))),t=Oi(t,i),n=!0}return r?r[ui](t,e,n?void 0:this):e.yieldWith(n?Ui(t):this)}}),Wi=e=>Ui(ki(e)),Gi=e=>Ui(ji(e)),k=Ri({op:`WithFiber`,[D](e){return this[E](e)}}),Ki=function(){class e extends globalThis.Error{}let t=Li({op:`YieldableError`,[D](){return Wi(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),qi=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return class extends Ki{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(ai(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}(),Ji=e=>{class t extends qi{_tag=e}return t.prototype.name=e,t},Yi=`~effect/Cause/Done`,Xi=e=>S(e,Yi),Zi={[Yi]:Yi,_tag:`Done`,value:void 0},Qi=e=>e===void 0?Zi:{[Yi]:Yi,_tag:`Done`,value:e},$i=Wi(Zi),ea=e=>e===void 0?$i:Wi(Qi(e)),ta=e=>Li({op:e.label,[D]:e.evaluate}),na=e=>(t,n)=>t===n||e(t,n),ra=(e,t)=>e===t,ia=()=>ra;function aa(e){return na((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 oa(e){return na((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 sa=`~effect/Option`,ca={[sa]:{_A:e=>e},...pi,[Symbol.iterator](){return new ni(this)}},la=Object.defineProperty(Object.assign(Object.create(ca),{_tag:`Some`,_op:`Some`,[w](e){return fa(e)&&ma(e)&&vr(this.value,e.value)},[er](){return rr(C(this._tag))(C(this.value))},toString(){return`some(${T(this.value)})`},toJSON(){return{_id:`Option`,_tag:this._tag,value:Xr(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),ua=C(`None`),da=Object.assign(Object.create(ca),{_tag:`None`,_op:`None`,valueOrUndefined:void 0,[w](e){return fa(e)&&pa(e)},[er](){return ua},toString(){return`none()`},toJSON(){return{_id:`Option`,_tag:this._tag}}}),fa=e=>S(e,sa),pa=e=>e._tag===`None`,ma=e=>e._tag===`Some`,ha=Object.create(da),ga=function(e){this.value=e};ga.prototype=la;var _a=e=>new ga(e),va=`~effect/Result`,ya={[va]:{_A:e=>e,_E:e=>e},...pi,[Symbol.iterator](){return new ni(this)}},ba=Object.assign(Object.create(ya),{_tag:`Success`,_op:`Success`,[w](e){return Sa(e)&&wa(e)&&vr(this.success,e.success)},[er](){return rr(C(this._tag))(C(this.success))},toString(){return`success(${T(this.success)})`},toJSON(){return{_id:`Result`,_tag:this._tag,value:Xr(this.success)}}}),xa=Object.assign(Object.create(ya),{_tag:`Failure`,_op:`Failure`,[w](e){return Sa(e)&&Ca(e)&&vr(this.failure,e.failure)},[er](){return rr(C(this._tag))(C(this.failure))},toString(){return`failure(${T(this.failure)})`},toJSON(){return{_id:`Result`,_tag:this._tag,failure:Xr(this.failure)}}}),Sa=e=>S(e,va),Ca=e=>e._tag===`Failure`,wa=e=>e._tag===`Success`,Ta=function(e){this.failure=e};Ta.prototype=xa;var Ea=e=>new Ta(e),Da=function(e){this.success=e};Da.prototype=ba;var Oa=e=>new Da(e);function ka(e){return(t,n)=>t===n?0:e(t,n)}var Aa=ka((e,t)=>e<t?-1:1),ja=ka((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),Ma=b(2,(e,t)=>ka((n,r)=>e(t(n),t(r)))),Na=e=>b(2,(t,n)=>e(t,n)===-1),Pa=e=>b(2,(t,n)=>e(t,n)===1),Fa=e=>b(2,(t,n)=>e(t,n)!==1),Ia=e=>b(2,(t,n)=>e(t,n)!==-1),La=()=>ha,Ra=_a,za=pa,Ba=ma,Va=b(2,(e,{onNone:t,onSome:n})=>za(e)?t():n(e.value)),Ha=b(2,(e,t)=>za(e)?t():e.value),Ua=e=>e==null?La():Ra(e),Wa=Ha(jn),Ga=e=>(...t)=>{try{return Ra(e(...t))}catch{return La()}},Ka=`~effect/Context/Service`,A=function(){function e(){}let t=e;Object.setPrototypeOf(t,qa);let n=(e,n)=>(t.key=e,n?.defaultValue&&(t[Ya]=Ya,t.defaultValue=n.defaultValue),n?.make&&(t.make=n.make),n?.fiberCached&&Ja.add(e),t);return arguments.length>0?n(arguments[0],arguments[1]):n},qa={[Ka]:Ka,...ta({label:`Service`,evaluate(e){return Bi(bo(e.context,this))}}),toJSON(){return{_id:`Service`,key:this.key}},of(e){return e},context(e){return mo(this,e)},use(e){return k(t=>e(bo(t.context,this)))},useSync(e){return k(t=>Bi(e(bo(t.context,this))))}},Ja=new Set,Ya=`~effect/Context/Reference`,Xa=`~effect/Context`,Za=8,Qa=8,$a=(e,t,n,r)=>{let i=Object.create(oo);return i.cacheRoot=e??i,i.base=t,i.overlay=n,i.depth=r,i._flat=void 0,i.baseHits=0,i},eo=(e,t)=>{t&&(eo(e,t.parent),e.set(t.key,t.value))},to=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return eo(t,e.overlay),e._flat=t},no=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),ao(n)},ro=Symbol(),io=(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)?ro:(n.overlay&&++n.baseHits>=n.base.size&&n.baseHits>=Qa&&(n.base=to(n),n.overlay=void 0,n.depth=0),r)},ao=e=>$a(void 0,e,void 0,0),oo={get mapUnsafe(){return to(this)},...pi,[Xa]:{_Services:e=>e},toJSON(){return{_id:`Context`,services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[w](e){if(!co(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)||!vr(r,n.get(e)))return!1;return!0},[er](){return or(this.mapUnsafe.size)}},so=(e,t)=>e.cacheRoot===t.cacheRoot,co=e=>S(e,Xa),lo=e=>S(e,Ka),uo=e=>!!e[Ya],fo=()=>po,po=ao(new Map),mo=(e,t)=>ao(new Map([[e.key,t]])),ho=b(3,(e,t,n)=>go(e,t.key,n)),go=(e,t,n)=>{let r=e,i=Ja.has(t)?void 0:r.cacheRoot;if(r.depth>=Za){let e=new Map(r.mapUnsafe);return e.set(t,n),$a(i,e,void 0,0)}return $a(i,r.base,{key:t,value:n,parent:r.overlay},r.depth+1)},_o=b(2,(e,t)=>vo(e,t.key)),vo=(e,t)=>{let n=io(e,t);return n===ro?void 0:n},yo=b(2,(e,t)=>{let n=io(e,t.key);if(n===ro){if(uo(t))return So(t);throw Co(t)}return n}),bo=yo,xo=`~effect/Context/defaultValue`,So=e=>xo in e?e[xo]:e[xo]=e.defaultValue(),Co=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},wo=b(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:no(e,e=>t.mapUnsafe.forEach((t,n)=>e.set(n,t)))),To=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((e,n)=>{t.set(n,e)});return ao(t)},j=A,Eo=e=>e.length>0,Do=Oa,Oo=Ea,ko=e=>{if(Gn(e))try{return Do(e())}catch(e){return Oo(e)}try{return Do(e.try())}catch(t){return Oo(e.catch(t))}},Ao=Ca,jo=wa,Mo=b(2,(e,{onFailure:t,onSuccess:n})=>Ao(e)?t(e.failure):n(e.success)),No=aa,Po=b(2,(e,t)=>Object.hasOwn(e,t)),Fo=b(2,(e,t)=>{let n={...e};for(let r of Io(e))ii(n,r,t(e[r],r));return n}),Io=e=>Object.keys(e),Lo=e=>b(2,(t,n)=>{for(let r of Io(t))if(!Po(n,r)||!e(t[r],n[r]))return!1;return!0}),Ro=e=>{let t=Lo(e);return(e,n)=>t(e,n)&&t(n,e)},zo=globalThis.Array,Bo=e=>zo.isArray(e)?e:zo.from(e),Vo=e=>zo.isArray(e)?e:[e],Ho=b(2,(e,t)=>[...e,t]),Uo=b(2,(e,t)=>Bo(e).concat(Bo(t)));zo.isArray;var Wo=Eo,Go=Eo,Ko=(e,t)=>{let n=C(t),r=e.get(n);if(r===void 0)return e.set(n,[t]),!0;for(let e of r)if(vr(e,t))return!1;return r.push(t),!0},qo=()=>[],Jo=e=>[e],Yo=b(2,(e,t)=>e.map(t)),Xo=oa,Zo=e=>{let t=Bo(e);if(t.length<2)return[...t];let n=new Map,r=[];for(let e of t)Ko(n,e)&&r.push(e);return r},Qo=`~effect/Duration`,$o=BigInt(0),es=BigInt(1),ts=BigInt(2),ns=BigInt(10),rs=BigInt(1e3),is=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),as=e=>is(e*1e6),os=(e,t)=>{let n=e.indexOf(`.`);if(n===-1)return BigInt(e)*t;let r=e[0]===`-`,i=e.slice(n+1),a=ns**BigInt(i.length),o=(BigInt(e.slice(+!!r,n))*a+BigInt(i))*t,s=o/a+(o%a*ts>=a?es:$o);return r?-s:s},ss=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,cs=e=>{switch(typeof e){case`number`:return bs(e);case`bigint`:return ys(e);case`string`:{if(e===`Infinity`)return _s;if(e===`-Infinity`)return vs;let t=ss.exec(e);if(!t)break;let[n,r,i]=t;if(i===`nano`||i===`nanos`)return ys(os(r,es));if(i===`micro`||i===`micros`)return ys(os(r,rs));let a=Number(r);switch(i){case`milli`:case`millis`:return bs(a);case`second`:case`seconds`:return xs(a);case`minute`:case`minutes`:return Ss(a);case`hour`:case`hours`:return Cs(a);case`day`:case`days`:return ws(a);case`week`:case`weeks`:return Ts(a)}break}case`object`:{if(e===null)break;if(Qo in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(Vn)?ls(e):Number.isNaN(e[0])||Number.isNaN(e[1])?gs:e[0]===-1/0||e[1]===-1/0?vs:e[0]===1/0||e[1]===1/0?_s:ms(is(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?ms(n):ms(is(n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0)))}}return ls(e)},ls=e=>{throw Error(`Invalid Input: ${e}`)},us={_tag:`Millis`,millis:0},ds={_tag:`Infinity`},fs={_tag:`NegativeInfinity`},ps={[Qo]:Qo,[er](){switch(this.value._tag){case`Millis`:{let e=this.value.millis*1e6;return Number.isFinite(e)?C(is(e)):or(this.value.millis)}case`Nanos`:return C(this.value.nanos);default:return lr(this.value)}},[w](e){return hs(e)&&js(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`}}},[Yr](){return this.toJSON()},pipe(){return y(this,arguments)}},ms=e=>{let t=Object.create(ps);return t.value=typeof e==`number`?isNaN(e)||e===0||Object.is(e,-0)?us:Number.isFinite(e)?Number.isInteger(e)?{_tag:`Millis`,millis:e}:{_tag:`Nanos`,nanos:as(e)}:e>0?ds:fs:e===$o?us:{_tag:`Nanos`,nanos:e},t},hs=e=>S(e,Qo),gs=ms(0),_s=ms(1/0),vs=ms(-1/0),ys=e=>ms(e),bs=e=>ms(e),xs=e=>ms(e*1e3),Ss=e=>ms(e*6e4),Cs=e=>ms(e*36e5),ws=e=>ms(e*864e5),Ts=e=>ms(e*6048e5),Es=e=>Os(cs(e),{onMillis:x,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),Ds=e=>{let t=cs(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 as(t.value.millis)}},Os=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)()}}),ks=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(Ds(e),t.value.nanos):n.onNanos(e.value.nanos,Ds(t))),As=(e,t)=>ks(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),js=b(2,(e,t)=>As(e,t)),Ms=j(`effect/Scheduler`,{fiberCached:!0,defaultValue:()=>new Ls}),Ns=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},Ps=`setImmediate`in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},Fs=e=>{try{return Ps(e)}catch{return Ns(e)}},Is=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}},Ls=class{executionMode;setImmediate;constructor(e=`async`,t){this.executionMode=e,this.setImmediate=t??(e===`sync`?Ns:Fs)}shouldYield(e){return e.currentOpCount>=e.cache.maxOpsBeforeYield}makeDispatcher(){return new Rs(this.setImmediate)}},Rs=class{tasks=new Is;running=void 0;setImmediate;constructor(e=Fs){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()}},zs=j(`effect/Scheduler/MaxOpsBeforeYield`,{fiberCached:!0,defaultValue:()=>2048}),Bs=j(`effect/Scheduler/PreventSchedulerYield`,{fiberCached:!0,defaultValue:()=>!1}),Vs=class extends Dn{constructor(e){super(),e&&ai(this,e)}},Hs=e=>class extends Vs{_tag=e},Us=Ji,Ws=`~effect/encoding/EncodingError`,Gs=class extends Us(`EncodingError`){[Ws]=Ws},Ks=e=>{switch(e){case 16:return Ys();case 32:return Xs();default:{let t=``;for(let n=e>>>3;n>0;n--)t+=Js();return t}}},M=Uint8Array.from(`0123456789abcdef`,e=>e.charCodeAt(0)),qs=()=>Math.random()*4294967296>>>0,Js=()=>{let e=qs();return String.fromCharCode(M[e>>>28],M[e>>>24&15],M[e>>>20&15],M[e>>>16&15],M[e>>>12&15],M[e>>>8&15],M[e>>>4&15],M[e&15])},Ys=()=>{let e=qs(),t=qs();return String.fromCharCode(M[e>>>28],M[e>>>24&15],M[e>>>20&15],M[e>>>16&15],M[e>>>12&15],M[e>>>8&15],M[e>>>4&15],M[e&15],M[t>>>28],M[t>>>24&15],M[t>>>20&15],M[t>>>16&15],M[t>>>12&15],M[t>>>8&15],M[t>>>4&15],M[t&15])},Xs=()=>{let e=qs(),t=qs(),n=qs(),r=qs();return String.fromCharCode(M[e>>>28],M[e>>>24&15],M[e>>>20&15],M[e>>>16&15],M[e>>>12&15],M[e>>>8&15],M[e>>>4&15],M[e&15],M[t>>>28],M[t>>>24&15],M[t>>>20&15],M[t>>>16&15],M[t>>>12&15],M[t>>>8&15],M[t>>>4&15],M[t&15],M[n>>>28],M[n>>>24&15],M[n>>>20&15],M[n>>>16&15],M[n>>>12&15],M[n>>>8&15],M[n>>>4&15],M[n&15],M[r>>>28],M[r>>>24&15],M[r>>>20&15],M[r>>>16&15],M[r>>>12&15],M[r>>>8&15],M[r>>>4&15],M[r&15])},Zs=`effect/Tracer/ParentSpan`,Qs=class extends A()(Zs,{fiberCached:!0}){},$s=e=>e,ec=j(`effect/Tracer/DisablePropagation`,{defaultValue:An}),tc=j(`effect/Tracer/CurrentTraceLevel`,{defaultValue:()=>`Info`}),nc=j(`effect/Tracer/MinimumTraceLevel`,{defaultValue:()=>`All`}),rc=`effect/Tracer`,ic=$s({span:e=>new ac(e)}),ac=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??=Wa(this.parent)?.traceId??Ks(32)}get spanId(){return this._spanId??=Ks(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)}},oc=`effect/Metric/FiberRuntimeMetrics`,sc=j(`effect/References/CurrentStackFrame`,{fiberCached:!0,defaultValue:jn}),cc=j(`effect/References/TracerEnabled`,{fiberCached:!0,defaultValue:kn}),lc=j(`effect/References/TracerTimingEnabled`,{defaultValue:kn}),uc=j(`effect/References/TracerSpanAnnotations`,{defaultValue:()=>({})}),dc=j(`effect/References/TracerSpanLinks`,{defaultValue:()=>[]}),fc=j(`effect/References/CurrentLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),pc=j(`effect/References/MinimumLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),mc=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!=`boolean`)return e;let t=ei();if(t===0&&e?.captureStackTrace!==!0)return{...e,captureStackTrace:!1};ti(3);let n=Error();return ti(t),{...e,captureStackTrace:hc(()=>n.stack)}},hc=(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),gc=class extends Ci{constructor(e,t=wi){super(`Interrupt`,t,`Interrupted`),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:`Interrupt`,fiberId:this.fiberId}}[w](e){return Fi(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[er](){return rr(sr(`${this._tag}:${this.fiberId}`))(tr(this.annotations))}},_c=e=>new gc(e),vc=e=>new xi([new gc(e)]),yc=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag===`Fail`)return Do(n.error)}return Oo(e)},bc=e=>e.reasons.some(Fi),xc=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?Do(t):Oo(e)},Sc=b(2,(e,t)=>{let n=!1,r=e.reasons.map(e=>Ni(e)?(n=!0,new Ti(t(e.error),e.annotations)):e);return n?Ei(r):e}),Cc=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},wc=`~effect/Fiber`,Tc={_A:x,_E:x},Ec={id:0},Dc=(()=>{try{return globalThis.process?.getBuiltinModule?.(`node:async_hooks`)?.AsyncResource}catch{return}})(),Oc=()=>Dc===void 0?void 0:new Dc(`effect/Fiber`),kc=()=>globalThis[Lr],Ac=class{constructor(e,t=!0){this.setContext(e),this.id=++Ec.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._asyncContext=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[wc](){return Tc}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return bo(this.context,e)}addObserver(e){return this._exit?(e(this._exit),Mn):(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=vc(e);this.cache.stackFrame&&(n=Mi(n,mo(Vi,this.cache.stackFrame))),t&&(n=Mi(n,t)),this._interruptedCause=this._interruptedCause?Oi(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(Hc(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._asyncContext!==void 0){let t=this._asyncContext;return this._asyncContext=void 0,t.runInAsyncScope(this.evaluate,this,e)}if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===fi){this._asyncContext=Oc();return}let n=Pc.interruptChildren&&Pc.interruptChildren(this);if(n!==void 0)return this.evaluate(Cl(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=fo()}runLoop(e){let t=globalThis[Lr];globalThis[Lr]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;)try{this._deferredInterrupt&&(this._deferredInterrupt=!1,i=Hc(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!r&&!e.preventYield&&e.scheduler.shouldYield(this)){r=!0;let e=i;i=Cl(Kc,()=>e)}if(i=e.tracerContext?e.tracerContext(i,this):i[D](this),i===fi){let e=this._yielded;if(si in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return fi}}catch(e){if(!S(i,D))return Gi(`Fiber.runLoop: Not a valid effect: ${String(i)}`);i=Gi(e)}}finally{this._running=n,globalThis[Lr]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,Mc;for(;;){let t=this._stack.pop();if(!t)return;let n=t[di];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&Nc-1))return Bi(e);let t=this.getCont(O);return t?t[O](e,this):this.yieldWith(Bi(e))}yieldWith(e){return this._yielded=e,fi}children(){return this._children??=new Set}pipe(){return y(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&so(t,e))return;let n=e.cacheRoot,r=n._fiberCache??=jc(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}},jc=e=>{let t=vo(e,rc);return{scheduler:bo(e,Ms),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:bo(e,cc),span:vo(e,Zs),logLevel:bo(e,fc),minimumLogLevel:bo(e,pc),stackFrame:bo(e,sc),runtimeMetrics:vo(e,oc),maxOpsBeforeYield:bo(e,zs),preventYield:bo(e,Bs)}},Mc={[O](e,t){return Hc(t._interruptedCause)},[ui](e,t){return Hc(t._interruptedCause)}},Nc=32,Pc={interruptChildren:void 0},Fc=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(Hi.key,e.cache.stackFrame),ao(t)},Ic=e=>{let t=e;return t._exit?N(t._exit):tl(n=>t._exit?n(N(t._exit)):Wc(e.addObserver(e=>n(N(e)))))},Lc=e=>tl(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(N(r))}return a(),Wc(()=>i?.())}),Rc=e=>{let t=e;return t._exit?t._exit:tl(n=>t._exit?n(t._exit):Wc(e.addObserver(n)))},zc=e=>k(t=>Bc(e,t.id)),Bc=b(e=>S(e[0],wc),(e,t,n)=>k(r=>{let i=Fc(r);return i=i&&n?wo(i,n):i??n,e.interruptUnsafe(t,i),Sl(Ic(e))})),Vc=e=>k(t=>{let n=Fc(t),r=qo();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return Sl(Lc(r))}),N=Bi,Hc=Ui,Uc=Wi,Wc=Ri({op:`Sync`,[D](e){let t=this[E](),n=e.getCont(O);return n?n[O](t,e):e.yieldWith(Bi(t))}}),P=Ri({op:`Suspend`,[D](e){return this[E]()}}),Gc=Mo({onFailure:Uc,onSuccess:N}),Kc=Ri({op:`Yield`,[D](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(Ml)},this[E]??0),e.yieldWith(()=>{t=!0})}})(0),qc=e=>P(()=>Hc(e())),Jc=e=>Gi(e),Yc=e=>P(()=>Uc(e())),F=N(void 0),Xc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Ld(e,`An error occurred in Effect.try`):e.catch;return P(()=>{try{return N(t())}catch(e){return Uc(n(e))}})},Zc=e=>$c(function(t,n){e(n).then(e=>t(N(e)),e=>t(Jc(e)))},e.length!==0),Qc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Ld(e,`An error occurred in Effect.tryPromise`):e.catch;return $c(function(e,r){let i=e=>P(()=>{try{return Uc(ri(()=>n(e)))}catch(e){return Jc(e)}});try{t(r).then(t=>e(N(t)),t=>e(i(t)))}catch(t){e(i(t))}},t.length!==0)},$c=function(){let e=Li({op:`Async`,[D](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(el(()=>(t=!0,r?.abort(),i??Ml))),fi):n}}),t=function(e,t){this.register=e,this.withSignal=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),el=Ri({op:`AsyncFinalizer`,[di](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Uu))},[ui](e,t){return bc(e)?Cl(vu(Ui(e),this[E]()),()=>Hc(e)):Hc(e)}}),tl=e=>$c(e,e.length>=2),nl=tl(Mn),rl=(...e)=>{if(e.length===1){let t=e[0];return P(()=>cl(t()))}let[t,n]=e;return P(()=>cl(n.call(t.self)))},il=(e,...t)=>{let n=t.length===0?function(){return P(()=>cl(e.apply(this,arguments)))}:function(){let n=P(()=>cl(e.apply(this,arguments)));for(let e=0;e<t.length;e++)n=t[e](n,...arguments);return n};return al(e.length,n)},al=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),ol=(e,...t)=>al(e.length,t.length===0?function(){return sl(()=>e.apply(this,arguments))}:function(){let n=sl(()=>e.apply(this,arguments));for(let e of t)n=e(n,...arguments);return n}),sl=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return N(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 P(()=>n?(n=!1,Cl(r.value,e=>cl(t,e))):P(()=>cl(e())))}}}catch(e){return Jc(e)}},cl=function(){let e=Li({op:`Iterator`,[O](e,t){let n=this.iterator;for(;;){let r=n.next(e);if(r.done)return N(r.value);if(!I(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[D](e){return this[O](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)}}(),ll=b(2,(e,t)=>new fl(e,pl,N(t))),ul=function(e){return e._stack.push(this),this[E]},dl=Li({op:`OnSuccess`,[D]:ul}),fl=function(e,t,n){this[E]=e,this[O]=t,this.payload=n};fl.prototype=dl;var pl=function(){return this.payload},ml=function(e,t){return t.succeedWith(this.payload)},hl=(()=>{let e=`~effect/Effect/stackProbe`;return{[e]:function(){return Error().stack}}[e]()?.includes(`[as `+e+`]`)===!0})(),gl=function(e,t){let n=this.payload;return t.succeedWith(hl?n(e):ri(()=>n(e)))},_l=function(e){let t=this.payload;return t(e)},vl=function(e){let t=this.payload;return new fl(t(e),ml,e)},yl=function(e){return new fl(this.payload,ml,e)},bl=b(2,(e,t)=>new fl(e,hi(t)?pl:_l,t)),xl=b(2,(e,t)=>new fl(e,hi(t)?yl:vl,t)),Sl=e=>new fl(e,pl,Ml),Cl=b(2,(e,t)=>new fl(e,_l,t)),I=e=>e[si]!==void 0,wl=b(2,(e,t)=>I(e)?e._tag===`Success`?t(e.value):e:Cl(e,t)),Tl=b(2,(e,t)=>new fl(e,gl,t)),El=b(2,(e,t)=>I(e)?Nl(e,t):Tl(e,t)),Dl=b(2,(e,t)=>I(e)?Pl(e,t):$l(e,t)),Ol=b(2,(e,t)=>I(e)?Fl(e,t):eu(e,t)),kl=e=>e._tag===`Success`,Al=e=>e._tag===`Failure`?Do(e.cause):Oo(e),jl=e=>e._tag===`Failure`&&bc(e.cause),Ml=Bi(void 0),Nl=b(2,(e,t)=>e._tag===`Success`?Bi(t(e.value)):e),Pl=b(2,(e,t)=>{if(e._tag===`Success`)return e;let n=yc(e.cause);return Ao(n)?e:Wi(t(n.success))}),Fl=b(2,(e,t)=>{if(e._tag===`Success`)return Bi(t.onSuccess(e.value));let n=yc(e.cause);return Ao(n)?e:Wi(t.onFailure(n.success))}),Il=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?Ml:Ui(Ei(t))},Ll=b(2,(e,t)=>k(n=>{let r=n.context,i=t(r);return r===i?e:(n.setContext(i),Mu(n,()=>{n.setContext(r)}),e)})),Rl=b(3,(e,t,n)=>Ll(e,e=>{let r=yo(e,t),i=n(r);return r===i?e:ho(e,t,i)})),zl=()=>Bl,Bl=k(e=>N(e.context)),Vl=e=>k(t=>e(t.context)),Hl=b(2,(e,t)=>I(e)?e:Ll(e,wo(t))),Ul=function(){return arguments.length===1?b(2,(e,t)=>Wl(e,arguments[0],t)):b(3,(e,t,n)=>Wl(e,t,n)).apply(this,arguments)},Wl=(e,t,n)=>Ll(e,ho(t,n)),Gl=b(e=>hi(e[0]),(e,t)=>Xu({while:kn,body:On(t?.disableYield?e:Cl(e,e=>Kc)),step:Mn})),Kl=b(2,(e,t)=>new Jl(e,t.length===1?t:e=>t(e))),ql=Li({op:`OnFailure`,[D]:ul}),Jl=function(e,t){this[E]=e,this[ui]=t};Jl.prototype=ql;var Yl=b(3,(e,t,n)=>Kl(e,e=>{let r=t(e);return Ao(r)?Hc(r.failure):n(r.success,e)})),Xl=b(2,(e,t)=>Yl(e,yc,e=>t(e))),Zl=b(e=>hi(e[0]),(e,t,n,r)=>Kl(e,e=>{let i=yc(e);return Ao(i)?Hc(i.failure):t(i.success)?n(i.success):r?r(i.success):Hc(e)})),Ql=b(e=>hi(e[0]),(e,t,n,r)=>Zl(e,Array.isArray(t)?e=>S(e,`_tag`)&&t.includes(e._tag):Zn(t),n,r)),$l=b(2,(e,t)=>Xl(e,e=>Yc(()=>t(e)))),eu=b(2,(e,t)=>su(e,{onFailure:e=>Yc(()=>t.onFailure(e)),onSuccess:e=>Wc(()=>t.onSuccess(e))})),tu=e=>lu(e,{onFailure:Oo,onSuccess:Do}),nu=b(2,(e,t)=>new iu(e,t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),t.onFailure.length===1?t.onFailure:e=>t.onFailure(e))),ru=Li({op:`OnSuccessAndFailure`,[D]:ul}),iu=function(e,t,n){this[E]=e,this[O]=t,this[ui]=n};iu.prototype=ru;var au=function(e,t){let n=this.payload;return t.succeedWith(hl?n.onSuccess(e):ri(()=>n.onSuccess(e)))},ou=((e,t)=>{let n=Li({op:e,[D]:ul,[O]:au,[ui]:t}),r=function(e,t){this[E]=e,this.payload=t};return r.prototype=n,r})(`Match`,function(e,t){let n=e.reasons.find(Ni);if(n===void 0)return Hc(e);let r=this.payload;return t.succeedWith(hl?r.onFailure(n.error):ri(()=>r.onFailure(n.error)))}),su=b(2,(e,t)=>nu(e,{onFailure:e=>{let n=e.reasons.find(Ni);return n?t.onFailure(n.error):Hc(e)},onSuccess:t.onSuccess})),cu=b(2,(e,t)=>new ou(e,t)),lu=b(2,(e,t)=>{if(I(e)){if(e._tag===`Success`)return Bi(t.onSuccess(e.value));let n=yc(e.cause);return Ao(n)?e:Bi(t.onFailure(n.success))}return cu(e,t)}),uu=e=>I(e)?Bi(e):du(e),du=Ri({op:`Exit`,[D](e){return e._stack.push(this),this[E]},[O](e,t,n){return t.succeedWith(n??Bi(e))},[ui](e,t,n){return t.succeedWith(n??Ui(e))}}),fu=`~effect/Scope`,pu=`~effect/Scope/Closeable`,mu=A(`effect/Scope`),hu=(e,t)=>k(n=>(Ku(n),gu(e,t)??F)),gu=(e,t)=>{let n=e.state;if(n._tag===`Closed`||(e.state={_tag:`Closed`,exit:t},e.parent!==void 0&&wu(e.parent,e),n._tag===`Empty`))return;if(n.finalizer!==void 0)return _u(n.finalizer,t);let r=n.finalizers;return r.size===1?_u(r.values().next().value,t):yu(e,r,t)},_u=(e,t)=>{try{return e(t)}catch(e){return Gi(e)}},vu=(e,t)=>kl(e)?t:Kl(t,t=>Hc(Oi(e.cause,t))),yu=il(function*(e,t,n){let r=[],i=[],a=Array.from(t.values()),o=kc();for(let t=a.length-1;t>=0;t--){let s=a[t];e.strategy===`sequential`?r.push(yield*uu(_u(s,n))):i.push(id(o,_u(s,n),!0,!0,`inherit`))}return i.length>0&&(r=yield*Lc(i)),yield*Il(r)}),bu=(e,t)=>{let n=Eu(t,e);return e.state._tag===`Closed`?(n.state=e.state,n):(Cu(e,n,e=>hu(n,e)),n)},xu=(e,t)=>P(()=>e.state._tag===`Closed`?t(e.state.exit):(Cu(e,{},t),F)),Su=(e,t)=>xu(e,On(t)),Cu=(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))}},wu=(e,t)=>{if(e.state._tag!==`Open`)return;let n=e.state;n.finalizerKey===t?e.state=Du:n.finalizers!==void 0&&(n.finalizers.delete(t),n.finalizers.size===0&&(e.state=Du))},Tu=e=>Eu(e,void 0),Eu=(e=`sequential`,t)=>({[pu]:pu,[fu]:fu,strategy:e,parent:t,state:Du}),Du={_tag:`Empty`},Ou=Ul(mu),ku=e=>P(()=>{let t=Tu();return Nu(e(t),e=>P(()=>gu(t,e)??F))}),Au=function(){let e=Li({op:`OnExit`,[D](e){return e._stack.push(this),this.effect},[di](e){e.interruptible&&this.interruptible!==!0&&(e._stack.push(Uu),e.interruptible=!1)},[O](e,t,n){n??=Bi(e);let r;try{r=this.onExit(n)}catch(e){r=Gi(e)}return r?Cl(r,e=>n):n},[ui](e,t,n){n??=Ui(e);let r;try{r=this.onExit(n)}catch(e){r=Gi(e)}return r?Cl(vu(n,r),e=>n):n}}),t=function(e,t,n){this.effect=e,this.onExit=t,this.interruptible=n};return t.prototype=e,t}(),ju=(e,t,n)=>new Au(e,t,n),Mu=(e,t)=>{e._stack.push(new Au(void 0,t,void 0))},Nu=b(2,ju),Pu=b(3,(e,t,n)=>Nu(e,e=>{let r=t(e);return Ao(r)?F:n(r.success,e)})),Fu=b(2,(e,t)=>Pu(e,Al,t)),Iu=b(3,(e,t,n)=>Nu(e,e=>{if(e._tag!==`Failure`)return F;let r=t(e.cause);return Ao(r)?F:n(r.success,e.cause)})),Lu=b(2,(e,t)=>Iu(xc,t)(e)),Ru=On(1/0),zu=(e,t)=>{let n=0,r,i,a=(e,t)=>(t.awaiters++,Mu(e,()=>{if(!(--t.awaiters>0||i!==t))return i=void 0,zc(t.fiber)}),Rc(t.fiber));return[k(o=>{if(i!==void 0)return a(o,i);if(r!==void 0&&(n===1/0||o.getRef(Ed).currentTimeMillisUnsafe()<n))return r;r=void 0;let s=o.getRef(Ed),c={fiber:void 0,awaiters:0};return i=c,c.fiber=id(o,ju(e,e=>{if(i!==c||(i=void 0,jl(e)))return;let a=t(e);n=a===1/0?1/0:s.currentTimeMillisUnsafe()+a,r=e}),!0,!0),c.fiber._exit??a(o,c)}),Wc(()=>{r=void 0})]},Bu=e=>Wc(()=>zu(e,Ru)[0]),Vu=e=>k(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Uu),e):e),Hu=Ri({op:`SetInterruptible`,[di](e){if(e.interruptible=this[E],e._interruptedCause&&e.interruptible)return()=>Hc(e._interruptedCause)}}),Uu=Hu(!0),Wu=Hu(!1),Gu=e=>{if(e.interruptible=!0,e._stack.push(Wu),e._interruptedCause)return Hc(e._interruptedCause)},Ku=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(Uu))},qu=e=>k(t=>t.interruptible?e:Gu(t)??e),Ju=e=>k(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Uu),e(qu)):e(x)),Yu=(e,t)=>$n(e)?t?.mode===`result`?Zu(e,tu,t):Zu(e,x,t):t?.discard?t.mode===`result`?Zu(Object.values(e),tu,t):Zu(Object.values(e),x,t):P(()=>{let n={};return ll(Zu(Object.entries(e),([e,r])=>Tl(t?.mode===`result`?tu(r):r,t=>{ii(n,e,t)}),{discard:!0,concurrency:t?.concurrency}),n)}),Xu=Ri({op:`While`,[O](e,t){return this[E].step(e),this[E].while()?(t._stack.push(this),this[E].body()):Ml},[D](e){return this[E].while()?(e._stack.push(this),this[E].body()):Ml}}),Zu=b(e=>typeof e[1]==`function`,(e,t,n)=>P(()=>{let r=$u(n?.concurrency);if(r===1)return Qu(e,t,n);let i=Bo(e),a=i.length;if(a===0)return n?.discard?F:N([]);let o=n?.discard?void 0:Array(a),s=rd({f:t,out:o},i,{concurrency:r});return s?ll(s,o):N(o)})),Qu=(e,t,n)=>P(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return ll(Xu({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),$u=e=>e===`unbounded`?1/0:Math.max(1,e??1),ed=()=>e=>{let t=e.onItem,n=e.step,r=(e,t,r,a,o)=>Cl(uu(o),o=>n(e,t[r],o,r)??i(e,t,r+1,a)??F),i=(e,i,a=0,o=i.length)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!I(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},td=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=Gi(e);return f=t,c=!0,u&&u.size>0?Cl(Vu(Vc(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(I(ee)){if(f=n(e,o,ee,a),f)break}else if(l){p=void 0;let t=id(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=Ei(e);f=Ui(f._tag===`Failure`?Oi(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??F)}catch(e){d(m(e))}}),u.size<s)continue;i=!0,a++;return}else return tl(e=>{l=kc(),u=new Set,p=ee,d=e;let t;try{t=h()}catch(t){return e(m(t))}return t?e(t):P(()=>(f??=Ml,Cl(u?Vc(u):F,()=>f?._tag===`Failure`?f:F)))})}if(c=!0,f){if(u&&u.size>0){let e=Fc(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(F);else return Ml}};return h()}},nd=()=>e=>td(e),rd=td({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)}}),id=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new Ac(a.context,o);return r||(a.children().add(s),s._parent=a),n?s.evaluate(t):(s._asyncContext=Oc(),a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0)),s},ad=e=>(t,n)=>{let r=new Ac(n?.scheduler?ho(e,Ms,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},od=ad(fo()),sd=e=>{let t=ad(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},cd=(e=>{let t=sd(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw Cc(e.cause);return e.value})})(fo()),ld=e=>{let t=ad(e);return e=>{if(I(e))return e;let n=new Ls(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??Gi(new Fd(r))}},ud=ld(fo()),dd=(e=>{let t=ld(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw Cc(n.cause);return n.value}})(fo()),fd=N(!0),pd=N(!1),md=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return fd;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=[],fd}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](Ml)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](Ml)}open=k(e=>this._isOpen?pd:(this._isOpen=!0,this.scheduleUnsafe(e)));release=k(e=>this._isOpen?pd:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=tl(e=>this._isOpen?e(F):(this.waiters.push(e),Wc(()=>{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=Wc(()=>this.closeUnsafe());whenOpen=e=>Cl(this.await,()=>e);isOpen(){return this._isOpen}},hd=e=>new md(e??!1),gd=BigInt(0),_d={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:gd,endTime:gd,exit:Ml},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},vd=e=>Object.assign(Object.create(_d),e),yd=e=>e?bo(e.annotations,ec)?e._tag===`Span`?yd(Wa(e.parent)):La():Ra(e):La(),bd=(e,t,n)=>{let r=!e.cache.tracerEnabled||n?.annotations&&bo(n.annotations,ec),i=n?.parent===void 0?n?.root?La():yd(e.cache.span):Ra(n.parent),a;if(r)a=vd({name:t,parent:i,annotations:ho(n?.annotations??fo(),ec,!0)});else{let r=e.cache.tracer??ic,o=e.getRef(Ed),s=e.getRef(lc),c=e.getRef(uc),l=e.getRef(dc),u=n?.level??e.getRef(tc),d=n?.links===void 0?l.length===0?[]:l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??fo(),links:d,startTime:s?o.currentTimeNanosUnsafe():gd,kind:n?.kind??`internal`,root:n?.root??!1,sampled:n?.sampled??(Ba(i)&&i.value.sampled===!1?!1:!Rd(e.getRef(nc),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},xd=(e,t)=>(t=typeof t==`function`?t:jn,Rl(sc,n=>({name:e,stack:t,parent:n}))),Sd=(e,t,n,r)=>Wc(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():gd,t)}),Cd=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return k(t=>{let i=bd(t,e,n),a=t.getRef(Ed),o=t.getRef(lc);return Mu(t,e=>Sd(i,e,a,o)),r(i)})},wd=Ul(Qs),Td=function(){let e=hi(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=x;return t._tag===`Span`&&(n=mc(n),r=xd(t.name,n?.captureStackTrace)),e?wd(r(arguments[0]),t):e=>wd(r(e),t)},Ed=j(`effect/Clock`,{defaultValue:()=>new Od}),Dd=2**31-1,Od=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=Wc(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return jd()}currentTimeNanos=Wc(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return Ad()}monotonicTimeNanos=Wc(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(Es(e))}sleepMillis(e){return e<=0?Kc:Number.isFinite(e)?tl(t=>{let n=e>Dd?this.sleepMillis(e-Dd):F,r=setTimeout(()=>t(n),Math.min(e,Dd));return Wc(()=>clearTimeout(r))}):nl}},kd=BigInt(1e6),Ad=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())*kd;return e>t&&(t=e),t}}(),jd=function(){let e=BigInt(1e9),t;return()=>{let n=Ad(),r=BigInt(Date.now())*kd;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}}(),Md=`~effect/Cause/IllegalArgumentError`,Nd=class extends Ji(`IllegalArgumentError`){[Md]=Md;constructor(e){super({message:e})}},Pd=`~effect/Cause/AsyncFiberError`,Fd=class extends Ji(`AsyncFiberError`){[Pd]=Pd;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},Id=`~effect/Cause/UnknownError`,Ld=class extends Ji(`UnknownError`){[Id]=Id;constructor(e,t){super({message:t,cause:e})}},Rd=Pa(Ma(ja,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}})),zd={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};zd.gray,zd.blue,zd.green,zd.yellow,zd.red,zd.bgBrightRed,zd.black;var Bd=yi,Vd=bi,Hd=Ni,Ud=Ei,Wd=ki,Gd=ji,Kd=e=>new Ti(e),qd=e=>new Ai(e),Jd=_c,Yd=Sc,Xd=Oi,Zd=Cc,Qd=bc,$d=Xi,ef=ea,tf=Nd,nf=Bi,rf=Ui,af=Wi,of=Ml,sf=kl,cf={"~effect/Deferred":{_A:x,_E:x},pipe(){return y(this,arguments)}},lf=function(){this.resumes=void 0,this.effect=void 0};lf.prototype=cf;var uf=()=>new lf,df=e=>tl(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),Wc(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),ff=(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},pf=lc,mf=mu,hf=Tu,gf=Ou,_f=xu,vf=Su,yf=bu,bf=hu,xf=`~effect/Layer`,Sf=`~effect/Layer/MemoMap`,Cf=(e,t)=>{let n={observers:0,deferred:uf(),scope:hf(),finalizer:r=>P(()=>--n.observers>0?F:(e.map.delete(t),bf(n.scope,r)))};return n},wf=(e,t)=>t.state._tag!==`Closed`&&(e.observers++,Cu(t,{},e.finalizer),!0),Tf={[xf]:{_ROut:x,_E:x,_RIn:x},pipe(){return y(this,arguments)}},Ef=e=>{let t=Object.create(Tf);return t.build=e,t},Df=e=>Ef((t,n)=>{let r=yf(n);return Nu(e(t,r),e=>e._tag===`Failure`?bf(r,e):F)}),Of=e=>{let t=Df((n,r)=>n.getOrElseMemoize(t,r,e));return t},kf=class{get[Sf](){return Sf}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?(wf(n,t),n.deferred.effect??df(n.deferred)):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return P(()=>{let r;return ju(P(()=>{let i=this.get(e,t);if(i)return i;let a=Cf(this,e);return wf(a,t)?(r=a.deferred,this.map.set(e,a),n(this,a.scope)):n(this,t)}),e=>{r&&ff(r,e)})})}},Af=()=>new kf,jf=e=>new kf(e),Mf=class e extends A()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=_o(t,e);return n?jf(n):Af()}},Nf=b(3,(e,t,n)=>Ul(Tl(P(()=>e.build(t,n)),ho(Mf,t)),Mf,t)),Pf=b(2,(e,t)=>k(n=>Nf(e,Mf.forkOrCreate(n.context),t))),Ff=e=>Ef(On(N(e))),If=function(){return arguments.length===1?e=>Lf(arguments[0],e):Lf(arguments[0],arguments[1])},Lf=(e,t)=>Rf(Tl(t,t=>mo(e,t))),Rf=e=>Of((t,n)=>gf(e,n)),zf=e=>Rf(ll(e,fo())),Bf=(e,t,n)=>{let r=yf(n,`parallel`);return Zu(e,e=>e.build(t,yf(r,`sequential`)),{concurrency:e.length}).pipe(Tl(e=>To(...e)))},Vf=(...e)=>Df((t,n)=>Bf(e,t,n)),Hf=(e,t,n)=>Df((r,i)=>Cl(Array.isArray(t)?Bf(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(Hl(t),Tl(e=>n(e,t))))),Uf=b(2,(e,t)=>Hf(e,t,x)),Wf=b(2,(e,t)=>Hf(e,t,(e,t)=>wo(t,e))),Gf=Ed,Kf=`~effect/DateTime`,qf=`~effect/DateTime/TimeZone`,Jf={[Kf]:Kf,pipe(){return y(this,arguments)},[Yr](){return this.toString()},toJSON(){return op(this).toJSON()}},Yf={...Jf,_tag:`Utc`,[er](){return or(this.epochMilliseconds)},[w](e){return Zf(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${op(this).toJSON()})`}};({...Jf});var Xf={[qf]:qf,[Yr](){return this.toString()}};({...Xf}),{...Xf};var Zf=e=>S(e,Kf),Qf=e=>Zf(e[0]),$f=e=>e._tag===`Utc`,ep=e=>{let t=Object.create(Yf);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},tp=e=>{let t=e.getTime();if(Number.isNaN(t))throw new tf(`Invalid date`);return ep(t)},np=e=>{if(Zf(e))return e;if(e instanceof Date)return tp(e);if(typeof e==`object`){if(`epochMilliseconds`in e)return tp(new Date(e.epochMilliseconds));let t=new Date(0);return sp(t,e),tp(t)}return typeof e==`string`&&!rp(e)?tp(new Date(e+`Z`)):tp(new Date(e))},rp=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),ip=Ga(np),ap=e=>ep(e.epochMilliseconds),op=e=>new Date(e.epochMilliseconds),sp=(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)},cp=b(Qf,(e,t)=>new Intl.DateTimeFormat(t?.locale,t).format(e.epochMilliseconds)),lp=e=>op(e).toISOString(),up=b(2,(e,t)=>Yl(e,pp,e=>t(e))),dp=e=>e._tag===`Fail`&&$d(e.error),fp=e=>{let t,n=!1;for(let r of e.reasons)dp(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?Oo(e):n?Oo(Ud(e.reasons.filter(e=>!dp(e)))):Do(t)},pp=e=>{let t=fp(e);return Ao(t)?t:Do(t.success.value)},mp=e=>{let t=fp(e);return Ao(t)?rf(t.failure):nf(t.success.value)},hp=(e,t,n)=>ku(r=>Cl(n?.local?Nf(t,Af(),r):Pf(t,r),t=>Hl(e,t))),gp=b(e=>hi(e[0]),(e,t,n)=>co(t)?Hl(e,t):hp(e,Array.isArray(t)?Vf(...t):t,n)),_p=hi,vp=Yu,yp=Zc,bp=Qc,L=N,xp=P,Sp=Wc,Cp=F,wp=rl,R=Uc,Tp=Hc,Ep=qc,Dp=Jc,Op=Xc,kp=k,Ap=Gc,z=Cl,jp=bl,Mp=xl,Np=uu,Pp=Tl,Fp=ll,Ip=Sl,Lp=Ql,Rp=Kl,zp=$l,Bp=nu,Vp=zl,Hp=Vl,Up=gp,Wp=Hl,Gp=Ll,Kp=Ul,qp=Fu,Jp=Nu,Yp=Bu,Xp=Lu,Zp=Ju,Qp=Gl,$p=Cd,em=Td,tm=od,nm=cd,rm=dd,im=ud,am=il,om=El,sm=Dl,cm=Ol,lm=wl,um=ol,dm=`~effect/BigDecimal`,fm={[dm]:dm,[er](){let e=bm(this);return rr(sr(String(e.value)),or(e.scale))},[w](e){return pm(e)&&Tm(this,e)===0},toString(){return`BigDecimal(${Dm(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[Yr](){return this.toJSON()},pipe(){return y(this,arguments)}},pm=e=>S(e,dm),mm=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(fm);return n.value=e,n.scale=t,n},hm=(e,t)=>{let n=mm(e,t);return n.normalized=n,n},gm=BigInt(0),_m=BigInt(1),vm=BigInt(10),ym=hm(gm,0),bm=e=>{if(e.normalized===void 0){if(e.value===gm)e.normalized=ym;else{let t=`${e.value}`,n=t.length;for(;t[n-1]===`0`;)n--;e.normalized=hm(BigInt(t.slice(0,n)),e.scale-(t.length-n))}}return e.normalized},xm=100,Sm=[_m],Cm=(e,t)=>e===t?0:e<t?-1:1,wm=(e,t)=>{let n=`${e.value<gm?-e.value:e.value}`,r=`${t.value<gm?-t.value:t.value}`,i=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==gm)return i<gm?-1:1;let a=Math.max(n.length,r.length);return Aa(n.padEnd(a,`0`),r.padEnd(a,`0`))},Tm=(e,t)=>{if(e.scale===t.scale)return Cm(e.value,t.value);let n=Em(e),r=Em(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>xm)return n===-1?wm(t,e):wm(e,t);let o=Sm[a]??=vm**BigInt(a);return i>0?Cm(e.value,t.value*o):Cm(e.value*o,t.value)},Em=e=>e.value===gm?0:e.value<gm?-1:1,Dm=e=>{let t=bm(e);if(Math.abs(t.scale)>=16)return Om(t);let n=t.value<gm,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},Om=e=>{if(km(e))return`0e+0`;let t=bm(e),n=`${t.value}`,r=t.value<gm?2:1,i=n.slice(0,r),a=n.slice(r),o=a.length-t.scale;return`${i}${a===``?``:`.${a}`}e${o>=0?`+`:``}${o}`},km=e=>e.value===gm,Am=BigInt(1),jm=BigInt(1e3),Mm=BigInt(1024),Nm=[{symbol:`B`,factor:Am,names:[`B`,`byte`,`bytes`]},{symbol:`kB`,factor:jm,names:[`kB`,`kilobyte`,`kilobytes`]},{symbol:`MB`,factor:jm**BigInt(2),names:[`MB`,`megabyte`,`megabytes`]},{symbol:`GB`,factor:jm**BigInt(3),names:[`GB`,`gigabyte`,`gigabytes`]},{symbol:`TB`,factor:jm**BigInt(4),names:[`TB`,`terabyte`,`terabytes`]},{symbol:`PB`,factor:jm**BigInt(5),names:[`PB`,`petabyte`,`petabytes`]},{symbol:`EB`,factor:jm**BigInt(6),names:[`EB`,`exabyte`,`exabytes`]},{symbol:`ZB`,factor:jm**BigInt(7),names:[`ZB`,`zettabyte`,`zettabytes`]},{symbol:`YB`,factor:jm**BigInt(8),names:[`YB`,`yottabyte`,`yottabytes`]},{symbol:`RB`,factor:jm**BigInt(9),names:[`RB`,`ronnabyte`,`ronnabytes`]},{symbol:`QB`,factor:jm**BigInt(10),names:[`QB`,`quettabyte`,`quettabytes`]}],Pm=[Nm[0],{symbol:`KiB`,factor:Mm,names:[`KiB`,`kibibyte`,`kibibytes`]},{symbol:`MiB`,factor:Mm**BigInt(2),names:[`MiB`,`mebibyte`,`mebibytes`]},{symbol:`GiB`,factor:Mm**BigInt(3),names:[`GiB`,`gibibyte`,`gibibytes`]},{symbol:`TiB`,factor:Mm**BigInt(4),names:[`TiB`,`tebibyte`,`tebibytes`]},{symbol:`PiB`,factor:Mm**BigInt(5),names:[`PiB`,`pebibyte`,`pebibytes`]},{symbol:`EiB`,factor:Mm**BigInt(6),names:[`EiB`,`exbibyte`,`exbibytes`]},{symbol:`ZiB`,factor:Mm**BigInt(7),names:[`ZiB`,`zebibyte`,`zebibytes`]},{symbol:`YiB`,factor:Mm**BigInt(8),names:[`YiB`,`yobibyte`,`yobibytes`]}];[...Nm,...Pm.slice(1)];var Fm=Zf,Im=$f,Lm=tp,Rm=np,zm=ip,Bm=ap,Vm=cp,Hm=lp,Um=e=>Gm(typeof e==`string`?Km.encode(e):e),Wm=e=>{let t=qm(e),n=t.length;if(n%4!=0)return Oo(new Gs({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 Oo(new Gs({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=Xm(t.charCodeAt(e))<<18|Xm(t.charCodeAt(e+1))<<12|Xm(t.charCodeAt(e+2))<<6|Xm(t.charCodeAt(e+3));r[i]=n>>16,r[i+1]=n>>8&255,r[i+2]=n&255}return Do(r)}catch(e){return Oo(new Gs({kind:`Decode`,module:`Base64`,input:t,message:e instanceof Error?e.message:`Invalid input`}))}},Gm=e=>{let t=e.length,n=``,r=2;for(;r<t;r+=3)n+=Jm[e[r-2]>>2],n+=Jm[(e[r-2]&3)<<4|e[r-1]>>4],n+=Jm[(e[r-1]&15)<<2|e[r]>>6],n+=Jm[e[r]&63];return r===t+1&&(n+=Jm[e[r-2]>>2],n+=Jm[(e[r-2]&3)<<4],n+=`==`),r===t&&(n+=Jm[e[r-2]>>2],n+=Jm[(e[r-2]&3)<<4|e[r-1]>>4],n+=Jm[(e[r-1]&15)<<2],n+=`=`),n},Km=new TextEncoder,qm=e=>e.replace(/[\n\r]/g,``),Jm=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Ym=new Uint8Array(123).fill(255);for(let e=0;e<64;e++)Ym[Jm.charCodeAt(e)]=e;Ym[61]=0;var Xm=e=>{if(e>=Ym.length||Ym[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return Ym[e]},Zm=`~effect/http/Cookies`,Qm=`~effect/http/Cookies/Cookie`,$m={[Zm]:Zm,...Zr,toJSON(){return{_id:`effect/Cookies`,cookies:Fo(this.cookies,e=>e.toJSON())}},pipe(){return y(this,arguments)}},eh=e=>{let t=Object.create($m);return t.cookies=e,t},th=e=>{let t={};for(let n of e)ii(t,n.name,n);return eh(t)},nh=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=rh(e.trim());t&&n.push(t)}return th(n)};function rh(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(!ih.test(r))return;let i=t[0].slice(n+1),a=oh(i);if(t.length===1)return Object.assign(Object.create(ah),{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=xs(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(ah),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var ih=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,ah={[Qm]:Qm,...Zr,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},oh=e=>{try{return decodeURIComponent(e)}catch{return e}},sh=new WeakMap,ch=`~effect/Redacted`,lh=e=>S(e,ch),uh=(e,t)=>{let n=Object.create(dh);return t?.label&&(n.label=t.label),sh.set(n,e),n},dh={[ch]:{_A:e=>e},label:void 0,...pi,toJSON(){return this.toString()},toString(){return`<redacted${Bn(this.label)?`:`+this.label:``}>`},[er](){return C(sh.get(this))},[w](e){return lh(e)&&vr(sh.get(this),sh.get(e))}},fh=Symbol.for(`~effect/http/Headers`),ph=Object.defineProperties(Object.create(null),{[fh]:{value:fh},[Nr]:{value(e){return Ch(this,bo(e,Th))}},toJSON:{value(){return Fr(this)}},[w]:{value(e){return hh(this,e)}},[er]:{value(){return lr(this)}},toString:{value:Zr.toString},[Yr]:{value:Zr[Yr]}}),mh=e=>Object.assign(Object.create(ph),e),hh=Ro(ia()),gh=Object.create(ph),_h=e=>{if(e===void 0)return gh;if(Symbol.iterator in e){let t=Object.create(ph);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(ph);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},vh=e=>Object.setPrototypeOf(e,ph),yh=b(3,(e,t,n)=>{let r=mh(e);return r[t.toLowerCase()]=n,r}),bh=b(2,(e,t)=>mh({...e,..._h(t)})),xh=b(2,(e,t)=>{let n=mh(e);return Object.assign(n,t),n}),Sh=b(2,(e,t)=>{let n=mh(e);return delete n[t.toLowerCase()],n}),Ch=b(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=uh(e[r]))}else for(let r in e)r.search(t)!==-1&&(n[r]=uh(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),wh=(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},Th=j(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`,`AWSAccessKeyId`,`Signature`,`sig`,`X-Goog-Signature`]}),Eh=`~effect/http/UrlParams`,Dh=e=>S(e,Eh),Oh={...pi,[Eh]:Eh,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:`UrlParams`,params:Object.fromEntries(this.params)}},[w](e){return Mh(this,e)},[er](){return dr(this.params.flat())}},kh=e=>{let t=Object.create(Oh);return t.params=e,t},Ah=e=>{if(Dh(e))return e;let t=jh(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 kh(n)},jh=e=>{let t=typeof e[Symbol.iterator]==`function`?Bo(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=jh(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},Mh=na((e,t)=>Nh(e.params,t.params)),Nh=Xo(No([ia(),ia()])),Ph=kh([]),Fh=b(2,(e,t)=>kh(t(e.params))),Ih=b(2,(e,t)=>{let n=Ah(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 kh(n)}),Lh=b(2,(e,t)=>Fh(e,Uo(Ah(t).params))),Rh=e=>new URLSearchParams(Ah(e).params).toString(),zh=e=>{let t={};for(let[n,r]of e.params)if(!Object.hasOwn(t,n))ii(t,n,r);else{let e=t[n];typeof e==`string`?ii(t,n,[e,r]):e.push(r)}return t};function Bh(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function Vh(e){return t=>Bh(t)?.[e]}var Hh=`~structural`,Uh=`~sentinels`,Wh=`~constructor`,Gh=Nn(e=>{let t=Bh(e)?.identifier;return typeof t==`string`?t:e.getExpected(Gh)}),B=Symbol(),Kh=nf,qh=Kh(B),V=Kh(B),Jh=e=>e===B?La():Ra(e),Yh=e=>e._tag===`None`?qh:Kh(e.value),Xh=`~effect/SchemaIssue/Issue`;function Zh(e){return S(e,Xh)&&e[Xh]===Xh}function Qh(e){return Object.hasOwn(e,`input`)}var $h=class{[Xh]=Xh;constructor(e,t){t?.reportInput===!0&&e!==B&&(this.input=e)}},eg=class extends $h{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},tg=class extends $h{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},ng=class extends $h{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},rg=class extends $h{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},ig=class extends $h{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},ag=class extends $h{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},og=class extends $h{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},sg=class extends $h{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}};function cg(e,t,n,r,i){return new ag(e,[new ng([t],n)],r,i)}var lg=class extends $h{_tag=`Forbidden`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},ug=class extends $h{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},dg=class extends $h{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function fg(e,t,n){if(Zh(e))return e;if(typeof e==`string`)return new sg({message:e},t,n);let r=typeof e.issue==`string`?new sg({message:e.issue},t,n):e.issue;return new ng(e.path,r)}function pg(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new sg(void 0,t,n):fg(e,t,n)}function mg(e,t,n,r){return Array.isArray(t)?Go(t)?t.length===1?fg(t[0],n,r):new ag(e,Yo(t,e=>fg(e,n,r)),n,r):void 0:pg(t,n,r)}var hg=e=>{let t=Eg(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return bg(Gh(e.ast),e);case`InvalidValue`:{let t=yg(e);if(t!==void 0)return bg(t,e);let n=vg(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=vg(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=vg(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},gg=e=>Eg(e.issue)??Eg(e);function _g(e){return t=>({issues:xg(t,[],e?.leafHook??hg,e?.checkHook??gg)})}function vg(e){return Qh(e)?T(e.input):void 0}function yg(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function bg(e,t){let n=vg(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function xg(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 xg(e.issue,t,n,r);let a=yg(e.issue);return[{path:t,message:a===void 0?bg(Sg(e.filter),e):bg(a,e.issue)}]}case`Encoding`:return xg(e.issue,t,n,r);case`Pointer`:return xg(e.issue,[...t,...e.path],n,r);case`Composite`:return e.issues.flatMap(e=>xg(e,t,n,r));case`AnyOf`:return e.issues.length===0?[{path:t,message:Eg(e)??bg(Gh(e.ast),e)}]:e.issues.flatMap(e=>xg(e,t,n,r));default:return[{path:t,message:n(e)}]}}function Sg(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=>Sg(e)).join(` & `)}}function Cg(){return e=>Tg(e,``)}var wg=Cg();function Tg(e,t){let n;switch(e._tag){case`Filter`:{let r=gg(e);if(r!==void 0)n=r;else{if(e.issue._tag!==`InvalidValue`)return Tg(e.issue,t);let r=yg(e.issue);n=r===void 0?bg(Sg(e.filter),e):bg(r,e.issue)}break}case`Encoding`:return Tg(e.issue,t);case`Pointer`:return Tg(e.issue,t+Hr(e.path));case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>Tg(e,t)).join(`
|
|
9
|
+
`);n=Eg(e)??bg(Gh(e.ast),e);break;default:n=hg(e)}return t?`${n}\n at ${t}`:n}function Eg(e){if(e._tag===`Pointer`)return;if(e._tag===`Encoding`)return Eg(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 Dg(e){let t;for(let n of e.reasons){if(!Hd(n)||!Zh(n.error))return;t??=n.error}return t}function Og(e,t){let n=Dg(e);if(n===void 0)throw Error(t,{cause:e});return n}var kg=e=>Object.assign(Object.create(En),e);function Ag(e){return Ig((t,n)=>R(e(t,n)))}function jg(e){return Ag((t,n)=>{let r={message:e(t)};return Ba(t)?new lg(r,t.value,n):new lg(r)})}var Mg=jg(()=>`Encoding is not supported`),Ng=kg({_tag:`Passthrough`});function Pg(){return Ng}function H(e){return kg({_tag:`Transform`,transform:e})}function Fg(e){return kg({_tag:`TransformEffect`,transform:e})}function Ig(e){return kg({_tag:`TransformOptionalEffect`,transform:e})}function Lg(){return H(globalThis.String)}function Rg(){return H(globalThis.Number)}function zg(e){return Fg((t,n)=>Op({try:()=>JSON.parse(t,e?.reviver),catch:()=>new sg({expected:`a valid JSON string`},t,n)}))}function Bg(e){return Fg((t,n)=>Op({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 sg({expected:`a JSON-serializable value`},t,n)}))}function Vg(){return H(Um)}function Hg(){return Fg((e,t)=>sm(Ap(Wm(e)),()=>new sg({expected:`a valid Base64 string`},e,t)))}var Ug=class extends Dn{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Ug(this.encode,this.decode)}},Wg=`~effect/SchemaTransformation/Transformation`,Gg=class extends Dn{[Wg]=Wg;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Gg(this.encode,this.decode)}};function Kg(e){return S(e,Wg)&&e[Wg]===Wg}var qg=e=>Kg(e)?e:new Gg(e.decode,e.encode);function Jg(e){return new Gg(Fg(e.decode),Fg(e.encode))}function Yg(e){return new Gg(H(e.decode),H(e.encode))}var Xg=new Gg(Pg(),Pg());function Zg(){return Xg}var Qg=new Gg(Rg(),Lg()),$g=e=>Yn(e)&&typeof e.message==`string`,e_=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:i_(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},t_=e=>{try{let t=Kr(e);return t===void 0?T(e):JSON.parse(t)}catch{return T(e)}},n_=(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},r_=e=>{let t=new WeakSet,n=r=>{if(Qn(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=n_(r,e,n);return t.delete(r),i}return t_(r)};return n},i_=e=>$g(e)?e_(e):e,a_=e=>Yg({decode:i_,encode:r_(e)}),o_=new Gg(Hg(),Vg());function s_(e){return new Gg(zg(e??{}),Bg(e))}function c_(e){return t=>t._tag===e}var l_=c_(`Declaration`),u_=c_(`Null`),d_=c_(`Void`),f_=c_(`Never`),p_=c_(`Literal`),m_=c_(`UniqueSymbol`),h_=c_(`Enum`),g_=c_(`Arrays`),__=c_(`Objects`),v_=c_(`Union`),y_=c_(`Suspend`),U=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},b_={},x_=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}},S_=`~effect/Schema`,C_=class{[S_]=S_;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}>`}},w_=class extends C_{_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===B?qh:(e??=this.run(this.typeParameters))(t,this,n)}_rebuild(e,t,n,r,i){let a=Kv(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new w_(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>`}},T_=new class extends C_{_tag=`Null`;getParser(){return uy(this,null)}getExpected(){return`null`}},E_=class extends C_{_tag=`Undefined`;getParser(){return uy(this,void 0)}toCodecJson(){return W(this,[D_])}getExpected(){return`undefined`}},D_=new U(T_,new Gg(H(()=>void 0),H(()=>null))),O_=new E_,k_=new class extends C_{_tag=`Void`;getParser(){let e=Kh(void 0);return t=>t===B?qh:e}toCodecJson(){return W(this,[D_])}getExpected(){return`void`}},A_=new class extends C_{_tag=`Never`;getParser(){return dy(this,qn)}getExpected(){return`never`}},j_=new class extends C_{_tag=`Unknown`;getParser(){return dy(this,Jn)}getExpected(){return`unknown`}},M_=class extends C_{_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 ${T(e)}`);this.literal=e}getParser(){return uy(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?N_(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:N_(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function N_(e){let t=globalThis.String(e.literal);return W(e,[new U(new M_(t),new Gg(H(()=>e.literal),H(()=>t)))])}var P_=new class extends C_{_tag=`String`;getParser(){return dy(this,Bn)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&by(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},F_=class extends C_{_tag=`Number`;getParser(){return dy(this,Vn)}matchKey(e,t){return this._match(hy,e,t)}matchPart(e,t){return this._match(my,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:by(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(I_(this.checks,`effect/schema/isFinite`)||I_(this.checks,`effect/schema/isInt`))?this:W(this,[Av])}toCodecStringTree(){return this.toCodecJson()===this?W(this,[vy]):W(this,[yy])}getExpected(){return`number`}};function I_(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&I_(e.checks,t))}var L_=new F_,R_=new class extends C_{_tag=`Boolean`;getParser(){return dy(this,Hn)}getExpected(){return`boolean`}},z_=class extends C_{_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(ty(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(ty(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 ig(n,t[o],i),a=new ng([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return R(new ag(n,[a],t,i))}return e.issues?R(new ag(n,e.issues,t,i)):Kh(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:$u(t.concurrency),f=d===1?H_(i,e,0,u):U_(i,e,{concurrency:d,end:u});if(!f)return c(i);if(I(f))return lm(f,()=>c(i));let p=!0;return xp(()=>p?(p=!1,z(f,()=>c(i))):l(e,t))};return(e,a)=>{if(e===B)return qh;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)):R(new og(n,e,a))}catch(e){return Dp(e)}}}_rebuild(e,t,n){let r=Kv(this.elements,e),i=Kv(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new z_(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 B_(e,t,n,r){if(n._tag===`Failure`)return W_(e,e.ast,r,n);let i=n===V?t:n[E];if(i!==B)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(ty(t.ast))return;let n=new ng([r],new rg(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return af(new ag(e.ast,[n],e.input,e.options))}}var V_={onItem(e,t,n){let r=n<e.len?t:B;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:B_},H_=ed()(V_),U_=nd()(V_),W_=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=Dg(r.cause);if(i===void 0)return rf(Yd(r.cause,r=>new ag(t,[new ng([n],r)],e.input,e.options)));let a=new ng([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return af(new ag(t,[a],e.input,e.options))},G_=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;function K_(e,t,n=b_){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(fy(oy(t)))}var q_=class{name;type;constructor(e,t){this.name=e,this.type=t}};function J_(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(J_);default:return!1}}function Y_(e){let t=Iv(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(Y_);default:return!1}}function X_(e){return J_(e)&&Y_(e)}var Z_=class{parameter;type;constructor(e,t){if(!X_(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,ty(t)&&!ly(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},Q_=class extends C_{_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 dy(n,Kn);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(fy(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 W_(t,n,i,s)??of;let c=s===V?o:s[E];if(a!==B&&c!==B){if(r&&(e.has(i)||e.has(typeof a==`number`?globalThis.String(a):a)))return of;ii(t.out,a,c)}return of},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!I(t))return z(Np(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return W_(e,n,r,a)??of;let o=a===V?r:a[E],s=e.input[r],l=i.parserValue(s,e.options);return I(l)?t(e,r,o,s,l):z(Np(l),n=>t(e,r,o,s,n))},l=(e,n,r)=>{let i=e.input[n],a=r.parserValue(i,e.options);return I(a)?t(e,n,n,i,a):z(Np(a),r=>t(e,n,n,i,r))},u=i?nd()({onItem:(e,[t,n])=>n.is.parameter===P_?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return um(function*(t,d){if(t===B)return B;if(typeof t!=`object`||!t||Array.isArray(t))return yield*R(new og(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:$u(d.concurrency),ne=i&&ee?n.indexSignatures.map(e=>K_(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 ig(n,f[a],d),r=new ng([a],e);if(h){m.issues?m.issues.push(r):m.issues=[r];continue}return yield*R(new ag(n,[r],t,d))}}}if(r){let e=te===1?tv(m,a):nv(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===P_?l:c,r=ne?.[e]??(t.is.parameter===P_?Object.keys(f):K_(f,t.is.parameter,d));for(let e=0;e<r.length;e++){let i=n(m,r[e],t);if(!I(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(u){let e=qo();for(let t=0;t<i;t++){let n=o[t],r=ne?.[t]??(n.is.parameter===P_?Object.keys(f):K_(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*R(new ag(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return z(Np(n),n=>{let i=$_(e,r,n);if(i)return i;let o=()=>Kh(e.out),s=tv(e,a.slice(t+1));return s?lm(s,o):o()})};return(e,t)=>{if(e===B)return qh;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&$u(t.concurrency)!==1)return(l??=c())(e,t);if(typeof e!=`object`||!e||Array.isArray(e))return R(new og(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=mv(i,s),l=c?i[s]:B,d=n.parser(l,t);if(!I(d))return u(o,e,d);if(d===V){c&&ii(a,s,l);continue}let f=$_(o,n,d);if(f)return f}}catch(e){return Dp(e)}return Kh(a)}}_rebuild(e,t,n,r){let i=Kv(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new q_(t.name,n)}),a=Kv(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new Z_(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new Q_(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 $_(e,t,n){if(n._tag===`Failure`)return W_(e,e.ast,t.name,n);if(n===V)return;let r=n[E];if(r!==B){ii(e.out,t.name,r);return}if(delete e.out[t.name],!ty(t.type)){let n=new ng([t.name],new rg(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return af(new ag(e.ast,[n],e.input,e.options))}}var ev={onItem(e,t){if(!mv(e.input,t.name))return t.parser(B,e.options);let n=e.input[t.name];return ii(e.out,t.name,n),t.parser(n,e.options)},step:$_},tv=ed()(ev),nv=nd()(ev);function rv(e,t){return e?t?[...e,...t]:e:t}function iv(e,t,n){return new Q_(Reflect.ownKeys(e).map(t=>new q_(t,e[t].ast)),[],n,t)}function av(e){return e.ast}function ov(e,t=void 0){return new z_(!1,e.map(e=>e.ast),[],void 0,t)}function sv(e,t,n){return new gv(e.map(av),t,void 0,n)}var cv=Pn(e=>{for(;;){if(y_(e))return j_;let t=e.encoding;if(!t)return e.recur?.(cv,x)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==x))return j_;e=t[t.length-1].to}});function lv(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(lv)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function uv(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[Uh];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!ty(t)){if(p_(t))return[{key:e.name,literal:t.literal}];if(m_(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!ty(e)){if(p_(e))return[{key:t,literal:e.literal}];if(m_(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>uv(cv(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return uv(e.thunk())}}var dv=new WeakMap,fv=Object.freeze([]),pv=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,mv=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function hv(e){let t=dv.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=cv(c);if(f_(l))continue;if(p_(l)||m_(l)){a??=new Map;let e=p_(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=uv(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=lv(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??fv);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??fv;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(Xn(e)){let n=mv(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??fv;if(t)return o}return fv}}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=pv(t);if(!Xn(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=mv(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=mv(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=mv(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(pv(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return dv.set(e,t),t}var gv=class extends C_{_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===B)return qh;let i=(o??=hv(n.types))(e,r);if(i.length===0)return R(new ug(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:I(r)?_v(n,r.cause,e,t):vv(n,r,e,t)}return yv(n,a,i,e,t)}}_rebuild(e,t,n){let r=Kv(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new gv(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=oy(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(p_);if(t.length>0)return`${Cv(n.isMutable)}[ ${t.map(t=>e(t)+wv(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>p_(e.type));if(t.length>0)return`{ ${t.map(t=>`${Cv(t.type.context?.isMutable)}${Vr(t.name)}${wv(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function _v(e,t,n,r){let i=Dg(t);return i?af(new ug(e,[i],n,r)):rf(t)}function vv(e,t,n,r){return Rp(t,t=>_v(e,t,n,r))}function yv(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=xv(a,n);if(!o)return a.out?a.out:R(new ug(e,a.issues??[],r,i));if(I(o))return bv(o,a);let s=!0;return xp(()=>s?(s=!1,bv(o,a)):yv(e,t,n,r,i))}function bv(e,t){return lm(e,e=>t.out===V?L(t.input):t.out?t.out:R(new ug(t.ast,t.issues??[],t.input,t.options)))}var xv=ed()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=Dg(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]),af(new dg(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return of}}}),Sv=new gv([new M_(`Infinity`),new M_(`-Infinity`),new M_(`NaN`)]);function Cv(e){return e?``:`readonly `}function wv(e){return e?`?`:``}var Tv=class extends Dn{_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 Tv(this.run,{...this.annotations,...e},this.aborted)}abort(){return new Tv(this.run,this.annotations,!0)}and(e,t){return new Ev([this,e],t)}},Ev=class extends Dn{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new Ev(this.checks,{...this.annotations,...e})}and(e,t){return new Ev([this,e],t)}};function Dv(e,t,n=!1){return new Tv((t,n,r)=>mg(n,e(t,n,r),t,r),t,n)}function Ov(e){return Dv(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 kv=zv(L_,[Ov()]),Av=new U(new gv([kv,Sv]),new Gg(Rg(),H(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function jv(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return Dv(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 Mv=new WeakMap;function Nv(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&Mv.set(n,Pv(e)),n}function Pv(e){let t=Mv.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 Mv.set(e,n),n}function W(e,t){return e.encoding===t?e:Nv(e,{encoding:t})}function Fv(e,t){if(e.context===t)return e;let n=Pv(e);return n.context===t&&n.encoding===e.encoding?n:Nv(e,{context:t})}function Iv(e){return e.encoding?Iv(e.encoding[e.encoding.length-1].to):e}function Lv(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Rv(e,Ho(e.checks.slice(0,-1),n.annotate(t)))}return Nv(e,{annotations:{...e.annotations,...t}})}function Rv(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:Nv(e,{checks:t})}function zv(e,t){return Rv(e,rv(e.checks,t))}function Bv(e,t){let n=t(e.to);return n===e.to?e:new U(n,e.transformation)}function Vv(e,t){let n=e,r=n[n.length-1],i=Bv(r,t);return i===r?e:Ho(e.slice(0,e.length-1),i)}function Hv(e){return t=>t.encoding?W(t,Vv(t.encoding,e)):t}function Uv(e,t){return Hv(e=>Fv(e,t))(e)}function Wv(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:W(r,Vv(r.encoding,n))}return e(r)}return Pn(n)}function Gv(e,t,n){let r=new U(e,t);return W(n,n.encoding?[...n.encoding,r]:[r])}function Kv(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 qv(e,t){return Fv(e,e.context?new x_(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new x_(!1,!1,void 0,t))}var Jv=Pn(e=>Yv(Fv(e,e.context?e.context.isOptional===!1?new x_(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new x_(!0,!1)))),Yv=Hv(Jv),Xv=Nn(e=>Jv(new gv([e,O_])));function Zv(e,t){return Fv(e,e.context?new x_(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new x_(!1,!1,t))}function Qv(e,t,n){return Gv(e,n,t)}function $v(e){let t=[],n=[];function r(e){switch(e._tag){case`Literal`:Wn(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 ey(e,t){let{literals:n,parameters:r}=$v(e);return new Q_(n.map(e=>new q_(e,t)),r.map(e=>new Z_(e,t)))}function ty(e){return e.context?.isOptional??!1}function ny(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(ny)}function ry(e){function t(e){return ny(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return Wo(n)?n:void 0}function iy(e){let t=!0;function n(e){return t=t&&!e.encoding&&!y_(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}var ay=Pn(e=>{let t=Pv(e);if(t!==e){let n=ay(t);return n===t&&e.encoding===void 0?e:Fv(n,e.context)}let n=`recur`in e?e.recur(ay):e;if(`encodingChecks`in n&&n.encodingChecks){let t=iy(e)?n.encodingChecks:g_(n)||__(n)||l_(n)&&n.typeParameters.length>0?ry(n.encodingChecks):void 0;return Nv(n,{encodingChecks:void 0,checks:rv(n.checks,t)})}return n}),oy=Pn(e=>ay(cy(e)));function sy(e,t){let n=t,r=n.length,i=n[r-1],a=[new U(cy(W(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new U(cy(n[e-1].to),n[e].transformation.flip()));let o=cy(i.to);return o.encoding?W(o,[...o.encoding,...a]):W(o,a)}var cy=Nn(e=>{if(e.encoding)return sy(e,e.encoding);let t=Pv(e);if(t!==e){let n=cy(t);return n===t?e:Fv(n,e.context)}return`flip`in e?e.flip(cy):`recur`in e?e.recur(cy):e});function ly(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(ly);default:return!1}}function uy(e,t){let n=t===0?V:Kh(t);return(r,i)=>r===B?qh:r===t?n:R(new og(e,r,i))}function dy(e,t){return(n,r)=>n===B?qh:t(n)?V:R(new og(e,n,r))}var fy=Wv(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(fy)}}),py=Wv(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(py)}}),my=new globalThis.RegExp(`^${G_}$`),hy=new globalThis.RegExp(`^(?:${G_}|Infinity|-Infinity|NaN)$`);function gy(e){return jv(my,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:my.source}),...e})}var _y=zv(P_,[gy()]),vy=new U(_y,Qg),yy=new U(new gv([_y,Sv]),Qg);function by(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=by(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 eg(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function xy(e){if(!l_(e))return;let t=e.annotations?.[Wh];return Gn(t)?t(e.typeParameters):void 0}var Sy=Vh;function Cy(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function wy(e){return e===void 0||typeof e==`string`}function Ty(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 Ey(e){return Ty(e,Cy)}var Dy=new w_([],()=>(e,t,n)=>Ey(e)?V:R(new og(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>jy}),Oy=new U(Dy,Zg()),ky=new U(new gv([new z_(!1,[],[Dy]),new Q_([],[new Z_(P_,Dy)])]),Zg());function Ay(e){return Ty(e,wy)}var jy=new U(new w_([],()=>(e,t,n)=>Ay(e)?V:R(new og(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),Zg()),My=(e,t,n)=>e===V?n(t):lm(e,n);function Ny(e){if(e._tag===`Middleware`)return(t,n,r)=>Py(t===V?e.decode(Kh(Jh(n)),r):e.decode(om(t,Jh),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===V?Kh(t):e;case`Transform`:{let e=e=>e===B?qh:Kh(t.transform(e));return(t,n)=>My(t,n,e)}case`TransformOptional`:{let e=e=>Yh(t.transform(Jh(e)));return(t,n)=>My(t,n,e)}case`TransformEffect`:return(e,n,r)=>My(e,n,e=>e===B?qh:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>My(e,n,e=>Py(t.transform(Jh(e),r)))}}var Py=e=>lm(e,Yh),Fy=(e,t,n,r)=>Rp(r,r=>Ep(()=>Yd(r,r=>new tg(e,r,t,n))));function Iy(e,t){let n=Ny(e.link.transformation),r;return(i,a)=>{if(i===B)return qh;if(e.isConstructed(i))return V;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function Ly(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==B&&r!==void 0)return t(r,i);let a=n;if(I(a)&&a._tag===`Success`){let e=t(a[E],i);return e===V?a:e}return lm(Fy(e,r,i,a),e=>{let n=t(e,i);return n===V?Kh(e):n})}}function Ry(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:Ly(e,n)}function zy(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?xy(e):void 0,o=a?Iy(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>Ny(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(I(r)){if(r._tag===`Success`){let i=r===V?t:r[E];if(t!==B&&i!==B){let i=by(u,t,void 0,e,n);i&&(r=R(new ag(e,i,t,n)))}}}else r=z(r,r=>{if(t!==B&&r!==B){let r=by(u,t,void 0,e,n);if(r)return R(new ag(e,r,t,n))}return L(r)})}if(s&&!n.disableChecks){if(I(r)){if(r._tag===`Success`){let i=r===V?t:r[E];if(i===B)return r;let a=by(s,i,void 0,e,n);a&&(r=R(new ag(e,a,i,n)))}}else r=z(r,t=>{if(t!==B){let r=by(s,t,void 0,e,n);if(r)return R(new ag(e,r,t,n))}return L(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[E],o=t(a,r)):o=lm(o,e=>{let n=t(e,r);return n===V?Kh(e):n})}if(o._tag===`Success`){let e=o[E],t=p(e,r);return t===V?o:t}return o=Fy(e,n,r,o),lm(o,e=>{let t=p(e,r);return t===V?Kh(e):t})}:p}var By=Symbol(),Vy=new WeakMap,Hy=e=>Ky(e).parser,Uy=e=>Ky(e).makeEffect,Wy=e=>Ry(e,Uy),Gy=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=zy(this.ast,Hy)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=zy(this.ast,Uy,Wy)}};function Ky(e){let t=Vy.get(e);if(t!==void 0)return t;let n=new Gy(e);return Vy.set(e,n),n}function qy(e){let t=e.ast,n;return(e,r)=>(n??=ab(ub,ay(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function Jy(e){let t=qy(e);return(e,n)=>{let r=im(t(e,n));return sf(r)?Ra(r.value):(Og(r.cause,`Option adapter can only return none for schema issues`),La())}}function Yy(e){return cb(ay(e.ast))}function Xy(e){return Qy(e.ast)}function Zy(e){{let t=ob(rb(e));return e=>{let n=t(e,b_);return sf(n)?!0:(Og(n.cause,`Type guard adapter can only return false for schema issues`),!1)}}}function Qy(e){let t=ay(e),n=e=>(n=Zy(t),n(e));return e=>n(e)}function $y(e,t){let n=rb(e.ast);return t===void 0?n:(e,r)=>n(e,tb(t,r))}function eb(e,t){let n=rb(cy(e.ast));return t===void 0?n:(e,r)=>n(e,tb(t,r))}var tb=(e,t)=>t?{...e,...t}:e,nb=e=>e===B?R(new sg):L(e);function rb(e){return ab(lb,e)}function ib(e,t){return e===V?L(t):I(e)?e[E]===B?nb(B):e:lm(e,nb)}function ab(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??b_);return a===V?L(r):I(a)?a[E]===B?nb(B):a:lm(a,nb)}}function ob(e){return(t,n)=>im(e(t,n))}function sb(e,t){let n=im(e);if(sf(n))return n.value;let r=Og(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}function cb(e){let t,n;return(r,i)=>{t??=Ky(e);let a=i?.disableChecks?i.parseOptions?{...i.parseOptions,disableChecks:!0}:{disableChecks:!0}:i?.parseOptions??b_,o=t.make;if(o!==void 0&&r!==B){let e;try{e=o(r,a)}catch(e){throw Og(Gd(e),`Constructor adapter can only throw schema issues`),e}if(e!==By&&e!==B)return e}return sb(ib((n??=t.makeEffect)(r,a),r),`Constructor adapter can only throw schema issues`)}}var lb=e=>Ky(e).parser,ub=e=>Ky(e).makeEffect,db=`~effect/Schema/Schema`,fb=Symbol(),pb={[db]:db,get make(){let e=Yy(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=qy(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=Jy(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return y(this,arguments)},annotate(e){return this.rebuild(Lv(this.ast,e))},annotateKey(e){return this.rebuild(qv(this.ast,e))},check(...e){return this.rebuild(zv(this.ast,e))},rebuild(e){return mb(e,this[fb])}};function mb(e,t){function n(){}let r=Object.setPrototypeOf(n,pb);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[fb]=t,r.ast=e,r}function hb(e){return mb(gb(e.ast),{schema:e})}var gb=Wv(e=>{let t=xb(e,gb),n=e.context;return t===e||n===void 0?t:Uv(t,_b(n))});function _b(e){return e.constructorDefault===void 0?e:new x_(e.isOptional,e.isMutable,void 0,e.annotations)}function vb(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function yb(e){return t=>{let n=[...t].sort((t,n)=>e(oy(t))-e(oy(n)));return n.some((e,n)=>e!==t[n])?n:t}}var bb=yb(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function xb(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!Gn(n))return W(e,[Oy]);let r=n(e.typeParameters.map(e=>mb(oy(e))));return r===void 0?e:W(e,[Bv(r,t)])}case`Unknown`:return W(e,[Oy]);case`ObjectKeyword`:return W(e,[ky]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return vb(e),e.recur(t,py);case`Union`:{let n=bb(e.types);return n===e.types?e.recur(t):new gv(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 Sb(e){return mb(Ob(e.ast),{schema:e})}var Cb=yb(e=>{switch(e._tag){case`Null`:case`Boolean`:case`Number`:case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function wb(e,t,n){switch(e._tag){case`Declaration`:{let r=e.typeParameters.map(e=>mb(t(oy(e)))),i=e.annotations?.toCodecStringTree;if(Gn(i)){let n=i(r);return n===void 0?e:W(e,[Bv(n,t)])}let a=e.annotations?.toCodecJson,o=Gn(a)?a(r):void 0,s=o===void 0?e.annotations?.toCodec:void 0,c=o??(Gn(s)?s(r):void 0);return c===void 0?n(e):W(e,[Bv(c,t)])}case`Null`:return W(e,[Tb]);case`Boolean`:return W(e,[Eb]);case`Unknown`:case`ObjectKeyword`:return W(e,[jy]);case`Enum`:case`Number`:case`Literal`:case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return vb(e),e.recur(t,py);case`Union`:{let n=Cb(e.types);return n===e.types?e.recur(t):new gv(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 Tb=new U(new M_(`null`),new Gg(H(()=>null),H(()=>`null`))),Eb=new U(new gv([new M_(`true`),new M_(`false`)]),new Gg(H(e=>e===`true`),Lg())),Db=new Gg(H(e=>typeof e==`string`?[e]:e),Pg()),Ob=Wv(e=>{let t=wb(e,Ob,e=>{throw new globalThis.Error(`Missing structural codec for StringTree`,{cause:e})});return t!==e&&e.context!==void 0?Uv(t,_b(e.context)):t},{stopAt:e=>e.transformation===Db}),kb=b(2,(e,t)=>({...e,...t})),Ab=e=>e,jb=`~effect/Schema/SchemaError`;function Mb(e){return S(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}var Nb=db;function Pb(){return(e,t,n)=>G(new w_(e.map(av),e=>t(e.map(e=>G(e))),n))}function Fb(e,t){return Pb()([],()=>(t,n,r)=>e(t)?L(t):R(new og(n,t,r)),t)}var Ib=class extends Us(`SchemaError`){[jb]=jb;constructor(e){let t=ei();ti(0);try{super({issue:e})}finally{ti(t)}}get message(){return wg(this.issue)}toString(){return`SchemaError(${this.message})`}};function Lb(e){return Mb(e)}function Rb(e){return I(e)?zb(e):Rp(e,e=>Ep(()=>Yd(e,e=>new Ib(e))))}function zb(e){return sf(e)?e:rf(Yd(e.cause,e=>new Ib(e)))}function Bb(e,t){let n;for(let r of e.reasons){if(!Hd(r)||!Lb(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 Vb(e){let t=im(e);if(sf(t))return t.value;throw Bb(t.cause,`Sync adapter can only throw schema errors`)}var Hb=Xy;function Ub(e,t){let n=$y(e,t);return(e,t)=>Rb(n(e,t))}var Wb=Ub;function Gb(e,t){let n=Ub(e,t);return(e,t)=>Vb(n(e,t))}function Kb(e,t){let n=eb(e,t);return(e,t)=>Rb(n(e,t))}var G=mb;function qb(e){return S(e,Nb)&&e[Nb]===Nb}var Jb=Ab(e=>G(Jv(e.ast),{schema:e})),Yb=Ab(e=>{let t=hx(e);return G(Xv(e.ast),{schema:t})}),Xb=Ab(e=>G(ay(e.ast),{schema:e}));function Zb(e){let t=G(new M_(e),{literal:e,transform(n){return t.pipe(Y(Zb(n),{decode:H(()=>n),encode:H(()=>e)}))}});return t}var Qb=G(A_),$b=G(j_),ex=G(T_),tx=G(O_),K=G(P_),nx=G(L_),rx=G(R_),ix=G(k_);function ax(e,t){return G(e,{fields:t,mapFields(e,t){let n=e(this.fields);return ax(iv(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function q(e){return ax(iv(e,void 0),e)}function ox(e){return Ab(t=>t.mapFields(kb(e)))}function sx(e,t){return G(ey(e.ast,t.ast),{key:e,value:t})}function cx(e,t){return G(e,{elements:t,mapElements(e,t){let n=e(this.elements);return cx(ov(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function lx(e){return cx(ov(e),e)}var J=Ab(e=>G(new z_(!1,[],[e.ast]),{value:e})),ux=Ab(e=>G(new z_(!1,[e.ast],[e.ast]),{value:e}));function dx(e,t){return G(e,{members:t,mapMembers(e,t){let n=e(this.members);return dx(sv(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function fx(e,t){return dx(sv(e,t,void 0),e)}function px(e){let t=e.map(Zb);return G(sv(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return fx(e(this.members))},pick(e){return px(e)},transform(e){return fx(t.map((t,n)=>t.transform(e[n])))}})}var mx=Ab(e=>fx([e,ex])),hx=Ab(e=>fx([e,tx]));function Y(e,t){return n=>G(Qv(n.ast,e.ast,t?qg(t):Zg()),{from:n,to:e})}function gx(){return(e,t)=>xx()(e,{decode:t,encode:Mg})}function _x(e){return t=>G(Zv(t.ast,e),{schema:t})}function vx(e){return Zb(e).pipe(_x(L(e)))}function yx(e,t){return q({_tag:vx(e),...t})}function bx(e,t){return Fb(t=>t instanceof e,t)}function xx(){return(e,t)=>new U(e.ast,qg(t))}var Sx=Dv;function Cx(e,t){let n=e.source,r=e.flags,i=/^[dg]*uy?$/.test(r),a=r===``?`new RegExp(${T(n)})`:`new RegExp(${T(n)}, ${T(r)})`;return jv(e,{toJsonSchema:()=>i?{pattern:r.endsWith(`y`)?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}var wx=G(kv);function Tx(e){let t=Ia(e.order),n=Pa(e.order),r=Fa(e.order),i=Na(e.order),a=e.formatter??T;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return Sx(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 Ex(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${T(e)}`);return e}var Dx=Tx({order:ja,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:Ex(e.minimum),maximum:Ex(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${T(e.minimum)}, maximum: ${T(e.maximum)}, exclusiveMinimum: ${T(t)}, exclusiveMaximum: ${T(n)} })`})}}});function Ox(e){return Sx(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 kx=nx.check(Ox());function Ax(e,t){return e=Nx(e),jx(e,Math.ceil(e/2),t)}function jx(e,t,n){return Sx(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})`}),[Hh]:!0,arbitraryConstraint:{minLength:e},...n})}function Mx(e,t){return e=Nx(e),Sx(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})`}),[Hh]:!0,arbitraryConstraint:{maxLength:e},...t})}function Nx(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}function Px(e,t){return e=Nx(e),Sx(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})`}),[Hh]:!0,arbitraryConstraint:{minProperties:e},...t})}function Fx(e){return Sx(e=>Zo(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 Ix=e=>+(e?.includeStack===!0)|(e?.excludeCause===!0?2:0),Lx=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},Rx=[];function zx(e){let t=Ix(e),n=Rx[t];if(n!==void 0)return n;let r=fS.pipe(Y($b,a_(Lx(t))));return Rx[t]=r,r}globalThis.RegExp,globalThis.URL;var Bx=K.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`});function Vx(e,t){return Bx.pipe(Y(e,s_(t)))}var Hx=Vx($b);globalThis.File,globalThis.FormData,globalThis.URLSearchParams;var Ux=K.annotate({expected:`a base64 encoded string that will be decoded as Uint8Array`,format:`byte`,contentEncoding:`base64`}),Wx=bx(globalThis.Uint8Array,{representation:{id:`effect/schema/Uint8Array`,payload:null},toCode:()=>({runtime:`Schema.Uint8Array`,Type:`globalThis.Uint8Array`}),expected:`Uint8Array`,toCodecJson:()=>xx()(Ux,o_)});function Gx(e,t){return G(Pb()([e,t],([e,t])=>(n,r,i)=>{if(!Vd(n))return R(new og(r,n,i));switch(n._tag){case`Fail`:return cm($y(e)(n.error,i),{onSuccess:Kd,onFailure:e=>cg(r,`error`,e,n,i)});case`Die`:return cm($y(t)(n.defect,i),{onSuccess:qd,onFailure:e=>cg(r,`defect`,e,n,i)});case`Interrupt`:return L(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])=>xx()(fx([q({_tag:Zb(`Fail`),error:e}),q({_tag:Zb(`Die`),defect:t}),q({_tag:Zb(`Interrupt`),fiberId:hx(wx)})]),Yg({decode:e=>{switch(e._tag){case`Fail`:return Kd(e.error);case`Die`:return qd(e.defect);case`Interrupt`:return Jd(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 Kx(e,t){return G(Pb()([e,t],([e,t])=>{let n=J(Gx(e,t));return(e,t,r)=>Bd(e)?cm($y(n)(e.reasons,r),{onSuccess:Ud,onFailure:n=>cg(t,`failures`,n,e,r)}):R(new og(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])=>xx()(J(Gx(e,t)),Yg({decode:Ud,encode:({reasons:e})=>e}))}).ast,{error:e,defect:t})}var qx=Jg({decode:(e,t)=>Va(zm(e),{onNone:()=>R(new sg({expected:`a valid UTC DateTime string`},e,t)),onSome:e=>L(Bm(e))}),encode:e=>L(Hm(e))}),Jx=-864e13,Yx=864e13;function Xx(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 Zx(e,t){return kx.check(Dx({minimum:e,maximum:t}))}var Qx=Fb(e=>Fm(e)&&Im(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]=Xx(e,Jx,Yx);return gx()(Zx(t,n),H(Rm))},toCodecJson:()=>xx()(K,qx),toFormatter:()=>e=>e.toString()}),$x=K.annotate({expected:`a string that will be decoded as a DateTime.Utc`}).pipe(Y(Qx,qx)),eS=Fb(Dh,{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:()=>Mh,toCodec:()=>xx()(J(lx([K,K])),Yg({decode:kh,encode:e=>e.params}))}).pipe(Y(sx(K,fx([K,ux(K)])),Yg({decode:zh,encode:Ah}))),tS=globalThis.Symbol.for(`immer-draftable`),nS={};function rS(e,t,n,r,i){let a=oS(n,t,r),o=aS(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===nS?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:nS,value:i}})}static[Nb]=Nb;get[o](){return o}static[tS]=!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 Yy(a(this))(e??{},t)}static makeOption(e,t){return Jy(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(Lv(this.ast,e))}static annotateKey(e){return this.rebuild(qv(this.ast,e))}static check(...e){return this.rebuild(zv(this.ast,e))}static extend(e){return(t,r)=>{let a=sS(t)?t:q(t),o={...n.fields,...a.fields},s=iv(o,n.ast.checks,{identifier:e});return rS(this,e,ax(zv(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 iS(e){return new Gg(H(t=>new e(t,{"~payload":{token:nS,value:t}})),Pg())}function aS(e){return`~effect/Schema/Class/${e}`}function oS(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=aS(t),o=e=>e instanceof i||S(e,a),s=iS(i);return r=Y(G(new w_([e.ast],()=>(e,t,n)=>o(e)?L(e):R(new og(t,e,n)),{identifier:t,[Wh]:([e])=>({isConstructed:o,link:new U(e,s)}),toCodec:([e])=>new U(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[Uh]:uv(e.ast),...n})),s)(e)}}function sS(e){return qb(e)}var cS=e=>(t,n)=>rS(qi,e,sS(t)?t:q(t),n,e=>({name:e})),lS=e=>(t,n,r)=>{let i=sS(n)?n.mapFields(e=>({_tag:vx(t),...e}),{unsafePreserveChecks:!0}):yx(t,n);return cS(e??t)(i,r)},uS=hb,dS=Sb,fS=G(Lv(Dy,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),pS=zc,mS=hd,hS=`~effect/MutableRef`,gS={[hS]:hS,...pi,toJSON(){return{_id:`MutableRef`,current:Xr(this.current)}}},_S=e=>{let t=Object.create(gS);return t.current=e,t},vS={"~effect/Channel":{_Env:x,_InErr:x,_InElem:x,_OutErr:x,_OutElem:x},pipe(){return y(this,arguments)}},yS=e=>{let t=Object.create(vS);return t.transform=(t,n)=>Rp(e(t,n),e=>L(Tp(e))),t},bS=(e,t)=>yS((n,r)=>z(CS(e)(n,r),e=>t(e,r))),xS=e=>yS((t,n)=>e),SS=e=>yS(am(function*(t,n){let r=yf(n),i=e=>bf(r,mp(e));return qp(yield*qp(e(t,n,r),i),i)})),CS=e=>e.transform,wS=e=>yS((t,n)=>xp(()=>CS(e())(t,n))),TS=e=>xS(L(R(e))),ES=e=>yS((t,n)=>DS({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),DS=e=>{let t=e.readable.getReader(),n=e.exit??_S(void 0),r=xp(()=>n.current?n.current:Bp(bp({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??Tp(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?ef():L(Jo(t))}));return Fp(vf(e.scope,e.releaseLockOnEnd?Sp(()=>t.releaseLock()):yp(()=>t.cancel().catch(Mn))),r)},OS=b(2,(e,t)=>bS(e,e=>Sp(()=>{let n=0;return Pp(e,e=>t(e,n++))}))),kS=b(2,(e,t)=>yS((n,r)=>z(CS(e)(n,r),e=>CS(t)(e,r)))),AS=b(2,(e,t)=>SS((n,r,i)=>_f(i,t).pipe(jp(CS(e)(n,r))))),jS=b(2,(e,t)=>AS(e,e=>t)),MS=(e,t,n)=>xp(()=>{let r=hf();return up(z(CS(e)(ef(),r),t),n||L).pipe(Jp(e=>bf(r,e)))}),NS=b(2,(e,t)=>yS((n,r)=>Pp(Wp(CS(e)(n,r),t),Wp(t)))),PS=b(2,(e,t)=>MS(e,e=>Qp(z(e,t),{disableYield:!0}))),FS=(e,t)=>CS(e)(ef(),t),IS=(e,t)=>()=>{let n=Wb(ux(e),t);return yS((e,t)=>L(z(e,e=>n(e))))},LS=`~effect/Stream`,RS={_R:x,_E:x,_A:x},zS=function(e){this.channel=e};zS.prototype={[LS]:RS,pipe(){return y(this,arguments)}};var BS=e=>new zS(e),VS=`~effect/Stream`,HS=e=>S(e,VS),US=BS,WS=(e,t)=>US(yS((n,r)=>z(FS(e.channel,r),e=>t(e,r)))),GS=e=>US(wS(()=>e().channel)),KS=e=>US(TS(e)),qS=e=>US(ES(e)),JS=b(2,(e,t)=>GS(()=>{let n=0;return US(OS(e.channel,Yo(e=>t(e,n++))))})),YS=b(2,(e,t)=>US(kS(e.channel,t))),XS=b(e=>HS(e[0]),(e,t)=>GS(()=>{let n=new TextDecoder(t?.encoding);return JS(e,e=>n.decode(e,{stream:!0}))})),ZS=b(2,(e,t)=>US(jS(e.channel,t))),QS=b(2,(e,t)=>US(NS(e.channel,t))),$S=b(2,(e,t)=>PS(e.channel,t)),eC=b(e=>HS(e[0]),(e,t,n)=>{let r,i,a=mS(!1);return new ReadableStream({start(n){i=tm(Wp($S(e,e=>a.whenOpen(Sp(()=>{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 nm(Ip(pS(i)))}},n?.strategy)}),tC=b(e=>HS(e[0]),(e,t)=>Pp(Vp(),n=>eC(e,n,t))),nC=b(2,(e,t)=>e===void 0?void 0:t(e)),rC=e=>K.pipe(_x(L(e))),iC={InvalidInput:400,Unauthenticated:401,Forbidden:403},aC=q({path:J(fx([K,wx])),message:K}),oC=_g(),sC=class e extends lS()(`InvalidInput`,{message:rC(`The input does not match the action's input.`),issues:J(aC).pipe(_x(L([])))},{httpApiStatus:iC.InvalidInput}){static fromSchemaError=({issue:t,message:n})=>new e({message:n,issues:oC(t).issues.map(e=>({path:(e.path??[]).map(e=>{let t=Wn(e)?e:e.key;return Un(t)?String(t):t}),message:e.message}))})},cC=class extends lS()(`Unauthenticated`,{message:rC(`Authentication is required.`)},{httpApiStatus:iC.Unauthenticated}){},lC=K.check(Cx(/^[\x21\x23-\x5B\x5D-\x7E]+$/)),uC=[cC,class extends lS()(`Forbidden`,{message:rC(`Not allowed.`),scopes:Jb(ux(lC))},{httpApiStatus:iC.Forbidden}){}];fx(uC);var dC=[sC,...uC],fC=fx(dC),pC=e=>e===void 0?[]:qb(e)?[e]:e,mC=(e,t=[])=>[...new Set([...dC,...e.error,...t])],hC=Symbol.for(`@gjermundgaraba/effect-actions/Anyone`),gC=/^[A-Za-z0-9_-]{1,128}$/,_C=(e,t)=>{if(!gC.test(t)||t===`then`)throw Error(`Invalid ${e}: ${t}`)},vC=(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)}},yC=(e,t)=>vC(e,t,e=>e.name),bC=e=>y_(e)?bC(e.thunk()):e,xC=e=>{let t=bC(e);return v_(t)?t.types.flatMap(xC):[t]},SC=e=>p_(e)?[e.literal]:h_(e)?e.enums.map(([,e])=>e):[void 0],CC=e=>xC(oy(e)).flatMap(e=>{let t=__(e)?e.propertySignatures.find(e=>e.name===`_tag`)?.type:void 0;return t===void 0?[]:xC(t).flatMap(SC).filter(Bn)}),wC=(e,t)=>{let n=t.flatMap(e=>CC(e.ast)).find(e=>Object.hasOwn(iC,e));if(n!==void 0)throw Error(`${e}: error _tag "${n}" is built in, and declared on every surface`)},TC=(e,t)=>t.length===0?Ub(uS(e.input))({}):L(t[0]),EC=sx(K,Qb),DC=e=>qb(e)?e:Reflect.ownKeys(e).length===0?EC:q(e);function X(e,t){_C(`action name`,e);let{caller:n,readOnly:r}=t;if(n!==hC&&!lo(n))throw Error(`Missing caller: declare Action.Anyone or an identity service key`);if(n!==hC&&uo(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:DC(t.input??{}),success:t.success===void 0?ix:DC(t.success),error:pC(t.error),readOnly:r,mcp:{...t.mcp}};return wC(`Action "${i.name}"`,i.error),i}var OC=(e,t)=>{for(let n of e)if(n.caller!==hC&&(t===void 0||n.caller.key!==t.identity.key))throw Error(`Protected action '${n.name}' requires its matching authentication descriptor`)},kC=`~effect/http/HttpBody`,AC=e=>S(e,kC),jC=class{[kC];constructor(){this[kC]=kC}[Yr](){return this.toJSON()}toString(){return T(this,{ignoreToString:!0})}},MC=new class extends jC{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},NC=class extends jC{_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??=LC(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}}},PC=(e,t)=>new NC(e,t??`application/octet-stream`,e.length),FC=new TextEncoder,IC=globalThis.Buffer,LC=IC===void 0?e=>FC.encode(e):e=>IC.from(e,`utf8`),RC=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),IC!==void 0)return new NC(void 0,t??`text/plain`,IC.byteLength(e,`utf8`),e);let n=FC.encode(e);return new NC(n,t??`text/plain`,n.length,e)},zC=(e,t)=>RC(Rh(Ah(e)),t??`application/x-www-form-urlencoded`),BC=class extends jC{_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}}},VC=e=>new BC(e),HC=`~effect/http/HttpClientError`,UC=class extends Us(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[HC]=HC;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},WC=e=>e.endsWith(`Error`)?e.slice(0,-5):e,GC=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,KC=class extends Us(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return GC(WC(this._tag),this.description,this.methodAndUrl)}},qC=class extends Us(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return GC(WC(this._tag),this.description,this.methodAndUrl)}},JC=class extends Us(`StatusCodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return GC(WC(this._tag),this.description,e)}},YC=class extends Us(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return GC(WC(this._tag),this.description,e)}},XC=class extends Us(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return GC(WC(this._tag),this.description,e)}},ZC=e=>e!==`GET`&&e!==`HEAD`&&e!==`OPTIONS`&&e!==`TRACE`,QC=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],$C=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?Sh(Sh(e,`content-type`),`content-length`):(e=t.contentType===void 0?Sh(e,`content-type`):yh(e,`content-type`,t.contentType),t.contentLength===void 0?Sh(e,`content-length`):yh(e,`content-length`,t.contentLength.toString())),ew=class extends Us(`UrlError`){},tw=(e,t,n)=>ko({try:()=>{let r=new URL(e,nw());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 ew({cause:e})}),nw=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},rw=`~effect/http/HttpClientRequest`,iw={[rw]:rw,...Zr,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Fr(this.headers),body:this.body.toJSON()}},pipe(){return y(this,arguments)}};function aw(e,t,n,r,i,a){let o=Object.create(iw);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var ow=aw(`GET`,``,Ph,La(),gh,MC),sw=e=>(t,n)=>cw(ow,{method:e,url:t,...n??void 0}),cw=b(2,(e,t)=>{let n=e;return t.method&&(n=lw(n,t.method)),t.url&&(n=mw(n,t.url)),t.headers&&(n=dw(n,t.headers)),t.urlParams&&(n=_w(n,t.urlParams)),t.hash&&(n=yw(n,t.hash)),t.body&&(n=bw(n,t.body)),t.accept&&(n=fw(n,t.accept)),t.acceptJson&&(n=pw(n)),n}),lw=b(2,(e,t)=>aw(t,e.url,e.urlParams,e.hash,e.headers,e.body)),uw=b(3,(e,t,n)=>aw(e.method,e.url,e.urlParams,e.hash,yh(e.headers,t,n),e.body)),dw=b(2,(e,t)=>aw(e.method,e.url,e.urlParams,e.hash,bh(e.headers,t),e.body)),fw=b(2,(e,t)=>uw(e,`Accept`,t)),pw=fw(`application/json`),mw=b(2,(e,t)=>{if(typeof t==`string`)return aw(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Ah(n.searchParams),i=Ua(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,aw(e.method,n.toString(),r,i,e.headers,e.body)}),hw=b(2,(e,t)=>t===``?e:aw(e.method,gw(t,e.url),e.urlParams,e.hash,e.headers,e.body)),gw=(e,t)=>{let n=e.endsWith(`/`),r=t.startsWith(`/`);return n&&r?e+t.slice(1):!n&&!r?e+`/`+t:e+t},_w=b(2,(e,t)=>aw(e.method,e.url,Ih(e.urlParams,t),e.hash,e.headers,e.body)),vw=b(2,(e,t)=>aw(e.method,e.url,Lh(e.urlParams,t),e.hash,e.headers,e.body)),yw=b(2,(e,t)=>aw(e.method,e.url,e.urlParams,Ra(t),e.headers,e.body)),bw=b(2,(e,t)=>aw(e.method,e.url,e.urlParams,e.hash,$C(e.headers,t),t)),xw=b(2,(e,t)=>bw(e,VC(t)));function Sw(e){let t=tw(e.url,e.urlParams,Wa(e.hash));return jo(t)?Ra(t.success):La()}var Cw=`~effect/http/HttpIncomingMessage`,ww=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=rm(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=rm(e.text)}catch{}let i={...t,headers:Fr(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},Tw=`~effect/http/HttpClientResponse`,Ew=(e,t)=>new Dw(e,t),Dw=class extends Qr{[Cw];[Tw];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[Cw]=Cw,this[Tw]=Tw}toJSON(){return ww(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=Sw(this.request);return za(e)?``:(e.value.hash=``,e.value.href)}get headers(){return _h(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=nh(this.source.headers.getSetCookie?.()??[])}get remoteAddress(){return La()}get stream(){return this.source.body?qS({evaluate:()=>this.source.body,onError:e=>new UC({reason:new YC({request:this.request,response:this,cause:e})})}):KS(new UC({reason:new XC({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return z(this.text,e=>Op({try:()=>e===``?null:JSON.parse(e),catch:e=>new UC({reason:new YC({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=Pp(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return z(this.text,e=>Op({try:()=>Ah(new URLSearchParams(e)),catch:e=>new UC({reason:new YC({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=bp({try:()=>this.source.formData(),catch:e=>new UC({reason:new YC({request:this.request,response:this,cause:e})})}).pipe(Yp,rm)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=bp({try:()=>this.source.arrayBuffer(),catch:e=>new UC({reason:new YC({request:this.request,response:this,cause:e})})}).pipe(Yp,rm),this.arrayBufferBody}pipe(){return y(this,arguments)}},Ow=e=>vh({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${Va(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),kw={"http:":80,"https:":443,"ws:":80,"wss:":443},Aw=(e,t)=>{let n=t.search.slice(1);if(e.attribute(`url.full`,t.toString()),e.attribute(`url.path`,t.pathname),n!==``&&e.attribute(`url.query`,n),e.attribute(`url.scheme`,t.protocol.slice(0,-1)),t.hostname!==``){e.attribute(`server.address`,t.hostname.startsWith(`[`)?t.hostname.slice(1,-1):t.hostname);let n=t.port===``?kw[t.protocol]:Number(t.port);n!==void 0&&e.attribute(`server.port`,n)}},jw=(e,t,n,r,i)=>{for(let a in n)r(a,t)&&e.attribute(`http.${t}.header.${a}`,wh(a,i)?`<redacted>`:n[a])},Mw=`~effect/http/HttpClient`,Nw=A(`effect/HttpClient`),Pw=b(2,(e,t)=>Fw(n=>t(e.postprocess(n)),e.preprocess)),Fw=(e,t)=>{let n=Object.create(Iw);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},Iw={[Mw]:Mw,pipe(){return y(this,arguments)},...Zr,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(QC.map(([e,t])=>[t,function(t,n){return this.execute(sw(e)(t,n))}]))},Lw=e=>Fw(t=>z(t,t=>kp(n=>{let r=Kw.get(t),i=r??new AbortController,a=tw(t.url,t.urlParams,Wa(t.hash));if(Ao(a))return R(new UC({reason:new qC({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(ec)||n.getRef(Bw)(t)){let a=e(t,o,i.signal,n);return r?a:Zp(e=>Bp(e(a),{onSuccess(e){return Gw.register(e,i),L(new qw(e,i))},onFailure(e){return Qd(e)&&i.abort(),Tp(e)}}))}return $p(n.getRef(Uw)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method);let s=n.getRef(Th);Aw(a,o);let c=n.getRef(Vw);return jw(a,`request`,t.headers,c,s),t=n.getRef(Hw)?dw(t,Ow(a)):t,Zp(l=>l(e(t,o,i.signal,n)).pipe(em(a,{captureStackTrace:!1}),Bp({onSuccess:e=>(a.attribute(`http.response.status_code`,e.status),jw(a,`response`,e.headers,c,s),e.status>=400&&e.status<600&&(a.attribute(`error.type`,String(e.status)),Rw(n,a,t,e)),r?L(e):(Gw.register(e,i),L(new qw(e,i)))),onFailure(e){return!r&&Qd(e)&&i.abort(),Tp(e)}})))})})),L),Rw=(e,t,n,r)=>{let i=ei();ti(0);let a;try{a=af(new UC({reason:new JC({request:n,response:r})}))}finally{ti(i)}t.end(e.getRef(pf)?e.getRef(Gf).currentTimeNanosUnsafe():BigInt(0),a)},zw=b(2,(e,t)=>Fw(e.postprocess,n=>Pp(e.preprocess(n),t))),Bw=j(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>An}),Vw=j(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>An}),Hw=j(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:kn}),Uw=j(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>e.method}),Ww=e=>If(Nw)(Hp(t=>Pp(e,e=>Pw(e,Gp(e=>wo(t,e)))))),Gw=(()=>{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 WeakMap;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,qw=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[Tw]=Tw;[Cw]=Cw;applyInterrupt(e){return xp(()=>(Gw.unregister(this.original),Xp(e,()=>Sp(()=>{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 GS(()=>(Gw.unregister(this.original),ZS(this.original.stream,Sp(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Yr](){return this.original[Yr]()}pipe(){return y(this,arguments)}},Jw=j(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),Yw=class extends A()(`effect/http/FetchHttpClient/RequestInit`){},Xw=Ww(L(Lw((e,t,n,r)=>{let i=r.getRef(Jw),a=_o(r.context,Yw)??{},o=a.headers?xh(_h(a.headers),e.headers):e.headers;o[`content-length`]&&(o=Sh(o,`content-length`));let s=r=>Pp(bp({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 UC({reason:new KC({request:e,cause:t})})}),t=>Ew(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 z(tC(e.body.stream),s)}return s(void 0)})));({...pi});var Zw=new Uint8Array(256);for(let e of"!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")Zw[e.charCodeAt(0)]=1;var Qw=new Uint8Array(256);Qw[9]=1;for(let e=32;e<=126;e++)Qw[e]=1;for(let e=128;e<=255;e++)Qw[e]=1;var $w=A(`effect/http/HttpServerRequest`),eT=new WeakSet,tT=e=>kp(t=>{let n=yo(t.context,$w);return eT.add(n.source),e}),nT=A(`effect/http/HttpRouter`),rT=e=>e.endsWith(`/`)?e.slice(0,-1):e,iT=b(2,(e,t)=>(t=rT(t),e===`*`?`${t}/*`:e===`/`?t:t+e)),aT=`~effect/http/HttpRouter/Middleware`,oT=function(){return arguments.length===0?sT:sT(arguments[0],arguments[1])},sT=(e,t)=>t?.global?zf(wp(function*(){let t=yield*nT,n=_p(e)?yield*e:e;yield*t.addGlobalMiddleware(n)})):new uT(_p(e)?Rf(Pp(e,e=>ao(new Map([[lT,e]])))):Ff(ao(new Map([[lT,e]])))),cT=0,lT=`effect/http/HttpRouter/MiddlewareFn`,uT=class e{[aT]={};layerFn;dependencies;constructor(e,t){this.layerFn=e,this.dependencies=t;let n=`effect/http/HttpRouter/Middleware-${++cT}`;this.layer=Rf(wp({self:this},function*(){let e=yield*Vp(),t=[vo(e,lT)];if(this.dependencies){let n=yield*Mf,r=bo(e,mf),i=yield*Nf(this.dependencies,n,r);t.push(...fT(i))}return ao(new Map([[n,t]]))})).pipe(Uf(this.layerFn))}layer;combine(t){return new e(this.layerFn,this.dependencies?Wf(this.dependencies,t.layer):t.layer)}},dT=new WeakMap,fT=e=>{let t=dT.get(e);if(t)return t;let n=qo(),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=Bo(e).reverse()}return dT.set(e,t),t};oT(tT).layer;var pT={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},mT=e=>pT[e],hT=`~effect/encoding/Sse/SseError`,gT=class extends Us(`EventTooLarge`){get message(){return`Pending SSE event exceeded the maximum size of ${this.maxEventSize}`}},_T=class extends Us(`SseError`){[hT]=hT;get message(){return this.reason.message}},vT=10485760,yT=e=>yS((t,n)=>Sp(()=>{let n=[],r,i=xT(e=>{e._tag===`Retry`?r=e:n.push(e)},e),a=z(t,e=>{for(let t=0;t<e.length;t++){let n=i.feed(e[t]);if(n!==void 0)return R(n)}return Cp});return xp(function e(){if(Wo(n)){let e=n;return n=[],L(e)}return r?R(r):z(a,e)})})),bT=(e,t,n)=>kS(yT(t),IS(CT.pipe(Y(e,wT)),n)());function xT(e,t){let n=t?.maxEventSize??vT,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(ST)&&(i=i.slice(ST.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 _T({reason:new gT({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 ET({duration:bs(parseInt(p,10)),lastEventId:c}))}}var ST=``,CT=q({_tag:vx(`Event`),id:hx(K),event:K,data:K}),wT=Yg({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})}),TT=`~effect/encoding/Sse/Retry`,ET=class e extends Hs(`Retry`){[TT]=TT;static is(e){return S(e,TT)}static filter(t){return e.is(t)?Do(t):Oo(t)}},DT=`~effect/http-api/HttpApiSchema/Stream`;function OT(e){let t=typeof e==`string`?mT(e):e;return e=>e.annotate({httpApiStatus:t})}var kT=(e=>ix.pipe(OT(e)))(204),AT=e=>qb(e)&&S(e,DT),jT=e=>AT(e)&&e._tag===`StreamSse`,MT=e=>AT(e)&&e._tag===`StreamUint8Array`,NT=`~effect/http-api/HttpApiSchema/WithHeaders`,PT=`~effect/http-api/HttpApiSchema/WithHeadersValue`,FT=e=>({[PT]:PT,body:e.body,headers:e.headers}),IT=e=>qb(e)&&S(e,`~effect/http-api/HttpApiSchema/WithHeaders`);function LT(e,t,n){return G(e.ast,{[NT]:NT,schema:t,headers:n})}function RT(e,t){return e.annotate({"~httpApiEncoding":{_tag:t._tag,contentType:t.contentType??zT(t._tag)}})}function zT(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 BT(e){return t=>RT(t,{_tag:`Json`,...e})}function VT(e){return t=>RT(t,{_tag:`FormUrlEncoded`,...e})}var HT=e=>{if(d_(e)||d_(oy(e)))return!0;let t=e.encoding?.[0].to;return t!==void 0&&d_(t)},UT=Sy(`~httpApiEncoding`),WT=Sy(`~httpApiWithHeaders`),GT=Sy(`httpApiStatus`),KT={_tag:`Json`,contentType:`application/json`},qT={_tag:`FormUrlEncoded`,contentType:`application/x-www-form-urlencoded`};function JT(e){return UT(e)??KT}function YT(e,t){return UT(e)||(ZC(t)?KT:qT)}function XT(e){let t=JT(e);if(t._tag===`Multipart`)throw Error(`Multipart is not supported in response`);return t}function ZT(e){return GT(e)??200}function QT(e){return IT(e)?GT(e.ast)??ZT(e.schema.ast):ZT(e.ast)}function $T(e){return IT(e)&&UT(e.ast)===void 0?XT(e.schema.ast):XT(e.ast)}function eE(e){return GT(e)??500}function tE(e){return IT(e)?GT(e.ast)??eE(e.schema.ast):eE(e.ast)}function nE(e){let t=e.toLowerCase().trim(),n=t.indexOf(`;`);return n===-1?t:t.slice(0,n).trim()}var rE=`~effect/http-api/HttpApiEndpoint`;function iE(e){let t=[];for(let{schemas:n}of e.payload.values())t.push(...n);return t}function aE(e){let t=Array.from(e.success);return Wo(t)?t:[kT]}function oE(e){let t=new Set(e.error),n=e.disableCodecs?x:hE;for(let r of e.middlewares){let e=r;for(let r of e.error)t.add(n(r))}return Array.from(t)}var sE={[rE]:rE,pipe(){return y(this,arguments)},prefix(e){return lE({...cE(this),path:iT(this.path,e)})},middleware(e){return lE({...cE(this),middlewares:new Set([...this.middlewares,e])})},annotate(e,t){return lE({...cE(this),annotations:ho(this.annotations,e,t)})},annotateMerge(e){return lE({...cE(this),annotations:wo(this.annotations,e)})}},cE=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 lE(e){function t(){}return Object.setPrototypeOf(t,sE),Object.assign(t,e)}var uE=e=>(t,n,r)=>{let i=r?.disableCodecs??!1,a=i?x:dS;return lE({identifier:t,path:n,method:e,params:dE(r?.params,a),query:dE(r?.query,a),headers:dE(r?.headers,a),payload:fE(r?.payload,e,i),success:mE(r?.success,e,i),error:gE(r?.error,i),annotations:fo(),middlewares:new Set,disableCodecs:i})};function dE(e,t){if(e!==void 0)return qb(e)?t(e):t(q(e))}function fE(e,t,n){let r=new Map;if(e===void 0)return r;let i=Array.isArray(e)?e:qb(e)?[e]:[q(e).pipe(VT())],a=n?x:EE;for(let e of i){let n=YT(e.ast,t),i=nE(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 pE=`effect/http-api/stream/failure`;function mE(e,t,n){if(e===void 0)return new Set;let r=Vo(e);return _E(r,t),new Set(n?r:r.map(hE))}var hE=Nn(e=>AT(e)?e:IT(e)?LT(e,AT(e.schema)?e.schema:TE(e.schema,$T(e)),dS(e.headers)):wE(e));function gE(e,t){if(e===void 0)return new Set;let n=Vo(e);for(let e of n)if(AT(IT(e)?e.schema:e))throw Error(`Streaming schemas are not supported in error responses`);return yE(n,tE),new Set(t?n:n.map(hE))}function _E(e,t){let n=!1,r=new Map;for(let i of e){let e=IT(i)?i.schema:i,a=QT(i);if(AT(e)){if(bE(e,t),n)throw Error(`Multiple streaming success responses are not supported`);n=!0;let i=vE(r,a);if(i.noContent)throw Error(`Cannot combine no-content and streaming success responses for status: ${a}`);if(i.bufferedContentTypes.has(nE(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=vE(r,a),n=HT(e.ast);if(t.stream!==void 0){if(n)throw Error(`Cannot combine no-content and streaming success responses for status: ${a}`);let e=$T(i);if(nE(e.contentType)===nE(t.stream.contentType))throw Error(`Cannot combine buffered and streaming success responses for status ${a} and content-type: ${e.contentType}`)}n||t.bufferedContentTypes.add(nE($T(i).contentType)),t.noContent=t.noContent||n}}yE(e,QT)}function vE(e,t){let n=e.get(t);return n===void 0&&(n={bufferedContentTypes:new Set,noContent:!1},e.set(t,n)),n}function yE(e,t){let n=new Map;for(let r of e){let e=t(r),i=WT(r.ast),a=IT(r)?r.schema:i?.body??r,o=HT(a.ast)?``:nE(AT(a)?a.contentType:$T(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(IT(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 bE(e,t){if(t===`HEAD`)throw Error(`HEAD endpoints cannot declare streaming success responses`);if(jT(e)&&xE(e.events.ast))throw Error(`SSE event name is reserved: ${pE}`)}function xE(e){return SE(oy(e),new Set)}function SE(e,t){if(t.has(e))return!1;if(t.add(e),v_(e))return e.types.some(e=>SE(e,t));if(y_(e))return SE(e.thunk(),t);if(!__(e))return!1;let n=e.propertySignatures.find(e=>e.name===`event`);return n!==void 0&&CE(n.type,t)}function CE(e,t){if(t.has(e))return!1;t.add(e);let n=oy(e);return n===e?p_(e)?e.literal===pE:v_(e)?e.types.some(e=>CE(e,t)):y_(e)?CE(e.thunk(),t):!1:CE(n,t)}function wE(e){let t=XT(e.ast),n=WT(e.ast);return n===void 0?TE(e,t):e.annotate({"~httpApiWithHeaders":{...n,bodyCodec:TE(n.body,t),headersCodec:dS(n.headers)}})}function TE(e,t){switch(t._tag){case`Json`:return uS(e);case`FormUrlEncoded`:return dS(e);case`Text`:case`Uint8Array`:return e}}function EE(e,t){switch(YT(e.ast,t)._tag){case`Json`:return uS(e);case`FormUrlEncoded`:return dS(e);case`Text`:case`Uint8Array`:case`Multipart`:return e}}var DE=uE(`POST`),OE=`~effect/http-api/HttpApi`,kE={[OE]:OE,pipe(){return y(this,arguments)},add(...e){let t={...this.groups};for(let n of e)ii(t,n.identifier,n);return jE({...AE(this),groups:t})},addHttpApi(e){let t={...this.groups};for(let n of Object.keys(e.groups)){let r=e.groups[n];ii(t,n,r.annotateMerge(wo(e.annotations,r.annotations)))}return jE({...AE(this),groups:t})},prefix(e){return jE({...AE(this),groups:Fo(this.groups,t=>t.prefix(e))})},middleware(e){return jE({...AE(this),groups:Fo(this.groups,t=>t.middleware(e))})},annotate(e,t){return jE({...AE(this),annotations:ho(this.annotations,e,t)})},annotateMerge(e){return jE({...AE(this),annotations:wo(this.annotations,e)})}},AE=e=>({identifier:e.identifier,groups:e.groups,annotations:e.annotations}),jE=e=>{function t(){}return Object.setPrototypeOf(t,kE),Object.assign(t,e)},ME=e=>jE({identifier:e,groups:{},annotations:fo()}),NE=(e,t)=>{let n=Object.values(e.groups);for(let r of n){let n=wo(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:wo(n,e.annotations),successes:PE(aE(e),QT),errors:PE(oE(e),tE)})}},PE=(e,t)=>{let n=new Map;return e.forEach(r),n;function r(e){if(AT(IT(e)?e.schema:e))return;let r=t(e),i=n.get(r);i===void 0?n.set(r,[e]):i.push(e)}},FE=class extends A()(`effect/http-api/HttpApi/ParseOptions`){},IE=class extends A()(`effect/http-api/HttpApi/ParamsParseOptions`){},LE=class extends A()(`effect/http-api/HttpApi/QueryParseOptions`){},RE=class extends A()(`effect/http-api/HttpApi/HeadersParseOptions`){},zE=class extends A()(`effect/http-api/HttpApi/PayloadParseOptions`){},BE=class extends A()(`effect/http-api/HttpApi/SuccessParseOptions`){},VE=class extends A()(`effect/http-api/HttpApi/ErrorParseOptions`){},HE=e=>{let t=_o(e,FE);return{params:_o(e,IE)??t,query:_o(e,LE)??t,headers:_o(e,RE)??t,payload:_o(e,zE)??t,success:_o(e,BE)??t,error:_o(e,VE)??t}},UE=`~effect/http-api/HttpApiMiddleware`,WE=`~effect/http-api/HttpApiMiddleware/Security`,GE=()=>(e,t)=>{let n=ei(),r;n!==0&&(ti(2),r=new globalThis.Error,ti(n));class i extends A()(e){}let a=i;if(Object.defineProperty(i,"stack",{get(){return r?.stack}}),a[UE]=UE,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[WE]=WE,a.security=t.security}return a};function KE(e){return e===void 0?new Set:new Set(Array.isArray(e)?e:[e])}var qE=new Set;function JE(e){if(e===void 0)return qE;let t=Iv(e.ast);return __(t)&&t.indexSignatures.length===0?new Set(t.propertySignatures.map(e=>String(e.name))):void 0}var YE=class extends A()(`effect/http-api/OpenApi/Description`){},XE=(e,t)=>wp(function*(){let n=yield*Vp(),r=t.httpClient.pipe(t?.baseUrl===void 0?x:zw(hw(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)}})}NE(e,{predicate:t?.predicate,onGroup(e){t.onGroup?.(e)},onEndpoint(e){let{group:n,endpoint:r,errors:a,successes:o,mergedAnnotations:s}=e,c=HE(s),l=eD(r.path,r.params),u={orElse:bD},d=new Map;for(let[e,t]of a.entries()){let n=oD(t);for(let[t,r]of n.entries())iD(d,e,t,tD(r,c.error,c.headers))}for(let[e,t]of d.entries()){let n=aD(t);u[e]=e=>z(Rp(n(e),t=>Tp(Xd(Wd(new UC({reason:new JC({request:e.request,response:e})})),t))),R)}let f=new Map;for(let[e,t]of o.entries()){let n=oD(t);for(let[t,r]of n.entries())iD(f,e,t,tD(r,c.success,c.headers))}for(let e of uD(r)){let t=lD(e)?e.schema:e;iD(f,QT(e),t.contentType,dD(e,c.success,c.headers))}for(let[e,t]of f.entries())u[e]=aD(t);let p=nC(r.params,e=>Kb(e,c.params)),m=iE(r),h=Wo(m)?Kb(ZC(r.method)?SD(m,r.method):fx(m),c.payload):void 0,ee=nC(r.headers,e=>Kb(e,c.headers)),te=nC(r.query,e=>Kb(e,c.query)),ne=Array.from(e.middleware,e=>`${e.key}/Client`),re=am(function*(e){let a=sw(r.method)(r.path);if(e!==void 0){if(p!==void 0){let t=yield*p(e.params);a=mw(a,l(t))}if(h!==void 0){if(ZC(r.method)){if(e.payload instanceof FormData)a=xw(a,e.payload);else{let t=yield*h(e.payload);a=bw(a,t)}}else{let t=yield*h(e.payload);a=vw(a,t)}}if(ee!==void 0){let t=yield*ee(e.headers);a=dw(a,t)}if(te!==void 0){let t=yield*te(e.query);a=vw(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})}})}),ZE=(e,t)=>z(Nw,n=>QE(e,{...t,httpClient:t?.transformClient?t.transformClient(n):n})),QE=(e,t)=>{let n={};return XE(e,{...t,onGroup({group:e}){e.topLevel||ii(n,e.identifier,{})},onEndpoint({endpoint:e,endpointFn:t,group:r}){ii(r.topLevel?n:n[r.identifier],e.identifier,t)}}).pipe(Fp(n))},$E=/(\/?):(\w+)(\?)?/g,eD=(e,t)=>{if(t===void 0||!e.includes(`:`))return t=>e;let n=JE(t);return t=>e.replace($E,(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 tD(e,t,n){let r=e.some(e=>IT(e)||WT(e.ast)!==void 0),i=Ub(r?fx(e.map(e=>rD(e,t,n))):vD(e),t);return e=>z(e.arrayBuffer,r?t=>i({body:t,headers:e.headers}):i)}var nD=q({body:$b,headers:$b});function rD(e,t,n){let r=WT(e.ast),i=r===void 0?IT(e)?{body:e.schema,headers:e.headers,toValue:FT}:{body:e,headers:$b,toValue:e=>e.body}:{body:r.bodyCodec,headers:r.headersCodec,toValue:r.transformation.decode},a=Ub(yD(i.body).pipe(Y(i.body)),t),o=Ub(i.headers,n);return nD.pipe(Y(IT(e)?e:Xb(e),Jg({decode:e=>vp({body:a(e.body),headers:o(e.headers)}).pipe(Pp(i.toValue),zp(e=>e.issue)),encode:(e,t)=>R(new lg({message:`Decode only schema`},e,t))})))}function iD(e,t,n,r){let i=nE(n),a=e.get(t);a===void 0?e.set(t,[{contentType:i,decode:r}]):a.push({contentType:i,decode:r})}function aD(e){let t=e[0];return e.length===1&&t!==void 0?t.decode:(t,n)=>{let r=nE(t.headers[`content-type`]??``),i=e.find(e=>e.contentType===r);return i===void 0?sD(t,r,e):i.decode(t,n)}}function oD(e){let t=new Map;for(let n of e){let e=HT((IT(n)?n.schema:n).ast)?``:nE($T(n).contentType),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return t}function sD(e,t,n){let r=Array.from(new Set(n.map(e=>e.contentType))).join(`, `);return R(new UC({reason:new YC({request:e.request,response:e,description:`Unsupported response content-type for status ${e.status}: ${t||`<missing>`}. Expected one of: ${r}`})}))}var cD=`effect/http-api/stream/failure`,lD=e=>IT(e);function uD(e){let t=[];for(let n of e.success)AT(IT(n)?n.schema:n)&&t.push(n);return t}function dD(e,t,n){let r=lD(e),i=r?e.schema:e,a=MT(i)?void 0:{declaration:i,decoder:fD(i,t)},o=(e,t)=>Pp(Vp(),n=>QS(a===void 0?e.stream:pD(e.stream,a.declaration,a.decoder(t)),n));if(!r)return o;let s=Ub(e.headers,n);return(e,t)=>z(s(e.headers),n=>Pp(o(e,t),e=>FT({body:e,headers:n})))}function fD(e,t){let n=fx([q({id:Yb(K),event:Zb(cD),data:Vx(uS(Kx(e.error,zx())))}),e.events]),r=bT(n,void 0,t);return e=>e===void 0?r:bT(n,e,t)}function pD(e,t,n){let r=WS(e.pipe(XS,YS(n)),e=>Sp(()=>{let t;return xp(()=>t===void 0?z(e,e=>{for(let n=0;n<e.length;n++){let r=e[n];if(r.event===cD&&Bd(r.data)){if(n===0)return Tp(r.data);t=r.data,e=e.slice(0,n);break}}return L(e)}):Tp(t))}));return t.sseMode===`data`?JS(r,e=>e.data):r}var mD=bx(globalThis.ArrayBuffer,{expected:`ArrayBuffer`}),hD=mD.pipe(Y(Wx,Yg({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)}}))),gD=mD.pipe(Y(K,Yg({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)}}))),_D=gD.pipe(Y(fx([Zb(``).pipe(Y(tx,Yg({decode:()=>void 0,encode:()=>``}))),Hx])));function vD(e){return fx(e.map(t));function t(e){return yD(e).pipe(Y(e))}}function yD(e){switch(XT(e.ast)._tag){case`Json`:return u_(oy(e.ast))?_D.pipe(Y($b,Yg({decode:e=>e===void 0?null:e,encode:e=>e===null?void 0:e}))):_D;case`FormUrlEncoded`:return gD.pipe(Y(eS,Yg({decode:e=>Ah(new URLSearchParams(e)),encode:Rh})));case`Uint8Array`:return hD;case`Text`:return gD}}var bD=e=>R(new UC({reason:new YC({request:e.request,response:e})})),xD=Fb(AC);function SD(e,t){return fx(e.map(e=>wD(e,t)))}var CD=new WeakMap;function wD(e,t){let n=e.ast,r=CD.get(n);if(r!==void 0)return r;let i=YT(n,t),a=xD.pipe(Y(e,Jg({decode(e,t){return R(new lg({message:`Encode only schema`},e,t))},encode(e,t){switch(i._tag){case`Multipart`:return R(new lg({message:`Payload must be a FormData`},e,t));case`Json`:try{return L(RC(JSON.stringify(e),i.contentType))}catch{return R(new sg({expected:`a JSON-serializable request body`},e,t))}case`Text`:return typeof e==`string`?L(RC(e,i.contentType)):R(new sg({message:`Expected a string`},e,t));case`FormUrlEncoded`:return Yn(e)?L(zC(Ah(e),i.contentType)):R(new sg({message:`Expected a record`},e,t));case`Uint8Array`:return e instanceof Uint8Array?L(PC(e,i.contentType)):R(new sg({message:`Expected a Uint8Array`},e,t))}}})));return CD.set(n,a),a}var TD=`~effect/http-api/HttpApiGroup`,ED={[TD]:TD,add(...e){let t={...this.endpoints};for(let n of e)ii(t,n.identifier,n);return OD({...DD(this),endpoints:t})},prefix(e){return OD({...DD(this),endpoints:Fo(this.endpoints,t=>t.prefix(e))})},middleware(e){return OD({...DD(this),endpoints:Fo(this.endpoints,t=>t.middleware(e))})},annotateMerge(e){return OD({...DD(this),annotations:wo(this.annotations,e)})},annotate(e,t){return OD({...DD(this),annotations:ho(this.annotations,e,t)})},annotateEndpointsMerge(e){return OD({...DD(this),endpoints:Fo(this.endpoints,t=>t.annotateMerge(e))})},annotateEndpoints(e,t){return OD({...DD(this),endpoints:Fo(this.endpoints,n=>n.annotate(e,t))})},pipe(){return y(this,arguments)}},DD=e=>({identifier:e.identifier,topLevel:e.topLevel,endpoints:e.endpoints,annotations:e.annotations}),OD=e=>{function t(){}return Object.setPrototypeOf(t,ED),t.key=`effect/http-api/HttpApiGroup/${e.identifier}`,Object.assign(t,e)},kD=(e,t)=>OD({identifier:e,topLevel:t?.topLevel??!1,endpoints:{},annotations:fo()}),AD=`~effect/http-api/HttpApiSecurity`,jD={[AD]:AD,pipe(){return y(this,arguments)}},MD=(e=>Object.assign(Object.create(jD),{_tag:`Http`,scheme:e.scheme,schemeLength:e.scheme.length,annotations:fo()}))({scheme:`Bearer`}),ND=e=>Object.assign(Object.create(jD),{_tag:`ApiKey`,key:e.key,in:e.in??`header`,annotations:fo()}),PD=Sy(`httpApiStatus`),FD=e=>PD(e)??(y_(e)?FD(e.thunk()):void 0),ID=e=>{let t=FD(e.ast);if(t!==void 0)return[PD(e.ast)===void 0?OT(t)(e):e];let n=bC(e.ast);return v_(n)&&n.checks===void 0&&n.encoding===void 0?n.types.flatMap(e=>ID(G(e))):[OT(422)(e)]},LD=(e,t={})=>Pp(ZE(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=Kb(uS(e.input),{errors:`all`});return(...t)=>TC(e,t).pipe(Mp(r),zp(sC.fromSchemaError),z(e=>n({payload:e})))}}),RD=e=>(e??`/api`).split(`/`).filter(e=>e!==``),zD=e=>`/${e.join(`/`)}`,BD=e=>e.join(`/`)||`/`,VD=(e,t)=>{let n=kD(e,{topLevel:!0}),[r,...i]=t;return ME(`actions`).annotate(FE,{errors:`all`}).add(r===void 0?n:n.add(r,...i))},HD=(e,t,n)=>DE(e.name,t,{payload:e.input.pipe(BT()),success:e.success,error:mC(e,n).flatMap(ID)});function UD(e,t={}){yC(`action`,e);let n=pC(t.error);wC(`ActionHttp binding`,n),OC(e,t.authentication);let r=RD(t.prefix),i=t.authentication?.[`~middleware`],a=t.authentication?.error??[],o=e.map(e=>{let t=i===void 0||e.caller===hC,o=HD(e,zD([...r,e.name]),t?n:[...n,...a]).annotate(YE,e.description);return t?o:o.middleware(i)}),s=VD(BD(r),o);return{actions:e,error:n,prefix:zD(r),api:s,authentication:t.authentication}}GE()(`effect-actions/ActionHttp/StepUp`),GE()(`effect-actions/ActionHttp/JsonContentType`);var WD=(e,t)=>Pp(LD(e,t),t=>Object.fromEntries(e.actions.map(e=>[e.name,t(e)])));function GD(e,{fetch:t,...n}={}){return WD(e,n).pipe(Up(Xw),Kp(Jw,t??((e,t)=>globalThis.fetch(e,t))),rm)}var KD=/^[\w.-]+$/,qD=(e,t,...n)=>{let r=n[0]?.security??MD,i=pC(n[0]?.error);if(!KD.test(e))throw Error(`Invalid authentication name: ${JSON.stringify(e)}, not an OpenAPI key`);if(wC(`Authentication "${e}"`,i),!Zn(r,`Http`)&&!Zn(r,`ApiKey`)&&!Zn(r,`Basic`))throw Error(`Authentication takes one native HttpApiSecurity scheme`);return{name:e,identity:t,security:r,error:i,"~provider":A(`effect-actions/Authentication/Provider/${e}`),"~middleware":GE()(`effect-actions/Authentication/Security/${e}`,{security:{[e]:r}}),"~verified":A(`effect-actions/Authentication/Verified/${e}`)}},JD=[class extends lS()(`BadRequest`,{error:K},{httpApiStatus:400}){},class extends lS()(`NotFound`,{error:K},{httpApiStatus:404}){},class extends lS()(`Conflict`,{error:K},{httpApiStatus:409}){},class extends lS()(`TooManyRequests`,{error:K},{httpApiStatus:429}){},class extends lS()(`InternalServerError`,{error:K},{httpApiStatus:500}){cause},class extends lS()(`ServiceUnavailable`,{error:K},{httpApiStatus:503}){}];[...JD];var YD=class extends A()(`clankerauth/CurrentOwner`){},XD=(e=>qD(`clankerauth.OwnerSession`,YD,{security:ND({in:`cookie`,key:e}),error:JD}))(`better-auth.session_token`),ZD=qD(`clankerauth.OwnerToken`,YD,{error:JD}),QD=q({email:K,password:K}),$D=px([`none`,`client_secret_basic`,`client_secret_post`]),eO=px([`web`,`native`]),tO=J(K).check(Fx({message:`Choose unique Resources`})),nO=q({client_name:K,redirect_uris:J(K),resources:tO,token_endpoint_auth_method:$D,application_type:eO}),rO=q({client_id:K,client_name:K,redirect_uris:J(K),application_type:eO}),iO=q({client_id:K}),aO=q({client_id:K,resource:Yb(K)}),oO=q({client_id:K,blocked:rx}),sO=q({onboarding:Yb(px([`managed`,`dcr`,`cimd`])),blocked:Yb(rx),client_id:K,client_name:Yb(K),redirect_uris:J(K),token_endpoint_auth_method:Yb(K),application_type:Yb(mx(K)),scope:Yb(K),grant_types:Yb(J(K))}),cO=sO.pipe(ox({client_secret:Yb(K),client_secret_expires_at:Yb(nx)})),lO=q({identifier:K,name:K,scopes:J(K)}),uO=lO.pipe(ox({builtIn:rx})),dO=q({identifier:K,name:K.check(Cx(/\S/u,{message:`Resources require a name`})),scopes:J(K.check(Cx(/^\s*[\x21\x23-\x5B\x5D-\x7E]+\s*$/u,{message:`Resources require well-formed custom scopes`})))}),fO=q({identifier:K}),pO=q({client_id:K,resource:K}),mO=q({client_id:K,resources:tO}),hO=q({clientAccess:J(pO)}),gO=sx(K,J(K)),_O=sx(K,J(K).check(Ax(1,{message:`Select explicitly granted, currently available Resource scopes`}),Fx({message:`Select explicitly granted, currently available Resource scopes`}))).check(Px(1,{message:`Select at least one Resource and scope`})),vO=K.check(Mx(100,{message:`Key names require 1–100 characters`}),Cx(/\S/u,{message:`Key names require 1–100 characters`})),yO=$x,bO=q({client_id:K,resource:K,scopes:J(K),approvedAt:mx(yO),refreshedAt:mx(yO)}),xO=q({name:vO,permissions:_O,expiresAt:mx(yO)}),SO=q({keyId:K}),CO=q({keyId:K,name:Yb(vO),permissions:Yb(_O),enabled:Yb(rx)}),wO=q({keyId:K,name:K,enabled:rx,permissions:gO,expiresAt:mx(yO),createdAt:yO}),TO={caller:hC,error:JD},EO={caller:YD,error:JD},DO=[X(`setupStatus`,{description:`Check whether the issuer needs its first owner account.`,readOnly:!0,...TO,success:q({required:rx})}),X(`setupOwner`,{description:`Create the first owner account.`,readOnly:!1,...TO,input:QD,success:q({created:rx}).pipe(OT(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,...TO,input:q({resource:K}),success:q({list:K})})],OO=q({clients:J(sO),resources:J(uO),clientAccess:J(pO),connections:J(bO),email:K,issuer:K}),kO=[X(`listClients`,{description:`List clients, resources, managed clients' resource access (what they may obtain), and every client's connections (what it holds).`,readOnly:!0,...EO,success:OO}),X(`createClient`,{description:`Register a first-party OAuth client. Returns its secret once when confidential.`,readOnly:!1,...EO,input:nO,success:cO.pipe(OT(201))}),X(`updateClient`,{description:`Rename a first-party client or change its redirect URIs and application type.`,readOnly:!1,...EO,input:rO,success:sO}),X(`deleteClient`,{description:`Delete a client and its stored authorization. An automatic client can register again; block it to keep it out.`,readOnly:!1,...EO,input:iO,success:q({deleted:rx})}),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,...EO,input:aO,success:q({revoked:rx})}),X(`blockClient`,{description:`Block or unblock OAuth authorization for a client.`,readOnly:!1,...EO,input:oO,success:q({blocked:rx})}),X(`rotateClientSecret`,{description:`Rotate a confidential client secret. Returns the new secret once.`,readOnly:!1,...EO,input:iO,success:cO}),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,...EO,input:mO,success:hO}),X(`createResource`,{description:`Create an OAuth resource and its scopes.`,readOnly:!1,...EO,input:dO,success:lO.pipe(OT(201))}),X(`updateResource`,{description:`Update an OAuth resource and its scopes.`,readOnly:!1,...EO,input:dO,success:lO}),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,...EO,input:fO,success:q({deleted:rx})}),X(`listApiKeys`,{description:`List API key metadata without secret values.`,readOnly:!0,...EO,success:q({keys:J(wO)})}),X(`createApiKey`,{description:`Create a scoped API key. Returns its secret once.`,readOnly:!1,...EO,input:xO,success:wO.pipe(ox({key:K}),OT(201))}),X(`updateApiKey`,{description:`Update an API key’s name, permissions or enabled state.`,readOnly:!1,...EO,input:CO,success:wO}),X(`deleteApiKey`,{description:`Delete an API key.`,readOnly:!1,...EO,input:SO,success:q({deleted:rx})})],AO=(e=>UD([...kO,...DO],{authentication:e}))(XD);UD(kO,{prefix:`/api/owner`,authentication:ZD});var Z=GD(AO),jO=Hb(fx(JD)),MO=Hb(fC),NO=e=>jO(e)?Error(e.error):e instanceof sC&&e.issues.length?Error([...new Set(e.issues.map(e=>e.message))].join(` `)):MO(e)?Error(e.message):Error(`Request could not be completed. Please try again.`);async function Q(e){try{return await nm(e)}catch(e){throw NO(e)}}var PO=gn({plugins:[Tn()]}),FO=document.querySelector(`#app`);FO.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 IO=document.querySelector(`#main`),$=e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]);function LO(e){let t=document.querySelector(`#message`);t.textContent=e,e&&t.hasAttribute(`tabindex`)&&(t.focus(),t.scrollIntoView({behavior:`smooth`,block:`center`}))}var RO=!1;async function zO(e){if(RO)return;RO=!0;let t=Array.from(IO.querySelectorAll(`button`),e=>({button:e,disabled:e.disabled}));t.forEach(({button:e})=>e.disabled=!0),LO(``);try{await e()}catch(e){LO(e instanceof Error?e.message:`Request failed`)}finally{t.forEach(({button:e,disabled:t})=>e.disabled=t),RO=!1}}function BO(e,t){!RO&&confirm(e)&&zO(t)}function VO(){IO.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(),zO(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(Fp(`/`),Lp(`Conflict`,()=>L(`/login`))));location.replace(r)})})}function HO(){IO.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(),zO(async()=>{if((await PO.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 UO(){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 PO.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`);IO.className=`center`,IO.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);zO(async()=>{if(n&&r.length&&!i.length)throw Error(`Tick at least one permission, or deny the request.`);if((await PO.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 WO(e,t){let n=e.get(t);if(n===null||n instanceof File)throw Error(`Missing form field: ${t}`);return n.trim()}function GO(e){return Array.from(e.querySelectorAll(`input[name="resources"]:checked`),e=>e.value)}function KO(e){let t=[...new Set(WO(e,`scopes`).split(/\s+/).filter(Boolean))];return{name:WO(e,`name`),scopes:t}}function qO(e){let t=[...new Set(WO(e,`redirect_uris`).split(/\s+/).filter(Boolean))];if(!t.length)throw Error(`Add at least one redirect URI.`);return t}var JO={none:`Public client (PKCE only)`,client_secret_basic:`Confidential client · HTTP Basic secret`,client_secret_post:`Confidential client · secret in request body`},YO=e=>Gb($D)(WO(e,`token_endpoint_auth_method`)),XO=e=>Gb(eO)(e.has(`native`)?`native`:`web`);function ZO(e){let t={};for(let n of e.querySelectorAll(`input[name="key-scope"]:checked`))(t[n.dataset.resource]??=[]).push(n.value);return t}var QO=new Map,$O=new Map;function ek(){let e=document.querySelector(`#credentials`);if(e.classList.toggle(`hidden`,$O.size===0&&QO.size===0),e.replaceChildren(),!$O.size&&!QO.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 $O.values()){let n=document.createElement(`pre`);n.textContent=JSON.stringify(e,null,2),t.before(n)}for(let e of QO.values()){let n=document.createElement(`pre`);n.textContent=e,t.before(n)}t.addEventListener(`click`,()=>{QO.clear(),$O.clear(),ek()})}function tk(){ek(),document.querySelector(`#credentials`).scrollIntoView({behavior:`smooth`})}async function nk(){try{await yk()}catch{document.querySelector(`#dashboard-mutations`).disabled=!0,LO(`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`,()=>{zO(nk)}),document.querySelector(`#message`).append(` `,e)}}var rk=`Optional. Separate scopes with spaces. offline_access is reserved.`,ik={managed:`Managed registration · first party, no consent screen`,dcr:`Dynamic registration`,cimd:`Client ID Metadata Document`},ak=e=>!e.onboarding||e.onboarding===`managed`,ok=(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>`,sk=(e,t)=>`<div class="empty"><h3>${e}</h3><p>${t}</p></div>`,ck=e=>`<code>${$(e.identifier)}</code><span class="muted">${$(e.scopes.join(` · `))}</span>`,lk=(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)}${ck(e)}</span></label>`).join(``),uk=(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>`,dk=(e,t)=>`<article class="resource"><h3>${$(e.name)}</h3>${ck(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>`,fk=()=>`<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/"></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">${rk}</p><button>Add resource +</button></form>`,pk=(e,t)=>`<article class="resource"><h3>${$(e.name)}</h3><p>${e.enabled?`Enabled`:`Disabled`} · ${e.expiresAt?`Expires ${$(Vm(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)}">${uk(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>`,mk=e=>`<h2>Create API key</h2><form id="key-create"><label>Name<input name="name" required maxlength="100" placeholder="Backup script"></label>${uk(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>`,hk=e=>$(Vm(e,{dateStyle:`medium`,timeStyle:`short`})),gk=(e,t)=>{let n=t.find(t=>t.identifier===e.resource),r=[e.approvedAt?`Approved ${hk(e.approvedAt)}`:`First party, no consent`,e.refreshedAt?`last token ${hk(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>`},_k=(e,t,n,r)=>{let i=ak(e),a=$(e.client_id),o=r.map(e=>gk(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>${lk(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">${ik[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>`},vk=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>${lk(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(JO).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 yk(){let[e,t]=await Q(vp([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);IO.className=`dashboard`,IO.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
|
+
${ok(`Resources`,n.length,`Protected APIs and MCP servers, and the scopes they define.`,n.map(t=>dk(t,e.clients.filter(e=>a(e.client_id).some(e=>e.resource===t.identifier)))).join(``)||sk(`Add your first Resource`,`Define a protected API or MCP server. Compatible MCP clients onboard automatically when you connect.`),fk())}
|
|
47
|
+
${ok(`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=>pk(e,r)).join(``)||sk(`No API keys`,`Create a key for a CLI or automation that needs direct access.`),mk(r))}
|
|
48
|
+
${ok(`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=>_k(e,n,i(e.client_id),a(e.client_id))).join(``)||sk(`No Clients registered`,`Connect your MCP client to a configured server to onboard automatically, or register a managed Client here.`),vk(n))}
|
|
49
|
+
</fieldset>`,ek();let o=e=>document.querySelector(e),s=(e,t)=>e.addEventListener(`submit`,n=>{n.preventDefault(),zO(()=>t(e))}),c=(e,t)=>{for(let n of IO.querySelectorAll(e))n.addEventListener(`click`,()=>t(n))};document.querySelector(`#logout`).addEventListener(`click`,()=>{zO(async()=>{await PO.signOut(),location.assign(`/login`)})}),s(o(`#register`),async e=>{let t=new FormData(e),n=await Q(Z.createClient({client_name:WO(t,`name`),redirect_uris:qO(t),resources:GO(e),application_type:XO(t),token_endpoint_auth_method:YO(t)}));e.reset(),$O.set(n.client_id,n),tk(),await nk()}),s(o(`#key-create`),async e=>{let t=new FormData(e),n=WO(t,`expiry`),r=await Q(Z.createApiKey({name:WO(t,`name`),permissions:ZO(e),expiresAt:n?Lm(new Date(n)):null}));QO.set(r.keyId,`${r.name}\n${r.key}`),e.reset(),tk(),await nk()}),s(o(`#resource-create`),async e=>{let t=new FormData(e);await Q(Z.createResource({identifier:WO(t,`identifier`),...KO(t)})),e.reset(),await nk()});for(let e of IO.querySelectorAll(`[data-key-rename]`))s(e,async e=>{await Q(Z.updateApiKey({keyId:e.dataset.keyRename,name:WO(new FormData(e),`name`)})),await nk()});for(let e of IO.querySelectorAll(`[data-key-grants]`))s(e,async e=>{await Q(Z.updateApiKey({keyId:e.dataset.keyGrants,permissions:ZO(e)})),await nk()});for(let e of IO.querySelectorAll(`[data-resource-edit]`))s(e,async e=>{await Q(Z.updateResource({identifier:e.dataset.resourceEdit,...KO(new FormData(e))})),await nk()});for(let e of IO.querySelectorAll(`[data-client-edit]`))s(e,async e=>{let t=new FormData(e);await Q(Z.updateClient({client_id:e.dataset.clientEdit,client_name:WO(t,`name`),redirect_uris:qO(t),application_type:XO(t)})),await nk()});for(let e of IO.querySelectorAll(`[data-client-access]`))e.addEventListener(`submit`,t=>{t.preventDefault();let n=e.dataset.clientAccess,r=GO(e),a=i(n).filter(e=>!r.includes(e)),o=async()=>{await Q(Z.setClientAccess({client_id:n,resources:r})),await nk()};a.length?BO(`Remove access to ${a.join(`, `)}? This revokes the Client\u2019s authorization for ${a.length===1?`it`:`them`}.`,o):zO(o)});c(`[data-key-toggle]`,e=>{zO(async()=>{await Q(Z.updateApiKey({keyId:e.dataset.keyToggle,enabled:e.dataset.enabled!==`true`})),await nk()})}),c(`[data-key-delete]`,e=>{let t=e.dataset.keyDelete;BO(`Delete this API key?`,async()=>{await Q(Z.deleteApiKey({keyId:t})),QO.delete(t),ek(),await nk()})}),c(`[data-revoke]`,e=>{let t=e.dataset.revoke;BO(`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 nk()})}),c(`[data-disconnect]`,e=>{let t=e.dataset.disconnect,n=e.dataset.resource;BO(`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 nk()})}),c(`[data-block]`,e=>{let t=e.dataset.block,n=e.dataset.blocked!==`true`;BO(n?`Block this Client and revoke its authorization?`:`Unblock this Client?`,async()=>{await Q(Z.blockClient({client_id:t,blocked:n})),await nk()})}),c(`[data-rotate]`,e=>{let t=e.dataset.rotate;BO(`Rotate the secret? The old one stops working immediately.`,async()=>{let e=await Q(Z.rotateClientSecret({client_id:t}));$O.set(e.client_id,e),tk()})}),c(`[data-delete]`,e=>{let t=e.dataset.delete;BO(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})),$O.delete(t),ek(),await nk()})}),c(`[data-resource-delete]`,e=>{let t=e.dataset.resourceDelete;BO(`Delete Resource ${t}? Every Client\u2019s authorization for it is revoked; API-key grants are kept.`,async()=>{await Q(Z.deleteResource({identifier:t})),await nk()})})}try{if((await Q(Z.setupStatus())).required)location.pathname===`/setup`?VO():location.replace(`/setup`);else if(location.pathname===`/setup`){let e=await PO.getSession();location.replace(e.data?`/`:`/login`)}else location.pathname===`/consent`?await UO():!(await PO.getSession()).data||location.pathname===`/login`?HO():await yk()}catch(e){IO.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>`}
|