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